golden hour
/tmp
⬆️ Go Up
Upload
File/Folder
Size
Actions
.s.PGSQL.5432
-
Del
OK
.wp_cron_private
111 B
Del
OK
error_log.txt
504 B
Del
OK
mysql.sock
-
Del
OK
php01mUcb
40 KB
Del
OK
php01tguP
8.5 KB
Del
OK
php09F8va
0 B
Del
OK
php09vT8o
40 KB
Del
OK
php0AtsaS
27.25 KB
Del
OK
php0CAHMv
40 KB
Del
OK
php0CiQjF
10.93 KB
Del
OK
php0EqtcF
281 B
Del
OK
php0JoXKr
32.5 KB
Del
OK
php0L6Yjx
1.5 KB
Del
OK
php0Ltb7h
216 KB
Del
OK
php0NMAye
80 KB
Del
OK
php0SZIUv
512 B
Del
OK
php0bx1RN
0 B
Del
OK
php0iUCyv
40 KB
Del
OK
php0k9T19
0 B
Del
OK
php0kdOR6
40 KB
Del
OK
php0n7cYe
40 KB
Del
OK
php0pN8J9
24.5 KB
Del
OK
php0rVDsi
80 KB
Del
OK
php0yMZ80
937 B
Del
OK
php0yT8gX
8.5 KB
Del
OK
php1EcjtX
33.8 KB
Del
OK
php1EdFo1
10.02 KB
Del
OK
php1GJqBj
40 KB
Del
OK
php1LMnzi
5.5 KB
Del
OK
php1OU7Wa
0 B
Del
OK
php1PTBRu
25.19 KB
Del
OK
php1UKXp7
46.22 KB
Del
OK
php1UOKqT
40 KB
Del
OK
php1UicbS
23.23 KB
Del
OK
php1VwCzk
3.38 KB
Del
OK
php1e1a7w
1.05 MB
Del
OK
php1fxBfr
512 B
Del
OK
php1iXX1M
40 KB
Del
OK
php1k9TgO
40 KB
Del
OK
php1s2OVF
3.94 KB
Del
OK
php1xqKaI
96 KB
Del
OK
php28At3t
16 KB
Del
OK
php29MzXR
3.98 KB
Del
OK
php2CaVG0
19.32 KB
Del
OK
php2Ez5E8
40 KB
Del
OK
php2OIZAJ
16 KB
Del
OK
php2Q527a
6.53 MB
Del
OK
php2S2baW
40 KB
Del
OK
php2TcimF
15.66 KB
Del
OK
php2XNrfC
4.99 KB
Del
OK
php2cOauz
24 KB
Del
OK
php2dQNRA
1.21 KB
Del
OK
php2eqZ0O
715.59 KB
Del
OK
php2gQIc6
8.24 KB
Del
OK
php2inYsi
40 KB
Del
OK
php2jjWxB
147.04 KB
Del
OK
php2lFD4k
2 KB
Del
OK
php2rCrQx
249.88 KB
Del
OK
php2wj4x2
35.27 KB
Del
OK
php2xi2b0
1.5 KB
Del
OK
php2zqVTM
8.5 KB
Del
OK
php32FDTG
16.5 KB
Del
OK
php37voyY
15.59 KB
Del
OK
php3D0n82
67.95 KB
Del
OK
php3M1O9x
43.19 MB
Del
OK
php3ON19I
0 B
Del
OK
php3P2kvK
11.5 KB
Del
OK
php3QU2do
0 B
Del
OK
php3TN5za
0 B
Del
OK
php3UEFTY
1.5 KB
Del
OK
php3dIAUq
31.81 KB
Del
OK
php3fe19A
512 B
Del
OK
php3gltxA
60.17 KB
Del
OK
php3ntMT9
39.45 KB
Del
OK
php3olRtr
1.5 KB
Del
OK
php3pOjZl
384.5 KB
Del
OK
php3rK5zV
32.5 KB
Del
OK
php3tprIC
550 B
Del
OK
php3xLip3
27.67 KB
Del
OK
php3zsXea
80 KB
Del
OK
php440adM
263.4 KB
Del
OK
php445aUf
9.89 KB
Del
OK
php45cCq0
32 KB
Del
OK
php4FVXp1
11.55 KB
Del
OK
php4Lv7Ai
0 B
Del
OK
php4MCktH
16 KB
Del
OK
php4OlHNM
0 B
Del
OK
php4TKIy9
4 KB
Del
OK
php4UBY3r
405 B
Del
OK
php4X6RpD
24.5 KB
Del
OK
php4YGCsf
32 KB
Del
OK
php4a9qMI
0 B
Del
OK
php4dGaa9
40 KB
Del
OK
php4dXw4u
80 KB
Del
OK
php4ez48G
40 KB
Del
OK
php4h2PFX
40 KB
Del
OK
php4icfa3
40 KB
Del
OK
php4mSNRQ
0 B
Del
OK
php4oUm5H
1.01 KB
Del
OK
php5DLWJi
512 B
Del
OK
php5FaKuU
39.54 KB
Del
OK
php5KQZ86
33.54 KB
Del
OK
php5Pm4BY
1.73 KB
Del
OK
php5V1Sqo
40 KB
Del
OK
php5V4oH9
83 B
Del
OK
php5fde6q
8.5 KB
Del
OK
php5gKjFI
4.22 MB
Del
OK
php5jyjgk
68 B
Del
OK
php5lKVj0
32 KB
Del
OK
php5r4Y7O
10.53 MB
Del
OK
php5tm8Rp
1.94 KB
Del
OK
php5vJXmQ
80 KB
Del
OK
php5yYpKf
8.58 KB
Del
OK
php68JiUr
0 B
Del
OK
php6CAWrS
53.56 MB
Del
OK
php6Im3r4
40 KB
Del
OK
php6JCsp9
32 KB
Del
OK
php6MWySe
40 KB
Del
OK
php6NE2eL
1.07 MB
Del
OK
php6QEPJr
41.78 MB
Del
OK
php6Qd5EW
8 KB
Del
OK
php6UZIvM
0 B
Del
OK
php6azyWE
23.83 KB
Del
OK
php6h4ySy
40 KB
Del
OK
php6iexHc
40 KB
Del
OK
php6pnCiz
110.07 KB
Del
OK
php6zIZFE
8 B
Del
OK
php77wybR
40 KB
Del
OK
php7CN70m
0 B
Del
OK
php7I1QXa
5.18 MB
Del
OK
php7J1Atw
234.4 KB
Del
OK
php7U4leS
55.32 MB
Del
OK
php7UQrRj
2 KB
Del
OK
php7WGDuk
91.96 KB
Del
OK
php7XE0an
512 B
Del
OK
php7Yz1Rp
2.5 KB
Del
OK
php7br3tc
81.21 KB
Del
OK
php7e7Qdz
40 KB
Del
OK
php7grjXm
27.3 KB
Del
OK
php7h1JM4
16.32 KB
Del
OK
php7hiFHT
23.55 KB
Del
OK
php7mcTCL
1.29 MB
Del
OK
php7rUahT
8 KB
Del
OK
php7siU9s
1.5 KB
Del
OK
php7wbrip
40 KB
Del
OK
php7xs4PV
9.77 KB
Del
OK
php86YnmU
16.37 KB
Del
OK
php86yPmE
8.08 KB
Del
OK
php87oTpS
28.49 KB
Del
OK
php8B4VlV
10.57 KB
Del
OK
php8Bg4Er
1.5 KB
Del
OK
php8GLz76
32 KB
Del
OK
php8Iz687
1013 B
Del
OK
php8TnD14
34.53 KB
Del
OK
php8XkkOb
40 KB
Del
OK
php8dpS39
32 KB
Del
OK
php8k5SY5
16 KB
Del
OK
php8kaGbK
40 KB
Del
OK
php8kpDuP
18.15 MB
Del
OK
php8wi06h
1.67 KB
Del
OK
php93xki0
26.23 KB
Del
OK
php99dbtt
39.42 KB
Del
OK
php9AUMAS
7.5 KB
Del
OK
php9CI6Vp
32 KB
Del
OK
php9Ihzha
12.5 KB
Del
OK
php9Iutz4
11.82 KB
Del
OK
php9J7msk
78 B
Del
OK
php9MGgnV
512 B
Del
OK
php9Nt6zt
35.52 KB
Del
OK
php9Q1sbk
57.74 MB
Del
OK
php9RXD7v
1.5 KB
Del
OK
php9YP9iW
30.8 KB
Del
OK
php9boBk3
79.29 MB
Del
OK
php9jvV3c
0 B
Del
OK
php9qCwBF
40 KB
Del
OK
php9qqqw0
42.62 KB
Del
OK
php9rp8br
32.72 KB
Del
OK
php9xy7tX
40 KB
Del
OK
phpA1LgKO
72 KB
Del
OK
phpA26A7k
8.5 KB
Del
OK
phpA9RRRV
512 B
Del
OK
phpABmhXR
11.51 KB
Del
OK
phpADYWCn
410 KB
Del
OK
phpAEiDiG
24.61 KB
Del
OK
phpAG7dHD
40 KB
Del
OK
phpAH0EnE
1.39 MB
Del
OK
phpAJwgvE
0 B
Del
OK
phpAOOMwi
2 KB
Del
OK
phpAP9lfl
40 KB
Del
OK
phpAaQAcM
72.05 KB
Del
OK
phpAfyDDb
40 KB
Del
OK
phpAiz6zw
512 B
Del
OK
phpAjRgLq
399 B
Del
OK
phpAzBMMM
35.38 KB
Del
OK
phpB2pERU
516 KB
Del
OK
phpB69IUu
32 KB
Del
OK
phpB6Q4EI
31.48 KB
Del
OK
phpBFxDtI
28.04 KB
Del
OK
phpBG4GP2
4.75 KB
Del
OK
phpBMomvl
15.82 KB
Del
OK
phpBR69HE
32 KB
Del
OK
phpBX8XAw
1.42 KB
Del
OK
phpBl0lUb
8.58 KB
Del
OK
phpBmh3Am
40 KB
Del
OK
phpBqTHDS
88.36 KB
Del
OK
phpC186oj
118 B
Del
OK
phpC6yCwB
17.19 KB
Del
OK
phpC8f5DM
4.67 KB
Del
OK
phpC9Ln41
160 KB
Del
OK
phpCIZwEh
13.91 KB
Del
OK
phpCLgq2B
178.49 KB
Del
OK
phpCMOzKd
601 B
Del
OK
phpCa5SPg
23.79 KB
Del
OK
phpCaZD1D
79.37 MB
Del
OK
phpCfpkv6
184 KB
Del
OK
phpChE8Wc
40 KB
Del
OK
phpCsNp9n
76.95 KB
Del
OK
phpCt58ws
8.5 KB
Del
OK
phpCto6S7
0 B
Del
OK
phpD7nFJN
40 KB
Del
OK
phpDFKBdu
0 B
Del
OK
phpDI8V3J
32 KB
Del
OK
phpDKhp9b
2.72 MB
Del
OK
phpDRQ9DM
5.12 MB
Del
OK
phpDVvD2X
32 KB
Del
OK
phpDlCYxC
195.86 KB
Del
OK
phpDojSMG
14.83 KB
Del
OK
phpDqnLKC
512 B
Del
OK
phpDrUtUX
151 KB
Del
OK
phpDyvWaQ
810 B
Del
OK
phpE1CLxk
24.08 KB
Del
OK
phpE85YQK
2.85 KB
Del
OK
phpECFWdn
40 KB
Del
OK
phpEF1nZd
40 KB
Del
OK
phpEHkFf0
1.56 KB
Del
OK
phpEIz6kY
4.9 KB
Del
OK
phpELlCkq
512 B
Del
OK
phpENBKKD
3.25 MB
Del
OK
phpEOZjEK
32 KB
Del
OK
phpEVPKWM
60.44 KB
Del
OK
phpEYy2WG
0 B
Del
OK
phpEbmrQr
8 KB
Del
OK
phpEhQ9AL
46 B
Del
OK
phpEoVbYr
40 KB
Del
OK
phpEpiP8R
0 B
Del
OK
phpEt6xl2
80 KB
Del
OK
phpEvFWWO
2.64 MB
Del
OK
phpEx5vdu
220 B
Del
OK
phpF1db4V
40 KB
Del
OK
phpF27R7c
102.01 MB
Del
OK
phpF2UCNR
2.5 KB
Del
OK
phpF4Acbd
2.5 KB
Del
OK
phpFDw8BK
46 B
Del
OK
phpFGyMvE
40 KB
Del
OK
phpFJj1Z6
1.87 MB
Del
OK
phpFPeK3A
25 KB
Del
OK
phpFUcPq9
1.31 MB
Del
OK
phpFbtsXw
0 B
Del
OK
phpFgy8Js
46 B
Del
OK
phpFjAsfz
1.5 KB
Del
OK
phpFkrmBz
78 B
Del
OK
phpFlgtL2
7.5 KB
Del
OK
phpFnjbmB
1.5 KB
Del
OK
phpG0pzF5
80 KB
Del
OK
phpG1rrPi
40 KB
Del
OK
phpG2E8tu
456.9 KB
Del
OK
phpG5SMWX
32 KB
Del
OK
phpG7MNVO
64.5 KB
Del
OK
phpGBYCWo
40 KB
Del
OK
phpGBt0R2
47.83 KB
Del
OK
phpGLA0Uh
20.68 KB
Del
OK
phpGMxv12
29.13 KB
Del
OK
phpGWoY85
416 KB
Del
OK
phpGZOiEG
32 KB
Del
OK
phpGe7TCG
40 KB
Del
OK
phpGhLaQ7
0 B
Del
OK
phpGiMBYZ
24 KB
Del
OK
phpGjzD7b
40 KB
Del
OK
phpGtENsj
0 B
Del
OK
phpGuLBMC
8 KB
Del
OK
phpH7O00N
32.5 KB
Del
OK
phpH808SC
40 KB
Del
OK
phpHAi6L2
79.35 MB
Del
OK
phpHBDBay
40 KB
Del
OK
phpHCqDBg
40 KB
Del
OK
phpHMeRe8
0 B
Del
OK
phpHUUrMT
2 KB
Del
OK
phpHggk41
0 B
Del
OK
phpHiczhe
392 KB
Del
OK
phpHnFFCl
6.32 KB
Del
OK
phpHyQMqj
3.79 KB
Del
OK
phpHzp4Jd
11.08 KB
Del
OK
phpI9Vgpt
15.87 KB
Del
OK
phpI9vy8I
151.38 KB
Del
OK
phpIBPQcM
20.04 KB
Del
OK
phpID77wU
32 KB
Del
OK
phpIEMNjF
17.56 KB
Del
OK
phpIIdfts
24.5 KB
Del
OK
phpIJndBV
13 KB
Del
OK
phpIK0bxI
23.09 KB
Del
OK
phpIMCR9F
29 KB
Del
OK
phpIMiWS7
1.5 KB
Del
OK
phpIQ2PCj
6 KB
Del
OK
phpIYJfHn
10.79 KB
Del
OK
phpIZtbLn
0 B
Del
OK
phpIbtQ60
11.5 KB
Del
OK
phpIidNsc
0 B
Del
OK
phpIjl1uC
0 B
Del
OK
phpIlGZVA
23.63 MB
Del
OK
phpIpvF03
0 B
Del
OK
phpIrtyps
860.95 KB
Del
OK
phpIvmCNS
22.7 KB
Del
OK
phpJ44BNU
14.41 KB
Del
OK
phpJ4rm1H
4.5 KB
Del
OK
phpJ5MxmL
164.98 KB
Del
OK
phpJCzlen
40 KB
Del
OK
phpJDGMzX
46.63 KB
Del
OK
phpJHWX0N
0 B
Del
OK
phpJIp4VW
0 B
Del
OK
phpJNFYHR
8 KB
Del
OK
phpJQUNz0
7.5 KB
Del
OK
phpJTiGy0
35.27 KB
Del
OK
phpJY9Eww
354.33 KB
Del
OK
phpJdD5Wa
16.05 KB
Del
OK
phpJesLeK
27.85 MB
Del
OK
phpJidmJ7
8 KB
Del
OK
phpJm0QXa
512 B
Del
OK
phpJq1PDF
23.01 KB
Del
OK
phpJyb8in
63.08 MB
Del
OK
phpKNXngO
35.41 KB
Del
OK
phpKOcA8K
40 KB
Del
OK
phpKQjzmP
40 KB
Del
OK
phpKRQ72Y
53.56 MB
Del
OK
phpKSh7Wl
6.5 KB
Del
OK
phpKTfsHK
17.65 MB
Del
OK
phpKUQ5m4
2.51 MB
Del
OK
phpKckQ0Q
3.5 KB
Del
OK
phpKhmkB0
79.44 MB
Del
OK
phpKzTb28
80 KB
Del
OK
phpL0medW
40 KB
Del
OK
phpLAdePz
1.35 MB
Del
OK
phpLEHLuv
512 B
Del
OK
phpLIQ7pY
8.5 KB
Del
OK
phpLOEQEU
33 B
Del
OK
phpLS94cB
32 KB
Del
OK
phpLUa2Z0
40 KB
Del
OK
phpLXq4WM
512 B
Del
OK
phpLo0sxn
35.39 KB
Del
OK
phpLqH87l
1.5 KB
Del
OK
phpLsCHuH
16 KB
Del
OK
phpLu1mBs
472 KB
Del
OK
phpLzRO82
3 KB
Del
OK
phpMAPPyA
512 B
Del
OK
phpMIdygD
40 KB
Del
OK
phpMM9u4f
72.97 KB
Del
OK
phpMNbay9
56.5 KB
Del
OK
phpMO0Y2e
32 KB
Del
OK
phpMSCsq2
8.5 KB
Del
OK
phpMUs66Z
512 B
Del
OK
phpMXQo3Q
1.5 KB
Del
OK
phpMYWlzf
512 B
Del
OK
phpMbCf3a
0 B
Del
OK
phpMedvLo
55.45 MB
Del
OK
phpN3xc6o
1.66 KB
Del
OK
phpN8lxu6
40 KB
Del
OK
phpNAg5Cc
25.76 KB
Del
OK
phpNFqaBT
0 B
Del
OK
phpNRjOLd
791.67 KB
Del
OK
phpNYyRsW
0 B
Del
OK
phpNdZcU6
40 KB
Del
OK
phpNgJx7w
40 KB
Del
OK
phpNje2eZ
32.05 KB
Del
OK
phpNjgLvm
1.5 KB
Del
OK
phpNpcqsI
14.5 KB
Del
OK
phpNvwCTh
0 B
Del
OK
phpNykVBj
512 B
Del
OK
phpNyoHY4
32.02 KB
Del
OK
phpO1mxEC
3.94 KB
Del
OK
phpO8gbMR
57.74 MB
Del
OK
phpOBnTO4
79.38 MB
Del
OK
phpOCRRXV
0 B
Del
OK
phpOCvs70
16 KB
Del
OK
phpOMiF5S
40 KB
Del
OK
phpOMoPtu
6.29 KB
Del
OK
phpONT9UL
19.16 KB
Del
OK
phpOOvmWo
181 B
Del
OK
phpOSjz0x
0 B
Del
OK
phpOU8tJD
0 B
Del
OK
phpOYgGKi
1.5 KB
Del
OK
phpOavCwM
88 KB
Del
OK
phpOcAuaK
31.4 KB
Del
OK
phpOu3TUR
62 B
Del
OK
phpP4iJFE
32 KB
Del
OK
phpP74C3a
18 B
Del
OK
phpP9rT5q
40 KB
Del
OK
phpPBqRGr
0 B
Del
OK
phpPFNbqU
40 KB
Del
OK
phpPFzKL4
19.34 KB
Del
OK
phpPJQ7BY
1.88 KB
Del
OK
phpPROmTq
1.76 KB
Del
OK
phpPVkJqO
0 B
Del
OK
phpPWQGIS
31.31 KB
Del
OK
phpPX9ony
40 KB
Del
OK
phpPc5KZ4
731.95 KB
Del
OK
phpPcFz3V
40 KB
Del
OK
phpPkCo8y
80 KB
Del
OK
phpPqIzil
32.72 KB
Del
OK
phpPrMVYK
39.64 KB
Del
OK
phpPreqC5
15.11 KB
Del
OK
phpPzOUDe
72.6 KB
Del
OK
phpQ6rrmq
1.5 KB
Del
OK
phpQDwlth
299 KB
Del
OK
phpQFxsPq
40 KB
Del
OK
phpQHWsKh
30 B
Del
OK
phpQPvRj3
512 B
Del
OK
phpQSkEHm
8 KB
Del
OK
phpQWe5Ya
5 KB
Del
OK
phpQd2Jhh
34.44 KB
Del
OK
phpQhJ510
200.5 KB
Del
OK
phpQhoYIZ
18.39 KB
Del
OK
phpQkefGr
40 KB
Del
OK
phpQlBcyZ
80 KB
Del
OK
phpQsXTfJ
40 KB
Del
OK
phpQtQ4Tu
15.25 MB
Del
OK
phpRC716h
16 KB
Del
OK
phpRIWqF2
40 KB
Del
OK
phpRLp9Hw
512 B
Del
OK
phpRX5HyJ
40 KB
Del
OK
phpRY6kxE
40 KB
Del
OK
phpRmG8Mp
457 B
Del
OK
phpRmRFOt
40 KB
Del
OK
phpRnnnh2
0 B
Del
OK
phpRqd13P
2.5 KB
Del
OK
phpRuVWSs
8 KB
Del
OK
phpRx3yOp
8 KB
Del
OK
phpRzmyJo
16 KB
Del
OK
phpSFB9iK
1.5 KB
Del
OK
phpSHNTYt
512 B
Del
OK
phpSL5J24
16.5 MB
Del
OK
phpSNAxJm
512 B
Del
OK
phpSV3958
77.52 MB
Del
OK
phpSWorIb
15.6 KB
Del
OK
phpSgFaor
40 KB
Del
OK
phpSjEzWN
40 KB
Del
OK
phpSl3v8s
0 B
Del
OK
phpSlgcp1
52 B
Del
OK
phpSmFUiV
40 KB
Del
OK
phpSySmLg
10.7 KB
Del
OK
phpT677nX
3.88 KB
Del
OK
phpTHDzBe
15.15 KB
Del
OK
phpTKGUnd
25.02 KB
Del
OK
phpTKND41
80 KB
Del
OK
phpTQrfsd
2 KB
Del
OK
phpTWd9oN
40 B
Del
OK
phpTagKwn
0 B
Del
OK
phpTlzK2m
65.68 KB
Del
OK
phpTnff7L
24.5 KB
Del
OK
phpToBTsi
57 B
Del
OK
phpToyPsW
512 B
Del
OK
phpTtaYa2
11.05 KB
Del
OK
phpU3uTFz
40 KB
Del
OK
phpU7uz55
15.65 KB
Del
OK
phpUIH7ix
0 B
Del
OK
phpUZ9X9f
639 KB
Del
OK
phpUaLNwx
40.11 KB
Del
OK
phpUbGApk
7.64 MB
Del
OK
phpUcd5Z9
999 B
Del
OK
phpUlmBSh
21.52 KB
Del
OK
phpUmI62w
0 B
Del
OK
phpUosLhV
40 KB
Del
OK
phpUpQY4f
0 B
Del
OK
phpUqH1om
128.5 KB
Del
OK
phpUrjHRo
27.75 KB
Del
OK
phpUwrqDO
0 B
Del
OK
phpVC6tdG
13.91 KB
Del
OK
phpVEenuw
33 B
Del
OK
phpVHnw3N
512 B
Del
OK
phpVRqvNP
11.12 MB
Del
OK
phpVVM36k
0 B
Del
OK
phpVWnn7O
15.69 KB
Del
OK
phpVZmSeK
8 KB
Del
OK
phpVhSI7T
46.39 MB
Del
OK
phpVlbocq
715.59 KB
Del
OK
phpVvtJcJ
0 B
Del
OK
phpVw457K
78.06 MB
Del
OK
phpVwbhnM
9.41 MB
Del
OK
phpVwyO1a
15.1 KB
Del
OK
phpVzPSj1
3.03 MB
Del
OK
phpW4hsSR
8.5 KB
Del
OK
phpW5J6zY
74.06 KB
Del
OK
phpW6TzcG
512 B
Del
OK
phpW7GQhR
67 B
Del
OK
phpW80yCr
40 KB
Del
OK
phpW8KwmC
0 B
Del
OK
phpW8nQzI
30.71 MB
Del
OK
phpWB9Vc4
941.23 KB
Del
OK
phpWBTw9T
3.29 KB
Del
OK
phpWCE1Th
79.3 MB
Del
OK
phpWEvKuZ
512 B
Del
OK
phpWTA2ar
35.4 KB
Del
OK
phpWTBjRR
32.5 KB
Del
OK
phpWUxphd
6.86 KB
Del
OK
phpWX3mlM
23.14 KB
Del
OK
phpWYTIsL
119 B
Del
OK
phpWZEs5j
0 B
Del
OK
phpWiNDHg
0 B
Del
OK
phpWlbinZ
40 KB
Del
OK
phpWyF18J
68.28 MB
Del
OK
phpX9NfYV
27.28 KB
Del
OK
phpXWrRLe
40 KB
Del
OK
phpXaI2yt
21 B
Del
OK
phpXbW5eW
192 KB
Del
OK
phpXeEKhc
8.5 KB
Del
OK
phpXkNHHE
8.5 KB
Del
OK
phpXm3YDI
80 KB
Del
OK
phpXmFMt6
1.42 KB
Del
OK
phpXrKKqo
0 B
Del
OK
phpXrrc3r
40 KB
Del
OK
phpXsx1rg
40 KB
Del
OK
phpY4xYwf
3.64 MB
Del
OK
phpY5VqsO
19.74 KB
Del
OK
phpY5f6HV
53.9 MB
Del
OK
phpY8SyxK
32 KB
Del
OK
phpYBn5sb
16 KB
Del
OK
phpYHLLMf
538 B
Del
OK
phpYJU5Jw
399 B
Del
OK
phpYKU3Fs
26.43 KB
Del
OK
phpYP4gnz
512 B
Del
OK
phpYUzBlp
7 KB
Del
OK
phpYZ1XX0
91.88 KB
Del
OK
phpYaEzve
4.5 KB
Del
OK
phpYaotvU
0 B
Del
OK
phpYbqEHR
40 KB
Del
OK
phpYgpaav
80 KB
Del
OK
phpYk6ooC
16.5 KB
Del
OK
phpYonSjm
24 KB
Del
OK
phpZ645wl
13.16 KB
Del
OK
phpZ723P0
40 KB
Del
OK
phpZCjTJe
26 B
Del
OK
phpZFHdpP
13.66 KB
Del
OK
phpZLCmXV
200 B
Del
OK
phpZQVhL6
538 B
Del
OK
phpZS4m0k
40 KB
Del
OK
phpZUgl5F
79.41 MB
Del
OK
phpZXbJsG
16 KB
Del
OK
phpZYfgmo
40 KB
Del
OK
phpZcmVhj
66.55 KB
Del
OK
phpZgfSQk
1.66 KB
Del
OK
phpZp2HzV
9.89 KB
Del
OK
phpZrxJwW
512 B
Del
OK
phpZwB5Zb
32.5 KB
Del
OK
phpZxUjA9
24 KB
Del
OK
php_sessions
-
Del
OK
phpa38H6V
80 KB
Del
OK
phpaEtPG9
40 KB
Del
OK
phpaGnfek
79.33 MB
Del
OK
phpaQzsAw
40 KB
Del
OK
phpaTN3Qs
40 KB
Del
OK
phpaWuwqA
40 KB
Del
OK
phpagjUdS
40 KB
Del
OK
phpahKg5K
0 B
Del
OK
phpanpoRm
40 KB
Del
OK
phpanxfLR
512 B
Del
OK
phpaoUy3u
5.53 KB
Del
OK
phpar1Lh2
40 KB
Del
OK
phpasLy8J
27.75 KB
Del
OK
phpaxoWIX
170.49 KB
Del
OK
phpb39n4j
40 KB
Del
OK
phpb7FPuG
32 KB
Del
OK
phpbByw9Y
40 KB
Del
OK
phpbGQxDz
21.5 KB
Del
OK
phpbIpleT
17.41 KB
Del
OK
phpbLTYtQ
40 KB
Del
OK
phpbN9rea
67.73 MB
Del
OK
phpbUCFwB
319 B
Del
OK
phpbY0pAs
24.5 KB
Del
OK
phpbg18wT
40 KB
Del
OK
phpbmCdwO
63.13 MB
Del
OK
phpbnDVY3
40 KB
Del
OK
phpbniljq
1.67 KB
Del
OK
phpbo1zqA
40 KB
Del
OK
phpbq87CB
35.48 KB
Del
OK
phpbvfLrC
80.5 KB
Del
OK
phpc58RO9
40 KB
Del
OK
phpc91PE3
283 B
Del
OK
phpcP8pJC
40 KB
Del
OK
phpcPHJRz
27.3 KB
Del
OK
phpcUnADS
32 KB
Del
OK
phpcUqt0w
39.62 KB
Del
OK
phpcVjrCW
40 KB
Del
OK
phpcYTUxC
43.68 KB
Del
OK
phpcj561o
40 KB
Del
OK
phpckDeiA
0 B
Del
OK
phpckXZib
512 B
Del
OK
phpcvxeey
11.45 MB
Del
OK
phpcxKKo2
76.87 KB
Del
OK
phpcyWMfS
412 B
Del
OK
phpd9yj4I
8.15 KB
Del
OK
phpdBX0YU
0 B
Del
OK
phpdBqH9G
1.5 KB
Del
OK
phpdJuguR
0 B
Del
OK
phpdL2pRD
40 KB
Del
OK
phpdQ9VZ7
35.35 KB
Del
OK
phpdQSqPV
8.86 KB
Del
OK
phpdWLuoM
30 B
Del
OK
phpdcx4o6
40 KB
Del
OK
phpdgO8xL
40 KB
Del
OK
phpdoYQLo
2.5 KB
Del
OK
phpdq5XHF
27.3 KB
Del
OK
phpe7jybV
32 KB
Del
OK
phpeCgzPX
27.67 KB
Del
OK
phpeNgMXr
0 B
Del
OK
phpeTjuGU
1.5 KB
Del
OK
phpeU9oDV
11.35 KB
Del
OK
phpeXic8d
6 KB
Del
OK
phpeZIl0A
31.81 KB
Del
OK
phpeg8PRA
15.63 KB
Del
OK
phpeka3IH
40 KB
Del
OK
phpemJnWA
40 KB
Del
OK
phpeouNfI
8.5 KB
Del
OK
phpevMga9
32 KB
Del
OK
phpevbjlO
16 KB
Del
OK
phpexMJky
694.37 KB
Del
OK
phpf1xr4u
64.07 KB
Del
OK
phpf3Wdwr
1.5 KB
Del
OK
phpf82doz
16.19 KB
Del
OK
phpfFqFv7
102.01 MB
Del
OK
phpfLEIaX
40 KB
Del
OK
phpfNwAFc
512 B
Del
OK
phpfcP9mX
12.32 KB
Del
OK
phpff8vTj
8.08 KB
Del
OK
phpffDKzS
40 KB
Del
OK
phpffmUMM
59 B
Del
OK
phpfq8oks
40 KB
Del
OK
phpfqWCYM
1.63 KB
Del
OK
phpfvp788
64.42 KB
Del
OK
phpg5NKSB
28 B
Del
OK
phpg9qLPE
512 B
Del
OK
phpgBX9ej
10.55 KB
Del
OK
phpgFW5Og
39.63 KB
Del
OK
phpgHrFki
512 B
Del
OK
phpgIdKtS
512 B
Del
OK
phpgVQqKn
0 B
Del
OK
phpgZZeXv
7.5 KB
Del
OK
phpgbX0cZ
0 B
Del
OK
phpghgCqD
62 B
Del
OK
phpgpaGUT
0 B
Del
OK
phpgrkDGo
50 B
Del
OK
phph0CZpN
80 KB
Del
OK
phph1Px6x
31.74 KB
Del
OK
phph4mi3p
40 KB
Del
OK
phphCXDud
27.28 KB
Del
OK
phphCsqSQ
512 B
Del
OK
phphQrS6j
38.8 KB
Del
OK
phphUX0pL
206 B
Del
OK
phphVOZp0
0 B
Del
OK
phphb4zJl
20.01 MB
Del
OK
phphqixDP
1.5 KB
Del
OK
phpi278sg
0 B
Del
OK
phpi29fKx
40 KB
Del
OK
phpi3pXDu
32.32 MB
Del
OK
phpiA2LAd
32 KB
Del
OK
phpiFPIH1
1.43 KB
Del
OK
phpiION5P
28.67 KB
Del
OK
phpiORDZV
35.33 KB
Del
OK
phpiSoWUS
32 KB
Del
OK
phpiU8JRj
1.21 KB
Del
OK
phpiW5PPS
80 KB
Del
OK
phpidbwyM
21.13 KB
Del
OK
phpifmXJh
14.01 KB
Del
OK
phpihFVxi
1.5 KB
Del
OK
phpii5l13
3.98 MB
Del
OK
phpiiW1Z0
0 B
Del
OK
phpimn9fZ
0 B
Del
OK
phpipJbfx
0 B
Del
OK
phpity2Px
32 KB
Del
OK
phpiuNze1
25 KB
Del
OK
phpiz0sfa
8.5 KB
Del
OK
phpizokim
335 B
Del
OK
phpj4mCEt
15.1 KB
Del
OK
phpj8Z2EY
8 KB
Del
OK
phpj9FQ75
40 KB
Del
OK
phpjA9Gr4
5.65 KB
Del
OK
phpjIGGD0
18.42 MB
Del
OK
phpjLJeSf
1 B
Del
OK
phpjUu8Kz
0 B
Del
OK
phpjWPMRD
4.58 MB
Del
OK
phpjYMbvq
15.14 KB
Del
OK
phpjbafu6
2.85 KB
Del
OK
phpjc0UlZ
40 KB
Del
OK
phpjlbXU6
8.94 KB
Del
OK
phpjpSyM6
16 KB
Del
OK
phpjwTDLc
40 B
Del
OK
phpk0x4At
39.59 KB
Del
OK
phpk77sRo
74.51 KB
Del
OK
phpkCV4Bo
512 B
Del
OK
phpkH8TgW
32 KB
Del
OK
phpkdhzEh
15.13 KB
Del
OK
phpkfnIlj
39.51 KB
Del
OK
phpkl3JOp
6 KB
Del
OK
phpknCWMB
16 KB
Del
OK
phpkz3Ol6
30 B
Del
OK
phpl2Mwlm
63.07 MB
Del
OK
phpl4uRRG
0 B
Del
OK
phpl5x3fb
8 KB
Del
OK
phpl9QvWX
80 KB
Del
OK
phplI05xU
40 KB
Del
OK
phplJTM8Z
0 B
Del
OK
phplKIaVD
16 KB
Del
OK
phplKVp27
39.45 KB
Del
OK
phplMiTRR
40 KB
Del
OK
phplP8wqZ
8 KB
Del
OK
phplQiPyR
129 B
Del
OK
phplS2mOo
64 B
Del
OK
phplTUtFr
8 KB
Del
OK
phplUyKpI
512 B
Del
OK
phplalkBE
1.5 KB
Del
OK
phplciJTA
40 KB
Del
OK
phplhP5td
4 KB
Del
OK
phpljUoKz
0 B
Del
OK
phplr7kRE
0 B
Del
OK
phplwetyi
1.5 KB
Del
OK
phpm3hQ8i
40 KB
Del
OK
phpm67AyA
0 B
Del
OK
phpm7sgqh
0 B
Del
OK
phpmKBeV3
61.87 KB
Del
OK
phpmPKW7t
15.16 KB
Del
OK
phpmRxoDq
6.74 KB
Del
OK
phpmXF0nI
8 KB
Del
OK
phpmii2Qv
266 B
Del
OK
phpmtNkhk
46 B
Del
OK
phpn0KERe
33.19 KB
Del
OK
phpnGhZTW
23.36 KB
Del
OK
phpnLgdch
40 KB
Del
OK
phpnLqiuK
1.5 KB
Del
OK
phpnRlY1k
0 B
Del
OK
phpnWOYI3
40 KB
Del
OK
phpnXEcU7
40 KB
Del
OK
phpnYgZws
52.59 MB
Del
OK
phpnbGptv
16 KB
Del
OK
phpnffb3O
9.69 KB
Del
OK
phpnpHj7c
79.37 MB
Del
OK
phpnvPx79
162 B
Del
OK
phpnzicFK
32 KB
Del
OK
phpnzqyBv
8.5 KB
Del
OK
phpo3OGCH
5.93 MB
Del
OK
phpoI2dNd
35.48 KB
Del
OK
phpoLhlOX
52 B
Del
OK
phpoRy30v
8.5 KB
Del
OK
phpoXKcu6
40 KB
Del
OK
phpoimKGx
8.5 KB
Del
OK
phpoj99Bi
79.36 MB
Del
OK
phpolwAOx
694.37 KB
Del
OK
phpono4UD
222 B
Del
OK
phposjthu
77 B
Del
OK
phpovOR2P
8 KB
Del
OK
phpp39IOE
25 KB
Del
OK
phpp47nX4
54 B
Del
OK
phpp4iiSN
80 KB
Del
OK
phpp6jmCv
6.5 KB
Del
OK
phppDnHzK
135 B
Del
OK
phppSsywW
5.32 KB
Del
OK
phppUOCLf
4.5 KB
Del
OK
phppZzdTj
40 KB
Del
OK
phppaFlqz
80 KB
Del
OK
phppdTWhO
26.06 KB
Del
OK
phppg3B26
63.13 MB
Del
OK
phppgoRqc
40 KB
Del
OK
phpplyETU
0 B
Del
OK
phppm69I3
40 KB
Del
OK
phppoPat9
0 B
Del
OK
phpptqmD6
40 KB
Del
OK
phppxvaUX
40 KB
Del
OK
phpq19HYj
8.5 KB
Del
OK
phpq2kqG9
31.35 KB
Del
OK
phpq54Smx
32 KB
Del
OK
phpq9gYkv
55.45 MB
Del
OK
phpqD4T6N
24.5 KB
Del
OK
phpqFhFbL
32 KB
Del
OK
phpqNWHwo
40 KB
Del
OK
phpqSlPp4
21 KB
Del
OK
phpqSn0xY
26.43 KB
Del
OK
phpqUsSUT
2.69 KB
Del
OK
phpqzlIJf
35.48 KB
Del
OK
phpr0P3XI
80 KB
Del
OK
phpr0neyA
40 KB
Del
OK
phpr1n3Lh
24 KB
Del
OK
phpr5SCZB
16 KB
Del
OK
phprCqXBR
80 KB
Del
OK
phprRKOPb
8.5 KB
Del
OK
phprS1dAg
15.6 KB
Del
OK
phprSgxPF
48.5 KB
Del
OK
phprb4Ry4
16 KB
Del
OK
phpredY18
1.5 KB
Del
OK
phprkPp3A
152.78 KB
Del
OK
phprl7Jmz
32 KB
Del
OK
phpruvaJy
0 B
Del
OK
phpsACbgB
51 B
Del
OK
phpsDoJoH
40 KB
Del
OK
phpsb6vUN
40 KB
Del
OK
phpsePHI3
722 B
Del
OK
phpsnB3gT
48.5 KB
Del
OK
phpspweSN
40 KB
Del
OK
phpt5jKdZ
0 B
Del
OK
phpt8Pe3G
80 KB
Del
OK
phpt9a4Yp
16 KB
Del
OK
phptCMN6u
31.42 KB
Del
OK
phptFvC48
40 KB
Del
OK
phptGLQau
0 B
Del
OK
phptKNNfU
1.5 KB
Del
OK
phptM3Ewp
8 KB
Del
OK
phptM65gy
27.34 KB
Del
OK
phptO3Xkx
39.45 KB
Del
OK
phptP4mxd
27.86 KB
Del
OK
phptdEPU4
0 B
Del
OK
phptiwifh
5 KB
Del
OK
phptlWVMF
1.44 KB
Del
OK
phptm4uK2
40 KB
Del
OK
phptnH4s5
1011.37 KB
Del
OK
phpts8ooi
79.34 MB
Del
OK
phptt5q0h
40 KB
Del
OK
phptz5Vsv
15.61 KB
Del
OK
phptz9K14
65.68 KB
Del
OK
phptzo7sN
32 KB
Del
OK
phpu2JMGP
16.05 KB
Del
OK
phpuBX1Jg
40 KB
Del
OK
phpuUcNRf
2.5 KB
Del
OK
phpuYE689
40 KB
Del
OK
phpuoi2eA
224 KB
Del
OK
phpuuunak
50 B
Del
OK
phpuwDW34
43.67 KB
Del
OK
phpv4O7T2
13 KB
Del
OK
phpvFJDCv
15.09 KB
Del
OK
phpvNfHa6
1.5 KB
Del
OK
phpvPT7Nq
16 KB
Del
OK
phpvRVIHc
11.24 KB
Del
OK
phpvT43gH
40 KB
Del
OK
phpvTfq4V
64 KB
Del
OK
phpvUbcmd
56 KB
Del
OK
phpvV0J0b
6.74 KB
Del
OK
phpvcPFS8
21.05 KB
Del
OK
phpvcXPH5
32 KB
Del
OK
phpvhAcXC
29.83 KB
Del
OK
phpvi3rcc
40 KB
Del
OK
phpvocBoC
210.23 KB
Del
OK
phpvpeSbE
24 KB
Del
OK
phpvxELdf
0 B
Del
OK
phpw1JqfM
8.21 MB
Del
OK
phpw1xogN
410 KB
Del
OK
phpw5ibSY
40 KB
Del
OK
phpwEhgp5
823.55 KB
Del
OK
phpwJX3Gh
5.54 KB
Del
OK
phpwY4ZlH
4.03 KB
Del
OK
phpwaMb08
1024 B
Del
OK
phpwehmf3
15.64 KB
Del
OK
phpwgMHS9
3.4 KB
Del
OK
phpwju2I5
17.19 KB
Del
OK
phpwmbE67
512 B
Del
OK
phpwqd1ED
23.21 KB
Del
OK
phpwwzZK5
27.39 KB
Del
OK
phpwypbbE
4.28 MB
Del
OK
phpx4jyaG
32.05 KB
Del
OK
phpx5jBHz
40 KB
Del
OK
phpxExLkI
40 KB
Del
OK
phpxK3sCR
40 KB
Del
OK
phpxOoq6n
1.5 KB
Del
OK
phpxSKAat
216 KB
Del
OK
phpxXxlqt
54 B
Del
OK
phpxZUylL
40 KB
Del
OK
phpxagDhl
0 B
Del
OK
phpxfnKDK
40 KB
Del
OK
phpxt02IE
16.41 KB
Del
OK
phpxvbXmn
16 KB
Del
OK
phpxwxlYr
40 KB
Del
OK
phpy1moZ2
39.58 KB
Del
OK
phpyD9NhX
19.16 KB
Del
OK
phpyJUNnX
78.07 MB
Del
OK
phpyKv2dV
1.5 KB
Del
OK
phpyOD5DC
32.04 KB
Del
OK
phpyTG8N1
80 KB
Del
OK
phpyXmuzz
40 KB
Del
OK
phpydox08
342.27 KB
Del
OK
phpyi2Wbr
0 B
Del
OK
phpyjqnUL
5.65 KB
Del
OK
phpytJwhd
31.47 KB
Del
OK
phpz1oBMs
39.45 KB
Del
OK
phpz2vOfd
1.5 KB
Del
OK
phpz32Tc7
0 B
Del
OK
phpz7GIMi
6.65 KB
Del
OK
phpzEFhj1
3 KB
Del
OK
phpzFuO8j
40 KB
Del
OK
phpzR182L
512 B
Del
OK
phpzSArE5
0 B
Del
OK
phpzTbpgh
40 KB
Del
OK
phpzVTEjg
5.5 KB
Del
OK
phpzi2xYj
40 KB
Del
OK
phpzn0Y1e
40 KB
Del
OK
phpznw4rp
8 KB
Del
OK
phpzokr9D
46 B
Del
OK
phpzpJJ6I
760 B
Del
OK
phpzqPqGK
20 KB
Del
OK
phpzzTHtu
0 B
Del
OK
phpzzrYWF
0 B
Del
OK
system_log.txt
282 B
Del
OK
www.seshaasschool.com.588275.tmp
34.55 KB
Del
OK
Edit: phpDRQ9DM
/* Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* * ISO C99 Standard: 7.13 Nonlocal jumps <setjmp.h> */ #ifndef _SETJMP_H #define _SETJMP_H 1 #include <features.h> __BEGIN_DECLS #include <bits/setjmp.h> /* Get `__jmp_buf'. */ #include <bits/types/struct___jmp_buf_tag.h> typedef struct __jmp_buf_tag jmp_buf[1]; /* Store the calling environment in ENV, also saving the signal mask. Return 0. */ extern int setjmp (jmp_buf __env) __THROWNL; /* Store the calling environment in ENV, also saving the signal mask if SAVEMASK is nonzero. Return 0. This is the internal name for `sigsetjmp'. */ extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROWNL; /* Store the calling environment in ENV, not saving the signal mask. Return 0. */ extern int _setjmp (struct __jmp_buf_tag __env[1]) __THROWNL; /* Do not save the signal mask. This is equivalent to the `_setjmp' BSD function. */ #define setjmp(env) _setjmp (env) /* Jump to the environment saved in ENV, making the `setjmp' call there return VAL, or 1 if VAL is 0. */ extern void longjmp (struct __jmp_buf_tag __env[1], int __val) __THROWNL __attribute__ ((__noreturn__)); #if defined __USE_MISC || defined __USE_XOPEN /* Same. Usually `_longjmp' is used with `_setjmp', which does not save the signal mask. But it is how ENV was saved that determines whether `longjmp' restores the mask; `_longjmp' is just an alias. */ extern void _longjmp (struct __jmp_buf_tag __env[1], int __val) __THROWNL __attribute__ ((__noreturn__)); #endif #ifdef __USE_POSIX /* Use the same type for `jmp_buf' and `sigjmp_buf'. The `__mask_was_saved' flag determines whether or not `longjmp' will restore the signal mask. */ typedef struct __jmp_buf_tag sigjmp_buf[1]; /* Store the calling environment in ENV, also saving the signal mask if SAVEMASK is nonzero. Return 0. */ # define sigsetjmp(env, savemask) __sigsetjmp (env, savemask) /* Jump to the environment saved in ENV, making the sigsetjmp call there return VAL, or 1 if VAL is 0. Restore the signal mask if that sigsetjmp call saved it. This is just an alias `longjmp'. */ extern void siglongjmp (sigjmp_buf __env, int __val) __THROWNL __attribute__ ((__noreturn__)); #endif /* Use POSIX. */ /* Define helper functions to catch unsafe code. */ #if __USE_FORTIFY_LEVEL > 0 # include <bits/setjmp2.h> #endif __END_DECLS #endif /* setjmp.h */ /* Header with interface version macros for library pieces copied elsewhere. Copyright (C) 1995-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _GNU_VERSIONS_H #define _GNU_VERSIONS_H 1 /* This file exists to define these few macros. Each specifies a version number associated with the library interface of a piece of the C library which is also distributed with other GNU packages. These pieces are both part of the GNU C library and also distributed with other GNU packages so those packages may use their facilities on systems lacking the GNU C library. The source files for each piece surround all their code with `#ifndef ELIDE_CODE' after defining it with this: #define OBSTACK_INTERFACE_VERSION 1 #if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1 #include <gnu-versions.h> #if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION #define ELIDE_CODE #endif #endif This allows those one to avoid compiling those files when part of a GNU package not libc, on a system using a GNU C library that supports the same interface. Please preserve the format of the comments after each macro. And remember, if any of these versions change, the libc.so major version number must change too (so avoid it)! */ #define _GNU_OBSTACK_INTERFACE_VERSION 1 /* vs malloc/obstack.c */ #define _GNU_REGEX_INTERFACE_VERSION 1 /* vs posix/regex.c */ #define _GNU_GLOB_INTERFACE_VERSION 2 /* vs posix/glob.c */ #define _GNU_GETOPT_INTERFACE_VERSION 2 /* vs posix/getopt.c and posix/getopt1.c */ #endif /* gnu-versions.h */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #include <asm/bitsperlong.h> /* * This file contains the system call numbers, based on the * layout of the x86-64 architecture, which embeds the * pointer to the syscall in the table. * * As a basic principle, no duplication of functionality * should be added, e.g. we don't use lseek when llseek * is present. New architectures should use this file * and implement the less feature-full calls in user space. */ #ifndef __SYSCALL #define __SYSCALL(x, y) #endif #if __BITS_PER_LONG == 32 || defined(__SYSCALL_COMPAT) #define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _32) #else #define __SC_3264(_nr, _32, _64) __SYSCALL(_nr, _64) #endif #ifdef __SYSCALL_COMPAT #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _comp) #define __SC_COMP_3264(_nr, _32, _64, _comp) __SYSCALL(_nr, _comp) #else #define __SC_COMP(_nr, _sys, _comp) __SYSCALL(_nr, _sys) #define __SC_COMP_3264(_nr, _32, _64, _comp) __SC_3264(_nr, _32, _64) #endif #define __NR_io_setup 0 __SC_COMP(__NR_io_setup, sys_io_setup, compat_sys_io_setup) #define __NR_io_destroy 1 __SYSCALL(__NR_io_destroy, sys_io_destroy) #define __NR_io_submit 2 __SC_COMP(__NR_io_submit, sys_io_submit, compat_sys_io_submit) #define __NR_io_cancel 3 __SYSCALL(__NR_io_cancel, sys_io_cancel) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_io_getevents 4 __SC_3264(__NR_io_getevents, sys_io_getevents_time32, sys_io_getevents) #endif #define __NR_setxattr 5 __SYSCALL(__NR_setxattr, sys_setxattr) #define __NR_lsetxattr 6 __SYSCALL(__NR_lsetxattr, sys_lsetxattr) #define __NR_fsetxattr 7 __SYSCALL(__NR_fsetxattr, sys_fsetxattr) #define __NR_getxattr 8 __SYSCALL(__NR_getxattr, sys_getxattr) #define __NR_lgetxattr 9 __SYSCALL(__NR_lgetxattr, sys_lgetxattr) #define __NR_fgetxattr 10 __SYSCALL(__NR_fgetxattr, sys_fgetxattr) #define __NR_listxattr 11 __SYSCALL(__NR_listxattr, sys_listxattr) #define __NR_llistxattr 12 __SYSCALL(__NR_llistxattr, sys_llistxattr) #define __NR_flistxattr 13 __SYSCALL(__NR_flistxattr, sys_flistxattr) #define __NR_removexattr 14 __SYSCALL(__NR_removexattr, sys_removexattr) #define __NR_lremovexattr 15 __SYSCALL(__NR_lremovexattr, sys_lremovexattr) #define __NR_fremovexattr 16 __SYSCALL(__NR_fremovexattr, sys_fremovexattr) #define __NR_getcwd 17 __SYSCALL(__NR_getcwd, sys_getcwd) #define __NR_lookup_dcookie 18 __SYSCALL(__NR_lookup_dcookie, sys_ni_syscall) #define __NR_eventfd2 19 __SYSCALL(__NR_eventfd2, sys_eventfd2) #define __NR_epoll_create1 20 __SYSCALL(__NR_epoll_create1, sys_epoll_create1) #define __NR_epoll_ctl 21 __SYSCALL(__NR_epoll_ctl, sys_epoll_ctl) #define __NR_epoll_pwait 22 __SC_COMP(__NR_epoll_pwait, sys_epoll_pwait, compat_sys_epoll_pwait) #define __NR_dup 23 __SYSCALL(__NR_dup, sys_dup) #define __NR_dup3 24 __SYSCALL(__NR_dup3, sys_dup3) #define __NR3264_fcntl 25 __SC_COMP_3264(__NR3264_fcntl, sys_fcntl64, sys_fcntl, compat_sys_fcntl64) #define __NR_inotify_init1 26 __SYSCALL(__NR_inotify_init1, sys_inotify_init1) #define __NR_inotify_add_watch 27 __SYSCALL(__NR_inotify_add_watch, sys_inotify_add_watch) #define __NR_inotify_rm_watch 28 __SYSCALL(__NR_inotify_rm_watch, sys_inotify_rm_watch) #define __NR_ioctl 29 __SC_COMP(__NR_ioctl, sys_ioctl, compat_sys_ioctl) #define __NR_ioprio_set 30 __SYSCALL(__NR_ioprio_set, sys_ioprio_set) #define __NR_ioprio_get 31 __SYSCALL(__NR_ioprio_get, sys_ioprio_get) #define __NR_flock 32 __SYSCALL(__NR_flock, sys_flock) #define __NR_mknodat 33 __SYSCALL(__NR_mknodat, sys_mknodat) #define __NR_mkdirat 34 __SYSCALL(__NR_mkdirat, sys_mkdirat) #define __NR_unlinkat 35 __SYSCALL(__NR_unlinkat, sys_unlinkat) #define __NR_symlinkat 36 __SYSCALL(__NR_symlinkat, sys_symlinkat) #define __NR_linkat 37 __SYSCALL(__NR_linkat, sys_linkat) #ifdef __ARCH_WANT_RENAMEAT /* renameat is superseded with flags by renameat2 */ #define __NR_renameat 38 __SYSCALL(__NR_renameat, sys_renameat) #endif /* __ARCH_WANT_RENAMEAT */ #define __NR_umount2 39 __SYSCALL(__NR_umount2, sys_umount) #define __NR_mount 40 __SYSCALL(__NR_mount, sys_mount) #define __NR_pivot_root 41 __SYSCALL(__NR_pivot_root, sys_pivot_root) #define __NR_nfsservctl 42 __SYSCALL(__NR_nfsservctl, sys_ni_syscall) #define __NR3264_statfs 43 __SC_COMP_3264(__NR3264_statfs, sys_statfs64, sys_statfs, \ compat_sys_statfs64) #define __NR3264_fstatfs 44 __SC_COMP_3264(__NR3264_fstatfs, sys_fstatfs64, sys_fstatfs, \ compat_sys_fstatfs64) #define __NR3264_truncate 45 __SC_COMP_3264(__NR3264_truncate, sys_truncate64, sys_truncate, \ compat_sys_truncate64) #define __NR3264_ftruncate 46 __SC_COMP_3264(__NR3264_ftruncate, sys_ftruncate64, sys_ftruncate, \ compat_sys_ftruncate64) #define __NR_fallocate 47 __SC_COMP(__NR_fallocate, sys_fallocate, compat_sys_fallocate) #define __NR_faccessat 48 __SYSCALL(__NR_faccessat, sys_faccessat) #define __NR_chdir 49 __SYSCALL(__NR_chdir, sys_chdir) #define __NR_fchdir 50 __SYSCALL(__NR_fchdir, sys_fchdir) #define __NR_chroot 51 __SYSCALL(__NR_chroot, sys_chroot) #define __NR_fchmod 52 __SYSCALL(__NR_fchmod, sys_fchmod) #define __NR_fchmodat 53 __SYSCALL(__NR_fchmodat, sys_fchmodat) #define __NR_fchownat 54 __SYSCALL(__NR_fchownat, sys_fchownat) #define __NR_fchown 55 __SYSCALL(__NR_fchown, sys_fchown) #define __NR_openat 56 __SYSCALL(__NR_openat, sys_openat) #define __NR_close 57 __SYSCALL(__NR_close, sys_close) #define __NR_vhangup 58 __SYSCALL(__NR_vhangup, sys_vhangup) #define __NR_pipe2 59 __SYSCALL(__NR_pipe2, sys_pipe2) #define __NR_quotactl 60 __SYSCALL(__NR_quotactl, sys_quotactl) #define __NR_getdents64 61 __SYSCALL(__NR_getdents64, sys_getdents64) #define __NR3264_lseek 62 __SC_3264(__NR3264_lseek, sys_llseek, sys_lseek) #define __NR_read 63 __SYSCALL(__NR_read, sys_read) #define __NR_write 64 __SYSCALL(__NR_write, sys_write) #define __NR_readv 65 __SC_COMP(__NR_readv, sys_readv, sys_readv) #define __NR_writev 66 __SC_COMP(__NR_writev, sys_writev, sys_writev) #define __NR_pread64 67 __SC_COMP(__NR_pread64, sys_pread64, compat_sys_pread64) #define __NR_pwrite64 68 __SC_COMP(__NR_pwrite64, sys_pwrite64, compat_sys_pwrite64) #define __NR_preadv 69 __SC_COMP(__NR_preadv, sys_preadv, compat_sys_preadv) #define __NR_pwritev 70 __SC_COMP(__NR_pwritev, sys_pwritev, compat_sys_pwritev) #define __NR3264_sendfile 71 __SYSCALL(__NR3264_sendfile, sys_sendfile64) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_pselect6 72 __SC_COMP_3264(__NR_pselect6, sys_pselect6_time32, sys_pselect6, compat_sys_pselect6_time32) #define __NR_ppoll 73 __SC_COMP_3264(__NR_ppoll, sys_ppoll_time32, sys_ppoll, compat_sys_ppoll_time32) #endif #define __NR_signalfd4 74 __SC_COMP(__NR_signalfd4, sys_signalfd4, compat_sys_signalfd4) #define __NR_vmsplice 75 __SYSCALL(__NR_vmsplice, sys_vmsplice) #define __NR_splice 76 __SYSCALL(__NR_splice, sys_splice) #define __NR_tee 77 __SYSCALL(__NR_tee, sys_tee) #define __NR_readlinkat 78 __SYSCALL(__NR_readlinkat, sys_readlinkat) #if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64) #define __NR3264_fstatat 79 __SC_3264(__NR3264_fstatat, sys_fstatat64, sys_newfstatat) #define __NR3264_fstat 80 __SC_3264(__NR3264_fstat, sys_fstat64, sys_newfstat) #endif #define __NR_sync 81 __SYSCALL(__NR_sync, sys_sync) #define __NR_fsync 82 __SYSCALL(__NR_fsync, sys_fsync) #define __NR_fdatasync 83 __SYSCALL(__NR_fdatasync, sys_fdatasync) #ifdef __ARCH_WANT_SYNC_FILE_RANGE2 #define __NR_sync_file_range2 84 __SC_COMP(__NR_sync_file_range2, sys_sync_file_range2, \ compat_sys_sync_file_range2) #else #define __NR_sync_file_range 84 __SC_COMP(__NR_sync_file_range, sys_sync_file_range, \ compat_sys_sync_file_range) #endif #define __NR_timerfd_create 85 __SYSCALL(__NR_timerfd_create, sys_timerfd_create) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_timerfd_settime 86 __SC_3264(__NR_timerfd_settime, sys_timerfd_settime32, \ sys_timerfd_settime) #define __NR_timerfd_gettime 87 __SC_3264(__NR_timerfd_gettime, sys_timerfd_gettime32, \ sys_timerfd_gettime) #endif #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_utimensat 88 __SC_3264(__NR_utimensat, sys_utimensat_time32, sys_utimensat) #endif #define __NR_acct 89 __SYSCALL(__NR_acct, sys_acct) #define __NR_capget 90 __SYSCALL(__NR_capget, sys_capget) #define __NR_capset 91 __SYSCALL(__NR_capset, sys_capset) #define __NR_personality 92 __SYSCALL(__NR_personality, sys_personality) #define __NR_exit 93 __SYSCALL(__NR_exit, sys_exit) #define __NR_exit_group 94 __SYSCALL(__NR_exit_group, sys_exit_group) #define __NR_waitid 95 __SC_COMP(__NR_waitid, sys_waitid, compat_sys_waitid) #define __NR_set_tid_address 96 __SYSCALL(__NR_set_tid_address, sys_set_tid_address) #define __NR_unshare 97 __SYSCALL(__NR_unshare, sys_unshare) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_futex 98 __SC_3264(__NR_futex, sys_futex_time32, sys_futex) #endif #define __NR_set_robust_list 99 __SC_COMP(__NR_set_robust_list, sys_set_robust_list, \ compat_sys_set_robust_list) #define __NR_get_robust_list 100 __SC_COMP(__NR_get_robust_list, sys_get_robust_list, \ compat_sys_get_robust_list) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_nanosleep 101 __SC_3264(__NR_nanosleep, sys_nanosleep_time32, sys_nanosleep) #endif #define __NR_getitimer 102 __SC_COMP(__NR_getitimer, sys_getitimer, compat_sys_getitimer) #define __NR_setitimer 103 __SC_COMP(__NR_setitimer, sys_setitimer, compat_sys_setitimer) #define __NR_kexec_load 104 __SC_COMP(__NR_kexec_load, sys_kexec_load, compat_sys_kexec_load) #define __NR_init_module 105 __SYSCALL(__NR_init_module, sys_init_module) #define __NR_delete_module 106 __SYSCALL(__NR_delete_module, sys_delete_module) #define __NR_timer_create 107 __SC_COMP(__NR_timer_create, sys_timer_create, compat_sys_timer_create) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_timer_gettime 108 __SC_3264(__NR_timer_gettime, sys_timer_gettime32, sys_timer_gettime) #endif #define __NR_timer_getoverrun 109 __SYSCALL(__NR_timer_getoverrun, sys_timer_getoverrun) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_timer_settime 110 __SC_3264(__NR_timer_settime, sys_timer_settime32, sys_timer_settime) #endif #define __NR_timer_delete 111 __SYSCALL(__NR_timer_delete, sys_timer_delete) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_clock_settime 112 __SC_3264(__NR_clock_settime, sys_clock_settime32, sys_clock_settime) #define __NR_clock_gettime 113 __SC_3264(__NR_clock_gettime, sys_clock_gettime32, sys_clock_gettime) #define __NR_clock_getres 114 __SC_3264(__NR_clock_getres, sys_clock_getres_time32, sys_clock_getres) #define __NR_clock_nanosleep 115 __SC_3264(__NR_clock_nanosleep, sys_clock_nanosleep_time32, \ sys_clock_nanosleep) #endif #define __NR_syslog 116 __SYSCALL(__NR_syslog, sys_syslog) #define __NR_ptrace 117 __SC_COMP(__NR_ptrace, sys_ptrace, compat_sys_ptrace) #define __NR_sched_setparam 118 __SYSCALL(__NR_sched_setparam, sys_sched_setparam) #define __NR_sched_setscheduler 119 __SYSCALL(__NR_sched_setscheduler, sys_sched_setscheduler) #define __NR_sched_getscheduler 120 __SYSCALL(__NR_sched_getscheduler, sys_sched_getscheduler) #define __NR_sched_getparam 121 __SYSCALL(__NR_sched_getparam, sys_sched_getparam) #define __NR_sched_setaffinity 122 __SC_COMP(__NR_sched_setaffinity, sys_sched_setaffinity, \ compat_sys_sched_setaffinity) #define __NR_sched_getaffinity 123 __SC_COMP(__NR_sched_getaffinity, sys_sched_getaffinity, \ compat_sys_sched_getaffinity) #define __NR_sched_yield 124 __SYSCALL(__NR_sched_yield, sys_sched_yield) #define __NR_sched_get_priority_max 125 __SYSCALL(__NR_sched_get_priority_max, sys_sched_get_priority_max) #define __NR_sched_get_priority_min 126 __SYSCALL(__NR_sched_get_priority_min, sys_sched_get_priority_min) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_sched_rr_get_interval 127 __SC_3264(__NR_sched_rr_get_interval, sys_sched_rr_get_interval_time32, \ sys_sched_rr_get_interval) #endif #define __NR_restart_syscall 128 __SYSCALL(__NR_restart_syscall, sys_restart_syscall) #define __NR_kill 129 __SYSCALL(__NR_kill, sys_kill) #define __NR_tkill 130 __SYSCALL(__NR_tkill, sys_tkill) #define __NR_tgkill 131 __SYSCALL(__NR_tgkill, sys_tgkill) #define __NR_sigaltstack 132 __SC_COMP(__NR_sigaltstack, sys_sigaltstack, compat_sys_sigaltstack) #define __NR_rt_sigsuspend 133 __SC_COMP(__NR_rt_sigsuspend, sys_rt_sigsuspend, compat_sys_rt_sigsuspend) #define __NR_rt_sigaction 134 __SC_COMP(__NR_rt_sigaction, sys_rt_sigaction, compat_sys_rt_sigaction) #define __NR_rt_sigprocmask 135 __SC_COMP(__NR_rt_sigprocmask, sys_rt_sigprocmask, compat_sys_rt_sigprocmask) #define __NR_rt_sigpending 136 __SC_COMP(__NR_rt_sigpending, sys_rt_sigpending, compat_sys_rt_sigpending) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_rt_sigtimedwait 137 __SC_COMP_3264(__NR_rt_sigtimedwait, sys_rt_sigtimedwait_time32, \ sys_rt_sigtimedwait, compat_sys_rt_sigtimedwait_time32) #endif #define __NR_rt_sigqueueinfo 138 __SC_COMP(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo, \ compat_sys_rt_sigqueueinfo) #define __NR_rt_sigreturn 139 __SC_COMP(__NR_rt_sigreturn, sys_rt_sigreturn, compat_sys_rt_sigreturn) #define __NR_setpriority 140 __SYSCALL(__NR_setpriority, sys_setpriority) #define __NR_getpriority 141 __SYSCALL(__NR_getpriority, sys_getpriority) #define __NR_reboot 142 __SYSCALL(__NR_reboot, sys_reboot) #define __NR_setregid 143 __SYSCALL(__NR_setregid, sys_setregid) #define __NR_setgid 144 __SYSCALL(__NR_setgid, sys_setgid) #define __NR_setreuid 145 __SYSCALL(__NR_setreuid, sys_setreuid) #define __NR_setuid 146 __SYSCALL(__NR_setuid, sys_setuid) #define __NR_setresuid 147 __SYSCALL(__NR_setresuid, sys_setresuid) #define __NR_getresuid 148 __SYSCALL(__NR_getresuid, sys_getresuid) #define __NR_setresgid 149 __SYSCALL(__NR_setresgid, sys_setresgid) #define __NR_getresgid 150 __SYSCALL(__NR_getresgid, sys_getresgid) #define __NR_setfsuid 151 __SYSCALL(__NR_setfsuid, sys_setfsuid) #define __NR_setfsgid 152 __SYSCALL(__NR_setfsgid, sys_setfsgid) #define __NR_times 153 __SC_COMP(__NR_times, sys_times, compat_sys_times) #define __NR_setpgid 154 __SYSCALL(__NR_setpgid, sys_setpgid) #define __NR_getpgid 155 __SYSCALL(__NR_getpgid, sys_getpgid) #define __NR_getsid 156 __SYSCALL(__NR_getsid, sys_getsid) #define __NR_setsid 157 __SYSCALL(__NR_setsid, sys_setsid) #define __NR_getgroups 158 __SYSCALL(__NR_getgroups, sys_getgroups) #define __NR_setgroups 159 __SYSCALL(__NR_setgroups, sys_setgroups) #define __NR_uname 160 __SYSCALL(__NR_uname, sys_newuname) #define __NR_sethostname 161 __SYSCALL(__NR_sethostname, sys_sethostname) #define __NR_setdomainname 162 __SYSCALL(__NR_setdomainname, sys_setdomainname) #ifdef __ARCH_WANT_SET_GET_RLIMIT /* getrlimit and setrlimit are superseded with prlimit64 */ #define __NR_getrlimit 163 __SC_COMP(__NR_getrlimit, sys_getrlimit, compat_sys_getrlimit) #define __NR_setrlimit 164 __SC_COMP(__NR_setrlimit, sys_setrlimit, compat_sys_setrlimit) #endif #define __NR_getrusage 165 __SC_COMP(__NR_getrusage, sys_getrusage, compat_sys_getrusage) #define __NR_umask 166 __SYSCALL(__NR_umask, sys_umask) #define __NR_prctl 167 __SYSCALL(__NR_prctl, sys_prctl) #define __NR_getcpu 168 __SYSCALL(__NR_getcpu, sys_getcpu) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_gettimeofday 169 __SC_COMP(__NR_gettimeofday, sys_gettimeofday, compat_sys_gettimeofday) #define __NR_settimeofday 170 __SC_COMP(__NR_settimeofday, sys_settimeofday, compat_sys_settimeofday) #define __NR_adjtimex 171 __SC_3264(__NR_adjtimex, sys_adjtimex_time32, sys_adjtimex) #endif #define __NR_getpid 172 __SYSCALL(__NR_getpid, sys_getpid) #define __NR_getppid 173 __SYSCALL(__NR_getppid, sys_getppid) #define __NR_getuid 174 __SYSCALL(__NR_getuid, sys_getuid) #define __NR_geteuid 175 __SYSCALL(__NR_geteuid, sys_geteuid) #define __NR_getgid 176 __SYSCALL(__NR_getgid, sys_getgid) #define __NR_getegid 177 __SYSCALL(__NR_getegid, sys_getegid) #define __NR_gettid 178 __SYSCALL(__NR_gettid, sys_gettid) #define __NR_sysinfo 179 __SC_COMP(__NR_sysinfo, sys_sysinfo, compat_sys_sysinfo) #define __NR_mq_open 180 __SC_COMP(__NR_mq_open, sys_mq_open, compat_sys_mq_open) #define __NR_mq_unlink 181 __SYSCALL(__NR_mq_unlink, sys_mq_unlink) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_mq_timedsend 182 __SC_3264(__NR_mq_timedsend, sys_mq_timedsend_time32, sys_mq_timedsend) #define __NR_mq_timedreceive 183 __SC_3264(__NR_mq_timedreceive, sys_mq_timedreceive_time32, \ sys_mq_timedreceive) #endif #define __NR_mq_notify 184 __SC_COMP(__NR_mq_notify, sys_mq_notify, compat_sys_mq_notify) #define __NR_mq_getsetattr 185 __SC_COMP(__NR_mq_getsetattr, sys_mq_getsetattr, compat_sys_mq_getsetattr) #define __NR_msgget 186 __SYSCALL(__NR_msgget, sys_msgget) #define __NR_msgctl 187 __SC_COMP(__NR_msgctl, sys_msgctl, compat_sys_msgctl) #define __NR_msgrcv 188 __SC_COMP(__NR_msgrcv, sys_msgrcv, compat_sys_msgrcv) #define __NR_msgsnd 189 __SC_COMP(__NR_msgsnd, sys_msgsnd, compat_sys_msgsnd) #define __NR_semget 190 __SYSCALL(__NR_semget, sys_semget) #define __NR_semctl 191 __SC_COMP(__NR_semctl, sys_semctl, compat_sys_semctl) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_semtimedop 192 __SC_3264(__NR_semtimedop, sys_semtimedop_time32, sys_semtimedop) #endif #define __NR_semop 193 __SYSCALL(__NR_semop, sys_semop) #define __NR_shmget 194 __SYSCALL(__NR_shmget, sys_shmget) #define __NR_shmctl 195 __SC_COMP(__NR_shmctl, sys_shmctl, compat_sys_shmctl) #define __NR_shmat 196 __SC_COMP(__NR_shmat, sys_shmat, compat_sys_shmat) #define __NR_shmdt 197 __SYSCALL(__NR_shmdt, sys_shmdt) #define __NR_socket 198 __SYSCALL(__NR_socket, sys_socket) #define __NR_socketpair 199 __SYSCALL(__NR_socketpair, sys_socketpair) #define __NR_bind 200 __SYSCALL(__NR_bind, sys_bind) #define __NR_listen 201 __SYSCALL(__NR_listen, sys_listen) #define __NR_accept 202 __SYSCALL(__NR_accept, sys_accept) #define __NR_connect 203 __SYSCALL(__NR_connect, sys_connect) #define __NR_getsockname 204 __SYSCALL(__NR_getsockname, sys_getsockname) #define __NR_getpeername 205 __SYSCALL(__NR_getpeername, sys_getpeername) #define __NR_sendto 206 __SYSCALL(__NR_sendto, sys_sendto) #define __NR_recvfrom 207 __SC_COMP(__NR_recvfrom, sys_recvfrom, compat_sys_recvfrom) #define __NR_setsockopt 208 __SC_COMP(__NR_setsockopt, sys_setsockopt, sys_setsockopt) #define __NR_getsockopt 209 __SC_COMP(__NR_getsockopt, sys_getsockopt, sys_getsockopt) #define __NR_shutdown 210 __SYSCALL(__NR_shutdown, sys_shutdown) #define __NR_sendmsg 211 __SC_COMP(__NR_sendmsg, sys_sendmsg, compat_sys_sendmsg) #define __NR_recvmsg 212 __SC_COMP(__NR_recvmsg, sys_recvmsg, compat_sys_recvmsg) #define __NR_readahead 213 __SC_COMP(__NR_readahead, sys_readahead, compat_sys_readahead) #define __NR_brk 214 __SYSCALL(__NR_brk, sys_brk) #define __NR_munmap 215 __SYSCALL(__NR_munmap, sys_munmap) #define __NR_mremap 216 __SYSCALL(__NR_mremap, sys_mremap) #define __NR_add_key 217 __SYSCALL(__NR_add_key, sys_add_key) #define __NR_request_key 218 __SYSCALL(__NR_request_key, sys_request_key) #define __NR_keyctl 219 __SC_COMP(__NR_keyctl, sys_keyctl, compat_sys_keyctl) #define __NR_clone 220 __SYSCALL(__NR_clone, sys_clone) #define __NR_execve 221 __SC_COMP(__NR_execve, sys_execve, compat_sys_execve) #define __NR3264_mmap 222 __SC_3264(__NR3264_mmap, sys_mmap2, sys_mmap) #define __NR3264_fadvise64 223 __SC_COMP(__NR3264_fadvise64, sys_fadvise64_64, compat_sys_fadvise64_64) /* CONFIG_MMU only */ #ifndef __ARCH_NOMMU #define __NR_swapon 224 __SYSCALL(__NR_swapon, sys_swapon) #define __NR_swapoff 225 __SYSCALL(__NR_swapoff, sys_swapoff) #define __NR_mprotect 226 __SYSCALL(__NR_mprotect, sys_mprotect) #define __NR_msync 227 __SYSCALL(__NR_msync, sys_msync) #define __NR_mlock 228 __SYSCALL(__NR_mlock, sys_mlock) #define __NR_munlock 229 __SYSCALL(__NR_munlock, sys_munlock) #define __NR_mlockall 230 __SYSCALL(__NR_mlockall, sys_mlockall) #define __NR_munlockall 231 __SYSCALL(__NR_munlockall, sys_munlockall) #define __NR_mincore 232 __SYSCALL(__NR_mincore, sys_mincore) #define __NR_madvise 233 __SYSCALL(__NR_madvise, sys_madvise) #define __NR_remap_file_pages 234 __SYSCALL(__NR_remap_file_pages, sys_remap_file_pages) #define __NR_mbind 235 __SYSCALL(__NR_mbind, sys_mbind) #define __NR_get_mempolicy 236 __SYSCALL(__NR_get_mempolicy, sys_get_mempolicy) #define __NR_set_mempolicy 237 __SYSCALL(__NR_set_mempolicy, sys_set_mempolicy) #define __NR_migrate_pages 238 __SYSCALL(__NR_migrate_pages, sys_migrate_pages) #define __NR_move_pages 239 __SYSCALL(__NR_move_pages, sys_move_pages) #endif #define __NR_rt_tgsigqueueinfo 240 __SC_COMP(__NR_rt_tgsigqueueinfo, sys_rt_tgsigqueueinfo, \ compat_sys_rt_tgsigqueueinfo) #define __NR_perf_event_open 241 __SYSCALL(__NR_perf_event_open, sys_perf_event_open) #define __NR_accept4 242 __SYSCALL(__NR_accept4, sys_accept4) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_recvmmsg 243 __SC_COMP_3264(__NR_recvmmsg, sys_recvmmsg_time32, sys_recvmmsg, compat_sys_recvmmsg_time32) #endif /* * Architectures may provide up to 16 syscalls of their own * starting with this value. */ #define __NR_arch_specific_syscall 244 #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_wait4 260 __SC_COMP(__NR_wait4, sys_wait4, compat_sys_wait4) #endif #define __NR_prlimit64 261 __SYSCALL(__NR_prlimit64, sys_prlimit64) #define __NR_fanotify_init 262 __SYSCALL(__NR_fanotify_init, sys_fanotify_init) #define __NR_fanotify_mark 263 __SYSCALL(__NR_fanotify_mark, sys_fanotify_mark) #define __NR_name_to_handle_at 264 __SYSCALL(__NR_name_to_handle_at, sys_name_to_handle_at) #define __NR_open_by_handle_at 265 __SYSCALL(__NR_open_by_handle_at, sys_open_by_handle_at) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_clock_adjtime 266 __SC_3264(__NR_clock_adjtime, sys_clock_adjtime32, sys_clock_adjtime) #endif #define __NR_syncfs 267 __SYSCALL(__NR_syncfs, sys_syncfs) #define __NR_setns 268 __SYSCALL(__NR_setns, sys_setns) #define __NR_sendmmsg 269 __SC_COMP(__NR_sendmmsg, sys_sendmmsg, compat_sys_sendmmsg) #define __NR_process_vm_readv 270 __SYSCALL(__NR_process_vm_readv, sys_process_vm_readv) #define __NR_process_vm_writev 271 __SYSCALL(__NR_process_vm_writev, sys_process_vm_writev) #define __NR_kcmp 272 __SYSCALL(__NR_kcmp, sys_kcmp) #define __NR_finit_module 273 __SYSCALL(__NR_finit_module, sys_finit_module) #define __NR_sched_setattr 274 __SYSCALL(__NR_sched_setattr, sys_sched_setattr) #define __NR_sched_getattr 275 __SYSCALL(__NR_sched_getattr, sys_sched_getattr) #define __NR_renameat2 276 __SYSCALL(__NR_renameat2, sys_renameat2) #define __NR_seccomp 277 __SYSCALL(__NR_seccomp, sys_seccomp) #define __NR_getrandom 278 __SYSCALL(__NR_getrandom, sys_getrandom) #define __NR_memfd_create 279 __SYSCALL(__NR_memfd_create, sys_memfd_create) #define __NR_bpf 280 __SYSCALL(__NR_bpf, sys_bpf) #define __NR_execveat 281 __SC_COMP(__NR_execveat, sys_execveat, compat_sys_execveat) #define __NR_userfaultfd 282 __SYSCALL(__NR_userfaultfd, sys_userfaultfd) #define __NR_membarrier 283 __SYSCALL(__NR_membarrier, sys_membarrier) #define __NR_mlock2 284 __SYSCALL(__NR_mlock2, sys_mlock2) #define __NR_copy_file_range 285 __SYSCALL(__NR_copy_file_range, sys_copy_file_range) #define __NR_preadv2 286 __SC_COMP(__NR_preadv2, sys_preadv2, compat_sys_preadv2) #define __NR_pwritev2 287 __SC_COMP(__NR_pwritev2, sys_pwritev2, compat_sys_pwritev2) #define __NR_pkey_mprotect 288 __SYSCALL(__NR_pkey_mprotect, sys_pkey_mprotect) #define __NR_pkey_alloc 289 __SYSCALL(__NR_pkey_alloc, sys_pkey_alloc) #define __NR_pkey_free 290 __SYSCALL(__NR_pkey_free, sys_pkey_free) #define __NR_statx 291 __SYSCALL(__NR_statx, sys_statx) #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #define __NR_io_pgetevents 292 __SC_COMP_3264(__NR_io_pgetevents, sys_io_pgetevents_time32, sys_io_pgetevents, compat_sys_io_pgetevents) #endif #define __NR_rseq 293 __SYSCALL(__NR_rseq, sys_rseq) #define __NR_kexec_file_load 294 __SYSCALL(__NR_kexec_file_load, sys_kexec_file_load) /* 295 through 402 are unassigned to sync up with generic numbers, don't use */ #if defined(__SYSCALL_COMPAT) || __BITS_PER_LONG == 32 #define __NR_clock_gettime64 403 __SYSCALL(__NR_clock_gettime64, sys_clock_gettime) #define __NR_clock_settime64 404 __SYSCALL(__NR_clock_settime64, sys_clock_settime) #define __NR_clock_adjtime64 405 __SYSCALL(__NR_clock_adjtime64, sys_clock_adjtime) #define __NR_clock_getres_time64 406 __SYSCALL(__NR_clock_getres_time64, sys_clock_getres) #define __NR_clock_nanosleep_time64 407 __SYSCALL(__NR_clock_nanosleep_time64, sys_clock_nanosleep) #define __NR_timer_gettime64 408 __SYSCALL(__NR_timer_gettime64, sys_timer_gettime) #define __NR_timer_settime64 409 __SYSCALL(__NR_timer_settime64, sys_timer_settime) #define __NR_timerfd_gettime64 410 __SYSCALL(__NR_timerfd_gettime64, sys_timerfd_gettime) #define __NR_timerfd_settime64 411 __SYSCALL(__NR_timerfd_settime64, sys_timerfd_settime) #define __NR_utimensat_time64 412 __SYSCALL(__NR_utimensat_time64, sys_utimensat) #define __NR_pselect6_time64 413 __SC_COMP(__NR_pselect6_time64, sys_pselect6, compat_sys_pselect6_time64) #define __NR_ppoll_time64 414 __SC_COMP(__NR_ppoll_time64, sys_ppoll, compat_sys_ppoll_time64) #define __NR_io_pgetevents_time64 416 __SYSCALL(__NR_io_pgetevents_time64, sys_io_pgetevents) #define __NR_recvmmsg_time64 417 __SC_COMP(__NR_recvmmsg_time64, sys_recvmmsg, compat_sys_recvmmsg_time64) #define __NR_mq_timedsend_time64 418 __SYSCALL(__NR_mq_timedsend_time64, sys_mq_timedsend) #define __NR_mq_timedreceive_time64 419 __SYSCALL(__NR_mq_timedreceive_time64, sys_mq_timedreceive) #define __NR_semtimedop_time64 420 __SYSCALL(__NR_semtimedop_time64, sys_semtimedop) #define __NR_rt_sigtimedwait_time64 421 __SC_COMP(__NR_rt_sigtimedwait_time64, sys_rt_sigtimedwait, compat_sys_rt_sigtimedwait_time64) #define __NR_futex_time64 422 __SYSCALL(__NR_futex_time64, sys_futex) #define __NR_sched_rr_get_interval_time64 423 __SYSCALL(__NR_sched_rr_get_interval_time64, sys_sched_rr_get_interval) #endif #define __NR_pidfd_send_signal 424 __SYSCALL(__NR_pidfd_send_signal, sys_pidfd_send_signal) #define __NR_io_uring_setup 425 __SYSCALL(__NR_io_uring_setup, sys_io_uring_setup) #define __NR_io_uring_enter 426 __SYSCALL(__NR_io_uring_enter, sys_io_uring_enter) #define __NR_io_uring_register 427 __SYSCALL(__NR_io_uring_register, sys_io_uring_register) #define __NR_open_tree 428 __SYSCALL(__NR_open_tree, sys_open_tree) #define __NR_move_mount 429 __SYSCALL(__NR_move_mount, sys_move_mount) #define __NR_fsopen 430 __SYSCALL(__NR_fsopen, sys_fsopen) #define __NR_fsconfig 431 __SYSCALL(__NR_fsconfig, sys_fsconfig) #define __NR_fsmount 432 __SYSCALL(__NR_fsmount, sys_fsmount) #define __NR_fspick 433 __SYSCALL(__NR_fspick, sys_fspick) #define __NR_pidfd_open 434 __SYSCALL(__NR_pidfd_open, sys_pidfd_open) #ifdef __ARCH_WANT_SYS_CLONE3 #define __NR_clone3 435 __SYSCALL(__NR_clone3, sys_clone3) #endif #define __NR_close_range 436 __SYSCALL(__NR_close_range, sys_close_range) #define __NR_openat2 437 __SYSCALL(__NR_openat2, sys_openat2) #define __NR_pidfd_getfd 438 __SYSCALL(__NR_pidfd_getfd, sys_pidfd_getfd) #define __NR_faccessat2 439 __SYSCALL(__NR_faccessat2, sys_faccessat2) #define __NR_process_madvise 440 __SYSCALL(__NR_process_madvise, sys_process_madvise) #define __NR_epoll_pwait2 441 __SC_COMP(__NR_epoll_pwait2, sys_epoll_pwait2, compat_sys_epoll_pwait2) #define __NR_mount_setattr 442 __SYSCALL(__NR_mount_setattr, sys_mount_setattr) #define __NR_quotactl_fd 443 __SYSCALL(__NR_quotactl_fd, sys_quotactl_fd) #define __NR_landlock_create_ruleset 444 __SYSCALL(__NR_landlock_create_ruleset, sys_landlock_create_ruleset) #define __NR_landlock_add_rule 445 __SYSCALL(__NR_landlock_add_rule, sys_landlock_add_rule) #define __NR_landlock_restrict_self 446 __SYSCALL(__NR_landlock_restrict_self, sys_landlock_restrict_self) #ifdef __ARCH_WANT_MEMFD_SECRET #define __NR_memfd_secret 447 __SYSCALL(__NR_memfd_secret, sys_memfd_secret) #endif #define __NR_process_mrelease 448 __SYSCALL(__NR_process_mrelease, sys_process_mrelease) #define __NR_futex_waitv 449 __SYSCALL(__NR_futex_waitv, sys_futex_waitv) #define __NR_set_mempolicy_home_node 450 __SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node) #define __NR_cachestat 451 __SYSCALL(__NR_cachestat, sys_cachestat) #define __NR_fchmodat2 452 __SYSCALL(__NR_fchmodat2, sys_fchmodat2) #define __NR_map_shadow_stack 453 __SYSCALL(__NR_map_shadow_stack, sys_map_shadow_stack) #define __NR_futex_wake 454 __SYSCALL(__NR_futex_wake, sys_futex_wake) #define __NR_futex_wait 455 __SYSCALL(__NR_futex_wait, sys_futex_wait) #define __NR_futex_requeue 456 __SYSCALL(__NR_futex_requeue, sys_futex_requeue) #undef __NR_syscalls #define __NR_syscalls 457 /* * 32 bit systems traditionally used different * syscalls for off_t and loff_t arguments, while * 64 bit systems only need the off_t version. * For new 32 bit platforms, there is no need to * implement the old 32 bit off_t syscalls, so * they take different names. * Here we map the numbers so that both versions * use the same syscall table layout. */ #if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT) #define __NR_fcntl __NR3264_fcntl #define __NR_statfs __NR3264_statfs #define __NR_fstatfs __NR3264_fstatfs #define __NR_truncate __NR3264_truncate #define __NR_ftruncate __NR3264_ftruncate #define __NR_lseek __NR3264_lseek #define __NR_sendfile __NR3264_sendfile #if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64) #define __NR_newfstatat __NR3264_fstatat #define __NR_fstat __NR3264_fstat #endif #define __NR_mmap __NR3264_mmap #define __NR_fadvise64 __NR3264_fadvise64 #ifdef __NR3264_stat #define __NR_stat __NR3264_stat #define __NR_lstat __NR3264_lstat #endif #else #define __NR_fcntl64 __NR3264_fcntl #define __NR_statfs64 __NR3264_statfs #define __NR_fstatfs64 __NR3264_fstatfs #define __NR_truncate64 __NR3264_truncate #define __NR_ftruncate64 __NR3264_ftruncate #define __NR_llseek __NR3264_lseek #define __NR_sendfile64 __NR3264_sendfile #if defined(__ARCH_WANT_NEW_STAT) || defined(__ARCH_WANT_STAT64) #define __NR_fstatat64 __NR3264_fstatat #define __NR_fstat64 __NR3264_fstat #endif #define __NR_mmap2 __NR3264_mmap #define __NR_fadvise64_64 __NR3264_fadvise64 #ifdef __NR3264_stat #define __NR_stat64 __NR3264_stat #define __NR_lstat64 __NR3264_lstat #endif #endif /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_PARAM_H #define __ASM_GENERIC_PARAM_H #ifndef HZ #define HZ 100 #endif #ifndef EXEC_PAGESIZE #define EXEC_PAGESIZE 4096 #endif #ifndef NOGROUP #define NOGROUP (-1) #endif #define MAXHOSTNAMELEN 64 /* max length of hostname */ #endif /* __ASM_GENERIC_PARAM_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_STAT_H #define __ASM_GENERIC_STAT_H /* * Everybody gets this wrong and has to stick with it for all * eternity. Hopefully, this version gets used by new architectures * so they don't fall into the same traps. * * stat64 is copied from powerpc64, with explicit padding added. * stat is the same structure layout on 64-bit, without the 'long long' * types. * * By convention, 64 bit architectures use the stat interface, while * 32 bit architectures use the stat64 interface. Note that we don't * provide an __old_kernel_stat here, which new architecture should * not have to start with. */ #include <asm/bitsperlong.h> #define STAT_HAVE_NSEC 1 struct stat { unsigned long st_dev; /* Device. */ unsigned long st_ino; /* File serial number. */ unsigned int st_mode; /* File mode. */ unsigned int st_nlink; /* Link count. */ unsigned int st_uid; /* User ID of the file's owner. */ unsigned int st_gid; /* Group ID of the file's group. */ unsigned long st_rdev; /* Device number, if device. */ unsigned long __pad1; long st_size; /* Size of file, in bytes. */ int st_blksize; /* Optimal block size for I/O. */ int __pad2; long st_blocks; /* Number 512-byte blocks allocated. */ long st_atime; /* Time of last access. */ unsigned long st_atime_nsec; long st_mtime; /* Time of last modification. */ unsigned long st_mtime_nsec; long st_ctime; /* Time of last status change. */ unsigned long st_ctime_nsec; unsigned int __unused4; unsigned int __unused5; }; /* This matches struct stat64 in glibc2.1. Only used for 32 bit. */ #if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64) struct stat64 { unsigned long long st_dev; /* Device. */ unsigned long long st_ino; /* File serial number. */ unsigned int st_mode; /* File mode. */ unsigned int st_nlink; /* Link count. */ unsigned int st_uid; /* User ID of the file's owner. */ unsigned int st_gid; /* Group ID of the file's group. */ unsigned long long st_rdev; /* Device number, if device. */ unsigned long long __pad1; long long st_size; /* Size of file, in bytes. */ int st_blksize; /* Optimal block size for I/O. */ int __pad2; long long st_blocks; /* Number 512-byte blocks allocated. */ int st_atime; /* Time of last access. */ unsigned int st_atime_nsec; int st_mtime; /* Time of last modification. */ unsigned int st_mtime_nsec; int st_ctime; /* Time of last status change. */ unsigned int st_ctime_nsec; unsigned int __unused4; unsigned int __unused5; }; #endif #endif /* __ASM_GENERIC_STAT_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_SOCKIOS_H #define __ASM_GENERIC_SOCKIOS_H /* Socket-level I/O control calls. */ #define FIOSETOWN 0x8901 #define SIOCSPGRP 0x8902 #define FIOGETOWN 0x8903 #define SIOCGPGRP 0x8904 #define SIOCATMARK 0x8905 #define SIOCGSTAMP_OLD 0x8906 /* Get stamp (timeval) */ #define SIOCGSTAMPNS_OLD 0x8907 /* Get stamp (timespec) */ #endif /* __ASM_GENERIC_SOCKIOS_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_SIGNAL_DEFS_H #define __ASM_GENERIC_SIGNAL_DEFS_H /* * SA_FLAGS values: * * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. * SA_SIGINFO delivers the signal with SIGINFO structs. * SA_ONSTACK indicates that a registered stack_t will be used. * SA_RESTART flag to get restarting signals (which were the default long ago) * SA_NODEFER prevents the current signal from being masked in the handler. * SA_RESETHAND clears the handler when the signal is delivered. * SA_UNSUPPORTED is a flag bit that will never be supported. Kernels from * before the introduction of SA_UNSUPPORTED did not clear unknown bits from * sa_flags when read using the oldact argument to sigaction and rt_sigaction, * so this bit allows flag bit support to be detected from userspace while * allowing an old kernel to be distinguished from a kernel that supports every * flag bit. * SA_EXPOSE_TAGBITS exposes an architecture-defined set of tag bits in * siginfo.si_addr. * * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single * Unix names RESETHAND and NODEFER respectively. */ #ifndef SA_NOCLDSTOP #define SA_NOCLDSTOP 0x00000001 #endif #ifndef SA_NOCLDWAIT #define SA_NOCLDWAIT 0x00000002 #endif #ifndef SA_SIGINFO #define SA_SIGINFO 0x00000004 #endif /* 0x00000008 used on alpha, mips, parisc */ /* 0x00000010 used on alpha, parisc */ /* 0x00000020 used on alpha, parisc, sparc */ /* 0x00000040 used on alpha, parisc */ /* 0x00000080 used on parisc */ /* 0x00000100 used on sparc */ /* 0x00000200 used on sparc */ #define SA_UNSUPPORTED 0x00000400 #define SA_EXPOSE_TAGBITS 0x00000800 /* 0x00010000 used on mips */ /* 0x00800000 used for internal SA_IMMUTABLE */ /* 0x01000000 used on x86 */ /* 0x02000000 used on x86 */ /* * New architectures should not define the obsolete * SA_RESTORER 0x04000000 */ #ifndef SA_ONSTACK #define SA_ONSTACK 0x08000000 #endif #ifndef SA_RESTART #define SA_RESTART 0x10000000 #endif #ifndef SA_NODEFER #define SA_NODEFER 0x40000000 #endif #ifndef SA_RESETHAND #define SA_RESETHAND 0x80000000 #endif #define SA_NOMASK SA_NODEFER #define SA_ONESHOT SA_RESETHAND #ifndef SIG_BLOCK #define SIG_BLOCK 0 /* for blocking signals */ #endif #ifndef SIG_UNBLOCK #define SIG_UNBLOCK 1 /* for unblocking signals */ #endif #ifndef SIG_SETMASK #define SIG_SETMASK 2 /* for setting the signal mask */ #endif #ifndef __ASSEMBLY__ typedef void __signalfn_t(int); typedef __signalfn_t *__sighandler_t; typedef void __restorefn_t(void); typedef __restorefn_t *__sigrestore_t; #define SIG_DFL ((__sighandler_t)0) /* default signal handling */ #define SIG_IGN ((__sighandler_t)1) /* ignore signal */ #define SIG_ERR ((__sighandler_t)-1) /* error return from signal */ #endif #endif /* __ASM_GENERIC_SIGNAL_DEFS_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_SWAB_H #define _ASM_GENERIC_SWAB_H #include <asm/bitsperlong.h> /* * 32 bit architectures typically (but not always) want to * set __SWAB_64_THRU_32__. In user space, this is only * valid if the compiler supports 64 bit data types. */ #if __BITS_PER_LONG == 32 #if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__) #define __SWAB_64_THRU_32__ #endif #endif #endif /* _ASM_GENERIC_SWAB_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_TERMBITS_H #define __ASM_GENERIC_TERMBITS_H #include <linux/posix_types.h> #include <asm-generic/termbits-common.h> typedef unsigned int tcflag_t; #define NCCS 19 struct termios { tcflag_t c_iflag; /* input mode flags */ tcflag_t c_oflag; /* output mode flags */ tcflag_t c_cflag; /* control mode flags */ tcflag_t c_lflag; /* local mode flags */ cc_t c_line; /* line discipline */ cc_t c_cc[NCCS]; /* control characters */ }; struct termios2 { tcflag_t c_iflag; /* input mode flags */ tcflag_t c_oflag; /* output mode flags */ tcflag_t c_cflag; /* control mode flags */ tcflag_t c_lflag; /* local mode flags */ cc_t c_line; /* line discipline */ cc_t c_cc[NCCS]; /* control characters */ speed_t c_ispeed; /* input speed */ speed_t c_ospeed; /* output speed */ }; struct ktermios { tcflag_t c_iflag; /* input mode flags */ tcflag_t c_oflag; /* output mode flags */ tcflag_t c_cflag; /* control mode flags */ tcflag_t c_lflag; /* local mode flags */ cc_t c_line; /* line discipline */ cc_t c_cc[NCCS]; /* control characters */ speed_t c_ispeed; /* input speed */ speed_t c_ospeed; /* output speed */ }; /* c_cc characters */ #define VINTR 0 #define VQUIT 1 #define VERASE 2 #define VKILL 3 #define VEOF 4 #define VTIME 5 #define VMIN 6 #define VSWTC 7 #define VSTART 8 #define VSTOP 9 #define VSUSP 10 #define VEOL 11 #define VREPRINT 12 #define VDISCARD 13 #define VWERASE 14 #define VLNEXT 15 #define VEOL2 16 /* c_iflag bits */ #define IUCLC 0x00200 #define IXON 0x00400 #define IXOFF 0x01000 #define IMAXBEL 0x02000 #define IUTF8 0x04000 /* c_oflag bits */ #define OLCUC 0x00002 #define ONLCR 0x00004 #define NLDLY 0x00100 #define NL0 0x00000 #define NL1 0x00100 #define CRDLY 0x00600 #define CR0 0x00000 #define CR1 0x00200 #define CR2 0x00400 #define CR3 0x00600 #define TABDLY 0x01800 #define TAB0 0x00000 #define TAB1 0x00800 #define TAB2 0x01000 #define TAB3 0x01800 #define XTABS 0x01800 #define BSDLY 0x02000 #define BS0 0x00000 #define BS1 0x02000 #define VTDLY 0x04000 #define VT0 0x00000 #define VT1 0x04000 #define FFDLY 0x08000 #define FF0 0x00000 #define FF1 0x08000 /* c_cflag bit meaning */ #define CBAUD 0x0000100f #define CSIZE 0x00000030 #define CS5 0x00000000 #define CS6 0x00000010 #define CS7 0x00000020 #define CS8 0x00000030 #define CSTOPB 0x00000040 #define CREAD 0x00000080 #define PARENB 0x00000100 #define PARODD 0x00000200 #define HUPCL 0x00000400 #define CLOCAL 0x00000800 #define CBAUDEX 0x00001000 #define BOTHER 0x00001000 #define B57600 0x00001001 #define B115200 0x00001002 #define B230400 0x00001003 #define B460800 0x00001004 #define B500000 0x00001005 #define B576000 0x00001006 #define B921600 0x00001007 #define B1000000 0x00001008 #define B1152000 0x00001009 #define B1500000 0x0000100a #define B2000000 0x0000100b #define B2500000 0x0000100c #define B3000000 0x0000100d #define B3500000 0x0000100e #define B4000000 0x0000100f #define CIBAUD 0x100f0000 /* input baud rate */ /* c_lflag bits */ #define ISIG 0x00001 #define ICANON 0x00002 #define XCASE 0x00004 #define ECHO 0x00008 #define ECHOE 0x00010 #define ECHOK 0x00020 #define ECHONL 0x00040 #define NOFLSH 0x00080 #define TOSTOP 0x00100 #define ECHOCTL 0x00200 #define ECHOPRT 0x00400 #define ECHOKE 0x00800 #define FLUSHO 0x01000 #define PENDIN 0x04000 #define IEXTEN 0x08000 #define EXTPROC 0x10000 /* tcsetattr uses these */ #define TCSANOW 0 #define TCSADRAIN 1 #define TCSAFLUSH 2 #endif /* __ASM_GENERIC_TERMBITS_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_IOCTL_H #define _ASM_GENERIC_IOCTL_H /* ioctl command encoding: 32 bits total, command in lower 16 bits, * size of the parameter structure in the lower 14 bits of the * upper 16 bits. * Encoding the size of the parameter structure in the ioctl request * is useful for catching programs compiled with old versions * and to avoid overwriting user space outside the user buffer area. * The highest 2 bits are reserved for indicating the ``access mode''. * NOTE: This limits the max parameter size to 16kB -1 ! */ /* * The following is for compatibility across the various Linux * platforms. The generic ioctl numbering scheme doesn't really enforce * a type field. De facto, however, the top 8 bits of the lower 16 * bits are indeed used as a type field, so we might just as well make * this explicit here. Please be sure to use the decoding macros * below from now on. */ #define _IOC_NRBITS 8 #define _IOC_TYPEBITS 8 /* * Let any architecture override either of the following before * including this file. */ #ifndef _IOC_SIZEBITS # define _IOC_SIZEBITS 14 #endif #ifndef _IOC_DIRBITS # define _IOC_DIRBITS 2 #endif #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) #define _IOC_NRSHIFT 0 #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) /* * Direction bits, which any architecture can choose to override * before including this file. * * NOTE: _IOC_WRITE means userland is writing and kernel is * reading. _IOC_READ means userland is reading and kernel is writing. */ #ifndef _IOC_NONE # define _IOC_NONE 0U #endif #ifndef _IOC_WRITE # define _IOC_WRITE 1U #endif #ifndef _IOC_READ # define _IOC_READ 2U #endif #define _IOC(dir,type,nr,size) \ (((dir) << _IOC_DIRSHIFT) | \ ((type) << _IOC_TYPESHIFT) | \ ((nr) << _IOC_NRSHIFT) | \ ((size) << _IOC_SIZESHIFT)) #define _IOC_TYPECHECK(t) (sizeof(t)) /* * Used to create numbers. * * NOTE: _IOW means userland is writing and kernel is reading. _IOR * means userland is reading and kernel is writing. */ #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) #define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size))) #define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) #define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) #define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) #define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) #define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) /* used to decode ioctl numbers.. */ #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) /* ...and for the drivers/sound files... */ #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) #define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) #define IOCSIZE_SHIFT (_IOC_SIZESHIFT) #endif /* _ASM_GENERIC_IOCTL_H */ #ifndef __ASM_GENERIC_BPF_PERF_EVENT_H__ #define __ASM_GENERIC_BPF_PERF_EVENT_H__ #include <linux/ptrace.h> /* Export kernel pt_regs structure */ typedef struct pt_regs bpf_user_pt_regs_t; #endif /* __ASM_GENERIC_BPF_PERF_EVENT_H__ */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_POLL_H #define __ASM_GENERIC_POLL_H /* These are specified by iBCS2 */ #define POLLIN 0x0001 #define POLLPRI 0x0002 #define POLLOUT 0x0004 #define POLLERR 0x0008 #define POLLHUP 0x0010 #define POLLNVAL 0x0020 /* The rest seem to be more-or-less nonstandard. Check them! */ #define POLLRDNORM 0x0040 #define POLLRDBAND 0x0080 #ifndef POLLWRNORM #define POLLWRNORM 0x0100 #endif #ifndef POLLWRBAND #define POLLWRBAND 0x0200 #endif #ifndef POLLMSG #define POLLMSG 0x0400 #endif #ifndef POLLREMOVE #define POLLREMOVE 0x1000 #endif #ifndef POLLRDHUP #define POLLRDHUP 0x2000 #endif #define POLLFREE (__poll_t)0x4000 #define POLL_BUSY_LOOP (__poll_t)0x8000 struct pollfd { int fd; short events; short revents; }; #endif /* __ASM_GENERIC_POLL_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_TYPES_H #define _ASM_GENERIC_TYPES_H /* * int-ll64 is used everywhere now. */ #include <asm-generic/int-ll64.h> #endif /* _ASM_GENERIC_TYPES_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_TERMIOS_H #define _ASM_GENERIC_TERMIOS_H /* * Most architectures have straight copies of the x86 code, with * varying levels of bug fixes on top. Usually it's a good idea * to use this generic version instead, but be careful to avoid * ABI changes. * New architectures should not provide their own version. */ #include <asm/termbits.h> #include <asm/ioctls.h> struct winsize { unsigned short ws_row; unsigned short ws_col; unsigned short ws_xpixel; unsigned short ws_ypixel; }; #define NCC 8 struct termio { unsigned short c_iflag; /* input mode flags */ unsigned short c_oflag; /* output mode flags */ unsigned short c_cflag; /* control mode flags */ unsigned short c_lflag; /* local mode flags */ unsigned char c_line; /* line discipline */ unsigned char c_cc[NCC]; /* control characters */ }; /* modem lines */ #define TIOCM_LE 0x001 #define TIOCM_DTR 0x002 #define TIOCM_RTS 0x004 #define TIOCM_ST 0x008 #define TIOCM_SR 0x010 #define TIOCM_CTS 0x020 #define TIOCM_CAR 0x040 #define TIOCM_RNG 0x080 #define TIOCM_DSR 0x100 #define TIOCM_CD TIOCM_CAR #define TIOCM_RI TIOCM_RNG #define TIOCM_OUT1 0x2000 #define TIOCM_OUT2 0x4000 #define TIOCM_LOOP 0x8000 /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ #endif /* _ASM_GENERIC_TERMIOS_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_SIGNAL_H #define __ASM_GENERIC_SIGNAL_H #include <linux/types.h> #define _NSIG 64 #define _NSIG_BPW __BITS_PER_LONG #define _NSIG_WORDS (_NSIG / _NSIG_BPW) #define SIGHUP 1 #define SIGINT 2 #define SIGQUIT 3 #define SIGILL 4 #define SIGTRAP 5 #define SIGABRT 6 #define SIGIOT 6 #define SIGBUS 7 #define SIGFPE 8 #define SIGKILL 9 #define SIGUSR1 10 #define SIGSEGV 11 #define SIGUSR2 12 #define SIGPIPE 13 #define SIGALRM 14 #define SIGTERM 15 #define SIGSTKFLT 16 #define SIGCHLD 17 #define SIGCONT 18 #define SIGSTOP 19 #define SIGTSTP 20 #define SIGTTIN 21 #define SIGTTOU 22 #define SIGURG 23 #define SIGXCPU 24 #define SIGXFSZ 25 #define SIGVTALRM 26 #define SIGPROF 27 #define SIGWINCH 28 #define SIGIO 29 #define SIGPOLL SIGIO /* #define SIGLOST 29 */ #define SIGPWR 30 #define SIGSYS 31 #define SIGUNUSED 31 /* These should not be considered constants from userland. */ #define SIGRTMIN 32 #ifndef SIGRTMAX #define SIGRTMAX _NSIG #endif #if !defined MINSIGSTKSZ || !defined SIGSTKSZ #define MINSIGSTKSZ 2048 #define SIGSTKSZ 8192 #endif #ifndef __ASSEMBLY__ typedef struct { unsigned long sig[_NSIG_WORDS]; } sigset_t; /* not actually used, but required for linux/syscalls.h */ typedef unsigned long old_sigset_t; #include <asm-generic/signal-defs.h> #ifdef SA_RESTORER #define __ARCH_HAS_SA_RESTORER #endif struct sigaction { __sighandler_t sa_handler; unsigned long sa_flags; #ifdef SA_RESTORER __sigrestore_t sa_restorer; #endif sigset_t sa_mask; /* mask last for extensibility */ }; typedef struct sigaltstack { void *ss_sp; int ss_flags; __kernel_size_t ss_size; } stack_t; #endif /* __ASSEMBLY__ */ #endif /* __ASM_GENERIC_SIGNAL_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_MSGBUF_H #define __ASM_GENERIC_MSGBUF_H #include <asm/bitsperlong.h> #include <asm/ipcbuf.h> /* * generic msqid64_ds structure. * * Note extra padding because this structure is passed back and forth * between kernel and user space. * * msqid64_ds was originally meant to be architecture specific, but * everyone just ended up making identical copies without specific * optimizations, so we may just as well all use the same one. * * 64 bit architectures use a 64-bit long time field here, while * 32 bit architectures have a pair of unsigned long values. * On big-endian systems, the lower half is in the wrong place. * * Pad space is left for: * - 2 miscellaneous 32-bit values */ struct msqid64_ds { struct ipc64_perm msg_perm; #if __BITS_PER_LONG == 64 long msg_stime; /* last msgsnd time */ long msg_rtime; /* last msgrcv time */ long msg_ctime; /* last change time */ #else unsigned long msg_stime; /* last msgsnd time */ unsigned long msg_stime_high; unsigned long msg_rtime; /* last msgrcv time */ unsigned long msg_rtime_high; unsigned long msg_ctime; /* last change time */ unsigned long msg_ctime_high; #endif unsigned long msg_cbytes; /* current number of bytes on queue */ unsigned long msg_qnum; /* number of messages in queue */ unsigned long msg_qbytes; /* max number of bytes on queue */ __kernel_pid_t msg_lspid; /* pid of last msgsnd */ __kernel_pid_t msg_lrpid; /* last receive pid */ unsigned long __unused4; unsigned long __unused5; }; #endif /* __ASM_GENERIC_MSGBUF_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_FCNTL_H #define _ASM_GENERIC_FCNTL_H #include <linux/types.h> /* * FMODE_EXEC is 0x20 * FMODE_NONOTIFY is 0x4000000 * These cannot be used by userspace O_* until internal and external open * flags are split. * -Eric Paris */ /* * When introducing new O_* bits, please check its uniqueness in fcntl_init(). */ #define O_ACCMODE 00000003 #define O_RDONLY 00000000 #define O_WRONLY 00000001 #define O_RDWR 00000002 #ifndef O_CREAT #define O_CREAT 00000100 /* not fcntl */ #endif #ifndef O_EXCL #define O_EXCL 00000200 /* not fcntl */ #endif #ifndef O_NOCTTY #define O_NOCTTY 00000400 /* not fcntl */ #endif #ifndef O_TRUNC #define O_TRUNC 00001000 /* not fcntl */ #endif #ifndef O_APPEND #define O_APPEND 00002000 #endif #ifndef O_NONBLOCK #define O_NONBLOCK 00004000 #endif #ifndef O_DSYNC #define O_DSYNC 00010000 /* used to be O_SYNC, see below */ #endif #ifndef FASYNC #define FASYNC 00020000 /* fcntl, for BSD compatibility */ #endif #ifndef O_DIRECT #define O_DIRECT 00040000 /* direct disk access hint */ #endif #ifndef O_LARGEFILE #define O_LARGEFILE 00100000 #endif #ifndef O_DIRECTORY #define O_DIRECTORY 00200000 /* must be a directory */ #endif #ifndef O_NOFOLLOW #define O_NOFOLLOW 00400000 /* don't follow links */ #endif #ifndef O_NOATIME #define O_NOATIME 01000000 #endif #ifndef O_CLOEXEC #define O_CLOEXEC 02000000 /* set close_on_exec */ #endif /* * Before Linux 2.6.33 only O_DSYNC semantics were implemented, but using * the O_SYNC flag. We continue to use the existing numerical value * for O_DSYNC semantics now, but using the correct symbolic name for it. * This new value is used to request true Posix O_SYNC semantics. It is * defined in this strange way to make sure applications compiled against * new headers get at least O_DSYNC semantics on older kernels. * * This has the nice side-effect that we can simply test for O_DSYNC * wherever we do not care if O_DSYNC or O_SYNC is used. * * Note: __O_SYNC must never be used directly. */ #ifndef O_SYNC #define __O_SYNC 04000000 #define O_SYNC (__O_SYNC|O_DSYNC) #endif #ifndef O_PATH #define O_PATH 010000000 #endif #ifndef __O_TMPFILE #define __O_TMPFILE 020000000 #endif /* a horrid kludge trying to make sure that this will fail on old kernels */ #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY) #define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT) #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK #endif #define F_DUPFD 0 /* dup */ #define F_GETFD 1 /* get close_on_exec */ #define F_SETFD 2 /* set/clear close_on_exec */ #define F_GETFL 3 /* get file->f_flags */ #define F_SETFL 4 /* set file->f_flags */ #ifndef F_GETLK #define F_GETLK 5 #define F_SETLK 6 #define F_SETLKW 7 #endif #ifndef F_SETOWN #define F_SETOWN 8 /* for sockets. */ #define F_GETOWN 9 /* for sockets. */ #endif #ifndef F_SETSIG #define F_SETSIG 10 /* for sockets. */ #define F_GETSIG 11 /* for sockets. */ #endif #if __BITS_PER_LONG == 32 || defined(__KERNEL__) #ifndef F_GETLK64 #define F_GETLK64 12 /* using 'struct flock64' */ #define F_SETLK64 13 #define F_SETLKW64 14 #endif #endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */ #ifndef F_SETOWN_EX #define F_SETOWN_EX 15 #define F_GETOWN_EX 16 #endif #ifndef F_GETOWNER_UIDS #define F_GETOWNER_UIDS 17 #endif /* * Open File Description Locks * * Usually record locks held by a process are released on *any* close and are * not inherited across a fork(). * * These cmd values will set locks that conflict with process-associated * record locks, but are "owned" by the open file description, not the * process. This means that they are inherited across fork() like BSD (flock) * locks, and they are only released automatically when the last reference to * the the open file against which they were acquired is put. */ #define F_OFD_GETLK 36 #define F_OFD_SETLK 37 #define F_OFD_SETLKW 38 #define F_OWNER_TID 0 #define F_OWNER_PID 1 #define F_OWNER_PGRP 2 struct f_owner_ex { int type; __kernel_pid_t pid; }; /* for F_[GET|SET]FL */ #define FD_CLOEXEC 1 /* actually anything with low bit set goes */ /* for posix fcntl() and lockf() */ #ifndef F_RDLCK #define F_RDLCK 0 #define F_WRLCK 1 #define F_UNLCK 2 #endif /* for old implementation of bsd flock () */ #ifndef F_EXLCK #define F_EXLCK 4 /* or 3 */ #define F_SHLCK 8 /* or 4 */ #endif /* operations for bsd flock(), also used by the kernel implementation */ #define LOCK_SH 1 /* shared lock */ #define LOCK_EX 2 /* exclusive lock */ #define LOCK_NB 4 /* or'd with one of the above to prevent blocking */ #define LOCK_UN 8 /* remove lock */ /* * LOCK_MAND support has been removed from the kernel. We leave the symbols * here to not break legacy builds, but these should not be used in new code. */ #define LOCK_MAND 32 /* This is a mandatory flock ... */ #define LOCK_READ 64 /* which allows concurrent read operations */ #define LOCK_WRITE 128 /* which allows concurrent write operations */ #define LOCK_RW 192 /* which allows concurrent read & write ops */ #define F_LINUX_SPECIFIC_BASE 1024 #ifndef HAVE_ARCH_STRUCT_FLOCK #ifndef __ARCH_FLOCK_PAD #define __ARCH_FLOCK_PAD #endif struct flock { short l_type; short l_whence; __kernel_off_t l_start; __kernel_off_t l_len; __kernel_pid_t l_pid; __ARCH_FLOCK_PAD }; #endif #ifndef HAVE_ARCH_STRUCT_FLOCK64 #ifndef __ARCH_FLOCK64_PAD #define __ARCH_FLOCK64_PAD #endif struct flock64 { short l_type; short l_whence; __kernel_loff_t l_start; __kernel_loff_t l_len; __kernel_pid_t l_pid; __ARCH_FLOCK64_PAD }; #endif #endif /* _ASM_GENERIC_FCNTL_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * asm-generic/int-l64.h * * Integer declarations for architectures which use "long" * for 64-bit types. */ #ifndef _ASM_GENERIC_INT_L64_H #define _ASM_GENERIC_INT_L64_H #include <asm/bitsperlong.h> #ifndef __ASSEMBLY__ /* * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the * header files exported to user space */ typedef __signed__ char __s8; typedef unsigned char __u8; typedef __signed__ short __s16; typedef unsigned short __u16; typedef __signed__ int __s32; typedef unsigned int __u32; typedef __signed__ long __s64; typedef unsigned long __u64; #endif /* __ASSEMBLY__ */ #endif /* _ASM_GENERIC_INT_L64_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_IOCTLS_H #define __ASM_GENERIC_IOCTLS_H #include <linux/ioctl.h> /* * These are the most common definitions for tty ioctl numbers. * Most of them do not use the recommended _IOC(), but there is * probably some source code out there hardcoding the number, * so we might as well use them for all new platforms. * * The architectures that use different values here typically * try to be compatible with some Unix variants for the same * architecture. */ /* 0x54 is just a magic number to make these relatively unique ('T') */ #define TCGETS 0x5401 #define TCSETS 0x5402 #define TCSETSW 0x5403 #define TCSETSF 0x5404 #define TCGETA 0x5405 #define TCSETA 0x5406 #define TCSETAW 0x5407 #define TCSETAF 0x5408 #define TCSBRK 0x5409 #define TCXONC 0x540A #define TCFLSH 0x540B #define TIOCEXCL 0x540C #define TIOCNXCL 0x540D #define TIOCSCTTY 0x540E #define TIOCGPGRP 0x540F #define TIOCSPGRP 0x5410 #define TIOCOUTQ 0x5411 #define TIOCSTI 0x5412 #define TIOCGWINSZ 0x5413 #define TIOCSWINSZ 0x5414 #define TIOCMGET 0x5415 #define TIOCMBIS 0x5416 #define TIOCMBIC 0x5417 #define TIOCMSET 0x5418 #define TIOCGSOFTCAR 0x5419 #define TIOCSSOFTCAR 0x541A #define FIONREAD 0x541B #define TIOCINQ FIONREAD #define TIOCLINUX 0x541C #define TIOCCONS 0x541D #define TIOCGSERIAL 0x541E #define TIOCSSERIAL 0x541F #define TIOCPKT 0x5420 #define FIONBIO 0x5421 #define TIOCNOTTY 0x5422 #define TIOCSETD 0x5423 #define TIOCGETD 0x5424 #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ #define TIOCSBRK 0x5427 /* BSD compatibility */ #define TIOCCBRK 0x5428 /* BSD compatibility */ #define TIOCGSID 0x5429 /* Return the session ID of FD */ #define TCGETS2 _IOR('T', 0x2A, struct termios2) #define TCSETS2 _IOW('T', 0x2B, struct termios2) #define TCSETSW2 _IOW('T', 0x2C, struct termios2) #define TCSETSF2 _IOW('T', 0x2D, struct termios2) #define TIOCGRS485 0x542E #ifndef TIOCSRS485 #define TIOCSRS485 0x542F #endif #define TIOCGPTN _IOR('T', 0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ #define TIOCSPTLCK _IOW('T', 0x31, int) /* Lock/unlock Pty */ #define TIOCGDEV _IOR('T', 0x32, unsigned int) /* Get primary device node of /dev/console */ #define TCGETX 0x5432 /* SYS5 TCGETX compatibility */ #define TCSETX 0x5433 #define TCSETXF 0x5434 #define TCSETXW 0x5435 #define TIOCSIG _IOW('T', 0x36, int) /* pty: generate signal */ #define TIOCVHANGUP 0x5437 #define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */ #define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */ #define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */ #define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */ #define TIOCGISO7816 _IOR('T', 0x42, struct serial_iso7816) #define TIOCSISO7816 _IOWR('T', 0x43, struct serial_iso7816) #define FIONCLEX 0x5450 #define FIOCLEX 0x5451 #define FIOASYNC 0x5452 #define TIOCSERCONFIG 0x5453 #define TIOCSERGWILD 0x5454 #define TIOCSERSWILD 0x5455 #define TIOCGLCKTRMIOS 0x5456 #define TIOCSLCKTRMIOS 0x5457 #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ #define TIOCSERGETLSR 0x5459 /* Get line status register */ #define TIOCSERGETMULTI 0x545A /* Get multiport config */ #define TIOCSERSETMULTI 0x545B /* Set multiport config */ #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ #define TIOCGICOUNT 0x545D /* read serial port __inline__ interrupt counts */ /* * Some arches already define FIOQSIZE due to a historical * conflict with a Hayes modem-specific ioctl value. */ #ifndef FIOQSIZE # define FIOQSIZE 0x5460 #endif /* Used for packet mode */ #define TIOCPKT_DATA 0 #define TIOCPKT_FLUSHREAD 1 #define TIOCPKT_FLUSHWRITE 2 #define TIOCPKT_STOP 4 #define TIOCPKT_START 8 #define TIOCPKT_NOSTOP 16 #define TIOCPKT_DOSTOP 32 #define TIOCPKT_IOCTL 64 #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ #endif /* __ASM_GENERIC_IOCTLS_H */ #ifndef __ASM_GENERIC_AUXVEC_H #define __ASM_GENERIC_AUXVEC_H /* * Not all architectures need their own auxvec.h, the most * common definitions are already in linux/auxvec.h. */ #endif /* __ASM_GENERIC_AUXVEC_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_ERRNO_H #define _ASM_GENERIC_ERRNO_H #include <asm-generic/errno-base.h> #define EDEADLK 35 /* Resource deadlock would occur */ #define ENAMETOOLONG 36 /* File name too long */ #define ENOLCK 37 /* No record locks available */ /* * This error code is special: arch syscall entry code will return * -ENOSYS if users try to call a syscall that doesn't exist. To keep * failures of syscalls that really do exist distinguishable from * failures due to attempts to use a nonexistent syscall, syscall * implementations should refrain from returning -ENOSYS. */ #define ENOSYS 38 /* Invalid system call number */ #define ENOTEMPTY 39 /* Directory not empty */ #define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define ENOMSG 42 /* No message of desired type */ #define EIDRM 43 /* Identifier removed */ #define ECHRNG 44 /* Channel number out of range */ #define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL3HLT 46 /* Level 3 halted */ #define EL3RST 47 /* Level 3 reset */ #define ELNRNG 48 /* Link number out of range */ #define EUNATCH 49 /* Protocol driver not attached */ #define ENOCSI 50 /* No CSI structure available */ #define EL2HLT 51 /* Level 2 halted */ #define EBADE 52 /* Invalid exchange */ #define EBADR 53 /* Invalid request descriptor */ #define EXFULL 54 /* Exchange full */ #define ENOANO 55 /* No anode */ #define EBADRQC 56 /* Invalid request code */ #define EBADSLT 57 /* Invalid slot */ #define EDEADLOCK EDEADLK #define EBFONT 59 /* Bad font file format */ #define ENOSTR 60 /* Device not a stream */ #define ENODATA 61 /* No data available */ #define ETIME 62 /* Timer expired */ #define ENOSR 63 /* Out of streams resources */ #define ENONET 64 /* Machine is not on the network */ #define ENOPKG 65 /* Package not installed */ #define EREMOTE 66 /* Object is remote */ #define ENOLINK 67 /* Link has been severed */ #define EADV 68 /* Advertise error */ #define ESRMNT 69 /* Srmount error */ #define ECOMM 70 /* Communication error on send */ #define EPROTO 71 /* Protocol error */ #define EMULTIHOP 72 /* Multihop attempted */ #define EDOTDOT 73 /* RFS specific error */ #define EBADMSG 74 /* Not a data message */ #define EOVERFLOW 75 /* Value too large for defined data type */ #define ENOTUNIQ 76 /* Name not unique on network */ #define EBADFD 77 /* File descriptor in bad state */ #define EREMCHG 78 /* Remote address changed */ #define ELIBACC 79 /* Can not access a needed shared library */ #define ELIBBAD 80 /* Accessing a corrupted shared library */ #define ELIBSCN 81 /* .lib section in a.out corrupted */ #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ #define ELIBEXEC 83 /* Cannot exec a shared library directly */ #define EILSEQ 84 /* Illegal byte sequence */ #define ERESTART 85 /* Interrupted system call should be restarted */ #define ESTRPIPE 86 /* Streams pipe error */ #define EUSERS 87 /* Too many users */ #define ENOTSOCK 88 /* Socket operation on non-socket */ #define EDESTADDRREQ 89 /* Destination address required */ #define EMSGSIZE 90 /* Message too long */ #define EPROTOTYPE 91 /* Protocol wrong type for socket */ #define ENOPROTOOPT 92 /* Protocol not available */ #define EPROTONOSUPPORT 93 /* Protocol not supported */ #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #define EPFNOSUPPORT 96 /* Protocol family not supported */ #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EADDRINUSE 98 /* Address already in use */ #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ #define ENETDOWN 100 /* Network is down */ #define ENETUNREACH 101 /* Network is unreachable */ #define ENETRESET 102 /* Network dropped connection because of reset */ #define ECONNABORTED 103 /* Software caused connection abort */ #define ECONNRESET 104 /* Connection reset by peer */ #define ENOBUFS 105 /* No buffer space available */ #define EISCONN 106 /* Transport endpoint is already connected */ #define ENOTCONN 107 /* Transport endpoint is not connected */ #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ #define ETOOMANYREFS 109 /* Too many references: cannot splice */ #define ETIMEDOUT 110 /* Connection timed out */ #define ECONNREFUSED 111 /* Connection refused */ #define EHOSTDOWN 112 /* Host is down */ #define EHOSTUNREACH 113 /* No route to host */ #define EALREADY 114 /* Operation already in progress */ #define EINPROGRESS 115 /* Operation now in progress */ #define ESTALE 116 /* Stale file handle */ #define EUCLEAN 117 /* Structure needs cleaning */ #define ENOTNAM 118 /* Not a XENIX named type file */ #define ENAVAIL 119 /* No XENIX semaphores available */ #define EISNAM 120 /* Is a named type file */ #define EREMOTEIO 121 /* Remote I/O error */ #define EDQUOT 122 /* Quota exceeded */ #define ENOMEDIUM 123 /* No medium found */ #define EMEDIUMTYPE 124 /* Wrong medium type */ #define ECANCELED 125 /* Operation Canceled */ #define ENOKEY 126 /* Required key not available */ #define EKEYEXPIRED 127 /* Key has expired */ #define EKEYREVOKED 128 /* Key has been revoked */ #define EKEYREJECTED 129 /* Key was rejected by service */ /* for robust mutexes */ #define EOWNERDEAD 130 /* Owner died */ #define ENOTRECOVERABLE 131 /* State not recoverable */ #define ERFKILL 132 /* Operation not possible due to RF-kill */ #define EHWPOISON 133 /* Memory page has hardware error */ #endif /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_SEMBUF_H #define __ASM_GENERIC_SEMBUF_H #include <asm/bitsperlong.h> #include <asm/ipcbuf.h> /* * The semid64_ds structure for most architectures (though it came from x86_32 * originally). Note extra padding because this structure is passed back and * forth between kernel and user space. * * semid64_ds was originally meant to be architecture specific, but * everyone just ended up making identical copies without specific * optimizations, so we may just as well all use the same one. * * 64 bit architectures use a 64-bit long time field here, while * 32 bit architectures have a pair of unsigned long values. * * On big-endian systems, the padding is in the wrong place for * historic reasons, so user space has to reconstruct a time_t * value using * * user_semid_ds.sem_otime = kernel_semid64_ds.sem_otime + * ((long long)kernel_semid64_ds.sem_otime_high << 32) * * Pad space is left for 2 miscellaneous 32-bit values */ struct semid64_ds { struct ipc64_perm sem_perm; /* permissions .. see ipc.h */ #if __BITS_PER_LONG == 64 long sem_otime; /* last semop time */ long sem_ctime; /* last change time */ #else unsigned long sem_otime; /* last semop time */ unsigned long sem_otime_high; unsigned long sem_ctime; /* last change time */ unsigned long sem_ctime_high; #endif unsigned long sem_nsems; /* no. of semaphores in array */ unsigned long __unused3; unsigned long __unused4; }; #endif /* __ASM_GENERIC_SEMBUF_H */ #ifndef _ASM_GENERIC_HUGETLB_ENCODE_H_ #define _ASM_GENERIC_HUGETLB_ENCODE_H_ /* * Several system calls take a flag to request "hugetlb" huge pages. * Without further specification, these system calls will use the * system's default huge page size. If a system supports multiple * huge page sizes, the desired huge page size can be specified in * bits [26:31] of the flag arguments. The value in these 6 bits * will encode the log2 of the huge page size. * * The following definitions are associated with this huge page size * encoding in flag arguments. System call specific header files * that use this encoding should include this file. They can then * provide definitions based on these with their own specific prefix. * for example: * #define MAP_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT */ #define HUGETLB_FLAG_ENCODE_SHIFT 26 #define HUGETLB_FLAG_ENCODE_MASK 0x3f #define HUGETLB_FLAG_ENCODE_16KB (14U << HUGETLB_FLAG_ENCODE_SHIFT) #define HUGETLB_FLAG_ENCODE_64KB (16U << HUGETLB_FLAG_ENCODE_SHIFT) #define HUGETLB_FLAG_ENCODE_512KB (19U << HUGETLB_FLAG_ENCODE_SHIFT) #define HUGETLB_FLAG_ENCODE_1MB (20U << HUGETLB_FLAG_ENCODE_SHIFT) #define HUGETLB_FLAG_ENCODE_2MB (21U << HUGETLB_FLAG_ENCODE_SHIFT) #define HUGETLB_FLAG_ENCODE_8MB (23U << HUGETLB_FLAG_ENCODE_SHIFT) #define HUGETLB_FLAG_ENCODE_16MB (24U << HUGETLB_FLAG_ENCODE_SHIFT) #define HUGETLB_FLAG_ENCODE_32MB (25U << HUGETLB_FLAG_ENCODE_SHIFT) #define HUGETLB_FLAG_ENCODE_256MB (28U << HUGETLB_FLAG_ENCODE_SHIFT) #define HUGETLB_FLAG_ENCODE_512MB (29U << HUGETLB_FLAG_ENCODE_SHIFT) #define HUGETLB_FLAG_ENCODE_1GB (30U << HUGETLB_FLAG_ENCODE_SHIFT) #define HUGETLB_FLAG_ENCODE_2GB (31U << HUGETLB_FLAG_ENCODE_SHIFT) #define HUGETLB_FLAG_ENCODE_16GB (34U << HUGETLB_FLAG_ENCODE_SHIFT) #endif /* _ASM_GENERIC_HUGETLB_ENCODE_H_ */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_BITS_PER_LONG #define __ASM_GENERIC_BITS_PER_LONG /* * There seems to be no way of detecting this automatically from user * space, so 64 bit architectures should override this in their * bitsperlong.h. In particular, an architecture that supports * both 32 and 64 bit user space must not rely on CONFIG_64BIT * to decide it, but rather check a compiler provided macro. */ #ifndef __BITS_PER_LONG #define __BITS_PER_LONG 32 #endif #ifndef __BITS_PER_LONG_LONG #define __BITS_PER_LONG_LONG 64 #endif #endif /* __ASM_GENERIC_BITS_PER_LONG */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_TERMBITS_COMMON_H #define __ASM_GENERIC_TERMBITS_COMMON_H typedef unsigned char cc_t; typedef unsigned int speed_t; /* c_iflag bits */ #define IGNBRK 0x001 /* Ignore break condition */ #define BRKINT 0x002 /* Signal interrupt on break */ #define IGNPAR 0x004 /* Ignore characters with parity errors */ #define PARMRK 0x008 /* Mark parity and framing errors */ #define INPCK 0x010 /* Enable input parity check */ #define ISTRIP 0x020 /* Strip 8th bit off characters */ #define INLCR 0x040 /* Map NL to CR on input */ #define IGNCR 0x080 /* Ignore CR */ #define ICRNL 0x100 /* Map CR to NL on input */ #define IXANY 0x800 /* Any character will restart after stop */ /* c_oflag bits */ #define OPOST 0x01 /* Perform output processing */ #define OCRNL 0x08 #define ONOCR 0x10 #define ONLRET 0x20 #define OFILL 0x40 #define OFDEL 0x80 /* c_cflag bit meaning */ /* Common CBAUD rates */ #define B0 0x00000000 /* hang up */ #define B50 0x00000001 #define B75 0x00000002 #define B110 0x00000003 #define B134 0x00000004 #define B150 0x00000005 #define B200 0x00000006 #define B300 0x00000007 #define B600 0x00000008 #define B1200 0x00000009 #define B1800 0x0000000a #define B2400 0x0000000b #define B4800 0x0000000c #define B9600 0x0000000d #define B19200 0x0000000e #define B38400 0x0000000f #define EXTA B19200 #define EXTB B38400 #define ADDRB 0x20000000 /* address bit */ #define CMSPAR 0x40000000 /* mark or space (stick) parity */ #define CRTSCTS 0x80000000 /* flow control */ #define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */ /* tcflow() ACTION argument and TCXONC use these */ #define TCOOFF 0 /* Suspend output */ #define TCOON 1 /* Restart suspended output */ #define TCIOFF 2 /* Send a STOP character */ #define TCION 3 /* Send a START character */ /* tcflush() QUEUE_SELECTOR argument and TCFLSH use these */ #define TCIFLUSH 0 /* Discard data received but not yet read */ #define TCOFLUSH 1 /* Discard data written but not yet sent */ #define TCIOFLUSH 2 /* Discard all pending data */ #endif /* __ASM_GENERIC_TERMBITS_COMMON_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _GENERIC_STATFS_H #define _GENERIC_STATFS_H #include <linux/types.h> /* * Most 64-bit platforms use 'long', while most 32-bit platforms use '__u32'. * Yes, they differ in signedness as well as size. * Special cases can override it for themselves -- except for S390x, which * is just a little too special for us. And MIPS, which I'm not touching * with a 10' pole. */ #ifndef __statfs_word #if __BITS_PER_LONG == 64 #define __statfs_word __kernel_long_t #else #define __statfs_word __u32 #endif #endif struct statfs { __statfs_word f_type; __statfs_word f_bsize; __statfs_word f_blocks; __statfs_word f_bfree; __statfs_word f_bavail; __statfs_word f_files; __statfs_word f_ffree; __kernel_fsid_t f_fsid; __statfs_word f_namelen; __statfs_word f_frsize; __statfs_word f_flags; __statfs_word f_spare[4]; }; /* * ARM needs to avoid the 32-bit padding at the end, for consistency * between EABI and OABI */ #ifndef ARCH_PACK_STATFS64 #define ARCH_PACK_STATFS64 #endif struct statfs64 { __statfs_word f_type; __statfs_word f_bsize; __u64 f_blocks; __u64 f_bfree; __u64 f_bavail; __u64 f_files; __u64 f_ffree; __kernel_fsid_t f_fsid; __statfs_word f_namelen; __statfs_word f_frsize; __statfs_word f_flags; __statfs_word f_spare[4]; } ARCH_PACK_STATFS64; /* * IA64 and x86_64 need to avoid the 32-bit padding at the end, * to be compatible with the i386 ABI */ #ifndef ARCH_PACK_COMPAT_STATFS64 #define ARCH_PACK_COMPAT_STATFS64 #endif struct compat_statfs64 { __u32 f_type; __u32 f_bsize; __u64 f_blocks; __u64 f_bfree; __u64 f_bavail; __u64 f_files; __u64 f_ffree; __kernel_fsid_t f_fsid; __u32 f_namelen; __u32 f_frsize; __u32 f_flags; __u32 f_spare[4]; } ARCH_PACK_COMPAT_STATFS64; #endif /* _GENERIC_STATFS_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_IPCBUF_H #define __ASM_GENERIC_IPCBUF_H #include <linux/posix_types.h> /* * The generic ipc64_perm structure: * Note extra padding because this structure is passed back and forth * between kernel and user space. * * ipc64_perm was originally meant to be architecture specific, but * everyone just ended up making identical copies without specific * optimizations, so we may just as well all use the same one. * * Pad space is left for: * - 32-bit mode_t on architectures that only had 16 bit * - 32-bit seq * - 2 miscellaneous 32-bit values */ struct ipc64_perm { __kernel_key_t key; __kernel_uid32_t uid; __kernel_gid32_t gid; __kernel_uid32_t cuid; __kernel_gid32_t cgid; __kernel_mode_t mode; /* pad if mode_t is u16: */ unsigned char __pad1[4 - sizeof(__kernel_mode_t)]; unsigned short seq; unsigned short __pad2; __kernel_ulong_t __unused1; __kernel_ulong_t __unused2; }; #endif /* __ASM_GENERIC_IPCBUF_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_ERRNO_BASE_H #define _ASM_GENERIC_ERRNO_BASE_H #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ #define ESRCH 3 /* No such process */ #define EINTR 4 /* Interrupted system call */ #define EIO 5 /* I/O error */ #define ENXIO 6 /* No such device or address */ #define E2BIG 7 /* Argument list too long */ #define ENOEXEC 8 /* Exec format error */ #define EBADF 9 /* Bad file number */ #define ECHILD 10 /* No child processes */ #define EAGAIN 11 /* Try again */ #define ENOMEM 12 /* Out of memory */ #define EACCES 13 /* Permission denied */ #define EFAULT 14 /* Bad address */ #define ENOTBLK 15 /* Block device required */ #define EBUSY 16 /* Device or resource busy */ #define EEXIST 17 /* File exists */ #define EXDEV 18 /* Cross-device link */ #define ENODEV 19 /* No such device */ #define ENOTDIR 20 /* Not a directory */ #define EISDIR 21 /* Is a directory */ #define EINVAL 22 /* Invalid argument */ #define ENFILE 23 /* File table overflow */ #define EMFILE 24 /* Too many open files */ #define ENOTTY 25 /* Not a typewriter */ #define ETXTBSY 26 /* Text file busy */ #define EFBIG 27 /* File too large */ #define ENOSPC 28 /* No space left on device */ #define ESPIPE 29 /* Illegal seek */ #define EROFS 30 /* Read-only file system */ #define EMLINK 31 /* Too many links */ #define EPIPE 32 /* Broken pipe */ #define EDOM 33 /* Math argument out of domain of func */ #define ERANGE 34 /* Math result not representable */ #endif /* * There isn't anything here, but the file must not be empty or patch * will delete it. */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* * asm-generic/int-ll64.h * * Integer declarations for architectures which use "long long" * for 64-bit types. */ #ifndef _ASM_GENERIC_INT_LL64_H #define _ASM_GENERIC_INT_LL64_H #include <asm/bitsperlong.h> #ifndef __ASSEMBLY__ /* * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the * header files exported to user space */ typedef __signed__ char __s8; typedef unsigned char __u8; typedef __signed__ short __s16; typedef unsigned short __u16; typedef __signed__ int __s32; typedef unsigned int __u32; #ifdef __GNUC__ __extension__ typedef __signed__ long long __s64; __extension__ typedef unsigned long long __u64; #else typedef __signed__ long long __s64; typedef unsigned long long __u64; #endif #endif /* __ASSEMBLY__ */ #endif /* _ASM_GENERIC_INT_LL64_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_MMAN_H #define __ASM_GENERIC_MMAN_H #include <asm-generic/mman-common.h> #define MAP_GROWSDOWN 0x0100 /* stack-like segment */ #define MAP_DENYWRITE 0x0800 /* ETXTBSY */ #define MAP_EXECUTABLE 0x1000 /* mark it as an executable */ #define MAP_LOCKED 0x2000 /* pages are locked */ #define MAP_NORESERVE 0x4000 /* don't check for reservations */ /* * Bits [26:31] are reserved, see asm-generic/hugetlb_encode.h * for MAP_HUGETLB usage */ #define MCL_CURRENT 1 /* lock all current mappings */ #define MCL_FUTURE 2 /* lock all future mappings */ #define MCL_ONFAULT 4 /* lock all pages that are faulted in */ #endif /* __ASM_GENERIC_MMAN_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_MMAN_COMMON_H #define __ASM_GENERIC_MMAN_COMMON_H /* Author: Michael S. Tsirkin <mst@mellanox.co.il>, Mellanox Technologies Ltd. Based on: asm-xxx/mman.h */ #define PROT_READ 0x1 /* page can be read */ #define PROT_WRITE 0x2 /* page can be written */ #define PROT_EXEC 0x4 /* page can be executed */ #define PROT_SEM 0x8 /* page may be used for atomic ops */ /* 0x10 reserved for arch-specific use */ /* 0x20 reserved for arch-specific use */ #define PROT_NONE 0x0 /* page can not be accessed */ #define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */ #define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */ /* 0x01 - 0x03 are defined in linux/mman.h */ #define MAP_TYPE 0x0f /* Mask for type of mapping */ #define MAP_FIXED 0x10 /* Interpret addr exactly */ #define MAP_ANONYMOUS 0x20 /* don't use a file */ /* 0x0100 - 0x4000 flags are defined in asm-generic/mman.h */ #define MAP_POPULATE 0x008000 /* populate (prefault) pagetables */ #define MAP_NONBLOCK 0x010000 /* do not block on IO */ #define MAP_STACK 0x020000 /* give out an address that is best suited for process/thread stacks */ #define MAP_HUGETLB 0x040000 /* create a huge page mapping */ #define MAP_SYNC 0x080000 /* perform synchronous page faults for the mapping */ #define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ #define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be * uninitialized */ /* * Flags for mlock */ #define MLOCK_ONFAULT 0x01 /* Lock pages in range after they are faulted in, do not prefault */ #define MS_ASYNC 1 /* sync memory asynchronously */ #define MS_INVALIDATE 2 /* invalidate the caches */ #define MS_SYNC 4 /* synchronous memory sync */ #define MADV_NORMAL 0 /* no further special treatment */ #define MADV_RANDOM 1 /* expect random page references */ #define MADV_SEQUENTIAL 2 /* expect sequential page references */ #define MADV_WILLNEED 3 /* will need these pages */ #define MADV_DONTNEED 4 /* don't need these pages */ /* common parameters: try to keep these consistent across architectures */ #define MADV_FREE 8 /* free pages only if memory pressure */ #define MADV_REMOVE 9 /* remove these pages & resources */ #define MADV_DONTFORK 10 /* don't inherit across fork */ #define MADV_DOFORK 11 /* do inherit across fork */ #define MADV_HWPOISON 100 /* poison a page for testing */ #define MADV_SOFT_OFFLINE 101 /* soft offline page for testing */ #define MADV_MERGEABLE 12 /* KSM may merge identical pages */ #define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages */ #define MADV_HUGEPAGE 14 /* Worth backing with hugepages */ #define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */ #define MADV_DONTDUMP 16 /* Explicity exclude from the core dump, overrides the coredump filter bits */ #define MADV_DODUMP 17 /* Clear the MADV_DONTDUMP flag */ #define MADV_WIPEONFORK 18 /* Zero memory on fork, child only */ #define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */ #define MADV_COLD 20 /* deactivate these pages */ #define MADV_PAGEOUT 21 /* reclaim these pages */ #define MADV_POPULATE_READ 22 /* populate (prefault) page tables readable */ #define MADV_POPULATE_WRITE 23 /* populate (prefault) page tables writable */ #define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages too */ #define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */ /* compatibility flags */ #define MAP_FILE 0 #define PKEY_DISABLE_ACCESS 0x1 #define PKEY_DISABLE_WRITE 0x2 #define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\ PKEY_DISABLE_WRITE) #endif /* __ASM_GENERIC_MMAN_COMMON_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_SOCKET_H #define __ASM_GENERIC_SOCKET_H #include <linux/posix_types.h> #include <asm/sockios.h> /* For setsockopt(2) */ #define SOL_SOCKET 1 #define SO_DEBUG 1 #define SO_REUSEADDR 2 #define SO_TYPE 3 #define SO_ERROR 4 #define SO_DONTROUTE 5 #define SO_BROADCAST 6 #define SO_SNDBUF 7 #define SO_RCVBUF 8 #define SO_SNDBUFFORCE 32 #define SO_RCVBUFFORCE 33 #define SO_KEEPALIVE 9 #define SO_OOBINLINE 10 #define SO_NO_CHECK 11 #define SO_PRIORITY 12 #define SO_LINGER 13 #define SO_BSDCOMPAT 14 #define SO_REUSEPORT 15 #ifndef SO_PASSCRED /* powerpc only differs in these */ #define SO_PASSCRED 16 #define SO_PEERCRED 17 #define SO_RCVLOWAT 18 #define SO_SNDLOWAT 19 #define SO_RCVTIMEO_OLD 20 #define SO_SNDTIMEO_OLD 21 #endif /* Security levels - as per NRL IPv6 - don't actually do anything */ #define SO_SECURITY_AUTHENTICATION 22 #define SO_SECURITY_ENCRYPTION_TRANSPORT 23 #define SO_SECURITY_ENCRYPTION_NETWORK 24 #define SO_BINDTODEVICE 25 /* Socket filtering */ #define SO_ATTACH_FILTER 26 #define SO_DETACH_FILTER 27 #define SO_GET_FILTER SO_ATTACH_FILTER #define SO_PEERNAME 28 #define SO_ACCEPTCONN 30 #define SO_PEERSEC 31 #define SO_PASSSEC 34 #define SO_MARK 36 #define SO_PROTOCOL 38 #define SO_DOMAIN 39 #define SO_RXQ_OVFL 40 #define SO_WIFI_STATUS 41 #define SCM_WIFI_STATUS SO_WIFI_STATUS #define SO_PEEK_OFF 42 /* Instruct lower device to use last 4-bytes of skb data as FCS */ #define SO_NOFCS 43 #define SO_LOCK_FILTER 44 #define SO_SELECT_ERR_QUEUE 45 #define SO_BUSY_POLL 46 #define SO_MAX_PACING_RATE 47 #define SO_BPF_EXTENSIONS 48 #define SO_INCOMING_CPU 49 #define SO_ATTACH_BPF 50 #define SO_DETACH_BPF SO_DETACH_FILTER #define SO_ATTACH_REUSEPORT_CBPF 51 #define SO_ATTACH_REUSEPORT_EBPF 52 #define SO_CNX_ADVICE 53 #define SCM_TIMESTAMPING_OPT_STATS 54 #define SO_MEMINFO 55 #define SO_INCOMING_NAPI_ID 56 #define SO_COOKIE 57 #define SCM_TIMESTAMPING_PKTINFO 58 #define SO_PEERGROUPS 59 #define SO_ZEROCOPY 60 #define SO_TXTIME 61 #define SCM_TXTIME SO_TXTIME #define SO_BINDTOIFINDEX 62 #define SO_TIMESTAMP_OLD 29 #define SO_TIMESTAMPNS_OLD 35 #define SO_TIMESTAMPING_OLD 37 #define SO_TIMESTAMP_NEW 63 #define SO_TIMESTAMPNS_NEW 64 #define SO_TIMESTAMPING_NEW 65 #define SO_RCVTIMEO_NEW 66 #define SO_SNDTIMEO_NEW 67 #define SO_DETACH_REUSEPORT_BPF 68 #define SO_PREFER_BUSY_POLL 69 #define SO_BUSY_POLL_BUDGET 70 #define SO_NETNS_COOKIE 71 #define SO_RESERVE_MEM 73 #define SO_TXREHASH 74 #define SCM_TS_OPT_ID 81 #if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__)) /* on 64-bit and x32, avoid the ?: operator */ #define SO_TIMESTAMP SO_TIMESTAMP_OLD #define SO_TIMESTAMPNS SO_TIMESTAMPNS_OLD #define SO_TIMESTAMPING SO_TIMESTAMPING_OLD #define SO_RCVTIMEO SO_RCVTIMEO_OLD #define SO_SNDTIMEO SO_SNDTIMEO_OLD #else #define SO_TIMESTAMP (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMP_OLD : SO_TIMESTAMP_NEW) #define SO_TIMESTAMPNS (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPNS_OLD : SO_TIMESTAMPNS_NEW) #define SO_TIMESTAMPING (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_TIMESTAMPING_OLD : SO_TIMESTAMPING_NEW) #define SO_RCVTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_RCVTIMEO_OLD : SO_RCVTIMEO_NEW) #define SO_SNDTIMEO (sizeof(time_t) == sizeof(__kernel_long_t) ? SO_SNDTIMEO_OLD : SO_SNDTIMEO_NEW) #endif #define SCM_TIMESTAMP SO_TIMESTAMP #define SCM_TIMESTAMPNS SO_TIMESTAMPNS #define SCM_TIMESTAMPING SO_TIMESTAMPING #endif /* __ASM_GENERIC_SOCKET_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_UCONTEXT_H #define __ASM_GENERIC_UCONTEXT_H struct ucontext { unsigned long uc_flags; struct ucontext *uc_link; stack_t uc_stack; struct sigcontext uc_mcontext; sigset_t uc_sigmask; /* mask last for extensibility */ }; #endif /* __ASM_GENERIC_UCONTEXT_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_SETUP_H #define __ASM_GENERIC_SETUP_H #define COMMAND_LINE_SIZE 512 #endif /* __ASM_GENERIC_SETUP_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_SHMBUF_H #define __ASM_GENERIC_SHMBUF_H #include <asm/bitsperlong.h> #include <asm/ipcbuf.h> #include <asm/posix_types.h> /* * The shmid64_ds structure for x86 architecture. * Note extra padding because this structure is passed back and forth * between kernel and user space. * * shmid64_ds was originally meant to be architecture specific, but * everyone just ended up making identical copies without specific * optimizations, so we may just as well all use the same one. * * 64 bit architectures use a 64-bit long time field here, while * 32 bit architectures have a pair of unsigned long values. * On big-endian systems, the lower half is in the wrong place. * * * Pad space is left for: * - 2 miscellaneous 32-bit values */ struct shmid64_ds { struct ipc64_perm shm_perm; /* operation perms */ __kernel_size_t shm_segsz; /* size of segment (bytes) */ #if __BITS_PER_LONG == 64 long shm_atime; /* last attach time */ long shm_dtime; /* last detach time */ long shm_ctime; /* last change time */ #else unsigned long shm_atime; /* last attach time */ unsigned long shm_atime_high; unsigned long shm_dtime; /* last detach time */ unsigned long shm_dtime_high; unsigned long shm_ctime; /* last change time */ unsigned long shm_ctime_high; #endif __kernel_pid_t shm_cpid; /* pid of creator */ __kernel_pid_t shm_lpid; /* pid of last operator */ unsigned long shm_nattch; /* no. of current attaches */ unsigned long __unused4; unsigned long __unused5; }; struct shminfo64 { unsigned long shmmax; unsigned long shmmin; unsigned long shmmni; unsigned long shmseg; unsigned long shmall; unsigned long __unused1; unsigned long __unused2; unsigned long __unused3; unsigned long __unused4; }; #endif /* __ASM_GENERIC_SHMBUF_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef __ASM_GENERIC_POSIX_TYPES_H #define __ASM_GENERIC_POSIX_TYPES_H #include <asm/bitsperlong.h> /* * This file is generally used by user-level software, so you need to * be a little careful about namespace pollution etc. * * First the types that are often defined in different ways across * architectures, so that you can override them. */ #ifndef __kernel_long_t typedef long __kernel_long_t; typedef unsigned long __kernel_ulong_t; #endif #ifndef __kernel_ino_t typedef __kernel_ulong_t __kernel_ino_t; #endif #ifndef __kernel_mode_t typedef unsigned int __kernel_mode_t; #endif #ifndef __kernel_pid_t typedef int __kernel_pid_t; #endif #ifndef __kernel_ipc_pid_t typedef int __kernel_ipc_pid_t; #endif #ifndef __kernel_uid_t typedef unsigned int __kernel_uid_t; typedef unsigned int __kernel_gid_t; #endif #ifndef __kernel_suseconds_t typedef __kernel_long_t __kernel_suseconds_t; #endif #ifndef __kernel_daddr_t typedef int __kernel_daddr_t; #endif #ifndef __kernel_uid32_t typedef unsigned int __kernel_uid32_t; typedef unsigned int __kernel_gid32_t; #endif #ifndef __kernel_old_uid_t typedef __kernel_uid_t __kernel_old_uid_t; typedef __kernel_gid_t __kernel_old_gid_t; #endif #ifndef __kernel_old_dev_t typedef unsigned int __kernel_old_dev_t; #endif /* * Most 32 bit architectures use "unsigned int" size_t, * and all 64 bit architectures use "unsigned long" size_t. */ #ifndef __kernel_size_t #if __BITS_PER_LONG != 64 typedef unsigned int __kernel_size_t; typedef int __kernel_ssize_t; typedef int __kernel_ptrdiff_t; #else typedef __kernel_ulong_t __kernel_size_t; typedef __kernel_long_t __kernel_ssize_t; typedef __kernel_long_t __kernel_ptrdiff_t; #endif #endif #ifndef __kernel_fsid_t typedef struct { int val[2]; } __kernel_fsid_t; #endif /* * anything below here should be completely generic */ typedef __kernel_long_t __kernel_off_t; typedef long long __kernel_loff_t; typedef __kernel_long_t __kernel_old_time_t; typedef __kernel_long_t __kernel_time_t; typedef long long __kernel_time64_t; typedef __kernel_long_t __kernel_clock_t; typedef int __kernel_timer_t; typedef int __kernel_clockid_t; typedef char * __kernel_caddr_t; typedef unsigned short __kernel_uid16_t; typedef unsigned short __kernel_gid16_t; #endif /* __ASM_GENERIC_POSIX_TYPES_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_SIGINFO_H #define _ASM_GENERIC_SIGINFO_H #include <linux/types.h> typedef union sigval { int sival_int; void *sival_ptr; } sigval_t; #define SI_MAX_SIZE 128 /* * The default "si_band" type is "long", as specified by POSIX. * However, some architectures want to override this to "int" * for historical compatibility reasons, so we allow that. */ #ifndef __ARCH_SI_BAND_T #define __ARCH_SI_BAND_T long #endif #ifndef __ARCH_SI_CLOCK_T #define __ARCH_SI_CLOCK_T __kernel_clock_t #endif #ifndef __ARCH_SI_ATTRIBUTES #define __ARCH_SI_ATTRIBUTES #endif /* * Be careful when extending this union. On 32bit siginfo_t is 32bit * aligned. Which means that a 64bit field or any other field that * would increase the alignment of siginfo_t will break the ABI. */ union __sifields { /* kill() */ struct { __kernel_pid_t _pid; /* sender's pid */ __kernel_uid32_t _uid; /* sender's uid */ } _kill; /* POSIX.1b timers */ struct { __kernel_timer_t _tid; /* timer id */ int _overrun; /* overrun count */ sigval_t _sigval; /* same as below */ int _sys_private; /* not to be passed to user */ } _timer; /* POSIX.1b signals */ struct { __kernel_pid_t _pid; /* sender's pid */ __kernel_uid32_t _uid; /* sender's uid */ sigval_t _sigval; } _rt; /* SIGCHLD */ struct { __kernel_pid_t _pid; /* which child */ __kernel_uid32_t _uid; /* sender's uid */ int _status; /* exit code */ __ARCH_SI_CLOCK_T _utime; __ARCH_SI_CLOCK_T _stime; } _sigchld; /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */ struct { void *_addr; /* faulting insn/memory ref. */ #ifdef __ia64__ int _imm; /* immediate value for "break" */ unsigned int _flags; /* see ia64 si_flags */ unsigned long _isr; /* isr */ #endif #define __ADDR_BND_PKEY_PAD (__alignof__(void *) < sizeof(short) ? \ sizeof(short) : __alignof__(void *)) union { /* used on alpha and sparc */ int _trapno; /* TRAP # which caused the signal */ /* * used when si_code=BUS_MCEERR_AR or * used when si_code=BUS_MCEERR_AO */ short _addr_lsb; /* LSB of the reported address */ /* used when si_code=SEGV_BNDERR */ struct { char _dummy_bnd[__ADDR_BND_PKEY_PAD]; void *_lower; void *_upper; } _addr_bnd; /* used when si_code=SEGV_PKUERR */ struct { char _dummy_pkey[__ADDR_BND_PKEY_PAD]; __u32 _pkey; } _addr_pkey; /* used when si_code=TRAP_PERF */ struct { unsigned long _data; __u32 _type; __u32 _flags; } _perf; }; } _sigfault; /* SIGPOLL */ struct { __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */ int _fd; } _sigpoll; /* SIGSYS */ struct { void *_call_addr; /* calling user insn */ int _syscall; /* triggering system call number */ unsigned int _arch; /* AUDIT_ARCH_* of syscall */ } _sigsys; }; #ifndef __ARCH_HAS_SWAPPED_SIGINFO #define __SIGINFO \ struct { \ int si_signo; \ int si_errno; \ int si_code; \ union __sifields _sifields; \ } #else #define __SIGINFO \ struct { \ int si_signo; \ int si_code; \ int si_errno; \ union __sifields _sifields; \ } #endif /* __ARCH_HAS_SWAPPED_SIGINFO */ typedef struct siginfo { union { __SIGINFO; int _si_pad[SI_MAX_SIZE/sizeof(int)]; }; } __ARCH_SI_ATTRIBUTES siginfo_t; /* * How these fields are to be accessed. */ #define si_pid _sifields._kill._pid #define si_uid _sifields._kill._uid #define si_tid _sifields._timer._tid #define si_overrun _sifields._timer._overrun #define si_sys_private _sifields._timer._sys_private #define si_status _sifields._sigchld._status #define si_utime _sifields._sigchld._utime #define si_stime _sifields._sigchld._stime #define si_value _sifields._rt._sigval #define si_int _sifields._rt._sigval.sival_int #define si_ptr _sifields._rt._sigval.sival_ptr #define si_addr _sifields._sigfault._addr #define si_trapno _sifields._sigfault._trapno #define si_addr_lsb _sifields._sigfault._addr_lsb #define si_lower _sifields._sigfault._addr_bnd._lower #define si_upper _sifields._sigfault._addr_bnd._upper #define si_pkey _sifields._sigfault._addr_pkey._pkey #define si_perf_data _sifields._sigfault._perf._data #define si_perf_type _sifields._sigfault._perf._type #define si_perf_flags _sifields._sigfault._perf._flags #define si_band _sifields._sigpoll._band #define si_fd _sifields._sigpoll._fd #define si_call_addr _sifields._sigsys._call_addr #define si_syscall _sifields._sigsys._syscall #define si_arch _sifields._sigsys._arch /* * si_code values * Digital reserves positive values for kernel-generated signals. */ #define SI_USER 0 /* sent by kill, sigsend, raise */ #define SI_KERNEL 0x80 /* sent by the kernel from somewhere */ #define SI_QUEUE -1 /* sent by sigqueue */ #define SI_TIMER -2 /* sent by timer expiration */ #define SI_MESGQ -3 /* sent by real time mesq state change */ #define SI_ASYNCIO -4 /* sent by AIO completion */ #define SI_SIGIO -5 /* sent by queued SIGIO */ #define SI_TKILL -6 /* sent by tkill system call */ #define SI_DETHREAD -7 /* sent by execve() killing subsidiary threads */ #define SI_ASYNCNL -60 /* sent by glibc async name lookup completion */ #define SI_FROMUSER(siptr) ((siptr)->si_code <= 0) #define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0) /* * SIGILL si_codes */ #define ILL_ILLOPC 1 /* illegal opcode */ #define ILL_ILLOPN 2 /* illegal operand */ #define ILL_ILLADR 3 /* illegal addressing mode */ #define ILL_ILLTRP 4 /* illegal trap */ #define ILL_PRVOPC 5 /* privileged opcode */ #define ILL_PRVREG 6 /* privileged register */ #define ILL_COPROC 7 /* coprocessor error */ #define ILL_BADSTK 8 /* internal stack error */ #define ILL_BADIADDR 9 /* unimplemented instruction address */ #define __ILL_BREAK 10 /* illegal break */ #define __ILL_BNDMOD 11 /* bundle-update (modification) in progress */ #define NSIGILL 11 /* * SIGFPE si_codes */ #define FPE_INTDIV 1 /* integer divide by zero */ #define FPE_INTOVF 2 /* integer overflow */ #define FPE_FLTDIV 3 /* floating point divide by zero */ #define FPE_FLTOVF 4 /* floating point overflow */ #define FPE_FLTUND 5 /* floating point underflow */ #define FPE_FLTRES 6 /* floating point inexact result */ #define FPE_FLTINV 7 /* floating point invalid operation */ #define FPE_FLTSUB 8 /* subscript out of range */ #define __FPE_DECOVF 9 /* decimal overflow */ #define __FPE_DECDIV 10 /* decimal division by zero */ #define __FPE_DECERR 11 /* packed decimal error */ #define __FPE_INVASC 12 /* invalid ASCII digit */ #define __FPE_INVDEC 13 /* invalid decimal digit */ #define FPE_FLTUNK 14 /* undiagnosed floating-point exception */ #define FPE_CONDTRAP 15 /* trap on condition */ #define NSIGFPE 15 /* * SIGSEGV si_codes */ #define SEGV_MAPERR 1 /* address not mapped to object */ #define SEGV_ACCERR 2 /* invalid permissions for mapped object */ #define SEGV_BNDERR 3 /* failed address bound checks */ #ifdef __ia64__ # define __SEGV_PSTKOVF 4 /* paragraph stack overflow */ #else # define SEGV_PKUERR 4 /* failed protection key checks */ #endif #define SEGV_ACCADI 5 /* ADI not enabled for mapped object */ #define SEGV_ADIDERR 6 /* Disrupting MCD error */ #define SEGV_ADIPERR 7 /* Precise MCD exception */ #define SEGV_MTEAERR 8 /* Asynchronous ARM MTE error */ #define SEGV_MTESERR 9 /* Synchronous ARM MTE exception */ #define SEGV_CPERR 10 /* Control protection fault */ #define NSIGSEGV 10 /* * SIGBUS si_codes */ #define BUS_ADRALN 1 /* invalid address alignment */ #define BUS_ADRERR 2 /* non-existent physical address */ #define BUS_OBJERR 3 /* object specific hardware error */ /* hardware memory error consumed on a machine check: action required */ #define BUS_MCEERR_AR 4 /* hardware memory error detected in process but not consumed: action optional*/ #define BUS_MCEERR_AO 5 #define NSIGBUS 5 /* * SIGTRAP si_codes */ #define TRAP_BRKPT 1 /* process breakpoint */ #define TRAP_TRACE 2 /* process trace trap */ #define TRAP_BRANCH 3 /* process taken branch trap */ #define TRAP_HWBKPT 4 /* hardware breakpoint/watchpoint */ #define TRAP_UNK 5 /* undiagnosed trap */ #define TRAP_PERF 6 /* perf event with sigtrap=1 */ #define NSIGTRAP 6 /* * There is an additional set of SIGTRAP si_codes used by ptrace * that are of the form: ((PTRACE_EVENT_XXX << 8) | SIGTRAP) */ /* * Flags for si_perf_flags if SIGTRAP si_code is TRAP_PERF. */ #define TRAP_PERF_FLAG_ASYNC (1u << 0) /* * SIGCHLD si_codes */ #define CLD_EXITED 1 /* child has exited */ #define CLD_KILLED 2 /* child was killed */ #define CLD_DUMPED 3 /* child terminated abnormally */ #define CLD_TRAPPED 4 /* traced child has trapped */ #define CLD_STOPPED 5 /* child has stopped */ #define CLD_CONTINUED 6 /* stopped child has continued */ #define NSIGCHLD 6 /* * SIGPOLL (or any other signal without signal specific si_codes) si_codes */ #define POLL_IN 1 /* data input available */ #define POLL_OUT 2 /* output buffers available */ #define POLL_MSG 3 /* input message available */ #define POLL_ERR 4 /* i/o error */ #define POLL_PRI 5 /* high priority input available */ #define POLL_HUP 6 /* device disconnected */ #define NSIGPOLL 6 /* * SIGSYS si_codes */ #define SYS_SECCOMP 1 /* seccomp triggered */ #define SYS_USER_DISPATCH 2 /* syscall user dispatch triggered */ #define NSIGSYS 2 /* * SIGEMT si_codes */ #define EMT_TAGOVF 1 /* tag overflow */ #define NSIGEMT 1 /* * sigevent definitions * * It seems likely that SIGEV_THREAD will have to be handled from * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the * thread manager then catches and does the appropriate nonsense. * However, everything is written out here so as to not get lost. */ #define SIGEV_SIGNAL 0 /* notify via signal */ #define SIGEV_NONE 1 /* other notification: meaningless */ #define SIGEV_THREAD 2 /* deliver via thread creation */ #define SIGEV_THREAD_ID 4 /* deliver to thread */ /* * This works because the alignment is ok on all current architectures * but we leave open this being overridden in the future */ #ifndef __ARCH_SIGEV_PREAMBLE_SIZE #define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(int) * 2 + sizeof(sigval_t)) #endif #define SIGEV_MAX_SIZE 64 #define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) \ / sizeof(int)) typedef struct sigevent { sigval_t sigev_value; int sigev_signo; int sigev_notify; union { int _pad[SIGEV_PAD_SIZE]; int _tid; struct { void (*_function)(sigval_t); void *_attribute; /* really pthread_attr_t */ } _sigev_thread; } _sigev_un; } sigevent_t; #define sigev_notify_function _sigev_un._sigev_thread._function #define sigev_notify_attributes _sigev_un._sigev_thread._attribute #define sigev_notify_thread_id _sigev_un._tid #endif /* _ASM_GENERIC_SIGINFO_H */ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ #ifndef _ASM_GENERIC_RESOURCE_H #define _ASM_GENERIC_RESOURCE_H /* * Resource limit IDs * * ( Compatibility detail: there are architectures that have * a different rlimit ID order in the 5-9 range and want * to keep that order for binary compatibility. The reasons * are historic and all new rlimits are identical across all * arches. If an arch has such special order for some rlimits * then it defines them prior including asm-generic/resource.h. ) */ #define RLIMIT_CPU 0 /* CPU time in sec */ #define RLIMIT_FSIZE 1 /* Maximum filesize */ #define RLIMIT_DATA 2 /* max data size */ #define RLIMIT_STACK 3 /* max stack size */ #define RLIMIT_CORE 4 /* max core file size */ #ifndef RLIMIT_RSS # define RLIMIT_RSS 5 /* max resident set size */ #endif #ifndef RLIMIT_NPROC # define RLIMIT_NPROC 6 /* max number of processes */ #endif #ifndef RLIMIT_NOFILE # define RLIMIT_NOFILE 7 /* max number of open files */ #endif #ifndef RLIMIT_MEMLOCK # define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ #endif #ifndef RLIMIT_AS # define RLIMIT_AS 9 /* address space limit */ #endif #define RLIMIT_LOCKS 10 /* maximum file locks held */ #define RLIMIT_SIGPENDING 11 /* max number of pending signals */ #define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */ #define RLIMIT_NICE 13 /* max nice prio allowed to raise to 0-39 for nice level 19 .. -20 */ #define RLIMIT_RTPRIO 14 /* maximum realtime priority */ #define RLIMIT_RTTIME 15 /* timeout for RT tasks in us */ #define RLIM_NLIMITS 16 /* * SuS says limits have to be unsigned. * Which makes a ton more sense anyway. * * Some architectures override this (for compatibility reasons): */ #ifndef RLIM_INFINITY # define RLIM_INFINITY (~0UL) #endif #endif /* _ASM_GENERIC_RESOURCE_H */ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software <http://www.openldap.org/>. * * Copyright 1998-2026 The OpenLDAP Foundation. * Portions Copyright 1997,2002,2003 IBM Corporation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP * Public License. * * A copy of this license is available in file LICENSE in the * top-level directory of the distribution or, alternatively, at * <http://www.OpenLDAP.org/license.html>. */ /* * This header is used in development of SLAPI plugins for * OpenLDAP slapd(8) and other directory servers supporting * this interface. Your portability mileage may vary. */ #ifndef _SLAPI_PLUGIN_H #define _SLAPI_PLUGIN_H #include <ldap.h> typedef struct slapi_pblock Slapi_PBlock; typedef struct slapi_entry Slapi_Entry; typedef struct slapi_attr Slapi_Attr; typedef struct slapi_value Slapi_Value; typedef struct slapi_valueset Slapi_ValueSet; typedef struct slapi_filter Slapi_Filter; typedef struct BackendDB Slapi_Backend; typedef struct Operation Slapi_Operation; typedef struct Connection Slapi_Connection; typedef struct slapi_dn Slapi_DN; typedef struct slapi_rdn Slapi_RDN; typedef struct slapi_mod Slapi_Mod; typedef struct slapi_mods Slapi_Mods; typedef struct slapi_componentid Slapi_ComponentId; #define SLAPI_ATTR_UNIQUEID "entryUUID" #define SLAPI_ATTR_OBJECTCLASS "objectClass" /* pblock routines */ int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value ); int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value ); Slapi_PBlock *slapi_pblock_new( void ); void slapi_pblock_destroy( Slapi_PBlock *pb ); /* entry/attr/dn routines */ Slapi_Entry *slapi_str2entry( char *s, int flags ); #define SLAPI_STR2ENTRY_REMOVEDUPVALS 1 #define SLAPI_STR2ENTRY_ADDRDNVALS 2 #define SLAPI_STR2ENTRY_BIGENTRY 4 #define SLAPI_STR2ENTRY_TOMBSTONE_CHECK 8 #define SLAPI_STR2ENTRY_IGNORE_STATE 16 #define SLAPI_STR2ENTRY_INCLUDE_VERSION_STR 32 #define SLAPI_STR2ENTRY_EXPAND_OBJECTCLASSES 64 #define SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF 128 char *slapi_entry2str( Slapi_Entry *e, int *len ); char *slapi_entry_get_dn( Slapi_Entry *e ); int slapi_x_entry_get_id( Slapi_Entry *e ); void slapi_entry_set_dn( Slapi_Entry *e, char *dn ); Slapi_Entry *slapi_entry_dup( Slapi_Entry *e ); int slapi_entry_attr_delete( Slapi_Entry *e, char *type ); Slapi_Entry *slapi_entry_alloc(); void slapi_entry_free( Slapi_Entry *e ); int slapi_entry_attr_merge( Slapi_Entry *e, char *type, struct berval **vals ); int slapi_entry_attr_find( Slapi_Entry *e, char *type, Slapi_Attr **attr ); char *slapi_entry_attr_get_charptr( const Slapi_Entry *e, const char *type ); int slapi_entry_attr_get_int( const Slapi_Entry *e, const char *type ); long slapi_entry_attr_get_long( const Slapi_Entry *e, const char *type ); unsigned int slapi_entry_attr_get_uint( const Slapi_Entry *e, const char *type ); unsigned long slapi_entry_attr_get_ulong( const Slapi_Entry *e, const char *type ); int slapi_attr_get_values( Slapi_Attr *attr, struct berval ***vals ); char *slapi_dn_normalize( char *dn ); char *slapi_dn_normalize_case( char *dn ); int slapi_dn_issuffix( char *dn, char *suffix ); char *slapi_dn_beparent( Slapi_PBlock *pb, const char *dn ); int slapi_dn_isbesuffix( Slapi_PBlock *pb, char *dn ); char *slapi_dn_parent( const char *dn ); int slapi_dn_isparent( const char *parentdn, const char *childdn ); char *slapi_dn_ignore_case( char *dn ); int slapi_rdn2typeval( char *rdn, char **type, struct berval *bv ); char *slapi_dn_plus_rdn(const char *dn, const char *rdn); /* DS 5.x SLAPI */ int slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e, char *attr, struct berval *val, int access ); int slapi_acl_check_mods( Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods, char **errbuf ); Slapi_Attr *slapi_attr_new( void ); Slapi_Attr *slapi_attr_init( Slapi_Attr *a, const char *type ); void slapi_attr_free( Slapi_Attr **a ); Slapi_Attr *slapi_attr_dup( const Slapi_Attr *attr ); int slapi_attr_add_value( Slapi_Attr *a, const Slapi_Value *v ); int slapi_attr_type2plugin( const char *type, void **pi ); int slapi_attr_get_type( const Slapi_Attr *attr, char **type ); int slapi_attr_get_oid_copy( const Slapi_Attr *attr, char **oidp ); int slapi_attr_get_flags( const Slapi_Attr *attr, unsigned long *flags ); int slapi_attr_flag_is_set( const Slapi_Attr *attr, unsigned long flag ); int slapi_attr_value_cmp( const Slapi_Attr *attr, const struct berval *v1, const struct berval *v2 ); int slapi_attr_value_find( const Slapi_Attr *a, struct berval *v ); #define SLAPI_TYPE_CMP_EXACT 0 #define SLAPI_TYPE_CMP_BASE 1 #define SLAPI_TYPE_CMP_SUBTYPE 2 int slapi_attr_type_cmp( const char *t1, const char *t2, int opt ); int slapi_attr_types_equivalent( const char *t1, const char *t2 ); int slapi_attr_first_value( Slapi_Attr *a, Slapi_Value **v ); int slapi_attr_next_value( Slapi_Attr *a, int hint, Slapi_Value **v ); int slapi_attr_get_numvalues( const Slapi_Attr *a, int *numValues ); int slapi_attr_get_valueset( const Slapi_Attr *a, Slapi_ValueSet **vs ); int slapi_attr_get_bervals_copy( Slapi_Attr *a, struct berval ***vals ); int slapi_entry_attr_hasvalue( Slapi_Entry *e, const char *type, const char *value ); int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); void slapi_entry_attr_set_charptr(Slapi_Entry* e, const char *type, const char *value); void slapi_entry_attr_set_int( Slapi_Entry* e, const char *type, int l); void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigned int l); void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l); void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l); int slapi_entry_has_children(const Slapi_Entry *e); size_t slapi_entry_size(Slapi_Entry *e); int slapi_is_rootdse( const char *dn ); int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); int slapi_entry_add_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); int slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs); int slapi_entry_delete_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); int slapi_entry_merge_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); int slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); int slapi_entry_add_value(Slapi_Entry *e, const char *type, const Slapi_Value *value); int slapi_entry_add_string(Slapi_Entry *e, const char *type, const char *value); int slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value); int slapi_entry_first_attr( const Slapi_Entry *e, Slapi_Attr **attr ); int slapi_entry_next_attr( const Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **attr ); const char *slapi_entry_get_uniqueid( const Slapi_Entry *e ); void slapi_entry_set_uniqueid( Slapi_Entry *e, char *uniqueid ); int slapi_entry_schema_check( Slapi_PBlock *pb, Slapi_Entry *e ); int slapi_entry_rdn_values_present( const Slapi_Entry *e ); int slapi_entry_add_rdn_values( Slapi_Entry *e ); char *slapi_attr_syntax_normalize( const char *s ); Slapi_Value *slapi_value_new( void ); Slapi_Value *slapi_value_new_berval(const struct berval *bval); Slapi_Value *slapi_value_new_value(const Slapi_Value *v); Slapi_Value *slapi_value_new_string(const char *s); Slapi_Value *slapi_value_init(Slapi_Value *v); Slapi_Value *slapi_value_init_berval(Slapi_Value *v, struct berval *bval); Slapi_Value *slapi_value_init_string(Slapi_Value *v, const char *s); Slapi_Value *slapi_value_dup(const Slapi_Value *v); void slapi_value_free(Slapi_Value **value); const struct berval *slapi_value_get_berval( const Slapi_Value *value ); Slapi_Value *slapi_value_set_berval( Slapi_Value *value, const struct berval *bval ); Slapi_Value *slapi_value_set_value( Slapi_Value *value, const Slapi_Value *vfrom); Slapi_Value *slapi_value_set( Slapi_Value *value, void *val, unsigned long len); int slapi_value_set_string(Slapi_Value *value, const char *strVal); int slapi_value_set_int(Slapi_Value *value, int intVal); const char*slapi_value_get_string(const Slapi_Value *value); int slapi_value_get_int(const Slapi_Value *value); unsigned int slapi_value_get_uint(const Slapi_Value *value); long slapi_value_get_long(const Slapi_Value *value); unsigned long slapi_value_get_ulong(const Slapi_Value *value); size_t slapi_value_get_length(const Slapi_Value *value); int slapi_value_compare(const Slapi_Attr *a, const Slapi_Value *v1, const Slapi_Value *v2); Slapi_ValueSet *slapi_valueset_new( void ); void slapi_valueset_free(Slapi_ValueSet *vs); void slapi_valueset_init(Slapi_ValueSet *vs); void slapi_valueset_done(Slapi_ValueSet *vs); void slapi_valueset_add_value(Slapi_ValueSet *vs, const Slapi_Value *addval); int slapi_valueset_first_value( Slapi_ValueSet *vs, Slapi_Value **v ); int slapi_valueset_next_value( Slapi_ValueSet *vs, int index, Slapi_Value **v); int slapi_valueset_count( const Slapi_ValueSet *vs); void slapi_valueset_set_valueset(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2); /* DNs */ Slapi_DN *slapi_sdn_new( void ); Slapi_DN *slapi_sdn_new_dn_byval( const char *dn ); Slapi_DN *slapi_sdn_new_ndn_byval( const char *ndn ); Slapi_DN *slapi_sdn_new_dn_byref( const char *dn ); Slapi_DN *slapi_sdn_new_ndn_byref( const char *ndn ); Slapi_DN *slapi_sdn_new_dn_passin( const char *dn ); Slapi_DN *slapi_sdn_set_dn_byval( Slapi_DN *sdn, const char *dn ); Slapi_DN *slapi_sdn_set_dn_byref( Slapi_DN *sdn, const char *dn ); Slapi_DN *slapi_sdn_set_dn_passin( Slapi_DN *sdn, const char *dn ); Slapi_DN *slapi_sdn_set_ndn_byval( Slapi_DN *sdn, const char *ndn ); Slapi_DN *slapi_sdn_set_ndn_byref( Slapi_DN *sdn, const char *ndn ); void slapi_sdn_done( Slapi_DN *sdn ); void slapi_sdn_free( Slapi_DN **sdn ); const char * slapi_sdn_get_dn( const Slapi_DN *sdn ); const char * slapi_sdn_get_ndn( const Slapi_DN *sdn ); void slapi_sdn_get_parent( const Slapi_DN *sdn,Slapi_DN *sdn_parent ); void slapi_sdn_get_backend_parent( const Slapi_DN *sdn, Slapi_DN *sdn_parent, const Slapi_Backend *backend ); Slapi_DN * slapi_sdn_dup( const Slapi_DN *sdn ); void slapi_sdn_copy( const Slapi_DN *from, Slapi_DN *to ); int slapi_sdn_compare( const Slapi_DN *sdn1, const Slapi_DN *sdn2 ); int slapi_sdn_isempty( const Slapi_DN *sdn ); int slapi_sdn_issuffix(const Slapi_DN *sdn, const Slapi_DN *suffixsdn ); int slapi_sdn_isparent( const Slapi_DN *parent, const Slapi_DN *child ); int slapi_sdn_isgrandparent( const Slapi_DN *parent, const Slapi_DN *child ); int slapi_sdn_get_ndn_len( const Slapi_DN *sdn ); int slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int scope ); void slapi_sdn_get_rdn( const Slapi_DN *sdn,Slapi_RDN *rdn ); Slapi_DN *slapi_sdn_set_rdn( Slapi_DN *sdn, const Slapi_RDN *rdn ); Slapi_DN *slapi_sdn_set_parent( Slapi_DN *sdn, const Slapi_DN *parentdn ); int slapi_sdn_is_rdn_component( const Slapi_DN *rdn, const Slapi_Attr *a, const Slapi_Value *v ); char * slapi_moddn_get_newdn( Slapi_DN *dn_olddn, char *newrdn, char *newsuperiordn ); /* RDNs */ Slapi_RDN *slapi_rdn_new( void ); Slapi_RDN *slapi_rdn_new_dn( const char *dn ); Slapi_RDN *slapi_rdn_new_sdn( const Slapi_DN *sdn ); Slapi_RDN *slapi_rdn_new_rdn( const Slapi_RDN *fromrdn ); void slapi_rdn_init( Slapi_RDN *rdn ); void slapi_rdn_init_dn( Slapi_RDN *rdn, const char *dn ); void slapi_rdn_init_sdn( Slapi_RDN *rdn, const Slapi_DN *sdn ); void slapi_rdn_init_rdn( Slapi_RDN *rdn, const Slapi_RDN *fromrdn ); void slapi_rdn_set_dn( Slapi_RDN *rdn, const char *dn ); void slapi_rdn_set_sdn( Slapi_RDN *rdn, const Slapi_DN *sdn ); void slapi_rdn_set_rdn( Slapi_RDN *rdn, const Slapi_RDN *fromrdn ); void slapi_rdn_free( Slapi_RDN **rdn ); void slapi_rdn_done( Slapi_RDN *rdn ); int slapi_rdn_get_first( Slapi_RDN *rdn, char **type, char **value ); int slapi_rdn_get_next( Slapi_RDN *rdn, int index, char **type, char **value ); int slapi_rdn_get_index( Slapi_RDN *rdn, const char *type, const char *value, size_t length ); int slapi_rdn_get_index_attr( Slapi_RDN *rdn, const char *type, char **value ); int slapi_rdn_contains( Slapi_RDN *rdn, const char *type, const char *value,size_t length ); int slapi_rdn_contains_attr( Slapi_RDN *rdn, const char *type, char **value ); int slapi_rdn_add( Slapi_RDN *rdn, const char *type, const char *value ); int slapi_rdn_remove_index( Slapi_RDN *rdn, int atindex ); int slapi_rdn_remove( Slapi_RDN *rdn, const char *type, const char *value, size_t length ); int slapi_rdn_remove_attr( Slapi_RDN *rdn, const char *type ); int slapi_rdn_isempty( const Slapi_RDN *rdn ); int slapi_rdn_get_num_components( Slapi_RDN *rdn ); int slapi_rdn_compare( Slapi_RDN *rdn1, Slapi_RDN *rdn2 ); const char *slapi_rdn_get_rdn( const Slapi_RDN *rdn ); const char *slapi_rdn_get_nrdn( const Slapi_RDN *rdn ); Slapi_DN *slapi_sdn_add_rdn( Slapi_DN *sdn, const Slapi_RDN *rdn ); /* locks and synchronization */ typedef struct slapi_mutex Slapi_Mutex; typedef struct slapi_condvar Slapi_CondVar; Slapi_Mutex *slapi_new_mutex( void ); void slapi_destroy_mutex( Slapi_Mutex *mutex ); void slapi_lock_mutex( Slapi_Mutex *mutex ); int slapi_unlock_mutex( Slapi_Mutex *mutex ); Slapi_CondVar *slapi_new_condvar( Slapi_Mutex *mutex ); void slapi_destroy_condvar( Slapi_CondVar *cvar ); int slapi_wait_condvar( Slapi_CondVar *cvar, struct timeval *timeout ); int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all ); /* thread-safe LDAP connections */ LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared ); void slapi_ldap_unbind( LDAP *ld ); char *slapi_ch_malloc( unsigned long size ); void slapi_ch_free( void **ptr ); void slapi_ch_free_string( char **ptr ); char *slapi_ch_calloc( unsigned long nelem, unsigned long size ); char *slapi_ch_realloc( char *block, unsigned long size ); char *slapi_ch_strdup( const char *s ); void slapi_ch_array_free( char **arrayp ); struct berval *slapi_ch_bvdup(const struct berval *v); struct berval **slapi_ch_bvecdup(const struct berval **v); /* LDAP V3 routines */ int slapi_control_present( LDAPControl **controls, char *oid, struct berval **val, int *iscritical); void slapi_register_supported_control(char *controloid, unsigned long controlops); #define SLAPI_OPERATION_BIND 0x00000001L #define SLAPI_OPERATION_UNBIND 0x00000002L #define SLAPI_OPERATION_SEARCH 0x00000004L #define SLAPI_OPERATION_MODIFY 0x00000008L #define SLAPI_OPERATION_ADD 0x00000010L #define SLAPI_OPERATION_DELETE 0x00000020L #define SLAPI_OPERATION_MODDN 0x00000040L #define SLAPI_OPERATION_MODRDN SLAPI_OPERATION_MODDN #define SLAPI_OPERATION_COMPARE 0x00000080L #define SLAPI_OPERATION_ABANDON 0x00000100L #define SLAPI_OPERATION_EXTENDED 0x00000200L #define SLAPI_OPERATION_ANY 0xFFFFFFFFL #define SLAPI_OPERATION_NONE 0x00000000L int slapi_get_supported_controls(char ***ctrloidsp, unsigned long **ctrlopsp); LDAPControl *slapi_dup_control(LDAPControl *ctrl); void slapi_register_supported_saslmechanism(char *mechanism); char **slapi_get_supported_saslmechanisms(); char **slapi_get_supported_extended_ops(void); /* operation */ int slapi_op_abandoned( Slapi_PBlock *pb ); unsigned long slapi_op_get_type(Slapi_Operation * op); void slapi_operation_set_flag(Slapi_Operation *op, unsigned long flag); void slapi_operation_clear_flag(Slapi_Operation *op, unsigned long flag); int slapi_operation_is_flag_set(Slapi_Operation *op, unsigned long flag); char *slapi_op_type_to_string(unsigned long type); /* send ldap result back */ void slapi_send_ldap_result( Slapi_PBlock *pb, int err, char *matched, char *text, int nentries, struct berval **urls ); int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e, LDAPControl **ectrls, char **attrs, int attrsonly ); int slapi_send_ldap_search_reference( Slapi_PBlock *pb, Slapi_Entry *e, struct berval **urls, LDAPControl **ectrls, struct berval **v2refs ); /* filter routines */ Slapi_Filter *slapi_str2filter( char *str ); Slapi_Filter *slapi_filter_dup( Slapi_Filter *f ); void slapi_filter_free( Slapi_Filter *f, int recurse ); int slapi_filter_get_choice( Slapi_Filter *f); int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval ); Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f ); Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev ); int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type ); int slapi_x_filter_set_attribute_type( Slapi_Filter *f, const char *type ); int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial, char ***any, char **final ); Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2); int slapi_x_filter_append( int choice, Slapi_Filter **pContainingFilter, Slapi_Filter **pNextFilter, Slapi_Filter *filterToAppend ); int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f, int verify_access ); int slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f ); typedef int (*FILTER_APPLY_FN)( Slapi_Filter *f, void *arg ); int slapi_filter_apply( Slapi_Filter *f, FILTER_APPLY_FN fn, void *arg, int *error_code ); #define SLAPI_FILTER_SCAN_STOP -1 /* set by callback */ #define SLAPI_FILTER_SCAN_ERROR -2 /* set by callback */ #define SLAPI_FILTER_SCAN_NOMORE 0 /* set by callback */ #define SLAPI_FILTER_SCAN_CONTINUE 1 /* set by callback */ #define SLAPI_FILTER_UNKNOWN_FILTER_TYPE 2 /* set by slapi_filter_apply() */ /* internal add/delete/search/modify routines */ Slapi_PBlock *slapi_search_internal( char *base, int scope, char *filter, LDAPControl **controls, char **attrs, int attrsonly ); Slapi_PBlock *slapi_modify_internal( char *dn, LDAPMod **mods, LDAPControl **controls, int log_change ); Slapi_PBlock *slapi_add_internal( char * dn, LDAPMod **attrs, LDAPControl **controls, int log_changes ); Slapi_PBlock *slapi_add_entry_internal( Slapi_Entry * e, LDAPControl **controls, int log_change ); Slapi_PBlock *slapi_delete_internal( char * dn, LDAPControl **controls, int log_change ); Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn, int deloldrdn, LDAPControl **controls, int log_change ); Slapi_PBlock *slapi_rename_internal( const char * olddn, const char *newrdn, const char *newsuperior, int deloldrdn, LDAPControl **controls, int log_change ); void slapi_free_search_results_internal(Slapi_PBlock *pb); /* new internal add/delete/search/modify routines */ typedef void (*plugin_result_callback)( int rc, void *callback_data ); typedef int (*plugin_referral_entry_callback)( char * referral, void *callback_data ); typedef int (*plugin_search_entry_callback)( Slapi_Entry *e, void *callback_data ); void slapi_free_search_results_internal( Slapi_PBlock *pb ); #define SLAPI_OP_FLAG_NEVER_CHAIN 0x0800 int slapi_search_internal_pb( Slapi_PBlock *pb ); int slapi_search_internal_callback_pb( Slapi_PBlock *pb, void *callback_data, plugin_result_callback prc, plugin_search_entry_callback psec, plugin_referral_entry_callback prec ); int slapi_add_internal_pb( Slapi_PBlock *pb ); int slapi_modify_internal_pb( Slapi_PBlock *pb ); int slapi_modrdn_internal_pb( Slapi_PBlock *pb ); int slapi_delete_internal_pb( Slapi_PBlock *pb ); int slapi_seq_internal_callback_pb(Slapi_PBlock *pb, void *callback_data, plugin_result_callback res_callback, plugin_search_entry_callback srch_callback, plugin_referral_entry_callback ref_callback); void slapi_search_internal_set_pb( Slapi_PBlock *pb, const char *base, int scope, const char *filter, char **attrs, int attrsonly, LDAPControl **controls, const char *uniqueid, Slapi_ComponentId *plugin_identity, int operation_flags ); void slapi_add_entry_internal_set_pb( Slapi_PBlock *pb, Slapi_Entry *e, LDAPControl **controls, Slapi_ComponentId *plugin_identity, int operation_flags ); int slapi_add_internal_set_pb( Slapi_PBlock *pb, const char *dn, LDAPMod **attrs, LDAPControl **controls, Slapi_ComponentId *plugin_identity, int operation_flags ); void slapi_modify_internal_set_pb( Slapi_PBlock *pb, const char *dn, LDAPMod **mods, LDAPControl **controls, const char *uniqueid, Slapi_ComponentId *plugin_identity, int operation_flags ); void slapi_rename_internal_set_pb( Slapi_PBlock *pb, const char *olddn, const char *newrdn, const char *newsuperior, int deloldrdn, LDAPControl **controls, const char *uniqueid, Slapi_ComponentId *plugin_identity, int operation_flags ); void slapi_delete_internal_set_pb( Slapi_PBlock *pb, const char *dn, LDAPControl **controls, const char *uniqueid, Slapi_ComponentId *plugin_identity, int operation_flags ); void slapi_seq_internal_set_pb( Slapi_PBlock *pb, char *ibase, int type, char *attrname, char *val, char **attrs, int attrsonly, LDAPControl **controls, Slapi_ComponentId *plugin_identity, int operation_flags ); /* connection related routines */ int slapi_is_connection_ssl(Slapi_PBlock *pPB, int *isSSL); int slapi_get_client_port(Slapi_PBlock *pPB, int *fromPort); int slapi_get_client_ip(Slapi_PBlock *pb, char **clientIP); void slapi_free_client_ip(char **clientIP); /* computed attributes */ typedef struct _computed_attr_context computed_attr_context; typedef int (*slapi_compute_output_t)(computed_attr_context *c, Slapi_Attr *a, Slapi_Entry *e); typedef int (*slapi_compute_callback_t)(computed_attr_context *c, char *type, Slapi_Entry *e, slapi_compute_output_t outputfn); typedef int (*slapi_search_rewrite_callback_t)(Slapi_PBlock *pb); int slapi_compute_add_evaluator(slapi_compute_callback_t function); int slapi_compute_add_search_rewriter(slapi_search_rewrite_callback_t function); int compute_rewrite_search_filter(Slapi_PBlock *pb); int compute_evaluator(computed_attr_context *c, char *type, Slapi_Entry *e, slapi_compute_output_t outputfn); int slapi_x_compute_get_pblock(computed_attr_context *c, Slapi_PBlock **pb); /* backend routines */ void slapi_be_set_readonly( Slapi_Backend *be, int readonly ); int slapi_be_get_readonly( Slapi_Backend *be ); const char *slapi_x_be_get_updatedn( Slapi_Backend *be ); Slapi_Backend *slapi_be_select( const Slapi_DN *sdn ); /* ACL plugins; only SLAPI_PLUGIN_ACL_ALLOW_ACCESS supported now */ typedef int (*slapi_acl_callback_t)(Slapi_PBlock *pb, Slapi_Entry *e, const char *attr, struct berval *berval, int access, void *state); /* object extensions */ typedef void *(*slapi_extension_constructor_fnptr)(void *object, void *parent); typedef void (*slapi_extension_destructor_fnptr)(void *extension, void *object, void *parent); int slapi_register_object_extension( const char *pluginname, const char *objectname, slapi_extension_constructor_fnptr constructor, slapi_extension_destructor_fnptr destructor, int *objecttype, int *extensionhandle); #define SLAPI_EXT_CONNECTION "Connection" #define SLAPI_EXT_OPERATION "Operation" #define SLAPI_EXT_ENTRY "Entry" #define SLAPI_EXT_MTNODE "Mapping Tree Node" void *slapi_get_object_extension(int objecttype, void *object, int extensionhandle); void slapi_set_object_extension(int objecttype, void *object, int extensionhandle, void *extension); int slapi_x_backend_get_flags( const Slapi_Backend *be, unsigned long *flags ); /* parameters currently supported */ /* * Attribute flags returned by slapi_attr_get_flags() */ #define SLAPI_ATTR_FLAG_SINGLE 0x0001 #define SLAPI_ATTR_FLAG_OPATTR 0x0002 #define SLAPI_ATTR_FLAG_READONLY 0x0004 #define SLAPI_ATTR_FLAG_STD_ATTR SLAPI_ATTR_FLAG_READONLY #define SLAPI_ATTR_FLAG_OBSOLETE 0x0040 #define SLAPI_ATTR_FLAG_COLLECTIVE 0x0080 #define SLAPI_ATTR_FLAG_NOUSERMOD 0x0100 /* * Backend flags returned by slapi_x_backend_get_flags() */ #define SLAPI_BACKEND_FLAG_NOLASTMOD 0x0001U #define SLAPI_BACKEND_FLAG_NO_SCHEMA_CHECK 0x0002U #define SLAPI_BACKEND_FLAG_GLUE_INSTANCE 0x0010U /* a glue backend */ #define SLAPI_BACKEND_FLAG_GLUE_SUBORDINATE 0x0020U /* child of a glue hierarchy */ #define SLAPI_BACKEND_FLAG_GLUE_LINKED 0x0040U /* child is connected to parent */ #define SLAPI_BACKEND_FLAG_OVERLAY 0x0080U /* this db struct is an overlay */ #define SLAPI_BACKEND_FLAG_GLOBAL_OVERLAY 0x0100U /* this db struct is a global overlay */ #define SLAPI_BACKEND_FLAG_SHADOW 0x8000U /* a shadow */ #define SLAPI_BACKEND_FLAG_SYNC_SHADOW 0x1000U /* a sync shadow */ #define SLAPI_BACKEND_FLAG_SLURP_SHADOW 0x2000U /* a slurp shadow */ /* * ACL levels */ #define SLAPI_ACL_COMPARE 0x01 #define SLAPI_ACL_SEARCH 0x02 #define SLAPI_ACL_READ 0x04 #define SLAPI_ACL_WRITE 0x08 #define SLAPI_ACL_DELETE 0x10 #define SLAPI_ACL_ADD 0x20 #define SLAPI_ACL_SELF 0x40 #define SLAPI_ACL_PROXY 0x80 #define SLAPI_ACL_ALL 0x7f /* plugin types supported */ #define SLAPI_PLUGIN_DATABASE 1 #define SLAPI_PLUGIN_EXTENDEDOP 2 #define SLAPI_PLUGIN_PREOPERATION 3 #define SLAPI_PLUGIN_POSTOPERATION 4 #define SLAPI_PLUGIN_MATCHINGRULE 5 #define SLAPI_PLUGIN_SYNTAX 6 #define SLAPI_PLUGIN_AUDIT 7 /* misc params */ #define SLAPI_BACKEND 130 #define SLAPI_CONNECTION 131 #define SLAPI_OPERATION 132 #define SLAPI_REQUESTOR_ISROOT 133 #define SLAPI_BE_MONITORDN 134 #define SLAPI_BE_TYPE 135 #define SLAPI_BE_READONLY 136 #define SLAPI_BE_LASTMOD 137 #define SLAPI_CONN_ID 139 /* operation params */ #define SLAPI_OPINITIATED_TIME 140 #define SLAPI_REQUESTOR_DN 141 #define SLAPI_IS_REPLICATED_OPERATION 142 #define SLAPI_REQUESTOR_ISUPDATEDN SLAPI_IS_REPLICATED_OPERATION /* connection structure params*/ #define SLAPI_CONN_DN 143 #define SLAPI_CONN_AUTHTYPE 144 #define SLAPI_CONN_CLIENTIP 145 #define SLAPI_CONN_SERVERIP 146 /* OpenLDAP extensions */ #define SLAPI_X_CONN_CLIENTPATH 1300 #define SLAPI_X_CONN_SERVERPATH 1301 #define SLAPI_X_CONN_IS_UDP 1302 #define SLAPI_X_CONN_SSF 1303 #define SLAPI_X_CONN_SASL_CONTEXT 1304 #define SLAPI_X_OPERATION_DELETE_GLUE_PARENT 1305 #define SLAPI_X_RELAX 1306 #define SLAPI_X_MANAGEDIT SLAPI_X_RELAX #define SLAPI_X_OPERATION_NO_SCHEMA_CHECK 1307 #define SLAPI_X_ADD_STRUCTURAL_CLASS 1308 #define SLAPI_X_OPERATION_NO_SUBORDINATE_GLUE 1309 /* Authentication types */ #define SLAPD_AUTH_NONE "none" #define SLAPD_AUTH_SIMPLE "simple" #define SLAPD_AUTH_SSL "SSL" #define SLAPD_AUTH_SASL "SASL " /* plugin configuration parmams */ #define SLAPI_PLUGIN 3 #define SLAPI_PLUGIN_PRIVATE 4 #define SLAPI_PLUGIN_TYPE 5 #define SLAPI_PLUGIN_ARGV 6 #define SLAPI_PLUGIN_ARGC 7 #define SLAPI_PLUGIN_VERSION 8 #define SLAPI_PLUGIN_OPRETURN 9 #define SLAPI_PLUGIN_OBJECT 10 #define SLAPI_PLUGIN_DESTROY_FN 11 #define SLAPI_PLUGIN_DESCRIPTION 12 #define SLAPI_PLUGIN_IDENTITY 13 /* internal operations params */ #define SLAPI_PLUGIN_INTOP_RESULT 15 #define SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES 16 #define SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS 17 /* transaction arguments */ #define SLAPI_PARENT_TXN 190 #define SLAPI_TXN 191 /* function pointer params for backends */ #define SLAPI_PLUGIN_DB_BIND_FN 200 #define SLAPI_PLUGIN_DB_UNBIND_FN 201 #define SLAPI_PLUGIN_DB_SEARCH_FN 202 #define SLAPI_PLUGIN_DB_COMPARE_FN 203 #define SLAPI_PLUGIN_DB_MODIFY_FN 204 #define SLAPI_PLUGIN_DB_MODRDN_FN 205 #define SLAPI_PLUGIN_DB_ADD_FN 206 #define SLAPI_PLUGIN_DB_DELETE_FN 207 #define SLAPI_PLUGIN_DB_ABANDON_FN 208 #define SLAPI_PLUGIN_DB_CONFIG_FN 209 #define SLAPI_PLUGIN_CLOSE_FN 210 #define SLAPI_PLUGIN_DB_FLUSH_FN 211 #define SLAPI_PLUGIN_START_FN 212 #define SLAPI_PLUGIN_DB_SEQ_FN 213 #define SLAPI_PLUGIN_DB_ENTRY_FN 214 #define SLAPI_PLUGIN_DB_REFERRAL_FN 215 #define SLAPI_PLUGIN_DB_RESULT_FN 216 #define SLAPI_PLUGIN_DB_LDIF2DB_FN 217 #define SLAPI_PLUGIN_DB_DB2LDIF_FN 218 #define SLAPI_PLUGIN_DB_BEGIN_FN 219 #define SLAPI_PLUGIN_DB_COMMIT_FN 220 #define SLAPI_PLUGIN_DB_ABORT_FN 221 #define SLAPI_PLUGIN_DB_ARCHIVE2DB_FN 222 #define SLAPI_PLUGIN_DB_DB2ARCHIVE_FN 223 #define SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN 224 #define SLAPI_PLUGIN_DB_FREE_RESULT_SET_FN 225 #define SLAPI_PLUGIN_DB_SIZE_FN 226 #define SLAPI_PLUGIN_DB_TEST_FN 227 /* functions pointers for LDAP V3 extended ops */ #define SLAPI_PLUGIN_EXT_OP_FN 300 #define SLAPI_PLUGIN_EXT_OP_OIDLIST 301 /* preoperation */ #define SLAPI_PLUGIN_PRE_BIND_FN 401 #define SLAPI_PLUGIN_PRE_UNBIND_FN 402 #define SLAPI_PLUGIN_PRE_SEARCH_FN 403 #define SLAPI_PLUGIN_PRE_COMPARE_FN 404 #define SLAPI_PLUGIN_PRE_MODIFY_FN 405 #define SLAPI_PLUGIN_PRE_MODRDN_FN 406 #define SLAPI_PLUGIN_PRE_ADD_FN 407 #define SLAPI_PLUGIN_PRE_DELETE_FN 408 #define SLAPI_PLUGIN_PRE_ABANDON_FN 409 #define SLAPI_PLUGIN_PRE_ENTRY_FN 410 #define SLAPI_PLUGIN_PRE_REFERRAL_FN 411 #define SLAPI_PLUGIN_PRE_RESULT_FN 412 /* internal preoperation */ #define SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN 420 #define SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN 421 #define SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN 422 #define SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN 423 /* backend preoperation */ #define SLAPI_PLUGIN_BE_PRE_ADD_FN 450 #define SLAPI_PLUGIN_BE_PRE_MODIFY_FN 451 #define SLAPI_PLUGIN_BE_PRE_MODRDN_FN 452 #define SLAPI_PLUGIN_BE_PRE_DELETE_FN 453 /* postoperation */ #define SLAPI_PLUGIN_POST_BIND_FN 501 #define SLAPI_PLUGIN_POST_UNBIND_FN 502 #define SLAPI_PLUGIN_POST_SEARCH_FN 503 #define SLAPI_PLUGIN_POST_COMPARE_FN 504 #define SLAPI_PLUGIN_POST_MODIFY_FN 505 #define SLAPI_PLUGIN_POST_MODRDN_FN 506 #define SLAPI_PLUGIN_POST_ADD_FN 507 #define SLAPI_PLUGIN_POST_DELETE_FN 508 #define SLAPI_PLUGIN_POST_ABANDON_FN 509 #define SLAPI_PLUGIN_POST_ENTRY_FN 510 #define SLAPI_PLUGIN_POST_REFERRAL_FN 511 #define SLAPI_PLUGIN_POST_RESULT_FN 512 /* internal postoperation */ #define SLAPI_PLUGIN_INTERNAL_POST_ADD_FN 520 #define SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN 521 #define SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN 522 #define SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN 523 /* backend postoperation */ #define SLAPI_PLUGIN_BE_POST_ADD_FN 550 #define SLAPI_PLUGIN_BE_POST_MODIFY_FN 551 #define SLAPI_PLUGIN_BE_POST_MODRDN_FN 552 #define SLAPI_PLUGIN_BE_POST_DELETE_FN 553 #define SLAPI_OPERATION_TYPE 590 #define SLAPI_OPERATION_MSGID 591 #define SLAPI_PLUGIN_MR_FILTER_CREATE_FN 600 #define SLAPI_PLUGIN_MR_INDEXER_CREATE_FN 601 #define SLAPI_PLUGIN_MR_FILTER_MATCH_FN 602 #define SLAPI_PLUGIN_MR_FILTER_INDEX_FN 603 #define SLAPI_PLUGIN_MR_FILTER_RESET_FN 604 #define SLAPI_PLUGIN_MR_INDEX_FN 605 #define SLAPI_PLUGIN_MR_OID 610 #define SLAPI_PLUGIN_MR_TYPE 611 #define SLAPI_PLUGIN_MR_VALUE 612 #define SLAPI_PLUGIN_MR_VALUES 613 #define SLAPI_PLUGIN_MR_KEYS 614 #define SLAPI_PLUGIN_MR_FILTER_REUSABLE 615 #define SLAPI_PLUGIN_MR_QUERY_OPERATOR 616 #define SLAPI_PLUGIN_MR_USAGE 617 #define SLAPI_MATCHINGRULE_NAME 1 #define SLAPI_MATCHINGRULE_OID 2 #define SLAPI_MATCHINGRULE_DESC 3 #define SLAPI_MATCHINGRULE_SYNTAX 4 #define SLAPI_MATCHINGRULE_OBSOLETE 5 #define SLAPI_OP_LESS 1 #define SLAPI_OP_LESS_OR_EQUAL 2 #define SLAPI_OP_EQUAL 3 #define SLAPI_OP_GREATER_OR_EQUAL 4 #define SLAPI_OP_GREATER 5 #define SLAPI_OP_SUBSTRING 6 #define SLAPI_PLUGIN_MR_USAGE_INDEX 0 #define SLAPI_PLUGIN_MR_USAGE_SORT 1 #define SLAPI_PLUGIN_SYNTAX_FILTER_AVA 700 #define SLAPI_PLUGIN_SYNTAX_FILTER_SUB 701 #define SLAPI_PLUGIN_SYNTAX_VALUES2KEYS 702 #define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA 703 #define SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB 704 #define SLAPI_PLUGIN_SYNTAX_NAMES 705 #define SLAPI_PLUGIN_SYNTAX_OID 706 #define SLAPI_PLUGIN_SYNTAX_FLAGS 707 #define SLAPI_PLUGIN_SYNTAX_COMPARE 708 #define SLAPI_PLUGIN_SYNTAX_FLAG_ORKEYS 1 #define SLAPI_PLUGIN_SYNTAX_FLAG_ORDERING 2 #define SLAPI_PLUGIN_ACL_INIT 730 #define SLAPI_PLUGIN_ACL_SYNTAX_CHECK 731 #define SLAPI_PLUGIN_ACL_ALLOW_ACCESS 732 #define SLAPI_PLUGIN_ACL_MODS_ALLOWED 733 #define SLAPI_PLUGIN_ACL_MODS_UPDATE 734 #define SLAPI_OPERATION_AUTHTYPE 741 #define SLAPI_OPERATION_ID 742 #define SLAPI_CONN_CERT 743 #define SLAPI_CONN_AUTHMETHOD 746 #define SLAPI_IS_INTERNAL_OPERATION 748 #define SLAPI_RESULT_CODE 881 #define SLAPI_RESULT_TEXT 882 #define SLAPI_RESULT_MATCHED 883 /* managedsait control */ #define SLAPI_MANAGEDSAIT 1000 /* audit plugin defines */ #define SLAPI_PLUGIN_AUDIT_DATA 1100 #define SLAPI_PLUGIN_AUDIT_FN 1101 /* backend_group extension */ #define SLAPI_X_PLUGIN_PRE_GROUP_FN 1202 #define SLAPI_X_PLUGIN_POST_GROUP_FN 1203 #define SLAPI_X_GROUP_ENTRY 1250 /* group entry */ #define SLAPI_X_GROUP_ATTRIBUTE 1251 /* member attribute */ #define SLAPI_X_GROUP_OPERATION_DN 1252 /* asserted value */ #define SLAPI_X_GROUP_TARGET_ENTRY 1253 /* target entry */ /* internal preoperation extensions */ #define SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN 1260 #define SLAPI_PLUGIN_INTERNAL_PRE_UNBIND_FN 1261 #define SLAPI_PLUGIN_INTERNAL_PRE_SEARCH_FN 1262 #define SLAPI_PLUGIN_INTERNAL_PRE_COMPARE_FN 1263 #define SLAPI_PLUGIN_INTERNAL_PRE_ABANDON_FN 1264 /* internal postoperation extensions */ #define SLAPI_PLUGIN_INTERNAL_POST_BIND_FN 1270 #define SLAPI_PLUGIN_INTERNAL_POST_UNBIND_FN 1271 #define SLAPI_PLUGIN_INTERNAL_POST_SEARCH_FN 1272 #define SLAPI_PLUGIN_INTERNAL_POST_COMPARE_FN 1273 #define SLAPI_PLUGIN_INTERNAL_POST_ABANDON_FN 1274 /* config stuff */ #define SLAPI_CONFIG_FILENAME 40 #define SLAPI_CONFIG_LINENO 41 #define SLAPI_CONFIG_ARGC 42 #define SLAPI_CONFIG_ARGV 43 /* operational params */ #define SLAPI_TARGET_ADDRESS 48 #define SLAPI_TARGET_UNIQUEID 49 #define SLAPI_TARGET_DN 50 /* server LDAPv3 controls */ #define SLAPI_REQCONTROLS 51 #define SLAPI_RESCONTROLS 55 #define SLAPI_ADD_RESCONTROL 56 #define SLAPI_CONTROLS_ARG 58 /* add params */ #define SLAPI_ADD_TARGET SLAPI_TARGET_DN #define SLAPI_ADD_ENTRY 60 #define SLAPI_ADD_EXISTING_DN_ENTRY 61 #define SLAPI_ADD_PARENT_ENTRY 62 #define SLAPI_ADD_PARENT_UNIQUEID 63 #define SLAPI_ADD_EXISTING_UNIQUEID_ENTRY 64 /* bind params */ #define SLAPI_BIND_TARGET SLAPI_TARGET_DN #define SLAPI_BIND_METHOD 70 #define SLAPI_BIND_CREDENTIALS 71 #define SLAPI_BIND_SASLMECHANISM 72 #define SLAPI_BIND_RET_SASLCREDS 73 /* compare params */ #define SLAPI_COMPARE_TARGET SLAPI_TARGET_DN #define SLAPI_COMPARE_TYPE 80 #define SLAPI_COMPARE_VALUE 81 /* delete params */ #define SLAPI_DELETE_TARGET SLAPI_TARGET_DN #define SLAPI_DELETE_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY /* modify params */ #define SLAPI_MODIFY_TARGET SLAPI_TARGET_DN #define SLAPI_MODIFY_MODS 90 #define SLAPI_MODIFY_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY /* modrdn params */ #define SLAPI_MODRDN_TARGET SLAPI_TARGET_DN #define SLAPI_MODRDN_NEWRDN 100 #define SLAPI_MODRDN_DELOLDRDN 101 #define SLAPI_MODRDN_NEWSUPERIOR 102 /* v3 only */ #define SLAPI_MODRDN_EXISTING_ENTRY SLAPI_ADD_EXISTING_DN_ENTRY #define SLAPI_MODRDN_PARENT_ENTRY 104 #define SLAPI_MODRDN_NEWPARENT_ENTRY 105 #define SLAPI_MODRDN_TARGET_ENTRY 106 #define SLAPI_MODRDN_NEWSUPERIOR_ADDRESS 107 /* search params */ #define SLAPI_SEARCH_TARGET SLAPI_TARGET_DN #define SLAPI_SEARCH_SCOPE 110 #define SLAPI_SEARCH_DEREF 111 #define SLAPI_SEARCH_SIZELIMIT 112 #define SLAPI_SEARCH_TIMELIMIT 113 #define SLAPI_SEARCH_FILTER 114 #define SLAPI_SEARCH_STRFILTER 115 #define SLAPI_SEARCH_ATTRS 116 #define SLAPI_SEARCH_ATTRSONLY 117 /* abandon params */ #define SLAPI_ABANDON_MSGID 120 /* extended operation params */ #define SLAPI_EXT_OP_REQ_OID 160 #define SLAPI_EXT_OP_REQ_VALUE 161 /* extended operation return codes */ #define SLAPI_EXT_OP_RET_OID 162 #define SLAPI_EXT_OP_RET_VALUE 163 #define SLAPI_PLUGIN_EXTENDED_SENT_RESULT -1 #define SLAPI_FAIL_DISKFULL -2 #define SLAPI_FAIL_GENERAL -1 #define SLAPI_PLUGIN_EXTENDED_NOT_HANDLED -2 #define SLAPI_BIND_SUCCESS 0 #define SLAPI_BIND_FAIL 2 #define SLAPI_BIND_ANONYMOUS 3 /* Search result params */ #define SLAPI_SEARCH_RESULT_SET 193 #define SLAPI_SEARCH_RESULT_ENTRY 194 #define SLAPI_NENTRIES 195 #define SLAPI_SEARCH_REFERRALS 196 /* filter types */ #ifndef LDAP_FILTER_AND #define LDAP_FILTER_AND 0xa0L #endif #ifndef LDAP_FILTER_OR #define LDAP_FILTER_OR 0xa1L #endif #ifndef LDAP_FILTER_NOT #define LDAP_FILTER_NOT 0xa2L #endif #ifndef LDAP_FILTER_EQUALITY #define LDAP_FILTER_EQUALITY 0xa3L #endif #ifndef LDAP_FILTER_SUBSTRINGS #define LDAP_FILTER_SUBSTRINGS 0xa4L #endif #ifndef LDAP_FILTER_GE #define LDAP_FILTER_GE 0xa5L #endif #ifndef LDAP_FILTER_LE #define LDAP_FILTER_LE 0xa6L #endif #ifndef LDAP_FILTER_PRESENT #define LDAP_FILTER_PRESENT 0x87L #endif #ifndef LDAP_FILTER_APPROX #define LDAP_FILTER_APPROX 0xa8L #endif #ifndef LDAP_FILTER_EXT_MATCH #define LDAP_FILTER_EXT_MATCH 0xa9L #endif int slapi_log_error( int severity, char *subsystem, char *fmt, ... ); #define SLAPI_LOG_FATAL 0 #define SLAPI_LOG_TRACE 1 #define SLAPI_LOG_PACKETS 2 #define SLAPI_LOG_ARGS 3 #define SLAPI_LOG_CONNS 4 #define SLAPI_LOG_BER 5 #define SLAPI_LOG_FILTER 6 #define SLAPI_LOG_CONFIG 7 #define SLAPI_LOG_ACL 8 #define SLAPI_LOG_SHELL 9 #define SLAPI_LOG_PARSE 10 #define SLAPI_LOG_HOUSE 11 #define SLAPI_LOG_REPL 12 #define SLAPI_LOG_CACHE 13 #define SLAPI_LOG_PLUGIN 14 #define SLAPI_LOG_TIMING 15 #define SLAPI_PLUGIN_DESCRIPTION 12 typedef struct slapi_plugindesc { char *spd_id; char *spd_vendor; char *spd_version; char *spd_description; } Slapi_PluginDesc; #define SLAPI_PLUGIN_VERSION_01 "01" #define SLAPI_PLUGIN_VERSION_02 "02" #define SLAPI_PLUGIN_VERSION_03 "03" #define SLAPI_PLUGIN_CURRENT_VERSION SLAPI_PLUGIN_VERSION_03 #endif /* _SLAPI_PLUGIN_H */ #include <sys/syscall.h> /* Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* * POSIX Standard: 2.10 Symbolic Constants <unistd.h> */ #ifndef _UNISTD_H #define _UNISTD_H 1 #include <features.h> __BEGIN_DECLS /* These may be used to determine what facilities are present at compile time. Their values can be obtained at run time from `sysconf'. */ #ifdef __USE_XOPEN2K8 /* POSIX Standard approved as ISO/IEC 9945-1 as of September 2008. */ # define _POSIX_VERSION 200809L #elif defined __USE_XOPEN2K /* POSIX Standard approved as ISO/IEC 9945-1 as of December 2001. */ # define _POSIX_VERSION 200112L #elif defined __USE_POSIX199506 /* POSIX Standard approved as ISO/IEC 9945-1 as of June 1995. */ # define _POSIX_VERSION 199506L #elif defined __USE_POSIX199309 /* POSIX Standard approved as ISO/IEC 9945-1 as of September 1993. */ # define _POSIX_VERSION 199309L #else /* POSIX Standard approved as ISO/IEC 9945-1 as of September 1990. */ # define _POSIX_VERSION 199009L #endif /* These are not #ifdef __USE_POSIX2 because they are in the theoretically application-owned namespace. */ #ifdef __USE_XOPEN2K8 # define __POSIX2_THIS_VERSION 200809L /* The utilities on GNU systems also correspond to this version. */ #elif defined __USE_XOPEN2K /* The utilities on GNU systems also correspond to this version. */ # define __POSIX2_THIS_VERSION 200112L #elif defined __USE_POSIX199506 /* The utilities on GNU systems also correspond to this version. */ # define __POSIX2_THIS_VERSION 199506L #else /* The utilities on GNU systems also correspond to this version. */ # define __POSIX2_THIS_VERSION 199209L #endif /* The utilities on GNU systems also correspond to this version. */ #define _POSIX2_VERSION __POSIX2_THIS_VERSION /* This symbol was required until the 2001 edition of POSIX. */ #define _POSIX2_C_VERSION __POSIX2_THIS_VERSION /* If defined, the implementation supports the C Language Bindings Option. */ #define _POSIX2_C_BIND __POSIX2_THIS_VERSION /* If defined, the implementation supports the C Language Development Utilities Option. */ #define _POSIX2_C_DEV __POSIX2_THIS_VERSION /* If defined, the implementation supports the Software Development Utilities Option. */ #define _POSIX2_SW_DEV __POSIX2_THIS_VERSION /* If defined, the implementation supports the creation of locales with the localedef utility. */ #define _POSIX2_LOCALEDEF __POSIX2_THIS_VERSION /* X/Open version number to which the library conforms. It is selectable. */ #ifdef __USE_XOPEN2K8 # define _XOPEN_VERSION 700 #elif defined __USE_XOPEN2K # define _XOPEN_VERSION 600 #elif defined __USE_UNIX98 # define _XOPEN_VERSION 500 #else # define _XOPEN_VERSION 4 #endif /* Commands and utilities from XPG4 are available. */ #define _XOPEN_XCU_VERSION 4 /* We are compatible with the old published standards as well. */ #define _XOPEN_XPG2 1 #define _XOPEN_XPG3 1 #define _XOPEN_XPG4 1 /* The X/Open Unix extensions are available. */ #define _XOPEN_UNIX 1 /* The enhanced internationalization capabilities according to XPG4.2 are present. */ #define _XOPEN_ENH_I18N 1 /* The legacy interfaces are also available. */ #define _XOPEN_LEGACY 1 /* Get values of POSIX options: If these symbols are defined, the corresponding features are always available. If not, they may be available sometimes. The current values can be obtained with `sysconf'. _POSIX_JOB_CONTROL Job control is supported. _POSIX_SAVED_IDS Processes have a saved set-user-ID and a saved set-group-ID. _POSIX_REALTIME_SIGNALS Real-time, queued signals are supported. _POSIX_PRIORITY_SCHEDULING Priority scheduling is supported. _POSIX_TIMERS POSIX.4 clocks and timers are supported. _POSIX_ASYNCHRONOUS_IO Asynchronous I/O is supported. _POSIX_PRIORITIZED_IO Prioritized asynchronous I/O is supported. _POSIX_SYNCHRONIZED_IO Synchronizing file data is supported. _POSIX_FSYNC The fsync function is present. _POSIX_MAPPED_FILES Mapping of files to memory is supported. _POSIX_MEMLOCK Locking of all memory is supported. _POSIX_MEMLOCK_RANGE Locking of ranges of memory is supported. _POSIX_MEMORY_PROTECTION Setting of memory protections is supported. _POSIX_MESSAGE_PASSING POSIX.4 message queues are supported. _POSIX_SEMAPHORES POSIX.4 counting semaphores are supported. _POSIX_SHARED_MEMORY_OBJECTS POSIX.4 shared memory objects are supported. _POSIX_THREADS POSIX.1c pthreads are supported. _POSIX_THREAD_ATTR_STACKADDR Thread stack address attribute option supported. _POSIX_THREAD_ATTR_STACKSIZE Thread stack size attribute option supported. _POSIX_THREAD_SAFE_FUNCTIONS Thread-safe functions are supported. _POSIX_THREAD_PRIORITY_SCHEDULING POSIX.1c thread execution scheduling supported. _POSIX_THREAD_PRIO_INHERIT Thread priority inheritance option supported. _POSIX_THREAD_PRIO_PROTECT Thread priority protection option supported. _POSIX_THREAD_PROCESS_SHARED Process-shared synchronization supported. _POSIX_PII Protocol-independent interfaces are supported. _POSIX_PII_XTI XTI protocol-indep. interfaces are supported. _POSIX_PII_SOCKET Socket protocol-indep. interfaces are supported. _POSIX_PII_INTERNET Internet family of protocols supported. _POSIX_PII_INTERNET_STREAM Connection-mode Internet protocol supported. _POSIX_PII_INTERNET_DGRAM Connectionless Internet protocol supported. _POSIX_PII_OSI ISO/OSI family of protocols supported. _POSIX_PII_OSI_COTS Connection-mode ISO/OSI service supported. _POSIX_PII_OSI_CLTS Connectionless ISO/OSI service supported. _POSIX_POLL Implementation supports `poll' function. _POSIX_SELECT Implementation supports `select' and `pselect'. _XOPEN_REALTIME X/Open realtime support is available. _XOPEN_REALTIME_THREADS X/Open realtime thread support is available. _XOPEN_SHM Shared memory interface according to XPG4.2. _XBS5_ILP32_OFF32 Implementation provides environment with 32-bit int, long, pointer, and off_t types. _XBS5_ILP32_OFFBIG Implementation provides environment with 32-bit int, long, and pointer and off_t with at least 64 bits. _XBS5_LP64_OFF64 Implementation provides environment with 32-bit int, and 64-bit long, pointer, and off_t types. _XBS5_LPBIG_OFFBIG Implementation provides environment with at least 32 bits int and long, pointer, and off_t with at least 64 bits. If any of these symbols is defined as -1, the corresponding option is not true for any file. If any is defined as other than -1, the corresponding option is true for all files. If a symbol is not defined at all, the value for a specific file can be obtained from `pathconf' and `fpathconf'. _POSIX_CHOWN_RESTRICTED Only the super user can use `chown' to change the owner of a file. `chown' can only be used to change the group ID of a file to a group of which the calling process is a member. _POSIX_NO_TRUNC Pathname components longer than NAME_MAX generate an error. _POSIX_VDISABLE If defined, if the value of an element of the `c_cc' member of `struct termios' is _POSIX_VDISABLE, no character will have the effect associated with that element. _POSIX_SYNC_IO Synchronous I/O may be performed. _POSIX_ASYNC_IO Asynchronous I/O may be performed. _POSIX_PRIO_IO Prioritized Asynchronous I/O may be performed. Support for the Large File Support interface is not generally available. If it is available the following constants are defined to one. _LFS64_LARGEFILE Low-level I/O supports large files. _LFS64_STDIO Standard I/O supports large files. */ #include <bits/posix_opt.h> /* Get the environment definitions from Unix98. */ #if defined __USE_UNIX98 || defined __USE_XOPEN2K # include <bits/environments.h> #endif /* Standard file descriptors. */ #define STDIN_FILENO 0 /* Standard input. */ #define STDOUT_FILENO 1 /* Standard output. */ #define STDERR_FILENO 2 /* Standard error output. */ /* All functions that are not declared anywhere else. */ #include <bits/types.h> #ifndef __ssize_t_defined typedef __ssize_t ssize_t; # define __ssize_t_defined #endif #define __need_size_t #define __need_NULL #include <stddef.h> #if defined __USE_XOPEN || defined __USE_XOPEN2K /* The Single Unix specification says that some more types are available here. */ # ifndef __gid_t_defined typedef __gid_t gid_t; # define __gid_t_defined # endif # ifndef __uid_t_defined typedef __uid_t uid_t; # define __uid_t_defined # endif # ifndef __off_t_defined # ifndef __USE_FILE_OFFSET64 typedef __off_t off_t; # else typedef __off64_t off_t; # endif # define __off_t_defined # endif # if defined __USE_LARGEFILE64 && !defined __off64_t_defined typedef __off64_t off64_t; # define __off64_t_defined # endif # ifndef __useconds_t_defined typedef __useconds_t useconds_t; # define __useconds_t_defined # endif # ifndef __pid_t_defined typedef __pid_t pid_t; # define __pid_t_defined # endif #endif /* X/Open */ #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K # ifndef __intptr_t_defined typedef __intptr_t intptr_t; # define __intptr_t_defined # endif #endif #if defined __USE_MISC || defined __USE_XOPEN # ifndef __socklen_t_defined typedef __socklen_t socklen_t; # define __socklen_t_defined # endif #endif /* Values for the second argument to access. These may be OR'd together. */ #define R_OK 4 /* Test for read permission. */ #define W_OK 2 /* Test for write permission. */ #define X_OK 1 /* Test for execute permission. */ #define F_OK 0 /* Test for existence. */ /* Test for access to NAME using the real UID and real GID. */ extern int access (const char *__name, int __type) __THROW __nonnull ((1)); #ifdef __USE_GNU /* Test for access to NAME using the effective UID and GID (as normal file operations use). */ extern int euidaccess (const char *__name, int __type) __THROW __nonnull ((1)); /* An alias for `euidaccess', used by some other systems. */ extern int eaccess (const char *__name, int __type) __THROW __nonnull ((1)); /* Execute program relative to a directory file descriptor. */ extern int execveat (int __fd, const char *__path, char *const __argv[], char *const __envp[], int __flags) __THROW __nonnull ((2, 3)); #endif #ifdef __USE_ATFILE /* Test for access to FILE relative to the directory FD is open on. If AT_EACCESS is set in FLAG, then use effective IDs like `eaccess', otherwise use real IDs like `access'. */ extern int faccessat (int __fd, const char *__file, int __type, int __flag) __THROW __nonnull ((2)) __wur; #endif /* Use GNU. */ /* Values for the WHENCE argument to lseek. */ #ifndef _STDIO_H /* <stdio.h> has the same definitions. */ # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Seek from end of file. */ # ifdef __USE_GNU # define SEEK_DATA 3 /* Seek to next data. */ # define SEEK_HOLE 4 /* Seek to next hole. */ # endif #endif #if defined __USE_MISC && !defined L_SET /* Old BSD names for the same constants; just for compatibility. */ # define L_SET SEEK_SET # define L_INCR SEEK_CUR # define L_XTND SEEK_END #endif /* Move FD's file position to OFFSET bytes from the beginning of the file (if WHENCE is SEEK_SET), the current position (if WHENCE is SEEK_CUR), or the end of the file (if WHENCE is SEEK_END). Return the new file position. */ #ifndef __USE_FILE_OFFSET64 extern __off_t lseek (int __fd, __off_t __offset, int __whence) __THROW; #else # ifdef __REDIRECT_NTH extern __off64_t __REDIRECT_NTH (lseek, (int __fd, __off64_t __offset, int __whence), lseek64); # else # define lseek lseek64 # endif #endif #ifdef __USE_LARGEFILE64 extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence) __THROW; #endif /* Close the file descriptor FD. This function is a cancellation point and therefore not marked with __THROW. */ extern int close (int __fd); #ifdef __USE_MISC /* Close all open file descriptors greater than or equal to LOWFD. Negative LOWFD is clamped to 0. */ extern void closefrom (int __lowfd) __THROW; #endif /* Read NBYTES into BUF from FD. Return the number read, -1 for errors or 0 for EOF. This function is a cancellation point and therefore not marked with __THROW. */ extern ssize_t read (int __fd, void *__buf, size_t __nbytes) __wur __fortified_attr_access (__write_only__, 2, 3); /* Write N bytes of BUF to FD. Return the number written, or -1. This function is a cancellation point and therefore not marked with __THROW. */ extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur __attr_access ((__read_only__, 2, 3)); #if defined __USE_UNIX98 || defined __USE_XOPEN2K8 # ifndef __USE_FILE_OFFSET64 /* Read NBYTES into BUF from FD at the given position OFFSET without changing the file pointer. Return the number read, -1 for errors or 0 for EOF. This function is a cancellation point and therefore not marked with __THROW. */ extern ssize_t pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset) __wur __fortified_attr_access (__write_only__, 2, 3); /* Write N bytes of BUF to FD at the given position OFFSET without changing the file pointer. Return the number written, or -1. This function is a cancellation point and therefore not marked with __THROW. */ extern ssize_t pwrite (int __fd, const void *__buf, size_t __n, __off_t __offset) __wur __attr_access ((__read_only__, 2, 3)); # else # ifdef __REDIRECT extern ssize_t __REDIRECT (pread, (int __fd, void *__buf, size_t __nbytes, __off64_t __offset), pread64) __wur __fortified_attr_access (__write_only__, 2, 3); extern ssize_t __REDIRECT (pwrite, (int __fd, const void *__buf, size_t __nbytes, __off64_t __offset), pwrite64) __wur __attr_access ((__read_only__, 2, 3)); # else # define pread pread64 # define pwrite pwrite64 # endif # endif # ifdef __USE_LARGEFILE64 /* Read NBYTES into BUF from FD at the given position OFFSET without changing the file pointer. Return the number read, -1 for errors or 0 for EOF. */ extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset) __wur __fortified_attr_access (__write_only__, 2, 3); /* Write N bytes of BUF to FD at the given position OFFSET without changing the file pointer. Return the number written, or -1. */ extern ssize_t pwrite64 (int __fd, const void *__buf, size_t __n, __off64_t __offset) __wur __attr_access ((__read_only__, 2, 3)); # endif #endif /* Create a one-way communication channel (pipe). If successful, two file descriptors are stored in PIPEDES; bytes written on PIPEDES[1] can be read from PIPEDES[0]. Returns 0 if successful, -1 if not. */ extern int pipe (int __pipedes[2]) __THROW __wur; #ifdef __USE_GNU /* Same as pipe but apply flags passed in FLAGS to the new file descriptors. */ extern int pipe2 (int __pipedes[2], int __flags) __THROW __wur; #endif /* Schedule an alarm. In SECONDS seconds, the process will get a SIGALRM. If SECONDS is zero, any currently scheduled alarm will be cancelled. The function returns the number of seconds remaining until the last alarm scheduled would have signaled, or zero if there wasn't one. There is no return value to indicate an error, but you can set `errno' to 0 and check its value after calling `alarm', and this might tell you. The signal may come late due to processor scheduling. */ extern unsigned int alarm (unsigned int __seconds) __THROW; /* Make the process sleep for SECONDS seconds, or until a signal arrives and is not ignored. The function returns the number of seconds less than SECONDS which it actually slept (thus zero if it slept the full time). If a signal handler does a `longjmp' or modifies the handling of the SIGALRM signal while inside `sleep' call, the handling of the SIGALRM signal afterwards is undefined. There is no return value to indicate error, but if `sleep' returns SECONDS, it probably didn't work. This function is a cancellation point and therefore not marked with __THROW. */ extern unsigned int sleep (unsigned int __seconds); #if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \ || defined __USE_MISC /* Set an alarm to go off (generating a SIGALRM signal) in VALUE microseconds. If INTERVAL is nonzero, when the alarm goes off, the timer is reset to go off every INTERVAL microseconds thereafter. Returns the number of microseconds remaining before the alarm. */ extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval) __THROW; /* Sleep USECONDS microseconds, or until a signal arrives that is not blocked or ignored. This function is a cancellation point and therefore not marked with __THROW. */ extern int usleep (__useconds_t __useconds); #endif /* Suspend the process until a signal arrives. This always returns -1 and sets `errno' to EINTR. This function is a cancellation point and therefore not marked with __THROW. */ extern int pause (void); /* Change the owner and group of FILE. */ extern int chown (const char *__file, __uid_t __owner, __gid_t __group) __THROW __nonnull ((1)) __wur; #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 /* Change the owner and group of the file that FD is open on. */ extern int fchown (int __fd, __uid_t __owner, __gid_t __group) __THROW __wur; /* Change owner and group of FILE, if it is a symbolic link the ownership of the symbolic link is changed. */ extern int lchown (const char *__file, __uid_t __owner, __gid_t __group) __THROW __nonnull ((1)) __wur; #endif /* Use X/Open Unix. */ #ifdef __USE_ATFILE /* Change the owner and group of FILE relative to the directory FD is open on. */ extern int fchownat (int __fd, const char *__file, __uid_t __owner, __gid_t __group, int __flag) __THROW __nonnull ((2)) __wur; #endif /* Use GNU. */ /* Change the process's working directory to PATH. */ extern int chdir (const char *__path) __THROW __nonnull ((1)) __wur; #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 /* Change the process's working directory to the one FD is open on. */ extern int fchdir (int __fd) __THROW __wur; #endif /* Get the pathname of the current working directory, and put it in SIZE bytes of BUF. Returns NULL if the directory couldn't be determined or SIZE was too small. If successful, returns BUF. In GNU, if BUF is NULL, an array is allocated with `malloc'; the array is SIZE bytes long, unless SIZE == 0, in which case it is as big as necessary. */ extern char *getcwd (char *__buf, size_t __size) __THROW __wur; #ifdef __USE_GNU /* Return a malloc'd string containing the current directory name. If the environment variable `PWD' is set, and its value is correct, that value is used. */ extern char *get_current_dir_name (void) __THROW; #endif #if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \ || defined __USE_MISC /* Put the absolute pathname of the current working directory in BUF. If successful, return BUF. If not, put an error message in BUF and return NULL. BUF should be at least PATH_MAX bytes long. */ extern char *getwd (char *__buf) __THROW __nonnull ((1)) __attribute_deprecated__ __wur __attr_access ((__write_only__, 1)); #endif /* Duplicate FD, returning a new file descriptor on the same file. */ extern int dup (int __fd) __THROW __wur; /* Duplicate FD to FD2, closing FD2 and making it open on the same file. */ extern int dup2 (int __fd, int __fd2) __THROW; #ifdef __USE_GNU /* Duplicate FD to FD2, closing FD2 and making it open on the same file while setting flags according to FLAGS. */ extern int dup3 (int __fd, int __fd2, int __flags) __THROW; #endif /* NULL-terminated array of "NAME=VALUE" environment variables. */ extern char **__environ; #ifdef __USE_GNU extern char **environ; #endif /* Replace the current process, executing PATH with arguments ARGV and environment ENVP. ARGV and ENVP are terminated by NULL pointers. */ extern int execve (const char *__path, char *const __argv[], char *const __envp[]) __THROW __nonnull ((1, 2)); #ifdef __USE_XOPEN2K8 /* Execute the file FD refers to, overlaying the running program image. ARGV and ENVP are passed to the new program, as for `execve'. */ extern int fexecve (int __fd, char *const __argv[], char *const __envp[]) __THROW __nonnull ((2)); #endif /* Execute PATH with arguments ARGV and environment from `environ'. */ extern int execv (const char *__path, char *const __argv[]) __THROW __nonnull ((1, 2)); /* Execute PATH with all arguments after PATH until a NULL pointer, and the argument after that for environment. */ extern int execle (const char *__path, const char *__arg, ...) __THROW __nonnull ((1, 2)); /* Execute PATH with all arguments after PATH until a NULL pointer and environment from `environ'. */ extern int execl (const char *__path, const char *__arg, ...) __THROW __nonnull ((1, 2)); /* Execute FILE, searching in the `PATH' environment variable if it contains no slashes, with arguments ARGV and environment from `environ'. */ extern int execvp (const char *__file, char *const __argv[]) __THROW __nonnull ((1, 2)); /* Execute FILE, searching in the `PATH' environment variable if it contains no slashes, with all arguments after FILE until a NULL pointer and environment from `environ'. */ extern int execlp (const char *__file, const char *__arg, ...) __THROW __nonnull ((1, 2)); #ifdef __USE_GNU /* Execute FILE, searching in the `PATH' environment variable if it contains no slashes, with arguments ARGV and environment from `environ'. */ extern int execvpe (const char *__file, char *const __argv[], char *const __envp[]) __THROW __nonnull ((1, 2)); #endif #if defined __USE_MISC || defined __USE_XOPEN /* Add INC to priority of the current process. */ extern int nice (int __inc) __THROW __wur; #endif /* Terminate program execution with the low-order 8 bits of STATUS. */ extern void _exit (int __status) __attribute__ ((__noreturn__)); /* Get the `_PC_*' symbols for the NAME argument to `pathconf' and `fpathconf'; the `_SC_*' symbols for the NAME argument to `sysconf'; and the `_CS_*' symbols for the NAME argument to `confstr'. */ #include <bits/confname.h> /* Get file-specific configuration information about PATH. */ extern long int pathconf (const char *__path, int __name) __THROW __nonnull ((1)); /* Get file-specific configuration about descriptor FD. */ extern long int fpathconf (int __fd, int __name) __THROW; /* Get the value of the system variable NAME. */ extern long int sysconf (int __name) __THROW; #ifdef __USE_POSIX2 /* Get the value of the string-valued system variable NAME. */ extern size_t confstr (int __name, char *__buf, size_t __len) __THROW __fortified_attr_access (__write_only__, 2, 3); #endif /* Get the process ID of the calling process. */ extern __pid_t getpid (void) __THROW; /* Get the process ID of the calling process's parent. */ extern __pid_t getppid (void) __THROW; /* Get the process group ID of the calling process. */ extern __pid_t getpgrp (void) __THROW; /* Get the process group ID of process PID. */ extern __pid_t __getpgid (__pid_t __pid) __THROW; #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 extern __pid_t getpgid (__pid_t __pid) __THROW; #endif /* Set the process group ID of the process matching PID to PGID. If PID is zero, the current process's process group ID is set. If PGID is zero, the process ID of the process is used. */ extern int setpgid (__pid_t __pid, __pid_t __pgid) __THROW; #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED /* Both System V and BSD have `setpgrp' functions, but with different calling conventions. The BSD function is the same as POSIX.1 `setpgid' (above). The System V function takes no arguments and puts the calling process in its on group like `setpgid (0, 0)'. New programs should always use `setpgid' instead. GNU provides the POSIX.1 function. */ /* Set the process group ID of the calling process to its own PID. This is exactly the same as `setpgid (0, 0)'. */ extern int setpgrp (void) __THROW; #endif /* Use misc or X/Open. */ /* Create a new session with the calling process as its leader. The process group IDs of the session and the calling process are set to the process ID of the calling process, which is returned. */ extern __pid_t setsid (void) __THROW; #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 /* Return the session ID of the given process. */ extern __pid_t getsid (__pid_t __pid) __THROW; #endif /* Get the real user ID of the calling process. */ extern __uid_t getuid (void) __THROW; /* Get the effective user ID of the calling process. */ extern __uid_t geteuid (void) __THROW; /* Get the real group ID of the calling process. */ extern __gid_t getgid (void) __THROW; /* Get the effective group ID of the calling process. */ extern __gid_t getegid (void) __THROW; /* If SIZE is zero, return the number of supplementary groups the calling process is in. Otherwise, fill in the group IDs of its supplementary groups in LIST and return the number written. */ extern int getgroups (int __size, __gid_t __list[]) __THROW __wur __fortified_attr_access (__write_only__, 2, 1); #ifdef __USE_GNU /* Return nonzero iff the calling process is in group GID. */ extern int group_member (__gid_t __gid) __THROW; #endif /* Set the user ID of the calling process to UID. If the calling process is the super-user, set the real and effective user IDs, and the saved set-user-ID to UID; if not, the effective user ID is set to UID. */ extern int setuid (__uid_t __uid) __THROW __wur; #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED /* Set the real user ID of the calling process to RUID, and the effective user ID of the calling process to EUID. */ extern int setreuid (__uid_t __ruid, __uid_t __euid) __THROW __wur; #endif #ifdef __USE_XOPEN2K /* Set the effective user ID of the calling process to UID. */ extern int seteuid (__uid_t __uid) __THROW __wur; #endif /* Use POSIX.1-2001. */ /* Set the group ID of the calling process to GID. If the calling process is the super-user, set the real and effective group IDs, and the saved set-group-ID to GID; if not, the effective group ID is set to GID. */ extern int setgid (__gid_t __gid) __THROW __wur; #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED /* Set the real group ID of the calling process to RGID, and the effective group ID of the calling process to EGID. */ extern int setregid (__gid_t __rgid, __gid_t __egid) __THROW __wur; #endif #ifdef __USE_XOPEN2K /* Set the effective group ID of the calling process to GID. */ extern int setegid (__gid_t __gid) __THROW __wur; #endif /* Use POSIX.1-2001. */ #ifdef __USE_GNU /* Fetch the real user ID, effective user ID, and saved-set user ID, of the calling process. */ extern int getresuid (__uid_t *__ruid, __uid_t *__euid, __uid_t *__suid) __THROW; /* Fetch the real group ID, effective group ID, and saved-set group ID, of the calling process. */ extern int getresgid (__gid_t *__rgid, __gid_t *__egid, __gid_t *__sgid) __THROW; /* Set the real user ID, effective user ID, and saved-set user ID, of the calling process to RUID, EUID, and SUID, respectively. */ extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid) __THROW __wur; /* Set the real group ID, effective group ID, and saved-set group ID, of the calling process to RGID, EGID, and SGID, respectively. */ extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid) __THROW __wur; #endif /* Clone the calling process, creating an exact copy. Return -1 for errors, 0 to the new process, and the process ID of the new process to the old process. */ extern __pid_t fork (void) __THROWNL; #if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8) \ || defined __USE_MISC /* Clone the calling process, but without copying the whole address space. The calling process is suspended until the new process exits or is replaced by a call to `execve'. Return -1 for errors, 0 to the new process, and the process ID of the new process to the old process. */ extern __pid_t vfork (void) __THROW; #endif /* Use misc or XPG < 7. */ #ifdef __USE_GNU /* This is similar to fork, however it does not run the atfork handlers neither reinitialize any internal locks in multithread case. Different than fork, _Fork is async-signal-safe. */ extern __pid_t _Fork (void) __THROW; #endif /* Return the pathname of the terminal FD is open on, or NULL on errors. The returned storage is good only until the next call to this function. */ extern char *ttyname (int __fd) __THROW; /* Store at most BUFLEN characters of the pathname of the terminal FD is open on in BUF. Return 0 on success, otherwise an error number. */ extern int ttyname_r (int __fd, char *__buf, size_t __buflen) __THROW __nonnull ((2)) __wur __fortified_attr_access (__write_only__, 2, 3); /* Return 1 if FD is a valid descriptor associated with a terminal, zero if not. */ extern int isatty (int __fd) __THROW; #ifdef __USE_MISC /* Return the index into the active-logins file (utmp) for the controlling terminal. */ extern int ttyslot (void) __THROW; #endif /* Make a link to FROM named TO. */ extern int link (const char *__from, const char *__to) __THROW __nonnull ((1, 2)) __wur; #ifdef __USE_ATFILE /* Like link but relative paths in TO and FROM are interpreted relative to FROMFD and TOFD respectively. */ extern int linkat (int __fromfd, const char *__from, int __tofd, const char *__to, int __flags) __THROW __nonnull ((2, 4)) __wur; #endif #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K /* Make a symbolic link to FROM named TO. */ extern int symlink (const char *__from, const char *__to) __THROW __nonnull ((1, 2)) __wur; /* Read the contents of the symbolic link PATH into no more than LEN bytes of BUF. The contents are not null-terminated. Returns the number of characters read, or -1 for errors. */ extern ssize_t readlink (const char *__restrict __path, char *__restrict __buf, size_t __len) __THROW __nonnull ((1, 2)) __wur __fortified_attr_access (__write_only__, 2, 3); #endif /* Use POSIX.1-2001. */ #ifdef __USE_ATFILE /* Like symlink but a relative path in TO is interpreted relative to TOFD. */ extern int symlinkat (const char *__from, int __tofd, const char *__to) __THROW __nonnull ((1, 3)) __wur; /* Like readlink but a relative PATH is interpreted relative to FD. */ extern ssize_t readlinkat (int __fd, const char *__restrict __path, char *__restrict __buf, size_t __len) __THROW __nonnull ((2, 3)) __wur __fortified_attr_access (__write_only__, 3, 4); #endif /* Remove the link NAME. */ extern int unlink (const char *__name) __THROW __nonnull ((1)); #ifdef __USE_ATFILE /* Remove the link NAME relative to FD. */ extern int unlinkat (int __fd, const char *__name, int __flag) __THROW __nonnull ((2)); #endif /* Remove the directory PATH. */ extern int rmdir (const char *__path) __THROW __nonnull ((1)); /* Return the foreground process group ID of FD. */ extern __pid_t tcgetpgrp (int __fd) __THROW; /* Set the foreground process group ID of FD set PGRP_ID. */ extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) __THROW; /* Return the login name of the user. This function is a possible cancellation point and therefore not marked with __THROW. */ extern char *getlogin (void); #ifdef __USE_POSIX199506 /* Return at most NAME_LEN characters of the login name of the user in NAME. If it cannot be determined or some other error occurred, return the error code. Otherwise return 0. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int getlogin_r (char *__name, size_t __name_len) __nonnull ((1)) __fortified_attr_access (__write_only__, 1, 2); #endif #ifdef __USE_MISC /* Set the login name returned by `getlogin'. */ extern int setlogin (const char *__name) __THROW __nonnull ((1)); #endif #ifdef __USE_POSIX2 /* Get definitions and prototypes for functions to process the arguments in ARGV (ARGC of them, minus the program name) for options given in OPTS. */ # include <bits/getopt_posix.h> #endif #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K /* Put the name of the current host in no more than LEN bytes of NAME. The result is null-terminated if LEN is large enough for the full name and the terminator. */ extern int gethostname (char *__name, size_t __len) __THROW __nonnull ((1)) __fortified_attr_access (__write_only__, 1, 2); #endif #if defined __USE_MISC /* Set the name of the current host to NAME, which is LEN bytes long. This call is restricted to the super-user. */ extern int sethostname (const char *__name, size_t __len) __THROW __nonnull ((1)) __wur __attr_access ((__read_only__, 1, 2)); /* Set the current machine's Internet number to ID. This call is restricted to the super-user. */ extern int sethostid (long int __id) __THROW __wur; /* Get and set the NIS (aka YP) domain name, if any. Called just like `gethostname' and `sethostname'. The NIS domain name is usually the empty string when not using NIS. */ extern int getdomainname (char *__name, size_t __len) __THROW __nonnull ((1)) __wur __fortified_attr_access (__write_only__, 1, 2); extern int setdomainname (const char *__name, size_t __len) __THROW __nonnull ((1)) __wur __attr_access ((__read_only__, 1, 2)); /* Revoke access permissions to all processes currently communicating with the control terminal, and then send a SIGHUP signal to the process group of the control terminal. */ extern int vhangup (void) __THROW; /* Revoke the access of all descriptors currently open on FILE. */ extern int revoke (const char *__file) __THROW __nonnull ((1)) __wur; /* Enable statistical profiling, writing samples of the PC into at most SIZE bytes of SAMPLE_BUFFER; every processor clock tick while profiling is enabled, the system examines the user PC and increments SAMPLE_BUFFER[((PC - OFFSET) / 2) * SCALE / 65536]. If SCALE is zero, disable profiling. Returns zero on success, -1 on error. */ extern int profil (unsigned short int *__sample_buffer, size_t __size, size_t __offset, unsigned int __scale) __THROW __nonnull ((1)); /* Turn accounting on if NAME is an existing file. The system will then write a record for each process as it terminates, to this file. If NAME is NULL, turn accounting off. This call is restricted to the super-user. */ extern int acct (const char *__name) __THROW; /* Successive calls return the shells listed in `/etc/shells'. */ extern char *getusershell (void) __THROW; extern void endusershell (void) __THROW; /* Discard cached info. */ extern void setusershell (void) __THROW; /* Rewind and re-read the file. */ /* Put the program in the background, and dissociate from the controlling terminal. If NOCHDIR is zero, do `chdir ("/")'. If NOCLOSE is zero, redirects stdin, stdout, and stderr to /dev/null. */ extern int daemon (int __nochdir, int __noclose) __THROW __wur; #endif /* Use misc. */ #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K) /* Make PATH be the root directory (the starting point for absolute paths). This call is restricted to the super-user. */ extern int chroot (const char *__path) __THROW __nonnull ((1)) __wur; /* Prompt with PROMPT and read a string from the terminal without echoing. Uses /dev/tty if possible; otherwise stderr and stdin. */ extern char *getpass (const char *__prompt) __nonnull ((1)); #endif /* Use misc || X/Open. */ /* Make all changes done to FD actually appear on disk. This function is a cancellation point and therefore not marked with __THROW. */ extern int fsync (int __fd); #ifdef __USE_GNU /* Make all changes done to all files on the file system associated with FD actually appear on disk. */ extern int syncfs (int __fd) __THROW; #endif #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED /* Return identifier for the current host. */ extern long int gethostid (void); /* Make all changes done to all files actually appear on disk. */ extern void sync (void) __THROW; # if defined __USE_MISC || !defined __USE_XOPEN2K /* Return the number of bytes in a page. This is the system's page size, which is not necessarily the same as the hardware page size. */ extern int getpagesize (void) __THROW __attribute__ ((__const__)); /* Return the maximum number of file descriptors the current process could possibly have. */ extern int getdtablesize (void) __THROW; # endif #endif /* Use misc || X/Open Unix. */ #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 /* Truncate FILE to LENGTH bytes. */ # ifndef __USE_FILE_OFFSET64 extern int truncate (const char *__file, __off_t __length) __THROW __nonnull ((1)) __wur; # else # ifdef __REDIRECT_NTH extern int __REDIRECT_NTH (truncate, (const char *__file, __off64_t __length), truncate64) __nonnull ((1)) __wur; # else # define truncate truncate64 # endif # endif # ifdef __USE_LARGEFILE64 extern int truncate64 (const char *__file, __off64_t __length) __THROW __nonnull ((1)) __wur; # endif #endif /* Use X/Open Unix || POSIX 2008. */ #if defined __USE_POSIX199309 \ || defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K /* Truncate the file FD is open on to LENGTH bytes. */ # ifndef __USE_FILE_OFFSET64 extern int ftruncate (int __fd, __off_t __length) __THROW __wur; # else # ifdef __REDIRECT_NTH extern int __REDIRECT_NTH (ftruncate, (int __fd, __off64_t __length), ftruncate64) __wur; # else # define ftruncate ftruncate64 # endif # endif # ifdef __USE_LARGEFILE64 extern int ftruncate64 (int __fd, __off64_t __length) __THROW __wur; # endif #endif /* Use POSIX.1b || X/Open Unix || XPG6. */ #if (defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K) \ || defined __USE_MISC /* Set the end of accessible data space (aka "the break") to ADDR. Returns zero on success and -1 for errors (with errno set). */ extern int brk (void *__addr) __THROW __wur; /* Increase or decrease the end of accessible data space by DELTA bytes. If successful, returns the address the previous end of data space (i.e. the beginning of the new space, if DELTA > 0); returns (void *) -1 for errors (with errno set). */ extern void *sbrk (intptr_t __delta) __THROW; #endif #ifdef __USE_MISC /* Invoke `system call' number SYSNO, passing it the remaining arguments. This is completely system-dependent, and not often useful. In Unix, `syscall' sets `errno' for all errors and most calls return -1 for errors; in many systems you cannot pass arguments or get return values for all system calls (`pipe', `fork', and `getppid' typically among them). In Mach, all system calls take normal arguments and always return an error code (zero for success). */ extern long int syscall (long int __sysno, ...) __THROW; #endif /* Use misc. */ #if (defined __USE_MISC || defined __USE_XOPEN_EXTENDED) && !defined F_LOCK /* NOTE: These declarations also appear in <fcntl.h>; be sure to keep both files consistent. Some systems have them there and some here, and some software depends on the macros being defined without including both. */ /* `lockf' is a simpler interface to the locking facilities of `fcntl'. LEN is always relative to the current file position. The CMD argument is one of the following. This function is a cancellation point and therefore not marked with __THROW. */ # define F_ULOCK 0 /* Unlock a previously locked region. */ # define F_LOCK 1 /* Lock a region for exclusive use. */ # define F_TLOCK 2 /* Test and lock a region for exclusive use. */ # define F_TEST 3 /* Test a region for other processes locks. */ # ifndef __USE_FILE_OFFSET64 extern int lockf (int __fd, int __cmd, __off_t __len) __wur; # else # ifdef __REDIRECT extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), lockf64) __wur; # else # define lockf lockf64 # endif # endif # ifdef __USE_LARGEFILE64 extern int lockf64 (int __fd, int __cmd, __off64_t __len) __wur; # endif #endif /* Use misc and F_LOCK not already defined. */ #ifdef __USE_GNU /* Evaluate EXPRESSION, and repeat as long as it returns -1 with `errno' set to EINTR. */ # define TEMP_FAILURE_RETRY(expression) \ (__extension__ \ ({ long int __result; \ do __result = (long int) (expression); \ while (__result == -1L && errno == EINTR); \ __result; })) /* Copy LENGTH bytes from INFD to OUTFD. */ ssize_t copy_file_range (int __infd, __off64_t *__pinoff, int __outfd, __off64_t *__poutoff, size_t __length, unsigned int __flags); #endif /* __USE_GNU */ #if defined __USE_POSIX199309 || defined __USE_UNIX98 /* Synchronize at least the data part of a file with the underlying media. */ extern int fdatasync (int __fildes); #endif /* Use POSIX199309 */ #ifdef __USE_MISC /* One-way hash PHRASE, returning a string suitable for storage in the user database. SALT selects the one-way function to use, and ensures that no two users' hashes are the same, even if they use the same passphrase. The return value points to static storage which will be overwritten by the next call to crypt. */ extern char *crypt (const char *__key, const char *__salt) __THROW __nonnull ((1, 2)); #endif #ifdef __USE_XOPEN /* Swab pairs bytes in the first N bytes of the area pointed to by FROM and copy the result to TO. The value of TO must not be in the range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM is without partner. */ extern void swab (const void *__restrict __from, void *__restrict __to, ssize_t __n) __THROW __nonnull ((1, 2)) __attr_access ((__read_only__, 1, 3)) __attr_access ((__write_only__, 2, 3)); #endif /* Prior to Issue 6, the Single Unix Specification required these prototypes to appear in this header. They are also found in <stdio.h>. */ #if defined __USE_XOPEN && !defined __USE_XOPEN2K /* Return the name of the controlling terminal. */ extern char *ctermid (char *__s) __THROW; /* Return the name of the current user. */ extern char *cuserid (char *__s); #endif /* Unix98 requires this function to be declared here. In other standards it is in <pthread.h>. */ #if defined __USE_UNIX98 && !defined __USE_XOPEN2K extern int pthread_atfork (void (*__prepare) (void), void (*__parent) (void), void (*__child) (void)) __THROW; #endif #ifdef __USE_MISC /* Write LENGTH bytes of randomness starting at BUFFER. Return 0 on success or -1 on error. */ int getentropy (void *__buffer, size_t __length) __wur __attr_access ((__write_only__, 1, 2)); #endif /* Define some macros helping to catch buffer overflows. */ #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function # include <bits/unistd.h> #endif /* System-specific extensions. */ #include <bits/unistd_ext.h> __END_DECLS #endif /* unistd.h */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFFIO_ #define _TIFFIO_ /* * TIFF I/O Library Definitions. */ #include "tiff.h" #include "tiffvers.h" /* * TIFF is defined as an incomplete type to hide the * library's internal data structures from clients. */ typedef struct tiff TIFF; /* * The following typedefs define the intrinsic size of * data types used in the *exported* interfaces. These * definitions depend on the proper definition of types * in tiff.h. Note also that the varargs interface used * to pass tag types and values uses the types defined in * tiff.h directly. * * NB: ttag_t is unsigned int and not unsigned short because * ANSI C requires that the type before the ellipsis be a * promoted type (i.e. one of int, unsigned int, pointer, * or double) and because we defined pseudo-tags that are * outside the range of legal Aldus-assigned tags. * NB: tsize_t is signed and not unsigned because some functions * return -1. * NB: toff_t is not off_t for many reasons; TIFFs max out at * 32-bit file offsets, and BigTIFF maxes out at 64-bit * offsets being the most important, and to ensure use of * a consistently unsigned type across architectures. * Prior to libtiff 4.0, this was an unsigned 32 bit type. */ /* * this is the machine addressing size type, only it's signed, so make it * int32_t on 32bit machines, int64_t on 64bit machines */ typedef TIFF_SSIZE_T tmsize_t; #define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1) typedef uint64_t toff_t; /* file offset */ /* the following are deprecated and should be replaced by their defining counterparts */ typedef uint32_t ttag_t; /* directory tag */ typedef uint16_t tdir_t; /* directory index */ typedef uint16_t tsample_t; /* sample number */ typedef uint32_t tstrile_t; /* strip or tile number */ typedef tstrile_t tstrip_t; /* strip number */ typedef tstrile_t ttile_t; /* tile number */ typedef tmsize_t tsize_t; /* i/o size in bytes */ typedef void* tdata_t; /* image data ref */ #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) #define __WIN32__ #endif /* * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). * * By default tif_unix.c is assumed. */ #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) # if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) # define AVOID_WIN32_FILEIO # endif #endif #if defined(USE_WIN32_FILEIO) # define VC_EXTRALEAN # include <windows.h> # ifdef __WIN32__ DECLARE_HANDLE(thandle_t); /* Win32 file handle */ # else typedef HFILE thandle_t; /* client data handle */ # endif /* __WIN32__ */ #else typedef void* thandle_t; /* client data handle */ #endif /* USE_WIN32_FILEIO */ /* * Flags to pass to TIFFPrintDirectory to control * printing of data structures that are potentially * very large. Bit-or these flags to enable printing * multiple items. */ #define TIFFPRINT_NONE 0x0 /* no extra info */ #define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ #define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ #define TIFFPRINT_COLORMAP 0x4 /* colormap */ #define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ #define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ #define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ /* * Colour conversion stuff */ /* reference white */ #define D65_X0 (95.0470F) #define D65_Y0 (100.0F) #define D65_Z0 (108.8827F) #define D50_X0 (96.4250F) #define D50_Y0 (100.0F) #define D50_Z0 (82.4680F) /* Structure for holding information about a display device. */ typedef unsigned char TIFFRGBValue; /* 8-bit samples */ typedef struct { float d_mat[3][3]; /* XYZ -> luminance matrix */ float d_YCR; /* Light o/p for reference white */ float d_YCG; float d_YCB; uint32_t d_Vrwr; /* Pixel values for ref. white */ uint32_t d_Vrwg; uint32_t d_Vrwb; float d_Y0R; /* Residual light for black pixel */ float d_Y0G; float d_Y0B; float d_gammaR; /* Gamma values for the three guns */ float d_gammaG; float d_gammaB; } TIFFDisplay; typedef struct { /* YCbCr->RGB support */ TIFFRGBValue* clamptab; /* range clamping table */ int* Cr_r_tab; int* Cb_b_tab; int32_t* Cr_g_tab; int32_t* Cb_g_tab; int32_t* Y_tab; } TIFFYCbCrToRGB; typedef struct { /* CIE Lab 1976->RGB support */ int range; /* Size of conversion table */ #define CIELABTORGB_TABLE_RANGE 1500 float rstep, gstep, bstep; float X0, Y0, Z0; /* Reference white point */ TIFFDisplay display; float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ } TIFFCIELabToRGB; /* * RGBA-style image support. */ typedef struct _TIFFRGBAImage TIFFRGBAImage; /* * The image reading and conversion routines invoke * ``put routines'' to copy/image/whatever tiles of * raw image data. A default set of routines are * provided to convert/copy raw image data to 8-bit * packed ABGR format rasters. Applications can supply * alternate routines that unpack the data into a * different format or, for example, unpack the data * and draw the unpacked raster on the display. */ typedef void (*tileContigRoutine) (TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t, uint32_t, uint32_t, int32_t, int32_t, unsigned char*); typedef void (*tileSeparateRoutine) (TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t, uint32_t, uint32_t, int32_t, int32_t, unsigned char*, unsigned char*, unsigned char*, unsigned char*); /* * RGBA-reader state. */ struct _TIFFRGBAImage { TIFF* tif; /* image handle */ int stoponerr; /* stop on read error */ int isContig; /* data is packed/separate */ int alpha; /* type of alpha data present */ uint32_t width; /* image width */ uint32_t height; /* image height */ uint16_t bitspersample; /* image bits/sample */ uint16_t samplesperpixel; /* image samples/pixel */ uint16_t orientation; /* image orientation */ uint16_t req_orientation; /* requested orientation */ uint16_t photometric; /* image photometric interp */ uint16_t* redcmap; /* colormap palette */ uint16_t* greencmap; uint16_t* bluecmap; /* get image data routine */ int (*get)(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); /* put decoded strip/tile */ union { void (*any)(TIFFRGBAImage*); tileContigRoutine contig; tileSeparateRoutine separate; } put; TIFFRGBValue* Map; /* sample mapping array */ uint32_t** BWmap; /* black&white map */ uint32_t** PALmap; /* palette image map */ TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ uint8_t* UaToAa; /* Unassociated alpha to associated alpha conversion LUT */ uint8_t* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ int row_offset; int col_offset; }; /* * Macros for extracting components from the * packed ABGR form returned by TIFFReadRGBAImage. */ #define TIFFGetR(abgr) ((abgr) & 0xff) #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) /* * A CODEC is a software package that implements decoding, * encoding, or decoding+encoding of a compression algorithm. * The library provides a collection of builtin codecs. * More codecs may be registered through calls to the library * and/or the builtin implementations may be overridden. */ typedef int (*TIFFInitMethod)(TIFF*, int); typedef struct { char* name; uint16_t scheme; TIFFInitMethod init; } TIFFCodec; #include <stdio.h> #include <stdarg.h> /* share internal LogLuv conversion routines? */ #ifndef LOGLUV_PUBLIC #define LOGLUV_PUBLIC 1 #endif #if defined(__GNUC__) || defined(__attribute__) # define TIFF_ATTRIBUTE(x) __attribute__(x) #else # define TIFF_ATTRIBUTE(x) /*nothing*/ #endif #if defined(c_plusplus) || defined(__cplusplus) extern "C" { #endif typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); typedef int (*TIFFCloseProc)(thandle_t); typedef toff_t (*TIFFSizeProc)(thandle_t); typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); typedef void (*TIFFExtendProc)(TIFF*); extern const char* TIFFGetVersion(void); extern const TIFFCodec* TIFFFindCODEC(uint16_t); extern TIFFCodec* TIFFRegisterCODEC(uint16_t, const char*, TIFFInitMethod); extern void TIFFUnRegisterCODEC(TIFFCodec*); extern int TIFFIsCODECConfigured(uint16_t); extern TIFFCodec* TIFFGetConfiguredCODECs(void); /* * Auxiliary functions. */ extern void* _TIFFmalloc(tmsize_t s); extern void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz); extern void* _TIFFrealloc(void* p, tmsize_t s); extern void _TIFFmemset(void* p, int v, tmsize_t c); extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); extern void _TIFFfree(void* p); /* ** Stuff, related to tag handling and creating custom tags. */ extern int TIFFGetTagListCount( TIFF * ); extern uint32_t TIFFGetTagListEntry(TIFF *, int tag_index ); #define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ #define TIFF_VARIABLE -1 /* marker for variable length tags */ #define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ #define TIFF_VARIABLE2 -3 /* marker for uint32_t var-length tags */ #define FIELD_CUSTOM 65 typedef struct _TIFFField TIFFField; typedef struct _TIFFFieldArray TIFFFieldArray; extern const TIFFField* TIFFFindField(TIFF *, uint32_t, TIFFDataType); extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32_t); extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); extern uint32_t TIFFFieldTag(const TIFFField*); extern const char* TIFFFieldName(const TIFFField*); extern TIFFDataType TIFFFieldDataType(const TIFFField*); extern int TIFFFieldPassCount(const TIFFField*); extern int TIFFFieldReadCount(const TIFFField*); extern int TIFFFieldWriteCount(const TIFFField*); extern int TIFFFieldSetGetSize(const TIFFField*); /* returns internal storage size of TIFFSetGetFieldType in bytes. */ extern int TIFFFieldSetGetCountSize(const TIFFField*); /* returns size of count parameter 0=none, 2=uint16_t, 4=uint32_t */ extern int TIFFFieldIsAnonymous(const TIFFField *); typedef int (*TIFFVSetMethod)(TIFF*, uint32_t, va_list); typedef int (*TIFFVGetMethod)(TIFF*, uint32_t, va_list); typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); typedef struct { TIFFVSetMethod vsetfield; /* tag set routine */ TIFFVGetMethod vgetfield; /* tag get routine */ TIFFPrintMethod printdir; /* directory print routine */ } TIFFTagMethods; extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); extern void *TIFFGetClientInfo(TIFF *, const char *); extern void TIFFSetClientInfo(TIFF *, void *, const char *); extern void TIFFCleanup(TIFF* tif); extern void TIFFClose(TIFF* tif); extern int TIFFFlush(TIFF* tif); extern int TIFFFlushData(TIFF* tif); extern int TIFFGetField(TIFF* tif, uint32_t tag, ...); extern int TIFFVGetField(TIFF* tif, uint32_t tag, va_list ap); extern int TIFFGetFieldDefaulted(TIFF* tif, uint32_t tag, ...); extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32_t tag, va_list ap); extern int TIFFReadDirectory(TIFF* tif); extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); extern int TIFFReadGPSDirectory(TIFF* tif, toff_t diroff); extern uint64_t TIFFScanlineSize64(TIFF* tif); extern tmsize_t TIFFScanlineSize(TIFF* tif); extern uint64_t TIFFRasterScanlineSize64(TIFF* tif); extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); extern uint64_t TIFFStripSize64(TIFF* tif); extern tmsize_t TIFFStripSize(TIFF* tif); extern uint64_t TIFFRawStripSize64(TIFF* tif, uint32_t strip); extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32_t strip); extern uint64_t TIFFVStripSize64(TIFF* tif, uint32_t nrows); extern tmsize_t TIFFVStripSize(TIFF* tif, uint32_t nrows); extern uint64_t TIFFTileRowSize64(TIFF* tif); extern tmsize_t TIFFTileRowSize(TIFF* tif); extern uint64_t TIFFTileSize64(TIFF* tif); extern tmsize_t TIFFTileSize(TIFF* tif); extern uint64_t TIFFVTileSize64(TIFF* tif, uint32_t nrows); extern tmsize_t TIFFVTileSize(TIFF* tif, uint32_t nrows); extern uint32_t TIFFDefaultStripSize(TIFF* tif, uint32_t request); extern void TIFFDefaultTileSize(TIFF*, uint32_t*, uint32_t*); extern int TIFFFileno(TIFF*); extern int TIFFSetFileno(TIFF*, int); extern thandle_t TIFFClientdata(TIFF*); extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); extern int TIFFGetMode(TIFF*); extern int TIFFSetMode(TIFF*, int); extern int TIFFIsTiled(TIFF*); extern int TIFFIsByteSwapped(TIFF*); extern int TIFFIsUpSampled(TIFF*); extern int TIFFIsMSB2LSB(TIFF*); extern int TIFFIsBigEndian(TIFF*); extern int TIFFIsBigTIFF(TIFF*); extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); extern TIFFSeekProc TIFFGetSeekProc(TIFF*); extern TIFFCloseProc TIFFGetCloseProc(TIFF*); extern TIFFSizeProc TIFFGetSizeProc(TIFF*); extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); extern uint32_t TIFFCurrentRow(TIFF*); extern uint16_t TIFFCurrentDirectory(TIFF*); extern uint16_t TIFFNumberOfDirectories(TIFF*); extern uint64_t TIFFCurrentDirOffset(TIFF*); extern uint32_t TIFFCurrentStrip(TIFF*); extern uint32_t TIFFCurrentTile(TIFF* tif); extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); extern int TIFFSetupStrips(TIFF *); extern int TIFFWriteCheck(TIFF*, int, const char *); extern void TIFFFreeDirectory(TIFF*); extern int TIFFCreateDirectory(TIFF*); extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); extern int TIFFCreateEXIFDirectory(TIFF*); extern int TIFFCreateGPSDirectory(TIFF*); extern int TIFFLastDirectory(TIFF*); extern int TIFFSetDirectory(TIFF*, uint16_t); extern int TIFFSetSubDirectory(TIFF*, uint64_t); extern int TIFFUnlinkDirectory(TIFF*, uint16_t); extern int TIFFSetField(TIFF*, uint32_t, ...); extern int TIFFVSetField(TIFF*, uint32_t, va_list); extern int TIFFUnsetField(TIFF*, uint32_t); extern int TIFFWriteDirectory(TIFF *); extern int TIFFWriteCustomDirectory(TIFF *, uint64_t *); extern int TIFFCheckpointDirectory(TIFF *); extern int TIFFRewriteDirectory(TIFF *); extern int TIFFDeferStrileArrayWriting(TIFF *); extern int TIFFForceStrileArrayWriting(TIFF* ); #if defined(c_plusplus) || defined(__cplusplus) extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); extern int TIFFReadScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample = 0); extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample = 0); extern int TIFFReadRGBAImage(TIFF*, uint32_t, uint32_t, uint32_t*, int = 0); extern int TIFFReadRGBAImageOriented(TIFF*, uint32_t, uint32_t, uint32_t*, int = ORIENTATION_BOTLEFT, int = 0); #else extern void TIFFPrintDirectory(TIFF*, FILE*, long); extern int TIFFReadScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample); extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32_t row, uint16_t sample); extern int TIFFReadRGBAImage(TIFF*, uint32_t, uint32_t, uint32_t*, int); extern int TIFFReadRGBAImageOriented(TIFF*, uint32_t, uint32_t, uint32_t*, int, int); #endif extern int TIFFReadRGBAStrip(TIFF*, uint32_t, uint32_t * ); extern int TIFFReadRGBATile(TIFF*, uint32_t, uint32_t, uint32_t * ); extern int TIFFReadRGBAStripExt(TIFF*, uint32_t, uint32_t *, int stop_on_error ); extern int TIFFReadRGBATileExt(TIFF*, uint32_t, uint32_t, uint32_t *, int stop_on_error ); extern int TIFFRGBAImageOK(TIFF*, char [1024]); extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32_t*, uint32_t, uint32_t); extern void TIFFRGBAImageEnd(TIFFRGBAImage*); extern TIFF* TIFFOpen(const char*, const char*); # ifdef __WIN32__ extern TIFF* TIFFOpenW(const wchar_t*, const char*); # endif /* __WIN32__ */ extern TIFF* TIFFFdOpen(int, const char*, const char*); extern TIFF* TIFFClientOpen(const char*, const char*, thandle_t, TIFFReadWriteProc, TIFFReadWriteProc, TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, TIFFMapFileProc, TIFFUnmapFileProc); extern const char* TIFFFileName(TIFF*); extern const char* TIFFSetFileName(TIFF*, const char *); extern void TIFFError(const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,2,3))); extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,3,4))); extern void TIFFWarning(const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,2,3))); extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,3,4))); extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); extern uint32_t TIFFComputeTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s); extern int TIFFCheckTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s); extern uint32_t TIFFNumberOfTiles(TIFF*); extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s); extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32_t x, uint32_t y, uint32_t z, uint16_t s); extern uint32_t TIFFComputeStrip(TIFF*, uint32_t, uint16_t); extern uint32_t TIFFNumberOfStrips(TIFF*); extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size); extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size); extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size); extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size); extern int TIFFReadFromUserBuffer(TIFF* tif, uint32_t strile, void* inbuf, tmsize_t insize, void* outbuf, tmsize_t outsize); extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc); extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32_t strip, void* data, tmsize_t cc); extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc); extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32_t tile, void* data, tmsize_t cc); extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths within TIFF file. */ extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); extern void TIFFSwabShort(uint16_t*); extern void TIFFSwabLong(uint32_t*); extern void TIFFSwabLong8(uint64_t*); extern void TIFFSwabFloat(float*); extern void TIFFSwabDouble(double*); extern void TIFFSwabArrayOfShort(uint16_t* wp, tmsize_t n); extern void TIFFSwabArrayOfTriples(uint8_t* tp, tmsize_t n); extern void TIFFSwabArrayOfLong(uint32_t* lp, tmsize_t n); extern void TIFFSwabArrayOfLong8(uint64_t* lp, tmsize_t n); extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); extern void TIFFReverseBits(uint8_t* cp, tmsize_t n); extern const unsigned char* TIFFGetBitRevTable(int); extern uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile); extern uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile); extern uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile, int *pbErr); extern uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile, int *pbErr); #ifdef LOGLUV_PUBLIC #define U_NEU 0.210526316 #define V_NEU 0.473684211 #define UVSCALE 410. extern double LogL16toY(int); extern double LogL10toY(int); extern void XYZtoRGB24(float*, uint8_t*); extern int uv_decode(double*, double*, int); extern void LogLuv24toXYZ(uint32_t, float*); extern void LogLuv32toXYZ(uint32_t, float*); #if defined(c_plusplus) || defined(__cplusplus) extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); extern uint32_t LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); extern uint32_t LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); #else extern int LogL16fromY(double, int); extern int LogL10fromY(double, int); extern int uv_encode(double, double, int); extern uint32_t LogLuv24fromXYZ(float*, int); extern uint32_t LogLuv32fromXYZ(float*, int); #endif #endif /* LOGLUV_PUBLIC */ extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32_t, int32_t, int32_t, float *, float *, float *); extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32_t *, uint32_t *, uint32_t *); extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32_t, int32_t, int32_t, uint32_t *, uint32_t *, uint32_t *); /**************************************************************************** * O B S O L E T E D I N T E R F A C E S * * Don't use this stuff in your applications, it may be removed in the future * libtiff versions. ****************************************************************************/ typedef struct { ttag_t field_tag; /* field's tag */ short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ short field_writecount; /* write count/TIFF_VARIABLE */ TIFFDataType field_type; /* type of associated data */ unsigned short field_bit; /* bit in fieldsset bit vector */ unsigned char field_oktochange; /* if true, can change while writing */ unsigned char field_passcount; /* if true, pass dir count on set */ char *field_name; /* ASCII name */ } TIFFFieldInfo; extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32_t); #if defined(c_plusplus) || defined(__cplusplus) } #endif #endif /* _TIFFIO_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ /* Public API for GNU gettext PO files - contained in libgettextpo. Copyright (C) 2003-2008, 2010, 2012-2016, 2019-2020 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _GETTEXT_PO_H #define _GETTEXT_PO_H 1 #include <stdlib.h> #ifdef __cplusplus extern "C" { #endif /* =========================== Meta Information ============================ */ /* Version number: (major<<16) + (minor<<8) + subminor */ #define LIBGETTEXTPO_VERSION 0x001500 extern int libgettextpo_version; /* ================================= Types ================================= */ /* A po_file_t represents the contents of a PO file. */ typedef struct po_file *po_file_t; /* A po_message_iterator_t represents an iterator through a domain of a PO file. */ typedef struct po_message_iterator *po_message_iterator_t; /* A po_message_t represents a message in a PO file. */ typedef struct po_message *po_message_t; /* A po_filepos_t represents a string's position within a source file. */ typedef struct po_filepos *po_filepos_t; /* A po_error_handler handles error situations. */ struct po_error_handler { /* Signal an error. The error message is built from FORMAT and the following arguments. ERRNUM, if nonzero, is an errno value. Must increment the error_message_count variable declared in error.h. Must not return if STATUS is nonzero. */ void (*error) (int status, int errnum, const char *format, ...) #if ((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3) && !__STRICT_ANSI__ __attribute__ ((__format__ (__printf__, 3, 4))) #endif ; /* Signal an error. The error message is built from FORMAT and the following arguments. The error location is at FILENAME line LINENO. ERRNUM, if nonzero, is an errno value. Must increment the error_message_count variable declared in error.h. Must not return if STATUS is nonzero. */ void (*error_at_line) (int status, int errnum, const char *filename, unsigned int lineno, const char *format, ...) #if ((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ > 3) && !__STRICT_ANSI__ __attribute__ ((__format__ (__printf__, 5, 6))) #endif ; /* Signal a multiline warning. The PREFIX applies to all lines of the MESSAGE. Free the PREFIX and MESSAGE when done. */ void (*multiline_warning) (char *prefix, char *message); /* Signal a multiline error. The PREFIX applies to all lines of the MESSAGE. Free the PREFIX and MESSAGE when done. Must increment the error_message_count variable declared in error.h if PREFIX is non-NULL. */ void (*multiline_error) (char *prefix, char *message); }; typedef const struct po_error_handler *po_error_handler_t; /* A po_xerror_handler handles warnings, error and fatal error situations. */ #define PO_SEVERITY_WARNING 0 /* just a warning, tell the user */ #define PO_SEVERITY_ERROR 1 /* an error, the operation cannot complete */ #define PO_SEVERITY_FATAL_ERROR 2 /* an error, the operation must be aborted */ struct po_xerror_handler { /* Signal a problem of the given severity. MESSAGE and/or FILENAME + LINENO indicate where the problem occurred. If FILENAME is NULL, FILENAME and LINENO and COLUMN should be ignored. If LINENO is (size_t)(-1), LINENO and COLUMN should be ignored. If COLUMN is (size_t)(-1), it should be ignored. MESSAGE_TEXT is the problem description (if MULTILINE_P is true, multiple lines of text, each terminated with a newline, otherwise usually a single line). Must not return if SEVERITY is PO_SEVERITY_FATAL_ERROR. */ void (*xerror) (int severity, po_message_t message, const char *filename, size_t lineno, size_t column, int multiline_p, const char *message_text); /* Signal a problem that refers to two messages. Similar to two calls to xerror. If possible, a "..." can be appended to MESSAGE_TEXT1 and prepended to MESSAGE_TEXT2. */ void (*xerror2) (int severity, po_message_t message1, const char *filename1, size_t lineno1, size_t column1, int multiline_p1, const char *message_text1, po_message_t message2, const char *filename2, size_t lineno2, size_t column2, int multiline_p2, const char *message_text2); }; typedef const struct po_xerror_handler *po_xerror_handler_t; /* Memory allocation: The memory allocations performed by these functions use xmalloc(), therefore will cause a program exit if memory is exhausted. The memory allocated by po_file_read, and implicitly returned through the po_message_* functions, lasts until freed with po_file_free. */ /* ============================= po_file_t API ============================= */ /* Create an empty PO file representation in memory. */ extern po_file_t po_file_create (void); /* Read a PO file into memory. Return its contents. Upon failure, call function from handler. */ #define po_file_read po_file_read_v3 extern po_file_t po_file_read (const char *filename, po_xerror_handler_t handler); /* Write an in-memory PO file to a file. Upon failure, call function from handler. */ #define po_file_write po_file_write_v2 extern po_file_t po_file_write (po_file_t file, const char *filename, po_xerror_handler_t handler); /* Free a PO file from memory. */ extern void po_file_free (po_file_t file); /* Return the names of the domains covered by a PO file in memory. */ extern const char * const * po_file_domains (po_file_t file); /* =========================== Header entry API ============================ */ /* Return the header entry of a domain of a PO file in memory. The domain NULL denotes the default domain. Return NULL if there is no header entry. */ extern const char * po_file_domain_header (po_file_t file, const char *domain); /* Return the value of a field in a header entry. The return value is either a freshly allocated string, to be freed by the caller, or NULL. */ extern char * po_header_field (const char *header, const char *field); /* Return the header entry with a given field set to a given value. The field is added if necessary. The return value is a freshly allocated string. */ extern char * po_header_set_field (const char *header, const char *field, const char *value); /* ======================= po_message_iterator_t API ======================= */ /* Create an iterator for traversing a domain of a PO file in memory. The domain NULL denotes the default domain. */ extern po_message_iterator_t po_message_iterator (po_file_t file, const char *domain); /* Free an iterator. */ extern void po_message_iterator_free (po_message_iterator_t iterator); /* Return the next message, and advance the iterator. Return NULL at the end of the message list. */ extern po_message_t po_next_message (po_message_iterator_t iterator); /* Insert a message in a PO file in memory, in the domain and at the position indicated by the iterator. The iterator thereby advances past the freshly inserted message. */ extern void po_message_insert (po_message_iterator_t iterator, po_message_t message); /* =========================== po_message_t API ============================ */ /* Return a freshly constructed message. To finish initializing the message, you must set the msgid and msgstr. */ extern po_message_t po_message_create (void); /* Return the context of a message, or NULL for a message not restricted to a context. */ extern const char * po_message_msgctxt (po_message_t message); /* Change the context of a message. NULL means a message not restricted to a context. */ extern void po_message_set_msgctxt (po_message_t message, const char *msgctxt); /* Return the msgid (untranslated English string) of a message. */ extern const char * po_message_msgid (po_message_t message); /* Change the msgid (untranslated English string) of a message. */ extern void po_message_set_msgid (po_message_t message, const char *msgid); /* Return the msgid_plural (untranslated English plural string) of a message, or NULL for a message without plural. */ extern const char * po_message_msgid_plural (po_message_t message); /* Change the msgid_plural (untranslated English plural string) of a message. NULL means a message without plural. */ extern void po_message_set_msgid_plural (po_message_t message, const char *msgid_plural); /* Return the msgstr (translation) of a message. Return the empty string for an untranslated message. */ extern const char * po_message_msgstr (po_message_t message); /* Change the msgstr (translation) of a message. Use an empty string to denote an untranslated message. */ extern void po_message_set_msgstr (po_message_t message, const char *msgstr); /* Return the msgstr[index] for a message with plural handling, or NULL when the index is out of range or for a message without plural. */ extern const char * po_message_msgstr_plural (po_message_t message, int index); /* Change the msgstr[index] for a message with plural handling. Use a NULL value at the end to reduce the number of plural forms. */ extern void po_message_set_msgstr_plural (po_message_t message, int index, const char *msgstr); /* Return the comments for a message. */ extern const char * po_message_comments (po_message_t message); /* Change the comments for a message. comments should be a multiline string, ending in a newline, or empty. */ extern void po_message_set_comments (po_message_t message, const char *comments); /* Return the extracted comments for a message. */ extern const char * po_message_extracted_comments (po_message_t message); /* Change the extracted comments for a message. comments should be a multiline string, ending in a newline, or empty. */ extern void po_message_set_extracted_comments (po_message_t message, const char *comments); /* Return the i-th file position for a message, or NULL if i is out of range. */ extern po_filepos_t po_message_filepos (po_message_t message, int i); /* Remove the i-th file position from a message. The indices of all following file positions for the message are decremented by one. */ extern void po_message_remove_filepos (po_message_t message, int i); /* Add a file position to a message, if it is not already present for the message. file is the file name. start_line is the line number where the string starts, or (size_t)(-1) if no line number is available. */ extern void po_message_add_filepos (po_message_t message, const char *file, size_t start_line); /* Return the previous context of a message, or NULL for none. */ extern const char * po_message_prev_msgctxt (po_message_t message); /* Change the previous context of a message. NULL is allowed. */ extern void po_message_set_prev_msgctxt (po_message_t message, const char *prev_msgctxt); /* Return the previous msgid (untranslated English string) of a message, or NULL for none. */ extern const char * po_message_prev_msgid (po_message_t message); /* Change the previous msgid (untranslated English string) of a message. NULL is allowed. */ extern void po_message_set_prev_msgid (po_message_t message, const char *prev_msgid); /* Return the previous msgid_plural (untranslated English plural string) of a message, or NULL for none. */ extern const char * po_message_prev_msgid_plural (po_message_t message); /* Change the previous msgid_plural (untranslated English plural string) of a message. NULL is allowed. */ extern void po_message_set_prev_msgid_plural (po_message_t message, const char *prev_msgid_plural); /* Return true if the message is marked obsolete. */ extern int po_message_is_obsolete (po_message_t message); /* Change the obsolete mark of a message. */ extern void po_message_set_obsolete (po_message_t message, int obsolete); /* Return true if the message is marked fuzzy. */ extern int po_message_is_fuzzy (po_message_t message); /* Change the fuzzy mark of a message. */ extern void po_message_set_fuzzy (po_message_t message, int fuzzy); /* Return true if the message is marked as being a format string of the given type (e.g. "c-format"). */ extern int po_message_is_format (po_message_t message, const char *format_type); /* Change the format string mark for a given type of a message. */ extern void po_message_set_format (po_message_t message, const char *format_type, /*bool*/int value); /* If a numeric range of a message is set, return true and store the minimum and maximum value in *MINP and *MAXP. */ extern int po_message_is_range (po_message_t message, int *minp, int *maxp); /* Change the numeric range of a message. MIN and MAX must be non-negative, with MIN < MAX. Use MIN = MAX = -1 to remove the numeric range of a message. */ extern void po_message_set_range (po_message_t message, int min, int max); /* =========================== po_filepos_t API ============================ */ /* Return the file name. */ extern const char * po_filepos_file (po_filepos_t filepos); /* Return the line number where the string starts, or (size_t)(-1) if no line number is available. */ extern size_t po_filepos_start_line (po_filepos_t filepos); /* ============================ Format type API ============================= */ /* Return a NULL terminated array of the supported format types. */ extern const char * const * po_format_list (void); /* Return the pretty name associated with a format type. For example, for "csharp-format", return "C#". Return NULL if the argument is not a supported format type. */ extern const char * po_format_pretty_name (const char *format_type); /* ============================= Checking API ============================== */ /* Test whether an entire file PO file is valid, like msgfmt does it. If it is invalid, pass the reasons to the handler. */ extern void po_file_check_all (po_file_t file, po_xerror_handler_t handler); /* Test a single message, to be inserted in a PO file in memory, like msgfmt does it. If it is invalid, pass the reasons to the handler. The iterator is not modified by this call; it only specifies the file and the domain. */ extern void po_message_check_all (po_message_t message, po_message_iterator_t iterator, po_xerror_handler_t handler); /* Test whether the message translation is a valid format string if the message is marked as being a format string. If it is invalid, pass the reasons to the handler. */ #define po_message_check_format po_message_check_format_v2 extern void po_message_check_format (po_message_t message, po_xerror_handler_t handler); #ifdef __cplusplus } #endif #endif /* _GETTEXT_PO_H */ /* __ __ _ ___\ \/ /_ __ __ _| |_ / _ \\ /| '_ \ / _` | __| | __// \| |_) | (_| | |_ \___/_/\_\ .__/ \__,_|\__| |_| XML parser Copyright (c) 1997-2000 Thai Open Source Software Center Ltd Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net> Copyright (c) 2000-2005 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net> Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net> Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org> Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org> Copyright (c) 2016 Thomas Beutlich <tc@tbeu.de> Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk> Copyright (c) 2022 Thijs Schreijer <thijs@thijsschreijer.nl> Copyright (c) 2023 Sony Corporation / Snild Dolkow <snild@sony.com> Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef Expat_INCLUDED #define Expat_INCLUDED 1 #include <stdlib.h> #include "expat_external.h" #ifdef __cplusplus extern "C" { #endif struct XML_ParserStruct; typedef struct XML_ParserStruct *XML_Parser; typedef unsigned char XML_Bool; #define XML_TRUE ((XML_Bool)1) #define XML_FALSE ((XML_Bool)0) /* The XML_Status enum gives the possible return values for several API functions. The preprocessor #defines are included so this stanza can be added to code that still needs to support older versions of Expat 1.95.x: #ifndef XML_STATUS_OK #define XML_STATUS_OK 1 #define XML_STATUS_ERROR 0 #endif Otherwise, the #define hackery is quite ugly and would have been dropped. */ enum XML_Status { XML_STATUS_ERROR = 0, #define XML_STATUS_ERROR XML_STATUS_ERROR XML_STATUS_OK = 1, #define XML_STATUS_OK XML_STATUS_OK XML_STATUS_SUSPENDED = 2 #define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED }; enum XML_Error { XML_ERROR_NONE, XML_ERROR_NO_MEMORY, XML_ERROR_SYNTAX, XML_ERROR_NO_ELEMENTS, XML_ERROR_INVALID_TOKEN, XML_ERROR_UNCLOSED_TOKEN, XML_ERROR_PARTIAL_CHAR, XML_ERROR_TAG_MISMATCH, XML_ERROR_DUPLICATE_ATTRIBUTE, XML_ERROR_JUNK_AFTER_DOC_ELEMENT, XML_ERROR_PARAM_ENTITY_REF, XML_ERROR_UNDEFINED_ENTITY, XML_ERROR_RECURSIVE_ENTITY_REF, XML_ERROR_ASYNC_ENTITY, XML_ERROR_BAD_CHAR_REF, XML_ERROR_BINARY_ENTITY_REF, XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, XML_ERROR_MISPLACED_XML_PI, XML_ERROR_UNKNOWN_ENCODING, XML_ERROR_INCORRECT_ENCODING, XML_ERROR_UNCLOSED_CDATA_SECTION, XML_ERROR_EXTERNAL_ENTITY_HANDLING, XML_ERROR_NOT_STANDALONE, XML_ERROR_UNEXPECTED_STATE, XML_ERROR_ENTITY_DECLARED_IN_PE, XML_ERROR_FEATURE_REQUIRES_XML_DTD, XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING, /* Added in 1.95.7. */ XML_ERROR_UNBOUND_PREFIX, /* Added in 1.95.8. */ XML_ERROR_UNDECLARING_PREFIX, XML_ERROR_INCOMPLETE_PE, XML_ERROR_XML_DECL, XML_ERROR_TEXT_DECL, XML_ERROR_PUBLICID, XML_ERROR_SUSPENDED, XML_ERROR_NOT_SUSPENDED, XML_ERROR_ABORTED, XML_ERROR_FINISHED, XML_ERROR_SUSPEND_PE, /* Added in 2.0. */ XML_ERROR_RESERVED_PREFIX_XML, XML_ERROR_RESERVED_PREFIX_XMLNS, XML_ERROR_RESERVED_NAMESPACE_URI, /* Added in 2.2.1. */ XML_ERROR_INVALID_ARGUMENT, /* Added in 2.3.0. */ XML_ERROR_NO_BUFFER, /* Added in 2.4.0. */ XML_ERROR_AMPLIFICATION_LIMIT_BREACH, /* Added in 2.6.4. */ XML_ERROR_NOT_STARTED, }; enum XML_Content_Type { XML_CTYPE_EMPTY = 1, XML_CTYPE_ANY, XML_CTYPE_MIXED, XML_CTYPE_NAME, XML_CTYPE_CHOICE, XML_CTYPE_SEQ }; enum XML_Content_Quant { XML_CQUANT_NONE, XML_CQUANT_OPT, XML_CQUANT_REP, XML_CQUANT_PLUS }; /* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be XML_CQUANT_NONE, and the other fields will be zero or NULL. If type == XML_CTYPE_MIXED, then quant will be NONE or REP and numchildren will contain number of elements that may be mixed in and children point to an array of XML_Content cells that will be all of XML_CTYPE_NAME type with no quantification. If type == XML_CTYPE_NAME, then the name points to the name, and the numchildren field will be zero and children will be NULL. The quant fields indicates any quantifiers placed on the name. CHOICE and SEQ will have name NULL, the number of children in numchildren and children will point, recursively, to an array of XML_Content cells. The EMPTY, ANY, and MIXED types will only occur at top level. */ typedef struct XML_cp XML_Content; struct XML_cp { enum XML_Content_Type type; enum XML_Content_Quant quant; XML_Char *name; unsigned int numchildren; XML_Content *children; }; /* This is called for an element declaration. See above for description of the model argument. It's the user code's responsibility to free model when finished with it. See XML_FreeContentModel. There is no need to free the model from the handler, it can be kept around and freed at a later stage. */ typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData, const XML_Char *name, XML_Content *model); XMLPARSEAPI(void) XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl); /* The Attlist declaration handler is called for *each* attribute. So a single Attlist declaration with multiple attributes declared will generate multiple calls to this handler. The "default" parameter may be NULL in the case of the "#IMPLIED" or "#REQUIRED" keyword. The "isrequired" parameter will be true and the default value will be NULL in the case of "#REQUIRED". If "isrequired" is true and default is non-NULL, then this is a "#FIXED" default. */ typedef void(XMLCALL *XML_AttlistDeclHandler)( void *userData, const XML_Char *elname, const XML_Char *attname, const XML_Char *att_type, const XML_Char *dflt, int isrequired); XMLPARSEAPI(void) XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl); /* The XML declaration handler is called for *both* XML declarations and text declarations. The way to distinguish is that the version parameter will be NULL for text declarations. The encoding parameter may be NULL for XML declarations. The standalone parameter will be -1, 0, or 1 indicating respectively that there was no standalone parameter in the declaration, that it was given as no, or that it was given as yes. */ typedef void(XMLCALL *XML_XmlDeclHandler)(void *userData, const XML_Char *version, const XML_Char *encoding, int standalone); XMLPARSEAPI(void) XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler xmldecl); typedef struct { void *(*malloc_fcn)(size_t size); void *(*realloc_fcn)(void *ptr, size_t size); void (*free_fcn)(void *ptr); } XML_Memory_Handling_Suite; /* Constructs a new parser; encoding is the encoding specified by the external protocol or NULL if there is none specified. */ XMLPARSEAPI(XML_Parser) XML_ParserCreate(const XML_Char *encoding); /* Constructs a new parser and namespace processor. Element type names and attribute names that belong to a namespace will be expanded; unprefixed attribute names are never expanded; unprefixed element type names are expanded only if there is a default namespace. The expanded name is the concatenation of the namespace URI, the namespace separator character, and the local part of the name. If the namespace separator is '\0' then the namespace URI and the local part will be concatenated without any separator. It is a programming error to use the separator '\0' with namespace triplets (see XML_SetReturnNSTriplet). If a namespace separator is chosen that can be part of a URI or part of an XML name, splitting an expanded name back into its 1, 2 or 3 original parts on application level in the element handler may end up vulnerable, so these are advised against; sane choices for a namespace separator are e.g. '\n' (line feed) and '|' (pipe). Note that Expat does not validate namespace URIs (beyond encoding) against RFC 3986 today (and is not required to do so with regard to the XML 1.0 namespaces specification) but it may start doing that in future releases. Before that, an application using Expat must be ready to receive namespace URIs containing non-URI characters. */ XMLPARSEAPI(XML_Parser) XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); /* Constructs a new parser using the memory management suite referred to by memsuite. If memsuite is NULL, then use the standard library memory suite. If namespaceSeparator is non-NULL it creates a parser with namespace processing as described above. The character pointed at will serve as the namespace separator. All further memory operations used for the created parser will come from the given suite. */ XMLPARSEAPI(XML_Parser) XML_ParserCreate_MM(const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite, const XML_Char *namespaceSeparator); /* Prepare a parser object to be re-used. This is particularly valuable when memory allocation overhead is disproportionately high, such as when a large number of small documnents need to be parsed. All handlers are cleared from the parser, except for the unknownEncodingHandler. The parser's external state is re-initialized except for the values of ns and ns_triplets. Added in Expat 1.95.3. */ XMLPARSEAPI(XML_Bool) XML_ParserReset(XML_Parser parser, const XML_Char *encoding); /* atts is array of name/value pairs, terminated by 0; names and values are 0 terminated. */ typedef void(XMLCALL *XML_StartElementHandler)(void *userData, const XML_Char *name, const XML_Char **atts); typedef void(XMLCALL *XML_EndElementHandler)(void *userData, const XML_Char *name); /* s is not 0 terminated. */ typedef void(XMLCALL *XML_CharacterDataHandler)(void *userData, const XML_Char *s, int len); /* target and data are 0 terminated */ typedef void(XMLCALL *XML_ProcessingInstructionHandler)(void *userData, const XML_Char *target, const XML_Char *data); /* data is 0 terminated */ typedef void(XMLCALL *XML_CommentHandler)(void *userData, const XML_Char *data); typedef void(XMLCALL *XML_StartCdataSectionHandler)(void *userData); typedef void(XMLCALL *XML_EndCdataSectionHandler)(void *userData); /* This is called for any characters in the XML document for which there is no applicable handler. This includes both characters that are part of markup which is of a kind that is not reported (comments, markup declarations), or characters that are part of a construct which could be reported but for which no handler has been supplied. The characters are passed exactly as they were in the XML document except that they will be encoded in UTF-8 or UTF-16. Line boundaries are not normalized. Note that a byte order mark character is not passed to the default handler. There are no guarantees about how characters are divided between calls to the default handler: for example, a comment might be split between multiple calls. */ typedef void(XMLCALL *XML_DefaultHandler)(void *userData, const XML_Char *s, int len); /* This is called for the start of the DOCTYPE declaration, before any DTD or internal subset is parsed. */ typedef void(XMLCALL *XML_StartDoctypeDeclHandler)(void *userData, const XML_Char *doctypeName, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset); /* This is called for the end of the DOCTYPE declaration when the closing > is encountered, but after processing any external subset. */ typedef void(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData); /* This is called for entity declarations. The is_parameter_entity argument will be non-zero if the entity is a parameter entity, zero otherwise. For internal entities (<!ENTITY foo "bar">), value will be non-NULL and systemId, publicID, and notationName will be NULL. The value string is NOT null-terminated; the length is provided in the value_length argument. Since it is legal to have zero-length values, do not use this argument to test for internal entities. For external entities, value will be NULL and systemId will be non-NULL. The publicId argument will be NULL unless a public identifier was provided. The notationName argument will have a non-NULL value only for unparsed entity declarations. Note that is_parameter_entity can't be changed to XML_Bool, since that would break binary compatibility. */ typedef void(XMLCALL *XML_EntityDeclHandler)( void *userData, const XML_Char *entityName, int is_parameter_entity, const XML_Char *value, int value_length, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName); XMLPARSEAPI(void) XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler); /* OBSOLETE -- OBSOLETE -- OBSOLETE This handler has been superseded by the EntityDeclHandler above. It is provided here for backward compatibility. This is called for a declaration of an unparsed (NDATA) entity. The base argument is whatever was set by XML_SetBase. The entityName, systemId and notationName arguments will never be NULL. The other arguments may be. */ typedef void(XMLCALL *XML_UnparsedEntityDeclHandler)( void *userData, const XML_Char *entityName, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName); /* This is called for a declaration of notation. The base argument is whatever was set by XML_SetBase. The notationName will never be NULL. The other arguments can be. */ typedef void(XMLCALL *XML_NotationDeclHandler)(void *userData, const XML_Char *notationName, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId); /* When namespace processing is enabled, these are called once for each namespace declaration. The call to the start and end element handlers occur between the calls to the start and end namespace declaration handlers. For an xmlns attribute, prefix will be NULL. For an xmlns="" attribute, uri will be NULL. */ typedef void(XMLCALL *XML_StartNamespaceDeclHandler)(void *userData, const XML_Char *prefix, const XML_Char *uri); typedef void(XMLCALL *XML_EndNamespaceDeclHandler)(void *userData, const XML_Char *prefix); /* This is called if the document is not standalone, that is, it has an external subset or a reference to a parameter entity, but does not have standalone="yes". If this handler returns XML_STATUS_ERROR, then processing will not continue, and the parser will return a XML_ERROR_NOT_STANDALONE error. If parameter entity parsing is enabled, then in addition to the conditions above this handler will only be called if the referenced entity was actually read. */ typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData); /* This is called for a reference to an external parsed general entity. The referenced entity is not automatically parsed. The application can parse it immediately or later using XML_ExternalEntityParserCreate. The parser argument is the parser parsing the entity containing the reference; it can be passed as the parser argument to XML_ExternalEntityParserCreate. The systemId argument is the system identifier as specified in the entity declaration; it will not be NULL. The base argument is the system identifier that should be used as the base for resolving systemId if systemId was relative; this is set by XML_SetBase; it may be NULL. The publicId argument is the public identifier as specified in the entity declaration, or NULL if none was specified; the whitespace in the public identifier will have been normalized as required by the XML spec. The context argument specifies the parsing context in the format expected by the context argument to XML_ExternalEntityParserCreate; context is valid only until the handler returns, so if the referenced entity is to be parsed later, it must be copied. context is NULL only when the entity is a parameter entity. The handler should return XML_STATUS_ERROR if processing should not continue because of a fatal error in the handling of the external entity. In this case the calling parser will return an XML_ERROR_EXTERNAL_ENTITY_HANDLING error. Note that unlike other handlers the first argument is the parser, not userData. */ typedef int(XMLCALL *XML_ExternalEntityRefHandler)(XML_Parser parser, const XML_Char *context, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId); /* This is called in two situations: 1) An entity reference is encountered for which no declaration has been read *and* this is not an error. 2) An internal entity reference is read, but not expanded, because XML_SetDefaultHandler has been called. Note: skipped parameter entities in declarations and skipped general entities in attribute values cannot be reported, because the event would be out of sync with the reporting of the declarations or attribute values */ typedef void(XMLCALL *XML_SkippedEntityHandler)(void *userData, const XML_Char *entityName, int is_parameter_entity); /* This structure is filled in by the XML_UnknownEncodingHandler to provide information to the parser about encodings that are unknown to the parser. The map[b] member gives information about byte sequences whose first byte is b. If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalar value c. If map[b] is -1, then the byte sequence is malformed. If map[b] is -n, where n >= 2, then b is the first byte of an n-byte sequence that encodes a single Unicode scalar value. The data member will be passed as the first argument to the convert function. The convert function is used to convert multibyte sequences; s will point to a n-byte sequence where map[(unsigned char)*s] == -n. The convert function must return the Unicode scalar value represented by this byte sequence or -1 if the byte sequence is malformed. The convert function may be NULL if the encoding is a single-byte encoding, that is if map[b] >= -1 for all bytes b. When the parser is finished with the encoding, then if release is not NULL, it will call release passing it the data member; once release has been called, the convert function will not be called again. Expat places certain restrictions on the encodings that are supported using this mechanism. 1. Every ASCII character that can appear in a well-formed XML document, other than the characters $@\^`{}~ must be represented by a single byte, and that byte must be the same byte that represents that character in ASCII. 2. No character may require more than 4 bytes to encode. 3. All characters encoded must have Unicode scalar values <= 0xFFFF, (i.e., characters that would be encoded by surrogates in UTF-16 are not allowed). Note that this restriction doesn't apply to the built-in support for UTF-8 and UTF-16. 4. No Unicode character may be encoded by more than one distinct sequence of bytes. */ typedef struct { int map[256]; void *data; int(XMLCALL *convert)(void *data, const char *s); void(XMLCALL *release)(void *data); } XML_Encoding; /* This is called for an encoding that is unknown to the parser. The encodingHandlerData argument is that which was passed as the second argument to XML_SetUnknownEncodingHandler. The name argument gives the name of the encoding as specified in the encoding declaration. If the callback can provide information about the encoding, it must fill in the XML_Encoding structure, and return XML_STATUS_OK. Otherwise it must return XML_STATUS_ERROR. If info does not describe a suitable encoding, then the parser will return an XML_ERROR_UNKNOWN_ENCODING error. */ typedef int(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData, const XML_Char *name, XML_Encoding *info); XMLPARSEAPI(void) XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, XML_EndElementHandler end); XMLPARSEAPI(void) XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler handler); XMLPARSEAPI(void) XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler handler); XMLPARSEAPI(void) XML_SetCharacterDataHandler(XML_Parser parser, XML_CharacterDataHandler handler); XMLPARSEAPI(void) XML_SetProcessingInstructionHandler(XML_Parser parser, XML_ProcessingInstructionHandler handler); XMLPARSEAPI(void) XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler handler); XMLPARSEAPI(void) XML_SetCdataSectionHandler(XML_Parser parser, XML_StartCdataSectionHandler start, XML_EndCdataSectionHandler end); XMLPARSEAPI(void) XML_SetStartCdataSectionHandler(XML_Parser parser, XML_StartCdataSectionHandler start); XMLPARSEAPI(void) XML_SetEndCdataSectionHandler(XML_Parser parser, XML_EndCdataSectionHandler end); /* This sets the default handler and also inhibits expansion of internal entities. These entity references will be passed to the default handler, or to the skipped entity handler, if one is set. */ XMLPARSEAPI(void) XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler); /* This sets the default handler but does not inhibit expansion of internal entities. The entity reference will not be passed to the default handler. */ XMLPARSEAPI(void) XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler); XMLPARSEAPI(void) XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start, XML_EndDoctypeDeclHandler end); XMLPARSEAPI(void) XML_SetStartDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start); XMLPARSEAPI(void) XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_EndDoctypeDeclHandler end); XMLPARSEAPI(void) XML_SetUnparsedEntityDeclHandler(XML_Parser parser, XML_UnparsedEntityDeclHandler handler); XMLPARSEAPI(void) XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler handler); XMLPARSEAPI(void) XML_SetNamespaceDeclHandler(XML_Parser parser, XML_StartNamespaceDeclHandler start, XML_EndNamespaceDeclHandler end); XMLPARSEAPI(void) XML_SetStartNamespaceDeclHandler(XML_Parser parser, XML_StartNamespaceDeclHandler start); XMLPARSEAPI(void) XML_SetEndNamespaceDeclHandler(XML_Parser parser, XML_EndNamespaceDeclHandler end); XMLPARSEAPI(void) XML_SetNotStandaloneHandler(XML_Parser parser, XML_NotStandaloneHandler handler); XMLPARSEAPI(void) XML_SetExternalEntityRefHandler(XML_Parser parser, XML_ExternalEntityRefHandler handler); /* If a non-NULL value for arg is specified here, then it will be passed as the first argument to the external entity ref handler instead of the parser object. */ XMLPARSEAPI(void) XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg); XMLPARSEAPI(void) XML_SetSkippedEntityHandler(XML_Parser parser, XML_SkippedEntityHandler handler); XMLPARSEAPI(void) XML_SetUnknownEncodingHandler(XML_Parser parser, XML_UnknownEncodingHandler handler, void *encodingHandlerData); /* This can be called within a handler for a start element, end element, processing instruction or character data. It causes the corresponding markup to be passed to the default handler. */ XMLPARSEAPI(void) XML_DefaultCurrent(XML_Parser parser); /* If do_nst is non-zero, and namespace processing is in effect, and a name has a prefix (i.e. an explicit namespace qualifier) then that name is returned as a triplet in a single string separated by the separator character specified when the parser was created: URI + sep + local_name + sep + prefix. If do_nst is zero, then namespace information is returned in the default manner (URI + sep + local_name) whether or not the name has a prefix. Note: Calling XML_SetReturnNSTriplet after XML_Parse or XML_ParseBuffer has no effect. */ XMLPARSEAPI(void) XML_SetReturnNSTriplet(XML_Parser parser, int do_nst); /* This value is passed as the userData argument to callbacks. */ XMLPARSEAPI(void) XML_SetUserData(XML_Parser parser, void *userData); /* Returns the last value set by XML_SetUserData or NULL. */ #define XML_GetUserData(parser) (*(void **)(parser)) /* This is equivalent to supplying an encoding argument to XML_ParserCreate. On success XML_SetEncoding returns non-zero, zero otherwise. Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer has no effect and returns XML_STATUS_ERROR. */ XMLPARSEAPI(enum XML_Status) XML_SetEncoding(XML_Parser parser, const XML_Char *encoding); /* If this function is called, then the parser will be passed as the first argument to callbacks instead of userData. The userData will still be accessible using XML_GetUserData. */ XMLPARSEAPI(void) XML_UseParserAsHandlerArg(XML_Parser parser); /* If useDTD == XML_TRUE is passed to this function, then the parser will assume that there is an external subset, even if none is specified in the document. In such a case the parser will call the externalEntityRefHandler with a value of NULL for the systemId argument (the publicId and context arguments will be NULL as well). Note: For the purpose of checking WFC: Entity Declared, passing useDTD == XML_TRUE will make the parser behave as if the document had a DTD with an external subset. Note: If this function is called, then this must be done before the first call to XML_Parse or XML_ParseBuffer, since it will have no effect after that. Returns XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING. Note: If the document does not have a DOCTYPE declaration at all, then startDoctypeDeclHandler and endDoctypeDeclHandler will not be called, despite an external subset being parsed. Note: If XML_DTD is not defined when Expat is compiled, returns XML_ERROR_FEATURE_REQUIRES_XML_DTD. Note: If parser == NULL, returns XML_ERROR_INVALID_ARGUMENT. */ XMLPARSEAPI(enum XML_Error) XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD); /* Sets the base to be used for resolving relative URIs in system identifiers in declarations. Resolving relative identifiers is left to the application: this value will be passed through as the base argument to the XML_ExternalEntityRefHandler, XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base argument will be copied. Returns XML_STATUS_ERROR if out of memory, XML_STATUS_OK otherwise. */ XMLPARSEAPI(enum XML_Status) XML_SetBase(XML_Parser parser, const XML_Char *base); XMLPARSEAPI(const XML_Char *) XML_GetBase(XML_Parser parser); /* Returns the number of the attribute/value pairs passed in last call to the XML_StartElementHandler that were specified in the start-tag rather than defaulted. Each attribute/value pair counts as 2; thus this corresponds to an index into the atts array passed to the XML_StartElementHandler. Returns -1 if parser == NULL. */ XMLPARSEAPI(int) XML_GetSpecifiedAttributeCount(XML_Parser parser); /* Returns the index of the ID attribute passed in the last call to XML_StartElementHandler, or -1 if there is no ID attribute or parser == NULL. Each attribute/value pair counts as 2; thus this corresponds to an index into the atts array passed to the XML_StartElementHandler. */ XMLPARSEAPI(int) XML_GetIdAttributeIndex(XML_Parser parser); #ifdef XML_ATTR_INFO /* Source file byte offsets for the start and end of attribute names and values. The value indices are exclusive of surrounding quotes; thus in a UTF-8 source file an attribute value of "blah" will yield: info->valueEnd - info->valueStart = 4 bytes. */ typedef struct { XML_Index nameStart; /* Offset to beginning of the attribute name. */ XML_Index nameEnd; /* Offset after the attribute name's last byte. */ XML_Index valueStart; /* Offset to beginning of the attribute value. */ XML_Index valueEnd; /* Offset after the attribute value's last byte. */ } XML_AttrInfo; /* Returns an array of XML_AttrInfo structures for the attribute/value pairs passed in last call to the XML_StartElementHandler that were specified in the start-tag rather than defaulted. Each attribute/value pair counts as 1; thus the number of entries in the array is XML_GetSpecifiedAttributeCount(parser) / 2. */ XMLPARSEAPI(const XML_AttrInfo *) XML_GetAttributeInfo(XML_Parser parser); #endif /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is detected. The last call to XML_Parse must have isFinal true; len may be zero for this call (or any other). Though the return values for these functions has always been described as a Boolean value, the implementation, at least for the 1.95.x series, has always returned exactly one of the XML_Status values. */ XMLPARSEAPI(enum XML_Status) XML_Parse(XML_Parser parser, const char *s, int len, int isFinal); XMLPARSEAPI(void *) XML_GetBuffer(XML_Parser parser, int len); XMLPARSEAPI(enum XML_Status) XML_ParseBuffer(XML_Parser parser, int len, int isFinal); /* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return. Must be called from within a call-back handler, except when aborting (resumable = 0) an already suspended parser. Some call-backs may still follow because they would otherwise get lost. Examples: - endElementHandler() for empty elements when stopped in startElementHandler(), - endNameSpaceDeclHandler() when stopped in endElementHandler(), and possibly others. Can be called from most handlers, including DTD related call-backs, except when parsing an external parameter entity and resumable != 0. Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise. Possible error codes: - XML_ERROR_SUSPENDED: when suspending an already suspended parser. - XML_ERROR_FINISHED: when the parser has already finished. - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE. When resumable != 0 (true) then parsing is suspended, that is, XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED. Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer() return XML_STATUS_ERROR with error code XML_ERROR_ABORTED. *Note*: This will be applied to the current parser instance only, that is, if there is a parent parser then it will continue parsing when the externalEntityRefHandler() returns. It is up to the implementation of the externalEntityRefHandler() to call XML_StopParser() on the parent parser (recursively), if one wants to stop parsing altogether. When suspended, parsing can be resumed by calling XML_ResumeParser(). */ XMLPARSEAPI(enum XML_Status) XML_StopParser(XML_Parser parser, XML_Bool resumable); /* Resumes parsing after it has been suspended with XML_StopParser(). Must not be called from within a handler call-back. Returns same status codes as XML_Parse() or XML_ParseBuffer(). Additional error code XML_ERROR_NOT_SUSPENDED possible. *Note*: This must be called on the most deeply nested child parser instance first, and on its parent parser only after the child parser has finished, to be applied recursively until the document entity's parser is restarted. That is, the parent parser will not resume by itself and it is up to the application to call XML_ResumeParser() on it at the appropriate moment. */ XMLPARSEAPI(enum XML_Status) XML_ResumeParser(XML_Parser parser); enum XML_Parsing { XML_INITIALIZED, XML_PARSING, XML_FINISHED, XML_SUSPENDED }; typedef struct { enum XML_Parsing parsing; XML_Bool finalBuffer; } XML_ParsingStatus; /* Returns status of parser with respect to being initialized, parsing, finished, or suspended and processing the final buffer. XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus, XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED */ XMLPARSEAPI(void) XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status); /* Creates an XML_Parser object that can parse an external general entity; context is a '\0'-terminated string specifying the parse context; encoding is a '\0'-terminated string giving the name of the externally specified encoding, or NULL if there is no externally specified encoding. The context string consists of a sequence of tokens separated by formfeeds (\f); a token consisting of a name specifies that the general entity of the name is open; a token of the form prefix=uri specifies the namespace for a particular prefix; a token of the form =uri specifies the default namespace. This can be called at any point after the first call to an ExternalEntityRefHandler so longer as the parser has not yet been freed. The new parser is completely independent and may safely be used in a separate thread. The handlers and userData are initialized from the parser argument. Returns NULL if out of memory. Otherwise returns a new XML_Parser object. */ XMLPARSEAPI(XML_Parser) XML_ExternalEntityParserCreate(XML_Parser parser, const XML_Char *context, const XML_Char *encoding); enum XML_ParamEntityParsing { XML_PARAM_ENTITY_PARSING_NEVER, XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE, XML_PARAM_ENTITY_PARSING_ALWAYS }; /* Controls parsing of parameter entities (including the external DTD subset). If parsing of parameter entities is enabled, then references to external parameter entities (including the external DTD subset) will be passed to the handler set with XML_SetExternalEntityRefHandler. The context passed will be 0. Unlike external general entities, external parameter entities can only be parsed synchronously. If the external parameter entity is to be parsed, it must be parsed during the call to the external entity ref handler: the complete sequence of XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and XML_ParserFree calls must be made during this call. After XML_ExternalEntityParserCreate has been called to create the parser for the external parameter entity (context must be 0 for this call), it is illegal to make any calls on the old parser until XML_ParserFree has been called on the newly created parser. If the library has been compiled without support for parameter entity parsing (ie without XML_DTD being defined), then XML_SetParamEntityParsing will return 0 if parsing of parameter entities is requested; otherwise it will return non-zero. Note: If XML_SetParamEntityParsing is called after XML_Parse or XML_ParseBuffer, then it has no effect and will always return 0. Note: If parser == NULL, the function will do nothing and return 0. */ XMLPARSEAPI(int) XML_SetParamEntityParsing(XML_Parser parser, enum XML_ParamEntityParsing parsing); /* Sets the hash salt to use for internal hash calculations. Helps in preventing DoS attacks based on predicting hash function behavior. This must be called before parsing is started. Returns 1 if successful, 0 when called after parsing has started. Note: If parser == NULL, the function will do nothing and return 0. */ XMLPARSEAPI(int) XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt); /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then XML_GetErrorCode returns information about the error. */ XMLPARSEAPI(enum XML_Error) XML_GetErrorCode(XML_Parser parser); /* These functions return information about the current parse location. They may be called from any callback called to report some parse event; in this case the location is the location of the first of the sequence of characters that generated the event. When called from callbacks generated by declarations in the document prologue, the location identified isn't as neatly defined, but will be within the relevant markup. When called outside of the callback functions, the position indicated will be just past the last parse event (regardless of whether there was an associated callback). They may also be called after returning from a call to XML_Parse or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then the location is the location of the character at which the error was detected; otherwise the location is the location of the last parse event, as described above. Note: XML_GetCurrentLineNumber and XML_GetCurrentColumnNumber return 0 to indicate an error. Note: XML_GetCurrentByteIndex returns -1 to indicate an error. */ XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser); XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser); XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser); /* Return the number of bytes in the current event. Returns 0 if the event is in an internal entity. */ XMLPARSEAPI(int) XML_GetCurrentByteCount(XML_Parser parser); /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets the integer pointed to by offset to the offset within this buffer of the current parse position, and sets the integer pointed to by size to the size of this buffer (the number of input bytes). Otherwise returns a NULL pointer. Also returns a NULL pointer if a parse isn't active. NOTE: The character pointer returned should not be used outside the handler that makes the call. */ XMLPARSEAPI(const char *) XML_GetInputContext(XML_Parser parser, int *offset, int *size); /* For backwards compatibility with previous versions. */ #define XML_GetErrorLineNumber XML_GetCurrentLineNumber #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber #define XML_GetErrorByteIndex XML_GetCurrentByteIndex /* Frees the content model passed to the element declaration handler */ XMLPARSEAPI(void) XML_FreeContentModel(XML_Parser parser, XML_Content *model); /* Exposing the memory handling functions used in Expat */ XMLPARSEAPI(void *) XML_ATTR_MALLOC XML_ATTR_ALLOC_SIZE(2) XML_MemMalloc(XML_Parser parser, size_t size); XMLPARSEAPI(void *) XML_ATTR_ALLOC_SIZE(3) XML_MemRealloc(XML_Parser parser, void *ptr, size_t size); XMLPARSEAPI(void) XML_MemFree(XML_Parser parser, void *ptr); /* Frees memory used by the parser. */ XMLPARSEAPI(void) XML_ParserFree(XML_Parser parser); /* Returns a string describing the error. */ XMLPARSEAPI(const XML_LChar *) XML_ErrorString(enum XML_Error code); /* Return a string containing the version number of this expat */ XMLPARSEAPI(const XML_LChar *) XML_ExpatVersion(void); typedef struct { int major; int minor; int micro; } XML_Expat_Version; /* Return an XML_Expat_Version structure containing numeric version number information for this version of expat. */ XMLPARSEAPI(XML_Expat_Version) XML_ExpatVersionInfo(void); /* Added in Expat 1.95.5. */ enum XML_FeatureEnum { XML_FEATURE_END = 0, XML_FEATURE_UNICODE, XML_FEATURE_UNICODE_WCHAR_T, XML_FEATURE_DTD, XML_FEATURE_CONTEXT_BYTES, XML_FEATURE_MIN_SIZE, XML_FEATURE_SIZEOF_XML_CHAR, XML_FEATURE_SIZEOF_XML_LCHAR, XML_FEATURE_NS, XML_FEATURE_LARGE_SIZE, XML_FEATURE_ATTR_INFO, /* Added in Expat 2.4.0. */ XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT, XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT, /* Additional features must be added to the end of this enum. */ /* Added in Expat 2.7.2. */ XML_FEATURE_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION_DEFAULT, XML_FEATURE_ALLOC_TRACKER_ACTIVATION_THRESHOLD_DEFAULT, }; typedef struct { enum XML_FeatureEnum feature; const XML_LChar *name; long int value; } XML_Feature; XMLPARSEAPI(const XML_Feature *) XML_GetFeatureList(void); #ifdef XML_DTD /* Added in Expat 2.4.0. */ XMLPARSEAPI(XML_Bool) XML_SetBillionLaughsAttackProtectionMaximumAmplification( XML_Parser parser, float maximumAmplificationFactor); /* Added in Expat 2.4.0. */ XMLPARSEAPI(XML_Bool) XML_SetBillionLaughsAttackProtectionActivationThreshold( XML_Parser parser, unsigned long long activationThresholdBytes); /* Added in Expat 2.7.2. */ XMLPARSEAPI(XML_Bool) XML_SetAllocTrackerMaximumAmplification(XML_Parser parser, float maximumAmplificationFactor); /* Added in Expat 2.7.2. */ XMLPARSEAPI(XML_Bool) XML_SetAllocTrackerActivationThreshold( XML_Parser parser, unsigned long long activationThresholdBytes); #endif /* Added in Expat 2.6.0. */ XMLPARSEAPI(XML_Bool) XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled); /* Expat follows the semantic versioning convention. See http://semver.org. */ #define XML_MAJOR_VERSION 2 #define XML_MINOR_VERSION 5 #define XML_MICRO_VERSION 0 #ifdef __cplusplus } #endif #endif /* not Expat_INCLUDED */ /* Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* * ISO C99 Standard: 7.10/5.2.4.2.1 Sizes of integer types <limits.h> */ #ifndef _LIBC_LIMITS_H_ #define _LIBC_LIMITS_H_ 1 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION #include <bits/libc-header-start.h> /* Maximum length of any multibyte character in any locale. We define this value here since the gcc header does not define the correct value. */ #define MB_LEN_MAX 16 /* If we are not using GNU CC we have to define all the symbols ourself. Otherwise use gcc's definitions (see below). */ #if !defined __GNUC__ || __GNUC__ < 2 /* We only protect from multiple inclusion here, because all the other #include's protect themselves, and in GCC 2 we may #include_next through multiple copies of this file before we get to GCC's. */ # ifndef _LIMITS_H # define _LIMITS_H 1 #include <bits/wordsize.h> /* We don't have #include_next. Define ANSI <limits.h> for standard 32-bit words. */ /* These assume 8-bit `char's, 16-bit `short int's, and 32-bit `int's and `long int's. */ /* Number of bits in a `char'. */ # define CHAR_BIT 8 /* Minimum and maximum values a `signed char' can hold. */ # define SCHAR_MIN (-128) # define SCHAR_MAX 127 /* Maximum value an `unsigned char' can hold. (Minimum is 0.) */ # define UCHAR_MAX 255 /* Minimum and maximum values a `char' can hold. */ # ifdef __CHAR_UNSIGNED__ # define CHAR_MIN 0 # define CHAR_MAX UCHAR_MAX # else # define CHAR_MIN SCHAR_MIN # define CHAR_MAX SCHAR_MAX # endif /* Minimum and maximum values a `signed short int' can hold. */ # define SHRT_MIN (-32768) # define SHRT_MAX 32767 /* Maximum value an `unsigned short int' can hold. (Minimum is 0.) */ # define USHRT_MAX 65535 /* Minimum and maximum values a `signed int' can hold. */ # define INT_MIN (-INT_MAX - 1) # define INT_MAX 2147483647 /* Maximum value an `unsigned int' can hold. (Minimum is 0.) */ # define UINT_MAX 4294967295U /* Minimum and maximum values a `signed long int' can hold. */ # if __WORDSIZE == 64 # define LONG_MAX 9223372036854775807L # else # define LONG_MAX 2147483647L # endif # define LONG_MIN (-LONG_MAX - 1L) /* Maximum value an `unsigned long int' can hold. (Minimum is 0.) */ # if __WORDSIZE == 64 # define ULONG_MAX 18446744073709551615UL # else # define ULONG_MAX 4294967295UL # endif # ifdef __USE_ISOC99 /* Minimum and maximum values a `signed long long int' can hold. */ # define LLONG_MAX 9223372036854775807LL # define LLONG_MIN (-LLONG_MAX - 1LL) /* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ # define ULLONG_MAX 18446744073709551615ULL # endif /* ISO C99 */ # endif /* limits.h */ #endif /* GCC 2. */ #endif /* !_LIBC_LIMITS_H_ */ /* Get the compiler's limits.h, which defines almost all the ISO constants. We put this #include_next outside the double inclusion check because it should be possible to include this file more than once and still get the definitions from gcc's header. */ #if defined __GNUC__ && !defined _GCC_LIMITS_H_ /* `_GCC_LIMITS_H_' is what GCC's file defines. */ # include_next <limits.h> #endif /* The <limits.h> files in some gcc versions don't define LLONG_MIN, LLONG_MAX, and ULLONG_MAX. Instead only the values gcc defined for ages are available. */ #if defined __USE_ISOC99 && defined __GNUC__ # ifndef LLONG_MIN # define LLONG_MIN (-LLONG_MAX-1) # endif # ifndef LLONG_MAX # define LLONG_MAX __LONG_LONG_MAX__ # endif # ifndef ULLONG_MAX # define ULLONG_MAX (LLONG_MAX * 2ULL + 1) # endif #endif /* The integer width macros are not defined by GCC's <limits.h> before GCC 7, or if _GNU_SOURCE rather than __STDC_WANT_IEC_60559_BFP_EXT__ is used to enable this feature. */ #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) # ifndef CHAR_WIDTH # define CHAR_WIDTH 8 # endif # ifndef SCHAR_WIDTH # define SCHAR_WIDTH 8 # endif # ifndef UCHAR_WIDTH # define UCHAR_WIDTH 8 # endif # ifndef SHRT_WIDTH # define SHRT_WIDTH 16 # endif # ifndef USHRT_WIDTH # define USHRT_WIDTH 16 # endif # ifndef INT_WIDTH # define INT_WIDTH 32 # endif # ifndef UINT_WIDTH # define UINT_WIDTH 32 # endif # ifndef LONG_WIDTH # define LONG_WIDTH __WORDSIZE # endif # ifndef ULONG_WIDTH # define ULONG_WIDTH __WORDSIZE # endif # ifndef LLONG_WIDTH # define LLONG_WIDTH 64 # endif # ifndef ULLONG_WIDTH # define ULLONG_WIDTH 64 # endif #endif /* Use IEC_60559_BFP_EXT. */ /* The macros for _Bool are not defined by GCC's <limits.h> before GCC 11, or if _GNU_SOURCE is defined rather than enabling C2x support with -std. */ #if __GLIBC_USE (ISOC2X) # ifndef BOOL_MAX # define BOOL_MAX 1 # endif # ifndef BOOL_WIDTH # define BOOL_WIDTH 1 # endif #endif #ifdef __USE_POSIX /* POSIX adds things to <limits.h>. */ # include <bits/posix1_lim.h> #endif #ifdef __USE_POSIX2 # include <bits/posix2_lim.h> #endif #ifdef __USE_XOPEN # include <bits/xopen_lim.h> #endif /* Declarations for getopt. Copyright (C) 1989-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. Unlike the bulk of the getopt implementation, this file is NOT part of gnulib; gnulib also has a getopt.h but it is different. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _GETOPT_H #define _GETOPT_H 1 #include <features.h> /* The type of the 'argv' argument to getopt_long and getopt_long_only is properly 'char **', since both functions may write to the array (in order to move all the options to the beginning). However, for compatibility with old versions of LSB, glibc has to use 'char *const *' instead. */ #ifndef __getopt_argv_const # define __getopt_argv_const const #endif #include <bits/getopt_core.h> #include <bits/getopt_ext.h> #endif /* getopt.h */ /* File tree traversal functions declarations. Copyright (C) 1994-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)fts.h 8.3 (Berkeley) 8/14/94 */ #ifndef _FTS_H #define _FTS_H 1 #include <features.h> #include <sys/types.h> typedef struct { struct _ftsent *fts_cur; /* current node */ struct _ftsent *fts_child; /* linked list of children */ struct _ftsent **fts_array; /* sort array */ dev_t fts_dev; /* starting device # */ char *fts_path; /* path for this descent */ int fts_rfd; /* fd for root */ int fts_pathlen; /* sizeof(path) */ int fts_nitems; /* elements in the sort array */ int (*fts_compar) (const void *, const void *); /* compare fn */ #define FTS_COMFOLLOW 0x0001 /* follow command line symlinks */ #define FTS_LOGICAL 0x0002 /* logical walk */ #define FTS_NOCHDIR 0x0004 /* don't change directories */ #define FTS_NOSTAT 0x0008 /* don't get stat info */ #define FTS_PHYSICAL 0x0010 /* physical walk */ #define FTS_SEEDOT 0x0020 /* return dot and dot-dot */ #define FTS_XDEV 0x0040 /* don't cross devices */ #define FTS_WHITEOUT 0x0080 /* return whiteout information */ #define FTS_OPTIONMASK 0x00ff /* valid user option mask */ #define FTS_NAMEONLY 0x0100 /* (private) child names only */ #define FTS_STOP 0x0200 /* (private) unrecoverable error */ int fts_options; /* fts_open options, global flags */ } FTS; #ifdef __USE_LARGEFILE64 typedef struct { struct _ftsent64 *fts_cur; /* current node */ struct _ftsent64 *fts_child; /* linked list of children */ struct _ftsent64 **fts_array; /* sort array */ dev_t fts_dev; /* starting device # */ char *fts_path; /* path for this descent */ int fts_rfd; /* fd for root */ int fts_pathlen; /* sizeof(path) */ int fts_nitems; /* elements in the sort array */ int (*fts_compar) (const void *, const void *); /* compare fn */ int fts_options; /* fts_open options, global flags */ } FTS64; #endif typedef struct _ftsent { struct _ftsent *fts_cycle; /* cycle node */ struct _ftsent *fts_parent; /* parent directory */ struct _ftsent *fts_link; /* next file in directory */ long fts_number; /* local numeric value */ void *fts_pointer; /* local address value */ char *fts_accpath; /* access path */ char *fts_path; /* root path */ int fts_errno; /* errno for this node */ int fts_symfd; /* fd for symlink */ unsigned short fts_pathlen; /* strlen(fts_path) */ unsigned short fts_namelen; /* strlen(fts_name) */ ino_t fts_ino; /* inode */ dev_t fts_dev; /* device */ nlink_t fts_nlink; /* link count */ #define FTS_ROOTPARENTLEVEL -1 #define FTS_ROOTLEVEL 0 short fts_level; /* depth (-1 to N) */ #define FTS_D 1 /* preorder directory */ #define FTS_DC 2 /* directory that causes cycles */ #define FTS_DEFAULT 3 /* none of the above */ #define FTS_DNR 4 /* unreadable directory */ #define FTS_DOT 5 /* dot or dot-dot */ #define FTS_DP 6 /* postorder directory */ #define FTS_ERR 7 /* error; errno is set */ #define FTS_F 8 /* regular file */ #define FTS_INIT 9 /* initialized only */ #define FTS_NS 10 /* stat(2) failed */ #define FTS_NSOK 11 /* no stat(2) requested */ #define FTS_SL 12 /* symbolic link */ #define FTS_SLNONE 13 /* symbolic link without target */ #define FTS_W 14 /* whiteout object */ unsigned short fts_info; /* user flags for FTSENT structure */ #define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ #define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ unsigned short fts_flags; /* private flags for FTSENT structure */ #define FTS_AGAIN 1 /* read node again */ #define FTS_FOLLOW 2 /* follow symbolic link */ #define FTS_NOINSTR 3 /* no instructions */ #define FTS_SKIP 4 /* discard node */ unsigned short fts_instr; /* fts_set() instructions */ struct stat *fts_statp; /* stat(2) information */ char fts_name[1]; /* file name */ } FTSENT; #ifdef __USE_LARGEFILE64 typedef struct _ftsent64 { struct _ftsent64 *fts_cycle; /* cycle node */ struct _ftsent64 *fts_parent; /* parent directory */ struct _ftsent64 *fts_link; /* next file in directory */ long fts_number; /* local numeric value */ void *fts_pointer; /* local address value */ char *fts_accpath; /* access path */ char *fts_path; /* root path */ int fts_errno; /* errno for this node */ int fts_symfd; /* fd for symlink */ unsigned short fts_pathlen; /* strlen(fts_path) */ unsigned short fts_namelen; /* strlen(fts_name) */ ino64_t fts_ino; /* inode */ dev_t fts_dev; /* device */ nlink_t fts_nlink; /* link count */ short fts_level; /* depth (-1 to N) */ unsigned short fts_info; /* user flags for FTSENT structure */ unsigned short fts_flags; /* private flags for FTSENT structure */ unsigned short fts_instr; /* fts_set() instructions */ struct stat64 *fts_statp; /* stat(2) information */ char fts_name[1]; /* file name */ } FTSENT64; #endif __BEGIN_DECLS #ifndef __USE_FILE_OFFSET64 FTSENT *fts_children (FTS *, int); int fts_close (FTS *); FTS *fts_open (char * const *, int, int (*)(const FTSENT **, const FTSENT **)); FTSENT *fts_read (FTS *); int fts_set (FTS *, FTSENT *, int) __THROW; #else # ifdef __REDIRECT # ifndef __USE_TIME_BITS64 FTSENT *__REDIRECT (fts_children, (FTS *, int), fts64_children); int __REDIRECT (fts_close, (FTS *), fts64_close); FTS *__REDIRECT (fts_open, (char * const *, int, int (*)(const FTSENT **, const FTSENT **)), fts64_open); FTSENT *__REDIRECT (fts_read, (FTS *), fts64_read); int __REDIRECT_NTH (fts_set, (FTS *, FTSENT *, int), fts64_set); # else FTSENT *__REDIRECT (fts_children, (FTS *, int), __fts64_children_time64); int __REDIRECT (fts_close, (FTS *), __fts64_close_time64); FTS *__REDIRECT (fts_open, (char * const *, int, int (*)(const FTSENT **, const FTSENT **)), __fts64_open_time64); FTSENT *__REDIRECT (fts_read, (FTS *), __fts64_read_time64); int __REDIRECT_NTH (fts_set, (FTS *, FTSENT *, int), __fts64_set_time64); # endif # else # ifndef __USE_TIME_BITS64 # define fts_children fts64_children # define fts_close fts64_close # define fts_open fts64_open # define fts_read fts64_read # define fts_set fts64_set # else # endif # endif #endif #ifdef __USE_LARGEFILE64 # ifndef __USE_TIME_BITS64 FTSENT64 *fts64_children (FTS64 *, int); int fts64_close (FTS64 *); FTS64 *fts64_open (char * const *, int, int (*)(const FTSENT64 **, const FTSENT64 **)); FTSENT64 *fts64_read (FTS64 *); int fts64_set (FTS64 *, FTSENT64 *, int) __THROW; # else # ifdef __REDIRECT FTSENT *__REDIRECT (fts64_children, (FTS64 *, int), __fts64_children_time64); int __REDIRECT (fts64_close, (FTS64 *), __fts64_close_time64); FTS *__REDIRECT (fts64_open, (char * const *, int, int (*)(const FTSENT64 **, const FTSENT64 **)), __fts64_open_time64); FTSENT *__REDIRECT (fts64_read, (FTS64 *), __fts64_read_time64); int __REDIRECT_NTH (fts64_set, (FTS64 *, FTSENT64 *, int), __fts64_set_time64); # else # define fts_children __fts64_children_time64 # define fts_close __fts64_close_time64 # define fts_open __fts64_open_time64 # define fts_read __fts64_read_time64 # define fts_set __fts64_set_time64 # endif # endif #endif __END_DECLS #endif /* fts.h */ /* ***************************************************************************** ** Initial file written and documented by: ** Kevin Shepherd <kshepherd@php.net> December 2007 ** of Scarlet Line http://www.scarletline.com/ ** with contributions from Torben Nielsen. *******************************************************************************/ /** \file gdpp.h \brief Object Oriented C++ wrappers around libgd functionality. Example usage, convert png to gif: #include <fstream> #include <gdpp.h> std::ifstream in("image.png", std::ios_base::in | std::ios_base::binary ); GD::Image im(in, GD::Png_tag()); if (im.good()) { std::ofstream out("image.gif", std::ios_base::out | std::ios_base::binary ); im.Gif(out); } */ #ifndef _gdpp_h #define _gdpp_h #ifdef __cplusplus #include "gd_io_stream.h" #include <string> /// namespace GD:: contains the C++ wrapper classes for libgd /** This namespace is primarily to avoid name clashes, and to contain all of the gd classes within one namespace. It is not recommended to use the "using namespace" directive with this namespace. Example usage: GD::Image im(64, 32, true); // Create a truecolor image 64 pixels wide by 32 pixels high GD::Point pt(10, 8); // The point at x=10, y=8. GD::Size sz(16, 8); // The size width=16, height=8. GD::TrueColor col(0xFF, 0, 0); // The colour red; R=255, G=0, B=0. im.Rectangle(pt, sz, col.Int()); // Draw a red rectangle with top left corner at pt, of size sz. */ namespace GD { /** This class GD::Point stores a point in two dimensions, somewhere on the plane of an image. */ class BGD_EXPORT_DATA_PROT Point { public: // Constructors Point(int x, int y) :_x(x), _y(y) {} Point(const Point & p) :_x(p._x), _y(p._y) {} Point() :_x(0), _y(0) {} Point & operator=(const Point & p) { _x = p._x; _y = p._y; return (* this); } // Accessors int X() const { return _x; } int Y() const { return _y; } // Updaters void X(int x) { _x = x; } void Y(int y) { _y = y; } void set(int x, int y) { _x = x; _y = y; } int & lhsX() { return _x; } int & lhsY() { return _y; } gdPointPtr as_gdPointPtr() { return (gdPointPtr) this; } protected: int _x, _y; }; typedef Point * PointPtr; /** This class GD::Size stores length in two dimensions. Giving the size of an area as width and height. */ class BGD_EXPORT_DATA_PROT Size { public: // Constructors Size(int w, int h) :_w(w), _h(h) {} Size(const Size & p) :_w(p._w), _h(p._h) {} Size() :_w(0), _h(0) {} Size & operator=(const Size & p) { _w = p._w; _h = p._h; return (* this); } // Accessors int W() const { return _w; } int H() const { return _h; } // Updaters void W(int w) { _w = w; } void H(int h) { _h = h; } void set(int w, int h) { _w = w; _h = h; } int & lhsW() { return _w; } int & lhsH() { return _h; } protected: int _w, _h; }; typedef Size * SizePtr; /** This class GD::TrueColor stores a colour as an RGBA quadruplet. It can also be read as an integer, and in other colour formats. */ class BGD_EXPORT_DATA_PROT TrueColor { public: union as_types { int as_int; struct uchars { unsigned char blue, green, red, alpha; } as_uchar; }; TrueColor() { internal.as_int = 0; } TrueColor(int c) { internal.as_int = c; } TrueColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0) { internal.as_uchar.alpha = a; internal.as_uchar.red = r; internal.as_uchar.green = g; internal.as_uchar.blue = b; } // Accessors int Int() const { return internal.as_int; } unsigned char Red() const { return internal.as_uchar.red; } unsigned char Green() const { return internal.as_uchar.green; } unsigned char Blue() const { return internal.as_uchar.blue; } unsigned char Alpha() const { return internal.as_uchar.alpha; } // Updaters void set(int c) { internal.as_int = c; } void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0) { internal.as_uchar.alpha = a; internal.as_uchar.red = r; internal.as_uchar.green = g; internal.as_uchar.blue = b; } void Red(unsigned char c) { internal.as_uchar.red = c; } void Green(unsigned char c) { internal.as_uchar.green = c; } void Blue(unsigned char c) { internal.as_uchar.blue = c; } void Alpha(unsigned char c) { internal.as_uchar.alpha = c; } protected: as_types internal; }; /* The following tags are simply empty structures which are used to tell the compiler which constructor we want when we know the image file format. */ struct BGD_EXPORT_DATA_PROT Png_tag {}; struct BGD_EXPORT_DATA_PROT Gif_tag {}; struct BGD_EXPORT_DATA_PROT WBMP_tag {}; struct BGD_EXPORT_DATA_PROT Jpeg_tag {}; struct BGD_EXPORT_DATA_PROT Gd_tag {}; struct BGD_EXPORT_DATA_PROT Gd2_tag {}; struct BGD_EXPORT_DATA_PROT Xbm_tag {}; /** This class GD::Image wraps all of the 'C' libgd functionality for the convenience of C++ users. An instance of this class corresponds to a single image. */ class BGD_EXPORT_DATA_PROT Image { public: /** Construct a null image */ Image() :im(0) {} /** Construct a blank image, of the given size and colour format type. \param[in] sx Width of the image \param[in] sy Height of the image \param[in] istruecolor Create a true colour image, defaults to false, i.e. create an indexed palette image. */ Image(int sx, int sy, bool istruecolor = false) :im(0) { if (istruecolor) CreateTrueColor(sx, sy); else Create(sx, sy); } /** Construct a blank image, of the given size and colour format type. \param[in] s Width and height of the image \param[in] istruecolor Create a true colour image, defaults to false, i.e. create an indexed palette image. */ Image(const Size & s, bool istruecolor = false) :im(0) { if (istruecolor) CreateTrueColor(s); else Create(s); } /** Construct an instance of the GD::Image class, given the internal gdImage poimter. Note that gdImageDestroy will be called on the image pointer in the destructor. \param[in] i Pointer to the internal gdImage */ Image(gdImagePtr i) :im(i) {} /** Copy constructor. Construct an instance of the GD::Image class, by making a copy of the GD::Image provided. \param[in] i Reference to the image to be copied */ Image(const GD::Image & i) :im(0) { Copy(i); } /** Construct an image by reading from \p in. This constructor will first attempt to determine the file format. \param[in] in The stream containing the image data */ Image(std::istream & in) :im(0) { CreateFrom(in); } /** Construct an image by reading from \p in. This constructor will first attempt to determine the file format. \param[in] in An opened FILE * handle to a file containing the image data */ Image(FILE * in) :im(0) { CreateFrom(in); } /** Construct an image by reading from memory block \p data. This constructor will first attempt to determine the image formatting. \param[in] size The byte count of the memory block \param[in] data Pointer to the memory block */ Image(int size, void * data) :im(0) { CreateFrom(size, data); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input \param[in] in The stream containing the image data */ Image(std::istream & in, Png_tag) :im(0) { CreateFromPng(in); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input \param[in] in An opened FILE * handle to a file containing the image data */ Image(FILE * in, Png_tag) :im(0) { CreateFromPng(in); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input \param[in] in The io context from which to read the image data */ Image(gdIOCtx * in, Png_tag) :im(0) { CreateFromPng(in); } /** Construct an image by reading from memory block \p data. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(sz, dat, GD::Png_tag()); // read a png file from dat \param[in] size The byte count of the memory block \param[in] data Pointer to the memory block */ Image(int size, void * data, Png_tag) :im(0) { CreateFromPng(size, data); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Gif_tag()); // read a gif file from input \param[in] in The stream containing the image data */ Image(std::istream & in, Gif_tag) :im(0) { CreateFromGif(in); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Gif_tag()); // read a gif file from input \param[in] in An opened FILE * handle to a file containing the image data */ Image(FILE * in, Gif_tag) :im(0) { CreateFromGif(in); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Gif_tag()); // read a gif file from input \param[in] in The io context from which to read the image data */ Image(gdIOCtx * in, Gif_tag) :im(0) { CreateFromGif(in); } /** Construct an image by reading from memory block \p data. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(sz, dat, GD::Gif_tag()); // read a gif file from dat \param[in] size The byte count of the memory block \param[in] data Pointer to the memory block */ Image(int size, void * data, Gif_tag) :im(0) { CreateFromGif(size, data); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::WBMP_tag()); // read a monchrome WBMP file from input \param[in] in The stream containing the image data */ Image(std::istream & in, WBMP_tag) :im(0) { CreateFromWBMP(in); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::WBMP_tag()); // read a monchrome WBMP file from input \param[in] in An opened FILE * handle to a file containing the image data */ Image(FILE * in, WBMP_tag) :im(0) { CreateFromWBMP(in); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::WBMP_tag()); // read a monchrome WBMP file from input \param[in] in The io context from which to read the image data */ Image(gdIOCtx * in, WBMP_tag) :im(0) { CreateFromWBMP(in); } /** Construct an image by reading from memory block \p data. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(sz, dat, GD::WBMP_tag()); // read a monchrome WBMP file from dat \param[in] size The byte count of the memory block \param[in] data Pointer to the memory block */ Image(int size, void * data, WBMP_tag) :im(0) { CreateFromWBMP(size, data); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input \param[in] in The stream containing the image data */ Image(std::istream & in, Jpeg_tag) :im(0) { CreateFromJpeg(in); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input \param[in] in An opened FILE * handle to a file containing the image data */ Image(FILE * in, Jpeg_tag) :im(0) { CreateFromJpeg(in); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input \param[in] in The io context from which to read the image data */ Image(gdIOCtx * in, Jpeg_tag) :im(0) { CreateFromJpeg(in); } /** Construct an image by reading from memory block \p data. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(sz, dat, GD::Jpeg_tag()); // read a jpeg file from dat \param[in] size The byte count of the memory block \param[in] data Pointer to the memory block */ Image(int size, void * data, Jpeg_tag) :im(0) { CreateFromJpeg(size, data); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Gd_tag()); // read a gd file from input \param[in] in The stream containing the image data */ Image(std::istream & in, Gd_tag) :im(0) { CreateFromGd(in); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Gd_tag()); // read a gd file from input \param[in] in An opened FILE * handle to a file containing the image data */ Image(FILE * in, Gd_tag) :im(0) { CreateFromGd(in); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Gd_tag()); // read a gd file from input \param[in] in The io context from which to read the image data */ Image(gdIOCtx * in, Gd_tag) :im(0) { CreateFromGd(in); } /** Construct an image by reading from memory block \p data. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(sz, dat, GD::Gd_tag()); // read a gd file from dat \param[in] size The byte count of the memory block \param[in] data Pointer to the memory block */ Image(int size, void * data, Gd_tag) :im(0) { CreateFromGd(size, data); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Gd2_tag()); // read a gd2 file from input \param[in] in The stream containing the image data */ Image(std::istream & in, Gd2_tag) :im(0) { CreateFromGd2(in); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input \param[in] in An opened FILE * handle to a file containing the image data */ Image(FILE * in, Gd2_tag) :im(0) { CreateFromGd2(in); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Gd2_tag()); // read a gd2 file from input \param[in] in The io context from which to read the image data */ Image(gdIOCtx * in, Gd2_tag) :im(0) { CreateFromGd2(in); } /** Construct an image by reading from memory block \p data. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(sz, dat, GD::Gd2_tag()); // read a gd2 file from dat \param[in] size The byte count of the memory block \param[in] data Pointer to the memory block */ Image(int size, void * data, Gd2_tag) :im(0) { CreateFromGd2(size, data); } /** Construct an image by reading from \p in. The tag is an empty struct which simply tells the compiler which image read function to use. e.g. GD::Image img(input, GD::Xbm_tag()); // read an xbm file from input \param[in] in An opened FILE * handle to a file containing the image data */ Image(FILE * in, Xbm_tag) :im(0) { CreateFromXbm(in); } ~Image() { clear(); } /** Assignment Operator. Make this a copy of the GD::Image provided. \param[in] src Reference to the image to be copied */ GD::Image & operator=(const GD::Image & src) { Copy(src); return (* this); } /** Make this an exact copy of the GD::Image provided. Any existing iamge data is discarded. \param[in] src Reference to the image to be copied */ void Copy(const GD::Image & src) { int w = src.Width(), h = src.Height(); if (src.IsTrueColor()) CreateTrueColor(w, h); else { Create(w, h); PaletteCopy(src); } Copy(src, 0, 0, 0, 0, w, h); } /** Check to see if this appears to be a valid image */ bool good() const { return (im != 0); } // Creation: /** Create a palette-based image, with no more than 256 colors. \param sx Width of the desired image \param sy Height of the desired image \return true if it worked, else false */ bool Create(int sx, int sy) { clear(); return ((im = gdImageCreate(sx, sy)) != 0); } /** Create a truecolor image. \param sx Width of the desired image \param sy Height of the desired image \return true if it worked, else false */ bool CreateTrueColor(int sx, int sy) { clear(); return ((im = gdImageCreateTrueColor(sx, sy)) != 0); } /** Create a palette-based image, with no more than 256 colors. \param s Width and height of the desired image \return true if it worked, else false */ bool Create(const Size & s) { return Create(s.W(), s.H()); } /** Create a truecolor image. \param s Width and height of the desired image \return true if it worked, else false */ bool CreateTrueColor(const Size & s) { return CreateTrueColor(s.W(), s.H()); } // Create, determining the image format from the data /// Read an image from an open FILE * handle, after determining the image format bool CreateFrom(FILE * in); /// Read an image from an open standard library input stream, after determining the image format bool CreateFrom(std::istream & in); /// Read an image from a memory block, after determining the image format bool CreateFrom(int size, void * data); // Png bool CreateFromPng(FILE * in) { clear(); return ((im = gdImageCreateFromPng(in)) != 0); } bool CreateFromPng(gdIOCtx * in) { clear(); return ((im = gdImageCreateFromPngCtx(in)) != 0); } bool CreateFromPng(int size, void * data) { clear(); return ((im = gdImageCreateFromPngPtr(size, data)) != 0); } bool CreateFromPng(std::istream & in) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromPngCtx( & _in_ctx)) != 0); } // Gif bool CreateFromGif(FILE * in) { clear(); return ((im = gdImageCreateFromGif(in)) != 0); } bool CreateFromGif(gdIOCtx * in) { clear(); return ((im = gdImageCreateFromGifCtx(in)) != 0); } bool CreateFromGif(int size, void * data) { clear(); return ((im = gdImageCreateFromGifPtr(size, data)) != 0); } bool CreateFromGif(std::istream & in) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromGifCtx( & _in_ctx)) != 0); } // WBMP bool CreateFromWBMP(FILE * in) { clear(); return ((im = gdImageCreateFromWBMP(in)) != 0); } bool CreateFromWBMP(gdIOCtx * in) { clear(); return ((im = gdImageCreateFromWBMPCtx(in)) != 0); } bool CreateFromWBMP(int size, void * data) { clear(); return ((im = gdImageCreateFromWBMPPtr(size, data)) != 0); } bool CreateFromWBMP(std::istream & in) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromWBMPCtx( & _in_ctx)) != 0); } // Jpeg /** Load a truecolor image from a JPEG format file. Invoke CreateFromJpeg with an already opened pointer to a file containing the desired image. CreateFromJpeg does not close the file. \return true for success, or false if unable to load the image (most often because the file is corrupt or does not contain a JPEG image). You can call Width() and Height() member functions of the image to determine its size. The returned image is always a truecolor image. */ bool CreateFromJpeg(FILE * in) { clear(); return ((im = gdImageCreateFromJpeg(in)) != 0); } /** Load a truecolor image from a JPEG format file. Invoke CreateFromJpeg with an already opened pointer to a file containing the desired image. CreateFromJpeg does not close the file. \return true for success, or false if unable to load the image (most often because the file is corrupt or does not contain a JPEG image). You can call Width() and Height() member functions of the image to determine its size. The returned image is always a truecolor image. */ bool CreateFromJpeg(gdIOCtx * in) { clear(); return ((im = gdImageCreateFromJpegCtx(in)) != 0); } /** Load a truecolor image from a JPEG format file. Invoke CreateFromJpeg with an already opened pointer to a file containing the desired image. CreateFromJpeg does not close the file. \return true for success, or false if unable to load the image (most often because the file is corrupt or does not contain a JPEG image). You can call Width() and Height() member functions of the image to determine its size. The returned image is always a truecolor image. */ bool CreateFromJpeg(int size, void * data) { clear(); return ((im = gdImageCreateFromJpegPtr(size, data)) != 0); } /** Load a truecolor image from a JPEG format file. Invoke CreateFromJpeg with an image file in memory. \return true for success, or false if unable to load the image (most often because the format is corrupt or does not contain a JPEG image). You can call Width() and Height() member functions of the image to determine its size. The returned image is always a truecolor image. */ bool CreateFromJpeg(std::istream & in) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromJpegCtx( & _in_ctx)) != 0); } // Gd bool CreateFromGd(FILE * in) { clear(); return ((im = gdImageCreateFromGd(in)) != 0); } bool CreateFromGd(gdIOCtx * in) { clear(); return ((im = gdImageCreateFromGdCtx(in)) != 0); } bool CreateFromGd(int size, void * data) { clear(); return ((im = gdImageCreateFromGdPtr(size, data)) != 0); } bool CreateFromGd(std::istream & in) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromGdCtx( & _in_ctx)) != 0); } // Gd2 bool CreateFromGd2(FILE * in) { clear(); return ((im = gdImageCreateFromGd2(in)) != 0); } bool CreateFromGd2(gdIOCtx * in) { clear(); return ((im = gdImageCreateFromGd2Ctx(in)) != 0); } bool CreateFromGd2(int size, void * data) { clear(); return ((im = gdImageCreateFromGd2Ptr(size, data)) != 0); } bool CreateFromGd2(std::istream & in) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromGd2Ctx( & _in_ctx)) != 0); } // Gd2 Part bool CreateFromGd2Part(FILE * in, int srcx, int srcy, int w, int h) { clear(); return ((im = gdImageCreateFromGd2Part(in, srcx, srcy, w, h)) != 0); } bool CreateFromGd2Part(gdIOCtx * in, int srcx, int srcy, int w, int h) { clear(); return ((im = gdImageCreateFromGd2PartCtx(in, srcx, srcy, w, h)) != 0); } bool CreateFromGd2Part(int size, void * data, int srcx, int srcy, int w, int h) { clear(); return ((im = gdImageCreateFromGd2PartPtr(size, data, srcx, srcy, w, h)) != 0); } bool CreateFromGd2Part(std::istream & in, int srcx, int srcy, int w, int h) { clear(); istreamIOCtx _in_ctx(in); return ((im = gdImageCreateFromGd2PartCtx( & _in_ctx, srcx, srcy, w, h)) != 0); } bool CreateFromGd2Part(FILE * in, const Point & src, const Size & s) { return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H()); } bool CreateFromGd2Part(gdIOCtx * in, const Point & src, const Size & s) { return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H()); } bool CreateFromGd2Part(int size, void * data, const Point & src, const Size & s) { return CreateFromGd2Part(size, data, src.X(), src.Y(), s.W(), s.H()); } bool CreateFromGd2Part(std::istream & in, const Point & src, const Size & s) { return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H()); } // Xbm bool CreateFromXbm(FILE * in) { clear(); return ((im = gdImageCreateFromXbm(in)) != 0); } // Xpm bool CreateFromXpm(char * filename) { clear(); return ((im = gdImageCreateFromXpm(filename)) != 0); } bool CreateFromXpm(std::string & filename) { return CreateFromXpm((char *)(filename.c_str())); } // Accessors, Updaters & Methods: void SetPixel(int x, int y, int color) { gdImageSetPixel(im, x, y, color); } void SetPixel(const Point & p, int color) { SetPixel(p.X(), p.Y(), color); } int GetPixel(int x, int y) const { return gdImageGetPixel(im, x, y); } int GetPixel(const Point & p) const { return GetPixel(p.X(), p.Y()); } int GetTrueColorPixel(int x, int y) const { return gdImageGetTrueColorPixel(im, x, y); } int GetTrueColorPixel(const Point & p) const { return GetTrueColorPixel(p.X(), p.Y()); } void SetPixel(int x, int y, TrueColor c) { SetPixel(x, y, c.Int()); } void SetPixel(const Point & p, TrueColor c) { SetPixel(p.X(), p.Y(), c.Int()); } void GetTrueColorPixel(TrueColor & c, int x, int y) const { c.set(GetTrueColorPixel(x, y)); } void GetTrueColorPixel(TrueColor & c, const Point & p) const { c.set(GetTrueColorPixel(p.X(), p.Y())); } void AABlend() { gdImageAABlend(im); } void Line(int x1, int y1, int x2, int y2, int color) { gdImageLine(im, x1, y1, x2, y2, color); } void Line(const Point & p1, const Point & p2, int color) { Line(p1.X(), p1.Y(), p2.X(), p2.Y(), color); } void Rectangle(int x1, int y1, int x2, int y2, int color) { gdImageRectangle(im, x1, y1, x2, y2, color); } void Rectangle(const Point & p1, const Point & p2, int color) { Rectangle(p1.X(), p1.Y(), p2.X(), p2.Y(), color); } void Rectangle(const Point & p, const Size & s, int color) { Rectangle(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H(), color); } void FilledRectangle(int x1, int y1, int x2, int y2, int color) { gdImageFilledRectangle(im, x1, y1, x2, y2, color); } void FilledRectangle(const Point & p1, const Point & p2, int color) { FilledRectangle(p1.X(), p1.Y(), p2.X(), p2.Y(), color); } void FilledRectangle(const Point & p, const Size & s, int color) { FilledRectangle(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H(), color); } void SetClip(int x1, int y1, int x2, int y2) { gdImageSetClip(im, x1, y1, x2, y2); } void SetClip(const Point & p1, const Point & p2) { SetClip(p1.X(), p1.Y(), p2.X(), p2.Y()); } void SetClip(const Point & p, const Size & s) { SetClip(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H()); } void GetClip(int & x1, int & y1, int & x2, int & y2) const { gdImageGetClip(im, & x1, & y1, & x2, & y2); } void GetClip(Point & p1, Point & p2) const { GetClip(p1.lhsX(), p1.lhsY(), p2.lhsX(), p2.lhsY()); } void GetClip(Point & p, Size & s) const { Point p2; GetClip(p.lhsX(), p.lhsY(), p2.lhsX(), p2.lhsY()); s.set(p2.X() - p.X(), p2.Y() - p.Y()); } bool BoundsSafe(int x, int y) const { return (gdImageBoundsSafe(im, x, y)?true:false); } bool BoundsSafe(const Point & p) const { return BoundsSafe(p.X(), p.Y()); } void Char(gdFontPtr f, int x, int y, int c, int color) { gdImageChar(im, f, x, y, c, color); } void CharUp(gdFontPtr f, int x, int y, int c, int color) { gdImageCharUp(im, f, x, y, c, color); } void Char(gdFontPtr f, const Point & p, int c, int color) { Char(f, p.X(), p.Y(), c, color); } void CharUp(gdFontPtr f, const Point & p, int c, int color) { CharUp(f, p.X(), p.Y(), c, color); } void String(gdFontPtr f, int x, int y, unsigned char * s, int color) { gdImageString(im, f, x, y, (unsigned char *)s, color); } void StringUp(gdFontPtr f, int x, int y, unsigned char * s, int color) { gdImageStringUp(im, f, x, y, (unsigned char *)s, color); } void String(gdFontPtr f, int x, int y, unsigned short * s, int color) { gdImageString16(im, f, x, y, (unsigned short *)s, color); } void StringUp(gdFontPtr f, int x, int y, unsigned short * s, int color) { gdImageStringUp16(im, f, x, y, (unsigned short *)s, color); } void String(gdFontPtr f, int x, int y, char * s, int color) { gdImageString(im, f, x, y, (unsigned char *)s, color); } void StringUp(gdFontPtr f, int x, int y, char * s, int color) { gdImageStringUp(im, f, x, y, (unsigned char *)s, color); } void String(gdFontPtr f, int x, int y, const std::string & s, int color) { String(f, x, y, (char *)s.c_str(), color); } void StringUp(gdFontPtr f, int x, int y, const std::string & s, int color) { StringUp(f, x, y, (char *)s.c_str(), color); } void String(gdFontPtr f, const Point & p, unsigned char * s, int color) { String(f, p.X(), p.Y(), (unsigned char *)s, color); } void StringUp(gdFontPtr f, const Point & p, unsigned char * s, int color) { StringUp(f, p.X(), p.Y(), (unsigned char *)s, color); } void String(gdFontPtr f, const Point & p, unsigned short * s, int color) { String(f, p.X(), p.Y(), (unsigned short *)s, color); } void StringUp(gdFontPtr f, const Point & p, unsigned short * s, int color) { StringUp(f, p.X(), p.Y(), (unsigned short *)s, color); } void String(gdFontPtr f, const Point & p, char * s, int color) { String(f, p.X(), p.Y(), (unsigned char *)s, color); } void StringUp(gdFontPtr f, const Point & p, char * s, int color) { StringUp(f, p.X(), p.Y(), (unsigned char *)s, color); } void String(gdFontPtr f, const Point & p, const std::string & s, int color) { String(f, p, (char *)s.c_str(), color); } void StringUp(gdFontPtr f, const Point & p, const std::string & s, int color) { StringUp(f, p, (char *)s.c_str(), color); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, int x, int y, char * string) { return gdImageStringFT(im, brect, fg, fontlist, ptsize, angle, x, y, string); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, int x, int y, char * string, gdFTStringExtraPtr strex) { return gdImageStringFTEx(im, brect, fg, fontlist, ptsize, angle, x, y, string, strex); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, int x, int y, const std::string & string) { return StringFT(brect, fg, fontlist, ptsize, angle, x, y, (char *)string.c_str()); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, int x, int y, const std::string & string, gdFTStringExtraPtr strex) { return StringFT(brect, fg, fontlist, ptsize, angle, x, y, (char *)string.c_str(), strex); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, const Point & p, char * string) { return StringFT(brect, fg, fontlist, ptsize, angle, p.X(), p.Y(), string); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, const Point & p, char * string, gdFTStringExtraPtr strex) { return StringFT(brect, fg, fontlist, ptsize, angle, p.X(), p.Y(), string, strex); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, const Point & p, const std::string & string) { return StringFT(brect, fg, fontlist, ptsize, angle, p, (char *)string.c_str()); } char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle, const Point & p, const std::string & string, gdFTStringExtraPtr strex) { return StringFT(brect, fg, fontlist, ptsize, angle, p, (char *)string.c_str(), strex); } void Polygon(gdPointPtr p, int n, int c) { gdImagePolygon(im, p, n, c); } void OpenPolygon(gdPointPtr p, int n, int c) { gdImageOpenPolygon(im, p, n, c); } void FilledPolygon(gdPointPtr p, int n, int c) { gdImageFilledPolygon(im, p, n, c); } void Polygon(PointPtr p, int n, int c) { Polygon(p->as_gdPointPtr(), n, c); } void OpenPolygon(PointPtr p, int n, int c) { OpenPolygon(p->as_gdPointPtr(), n, c); } void FilledPolygon(PointPtr p, int n, int c) { FilledPolygon(p->as_gdPointPtr(), n, c); } int ColorAllocate(int r, int g, int b) { return gdImageColorAllocate(im, r, g, b); } int ColorAllocate(int r, int g, int b, int a) { return gdImageColorAllocateAlpha(im, r, g, b, a); } int ColorClosest(int r, int g, int b) const { return gdImageColorClosest(im, r, g, b); } int ColorClosest(int r, int g, int b, int a) const { return gdImageColorClosestAlpha(im, r, g, b, a); } int ColorClosestHWB(int r, int g, int b) const { return gdImageColorClosestHWB(im, r, g, b); } int ColorExact(int r, int g, int b) const { return gdImageColorExact(im, r, g, b); } int ColorExact(int r, int g, int b, int a) const { return gdImageColorExactAlpha(im, r, g, b, a); } int ColorResolve(int r, int g, int b) { return gdImageColorResolve(im, r, g, b); } int ColorResolve(int r, int g, int b, int a) { return gdImageColorResolveAlpha(im, r, g, b, a); } void ColorDeallocate(int color) { gdImageColorDeallocate(im, color); } void TrueColorToPalette(int ditherFlag, int colorsWanted) { gdImageTrueColorToPalette(im, ditherFlag, colorsWanted); } void ColorTransparent(int color) { gdImageColorTransparent(im, color); } void PaletteCopy(gdImagePtr src) { gdImagePaletteCopy(im, src); } void PaletteCopy(const GD::Image & src) { PaletteCopy(src.im); } /** Write out this image in GIF file format to \p out. \param out A FILE * handle */ void Gif(FILE * out) const { gdImageGif(im, out); } /** Write out this image in GIF file format to \p out. \param out A gdIOCtx * handle */ void Gif(gdIOCtx * out) const { gdImageGifCtx(im, out); } /** Allocate sufficient memory, and write this image, in GIF file format, to that memory. \param size A pointer for the allocated memory \return A pointer to the allocated memory, containing the image GIF file formatted. Caller is responsible for freeing with gdFree(). */ void * Gif(int * size) const { return gdImageGifPtr(im, size); } /** Write out this image in GIF file format to \p out. \param out An output stream, already opened. */ void Gif(std::ostream & out) const { ostreamIOCtx _out_ctx(out); gdImageGifCtx(im, & _out_ctx); } /** Write out this image in PNG file format to \p out. \param out A FILE * handle */ void Png(FILE * out) const { gdImagePng(im, out); } /** Write out this image in PNG file format to \p out. \param out A gdIOCtx * handle */ void Png(gdIOCtx * out) const { gdImagePngCtx(im, out); } /** Allocate sufficient memory, and write this image, in PNG file format, to that memory. \param size A pointer for the allocated memory \return A pointer to the allocated memory, containing the image PNG file formatted. Caller is responsible for freeing with gdFree(). */ void * Png(int * size) const { return gdImagePngPtr(im, size); } /** Write out this image in PNG file format to \p out. \param out An output stream, already opened. */ void Png(std::ostream & out) const { ostreamIOCtx _out_ctx(out); gdImagePngCtx(im, & _out_ctx); } /** Write out this image in PNG file format to \p out. \param out A FILE * handle \param level The level of compression: 0 == "no compression", 1 == "compressed as quickly as possible" --> 9 == "compressed as much as possible", -1 == zlib default compression level */ void Png(FILE * out, int level) const { gdImagePngEx(im, out, level); } /** Write out this image in PNG file format to \p out. \param out A gdIOCtx * handle \param level The level of compression: 0 == "no compression", 1 == "compressed as quickly as possible" --> 9 == "compressed as much as possible", -1 == zlib default compression level */ void Png(gdIOCtx * out, int level) const { gdImagePngCtxEx(im, out, level); } /** Allocate sufficient memory, and write this image, in PNG file format, to that memory. \param size A pointer for the allocated memory \param level The level of compression: 0 == "no compression", 1 == "compressed as quickly as possible" --> 9 == "compressed as much as possible", -1 == zlib default compression level \return A pointer to the allocated memory, containing the image PNG file formatted. Caller is responsible for freeing with gdFree(). */ void * Png(int * size, int level) const { return gdImagePngPtrEx(im, size, level); } /** Write out this image in PNG file format to \p out. \param out An output stream, already opened. \param level The level of compression: 0 == "no compression", 1 == "compressed as quickly as possible" --> 9 == "compressed as much as possible", -1 == zlib default compression level */ void Png(std::ostream & out, int level) const { ostreamIOCtx _out_ctx(out); gdImagePngCtxEx(im, & _out_ctx, level); } /** Write out this image in WBMP file format ( black and white only ) to \p out. \param fg The color index of the foreground. All other pixels considered background. \param out A FILE * handle */ void WBMP(int fg, FILE * out) const { gdImageWBMP(im, fg, out); } /** Write out this image in WBMP file format ( black and white only ) to \p out. \param fg The color index of the foreground. All other pixels considered background. \param out A gdIOCtx * handle */ void WBMP(int fg, gdIOCtx * out) const { gdImageWBMPCtx(im, fg, out); } /** Allocate sufficient memory, and write this image, in WBMP file format ( black and white only ), to that memory. \param size A pointer for the allocated memory \param fg The color index of the foreground. All other pixels considered background. \return A pointer to the allocated memory, containing the image WBMP file formatted. Caller is responsible for freeing with gdFree(). */ void * WBMP(int * size, int fg) const { return gdImageWBMPPtr(im, size, fg); } /** Write out this image in WBMP file format ( black and white only ) to \p out. \param fg The color index of the foreground. All other pixels considered background. \param out An output stream, already opened. */ void WBMP(int fg, std::ostream & out) const { ostreamIOCtx _out_ctx(out); gdImageWBMPCtx(im, fg, & _out_ctx); } /** Write out this image in JPEG file format to \p out. \param out A FILE * handle \param quality Should be a value in the range 0-95, higher numbers imply both higher quality and larger image size. Default value is -1, indicating "use a sensible default value". */ void Jpeg(FILE * out, int quality = -1) const { gdImageJpeg(im, out, quality); } /** Write out this image in JPEG file format to \p out. \param out A gdIOCtx * handle \param quality Should be a value in the range 0-95, higher numbers imply both higher quality and larger image size. Default value is -1, indicating "use a sensible default value". */ void Jpeg(gdIOCtx * out, int quality = -1) const { gdImageJpegCtx(im, out, quality); } /** Allocate sufficient memory, and write this image, in JPEG file format, to that memory. \param size A pointer for the allocated memory \param quality Should be a value in the range 0-95, higher numbers imply both higher quality and larger image size. Default value is -1, indicating "use a sensible default value". \return A pointer to the allocated memory, containing the image JPEG file formatted. Caller is responsible for freeing with gdFree(). */ void * Jpeg(int * size, int quality = -1) const { return gdImageJpegPtr(im, size, quality); } /** Write out this image in JPEG file format to \p out. \param out An output stream, already opened. \param quality Should be a value in the range 0-95, higher numbers imply both higher quality and larger image size. Default value is -1, indicating "use a sensible default value". */ void Jpeg(std::ostream & out, int quality = -1) const { ostreamIOCtx _out_ctx(out); gdImageJpegCtx(im, & _out_ctx, quality); } void GifAnimBegin(FILE * out, int GlobalCM, int Loops) const { gdImageGifAnimBegin(im, out, GlobalCM, Loops); } void GifAnimAdd(FILE * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const { gdImageGifAnimAdd(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); } void GifAnimAdd(FILE * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, const GD::Image & previm) const { GifAnimAdd(out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm.im); } inline static void GifAnimEnd(FILE * out) { gdImageGifAnimEnd(out); } void GifAnimBegin(gdIOCtx * out, int GlobalCM, int Loops) const { gdImageGifAnimBeginCtx(im, out, GlobalCM, Loops); } void GifAnimAdd(gdIOCtx * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const { gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); } void GifAnimAdd(gdIOCtx * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, const GD::Image & previm) const { GifAnimAdd(out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm.im); } inline static void GifAnimEnd(gdIOCtx * out) { gdImageGifAnimEndCtx(out); } void * GifAnimBegin(int * size, int GlobalCM, int Loops) const { return gdImageGifAnimBeginPtr(im, size, GlobalCM, Loops); } void * GifAnimAdd(int * size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const { return gdImageGifAnimAddPtr(im, size, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm); } void * GifAnimAdd(int * size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, const GD::Image & previm) const { return GifAnimAdd(size, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm.im); } inline static void * GifAnimEnd(int * size) { return gdImageGifAnimEndPtr(size); } void Gd(FILE * out) const { gdImageGd(im, out); } void* Gd(int * size) const { return gdImageGdPtr(im, size); } void Gd2(FILE * out, int cs, int fmt) const { gdImageGd2(im, out, cs, fmt); } void* Gd2(int cs, int fmt, int * size) const { return gdImageGd2Ptr(im, cs, fmt, size); } void Ellipse(int cx, int cy, int w, int h, int color) { gdImageEllipse(im, cx, cy, w, h, color); } /** Draw a partial ellipse centered at the given point, with the specified width and height in pixels. */ void FilledArc(int cx, int cy, int w, int h, int s, int e, int color, int style) { gdImageFilledArc(im, cx, cy, w, h, s, e, color, style); } void Arc(int cx, int cy, int w, int h, int s, int e, int color) { gdImageArc(im, cx, cy, w, h, s, e, color); } void FilledEllipse(int cx, int cy, int w, int h, int color) { gdImageFilledEllipse(im, cx, cy, w, h, color); } void FillToBorder(int x, int y, int border, int color) { gdImageFillToBorder(im, x, y, border, color); } void Fill(int x, int y, int color) { gdImageFill(im, x, y, color); } void Ellipse(const Point & c, const Size & s, int color) { Ellipse(c.X(), c.Y(), s.W(), s.H(), color); } void FilledArc(const Point & c, const Size & si, int s, int e, int color, int style) { FilledArc(c.X(), c.Y(), si.W(), si.H(), s, e, color, style); } void Arc(const Point & c, const Size & si, int s, int e, int color) { Arc(c.X(), c.Y(), si.W(), si.H(), s, e, color); } void FilledEllipse(const Point & c, const Size & s, int color) { FilledEllipse(c.X(), c.Y(), s.W(), s.H(), color); } void FillToBorder(const Point & p, int border, int color) { FillToBorder(p.X(), p.Y(), border, color); } void Fill(const Point & p, int color) { Fill(p.X(), p.Y(), color); } void Copy(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h) { gdImageCopy(im, src, dstX, dstY, srcX, srcY, w, h); } void CopyMerge(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) { gdImageCopyMerge(im, src, dstX, dstY, srcX, srcY, w, h, pct); } void CopyMergeGray(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) { gdImageCopyMergeGray(im, src, dstX, dstY, srcX, srcY, w, h, pct); } void CopyResized(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) { gdImageCopyResized(im, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); } void CopyResampled(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) { gdImageCopyResampled(im, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); } void CopyRotated(const gdImagePtr src, double dstX, double dstY, int srcX, int srcY, int srcWidth, int srcHeight, int angle) { gdImageCopyRotated(im, src, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle); } Image * CopyGaussianBlurred(int radius, double sigma) { return new Image(gdImageCopyGaussianBlurred(im, radius, sigma)); } void Copy(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s) { Copy(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H()); } void CopyMerge(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s, int pct) { CopyMerge(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct); } void CopyMergeGray(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s, int pct) { CopyMergeGray(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct); } void CopyResized(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) { CopyResized(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); } void CopyResampled(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) { CopyResampled(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); } void CopyRotated(const gdImagePtr src, double dstX, double dstY, const Point & srcP, const Size & srcS, int angle) { CopyRotated(src, dstX, dstY, srcP.X(), srcP.Y(), srcS.W(), srcS.H(), angle); } void Copy(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int w, int h) { Copy(src.im, dstX, dstY, srcX, srcY, w, h); } void CopyMerge(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) { CopyMerge(src.im, dstX, dstY, srcX, srcY, w, h, pct); } void CopyMergeGray(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) { CopyMergeGray(src.im, dstX, dstY, srcX, srcY, w, h, pct); } void CopyResized(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) { CopyResized(src.im, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); } void CopyResampled(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) { CopyResampled(src.im, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH); } void CopyRotated(const GD::Image & src, double dstX, double dstY, int srcX, int srcY, int srcWidth, int srcHeight, int angle) { CopyRotated(src.im, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle); } void Copy(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & s) { Copy(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H()); } void CopyMerge(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & s, int pct) { CopyMerge(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct); } void CopyMergeGray(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & s, int pct) { CopyMergeGray(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct); } void CopyResized(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) { CopyResized(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); } void CopyResampled(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) { CopyResampled(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H()); } void CopyRotated(const GD::Image & src, double dstX, double dstY, const Point & srcP, const Size & srcS, int angle) { CopyRotated(src.im, dstX, dstY, srcP.X(), srcP.Y(), srcS.W(), srcS.H(), angle); } Image * Clone() { return new Image(gdImageClone(im)); } void SetBrush(gdImagePtr brush) { gdImageSetBrush(im, brush); } void SetBrush(const GD::Image & brush) { SetBrush(brush.im); } void SetTile(gdImagePtr tile) { gdImageSetTile(im, tile); } void SetTile(const GD::Image & tile) { SetTile(tile.im); } void SetAntiAliased(int c) { gdImageSetAntiAliased(im, c); } void SetAntiAliasedDontBlend(int c, int dont_blend) { gdImageSetAntiAliasedDontBlend(im, c, dont_blend); } void SetStyle(int * style, int noOfPixels) { gdImageSetStyle(im, style, noOfPixels); } void SetThickness(int thickness) { gdImageSetThickness(im, thickness); } void SetResolution(int res_x, int res_y) { gdImageSetResolution(im, res_x, res_y); } void SetInterpolationMethod(gdInterpolationMethod interpolation_method) { gdImageSetInterpolationMethod(im, interpolation_method); } Image * RotateInterpolated(const float angle, int bgcolor) { return new Image(gdImageRotateInterpolated(im, angle, bgcolor)); } void Interlace(bool interlaceArg) { gdImageInterlace(im, interlaceArg?1:0); } void AlphaBlending(bool alphaBlendingArg) { gdImageAlphaBlending(im, alphaBlendingArg?1:0); } void SaveAlpha(bool saveAlphaArg) { gdImageSaveAlpha(im, saveAlphaArg?1:0); } int ColorReplace(int src, int dst) { return gdImageColorReplace(im, src, dst); } int ColorReplaceArray(int len, int * src, int * dst) { return gdImageColorReplaceArray(im, len, src, dst); } int ColorReplaceCallback(gdCallbackImageColor callback) { return gdImageColorReplaceCallback(im, callback); } int ColorReplaceThreshold(int src, int dst, float threshold) { return gdImageColorReplaceThreshold(im, src, dst, threshold); } bool Pixelate(int block_size, gdPixelateMode mode) { return gdImagePixelate(im, block_size, mode) == 0 ? false : true; } Image * Scale(int new_width, int new_height) { return new Image(gdImageScale(im, new_width, new_height)); } bool IsTrueColor() const { return (gdImageTrueColor(im)?true:false); } int SX() const { return gdImageSX(im); } int SY() const { return gdImageSY(im); } int Width() const { return SX(); } int Height() const { return SY(); } int ResX() const { return gdImageResolutionX(im); } int ResY() const { return gdImageResolutionY(im); } void GetSize(Size & s) const { s.set(SX(), SY()); } int ColorsTotal() const { return gdImageColorsTotal(im); } int Red(int color) const { return gdImageRed(im, color); } int Green(int color) const { return gdImageGreen(im, color); } int Blue(int color) const { return gdImageBlue(im, color); } int Alpha(int color) const { return gdImageAlpha(im, color); } int GetTransparent() const { return gdImageGetTransparent(im); } int GetInterlaced() const { return gdImageGetInterlaced(im); } int PalettePixel(int x, int y) const { return gdImagePalettePixel(im, x, y); } int TrueColorPixel(int x, int y) const { return gdImageTrueColorPixel(im, x, y); } const gdImagePtr GetPtr() const { return im; } protected: /// Free the internal image pointer void clear() { if (im) gdImageDestroy(im); im = 0; } gdImagePtr im; }; } // namespace GD /// Read in an image from a standard library input stream std::istream & operator>> (std::istream & in, GD::Image & img); #endif /* __cplusplus */ #endif /* _gdpp_h */ /* Declarations for math functions. Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* * ISO C99 Standard: 7.12 Mathematics <math.h> */ #ifndef _MATH_H #define _MATH_H 1 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION #include <bits/libc-header-start.h> #if defined log && defined __GNUC__ # warning A macro called log was already defined when <math.h> was included. # warning This will cause compilation problems. #endif __BEGIN_DECLS /* Get definitions of __intmax_t and __uintmax_t. */ #include <bits/types.h> /* Get machine-dependent vector math functions declarations. */ #include <bits/math-vector.h> /* Gather machine dependent type support. */ #include <bits/floatn.h> /* Value returned on overflow. With IEEE 754 floating point, this is +Infinity, otherwise the largest representable positive value. */ #if __GNUC_PREREQ (3, 3) # define HUGE_VAL (__builtin_huge_val ()) #else /* This may provoke compiler warnings, and may not be rounded to +Infinity in all IEEE 754 rounding modes, but is the best that can be done in ISO C while remaining a constant expression. 10,000 is greater than the maximum (decimal) exponent for all supported floating-point formats and widths. */ # define HUGE_VAL 1e10000 #endif #ifdef __USE_ISOC99 # if __GNUC_PREREQ (3, 3) # define HUGE_VALF (__builtin_huge_valf ()) # define HUGE_VALL (__builtin_huge_vall ()) # else # define HUGE_VALF 1e10000f # define HUGE_VALL 1e10000L # endif #endif #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT) # define HUGE_VAL_F16 (__builtin_huge_valf16 ()) #endif #if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT) # define HUGE_VAL_F32 (__builtin_huge_valf32 ()) #endif #if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT) # define HUGE_VAL_F64 (__builtin_huge_valf64 ()) #endif #if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) # define HUGE_VAL_F128 (__builtin_huge_valf128 ()) #endif #if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT) # define HUGE_VAL_F32X (__builtin_huge_valf32x ()) #endif #if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT) # define HUGE_VAL_F64X (__builtin_huge_valf64x ()) #endif #if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT) # define HUGE_VAL_F128X (__builtin_huge_valf128x ()) #endif #ifdef __USE_ISOC99 /* IEEE positive infinity. */ # if __GNUC_PREREQ (3, 3) # define INFINITY (__builtin_inff ()) # else # define INFINITY HUGE_VALF # endif /* IEEE Not A Number. */ # if __GNUC_PREREQ (3, 3) # define NAN (__builtin_nanf ("")) # else /* This will raise an "invalid" exception outside static initializers, but is the best that can be done in ISO C while remaining a constant expression. */ # define NAN (0.0f / 0.0f) # endif #endif /* __USE_ISOC99 */ #if __GLIBC_USE (IEC_60559_BFP_EXT) /* Signaling NaN macros, if supported. */ # if __GNUC_PREREQ (3, 3) # define SNANF (__builtin_nansf ("")) # define SNAN (__builtin_nans ("")) # define SNANL (__builtin_nansl ("")) # endif #endif #if (__HAVE_FLOAT16 \ && __GLIBC_USE (IEC_60559_TYPES_EXT) \ && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) # define SNANF16 (__builtin_nansf16 ("")) #endif #if (__HAVE_FLOAT32 \ && __GLIBC_USE (IEC_60559_TYPES_EXT) \ && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) # define SNANF32 (__builtin_nansf32 ("")) #endif #if (__HAVE_FLOAT64 \ && __GLIBC_USE (IEC_60559_TYPES_EXT) \ && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) # define SNANF64 (__builtin_nansf64 ("")) #endif #if (__HAVE_FLOAT128 \ && __GLIBC_USE (IEC_60559_TYPES_EXT) \ && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) # define SNANF128 (__builtin_nansf128 ("")) #endif #if (__HAVE_FLOAT32X \ && __GLIBC_USE (IEC_60559_TYPES_EXT) \ && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) # define SNANF32X (__builtin_nansf32x ("")) #endif #if (__HAVE_FLOAT64X \ && __GLIBC_USE (IEC_60559_TYPES_EXT) \ && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) # define SNANF64X (__builtin_nansf64x ("")) #endif #if (__HAVE_FLOAT128X \ && __GLIBC_USE (IEC_60559_TYPES_EXT) \ && (defined __USE_GNU || !__GLIBC_USE (ISOC2X))) # define SNANF128X (__builtin_nansf128x ("")) #endif /* Get __GLIBC_FLT_EVAL_METHOD. */ #include <bits/flt-eval-method.h> #ifdef __USE_ISOC99 /* Define the following typedefs. float_t floating-point type at least as wide as `float' used to evaluate `float' expressions double_t floating-point type at least as wide as `double' used to evaluate `double' expressions */ # if __GLIBC_FLT_EVAL_METHOD == 0 || __GLIBC_FLT_EVAL_METHOD == 16 typedef float float_t; typedef double double_t; # elif __GLIBC_FLT_EVAL_METHOD == 1 typedef double float_t; typedef double double_t; # elif __GLIBC_FLT_EVAL_METHOD == 2 typedef long double float_t; typedef long double double_t; # elif __GLIBC_FLT_EVAL_METHOD == 32 typedef _Float32 float_t; typedef double double_t; # elif __GLIBC_FLT_EVAL_METHOD == 33 typedef _Float32x float_t; typedef _Float32x double_t; # elif __GLIBC_FLT_EVAL_METHOD == 64 typedef _Float64 float_t; typedef _Float64 double_t; # elif __GLIBC_FLT_EVAL_METHOD == 65 typedef _Float64x float_t; typedef _Float64x double_t; # elif __GLIBC_FLT_EVAL_METHOD == 128 typedef _Float128 float_t; typedef _Float128 double_t; # elif __GLIBC_FLT_EVAL_METHOD == 129 typedef _Float128x float_t; typedef _Float128x double_t; # else # error "Unknown __GLIBC_FLT_EVAL_METHOD" # endif #endif /* Define macros for the return values of ilogb and llogb, based on __FP_LOGB0_IS_MIN and __FP_LOGBNAN_IS_MIN. FP_ILOGB0 Expands to a value returned by `ilogb (0.0)'. FP_ILOGBNAN Expands to a value returned by `ilogb (NAN)'. FP_LLOGB0 Expands to a value returned by `llogb (0.0)'. FP_LLOGBNAN Expands to a value returned by `llogb (NAN)'. */ #include <bits/fp-logb.h> #ifdef __USE_ISOC99 # if __FP_LOGB0_IS_MIN # define FP_ILOGB0 (-2147483647 - 1) # else # define FP_ILOGB0 (-2147483647) # endif # if __FP_LOGBNAN_IS_MIN # define FP_ILOGBNAN (-2147483647 - 1) # else # define FP_ILOGBNAN 2147483647 # endif #endif #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) # if __WORDSIZE == 32 # define __FP_LONG_MAX 0x7fffffffL # else # define __FP_LONG_MAX 0x7fffffffffffffffL # endif # if __FP_LOGB0_IS_MIN # define FP_LLOGB0 (-__FP_LONG_MAX - 1) # else # define FP_LLOGB0 (-__FP_LONG_MAX) # endif # if __FP_LOGBNAN_IS_MIN # define FP_LLOGBNAN (-__FP_LONG_MAX - 1) # else # define FP_LLOGBNAN __FP_LONG_MAX # endif #endif /* Get the architecture specific values describing the floating-point evaluation. The following symbols will get defined: FP_FAST_FMA FP_FAST_FMAF FP_FAST_FMAL If defined it indicates that the `fma' function generally executes about as fast as a multiply and an add. This macro is defined only iff the `fma' function is implemented directly with a hardware multiply-add instructions. */ #include <bits/fp-fast.h> #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) /* Rounding direction macros for fromfp functions. */ enum { FP_INT_UPWARD = # define FP_INT_UPWARD 0 FP_INT_UPWARD, FP_INT_DOWNWARD = # define FP_INT_DOWNWARD 1 FP_INT_DOWNWARD, FP_INT_TOWARDZERO = # define FP_INT_TOWARDZERO 2 FP_INT_TOWARDZERO, FP_INT_TONEARESTFROMZERO = # define FP_INT_TONEARESTFROMZERO 3 FP_INT_TONEARESTFROMZERO, FP_INT_TONEAREST = # define FP_INT_TONEAREST 4 FP_INT_TONEAREST, }; #endif /* The file <bits/mathcalls.h> contains the prototypes for all the actual math functions. These macros are used for those prototypes, so we can easily declare each function as both `name' and `__name', and can declare the float versions `namef' and `__namef'. */ #define __SIMD_DECL(function) __CONCAT (__DECL_SIMD_, function) #define __MATHCALL_VEC(function, suffix, args) \ __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \ __MATHCALL (function, suffix, args) #define __MATHDECL_VEC(type, function,suffix, args) \ __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \ __MATHDECL(type, function,suffix, args) #define __MATHCALL(function,suffix, args) \ __MATHDECL (_Mdouble_,function,suffix, args) #define __MATHDECL(type, function,suffix, args) \ __MATHDECL_1(type, function,suffix, args); \ __MATHDECL_1(type, __CONCAT(__,function),suffix, args) #define __MATHCALLX(function,suffix, args, attrib) \ __MATHDECLX (_Mdouble_,function,suffix, args, attrib) #define __MATHDECLX(type, function,suffix, args, attrib) \ __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \ __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib) #define __MATHDECL_1_IMPL(type, function, suffix, args) \ extern type __MATH_PRECNAME(function,suffix) args __THROW #define __MATHDECL_1(type, function, suffix, args) \ __MATHDECL_1_IMPL(type, function, suffix, args) /* Ignore the alias by default. The alias is only useful with redirections. */ #define __MATHDECL_ALIAS(type, function, suffix, args, alias) \ __MATHDECL_1(type, function, suffix, args) #define __MATHREDIR(type, function, suffix, args, to) \ extern type __REDIRECT_NTH (__MATH_PRECNAME (function, suffix), args, to) #define _Mdouble_ double #define __MATH_PRECNAME(name,r) __CONCAT(name,r) #define __MATH_DECLARING_DOUBLE 1 #define __MATH_DECLARING_FLOATN 0 #include <bits/mathcalls-helper-functions.h> #include <bits/mathcalls.h> #undef _Mdouble_ #undef __MATH_PRECNAME #undef __MATH_DECLARING_DOUBLE #undef __MATH_DECLARING_FLOATN #ifdef __USE_ISOC99 /* Include the file of declarations again, this time using `float' instead of `double' and appending f to each function name. */ # define _Mdouble_ float # define __MATH_PRECNAME(name,r) name##f##r # define __MATH_DECLARING_DOUBLE 0 # define __MATH_DECLARING_FLOATN 0 # include <bits/mathcalls-helper-functions.h> # include <bits/mathcalls.h> # undef _Mdouble_ # undef __MATH_PRECNAME # undef __MATH_DECLARING_DOUBLE # undef __MATH_DECLARING_FLOATN # if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \ || defined __LDBL_COMPAT \ || defined _LIBC_TEST # ifdef __LDBL_COMPAT # ifdef __USE_ISOC99 extern float __nldbl_nexttowardf (float __x, long double __y) __THROW __attribute__ ((__const__)); # ifdef __REDIRECT_NTH extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y), __nldbl_nexttowardf) __attribute__ ((__const__)); extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y), nextafter) __attribute__ ((__const__)); extern long double __REDIRECT_NTH (nexttowardl, (long double __x, long double __y), nextafter) __attribute__ ((__const__)); # endif # endif # undef __MATHDECL_1 # define __MATHDECL_1(type, function,suffix, args) \ __MATHREDIR(type, function, suffix, args, __CONCAT(function,suffix)) # elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 # ifdef __REDIRECT_NTH # ifdef __USE_ISOC99 extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y), __nexttowardf_to_ieee128) __attribute__ ((__const__)); extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y), __nexttoward_to_ieee128) __attribute__ ((__const__)); #define __dremieee128 __remainderieee128 #define __gammaieee128 __lgammaieee128 # endif # endif # undef __MATHDECL_1 # undef __MATHDECL_ALIAS # define __REDIRTO(function, suffix) \ __ ## function ## ieee128 ## suffix # define __REDIRTO_ALT(function, suffix) \ __ ## function ## f128 ## suffix # define __MATHDECL_1(type, function, suffix, args) \ __MATHREDIR (type, function, suffix, args, __REDIRTO (function, suffix)) # define __MATHDECL_ALIAS(type, function, suffix, args, alias) \ __MATHREDIR (type, function, suffix, args, __REDIRTO_ALT (alias, suffix)) # endif /* Include the file of declarations again, this time using `long double' instead of `double' and appending l to each function name. */ # define _Mdouble_ long double # define __MATH_PRECNAME(name,r) name##l##r # define __MATH_DECLARING_DOUBLE 0 # define __MATH_DECLARING_FLOATN 0 # define __MATH_DECLARE_LDOUBLE 1 # include <bits/mathcalls-helper-functions.h> # include <bits/mathcalls.h> # undef _Mdouble_ # undef __MATH_PRECNAME # undef __MATH_DECLARING_DOUBLE # undef __MATH_DECLARING_FLOATN # if defined __LDBL_COMPAT \ || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 # undef __REDIRTO # undef __REDIRTO_ALT # undef __MATHDECL_1 # undef __MATHDECL_ALIAS # define __MATHDECL_1(type, function, suffix, args) \ __MATHDECL_1_IMPL(type, function, suffix, args) # define __MATHDECL_ALIAS(type, function, suffix, args, alias) \ __MATHDECL_1(type, function, suffix, args) # endif # endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */ #endif /* Use ISO C99. */ /* Include the file of declarations for _FloatN and _FloatNx types. */ #if __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC) # define _Mdouble_ _Float16 # define __MATH_PRECNAME(name,r) name##f16##r # define __MATH_DECLARING_DOUBLE 0 # define __MATH_DECLARING_FLOATN 1 # if __HAVE_DISTINCT_FLOAT16 # include <bits/mathcalls-helper-functions.h> # endif # if __GLIBC_USE (IEC_60559_TYPES_EXT) # include <bits/mathcalls.h> # endif # undef _Mdouble_ # undef __MATH_PRECNAME # undef __MATH_DECLARING_DOUBLE # undef __MATH_DECLARING_FLOATN #endif /* __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC). */ #if __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC) # define _Mdouble_ _Float32 # define __MATH_PRECNAME(name,r) name##f32##r # define __MATH_DECLARING_DOUBLE 0 # define __MATH_DECLARING_FLOATN 1 # if __HAVE_DISTINCT_FLOAT32 # include <bits/mathcalls-helper-functions.h> # endif # if __GLIBC_USE (IEC_60559_TYPES_EXT) # include <bits/mathcalls.h> # endif # undef _Mdouble_ # undef __MATH_PRECNAME # undef __MATH_DECLARING_DOUBLE # undef __MATH_DECLARING_FLOATN #endif /* __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC). */ #if __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC) # define _Mdouble_ _Float64 # define __MATH_PRECNAME(name,r) name##f64##r # define __MATH_DECLARING_DOUBLE 0 # define __MATH_DECLARING_FLOATN 1 # if __HAVE_DISTINCT_FLOAT64 # include <bits/mathcalls-helper-functions.h> # endif # if __GLIBC_USE (IEC_60559_TYPES_EXT) # include <bits/mathcalls.h> # endif # undef _Mdouble_ # undef __MATH_PRECNAME # undef __MATH_DECLARING_DOUBLE # undef __MATH_DECLARING_FLOATN #endif /* __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC). */ #if __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC) # define _Mdouble_ _Float128 # define __MATH_PRECNAME(name,r) name##f128##r # define __MATH_DECLARING_DOUBLE 0 # define __MATH_DECLARING_FLOATN 1 # if __HAVE_DISTINCT_FLOAT128 # include <bits/mathcalls-helper-functions.h> # endif # if __GLIBC_USE (IEC_60559_TYPES_EXT) # include <bits/mathcalls.h> # endif # undef _Mdouble_ # undef __MATH_PRECNAME # undef __MATH_DECLARING_DOUBLE # undef __MATH_DECLARING_FLOATN #endif /* __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !_LIBC). */ #if __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC) # define _Mdouble_ _Float32x # define __MATH_PRECNAME(name,r) name##f32x##r # define __MATH_DECLARING_DOUBLE 0 # define __MATH_DECLARING_FLOATN 1 # if __HAVE_DISTINCT_FLOAT32X # include <bits/mathcalls-helper-functions.h> # endif # if __GLIBC_USE (IEC_60559_TYPES_EXT) # include <bits/mathcalls.h> # endif # undef _Mdouble_ # undef __MATH_PRECNAME # undef __MATH_DECLARING_DOUBLE # undef __MATH_DECLARING_FLOATN #endif /* __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC). */ #if __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC) # define _Mdouble_ _Float64x # define __MATH_PRECNAME(name,r) name##f64x##r # define __MATH_DECLARING_DOUBLE 0 # define __MATH_DECLARING_FLOATN 1 # if __HAVE_DISTINCT_FLOAT64X # include <bits/mathcalls-helper-functions.h> # endif # if __GLIBC_USE (IEC_60559_TYPES_EXT) # include <bits/mathcalls.h> # endif # undef _Mdouble_ # undef __MATH_PRECNAME # undef __MATH_DECLARING_DOUBLE # undef __MATH_DECLARING_FLOATN #endif /* __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC). */ #if __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC) # define _Mdouble_ _Float128x # define __MATH_PRECNAME(name,r) name##f128x##r # define __MATH_DECLARING_DOUBLE 0 # define __MATH_DECLARING_FLOATN 1 # if __HAVE_DISTINCT_FLOAT128X # include <bits/mathcalls-helper-functions.h> # endif # if __GLIBC_USE (IEC_60559_TYPES_EXT) # include <bits/mathcalls.h> # endif # undef _Mdouble_ # undef __MATH_PRECNAME # undef __MATH_DECLARING_DOUBLE # undef __MATH_DECLARING_FLOATN #endif /* __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC). */ #undef __MATHDECL_1_IMPL #undef __MATHDECL_1 #undef __MATHDECL_ALIAS #undef __MATHDECL #undef __MATHCALL /* Declare functions returning a narrower type. */ #define __MATHCALL_NARROW_ARGS_1 (_Marg_ __x) #define __MATHCALL_NARROW_ARGS_2 (_Marg_ __x, _Marg_ __y) #define __MATHCALL_NARROW_ARGS_3 (_Marg_ __x, _Marg_ __y, _Marg_ __z) #define __MATHCALL_NARROW_NORMAL(func, nargs) \ extern _Mret_ func __MATHCALL_NARROW_ARGS_ ## nargs __THROW #define __MATHCALL_NARROW_REDIR(func, redir, nargs) \ extern _Mret_ __REDIRECT_NTH (func, __MATHCALL_NARROW_ARGS_ ## nargs, \ redir) #define __MATHCALL_NARROW(func, redir, nargs) \ __MATHCALL_NARROW_NORMAL (func, nargs) #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) # define _Mret_ float # define _Marg_ double # define __MATHCALL_NAME(name) f ## name # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # define _Mret_ float # define _Marg_ long double # define __MATHCALL_NAME(name) f ## name ## l # ifdef __LDBL_COMPAT # define __MATHCALL_REDIR_NAME(name) f ## name # undef __MATHCALL_NARROW # define __MATHCALL_NARROW(func, redir, nargs) \ __MATHCALL_NARROW_REDIR (func, redir, nargs) # elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 # define __MATHCALL_REDIR_NAME(name) __ ## f32 ## name ## ieee128 # undef __MATHCALL_NARROW # define __MATHCALL_NARROW(func, redir, nargs) \ __MATHCALL_NARROW_REDIR (func, redir, nargs) # endif # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # if defined __LDBL_COMPAT \ || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 # undef __MATHCALL_REDIR_NAME # undef __MATHCALL_NARROW # define __MATHCALL_NARROW(func, redir, nargs) \ __MATHCALL_NARROW_NORMAL (func, nargs) # endif # define _Mret_ double # define _Marg_ long double # define __MATHCALL_NAME(name) d ## name ## l # ifdef __LDBL_COMPAT # define __MATHCALL_REDIR_NAME(name) __nldbl_d ## name ## l # undef __MATHCALL_NARROW # define __MATHCALL_NARROW(func, redir, nargs) \ __MATHCALL_NARROW_REDIR (func, redir, nargs) # elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 # define __MATHCALL_REDIR_NAME(name) __ ## f64 ## name ## ieee128 # undef __MATHCALL_NARROW # define __MATHCALL_NARROW(func, redir, nargs) \ __MATHCALL_NARROW_REDIR (func, redir, nargs) # endif # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # if defined __LDBL_COMPAT \ || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 # undef __MATHCALL_REDIR_NAME # undef __MATHCALL_NARROW # define __MATHCALL_NARROW(func, redir, nargs) \ __MATHCALL_NARROW_NORMAL (func, nargs) # endif #endif #if __GLIBC_USE (IEC_60559_TYPES_EXT) # if __HAVE_FLOAT16 && __HAVE_FLOAT32 # define _Mret_ _Float16 # define _Marg_ _Float32 # define __MATHCALL_NAME(name) f16 ## name ## f32 # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT16 && __HAVE_FLOAT32X # define _Mret_ _Float16 # define _Marg_ _Float32x # define __MATHCALL_NAME(name) f16 ## name ## f32x # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT16 && __HAVE_FLOAT64 # define _Mret_ _Float16 # define _Marg_ _Float64 # define __MATHCALL_NAME(name) f16 ## name ## f64 # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT16 && __HAVE_FLOAT64X # define _Mret_ _Float16 # define _Marg_ _Float64x # define __MATHCALL_NAME(name) f16 ## name ## f64x # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT16 && __HAVE_FLOAT128 # define _Mret_ _Float16 # define _Marg_ _Float128 # define __MATHCALL_NAME(name) f16 ## name ## f128 # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT16 && __HAVE_FLOAT128X # define _Mret_ _Float16 # define _Marg_ _Float128x # define __MATHCALL_NAME(name) f16 ## name ## f128x # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT32 && __HAVE_FLOAT32X # define _Mret_ _Float32 # define _Marg_ _Float32x # define __MATHCALL_NAME(name) f32 ## name ## f32x # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT32 && __HAVE_FLOAT64 # define _Mret_ _Float32 # define _Marg_ _Float64 # define __MATHCALL_NAME(name) f32 ## name ## f64 # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT32 && __HAVE_FLOAT64X # define _Mret_ _Float32 # define _Marg_ _Float64x # define __MATHCALL_NAME(name) f32 ## name ## f64x # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT32 && __HAVE_FLOAT128 # define _Mret_ _Float32 # define _Marg_ _Float128 # define __MATHCALL_NAME(name) f32 ## name ## f128 # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT32 && __HAVE_FLOAT128X # define _Mret_ _Float32 # define _Marg_ _Float128x # define __MATHCALL_NAME(name) f32 ## name ## f128x # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT32X && __HAVE_FLOAT64 # define _Mret_ _Float32x # define _Marg_ _Float64 # define __MATHCALL_NAME(name) f32x ## name ## f64 # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT32X && __HAVE_FLOAT64X # define _Mret_ _Float32x # define _Marg_ _Float64x # define __MATHCALL_NAME(name) f32x ## name ## f64x # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT32X && __HAVE_FLOAT128 # define _Mret_ _Float32x # define _Marg_ _Float128 # define __MATHCALL_NAME(name) f32x ## name ## f128 # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT32X && __HAVE_FLOAT128X # define _Mret_ _Float32x # define _Marg_ _Float128x # define __MATHCALL_NAME(name) f32x ## name ## f128x # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT64 && __HAVE_FLOAT64X # define _Mret_ _Float64 # define _Marg_ _Float64x # define __MATHCALL_NAME(name) f64 ## name ## f64x # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT64 && __HAVE_FLOAT128 # define _Mret_ _Float64 # define _Marg_ _Float128 # define __MATHCALL_NAME(name) f64 ## name ## f128 # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT64 && __HAVE_FLOAT128X # define _Mret_ _Float64 # define _Marg_ _Float128x # define __MATHCALL_NAME(name) f64 ## name ## f128x # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT64X && __HAVE_FLOAT128 # define _Mret_ _Float64x # define _Marg_ _Float128 # define __MATHCALL_NAME(name) f64x ## name ## f128 # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT64X && __HAVE_FLOAT128X # define _Mret_ _Float64x # define _Marg_ _Float128x # define __MATHCALL_NAME(name) f64x ## name ## f128x # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif # if __HAVE_FLOAT128 && __HAVE_FLOAT128X # define _Mret_ _Float128 # define _Marg_ _Float128x # define __MATHCALL_NAME(name) f128 ## name ## f128x # include <bits/mathcalls-narrow.h> # undef _Mret_ # undef _Marg_ # undef __MATHCALL_NAME # endif #endif #undef __MATHCALL_NARROW_ARGS_1 #undef __MATHCALL_NARROW_ARGS_2 #undef __MATHCALL_NARROW_ARGS_3 #undef __MATHCALL_NARROW_NORMAL #undef __MATHCALL_NARROW_REDIR #undef __MATHCALL_NARROW #if defined __USE_MISC || defined __USE_XOPEN /* This variable is used by `gamma' and `lgamma'. */ extern int signgam; #endif #if (__HAVE_DISTINCT_FLOAT16 \ || __HAVE_DISTINCT_FLOAT32 \ || __HAVE_DISTINCT_FLOAT64 \ || __HAVE_DISTINCT_FLOAT32X \ || __HAVE_DISTINCT_FLOAT64X \ || __HAVE_DISTINCT_FLOAT128X) # error "Unsupported _FloatN or _FloatNx types for <math.h>." #endif /* Depending on the type of TG_ARG, call an appropriately suffixed version of FUNC with arguments (including parentheses) ARGS. Suffixed functions may not exist for long double if it has the same format as double, or for other types with the same format as float, double or long double. The behavior is undefined if the argument does not have a real floating type. The definition may use a conditional expression, so all suffixed versions of FUNC must return the same type (FUNC may include a cast if necessary rather than being a single identifier). */ #ifdef __NO_LONG_DOUBLE_MATH # if __HAVE_DISTINCT_FLOAT128 # error "Distinct _Float128 without distinct long double not supported." # endif # define __MATH_TG(TG_ARG, FUNC, ARGS) \ (sizeof (TG_ARG) == sizeof (float) ? FUNC ## f ARGS : FUNC ARGS) #elif __HAVE_DISTINCT_FLOAT128 # if __HAVE_GENERIC_SELECTION # if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT32 # define __MATH_TG_F32(FUNC, ARGS) _Float32: FUNC ## f ARGS, # else # define __MATH_TG_F32(FUNC, ARGS) # endif # if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT64X # if __HAVE_FLOAT64X_LONG_DOUBLE # define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## l ARGS, # else # define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## f128 ARGS, # endif # else # define __MATH_TG_F64X(FUNC, ARGS) # endif # define __MATH_TG(TG_ARG, FUNC, ARGS) \ _Generic ((TG_ARG), \ float: FUNC ## f ARGS, \ __MATH_TG_F32 (FUNC, ARGS) \ default: FUNC ARGS, \ long double: FUNC ## l ARGS, \ __MATH_TG_F64X (FUNC, ARGS) \ _Float128: FUNC ## f128 ARGS) # else # if __HAVE_FLOATN_NOT_TYPEDEF # error "Non-typedef _FloatN but no _Generic." # endif # define __MATH_TG(TG_ARG, FUNC, ARGS) \ __builtin_choose_expr \ (__builtin_types_compatible_p (__typeof (TG_ARG), float), \ FUNC ## f ARGS, \ __builtin_choose_expr \ (__builtin_types_compatible_p (__typeof (TG_ARG), double), \ FUNC ARGS, \ __builtin_choose_expr \ (__builtin_types_compatible_p (__typeof (TG_ARG), long double), \ FUNC ## l ARGS, \ FUNC ## f128 ARGS))) # endif #else # define __MATH_TG(TG_ARG, FUNC, ARGS) \ (sizeof (TG_ARG) == sizeof (float) \ ? FUNC ## f ARGS \ : sizeof (TG_ARG) == sizeof (double) \ ? FUNC ARGS \ : FUNC ## l ARGS) #endif /* ISO C99 defines some generic macros which work on any data type. */ #ifdef __USE_ISOC99 /* All floating-point numbers can be put in one of these categories. */ enum { FP_NAN = # define FP_NAN 0 FP_NAN, FP_INFINITE = # define FP_INFINITE 1 FP_INFINITE, FP_ZERO = # define FP_ZERO 2 FP_ZERO, FP_SUBNORMAL = # define FP_SUBNORMAL 3 FP_SUBNORMAL, FP_NORMAL = # define FP_NORMAL 4 FP_NORMAL }; /* GCC bug 66462 means we cannot use the math builtins with -fsignaling-nan, so disable builtins if this is enabled. When fixed in a newer GCC, the __SUPPORT_SNAN__ check may be skipped for those versions. */ /* Return number of classification appropriate for X. */ # if ((__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ || __glibc_clang_prereq (2,8)) \ && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus) /* The check for __cplusplus allows the use of the builtin, even when optimization for size is on. This is provided for libstdc++, only to let its configure test work when it is built with -Os. No further use of this definition of fpclassify is expected in C++ mode, since libstdc++ provides its own version of fpclassify in cmath (which undefines fpclassify). */ # define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE, \ FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x) # else # define fpclassify(x) __MATH_TG ((x), __fpclassify, (x)) # endif /* Return nonzero value if sign of X is negative. */ # if __GNUC_PREREQ (6,0) || __glibc_clang_prereq (3,3) # define signbit(x) __builtin_signbit (x) # elif defined __cplusplus /* In C++ mode, __MATH_TG cannot be used, because it relies on __builtin_types_compatible_p, which is a C-only builtin. The check for __cplusplus allows the use of the builtin instead of __MATH_TG. This is provided for libstdc++, only to let its configure test work. No further use of this definition of signbit is expected in C++ mode, since libstdc++ provides its own version of signbit in cmath (which undefines signbit). */ # define signbit(x) __builtin_signbitl (x) # elif __GNUC_PREREQ (4,0) # define signbit(x) __MATH_TG ((x), __builtin_signbit, (x)) # else # define signbit(x) __MATH_TG ((x), __signbit, (x)) # endif /* Return nonzero value if X is not +-Inf or NaN. */ # if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ || __glibc_clang_prereq (2,8) # define isfinite(x) __builtin_isfinite (x) # else # define isfinite(x) __MATH_TG ((x), __finite, (x)) # endif /* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */ # if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ || __glibc_clang_prereq (2,8) # define isnormal(x) __builtin_isnormal (x) # else # define isnormal(x) (fpclassify (x) == FP_NORMAL) # endif /* Return nonzero value if X is a NaN. We could use `fpclassify' but we already have this functions `__isnan' and it is faster. */ # if (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ || __glibc_clang_prereq (2,8) # define isnan(x) __builtin_isnan (x) # else # define isnan(x) __MATH_TG ((x), __isnan, (x)) # endif /* Return nonzero value if X is positive or negative infinity. */ # if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \ && !defined __SUPPORT_SNAN__ && !defined __cplusplus /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0, use the helper function, __isinff128, with older compilers. This is only provided for C mode, because in C++ mode, GCC has no support for __builtin_types_compatible_p (and when in C++ mode, this macro is not used anyway, because libstdc++ headers undefine it). */ # define isinf(x) \ (__builtin_types_compatible_p (__typeof (x), _Float128) \ ? __isinff128 (x) : __builtin_isinf_sign (x)) # elif (__GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__) \ || __glibc_clang_prereq (3,7) # define isinf(x) __builtin_isinf_sign (x) # else # define isinf(x) __MATH_TG ((x), __isinf, (x)) # endif /* Bitmasks for the math_errhandling macro. */ # define MATH_ERRNO 1 /* errno set by math functions. */ # define MATH_ERREXCEPT 2 /* Exceptions raised by math functions. */ /* By default all math functions support both errno and exception handling (except for soft floating point implementations which may only support errno handling). If errno handling is disabled, exceptions are still supported by GLIBC. Set math_errhandling to 0 with -ffast-math (this is nonconforming but it is more useful than leaving it undefined). */ # ifdef __FAST_MATH__ # define math_errhandling 0 # elif defined __NO_MATH_ERRNO__ # define math_errhandling (MATH_ERREXCEPT) # else # define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT) # endif #endif /* Use ISO C99. */ #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) # include <bits/iscanonical.h> /* Return nonzero value if X is a signaling NaN. */ # ifndef __cplusplus # define issignaling(x) __MATH_TG ((x), __issignaling, (x)) # else /* In C++ mode, __MATH_TG cannot be used, because it relies on __builtin_types_compatible_p, which is a C-only builtin. On the other hand, overloading provides the means to distinguish between the floating-point types. The overloading resolution will match the correct parameter (regardless of type qualifiers (i.e.: const and volatile)). */ extern "C++" { inline int issignaling (float __val) { return __issignalingf (__val); } inline int issignaling (double __val) { return __issignaling (__val); } inline int issignaling (long double __val) { # ifdef __NO_LONG_DOUBLE_MATH return __issignaling (__val); # else return __issignalingl (__val); # endif } # if __HAVE_FLOAT128_UNLIKE_LDBL /* When using an IEEE 128-bit long double, _Float128 is defined as long double in C++. */ inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); } # endif } /* extern C++ */ # endif /* Return nonzero value if X is subnormal. */ # define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL) /* Return nonzero value if X is zero. */ # ifndef __cplusplus # ifdef __SUPPORT_SNAN__ # define iszero(x) (fpclassify (x) == FP_ZERO) # else # define iszero(x) (((__typeof (x)) (x)) == 0) # endif # else /* __cplusplus */ extern "C++" { # ifdef __SUPPORT_SNAN__ inline int iszero (float __val) { return __fpclassifyf (__val) == FP_ZERO; } inline int iszero (double __val) { return __fpclassify (__val) == FP_ZERO; } inline int iszero (long double __val) { # ifdef __NO_LONG_DOUBLE_MATH return __fpclassify (__val) == FP_ZERO; # else return __fpclassifyl (__val) == FP_ZERO; # endif } # if __HAVE_FLOAT128_UNLIKE_LDBL /* When using an IEEE 128-bit long double, _Float128 is defined as long double in C++. */ inline int iszero (_Float128 __val) { return __fpclassifyf128 (__val) == FP_ZERO; } # endif # else template <class __T> inline bool iszero (__T __val) { return __val == 0; } # endif } /* extern C++ */ # endif /* __cplusplus */ #endif /* Use IEC_60559_BFP_EXT. */ #ifdef __USE_XOPEN /* X/Open wants another strange constant. */ # define MAXFLOAT 3.40282347e+38F #endif /* Some useful constants. */ #if defined __USE_MISC || defined __USE_XOPEN # define M_E 2.7182818284590452354 /* e */ # define M_LOG2E 1.4426950408889634074 /* log_2 e */ # define M_LOG10E 0.43429448190325182765 /* log_10 e */ # define M_LN2 0.69314718055994530942 /* log_e 2 */ # define M_LN10 2.30258509299404568402 /* log_e 10 */ # define M_PI 3.14159265358979323846 /* pi */ # define M_PI_2 1.57079632679489661923 /* pi/2 */ # define M_PI_4 0.78539816339744830962 /* pi/4 */ # define M_1_PI 0.31830988618379067154 /* 1/pi */ # define M_2_PI 0.63661977236758134308 /* 2/pi */ # define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ # define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ # define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ #endif /* The above constants are not adequate for computation using `long double's. Therefore we provide as an extension constants with similar names as a GNU extension. Provide enough digits for the 128-bit IEEE quad. */ #ifdef __USE_GNU # define M_El 2.718281828459045235360287471352662498L /* e */ # define M_LOG2El 1.442695040888963407359924681001892137L /* log_2 e */ # define M_LOG10El 0.434294481903251827651128918916605082L /* log_10 e */ # define M_LN2l 0.693147180559945309417232121458176568L /* log_e 2 */ # define M_LN10l 2.302585092994045684017991454684364208L /* log_e 10 */ # define M_PIl 3.141592653589793238462643383279502884L /* pi */ # define M_PI_2l 1.570796326794896619231321691639751442L /* pi/2 */ # define M_PI_4l 0.785398163397448309615660845819875721L /* pi/4 */ # define M_1_PIl 0.318309886183790671537767526745028724L /* 1/pi */ # define M_2_PIl 0.636619772367581343075535053490057448L /* 2/pi */ # define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */ # define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */ # define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */ #endif #if __HAVE_FLOAT16 && defined __USE_GNU # define M_Ef16 __f16 (2.718281828459045235360287471352662498) /* e */ # define M_LOG2Ef16 __f16 (1.442695040888963407359924681001892137) /* log_2 e */ # define M_LOG10Ef16 __f16 (0.434294481903251827651128918916605082) /* log_10 e */ # define M_LN2f16 __f16 (0.693147180559945309417232121458176568) /* log_e 2 */ # define M_LN10f16 __f16 (2.302585092994045684017991454684364208) /* log_e 10 */ # define M_PIf16 __f16 (3.141592653589793238462643383279502884) /* pi */ # define M_PI_2f16 __f16 (1.570796326794896619231321691639751442) /* pi/2 */ # define M_PI_4f16 __f16 (0.785398163397448309615660845819875721) /* pi/4 */ # define M_1_PIf16 __f16 (0.318309886183790671537767526745028724) /* 1/pi */ # define M_2_PIf16 __f16 (0.636619772367581343075535053490057448) /* 2/pi */ # define M_2_SQRTPIf16 __f16 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ # define M_SQRT2f16 __f16 (1.414213562373095048801688724209698079) /* sqrt(2) */ # define M_SQRT1_2f16 __f16 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ #endif #if __HAVE_FLOAT32 && defined __USE_GNU # define M_Ef32 __f32 (2.718281828459045235360287471352662498) /* e */ # define M_LOG2Ef32 __f32 (1.442695040888963407359924681001892137) /* log_2 e */ # define M_LOG10Ef32 __f32 (0.434294481903251827651128918916605082) /* log_10 e */ # define M_LN2f32 __f32 (0.693147180559945309417232121458176568) /* log_e 2 */ # define M_LN10f32 __f32 (2.302585092994045684017991454684364208) /* log_e 10 */ # define M_PIf32 __f32 (3.141592653589793238462643383279502884) /* pi */ # define M_PI_2f32 __f32 (1.570796326794896619231321691639751442) /* pi/2 */ # define M_PI_4f32 __f32 (0.785398163397448309615660845819875721) /* pi/4 */ # define M_1_PIf32 __f32 (0.318309886183790671537767526745028724) /* 1/pi */ # define M_2_PIf32 __f32 (0.636619772367581343075535053490057448) /* 2/pi */ # define M_2_SQRTPIf32 __f32 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ # define M_SQRT2f32 __f32 (1.414213562373095048801688724209698079) /* sqrt(2) */ # define M_SQRT1_2f32 __f32 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ #endif #if __HAVE_FLOAT64 && defined __USE_GNU # define M_Ef64 __f64 (2.718281828459045235360287471352662498) /* e */ # define M_LOG2Ef64 __f64 (1.442695040888963407359924681001892137) /* log_2 e */ # define M_LOG10Ef64 __f64 (0.434294481903251827651128918916605082) /* log_10 e */ # define M_LN2f64 __f64 (0.693147180559945309417232121458176568) /* log_e 2 */ # define M_LN10f64 __f64 (2.302585092994045684017991454684364208) /* log_e 10 */ # define M_PIf64 __f64 (3.141592653589793238462643383279502884) /* pi */ # define M_PI_2f64 __f64 (1.570796326794896619231321691639751442) /* pi/2 */ # define M_PI_4f64 __f64 (0.785398163397448309615660845819875721) /* pi/4 */ # define M_1_PIf64 __f64 (0.318309886183790671537767526745028724) /* 1/pi */ # define M_2_PIf64 __f64 (0.636619772367581343075535053490057448) /* 2/pi */ # define M_2_SQRTPIf64 __f64 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ # define M_SQRT2f64 __f64 (1.414213562373095048801688724209698079) /* sqrt(2) */ # define M_SQRT1_2f64 __f64 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ #endif #if __HAVE_FLOAT128 && defined __USE_GNU # define M_Ef128 __f128 (2.718281828459045235360287471352662498) /* e */ # define M_LOG2Ef128 __f128 (1.442695040888963407359924681001892137) /* log_2 e */ # define M_LOG10Ef128 __f128 (0.434294481903251827651128918916605082) /* log_10 e */ # define M_LN2f128 __f128 (0.693147180559945309417232121458176568) /* log_e 2 */ # define M_LN10f128 __f128 (2.302585092994045684017991454684364208) /* log_e 10 */ # define M_PIf128 __f128 (3.141592653589793238462643383279502884) /* pi */ # define M_PI_2f128 __f128 (1.570796326794896619231321691639751442) /* pi/2 */ # define M_PI_4f128 __f128 (0.785398163397448309615660845819875721) /* pi/4 */ # define M_1_PIf128 __f128 (0.318309886183790671537767526745028724) /* 1/pi */ # define M_2_PIf128 __f128 (0.636619772367581343075535053490057448) /* 2/pi */ # define M_2_SQRTPIf128 __f128 (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ # define M_SQRT2f128 __f128 (1.414213562373095048801688724209698079) /* sqrt(2) */ # define M_SQRT1_2f128 __f128 (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ #endif #if __HAVE_FLOAT32X && defined __USE_GNU # define M_Ef32x __f32x (2.718281828459045235360287471352662498) /* e */ # define M_LOG2Ef32x __f32x (1.442695040888963407359924681001892137) /* log_2 e */ # define M_LOG10Ef32x __f32x (0.434294481903251827651128918916605082) /* log_10 e */ # define M_LN2f32x __f32x (0.693147180559945309417232121458176568) /* log_e 2 */ # define M_LN10f32x __f32x (2.302585092994045684017991454684364208) /* log_e 10 */ # define M_PIf32x __f32x (3.141592653589793238462643383279502884) /* pi */ # define M_PI_2f32x __f32x (1.570796326794896619231321691639751442) /* pi/2 */ # define M_PI_4f32x __f32x (0.785398163397448309615660845819875721) /* pi/4 */ # define M_1_PIf32x __f32x (0.318309886183790671537767526745028724) /* 1/pi */ # define M_2_PIf32x __f32x (0.636619772367581343075535053490057448) /* 2/pi */ # define M_2_SQRTPIf32x __f32x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ # define M_SQRT2f32x __f32x (1.414213562373095048801688724209698079) /* sqrt(2) */ # define M_SQRT1_2f32x __f32x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ #endif #if __HAVE_FLOAT64X && defined __USE_GNU # define M_Ef64x __f64x (2.718281828459045235360287471352662498) /* e */ # define M_LOG2Ef64x __f64x (1.442695040888963407359924681001892137) /* log_2 e */ # define M_LOG10Ef64x __f64x (0.434294481903251827651128918916605082) /* log_10 e */ # define M_LN2f64x __f64x (0.693147180559945309417232121458176568) /* log_e 2 */ # define M_LN10f64x __f64x (2.302585092994045684017991454684364208) /* log_e 10 */ # define M_PIf64x __f64x (3.141592653589793238462643383279502884) /* pi */ # define M_PI_2f64x __f64x (1.570796326794896619231321691639751442) /* pi/2 */ # define M_PI_4f64x __f64x (0.785398163397448309615660845819875721) /* pi/4 */ # define M_1_PIf64x __f64x (0.318309886183790671537767526745028724) /* 1/pi */ # define M_2_PIf64x __f64x (0.636619772367581343075535053490057448) /* 2/pi */ # define M_2_SQRTPIf64x __f64x (1.128379167095512573896158903121545172) /* 2/sqrt(pi) */ # define M_SQRT2f64x __f64x (1.414213562373095048801688724209698079) /* sqrt(2) */ # define M_SQRT1_2f64x __f64x (0.707106781186547524400844362104849039) /* 1/sqrt(2) */ #endif #if __HAVE_FLOAT128X && defined __USE_GNU # error "M_* values needed for _Float128x" #endif #ifdef __USE_ISOC99 # if __GNUC_PREREQ (3, 1) /* ISO C99 defines some macros to compare number while taking care for unordered numbers. Many FPUs provide special instructions to support these operations. Generic support in GCC for these as builtins went in 2.97, but not all cpus added their patterns until 3.1. Therefore we enable the builtins from 3.1 onwards and use a generic implementation othwerwise. */ # define isgreater(x, y) __builtin_isgreater(x, y) # define isgreaterequal(x, y) __builtin_isgreaterequal(x, y) # define isless(x, y) __builtin_isless(x, y) # define islessequal(x, y) __builtin_islessequal(x, y) # define islessgreater(x, y) __builtin_islessgreater(x, y) # define isunordered(x, y) __builtin_isunordered(x, y) # else # define isgreater(x, y) \ (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ !isunordered (__x, __y) && __x > __y; })) # define isgreaterequal(x, y) \ (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ !isunordered (__x, __y) && __x >= __y; })) # define isless(x, y) \ (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ !isunordered (__x, __y) && __x < __y; })) # define islessequal(x, y) \ (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ !isunordered (__x, __y) && __x <= __y; })) # define islessgreater(x, y) \ (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \ !isunordered (__x, __y) && __x != __y; })) /* isunordered must always check both operands first for signaling NaNs. */ # define isunordered(x, y) \ (__extension__ ({ __typeof__ (x) __u = (x); __typeof__ (y) __v = (y); \ __u != __v && (__u != __u || __v != __v); })) # endif #endif #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) /* An expression whose type has the widest of the evaluation formats of X and Y (which are of floating-point types). */ # if __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ > 64 # define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0L) # elif __FLT_EVAL_METHOD__ == 1 || __FLT_EVAL_METHOD__ > 32 # define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0) # elif __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 32 # define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0f) # else # define __MATH_EVAL_FMT2(x, y) ((x) + (y)) # endif /* Return X == Y but raising "invalid" and setting errno if X or Y is a NaN. */ # if !defined __cplusplus || (__cplusplus < 201103L && !defined __GNUC__) # define iseqsig(x, y) \ __MATH_TG (__MATH_EVAL_FMT2 (x, y), __iseqsig, ((x), (y))) # else /* In C++ mode, __MATH_TG cannot be used, because it relies on __builtin_types_compatible_p, which is a C-only builtin. Moreover, the comparison macros from ISO C take two floating-point arguments, which need not have the same type. Choosing what underlying function to call requires evaluating the formats of the arguments, then selecting which is wider. The macro __MATH_EVAL_FMT2 provides this information, however, only the type of the macro expansion is relevant (actually evaluating the expression would be incorrect). Thus, the type is used as a template parameter for __iseqsig_type, which calls the appropriate underlying function. */ extern "C++" { template<typename> struct __iseqsig_type; template<> struct __iseqsig_type<float> { static int __call (float __x, float __y) throw () { return __iseqsigf (__x, __y); } }; template<> struct __iseqsig_type<double> { static int __call (double __x, double __y) throw () { return __iseqsig (__x, __y); } }; template<> struct __iseqsig_type<long double> { static int __call (long double __x, long double __y) throw () { # ifndef __NO_LONG_DOUBLE_MATH return __iseqsigl (__x, __y); # else return __iseqsig (__x, __y); # endif } }; # if __HAVE_FLOAT128_UNLIKE_LDBL /* When using an IEEE 128-bit long double, _Float128 is defined as long double in C++. */ template<> struct __iseqsig_type<_Float128> { static int __call (_Float128 __x, _Float128 __y) throw () { return __iseqsigf128 (__x, __y); } }; # endif template<typename _T1, typename _T2> inline int iseqsig (_T1 __x, _T2 __y) throw () { # if __cplusplus >= 201103L typedef decltype (__MATH_EVAL_FMT2 (__x, __y)) _T3; # else typedef __typeof (__MATH_EVAL_FMT2 (__x, __y)) _T3; # endif return __iseqsig_type<_T3>::__call (__x, __y); } } /* extern "C++" */ # endif /* __cplusplus */ #endif __END_DECLS #endif /* math.h */ // * This makes emacs happy -*-Mode: C++;-*- /**************************************************************************** * Copyright 2019,2020 Thomas E. Dickey * * Copyright 1998-2012,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ // $Id: cursesm.h,v 1.34 2020/05/24 01:40:20 anonymous.maarten Exp $ #ifndef NCURSES_CURSESM_H_incl #define NCURSES_CURSESM_H_incl 1 #include <cursesp.h> extern "C" { # include <menu.h> } // // ------------------------------------------------------------------------- // This wraps the ITEM type of <menu.h> // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP NCursesMenuItem { friend class NCursesMenu; protected: ITEM *item; inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) { if (err != E_OK) THROW(new NCursesMenuException (err)); } public: NCursesMenuItem (const char* p_name = NULL, const char* p_descript = NULL) : item(0) { item = p_name ? ::new_item (p_name, p_descript) : STATIC_CAST(ITEM*)(0); if (p_name && !item) OnError (E_SYSTEM_ERROR); } // Create an item. If you pass both parameters as NULL, a delimiting // item is constructed which can be used to terminate a list of // NCursesMenu objects. NCursesMenuItem& operator=(const NCursesMenuItem& rhs) { if (this != &rhs) { *this = rhs; } return *this; } NCursesMenuItem(const NCursesMenuItem& rhs) : item(0) { (void) rhs; } virtual ~NCursesMenuItem () THROWS(NCursesException); // Release the items memory inline const char* name () const { return ::item_name (item); } // Name of the item inline const char* description () const { return ::item_description (item); } // Description of the item inline int (index) (void) const { return ::item_index (item); } // Index of the item in an item array (or -1) inline void options_on (Item_Options opts) { OnError (::item_opts_on (item, opts)); } // Switch on the items options inline void options_off (Item_Options opts) { OnError (::item_opts_off (item, opts)); } // Switch off the item's option inline Item_Options options () const { return ::item_opts (item); } // Retrieve the items options inline void set_options (Item_Options opts) { OnError (::set_item_opts (item, opts)); } // Set the items options inline void set_value (bool f) { OnError (::set_item_value (item,f)); } // Set/Reset the items selection state inline bool value () const { return ::item_value (item); } // Retrieve the items selection state inline bool visible () const { return ::item_visible (item); } // Retrieve visibility of the item virtual bool action(); // Perform an action associated with this item; you may use this in an // user supplied driver for a menu; you may derive from this class and // overload action() to supply items with different actions. // If an action returns true, the menu will be exited. The default action // is to do nothing. }; // Prototype for an items callback function. typedef bool ITEMCALLBACK(NCursesMenuItem&); // If you don't like to create a child class for individual items to // overload action(), you may use this class and provide a callback // function pointer for items. class NCURSES_CXX_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem { private: ITEMCALLBACK* p_fct; public: NCursesMenuCallbackItem(ITEMCALLBACK* fct = NULL, const char* p_name = NULL, const char* p_descript = NULL ) : NCursesMenuItem (p_name, p_descript), p_fct (fct) { } NCursesMenuCallbackItem& operator=(const NCursesMenuCallbackItem& rhs) { if (this != &rhs) { *this = rhs; } return *this; } NCursesMenuCallbackItem(const NCursesMenuCallbackItem& rhs) : NCursesMenuItem(rhs), p_fct(0) { } virtual ~NCursesMenuCallbackItem() THROWS(NCursesException); bool action(); }; // This are the built-in hook functions in this C++ binding. In C++ we use // virtual member functions (see below On_..._Init and On_..._Termination) // to provide this functionality in an object oriented manner. extern "C" { void _nc_xx_mnu_init(MENU *); void _nc_xx_mnu_term(MENU *); void _nc_xx_itm_init(MENU *); void _nc_xx_itm_term(MENU *); } // // ------------------------------------------------------------------------- // This wraps the MENU type of <menu.h> // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP NCursesMenu : public NCursesPanel { protected: MENU *menu; private: NCursesWindow* sub; // the subwindow object bool b_sub_owner; // is this our own subwindow? bool b_framed; // has the menu a border? bool b_autoDelete; // Delete items when deleting menu? NCursesMenuItem** my_items; // The array of items for this menu // This structure is used for the menu's user data field to link the // MENU* to the C++ object and to provide extra space for a user pointer. typedef struct { void* m_user; // the pointer for the user's data const NCursesMenu* m_back; // backward pointer to C++ object const MENU* m_owner; } UserHook; // Get the backward pointer to the C++ object from a MENU static inline NCursesMenu* getHook(const MENU *m) { UserHook* hook = STATIC_CAST(UserHook*)(::menu_userptr(m)); assert(hook != 0 && hook->m_owner==m); return const_cast<NCursesMenu*>(hook->m_back); } friend void _nc_xx_mnu_init(MENU *); friend void _nc_xx_mnu_term(MENU *); friend void _nc_xx_itm_init(MENU *); friend void _nc_xx_itm_term(MENU *); // Calculate ITEM* array for the menu ITEM** mapItems(NCursesMenuItem* nitems[]); protected: // internal routines inline void set_user(void *user) { UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu)); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu); uptr->m_user = user; } inline void *get_user() { UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu)); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu); return uptr->m_user; } void InitMenu (NCursesMenuItem* menu[], bool with_frame, bool autoDeleteItems); inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) { if (err != E_OK) THROW(new NCursesMenuException (this, err)); } // this wraps the menu_driver call. virtual int driver (int c) ; // 'Internal' constructor to create a menu without association to // an array of items. NCursesMenu( int nlines, int ncols, int begin_y = 0, int begin_x = 0) : NCursesPanel(nlines,ncols,begin_y,begin_x), menu (STATIC_CAST(MENU*)(0)), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_items(0) { } public: // Make a full window size menu NCursesMenu (NCursesMenuItem* Items[], bool with_frame=FALSE, // Reserve space for a frame? bool autoDelete_Items=FALSE) // Autocleanup of Items? : NCursesPanel(), menu(0), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_items(0) { InitMenu(Items, with_frame, autoDelete_Items); } // Make a menu with a window of this size. NCursesMenu (NCursesMenuItem* Items[], int nlines, int ncols, int begin_y = 0, int begin_x = 0, bool with_frame=FALSE, // Reserve space for a frame? bool autoDelete_Items=FALSE) // Autocleanup of Items? : NCursesPanel(nlines, ncols, begin_y, begin_x), menu(0), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_items(0) { InitMenu(Items, with_frame, autoDelete_Items); } NCursesMenu& operator=(const NCursesMenu& rhs) { if (this != &rhs) { *this = rhs; NCursesPanel::operator=(rhs); } return *this; } NCursesMenu(const NCursesMenu& rhs) : NCursesPanel(rhs), menu(rhs.menu), sub(rhs.sub), b_sub_owner(rhs.b_sub_owner), b_framed(rhs.b_framed), b_autoDelete(rhs.b_autoDelete), my_items(rhs.my_items) { } virtual ~NCursesMenu () THROWS(NCursesException); // Retrieve the menus subwindow inline NCursesWindow& subWindow() const { assert(sub!=NULL); return *sub; } // Set the menus subwindow void setSubWindow(NCursesWindow& sub); // Set these items for the menu inline void setItems(NCursesMenuItem* Items[]) { OnError(::set_menu_items(menu,mapItems(Items))); } // Remove the menu from the screen inline void unpost (void) { OnError (::unpost_menu (menu)); } // Post the menu to the screen if flag is true, unpost it otherwise inline void post(bool flag = TRUE) { flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu)); } // Get the number of rows and columns for this menu inline void scale (int& mrows, int& mcols) const { OnError (::scale_menu (menu, &mrows, &mcols)); } // Set the format of this menu inline void set_format(int mrows, int mcols) { OnError (::set_menu_format(menu, mrows, mcols)); } // Get the format of this menu inline void menu_format(int& rows,int& ncols) { ::menu_format(menu,&rows,&ncols); } // Items of the menu inline NCursesMenuItem* items() const { return *my_items; } // Get the number of items in this menu inline int count() const { return ::item_count(menu); } // Get the current item (i.e. the one the cursor is located) inline NCursesMenuItem* current_item() const { return my_items[::item_index(::current_item(menu))]; } // Get the marker string inline const char* mark() const { return ::menu_mark(menu); } // Set the marker string inline void set_mark(const char *marker) { OnError (::set_menu_mark (menu, marker)); } // Get the name of the request code c inline static const char* request_name(int c) { return ::menu_request_name(c); } // Get the current pattern inline char* pattern() const { return ::menu_pattern(menu); } // true if there is a pattern match, false otherwise. bool set_pattern (const char *pat); // set the default attributes for the menu // i.e. set fore, back and grey attribute virtual void setDefaultAttributes(); // Get the menus background attributes inline chtype back() const { return ::menu_back(menu); } // Get the menus foreground attributes inline chtype fore() const { return ::menu_fore(menu); } // Get the menus grey attributes (used for unselectable items) inline chtype grey() const { return ::menu_grey(menu); } // Set the menus background attributes inline chtype set_background(chtype a) { return ::set_menu_back(menu,a); } // Set the menus foreground attributes inline chtype set_foreground(chtype a) { return ::set_menu_fore(menu,a); } // Set the menus grey attributes (used for unselectable items) inline chtype set_grey(chtype a) { return ::set_menu_grey(menu,a); } inline void options_on (Menu_Options opts) { OnError (::menu_opts_on (menu,opts)); } inline void options_off(Menu_Options opts) { OnError (::menu_opts_off(menu,opts)); } inline Menu_Options options() const { return ::menu_opts(menu); } inline void set_options (Menu_Options opts) { OnError (::set_menu_opts (menu,opts)); } inline int pad() const { return ::menu_pad(menu); } inline void set_pad (int padch) { OnError (::set_menu_pad (menu, padch)); } // Position the cursor to the current item inline void position_cursor () const { OnError (::pos_menu_cursor (menu)); } // Set the current item inline void set_current(NCursesMenuItem& I) { OnError (::set_current_item(menu, I.item)); } // Get the current top row of the menu inline int top_row (void) const { return ::top_row (menu); } // Set the current top row of the menu inline void set_top_row (int row) { OnError (::set_top_row (menu, row)); } // spacing control // Set the spacing for the menu inline void setSpacing(int spc_description, int spc_rows, int spc_columns) { OnError(::set_menu_spacing(menu, spc_description, spc_rows, spc_columns)); } // Get the spacing info for the menu inline void Spacing(int& spc_description, int& spc_rows, int& spc_columns) const { OnError(::menu_spacing(menu, &spc_description, &spc_rows, &spc_columns)); } // Decorations inline void frame(const char *title=NULL, const char* btitle=NULL) { if (b_framed) NCursesPanel::frame(title,btitle); else OnError(E_SYSTEM_ERROR); } inline void boldframe(const char *title=NULL, const char* btitle=NULL) { if (b_framed) NCursesPanel::boldframe(title,btitle); else OnError(E_SYSTEM_ERROR); } inline void label(const char *topLabel, const char *bottomLabel) { if (b_framed) NCursesPanel::label(topLabel,bottomLabel); else OnError(E_SYSTEM_ERROR); } // ----- // Hooks // ----- // Called after the menu gets repositioned in its window. // This is especially true if the menu is posted. virtual void On_Menu_Init(); // Called before the menu gets repositioned in its window. // This is especially true if the menu is unposted. virtual void On_Menu_Termination(); // Called after the item became the current item virtual void On_Item_Init(NCursesMenuItem& item); // Called before this item is left as current item. virtual void On_Item_Termination(NCursesMenuItem& item); // Provide a default key virtualization. Translate the keyboard // code c into a menu request code. // The default implementation provides a hopefully straightforward // mapping for the most common keystrokes and menu requests. virtual int virtualize(int c); // Operators inline NCursesMenuItem* operator[](int i) const { if ( (i < 0) || (i >= ::item_count (menu)) ) OnError (E_BAD_ARGUMENT); return (my_items[i]); } // Perform the menu's operation // Return the item where you left the selection mark for a single // selection menu, or NULL for a multivalued menu. virtual NCursesMenuItem* operator()(void); // -------------------- // Exception handlers // Called by operator() // -------------------- // Called if the request is denied virtual void On_Request_Denied(int c) const; // Called if the item is not selectable virtual void On_Not_Selectable(int c) const; // Called if pattern doesn't match virtual void On_No_Match(int c) const; // Called if the command is unknown virtual void On_Unknown_Command(int c) const; }; // // ------------------------------------------------------------------------- // This is the typical C++ typesafe way to allow to attach // user data to an item of a menu. Its assumed that the user // data belongs to some class T. Use T as template argument // to create a UserItem. // ------------------------------------------------------------------------- // template<class T> class NCURSES_CXX_IMPEXP NCursesUserItem : public NCursesMenuItem { public: NCursesUserItem (const char* p_name, const char* p_descript = NULL, const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesMenuItem (p_name, p_descript) { if (item) OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void*>(p_UserData)))); } virtual ~NCursesUserItem() THROWS(NCursesException) {} inline const T* UserData (void) const { return reinterpret_cast<const T*>(::item_userptr (item)); }; inline virtual void setUserData(const T* p_UserData) { if (item) OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void *>(p_UserData)))); } }; // // ------------------------------------------------------------------------- // The same mechanism is used to attach user data to a menu // ------------------------------------------------------------------------- // template<class T> class NCURSES_CXX_IMPEXP NCursesUserMenu : public NCursesMenu { protected: NCursesUserMenu( int nlines, int ncols, int begin_y = 0, int begin_x = 0, const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesMenu(nlines,ncols,begin_y,begin_x) { if (menu) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); } public: NCursesUserMenu (NCursesMenuItem* Items[], const T* p_UserData = STATIC_CAST(T*)(0), bool with_frame=FALSE, bool autoDelete_Items=FALSE) : NCursesMenu (Items, with_frame, autoDelete_Items) { if (menu) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); }; NCursesUserMenu (NCursesMenuItem* Items[], int nlines, int ncols, int begin_y = 0, int begin_x = 0, const T* p_UserData = STATIC_CAST(T*)(0), bool with_frame=FALSE) : NCursesMenu (Items, nlines, ncols, begin_y, begin_x, with_frame) { if (menu) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); }; virtual ~NCursesUserMenu() THROWS(NCursesException) { }; inline T* UserData (void) { return reinterpret_cast<T*>(get_user ()); }; inline virtual void setUserData (const T* p_UserData) { if (menu) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); } }; #endif /* NCURSES_CURSESM_H_incl */ /**************************************************************************** * Copyright 2018,2020 Thomas E. Dickey * * Copyright 2006-2012,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Thomas E. Dickey 2006 * ****************************************************************************/ /* $Id: nc_tparm.h,v 1.11 2020/05/27 23:33:31 tom Exp $ */ #ifndef NC_TPARM_included #define NC_TPARM_included 1 #include <ncurses_cfg.h> #include <curses.h> /* * Cast parameters past the formatting-string for tparm() to match the * assumption of the varargs code. */ #ifndef TPARM_ARG #ifdef NCURSES_TPARM_ARG #define TPARM_ARG NCURSES_TPARM_ARG #else #define TPARM_ARG long #endif #endif /* TPARAM_ARG */ #define TPARM_N(n) (TPARM_ARG)(n) #define TPARM_9(a,b,c,d,e,f,g,h,i,j) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i),TPARM_N(j)) #if NCURSES_TPARM_VARARGS #define TPARM_8(a,b,c,d,e,f,g,h,i) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i)) #define TPARM_7(a,b,c,d,e,f,g,h) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h)) #define TPARM_6(a,b,c,d,e,f,g) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g)) #define TPARM_5(a,b,c,d,e,f) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f)) #define TPARM_4(a,b,c,d,e) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e)) #define TPARM_3(a,b,c,d) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d)) #define TPARM_2(a,b,c) tparm(a,TPARM_N(b),TPARM_N(c)) #define TPARM_1(a,b) tparm(a,TPARM_N(b)) #define TPARM_0(a) tparm(a) #else #define TPARM_8(a,b,c,d,e,f,g,h,i) TPARM_9(a,b,c,d,e,f,g,h,i,0) #define TPARM_7(a,b,c,d,e,f,g,h) TPARM_8(a,b,c,d,e,f,g,h,0) #define TPARM_6(a,b,c,d,e,f,g) TPARM_7(a,b,c,d,e,f,g,0) #define TPARM_5(a,b,c,d,e,f) TPARM_6(a,b,c,d,e,f,0) #define TPARM_4(a,b,c,d,e) TPARM_5(a,b,c,d,e,0) #define TPARM_3(a,b,c,d) TPARM_4(a,b,c,d,0) #define TPARM_2(a,b,c) TPARM_3(a,b,c,0) #define TPARM_1(a,b) TPARM_2(a,b,0) #define TPARM_0(a) TPARM_1(a,0) #endif #ifdef NCURSES_INTERNALS #define TIPARM_1(s,a) _nc_tiparm(1,s,a) #define TIPARM_2(s,a,b) _nc_tiparm(2,s,a,b) #define TIPARM_3(s,a,b,c) _nc_tiparm(3,s,a,b,c) #define TIPARM_4(s,a,b,c,d) _nc_tiparm(4,s,a,b,c,d) #define TIPARM_5(s,a,b,c,d,e) _nc_tiparm(5,s,a,b,c,d,e) #define TIPARM_6(s,a,b,c,d,e,f) _nc_tiparm(6,s,a,b,c,d,e,f) #define TIPARM_7(s,a,b,c,d,e,f,g) _nc_tiparm(7,s,a,b,c,d,e,f,g) #define TIPARM_8(s,a,b,c,d,e,f,g,h) _nc_tiparm(8,s,a,b,c,d,e,f,g,h) #define TIPARM_9(s,a,b,c,d,e,f,g,h,i) _nc_tiparm(9,s,a,b,c,d,e,f,g,h,i) #endif #endif /* NC_TPARM_included */ /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Thomas E. Dickey 1996 on * ****************************************************************************/ /* * $Id: tic.h,v 1.82 2021/03/20 16:06:15 tom Exp $ * tic.h - Global variables and structures for the terminfo compiler. */ #ifndef __TIC_H #define __TIC_H /* *INDENT-OFF* */ #ifdef __cplusplus extern "C" { #endif #include <ncurses_cfg.h> #include <curses.h> /* for the _tracef() prototype, ERR/OK, bool defs */ /* ** The format of SVr2 compiled terminfo files is as follows: ** ** Header (12 bytes), containing information given below ** Names Section, containing the names of the terminal ** Boolean Section, containing the values of all of the ** boolean capabilities ** A null byte may be inserted here to make ** sure that the Number Section begins on an ** even word boundary. ** Number Section, containing the values of all of the numeric ** capabilities, each as a short integer ** String Section, containing short integer offsets into the ** String Table, one per string capability ** String Table, containing the actual characters of the string ** capabilities. ** ** In the SVr2 format, "short" means signed 16-bit numbers, which is sometimes ** inconvenient. The numbers are signed, to provide for absent and canceled ** values. ncurses6.1 introduced an extension to this compiled format, by ** making the Number Section a list of signed 32-bit integers. ** ** NOTE that all short integers in the file are stored using VAX/PDP-style ** byte-order, i.e., least-significant byte first. ** ** There is no structure definition here because it would only confuse ** matters. Terminfo format is a raw byte layout, not a structure ** dump. If you happen to be on a little-endian machine with 16-bit ** shorts that requires no padding between short members in a struct, ** then there is a natural C structure that captures the header, but ** not very helpfully. */ #define MAGIC 0432 /* first two bytes of a compiled entry */ #define MAGIC2 01036 /* first two bytes of a compiled 32-bit entry */ #undef BYTE #define BYTE(p,n) (unsigned char)((p)[n]) #define IS_NEG1(p) ((BYTE(p,0) == 0377) && (BYTE(p,1) == 0377)) #define IS_NEG2(p) ((BYTE(p,0) == 0376) && (BYTE(p,1) == 0377)) #define LOW_MSB(p) (BYTE(p,0) + 256*BYTE(p,1)) #define IS_TIC_MAGIC(p) (LOW_MSB(p) == MAGIC || LOW_MSB(p) == MAGIC2) #define quick_prefix(s) (!strncmp((s), "b64:", (size_t)4) || !strncmp((s), "hex:", (size_t)4)) /* * The "maximum" here is misleading; XSI guarantees minimum values, which a * given implementation may exceed. */ #define MAX_NAME_SIZE 512 /* maximum legal name field size (XSI:127) */ #define MAX_ENTRY_SIZE1 4096 /* maximum legal entry size (SVr2) */ #define MAX_ENTRY_SIZE2 32768 /* maximum legal entry size (ncurses6.1) */ #if NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR #define MAX_ENTRY_SIZE MAX_ENTRY_SIZE2 #else #define MAX_ENTRY_SIZE MAX_ENTRY_SIZE1 #endif /* * The maximum size of individual name or alias is guaranteed in XSI to be at * least 14, since that corresponds to the older filename lengths. Newer * systems allow longer aliases, though not many terminal descriptions are * written to use them. The MAX_ALIAS symbol is used for warnings. */ #if HAVE_LONG_FILE_NAMES #define MAX_ALIAS 32 /* smaller than POSIX minimum for PATH_MAX */ #else #define MAX_ALIAS 14 /* SVr3 filename length */ #endif /* location of user's personal info directory */ #define PRIVATE_INFO "%s/.terminfo" /* plug getenv("HOME") into %s */ /* * Some traces are designed to be used via tic's verbose option (and similar in * infocmp and toe) rather than the 'trace()' function. So we use the bits * above the normal trace() parameter as a debug-level. */ #define MAX_DEBUG_LEVEL 15 #define DEBUG_LEVEL(n) ((n) << TRACE_SHIFT) #define set_trace_level(n) \ _nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL) \ + DEBUG_LEVEL(MAX_DEBUG_LEVEL) - 1, \ _nc_tracing |= DEBUG_LEVEL(n) #ifdef TRACE #define DEBUG(n, a) if (_nc_tracing >= DEBUG_LEVEL(n)) _tracef a #else #define DEBUG(n, a) /*nothing*/ #endif /* * These are the types of tokens returned by the scanner. The first * three are also used in the hash table of capability names. The scanner * returns one of these values after loading the specifics into the global * structure curr_token. */ #define BOOLEAN 0 /* Boolean capability */ #define NUMBER 1 /* Numeric capability */ #define STRING 2 /* String-valued capability */ #define CANCEL 3 /* Capability to be cancelled in following tc's */ #define NAMES 4 /* The names for a terminal type */ #define UNDEF 5 /* Undefined */ #define NO_PUSHBACK -1 /* used in pushtype to indicate no pushback */ /* * The global structure in which the specific parts of a * scanned token are returned. */ struct token { char *tk_name; /* name of capability */ int tk_valnumber; /* value of capability (if a number) */ char *tk_valstring; /* value of capability (if a string) */ }; /* * Offsets to string capabilities, with the corresponding functionkey codes. */ struct tinfo_fkeys { unsigned offset; chtype code; }; typedef short HashValue; /* * The file comp_captab.c contains an array of these structures, one per * possible capability. These are indexed by a hash table array of pointers to * the same structures for use by the parser. */ struct name_table_entry { const char *nte_name; /* name to hash on */ int nte_type; /* BOOLEAN, NUMBER or STRING */ HashValue nte_index; /* index of associated variable in its array */ HashValue nte_link; /* index in table of next hash, or -1 */ }; /* * Use this structure to hide differences between terminfo and termcap tables. */ typedef struct { unsigned table_size; const HashValue *table_data; HashValue (*hash_of)(const char *); int (*compare_names)(const char *, const char *); } HashData; struct alias { const char *from; const char *to; const char *source; }; #define NOTFOUND ((struct name_table_entry *) 0) /* * The file comp_userdefs.c contains an array of these structures, one per * possible capability. These are indexed by a hash table array of pointers to * the same structures for use by the parser. */ struct user_table_entry { const char *ute_name; /* name to hash on */ int ute_type; /* mask (BOOLEAN, NUMBER, STRING) */ unsigned ute_argc; /* number of parameters */ unsigned ute_args; /* bit-mask for string parameters */ HashValue ute_index; /* index of associated variable in its array */ HashValue ute_link; /* index in table of next hash, or -1 */ }; /* * The casts are required for correct sign-propagation with systems such as * AIX, IRIX64, Solaris which default to unsigned characters. The C standard * leaves this detail unspecified. */ /* out-of-band values for representing absent capabilities */ #define ABSENT_BOOLEAN ((signed char)-1) /* 255 */ #define ABSENT_NUMERIC (-1) #define ABSENT_STRING (char *)0 /* out-of-band values for representing cancels */ #define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */ #define CANCELLED_NUMERIC (-2) #define CANCELLED_STRING (char *)(-1) #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */ #define VALID_NUMERIC(s) ((s) >= 0) #define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING) /* termcap entries longer than this may break old binaries */ #define MAX_TERMCAP_LENGTH 1023 /* this is a documented limitation of terminfo */ #define MAX_TERMINFO_LENGTH 4096 #ifndef TERMINFO #define TERMINFO "/usr/share/terminfo" #endif #ifdef NCURSES_TERM_ENTRY_H_incl /* * These entrypoints are used only by the ncurses utilities such as tic. */ #ifdef NCURSES_INTERNALS /* access.c */ extern NCURSES_EXPORT(unsigned) _nc_pathlast (const char *); extern NCURSES_EXPORT(bool) _nc_is_abs_path (const char *); extern NCURSES_EXPORT(bool) _nc_is_dir_path (const char *); extern NCURSES_EXPORT(bool) _nc_is_file_path (const char *); extern NCURSES_EXPORT(char *) _nc_basename (char *); extern NCURSES_EXPORT(char *) _nc_rootname (char *); /* comp_captab.c */ extern NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool); extern NCURSES_EXPORT(const HashData *) _nc_get_hash_info (bool); extern NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool); /* comp_hash.c: name lookup */ extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_type_entry (const char *, int, bool); extern NCURSES_EXPORT(struct user_table_entry const *) _nc_find_user_entry (const char *); /* comp_scan.c: lexical analysis */ extern NCURSES_EXPORT(int) _nc_get_token (bool); extern NCURSES_EXPORT(void) _nc_panic_mode (char); extern NCURSES_EXPORT(void) _nc_push_token (int); extern NCURSES_EXPORT_VAR(int) _nc_curr_col; extern NCURSES_EXPORT_VAR(int) _nc_curr_line; extern NCURSES_EXPORT_VAR(int) _nc_syntax; extern NCURSES_EXPORT_VAR(int) _nc_strict_bsd; extern NCURSES_EXPORT_VAR(long) _nc_comment_end; extern NCURSES_EXPORT_VAR(long) _nc_comment_start; extern NCURSES_EXPORT_VAR(long) _nc_curr_file_pos; extern NCURSES_EXPORT_VAR(long) _nc_start_line; #define SYN_TERMINFO 0 #define SYN_TERMCAP 1 /* comp_error.c: warning & abort messages */ extern NCURSES_EXPORT(const char *) _nc_get_source (void); extern GCC_NORETURN NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(void) _nc_get_type (char *name); extern NCURSES_EXPORT(void) _nc_set_source (const char *const); extern NCURSES_EXPORT(void) _nc_set_type (const char *const); extern GCC_NORETURN NCURSES_EXPORT(void) _nc_syserr_abort (const char *const,...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(void) _nc_warning (const char *const,...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings; /* comp_scan.c */ extern NCURSES_EXPORT_VAR(struct token) _nc_curr_token; /* comp_userdefs.c */ NCURSES_EXPORT(const struct user_table_entry *) _nc_get_userdefs_table (void); NCURSES_EXPORT(const HashData *) _nc_get_hash_user (void); /* captoinfo.c: capability conversion */ extern NCURSES_EXPORT(char *) _nc_captoinfo (const char *, const char *, int const); extern NCURSES_EXPORT(char *) _nc_infotocap (const char *, const char *, int const); /* home_terminfo.c */ extern NCURSES_EXPORT(char *) _nc_home_terminfo (void); /* init_keytry.c */ #if BROKEN_LINKER #define _nc_tinfo_fkeys _nc_tinfo_fkeysf() extern NCURSES_EXPORT(const struct tinfo_fkeys *) _nc_tinfo_fkeysf (void); #else extern NCURSES_EXPORT_VAR(const struct tinfo_fkeys) _nc_tinfo_fkeys[]; #endif /* lib_tparm.c */ #define NUM_PARM 9 extern NCURSES_EXPORT_VAR(int) _nc_tparm_err; extern NCURSES_EXPORT(int) _nc_tparm_analyze(const char *, char **, int *); /* lib_trace.c */ extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing; extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *); extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *); /* lib_tputs.c */ extern NCURSES_EXPORT_VAR(int) _nc_nulls_sent; /* Add one for every null sent */ /* comp_main.c: compiler main */ extern const char * _nc_progname; /* db_iterator.c */ extern NCURSES_EXPORT(const char *) _nc_next_db(DBDIRS *, int *); extern NCURSES_EXPORT(const char *) _nc_tic_dir (const char *); extern NCURSES_EXPORT(void) _nc_first_db(DBDIRS *, int *); extern NCURSES_EXPORT(void) _nc_last_db(void); /* write_entry.c */ extern NCURSES_EXPORT(int) _nc_tic_written (void); #endif /* NCURSES_INTERNALS */ /* * These entrypoints were used by tack before 1.08. */ #undef NCURSES_TACK_1_08 #ifdef NCURSES_INTERNALS #define NCURSES_TACK_1_08 /* nothing */ #else #define NCURSES_TACK_1_08 GCC_DEPRECATED("upgrade to tack 1.08") #endif /* comp_hash.c: name lookup */ extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry (const char *, const HashValue *) NCURSES_TACK_1_08; extern NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool) NCURSES_TACK_1_08; /* comp_scan.c: lexical analysis */ extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *) NCURSES_TACK_1_08; /* comp_expand.c: expand string into readable form */ extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int) NCURSES_TACK_1_08; /* comp_scan.c: decode string from readable form */ extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *) NCURSES_TACK_1_08; #endif /* NCURSES_TERM_ENTRY_H_incl */ #ifdef __cplusplus } #endif /* *INDENT-ON* */ #endif /* __TIC_H */ /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Thomas E. Dickey 1996-on * ****************************************************************************/ /* $Id: curses.h.in,v 1.271 2021/03/20 16:25:43 tom Exp $ */ #ifndef __NCURSES_H #define __NCURSES_H #define CURSES 1 #define CURSES_H 1 /* These are defined only in curses.h, and are used for conditional compiles */ #define NCURSES_VERSION_MAJOR 6 #define NCURSES_VERSION_MINOR 2 #define NCURSES_VERSION_PATCH 20210508 /* This is defined in more than one ncurses header, for identification */ #undef NCURSES_VERSION #define NCURSES_VERSION "6.2" /* * Identify the mouse encoding version. */ #define NCURSES_MOUSE_VERSION 2 /* * Definitions to facilitate DLL's. */ #include <ncurses_dll.h> /* * Extra headers. */ #if 1 #include <stdint.h> #endif #ifdef __cplusplus #else #if 0 #include <stdnoreturn.h> #undef GCC_NORETURN #define GCC_NORETURN _Noreturn #endif #endif /* * User-definable tweak to disable the include of <stdbool.h>. */ #ifndef NCURSES_ENABLE_STDBOOL_H #define NCURSES_ENABLE_STDBOOL_H 1 #endif /* * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses * configured using --disable-macros. */ #ifndef NCURSES_ATTR_T #define NCURSES_ATTR_T int #endif /* * Expands to 'const' if ncurses is configured using --enable-const. Note that * doing so makes it incompatible with other implementations of X/Open Curses. */ #undef NCURSES_CONST #define NCURSES_CONST const #undef NCURSES_INLINE #define NCURSES_INLINE inline /* * The standard type used for color values, and for color-pairs. The latter * allows the curses library to enumerate the combinations of foreground and * background colors used by an application, and is normally the product of the * total foreground and background colors. * * X/Open uses "short" for both of these types, ultimately because they are * numbers from the SVr4 terminal database, which uses 16-bit signed values. */ #undef NCURSES_COLOR_T #define NCURSES_COLOR_T short #undef NCURSES_PAIRS_T #define NCURSES_PAIRS_T short /* * Definitions used to make WINDOW and similar structs opaque. */ #ifndef NCURSES_INTERNALS #define NCURSES_OPAQUE 0 #define NCURSES_OPAQUE_FORM 0 #define NCURSES_OPAQUE_MENU 0 #define NCURSES_OPAQUE_PANEL 0 #endif /* * Definition used to optionally suppress wattr* macros to help with the * transition from ncurses5 to ncurses6 by allowing the header files to * be shared across development packages for ncursesw in both ABIs. */ #ifndef NCURSES_WATTR_MACROS #define NCURSES_WATTR_MACROS 0 #endif /* * The reentrant code relies on the opaque setting, but adds features. */ #ifndef NCURSES_REENTRANT #define NCURSES_REENTRANT 0 #endif /* * In certain environments, we must work around linker problems for data */ #undef NCURSES_BROKEN_LINKER #if 0 #define NCURSES_BROKEN_LINKER 1 #endif /* * Control whether bindings for interop support are added. */ #undef NCURSES_INTEROP_FUNCS #define NCURSES_INTEROP_FUNCS 1 /* * The internal type used for window dimensions. */ #undef NCURSES_SIZE_T #define NCURSES_SIZE_T short /* * Control whether tparm() supports varargs or fixed-parameter list. */ #undef NCURSES_TPARM_VARARGS #define NCURSES_TPARM_VARARGS 1 /* * Control type used for tparm's arguments. While X/Open equates long and * char* values, this is not always workable for 64-bit platforms. */ #undef NCURSES_TPARM_ARG #define NCURSES_TPARM_ARG intptr_t /* * Control whether ncurses uses wcwidth() for checking width of line-drawing * characters. */ #undef NCURSES_WCWIDTH_GRAPHICS #define NCURSES_WCWIDTH_GRAPHICS 1 /* * NCURSES_CH_T is used in building the library, but not used otherwise in * this header file, since that would make the normal/wide-character versions * of the header incompatible. */ #undef NCURSES_CH_T #define NCURSES_CH_T cchar_t #if 1 && defined(_LP64) typedef unsigned chtype; typedef unsigned mmask_t; #else typedef uint32_t chtype; typedef uint32_t mmask_t; #endif /* * We need FILE, etc. Include this before checking any feature symbols. */ #include <stdio.h> /* * With XPG4, you must define _XOPEN_SOURCE_EXTENDED, it is redundant (or * conflicting) when _XOPEN_SOURCE is 500 or greater. If NCURSES_WIDECHAR is * not already defined, e.g., if the platform relies upon nonstandard feature * test macros, define it at this point if the standard feature test macros * indicate that it should be defined. */ #ifndef NCURSES_WIDECHAR #if defined(_XOPEN_SOURCE_EXTENDED) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) #define NCURSES_WIDECHAR 1 #else #define NCURSES_WIDECHAR 0 #endif #endif /* NCURSES_WIDECHAR */ #include <stdarg.h> /* we need va_list */ #if NCURSES_WIDECHAR #include <stddef.h> /* we want wchar_t */ #endif /* X/Open and SVr4 specify that curses implements 'bool'. However, C++ may also * implement it. If so, we must use the C++ compiler's type to avoid conflict * with other interfaces. * * A further complication is that <stdbool.h> may declare 'bool' to be a * different type, such as an enum which is not necessarily compatible with * C++. If we have <stdbool.h>, make 'bool' a macro, so users may #undef it. * Otherwise, let it remain a typedef to avoid conflicts with other #define's. * In either case, make a typedef for NCURSES_BOOL which can be used if needed * from either C or C++. */ #undef TRUE #define TRUE 1 #undef FALSE #define FALSE 0 typedef unsigned char NCURSES_BOOL; #if defined(__cplusplus) /* __cplusplus, etc. */ /* use the C++ compiler's bool type */ #define NCURSES_BOOL bool #else /* c89, c99, etc. */ #if NCURSES_ENABLE_STDBOOL_H #include <stdbool.h> /* use whatever the C compiler decides bool really is */ #define NCURSES_BOOL bool #else /* there is no predefined bool - use our own */ #undef bool #define bool NCURSES_BOOL #endif #endif /* !__cplusplus, etc. */ #ifdef __cplusplus extern "C" { #define NCURSES_CAST(type,value) static_cast<type>(value) #else #define NCURSES_CAST(type,value) (type)(value) #endif #define NCURSES_OK_ADDR(p) (0 != NCURSES_CAST(const void *, (p))) /* * X/Open attributes. In the ncurses implementation, they are identical to the * A_ attributes. */ #define WA_ATTRIBUTES A_ATTRIBUTES #define WA_NORMAL A_NORMAL #define WA_STANDOUT A_STANDOUT #define WA_UNDERLINE A_UNDERLINE #define WA_REVERSE A_REVERSE #define WA_BLINK A_BLINK #define WA_DIM A_DIM #define WA_BOLD A_BOLD #define WA_ALTCHARSET A_ALTCHARSET #define WA_INVIS A_INVIS #define WA_PROTECT A_PROTECT #define WA_HORIZONTAL A_HORIZONTAL #define WA_LEFT A_LEFT #define WA_LOW A_LOW #define WA_RIGHT A_RIGHT #define WA_TOP A_TOP #define WA_VERTICAL A_VERTICAL #if 1 #define WA_ITALIC A_ITALIC /* ncurses extension */ #endif /* colors */ #define COLOR_BLACK 0 #define COLOR_RED 1 #define COLOR_GREEN 2 #define COLOR_YELLOW 3 #define COLOR_BLUE 4 #define COLOR_MAGENTA 5 #define COLOR_CYAN 6 #define COLOR_WHITE 7 /* line graphics */ #if 0 || NCURSES_REENTRANT NCURSES_WRAPPED_VAR(chtype*, acs_map); #define acs_map NCURSES_PUBLIC_VAR(acs_map()) #else extern NCURSES_EXPORT_VAR(chtype) acs_map[]; #endif #define NCURSES_ACS(c) (acs_map[NCURSES_CAST(unsigned char,(c))]) /* VT100 symbols begin here */ #define ACS_ULCORNER NCURSES_ACS('l') /* upper left corner */ #define ACS_LLCORNER NCURSES_ACS('m') /* lower left corner */ #define ACS_URCORNER NCURSES_ACS('k') /* upper right corner */ #define ACS_LRCORNER NCURSES_ACS('j') /* lower right corner */ #define ACS_LTEE NCURSES_ACS('t') /* tee pointing right */ #define ACS_RTEE NCURSES_ACS('u') /* tee pointing left */ #define ACS_BTEE NCURSES_ACS('v') /* tee pointing up */ #define ACS_TTEE NCURSES_ACS('w') /* tee pointing down */ #define ACS_HLINE NCURSES_ACS('q') /* horizontal line */ #define ACS_VLINE NCURSES_ACS('x') /* vertical line */ #define ACS_PLUS NCURSES_ACS('n') /* large plus or crossover */ #define ACS_S1 NCURSES_ACS('o') /* scan line 1 */ #define ACS_S9 NCURSES_ACS('s') /* scan line 9 */ #define ACS_DIAMOND NCURSES_ACS('`') /* diamond */ #define ACS_CKBOARD NCURSES_ACS('a') /* checker board (stipple) */ #define ACS_DEGREE NCURSES_ACS('f') /* degree symbol */ #define ACS_PLMINUS NCURSES_ACS('g') /* plus/minus */ #define ACS_BULLET NCURSES_ACS('~') /* bullet */ /* Teletype 5410v1 symbols begin here */ #define ACS_LARROW NCURSES_ACS(',') /* arrow pointing left */ #define ACS_RARROW NCURSES_ACS('+') /* arrow pointing right */ #define ACS_DARROW NCURSES_ACS('.') /* arrow pointing down */ #define ACS_UARROW NCURSES_ACS('-') /* arrow pointing up */ #define ACS_BOARD NCURSES_ACS('h') /* board of squares */ #define ACS_LANTERN NCURSES_ACS('i') /* lantern symbol */ #define ACS_BLOCK NCURSES_ACS('0') /* solid square block */ /* * These aren't documented, but a lot of System Vs have them anyway * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings). * The ACS_names may not match AT&T's, our source didn't know them. */ #define ACS_S3 NCURSES_ACS('p') /* scan line 3 */ #define ACS_S7 NCURSES_ACS('r') /* scan line 7 */ #define ACS_LEQUAL NCURSES_ACS('y') /* less/equal */ #define ACS_GEQUAL NCURSES_ACS('z') /* greater/equal */ #define ACS_PI NCURSES_ACS('{') /* Pi */ #define ACS_NEQUAL NCURSES_ACS('|') /* not equal */ #define ACS_STERLING NCURSES_ACS('}') /* UK pound sign */ /* * Line drawing ACS names are of the form ACS_trbl, where t is the top, r * is the right, b is the bottom, and l is the left. t, r, b, and l might * be B (blank), S (single), D (double), or T (thick). The subset defined * here only uses B and S. */ #define ACS_BSSB ACS_ULCORNER #define ACS_SSBB ACS_LLCORNER #define ACS_BBSS ACS_URCORNER #define ACS_SBBS ACS_LRCORNER #define ACS_SBSS ACS_RTEE #define ACS_SSSB ACS_LTEE #define ACS_SSBS ACS_BTEE #define ACS_BSSS ACS_TTEE #define ACS_BSBS ACS_HLINE #define ACS_SBSB ACS_VLINE #define ACS_SSSS ACS_PLUS #undef ERR #define ERR (-1) #undef OK #define OK (0) /* values for the _flags member */ #define _SUBWIN 0x01 /* is this a sub-window? */ #define _ENDLINE 0x02 /* is the window flush right? */ #define _FULLWIN 0x04 /* is the window full-screen? */ #define _SCROLLWIN 0x08 /* bottom edge is at screen bottom? */ #define _ISPAD 0x10 /* is this window a pad? */ #define _HASMOVED 0x20 /* has cursor moved since last refresh? */ #define _WRAPPED 0x40 /* cursor was just wrappped */ /* * this value is used in the firstchar and lastchar fields to mark * unchanged lines */ #define _NOCHANGE -1 /* * this value is used in the oldindex field to mark lines created by insertions * and scrolls. */ #define _NEWINDEX -1 typedef struct screen SCREEN; typedef struct _win_st WINDOW; typedef chtype attr_t; /* ...must be at least as wide as chtype */ #if NCURSES_WIDECHAR #if 0 #ifdef mblen /* libutf8.h defines it w/o undefining first */ #undef mblen #endif #include <libutf8.h> #endif #if 1 #include <wchar.h> /* ...to get mbstate_t, etc. */ #endif #if 0 typedef unsigned short wchar_t1; #endif #if 0 typedef unsigned int wint_t1; #endif /* * cchar_t stores an array of CCHARW_MAX wide characters. The first is * normally a spacing character. The others are non-spacing. If those * (spacing and nonspacing) do not fill the array, a null L'\0' follows. * Otherwise, a null is assumed to follow when extracting via getcchar(). */ #define CCHARW_MAX 5 typedef struct { attr_t attr; wchar_t chars[CCHARW_MAX]; #if 1 #undef NCURSES_EXT_COLORS #define NCURSES_EXT_COLORS 20210508 int ext_color; /* color pair, must be more than 16-bits */ #endif } cchar_t; #endif /* NCURSES_WIDECHAR */ #if !NCURSES_OPAQUE struct ldat; struct _win_st { NCURSES_SIZE_T _cury, _curx; /* current cursor position */ /* window location and size */ NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */ NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */ short _flags; /* window state flags */ /* attribute tracking */ attr_t _attrs; /* current attribute for non-space character */ chtype _bkgd; /* current background char/attribute pair */ /* option values set by user */ bool _notimeout; /* no time out on function-key entry? */ bool _clear; /* consider all data in the window invalid? */ bool _leaveok; /* OK to not reset cursor on exit? */ bool _scroll; /* OK to scroll this window? */ bool _idlok; /* OK to use insert/delete line? */ bool _idcok; /* OK to use insert/delete char? */ bool _immed; /* window in immed mode? (not yet used) */ bool _sync; /* window in sync mode? */ bool _use_keypad; /* process function keys into KEY_ symbols? */ int _delay; /* 0 = nodelay, <0 = blocking, >0 = delay */ struct ldat *_line; /* the actual line data */ /* global screen state */ NCURSES_SIZE_T _regtop; /* top line of scrolling region */ NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */ /* these are used only if this is a sub-window */ int _parx; /* x coordinate of this window in parent */ int _pary; /* y coordinate of this window in parent */ WINDOW *_parent; /* pointer to parent if a sub-window */ /* these are used only if this is a pad */ struct pdat { NCURSES_SIZE_T _pad_y, _pad_x; NCURSES_SIZE_T _pad_top, _pad_left; NCURSES_SIZE_T _pad_bottom, _pad_right; } _pad; NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */ #if NCURSES_WIDECHAR cchar_t _bkgrnd; /* current background char/attribute pair */ #if 1 int _color; /* current color-pair for non-space character */ #endif #endif }; #endif /* NCURSES_OPAQUE */ /* * GCC (and some other compilers) define '__attribute__'; we're using this * macro to alert the compiler to flag inconsistencies in printf/scanf-like * function calls. Just in case '__attribute__' isn't defined, make a dummy. * Old versions of G++ do not accept it anyway, at least not consistently with * GCC. */ #if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__)) #define __attribute__(p) /* nothing */ #endif /* * We cannot define these in ncurses_cfg.h, since they require parameters to be * passed (that is non-portable). If you happen to be using gcc with warnings * enabled, define * GCC_PRINTF * GCC_SCANF * to improve checking of calls to printw(), etc. */ #ifndef GCC_PRINTFLIKE #if defined(GCC_PRINTF) && !defined(printf) #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) #else #define GCC_PRINTFLIKE(fmt,var) /*nothing*/ #endif #endif #ifndef GCC_SCANFLIKE #if defined(GCC_SCANF) && !defined(scanf) #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) #else #define GCC_SCANFLIKE(fmt,var) /*nothing*/ #endif #endif #ifndef GCC_NORETURN #define GCC_NORETURN /* nothing */ #endif #ifndef GCC_UNUSED #define GCC_UNUSED /* nothing */ #endif #undef GCC_DEPRECATED #if (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)) && !defined(NCURSES_INTERNALS) #define GCC_DEPRECATED(msg) __attribute__((deprecated)) #else #define GCC_DEPRECATED(msg) /* nothing */ #endif /* * Curses uses a helper function. Define our type for this to simplify * extending it for the sp-funcs feature. */ typedef int (*NCURSES_OUTC)(int); /* * Function prototypes. This is the complete X/Open Curses list of required * functions. Those marked `generated' will have sources generated from the * macro definitions later in this file, in order to satisfy XPG4.2 * requirements. */ extern NCURSES_EXPORT(int) addch (const chtype); /* generated */ extern NCURSES_EXPORT(int) addchnstr (const chtype *, int); /* generated */ extern NCURSES_EXPORT(int) addchstr (const chtype *); /* generated */ extern NCURSES_EXPORT(int) addnstr (const char *, int); /* generated */ extern NCURSES_EXPORT(int) addstr (const char *); /* generated */ extern NCURSES_EXPORT(int) attroff (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attron (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attr_get (attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ extern NCURSES_EXPORT(int) attr_off (attr_t, void *); /* generated */ extern NCURSES_EXPORT(int) attr_on (attr_t, void *); /* generated */ extern NCURSES_EXPORT(int) attr_set (attr_t, NCURSES_PAIRS_T, void *); /* generated */ extern NCURSES_EXPORT(int) baudrate (void); /* implemented */ extern NCURSES_EXPORT(int) beep (void); /* implemented */ extern NCURSES_EXPORT(int) bkgd (chtype); /* generated */ extern NCURSES_EXPORT(void) bkgdset (chtype); /* generated */ extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* generated */ extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype); /* generated */ extern NCURSES_EXPORT(bool) can_change_color (void); /* implemented */ extern NCURSES_EXPORT(int) cbreak (void); /* implemented */ extern NCURSES_EXPORT(int) chgat (int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ extern NCURSES_EXPORT(int) clear (void); /* generated */ extern NCURSES_EXPORT(int) clearok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) clrtobot (void); /* generated */ extern NCURSES_EXPORT(int) clrtoeol (void); /* generated */ extern NCURSES_EXPORT(int) color_content (NCURSES_COLOR_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ extern NCURSES_EXPORT(int) color_set (NCURSES_PAIRS_T,void*); /* generated */ extern NCURSES_EXPORT(int) COLOR_PAIR (int); /* generated */ extern NCURSES_EXPORT(int) copywin (const WINDOW*,WINDOW*,int,int,int,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) curs_set (int); /* implemented */ extern NCURSES_EXPORT(int) def_prog_mode (void); /* implemented */ extern NCURSES_EXPORT(int) def_shell_mode (void); /* implemented */ extern NCURSES_EXPORT(int) delay_output (int); /* implemented */ extern NCURSES_EXPORT(int) delch (void); /* generated */ extern NCURSES_EXPORT(void) delscreen (SCREEN *); /* implemented */ extern NCURSES_EXPORT(int) delwin (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) deleteln (void); /* generated */ extern NCURSES_EXPORT(WINDOW *) derwin (WINDOW *,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) doupdate (void); /* implemented */ extern NCURSES_EXPORT(WINDOW *) dupwin (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) echo (void); /* implemented */ extern NCURSES_EXPORT(int) echochar (const chtype); /* generated */ extern NCURSES_EXPORT(int) erase (void); /* generated */ extern NCURSES_EXPORT(int) endwin (void); /* implemented */ extern NCURSES_EXPORT(char) erasechar (void); /* implemented */ extern NCURSES_EXPORT(void) filter (void); /* implemented */ extern NCURSES_EXPORT(int) flash (void); /* implemented */ extern NCURSES_EXPORT(int) flushinp (void); /* implemented */ extern NCURSES_EXPORT(chtype) getbkgd (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getch (void); /* generated */ extern NCURSES_EXPORT(int) getnstr (char *, int); /* generated */ extern NCURSES_EXPORT(int) getstr (char *); /* generated */ extern NCURSES_EXPORT(WINDOW *) getwin (FILE *); /* implemented */ extern NCURSES_EXPORT(int) halfdelay (int); /* implemented */ extern NCURSES_EXPORT(bool) has_colors (void); /* implemented */ extern NCURSES_EXPORT(bool) has_ic (void); /* implemented */ extern NCURSES_EXPORT(bool) has_il (void); /* implemented */ extern NCURSES_EXPORT(int) hline (chtype, int); /* generated */ extern NCURSES_EXPORT(void) idcok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(int) idlok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(void) immedok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(chtype) inch (void); /* generated */ extern NCURSES_EXPORT(int) inchnstr (chtype *, int); /* generated */ extern NCURSES_EXPORT(int) inchstr (chtype *); /* generated */ extern NCURSES_EXPORT(WINDOW *) initscr (void); /* implemented */ extern NCURSES_EXPORT(int) init_color (NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ extern NCURSES_EXPORT(int) init_pair (NCURSES_PAIRS_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ extern NCURSES_EXPORT(int) innstr (char *, int); /* generated */ extern NCURSES_EXPORT(int) insch (chtype); /* generated */ extern NCURSES_EXPORT(int) insdelln (int); /* generated */ extern NCURSES_EXPORT(int) insertln (void); /* generated */ extern NCURSES_EXPORT(int) insnstr (const char *, int); /* generated */ extern NCURSES_EXPORT(int) insstr (const char *); /* generated */ extern NCURSES_EXPORT(int) instr (char *); /* generated */ extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(bool) isendwin (void); /* implemented */ extern NCURSES_EXPORT(bool) is_linetouched (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(bool) is_wintouched (WINDOW *); /* implemented */ extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int); /* implemented */ extern NCURSES_EXPORT(int) keypad (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(char) killchar (void); /* implemented */ extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(char *) longname (void); /* implemented */ extern NCURSES_EXPORT(int) meta (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) move (int, int); /* generated */ extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype); /* generated */ extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvaddchstr (int, int, const chtype *); /* generated */ extern NCURSES_EXPORT(int) mvaddnstr (int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvaddstr (int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ extern NCURSES_EXPORT(int) mvcur (int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) mvdelch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvderwin (WINDOW *, int, int); /* implemented */ extern NCURSES_EXPORT(int) mvgetch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvgetnstr (int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvgetstr (int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(chtype) mvinch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvinchnstr (int, int, chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvinchstr (int, int, chtype *); /* generated */ extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvinsch (int, int, chtype); /* generated */ extern NCURSES_EXPORT(int) mvinsnstr (int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvinsstr (int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvinstr (int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...) /* implemented */ GCC_PRINTFLIKE(3,4); extern NCURSES_EXPORT(int) mvscanw (int,int, const char *,...) /* implemented */ GCC_SCANFLIKE(3,4); extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype); /* generated */ extern NCURSES_EXPORT(int) mvwaddchnstr (WINDOW *, int, int, const chtype *, int);/* generated */ extern NCURSES_EXPORT(int) mvwaddchstr (WINDOW *, int, int, const chtype *); /* generated */ extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwaddstr (WINDOW *, int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, NCURSES_PAIRS_T, const void *);/* generated */ extern NCURSES_EXPORT(int) mvwdelch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetnstr (WINDOW *, int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) mvwin (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(chtype) mvwinch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwinchnstr (WINDOW *, int, int, chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinchstr (WINDOW *, int, int, chtype *); /* generated */ extern NCURSES_EXPORT(int) mvwinnstr (WINDOW *, int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinsch (WINDOW *, int, int, chtype); /* generated */ extern NCURSES_EXPORT(int) mvwinsnstr (WINDOW *, int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinsstr (WINDOW *, int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...) /* implemented */ GCC_PRINTFLIKE(4,5); extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, const char *,...) /* implemented */ GCC_SCANFLIKE(4,5); extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) napms (int); /* implemented */ extern NCURSES_EXPORT(WINDOW *) newpad (int,int); /* implemented */ extern NCURSES_EXPORT(SCREEN *) newterm (const char *,FILE *,FILE *); /* implemented */ extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) nl (void); /* implemented */ extern NCURSES_EXPORT(int) nocbreak (void); /* implemented */ extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) noecho (void); /* implemented */ extern NCURSES_EXPORT(int) nonl (void); /* implemented */ extern NCURSES_EXPORT(void) noqiflush (void); /* implemented */ extern NCURSES_EXPORT(int) noraw (void); /* implemented */ extern NCURSES_EXPORT(int) notimeout (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) overlay (const WINDOW*,WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) pair_content (NCURSES_PAIRS_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ extern NCURSES_EXPORT(int) PAIR_NUMBER (int); /* generated */ extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) pnoutrefresh (WINDOW*,int,int,int,int,int,int);/* implemented */ extern NCURSES_EXPORT(int) prefresh (WINDOW *,int,int,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) printw (const char *,...) /* implemented */ GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *); /* implemented */ extern NCURSES_EXPORT(void) qiflush (void); /* implemented */ extern NCURSES_EXPORT(int) raw (void); /* implemented */ extern NCURSES_EXPORT(int) redrawwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) refresh (void); /* generated */ extern NCURSES_EXPORT(int) resetty (void); /* implemented */ extern NCURSES_EXPORT(int) reset_prog_mode (void); /* implemented */ extern NCURSES_EXPORT(int) reset_shell_mode (void); /* implemented */ extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int)); /* implemented */ extern NCURSES_EXPORT(int) savetty (void); /* implemented */ extern NCURSES_EXPORT(int) scanw (const char *,...) /* implemented */ GCC_SCANFLIKE(1,2); extern NCURSES_EXPORT(int) scr_dump (const char *); /* implemented */ extern NCURSES_EXPORT(int) scr_init (const char *); /* implemented */ extern NCURSES_EXPORT(int) scrl (int); /* generated */ extern NCURSES_EXPORT(int) scroll (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) scrollok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) scr_restore (const char *); /* implemented */ extern NCURSES_EXPORT(int) scr_set (const char *); /* implemented */ extern NCURSES_EXPORT(int) setscrreg (int,int); /* generated */ extern NCURSES_EXPORT(SCREEN *) set_term (SCREEN *); /* implemented */ extern NCURSES_EXPORT(int) slk_attroff (const chtype); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_off (const attr_t, void *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) slk_attron (const chtype); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_on (attr_t,void*); /* generated:WIDEC */ extern NCURSES_EXPORT(int) slk_attrset (const chtype); /* implemented */ extern NCURSES_EXPORT(attr_t) slk_attr (void); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_set (const attr_t,NCURSES_PAIRS_T,void*); /* implemented */ extern NCURSES_EXPORT(int) slk_clear (void); /* implemented */ extern NCURSES_EXPORT(int) slk_color (NCURSES_PAIRS_T); /* implemented */ extern NCURSES_EXPORT(int) slk_init (int); /* implemented */ extern NCURSES_EXPORT(char *) slk_label (int); /* implemented */ extern NCURSES_EXPORT(int) slk_noutrefresh (void); /* implemented */ extern NCURSES_EXPORT(int) slk_refresh (void); /* implemented */ extern NCURSES_EXPORT(int) slk_restore (void); /* implemented */ extern NCURSES_EXPORT(int) slk_set (int,const char *,int); /* implemented */ extern NCURSES_EXPORT(int) slk_touch (void); /* implemented */ extern NCURSES_EXPORT(int) standout (void); /* generated */ extern NCURSES_EXPORT(int) standend (void); /* generated */ extern NCURSES_EXPORT(int) start_color (void); /* implemented */ extern NCURSES_EXPORT(WINDOW *) subpad (WINDOW *, int, int, int, int); /* implemented */ extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *, int, int, int, int); /* implemented */ extern NCURSES_EXPORT(int) syncok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(chtype) termattrs (void); /* implemented */ extern NCURSES_EXPORT(char *) termname (void); /* implemented */ extern NCURSES_EXPORT(void) timeout (int); /* generated */ extern NCURSES_EXPORT(int) touchline (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) touchwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) typeahead (int); /* implemented */ extern NCURSES_EXPORT(int) ungetch (int); /* implemented */ extern NCURSES_EXPORT(int) untouchwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(void) use_env (bool); /* implemented */ extern NCURSES_EXPORT(void) use_tioctl (bool); /* implemented */ extern NCURSES_EXPORT(int) vidattr (chtype); /* implemented */ extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC); /* implemented */ extern NCURSES_EXPORT(int) vline (chtype, int); /* generated */ extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_printw); /* implemented */ extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list); /* implemented */ extern NCURSES_EXPORT(int) vwscanw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_scanw); /* implemented */ extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, const char *,va_list); /* implemented */ extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int); /* implemented */ extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *); /* generated */ extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int); /* implemented */ extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *); /* generated */ extern NCURSES_EXPORT(int) wattron (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattroff (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattrset (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattr_get (WINDOW *, attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ extern NCURSES_EXPORT(int) wattr_on (WINDOW *, attr_t, void *); /* implemented */ extern NCURSES_EXPORT(int) wattr_off (WINDOW *, attr_t, void *); /* implemented */ extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, NCURSES_PAIRS_T, void *); /* generated */ extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype); /* implemented */ extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype); /* implemented */ extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* implemented */ extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, NCURSES_PAIRS_T, const void *);/* implemented */ extern NCURSES_EXPORT(int) wclear (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wclrtobot (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wclrtoeol (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wcolor_set (WINDOW*,NCURSES_PAIRS_T,void*); /* implemented */ extern NCURSES_EXPORT(void) wcursyncup (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wdelch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wdeleteln (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wechochar (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) werase (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wgetch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int); /* implemented */ extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *); /* generated */ extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int); /* implemented */ extern NCURSES_EXPORT(chtype) winch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) winchnstr (WINDOW *, chtype *, int); /* implemented */ extern NCURSES_EXPORT(int) winchstr (WINDOW *, chtype *); /* generated */ extern NCURSES_EXPORT(int) winnstr (WINDOW *, char *, int); /* implemented */ extern NCURSES_EXPORT(int) winsch (WINDOW *, chtype); /* implemented */ extern NCURSES_EXPORT(int) winsdelln (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) winsertln (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) winsnstr (WINDOW *, const char *,int); /* implemented */ extern NCURSES_EXPORT(int) winsstr (WINDOW *, const char *); /* generated */ extern NCURSES_EXPORT(int) winstr (WINDOW *, char *); /* generated */ extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wprintw (WINDOW *, const char *,...) /* implemented */ GCC_PRINTFLIKE(2,3); extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wrefresh (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wscanw (WINDOW *, const char *,...) /* implemented */ GCC_SCANFLIKE(2,3); extern NCURSES_EXPORT(int) wscrl (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wstandout (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wstandend (WINDOW *); /* generated */ extern NCURSES_EXPORT(void) wsyncdown (WINDOW *); /* implemented */ extern NCURSES_EXPORT(void) wsyncup (WINDOW *); /* implemented */ extern NCURSES_EXPORT(void) wtimeout (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) wtouchln (WINDOW *,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int); /* implemented */ /* * These are also declared in <term.h>: */ extern NCURSES_EXPORT(int) tigetflag (const char *); /* implemented */ extern NCURSES_EXPORT(int) tigetnum (const char *); /* implemented */ extern NCURSES_EXPORT(char *) tigetstr (const char *); /* implemented */ extern NCURSES_EXPORT(int) putp (const char *); /* implemented */ #if NCURSES_TPARM_VARARGS extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */ #else extern NCURSES_EXPORT(char *) tparm (const char *, NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG); /* special */ #endif extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */ /* * These functions are not in X/Open, but we use them in macro definitions: */ extern NCURSES_EXPORT(int) getattrs (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getcurx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getcury (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getbegx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getbegy (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getmaxx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getmaxy (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getparx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getpary (const WINDOW *); /* generated */ /* * vid_attr() was implemented originally based on a draft of X/Open curses. */ #if !NCURSES_WIDECHAR #define vid_attr(a,pair,opts) vidattr(a) #endif /* * These functions are extensions - not in X/Open Curses. */ #if 1 #undef NCURSES_EXT_FUNCS #define NCURSES_EXT_FUNCS 20210508 typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *); typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *); extern NCURSES_EXPORT(bool) is_term_resized (int, int); extern NCURSES_EXPORT(char *) keybound (int, int); extern NCURSES_EXPORT(const char *) curses_version (void); extern NCURSES_EXPORT(int) alloc_pair (int, int); extern NCURSES_EXPORT(int) assume_default_colors (int, int); extern NCURSES_EXPORT(int) define_key (const char *, int); extern NCURSES_EXPORT(int) extended_color_content(int, int *, int *, int *); extern NCURSES_EXPORT(int) extended_pair_content(int, int *, int *); extern NCURSES_EXPORT(int) extended_slk_color(int); extern NCURSES_EXPORT(int) find_pair (int, int); extern NCURSES_EXPORT(int) free_pair (int); extern NCURSES_EXPORT(int) get_escdelay (void); extern NCURSES_EXPORT(int) init_extended_color(int, int, int, int); extern NCURSES_EXPORT(int) init_extended_pair(int, int, int); extern NCURSES_EXPORT(int) key_defined (const char *); extern NCURSES_EXPORT(int) keyok (int, bool); extern NCURSES_EXPORT(void) reset_color_pairs (void); extern NCURSES_EXPORT(int) resize_term (int, int); extern NCURSES_EXPORT(int) resizeterm (int, int); extern NCURSES_EXPORT(int) set_escdelay (int); extern NCURSES_EXPORT(int) set_tabsize (int); extern NCURSES_EXPORT(int) use_default_colors (void); extern NCURSES_EXPORT(int) use_extended_names (bool); extern NCURSES_EXPORT(int) use_legacy_coding (int); extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *); extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *); extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int); extern NCURSES_EXPORT(void) nofilter(void); /* * These extensions provide access to information stored in the WINDOW even * when NCURSES_OPAQUE is set: */ extern NCURSES_EXPORT(WINDOW *) wgetparent (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_cleared (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_idcok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_idlok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_immedok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_keypad (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_leaveok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_nodelay (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_notimeout (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_pad (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_scrollok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_subwin (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_syncok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wgetdelay (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wgetscrreg (const WINDOW *, int *, int *); /* generated */ #else #define curses_version() NCURSES_VERSION #endif /* * Extra extension-functions, which pass a SCREEN pointer rather than using * a global variable SP. */ #if 1 #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 20210508 #define NCURSES_SP_NAME(name) name##_sp /* Define the sp-funcs helper function */ #define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC) typedef int (*NCURSES_SP_OUTC)(SCREEN*, int); extern NCURSES_EXPORT(SCREEN *) new_prescr (void); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(baudrate) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(beep) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(can_change_color) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(cbreak) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(color_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(delay_output) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(doupdate) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(echo) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(endwin) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char) NCURSES_SP_NAME(erasechar) (SCREEN*);/* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(filter) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flash) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flushinp) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(getwin) (SCREEN*, FILE *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(halfdelay) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_colors) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_ic) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_il) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_color) (SCREEN*, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_pair) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(intrflush) (SCREEN*, WINDOW*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(isendwin) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(keyname) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char) NCURSES_SP_NAME(killchar) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mvcur) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newpad) (SCREEN*, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, const char *, FILE *, FILE *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newwin) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nl) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noecho) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nonl) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(noqiflush) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noraw) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(pair_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(qiflush) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(raw) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resetty) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ripoffline) (SCREEN*, int, int (*)(WINDOW *, int)); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(savetty) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_init) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_restore) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_set) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attroff) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attron) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attrset) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(slk_attr) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attr_set) (SCREEN*, const attr_t, NCURSES_PAIRS_T, void*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_clear) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_color) (SCREEN*, NCURSES_PAIRS_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_init) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(slk_label) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_noutrefresh) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_refresh) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_restore) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_set) (SCREEN*, int, const char *, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_touch) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(start_color) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(termattrs) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(termname) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetch) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_env) (SCREEN*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_tioctl) (SCREEN*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ #if 1 extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(alloc_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_color_content) (SCREEN*, int, int *, int *, int *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_pair_content) (SCREEN*, int, int *, int *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_slk_color) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(find_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(free_pair) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_color) (SCREEN*, int, int, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_pair) (SCREEN*, int, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(is_term_resized) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined) (SCREEN*, const char *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */ /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(reset_color_pairs) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resize_term) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resizeterm) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_escdelay) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_tabsize) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_default_colors) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ #endif #else #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 0 #define NCURSES_SP_NAME(name) name #define NCURSES_SP_OUTC NCURSES_OUTC #endif /* attributes */ #define NCURSES_ATTR_SHIFT 8 #define NCURSES_BITS(mask,shift) (NCURSES_CAST(chtype,(mask)) << ((shift) + NCURSES_ATTR_SHIFT)) #define A_NORMAL (1U - 1U) #define A_ATTRIBUTES NCURSES_BITS(~(1U - 1U),0) #define A_CHARTEXT (NCURSES_BITS(1U,0) - 1U) #define A_COLOR NCURSES_BITS(((1U) << 8) - 1U,0) #define A_STANDOUT NCURSES_BITS(1U,8) #define A_UNDERLINE NCURSES_BITS(1U,9) #define A_REVERSE NCURSES_BITS(1U,10) #define A_BLINK NCURSES_BITS(1U,11) #define A_DIM NCURSES_BITS(1U,12) #define A_BOLD NCURSES_BITS(1U,13) #define A_ALTCHARSET NCURSES_BITS(1U,14) #define A_INVIS NCURSES_BITS(1U,15) #define A_PROTECT NCURSES_BITS(1U,16) #define A_HORIZONTAL NCURSES_BITS(1U,17) #define A_LEFT NCURSES_BITS(1U,18) #define A_LOW NCURSES_BITS(1U,19) #define A_RIGHT NCURSES_BITS(1U,20) #define A_TOP NCURSES_BITS(1U,21) #define A_VERTICAL NCURSES_BITS(1U,22) #if 1 #define A_ITALIC NCURSES_BITS(1U,23) /* ncurses extension */ #endif /* * Most of the pseudo functions are macros that either provide compatibility * with older versions of curses, or provide inline functionality to improve * performance. */ /* * These pseudo functions are always implemented as macros: */ #define getyx(win,y,x) (y = getcury(win), x = getcurx(win)) #define getbegyx(win,y,x) (y = getbegy(win), x = getbegx(win)) #define getmaxyx(win,y,x) (y = getmaxy(win), x = getmaxx(win)) #define getparyx(win,y,x) (y = getpary(win), x = getparx(win)) #define getsyx(y,x) do { if (newscr) { \ if (is_leaveok(newscr)) \ (y) = (x) = -1; \ else \ getyx(newscr,(y), (x)); \ } \ } while(0) #define setsyx(y,x) do { if (newscr) { \ if ((y) == -1 && (x) == -1) \ leaveok(newscr, TRUE); \ else { \ leaveok(newscr, FALSE); \ wmove(newscr, (y), (x)); \ } \ } \ } while(0) #ifndef NCURSES_NOMACROS /* * These miscellaneous pseudo functions are provided for compatibility: */ #define wgetstr(w, s) wgetnstr(w, s, -1) #define getnstr(s, n) wgetnstr(stdscr, s, (n)) #define setterm(term) setupterm(term, 1, (int *)0) #define fixterm() reset_prog_mode() #define resetterm() reset_shell_mode() #define saveterm() def_prog_mode() #define crmode() cbreak() #define nocrmode() nocbreak() #define gettmode() /* It seems older SYSV curses versions define these */ #if !NCURSES_OPAQUE #define getattrs(win) NCURSES_CAST(int, NCURSES_OK_ADDR(win) ? (win)->_attrs : A_NORMAL) #define getcurx(win) (NCURSES_OK_ADDR(win) ? (win)->_curx : ERR) #define getcury(win) (NCURSES_OK_ADDR(win) ? (win)->_cury : ERR) #define getbegx(win) (NCURSES_OK_ADDR(win) ? (win)->_begx : ERR) #define getbegy(win) (NCURSES_OK_ADDR(win) ? (win)->_begy : ERR) #define getmaxx(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxx + 1) : ERR) #define getmaxy(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxy + 1) : ERR) #define getparx(win) (NCURSES_OK_ADDR(win) ? (win)->_parx : ERR) #define getpary(win) (NCURSES_OK_ADDR(win) ? (win)->_pary : ERR) #endif /* NCURSES_OPAQUE */ #define wstandout(win) (wattrset(win,A_STANDOUT)) #define wstandend(win) (wattrset(win,A_NORMAL)) #define wattron(win,at) wattr_on(win, NCURSES_CAST(attr_t, at), NULL) #define wattroff(win,at) wattr_off(win, NCURSES_CAST(attr_t, at), NULL) #if !NCURSES_OPAQUE #if NCURSES_WATTR_MACROS #if NCURSES_WIDECHAR && 1 #define wattrset(win,at) \ (NCURSES_OK_ADDR(win) \ ? ((win)->_color = NCURSES_CAST(int, PAIR_NUMBER(at)), \ (win)->_attrs = NCURSES_CAST(attr_t, at), \ OK) \ : ERR) #else #define wattrset(win,at) \ (NCURSES_OK_ADDR(win) \ ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \ OK) \ : ERR) #endif #endif /* NCURSES_WATTR_MACROS */ #endif /* NCURSES_OPAQUE */ #define scroll(win) wscrl(win,1) #define touchwin(win) wtouchln((win), 0, getmaxy(win), 1) #define touchline(win, s, c) wtouchln((win), s, c, 1) #define untouchwin(win) wtouchln((win), 0, getmaxy(win), 0) #define box(win, v, h) wborder(win, v, v, h, h, 0, 0, 0, 0) #define border(ls, rs, ts, bs, tl, tr, bl, br) wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br) #define hline(ch, n) whline(stdscr, ch, (n)) #define vline(ch, n) wvline(stdscr, ch, (n)) #define winstr(w, s) winnstr(w, s, -1) #define winchstr(w, s) winchnstr(w, s, -1) #define winsstr(w, s) winsnstr(w, s, -1) #if !NCURSES_OPAQUE #define redrawwin(win) wredrawln(win, 0, (NCURSES_OK_ADDR(win) ? (win)->_maxy+1 : -1)) #endif /* NCURSES_OPAQUE */ #define waddstr(win,str) waddnstr(win,str,-1) #define waddchstr(win,str) waddchnstr(win,str,-1) /* * These apply to the first 256 color pairs. */ #define COLOR_PAIR(n) (NCURSES_BITS((n), 0) & A_COLOR) #define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & A_COLOR) >> NCURSES_ATTR_SHIFT))) /* * pseudo functions for standard screen */ #define addch(ch) waddch(stdscr,(ch)) #define addchnstr(str,n) waddchnstr(stdscr,(str),(n)) #define addchstr(str) waddchstr(stdscr,(str)) #define addnstr(str,n) waddnstr(stdscr,(str),(n)) #define addstr(str) waddnstr(stdscr,(str),-1) #define attr_get(ap,cp,o) wattr_get(stdscr,(ap),(cp),(o)) #define attr_off(a,o) wattr_off(stdscr,(a),(o)) #define attr_on(a,o) wattr_on(stdscr,(a),(o)) #define attr_set(a,c,o) wattr_set(stdscr,(a),(c),(o)) #define attroff(at) wattroff(stdscr,(at)) #define attron(at) wattron(stdscr,(at)) #define attrset(at) wattrset(stdscr,(at)) #define bkgd(ch) wbkgd(stdscr,(ch)) #define bkgdset(ch) wbkgdset(stdscr,(ch)) #define chgat(n,a,c,o) wchgat(stdscr,(n),(a),(c),(o)) #define clear() wclear(stdscr) #define clrtobot() wclrtobot(stdscr) #define clrtoeol() wclrtoeol(stdscr) #define color_set(c,o) wcolor_set(stdscr,(c),(o)) #define delch() wdelch(stdscr) #define deleteln() winsdelln(stdscr,-1) #define echochar(c) wechochar(stdscr,(c)) #define erase() werase(stdscr) #define getch() wgetch(stdscr) #define getstr(str) wgetstr(stdscr,(str)) #define inch() winch(stdscr) #define inchnstr(s,n) winchnstr(stdscr,(s),(n)) #define inchstr(s) winchstr(stdscr,(s)) #define innstr(s,n) winnstr(stdscr,(s),(n)) #define insch(c) winsch(stdscr,(c)) #define insdelln(n) winsdelln(stdscr,(n)) #define insertln() winsdelln(stdscr,1) #define insnstr(s,n) winsnstr(stdscr,(s),(n)) #define insstr(s) winsstr(stdscr,(s)) #define instr(s) winstr(stdscr,(s)) #define move(y,x) wmove(stdscr,(y),(x)) #define refresh() wrefresh(stdscr) #define scrl(n) wscrl(stdscr,(n)) #define setscrreg(t,b) wsetscrreg(stdscr,(t),(b)) #define standend() wstandend(stdscr) #define standout() wstandout(stdscr) #define timeout(delay) wtimeout(stdscr,(delay)) #define wdeleteln(win) winsdelln(win,-1) #define winsertln(win) winsdelln(win,1) /* * mv functions */ #define mvwaddch(win,y,x,ch) (wmove((win),(y),(x)) == ERR ? ERR : waddch((win),(ch))) #define mvwaddchnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),(n))) #define mvwaddchstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),-1)) #define mvwaddnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),(n))) #define mvwaddstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),-1)) #define mvwchgat(win,y,x,n,a,c,o) (wmove((win),(y),(x)) == ERR ? ERR : wchgat((win),(n),(a),(c),(o))) #define mvwdelch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wdelch(win)) #define mvwgetch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wgetch(win)) #define mvwgetnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : wgetnstr((win),(str),(n))) #define mvwgetstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : wgetstr((win),(str))) #define mvwhline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : whline((win),(c),(n))) #define mvwinch(win,y,x) (wmove((win),(y),(x)) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win)) #define mvwinchnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winchnstr((win),(s),(n))) #define mvwinchstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winchstr((win),(s))) #define mvwinnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winnstr((win),(s),(n))) #define mvwinsch(win,y,x,c) (wmove((win),(y),(x)) == ERR ? ERR : winsch((win),(c))) #define mvwinsnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winsnstr((win),(s),(n))) #define mvwinsstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winsstr((win),(s))) #define mvwinstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winstr((win),(s))) #define mvwvline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : wvline((win),(c),(n))) #define mvaddch(y,x,ch) mvwaddch(stdscr,(y),(x),(ch)) #define mvaddchnstr(y,x,str,n) mvwaddchnstr(stdscr,(y),(x),(str),(n)) #define mvaddchstr(y,x,str) mvwaddchstr(stdscr,(y),(x),(str)) #define mvaddnstr(y,x,str,n) mvwaddnstr(stdscr,(y),(x),(str),(n)) #define mvaddstr(y,x,str) mvwaddstr(stdscr,(y),(x),(str)) #define mvchgat(y,x,n,a,c,o) mvwchgat(stdscr,(y),(x),(n),(a),(c),(o)) #define mvdelch(y,x) mvwdelch(stdscr,(y),(x)) #define mvgetch(y,x) mvwgetch(stdscr,(y),(x)) #define mvgetnstr(y,x,str,n) mvwgetnstr(stdscr,(y),(x),(str),(n)) #define mvgetstr(y,x,str) mvwgetstr(stdscr,(y),(x),(str)) #define mvhline(y,x,c,n) mvwhline(stdscr,(y),(x),(c),(n)) #define mvinch(y,x) mvwinch(stdscr,(y),(x)) #define mvinchnstr(y,x,s,n) mvwinchnstr(stdscr,(y),(x),(s),(n)) #define mvinchstr(y,x,s) mvwinchstr(stdscr,(y),(x),(s)) #define mvinnstr(y,x,s,n) mvwinnstr(stdscr,(y),(x),(s),(n)) #define mvinsch(y,x,c) mvwinsch(stdscr,(y),(x),(c)) #define mvinsnstr(y,x,s,n) mvwinsnstr(stdscr,(y),(x),(s),(n)) #define mvinsstr(y,x,s) mvwinsstr(stdscr,(y),(x),(s)) #define mvinstr(y,x,s) mvwinstr(stdscr,(y),(x),(s)) #define mvvline(y,x,c,n) mvwvline(stdscr,(y),(x),(c),(n)) /* * Some wide-character functions can be implemented without the extensions. */ #if !NCURSES_OPAQUE #define getbkgd(win) (NCURSES_OK_ADDR(win) ? ((win)->_bkgd) : 0) #endif /* NCURSES_OPAQUE */ #define slk_attr_off(a,v) ((v) ? ERR : slk_attroff(a)) #define slk_attr_on(a,v) ((v) ? ERR : slk_attron(a)) #if !NCURSES_OPAQUE #if NCURSES_WATTR_MACROS #if NCURSES_WIDECHAR && 1 #define wattr_set(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)((win)->_attrs = ((a) & ~A_COLOR), \ (win)->_color = (opts) ? *(int *)(opts) : (p)), \ OK) \ : ERR) #define wattr_get(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)(NCURSES_OK_ADDR(a) \ ? (*(a) = (win)->_attrs) \ : OK), \ (void)(NCURSES_OK_ADDR(p) \ ? (*(p) = (NCURSES_PAIRS_T) (win)->_color) \ : OK), \ (void)(NCURSES_OK_ADDR(opts) \ ? (*(int *)(opts) = (win)->_color) \ : OK), \ OK) \ : ERR) #else /* !(NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */ #define wattr_set(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)((win)->_attrs = (((a) & ~A_COLOR) | \ (attr_t)COLOR_PAIR(p))), \ OK) \ : ERR) #define wattr_get(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)(NCURSES_OK_ADDR(a) \ ? (*(a) = (win)->_attrs) \ : OK), \ (void)(NCURSES_OK_ADDR(p) \ ? (*(p) = (NCURSES_PAIRS_T) PAIR_NUMBER((win)->_attrs)) \ : OK), \ OK) \ : ERR) #endif /* (NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */ #endif /* NCURSES_WATTR_MACROS */ #endif /* NCURSES_OPAQUE */ /* * X/Open curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use * varargs.h. It adds new calls vw_printw/vw_scanw, which are supposed to * use POSIX stdarg.h. The ncurses versions of vwprintw/vwscanw already * use stdarg.h, so... */ /* define vw_printw vwprintw */ /* define vw_scanw vwscanw */ /* * Export fallback function for use in C++ binding. */ #if !1 #define vsscanf(a,b,c) _nc_vsscanf(a,b,c) NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list); #endif /* * These macros are extensions - not in X/Open Curses. */ #if 1 #if !NCURSES_OPAQUE #define is_cleared(win) (NCURSES_OK_ADDR(win) ? (win)->_clear : FALSE) #define is_idcok(win) (NCURSES_OK_ADDR(win) ? (win)->_idcok : FALSE) #define is_idlok(win) (NCURSES_OK_ADDR(win) ? (win)->_idlok : FALSE) #define is_immedok(win) (NCURSES_OK_ADDR(win) ? (win)->_immed : FALSE) #define is_keypad(win) (NCURSES_OK_ADDR(win) ? (win)->_use_keypad : FALSE) #define is_leaveok(win) (NCURSES_OK_ADDR(win) ? (win)->_leaveok : FALSE) #define is_nodelay(win) (NCURSES_OK_ADDR(win) ? ((win)->_delay == 0) : FALSE) #define is_notimeout(win) (NCURSES_OK_ADDR(win) ? (win)->_notimeout : FALSE) #define is_pad(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _ISPAD) != 0 : FALSE) #define is_scrollok(win) (NCURSES_OK_ADDR(win) ? (win)->_scroll : FALSE) #define is_subwin(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE) #define is_syncok(win) (NCURSES_OK_ADDR(win) ? (win)->_sync : FALSE) #define wgetdelay(win) (NCURSES_OK_ADDR(win) ? (win)->_delay : 0) #define wgetparent(win) (NCURSES_OK_ADDR(win) ? (win)->_parent : 0) #define wgetscrreg(win,t,b) (NCURSES_OK_ADDR(win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR) #endif #endif /* * X/Open says this returns a bool; SVr4 also checked for out-of-range line. * The macro provides compatibility: */ #define is_linetouched(w,l) ((!(w) || ((l) > getmaxy(w)) || ((l) < 0)) ? ERR : (is_linetouched)((w),(l))) #endif /* NCURSES_NOMACROS */ /* * Public variables. * * Notes: * a. ESCDELAY was an undocumented feature under AIX curses. * It gives the ESC expire time in milliseconds. * b. ttytype is needed for backward compatibility */ #if NCURSES_REENTRANT NCURSES_WRAPPED_VAR(WINDOW *, curscr); NCURSES_WRAPPED_VAR(WINDOW *, newscr); NCURSES_WRAPPED_VAR(WINDOW *, stdscr); NCURSES_WRAPPED_VAR(char *, ttytype); NCURSES_WRAPPED_VAR(int, COLORS); NCURSES_WRAPPED_VAR(int, COLOR_PAIRS); NCURSES_WRAPPED_VAR(int, COLS); NCURSES_WRAPPED_VAR(int, ESCDELAY); NCURSES_WRAPPED_VAR(int, LINES); NCURSES_WRAPPED_VAR(int, TABSIZE); #define curscr NCURSES_PUBLIC_VAR(curscr()) #define newscr NCURSES_PUBLIC_VAR(newscr()) #define stdscr NCURSES_PUBLIC_VAR(stdscr()) #define ttytype NCURSES_PUBLIC_VAR(ttytype()) #define COLORS NCURSES_PUBLIC_VAR(COLORS()) #define COLOR_PAIRS NCURSES_PUBLIC_VAR(COLOR_PAIRS()) #define COLS NCURSES_PUBLIC_VAR(COLS()) #define ESCDELAY NCURSES_PUBLIC_VAR(ESCDELAY()) #define LINES NCURSES_PUBLIC_VAR(LINES()) #define TABSIZE NCURSES_PUBLIC_VAR(TABSIZE()) #else extern NCURSES_EXPORT_VAR(WINDOW *) curscr; extern NCURSES_EXPORT_VAR(WINDOW *) newscr; extern NCURSES_EXPORT_VAR(WINDOW *) stdscr; extern NCURSES_EXPORT_VAR(char) ttytype[]; extern NCURSES_EXPORT_VAR(int) COLORS; extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS; extern NCURSES_EXPORT_VAR(int) COLS; extern NCURSES_EXPORT_VAR(int) ESCDELAY; extern NCURSES_EXPORT_VAR(int) LINES; extern NCURSES_EXPORT_VAR(int) TABSIZE; #endif /* * Pseudo-character tokens outside ASCII range. The curses wgetch() function * will return any given one of these only if the corresponding k- capability * is defined in your terminal's terminfo entry. * * Some keys (KEY_A1, etc) are arranged like this: * a1 up a3 * left b2 right * c1 down c3 * * A few key codes do not depend upon the terminfo entry. */ #define KEY_CODE_YES 0400 /* A wchar_t contains a key code */ #define KEY_MIN 0401 /* Minimum curses key */ #define KEY_BREAK 0401 /* Break key (unreliable) */ #define KEY_SRESET 0530 /* Soft (partial) reset (unreliable) */ #define KEY_RESET 0531 /* Reset or hard reset (unreliable) */ /* * These definitions were generated by ./MKkey_defs.sh ../../include/Caps ../../include/Caps-ncurses */ #define KEY_DOWN 0402 /* down-arrow key */ #define KEY_UP 0403 /* up-arrow key */ #define KEY_LEFT 0404 /* left-arrow key */ #define KEY_RIGHT 0405 /* right-arrow key */ #define KEY_HOME 0406 /* home key */ #define KEY_BACKSPACE 0407 /* backspace key */ #define KEY_F0 0410 /* Function keys. Space for 64 */ #define KEY_F(n) (KEY_F0+(n)) /* Value of function key n */ #define KEY_DL 0510 /* delete-line key */ #define KEY_IL 0511 /* insert-line key */ #define KEY_DC 0512 /* delete-character key */ #define KEY_IC 0513 /* insert-character key */ #define KEY_EIC 0514 /* sent by rmir or smir in insert mode */ #define KEY_CLEAR 0515 /* clear-screen or erase key */ #define KEY_EOS 0516 /* clear-to-end-of-screen key */ #define KEY_EOL 0517 /* clear-to-end-of-line key */ #define KEY_SF 0520 /* scroll-forward key */ #define KEY_SR 0521 /* scroll-backward key */ #define KEY_NPAGE 0522 /* next-page key */ #define KEY_PPAGE 0523 /* previous-page key */ #define KEY_STAB 0524 /* set-tab key */ #define KEY_CTAB 0525 /* clear-tab key */ #define KEY_CATAB 0526 /* clear-all-tabs key */ #define KEY_ENTER 0527 /* enter/send key */ #define KEY_PRINT 0532 /* print key */ #define KEY_LL 0533 /* lower-left key (home down) */ #define KEY_A1 0534 /* upper left of keypad */ #define KEY_A3 0535 /* upper right of keypad */ #define KEY_B2 0536 /* center of keypad */ #define KEY_C1 0537 /* lower left of keypad */ #define KEY_C3 0540 /* lower right of keypad */ #define KEY_BTAB 0541 /* back-tab key */ #define KEY_BEG 0542 /* begin key */ #define KEY_CANCEL 0543 /* cancel key */ #define KEY_CLOSE 0544 /* close key */ #define KEY_COMMAND 0545 /* command key */ #define KEY_COPY 0546 /* copy key */ #define KEY_CREATE 0547 /* create key */ #define KEY_END 0550 /* end key */ #define KEY_EXIT 0551 /* exit key */ #define KEY_FIND 0552 /* find key */ #define KEY_HELP 0553 /* help key */ #define KEY_MARK 0554 /* mark key */ #define KEY_MESSAGE 0555 /* message key */ #define KEY_MOVE 0556 /* move key */ #define KEY_NEXT 0557 /* next key */ #define KEY_OPEN 0560 /* open key */ #define KEY_OPTIONS 0561 /* options key */ #define KEY_PREVIOUS 0562 /* previous key */ #define KEY_REDO 0563 /* redo key */ #define KEY_REFERENCE 0564 /* reference key */ #define KEY_REFRESH 0565 /* refresh key */ #define KEY_REPLACE 0566 /* replace key */ #define KEY_RESTART 0567 /* restart key */ #define KEY_RESUME 0570 /* resume key */ #define KEY_SAVE 0571 /* save key */ #define KEY_SBEG 0572 /* shifted begin key */ #define KEY_SCANCEL 0573 /* shifted cancel key */ #define KEY_SCOMMAND 0574 /* shifted command key */ #define KEY_SCOPY 0575 /* shifted copy key */ #define KEY_SCREATE 0576 /* shifted create key */ #define KEY_SDC 0577 /* shifted delete-character key */ #define KEY_SDL 0600 /* shifted delete-line key */ #define KEY_SELECT 0601 /* select key */ #define KEY_SEND 0602 /* shifted end key */ #define KEY_SEOL 0603 /* shifted clear-to-end-of-line key */ #define KEY_SEXIT 0604 /* shifted exit key */ #define KEY_SFIND 0605 /* shifted find key */ #define KEY_SHELP 0606 /* shifted help key */ #define KEY_SHOME 0607 /* shifted home key */ #define KEY_SIC 0610 /* shifted insert-character key */ #define KEY_SLEFT 0611 /* shifted left-arrow key */ #define KEY_SMESSAGE 0612 /* shifted message key */ #define KEY_SMOVE 0613 /* shifted move key */ #define KEY_SNEXT 0614 /* shifted next key */ #define KEY_SOPTIONS 0615 /* shifted options key */ #define KEY_SPREVIOUS 0616 /* shifted previous key */ #define KEY_SPRINT 0617 /* shifted print key */ #define KEY_SREDO 0620 /* shifted redo key */ #define KEY_SREPLACE 0621 /* shifted replace key */ #define KEY_SRIGHT 0622 /* shifted right-arrow key */ #define KEY_SRSUME 0623 /* shifted resume key */ #define KEY_SSAVE 0624 /* shifted save key */ #define KEY_SSUSPEND 0625 /* shifted suspend key */ #define KEY_SUNDO 0626 /* shifted undo key */ #define KEY_SUSPEND 0627 /* suspend key */ #define KEY_UNDO 0630 /* undo key */ #define KEY_MOUSE 0631 /* Mouse event has occurred */ #ifdef NCURSES_EXT_FUNCS #define KEY_RESIZE 0632 /* Terminal resize event */ #endif #define KEY_MAX 0777 /* Maximum key value is 0632 */ /* $Id: curses.wide,v 1.50 2017/03/26 16:05:21 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in * (see that file for the relevant copyright). */ #define _XOPEN_CURSES 1 #if NCURSES_WIDECHAR extern NCURSES_EXPORT_VAR(cchar_t *) _nc_wacs; #define NCURSES_WACS(c) (&_nc_wacs[NCURSES_CAST(unsigned char,(c))]) #define WACS_BSSB NCURSES_WACS('l') #define WACS_SSBB NCURSES_WACS('m') #define WACS_BBSS NCURSES_WACS('k') #define WACS_SBBS NCURSES_WACS('j') #define WACS_SBSS NCURSES_WACS('u') #define WACS_SSSB NCURSES_WACS('t') #define WACS_SSBS NCURSES_WACS('v') #define WACS_BSSS NCURSES_WACS('w') #define WACS_BSBS NCURSES_WACS('q') #define WACS_SBSB NCURSES_WACS('x') #define WACS_SSSS NCURSES_WACS('n') #define WACS_ULCORNER WACS_BSSB #define WACS_LLCORNER WACS_SSBB #define WACS_URCORNER WACS_BBSS #define WACS_LRCORNER WACS_SBBS #define WACS_RTEE WACS_SBSS #define WACS_LTEE WACS_SSSB #define WACS_BTEE WACS_SSBS #define WACS_TTEE WACS_BSSS #define WACS_HLINE WACS_BSBS #define WACS_VLINE WACS_SBSB #define WACS_PLUS WACS_SSSS #define WACS_S1 NCURSES_WACS('o') /* scan line 1 */ #define WACS_S9 NCURSES_WACS('s') /* scan line 9 */ #define WACS_DIAMOND NCURSES_WACS('`') /* diamond */ #define WACS_CKBOARD NCURSES_WACS('a') /* checker board */ #define WACS_DEGREE NCURSES_WACS('f') /* degree symbol */ #define WACS_PLMINUS NCURSES_WACS('g') /* plus/minus */ #define WACS_BULLET NCURSES_WACS('~') /* bullet */ /* Teletype 5410v1 symbols */ #define WACS_LARROW NCURSES_WACS(',') /* arrow left */ #define WACS_RARROW NCURSES_WACS('+') /* arrow right */ #define WACS_DARROW NCURSES_WACS('.') /* arrow down */ #define WACS_UARROW NCURSES_WACS('-') /* arrow up */ #define WACS_BOARD NCURSES_WACS('h') /* board of squares */ #define WACS_LANTERN NCURSES_WACS('i') /* lantern symbol */ #define WACS_BLOCK NCURSES_WACS('0') /* solid square block */ /* ncurses extensions */ #define WACS_S3 NCURSES_WACS('p') /* scan line 3 */ #define WACS_S7 NCURSES_WACS('r') /* scan line 7 */ #define WACS_LEQUAL NCURSES_WACS('y') /* less/equal */ #define WACS_GEQUAL NCURSES_WACS('z') /* greater/equal */ #define WACS_PI NCURSES_WACS('{') /* Pi */ #define WACS_NEQUAL NCURSES_WACS('|') /* not equal */ #define WACS_STERLING NCURSES_WACS('}') /* UK pound sign */ /* double lines */ #define WACS_BDDB NCURSES_WACS('C') #define WACS_DDBB NCURSES_WACS('D') #define WACS_BBDD NCURSES_WACS('B') #define WACS_DBBD NCURSES_WACS('A') #define WACS_DBDD NCURSES_WACS('G') #define WACS_DDDB NCURSES_WACS('F') #define WACS_DDBD NCURSES_WACS('H') #define WACS_BDDD NCURSES_WACS('I') #define WACS_BDBD NCURSES_WACS('R') #define WACS_DBDB NCURSES_WACS('Y') #define WACS_DDDD NCURSES_WACS('E') #define WACS_D_ULCORNER WACS_BDDB #define WACS_D_LLCORNER WACS_DDBB #define WACS_D_URCORNER WACS_BBDD #define WACS_D_LRCORNER WACS_DBBD #define WACS_D_RTEE WACS_DBDD #define WACS_D_LTEE WACS_DDDB #define WACS_D_BTEE WACS_DDBD #define WACS_D_TTEE WACS_BDDD #define WACS_D_HLINE WACS_BDBD #define WACS_D_VLINE WACS_DBDB #define WACS_D_PLUS WACS_DDDD /* thick lines */ #define WACS_BTTB NCURSES_WACS('L') #define WACS_TTBB NCURSES_WACS('M') #define WACS_BBTT NCURSES_WACS('K') #define WACS_TBBT NCURSES_WACS('J') #define WACS_TBTT NCURSES_WACS('U') #define WACS_TTTB NCURSES_WACS('T') #define WACS_TTBT NCURSES_WACS('V') #define WACS_BTTT NCURSES_WACS('W') #define WACS_BTBT NCURSES_WACS('Q') #define WACS_TBTB NCURSES_WACS('X') #define WACS_TTTT NCURSES_WACS('N') #define WACS_T_ULCORNER WACS_BTTB #define WACS_T_LLCORNER WACS_TTBB #define WACS_T_URCORNER WACS_BBTT #define WACS_T_LRCORNER WACS_TBBT #define WACS_T_RTEE WACS_TBTT #define WACS_T_LTEE WACS_TTTB #define WACS_T_BTEE WACS_TTBT #define WACS_T_TTEE WACS_BTTT #define WACS_T_HLINE WACS_BTBT #define WACS_T_VLINE WACS_TBTB #define WACS_T_PLUS WACS_TTTT /* * Function prototypes for wide-character operations. * * "generated" comments should include ":WIDEC" to make the corresponding * functions ifdef'd in lib_gen.c * * "implemented" comments do not need this marker. */ extern NCURSES_EXPORT(int) add_wch (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) add_wchnstr (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) add_wchstr (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) addnwstr (const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) addwstr (const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) bkgrnd (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(void) bkgrndset (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) border_set (const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* generated:WIDEC */ extern NCURSES_EXPORT(int) box_set (WINDOW *, const cchar_t *, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) echo_wchar (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) erasewchar (wchar_t*); /* implemented */ extern NCURSES_EXPORT(int) get_wch (wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) get_wstr (wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) getbkgrnd (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) getcchar (const cchar_t *, wchar_t*, attr_t*, NCURSES_PAIRS_T*, void*); /* implemented */ extern NCURSES_EXPORT(int) getn_wstr (wint_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) hline_set (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wch (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wchnstr (cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wchstr (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) innwstr (wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_nwstr (const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_wch (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_wstr (const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) inwstr (wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(NCURSES_CONST char*) key_name (wchar_t); /* implemented */ extern NCURSES_EXPORT(int) killwchar (wchar_t *); /* implemented */ extern NCURSES_EXPORT(int) mvadd_wch (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvadd_wchnstr (int, int, const cchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvadd_wchstr (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvaddnwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvaddwstr (int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvget_wch (int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvget_wstr (int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvgetn_wstr (int, int, wint_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvhline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wch (int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wchnstr (int, int, cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wchstr (int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvinnwstr (int, int, wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_nwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_wch (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_wstr (int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvinwstr (int, int, wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvvline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wchnstr (WINDOW *, int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wchstr (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwaddnwstr (WINDOW *, int, int, const wchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwaddwstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwget_wch (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwget_wstr (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwgetn_wstr (WINDOW *, int, int, wint_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwhline_set (WINDOW *, int, int, const cchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wch (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wchnstr (WINDOW *, int,int, cchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wchstr (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwinnwstr (WINDOW *, int, int, wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_nwstr (WINDOW *, int,int, const wchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_wstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwinwstr (WINDOW *, int, int, wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwvline_set (WINDOW *, int,int, const cchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) pecho_wchar (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) setcchar (cchar_t *, const wchar_t *, const attr_t, NCURSES_PAIRS_T, const void *); /* implemented */ extern NCURSES_EXPORT(int) slk_wset (int, const wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(attr_t) term_attrs (void); /* implemented */ extern NCURSES_EXPORT(int) unget_wch (const wchar_t); /* implemented */ extern NCURSES_EXPORT(int) vid_attr (attr_t, NCURSES_PAIRS_T, void *); /* implemented */ extern NCURSES_EXPORT(int) vid_puts (attr_t, NCURSES_PAIRS_T, void *, NCURSES_OUTC); /* implemented */ extern NCURSES_EXPORT(int) vline_set (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wadd_wch (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wadd_wchnstr (WINDOW *,const cchar_t *,int); /* implemented */ extern NCURSES_EXPORT(int) wadd_wchstr (WINDOW *,const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) waddnwstr (WINDOW *,const wchar_t *,int); /* implemented */ extern NCURSES_EXPORT(int) waddwstr (WINDOW *,const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wbkgrnd (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(void) wbkgrndset (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wborder_set (WINDOW *,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* implemented */ extern NCURSES_EXPORT(int) wecho_wchar (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wget_wch (WINDOW *, wint_t *); /* implemented */ extern NCURSES_EXPORT(int) wget_wstr (WINDOW *, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wgetbkgrnd (WINDOW *, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wgetn_wstr (WINDOW *, wint_t *, int); /* implemented */ extern NCURSES_EXPORT(int) whline_set (WINDOW *, const cchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) win_wch (WINDOW *, cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) win_wchnstr (WINDOW *, cchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) win_wchstr (WINDOW *, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) winnwstr (WINDOW *, wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) wins_nwstr (WINDOW *, const wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) wins_wch (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wins_wstr (WINDOW *, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) winwstr (WINDOW *, wchar_t *); /* implemented */ extern NCURSES_EXPORT(wchar_t*) wunctrl (cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wvline_set (WINDOW *, const cchar_t *, int); /* implemented */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(term_attrs) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(unget_wch) (SCREEN*, const wchar_t); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_attr) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ #endif #ifndef NCURSES_NOMACROS /* * XSI curses macros for XPG4 conformance. */ #define add_wch(c) wadd_wch(stdscr,(c)) #define add_wchnstr(str,n) wadd_wchnstr(stdscr,(str),(n)) #define add_wchstr(str) wadd_wchstr(stdscr,(str)) #define addnwstr(wstr,n) waddnwstr(stdscr,(wstr),(n)) #define addwstr(wstr) waddwstr(stdscr,(wstr)) #define bkgrnd(c) wbkgrnd(stdscr,(c)) #define bkgrndset(c) wbkgrndset(stdscr,(c)) #define border_set(l,r,t,b,tl,tr,bl,br) wborder_set(stdscr,(l),(r),(t),(b),tl,tr,bl,br) #define box_set(w,v,h) wborder_set((w),(v),(v),(h),(h),0,0,0,0) #define echo_wchar(c) wecho_wchar(stdscr,(c)) #define get_wch(c) wget_wch(stdscr,(c)) #define get_wstr(t) wget_wstr(stdscr,(t)) #define getbkgrnd(wch) wgetbkgrnd(stdscr,(wch)) #define getn_wstr(t,n) wgetn_wstr(stdscr,(t),(n)) #define hline_set(c,n) whline_set(stdscr,(c),(n)) #define in_wch(c) win_wch(stdscr,(c)) #define in_wchnstr(c,n) win_wchnstr(stdscr,(c),(n)) #define in_wchstr(c) win_wchstr(stdscr,(c)) #define innwstr(c,n) winnwstr(stdscr,(c),(n)) #define ins_nwstr(t,n) wins_nwstr(stdscr,(t),(n)) #define ins_wch(c) wins_wch(stdscr,(c)) #define ins_wstr(t) wins_wstr(stdscr,(t)) #define inwstr(c) winwstr(stdscr,(c)) #define vline_set(c,n) wvline_set(stdscr,(c),(n)) #define wadd_wchstr(win,str) wadd_wchnstr((win),(str),-1) #define waddwstr(win,wstr) waddnwstr((win),(wstr),-1) #define wget_wstr(w,t) wgetn_wstr((w),(t),-1) #define win_wchstr(w,c) win_wchnstr((w),(c),-1) #define wins_wstr(w,t) wins_nwstr((w),(t),-1) #if !NCURSES_OPAQUE #define wgetbkgrnd(win,wch) (NCURSES_OK_ADDR(wch) ? ((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK) : ERR) #endif #define mvadd_wch(y,x,c) mvwadd_wch(stdscr,(y),(x),(c)) #define mvadd_wchnstr(y,x,s,n) mvwadd_wchnstr(stdscr,(y),(x),(s),(n)) #define mvadd_wchstr(y,x,s) mvwadd_wchstr(stdscr,(y),(x),(s)) #define mvaddnwstr(y,x,wstr,n) mvwaddnwstr(stdscr,(y),(x),(wstr),(n)) #define mvaddwstr(y,x,wstr) mvwaddwstr(stdscr,(y),(x),(wstr)) #define mvget_wch(y,x,c) mvwget_wch(stdscr,(y),(x),(c)) #define mvget_wstr(y,x,t) mvwget_wstr(stdscr,(y),(x),(t)) #define mvgetn_wstr(y,x,t,n) mvwgetn_wstr(stdscr,(y),(x),(t),(n)) #define mvhline_set(y,x,c,n) mvwhline_set(stdscr,(y),(x),(c),(n)) #define mvin_wch(y,x,c) mvwin_wch(stdscr,(y),(x),(c)) #define mvin_wchnstr(y,x,c,n) mvwin_wchnstr(stdscr,(y),(x),(c),(n)) #define mvin_wchstr(y,x,c) mvwin_wchstr(stdscr,(y),(x),(c)) #define mvinnwstr(y,x,c,n) mvwinnwstr(stdscr,(y),(x),(c),(n)) #define mvins_nwstr(y,x,t,n) mvwins_nwstr(stdscr,(y),(x),(t),(n)) #define mvins_wch(y,x,c) mvwins_wch(stdscr,(y),(x),(c)) #define mvins_wstr(y,x,t) mvwins_wstr(stdscr,(y),(x),(t)) #define mvinwstr(y,x,c) mvwinwstr(stdscr,(y),(x),(c)) #define mvvline_set(y,x,c,n) mvwvline_set(stdscr,(y),(x),(c),(n)) #define mvwadd_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wch((win),(c))) #define mvwadd_wchnstr(win,y,x,s,n) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchnstr((win),(s),(n))) #define mvwadd_wchstr(win,y,x,s) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchstr((win),(s))) #define mvwaddnwstr(win,y,x,wstr,n) (wmove(win,(y),(x)) == ERR ? ERR : waddnwstr((win),(wstr),(n))) #define mvwaddwstr(win,y,x,wstr) (wmove(win,(y),(x)) == ERR ? ERR : waddwstr((win),(wstr))) #define mvwget_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wget_wch((win),(c))) #define mvwget_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wget_wstr((win),(t))) #define mvwgetn_wstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wgetn_wstr((win),(t),(n))) #define mvwhline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : whline_set((win),(c),(n))) #define mvwin_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wch((win),(c))) #define mvwin_wchnstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : win_wchnstr((win),(c),(n))) #define mvwin_wchstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wchstr((win),(c))) #define mvwinnwstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : winnwstr((win),(c),(n))) #define mvwins_nwstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wins_nwstr((win),(t),(n))) #define mvwins_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wins_wch((win),(c))) #define mvwins_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wins_wstr((win),(t))) #define mvwinwstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : winwstr((win),(c))) #define mvwvline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : wvline_set((win),(c),(n))) #endif /* NCURSES_NOMACROS */ #if defined(TRACE) || defined(NCURSES_TEST) extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *); extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *); #endif #endif /* NCURSES_WIDECHAR */ /* $Id: curses.tail,v 1.26 2021/03/20 15:49:25 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in * (see that file for the relevant copyright). */ /* mouse interface */ #if NCURSES_MOUSE_VERSION > 1 #define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5)) #else #define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6)) #endif #define NCURSES_BUTTON_RELEASED 001L #define NCURSES_BUTTON_PRESSED 002L #define NCURSES_BUTTON_CLICKED 004L #define NCURSES_DOUBLE_CLICKED 010L #define NCURSES_TRIPLE_CLICKED 020L #define NCURSES_RESERVED_EVENT 040L /* event masks */ #define BUTTON1_RELEASED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED) #define BUTTON1_PRESSED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED) #define BUTTON1_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED) #define BUTTON1_DOUBLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED) #define BUTTON1_TRIPLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED) #define BUTTON2_RELEASED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED) #define BUTTON2_PRESSED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED) #define BUTTON2_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED) #define BUTTON2_DOUBLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED) #define BUTTON2_TRIPLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED) #define BUTTON3_RELEASED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED) #define BUTTON3_PRESSED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED) #define BUTTON3_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED) #define BUTTON3_DOUBLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED) #define BUTTON3_TRIPLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED) #define BUTTON4_RELEASED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED) #define BUTTON4_PRESSED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED) #define BUTTON4_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED) #define BUTTON4_DOUBLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED) #define BUTTON4_TRIPLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED) /* * In 32 bits the version-1 scheme does not provide enough space for a 5th * button, unless we choose to change the ABI by omitting the reserved-events. */ #if NCURSES_MOUSE_VERSION > 1 #define BUTTON5_RELEASED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED) #define BUTTON5_PRESSED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED) #define BUTTON5_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED) #define BUTTON5_DOUBLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED) #define BUTTON5_TRIPLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED) #define BUTTON_CTRL NCURSES_MOUSE_MASK(6, 0001L) #define BUTTON_SHIFT NCURSES_MOUSE_MASK(6, 0002L) #define BUTTON_ALT NCURSES_MOUSE_MASK(6, 0004L) #define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(6, 0010L) #else #define BUTTON1_RESERVED_EVENT NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT) #define BUTTON2_RESERVED_EVENT NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT) #define BUTTON3_RESERVED_EVENT NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT) #define BUTTON4_RESERVED_EVENT NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT) #define BUTTON_CTRL NCURSES_MOUSE_MASK(5, 0001L) #define BUTTON_SHIFT NCURSES_MOUSE_MASK(5, 0002L) #define BUTTON_ALT NCURSES_MOUSE_MASK(5, 0004L) #define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(5, 0010L) #endif #define ALL_MOUSE_EVENTS (REPORT_MOUSE_POSITION - 1) /* macros to extract single event-bits from masks */ #define BUTTON_RELEASE(e, x) ((e) & NCURSES_MOUSE_MASK(x, 001)) #define BUTTON_PRESS(e, x) ((e) & NCURSES_MOUSE_MASK(x, 002)) #define BUTTON_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 004)) #define BUTTON_DOUBLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 010)) #define BUTTON_TRIPLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 020)) #define BUTTON_RESERVED_EVENT(e, x) ((e) & NCURSES_MOUSE_MASK(x, 040)) typedef struct { short id; /* ID to distinguish multiple devices */ int x, y, z; /* event coordinates (character-cell) */ mmask_t bstate; /* button state bits */ } MEVENT; extern NCURSES_EXPORT(bool) has_mouse(void); extern NCURSES_EXPORT(int) getmouse (MEVENT *); extern NCURSES_EXPORT(int) ungetmouse (MEVENT *); extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *); extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int); extern NCURSES_EXPORT(int) mouseinterval (int); extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool); extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* generated */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_mouse) (SCREEN*); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *); extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, mmask_t *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mouseinterval) (SCREEN*, int); #endif #ifndef NCURSES_NOMACROS #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen) #endif /* other non-XSI functions */ extern NCURSES_EXPORT(int) mcprint (char *, int); /* direct data to printer */ extern NCURSES_EXPORT(int) has_key (int); /* do we have given key? */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (SCREEN*, int); /* do we have given key? */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mcprint) (SCREEN*, char *, int); /* direct data to printer */ #endif /* Debugging : use with libncurses_g.a */ extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(char *) _traceattr (attr_t); extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype); extern NCURSES_EXPORT(char *) _tracechar (int); extern NCURSES_EXPORT(char *) _tracechtype (chtype); extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype); #if NCURSES_WIDECHAR #define _tracech_t _tracecchar_t extern NCURSES_EXPORT(char *) _tracecchar_t (const cchar_t *); #define _tracech_t2 _tracecchar_t2 extern NCURSES_EXPORT(char *) _tracecchar_t2 (int, const cchar_t *); #else #define _tracech_t _tracechtype #define _tracech_t2 _tracechtype2 #endif extern NCURSES_EXPORT(void) trace (const unsigned) GCC_DEPRECATED("use curses_trace"); extern NCURSES_EXPORT(unsigned) curses_trace (const unsigned); /* trace masks */ #define TRACE_DISABLE 0x0000 /* turn off tracing */ #define TRACE_TIMES 0x0001 /* trace user and system times of updates */ #define TRACE_TPUTS 0x0002 /* trace tputs calls */ #define TRACE_UPDATE 0x0004 /* trace update actions, old & new screens */ #define TRACE_MOVE 0x0008 /* trace cursor moves and scrolls */ #define TRACE_CHARPUT 0x0010 /* trace all character outputs */ #define TRACE_ORDINARY 0x001F /* trace all update actions */ #define TRACE_CALLS 0x0020 /* trace all curses calls */ #define TRACE_VIRTPUT 0x0040 /* trace virtual character puts */ #define TRACE_IEVENT 0x0080 /* trace low-level input processing */ #define TRACE_BITS 0x0100 /* trace state of TTY control bits */ #define TRACE_ICALLS 0x0200 /* trace internal/nested calls */ #define TRACE_CCALLS 0x0400 /* trace per-character calls */ #define TRACE_DATABASE 0x0800 /* trace read/write of terminfo/termcap data */ #define TRACE_ATTRS 0x1000 /* trace attribute updates */ #define TRACE_SHIFT 13 /* number of bits in the trace masks */ #define TRACE_MAXIMUM ((1 << TRACE_SHIFT) - 1) /* maximum trace level */ #if defined(TRACE) || defined(NCURSES_TEST) extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable; /* enable optimizations */ extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *); #define OPTIMIZE_MVCUR 0x01 /* cursor movement optimization */ #define OPTIMIZE_HASHMAP 0x02 /* diff hashing to detect scrolls */ #define OPTIMIZE_SCROLL 0x04 /* scroll optimization */ #define OPTIMIZE_ALL 0xff /* enable all optimizations (dflt) */ #endif extern GCC_NORETURN NCURSES_EXPORT(void) exit_curses (int); #include <unctrl.h> #ifdef __cplusplus #ifndef NCURSES_NOMACROS /* these names conflict with STL */ #undef box #undef clear #undef erase #undef move #undef refresh #endif /* NCURSES_NOMACROS */ } #endif #endif /* __NCURSES_H */ // * This makes emacs happy -*-Mode: C++;-*- /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ // $Id: etip.h.in,v 1.46 2021/04/17 17:59:57 tom Exp $ #ifndef NCURSES_ETIP_H_incl #define NCURSES_ETIP_H_incl 1 // These are substituted at configure/build time #ifndef HAVE_BUILTIN_H #define HAVE_BUILTIN_H 0 #endif #ifndef HAVE_GXX_BUILTIN_H #define HAVE_GXX_BUILTIN_H 0 #endif #ifndef HAVE_GPP_BUILTIN_H #define HAVE_GPP_BUILTIN_H 0 #endif #ifndef HAVE_IOSTREAM #define HAVE_IOSTREAM 1 #endif #ifndef HAVE_TYPEINFO #define HAVE_TYPEINFO 1 #endif #ifndef HAVE_VALUES_H #define HAVE_VALUES_H 0 #endif #ifndef ETIP_NEEDS_MATH_H #define ETIP_NEEDS_MATH_H 0 #endif #ifndef ETIP_NEEDS_MATH_EXCEPTION #define ETIP_NEEDS_MATH_EXCEPTION 0 #endif #ifndef CPP_HAS_PARAM_INIT #define CPP_HAS_PARAM_INIT 0 #endif #ifndef CPP_HAS_STATIC_CAST #define CPP_HAS_STATIC_CAST 1 #endif #ifndef IOSTREAM_NAMESPACE #define IOSTREAM_NAMESPACE 1 #endif #ifdef __GNUG__ # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8)) # if HAVE_TYPEINFO # include <typeinfo> # endif # endif #endif #if defined(__GNUG__) # if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H # if ETIP_NEEDS_MATH_H # if ETIP_NEEDS_MATH_EXCEPTION # undef exception # define exception math_exception # endif # include <math.h> # endif # undef exception # define exception builtin_exception # if HAVE_GPP_BUILTIN_H # include <gpp/builtin.h> # elif HAVE_GXX_BUILTIN_H # include <g++/builtin.h> # else # include <builtin.h> # endif # undef exception # endif #elif defined (__SUNPRO_CC) # include <generic.h> #endif #include <curses.h> extern "C" { #if HAVE_VALUES_H # include <values.h> #endif #include <assert.h> #include <eti.h> #include <errno.h> } // Language features #if CPP_HAS_PARAM_INIT #define NCURSES_PARAM_INIT(value) = value #else #define NCURSES_PARAM_INIT(value) /*nothing*/ #endif #if CPP_HAS_STATIC_CAST #define STATIC_CAST(s) static_cast<s> #else #define STATIC_CAST(s) (s) #endif // Forward Declarations class NCURSES_CXX_IMPEXP NCursesPanel; class NCURSES_CXX_IMPEXP NCursesMenu; class NCURSES_CXX_IMPEXP NCursesForm; class NCURSES_CXX_IMPEXP NCursesException { public: const char *message; int errorno; NCursesException (const char* msg, int err) : message(msg), errorno (err) {}; explicit NCursesException (const char* msg) : message(msg), errorno (E_SYSTEM_ERROR) {}; NCursesException& operator=(const NCursesException& rhs) { message = rhs.message; errorno = rhs.errorno; return *this; } NCursesException(const NCursesException& rhs) : message(rhs.message), errorno(rhs.errorno) { } virtual const char *classname() const { return "NCursesWindow"; } virtual ~NCursesException() { } }; class NCURSES_CXX_IMPEXP NCursesPanelException : public NCursesException { public: const NCursesPanel* p; NCursesPanelException (const char *msg, int err) : NCursesException (msg, err), p (0) {}; NCursesPanelException (const NCursesPanel* panel, const char *msg, int err) : NCursesException (msg, err), p (panel) {}; explicit NCursesPanelException (int err) : NCursesException ("panel library error", err), p (0) {}; NCursesPanelException (const NCursesPanel* panel, int err) : NCursesException ("panel library error", err), p (panel) {}; NCursesPanelException& operator=(const NCursesPanelException& rhs) { if (this != &rhs) { NCursesException::operator=(rhs); p = rhs.p; } return *this; } NCursesPanelException(const NCursesPanelException& rhs) : NCursesException(rhs), p(rhs.p) { } virtual const char *classname() const { return "NCursesPanel"; } virtual ~NCursesPanelException() { } }; class NCURSES_CXX_IMPEXP NCursesMenuException : public NCursesException { public: const NCursesMenu* m; NCursesMenuException (const char *msg, int err) : NCursesException (msg, err), m (0) {}; NCursesMenuException (const NCursesMenu* menu, const char *msg, int err) : NCursesException (msg, err), m (menu) {}; explicit NCursesMenuException (int err) : NCursesException ("menu library error", err), m (0) {}; NCursesMenuException (const NCursesMenu* menu, int err) : NCursesException ("menu library error", err), m (menu) {}; NCursesMenuException& operator=(const NCursesMenuException& rhs) { if (this != &rhs) { NCursesException::operator=(rhs); m = rhs.m; } return *this; } NCursesMenuException(const NCursesMenuException& rhs) : NCursesException(rhs), m(rhs.m) { } virtual const char *classname() const { return "NCursesMenu"; } virtual ~NCursesMenuException() { } }; class NCURSES_CXX_IMPEXP NCursesFormException : public NCursesException { public: const NCursesForm* f; NCursesFormException (const char *msg, int err) : NCursesException (msg, err), f (0) {}; NCursesFormException (const NCursesForm* form, const char *msg, int err) : NCursesException (msg, err), f (form) {}; explicit NCursesFormException (int err) : NCursesException ("form library error", err), f (0) {}; NCursesFormException (const NCursesForm* form, int err) : NCursesException ("form library error", err), f (form) {}; NCursesFormException& operator=(const NCursesFormException& rhs) { if (this != &rhs) { NCursesException::operator=(rhs); f = rhs.f; } return *this; } NCursesFormException(const NCursesFormException& rhs) : NCursesException(rhs), f(rhs.f) { } virtual const char *classname() const { return "NCursesForm"; } virtual ~NCursesFormException() { } }; #if !((defined(__GNUG__) && defined(__EXCEPTIONS) && (__GNUG__ < 7)) || defined(__SUNPRO_CC)) # if HAVE_IOSTREAM # include <iostream> # if IOSTREAM_NAMESPACE using std::cerr; using std::endl; # endif # else # include <iostream.h> # endif #endif inline void THROW(const NCursesException *e) { #if defined(__GNUG__) && defined(__EXCEPTIONS) # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8)) (*lib_error_handler)(e ? e->classname() : "", e ? e->message : ""); # elif (__GNUG__ >= 7) // g++ 7.0 warns about deprecation, but lacks the predefined symbols ::endwin(); std::cerr << "Found a problem - goodbye" << std::endl; exit(EXIT_FAILURE); # else # define CPP_HAS_TRY_CATCH 1 # endif #elif defined(__SUNPRO_CC) # if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5) genericerror(1, ((e != 0) ? (char *)(e->message) : "")); # else # define CPP_HAS_TRY_CATCH 1 # endif #else if (e) cerr << e->message << endl; exit(0); #endif #ifndef CPP_HAS_TRY_CATCH #define CPP_HAS_TRY_CATCH 0 #define NCURSES_CPP_TRY /* nothing */ #define NCURSES_CPP_CATCH(e) if (false) #define THROWS(s) /* nothing */ #define THROW2(s,t) /* nothing */ #elif CPP_HAS_TRY_CATCH throw *e; #define NCURSES_CPP_TRY try #define NCURSES_CPP_CATCH(e) catch(e) #if defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510) // C++17 deprecates the usage of throw(). #define THROWS(s) /* nothing */ #define THROW2(s,t) /* nothing */ #else #define THROWS(s) throw(s) #define THROW2(s,t) throw(s,t) #endif #endif } #endif /* NCURSES_ETIP_H_incl */ /**************************************************************************** * Copyright 2020 Thomas E. Dickey * * Copyright 1998-2002,2003 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1995,1997 * ****************************************************************************/ /* $Id: eti.h,v 1.9 2020/02/02 23:34:34 tom Exp $ */ #ifndef NCURSES_ETI_H_incl #define NCURSES_ETI_H_incl 1 #define E_OK (0) #define E_SYSTEM_ERROR (-1) #define E_BAD_ARGUMENT (-2) #define E_POSTED (-3) #define E_CONNECTED (-4) #define E_BAD_STATE (-5) #define E_NO_ROOM (-6) #define E_NOT_POSTED (-7) #define E_UNKNOWN_COMMAND (-8) #define E_NO_MATCH (-9) #define E_NOT_SELECTABLE (-10) #define E_NOT_CONNECTED (-11) #define E_REQUEST_DENIED (-12) #define E_INVALID_FIELD (-13) #define E_CURRENT (-14) #endif // * this is for making emacs happy: -*-Mode: C++;-*- // vile:cppmode /**************************************************************************** * Copyright 2019-2020,2021 Thomas E. Dickey * * Copyright 1998-2003,2005 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ // $Id: cursslk.h,v 1.19 2021/04/17 18:11:08 tom Exp $ #ifndef NCURSES_CURSSLK_H_incl #define NCURSES_CURSSLK_H_incl #include <cursesw.h> class NCURSES_CXX_IMPEXP Soft_Label_Key_Set { public: // This inner class represents the attributes of a Soft Label Key (SLK) class NCURSES_CXX_IMPEXP Soft_Label_Key { friend class Soft_Label_Key_Set; public: typedef enum { Left=0, Center=1, Right=2 } Justification; private: char *label; // The Text of the Label Justification format; // The Justification int num; // The number of the Label Soft_Label_Key() : label(NULL), format(Left), num(-1) { } virtual ~Soft_Label_Key() { delete[] label; }; public: // Set the text of the Label Soft_Label_Key& operator=(char *text); // Set the Justification of the Label Soft_Label_Key& operator=(Justification just) { format = just; return *this; } // Retrieve the text of the label inline char* operator()(void) const { return label; } Soft_Label_Key& operator=(const Soft_Label_Key& rhs) { if (this != &rhs) { *this = rhs; } return *this; } Soft_Label_Key(const Soft_Label_Key& rhs) : label(NULL), format(rhs.format), num(rhs.num) { *this = rhs.label; } }; public: typedef enum { None = -1, Three_Two_Three = 0, Four_Four = 1, PC_Style = 2, PC_Style_With_Index = 3 } Label_Layout; private: static long count; // Number of Key Sets static Label_Layout format; // Layout of the Key Sets static int num_labels; // Number Of Labels in Key Sets bool b_attrInit; // Are attributes initialized Soft_Label_Key *slk_array; // The array of SLK's // Init the Key Set void init(); // Activate or Deactivate Label# i, Label counting starts with 1! void activate_label(int i, bool bf=TRUE); // Activate of Deactivate all Labels void activate_labels(bool bf); protected: inline void Error (const char* msg) const THROWS(NCursesException) { THROW(new NCursesException (msg)); } // Remove SLK's from screen void clear() { if (ERR==::slk_clear()) Error("slk_clear"); } // Restore them void restore() { if (ERR==::slk_restore()) Error("slk_restore"); } public: // Construct a Key Set, use the most comfortable layout as default. // You must create a Soft_Label_Key_Set before you create any object of // the NCursesWindow, NCursesPanel or derived classes. (Actually before // ::initscr() is called). explicit Soft_Label_Key_Set(Label_Layout fmt); // This constructor assumes, that you already constructed a Key Set // with a layout by the constructor above. This layout will be reused. Soft_Label_Key_Set(); Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs) { if (this != &rhs) { *this = rhs; init(); // allocate a new slk_array[] } return *this; } Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs) : b_attrInit(rhs.b_attrInit), slk_array(NULL) { init(); // allocate a new slk_array[] } virtual ~Soft_Label_Key_Set() THROWS(NCursesException); // Get Label# i. Label counting starts with 1! Soft_Label_Key& operator[](int i); // Retrieve number of Labels int labels() const; // Refresh the SLK portion of the screen inline void refresh() { if (ERR==::slk_refresh()) Error("slk_refresh"); } // Mark the SLK portion of the screen for refresh, defer actual refresh // until next update call. inline void noutrefresh() { if (ERR==::slk_noutrefresh()) Error("slk_noutrefresh"); } // Mark the whole SLK portion of the screen as modified inline void touch() { if (ERR==::slk_touch()) Error("slk_touch"); } // Activate Label# i inline void show(int i) { activate_label(i,FALSE); activate_label(i,TRUE); } // Hide Label# i inline void hide(int i) { activate_label(i,FALSE); } // Show all Labels inline void show() { activate_labels(FALSE); activate_labels(TRUE); } // Hide all Labels inline void hide() { activate_labels(FALSE); } inline void attron(attr_t attrs) { if (ERR==::slk_attron(attrs)) Error("slk_attron"); } inline void attroff(attr_t attrs) { if (ERR==::slk_attroff(attrs)) Error("slk_attroff"); } inline void attrset(attr_t attrs) { if (ERR==::slk_attrset(attrs)) Error("slk_attrset"); } inline void color(short color_pair_number) { if (ERR==::slk_color(color_pair_number)) Error("slk_color"); } inline attr_t attr() const { return ::slk_attr(); } }; #endif /* NCURSES_CURSSLK_H_incl */ /**************************************************************************** * Copyright 2020 Thomas E. Dickey * * Copyright 1998-2009,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Juergen Pfeifer 1996-1999,2008 * ****************************************************************************/ /* $Id: panel.h,v 1.14 2020/07/04 20:38:43 tom Exp $ */ /* panel.h -- interface file for panels library */ #ifndef NCURSES_PANEL_H_incl #define NCURSES_PANEL_H_incl 1 #include <curses.h> typedef struct panel #if !NCURSES_OPAQUE_PANEL { WINDOW *win; struct panel *below; struct panel *above; NCURSES_CONST void *user; } #endif /* !NCURSES_OPAQUE_PANEL */ PANEL; #if defined(__cplusplus) extern "C" { #endif #if defined(BUILDING_PANEL) # define PANEL_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT #else # define PANEL_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT #endif #define PANEL_WRAPPED_VAR(type,name) extern PANEL_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) #define PANEL_EXPORT(type) PANEL_IMPEXP type NCURSES_API #define PANEL_EXPORT_VAR(type) PANEL_IMPEXP type extern PANEL_EXPORT(WINDOW*) panel_window (const PANEL *); extern PANEL_EXPORT(void) update_panels (void); extern PANEL_EXPORT(int) hide_panel (PANEL *); extern PANEL_EXPORT(int) show_panel (PANEL *); extern PANEL_EXPORT(int) del_panel (PANEL *); extern PANEL_EXPORT(int) top_panel (PANEL *); extern PANEL_EXPORT(int) bottom_panel (PANEL *); extern PANEL_EXPORT(PANEL*) new_panel (WINDOW *); extern PANEL_EXPORT(PANEL*) panel_above (const PANEL *); extern PANEL_EXPORT(PANEL*) panel_below (const PANEL *); extern PANEL_EXPORT(int) set_panel_userptr (PANEL *, NCURSES_CONST void *); extern PANEL_EXPORT(NCURSES_CONST void*) panel_userptr (const PANEL *); extern PANEL_EXPORT(int) move_panel (PANEL *, int, int); extern PANEL_EXPORT(int) replace_panel (PANEL *,WINDOW *); extern PANEL_EXPORT(int) panel_hidden (const PANEL *); #if NCURSES_SP_FUNCS extern PANEL_EXPORT(PANEL *) ground_panel(SCREEN *); extern PANEL_EXPORT(PANEL *) ceiling_panel(SCREEN *); extern PANEL_EXPORT(void) NCURSES_SP_NAME(update_panels) (SCREEN*); #endif #if defined(__cplusplus) } #endif #endif /* NCURSES_PANEL_H_incl */ /* end of panel.h */ /**************************************************************************** * Copyright 2020 Thomas E. Dickey * * Copyright 1998-2001,2009 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ /* * unctrl.h * * Display a printable version of a control character. * Control characters are displayed in caret notation (^x), DELETE is displayed * as ^?. Printable characters are displayed as is. */ /* $Id: unctrl.h.in,v 1.12 2020/02/02 23:34:34 tom Exp $ */ #ifndef NCURSES_UNCTRL_H_incl #define NCURSES_UNCTRL_H_incl 1 #undef NCURSES_VERSION #define NCURSES_VERSION "6.2" #ifdef __cplusplus extern "C" { #endif #include <curses.h> #undef unctrl NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype); #if 1 NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype); #endif #ifdef __cplusplus } #endif #endif /* NCURSES_UNCTRL_H_incl */ /**************************************************************************** * Copyright 2018,2020 Thomas E. Dickey * * Copyright 1998-2000,2001 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ /* $Id: termcap.h.in,v 1.19 2020/02/02 23:34:34 tom Exp $ */ #ifndef NCURSES_TERMCAP_H_incl #define NCURSES_TERMCAP_H_incl 1 #undef NCURSES_VERSION #define NCURSES_VERSION "6.2" #include <ncurses_dll.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include <sys/types.h> #undef NCURSES_OSPEED #define NCURSES_OSPEED unsigned extern NCURSES_EXPORT_VAR(char) PC; extern NCURSES_EXPORT_VAR(char *) UP; extern NCURSES_EXPORT_VAR(char *) BC; extern NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed; #if !defined(NCURSES_TERM_H_incl) extern NCURSES_EXPORT(char *) tgetstr (const char *, char **); extern NCURSES_EXPORT(char *) tgoto (const char *, int, int); extern NCURSES_EXPORT(int) tgetent (char *, const char *); extern NCURSES_EXPORT(int) tgetflag (const char *); extern NCURSES_EXPORT(int) tgetnum (const char *); extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int)); #endif #ifdef __cplusplus } #endif #endif /* NCURSES_TERMCAP_H_incl */ /**************************************************************************** * Copyright 2018,2020 Thomas E. Dickey * * Copyright 2009,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /* $Id: ncurses_dll.h.in,v 1.17 2020/09/05 17:58:47 juergen Exp $ */ #ifndef NCURSES_DLL_H_incl #define NCURSES_DLL_H_incl 1 /* * MinGW gcc (unlike MSYS2 and Cygwin) should define _WIN32 and possibly _WIN64. */ #if defined(__MINGW64__) #ifndef _WIN64 #define _WIN64 1 #endif #elif defined(__MINGW32__) #ifndef _WIN32 #define _WIN32 1 #endif /* 2014-08-02 workaround for broken MinGW compiler. * Oddly, only TRACE is mapped to trace - the other -D's are okay. * suggest TDM as an alternative. */ #if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) #ifdef trace #undef trace #define TRACE #endif #endif /* broken compiler */ #endif /* MingW */ /* * For reentrant code, we map the various global variables into SCREEN by * using functions to access them. */ #define NCURSES_PUBLIC_VAR(name) _nc_##name #if defined(BUILDING_NCURSES) # define NCURSES_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT #else # define NCURSES_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT #endif #define NCURSES_WRAPPED_VAR(type,name) extern NCURSES_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) #define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API #define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type /* * These symbols hide dllimport/dllexport, for compilers which care about it. */ #if defined(__CYGWIN__) || (defined(_WIN32) || defined(_WIN64)) # if defined(NCURSES_STATIC) /* "static" here only implies "not-a-DLL" */ # define NCURSES_EXPORT_GENERAL_IMPORT # define NCURSES_EXPORT_GENERAL_EXPORT # else # define NCURSES_EXPORT_GENERAL_IMPORT __declspec(dllimport) # define NCURSES_EXPORT_GENERAL_EXPORT __declspec(dllexport) # endif # define NCURSES_API __cdecl #else # define NCURSES_EXPORT_GENERAL_IMPORT # define NCURSES_EXPORT_GENERAL_EXPORT # define NCURSES_API /* FIXME: __attribute__ ((cdecl)) is only available on x86 */ #endif #endif /* NCURSES_DLL_H_incl */ // * This makes emacs happy -*-Mode: C++;-*- // vile:cppmode /**************************************************************************** * Copyright 2019-2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ // $Id: cursesf.h,v 1.38 2021/04/17 18:11:08 tom Exp $ #ifndef NCURSES_CURSESF_H_incl #define NCURSES_CURSESF_H_incl 1 #include <cursesp.h> #ifndef __EXT_QNX #include <string.h> #endif extern "C" { # include <form.h> } // // ------------------------------------------------------------------------- // The abstract base class for builtin and user defined Fieldtypes. // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP NCursesFormField; // forward declaration // Class to represent builtin field types as well as C++ written new // fieldtypes (see classes UserDefineFieldType... class NCURSES_CXX_IMPEXP NCursesFieldType { friend class NCursesFormField; protected: FIELDTYPE* fieldtype; inline void OnError(int err) const THROW2(NCursesException const, NCursesFormException) { if (err!=E_OK) THROW(new NCursesFormException (err)); } NCursesFieldType(FIELDTYPE *f) : fieldtype(f) { } virtual ~NCursesFieldType() {} // Set the fields f fieldtype to this one. virtual void set(NCursesFormField& f) = 0; public: NCursesFieldType() : fieldtype(STATIC_CAST(FIELDTYPE*)(0)) { } NCursesFieldType& operator=(const NCursesFieldType& rhs) { if (this != &rhs) { *this = rhs; } return *this; } NCursesFieldType(const NCursesFieldType& rhs) : fieldtype(rhs.fieldtype) { } }; // // ------------------------------------------------------------------------- // The class representing a forms field, wrapping the lowlevel FIELD struct // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP NCursesFormField { friend class NCursesForm; protected: FIELD *field; // lowlevel structure NCursesFieldType* ftype; // Associated field type // Error handler inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) { if (err != E_OK) THROW(new NCursesFormException (err)); } public: // Create a 'Null' field. Can be used to delimit a field list NCursesFormField() : field(STATIC_CAST(FIELD*)(0)), ftype(STATIC_CAST(NCursesFieldType*)(0)) { } // Create a new field NCursesFormField (int rows, int ncols, int first_row = 0, int first_col = 0, int offscreen_rows = 0, int additional_buffers = 0) : field(0), ftype(STATIC_CAST(NCursesFieldType*)(0)) { field = ::new_field(rows, ncols, first_row, first_col, offscreen_rows, additional_buffers); if (!field) OnError(errno); } NCursesFormField& operator=(const NCursesFormField& rhs) { if (this != &rhs) { *this = rhs; } return *this; } NCursesFormField(const NCursesFormField& rhs) : field(rhs.field), ftype(rhs.ftype) { } virtual ~NCursesFormField () THROWS(NCursesException); // Duplicate the field at a new position inline NCursesFormField* dup(int first_row, int first_col) { NCursesFormField* f = new NCursesFormField(); if (!f) OnError(E_SYSTEM_ERROR); else { f->ftype = ftype; f->field = ::dup_field(field,first_row,first_col); if (!f->field) OnError(errno); } return f; } // Link the field to a new location inline NCursesFormField* link(int first_row, int first_col) { NCursesFormField* f = new NCursesFormField(); if (!f) OnError(E_SYSTEM_ERROR); else { f->ftype = ftype; f->field = ::link_field(field,first_row,first_col); if (!f->field) OnError(errno); } return f; } // Get the lowlevel field representation inline FIELD* get_field() const { return field; } // Retrieve info about the field inline void info(int& rows, int& ncols, int& first_row, int& first_col, int& offscreen_rows, int& additional_buffers) const { OnError(::field_info(field, &rows, &ncols, &first_row, &first_col, &offscreen_rows, &additional_buffers)); } // Retrieve info about the fields dynamic properties. inline void dynamic_info(int& dynamic_rows, int& dynamic_cols, int& max_growth) const { OnError(::dynamic_field_info(field, &dynamic_rows, &dynamic_cols, &max_growth)); } // For a dynamic field you may set the maximum growth limit. // A zero means unlimited growth. inline void set_maximum_growth(int growth = 0) { OnError(::set_max_field(field,growth)); } // Move the field to a new position inline void move(int row, int col) { OnError(::move_field(field,row,col)); } // Mark the field to start a new page inline void new_page(bool pageFlag = FALSE) { OnError(::set_new_page(field,pageFlag)); } // Retrieve whether or not the field starts a new page. inline bool is_new_page() const { return ::new_page(field); } // Set the justification for the field inline void set_justification(int just) { OnError(::set_field_just(field,just)); } // Retrieve the fields justification inline int justification() const { return ::field_just(field); } // Set the foreground attribute for the field inline void set_foreground(chtype foreground) { OnError(::set_field_fore(field,foreground)); } // Retrieve the fields foreground attribute inline chtype fore() const { return ::field_fore(field); } // Set the background attribute for the field inline void set_background(chtype background) { OnError(::set_field_back(field,background)); } // Retrieve the fields background attribute inline chtype back() const { return ::field_back(field); } // Set the padding character for the field inline void set_pad_character(int padding) { OnError(::set_field_pad(field, padding)); } // Retrieve the fields padding character inline int pad() const { return ::field_pad(field); } // Switch on the fields options inline void options_on (Field_Options opts) { OnError (::field_opts_on (field, opts)); } // Switch off the fields options inline void options_off (Field_Options opts) { OnError (::field_opts_off (field, opts)); } // Retrieve the fields options inline Field_Options options () const { return ::field_opts (field); } // Set the fields options inline void set_options (Field_Options opts) { OnError (::set_field_opts (field, opts)); } // Mark the field as changed inline void set_changed(bool changeFlag = TRUE) { OnError(::set_field_status(field,changeFlag)); } // Test whether or not the field is marked as changed inline bool changed() const { return ::field_status(field); } // Return the index of the field in the field array of a form // or -1 if the field is not associated to a form inline int (index)() const { return ::field_index(field); } // Store a value in a fields buffer. The default buffer is nr. 0 inline void set_value(const char *val, int buffer = 0) { OnError(::set_field_buffer(field,buffer,val)); } // Retrieve the value of a fields buffer. The default buffer is nr. 0 inline char* value(int buffer = 0) const { return ::field_buffer(field,buffer); } // Set the validation type of the field. inline void set_fieldtype(NCursesFieldType& f) { ftype = &f; f.set(*this); // A good friend may do that... } // Retrieve the validation type of the field. inline NCursesFieldType* fieldtype() const { return ftype; } }; // This are the built-in hook functions in this C++ binding. In C++ we use // virtual member functions (see below On_..._Init and On_..._Termination) // to provide this functionality in an object oriented manner. extern "C" { void _nc_xx_frm_init(FORM *); void _nc_xx_frm_term(FORM *); void _nc_xx_fld_init(FORM *); void _nc_xx_fld_term(FORM *); } // // ------------------------------------------------------------------------- // The class representing a form, wrapping the lowlevel FORM struct // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP NCursesForm : public NCursesPanel { protected: FORM* form; // the lowlevel structure private: NCursesWindow* sub; // the subwindow object bool b_sub_owner; // is this our own subwindow? bool b_framed; // has the form a border? bool b_autoDelete; // Delete fields when deleting form? NCursesFormField** my_fields; // The array of fields for this form // This structure is used for the form's user data field to link the // FORM* to the C++ object and to provide extra space for a user pointer. typedef struct { void* m_user; // the pointer for the user's data const NCursesForm* m_back; // backward pointer to C++ object const FORM* m_owner; } UserHook; // Get the backward pointer to the C++ object from a FORM static inline NCursesForm* getHook(const FORM *f) { UserHook* hook = reinterpret_cast<UserHook*>(::form_userptr(f)); assert(hook != 0 && hook->m_owner==f); return const_cast<NCursesForm*>(hook->m_back); } friend void _nc_xx_frm_init(FORM *); friend void _nc_xx_frm_term(FORM *); friend void _nc_xx_fld_init(FORM *); friend void _nc_xx_fld_term(FORM *); // Calculate FIELD* array for the menu FIELD** mapFields(NCursesFormField* nfields[]); protected: // internal routines inline void set_user(void *user) { UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form)); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form); uptr->m_user = user; } inline void *get_user() { UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form)); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form); return uptr->m_user; } void InitForm (NCursesFormField* Fields[], bool with_frame, bool autoDeleteFields); inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) { if (err != E_OK) THROW(new NCursesFormException (err)); } // this wraps the form_driver call. virtual int driver (int c) ; // 'Internal' constructor, builds an object without association to a // field array. NCursesForm( int nlines, int ncols, int begin_y = 0, int begin_x = 0) : NCursesPanel(nlines, ncols, begin_y, begin_x), form (STATIC_CAST(FORM*)(0)), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_fields(0) { } public: // Create form for the default panel. NCursesForm (NCursesFormField* Fields[], bool with_frame=FALSE, // reserve space for a frame? bool autoDelete_Fields=FALSE) // do automatic cleanup? : NCursesPanel(), form(0), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_fields(0) { InitForm(Fields, with_frame, autoDelete_Fields); } // Create a form in a panel with the given position and size. NCursesForm (NCursesFormField* Fields[], int nlines, int ncols, int begin_y, int begin_x, bool with_frame=FALSE, // reserve space for a frame? bool autoDelete_Fields=FALSE) // do automatic cleanup? : NCursesPanel(nlines, ncols, begin_y, begin_x), form(0), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_fields(0) { InitForm(Fields, with_frame, autoDelete_Fields); } NCursesForm& operator=(const NCursesForm& rhs) { if (this != &rhs) { *this = rhs; NCursesPanel::operator=(rhs); } return *this; } NCursesForm(const NCursesForm& rhs) : NCursesPanel(rhs), form(rhs.form), sub(rhs.sub), b_sub_owner(rhs.b_sub_owner), b_framed(rhs.b_framed), b_autoDelete(rhs.b_autoDelete), my_fields(rhs.my_fields) { } virtual ~NCursesForm() THROWS(NCursesException); // Set the default attributes for the form virtual void setDefaultAttributes(); // Retrieve current field of the form. inline NCursesFormField* current_field() const { return my_fields[::field_index(::current_field(form))]; } // Set the forms subwindow void setSubWindow(NCursesWindow& sub); // Set these fields for the form inline void setFields(NCursesFormField* Fields[]) { OnError(::set_form_fields(form,mapFields(Fields))); } // Remove the form from the screen inline void unpost (void) { OnError (::unpost_form (form)); } // Post the form to the screen if flag is true, unpost it otherwise inline void post(bool flag = TRUE) { OnError (flag ? ::post_form(form) : ::unpost_form (form)); } // Decorations inline void frame(const char *title=NULL, const char* btitle=NULL) { if (b_framed) NCursesPanel::frame(title,btitle); else OnError(E_SYSTEM_ERROR); } inline void boldframe(const char *title=NULL, const char* btitle=NULL) { if (b_framed) NCursesPanel::boldframe(title,btitle); else OnError(E_SYSTEM_ERROR); } inline void label(const char *topLabel, const char *bottomLabel) { if (b_framed) NCursesPanel::label(topLabel,bottomLabel); else OnError(E_SYSTEM_ERROR); } // ----- // Hooks // ----- // Called after the form gets repositioned in its window. // This is especially true if the form is posted. virtual void On_Form_Init(); // Called before the form gets repositioned in its window. // This is especially true if the form is unposted. virtual void On_Form_Termination(); // Called after the field became the current field virtual void On_Field_Init(NCursesFormField& field); // Called before this field is left as current field. virtual void On_Field_Termination(NCursesFormField& field); // Calculate required window size for the form. void scale(int& rows, int& ncols) const { OnError(::scale_form(form,&rows,&ncols)); } // Retrieve number of fields in the form. int count() const { return ::field_count(form); } // Make the page the current page of the form. void set_page(int pageNum) { OnError(::set_form_page(form, pageNum)); } // Retrieve current page number int page() const { return ::form_page(form); } // Switch on the forms options inline void options_on (Form_Options opts) { OnError (::form_opts_on (form, opts)); } // Switch off the forms options inline void options_off (Form_Options opts) { OnError (::form_opts_off (form, opts)); } // Retrieve the forms options inline Form_Options options () const { return ::form_opts (form); } // Set the forms options inline void set_options (Form_Options opts) { OnError (::set_form_opts (form, opts)); } // Are there more data in the current field after the data shown inline bool data_ahead() const { return ::data_ahead(form); } // Are there more data in the current field before the data shown inline bool data_behind() const { return ::data_behind(form); } // Position the cursor to the current field inline void position_cursor () { OnError (::pos_form_cursor (form)); } // Set the current field inline void set_current(NCursesFormField& F) { OnError (::set_current_field(form, F.field)); } // Provide a default key virtualization. Translate the keyboard // code c into a form request code. // The default implementation provides a hopefully straightforward // mapping for the most common keystrokes and form requests. virtual int virtualize(int c); // Operators inline NCursesFormField* operator[](int i) const { if ( (i < 0) || (i >= ::field_count (form)) ) OnError (E_BAD_ARGUMENT); return my_fields[i]; } // Perform the menu's operation // Return the field where you left the form. virtual NCursesFormField* operator()(void); // Exception handlers. The default is a Beep. virtual void On_Request_Denied(int c) const; virtual void On_Invalid_Field(int c) const; virtual void On_Unknown_Command(int c) const; }; // // ------------------------------------------------------------------------- // This is the typical C++ typesafe way to allow to attach // user data to a field of a form. Its assumed that the user // data belongs to some class T. Use T as template argument // to create a UserField. // ------------------------------------------------------------------------- template<class T> class NCURSES_CXX_IMPEXP NCursesUserField : public NCursesFormField { public: NCursesUserField (int rows, int ncols, int first_row = 0, int first_col = 0, const T* p_UserData = STATIC_CAST(T*)(0), int offscreen_rows = 0, int additional_buffers = 0) : NCursesFormField (rows, ncols, first_row, first_col, offscreen_rows, additional_buffers) { if (field) OnError(::set_field_userptr(field, STATIC_CAST(void *)(p_UserData))); } virtual ~NCursesUserField() THROWS(NCursesException) {}; inline const T* UserData (void) const { return reinterpret_cast<const T*>(::field_userptr (field)); } inline virtual void setUserData(const T* p_UserData) { if (field) OnError (::set_field_userptr (field, STATIC_CAST(void *)(p_UserData))); } }; // // ------------------------------------------------------------------------- // The same mechanism is used to attach user data to a form // ------------------------------------------------------------------------- // template<class T> class NCURSES_CXX_IMPEXP NCursesUserForm : public NCursesForm { protected: // 'Internal' constructor, builds an object without association to a // field array. NCursesUserForm( int nlines, int ncols, int begin_y = 0, int begin_x = 0, const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesForm(nlines,ncols,begin_y,begin_x) { if (form) set_user (const_cast<void *>(reinterpret_cast<const void*> (p_UserData))); } public: NCursesUserForm (NCursesFormField* Fields[], const T* p_UserData = STATIC_CAST(T*)(0), bool with_frame=FALSE, bool autoDelete_Fields=FALSE) : NCursesForm (Fields, with_frame, autoDelete_Fields) { if (form) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); }; NCursesUserForm (NCursesFormField* Fields[], int nlines, int ncols, int begin_y = 0, int begin_x = 0, const T* p_UserData = STATIC_CAST(T*)(0), bool with_frame=FALSE, bool autoDelete_Fields=FALSE) : NCursesForm (Fields, nlines, ncols, begin_y, begin_x, with_frame, autoDelete_Fields) { if (form) set_user (const_cast<void *>(reinterpret_cast<const void*> (p_UserData))); }; virtual ~NCursesUserForm() THROWS(NCursesException) { }; inline T* UserData (void) { return reinterpret_cast<T*>(get_user ()); }; inline virtual void setUserData (const T* p_UserData) { if (form) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); } }; // // ------------------------------------------------------------------------- // Builtin Fieldtypes // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP Alpha_Field : public NCursesFieldType { private: int min_field_width; void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype,min_field_width)); } public: explicit Alpha_Field(int width) : NCursesFieldType(TYPE_ALPHA), min_field_width(width) { } }; class NCURSES_CXX_IMPEXP Alphanumeric_Field : public NCursesFieldType { private: int min_field_width; void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype,min_field_width)); } public: explicit Alphanumeric_Field(int width) : NCursesFieldType(TYPE_ALNUM), min_field_width(width) { } }; class NCURSES_CXX_IMPEXP Integer_Field : public NCursesFieldType { private: int precision; long lower_limit, upper_limit; void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype, precision,lower_limit,upper_limit)); } public: Integer_Field(int prec, long low=0L, long high=0L) : NCursesFieldType(TYPE_INTEGER), precision(prec), lower_limit(low), upper_limit(high) { } }; class NCURSES_CXX_IMPEXP Numeric_Field : public NCursesFieldType { private: int precision; double lower_limit, upper_limit; void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype, precision,lower_limit,upper_limit)); } public: Numeric_Field(int prec, double low=0.0, double high=0.0) : NCursesFieldType(TYPE_NUMERIC), precision(prec), lower_limit(low), upper_limit(high) { } }; class NCURSES_CXX_IMPEXP Regular_Expression_Field : public NCursesFieldType { private: char* regex; void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype,regex)); } void copy_regex(const char *source) { regex = new char[1 + ::strlen(source)]; (::strcpy)(regex, source); } public: explicit Regular_Expression_Field(const char *expr) : NCursesFieldType(TYPE_REGEXP), regex(NULL) { copy_regex(expr); } Regular_Expression_Field& operator=(const Regular_Expression_Field& rhs) { if (this != &rhs) { *this = rhs; copy_regex(rhs.regex); NCursesFieldType::operator=(rhs); } return *this; } Regular_Expression_Field(const Regular_Expression_Field& rhs) : NCursesFieldType(rhs), regex(NULL) { copy_regex(rhs.regex); } ~Regular_Expression_Field() { delete[] regex; } }; class NCURSES_CXX_IMPEXP Enumeration_Field : public NCursesFieldType { private: const char** list; int case_sensitive; int non_unique_matches; void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype, list,case_sensitive,non_unique_matches)); } public: Enumeration_Field(const char* enums[], bool case_sens=FALSE, bool non_unique=FALSE) : NCursesFieldType(TYPE_ENUM), list(enums), case_sensitive(case_sens ? -1 : 0), non_unique_matches(non_unique ? -1 : 0) { } Enumeration_Field& operator=(const Enumeration_Field& rhs) { if (this != &rhs) { *this = rhs; NCursesFieldType::operator=(rhs); } return *this; } Enumeration_Field(const Enumeration_Field& rhs) : NCursesFieldType(rhs), list(rhs.list), case_sensitive(rhs.case_sensitive), non_unique_matches(rhs.non_unique_matches) { } }; class NCURSES_CXX_IMPEXP IPV4_Address_Field : public NCursesFieldType { private: void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype)); } public: IPV4_Address_Field() : NCursesFieldType(TYPE_IPV4) { } }; extern "C" { bool _nc_xx_fld_fcheck(FIELD *, const void*); bool _nc_xx_fld_ccheck(int c, const void *); void* _nc_xx_fld_makearg(va_list*); } // // ------------------------------------------------------------------------- // Abstract base class for User-Defined Fieldtypes // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP UserDefinedFieldType : public NCursesFieldType { friend class UDF_Init; // Internal helper to set up statics private: // For all C++ defined fieldtypes we need only one generic lowlevel // FIELDTYPE* element. static FIELDTYPE* generic_fieldtype; protected: // This are the functions required by the low level libforms functions // to construct a fieldtype. friend bool _nc_xx_fld_fcheck(FIELD *, const void*); friend bool _nc_xx_fld_ccheck(int c, const void *); friend void* _nc_xx_fld_makearg(va_list*); void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype,&f)); } protected: // Redefine this function to do a field validation. The argument // is a reference to the field you should validate. virtual bool field_check(NCursesFormField& f) = 0; // Redefine this function to do a character validation. The argument // is the character to be validated. virtual bool char_check (int c) = 0; public: UserDefinedFieldType(); }; extern "C" { bool _nc_xx_next_choice(FIELD*, const void *); bool _nc_xx_prev_choice(FIELD*, const void *); } // // ------------------------------------------------------------------------- // Abstract base class for User-Defined Fieldtypes with Choice functions // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType { friend class UDF_Init; // Internal helper to set up statics private: // For all C++ defined fieldtypes with choice functions we need only one // generic lowlevel FIELDTYPE* element. static FIELDTYPE* generic_fieldtype_with_choice; // This are the functions required by the low level libforms functions // to construct a fieldtype with choice functions. friend bool _nc_xx_next_choice(FIELD*, const void *); friend bool _nc_xx_prev_choice(FIELD*, const void *); protected: // Redefine this function to do the retrieval of the next choice value. // The argument is a reference to the field tobe examined. virtual bool next (NCursesFormField& f) = 0; // Redefine this function to do the retrieval of the previous choice value. // The argument is a reference to the field tobe examined. virtual bool previous(NCursesFormField& f) = 0; public: UserDefinedFieldType_With_Choice(); }; #endif /* NCURSES_CURSESF_H_incl */ /**************************************************************************** * Copyright 2018-2019,2020 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1995,1997 * ****************************************************************************/ /* $Id: form.h,v 0.31 2020/07/04 20:38:43 tom Exp $ */ #ifndef FORM_H #define FORM_H /* *INDENT-OFF*/ #include <curses.h> #include <eti.h> #ifdef __cplusplus extern "C" { #endif #if defined(BUILDING_FORM) # define FORM_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT #else # define FORM_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT #endif #define FORM_WRAPPED_VAR(type,name) extern FORM_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) #define FORM_EXPORT(type) FORM_IMPEXP type NCURSES_API #define FORM_EXPORT_VAR(type) FORM_IMPEXP type #ifndef FORM_PRIV_H typedef void *FIELD_CELL; #endif #ifndef NCURSES_FIELD_INTERNALS #define NCURSES_FIELD_INTERNALS /* nothing */ #endif typedef int Form_Options; typedef int Field_Options; /********** * _PAGE * **********/ typedef struct pagenode #if !NCURSES_OPAQUE_FORM { short pmin; /* index of first field on page */ short pmax; /* index of last field on page */ short smin; /* index of top leftmost field on page */ short smax; /* index of bottom rightmost field on page */ } #endif /* !NCURSES_OPAQUE_FORM */ _PAGE; /********** * FIELD * **********/ typedef struct fieldnode #if 1 /* not yet: !NCURSES_OPAQUE_FORM */ { unsigned short status; /* flags */ short rows; /* size in rows */ short cols; /* size in cols */ short frow; /* first row */ short fcol; /* first col */ int drows; /* dynamic rows */ int dcols; /* dynamic cols */ int maxgrow; /* maximum field growth */ int nrow; /* off-screen rows */ short nbuf; /* additional buffers */ short just; /* justification */ short page; /* page on form */ short index; /* into form -> field */ int pad; /* pad character */ chtype fore; /* foreground attribute */ chtype back; /* background attribute */ Field_Options opts; /* options */ struct fieldnode * snext; /* sorted order pointer */ struct fieldnode * sprev; /* sorted order pointer */ struct fieldnode * link; /* linked field chain */ struct formnode * form; /* containing form */ struct typenode * type; /* field type */ void * arg; /* argument for type */ FIELD_CELL * buf; /* field buffers */ void * usrptr; /* user pointer */ /* * The wide-character configuration requires extra information. Because * there are existing applications that manipulate the members of FIELD * directly, we cannot make the struct opaque, except by changing the ABI. * Offsets of members up to this point are the same in the narrow- and * wide-character configuration. But note that the type of buf depends on * the configuration, and is made opaque for that reason. */ NCURSES_FIELD_INTERNALS } #endif /* NCURSES_OPAQUE_FORM */ FIELD; /********* * FORM * *********/ typedef struct formnode #if 1 /* not yet: !NCURSES_OPAQUE_FORM */ { unsigned short status; /* flags */ short rows; /* size in rows */ short cols; /* size in cols */ int currow; /* current row in field window */ int curcol; /* current col in field window */ int toprow; /* in scrollable field window */ int begincol; /* in horiz. scrollable field */ short maxfield; /* number of fields */ short maxpage; /* number of pages */ short curpage; /* index into page */ Form_Options opts; /* options */ WINDOW * win; /* window */ WINDOW * sub; /* subwindow */ WINDOW * w; /* window for current field */ FIELD ** field; /* field [maxfield] */ FIELD * current; /* current field */ _PAGE * page; /* page [maxpage] */ void * usrptr; /* user pointer */ void (*forminit)(struct formnode *); void (*formterm)(struct formnode *); void (*fieldinit)(struct formnode *); void (*fieldterm)(struct formnode *); } #endif /* !NCURSES_OPAQUE_FORM */ FORM; /************** * FIELDTYPE * **************/ typedef struct typenode #if !NCURSES_OPAQUE_FORM { unsigned short status; /* flags */ long ref; /* reference count */ struct typenode * left; /* ptr to operand for | */ struct typenode * right; /* ptr to operand for | */ void* (*makearg)(va_list *); /* make fieldtype arg */ void* (*copyarg)(const void *); /* copy fieldtype arg */ void (*freearg)(void *); /* free fieldtype arg */ #if NCURSES_INTEROP_FUNCS union { bool (*ofcheck)(FIELD *,const void *); /* field validation */ bool (*gfcheck)(FORM*,FIELD *,const void*); /* generic field validation */ } fieldcheck; union { bool (*occheck)(int,const void *); /* character validation */ bool (*gccheck)(int,FORM*, FIELD*,const void*); /* generic char validation */ } charcheck; union { bool (*onext)(FIELD *,const void *); /* enumerate next value */ bool (*gnext)(FORM*,FIELD*,const void*); /* generic enumerate next */ } enum_next; union { bool (*oprev)(FIELD *,const void *); /* enumerate prev value */ bool (*gprev)(FORM*,FIELD*,const void*); /* generic enumerate prev */ } enum_prev; void* (*genericarg)(void*); /* Alternate Arg method */ #else bool (*fcheck)(FIELD *,const void *); /* field validation */ bool (*ccheck)(int,const void *); /* character validation */ bool (*next)(FIELD *,const void *); /* enumerate next value */ bool (*prev)(FIELD *,const void *); /* enumerate prev value */ #endif } #endif /* !NCURSES_OPAQUE_FORM */ FIELDTYPE; typedef void (*Form_Hook)(FORM *); /*************************** * miscellaneous #defines * ***************************/ /* field justification */ #define NO_JUSTIFICATION (0) #define JUSTIFY_LEFT (1) #define JUSTIFY_CENTER (2) #define JUSTIFY_RIGHT (3) /* field options */ #define O_VISIBLE (0x0001U) #define O_ACTIVE (0x0002U) #define O_PUBLIC (0x0004U) #define O_EDIT (0x0008U) #define O_WRAP (0x0010U) #define O_BLANK (0x0020U) #define O_AUTOSKIP (0x0040U) #define O_NULLOK (0x0080U) #define O_PASSOK (0x0100U) #define O_STATIC (0x0200U) #define O_DYNAMIC_JUSTIFY (0x0400U) /* ncurses extension */ #define O_NO_LEFT_STRIP (0x0800U) /* ncurses extension */ #define O_EDGE_INSERT_STAY (0x1000U) /* ncurses extension */ #define O_INPUT_LIMIT (0x2000U) /* ncurses extension */ /* form options */ #define O_NL_OVERLOAD (0x0001U) #define O_BS_OVERLOAD (0x0002U) /* form driver commands */ #define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */ #define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */ #define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */ #define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */ #define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */ #define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */ #define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */ #define REQ_LAST_FIELD (KEY_MAX + 8) /* move to last field */ #define REQ_SNEXT_FIELD (KEY_MAX + 9) /* move to sorted next field */ #define REQ_SPREV_FIELD (KEY_MAX + 10) /* move to sorted prev field */ #define REQ_SFIRST_FIELD (KEY_MAX + 11) /* move to sorted first field */ #define REQ_SLAST_FIELD (KEY_MAX + 12) /* move to sorted last field */ #define REQ_LEFT_FIELD (KEY_MAX + 13) /* move to left to field */ #define REQ_RIGHT_FIELD (KEY_MAX + 14) /* move to right to field */ #define REQ_UP_FIELD (KEY_MAX + 15) /* move to up to field */ #define REQ_DOWN_FIELD (KEY_MAX + 16) /* move to down to field */ #define REQ_NEXT_CHAR (KEY_MAX + 17) /* move to next char in field */ #define REQ_PREV_CHAR (KEY_MAX + 18) /* move to prev char in field */ #define REQ_NEXT_LINE (KEY_MAX + 19) /* move to next line in field */ #define REQ_PREV_LINE (KEY_MAX + 20) /* move to prev line in field */ #define REQ_NEXT_WORD (KEY_MAX + 21) /* move to next word in field */ #define REQ_PREV_WORD (KEY_MAX + 22) /* move to prev word in field */ #define REQ_BEG_FIELD (KEY_MAX + 23) /* move to first char in field */ #define REQ_END_FIELD (KEY_MAX + 24) /* move after last char in fld */ #define REQ_BEG_LINE (KEY_MAX + 25) /* move to beginning of line */ #define REQ_END_LINE (KEY_MAX + 26) /* move after last char in line */ #define REQ_LEFT_CHAR (KEY_MAX + 27) /* move left in field */ #define REQ_RIGHT_CHAR (KEY_MAX + 28) /* move right in field */ #define REQ_UP_CHAR (KEY_MAX + 29) /* move up in field */ #define REQ_DOWN_CHAR (KEY_MAX + 30) /* move down in field */ #define REQ_NEW_LINE (KEY_MAX + 31) /* insert/overlay new line */ #define REQ_INS_CHAR (KEY_MAX + 32) /* insert blank char at cursor */ #define REQ_INS_LINE (KEY_MAX + 33) /* insert blank line at cursor */ #define REQ_DEL_CHAR (KEY_MAX + 34) /* delete char at cursor */ #define REQ_DEL_PREV (KEY_MAX + 35) /* delete char before cursor */ #define REQ_DEL_LINE (KEY_MAX + 36) /* delete line at cursor */ #define REQ_DEL_WORD (KEY_MAX + 37) /* delete word at cursor */ #define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */ #define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */ #define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */ #define REQ_OVL_MODE (KEY_MAX + 41) /* begin overlay mode */ #define REQ_INS_MODE (KEY_MAX + 42) /* begin insert mode */ #define REQ_SCR_FLINE (KEY_MAX + 43) /* scroll field forward a line */ #define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */ #define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */ #define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */ #define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page */ #define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page */ #define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */ #define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */ #define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */ #define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */ #define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */ #define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */ #define REQ_VALIDATION (KEY_MAX + 55) /* validate field */ #define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */ #define REQ_PREV_CHOICE (KEY_MAX + 57) /* display prev field choice */ #define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */ #define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */ #if defined(MAX_COMMAND) # if (MAX_FORM_COMMAND > MAX_COMMAND) # error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND # elif (MAX_COMMAND != (KEY_MAX + 128)) # error Something is wrong -- MAX_COMMAND is already inconsistently defined. # endif #else # define MAX_COMMAND (KEY_MAX + 128) #endif /************************* * standard field types * *************************/ extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA; extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM; extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM; extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER; extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC; extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP; /************************************ * built-in additional field types * * They are not defined in SVr4 * ************************************/ extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Version 4 address */ /*********************** * FIELDTYPE routines * ***********************/ extern FORM_EXPORT(FIELDTYPE *) new_fieldtype ( bool (* const field_check)(FIELD *,const void *), bool (* const char_check)(int,const void *)); extern FORM_EXPORT(FIELDTYPE *) link_fieldtype( FIELDTYPE *, FIELDTYPE *); extern FORM_EXPORT(int) free_fieldtype (FIELDTYPE *); extern FORM_EXPORT(int) set_fieldtype_arg (FIELDTYPE *, void * (* const make_arg)(va_list *), void * (* const copy_arg)(const void *), void (* const free_arg)(void *)); extern FORM_EXPORT(int) set_fieldtype_choice (FIELDTYPE *, bool (* const next_choice)(FIELD *,const void *), bool (* const prev_choice)(FIELD *,const void *)); /******************* * FIELD routines * *******************/ extern FORM_EXPORT(FIELD *) new_field (int,int,int,int,int,int); extern FORM_EXPORT(FIELD *) dup_field (FIELD *,int,int); extern FORM_EXPORT(FIELD *) link_field (FIELD *,int,int); extern FORM_EXPORT(int) free_field (FIELD *); extern FORM_EXPORT(int) field_info (const FIELD *,int *,int *,int *,int *,int *,int *); extern FORM_EXPORT(int) dynamic_field_info (const FIELD *,int *,int *,int *); extern FORM_EXPORT(int) set_max_field ( FIELD *,int); extern FORM_EXPORT(int) move_field (FIELD *,int,int); extern FORM_EXPORT(int) set_field_type (FIELD *,FIELDTYPE *,...); extern FORM_EXPORT(int) set_new_page (FIELD *,bool); extern FORM_EXPORT(int) set_field_just (FIELD *,int); extern FORM_EXPORT(int) field_just (const FIELD *); extern FORM_EXPORT(int) set_field_fore (FIELD *,chtype); extern FORM_EXPORT(int) set_field_back (FIELD *,chtype); extern FORM_EXPORT(int) set_field_pad (FIELD *,int); extern FORM_EXPORT(int) field_pad (const FIELD *); extern FORM_EXPORT(int) set_field_buffer (FIELD *,int,const char *); extern FORM_EXPORT(int) set_field_status (FIELD *,bool); extern FORM_EXPORT(int) set_field_userptr (FIELD *, void *); extern FORM_EXPORT(int) set_field_opts (FIELD *,Field_Options); extern FORM_EXPORT(int) field_opts_on (FIELD *,Field_Options); extern FORM_EXPORT(int) field_opts_off (FIELD *,Field_Options); extern FORM_EXPORT(chtype) field_fore (const FIELD *); extern FORM_EXPORT(chtype) field_back (const FIELD *); extern FORM_EXPORT(bool) new_page (const FIELD *); extern FORM_EXPORT(bool) field_status (const FIELD *); extern FORM_EXPORT(void *) field_arg (const FIELD *); extern FORM_EXPORT(void *) field_userptr (const FIELD *); extern FORM_EXPORT(FIELDTYPE *) field_type (const FIELD *); extern FORM_EXPORT(char *) field_buffer (const FIELD *,int); extern FORM_EXPORT(Field_Options) field_opts (const FIELD *); /****************** * FORM routines * ******************/ extern FORM_EXPORT(FORM *) new_form (FIELD **); extern FORM_EXPORT(FIELD **) form_fields (const FORM *); extern FORM_EXPORT(FIELD *) current_field (const FORM *); extern FORM_EXPORT(WINDOW *) form_win (const FORM *); extern FORM_EXPORT(WINDOW *) form_sub (const FORM *); extern FORM_EXPORT(Form_Hook) form_init (const FORM *); extern FORM_EXPORT(Form_Hook) form_term (const FORM *); extern FORM_EXPORT(Form_Hook) field_init (const FORM *); extern FORM_EXPORT(Form_Hook) field_term (const FORM *); extern FORM_EXPORT(int) free_form (FORM *); extern FORM_EXPORT(int) set_form_fields (FORM *,FIELD **); extern FORM_EXPORT(int) field_count (const FORM *); extern FORM_EXPORT(int) set_form_win (FORM *,WINDOW *); extern FORM_EXPORT(int) set_form_sub (FORM *,WINDOW *); extern FORM_EXPORT(int) set_current_field (FORM *,FIELD *); extern FORM_EXPORT(int) unfocus_current_field (FORM *); extern FORM_EXPORT(int) field_index (const FIELD *); extern FORM_EXPORT(int) set_form_page (FORM *,int); extern FORM_EXPORT(int) form_page (const FORM *); extern FORM_EXPORT(int) scale_form (const FORM *,int *,int *); extern FORM_EXPORT(int) set_form_init (FORM *,Form_Hook); extern FORM_EXPORT(int) set_form_term (FORM *,Form_Hook); extern FORM_EXPORT(int) set_field_init (FORM *,Form_Hook); extern FORM_EXPORT(int) set_field_term (FORM *,Form_Hook); extern FORM_EXPORT(int) post_form (FORM *); extern FORM_EXPORT(int) unpost_form (FORM *); extern FORM_EXPORT(int) pos_form_cursor (FORM *); extern FORM_EXPORT(int) form_driver (FORM *,int); # if NCURSES_WIDECHAR extern FORM_EXPORT(int) form_driver_w (FORM *,int,wchar_t); # endif extern FORM_EXPORT(int) set_form_userptr (FORM *,void *); extern FORM_EXPORT(int) set_form_opts (FORM *,Form_Options); extern FORM_EXPORT(int) form_opts_on (FORM *,Form_Options); extern FORM_EXPORT(int) form_opts_off (FORM *,Form_Options); extern FORM_EXPORT(int) form_request_by_name (const char *); extern FORM_EXPORT(const char *) form_request_name (int); extern FORM_EXPORT(void *) form_userptr (const FORM *); extern FORM_EXPORT(Form_Options) form_opts (const FORM *); extern FORM_EXPORT(bool) data_ahead (const FORM *); extern FORM_EXPORT(bool) data_behind (const FORM *); #if NCURSES_SP_FUNCS extern FORM_EXPORT(FORM *) NCURSES_SP_NAME(new_form) (SCREEN*, FIELD **); #endif #ifdef __cplusplus } #endif /* *INDENT-ON*/ #endif /* FORM_H */ /**************************************************************************** * Copyright 2018-2019,2020 Thomas E. Dickey * * Copyright 1998-2015,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Thomas E. Dickey 1998-on * ****************************************************************************/ /* $Id: term_entry.h,v 1.60 2020/02/29 15:46:00 anonymous.maarten Exp $ */ /* * term_entry.h -- interface to entry-manipulation code */ #ifndef NCURSES_TERM_ENTRY_H_incl #define NCURSES_TERM_ENTRY_H_incl 1 /* *INDENT-OFF* */ #ifdef __cplusplus extern "C" { #endif #include <curses.h> #include <term.h> /* * These macros may be used by programs that know about TERMTYPE: */ #if NCURSES_XNAMES #define NUM_BOOLEANS(tp) (tp)->num_Booleans #define NUM_NUMBERS(tp) (tp)->num_Numbers #define NUM_STRINGS(tp) (tp)->num_Strings #define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i] #else #define NUM_BOOLEANS(tp) BOOLCOUNT #define NUM_NUMBERS(tp) NUMCOUNT #define NUM_STRINGS(tp) STRCOUNT #define EXT_NAMES(tp,i,limit,index,table) table[i] #endif #define NUM_EXT_NAMES(tp) (unsigned) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings) #define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++) #define for_each_number(n,tp) for(n = 0; n < NUM_NUMBERS(tp); n++) #define for_each_string(n,tp) for(n = 0; n < NUM_STRINGS(tp); n++) #if NCURSES_XNAMES #define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; (int) n < (int) NUM_BOOLEANS(tp); n++) #define for_each_ext_number(n,tp) for(n = NUMCOUNT; (int) n < (int) NUM_NUMBERS(tp); n++) #define for_each_ext_string(n,tp) for(n = STRCOUNT; (int) n < (int) NUM_STRINGS(tp); n++) #endif #define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names) #define ExtNumname(tp,i,names) EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names) #define ExtStrname(tp,i,names) EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names) /* * The remaining type-definitions and macros are used only internally by the * ncurses utilities. */ #ifdef NCURSES_INTERNALS /* * see db_iterator.c - this enumeration lists the places searched for a * terminal description and defines the order in which they are searched. */ typedef enum { dbdTIC = 0, /* special, used by tic when writing entry */ #if NCURSES_USE_DATABASE dbdEnvOnce, /* the $TERMINFO environment variable */ dbdHome, /* $HOME/.terminfo */ dbdEnvList, /* the $TERMINFO_DIRS environment variable */ dbdCfgList, /* the compiled-in TERMINFO_DIRS value */ dbdCfgOnce, /* the compiled-in TERMINFO value */ #endif #if NCURSES_USE_TERMCAP dbdEnvOnce2, /* the $TERMCAP environment variable */ dbdEnvList2, /* the $TERMPATH environment variable */ dbdCfgList2, /* the compiled-in TERMPATH */ #endif dbdLAST } DBDIRS; #define MAX_USES 32 #define MAX_CROSSLINKS 16 typedef struct entry ENTRY; typedef struct { char *name; ENTRY *link; long line; } ENTRY_USES; struct entry { TERMTYPE2 tterm; unsigned nuses; ENTRY_USES uses[MAX_USES]; int ncrosslinks; ENTRY *crosslinks[MAX_CROSSLINKS]; long cstart; long cend; long startline; ENTRY *next; ENTRY *last; }; extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head; extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail; #define for_entry_list(qp) for (qp = _nc_head; qp; qp = qp->next) #define MAX_LINE 132 #define NULLHOOK (bool(*)(ENTRY *))0 /* * Note that WANTED and PRESENT are not simple inverses! If a capability * has been explicitly cancelled, it's not considered WANTED. */ #define WANTED(s) ((s) == ABSENT_STRING) #define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING)) #define ANDMISSING(p,q) \ { \ if (PRESENT(p) && !PRESENT(q)) \ _nc_warning(#p " but no " #q); \ } #define PAIRED(p,q) \ { \ if (PRESENT(q) && !PRESENT(p)) \ _nc_warning(#q " but no " #p); \ if (PRESENT(p) && !PRESENT(q)) \ _nc_warning(#p " but no " #q); \ } /* * These entrypoints are used only by the ncurses utilities such as tic. */ /* alloc_entry.c: elementary allocation code */ extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp); extern NCURSES_EXPORT(char *) _nc_save_str (const char *const); extern NCURSES_EXPORT(void) _nc_init_entry (ENTRY *const); extern NCURSES_EXPORT(void) _nc_merge_entry (ENTRY *const, ENTRY *const); extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool); /* alloc_ttype.c: elementary allocation code */ extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE2 *, TERMTYPE2 *); /* free_ttype.c: elementary allocation code */ extern NCURSES_EXPORT(void) _nc_free_termtype2 (TERMTYPE2 *); /* lib_termcap.c: trim sgr0 string for termcap users */ extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE2 *); /* parse_entry.c: entry-parsing code */ #if NCURSES_XNAMES extern NCURSES_EXPORT_VAR(bool) _nc_user_definable; extern NCURSES_EXPORT_VAR(bool) _nc_disable_period; #endif extern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool); extern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *); /* write_entry.c: writing an entry to the file system */ extern NCURSES_EXPORT(void) _nc_set_writedir (const char *); extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE2 *const); extern NCURSES_EXPORT(int) _nc_write_object (TERMTYPE2 *, char *, unsigned *, unsigned); /* comp_parse.c: entry list handling */ extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*)); extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *); extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */ extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool); extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *); extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */ extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2)(TERMTYPE2 *, bool); /* trace_xnames.c */ extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *); #endif /* NCURSES_INTERNALS */ /* * These entrypoints were used by tack before 1.08. */ #undef NCURSES_TACK_1_08 #ifdef NCURSES_INTERNALS #define NCURSES_TACK_1_08 /* nothing */ #else #define NCURSES_TACK_1_08 GCC_DEPRECATED("upgrade to tack 1.08") #endif /* alloc_ttype.c: elementary allocation code */ extern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, const TERMTYPE *) NCURSES_TACK_1_08; /* lib_acs.c */ extern NCURSES_EXPORT(void) _nc_init_acs (void) NCURSES_TACK_1_08; /* corresponds to traditional 'init_acs()' */ /* free_ttype.c: elementary allocation code */ extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *) NCURSES_TACK_1_08; #ifdef __cplusplus } #endif /* *INDENT-ON* */ #endif /* NCURSES_TERM_ENTRY_H_incl */ /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2013,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /****************************************************************************/ /* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 */ /* and: Eric S. Raymond <esr@snark.thyrsus.com> */ /* and: Thomas E. Dickey 1995-on */ /****************************************************************************/ /* $Id: MKterm.h.awk.in,v 1.79 2021/03/20 16:08:03 tom Exp $ */ /* ** term.h -- Definition of struct term */ #ifndef NCURSES_TERM_H_incl #define NCURSES_TERM_H_incl 1 #undef NCURSES_VERSION #define NCURSES_VERSION "6.2" #include <ncurses_dll.h> #ifdef __cplusplus extern "C" { #endif /* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H * definition (based on the system for which this was configured). */ #ifndef __NCURSES_H typedef struct screen SCREEN; #if 1 #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 20210508 #undef NCURSES_SP_NAME #define NCURSES_SP_NAME(name) name##_sp /* Define the sp-funcs helper function */ #undef NCURSES_SP_OUTC #define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC) typedef int (*NCURSES_SP_OUTC)(SCREEN*, int); #endif #endif /* __NCURSES_H */ #undef NCURSES_CONST #define NCURSES_CONST const #undef NCURSES_SBOOL #define NCURSES_SBOOL char #undef NCURSES_USE_DATABASE #define NCURSES_USE_DATABASE 1 #undef NCURSES_USE_TERMCAP #define NCURSES_USE_TERMCAP 0 #undef NCURSES_XNAMES #define NCURSES_XNAMES 1 /* We will use these symbols to hide differences between * termios/termio/sgttyb interfaces. */ #undef TTY #undef SET_TTY #undef GET_TTY /* Assume POSIX termio if we have the header and function */ /* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */ #if 1 && 1 #undef TERMIOS #define TERMIOS 1 #include <termios.h> #define TTY struct termios #else /* !HAVE_TERMIOS_H */ /* #if HAVE_TERMIO_H */ #if 1 #undef TERMIOS #define TERMIOS 1 #include <termio.h> #define TTY struct termio #else /* !HAVE_TERMIO_H */ #if (defined(_WIN32) || defined(_WIN64)) #if 0 #include <win32_curses.h> #define TTY struct winconmode #else #include <ncurses_mingw.h> #define TTY struct termios #endif #else #undef TERMIOS #include <sgtty.h> #include <sys/ioctl.h> #define TTY struct sgttyb #endif /* MINGW32 */ #endif /* HAVE_TERMIO_H */ #endif /* HAVE_TERMIOS_H */ #ifdef TERMIOS #define GET_TTY(fd, buf) tcgetattr(fd, buf) #define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf) #elif 0 && (defined(_WIN32) || defined(_WIN64)) #define GET_TTY(fd, buf) _nc_console_getmode(_nc_console_fd2handle(fd),buf) #define SET_TTY(fd, buf) _nc_console_setmode(_nc_console_fd2handle(fd),buf) #else #define GET_TTY(fd, buf) gtty(fd, buf) #define SET_TTY(fd, buf) stty(fd, buf) #endif #ifndef GCC_NORETURN #define GCC_NORETURN /* nothing */ #endif #define NAMESIZE 256 /* The cast works because TERMTYPE is the first data in TERMINAL */ #define CUR ((TERMTYPE *)(cur_term))-> #define auto_left_margin CUR Booleans[0] #define auto_right_margin CUR Booleans[1] #define no_esc_ctlc CUR Booleans[2] #define ceol_standout_glitch CUR Booleans[3] #define eat_newline_glitch CUR Booleans[4] #define erase_overstrike CUR Booleans[5] #define generic_type CUR Booleans[6] #define hard_copy CUR Booleans[7] #define has_meta_key CUR Booleans[8] #define has_status_line CUR Booleans[9] #define insert_null_glitch CUR Booleans[10] #define memory_above CUR Booleans[11] #define memory_below CUR Booleans[12] #define move_insert_mode CUR Booleans[13] #define move_standout_mode CUR Booleans[14] #define over_strike CUR Booleans[15] #define status_line_esc_ok CUR Booleans[16] #define dest_tabs_magic_smso CUR Booleans[17] #define tilde_glitch CUR Booleans[18] #define transparent_underline CUR Booleans[19] #define xon_xoff CUR Booleans[20] #define needs_xon_xoff CUR Booleans[21] #define prtr_silent CUR Booleans[22] #define hard_cursor CUR Booleans[23] #define non_rev_rmcup CUR Booleans[24] #define no_pad_char CUR Booleans[25] #define non_dest_scroll_region CUR Booleans[26] #define can_change CUR Booleans[27] #define back_color_erase CUR Booleans[28] #define hue_lightness_saturation CUR Booleans[29] #define col_addr_glitch CUR Booleans[30] #define cr_cancels_micro_mode CUR Booleans[31] #define has_print_wheel CUR Booleans[32] #define row_addr_glitch CUR Booleans[33] #define semi_auto_right_margin CUR Booleans[34] #define cpi_changes_res CUR Booleans[35] #define lpi_changes_res CUR Booleans[36] #define columns CUR Numbers[0] #define init_tabs CUR Numbers[1] #define lines CUR Numbers[2] #define lines_of_memory CUR Numbers[3] #define magic_cookie_glitch CUR Numbers[4] #define padding_baud_rate CUR Numbers[5] #define virtual_terminal CUR Numbers[6] #define width_status_line CUR Numbers[7] #define num_labels CUR Numbers[8] #define label_height CUR Numbers[9] #define label_width CUR Numbers[10] #define max_attributes CUR Numbers[11] #define maximum_windows CUR Numbers[12] #define max_colors CUR Numbers[13] #define max_pairs CUR Numbers[14] #define no_color_video CUR Numbers[15] #define buffer_capacity CUR Numbers[16] #define dot_vert_spacing CUR Numbers[17] #define dot_horz_spacing CUR Numbers[18] #define max_micro_address CUR Numbers[19] #define max_micro_jump CUR Numbers[20] #define micro_col_size CUR Numbers[21] #define micro_line_size CUR Numbers[22] #define number_of_pins CUR Numbers[23] #define output_res_char CUR Numbers[24] #define output_res_line CUR Numbers[25] #define output_res_horz_inch CUR Numbers[26] #define output_res_vert_inch CUR Numbers[27] #define print_rate CUR Numbers[28] #define wide_char_size CUR Numbers[29] #define buttons CUR Numbers[30] #define bit_image_entwining CUR Numbers[31] #define bit_image_type CUR Numbers[32] #define back_tab CUR Strings[0] #define bell CUR Strings[1] #define carriage_return CUR Strings[2] #define change_scroll_region CUR Strings[3] #define clear_all_tabs CUR Strings[4] #define clear_screen CUR Strings[5] #define clr_eol CUR Strings[6] #define clr_eos CUR Strings[7] #define column_address CUR Strings[8] #define command_character CUR Strings[9] #define cursor_address CUR Strings[10] #define cursor_down CUR Strings[11] #define cursor_home CUR Strings[12] #define cursor_invisible CUR Strings[13] #define cursor_left CUR Strings[14] #define cursor_mem_address CUR Strings[15] #define cursor_normal CUR Strings[16] #define cursor_right CUR Strings[17] #define cursor_to_ll CUR Strings[18] #define cursor_up CUR Strings[19] #define cursor_visible CUR Strings[20] #define delete_character CUR Strings[21] #define delete_line CUR Strings[22] #define dis_status_line CUR Strings[23] #define down_half_line CUR Strings[24] #define enter_alt_charset_mode CUR Strings[25] #define enter_blink_mode CUR Strings[26] #define enter_bold_mode CUR Strings[27] #define enter_ca_mode CUR Strings[28] #define enter_delete_mode CUR Strings[29] #define enter_dim_mode CUR Strings[30] #define enter_insert_mode CUR Strings[31] #define enter_secure_mode CUR Strings[32] #define enter_protected_mode CUR Strings[33] #define enter_reverse_mode CUR Strings[34] #define enter_standout_mode CUR Strings[35] #define enter_underline_mode CUR Strings[36] #define erase_chars CUR Strings[37] #define exit_alt_charset_mode CUR Strings[38] #define exit_attribute_mode CUR Strings[39] #define exit_ca_mode CUR Strings[40] #define exit_delete_mode CUR Strings[41] #define exit_insert_mode CUR Strings[42] #define exit_standout_mode CUR Strings[43] #define exit_underline_mode CUR Strings[44] #define flash_screen CUR Strings[45] #define form_feed CUR Strings[46] #define from_status_line CUR Strings[47] #define init_1string CUR Strings[48] #define init_2string CUR Strings[49] #define init_3string CUR Strings[50] #define init_file CUR Strings[51] #define insert_character CUR Strings[52] #define insert_line CUR Strings[53] #define insert_padding CUR Strings[54] #define key_backspace CUR Strings[55] #define key_catab CUR Strings[56] #define key_clear CUR Strings[57] #define key_ctab CUR Strings[58] #define key_dc CUR Strings[59] #define key_dl CUR Strings[60] #define key_down CUR Strings[61] #define key_eic CUR Strings[62] #define key_eol CUR Strings[63] #define key_eos CUR Strings[64] #define key_f0 CUR Strings[65] #define key_f1 CUR Strings[66] #define key_f10 CUR Strings[67] #define key_f2 CUR Strings[68] #define key_f3 CUR Strings[69] #define key_f4 CUR Strings[70] #define key_f5 CUR Strings[71] #define key_f6 CUR Strings[72] #define key_f7 CUR Strings[73] #define key_f8 CUR Strings[74] #define key_f9 CUR Strings[75] #define key_home CUR Strings[76] #define key_ic CUR Strings[77] #define key_il CUR Strings[78] #define key_left CUR Strings[79] #define key_ll CUR Strings[80] #define key_npage CUR Strings[81] #define key_ppage CUR Strings[82] #define key_right CUR Strings[83] #define key_sf CUR Strings[84] #define key_sr CUR Strings[85] #define key_stab CUR Strings[86] #define key_up CUR Strings[87] #define keypad_local CUR Strings[88] #define keypad_xmit CUR Strings[89] #define lab_f0 CUR Strings[90] #define lab_f1 CUR Strings[91] #define lab_f10 CUR Strings[92] #define lab_f2 CUR Strings[93] #define lab_f3 CUR Strings[94] #define lab_f4 CUR Strings[95] #define lab_f5 CUR Strings[96] #define lab_f6 CUR Strings[97] #define lab_f7 CUR Strings[98] #define lab_f8 CUR Strings[99] #define lab_f9 CUR Strings[100] #define meta_off CUR Strings[101] #define meta_on CUR Strings[102] #define newline CUR Strings[103] #define pad_char CUR Strings[104] #define parm_dch CUR Strings[105] #define parm_delete_line CUR Strings[106] #define parm_down_cursor CUR Strings[107] #define parm_ich CUR Strings[108] #define parm_index CUR Strings[109] #define parm_insert_line CUR Strings[110] #define parm_left_cursor CUR Strings[111] #define parm_right_cursor CUR Strings[112] #define parm_rindex CUR Strings[113] #define parm_up_cursor CUR Strings[114] #define pkey_key CUR Strings[115] #define pkey_local CUR Strings[116] #define pkey_xmit CUR Strings[117] #define print_screen CUR Strings[118] #define prtr_off CUR Strings[119] #define prtr_on CUR Strings[120] #define repeat_char CUR Strings[121] #define reset_1string CUR Strings[122] #define reset_2string CUR Strings[123] #define reset_3string CUR Strings[124] #define reset_file CUR Strings[125] #define restore_cursor CUR Strings[126] #define row_address CUR Strings[127] #define save_cursor CUR Strings[128] #define scroll_forward CUR Strings[129] #define scroll_reverse CUR Strings[130] #define set_attributes CUR Strings[131] #define set_tab CUR Strings[132] #define set_window CUR Strings[133] #define tab CUR Strings[134] #define to_status_line CUR Strings[135] #define underline_char CUR Strings[136] #define up_half_line CUR Strings[137] #define init_prog CUR Strings[138] #define key_a1 CUR Strings[139] #define key_a3 CUR Strings[140] #define key_b2 CUR Strings[141] #define key_c1 CUR Strings[142] #define key_c3 CUR Strings[143] #define prtr_non CUR Strings[144] #define char_padding CUR Strings[145] #define acs_chars CUR Strings[146] #define plab_norm CUR Strings[147] #define key_btab CUR Strings[148] #define enter_xon_mode CUR Strings[149] #define exit_xon_mode CUR Strings[150] #define enter_am_mode CUR Strings[151] #define exit_am_mode CUR Strings[152] #define xon_character CUR Strings[153] #define xoff_character CUR Strings[154] #define ena_acs CUR Strings[155] #define label_on CUR Strings[156] #define label_off CUR Strings[157] #define key_beg CUR Strings[158] #define key_cancel CUR Strings[159] #define key_close CUR Strings[160] #define key_command CUR Strings[161] #define key_copy CUR Strings[162] #define key_create CUR Strings[163] #define key_end CUR Strings[164] #define key_enter CUR Strings[165] #define key_exit CUR Strings[166] #define key_find CUR Strings[167] #define key_help CUR Strings[168] #define key_mark CUR Strings[169] #define key_message CUR Strings[170] #define key_move CUR Strings[171] #define key_next CUR Strings[172] #define key_open CUR Strings[173] #define key_options CUR Strings[174] #define key_previous CUR Strings[175] #define key_print CUR Strings[176] #define key_redo CUR Strings[177] #define key_reference CUR Strings[178] #define key_refresh CUR Strings[179] #define key_replace CUR Strings[180] #define key_restart CUR Strings[181] #define key_resume CUR Strings[182] #define key_save CUR Strings[183] #define key_suspend CUR Strings[184] #define key_undo CUR Strings[185] #define key_sbeg CUR Strings[186] #define key_scancel CUR Strings[187] #define key_scommand CUR Strings[188] #define key_scopy CUR Strings[189] #define key_screate CUR Strings[190] #define key_sdc CUR Strings[191] #define key_sdl CUR Strings[192] #define key_select CUR Strings[193] #define key_send CUR Strings[194] #define key_seol CUR Strings[195] #define key_sexit CUR Strings[196] #define key_sfind CUR Strings[197] #define key_shelp CUR Strings[198] #define key_shome CUR Strings[199] #define key_sic CUR Strings[200] #define key_sleft CUR Strings[201] #define key_smessage CUR Strings[202] #define key_smove CUR Strings[203] #define key_snext CUR Strings[204] #define key_soptions CUR Strings[205] #define key_sprevious CUR Strings[206] #define key_sprint CUR Strings[207] #define key_sredo CUR Strings[208] #define key_sreplace CUR Strings[209] #define key_sright CUR Strings[210] #define key_srsume CUR Strings[211] #define key_ssave CUR Strings[212] #define key_ssuspend CUR Strings[213] #define key_sundo CUR Strings[214] #define req_for_input CUR Strings[215] #define key_f11 CUR Strings[216] #define key_f12 CUR Strings[217] #define key_f13 CUR Strings[218] #define key_f14 CUR Strings[219] #define key_f15 CUR Strings[220] #define key_f16 CUR Strings[221] #define key_f17 CUR Strings[222] #define key_f18 CUR Strings[223] #define key_f19 CUR Strings[224] #define key_f20 CUR Strings[225] #define key_f21 CUR Strings[226] #define key_f22 CUR Strings[227] #define key_f23 CUR Strings[228] #define key_f24 CUR Strings[229] #define key_f25 CUR Strings[230] #define key_f26 CUR Strings[231] #define key_f27 CUR Strings[232] #define key_f28 CUR Strings[233] #define key_f29 CUR Strings[234] #define key_f30 CUR Strings[235] #define key_f31 CUR Strings[236] #define key_f32 CUR Strings[237] #define key_f33 CUR Strings[238] #define key_f34 CUR Strings[239] #define key_f35 CUR Strings[240] #define key_f36 CUR Strings[241] #define key_f37 CUR Strings[242] #define key_f38 CUR Strings[243] #define key_f39 CUR Strings[244] #define key_f40 CUR Strings[245] #define key_f41 CUR Strings[246] #define key_f42 CUR Strings[247] #define key_f43 CUR Strings[248] #define key_f44 CUR Strings[249] #define key_f45 CUR Strings[250] #define key_f46 CUR Strings[251] #define key_f47 CUR Strings[252] #define key_f48 CUR Strings[253] #define key_f49 CUR Strings[254] #define key_f50 CUR Strings[255] #define key_f51 CUR Strings[256] #define key_f52 CUR Strings[257] #define key_f53 CUR Strings[258] #define key_f54 CUR Strings[259] #define key_f55 CUR Strings[260] #define key_f56 CUR Strings[261] #define key_f57 CUR Strings[262] #define key_f58 CUR Strings[263] #define key_f59 CUR Strings[264] #define key_f60 CUR Strings[265] #define key_f61 CUR Strings[266] #define key_f62 CUR Strings[267] #define key_f63 CUR Strings[268] #define clr_bol CUR Strings[269] #define clear_margins CUR Strings[270] #define set_left_margin CUR Strings[271] #define set_right_margin CUR Strings[272] #define label_format CUR Strings[273] #define set_clock CUR Strings[274] #define display_clock CUR Strings[275] #define remove_clock CUR Strings[276] #define create_window CUR Strings[277] #define goto_window CUR Strings[278] #define hangup CUR Strings[279] #define dial_phone CUR Strings[280] #define quick_dial CUR Strings[281] #define tone CUR Strings[282] #define pulse CUR Strings[283] #define flash_hook CUR Strings[284] #define fixed_pause CUR Strings[285] #define wait_tone CUR Strings[286] #define user0 CUR Strings[287] #define user1 CUR Strings[288] #define user2 CUR Strings[289] #define user3 CUR Strings[290] #define user4 CUR Strings[291] #define user5 CUR Strings[292] #define user6 CUR Strings[293] #define user7 CUR Strings[294] #define user8 CUR Strings[295] #define user9 CUR Strings[296] #define orig_pair CUR Strings[297] #define orig_colors CUR Strings[298] #define initialize_color CUR Strings[299] #define initialize_pair CUR Strings[300] #define set_color_pair CUR Strings[301] #define set_foreground CUR Strings[302] #define set_background CUR Strings[303] #define change_char_pitch CUR Strings[304] #define change_line_pitch CUR Strings[305] #define change_res_horz CUR Strings[306] #define change_res_vert CUR Strings[307] #define define_char CUR Strings[308] #define enter_doublewide_mode CUR Strings[309] #define enter_draft_quality CUR Strings[310] #define enter_italics_mode CUR Strings[311] #define enter_leftward_mode CUR Strings[312] #define enter_micro_mode CUR Strings[313] #define enter_near_letter_quality CUR Strings[314] #define enter_normal_quality CUR Strings[315] #define enter_shadow_mode CUR Strings[316] #define enter_subscript_mode CUR Strings[317] #define enter_superscript_mode CUR Strings[318] #define enter_upward_mode CUR Strings[319] #define exit_doublewide_mode CUR Strings[320] #define exit_italics_mode CUR Strings[321] #define exit_leftward_mode CUR Strings[322] #define exit_micro_mode CUR Strings[323] #define exit_shadow_mode CUR Strings[324] #define exit_subscript_mode CUR Strings[325] #define exit_superscript_mode CUR Strings[326] #define exit_upward_mode CUR Strings[327] #define micro_column_address CUR Strings[328] #define micro_down CUR Strings[329] #define micro_left CUR Strings[330] #define micro_right CUR Strings[331] #define micro_row_address CUR Strings[332] #define micro_up CUR Strings[333] #define order_of_pins CUR Strings[334] #define parm_down_micro CUR Strings[335] #define parm_left_micro CUR Strings[336] #define parm_right_micro CUR Strings[337] #define parm_up_micro CUR Strings[338] #define select_char_set CUR Strings[339] #define set_bottom_margin CUR Strings[340] #define set_bottom_margin_parm CUR Strings[341] #define set_left_margin_parm CUR Strings[342] #define set_right_margin_parm CUR Strings[343] #define set_top_margin CUR Strings[344] #define set_top_margin_parm CUR Strings[345] #define start_bit_image CUR Strings[346] #define start_char_set_def CUR Strings[347] #define stop_bit_image CUR Strings[348] #define stop_char_set_def CUR Strings[349] #define subscript_characters CUR Strings[350] #define superscript_characters CUR Strings[351] #define these_cause_cr CUR Strings[352] #define zero_motion CUR Strings[353] #define char_set_names CUR Strings[354] #define key_mouse CUR Strings[355] #define mouse_info CUR Strings[356] #define req_mouse_pos CUR Strings[357] #define get_mouse CUR Strings[358] #define set_a_foreground CUR Strings[359] #define set_a_background CUR Strings[360] #define pkey_plab CUR Strings[361] #define device_type CUR Strings[362] #define code_set_init CUR Strings[363] #define set0_des_seq CUR Strings[364] #define set1_des_seq CUR Strings[365] #define set2_des_seq CUR Strings[366] #define set3_des_seq CUR Strings[367] #define set_lr_margin CUR Strings[368] #define set_tb_margin CUR Strings[369] #define bit_image_repeat CUR Strings[370] #define bit_image_newline CUR Strings[371] #define bit_image_carriage_return CUR Strings[372] #define color_names CUR Strings[373] #define define_bit_image_region CUR Strings[374] #define end_bit_image_region CUR Strings[375] #define set_color_band CUR Strings[376] #define set_page_length CUR Strings[377] #define display_pc_char CUR Strings[378] #define enter_pc_charset_mode CUR Strings[379] #define exit_pc_charset_mode CUR Strings[380] #define enter_scancode_mode CUR Strings[381] #define exit_scancode_mode CUR Strings[382] #define pc_term_options CUR Strings[383] #define scancode_escape CUR Strings[384] #define alt_scancode_esc CUR Strings[385] #define enter_horizontal_hl_mode CUR Strings[386] #define enter_left_hl_mode CUR Strings[387] #define enter_low_hl_mode CUR Strings[388] #define enter_right_hl_mode CUR Strings[389] #define enter_top_hl_mode CUR Strings[390] #define enter_vertical_hl_mode CUR Strings[391] #define set_a_attributes CUR Strings[392] #define set_pglen_inch CUR Strings[393] #define BOOLWRITE 37 #define NUMWRITE 33 #define STRWRITE 394 /* older synonyms for some capabilities */ #define beehive_glitch no_esc_ctlc #define teleray_glitch dest_tabs_magic_smso /* HPUX-11 uses this name rather than the standard one */ #ifndef micro_char_size #define micro_char_size micro_col_size #endif #ifdef __INTERNAL_CAPS_VISIBLE #define termcap_init2 CUR Strings[394] #define termcap_reset CUR Strings[395] #define magic_cookie_glitch_ul CUR Numbers[33] #define backspaces_with_bs CUR Booleans[37] #define crt_no_scrolling CUR Booleans[38] #define no_correctly_working_cr CUR Booleans[39] #define carriage_return_delay CUR Numbers[34] #define new_line_delay CUR Numbers[35] #define linefeed_if_not_lf CUR Strings[396] #define backspace_if_not_bs CUR Strings[397] #define gnu_has_meta_key CUR Booleans[40] #define linefeed_is_newline CUR Booleans[41] #define backspace_delay CUR Numbers[36] #define horizontal_tab_delay CUR Numbers[37] #define number_of_function_keys CUR Numbers[38] #define other_non_function_keys CUR Strings[398] #define arrow_key_map CUR Strings[399] #define has_hardware_tabs CUR Booleans[42] #define return_does_clr_eol CUR Booleans[43] #define acs_ulcorner CUR Strings[400] #define acs_llcorner CUR Strings[401] #define acs_urcorner CUR Strings[402] #define acs_lrcorner CUR Strings[403] #define acs_ltee CUR Strings[404] #define acs_rtee CUR Strings[405] #define acs_btee CUR Strings[406] #define acs_ttee CUR Strings[407] #define acs_hline CUR Strings[408] #define acs_vline CUR Strings[409] #define acs_plus CUR Strings[410] #define memory_lock CUR Strings[411] #define memory_unlock CUR Strings[412] #define box_chars_1 CUR Strings[413] #endif /* __INTERNAL_CAPS_VISIBLE */ /* * Predefined terminfo array sizes */ #define BOOLCOUNT 44 #define NUMCOUNT 39 #define STRCOUNT 414 /* used by code for comparing entries */ #define acs_chars_index 146 typedef struct termtype { /* in-core form of terminfo data */ char *term_names; /* str_table offset of term names */ char *str_table; /* pointer to string table */ NCURSES_SBOOL *Booleans; /* array of boolean values */ short *Numbers; /* array of integer values */ char **Strings; /* array of string offsets */ #if NCURSES_XNAMES char *ext_str_table; /* pointer to extended string table */ char **ext_Names; /* corresponding names */ unsigned short num_Booleans;/* count total Booleans */ unsigned short num_Numbers; /* count total Numbers */ unsigned short num_Strings; /* count total Strings */ unsigned short ext_Booleans;/* count extensions to Booleans */ unsigned short ext_Numbers; /* count extensions to Numbers */ unsigned short ext_Strings; /* count extensions to Strings */ #endif /* NCURSES_XNAMES */ } TERMTYPE; /* * The only reason these structures are visible is for read-only use. * Programs which modify the data are not, never were, portable across * curses implementations. */ #ifdef NCURSES_INTERNALS typedef struct termtype2 { /* in-core form of terminfo data */ char *term_names; /* str_table offset of term names */ char *str_table; /* pointer to string table */ NCURSES_SBOOL *Booleans; /* array of boolean values */ int *Numbers; /* array of integer values */ char **Strings; /* array of string offsets */ #if NCURSES_XNAMES char *ext_str_table; /* pointer to extended string table */ char **ext_Names; /* corresponding names */ unsigned short num_Booleans;/* count total Booleans */ unsigned short num_Numbers; /* count total Numbers */ unsigned short num_Strings; /* count total Strings */ unsigned short ext_Booleans;/* count extensions to Booleans */ unsigned short ext_Numbers; /* count extensions to Numbers */ unsigned short ext_Strings; /* count extensions to Strings */ #endif /* NCURSES_XNAMES */ } TERMTYPE2; typedef struct term { /* describe an actual terminal */ TERMTYPE type; /* terminal type description */ short Filedes; /* file description being written to */ TTY Ottyb; /* original state of the terminal */ TTY Nttyb; /* current state of the terminal */ int _baudrate; /* used to compute padding */ char * _termname; /* used for termname() */ TERMTYPE2 type2; /* extended terminal type description */ } TERMINAL; #else typedef struct term TERMINAL; #endif /* NCURSES_INTERNALS */ #if 0 && !0 extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term; #elif 0 NCURSES_WRAPPED_VAR(TERMINAL *, cur_term); #define cur_term NCURSES_PUBLIC_VAR(cur_term()) #else extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term; #endif #if 0 || 0 NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames); #define boolnames NCURSES_PUBLIC_VAR(boolnames()) #define boolcodes NCURSES_PUBLIC_VAR(boolcodes()) #define boolfnames NCURSES_PUBLIC_VAR(boolfnames()) #define numnames NCURSES_PUBLIC_VAR(numnames()) #define numcodes NCURSES_PUBLIC_VAR(numcodes()) #define numfnames NCURSES_PUBLIC_VAR(numfnames()) #define strnames NCURSES_PUBLIC_VAR(strnames()) #define strcodes NCURSES_PUBLIC_VAR(strcodes()) #define strfnames NCURSES_PUBLIC_VAR(strfnames()) #else extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[]; #endif /* * These entrypoints are used only by the ncurses utilities such as tic. */ #ifdef NCURSES_INTERNALS extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf); extern NCURSES_EXPORT(int) _nc_read_entry2 (const char * const, char * const, TERMTYPE2 *const); extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE2 *); extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE2 *, char *, int); extern NCURSES_EXPORT(char *) _nc_first_name (const char *const); extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const); extern NCURSES_EXPORT(char *) _nc_tiparm(int, const char *, ...); #endif /* NCURSES_INTERNALS */ /* * These entrypoints are used by tack 1.07. */ extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *); extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const); /* * Normal entry points */ extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *); extern NCURSES_EXPORT(int) del_curterm (TERMINAL *); /* miscellaneous entry points */ extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *); extern NCURSES_EXPORT(int) setupterm (const char *,int,int *); /* terminfo entry points, also declared in curses.h */ #if !defined(__NCURSES_H) extern NCURSES_EXPORT(char *) tigetstr (const char *); extern NCURSES_EXPORT_VAR(char) ttytype[]; extern NCURSES_EXPORT(int) putp (const char *); extern NCURSES_EXPORT(int) tigetflag (const char *); extern NCURSES_EXPORT(int) tigetnum (const char *); #if 1 /* NCURSES_TPARM_VARARGS */ extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */ #else extern NCURSES_EXPORT(char *) tparm (const char *, long,long,long,long,long,long,long,long,long); /* special */ #endif extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */ #endif /* __NCURSES_H */ /* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */ #if !defined(NCURSES_TERMCAP_H_incl) extern NCURSES_EXPORT(char *) tgetstr (const char *, char **); extern NCURSES_EXPORT(char *) tgoto (const char *, int, int); extern NCURSES_EXPORT(int) tgetent (char *, const char *); extern NCURSES_EXPORT(int) tgetflag (const char *); extern NCURSES_EXPORT(int) tgetnum (const char *); extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int)); #endif /* NCURSES_TERMCAP_H_incl */ /* * Include curses.h before term.h to enable these extensions. */ #if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0) extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tigetstr) (SCREEN*, const char *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(putp) (SCREEN*, const char *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetflag) (SCREEN*, const char *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetnum) (SCREEN*, const char *); #if 1 /* NCURSES_TPARM_VARARGS */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, ...); /* special */ #else extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, long,long,long,long,long,long,long,long,long); /* special */ #endif /* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgetstr) (SCREEN*, const char *, char **); extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetflag) (SCREEN*, const char *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetnum) (SCREEN*, const char *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC); extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *); #endif /* NCURSES_SP_FUNCS */ /* * Debugging features. */ extern GCC_NORETURN NCURSES_EXPORT(void) exit_terminfo(int); #ifdef __cplusplus } #endif #endif /* NCURSES_TERM_H_incl */ /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Thomas E. Dickey 1996-on * ****************************************************************************/ /* $Id: curses.h.in,v 1.271 2021/03/20 16:25:43 tom Exp $ */ #ifndef __NCURSES_H #define __NCURSES_H #define CURSES 1 #define CURSES_H 1 /* These are defined only in curses.h, and are used for conditional compiles */ #define NCURSES_VERSION_MAJOR 6 #define NCURSES_VERSION_MINOR 2 #define NCURSES_VERSION_PATCH 20210508 /* This is defined in more than one ncurses header, for identification */ #undef NCURSES_VERSION #define NCURSES_VERSION "6.2" /* * Identify the mouse encoding version. */ #define NCURSES_MOUSE_VERSION 2 /* * Definitions to facilitate DLL's. */ #include <ncurses_dll.h> /* * Extra headers. */ #if 1 #include <stdint.h> #endif #ifdef __cplusplus #else #if 0 #include <stdnoreturn.h> #undef GCC_NORETURN #define GCC_NORETURN _Noreturn #endif #endif /* * User-definable tweak to disable the include of <stdbool.h>. */ #ifndef NCURSES_ENABLE_STDBOOL_H #define NCURSES_ENABLE_STDBOOL_H 1 #endif /* * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses * configured using --disable-macros. */ #ifndef NCURSES_ATTR_T #define NCURSES_ATTR_T int #endif /* * Expands to 'const' if ncurses is configured using --enable-const. Note that * doing so makes it incompatible with other implementations of X/Open Curses. */ #undef NCURSES_CONST #define NCURSES_CONST const #undef NCURSES_INLINE #define NCURSES_INLINE inline /* * The standard type used for color values, and for color-pairs. The latter * allows the curses library to enumerate the combinations of foreground and * background colors used by an application, and is normally the product of the * total foreground and background colors. * * X/Open uses "short" for both of these types, ultimately because they are * numbers from the SVr4 terminal database, which uses 16-bit signed values. */ #undef NCURSES_COLOR_T #define NCURSES_COLOR_T short #undef NCURSES_PAIRS_T #define NCURSES_PAIRS_T short /* * Definitions used to make WINDOW and similar structs opaque. */ #ifndef NCURSES_INTERNALS #define NCURSES_OPAQUE 0 #define NCURSES_OPAQUE_FORM 0 #define NCURSES_OPAQUE_MENU 0 #define NCURSES_OPAQUE_PANEL 0 #endif /* * Definition used to optionally suppress wattr* macros to help with the * transition from ncurses5 to ncurses6 by allowing the header files to * be shared across development packages for ncursesw in both ABIs. */ #ifndef NCURSES_WATTR_MACROS #define NCURSES_WATTR_MACROS 0 #endif /* * The reentrant code relies on the opaque setting, but adds features. */ #ifndef NCURSES_REENTRANT #define NCURSES_REENTRANT 0 #endif /* * In certain environments, we must work around linker problems for data */ #undef NCURSES_BROKEN_LINKER #if 0 #define NCURSES_BROKEN_LINKER 1 #endif /* * Control whether bindings for interop support are added. */ #undef NCURSES_INTEROP_FUNCS #define NCURSES_INTEROP_FUNCS 1 /* * The internal type used for window dimensions. */ #undef NCURSES_SIZE_T #define NCURSES_SIZE_T short /* * Control whether tparm() supports varargs or fixed-parameter list. */ #undef NCURSES_TPARM_VARARGS #define NCURSES_TPARM_VARARGS 1 /* * Control type used for tparm's arguments. While X/Open equates long and * char* values, this is not always workable for 64-bit platforms. */ #undef NCURSES_TPARM_ARG #define NCURSES_TPARM_ARG intptr_t /* * Control whether ncurses uses wcwidth() for checking width of line-drawing * characters. */ #undef NCURSES_WCWIDTH_GRAPHICS #define NCURSES_WCWIDTH_GRAPHICS 1 /* * NCURSES_CH_T is used in building the library, but not used otherwise in * this header file, since that would make the normal/wide-character versions * of the header incompatible. */ #undef NCURSES_CH_T #define NCURSES_CH_T cchar_t #if 1 && defined(_LP64) typedef unsigned chtype; typedef unsigned mmask_t; #else typedef uint32_t chtype; typedef uint32_t mmask_t; #endif /* * We need FILE, etc. Include this before checking any feature symbols. */ #include <stdio.h> /* * With XPG4, you must define _XOPEN_SOURCE_EXTENDED, it is redundant (or * conflicting) when _XOPEN_SOURCE is 500 or greater. If NCURSES_WIDECHAR is * not already defined, e.g., if the platform relies upon nonstandard feature * test macros, define it at this point if the standard feature test macros * indicate that it should be defined. */ #ifndef NCURSES_WIDECHAR #if defined(_XOPEN_SOURCE_EXTENDED) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) #define NCURSES_WIDECHAR 1 #else #define NCURSES_WIDECHAR 0 #endif #endif /* NCURSES_WIDECHAR */ #include <stdarg.h> /* we need va_list */ #if NCURSES_WIDECHAR #include <stddef.h> /* we want wchar_t */ #endif /* X/Open and SVr4 specify that curses implements 'bool'. However, C++ may also * implement it. If so, we must use the C++ compiler's type to avoid conflict * with other interfaces. * * A further complication is that <stdbool.h> may declare 'bool' to be a * different type, such as an enum which is not necessarily compatible with * C++. If we have <stdbool.h>, make 'bool' a macro, so users may #undef it. * Otherwise, let it remain a typedef to avoid conflicts with other #define's. * In either case, make a typedef for NCURSES_BOOL which can be used if needed * from either C or C++. */ #undef TRUE #define TRUE 1 #undef FALSE #define FALSE 0 typedef unsigned char NCURSES_BOOL; #if defined(__cplusplus) /* __cplusplus, etc. */ /* use the C++ compiler's bool type */ #define NCURSES_BOOL bool #else /* c89, c99, etc. */ #if NCURSES_ENABLE_STDBOOL_H #include <stdbool.h> /* use whatever the C compiler decides bool really is */ #define NCURSES_BOOL bool #else /* there is no predefined bool - use our own */ #undef bool #define bool NCURSES_BOOL #endif #endif /* !__cplusplus, etc. */ #ifdef __cplusplus extern "C" { #define NCURSES_CAST(type,value) static_cast<type>(value) #else #define NCURSES_CAST(type,value) (type)(value) #endif #define NCURSES_OK_ADDR(p) (0 != NCURSES_CAST(const void *, (p))) /* * X/Open attributes. In the ncurses implementation, they are identical to the * A_ attributes. */ #define WA_ATTRIBUTES A_ATTRIBUTES #define WA_NORMAL A_NORMAL #define WA_STANDOUT A_STANDOUT #define WA_UNDERLINE A_UNDERLINE #define WA_REVERSE A_REVERSE #define WA_BLINK A_BLINK #define WA_DIM A_DIM #define WA_BOLD A_BOLD #define WA_ALTCHARSET A_ALTCHARSET #define WA_INVIS A_INVIS #define WA_PROTECT A_PROTECT #define WA_HORIZONTAL A_HORIZONTAL #define WA_LEFT A_LEFT #define WA_LOW A_LOW #define WA_RIGHT A_RIGHT #define WA_TOP A_TOP #define WA_VERTICAL A_VERTICAL #if 1 #define WA_ITALIC A_ITALIC /* ncurses extension */ #endif /* colors */ #define COLOR_BLACK 0 #define COLOR_RED 1 #define COLOR_GREEN 2 #define COLOR_YELLOW 3 #define COLOR_BLUE 4 #define COLOR_MAGENTA 5 #define COLOR_CYAN 6 #define COLOR_WHITE 7 /* line graphics */ #if 0 || NCURSES_REENTRANT NCURSES_WRAPPED_VAR(chtype*, acs_map); #define acs_map NCURSES_PUBLIC_VAR(acs_map()) #else extern NCURSES_EXPORT_VAR(chtype) acs_map[]; #endif #define NCURSES_ACS(c) (acs_map[NCURSES_CAST(unsigned char,(c))]) /* VT100 symbols begin here */ #define ACS_ULCORNER NCURSES_ACS('l') /* upper left corner */ #define ACS_LLCORNER NCURSES_ACS('m') /* lower left corner */ #define ACS_URCORNER NCURSES_ACS('k') /* upper right corner */ #define ACS_LRCORNER NCURSES_ACS('j') /* lower right corner */ #define ACS_LTEE NCURSES_ACS('t') /* tee pointing right */ #define ACS_RTEE NCURSES_ACS('u') /* tee pointing left */ #define ACS_BTEE NCURSES_ACS('v') /* tee pointing up */ #define ACS_TTEE NCURSES_ACS('w') /* tee pointing down */ #define ACS_HLINE NCURSES_ACS('q') /* horizontal line */ #define ACS_VLINE NCURSES_ACS('x') /* vertical line */ #define ACS_PLUS NCURSES_ACS('n') /* large plus or crossover */ #define ACS_S1 NCURSES_ACS('o') /* scan line 1 */ #define ACS_S9 NCURSES_ACS('s') /* scan line 9 */ #define ACS_DIAMOND NCURSES_ACS('`') /* diamond */ #define ACS_CKBOARD NCURSES_ACS('a') /* checker board (stipple) */ #define ACS_DEGREE NCURSES_ACS('f') /* degree symbol */ #define ACS_PLMINUS NCURSES_ACS('g') /* plus/minus */ #define ACS_BULLET NCURSES_ACS('~') /* bullet */ /* Teletype 5410v1 symbols begin here */ #define ACS_LARROW NCURSES_ACS(',') /* arrow pointing left */ #define ACS_RARROW NCURSES_ACS('+') /* arrow pointing right */ #define ACS_DARROW NCURSES_ACS('.') /* arrow pointing down */ #define ACS_UARROW NCURSES_ACS('-') /* arrow pointing up */ #define ACS_BOARD NCURSES_ACS('h') /* board of squares */ #define ACS_LANTERN NCURSES_ACS('i') /* lantern symbol */ #define ACS_BLOCK NCURSES_ACS('0') /* solid square block */ /* * These aren't documented, but a lot of System Vs have them anyway * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings). * The ACS_names may not match AT&T's, our source didn't know them. */ #define ACS_S3 NCURSES_ACS('p') /* scan line 3 */ #define ACS_S7 NCURSES_ACS('r') /* scan line 7 */ #define ACS_LEQUAL NCURSES_ACS('y') /* less/equal */ #define ACS_GEQUAL NCURSES_ACS('z') /* greater/equal */ #define ACS_PI NCURSES_ACS('{') /* Pi */ #define ACS_NEQUAL NCURSES_ACS('|') /* not equal */ #define ACS_STERLING NCURSES_ACS('}') /* UK pound sign */ /* * Line drawing ACS names are of the form ACS_trbl, where t is the top, r * is the right, b is the bottom, and l is the left. t, r, b, and l might * be B (blank), S (single), D (double), or T (thick). The subset defined * here only uses B and S. */ #define ACS_BSSB ACS_ULCORNER #define ACS_SSBB ACS_LLCORNER #define ACS_BBSS ACS_URCORNER #define ACS_SBBS ACS_LRCORNER #define ACS_SBSS ACS_RTEE #define ACS_SSSB ACS_LTEE #define ACS_SSBS ACS_BTEE #define ACS_BSSS ACS_TTEE #define ACS_BSBS ACS_HLINE #define ACS_SBSB ACS_VLINE #define ACS_SSSS ACS_PLUS #undef ERR #define ERR (-1) #undef OK #define OK (0) /* values for the _flags member */ #define _SUBWIN 0x01 /* is this a sub-window? */ #define _ENDLINE 0x02 /* is the window flush right? */ #define _FULLWIN 0x04 /* is the window full-screen? */ #define _SCROLLWIN 0x08 /* bottom edge is at screen bottom? */ #define _ISPAD 0x10 /* is this window a pad? */ #define _HASMOVED 0x20 /* has cursor moved since last refresh? */ #define _WRAPPED 0x40 /* cursor was just wrappped */ /* * this value is used in the firstchar and lastchar fields to mark * unchanged lines */ #define _NOCHANGE -1 /* * this value is used in the oldindex field to mark lines created by insertions * and scrolls. */ #define _NEWINDEX -1 typedef struct screen SCREEN; typedef struct _win_st WINDOW; typedef chtype attr_t; /* ...must be at least as wide as chtype */ #if NCURSES_WIDECHAR #if 0 #ifdef mblen /* libutf8.h defines it w/o undefining first */ #undef mblen #endif #include <libutf8.h> #endif #if 1 #include <wchar.h> /* ...to get mbstate_t, etc. */ #endif #if 0 typedef unsigned short wchar_t1; #endif #if 0 typedef unsigned int wint_t1; #endif /* * cchar_t stores an array of CCHARW_MAX wide characters. The first is * normally a spacing character. The others are non-spacing. If those * (spacing and nonspacing) do not fill the array, a null L'\0' follows. * Otherwise, a null is assumed to follow when extracting via getcchar(). */ #define CCHARW_MAX 5 typedef struct { attr_t attr; wchar_t chars[CCHARW_MAX]; #if 1 #undef NCURSES_EXT_COLORS #define NCURSES_EXT_COLORS 20210508 int ext_color; /* color pair, must be more than 16-bits */ #endif } cchar_t; #endif /* NCURSES_WIDECHAR */ #if !NCURSES_OPAQUE struct ldat; struct _win_st { NCURSES_SIZE_T _cury, _curx; /* current cursor position */ /* window location and size */ NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */ NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */ short _flags; /* window state flags */ /* attribute tracking */ attr_t _attrs; /* current attribute for non-space character */ chtype _bkgd; /* current background char/attribute pair */ /* option values set by user */ bool _notimeout; /* no time out on function-key entry? */ bool _clear; /* consider all data in the window invalid? */ bool _leaveok; /* OK to not reset cursor on exit? */ bool _scroll; /* OK to scroll this window? */ bool _idlok; /* OK to use insert/delete line? */ bool _idcok; /* OK to use insert/delete char? */ bool _immed; /* window in immed mode? (not yet used) */ bool _sync; /* window in sync mode? */ bool _use_keypad; /* process function keys into KEY_ symbols? */ int _delay; /* 0 = nodelay, <0 = blocking, >0 = delay */ struct ldat *_line; /* the actual line data */ /* global screen state */ NCURSES_SIZE_T _regtop; /* top line of scrolling region */ NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */ /* these are used only if this is a sub-window */ int _parx; /* x coordinate of this window in parent */ int _pary; /* y coordinate of this window in parent */ WINDOW *_parent; /* pointer to parent if a sub-window */ /* these are used only if this is a pad */ struct pdat { NCURSES_SIZE_T _pad_y, _pad_x; NCURSES_SIZE_T _pad_top, _pad_left; NCURSES_SIZE_T _pad_bottom, _pad_right; } _pad; NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */ #if NCURSES_WIDECHAR cchar_t _bkgrnd; /* current background char/attribute pair */ #if 1 int _color; /* current color-pair for non-space character */ #endif #endif }; #endif /* NCURSES_OPAQUE */ /* * GCC (and some other compilers) define '__attribute__'; we're using this * macro to alert the compiler to flag inconsistencies in printf/scanf-like * function calls. Just in case '__attribute__' isn't defined, make a dummy. * Old versions of G++ do not accept it anyway, at least not consistently with * GCC. */ #if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__)) #define __attribute__(p) /* nothing */ #endif /* * We cannot define these in ncurses_cfg.h, since they require parameters to be * passed (that is non-portable). If you happen to be using gcc with warnings * enabled, define * GCC_PRINTF * GCC_SCANF * to improve checking of calls to printw(), etc. */ #ifndef GCC_PRINTFLIKE #if defined(GCC_PRINTF) && !defined(printf) #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) #else #define GCC_PRINTFLIKE(fmt,var) /*nothing*/ #endif #endif #ifndef GCC_SCANFLIKE #if defined(GCC_SCANF) && !defined(scanf) #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) #else #define GCC_SCANFLIKE(fmt,var) /*nothing*/ #endif #endif #ifndef GCC_NORETURN #define GCC_NORETURN /* nothing */ #endif #ifndef GCC_UNUSED #define GCC_UNUSED /* nothing */ #endif #undef GCC_DEPRECATED #if (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)) && !defined(NCURSES_INTERNALS) #define GCC_DEPRECATED(msg) __attribute__((deprecated)) #else #define GCC_DEPRECATED(msg) /* nothing */ #endif /* * Curses uses a helper function. Define our type for this to simplify * extending it for the sp-funcs feature. */ typedef int (*NCURSES_OUTC)(int); /* * Function prototypes. This is the complete X/Open Curses list of required * functions. Those marked `generated' will have sources generated from the * macro definitions later in this file, in order to satisfy XPG4.2 * requirements. */ extern NCURSES_EXPORT(int) addch (const chtype); /* generated */ extern NCURSES_EXPORT(int) addchnstr (const chtype *, int); /* generated */ extern NCURSES_EXPORT(int) addchstr (const chtype *); /* generated */ extern NCURSES_EXPORT(int) addnstr (const char *, int); /* generated */ extern NCURSES_EXPORT(int) addstr (const char *); /* generated */ extern NCURSES_EXPORT(int) attroff (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attron (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attr_get (attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ extern NCURSES_EXPORT(int) attr_off (attr_t, void *); /* generated */ extern NCURSES_EXPORT(int) attr_on (attr_t, void *); /* generated */ extern NCURSES_EXPORT(int) attr_set (attr_t, NCURSES_PAIRS_T, void *); /* generated */ extern NCURSES_EXPORT(int) baudrate (void); /* implemented */ extern NCURSES_EXPORT(int) beep (void); /* implemented */ extern NCURSES_EXPORT(int) bkgd (chtype); /* generated */ extern NCURSES_EXPORT(void) bkgdset (chtype); /* generated */ extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* generated */ extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype); /* generated */ extern NCURSES_EXPORT(bool) can_change_color (void); /* implemented */ extern NCURSES_EXPORT(int) cbreak (void); /* implemented */ extern NCURSES_EXPORT(int) chgat (int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ extern NCURSES_EXPORT(int) clear (void); /* generated */ extern NCURSES_EXPORT(int) clearok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) clrtobot (void); /* generated */ extern NCURSES_EXPORT(int) clrtoeol (void); /* generated */ extern NCURSES_EXPORT(int) color_content (NCURSES_COLOR_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ extern NCURSES_EXPORT(int) color_set (NCURSES_PAIRS_T,void*); /* generated */ extern NCURSES_EXPORT(int) COLOR_PAIR (int); /* generated */ extern NCURSES_EXPORT(int) copywin (const WINDOW*,WINDOW*,int,int,int,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) curs_set (int); /* implemented */ extern NCURSES_EXPORT(int) def_prog_mode (void); /* implemented */ extern NCURSES_EXPORT(int) def_shell_mode (void); /* implemented */ extern NCURSES_EXPORT(int) delay_output (int); /* implemented */ extern NCURSES_EXPORT(int) delch (void); /* generated */ extern NCURSES_EXPORT(void) delscreen (SCREEN *); /* implemented */ extern NCURSES_EXPORT(int) delwin (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) deleteln (void); /* generated */ extern NCURSES_EXPORT(WINDOW *) derwin (WINDOW *,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) doupdate (void); /* implemented */ extern NCURSES_EXPORT(WINDOW *) dupwin (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) echo (void); /* implemented */ extern NCURSES_EXPORT(int) echochar (const chtype); /* generated */ extern NCURSES_EXPORT(int) erase (void); /* generated */ extern NCURSES_EXPORT(int) endwin (void); /* implemented */ extern NCURSES_EXPORT(char) erasechar (void); /* implemented */ extern NCURSES_EXPORT(void) filter (void); /* implemented */ extern NCURSES_EXPORT(int) flash (void); /* implemented */ extern NCURSES_EXPORT(int) flushinp (void); /* implemented */ extern NCURSES_EXPORT(chtype) getbkgd (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getch (void); /* generated */ extern NCURSES_EXPORT(int) getnstr (char *, int); /* generated */ extern NCURSES_EXPORT(int) getstr (char *); /* generated */ extern NCURSES_EXPORT(WINDOW *) getwin (FILE *); /* implemented */ extern NCURSES_EXPORT(int) halfdelay (int); /* implemented */ extern NCURSES_EXPORT(bool) has_colors (void); /* implemented */ extern NCURSES_EXPORT(bool) has_ic (void); /* implemented */ extern NCURSES_EXPORT(bool) has_il (void); /* implemented */ extern NCURSES_EXPORT(int) hline (chtype, int); /* generated */ extern NCURSES_EXPORT(void) idcok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(int) idlok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(void) immedok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(chtype) inch (void); /* generated */ extern NCURSES_EXPORT(int) inchnstr (chtype *, int); /* generated */ extern NCURSES_EXPORT(int) inchstr (chtype *); /* generated */ extern NCURSES_EXPORT(WINDOW *) initscr (void); /* implemented */ extern NCURSES_EXPORT(int) init_color (NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ extern NCURSES_EXPORT(int) init_pair (NCURSES_PAIRS_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ extern NCURSES_EXPORT(int) innstr (char *, int); /* generated */ extern NCURSES_EXPORT(int) insch (chtype); /* generated */ extern NCURSES_EXPORT(int) insdelln (int); /* generated */ extern NCURSES_EXPORT(int) insertln (void); /* generated */ extern NCURSES_EXPORT(int) insnstr (const char *, int); /* generated */ extern NCURSES_EXPORT(int) insstr (const char *); /* generated */ extern NCURSES_EXPORT(int) instr (char *); /* generated */ extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(bool) isendwin (void); /* implemented */ extern NCURSES_EXPORT(bool) is_linetouched (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(bool) is_wintouched (WINDOW *); /* implemented */ extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int); /* implemented */ extern NCURSES_EXPORT(int) keypad (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(char) killchar (void); /* implemented */ extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(char *) longname (void); /* implemented */ extern NCURSES_EXPORT(int) meta (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) move (int, int); /* generated */ extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype); /* generated */ extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvaddchstr (int, int, const chtype *); /* generated */ extern NCURSES_EXPORT(int) mvaddnstr (int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvaddstr (int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ extern NCURSES_EXPORT(int) mvcur (int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) mvdelch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvderwin (WINDOW *, int, int); /* implemented */ extern NCURSES_EXPORT(int) mvgetch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvgetnstr (int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvgetstr (int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(chtype) mvinch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvinchnstr (int, int, chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvinchstr (int, int, chtype *); /* generated */ extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvinsch (int, int, chtype); /* generated */ extern NCURSES_EXPORT(int) mvinsnstr (int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvinsstr (int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvinstr (int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...) /* implemented */ GCC_PRINTFLIKE(3,4); extern NCURSES_EXPORT(int) mvscanw (int,int, const char *,...) /* implemented */ GCC_SCANFLIKE(3,4); extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype); /* generated */ extern NCURSES_EXPORT(int) mvwaddchnstr (WINDOW *, int, int, const chtype *, int);/* generated */ extern NCURSES_EXPORT(int) mvwaddchstr (WINDOW *, int, int, const chtype *); /* generated */ extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwaddstr (WINDOW *, int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, NCURSES_PAIRS_T, const void *);/* generated */ extern NCURSES_EXPORT(int) mvwdelch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetnstr (WINDOW *, int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) mvwin (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(chtype) mvwinch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwinchnstr (WINDOW *, int, int, chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinchstr (WINDOW *, int, int, chtype *); /* generated */ extern NCURSES_EXPORT(int) mvwinnstr (WINDOW *, int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinsch (WINDOW *, int, int, chtype); /* generated */ extern NCURSES_EXPORT(int) mvwinsnstr (WINDOW *, int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinsstr (WINDOW *, int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...) /* implemented */ GCC_PRINTFLIKE(4,5); extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, const char *,...) /* implemented */ GCC_SCANFLIKE(4,5); extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) napms (int); /* implemented */ extern NCURSES_EXPORT(WINDOW *) newpad (int,int); /* implemented */ extern NCURSES_EXPORT(SCREEN *) newterm (const char *,FILE *,FILE *); /* implemented */ extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) nl (void); /* implemented */ extern NCURSES_EXPORT(int) nocbreak (void); /* implemented */ extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) noecho (void); /* implemented */ extern NCURSES_EXPORT(int) nonl (void); /* implemented */ extern NCURSES_EXPORT(void) noqiflush (void); /* implemented */ extern NCURSES_EXPORT(int) noraw (void); /* implemented */ extern NCURSES_EXPORT(int) notimeout (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) overlay (const WINDOW*,WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) pair_content (NCURSES_PAIRS_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ extern NCURSES_EXPORT(int) PAIR_NUMBER (int); /* generated */ extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) pnoutrefresh (WINDOW*,int,int,int,int,int,int);/* implemented */ extern NCURSES_EXPORT(int) prefresh (WINDOW *,int,int,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) printw (const char *,...) /* implemented */ GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *); /* implemented */ extern NCURSES_EXPORT(void) qiflush (void); /* implemented */ extern NCURSES_EXPORT(int) raw (void); /* implemented */ extern NCURSES_EXPORT(int) redrawwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) refresh (void); /* generated */ extern NCURSES_EXPORT(int) resetty (void); /* implemented */ extern NCURSES_EXPORT(int) reset_prog_mode (void); /* implemented */ extern NCURSES_EXPORT(int) reset_shell_mode (void); /* implemented */ extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int)); /* implemented */ extern NCURSES_EXPORT(int) savetty (void); /* implemented */ extern NCURSES_EXPORT(int) scanw (const char *,...) /* implemented */ GCC_SCANFLIKE(1,2); extern NCURSES_EXPORT(int) scr_dump (const char *); /* implemented */ extern NCURSES_EXPORT(int) scr_init (const char *); /* implemented */ extern NCURSES_EXPORT(int) scrl (int); /* generated */ extern NCURSES_EXPORT(int) scroll (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) scrollok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) scr_restore (const char *); /* implemented */ extern NCURSES_EXPORT(int) scr_set (const char *); /* implemented */ extern NCURSES_EXPORT(int) setscrreg (int,int); /* generated */ extern NCURSES_EXPORT(SCREEN *) set_term (SCREEN *); /* implemented */ extern NCURSES_EXPORT(int) slk_attroff (const chtype); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_off (const attr_t, void *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) slk_attron (const chtype); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_on (attr_t,void*); /* generated:WIDEC */ extern NCURSES_EXPORT(int) slk_attrset (const chtype); /* implemented */ extern NCURSES_EXPORT(attr_t) slk_attr (void); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_set (const attr_t,NCURSES_PAIRS_T,void*); /* implemented */ extern NCURSES_EXPORT(int) slk_clear (void); /* implemented */ extern NCURSES_EXPORT(int) slk_color (NCURSES_PAIRS_T); /* implemented */ extern NCURSES_EXPORT(int) slk_init (int); /* implemented */ extern NCURSES_EXPORT(char *) slk_label (int); /* implemented */ extern NCURSES_EXPORT(int) slk_noutrefresh (void); /* implemented */ extern NCURSES_EXPORT(int) slk_refresh (void); /* implemented */ extern NCURSES_EXPORT(int) slk_restore (void); /* implemented */ extern NCURSES_EXPORT(int) slk_set (int,const char *,int); /* implemented */ extern NCURSES_EXPORT(int) slk_touch (void); /* implemented */ extern NCURSES_EXPORT(int) standout (void); /* generated */ extern NCURSES_EXPORT(int) standend (void); /* generated */ extern NCURSES_EXPORT(int) start_color (void); /* implemented */ extern NCURSES_EXPORT(WINDOW *) subpad (WINDOW *, int, int, int, int); /* implemented */ extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *, int, int, int, int); /* implemented */ extern NCURSES_EXPORT(int) syncok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(chtype) termattrs (void); /* implemented */ extern NCURSES_EXPORT(char *) termname (void); /* implemented */ extern NCURSES_EXPORT(void) timeout (int); /* generated */ extern NCURSES_EXPORT(int) touchline (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) touchwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) typeahead (int); /* implemented */ extern NCURSES_EXPORT(int) ungetch (int); /* implemented */ extern NCURSES_EXPORT(int) untouchwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(void) use_env (bool); /* implemented */ extern NCURSES_EXPORT(void) use_tioctl (bool); /* implemented */ extern NCURSES_EXPORT(int) vidattr (chtype); /* implemented */ extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC); /* implemented */ extern NCURSES_EXPORT(int) vline (chtype, int); /* generated */ extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_printw); /* implemented */ extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list); /* implemented */ extern NCURSES_EXPORT(int) vwscanw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_scanw); /* implemented */ extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, const char *,va_list); /* implemented */ extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int); /* implemented */ extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *); /* generated */ extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int); /* implemented */ extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *); /* generated */ extern NCURSES_EXPORT(int) wattron (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattroff (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattrset (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattr_get (WINDOW *, attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ extern NCURSES_EXPORT(int) wattr_on (WINDOW *, attr_t, void *); /* implemented */ extern NCURSES_EXPORT(int) wattr_off (WINDOW *, attr_t, void *); /* implemented */ extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, NCURSES_PAIRS_T, void *); /* generated */ extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype); /* implemented */ extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype); /* implemented */ extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* implemented */ extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, NCURSES_PAIRS_T, const void *);/* implemented */ extern NCURSES_EXPORT(int) wclear (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wclrtobot (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wclrtoeol (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wcolor_set (WINDOW*,NCURSES_PAIRS_T,void*); /* implemented */ extern NCURSES_EXPORT(void) wcursyncup (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wdelch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wdeleteln (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wechochar (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) werase (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wgetch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int); /* implemented */ extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *); /* generated */ extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int); /* implemented */ extern NCURSES_EXPORT(chtype) winch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) winchnstr (WINDOW *, chtype *, int); /* implemented */ extern NCURSES_EXPORT(int) winchstr (WINDOW *, chtype *); /* generated */ extern NCURSES_EXPORT(int) winnstr (WINDOW *, char *, int); /* implemented */ extern NCURSES_EXPORT(int) winsch (WINDOW *, chtype); /* implemented */ extern NCURSES_EXPORT(int) winsdelln (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) winsertln (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) winsnstr (WINDOW *, const char *,int); /* implemented */ extern NCURSES_EXPORT(int) winsstr (WINDOW *, const char *); /* generated */ extern NCURSES_EXPORT(int) winstr (WINDOW *, char *); /* generated */ extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wprintw (WINDOW *, const char *,...) /* implemented */ GCC_PRINTFLIKE(2,3); extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wrefresh (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wscanw (WINDOW *, const char *,...) /* implemented */ GCC_SCANFLIKE(2,3); extern NCURSES_EXPORT(int) wscrl (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wstandout (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wstandend (WINDOW *); /* generated */ extern NCURSES_EXPORT(void) wsyncdown (WINDOW *); /* implemented */ extern NCURSES_EXPORT(void) wsyncup (WINDOW *); /* implemented */ extern NCURSES_EXPORT(void) wtimeout (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) wtouchln (WINDOW *,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int); /* implemented */ /* * These are also declared in <term.h>: */ extern NCURSES_EXPORT(int) tigetflag (const char *); /* implemented */ extern NCURSES_EXPORT(int) tigetnum (const char *); /* implemented */ extern NCURSES_EXPORT(char *) tigetstr (const char *); /* implemented */ extern NCURSES_EXPORT(int) putp (const char *); /* implemented */ #if NCURSES_TPARM_VARARGS extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */ #else extern NCURSES_EXPORT(char *) tparm (const char *, NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG); /* special */ #endif extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */ /* * These functions are not in X/Open, but we use them in macro definitions: */ extern NCURSES_EXPORT(int) getattrs (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getcurx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getcury (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getbegx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getbegy (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getmaxx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getmaxy (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getparx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getpary (const WINDOW *); /* generated */ /* * vid_attr() was implemented originally based on a draft of X/Open curses. */ #if !NCURSES_WIDECHAR #define vid_attr(a,pair,opts) vidattr(a) #endif /* * These functions are extensions - not in X/Open Curses. */ #if 1 #undef NCURSES_EXT_FUNCS #define NCURSES_EXT_FUNCS 20210508 typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *); typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *); extern NCURSES_EXPORT(bool) is_term_resized (int, int); extern NCURSES_EXPORT(char *) keybound (int, int); extern NCURSES_EXPORT(const char *) curses_version (void); extern NCURSES_EXPORT(int) alloc_pair (int, int); extern NCURSES_EXPORT(int) assume_default_colors (int, int); extern NCURSES_EXPORT(int) define_key (const char *, int); extern NCURSES_EXPORT(int) extended_color_content(int, int *, int *, int *); extern NCURSES_EXPORT(int) extended_pair_content(int, int *, int *); extern NCURSES_EXPORT(int) extended_slk_color(int); extern NCURSES_EXPORT(int) find_pair (int, int); extern NCURSES_EXPORT(int) free_pair (int); extern NCURSES_EXPORT(int) get_escdelay (void); extern NCURSES_EXPORT(int) init_extended_color(int, int, int, int); extern NCURSES_EXPORT(int) init_extended_pair(int, int, int); extern NCURSES_EXPORT(int) key_defined (const char *); extern NCURSES_EXPORT(int) keyok (int, bool); extern NCURSES_EXPORT(void) reset_color_pairs (void); extern NCURSES_EXPORT(int) resize_term (int, int); extern NCURSES_EXPORT(int) resizeterm (int, int); extern NCURSES_EXPORT(int) set_escdelay (int); extern NCURSES_EXPORT(int) set_tabsize (int); extern NCURSES_EXPORT(int) use_default_colors (void); extern NCURSES_EXPORT(int) use_extended_names (bool); extern NCURSES_EXPORT(int) use_legacy_coding (int); extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *); extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *); extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int); extern NCURSES_EXPORT(void) nofilter(void); /* * These extensions provide access to information stored in the WINDOW even * when NCURSES_OPAQUE is set: */ extern NCURSES_EXPORT(WINDOW *) wgetparent (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_cleared (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_idcok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_idlok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_immedok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_keypad (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_leaveok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_nodelay (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_notimeout (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_pad (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_scrollok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_subwin (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_syncok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wgetdelay (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wgetscrreg (const WINDOW *, int *, int *); /* generated */ #else #define curses_version() NCURSES_VERSION #endif /* * Extra extension-functions, which pass a SCREEN pointer rather than using * a global variable SP. */ #if 1 #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 20210508 #define NCURSES_SP_NAME(name) name##_sp /* Define the sp-funcs helper function */ #define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC) typedef int (*NCURSES_SP_OUTC)(SCREEN*, int); extern NCURSES_EXPORT(SCREEN *) new_prescr (void); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(baudrate) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(beep) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(can_change_color) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(cbreak) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(color_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(delay_output) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(doupdate) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(echo) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(endwin) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char) NCURSES_SP_NAME(erasechar) (SCREEN*);/* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(filter) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flash) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flushinp) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(getwin) (SCREEN*, FILE *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(halfdelay) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_colors) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_ic) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_il) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_color) (SCREEN*, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_pair) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(intrflush) (SCREEN*, WINDOW*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(isendwin) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(keyname) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char) NCURSES_SP_NAME(killchar) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mvcur) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newpad) (SCREEN*, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, const char *, FILE *, FILE *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newwin) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nl) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noecho) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nonl) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(noqiflush) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noraw) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(pair_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(qiflush) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(raw) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resetty) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ripoffline) (SCREEN*, int, int (*)(WINDOW *, int)); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(savetty) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_init) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_restore) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_set) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attroff) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attron) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attrset) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(slk_attr) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attr_set) (SCREEN*, const attr_t, NCURSES_PAIRS_T, void*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_clear) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_color) (SCREEN*, NCURSES_PAIRS_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_init) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(slk_label) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_noutrefresh) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_refresh) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_restore) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_set) (SCREEN*, int, const char *, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_touch) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(start_color) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(termattrs) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(termname) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetch) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_env) (SCREEN*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_tioctl) (SCREEN*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ #if 1 extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(alloc_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_color_content) (SCREEN*, int, int *, int *, int *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_pair_content) (SCREEN*, int, int *, int *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_slk_color) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(find_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(free_pair) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_color) (SCREEN*, int, int, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_pair) (SCREEN*, int, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(is_term_resized) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined) (SCREEN*, const char *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */ /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(reset_color_pairs) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resize_term) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resizeterm) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_escdelay) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_tabsize) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_default_colors) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ #endif #else #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 0 #define NCURSES_SP_NAME(name) name #define NCURSES_SP_OUTC NCURSES_OUTC #endif /* attributes */ #define NCURSES_ATTR_SHIFT 8 #define NCURSES_BITS(mask,shift) (NCURSES_CAST(chtype,(mask)) << ((shift) + NCURSES_ATTR_SHIFT)) #define A_NORMAL (1U - 1U) #define A_ATTRIBUTES NCURSES_BITS(~(1U - 1U),0) #define A_CHARTEXT (NCURSES_BITS(1U,0) - 1U) #define A_COLOR NCURSES_BITS(((1U) << 8) - 1U,0) #define A_STANDOUT NCURSES_BITS(1U,8) #define A_UNDERLINE NCURSES_BITS(1U,9) #define A_REVERSE NCURSES_BITS(1U,10) #define A_BLINK NCURSES_BITS(1U,11) #define A_DIM NCURSES_BITS(1U,12) #define A_BOLD NCURSES_BITS(1U,13) #define A_ALTCHARSET NCURSES_BITS(1U,14) #define A_INVIS NCURSES_BITS(1U,15) #define A_PROTECT NCURSES_BITS(1U,16) #define A_HORIZONTAL NCURSES_BITS(1U,17) #define A_LEFT NCURSES_BITS(1U,18) #define A_LOW NCURSES_BITS(1U,19) #define A_RIGHT NCURSES_BITS(1U,20) #define A_TOP NCURSES_BITS(1U,21) #define A_VERTICAL NCURSES_BITS(1U,22) #if 1 #define A_ITALIC NCURSES_BITS(1U,23) /* ncurses extension */ #endif /* * Most of the pseudo functions are macros that either provide compatibility * with older versions of curses, or provide inline functionality to improve * performance. */ /* * These pseudo functions are always implemented as macros: */ #define getyx(win,y,x) (y = getcury(win), x = getcurx(win)) #define getbegyx(win,y,x) (y = getbegy(win), x = getbegx(win)) #define getmaxyx(win,y,x) (y = getmaxy(win), x = getmaxx(win)) #define getparyx(win,y,x) (y = getpary(win), x = getparx(win)) #define getsyx(y,x) do { if (newscr) { \ if (is_leaveok(newscr)) \ (y) = (x) = -1; \ else \ getyx(newscr,(y), (x)); \ } \ } while(0) #define setsyx(y,x) do { if (newscr) { \ if ((y) == -1 && (x) == -1) \ leaveok(newscr, TRUE); \ else { \ leaveok(newscr, FALSE); \ wmove(newscr, (y), (x)); \ } \ } \ } while(0) #ifndef NCURSES_NOMACROS /* * These miscellaneous pseudo functions are provided for compatibility: */ #define wgetstr(w, s) wgetnstr(w, s, -1) #define getnstr(s, n) wgetnstr(stdscr, s, (n)) #define setterm(term) setupterm(term, 1, (int *)0) #define fixterm() reset_prog_mode() #define resetterm() reset_shell_mode() #define saveterm() def_prog_mode() #define crmode() cbreak() #define nocrmode() nocbreak() #define gettmode() /* It seems older SYSV curses versions define these */ #if !NCURSES_OPAQUE #define getattrs(win) NCURSES_CAST(int, NCURSES_OK_ADDR(win) ? (win)->_attrs : A_NORMAL) #define getcurx(win) (NCURSES_OK_ADDR(win) ? (win)->_curx : ERR) #define getcury(win) (NCURSES_OK_ADDR(win) ? (win)->_cury : ERR) #define getbegx(win) (NCURSES_OK_ADDR(win) ? (win)->_begx : ERR) #define getbegy(win) (NCURSES_OK_ADDR(win) ? (win)->_begy : ERR) #define getmaxx(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxx + 1) : ERR) #define getmaxy(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxy + 1) : ERR) #define getparx(win) (NCURSES_OK_ADDR(win) ? (win)->_parx : ERR) #define getpary(win) (NCURSES_OK_ADDR(win) ? (win)->_pary : ERR) #endif /* NCURSES_OPAQUE */ #define wstandout(win) (wattrset(win,A_STANDOUT)) #define wstandend(win) (wattrset(win,A_NORMAL)) #define wattron(win,at) wattr_on(win, NCURSES_CAST(attr_t, at), NULL) #define wattroff(win,at) wattr_off(win, NCURSES_CAST(attr_t, at), NULL) #if !NCURSES_OPAQUE #if NCURSES_WATTR_MACROS #if NCURSES_WIDECHAR && 1 #define wattrset(win,at) \ (NCURSES_OK_ADDR(win) \ ? ((win)->_color = NCURSES_CAST(int, PAIR_NUMBER(at)), \ (win)->_attrs = NCURSES_CAST(attr_t, at), \ OK) \ : ERR) #else #define wattrset(win,at) \ (NCURSES_OK_ADDR(win) \ ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \ OK) \ : ERR) #endif #endif /* NCURSES_WATTR_MACROS */ #endif /* NCURSES_OPAQUE */ #define scroll(win) wscrl(win,1) #define touchwin(win) wtouchln((win), 0, getmaxy(win), 1) #define touchline(win, s, c) wtouchln((win), s, c, 1) #define untouchwin(win) wtouchln((win), 0, getmaxy(win), 0) #define box(win, v, h) wborder(win, v, v, h, h, 0, 0, 0, 0) #define border(ls, rs, ts, bs, tl, tr, bl, br) wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br) #define hline(ch, n) whline(stdscr, ch, (n)) #define vline(ch, n) wvline(stdscr, ch, (n)) #define winstr(w, s) winnstr(w, s, -1) #define winchstr(w, s) winchnstr(w, s, -1) #define winsstr(w, s) winsnstr(w, s, -1) #if !NCURSES_OPAQUE #define redrawwin(win) wredrawln(win, 0, (NCURSES_OK_ADDR(win) ? (win)->_maxy+1 : -1)) #endif /* NCURSES_OPAQUE */ #define waddstr(win,str) waddnstr(win,str,-1) #define waddchstr(win,str) waddchnstr(win,str,-1) /* * These apply to the first 256 color pairs. */ #define COLOR_PAIR(n) (NCURSES_BITS((n), 0) & A_COLOR) #define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & A_COLOR) >> NCURSES_ATTR_SHIFT))) /* * pseudo functions for standard screen */ #define addch(ch) waddch(stdscr,(ch)) #define addchnstr(str,n) waddchnstr(stdscr,(str),(n)) #define addchstr(str) waddchstr(stdscr,(str)) #define addnstr(str,n) waddnstr(stdscr,(str),(n)) #define addstr(str) waddnstr(stdscr,(str),-1) #define attr_get(ap,cp,o) wattr_get(stdscr,(ap),(cp),(o)) #define attr_off(a,o) wattr_off(stdscr,(a),(o)) #define attr_on(a,o) wattr_on(stdscr,(a),(o)) #define attr_set(a,c,o) wattr_set(stdscr,(a),(c),(o)) #define attroff(at) wattroff(stdscr,(at)) #define attron(at) wattron(stdscr,(at)) #define attrset(at) wattrset(stdscr,(at)) #define bkgd(ch) wbkgd(stdscr,(ch)) #define bkgdset(ch) wbkgdset(stdscr,(ch)) #define chgat(n,a,c,o) wchgat(stdscr,(n),(a),(c),(o)) #define clear() wclear(stdscr) #define clrtobot() wclrtobot(stdscr) #define clrtoeol() wclrtoeol(stdscr) #define color_set(c,o) wcolor_set(stdscr,(c),(o)) #define delch() wdelch(stdscr) #define deleteln() winsdelln(stdscr,-1) #define echochar(c) wechochar(stdscr,(c)) #define erase() werase(stdscr) #define getch() wgetch(stdscr) #define getstr(str) wgetstr(stdscr,(str)) #define inch() winch(stdscr) #define inchnstr(s,n) winchnstr(stdscr,(s),(n)) #define inchstr(s) winchstr(stdscr,(s)) #define innstr(s,n) winnstr(stdscr,(s),(n)) #define insch(c) winsch(stdscr,(c)) #define insdelln(n) winsdelln(stdscr,(n)) #define insertln() winsdelln(stdscr,1) #define insnstr(s,n) winsnstr(stdscr,(s),(n)) #define insstr(s) winsstr(stdscr,(s)) #define instr(s) winstr(stdscr,(s)) #define move(y,x) wmove(stdscr,(y),(x)) #define refresh() wrefresh(stdscr) #define scrl(n) wscrl(stdscr,(n)) #define setscrreg(t,b) wsetscrreg(stdscr,(t),(b)) #define standend() wstandend(stdscr) #define standout() wstandout(stdscr) #define timeout(delay) wtimeout(stdscr,(delay)) #define wdeleteln(win) winsdelln(win,-1) #define winsertln(win) winsdelln(win,1) /* * mv functions */ #define mvwaddch(win,y,x,ch) (wmove((win),(y),(x)) == ERR ? ERR : waddch((win),(ch))) #define mvwaddchnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),(n))) #define mvwaddchstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),-1)) #define mvwaddnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),(n))) #define mvwaddstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),-1)) #define mvwchgat(win,y,x,n,a,c,o) (wmove((win),(y),(x)) == ERR ? ERR : wchgat((win),(n),(a),(c),(o))) #define mvwdelch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wdelch(win)) #define mvwgetch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wgetch(win)) #define mvwgetnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : wgetnstr((win),(str),(n))) #define mvwgetstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : wgetstr((win),(str))) #define mvwhline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : whline((win),(c),(n))) #define mvwinch(win,y,x) (wmove((win),(y),(x)) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win)) #define mvwinchnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winchnstr((win),(s),(n))) #define mvwinchstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winchstr((win),(s))) #define mvwinnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winnstr((win),(s),(n))) #define mvwinsch(win,y,x,c) (wmove((win),(y),(x)) == ERR ? ERR : winsch((win),(c))) #define mvwinsnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winsnstr((win),(s),(n))) #define mvwinsstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winsstr((win),(s))) #define mvwinstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winstr((win),(s))) #define mvwvline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : wvline((win),(c),(n))) #define mvaddch(y,x,ch) mvwaddch(stdscr,(y),(x),(ch)) #define mvaddchnstr(y,x,str,n) mvwaddchnstr(stdscr,(y),(x),(str),(n)) #define mvaddchstr(y,x,str) mvwaddchstr(stdscr,(y),(x),(str)) #define mvaddnstr(y,x,str,n) mvwaddnstr(stdscr,(y),(x),(str),(n)) #define mvaddstr(y,x,str) mvwaddstr(stdscr,(y),(x),(str)) #define mvchgat(y,x,n,a,c,o) mvwchgat(stdscr,(y),(x),(n),(a),(c),(o)) #define mvdelch(y,x) mvwdelch(stdscr,(y),(x)) #define mvgetch(y,x) mvwgetch(stdscr,(y),(x)) #define mvgetnstr(y,x,str,n) mvwgetnstr(stdscr,(y),(x),(str),(n)) #define mvgetstr(y,x,str) mvwgetstr(stdscr,(y),(x),(str)) #define mvhline(y,x,c,n) mvwhline(stdscr,(y),(x),(c),(n)) #define mvinch(y,x) mvwinch(stdscr,(y),(x)) #define mvinchnstr(y,x,s,n) mvwinchnstr(stdscr,(y),(x),(s),(n)) #define mvinchstr(y,x,s) mvwinchstr(stdscr,(y),(x),(s)) #define mvinnstr(y,x,s,n) mvwinnstr(stdscr,(y),(x),(s),(n)) #define mvinsch(y,x,c) mvwinsch(stdscr,(y),(x),(c)) #define mvinsnstr(y,x,s,n) mvwinsnstr(stdscr,(y),(x),(s),(n)) #define mvinsstr(y,x,s) mvwinsstr(stdscr,(y),(x),(s)) #define mvinstr(y,x,s) mvwinstr(stdscr,(y),(x),(s)) #define mvvline(y,x,c,n) mvwvline(stdscr,(y),(x),(c),(n)) /* * Some wide-character functions can be implemented without the extensions. */ #if !NCURSES_OPAQUE #define getbkgd(win) (NCURSES_OK_ADDR(win) ? ((win)->_bkgd) : 0) #endif /* NCURSES_OPAQUE */ #define slk_attr_off(a,v) ((v) ? ERR : slk_attroff(a)) #define slk_attr_on(a,v) ((v) ? ERR : slk_attron(a)) #if !NCURSES_OPAQUE #if NCURSES_WATTR_MACROS #if NCURSES_WIDECHAR && 1 #define wattr_set(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)((win)->_attrs = ((a) & ~A_COLOR), \ (win)->_color = (opts) ? *(int *)(opts) : (p)), \ OK) \ : ERR) #define wattr_get(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)(NCURSES_OK_ADDR(a) \ ? (*(a) = (win)->_attrs) \ : OK), \ (void)(NCURSES_OK_ADDR(p) \ ? (*(p) = (NCURSES_PAIRS_T) (win)->_color) \ : OK), \ (void)(NCURSES_OK_ADDR(opts) \ ? (*(int *)(opts) = (win)->_color) \ : OK), \ OK) \ : ERR) #else /* !(NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */ #define wattr_set(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)((win)->_attrs = (((a) & ~A_COLOR) | \ (attr_t)COLOR_PAIR(p))), \ OK) \ : ERR) #define wattr_get(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)(NCURSES_OK_ADDR(a) \ ? (*(a) = (win)->_attrs) \ : OK), \ (void)(NCURSES_OK_ADDR(p) \ ? (*(p) = (NCURSES_PAIRS_T) PAIR_NUMBER((win)->_attrs)) \ : OK), \ OK) \ : ERR) #endif /* (NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */ #endif /* NCURSES_WATTR_MACROS */ #endif /* NCURSES_OPAQUE */ /* * X/Open curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use * varargs.h. It adds new calls vw_printw/vw_scanw, which are supposed to * use POSIX stdarg.h. The ncurses versions of vwprintw/vwscanw already * use stdarg.h, so... */ /* define vw_printw vwprintw */ /* define vw_scanw vwscanw */ /* * Export fallback function for use in C++ binding. */ #if !1 #define vsscanf(a,b,c) _nc_vsscanf(a,b,c) NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list); #endif /* * These macros are extensions - not in X/Open Curses. */ #if 1 #if !NCURSES_OPAQUE #define is_cleared(win) (NCURSES_OK_ADDR(win) ? (win)->_clear : FALSE) #define is_idcok(win) (NCURSES_OK_ADDR(win) ? (win)->_idcok : FALSE) #define is_idlok(win) (NCURSES_OK_ADDR(win) ? (win)->_idlok : FALSE) #define is_immedok(win) (NCURSES_OK_ADDR(win) ? (win)->_immed : FALSE) #define is_keypad(win) (NCURSES_OK_ADDR(win) ? (win)->_use_keypad : FALSE) #define is_leaveok(win) (NCURSES_OK_ADDR(win) ? (win)->_leaveok : FALSE) #define is_nodelay(win) (NCURSES_OK_ADDR(win) ? ((win)->_delay == 0) : FALSE) #define is_notimeout(win) (NCURSES_OK_ADDR(win) ? (win)->_notimeout : FALSE) #define is_pad(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _ISPAD) != 0 : FALSE) #define is_scrollok(win) (NCURSES_OK_ADDR(win) ? (win)->_scroll : FALSE) #define is_subwin(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE) #define is_syncok(win) (NCURSES_OK_ADDR(win) ? (win)->_sync : FALSE) #define wgetdelay(win) (NCURSES_OK_ADDR(win) ? (win)->_delay : 0) #define wgetparent(win) (NCURSES_OK_ADDR(win) ? (win)->_parent : 0) #define wgetscrreg(win,t,b) (NCURSES_OK_ADDR(win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR) #endif #endif /* * X/Open says this returns a bool; SVr4 also checked for out-of-range line. * The macro provides compatibility: */ #define is_linetouched(w,l) ((!(w) || ((l) > getmaxy(w)) || ((l) < 0)) ? ERR : (is_linetouched)((w),(l))) #endif /* NCURSES_NOMACROS */ /* * Public variables. * * Notes: * a. ESCDELAY was an undocumented feature under AIX curses. * It gives the ESC expire time in milliseconds. * b. ttytype is needed for backward compatibility */ #if NCURSES_REENTRANT NCURSES_WRAPPED_VAR(WINDOW *, curscr); NCURSES_WRAPPED_VAR(WINDOW *, newscr); NCURSES_WRAPPED_VAR(WINDOW *, stdscr); NCURSES_WRAPPED_VAR(char *, ttytype); NCURSES_WRAPPED_VAR(int, COLORS); NCURSES_WRAPPED_VAR(int, COLOR_PAIRS); NCURSES_WRAPPED_VAR(int, COLS); NCURSES_WRAPPED_VAR(int, ESCDELAY); NCURSES_WRAPPED_VAR(int, LINES); NCURSES_WRAPPED_VAR(int, TABSIZE); #define curscr NCURSES_PUBLIC_VAR(curscr()) #define newscr NCURSES_PUBLIC_VAR(newscr()) #define stdscr NCURSES_PUBLIC_VAR(stdscr()) #define ttytype NCURSES_PUBLIC_VAR(ttytype()) #define COLORS NCURSES_PUBLIC_VAR(COLORS()) #define COLOR_PAIRS NCURSES_PUBLIC_VAR(COLOR_PAIRS()) #define COLS NCURSES_PUBLIC_VAR(COLS()) #define ESCDELAY NCURSES_PUBLIC_VAR(ESCDELAY()) #define LINES NCURSES_PUBLIC_VAR(LINES()) #define TABSIZE NCURSES_PUBLIC_VAR(TABSIZE()) #else extern NCURSES_EXPORT_VAR(WINDOW *) curscr; extern NCURSES_EXPORT_VAR(WINDOW *) newscr; extern NCURSES_EXPORT_VAR(WINDOW *) stdscr; extern NCURSES_EXPORT_VAR(char) ttytype[]; extern NCURSES_EXPORT_VAR(int) COLORS; extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS; extern NCURSES_EXPORT_VAR(int) COLS; extern NCURSES_EXPORT_VAR(int) ESCDELAY; extern NCURSES_EXPORT_VAR(int) LINES; extern NCURSES_EXPORT_VAR(int) TABSIZE; #endif /* * Pseudo-character tokens outside ASCII range. The curses wgetch() function * will return any given one of these only if the corresponding k- capability * is defined in your terminal's terminfo entry. * * Some keys (KEY_A1, etc) are arranged like this: * a1 up a3 * left b2 right * c1 down c3 * * A few key codes do not depend upon the terminfo entry. */ #define KEY_CODE_YES 0400 /* A wchar_t contains a key code */ #define KEY_MIN 0401 /* Minimum curses key */ #define KEY_BREAK 0401 /* Break key (unreliable) */ #define KEY_SRESET 0530 /* Soft (partial) reset (unreliable) */ #define KEY_RESET 0531 /* Reset or hard reset (unreliable) */ /* * These definitions were generated by ./MKkey_defs.sh ../../include/Caps ../../include/Caps-ncurses */ #define KEY_DOWN 0402 /* down-arrow key */ #define KEY_UP 0403 /* up-arrow key */ #define KEY_LEFT 0404 /* left-arrow key */ #define KEY_RIGHT 0405 /* right-arrow key */ #define KEY_HOME 0406 /* home key */ #define KEY_BACKSPACE 0407 /* backspace key */ #define KEY_F0 0410 /* Function keys. Space for 64 */ #define KEY_F(n) (KEY_F0+(n)) /* Value of function key n */ #define KEY_DL 0510 /* delete-line key */ #define KEY_IL 0511 /* insert-line key */ #define KEY_DC 0512 /* delete-character key */ #define KEY_IC 0513 /* insert-character key */ #define KEY_EIC 0514 /* sent by rmir or smir in insert mode */ #define KEY_CLEAR 0515 /* clear-screen or erase key */ #define KEY_EOS 0516 /* clear-to-end-of-screen key */ #define KEY_EOL 0517 /* clear-to-end-of-line key */ #define KEY_SF 0520 /* scroll-forward key */ #define KEY_SR 0521 /* scroll-backward key */ #define KEY_NPAGE 0522 /* next-page key */ #define KEY_PPAGE 0523 /* previous-page key */ #define KEY_STAB 0524 /* set-tab key */ #define KEY_CTAB 0525 /* clear-tab key */ #define KEY_CATAB 0526 /* clear-all-tabs key */ #define KEY_ENTER 0527 /* enter/send key */ #define KEY_PRINT 0532 /* print key */ #define KEY_LL 0533 /* lower-left key (home down) */ #define KEY_A1 0534 /* upper left of keypad */ #define KEY_A3 0535 /* upper right of keypad */ #define KEY_B2 0536 /* center of keypad */ #define KEY_C1 0537 /* lower left of keypad */ #define KEY_C3 0540 /* lower right of keypad */ #define KEY_BTAB 0541 /* back-tab key */ #define KEY_BEG 0542 /* begin key */ #define KEY_CANCEL 0543 /* cancel key */ #define KEY_CLOSE 0544 /* close key */ #define KEY_COMMAND 0545 /* command key */ #define KEY_COPY 0546 /* copy key */ #define KEY_CREATE 0547 /* create key */ #define KEY_END 0550 /* end key */ #define KEY_EXIT 0551 /* exit key */ #define KEY_FIND 0552 /* find key */ #define KEY_HELP 0553 /* help key */ #define KEY_MARK 0554 /* mark key */ #define KEY_MESSAGE 0555 /* message key */ #define KEY_MOVE 0556 /* move key */ #define KEY_NEXT 0557 /* next key */ #define KEY_OPEN 0560 /* open key */ #define KEY_OPTIONS 0561 /* options key */ #define KEY_PREVIOUS 0562 /* previous key */ #define KEY_REDO 0563 /* redo key */ #define KEY_REFERENCE 0564 /* reference key */ #define KEY_REFRESH 0565 /* refresh key */ #define KEY_REPLACE 0566 /* replace key */ #define KEY_RESTART 0567 /* restart key */ #define KEY_RESUME 0570 /* resume key */ #define KEY_SAVE 0571 /* save key */ #define KEY_SBEG 0572 /* shifted begin key */ #define KEY_SCANCEL 0573 /* shifted cancel key */ #define KEY_SCOMMAND 0574 /* shifted command key */ #define KEY_SCOPY 0575 /* shifted copy key */ #define KEY_SCREATE 0576 /* shifted create key */ #define KEY_SDC 0577 /* shifted delete-character key */ #define KEY_SDL 0600 /* shifted delete-line key */ #define KEY_SELECT 0601 /* select key */ #define KEY_SEND 0602 /* shifted end key */ #define KEY_SEOL 0603 /* shifted clear-to-end-of-line key */ #define KEY_SEXIT 0604 /* shifted exit key */ #define KEY_SFIND 0605 /* shifted find key */ #define KEY_SHELP 0606 /* shifted help key */ #define KEY_SHOME 0607 /* shifted home key */ #define KEY_SIC 0610 /* shifted insert-character key */ #define KEY_SLEFT 0611 /* shifted left-arrow key */ #define KEY_SMESSAGE 0612 /* shifted message key */ #define KEY_SMOVE 0613 /* shifted move key */ #define KEY_SNEXT 0614 /* shifted next key */ #define KEY_SOPTIONS 0615 /* shifted options key */ #define KEY_SPREVIOUS 0616 /* shifted previous key */ #define KEY_SPRINT 0617 /* shifted print key */ #define KEY_SREDO 0620 /* shifted redo key */ #define KEY_SREPLACE 0621 /* shifted replace key */ #define KEY_SRIGHT 0622 /* shifted right-arrow key */ #define KEY_SRSUME 0623 /* shifted resume key */ #define KEY_SSAVE 0624 /* shifted save key */ #define KEY_SSUSPEND 0625 /* shifted suspend key */ #define KEY_SUNDO 0626 /* shifted undo key */ #define KEY_SUSPEND 0627 /* suspend key */ #define KEY_UNDO 0630 /* undo key */ #define KEY_MOUSE 0631 /* Mouse event has occurred */ #ifdef NCURSES_EXT_FUNCS #define KEY_RESIZE 0632 /* Terminal resize event */ #endif #define KEY_MAX 0777 /* Maximum key value is 0632 */ /* $Id: curses.wide,v 1.50 2017/03/26 16:05:21 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in * (see that file for the relevant copyright). */ #define _XOPEN_CURSES 1 #if NCURSES_WIDECHAR extern NCURSES_EXPORT_VAR(cchar_t *) _nc_wacs; #define NCURSES_WACS(c) (&_nc_wacs[NCURSES_CAST(unsigned char,(c))]) #define WACS_BSSB NCURSES_WACS('l') #define WACS_SSBB NCURSES_WACS('m') #define WACS_BBSS NCURSES_WACS('k') #define WACS_SBBS NCURSES_WACS('j') #define WACS_SBSS NCURSES_WACS('u') #define WACS_SSSB NCURSES_WACS('t') #define WACS_SSBS NCURSES_WACS('v') #define WACS_BSSS NCURSES_WACS('w') #define WACS_BSBS NCURSES_WACS('q') #define WACS_SBSB NCURSES_WACS('x') #define WACS_SSSS NCURSES_WACS('n') #define WACS_ULCORNER WACS_BSSB #define WACS_LLCORNER WACS_SSBB #define WACS_URCORNER WACS_BBSS #define WACS_LRCORNER WACS_SBBS #define WACS_RTEE WACS_SBSS #define WACS_LTEE WACS_SSSB #define WACS_BTEE WACS_SSBS #define WACS_TTEE WACS_BSSS #define WACS_HLINE WACS_BSBS #define WACS_VLINE WACS_SBSB #define WACS_PLUS WACS_SSSS #define WACS_S1 NCURSES_WACS('o') /* scan line 1 */ #define WACS_S9 NCURSES_WACS('s') /* scan line 9 */ #define WACS_DIAMOND NCURSES_WACS('`') /* diamond */ #define WACS_CKBOARD NCURSES_WACS('a') /* checker board */ #define WACS_DEGREE NCURSES_WACS('f') /* degree symbol */ #define WACS_PLMINUS NCURSES_WACS('g') /* plus/minus */ #define WACS_BULLET NCURSES_WACS('~') /* bullet */ /* Teletype 5410v1 symbols */ #define WACS_LARROW NCURSES_WACS(',') /* arrow left */ #define WACS_RARROW NCURSES_WACS('+') /* arrow right */ #define WACS_DARROW NCURSES_WACS('.') /* arrow down */ #define WACS_UARROW NCURSES_WACS('-') /* arrow up */ #define WACS_BOARD NCURSES_WACS('h') /* board of squares */ #define WACS_LANTERN NCURSES_WACS('i') /* lantern symbol */ #define WACS_BLOCK NCURSES_WACS('0') /* solid square block */ /* ncurses extensions */ #define WACS_S3 NCURSES_WACS('p') /* scan line 3 */ #define WACS_S7 NCURSES_WACS('r') /* scan line 7 */ #define WACS_LEQUAL NCURSES_WACS('y') /* less/equal */ #define WACS_GEQUAL NCURSES_WACS('z') /* greater/equal */ #define WACS_PI NCURSES_WACS('{') /* Pi */ #define WACS_NEQUAL NCURSES_WACS('|') /* not equal */ #define WACS_STERLING NCURSES_WACS('}') /* UK pound sign */ /* double lines */ #define WACS_BDDB NCURSES_WACS('C') #define WACS_DDBB NCURSES_WACS('D') #define WACS_BBDD NCURSES_WACS('B') #define WACS_DBBD NCURSES_WACS('A') #define WACS_DBDD NCURSES_WACS('G') #define WACS_DDDB NCURSES_WACS('F') #define WACS_DDBD NCURSES_WACS('H') #define WACS_BDDD NCURSES_WACS('I') #define WACS_BDBD NCURSES_WACS('R') #define WACS_DBDB NCURSES_WACS('Y') #define WACS_DDDD NCURSES_WACS('E') #define WACS_D_ULCORNER WACS_BDDB #define WACS_D_LLCORNER WACS_DDBB #define WACS_D_URCORNER WACS_BBDD #define WACS_D_LRCORNER WACS_DBBD #define WACS_D_RTEE WACS_DBDD #define WACS_D_LTEE WACS_DDDB #define WACS_D_BTEE WACS_DDBD #define WACS_D_TTEE WACS_BDDD #define WACS_D_HLINE WACS_BDBD #define WACS_D_VLINE WACS_DBDB #define WACS_D_PLUS WACS_DDDD /* thick lines */ #define WACS_BTTB NCURSES_WACS('L') #define WACS_TTBB NCURSES_WACS('M') #define WACS_BBTT NCURSES_WACS('K') #define WACS_TBBT NCURSES_WACS('J') #define WACS_TBTT NCURSES_WACS('U') #define WACS_TTTB NCURSES_WACS('T') #define WACS_TTBT NCURSES_WACS('V') #define WACS_BTTT NCURSES_WACS('W') #define WACS_BTBT NCURSES_WACS('Q') #define WACS_TBTB NCURSES_WACS('X') #define WACS_TTTT NCURSES_WACS('N') #define WACS_T_ULCORNER WACS_BTTB #define WACS_T_LLCORNER WACS_TTBB #define WACS_T_URCORNER WACS_BBTT #define WACS_T_LRCORNER WACS_TBBT #define WACS_T_RTEE WACS_TBTT #define WACS_T_LTEE WACS_TTTB #define WACS_T_BTEE WACS_TTBT #define WACS_T_TTEE WACS_BTTT #define WACS_T_HLINE WACS_BTBT #define WACS_T_VLINE WACS_TBTB #define WACS_T_PLUS WACS_TTTT /* * Function prototypes for wide-character operations. * * "generated" comments should include ":WIDEC" to make the corresponding * functions ifdef'd in lib_gen.c * * "implemented" comments do not need this marker. */ extern NCURSES_EXPORT(int) add_wch (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) add_wchnstr (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) add_wchstr (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) addnwstr (const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) addwstr (const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) bkgrnd (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(void) bkgrndset (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) border_set (const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* generated:WIDEC */ extern NCURSES_EXPORT(int) box_set (WINDOW *, const cchar_t *, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) echo_wchar (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) erasewchar (wchar_t*); /* implemented */ extern NCURSES_EXPORT(int) get_wch (wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) get_wstr (wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) getbkgrnd (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) getcchar (const cchar_t *, wchar_t*, attr_t*, NCURSES_PAIRS_T*, void*); /* implemented */ extern NCURSES_EXPORT(int) getn_wstr (wint_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) hline_set (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wch (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wchnstr (cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wchstr (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) innwstr (wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_nwstr (const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_wch (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_wstr (const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) inwstr (wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(NCURSES_CONST char*) key_name (wchar_t); /* implemented */ extern NCURSES_EXPORT(int) killwchar (wchar_t *); /* implemented */ extern NCURSES_EXPORT(int) mvadd_wch (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvadd_wchnstr (int, int, const cchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvadd_wchstr (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvaddnwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvaddwstr (int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvget_wch (int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvget_wstr (int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvgetn_wstr (int, int, wint_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvhline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wch (int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wchnstr (int, int, cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wchstr (int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvinnwstr (int, int, wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_nwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_wch (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_wstr (int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvinwstr (int, int, wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvvline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wchnstr (WINDOW *, int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wchstr (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwaddnwstr (WINDOW *, int, int, const wchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwaddwstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwget_wch (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwget_wstr (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwgetn_wstr (WINDOW *, int, int, wint_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwhline_set (WINDOW *, int, int, const cchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wch (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wchnstr (WINDOW *, int,int, cchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wchstr (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwinnwstr (WINDOW *, int, int, wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_nwstr (WINDOW *, int,int, const wchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_wstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwinwstr (WINDOW *, int, int, wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwvline_set (WINDOW *, int,int, const cchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) pecho_wchar (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) setcchar (cchar_t *, const wchar_t *, const attr_t, NCURSES_PAIRS_T, const void *); /* implemented */ extern NCURSES_EXPORT(int) slk_wset (int, const wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(attr_t) term_attrs (void); /* implemented */ extern NCURSES_EXPORT(int) unget_wch (const wchar_t); /* implemented */ extern NCURSES_EXPORT(int) vid_attr (attr_t, NCURSES_PAIRS_T, void *); /* implemented */ extern NCURSES_EXPORT(int) vid_puts (attr_t, NCURSES_PAIRS_T, void *, NCURSES_OUTC); /* implemented */ extern NCURSES_EXPORT(int) vline_set (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wadd_wch (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wadd_wchnstr (WINDOW *,const cchar_t *,int); /* implemented */ extern NCURSES_EXPORT(int) wadd_wchstr (WINDOW *,const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) waddnwstr (WINDOW *,const wchar_t *,int); /* implemented */ extern NCURSES_EXPORT(int) waddwstr (WINDOW *,const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wbkgrnd (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(void) wbkgrndset (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wborder_set (WINDOW *,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* implemented */ extern NCURSES_EXPORT(int) wecho_wchar (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wget_wch (WINDOW *, wint_t *); /* implemented */ extern NCURSES_EXPORT(int) wget_wstr (WINDOW *, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wgetbkgrnd (WINDOW *, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wgetn_wstr (WINDOW *, wint_t *, int); /* implemented */ extern NCURSES_EXPORT(int) whline_set (WINDOW *, const cchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) win_wch (WINDOW *, cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) win_wchnstr (WINDOW *, cchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) win_wchstr (WINDOW *, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) winnwstr (WINDOW *, wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) wins_nwstr (WINDOW *, const wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) wins_wch (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wins_wstr (WINDOW *, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) winwstr (WINDOW *, wchar_t *); /* implemented */ extern NCURSES_EXPORT(wchar_t*) wunctrl (cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wvline_set (WINDOW *, const cchar_t *, int); /* implemented */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(term_attrs) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(unget_wch) (SCREEN*, const wchar_t); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_attr) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ #endif #ifndef NCURSES_NOMACROS /* * XSI curses macros for XPG4 conformance. */ #define add_wch(c) wadd_wch(stdscr,(c)) #define add_wchnstr(str,n) wadd_wchnstr(stdscr,(str),(n)) #define add_wchstr(str) wadd_wchstr(stdscr,(str)) #define addnwstr(wstr,n) waddnwstr(stdscr,(wstr),(n)) #define addwstr(wstr) waddwstr(stdscr,(wstr)) #define bkgrnd(c) wbkgrnd(stdscr,(c)) #define bkgrndset(c) wbkgrndset(stdscr,(c)) #define border_set(l,r,t,b,tl,tr,bl,br) wborder_set(stdscr,(l),(r),(t),(b),tl,tr,bl,br) #define box_set(w,v,h) wborder_set((w),(v),(v),(h),(h),0,0,0,0) #define echo_wchar(c) wecho_wchar(stdscr,(c)) #define get_wch(c) wget_wch(stdscr,(c)) #define get_wstr(t) wget_wstr(stdscr,(t)) #define getbkgrnd(wch) wgetbkgrnd(stdscr,(wch)) #define getn_wstr(t,n) wgetn_wstr(stdscr,(t),(n)) #define hline_set(c,n) whline_set(stdscr,(c),(n)) #define in_wch(c) win_wch(stdscr,(c)) #define in_wchnstr(c,n) win_wchnstr(stdscr,(c),(n)) #define in_wchstr(c) win_wchstr(stdscr,(c)) #define innwstr(c,n) winnwstr(stdscr,(c),(n)) #define ins_nwstr(t,n) wins_nwstr(stdscr,(t),(n)) #define ins_wch(c) wins_wch(stdscr,(c)) #define ins_wstr(t) wins_wstr(stdscr,(t)) #define inwstr(c) winwstr(stdscr,(c)) #define vline_set(c,n) wvline_set(stdscr,(c),(n)) #define wadd_wchstr(win,str) wadd_wchnstr((win),(str),-1) #define waddwstr(win,wstr) waddnwstr((win),(wstr),-1) #define wget_wstr(w,t) wgetn_wstr((w),(t),-1) #define win_wchstr(w,c) win_wchnstr((w),(c),-1) #define wins_wstr(w,t) wins_nwstr((w),(t),-1) #if !NCURSES_OPAQUE #define wgetbkgrnd(win,wch) (NCURSES_OK_ADDR(wch) ? ((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK) : ERR) #endif #define mvadd_wch(y,x,c) mvwadd_wch(stdscr,(y),(x),(c)) #define mvadd_wchnstr(y,x,s,n) mvwadd_wchnstr(stdscr,(y),(x),(s),(n)) #define mvadd_wchstr(y,x,s) mvwadd_wchstr(stdscr,(y),(x),(s)) #define mvaddnwstr(y,x,wstr,n) mvwaddnwstr(stdscr,(y),(x),(wstr),(n)) #define mvaddwstr(y,x,wstr) mvwaddwstr(stdscr,(y),(x),(wstr)) #define mvget_wch(y,x,c) mvwget_wch(stdscr,(y),(x),(c)) #define mvget_wstr(y,x,t) mvwget_wstr(stdscr,(y),(x),(t)) #define mvgetn_wstr(y,x,t,n) mvwgetn_wstr(stdscr,(y),(x),(t),(n)) #define mvhline_set(y,x,c,n) mvwhline_set(stdscr,(y),(x),(c),(n)) #define mvin_wch(y,x,c) mvwin_wch(stdscr,(y),(x),(c)) #define mvin_wchnstr(y,x,c,n) mvwin_wchnstr(stdscr,(y),(x),(c),(n)) #define mvin_wchstr(y,x,c) mvwin_wchstr(stdscr,(y),(x),(c)) #define mvinnwstr(y,x,c,n) mvwinnwstr(stdscr,(y),(x),(c),(n)) #define mvins_nwstr(y,x,t,n) mvwins_nwstr(stdscr,(y),(x),(t),(n)) #define mvins_wch(y,x,c) mvwins_wch(stdscr,(y),(x),(c)) #define mvins_wstr(y,x,t) mvwins_wstr(stdscr,(y),(x),(t)) #define mvinwstr(y,x,c) mvwinwstr(stdscr,(y),(x),(c)) #define mvvline_set(y,x,c,n) mvwvline_set(stdscr,(y),(x),(c),(n)) #define mvwadd_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wch((win),(c))) #define mvwadd_wchnstr(win,y,x,s,n) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchnstr((win),(s),(n))) #define mvwadd_wchstr(win,y,x,s) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchstr((win),(s))) #define mvwaddnwstr(win,y,x,wstr,n) (wmove(win,(y),(x)) == ERR ? ERR : waddnwstr((win),(wstr),(n))) #define mvwaddwstr(win,y,x,wstr) (wmove(win,(y),(x)) == ERR ? ERR : waddwstr((win),(wstr))) #define mvwget_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wget_wch((win),(c))) #define mvwget_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wget_wstr((win),(t))) #define mvwgetn_wstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wgetn_wstr((win),(t),(n))) #define mvwhline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : whline_set((win),(c),(n))) #define mvwin_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wch((win),(c))) #define mvwin_wchnstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : win_wchnstr((win),(c),(n))) #define mvwin_wchstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wchstr((win),(c))) #define mvwinnwstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : winnwstr((win),(c),(n))) #define mvwins_nwstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wins_nwstr((win),(t),(n))) #define mvwins_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wins_wch((win),(c))) #define mvwins_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wins_wstr((win),(t))) #define mvwinwstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : winwstr((win),(c))) #define mvwvline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : wvline_set((win),(c),(n))) #endif /* NCURSES_NOMACROS */ #if defined(TRACE) || defined(NCURSES_TEST) extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *); extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *); #endif #endif /* NCURSES_WIDECHAR */ /* $Id: curses.tail,v 1.26 2021/03/20 15:49:25 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in * (see that file for the relevant copyright). */ /* mouse interface */ #if NCURSES_MOUSE_VERSION > 1 #define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5)) #else #define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6)) #endif #define NCURSES_BUTTON_RELEASED 001L #define NCURSES_BUTTON_PRESSED 002L #define NCURSES_BUTTON_CLICKED 004L #define NCURSES_DOUBLE_CLICKED 010L #define NCURSES_TRIPLE_CLICKED 020L #define NCURSES_RESERVED_EVENT 040L /* event masks */ #define BUTTON1_RELEASED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED) #define BUTTON1_PRESSED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED) #define BUTTON1_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED) #define BUTTON1_DOUBLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED) #define BUTTON1_TRIPLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED) #define BUTTON2_RELEASED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED) #define BUTTON2_PRESSED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED) #define BUTTON2_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED) #define BUTTON2_DOUBLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED) #define BUTTON2_TRIPLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED) #define BUTTON3_RELEASED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED) #define BUTTON3_PRESSED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED) #define BUTTON3_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED) #define BUTTON3_DOUBLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED) #define BUTTON3_TRIPLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED) #define BUTTON4_RELEASED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED) #define BUTTON4_PRESSED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED) #define BUTTON4_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED) #define BUTTON4_DOUBLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED) #define BUTTON4_TRIPLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED) /* * In 32 bits the version-1 scheme does not provide enough space for a 5th * button, unless we choose to change the ABI by omitting the reserved-events. */ #if NCURSES_MOUSE_VERSION > 1 #define BUTTON5_RELEASED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED) #define BUTTON5_PRESSED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED) #define BUTTON5_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED) #define BUTTON5_DOUBLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED) #define BUTTON5_TRIPLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED) #define BUTTON_CTRL NCURSES_MOUSE_MASK(6, 0001L) #define BUTTON_SHIFT NCURSES_MOUSE_MASK(6, 0002L) #define BUTTON_ALT NCURSES_MOUSE_MASK(6, 0004L) #define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(6, 0010L) #else #define BUTTON1_RESERVED_EVENT NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT) #define BUTTON2_RESERVED_EVENT NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT) #define BUTTON3_RESERVED_EVENT NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT) #define BUTTON4_RESERVED_EVENT NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT) #define BUTTON_CTRL NCURSES_MOUSE_MASK(5, 0001L) #define BUTTON_SHIFT NCURSES_MOUSE_MASK(5, 0002L) #define BUTTON_ALT NCURSES_MOUSE_MASK(5, 0004L) #define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(5, 0010L) #endif #define ALL_MOUSE_EVENTS (REPORT_MOUSE_POSITION - 1) /* macros to extract single event-bits from masks */ #define BUTTON_RELEASE(e, x) ((e) & NCURSES_MOUSE_MASK(x, 001)) #define BUTTON_PRESS(e, x) ((e) & NCURSES_MOUSE_MASK(x, 002)) #define BUTTON_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 004)) #define BUTTON_DOUBLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 010)) #define BUTTON_TRIPLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 020)) #define BUTTON_RESERVED_EVENT(e, x) ((e) & NCURSES_MOUSE_MASK(x, 040)) typedef struct { short id; /* ID to distinguish multiple devices */ int x, y, z; /* event coordinates (character-cell) */ mmask_t bstate; /* button state bits */ } MEVENT; extern NCURSES_EXPORT(bool) has_mouse(void); extern NCURSES_EXPORT(int) getmouse (MEVENT *); extern NCURSES_EXPORT(int) ungetmouse (MEVENT *); extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *); extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int); extern NCURSES_EXPORT(int) mouseinterval (int); extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool); extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* generated */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_mouse) (SCREEN*); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *); extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, mmask_t *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mouseinterval) (SCREEN*, int); #endif #ifndef NCURSES_NOMACROS #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen) #endif /* other non-XSI functions */ extern NCURSES_EXPORT(int) mcprint (char *, int); /* direct data to printer */ extern NCURSES_EXPORT(int) has_key (int); /* do we have given key? */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (SCREEN*, int); /* do we have given key? */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mcprint) (SCREEN*, char *, int); /* direct data to printer */ #endif /* Debugging : use with libncurses_g.a */ extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(char *) _traceattr (attr_t); extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype); extern NCURSES_EXPORT(char *) _tracechar (int); extern NCURSES_EXPORT(char *) _tracechtype (chtype); extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype); #if NCURSES_WIDECHAR #define _tracech_t _tracecchar_t extern NCURSES_EXPORT(char *) _tracecchar_t (const cchar_t *); #define _tracech_t2 _tracecchar_t2 extern NCURSES_EXPORT(char *) _tracecchar_t2 (int, const cchar_t *); #else #define _tracech_t _tracechtype #define _tracech_t2 _tracechtype2 #endif extern NCURSES_EXPORT(void) trace (const unsigned) GCC_DEPRECATED("use curses_trace"); extern NCURSES_EXPORT(unsigned) curses_trace (const unsigned); /* trace masks */ #define TRACE_DISABLE 0x0000 /* turn off tracing */ #define TRACE_TIMES 0x0001 /* trace user and system times of updates */ #define TRACE_TPUTS 0x0002 /* trace tputs calls */ #define TRACE_UPDATE 0x0004 /* trace update actions, old & new screens */ #define TRACE_MOVE 0x0008 /* trace cursor moves and scrolls */ #define TRACE_CHARPUT 0x0010 /* trace all character outputs */ #define TRACE_ORDINARY 0x001F /* trace all update actions */ #define TRACE_CALLS 0x0020 /* trace all curses calls */ #define TRACE_VIRTPUT 0x0040 /* trace virtual character puts */ #define TRACE_IEVENT 0x0080 /* trace low-level input processing */ #define TRACE_BITS 0x0100 /* trace state of TTY control bits */ #define TRACE_ICALLS 0x0200 /* trace internal/nested calls */ #define TRACE_CCALLS 0x0400 /* trace per-character calls */ #define TRACE_DATABASE 0x0800 /* trace read/write of terminfo/termcap data */ #define TRACE_ATTRS 0x1000 /* trace attribute updates */ #define TRACE_SHIFT 13 /* number of bits in the trace masks */ #define TRACE_MAXIMUM ((1 << TRACE_SHIFT) - 1) /* maximum trace level */ #if defined(TRACE) || defined(NCURSES_TEST) extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable; /* enable optimizations */ extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *); #define OPTIMIZE_MVCUR 0x01 /* cursor movement optimization */ #define OPTIMIZE_HASHMAP 0x02 /* diff hashing to detect scrolls */ #define OPTIMIZE_SCROLL 0x04 /* scroll optimization */ #define OPTIMIZE_ALL 0xff /* enable all optimizations (dflt) */ #endif extern GCC_NORETURN NCURSES_EXPORT(void) exit_curses (int); #include <unctrl.h> #ifdef __cplusplus #ifndef NCURSES_NOMACROS /* these names conflict with STL */ #undef box #undef clear #undef erase #undef move #undef refresh #endif /* NCURSES_NOMACROS */ } #endif #endif /* __NCURSES_H */ /**************************************************************************** * Copyright 2020 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1995,1997 * ****************************************************************************/ /* $Id: menu.h,v 1.26 2020/12/12 00:38:02 tom Exp $ */ #ifndef ETI_MENU #define ETI_MENU #ifdef AMIGA #define TEXT TEXT_ncurses #endif #include <curses.h> #include <eti.h> #ifdef __cplusplus extern "C" { #endif #if defined(BUILDING_MENU) # define MENU_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT #else # define MENU_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT #endif #define MENU_WRAPPED_VAR(type,name) extern MENU_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) #define MENU_EXPORT(type) MENU_IMPEXP type NCURSES_API #define MENU_EXPORT_VAR(type) MENU_IMPEXP type typedef int Menu_Options; typedef int Item_Options; /* Menu options: */ #define O_ONEVALUE (0x01) #define O_SHOWDESC (0x02) #define O_ROWMAJOR (0x04) #define O_IGNORECASE (0x08) #define O_SHOWMATCH (0x10) #define O_NONCYCLIC (0x20) #define O_MOUSE_MENU (0x40) /* Item options: */ #define O_SELECTABLE (0x01) #if !NCURSES_OPAQUE_MENU typedef struct { const char *str; unsigned short length; } TEXT; #endif /* !NCURSES_OPAQUE_MENU */ struct tagMENU; typedef struct tagITEM #if !NCURSES_OPAQUE_MENU { TEXT name; /* name of menu item */ TEXT description; /* description of item, optional in display */ struct tagMENU *imenu; /* Pointer to parent menu */ void *userptr; /* Pointer to user defined per item data */ Item_Options opt; /* Item options */ short index; /* Item number if connected to a menu */ short y; /* y and x location of item in menu */ short x; bool value; /* Selection value */ struct tagITEM *left; /* neighbor items */ struct tagITEM *right; struct tagITEM *up; struct tagITEM *down; } #endif /* !NCURSES_OPAQUE_MENU */ ITEM; typedef void (*Menu_Hook) (struct tagMENU *); typedef struct tagMENU #if 1 /* not yet: !NCURSES_OPAQUE_MENU */ { short height; /* Nr. of chars high */ short width; /* Nr. of chars wide */ short rows; /* Nr. of items high */ short cols; /* Nr. of items wide */ short frows; /* Nr. of formatted items high */ short fcols; /* Nr. of formatted items wide */ short arows; /* Nr. of items high (actual) */ short namelen; /* Max. name length */ short desclen; /* Max. description length */ short marklen; /* Length of mark, if any */ short itemlen; /* Length of one item */ short spc_desc; /* Spacing for descriptor */ short spc_cols; /* Spacing for columns */ short spc_rows; /* Spacing for rows */ char *pattern; /* Buffer to store match chars */ short pindex; /* Index into pattern buffer */ WINDOW *win; /* Window containing menu */ WINDOW *sub; /* Subwindow for menu display */ WINDOW *userwin; /* User's window */ WINDOW *usersub; /* User's subwindow */ ITEM **items; /* array of items */ short nitems; /* Nr. of items in menu */ ITEM *curitem; /* Current item */ short toprow; /* Top row of menu */ chtype fore; /* Selection attribute */ chtype back; /* Nonselection attribute */ chtype grey; /* Inactive attribute */ unsigned char pad; /* Pad character */ Menu_Hook menuinit; /* User hooks */ Menu_Hook menuterm; Menu_Hook iteminit; Menu_Hook itemterm; void *userptr; /* Pointer to menus user data */ char *mark; /* Pointer to marker string */ Menu_Options opt; /* Menu options */ unsigned short status; /* Internal state of menu */ } #endif /* !NCURSES_OPAQUE_MENU */ MENU; /* Define keys */ #define REQ_LEFT_ITEM (KEY_MAX + 1) #define REQ_RIGHT_ITEM (KEY_MAX + 2) #define REQ_UP_ITEM (KEY_MAX + 3) #define REQ_DOWN_ITEM (KEY_MAX + 4) #define REQ_SCR_ULINE (KEY_MAX + 5) #define REQ_SCR_DLINE (KEY_MAX + 6) #define REQ_SCR_DPAGE (KEY_MAX + 7) #define REQ_SCR_UPAGE (KEY_MAX + 8) #define REQ_FIRST_ITEM (KEY_MAX + 9) #define REQ_LAST_ITEM (KEY_MAX + 10) #define REQ_NEXT_ITEM (KEY_MAX + 11) #define REQ_PREV_ITEM (KEY_MAX + 12) #define REQ_TOGGLE_ITEM (KEY_MAX + 13) #define REQ_CLEAR_PATTERN (KEY_MAX + 14) #define REQ_BACK_PATTERN (KEY_MAX + 15) #define REQ_NEXT_MATCH (KEY_MAX + 16) #define REQ_PREV_MATCH (KEY_MAX + 17) #define MIN_MENU_COMMAND (KEY_MAX + 1) #define MAX_MENU_COMMAND (KEY_MAX + 17) /* * Some AT&T code expects MAX_COMMAND to be out-of-band not * just for menu commands but for forms ones as well. */ #if defined(MAX_COMMAND) # if (MAX_MENU_COMMAND > MAX_COMMAND) # error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND # elif (MAX_COMMAND != (KEY_MAX + 128)) # error Something is wrong -- MAX_COMMAND is already inconsistently defined. # endif #else # define MAX_COMMAND (KEY_MAX + 128) #endif /* --------- prototypes for libmenu functions ----------------------------- */ extern MENU_EXPORT(ITEM **) menu_items(const MENU *); extern MENU_EXPORT(ITEM *) current_item(const MENU *); extern MENU_EXPORT(ITEM *) new_item(const char *, const char *); extern MENU_EXPORT(MENU *) new_menu(ITEM **); extern MENU_EXPORT(Item_Options) item_opts(const ITEM *); extern MENU_EXPORT(Menu_Options) menu_opts(const MENU *); extern MENU_EXPORT(Menu_Hook) item_init(const MENU *); extern MENU_EXPORT(Menu_Hook) item_term(const MENU *); extern MENU_EXPORT(Menu_Hook) menu_init(const MENU *); extern MENU_EXPORT(Menu_Hook) menu_term(const MENU *); extern MENU_EXPORT(WINDOW *) menu_sub(const MENU *); extern MENU_EXPORT(WINDOW *) menu_win(const MENU *); extern MENU_EXPORT(const char *) item_description(const ITEM *); extern MENU_EXPORT(const char *) item_name(const ITEM *); extern MENU_EXPORT(const char *) menu_mark(const MENU *); extern MENU_EXPORT(const char *) menu_request_name(int); extern MENU_EXPORT(char *) menu_pattern(const MENU *); extern MENU_EXPORT(void *) menu_userptr(const MENU *); extern MENU_EXPORT(void *) item_userptr(const ITEM *); extern MENU_EXPORT(chtype) menu_back(const MENU *); extern MENU_EXPORT(chtype) menu_fore(const MENU *); extern MENU_EXPORT(chtype) menu_grey(const MENU *); extern MENU_EXPORT(int) free_item(ITEM *); extern MENU_EXPORT(int) free_menu(MENU *); extern MENU_EXPORT(int) item_count(const MENU *); extern MENU_EXPORT(int) item_index(const ITEM *); extern MENU_EXPORT(int) item_opts_off(ITEM *, Item_Options); extern MENU_EXPORT(int) item_opts_on(ITEM *, Item_Options); extern MENU_EXPORT(int) menu_driver(MENU *, int); extern MENU_EXPORT(int) menu_opts_off(MENU *, Menu_Options); extern MENU_EXPORT(int) menu_opts_on(MENU *, Menu_Options); extern MENU_EXPORT(int) menu_pad(const MENU *); extern MENU_EXPORT(int) pos_menu_cursor(const MENU *); extern MENU_EXPORT(int) post_menu(MENU *); extern MENU_EXPORT(int) scale_menu(const MENU *, int *, int *); extern MENU_EXPORT(int) set_current_item(MENU *menu, ITEM *item); extern MENU_EXPORT(int) set_item_init(MENU *, Menu_Hook); extern MENU_EXPORT(int) set_item_opts(ITEM *, Item_Options); extern MENU_EXPORT(int) set_item_term(MENU *, Menu_Hook); extern MENU_EXPORT(int) set_item_userptr(ITEM *, void *); extern MENU_EXPORT(int) set_item_value(ITEM *, bool); extern MENU_EXPORT(int) set_menu_back(MENU *, chtype); extern MENU_EXPORT(int) set_menu_fore(MENU *, chtype); extern MENU_EXPORT(int) set_menu_format(MENU *, int, int); extern MENU_EXPORT(int) set_menu_grey(MENU *, chtype); extern MENU_EXPORT(int) set_menu_init(MENU *, Menu_Hook); extern MENU_EXPORT(int) set_menu_items(MENU *, ITEM **); extern MENU_EXPORT(int) set_menu_mark(MENU *, const char *); extern MENU_EXPORT(int) set_menu_opts(MENU *, Menu_Options); extern MENU_EXPORT(int) set_menu_pad(MENU *, int); extern MENU_EXPORT(int) set_menu_pattern(MENU *, const char *); extern MENU_EXPORT(int) set_menu_sub(MENU *, WINDOW *); extern MENU_EXPORT(int) set_menu_term(MENU *, Menu_Hook); extern MENU_EXPORT(int) set_menu_userptr(MENU *, void *); extern MENU_EXPORT(int) set_menu_win(MENU *, WINDOW *); extern MENU_EXPORT(int) set_top_row(MENU *, int); extern MENU_EXPORT(int) top_row(const MENU *); extern MENU_EXPORT(int) unpost_menu(MENU *); extern MENU_EXPORT(int) menu_request_by_name(const char *); extern MENU_EXPORT(int) set_menu_spacing(MENU *, int, int, int); extern MENU_EXPORT(int) menu_spacing(const MENU *, int *, int *, int *); extern MENU_EXPORT(bool) item_value(const ITEM *); extern MENU_EXPORT(bool) item_visible(const ITEM *); extern MENU_EXPORT(void) menu_format(const MENU *, int *, int *); #if NCURSES_SP_FUNCS extern MENU_EXPORT(MENU *) NCURSES_SP_NAME(new_menu) (SCREEN *, ITEM **); #endif #ifdef __cplusplus } #endif #endif /* ETI_MENU */ // * This makes emacs happy -*-Mode: C++;-*- // vile:cppmode /**************************************************************************** * Copyright 2019-2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ #ifndef NCURSES_CURSESP_H_incl #define NCURSES_CURSESP_H_incl 1 // $Id: cursesp.h,v 1.35 2021/04/17 18:11:08 tom Exp $ #include <cursesw.h> extern "C" { # include <panel.h> } class NCURSES_CXX_IMPEXP NCursesPanel : public NCursesWindow { protected: PANEL *p; static NCursesPanel *dummy; private: // This structure is used for the panel's user data field to link the // PANEL* to the C++ object and to provide extra space for a user pointer. typedef struct { void* m_user; // the pointer for the user's data const NCursesPanel* m_back; // backward pointer to C++ object const PANEL* m_owner; // the panel itself } UserHook; inline UserHook *UserPointer() { UserHook* uptr = reinterpret_cast<UserHook*>( const_cast<void *>(::panel_userptr (p))); return uptr; } void init(); // Initialize the panel object protected: void set_user(void *user) { UserHook* uptr = UserPointer(); if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) { uptr->m_user = user; } } // Set the user pointer of the panel. void *get_user() { UserHook* uptr = UserPointer(); void *result = 0; if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) result = uptr->m_user; return result; } void OnError (int err) const THROW2(NCursesException const, NCursesPanelException) { if (err==ERR) THROW(new NCursesPanelException (this, err)); } // If err is equal to the curses error indicator ERR, an error handler // is called. // Get a keystroke. Default implementation calls getch() virtual int getKey(void); public: NCursesPanel(int nlines, int ncols, int begin_y = 0, int begin_x = 0) : NCursesWindow(nlines,ncols,begin_y,begin_x), p(0) { init(); } // Create a panel with this size starting at the requested position. NCursesPanel() : NCursesWindow(::stdscr), p(0) { init(); } // This constructor creates the default Panel associated with the // ::stdscr window NCursesPanel& operator=(const NCursesPanel& rhs) { if (this != &rhs) { *this = rhs; NCursesWindow::operator=(rhs); } return *this; } NCursesPanel(const NCursesPanel& rhs) : NCursesWindow(rhs), p(rhs.p) { } virtual ~NCursesPanel() THROWS(NCursesException); // basic manipulation inline void hide() { OnError (::hide_panel(p)); } // Hide the panel. It stays in the stack but becomes invisible. inline void show() { OnError (::show_panel(p)); } // Show the panel, i.e. make it visible. inline void top() { OnError (::top_panel(p)); } // Make this panel the top panel in the stack. inline void bottom() { OnError (::bottom_panel(p)); } // Make this panel the bottom panel in the stack. // N.B.: The panel associated with ::stdscr is always on the bottom. So // actually bottom() makes the panel the first above ::stdscr. virtual int mvwin(int y, int x) { OnError(::move_panel(p, y, x)); return OK; } inline bool hidden() const { return (::panel_hidden (p) ? TRUE : FALSE); } // Return TRUE if the panel is hidden, FALSE otherwise. /* The functions panel_above() and panel_below() are not reflected in the NCursesPanel class. The reason for this is, that we cannot assume that a panel retrieved by those operations is one wrapped by a C++ class. Although this situation might be handled, we also need a reverse mapping from PANEL to NCursesPanel which needs some redesign of the low level stuff. At the moment, we define them in the interface but they will always produce an error. */ inline NCursesPanel& above() const { OnError(ERR); return *dummy; } inline NCursesPanel& below() const { OnError(ERR); return *dummy; } // Those two are rewrites of the corresponding virtual members of // NCursesWindow virtual int refresh(); // Propagate all panel changes to the virtual screen and update the // physical screen. virtual int noutrefresh(); // Propagate all panel changes to the virtual screen. static void redraw(); // Redraw all panels. // decorations virtual void frame(const char* title=NULL, const char* btitle=NULL); // Put a frame around the panel and put the title centered in the top line // and btitle in the bottom line. virtual void boldframe(const char* title=NULL, const char* btitle=NULL); // Same as frame(), but use highlighted attributes. virtual void label(const char* topLabel, const char* bottomLabel); // Put the title centered in the top line and btitle in the bottom line. virtual void centertext(int row,const char* label); // Put the label text centered in the specified row. }; /* We use templates to provide a typesafe mechanism to associate * user data with a panel. A NCursesUserPanel<T> is a panel * associated with some user data of type T. */ template<class T> class NCursesUserPanel : public NCursesPanel { public: NCursesUserPanel (int nlines, int ncols, int begin_y = 0, int begin_x = 0, const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel (nlines, ncols, begin_y, begin_x) { if (p) set_user (const_cast<void *>(reinterpret_cast<const void*> (p_UserData))); }; // This creates an user panel of the requested size with associated // user data pointed to by p_UserData. explicit NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel() { if (p) set_user(const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); }; // This creates an user panel associated with the ::stdscr and user data // pointed to by p_UserData. virtual ~NCursesUserPanel() THROWS(NCursesException) {}; T* UserData (void) { return reinterpret_cast<T*>(get_user ()); }; // Retrieve the user data associated with the panel. virtual void setUserData (const T* p_UserData) { if (p) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); } // Associate the user panel with the user data pointed to by p_UserData. }; #endif /* NCURSES_CURSESP_H_incl */ // * This makes emacs happy -*-Mode: C++;-*- /**************************************************************************** * Copyright 2019,2020 Thomas E. Dickey * * Copyright 1998-2005,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ // $Id: cursesapp.h,v 1.17 2020/08/29 16:22:03 juergen Exp $ #ifndef NCURSES_CURSESAPP_H_incl #define NCURSES_CURSESAPP_H_incl #include <cursslk.h> #if (defined(_WIN32) || defined(_WIN64)) # define NCURSES_CXX_MAIN_NAME cursespp_main # define NCURSES_CXX_MAIN \ int main(int argc, char *argv[]) { \ return NCURSES_CXX_MAIN_NAME(argc, argv); \ } #else # define NCURSES_CXX_MAIN_NAME main #endif NCURSES_CXX_IMPEXP int NCURSES_CXX_MAIN_NAME(int argc, char *argv[]); class NCURSES_CXX_IMPEXP NCursesApplication { public: typedef struct _slk_link { // This structure is used to maintain struct _slk_link* prev; // a stack of SLKs Soft_Label_Key_Set* SLKs; } SLK_Link; private: static int rinit(NCursesWindow& w); // Internal Init function for title static NCursesApplication* theApp; // Global ref. to the application static SLK_Link* slk_stack; protected: static NCursesWindow* titleWindow; // The Title Window (if any) bool b_Colors; // Is this a color application? NCursesWindow* Root_Window; // This is the stdscr equiv. // Initialization of attributes; // Rewrite this in your derived class if you prefer other settings virtual void init(bool bColors); // The number of lines for the title window. Default is no title window // You may rewrite this in your derived class virtual int titlesize() const { return 0; } // This method is called to put something into the title window initially // You may rewrite this in your derived class virtual void title() { } // The layout used for the Soft Label Keys. Default is to have no SLKs. // You may rewrite this in your derived class virtual Soft_Label_Key_Set::Label_Layout useSLKs() const { return Soft_Label_Key_Set::None; } // This method is called to initialize the SLKs. Default is nothing. // You may rewrite this in your derived class virtual void init_labels(Soft_Label_Key_Set& S) const { (void) S; } // Your derived class must implement this method. The return value must // be the exit value of your application. virtual int run() = 0; // The constructor is protected, so you may use it in your derived // class constructor. The argument tells whether or not you want colors. NCursesApplication(bool wantColors = FALSE); NCursesApplication& operator=(const NCursesApplication& rhs) { if (this != &rhs) { *this = rhs; } return *this; } NCursesApplication(const NCursesApplication& rhs) : b_Colors(rhs.b_Colors), Root_Window(rhs.Root_Window) { } static NCursesWindow *&getTitleWindow(); public: virtual ~NCursesApplication() THROWS(NCursesException); // Get a pointer to the current application object static NCursesApplication* getApplication(); // This method runs the application and returns its exit value int operator()(void); // Process the commandline arguments. The default implementation simply // ignores them. Your derived class may rewrite this. virtual void handleArgs(int argc, char* argv[]) { (void) argc; (void) argv; } // Does this application use colors? inline bool useColors() const { return b_Colors; } // Push the Key Set S onto the SLK Stack. S then becomes the current set // of Soft Labelled Keys. void push(Soft_Label_Key_Set& S); // Throw away the current set of SLKs and make the previous one the // new current set. bool pop(); // Retrieve the current set of Soft Labelled Keys. Soft_Label_Key_Set* top() const; // Attributes to use for menu and forms foregrounds virtual chtype foregrounds() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(1)) : A_BOLD; } // Attributes to use for menu and forms backgrounds virtual chtype backgrounds() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(2)) : A_NORMAL; } // Attributes to use for inactive (menu) elements virtual chtype inactives() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(3)|A_DIM) : A_DIM; } // Attributes to use for (form) labels and SLKs virtual chtype labels() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(4)) : A_NORMAL; } // Attributes to use for form backgrounds virtual chtype dialog_backgrounds() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(4)) : A_NORMAL; } // Attributes to use as default for (form) window backgrounds virtual chtype window_backgrounds() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(5)) : A_NORMAL; } // Attributes to use for the title window virtual chtype screen_titles() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(6)) : A_BOLD; } }; #endif /* NCURSES_CURSESAPP_H_incl */ // * This makes emacs happy -*-Mode: C++;-*- // vile:cppmode /**************************************************************************** * Copyright 2019-2020,2021 Thomas E. Dickey * * Copyright 1998-2014,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ #ifndef NCURSES_CURSESW_H_incl #define NCURSES_CURSESW_H_incl 1 // $Id: cursesw.h,v 1.58 2021/04/17 18:11:08 tom Exp $ extern "C" { # include <curses.h> } #if defined(BUILDING_NCURSES_CXX) # define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT #else # define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT #endif #define NCURSES_CXX_WRAPPED_VAR(type,name) extern NCURSES_CXX_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) #define NCURSES_CXX_EXPORT(type) NCURSES_CXX_IMPEXP type NCURSES_API #define NCURSES_CXX_EXPORT_VAR(type) NCURSES_CXX_IMPEXP type #include <etip.h> /* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro. Undefine it here, because NCursesWindow uses lines as a method. */ #undef lines /* "Convert" macros to inlines. We'll define it as another symbol to avoid * conflict with library symbols. */ #undef UNDEF #define UNDEF(name) CUR_ ##name #ifdef addch inline int UNDEF(addch)(chtype ch) { return addch(ch); } #undef addch #define addch UNDEF(addch) #endif #ifdef addchstr inline int UNDEF(addchstr)(chtype *at) { return addchstr(at); } #undef addchstr #define addchstr UNDEF(addchstr) #endif #ifdef addnstr inline int UNDEF(addnstr)(const char *str, int n) { return addnstr(str, n); } #undef addnstr #define addnstr UNDEF(addnstr) #endif #ifdef addstr inline int UNDEF(addstr)(const char * str) { return addstr(str); } #undef addstr #define addstr UNDEF(addstr) #endif #ifdef attroff inline int UNDEF(attroff)(chtype at) { return attroff(at); } #undef attroff #define attroff UNDEF(attroff) #endif #ifdef attron inline int UNDEF(attron)(chtype at) { return attron(at); } #undef attron #define attron UNDEF(attron) #endif #ifdef attrset inline chtype UNDEF(attrset)(chtype at) { return attrset(at); } #undef attrset #define attrset UNDEF(attrset) #endif #ifdef bkgd inline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); } #undef bkgd #define bkgd UNDEF(bkgd) #endif #ifdef bkgdset inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); } #undef bkgdset #define bkgdset UNDEF(bkgdset) #endif #ifdef border inline int UNDEF(border)(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br) { return border(ls, rs, ts, bs, tl, tr, bl, br); } #undef border #define border UNDEF(border) #endif #ifdef box inline int UNDEF(box)(WINDOW *win, int v, int h) { return box(win, v, h); } #undef box #define box UNDEF(box) #endif #ifdef chgat inline int UNDEF(chgat)(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) { return chgat(n, attr, color, opts); } #undef chgat #define chgat UNDEF(chgat) #endif #ifdef clear inline int UNDEF(clear)() { return clear(); } #undef clear #define clear UNDEF(clear) #endif #ifdef clearok inline int UNDEF(clearok)(WINDOW* win, bool bf) { return clearok(win, bf); } #undef clearok #define clearok UNDEF(clearok) #else extern "C" NCURSES_IMPEXP int NCURSES_API clearok(WINDOW*, bool); #endif #ifdef clrtobot inline int UNDEF(clrtobot)() { return clrtobot(); } #undef clrtobot #define clrtobot UNDEF(clrtobot) #endif #ifdef clrtoeol inline int UNDEF(clrtoeol)() { return clrtoeol(); } #undef clrtoeol #define clrtoeol UNDEF(clrtoeol) #endif #ifdef color_set inline chtype UNDEF(color_set)(NCURSES_PAIRS_T p, void* opts) { return color_set(p, opts); } #undef color_set #define color_set UNDEF(color_set) #endif #ifdef crmode inline int UNDEF(crmode)(void) { return crmode(); } #undef crmode #define crmode UNDEF(crmode) #endif #ifdef delch inline int UNDEF(delch)() { return delch(); } #undef delch #define delch UNDEF(delch) #endif #ifdef deleteln inline int UNDEF(deleteln)() { return deleteln(); } #undef deleteln #define deleteln UNDEF(deleteln) #endif #ifdef echochar inline int UNDEF(echochar)(chtype ch) { return echochar(ch); } #undef echochar #define echochar UNDEF(echochar) #endif #ifdef erase inline int UNDEF(erase)() { return erase(); } #undef erase #define erase UNDEF(erase) #endif #ifdef fixterm inline int UNDEF(fixterm)(void) { return fixterm(); } #undef fixterm #define fixterm UNDEF(fixterm) #endif #ifdef flushok inline int UNDEF(flushok)(WINDOW* _win, bool _bf) { return flushok(_win, _bf); } #undef flushok #define flushok UNDEF(flushok) #else #define _no_flushok #endif #ifdef getattrs inline int UNDEF(getattrs)(WINDOW *win) { return getattrs(win); } #undef getattrs #define getattrs UNDEF(getattrs) #endif #ifdef getbegyx inline void UNDEF(getbegyx)(WINDOW* win, int& y, int& x) { getbegyx(win, y, x); } #undef getbegyx #define getbegyx UNDEF(getbegyx) #endif #ifdef getbkgd inline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); } #undef getbkgd #define getbkgd UNDEF(getbkgd) #endif #ifdef getch inline int UNDEF(getch)() { return getch(); } #undef getch #define getch UNDEF(getch) #endif #ifdef getmaxyx inline void UNDEF(getmaxyx)(WINDOW* win, int& y, int& x) { getmaxyx(win, y, x); } #undef getmaxyx #define getmaxyx UNDEF(getmaxyx) #endif #ifdef getnstr inline int UNDEF(getnstr)(char *_str, int n) { return getnstr(_str, n); } #undef getnstr #define getnstr UNDEF(getnstr) #endif #ifdef getparyx inline void UNDEF(getparyx)(WINDOW* win, int& y, int& x) { getparyx(win, y, x); } #undef getparyx #define getparyx UNDEF(getparyx) #endif #ifdef getstr inline int UNDEF(getstr)(char *_str) { return getstr(_str); } #undef getstr #define getstr UNDEF(getstr) #endif #ifdef getyx inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) { getyx(win, y, x); } #undef getyx #define getyx UNDEF(getyx) #endif #ifdef hline inline int UNDEF(hline)(chtype ch, int n) { return hline(ch, n); } #undef hline #define hline UNDEF(hline) #endif #ifdef inch inline chtype UNDEF(inch)() { return inch(); } #undef inch #define inch UNDEF(inch) #endif #ifdef inchstr inline int UNDEF(inchstr)(chtype *str) { return inchstr(str); } #undef inchstr #define inchstr UNDEF(inchstr) #endif #ifdef innstr inline int UNDEF(innstr)(char *_str, int n) { return innstr(_str, n); } #undef innstr #define innstr UNDEF(innstr) #endif #ifdef insch inline int UNDEF(insch)(chtype c) { return insch(c); } #undef insch #define insch UNDEF(insch) #endif #ifdef insdelln inline int UNDEF(insdelln)(int n) { return insdelln(n); } #undef insdelln #define insdelln UNDEF(insdelln) #endif #ifdef insertln inline int UNDEF(insertln)() { return insertln(); } #undef insertln #define insertln UNDEF(insertln) #endif #ifdef insnstr inline int UNDEF(insnstr)(const char *_str, int n) { return insnstr(_str, n); } #undef insnstr #define insnstr UNDEF(insnstr) #endif #ifdef insstr inline int UNDEF(insstr)(const char *_str) { return insstr(_str); } #undef insstr #define insstr UNDEF(insstr) #endif #ifdef instr inline int UNDEF(instr)(char *_str) { return instr(_str); } #undef instr #define instr UNDEF(instr) #endif #ifdef intrflush inline void UNDEF(intrflush)(WINDOW *win, bool bf) { intrflush(); } #undef intrflush #define intrflush UNDEF(intrflush) #endif #ifdef is_linetouched inline int UNDEF(is_linetouched)(WINDOW *w, int l) { return is_linetouched(w,l); } #undef is_linetouched #define is_linetouched UNDEF(is_linetouched) #endif #ifdef leaveok inline int UNDEF(leaveok)(WINDOW* win, bool bf) { return leaveok(win, bf); } #undef leaveok #define leaveok UNDEF(leaveok) #else extern "C" NCURSES_IMPEXP int NCURSES_API leaveok(WINDOW* win, bool bf); #endif #ifdef move inline int UNDEF(move)(int x, int y) { return move(x, y); } #undef move #define move UNDEF(move) #endif #ifdef mvaddch inline int UNDEF(mvaddch)(int y, int x, chtype ch) { return mvaddch(y, x, ch); } #undef mvaddch #define mvaddch UNDEF(mvaddch) #endif #ifdef mvaddnstr inline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n) { return mvaddnstr(y, x, str, n); } #undef mvaddnstr #define mvaddnstr UNDEF(mvaddnstr) #endif #ifdef mvaddstr inline int UNDEF(mvaddstr)(int y, int x, const char * str) { return mvaddstr(y, x, str); } #undef mvaddstr #define mvaddstr UNDEF(mvaddstr) #endif #ifdef mvchgat inline int UNDEF(mvchgat)(int y, int x, int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) { return mvchgat(y, x, n, attr, color, opts); } #undef mvchgat #define mvchgat UNDEF(mvchgat) #endif #ifdef mvdelch inline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);} #undef mvdelch #define mvdelch UNDEF(mvdelch) #endif #ifdef mvgetch inline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);} #undef mvgetch #define mvgetch UNDEF(mvgetch) #endif #ifdef mvgetnstr inline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) { return mvgetnstr(y, x, str, n);} #undef mvgetnstr #define mvgetnstr UNDEF(mvgetnstr) #endif #ifdef mvgetstr inline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);} #undef mvgetstr #define mvgetstr UNDEF(mvgetstr) #endif #ifdef mvinch inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);} #undef mvinch #define mvinch UNDEF(mvinch) #endif #ifdef mvinnstr inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) { return mvinnstr(y, x, _str, n); } #undef mvinnstr #define mvinnstr UNDEF(mvinnstr) #endif #ifdef mvinsch inline int UNDEF(mvinsch)(int y, int x, chtype c) { return mvinsch(y, x, c); } #undef mvinsch #define mvinsch UNDEF(mvinsch) #endif #ifdef mvinsnstr inline int UNDEF(mvinsnstr)(int y, int x, const char *_str, int n) { return mvinsnstr(y, x, _str, n); } #undef mvinsnstr #define mvinsnstr UNDEF(mvinsnstr) #endif #ifdef mvinsstr inline int UNDEF(mvinsstr)(int y, int x, const char *_str) { return mvinsstr(y, x, _str); } #undef mvinsstr #define mvinsstr UNDEF(mvinsstr) #endif #ifdef mvwaddch inline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch) { return mvwaddch(win, y, x, ch); } #undef mvwaddch #define mvwaddch UNDEF(mvwaddch) #endif #ifdef mvwaddchnstr inline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, const chtype *str, int n) { return mvwaddchnstr(win, y, x, str, n); } #undef mvwaddchnstr #define mvwaddchnstr UNDEF(mvwaddchnstr) #endif #ifdef mvwaddchstr inline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, const chtype *str) { return mvwaddchstr(win, y, x, str); } #undef mvwaddchstr #define mvwaddchstr UNDEF(mvwaddchstr) #endif #ifdef mvwaddnstr inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n) { return mvwaddnstr(win, y, x, str, n); } #undef mvwaddnstr #define mvwaddnstr UNDEF(mvwaddnstr) #endif #ifdef mvwaddstr inline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str) { return mvwaddstr(win, y, x, str); } #undef mvwaddstr #define mvwaddstr UNDEF(mvwaddstr) #endif #ifdef mvwchgat inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) { return mvwchgat(win, y, x, n, attr, color, opts); } #undef mvwchgat #define mvwchgat UNDEF(mvwchgat) #endif #ifdef mvwdelch inline int UNDEF(mvwdelch)(WINDOW *win, int y, int x) { return mvwdelch(win, y, x); } #undef mvwdelch #define mvwdelch UNDEF(mvwdelch) #endif #ifdef mvwgetch inline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);} #undef mvwgetch #define mvwgetch UNDEF(mvwgetch) #endif #ifdef mvwgetnstr inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n) {return mvwgetnstr(win, y, x, str, n);} #undef mvwgetnstr #define mvwgetnstr UNDEF(mvwgetnstr) #endif #ifdef mvwgetstr inline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str) {return mvwgetstr(win, y, x, str);} #undef mvwgetstr #define mvwgetstr UNDEF(mvwgetstr) #endif #ifdef mvwhline inline int UNDEF(mvwhline)(WINDOW *win, int y, int x, chtype c, int n) { return mvwhline(win, y, x, c, n); } #undef mvwhline #define mvwhline UNDEF(mvwhline) #endif #ifdef mvwinch inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) { return mvwinch(win, y, x);} #undef mvwinch #define mvwinch UNDEF(mvwinch) #endif #ifdef mvwinchnstr inline int UNDEF(mvwinchnstr)(WINDOW *win, int y, int x, chtype *str, int n) { return mvwinchnstr(win, y, x, str, n); } #undef mvwinchnstr #define mvwinchnstr UNDEF(mvwinchnstr) #endif #ifdef mvwinchstr inline int UNDEF(mvwinchstr)(WINDOW *win, int y, int x, chtype *str) { return mvwinchstr(win, y, x, str); } #undef mvwinchstr #define mvwinchstr UNDEF(mvwinchstr) #endif #ifdef mvwinnstr inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) { return mvwinnstr(win, y, x, _str, n); } #undef mvwinnstr #define mvwinnstr UNDEF(mvwinnstr) #endif #ifdef mvwinsch inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c) { return mvwinsch(win, y, x, c); } #undef mvwinsch #define mvwinsch UNDEF(mvwinsch) #endif #ifdef mvwinsnstr inline int UNDEF(mvwinsnstr)(WINDOW *w, int y, int x, const char *_str, int n) { return mvwinsnstr(w, y, x, _str, n); } #undef mvwinsnstr #define mvwinsnstr UNDEF(mvwinsnstr) #endif #ifdef mvwinsstr inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x, const char *_str) { return mvwinsstr(w, y, x, _str); } #undef mvwinsstr #define mvwinsstr UNDEF(mvwinsstr) #endif #ifdef mvwvline inline int UNDEF(mvwvline)(WINDOW *win, int y, int x, chtype c, int n) { return mvwvline(win, y, x, c, n); } #undef mvwvline #define mvwvline UNDEF(mvwvline) #endif #ifdef napms inline void UNDEF(napms)(unsigned long x) { napms(x); } #undef napms #define napms UNDEF(napms) #endif #ifdef nocrmode inline int UNDEF(nocrmode)(void) { return nocrmode(); } #undef nocrmode #define nocrmode UNDEF(nocrmode) #endif #ifdef nodelay inline void UNDEF(nodelay)() { nodelay(); } #undef nodelay #define nodelay UNDEF(nodelay) #endif #ifdef redrawwin inline int UNDEF(redrawwin)(WINDOW *win) { return redrawwin(win); } #undef redrawwin #define redrawwin UNDEF(redrawwin) #endif #ifdef refresh inline int UNDEF(refresh)() { return refresh(); } #undef refresh #define refresh UNDEF(refresh) #endif #ifdef resetterm inline int UNDEF(resetterm)(void) { return resetterm(); } #undef resetterm #define resetterm UNDEF(resetterm) #endif #ifdef saveterm inline int UNDEF(saveterm)(void) { return saveterm(); } #undef saveterm #define saveterm UNDEF(saveterm) #endif #ifdef scrl inline int UNDEF(scrl)(int l) { return scrl(l); } #undef scrl #define scrl UNDEF(scrl) #endif #ifdef scroll inline int UNDEF(scroll)(WINDOW *win) { return scroll(win); } #undef scroll #define scroll UNDEF(scroll) #endif #ifdef scrollok inline int UNDEF(scrollok)(WINDOW* win, bool bf) { return scrollok(win, bf); } #undef scrollok #define scrollok UNDEF(scrollok) #else #if defined(__NCURSES_H) extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, bool); #else extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, char); #endif #endif #ifdef setscrreg inline int UNDEF(setscrreg)(int t, int b) { return setscrreg(t, b); } #undef setscrreg #define setscrreg UNDEF(setscrreg) #endif #ifdef standend inline int UNDEF(standend)() { return standend(); } #undef standend #define standend UNDEF(standend) #endif #ifdef standout inline int UNDEF(standout)() { return standout(); } #undef standout #define standout UNDEF(standout) #endif #ifdef subpad inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x) { return derwin(p, l, c, y, x); } #undef subpad #define subpad UNDEF(subpad) #endif #ifdef timeout inline void UNDEF(timeout)(int delay) { timeout(delay); } #undef timeout #define timeout UNDEF(timeout) #endif #ifdef touchline inline int UNDEF(touchline)(WINDOW *win, int s, int c) { return touchline(win, s, c); } #undef touchline #define touchline UNDEF(touchline) #endif #ifdef touchwin inline int UNDEF(touchwin)(WINDOW *win) { return touchwin(win); } #undef touchwin #define touchwin UNDEF(touchwin) #endif #ifdef untouchwin inline int UNDEF(untouchwin)(WINDOW *win) { return untouchwin(win); } #undef untouchwin #define untouchwin UNDEF(untouchwin) #endif #ifdef vline inline int UNDEF(vline)(chtype ch, int n) { return vline(ch, n); } #undef vline #define vline UNDEF(vline) #endif #ifdef waddchstr inline int UNDEF(waddchstr)(WINDOW *win, chtype *at) { return waddchstr(win, at); } #undef waddchstr #define waddchstr UNDEF(waddchstr) #endif #ifdef waddstr inline int UNDEF(waddstr)(WINDOW *win, char *str) { return waddstr(win, str); } #undef waddstr #define waddstr UNDEF(waddstr) #endif #ifdef wattroff inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); } #undef wattroff #define wattroff UNDEF(wattroff) #endif #ifdef wattrset inline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); } #undef wattrset #define wattrset UNDEF(wattrset) #endif #ifdef winch inline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); } #undef winch #define winch UNDEF(winch) #endif #ifdef winchnstr inline int UNDEF(winchnstr)(WINDOW *win, chtype *str, int n) { return winchnstr(win, str, n); } #undef winchnstr #define winchnstr UNDEF(winchnstr) #endif #ifdef winchstr inline int UNDEF(winchstr)(WINDOW *win, chtype *str) { return winchstr(win, str); } #undef winchstr #define winchstr UNDEF(winchstr) #endif #ifdef winsstr inline int UNDEF(winsstr)(WINDOW *w, const char *_str) { return winsstr(w, _str); } #undef winsstr #define winsstr UNDEF(winsstr) #endif #ifdef wstandend inline int UNDEF(wstandend)(WINDOW *win) { return wstandend(win); } #undef wstandend #define wstandend UNDEF(wstandend) #endif #ifdef wstandout inline int UNDEF(wstandout)(WINDOW *win) { return wstandout(win); } #undef wstandout #define wstandout UNDEF(wstandout) #endif /* * * C++ class for windows. * */ extern "C" int _nc_ripoffline(int, int (*init)(WINDOW*, int)); extern "C" int _nc_xx_ripoff_init(WINDOW *, int); extern "C" int _nc_has_mouse(void); class NCURSES_CXX_IMPEXP NCursesWindow { friend class NCursesMenu; friend class NCursesForm; private: static bool b_initialized; static void initialize(); void constructing(); friend int _nc_xx_ripoff_init(WINDOW *, int); void set_keyboard(); NCURSES_COLOR_T getcolor(int getback) const; NCURSES_PAIRS_T getPair() const; static int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back, NCURSES_PAIRS_T pair); static int colorInitialized; // This private constructor is only used during the initialization // of windows generated by ripoffline() calls. NCursesWindow(WINDOW* win, int ncols); protected: virtual void err_handler(const char *) const THROWS(NCursesException); // Signal an error with the given message text. static long count; // count of all active windows: // We rely on the c++ promise that // all otherwise uninitialized // static class vars are set to 0 WINDOW* w; // the curses WINDOW bool alloced; // TRUE if we own the WINDOW NCursesWindow* par; // parent, if subwindow NCursesWindow* subwins; // head of subwindows list NCursesWindow* sib; // next subwindow of parent void kill_subwindows(); // disable all subwindows // Destroy all subwindows. /* Only for use by derived classes. They are then in charge to fill the member variables correctly. */ NCursesWindow(); public: explicit NCursesWindow(WINDOW* window); // useful only for stdscr NCursesWindow(int nlines, // number of lines int ncols, // number of columns int begin_y, // line origin int begin_x); // col origin NCursesWindow(NCursesWindow& par,// parent window int nlines, // number of lines int ncols, // number of columns int begin_y, // absolute or relative int begin_x, // origins: char absrel = 'a');// if `a', begin_y & begin_x are // absolute screen pos, else if `r', they are relative to par origin NCursesWindow(NCursesWindow& par,// parent window bool do_box = TRUE); // this is the very common case that we want to create the subwindow that // is two lines and two columns smaller and begins at (1,1). // We may automatically request the box around it. NCursesWindow& operator=(const NCursesWindow& rhs) { if (this != &rhs) *this = rhs; return *this; } NCursesWindow(const NCursesWindow& rhs) : w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib) { } virtual ~NCursesWindow() THROWS(NCursesException); NCursesWindow Clone(); // Make an exact copy of the window. // Initialization. static void useColors(void); // Call this routine very early if you want to have colors. static int ripoffline(int ripoff_lines, int (*init)(NCursesWindow& win)); // This function is used to generate a window of ripped-of lines. // If the argument is positive, lines are removed from the top, if it // is negative lines are removed from the bottom. This enhances the // lowlevel ripoffline() function because it uses the internal // implementation that allows to remove more than just a single line. // This function must be called before any other ncurses function. The // creation of the window is deferred until ncurses gets initialized. // The initialization function is then called. // ------------------------------------------------------------------------- // terminal status // ------------------------------------------------------------------------- int lines() const { initialize(); return LINES; } // Number of lines on terminal, *not* window int cols() const { initialize(); return COLS; } // Number of cols on terminal, *not* window int tabsize() const { initialize(); return TABSIZE; } // Size of a tab on terminal, *not* window static int NumberOfColors(); // Number of available colors int colors() const { return NumberOfColors(); } // Number of available colors // ------------------------------------------------------------------------- // window status // ------------------------------------------------------------------------- int height() const { return maxy() + 1; } // Number of lines in this window int width() const { return maxx() + 1; } // Number of columns in this window int begx() const { return getbegx(w); } // Column of top left corner relative to stdscr int begy() const { return getbegy(w); } // Line of top left corner relative to stdscr int curx() const { return getcurx(w); } // Column of top left corner relative to stdscr int cury() const { return getcury(w); } // Line of top left corner relative to stdscr int maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; } // Largest x coord in window int maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; } // Largest y coord in window NCURSES_PAIRS_T getcolor() const; // Actual color pair NCURSES_COLOR_T foreground() const { return getcolor(0); } // Actual foreground color NCURSES_COLOR_T background() const { return getcolor(1); } // Actual background color int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back); // Set color palette entry int setcolor(NCURSES_PAIRS_T pair); // Set actually used palette entry // ------------------------------------------------------------------------- // window positioning // ------------------------------------------------------------------------- virtual int mvwin(int begin_y, int begin_x) { return ::mvwin(w, begin_y, begin_x); } // Move window to new position with the new position as top left corner. // This is virtual because it is redefined in NCursesPanel. // ------------------------------------------------------------------------- // coordinate positioning // ------------------------------------------------------------------------- int move(int y, int x) { return ::wmove(w, y, x); } // Move cursor the this position void getyx(int& y, int& x) const { ::getyx(w, y, x); } // Get current position of the cursor void getbegyx(int& y, int& x) const { ::getbegyx(w, y, x); } // Get beginning of the window void getmaxyx(int& y, int& x) const { ::getmaxyx(w, y, x); } // Get size of the window void getparyx(int& y, int& x) const { ::getparyx(w, y, x); } // Get parent's beginning of the window int mvcur(int oldrow, int oldcol, int newrow, int newcol) const { return ::mvcur(oldrow, oldcol, newrow, newcol); } // Perform lowlevel cursor motion that takes effect immediately. // ------------------------------------------------------------------------- // input // ------------------------------------------------------------------------- int getch() { return ::wgetch(w); } // Get a keystroke from the window. int getch(int y, int x) { return ::mvwgetch(w, y, x); } // Move cursor to position and get a keystroke from the window int getstr(char* str, int n=-1) { return ::wgetnstr(w, str, n); } // Read a series of characters into str until a newline or carriage return // is received. Read at most n characters. If n is negative, the limit is // ignored. int getstr(int y, int x, char* str, int n=-1) { return ::mvwgetnstr(w, y, x, str, n); } // Move the cursor to the requested position and then perform the getstr() // as described above. int instr(char *s, int n=-1) { return ::winnstr(w, s, n); } // Get a string of characters from the window into the buffer s. Retrieve // at most n characters, if n is negative retrieve all characters up to the // end of the current line. Attributes are stripped from the characters. int instr(int y, int x, char *s, int n=-1) { return ::mvwinnstr(w, y, x, s, n); } // Move the cursor to the requested position and then perform the instr() // as described above. int scanw(const char* fmt, ...) // Perform a scanw function from the window. #if __GNUG__ >= 2 __attribute__ ((format (scanf, 2, 3))); #else ; #endif int scanw(const char*, va_list); // Perform a scanw function from the window. int scanw(int y, int x, const char* fmt, ...) // Move the cursor to the requested position and then perform a scanw // from the window. #if __GNUG__ >= 2 __attribute__ ((format (scanf, 4, 5))); #else ; #endif int scanw(int y, int x, const char* fmt, va_list); // Move the cursor to the requested position and then perform a scanw // from the window. // ------------------------------------------------------------------------- // output // ------------------------------------------------------------------------- int addch(const chtype ch) { return ::waddch(w, ch); } // Put attributed character to the window. int addch(int y, int x, const chtype ch) { return ::mvwaddch(w, y, x, ch); } // Move cursor to the requested position and then put attributed character // to the window. int echochar(const chtype ch) { return ::wechochar(w, ch); } // Put attributed character to the window and refresh it immediately. int addstr(const char* str, int n=-1) { return ::waddnstr(w, str, n); } // Write the string str to the window, stop writing if the terminating // NUL or the limit n is reached. If n is negative, it is ignored. int addstr(int y, int x, const char * str, int n=-1) { return ::mvwaddnstr(w, y, x, str, n); } // Move the cursor to the requested position and then perform the addchstr // as described above. int addchstr(const chtype* str, int n=-1) { return ::waddchnstr(w, str, n); } // Write the string str to the window, stop writing if the terminating // NUL or the limit n is reached. If n is negative, it is ignored. int addchstr(int y, int x, const chtype * str, int n=-1) { return ::mvwaddchnstr(w, y, x, str, n); } // Move the cursor to the requested position and then perform the addchstr // as described above. int printw(const char* fmt, ...) // Do a formatted print to the window. #if (__GNUG__ >= 2) && !defined(printf) __attribute__ ((format (printf, 2, 3))); #else ; #endif int printw(int y, int x, const char * fmt, ...) // Move the cursor and then do a formatted print to the window. #if (__GNUG__ >= 2) && !defined(printf) __attribute__ ((format (printf, 4, 5))); #else ; #endif int printw(const char* fmt, va_list args); // Do a formatted print to the window. int printw(int y, int x, const char * fmt, va_list args); // Move the cursor and then do a formatted print to the window. chtype inch() const { return ::winch(w); } // Retrieve attributed character under the current cursor position. chtype inch(int y, int x) { return ::mvwinch(w, y, x); } // Move cursor to requested position and then retrieve attributed character // at this position. int inchstr(chtype* str, int n=-1) { return ::winchnstr(w, str, n); } // Read the string str from the window, stop reading if the terminating // NUL or the limit n is reached. If n is negative, it is ignored. int inchstr(int y, int x, chtype * str, int n=-1) { return ::mvwinchnstr(w, y, x, str, n); } // Move the cursor to the requested position and then perform the inchstr // as described above. int insch(chtype ch) { return ::winsch(w, ch); } // Insert attributed character into the window before current cursor // position. int insch(int y, int x, chtype ch) { return ::mvwinsch(w, y, x, ch); } // Move cursor to requested position and then insert the attributed // character before that position. int insertln() { return ::winsdelln(w, 1); } // Insert an empty line above the current line. int insdelln(int n=1) { return ::winsdelln(w, n); } // If n>0 insert that many lines above the current line. If n<0 delete // that many lines beginning with the current line. int insstr(const char *s, int n=-1) { return ::winsnstr(w, s, n); } // Insert the string into the window before the current cursor position. // Insert stops at end of string or when the limit n is reached. If n is // negative, it is ignored. int insstr(int y, int x, const char *s, int n=-1) { return ::mvwinsnstr(w, y, x, s, n); } // Move the cursor to the requested position and then perform the insstr() // as described above. int attron (chtype at) { return ::wattron (w, at); } // Switch on the window attributes; int attroff(chtype at) { return ::wattroff(w, static_cast<int>(at)); } // Switch off the window attributes; int attrset(chtype at) { return ::wattrset(w, static_cast<int>(at)); } // Set the window attributes; chtype attrget() { return ::getattrs(w); } // Get the window attributes; int color_set(NCURSES_PAIRS_T color_pair_number, void* opts=NULL) { return ::wcolor_set(w, color_pair_number, opts); } // Set the window color attribute; int chgat(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) { return ::wchgat(w, n, attr, color, opts); } // Change the attributes of the next n characters in the current line. If // n is negative or greater than the number of remaining characters in the // line, the attributes will be changed up to the end of the line. int chgat(int y, int x, int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) { return ::mvwchgat(w, y, x, n, attr, color, opts); } // Move the cursor to the requested position and then perform chgat() as // described above. // ------------------------------------------------------------------------- // background // ------------------------------------------------------------------------- chtype getbkgd() const { return ::getbkgd(w); } // Get current background setting. int bkgd(const chtype ch) { return ::wbkgd(w, ch); } // Set the background property and apply it to the window. void bkgdset(chtype ch) { ::wbkgdset(w, ch); } // Set the background property. // ------------------------------------------------------------------------- // borders // ------------------------------------------------------------------------- int box(chtype vert=0, chtype hor=0) { return ::wborder(w, vert, vert, hor, hor, 0, 0, 0, 0); } // Draw a box around the window with the given vertical and horizontal // drawing characters. If you specify a zero as character, curses will try // to find a "nice" character. int border(chtype left=0, chtype right=0, chtype top =0, chtype bottom=0, chtype top_left =0, chtype top_right=0, chtype bottom_left =0, chtype bottom_right=0) { return ::wborder(w, left, right, top, bottom, top_left, top_right, bottom_left, bottom_right); } // Draw a border around the window with the given characters for the // various parts of the border. If you pass zero for a character, curses // will try to find "nice" characters. // ------------------------------------------------------------------------- // lines and boxes // ------------------------------------------------------------------------- int hline(int len, chtype ch=0) { return ::whline(w, ch, len); } // Draw a horizontal line of len characters with the given character. If // you pass zero for the character, curses will try to find a "nice" one. int hline(int y, int x, int len, chtype ch=0) { return ::mvwhline(w, y, x, ch, len); } // Move the cursor to the requested position and then draw a horizontal line. int vline(int len, chtype ch=0) { return ::wvline(w, ch, len); } // Draw a vertical line of len characters with the given character. If // you pass zero for the character, curses will try to find a "nice" one. int vline(int y, int x, int len, chtype ch=0) { return ::mvwvline(w, y, x, ch, len); } // Move the cursor to the requested position and then draw a vertical line. // ------------------------------------------------------------------------- // erasure // ------------------------------------------------------------------------- int erase() { return ::werase(w); } // Erase the window. int clear() { return ::wclear(w); } // Clear the window. int clearok(bool bf) { return ::clearok(w, bf); } // Set/Reset the clear flag. If set, the next refresh() will clear the // screen. int clrtobot() { return ::wclrtobot(w); } // Clear to the end of the window. int clrtoeol() { return ::wclrtoeol(w); } // Clear to the end of the line. int delch() { return ::wdelch(w); } // Delete character under the cursor. int delch(int y, int x) { return ::mvwdelch(w, y, x); } // Move cursor to requested position and delete the character under the // cursor. int deleteln() { return ::winsdelln(w, -1); } // Delete the current line. // ------------------------------------------------------------------------- // screen control // ------------------------------------------------------------------------- int scroll(int amount=1) { return ::wscrl(w, amount); } // Scroll amount lines. If amount is positive, scroll up, otherwise // scroll down. int scrollok(bool bf) { return ::scrollok(w, bf); } // If bf is TRUE, window scrolls if cursor is moved off the bottom // edge of the window or a scrolling region, otherwise the cursor is left // at the bottom line. int setscrreg(int from, int to) { return ::wsetscrreg(w, from, to); } // Define a soft scrolling region. int idlok(bool bf) { return ::idlok(w, bf); } // If bf is TRUE, use insert/delete line hardware support if possible. // Otherwise do it in software. void idcok(bool bf) { ::idcok(w, bf); } // If bf is TRUE, use insert/delete character hardware support if possible. // Otherwise do it in software. int touchline(int s, int c) { return ::touchline(w, s, c); } // Mark the given lines as modified. int touchwin() { return ::wtouchln(w, 0, height(), 1); } // Mark the whole window as modified. int untouchwin() { return ::wtouchln(w, 0, height(), 0); } // Mark the whole window as unmodified. int touchln(int s, int cnt, bool changed=TRUE) { return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); } // Mark cnt lines beginning from line s as changed or unchanged, depending // on the value of the changed flag. bool is_linetouched(int line) const { return (::is_linetouched(w, line) == TRUE ? TRUE:FALSE); } // Return TRUE if line is marked as changed, FALSE otherwise bool is_wintouched() const { return (::is_wintouched(w) ? TRUE:FALSE); } // Return TRUE if window is marked as changed, FALSE otherwise int leaveok(bool bf) { return ::leaveok(w, bf); } // If bf is TRUE, curses will leave the cursor after an update wherever // it is after the update. int redrawln(int from, int n) { return ::wredrawln(w, from, n); } // Redraw n lines starting from the requested line int redrawwin() { return ::wredrawln(w, 0, height()); } // Redraw the whole window int doupdate() { return ::doupdate(); } // Do all outputs to make the physical screen looking like the virtual one void syncdown() { ::wsyncdown(w); } // Propagate the changes down to all descendant windows void syncup() { ::wsyncup(w); } // Propagate the changes up in the hierarchy void cursyncup() { ::wcursyncup(w); } // Position the cursor in all ancestor windows corresponding to our setting int syncok(bool bf) { return ::syncok(w, bf); } // If called with bf=TRUE, syncup() is called whenever the window is changed #ifndef _no_flushok int flushok(bool bf) { return ::flushok(w, bf); } #endif void immedok(bool bf) { ::immedok(w, bf); } // If called with bf=TRUE, any change in the window will cause an // automatic immediate refresh() int intrflush(bool bf) { return ::intrflush(w, bf); } int keypad(bool bf) { return ::keypad(w, bf); } // If called with bf=TRUE, the application will interpret function keys. int nodelay(bool bf) { return ::nodelay(w, bf); } int meta(bool bf) { return ::meta(w, bf); } // If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise // 7-Bit characters are generated. int standout() { return ::wstandout(w); } // Enable "standout" attributes int standend() { return ::wstandend(w); } // Disable "standout" attributes // ------------------------------------------------------------------------- // The next two are virtual, because we redefine them in the // NCursesPanel class. // ------------------------------------------------------------------------- virtual int refresh() { return ::wrefresh(w); } // Propagate the changes in this window to the virtual screen and call // doupdate(). This is redefined in NCursesPanel. virtual int noutrefresh() { return ::wnoutrefresh(w); } // Propagate the changes in this window to the virtual screen. This is // redefined in NCursesPanel. // ------------------------------------------------------------------------- // multiple window control // ------------------------------------------------------------------------- int overlay(NCursesWindow& win) { return ::overlay(w, win.w); } // Overlay this window over win. int overwrite(NCursesWindow& win) { return ::overwrite(w, win.w); } // Overwrite win with this window. int copywin(NCursesWindow& win, int sminrow, int smincol, int dminrow, int dmincol, int dmaxrow, int dmaxcol, bool overlaywin=TRUE) { return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)); } // Overlay or overwrite the rectangle in win given by dminrow,dmincol, // dmaxrow,dmaxcol with the rectangle in this window beginning at // sminrow,smincol. // ------------------------------------------------------------------------- // Extended functions // ------------------------------------------------------------------------- #if defined(NCURSES_EXT_FUNCS) && (NCURSES_EXT_FUNCS != 0) int wresize(int newLines, int newColumns) { return ::wresize(w, newLines, newColumns); } #endif // ------------------------------------------------------------------------- // Mouse related // ------------------------------------------------------------------------- bool has_mouse() const; // Return TRUE if terminal supports a mouse, FALSE otherwise // ------------------------------------------------------------------------- // traversal support // ------------------------------------------------------------------------- NCursesWindow* child() { return subwins; } // Get the first child window. NCursesWindow* sibling() { return sib; } // Get the next child of my parent. NCursesWindow* parent() { return par; } // Get my parent. bool isDescendant(NCursesWindow& win); // Return TRUE if win is a descendant of this. }; // ------------------------------------------------------------------------- // We leave this here for compatibility reasons. // ------------------------------------------------------------------------- class NCURSES_CXX_IMPEXP NCursesColorWindow : public NCursesWindow { public: explicit NCursesColorWindow(WINDOW* &window) // useful only for stdscr : NCursesWindow(window) { useColors(); } NCursesColorWindow(int nlines, // number of lines int ncols, // number of columns int begin_y, // line origin int begin_x) // col origin : NCursesWindow(nlines, ncols, begin_y, begin_x) { useColors(); } NCursesColorWindow(NCursesWindow& parentWin,// parent window int nlines, // number of lines int ncols, // number of columns int begin_y, // absolute or relative int begin_x, // origins: char absrel = 'a') // if `a', by & bx are : NCursesWindow(parentWin, nlines, ncols, // absolute screen pos, begin_y, begin_x, // else if `r', they are absrel ) { // relative to par origin useColors(); } }; // These enum definitions really belong inside the NCursesPad class, but only // recent compilers support that feature. typedef enum { REQ_PAD_REFRESH = KEY_MAX + 1, REQ_PAD_UP, REQ_PAD_DOWN, REQ_PAD_LEFT, REQ_PAD_RIGHT, REQ_PAD_EXIT } Pad_Request; const Pad_Request PAD_LOW = REQ_PAD_REFRESH; // lowest op-code const Pad_Request PAD_HIGH = REQ_PAD_EXIT; // highest op-code // ------------------------------------------------------------------------- // Pad Support. We allow an association of a pad with a "real" window // through which the pad may be viewed. // ------------------------------------------------------------------------- class NCURSES_CXX_IMPEXP NCursesPad : public NCursesWindow { private: NCursesWindow* viewWin; // the "viewport" window NCursesWindow* viewSub; // the "viewport" subwindow int h_gridsize, v_gridsize; protected: int min_row, min_col; // top left row/col of the pads display area NCursesWindow* Win(void) const { // Get the window into which the pad should be copied (if any) return (viewSub?viewSub:(viewWin?viewWin:0)); } NCursesWindow* getWindow(void) const { return viewWin; } NCursesWindow* getSubWindow(void) const { return viewSub; } virtual int driver (int key); // Virtualize keystroke key // The driver translates the keystroke c into an Pad_Request virtual void OnUnknownOperation(int pad_req) { (void) pad_req; ::beep(); } // This is called if the driver returns an unknown op-code virtual void OnNavigationError(int pad_req) { (void) pad_req; ::beep(); } // This is called if a navigation request couldn't be satisfied virtual void OnOperation(int pad_req) { (void) pad_req; }; // OnOperation is called if a Pad_Operation was executed and just before // the refresh() operation is done. public: NCursesPad(int nlines, int ncols); // create a pad with the given size NCursesPad& operator=(const NCursesPad& rhs) { if (this != &rhs) { *this = rhs; NCursesWindow::operator=(rhs); } return *this; } NCursesPad(const NCursesPad& rhs) : NCursesWindow(rhs), viewWin(rhs.viewWin), viewSub(rhs.viewSub), h_gridsize(rhs.h_gridsize), v_gridsize(rhs.v_gridsize), min_row(rhs.min_row), min_col(rhs.min_col) { } virtual ~NCursesPad() THROWS(NCursesException) {} int echochar(const chtype ch) { return ::pechochar(w, ch); } // Put the attributed character onto the pad and immediately do a // prefresh(). int refresh(); // If a viewport is defined the pad is displayed in this window, otherwise // this is a noop. int refresh(int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol) { return ::prefresh(w, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol); } // The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle // on the screen. <b>refresh</b> copies a rectangle of this size beginning // with top left corner pminrow,pmincol onto the screen and calls doupdate(). int noutrefresh(); // If a viewport is defined the pad is displayed in this window, otherwise // this is a noop. int noutrefresh(int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol) { return ::pnoutrefresh(w, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol); } // Does the same as refresh() but without calling doupdate(). virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1); // Add the window "view" as viewing window to the pad. virtual void setSubWindow(NCursesWindow& sub); // Use the subwindow "sub" of the viewport window for the actual viewing. // The full viewport window is usually used to provide some decorations // like frames, titles etc. virtual void operator() (void); // Perform Pad's operation }; // A FramedPad is constructed always with a viewport window. This viewport // will be framed (by a box() command) and the interior of the box is the // viewport subwindow. On the frame we display scrollbar sliders. class NCURSES_CXX_IMPEXP NCursesFramedPad : public NCursesPad { protected: virtual void OnOperation(int pad_req); public: NCursesFramedPad(NCursesWindow& win, int nlines, int ncols, int v_grid = 1, int h_grid = 1) : NCursesPad(nlines, ncols) { NCursesPad::setWindow(win, v_grid, h_grid); NCursesPad::setSubWindow(*(new NCursesWindow(win))); } // Construct the FramedPad with the given Window win as viewport. virtual ~NCursesFramedPad() THROWS(NCursesException) { delete getSubWindow(); } void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) { (void) view; (void) v_grid; (void) h_grid; err_handler("Operation not allowed"); } // Disable this call; the viewport is already defined void setSubWindow(NCursesWindow& sub) { (void) sub; err_handler("Operation not allowed"); } // Disable this call; the viewport subwindow is already defined }; #endif /* NCURSES_CURSESW_H_incl */ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * libmount.h - libmount API * * This file is part of libmount from util-linux project. * * Copyright (C) 2008-2018 Karel Zak <kzak@redhat.com> * * 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 General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef _LIBMOUNT_MOUNT_H #define _LIBMOUNT_MOUNT_H #ifdef __cplusplus extern "C" { #endif #include <stdio.h> #include <mntent.h> #include <sys/types.h> /* Make sure libc MS_* definitions are used by default. Note that MS_* flags * may be already defined by linux/fs.h or another file -- in this case we * don't want to include sys/mount.h at all to avoid collisions. */ #if defined(__linux__) && !defined(MS_RDONLY) # include <sys/mount.h> #endif #define LIBMOUNT_VERSION "2.37.4" #define LIBMOUNT_MAJOR_VERSION 2 #define LIBMOUNT_MINOR_VERSION 37 #define LIBMOUNT_PATCH_VERSION 4 /** * libmnt_cache: * * Stores canonicalized paths and evaluated tags */ struct libmnt_cache; /** * libmnt_lock: * * Stores information about the locked file (e.g. /etc/mtab) */ struct libmnt_lock; /** * libmnt_iter: * * Generic iterator (stores state about lists) */ struct libmnt_iter; /** * libmnt_optmap: * @name: option name[=type] where type is printf-like type specifier") * @id: option ID or MS_* flags (e.g MS_RDONLY) * @mask: MNT_{NOMTAB,INVERT,...} mask * * Mount options description (map) */ struct libmnt_optmap { const char *name; int id; int mask; }; /* * mount options map masks */ #define MNT_INVERT (1 << 1) /* invert the mountflag */ #define MNT_NOMTAB (1 << 2) /* skip in the mtab option string */ #define MNT_PREFIX (1 << 3) /* prefix used for some options (e.g. "x-foo") */ #define MNT_NOHLPS (1 << 4) /* don't add the option to mount.<type> helpers command line */ /** * libmnt_fs: * * Parsed fstab/mtab/mountinfo entry */ struct libmnt_fs; /** * libmnt_table: * * List of struct libmnt_fs entries (parsed fstab/mtab/mountinfo) */ struct libmnt_table; /** * libmnt_update * * /etc/mtab or utab update description */ struct libmnt_update; /** * libmnt_context * * Mount/umount status */ struct libmnt_context; /** * libmnt_monitor * * Mount tables monitor */ struct libmnt_monitor; /** * libmnt_tabdiff: * * Stores mountinfo state */ struct libmnt_tabdiff; /** * libmnt_ns: * * Describes mount namespace */ struct libmnt_ns; /* * Actions */ enum { MNT_ACT_MOUNT = 1, MNT_ACT_UMOUNT }; /* * Errors -- by default libmount returns -errno for generic errors (ENOMEM, * EINVAL, ...) and for mount(2) errors, but for some specific operations it * returns private error codes. Note that maximum system errno value should be * 4095 on UNIXes. * * See also mnt_context_get_syscall_errno() and mnt_context_get_helper_status(). */ /** * MNT_ERR_NOFSTAB: * * not found required entry in fstab */ #define MNT_ERR_NOFSTAB 5000 /** * MNT_ERR_NOFSTYPE: * * failed to detect filesystem type */ #define MNT_ERR_NOFSTYPE 5001 /** * MNT_ERR_NOSOURCE: * * required mount source undefined */ #define MNT_ERR_NOSOURCE 5002 /** * MNT_ERR_LOOPDEV: * * loopdev setup failed, errno set by libc */ #define MNT_ERR_LOOPDEV 5003 /** * MNT_ERR_MOUNTOPT: * * failed to parse/use userspace mount options */ #define MNT_ERR_MOUNTOPT 5004 /** * MNT_ERR_APPLYFLAGS: * * failed to apply MS_PROPAGATION flags */ #define MNT_ERR_APPLYFLAGS 5005 /** * MNT_ERR_AMBIFS: * * libblkid detected more filesystems on the device */ #define MNT_ERR_AMBIFS 5006 /** * MNT_ERR_LOOPOVERLAP: * * detected overlapping loop device that cannot be re-used */ #define MNT_ERR_LOOPOVERLAP 5007 /** * MNT_ERR_LOCK: * * failed to lock mtab/utab or so. */ #define MNT_ERR_LOCK 5008 /** * MNT_ERR_NAMESPACE: * * failed to switch namespace */ #define MNT_ERR_NAMESPACE 5009 /* * Overall return codes -- based on mount(8) and umount(8) return codes. * See mnt_context_get_excode() for more details. */ /** * MNT_EX_SUCCESS: * * [u]mount(8) exit code: no errors */ #define MNT_EX_SUCCESS 0 /** * MNT_EX_USAGE: * * [u]mount(8) exit code: incorrect invocation or permission */ #define MNT_EX_USAGE 1 /** * MNT_EX_SYSERR: * * [u]mount(8) exit code: out of memory, cannot fork, ... */ #define MNT_EX_SYSERR 2 /** * MNT_EX_SOFTWARE: * * [u]mount(8) exit code: internal mount bug or wrong version */ #define MNT_EX_SOFTWARE 4 /** * MNT_EX_USER: * * [u]mount(8) exit code: user interrupt */ #define MNT_EX_USER 8 /** * MNT_EX_FILEIO: * * [u]mount(8) exit code: problems writing, locking, ... mtab/utab */ #define MNT_EX_FILEIO 16 /** * MNT_EX_FAIL: * * [u]mount(8) exit code: mount failure */ #define MNT_EX_FAIL 32 /** * MNT_EX_SOMEOK: * * [u]mount(8) exit code: some mount succeeded; usually when executed with * --all options. Never returned by libmount. */ #define MNT_EX_SOMEOK 64 #ifndef __GNUC_PREREQ # if defined __GNUC__ && defined __GNUC_MINOR__ # define __GNUC_PREREQ(maj, min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) # else # define __GNUC_PREREQ(maj, min) 0 # endif #endif #ifndef __ul_attribute__ # if __GNUC_PREREQ (3, 4) # define __ul_attribute__(_a_) __attribute__(_a_) # else # define __ul_attribute__(_a_) # endif #endif /* init.c */ extern void mnt_init_debug(int mask); /* version.c */ extern int mnt_parse_version_string(const char *ver_string); extern int mnt_get_library_version(const char **ver_string); extern int mnt_get_library_features(const char ***features); /* utils.c */ extern char *mnt_mangle(const char *str) __ul_attribute__((warn_unused_result)); extern char *mnt_unmangle(const char *str) __ul_attribute__((warn_unused_result)); extern int mnt_tag_is_valid(const char *tag); extern int mnt_fstype_is_netfs(const char *type); extern int mnt_fstype_is_pseudofs(const char *type); extern int mnt_match_fstype(const char *type, const char *pattern) __ul_attribute__((warn_unused_result)); extern int mnt_match_options(const char *optstr, const char *pattern) __ul_attribute__((warn_unused_result)); extern const char *mnt_get_fstab_path(void); extern const char *mnt_get_swaps_path(void); extern const char *mnt_get_mtab_path(void); extern int mnt_has_regular_mtab(const char **mtab, int *writable); extern char *mnt_get_mountpoint(const char *path) __ul_attribute__((warn_unused_result)); extern int mnt_guess_system_root(dev_t devno, struct libmnt_cache *cache, char **path) __ul_attribute__((nonnull(3))); /* cache.c */ extern struct libmnt_cache *mnt_new_cache(void) __ul_attribute__((warn_unused_result)); extern void mnt_free_cache(struct libmnt_cache *cache); extern void mnt_ref_cache(struct libmnt_cache *cache); extern void mnt_unref_cache(struct libmnt_cache *cache); extern int mnt_cache_set_targets(struct libmnt_cache *cache, struct libmnt_table *mtab); extern int mnt_cache_read_tags(struct libmnt_cache *cache, const char *devname); extern int mnt_cache_device_has_tag(struct libmnt_cache *cache, const char *devname, const char *token, const char *value); extern char *mnt_cache_find_tag_value(struct libmnt_cache *cache, const char *devname, const char *token); extern char *mnt_get_fstype(const char *devname, int *ambi, struct libmnt_cache *cache) __ul_attribute__((warn_unused_result)); extern char *mnt_resolve_path(const char *path, struct libmnt_cache *cache) __ul_attribute__((warn_unused_result)); extern char *mnt_resolve_target(const char *path, struct libmnt_cache *cache) __ul_attribute__((warn_unused_result)); extern char *mnt_resolve_tag(const char *token, const char *value, struct libmnt_cache *cache) __ul_attribute__((warn_unused_result)); extern char *mnt_resolve_spec(const char *spec, struct libmnt_cache *cache) __ul_attribute__((warn_unused_result)); extern char *mnt_pretty_path(const char *path, struct libmnt_cache *cache) __ul_attribute__((warn_unused_result)); /* optstr.c */ extern int mnt_optstr_next_option(char **optstr, char **name, size_t *namesz, char **value, size_t *valuesz); extern int mnt_optstr_append_option(char **optstr, const char *name, const char *value); extern int mnt_optstr_prepend_option(char **optstr, const char *name, const char *value); extern int mnt_optstr_get_option(const char *optstr, const char *name, char **value, size_t *valsz); extern int mnt_optstr_set_option(char **optstr, const char *name, const char *value); extern int mnt_optstr_remove_option(char **optstr, const char *name); extern int mnt_optstr_deduplicate_option(char **optstr, const char *name); extern int mnt_split_optstr(const char *optstr, char **user, char **vfs, char **fs, int ignore_user, int ignore_vfs); extern int mnt_optstr_get_options(const char *optstr, char **subset, const struct libmnt_optmap *map, int ignore); extern int mnt_optstr_get_flags(const char *optstr, unsigned long *flags, const struct libmnt_optmap *map); extern int mnt_optstr_apply_flags(char **optstr, unsigned long flags, const struct libmnt_optmap *map); /* iter.c */ enum { MNT_ITER_FORWARD = 0, MNT_ITER_BACKWARD }; extern struct libmnt_iter *mnt_new_iter(int direction) __ul_attribute__((warn_unused_result)); extern void mnt_free_iter(struct libmnt_iter *itr); extern void mnt_reset_iter(struct libmnt_iter *itr, int direction) __ul_attribute__((nonnull)); extern int mnt_iter_get_direction(struct libmnt_iter *itr) __ul_attribute__((nonnull)); /* optmap.c */ enum { MNT_LINUX_MAP = 1, MNT_USERSPACE_MAP }; extern const struct libmnt_optmap *mnt_get_builtin_optmap(int id); /* lock.c */ extern struct libmnt_lock *mnt_new_lock(const char *datafile, pid_t id) __ul_attribute__((warn_unused_result)); extern void mnt_ref_lock(struct libmnt_lock *ml); extern void mnt_unref_lock(struct libmnt_lock *ml); extern void mnt_free_lock(struct libmnt_lock *ml); extern void mnt_unlock_file(struct libmnt_lock *ml); extern int mnt_lock_file(struct libmnt_lock *ml); extern int mnt_lock_block_signals(struct libmnt_lock *ml, int enable); /* fs.c */ extern struct libmnt_fs *mnt_new_fs(void) __ul_attribute__((warn_unused_result)); extern void mnt_free_fs(struct libmnt_fs *fs); extern void mnt_ref_fs(struct libmnt_fs *fs); extern void mnt_unref_fs(struct libmnt_fs *fs); extern void mnt_reset_fs(struct libmnt_fs *fs); extern struct libmnt_fs *mnt_copy_fs(struct libmnt_fs *dest, const struct libmnt_fs *src) __ul_attribute__((warn_unused_result)); extern void *mnt_fs_get_userdata(struct libmnt_fs *fs); extern int mnt_fs_set_userdata(struct libmnt_fs *fs, void *data); extern const char *mnt_fs_get_source(struct libmnt_fs *fs); extern int mnt_fs_set_source(struct libmnt_fs *fs, const char *source); extern const char *mnt_fs_get_srcpath(struct libmnt_fs *fs); extern int mnt_fs_get_table(struct libmnt_fs *fs, struct libmnt_table **tb); extern int mnt_fs_get_tag(struct libmnt_fs *fs, const char **name, const char **value); extern const char *mnt_fs_get_target(struct libmnt_fs *fs); extern int mnt_fs_set_target(struct libmnt_fs *fs, const char *tgt); extern const char *mnt_fs_get_fstype(struct libmnt_fs *fs); extern int mnt_fs_set_fstype(struct libmnt_fs *fs, const char *fstype); extern int mnt_fs_streq_srcpath(struct libmnt_fs *fs, const char *path) __ul_attribute__((warn_unused_result)); extern int mnt_fs_streq_target(struct libmnt_fs *fs, const char *path) __ul_attribute__((warn_unused_result)); extern char *mnt_fs_strdup_options(struct libmnt_fs *fs) __ul_attribute__((warn_unused_result)); extern const char *mnt_fs_get_options(struct libmnt_fs *fs) __ul_attribute__((warn_unused_result)); extern const char *mnt_fs_get_optional_fields(struct libmnt_fs *fs) __ul_attribute__((warn_unused_result)); extern int mnt_fs_get_propagation(struct libmnt_fs *fs, unsigned long *flags); extern int mnt_fs_set_options(struct libmnt_fs *fs, const char *optstr); extern int mnt_fs_append_options(struct libmnt_fs *fs, const char *optstr); extern int mnt_fs_prepend_options(struct libmnt_fs *fs, const char *optstr); extern int mnt_fs_get_option(struct libmnt_fs *fs, const char *name, char **value, size_t *valsz); extern const char *mnt_fs_get_fs_options(struct libmnt_fs *fs); extern const char *mnt_fs_get_vfs_options(struct libmnt_fs *fs); extern const char *mnt_fs_get_user_options(struct libmnt_fs *fs); extern char *mnt_fs_get_vfs_options_all(struct libmnt_fs *fs); extern const char *mnt_fs_get_attributes(struct libmnt_fs *fs); extern int mnt_fs_set_attributes(struct libmnt_fs *fs, const char *optstr); extern int mnt_fs_get_attribute(struct libmnt_fs *fs, const char *name, char **value, size_t *valsz); extern int mnt_fs_append_attributes(struct libmnt_fs *fs, const char *optstr); extern int mnt_fs_prepend_attributes(struct libmnt_fs *fs, const char *optstr); extern int mnt_fs_get_freq(struct libmnt_fs *fs); extern int mnt_fs_set_freq(struct libmnt_fs *fs, int freq); extern int mnt_fs_get_passno(struct libmnt_fs *fs); extern int mnt_fs_set_passno(struct libmnt_fs *fs, int passno); extern const char *mnt_fs_get_root(struct libmnt_fs *fs); extern int mnt_fs_set_root(struct libmnt_fs *fs, const char *path); extern const char *mnt_fs_get_bindsrc(struct libmnt_fs *fs); extern int mnt_fs_set_bindsrc(struct libmnt_fs *fs, const char *src); extern int mnt_fs_get_id(struct libmnt_fs *fs); extern int mnt_fs_get_parent_id(struct libmnt_fs *fs); extern dev_t mnt_fs_get_devno(struct libmnt_fs *fs); extern pid_t mnt_fs_get_tid(struct libmnt_fs *fs); extern const char *mnt_fs_get_swaptype(struct libmnt_fs *fs); extern off_t mnt_fs_get_size(struct libmnt_fs *fs); extern off_t mnt_fs_get_usedsize(struct libmnt_fs *fs); extern int mnt_fs_get_priority(struct libmnt_fs *fs); extern int mnt_fs_set_priority(struct libmnt_fs *fs, int prio); extern const char *mnt_fs_get_comment(struct libmnt_fs *fs); extern int mnt_fs_set_comment(struct libmnt_fs *fs, const char *comm); extern int mnt_fs_append_comment(struct libmnt_fs *fs, const char *comm); extern int mnt_fs_match_target(struct libmnt_fs *fs, const char *target, struct libmnt_cache *cache); extern int mnt_fs_match_source(struct libmnt_fs *fs, const char *source, struct libmnt_cache *cache); extern int mnt_fs_match_fstype(struct libmnt_fs *fs, const char *types); extern int mnt_fs_match_options(struct libmnt_fs *fs, const char *options); extern int mnt_fs_print_debug(struct libmnt_fs *fs, FILE *file); extern int mnt_fs_is_kernel(struct libmnt_fs *fs); extern int mnt_fs_is_swaparea(struct libmnt_fs *fs); extern int mnt_fs_is_netfs(struct libmnt_fs *fs); extern int mnt_fs_is_pseudofs(struct libmnt_fs *fs); extern void mnt_free_mntent(struct mntent *mnt); extern int mnt_fs_to_mntent(struct libmnt_fs *fs, struct mntent **mnt); /* tab-parse.c */ extern struct libmnt_table *mnt_new_table_from_file(const char *filename) __ul_attribute__((warn_unused_result)); extern struct libmnt_table *mnt_new_table_from_dir(const char *dirname) __ul_attribute__((warn_unused_result)); extern int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, const char *filename); extern int mnt_table_parse_file(struct libmnt_table *tb, const char *filename); extern int mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname); extern int mnt_table_parse_fstab(struct libmnt_table *tb, const char *filename); extern int mnt_table_parse_swaps(struct libmnt_table *tb, const char *filename); extern int mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename); extern int mnt_table_set_parser_errcb(struct libmnt_table *tb, int (*cb)(struct libmnt_table *tb, const char *filename, int line)); /* tab.c */ extern struct libmnt_table *mnt_new_table(void) __ul_attribute__((warn_unused_result)); extern void mnt_free_table(struct libmnt_table *tb); extern void mnt_ref_table(struct libmnt_table *tb); extern void mnt_unref_table(struct libmnt_table *tb); extern int mnt_reset_table(struct libmnt_table *tb); extern int mnt_table_get_nents(struct libmnt_table *tb); extern int mnt_table_is_empty(struct libmnt_table *tb); extern int mnt_table_set_userdata(struct libmnt_table *tb, void *data); extern void *mnt_table_get_userdata(struct libmnt_table *tb); extern void mnt_table_enable_comments(struct libmnt_table *tb, int enable); extern int mnt_table_with_comments(struct libmnt_table *tb); extern const char *mnt_table_get_intro_comment(struct libmnt_table *tb); extern int mnt_table_set_intro_comment(struct libmnt_table *tb, const char *comm); extern int mnt_table_append_intro_comment(struct libmnt_table *tb, const char *comm); extern int mnt_table_set_trailing_comment(struct libmnt_table *tb, const char *comm); extern const char *mnt_table_get_trailing_comment(struct libmnt_table *tb); extern int mnt_table_append_trailing_comment(struct libmnt_table *tb, const char *comm); extern int mnt_table_set_cache(struct libmnt_table *tb, struct libmnt_cache *mpc); extern struct libmnt_cache *mnt_table_get_cache(struct libmnt_table *tb); extern int mnt_table_add_fs(struct libmnt_table *tb, struct libmnt_fs *fs); extern int mnt_table_find_fs(struct libmnt_table *tb, struct libmnt_fs *fs); extern int mnt_table_insert_fs(struct libmnt_table *tb, int before, struct libmnt_fs *pos, struct libmnt_fs *fs); extern int mnt_table_move_fs(struct libmnt_table *src, struct libmnt_table *dst, int before, struct libmnt_fs *pos, struct libmnt_fs *fs); extern int mnt_table_remove_fs(struct libmnt_table *tb, struct libmnt_fs *fs); extern int mnt_table_first_fs(struct libmnt_table *tb, struct libmnt_fs **fs); extern int mnt_table_last_fs(struct libmnt_table *tb, struct libmnt_fs **fs); extern int mnt_table_over_fs(struct libmnt_table *tb, struct libmnt_fs *parent, struct libmnt_fs **child); extern int mnt_table_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr, struct libmnt_fs **fs); extern int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr, struct libmnt_fs *parent, struct libmnt_fs **chld); extern int mnt_table_get_root_fs(struct libmnt_table *tb, struct libmnt_fs **root); extern int mnt_table_set_iter(struct libmnt_table *tb, struct libmnt_iter *itr, struct libmnt_fs *fs); enum { MNT_UNIQ_FORWARD = (1 << 1), /* default is backward */ MNT_UNIQ_KEEPTREE = (1 << 2) }; extern int mnt_table_uniq_fs(struct libmnt_table *tb, int flags, int (*cmp)(struct libmnt_table *, struct libmnt_fs *, struct libmnt_fs *)); extern struct libmnt_fs *mnt_table_find_mountpoint(struct libmnt_table *tb, const char *path, int direction); extern struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *path, int direction); extern struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *path, int direction); extern struct libmnt_fs *mnt_table_find_tag(struct libmnt_table *tb, const char *tag, const char *val, int direction); extern struct libmnt_fs *mnt_table_find_target_with_option(struct libmnt_table *tb, const char *path, const char *option, const char *val, int direction); extern struct libmnt_fs *mnt_table_find_source(struct libmnt_table *tb, const char *source, int direction); extern struct libmnt_fs *mnt_table_find_pair(struct libmnt_table *tb, const char *source, const char *target, int direction); extern struct libmnt_fs *mnt_table_find_devno(struct libmnt_table *tb, dev_t devno, int direction); extern int mnt_table_find_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr, int (*match_func)(struct libmnt_fs *, void *), void *userdata, struct libmnt_fs **fs); extern int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs); /* tab_update.c */ extern struct libmnt_update *mnt_new_update(void) __ul_attribute__((warn_unused_result)); extern void mnt_free_update(struct libmnt_update *upd); extern int mnt_table_replace_file(struct libmnt_table *tb, const char *filename); extern int mnt_table_write_file(struct libmnt_table *tb, FILE *file); extern int mnt_update_is_ready(struct libmnt_update *upd); extern int mnt_update_set_fs(struct libmnt_update *upd, unsigned long mountflags, const char *target, struct libmnt_fs *fs); extern int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc); extern unsigned long mnt_update_get_mflags(struct libmnt_update *upd); extern int mnt_update_force_rdonly(struct libmnt_update *upd, int rdonly); extern const char *mnt_update_get_filename(struct libmnt_update *upd); extern struct libmnt_fs *mnt_update_get_fs(struct libmnt_update *upd); /* tab_diff.c */ enum { MNT_TABDIFF_MOUNT = 1, MNT_TABDIFF_UMOUNT, MNT_TABDIFF_MOVE, MNT_TABDIFF_REMOUNT, MNT_TABDIFF_PROPAGATION, /* not implemented yet (TODO) */ }; extern struct libmnt_tabdiff *mnt_new_tabdiff(void) __ul_attribute__((warn_unused_result)); extern void mnt_free_tabdiff(struct libmnt_tabdiff *df); extern int mnt_diff_tables(struct libmnt_tabdiff *df, struct libmnt_table *old_tab, struct libmnt_table *new_tab); extern int mnt_tabdiff_next_change(struct libmnt_tabdiff *df, struct libmnt_iter *itr, struct libmnt_fs **old_fs, struct libmnt_fs **new_fs, int *oper); /* monitor.c */ enum { MNT_MONITOR_TYPE_USERSPACE = 1, /* userspace mount options */ MNT_MONITOR_TYPE_KERNEL /* kernel mount table */ }; extern struct libmnt_monitor *mnt_new_monitor(void); extern void mnt_ref_monitor(struct libmnt_monitor *mn); extern void mnt_unref_monitor(struct libmnt_monitor *mn); extern int mnt_monitor_enable_kernel(struct libmnt_monitor *mn, int enable); extern int mnt_monitor_enable_userspace(struct libmnt_monitor *mn, int enable, const char *filename); extern int mnt_monitor_veil_kernel(struct libmnt_monitor *mn, int enable); extern int mnt_monitor_get_fd(struct libmnt_monitor *mn); extern int mnt_monitor_close_fd(struct libmnt_monitor *mn); extern int mnt_monitor_wait(struct libmnt_monitor *mn, int timeout); extern int mnt_monitor_next_change(struct libmnt_monitor *mn, const char **filename, int *type); extern int mnt_monitor_event_cleanup(struct libmnt_monitor *mn); /* context.c */ /* * Mode for mount options from fstab (or mtab), see mnt_context_set_optsmode(). */ enum { MNT_OMODE_IGNORE = (1 << 1), /* ignore mtab/fstab options */ MNT_OMODE_APPEND = (1 << 2), /* append mtab/fstab options to existing options */ MNT_OMODE_PREPEND = (1 << 3), /* prepend mtab/fstab options to existing options */ MNT_OMODE_REPLACE = (1 << 4), /* replace existing options with options from mtab/fstab */ MNT_OMODE_FORCE = (1 << 5), /* always read mtab/fstab options */ MNT_OMODE_FSTAB = (1 << 10), /* read from fstab */ MNT_OMODE_MTAB = (1 << 11), /* read from mtab if fstab not enabled or failed */ MNT_OMODE_NOTAB = (1 << 12), /* do not read fstab/mtab at all */ /* default */ MNT_OMODE_AUTO = (MNT_OMODE_PREPEND | MNT_OMODE_FSTAB | MNT_OMODE_MTAB), /* non-root users */ MNT_OMODE_USER = (MNT_OMODE_REPLACE | MNT_OMODE_FORCE | MNT_OMODE_FSTAB) }; extern struct libmnt_context *mnt_new_context(void) __ul_attribute__((warn_unused_result)); extern void mnt_free_context(struct libmnt_context *cxt); extern int mnt_reset_context(struct libmnt_context *cxt); extern int mnt_context_is_restricted(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_force_unrestricted(struct libmnt_context *cxt); extern int mnt_context_init_helper(struct libmnt_context *cxt, int action, int flags); extern int mnt_context_helper_setopt(struct libmnt_context *cxt, int c, char *arg); extern int mnt_context_set_optsmode(struct libmnt_context *cxt, int mode); extern int mnt_context_disable_canonicalize(struct libmnt_context *cxt, int disable); extern int mnt_context_enable_lazy(struct libmnt_context *cxt, int enable); extern int mnt_context_enable_rdonly_umount(struct libmnt_context *cxt, int enable); extern int mnt_context_enable_rwonly_mount(struct libmnt_context *cxt, int enable); extern int mnt_context_disable_helpers(struct libmnt_context *cxt, int disable); extern int mnt_context_enable_sloppy(struct libmnt_context *cxt, int enable); extern int mnt_context_enable_fake(struct libmnt_context *cxt, int enable); extern int mnt_context_disable_mtab(struct libmnt_context *cxt, int disable); extern int mnt_context_enable_force(struct libmnt_context *cxt, int enable); extern int mnt_context_enable_verbose(struct libmnt_context *cxt, int enable); extern int mnt_context_enable_loopdel(struct libmnt_context *cxt, int enable); extern int mnt_context_enable_fork(struct libmnt_context *cxt, int enable); extern int mnt_context_disable_swapmatch(struct libmnt_context *cxt, int disable); extern int mnt_context_get_optsmode(struct libmnt_context *cxt); extern int mnt_context_is_lazy(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_rdonly_umount(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_rwonly_mount(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_sloppy(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_fake(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_nomtab(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_force(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_verbose(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_loopdel(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_nohelpers(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_nocanonicalize(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_swapmatch(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_forced_rdonly(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_fork(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_parent(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_is_child(struct libmnt_context *cxt) __ul_attribute__((nonnull)); extern int mnt_context_wait_for_children(struct libmnt_context *cxt, int *nchildren, int *nerrs); extern int mnt_context_is_fs_mounted(struct libmnt_context *cxt, struct libmnt_fs *fs, int *mounted); extern int mnt_context_set_fs(struct libmnt_context *cxt, struct libmnt_fs *fs); extern struct libmnt_fs *mnt_context_get_fs(struct libmnt_context *cxt); extern int mnt_context_set_source(struct libmnt_context *cxt, const char *source); extern int mnt_context_set_target(struct libmnt_context *cxt, const char *target); extern int mnt_context_set_fstype(struct libmnt_context *cxt, const char *fstype); extern int mnt_context_set_target_prefix(struct libmnt_context *cxt, const char *path); extern const char *mnt_context_get_source(struct libmnt_context *cxt); extern const char *mnt_context_get_target(struct libmnt_context *cxt); extern const char *mnt_context_get_fstype(struct libmnt_context *cxt); extern const char *mnt_context_get_target_prefix(struct libmnt_context *cxt); extern void *mnt_context_get_mtab_userdata(struct libmnt_context *cxt); extern void *mnt_context_get_fstab_userdata(struct libmnt_context *cxt); extern void *mnt_context_get_fs_userdata(struct libmnt_context *cxt); extern int mnt_context_set_options(struct libmnt_context *cxt, const char *optstr); extern int mnt_context_append_options(struct libmnt_context *cxt, const char *optstr); extern const char *mnt_context_get_options(struct libmnt_context *cxt); extern int mnt_context_set_fstype_pattern(struct libmnt_context *cxt, const char *pattern); extern int mnt_context_set_options_pattern(struct libmnt_context *cxt, const char *pattern); extern int mnt_context_set_passwd_cb(struct libmnt_context *cxt, char *(*get)(struct libmnt_context *), void (*release)(struct libmnt_context *, char *)) __ul_attribute__((deprecated)); extern int mnt_context_set_tables_errcb(struct libmnt_context *cxt, int (*cb)(struct libmnt_table *tb, const char *filename, int line)); extern int mnt_context_set_fstab(struct libmnt_context *cxt, struct libmnt_table *tb); extern int mnt_context_get_fstab(struct libmnt_context *cxt, struct libmnt_table **tb); extern int mnt_context_get_mtab(struct libmnt_context *cxt, struct libmnt_table **tb); extern int mnt_context_get_table(struct libmnt_context *cxt, const char *filename, struct libmnt_table **tb); extern int mnt_context_set_cache(struct libmnt_context *cxt, struct libmnt_cache *cache); extern struct libmnt_cache *mnt_context_get_cache(struct libmnt_context *cxt); extern struct libmnt_lock *mnt_context_get_lock(struct libmnt_context *cxt); extern int mnt_context_set_mflags(struct libmnt_context *cxt, unsigned long flags); extern int mnt_context_get_mflags(struct libmnt_context *cxt, unsigned long *flags); extern int mnt_context_set_user_mflags(struct libmnt_context *cxt, unsigned long flags); extern int mnt_context_get_user_mflags(struct libmnt_context *cxt, unsigned long *flags); extern int mnt_context_set_mountdata(struct libmnt_context *cxt, void *data); extern int mnt_context_apply_fstab(struct libmnt_context *cxt); extern int mnt_context_reset_status(struct libmnt_context *cxt); extern int mnt_context_get_status(struct libmnt_context *cxt); extern int mnt_context_helper_executed(struct libmnt_context *cxt); extern int mnt_context_get_helper_status(struct libmnt_context *cxt); extern int mnt_context_syscall_called(struct libmnt_context *cxt); extern int mnt_context_get_syscall_errno(struct libmnt_context *cxt); extern int mnt_context_strerror(struct libmnt_context *cxt, char *buf, size_t bufsiz) __ul_attribute__((deprecated)); extern int mnt_context_get_excode(struct libmnt_context *cxt, int rc, char *buf, size_t bufsz); extern int mnt_context_set_target_ns(struct libmnt_context *cxt, const char *path); extern struct libmnt_ns *mnt_context_get_target_ns(struct libmnt_context *cxt); extern struct libmnt_ns *mnt_context_get_origin_ns(struct libmnt_context *cxt); extern struct libmnt_ns *mnt_context_switch_ns(struct libmnt_context *cxt, struct libmnt_ns *ns); extern struct libmnt_ns *mnt_context_switch_origin_ns(struct libmnt_context *cxt); extern struct libmnt_ns *mnt_context_switch_target_ns(struct libmnt_context *cxt); /* context_mount.c */ extern int mnt_context_mount(struct libmnt_context *cxt); extern int mnt_context_umount(struct libmnt_context *cxt); extern int mnt_context_next_mount(struct libmnt_context *cxt, struct libmnt_iter *itr, struct libmnt_fs **fs, int *mntrc, int *ignored); extern int mnt_context_next_remount(struct libmnt_context *cxt, struct libmnt_iter *itr, struct libmnt_fs **fs, int *mntrc, int *ignored); extern int mnt_context_prepare_mount(struct libmnt_context *cxt) __ul_attribute__((warn_unused_result)); extern int mnt_context_do_mount(struct libmnt_context *cxt); extern int mnt_context_finalize_mount(struct libmnt_context *cxt); /* context_umount.c */ extern int mnt_context_find_umount_fs(struct libmnt_context *cxt, const char *tgt, struct libmnt_fs **pfs); extern int mnt_context_next_umount(struct libmnt_context *cxt, struct libmnt_iter *itr, struct libmnt_fs **fs, int *mntrc, int *ignored); extern int mnt_context_prepare_umount(struct libmnt_context *cxt) __ul_attribute__((warn_unused_result)); extern int mnt_context_do_umount(struct libmnt_context *cxt); extern int mnt_context_finalize_umount(struct libmnt_context *cxt); extern int mnt_context_tab_applied(struct libmnt_context *cxt); extern int mnt_context_set_syscall_status(struct libmnt_context *cxt, int status); /* * mount(8) userspace options masks (MNT_MAP_USERSPACE map) */ #define MNT_MS_NOAUTO (1 << 2) #define MNT_MS_USER (1 << 3) #define MNT_MS_USERS (1 << 4) #define MNT_MS_OWNER (1 << 5) #define MNT_MS_GROUP (1 << 6) #define MNT_MS_NETDEV (1 << 7) #define MNT_MS_COMMENT (1 << 8) #define MNT_MS_LOOP (1 << 9) #define MNT_MS_NOFAIL (1 << 10) #define MNT_MS_UHELPER (1 << 11) #define MNT_MS_HELPER (1 << 12) #define MNT_MS_XCOMMENT (1 << 13) #define MNT_MS_OFFSET (1 << 14) #define MNT_MS_SIZELIMIT (1 << 15) #define MNT_MS_ENCRYPTION (1 << 16) #define MNT_MS_XFSTABCOMM (1 << 17) #define MNT_MS_HASH_DEVICE (1 << 18) #define MNT_MS_ROOT_HASH (1 << 19) #define MNT_MS_HASH_OFFSET (1 << 20) #define MNT_MS_ROOT_HASH_FILE (1 << 21) #define MNT_MS_FEC_DEVICE (1 << 22) #define MNT_MS_FEC_OFFSET (1 << 23) #define MNT_MS_FEC_ROOTS (1 << 24) #define MNT_MS_ROOT_HASH_SIG (1 << 25) /* * mount(2) MS_* masks (MNT_MAP_LINUX map) */ #ifndef MS_RDONLY #define MS_RDONLY 1 /* Mount read-only */ #endif #ifndef MS_NOSUID #define MS_NOSUID 2 /* Ignore suid and sgid bits */ #endif #ifndef MS_NODEV #define MS_NODEV 4 /* Disallow access to device special files */ #endif #ifndef MS_NOEXEC #define MS_NOEXEC 8 /* Disallow program execution */ #endif #ifndef MS_SYNCHRONOUS #define MS_SYNCHRONOUS 16 /* Writes are synced at once */ #endif #ifndef MS_REMOUNT #define MS_REMOUNT 32 /* Alter flags of a mounted FS */ #endif #ifndef MS_MANDLOCK #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */ #endif #ifndef MS_DIRSYNC #define MS_DIRSYNC 128 /* Directory modifications are synchronous */ #endif #ifndef MS_NOSYMFOLLOW #define MS_NOSYMFOLLOW 256 /* Don't follow symlinks */ #endif #ifndef MS_NOATIME #define MS_NOATIME 0x400 /* 1024: Do not update access times. */ #endif #ifndef MS_NODIRATIME #define MS_NODIRATIME 0x800 /* 2048: Don't update directory access times */ #endif #ifndef MS_BIND #define MS_BIND 0x1000 /* 4096: Mount existing tree elsewhere as well */ #endif #ifndef MS_MOVE #define MS_MOVE 0x2000 /* 8192: Atomically move the tree */ #endif #ifndef MS_REC #define MS_REC 0x4000 /* 16384: Recursive loopback */ #endif #ifndef MS_SILENT #define MS_SILENT 0x8000 /* 32768: Don't emit certain kernel messages */ #endif #ifndef MS_UNBINDABLE #define MS_UNBINDABLE (1<<17) /* 131072: Make unbindable */ #endif #ifndef MS_PRIVATE #define MS_PRIVATE (1<<18) /* 262144: Make private */ #endif #ifndef MS_SLAVE #define MS_SLAVE (1<<19) /* 524288: Make slave */ #endif #ifndef MS_SHARED #define MS_SHARED (1<<20) /* 1048576: Make shared */ #endif #ifndef MS_RELATIME #define MS_RELATIME (1<<21) /* 2097152: Update atime relative to mtime/ctime */ #endif #ifndef MS_I_VERSION #define MS_I_VERSION (1<<23) /* Update the inode I_version field */ #endif #ifndef MS_STRICTATIME #define MS_STRICTATIME (1<<24) /* Always perform atime updates */ #endif #ifndef MS_LAZYTIME #define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */ #endif /* * Magic mount flag number. Had to be or-ed to the flag values. Deprecated and * no more used since libmount v2.33; required for Linux <= 2.4. */ #ifndef MS_MGC_VAL #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */ #endif #ifndef MS_MGC_MSK #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */ #endif /* Shared-subtree options */ #define MS_PROPAGATION (MS_SHARED|MS_SLAVE|MS_UNBINDABLE|MS_PRIVATE) /* Options that we make ordinary users have by default. */ #define MS_SECURE (MS_NOEXEC|MS_NOSUID|MS_NODEV) /* Options that we make owner-mounted devices have by default */ #define MS_OWNERSECURE (MS_NOSUID|MS_NODEV) #ifdef __cplusplus } #endif #endif /* _LIBMOUNT_MOUNT_H */ // * This makes emacs happy -*-Mode: C++;-*- /**************************************************************************** * Copyright 2019,2020 Thomas E. Dickey * * Copyright 1998-2012,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ // $Id: cursesm.h,v 1.34 2020/05/24 01:40:20 anonymous.maarten Exp $ #ifndef NCURSES_CURSESM_H_incl #define NCURSES_CURSESM_H_incl 1 #include <cursesp.h> extern "C" { # include <menu.h> } // // ------------------------------------------------------------------------- // This wraps the ITEM type of <menu.h> // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP NCursesMenuItem { friend class NCursesMenu; protected: ITEM *item; inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) { if (err != E_OK) THROW(new NCursesMenuException (err)); } public: NCursesMenuItem (const char* p_name = NULL, const char* p_descript = NULL) : item(0) { item = p_name ? ::new_item (p_name, p_descript) : STATIC_CAST(ITEM*)(0); if (p_name && !item) OnError (E_SYSTEM_ERROR); } // Create an item. If you pass both parameters as NULL, a delimiting // item is constructed which can be used to terminate a list of // NCursesMenu objects. NCursesMenuItem& operator=(const NCursesMenuItem& rhs) { if (this != &rhs) { *this = rhs; } return *this; } NCursesMenuItem(const NCursesMenuItem& rhs) : item(0) { (void) rhs; } virtual ~NCursesMenuItem () THROWS(NCursesException); // Release the items memory inline const char* name () const { return ::item_name (item); } // Name of the item inline const char* description () const { return ::item_description (item); } // Description of the item inline int (index) (void) const { return ::item_index (item); } // Index of the item in an item array (or -1) inline void options_on (Item_Options opts) { OnError (::item_opts_on (item, opts)); } // Switch on the items options inline void options_off (Item_Options opts) { OnError (::item_opts_off (item, opts)); } // Switch off the item's option inline Item_Options options () const { return ::item_opts (item); } // Retrieve the items options inline void set_options (Item_Options opts) { OnError (::set_item_opts (item, opts)); } // Set the items options inline void set_value (bool f) { OnError (::set_item_value (item,f)); } // Set/Reset the items selection state inline bool value () const { return ::item_value (item); } // Retrieve the items selection state inline bool visible () const { return ::item_visible (item); } // Retrieve visibility of the item virtual bool action(); // Perform an action associated with this item; you may use this in an // user supplied driver for a menu; you may derive from this class and // overload action() to supply items with different actions. // If an action returns true, the menu will be exited. The default action // is to do nothing. }; // Prototype for an items callback function. typedef bool ITEMCALLBACK(NCursesMenuItem&); // If you don't like to create a child class for individual items to // overload action(), you may use this class and provide a callback // function pointer for items. class NCURSES_CXX_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem { private: ITEMCALLBACK* p_fct; public: NCursesMenuCallbackItem(ITEMCALLBACK* fct = NULL, const char* p_name = NULL, const char* p_descript = NULL ) : NCursesMenuItem (p_name, p_descript), p_fct (fct) { } NCursesMenuCallbackItem& operator=(const NCursesMenuCallbackItem& rhs) { if (this != &rhs) { *this = rhs; } return *this; } NCursesMenuCallbackItem(const NCursesMenuCallbackItem& rhs) : NCursesMenuItem(rhs), p_fct(0) { } virtual ~NCursesMenuCallbackItem() THROWS(NCursesException); bool action(); }; // This are the built-in hook functions in this C++ binding. In C++ we use // virtual member functions (see below On_..._Init and On_..._Termination) // to provide this functionality in an object oriented manner. extern "C" { void _nc_xx_mnu_init(MENU *); void _nc_xx_mnu_term(MENU *); void _nc_xx_itm_init(MENU *); void _nc_xx_itm_term(MENU *); } // // ------------------------------------------------------------------------- // This wraps the MENU type of <menu.h> // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP NCursesMenu : public NCursesPanel { protected: MENU *menu; private: NCursesWindow* sub; // the subwindow object bool b_sub_owner; // is this our own subwindow? bool b_framed; // has the menu a border? bool b_autoDelete; // Delete items when deleting menu? NCursesMenuItem** my_items; // The array of items for this menu // This structure is used for the menu's user data field to link the // MENU* to the C++ object and to provide extra space for a user pointer. typedef struct { void* m_user; // the pointer for the user's data const NCursesMenu* m_back; // backward pointer to C++ object const MENU* m_owner; } UserHook; // Get the backward pointer to the C++ object from a MENU static inline NCursesMenu* getHook(const MENU *m) { UserHook* hook = STATIC_CAST(UserHook*)(::menu_userptr(m)); assert(hook != 0 && hook->m_owner==m); return const_cast<NCursesMenu*>(hook->m_back); } friend void _nc_xx_mnu_init(MENU *); friend void _nc_xx_mnu_term(MENU *); friend void _nc_xx_itm_init(MENU *); friend void _nc_xx_itm_term(MENU *); // Calculate ITEM* array for the menu ITEM** mapItems(NCursesMenuItem* nitems[]); protected: // internal routines inline void set_user(void *user) { UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu)); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu); uptr->m_user = user; } inline void *get_user() { UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu)); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu); return uptr->m_user; } void InitMenu (NCursesMenuItem* menu[], bool with_frame, bool autoDeleteItems); inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) { if (err != E_OK) THROW(new NCursesMenuException (this, err)); } // this wraps the menu_driver call. virtual int driver (int c) ; // 'Internal' constructor to create a menu without association to // an array of items. NCursesMenu( int nlines, int ncols, int begin_y = 0, int begin_x = 0) : NCursesPanel(nlines,ncols,begin_y,begin_x), menu (STATIC_CAST(MENU*)(0)), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_items(0) { } public: // Make a full window size menu NCursesMenu (NCursesMenuItem* Items[], bool with_frame=FALSE, // Reserve space for a frame? bool autoDelete_Items=FALSE) // Autocleanup of Items? : NCursesPanel(), menu(0), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_items(0) { InitMenu(Items, with_frame, autoDelete_Items); } // Make a menu with a window of this size. NCursesMenu (NCursesMenuItem* Items[], int nlines, int ncols, int begin_y = 0, int begin_x = 0, bool with_frame=FALSE, // Reserve space for a frame? bool autoDelete_Items=FALSE) // Autocleanup of Items? : NCursesPanel(nlines, ncols, begin_y, begin_x), menu(0), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_items(0) { InitMenu(Items, with_frame, autoDelete_Items); } NCursesMenu& operator=(const NCursesMenu& rhs) { if (this != &rhs) { *this = rhs; NCursesPanel::operator=(rhs); } return *this; } NCursesMenu(const NCursesMenu& rhs) : NCursesPanel(rhs), menu(rhs.menu), sub(rhs.sub), b_sub_owner(rhs.b_sub_owner), b_framed(rhs.b_framed), b_autoDelete(rhs.b_autoDelete), my_items(rhs.my_items) { } virtual ~NCursesMenu () THROWS(NCursesException); // Retrieve the menus subwindow inline NCursesWindow& subWindow() const { assert(sub!=NULL); return *sub; } // Set the menus subwindow void setSubWindow(NCursesWindow& sub); // Set these items for the menu inline void setItems(NCursesMenuItem* Items[]) { OnError(::set_menu_items(menu,mapItems(Items))); } // Remove the menu from the screen inline void unpost (void) { OnError (::unpost_menu (menu)); } // Post the menu to the screen if flag is true, unpost it otherwise inline void post(bool flag = TRUE) { flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu)); } // Get the number of rows and columns for this menu inline void scale (int& mrows, int& mcols) const { OnError (::scale_menu (menu, &mrows, &mcols)); } // Set the format of this menu inline void set_format(int mrows, int mcols) { OnError (::set_menu_format(menu, mrows, mcols)); } // Get the format of this menu inline void menu_format(int& rows,int& ncols) { ::menu_format(menu,&rows,&ncols); } // Items of the menu inline NCursesMenuItem* items() const { return *my_items; } // Get the number of items in this menu inline int count() const { return ::item_count(menu); } // Get the current item (i.e. the one the cursor is located) inline NCursesMenuItem* current_item() const { return my_items[::item_index(::current_item(menu))]; } // Get the marker string inline const char* mark() const { return ::menu_mark(menu); } // Set the marker string inline void set_mark(const char *marker) { OnError (::set_menu_mark (menu, marker)); } // Get the name of the request code c inline static const char* request_name(int c) { return ::menu_request_name(c); } // Get the current pattern inline char* pattern() const { return ::menu_pattern(menu); } // true if there is a pattern match, false otherwise. bool set_pattern (const char *pat); // set the default attributes for the menu // i.e. set fore, back and grey attribute virtual void setDefaultAttributes(); // Get the menus background attributes inline chtype back() const { return ::menu_back(menu); } // Get the menus foreground attributes inline chtype fore() const { return ::menu_fore(menu); } // Get the menus grey attributes (used for unselectable items) inline chtype grey() const { return ::menu_grey(menu); } // Set the menus background attributes inline chtype set_background(chtype a) { return ::set_menu_back(menu,a); } // Set the menus foreground attributes inline chtype set_foreground(chtype a) { return ::set_menu_fore(menu,a); } // Set the menus grey attributes (used for unselectable items) inline chtype set_grey(chtype a) { return ::set_menu_grey(menu,a); } inline void options_on (Menu_Options opts) { OnError (::menu_opts_on (menu,opts)); } inline void options_off(Menu_Options opts) { OnError (::menu_opts_off(menu,opts)); } inline Menu_Options options() const { return ::menu_opts(menu); } inline void set_options (Menu_Options opts) { OnError (::set_menu_opts (menu,opts)); } inline int pad() const { return ::menu_pad(menu); } inline void set_pad (int padch) { OnError (::set_menu_pad (menu, padch)); } // Position the cursor to the current item inline void position_cursor () const { OnError (::pos_menu_cursor (menu)); } // Set the current item inline void set_current(NCursesMenuItem& I) { OnError (::set_current_item(menu, I.item)); } // Get the current top row of the menu inline int top_row (void) const { return ::top_row (menu); } // Set the current top row of the menu inline void set_top_row (int row) { OnError (::set_top_row (menu, row)); } // spacing control // Set the spacing for the menu inline void setSpacing(int spc_description, int spc_rows, int spc_columns) { OnError(::set_menu_spacing(menu, spc_description, spc_rows, spc_columns)); } // Get the spacing info for the menu inline void Spacing(int& spc_description, int& spc_rows, int& spc_columns) const { OnError(::menu_spacing(menu, &spc_description, &spc_rows, &spc_columns)); } // Decorations inline void frame(const char *title=NULL, const char* btitle=NULL) { if (b_framed) NCursesPanel::frame(title,btitle); else OnError(E_SYSTEM_ERROR); } inline void boldframe(const char *title=NULL, const char* btitle=NULL) { if (b_framed) NCursesPanel::boldframe(title,btitle); else OnError(E_SYSTEM_ERROR); } inline void label(const char *topLabel, const char *bottomLabel) { if (b_framed) NCursesPanel::label(topLabel,bottomLabel); else OnError(E_SYSTEM_ERROR); } // ----- // Hooks // ----- // Called after the menu gets repositioned in its window. // This is especially true if the menu is posted. virtual void On_Menu_Init(); // Called before the menu gets repositioned in its window. // This is especially true if the menu is unposted. virtual void On_Menu_Termination(); // Called after the item became the current item virtual void On_Item_Init(NCursesMenuItem& item); // Called before this item is left as current item. virtual void On_Item_Termination(NCursesMenuItem& item); // Provide a default key virtualization. Translate the keyboard // code c into a menu request code. // The default implementation provides a hopefully straightforward // mapping for the most common keystrokes and menu requests. virtual int virtualize(int c); // Operators inline NCursesMenuItem* operator[](int i) const { if ( (i < 0) || (i >= ::item_count (menu)) ) OnError (E_BAD_ARGUMENT); return (my_items[i]); } // Perform the menu's operation // Return the item where you left the selection mark for a single // selection menu, or NULL for a multivalued menu. virtual NCursesMenuItem* operator()(void); // -------------------- // Exception handlers // Called by operator() // -------------------- // Called if the request is denied virtual void On_Request_Denied(int c) const; // Called if the item is not selectable virtual void On_Not_Selectable(int c) const; // Called if pattern doesn't match virtual void On_No_Match(int c) const; // Called if the command is unknown virtual void On_Unknown_Command(int c) const; }; // // ------------------------------------------------------------------------- // This is the typical C++ typesafe way to allow to attach // user data to an item of a menu. Its assumed that the user // data belongs to some class T. Use T as template argument // to create a UserItem. // ------------------------------------------------------------------------- // template<class T> class NCURSES_CXX_IMPEXP NCursesUserItem : public NCursesMenuItem { public: NCursesUserItem (const char* p_name, const char* p_descript = NULL, const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesMenuItem (p_name, p_descript) { if (item) OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void*>(p_UserData)))); } virtual ~NCursesUserItem() THROWS(NCursesException) {} inline const T* UserData (void) const { return reinterpret_cast<const T*>(::item_userptr (item)); }; inline virtual void setUserData(const T* p_UserData) { if (item) OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void *>(p_UserData)))); } }; // // ------------------------------------------------------------------------- // The same mechanism is used to attach user data to a menu // ------------------------------------------------------------------------- // template<class T> class NCURSES_CXX_IMPEXP NCursesUserMenu : public NCursesMenu { protected: NCursesUserMenu( int nlines, int ncols, int begin_y = 0, int begin_x = 0, const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesMenu(nlines,ncols,begin_y,begin_x) { if (menu) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); } public: NCursesUserMenu (NCursesMenuItem* Items[], const T* p_UserData = STATIC_CAST(T*)(0), bool with_frame=FALSE, bool autoDelete_Items=FALSE) : NCursesMenu (Items, with_frame, autoDelete_Items) { if (menu) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); }; NCursesUserMenu (NCursesMenuItem* Items[], int nlines, int ncols, int begin_y = 0, int begin_x = 0, const T* p_UserData = STATIC_CAST(T*)(0), bool with_frame=FALSE) : NCursesMenu (Items, nlines, ncols, begin_y, begin_x, with_frame) { if (menu) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); }; virtual ~NCursesUserMenu() THROWS(NCursesException) { }; inline T* UserData (void) { return reinterpret_cast<T*>(get_user ()); }; inline virtual void setUserData (const T* p_UserData) { if (menu) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); } }; #endif /* NCURSES_CURSESM_H_incl */ /**************************************************************************** * Copyright 2018,2020 Thomas E. Dickey * * Copyright 2006-2012,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Thomas E. Dickey 2006 * ****************************************************************************/ /* $Id: nc_tparm.h,v 1.11 2020/05/27 23:33:31 tom Exp $ */ #ifndef NC_TPARM_included #define NC_TPARM_included 1 #include <ncurses_cfg.h> #include <curses.h> /* * Cast parameters past the formatting-string for tparm() to match the * assumption of the varargs code. */ #ifndef TPARM_ARG #ifdef NCURSES_TPARM_ARG #define TPARM_ARG NCURSES_TPARM_ARG #else #define TPARM_ARG long #endif #endif /* TPARAM_ARG */ #define TPARM_N(n) (TPARM_ARG)(n) #define TPARM_9(a,b,c,d,e,f,g,h,i,j) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i),TPARM_N(j)) #if NCURSES_TPARM_VARARGS #define TPARM_8(a,b,c,d,e,f,g,h,i) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i)) #define TPARM_7(a,b,c,d,e,f,g,h) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h)) #define TPARM_6(a,b,c,d,e,f,g) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g)) #define TPARM_5(a,b,c,d,e,f) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f)) #define TPARM_4(a,b,c,d,e) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e)) #define TPARM_3(a,b,c,d) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d)) #define TPARM_2(a,b,c) tparm(a,TPARM_N(b),TPARM_N(c)) #define TPARM_1(a,b) tparm(a,TPARM_N(b)) #define TPARM_0(a) tparm(a) #else #define TPARM_8(a,b,c,d,e,f,g,h,i) TPARM_9(a,b,c,d,e,f,g,h,i,0) #define TPARM_7(a,b,c,d,e,f,g,h) TPARM_8(a,b,c,d,e,f,g,h,0) #define TPARM_6(a,b,c,d,e,f,g) TPARM_7(a,b,c,d,e,f,g,0) #define TPARM_5(a,b,c,d,e,f) TPARM_6(a,b,c,d,e,f,0) #define TPARM_4(a,b,c,d,e) TPARM_5(a,b,c,d,e,0) #define TPARM_3(a,b,c,d) TPARM_4(a,b,c,d,0) #define TPARM_2(a,b,c) TPARM_3(a,b,c,0) #define TPARM_1(a,b) TPARM_2(a,b,0) #define TPARM_0(a) TPARM_1(a,0) #endif #ifdef NCURSES_INTERNALS #define TIPARM_1(s,a) _nc_tiparm(1,s,a) #define TIPARM_2(s,a,b) _nc_tiparm(2,s,a,b) #define TIPARM_3(s,a,b,c) _nc_tiparm(3,s,a,b,c) #define TIPARM_4(s,a,b,c,d) _nc_tiparm(4,s,a,b,c,d) #define TIPARM_5(s,a,b,c,d,e) _nc_tiparm(5,s,a,b,c,d,e) #define TIPARM_6(s,a,b,c,d,e,f) _nc_tiparm(6,s,a,b,c,d,e,f) #define TIPARM_7(s,a,b,c,d,e,f,g) _nc_tiparm(7,s,a,b,c,d,e,f,g) #define TIPARM_8(s,a,b,c,d,e,f,g,h) _nc_tiparm(8,s,a,b,c,d,e,f,g,h) #define TIPARM_9(s,a,b,c,d,e,f,g,h,i) _nc_tiparm(9,s,a,b,c,d,e,f,g,h,i) #endif #endif /* NC_TPARM_included */ #ifndef _GDFONTT_H_ #define _GDFONTT_H_ 1 #ifdef __cplusplus extern "C" { #endif /* This is a header file for gd font, generated using bdftogd version 0.5 by Jan Pazdziora, adelton@fi.muni.cz from bdf font -Misc-Fixed-Medium-R-Normal--8-80-75-75-C-50-ISO8859-2 at Thu Jan 8 13:49:54 1998. The original bdf was holding following copyright: "Libor Skarvada, libor@informatics.muni.cz" */ #include "gd.h" extern BGD_EXPORT_DATA_PROT gdFontPtr gdFontTiny; BGD_DECLARE(gdFontPtr) gdFontGetTiny(void); #ifdef __cplusplus } #endif #endif /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ttyent.h 8.1 (Berkeley) 6/2/93 */ #ifndef _TTYENT_H #define _TTYENT_H 1 #include <features.h> #define _PATH_TTYS "/etc/ttys" #define _TTYS_OFF "off" #define _TTYS_ON "on" #define _TTYS_SECURE "secure" #define _TTYS_WINDOW "window" struct ttyent { char *ty_name; /* terminal device name */ char *ty_getty; /* command to execute, usually getty */ char *ty_type; /* terminal type for termcap */ #define TTY_ON 0x01 /* enable logins (start ty_getty program) */ #define TTY_SECURE 0x02 /* allow uid of 0 to login */ int ty_status; /* status flags */ char *ty_window; /* command to start up window manager */ char *ty_comment; /* comment field */ }; __BEGIN_DECLS extern struct ttyent *getttyent (void) __THROW; extern struct ttyent *getttynam (const char *__tty) __THROW; extern int setttyent (void) __THROW; extern int endttyent (void) __THROW; __END_DECLS #endif /* ttyent.h */ #ifndef _GLX_glxproto_h_ #define _GLX_glxproto_h_ /* * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice including the dates of first publication and * either this permission notice or a reference to * http://oss.sgi.com/projects/FreeB/ * shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Except as contained in this notice, the name of Silicon Graphics, Inc. * shall not be used in advertising or otherwise to promote the sale, use or * other dealings in this Software without prior written authorization from * Silicon Graphics, Inc. */ #include <GL/glxmd.h> /*****************************************************************************/ /* ** Errors. */ #define GLXBadContext 0 #define GLXBadContextState 1 #define GLXBadDrawable 2 #define GLXBadPixmap 3 #define GLXBadContextTag 4 #define GLXBadCurrentWindow 5 #define GLXBadRenderRequest 6 #define GLXBadLargeRequest 7 #define GLXUnsupportedPrivateRequest 8 #define GLXBadFBConfig 9 #define GLXBadPbuffer 10 #define GLXBadCurrentDrawable 11 #define GLXBadWindow 12 #define GLXBadProfileARB 13 #define __GLX_NUMBER_ERRORS 14 /* ** Events. ** __GLX_NUMBER_EVENTS is set to 17 to account for the BufferClobberSGIX ** event - this helps initialization if the server supports the pbuffer ** extension and the client doesn't. */ #define GLX_PbufferClobber 0 #define GLX_BufferSwapComplete 1 #define __GLX_NUMBER_EVENTS 17 #define GLX_EXTENSION_NAME "GLX" #define GLX_EXTENSION_ALIAS "SGI-GLX" #define __GLX_MAX_CONTEXT_PROPS 3 #ifndef GLX_VENDOR #define GLX_VENDOR 0x1 #endif #ifndef GLX_VERSION #define GLX_VERSION 0x2 #endif #ifndef GLX_EXTENSIONS #define GLX_EXTENSIONS 0x3 #endif /*****************************************************************************/ /* ** For the structure definitions in this file, we must redefine these types in ** terms of Xmd.h types, which may include bitfields. All of these are ** undef'ed at the end of this file, restoring the definitions in glx.h. */ #define GLXContextID CARD32 #define GLXPixmap CARD32 #define GLXDrawable CARD32 #define GLXPbuffer CARD32 #define GLXWindow CARD32 #define GLXFBConfigID CARD32 #define GLXFBConfigIDSGIX CARD32 #define GLXPbufferSGIX CARD32 /* ** ContextTag is not exposed to the API. */ typedef CARD32 GLXContextTag; /*****************************************************************************/ /* ** Sizes of basic wire types. */ #define __GLX_SIZE_INT8 1 #define __GLX_SIZE_INT16 2 #define __GLX_SIZE_INT32 4 #define __GLX_SIZE_CARD8 1 #define __GLX_SIZE_CARD16 2 #define __GLX_SIZE_CARD32 4 #define __GLX_SIZE_FLOAT32 4 #define __GLX_SIZE_FLOAT64 8 /*****************************************************************************/ /* Requests */ /* ** Render command request. A bunch of rendering commands are packed into ** a single X extension request. */ typedef struct GLXRender { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextTag contextTag; } xGLXRenderReq; #define sz_xGLXRenderReq 8 /* ** The maximum size that a GLXRender command can be. The value must fit ** in 16 bits and should be a multiple of 4. */ #define __GLX_MAX_RENDER_CMD_SIZE 64000 /* ** Large render command request. A single large rendering command ** is output in multiple X extension requests. The first packet ** contains an opcode dependent header (see below) that describes ** the data that follows. */ typedef struct GLXRenderLarge { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextTag contextTag; CARD16 requestNumber; CARD16 requestTotal; CARD32 dataBytes; } xGLXRenderLargeReq; #define sz_xGLXRenderLargeReq 16 /* ** GLX single request. Commands that go over as single GLX protocol ** requests use this structure. The glxCode will be one of the X_GLsop ** opcodes. */ typedef struct GLXSingle { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextTag contextTag; } xGLXSingleReq; #define sz_xGLXSingleReq 8 /* ** glXQueryVersion request */ typedef struct GLXQueryVersion { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 majorVersion; CARD32 minorVersion; } xGLXQueryVersionReq; #define sz_xGLXQueryVersionReq 12 /* ** glXIsDirect request */ typedef struct GLXIsDirect { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextID context; } xGLXIsDirectReq; #define sz_xGLXIsDirectReq 8 /* ** glXCreateContext request */ typedef struct GLXCreateContext { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextID context; CARD32 visual; CARD32 screen; GLXContextID shareList; BOOL isDirect; CARD8 reserved1; CARD16 reserved2; } xGLXCreateContextReq; #define sz_xGLXCreateContextReq 24 /* ** glXDestroyContext request */ typedef struct GLXDestroyContext { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextID context; } xGLXDestroyContextReq; #define sz_xGLXDestroyContextReq 8 /* ** glXMakeCurrent request */ typedef struct GLXMakeCurrent { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXDrawable drawable; GLXContextID context; GLXContextTag oldContextTag; } xGLXMakeCurrentReq; #define sz_xGLXMakeCurrentReq 16 /* ** glXWaitGL request */ typedef struct GLXWaitGL { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextTag contextTag; } xGLXWaitGLReq; #define sz_xGLXWaitGLReq 8 /* ** glXWaitX request */ typedef struct GLXWaitX { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextTag contextTag; } xGLXWaitXReq; #define sz_xGLXWaitXReq 8 /* ** glXCopyContext request */ typedef struct GLXCopyContext { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextID source; GLXContextID dest; CARD32 mask; GLXContextTag contextTag; } xGLXCopyContextReq; #define sz_xGLXCopyContextReq 20 /* ** glXSwapBuffers request */ typedef struct GLXSwapBuffers { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextTag contextTag; GLXDrawable drawable; } xGLXSwapBuffersReq; #define sz_xGLXSwapBuffersReq 12 /* ** glXUseXFont request */ typedef struct GLXUseXFont { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextTag contextTag; CARD32 font; CARD32 first; CARD32 count; CARD32 listBase; } xGLXUseXFontReq; #define sz_xGLXUseXFontReq 24 /* ** glXCreateGLXPixmap request */ typedef struct GLXCreateGLXPixmap { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 screen; CARD32 visual; CARD32 pixmap; GLXPixmap glxpixmap; } xGLXCreateGLXPixmapReq; #define sz_xGLXCreateGLXPixmapReq 20 /* ** glXDestroyGLXPixmap request */ typedef struct GLXDestroyGLXPixmap { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXPixmap glxpixmap; } xGLXDestroyGLXPixmapReq; #define sz_xGLXDestroyGLXPixmapReq 8 /* ** glXGetVisualConfigs request */ typedef struct GLXGetVisualConfigs { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 screen; } xGLXGetVisualConfigsReq; #define sz_xGLXGetVisualConfigsReq 8 /* ** glXVendorPrivate request. */ typedef struct GLXVendorPrivate { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ GLXContextTag contextTag; /* ** More data may follow; this is just the header. */ } xGLXVendorPrivateReq; #define sz_xGLXVendorPrivateReq 12 /* ** glXVendorPrivateWithReply request */ typedef struct GLXVendorPrivateWithReply { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ GLXContextTag contextTag; /* ** More data may follow; this is just the header. */ } xGLXVendorPrivateWithReplyReq; #define sz_xGLXVendorPrivateWithReplyReq 12 /* ** glXQueryExtensionsString request */ typedef struct GLXQueryExtensionsString { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 screen; } xGLXQueryExtensionsStringReq; #define sz_xGLXQueryExtensionsStringReq 8 /* ** glXQueryServerString request */ typedef struct GLXQueryServerString { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 screen; CARD32 name; } xGLXQueryServerStringReq; #define sz_xGLXQueryServerStringReq 12 /* ** glXClientInfo request */ typedef struct GLXClientInfo { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 major; CARD32 minor; CARD32 numbytes; } xGLXClientInfoReq; #define sz_xGLXClientInfoReq 16 /*** Start of GLX 1.3 requests */ /* ** glXGetFBConfigs request */ typedef struct GLXGetFBConfigs { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 screen; } xGLXGetFBConfigsReq; #define sz_xGLXGetFBConfigsReq 8 /* ** glXCreatePixmap request */ typedef struct GLXCreatePixmap { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 screen; GLXFBConfigID fbconfig; CARD32 pixmap; GLXPixmap glxpixmap; CARD32 numAttribs; /* followed by attribute list */ } xGLXCreatePixmapReq; #define sz_xGLXCreatePixmapReq 24 /* ** glXDestroyPixmap request */ typedef struct GLXDestroyPixmap { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXPixmap glxpixmap; } xGLXDestroyPixmapReq; #define sz_xGLXDestroyPixmapReq 8 /* ** glXCreateNewContext request */ typedef struct GLXCreateNewContext { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextID context; GLXFBConfigID fbconfig; CARD32 screen; CARD32 renderType; GLXContextID shareList; BOOL isDirect; CARD8 reserved1; CARD16 reserved2; } xGLXCreateNewContextReq; #define sz_xGLXCreateNewContextReq 28 /* ** glXQueryContext request */ typedef struct GLXQueryContext { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextID context; } xGLXQueryContextReq; #define sz_xGLXQueryContextReq 8 /* ** glXMakeContextCurrent request */ typedef struct GLXMakeContextCurrent { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextTag oldContextTag; GLXDrawable drawable; GLXDrawable readdrawable; GLXContextID context; } xGLXMakeContextCurrentReq; #define sz_xGLXMakeContextCurrentReq 20 /* ** glXCreatePbuffer request */ typedef struct GLXCreatePbuffer { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 screen; GLXFBConfigID fbconfig; GLXPbuffer pbuffer; CARD32 numAttribs; /* followed by attribute list */ } xGLXCreatePbufferReq; #define sz_xGLXCreatePbufferReq 20 /* ** glXDestroyPbuffer request */ typedef struct GLXDestroyPbuffer { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXPbuffer pbuffer; } xGLXDestroyPbufferReq; #define sz_xGLXDestroyPbufferReq 8 /* ** glXGetDrawableAttributes request */ typedef struct GLXGetDrawableAttributes { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXDrawable drawable; } xGLXGetDrawableAttributesReq; #define sz_xGLXGetDrawableAttributesReq 8 /* ** glXChangeDrawableAttributes request */ typedef struct GLXChangeDrawableAttributes { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXDrawable drawable; CARD32 numAttribs; /* followed by attribute list */ } xGLXChangeDrawableAttributesReq; #define sz_xGLXChangeDrawableAttributesReq 12 /* ** glXCreateWindow request */ typedef struct GLXCreateWindow { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 screen; GLXFBConfigID fbconfig; CARD32 window; GLXWindow glxwindow; CARD32 numAttribs; /* followed by attribute list */ } xGLXCreateWindowReq; #define sz_xGLXCreateWindowReq 24 /* ** glXDestroyWindow request */ typedef struct GLXDestroyWindow { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXWindow glxwindow; } xGLXDestroyWindowReq; #define sz_xGLXDestroyWindowReq 8 /* Replies */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 error; CARD32 pad2; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXGetErrorReply; #define sz_xGLXGetErrorReply 32 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; GLXContextTag contextTag; CARD32 pad2; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXMakeCurrentReply; #define sz_xGLXMakeCurrentReply 32 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 pad2; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXReadPixelsReply; #define sz_xGLXReadPixelsReply 32 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 pad2; CARD32 width; CARD32 height; CARD32 depth; CARD32 pad6; } xGLXGetTexImageReply; #define sz_xGLXGetTexImageReply 32 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 pad2; CARD32 width; CARD32 height; CARD32 pad5; CARD32 pad6; } xGLXGetSeparableFilterReply; #define sz_xGLXGetSeparableFilterReply 32 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 pad2; CARD32 width; CARD32 height; CARD32 pad5; CARD32 pad6; } xGLXGetConvolutionFilterReply; #define sz_xGLXGetConvolutionFilterReply 32 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 pad2; CARD32 width; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXGetHistogramReply; #define sz_xGLXGetHistogramReply 32 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 pad2; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXGetMinmaxReply; #define sz_xGLXGetMinmaxReply 32 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 retval; CARD32 size; CARD32 newMode; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXRenderModeReply; #define sz_xGLXRenderModeReply 32 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 majorVersion; CARD32 minorVersion; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXQueryVersionReply; #define sz_xGLXQueryVersionReply 32 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 numVisuals; CARD32 numProps; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXGetVisualConfigsReply; #define sz_xGLXGetVisualConfigsReply 32 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; BOOL isDirect; CARD8 pad1; CARD16 pad2; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; CARD32 pad7; } xGLXIsDirectReply; #define sz_xGLXIsDirectReply 32 /* ** This reply structure is used for all single replies. Single replies ** ship either 1 piece of data or N pieces of data. In these cases ** size indicates how much data is to be returned. */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 retval; CARD32 size; CARD32 pad3; /* NOTE: may hold a single value */ CARD32 pad4; /* NOTE: may hold half a double */ CARD32 pad5; CARD32 pad6; } xGLXSingleReply; #define sz_xGLXSingleReply 32 /* ** This reply structure is used for all Vendor Private replies. Vendor ** Private replies can ship up to 24 bytes within the header or can ** be variable sized, in which case, the reply length field indicates ** the number of words of data which follow the header. */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 retval; CARD32 size; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXVendorPrivReply; #define sz_xGLXVendorPrivReply 32 /* ** QueryExtensionsStringReply ** n indicates the number of bytes to be returned. */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 n; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXQueryExtensionsStringReply; #define sz_xGLXQueryExtensionsStringReply 32 /* ** QueryServerString Reply struct ** n indicates the number of bytes to be returned. */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 n; CARD32 pad3; /* NOTE: may hold a single value */ CARD32 pad4; /* NOTE: may hold half a double */ CARD32 pad5; CARD32 pad6; } xGLXQueryServerStringReply; #define sz_xGLXQueryServerStringReply 32 /*** Start of GLX 1.3 replies */ /* ** glXGetFBConfigs reply */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 numFBConfigs; CARD32 numAttribs; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXGetFBConfigsReply; #define sz_xGLXGetFBConfigsReply 32 /* ** glXQueryContext reply */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 n; /* number of attribute/value pairs */ CARD32 pad2; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXQueryContextReply; #define sz_xGLXQueryContextReply 32 /* ** glXMakeContextCurrent reply */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; GLXContextTag contextTag; CARD32 pad2; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXMakeContextCurrentReply; #define sz_xGLXMakeContextCurrentReply 32 /* ** glXCreateGLXPbuffer reply ** This is used only in the direct rendering case on SGIs - otherwise ** CreateGLXPbuffer has no reply. It is not part of GLX 1.3. */ typedef struct { BYTE type; /* X_Reply */ CARD8 success; CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 pad2; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXCreateGLXPbufferReply; #define sz_xGLXCreateGLXPbufferReply 32 /* ** glXGetDrawableAttributes reply */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 numAttribs; CARD32 pad2; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXGetDrawableAttributesReply; #define sz_xGLXGetDrawableAttributesReply 32 /* ** glXGetColorTable reply */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 pad2; CARD32 width; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXGetColorTableReply; #define sz_xGLXGetColorTableReply 32 /************************************************************************/ /* GLX extension requests and replies */ /* ** glXQueryContextInfoEXT request */ typedef struct GLXQueryContextInfoEXT { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 pad1; /* unused; corresponds to contextTag in header */ GLXContextID context; } xGLXQueryContextInfoEXTReq; #define sz_xGLXQueryContextInfoEXTReq 16 /* ** glXQueryContextInfoEXT reply */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 n; /* number of attribute/value pairs */ CARD32 pad2; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXQueryContextInfoEXTReply; #define sz_xGLXQueryContextInfoEXTReply 32 /* ** glXMakeCurrentReadSGI request */ typedef struct GLXMakeCurrentReadSGI { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ GLXContextTag oldContextTag; GLXDrawable drawable; GLXDrawable readable; GLXContextID context; } xGLXMakeCurrentReadSGIReq; #define sz_xGLXMakeCurrentReadSGIReq 24 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; GLXContextTag contextTag; CARD32 writeVid; CARD32 writeType; CARD32 readVid; CARD32 readType; CARD32 pad6; } xGLXMakeCurrentReadSGIReply; #define sz_xGLXMakeCurrentReadSGIReply 32 /* ** glXGetFBConfigsSGIX request */ typedef struct GLXGetFBConfigsSGIX { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 pad1; /* unused; corresponds to contextTag in header */ CARD32 screen; } xGLXGetFBConfigsSGIXReq; #define sz_xGLXGetFBConfigsSGIXReq 16 /* ** glXCreateContextWithConfigSGIX request */ typedef struct GLXCreateContextWithConfigSGIX { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 pad1; /* unused; corresponds to contextTag in header */ GLXContextID context; GLXFBConfigID fbconfig; CARD32 screen; CARD32 renderType; GLXContextID shareList; BOOL isDirect; CARD8 reserved1; CARD16 reserved2; } xGLXCreateContextWithConfigSGIXReq; #define sz_xGLXCreateContextWithConfigSGIXReq 36 /* ** glXCreatePixmapWithConfigSGIX request */ typedef struct GLXCreateGLXPixmapWithConfigSGIX { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 pad1; /* unused; corresponds to contextTag in header */ CARD32 screen; GLXFBConfigID fbconfig; CARD32 pixmap; GLXPixmap glxpixmap; } xGLXCreateGLXPixmapWithConfigSGIXReq; #define sz_xGLXCreateGLXPixmapWithConfigSGIXReq 28 /* ** glXCreateGLXPbufferSGIX request */ typedef struct GLXCreateGLXPbufferSGIX { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 pad1; /* unused; corresponds to contextTag in header */ CARD32 screen; GLXFBConfigID fbconfig; GLXPbuffer pbuffer; CARD32 width; CARD32 height; /* followed by attribute list */ } xGLXCreateGLXPbufferSGIXReq; #define sz_xGLXCreateGLXPbufferSGIXReq 32 /* ** glXDestroyGLXPbufferSGIX request */ typedef struct GLXDestroyGLXPbuffer { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 pad1; /* unused; corresponds to contextTag in header */ GLXPbuffer pbuffer; } xGLXDestroyGLXPbufferSGIXReq; #define sz_xGLXDestroyGLXPbufferSGIXReq 16 /* ** glXChangeDrawableAttributesSGIX request */ typedef struct GLXChangeDrawableAttributesSGIX { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 pad1; /* unused; corresponds to contextTag in header */ GLXDrawable drawable; CARD32 numAttribs; /* followed by attribute list */ } xGLXChangeDrawableAttributesSGIXReq; #define sz_xGLXChangeDrawableAttributesSGIXReq 20 /* ** glXGetDrawableAttributesSGIX request */ typedef struct GLXGetDrawableAttributesSGIX { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 pad1; /* unused; corresponds to contextTag in header */ GLXDrawable drawable; } xGLXGetDrawableAttributesSGIXReq; #define sz_xGLXGetDrawableAttributesSGIXReq 16 /* ** glXGetDrawableAttributesSGIX reply */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 numAttribs; CARD32 pad2; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXGetDrawableAttributesSGIXReply; #define sz_xGLXGetDrawableAttributesSGIXReply 32 /* ** glXJoinSwapGroupSGIX request */ typedef struct GLXJoinSwapGroupSGIX { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 unused; /* corresponds to contextTag in hdr */ GLXDrawable drawable; GLXDrawable member; } xGLXJoinSwapGroupSGIXReq; #define sz_xGLXJoinSwapGroupSGIXReq 20 /* ** glXBindSwapBarrierSGIX request */ typedef struct GLXBindSwapBarrierSGIX { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 unused; /* corresponds to contextTag in hdr */ GLXDrawable drawable; CARD32 barrier; } xGLXBindSwapBarrierSGIXReq; #define sz_xGLXBindSwapBarrierSGIXReq 20 /* ** glXQueryMaxSwapBarriersSGIX request */ typedef struct GLXQueryMaxSwapBarriersSGIX { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 unused; /* corresponds to contextTag in hdr */ CARD32 screen; } xGLXQueryMaxSwapBarriersSGIXReq; #define sz_xGLXQueryMaxSwapBarriersSGIXReq 16 typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 max; CARD32 size; CARD32 pad3; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXQueryMaxSwapBarriersSGIXReply; #define sz_xGLXQueryMaxSwapBarriersSGIXReply 32 /* ** glXQueryHyperpipeNetworkSGIX request */ typedef struct GLXQueryHyperpipeNetworkSGIX { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 pad1; /* unused; corresponds to contextTag in header */ CARD32 screen; } xGLXQueryHyperpipeNetworkSGIXReq; #define sz_xGLXQueryHyperpipeNetworkSGIXReq 16 /* ** glXQueryHyperpipeNetworkSGIX reply */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 n; CARD32 npipes; /* NOTE: may hold a single value */ CARD32 pad4; /* NOTE: may hold half a double */ CARD32 pad5; CARD32 pad6; } xGLXQueryHyperpipeNetworkSGIXReply; #define sz_xGLXQueryHyperpipeNetworkSGIXReply 32 /* ** glXDestroyHyperpipeConfigSGIX request */ typedef struct GLXDestroyHyperpipeConfigSGIX { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 pad1; /* unused; corresponds to contextTag in header */ CARD32 screen; CARD32 hpId; CARD32 pad2; CARD32 pad3; CARD32 pad4; } xGLXDestroyHyperpipeConfigSGIXReq; #define sz_xGLXDestroyHyperpipeConfigSGIXReq 32 /* ** glXDestroyHyperpipeConfigSGIX reply */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 n; CARD32 success; /* NOTE: may hold a single value */ CARD32 pad4; /* NOTE: may hold half a double */ CARD32 pad5; CARD32 pad6; } xGLXDestroyHyperpipeConfigSGIXReply; #define sz_xGLXDestroyHyperpipeConfigSGIXReply 32 /* ** glXQueryHyperpipeConfigSGIX request */ typedef struct GLXQueryHyperpipeConfigSGIX { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 pad1; /* unused; corresponds to contextTag in header */ CARD32 screen; CARD32 hpId; CARD32 pad2; CARD32 pad3; CARD32 pad4; } xGLXQueryHyperpipeConfigSGIXReq; #define sz_xGLXQueryHyperpipeConfigSGIXReq 32 /* ** glXQueryHyperpipeConfigSGIX reply */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 n; CARD32 npipes; CARD32 pad4; CARD32 pad5; CARD32 pad6; } xGLXQueryHyperpipeConfigSGIXReply; #define sz_xGLXQueryHyperpipeConfigSGIXReply 32 /* ** glXHyperpipeConfigSGIX request */ typedef struct { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 vendorCode; /* vendor-specific opcode */ CARD32 pad1; /* unused; corresponds to contextTag in header */ CARD32 screen; CARD32 npipes; CARD32 networkId; CARD32 pad2; CARD32 pad3; /* followed by attribute list */ } xGLXHyperpipeConfigSGIXReq; #define sz_xGLXHyperpipeConfigSGIXReq 32 /* ** glXHyperpipeConfigSGIX reply */ typedef struct { BYTE type; /* X_Reply */ CARD8 unused; /* not used */ CARD16 sequenceNumber; CARD32 length; CARD32 pad1; CARD32 n; CARD32 npipes; CARD32 hpId; CARD32 pad5; CARD32 pad6; } xGLXHyperpipeConfigSGIXReply; #define sz_xGLXHyperpipeConfigSGIXReply 32 /** * \name Protocol structures for GLX_ARB_create_context and * GLX_ARB_create_context_profile */ /*@{*/ /** * Protocol header for glXSetClientInfoARB * * This structure is followed by \c numVersions * 2 \c CARD32 values listing * the OpenGL versions supported by the client. The pairs of values are an * OpenGL major version followed by a minor version. For example, * * CARD32 versions[4] = { 2, 1, 3, 0 }; * * says that the client supports OpenGL 2.1 and OpenGL 3.0. * * These are followed by \c numGLExtensionBytes bytes of \c STRING8 containing * the OpenGL extension string supported by the client and up to 3 bytes of * padding. * * The list of OpenGL extensions is followed by \c numGLXExtensionBytes bytes * of \c STRING8 containing the GLX extension string supported by the client * and up to 3 bytes of padding. * * This protocol replaces \c GLXClientInfo. * * \sa GLXClientInfo, GLXSetClientInfo2ARB */ typedef struct GLXSetClientInfoARB { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 major; CARD32 minor; CARD32 numVersions; CARD32 numGLExtensionBytes; CARD32 numGLXExtensionBytes; /* ** More data may follow; this is just the header. */ } xGLXSetClientInfoARBReq; #define sz_xGLXSetClientInfoARBReq 24 /** * Protocol head for glXCreateContextAttribsARB * * This protocol replaces \c GLXCreateContext, \c GLXCreateNewContext, and * \c GLXCreateContextWithConfigSGIX. */ typedef struct GLXCreateContextAttribsARB { CARD8 reqType; CARD8 glxCode; CARD16 length; GLXContextID context; GLXFBConfigID fbconfig; CARD32 screen; GLXContextID shareList; BOOL isDirect; CARD8 reserved1; CARD16 reserved2; CARD32 numAttribs; /* followed by attribute list */ } xGLXCreateContextAttribsARBReq; #define sz_xGLXCreateContextAttribsARBReq 28 /** * Protocol header for glXSetClientInfo2ARB * * The glXSetClientInfo2ARB protocol differs from glXSetClientInfoARB in that * the list of OpenGL versions supported by the client is 3 \c CARD32 values * per version: major version, minor version, and supported profile mask. * * This protocol replaces \c GLXClientInfo and \c GLXSetClientInfoARB. * * \sa GLXClientInfo, GLXSetClientInfoARB */ typedef struct GLXSetClientInfo2ARB { CARD8 reqType; CARD8 glxCode; CARD16 length; CARD32 major; CARD32 minor; CARD32 numVersions; CARD32 numGLExtensionBytes; CARD32 numGLXExtensionBytes; /* ** More data may follow; this is just the header. */ } xGLXSetClientInfo2ARBReq; #define sz_xGLXSetClientInfo2ARBReq 24 /*@}*/ /************************************************************************/ /* ** Events */ typedef struct { BYTE type; BYTE pad; CARD16 sequenceNumber; CARD16 event_type; /*** was clobber_class */ CARD16 draw_type; CARD32 drawable; CARD32 buffer_mask; /*** was mask */ CARD16 aux_buffer; CARD16 x; CARD16 y; CARD16 width; CARD16 height; CARD16 count; CARD32 unused2; } xGLXPbufferClobberEvent; typedef struct { BYTE type; BYTE pad; CARD16 sequenceNumber; CARD16 event_type; CARD32 drawable; CARD32 ust_hi; CARD32 ust_lo; CARD32 msc_hi; CARD32 msc_lo; CARD32 sbc_hi; CARD32 sbc_lo; } xGLXBufferSwapComplete; typedef struct { BYTE type; BYTE pad; CARD16 sequenceNumber; CARD16 event_type; CARD16 pad2; CARD32 drawable; CARD32 ust_hi; CARD32 ust_lo; CARD32 msc_hi; CARD32 msc_lo; CARD32 sbc; } xGLXBufferSwapComplete2; /************************************************************************/ /* ** Size of the standard X request header. */ #define __GLX_SINGLE_HDR_SIZE sz_xGLXSingleReq #define __GLX_VENDPRIV_HDR_SIZE sz_xGLXVendorPrivateReq #define __GLX_RENDER_HDR \ CARD16 length; \ CARD16 opcode #define __GLX_RENDER_HDR_SIZE 4 typedef struct { __GLX_RENDER_HDR; } __GLXrenderHeader; #define __GLX_RENDER_LARGE_HDR \ CARD32 length; \ CARD32 opcode #define __GLX_RENDER_LARGE_HDR_SIZE 8 typedef struct { __GLX_RENDER_LARGE_HDR; } __GLXrenderLargeHeader; /* ** The glBitmap, glPolygonStipple, glTexImage[12]D, glTexSubImage[12]D ** and glDrawPixels calls all have a pixel header transmitted after the ** Render or RenderLarge header and before their own opcode specific ** headers. */ #define __GLX_PIXEL_HDR \ BOOL swapBytes; \ BOOL lsbFirst; \ CARD8 reserved0; \ CARD8 reserved1; \ CARD32 rowLength; \ CARD32 skipRows; \ CARD32 skipPixels; \ CARD32 alignment #define __GLX_PIXEL_HDR_SIZE 20 typedef struct { __GLX_PIXEL_HDR; } __GLXpixelHeader; /* ** glTexImage[34]D and glTexSubImage[34]D calls ** all have a pixel header transmitted after the Render or RenderLarge ** header and before their own opcode specific headers. */ #define __GLX_PIXEL_3D_HDR \ BOOL swapBytes; \ BOOL lsbFirst; \ CARD8 reserved0; \ CARD8 reserved1; \ CARD32 rowLength; \ CARD32 imageHeight; \ CARD32 imageDepth; \ CARD32 skipRows; \ CARD32 skipImages; \ CARD32 skipVolumes; \ CARD32 skipPixels; \ CARD32 alignment #define __GLX_PIXEL_3D_HDR_SIZE 36 /* ** Data that is specific to a glBitmap call. The data is sent in the ** following order: ** Render or RenderLarge header ** Pixel header ** Bitmap header */ #define __GLX_BITMAP_HDR \ CARD32 width; \ CARD32 height; \ FLOAT32 xorig F32; \ FLOAT32 yorig F32; \ FLOAT32 xmove F32; \ FLOAT32 ymove F32 typedef struct { __GLX_RENDER_HDR; __GLX_PIXEL_HDR; __GLX_BITMAP_HDR; } __GLXbitmapHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_PIXEL_HDR; __GLX_BITMAP_HDR; } __GLXbitmapLargeHeader; typedef struct { __GLX_PIXEL_HDR; __GLX_BITMAP_HDR; } __GLXdispatchBitmapHeader; #define __GLX_BITMAP_HDR_SIZE 24 #define __GLX_BITMAP_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_PIXEL_HDR_SIZE + __GLX_BITMAP_HDR_SIZE) #define __GLX_BITMAP_CMD_DISPATCH_HDR_SIZE \ (__GLX_PIXEL_HDR_SIZE + __GLX_BITMAP_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_PIXEL_HDR; } __GLXpolygonStippleHeader; #define __GLX_POLYGONSTIPPLE_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_PIXEL_HDR_SIZE) /* ** Data that is specific to a glTexImage1D or glTexImage2D call. The ** data is sent in the following order: ** Render or RenderLarge header ** Pixel header ** TexImage header ** When a glTexImage1D call the height field is unexamined by the server. */ #define __GLX_TEXIMAGE_HDR \ CARD32 target; \ CARD32 level; \ CARD32 components; \ CARD32 width; \ CARD32 height; \ CARD32 border; \ CARD32 format; \ CARD32 type #define __GLX_TEXIMAGE_HDR_SIZE 32 #define __GLX_TEXIMAGE_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_PIXEL_HDR_SIZE + __GLX_TEXIMAGE_HDR_SIZE) #define __GLX_TEXIMAGE_CMD_DISPATCH_HDR_SIZE \ (__GLX_PIXEL_HDR_SIZE + __GLX_TEXIMAGE_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_PIXEL_HDR; __GLX_TEXIMAGE_HDR; } __GLXtexImageHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_PIXEL_HDR; __GLX_TEXIMAGE_HDR; } __GLXtexImageLargeHeader; typedef struct { __GLX_PIXEL_HDR; __GLX_TEXIMAGE_HDR; } __GLXdispatchTexImageHeader; /* ** Data that is specific to a glTexImage3D or glTexImage4D call. The ** data is sent in the following order: ** Render or RenderLarge header ** Pixel 3D header ** TexImage 3D header ** When a glTexImage3D call the size4d and woffset fields are unexamined ** by the server. ** Could be used by all TexImage commands and perhaps should be in the ** future. */ #define __GLX_TEXIMAGE_3D_HDR \ CARD32 target; \ CARD32 level; \ CARD32 internalformat; \ CARD32 width; \ CARD32 height; \ CARD32 depth; \ CARD32 size4d; \ CARD32 border; \ CARD32 format; \ CARD32 type; \ CARD32 nullimage #define __GLX_TEXIMAGE_3D_HDR_SIZE 44 #define __GLX_TEXIMAGE_3D_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_PIXEL_3D_HDR_SIZE + \ __GLX_TEXIMAGE_3D_HDR_SIZE) #define __GLX_TEXIMAGE_3D_CMD_DISPATCH_HDR_SIZE \ (__GLX_PIXEL_3D_HDR_SIZE + __GLX_TEXIMAGE_3D_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_PIXEL_3D_HDR; __GLX_TEXIMAGE_3D_HDR; } __GLXtexImage3DHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_PIXEL_3D_HDR; __GLX_TEXIMAGE_3D_HDR; } __GLXtexImage3DLargeHeader; typedef struct { __GLX_PIXEL_3D_HDR; __GLX_TEXIMAGE_3D_HDR; } __GLXdispatchTexImage3DHeader; /* ** Data that is specific to a glTexSubImage1D or glTexSubImage2D call. The ** data is sent in the following order: ** Render or RenderLarge header ** Pixel header ** TexSubImage header ** When a glTexSubImage1D call is made, the yoffset and height fields ** are unexamined by the server and are considered to be padding. */ #define __GLX_TEXSUBIMAGE_HDR \ CARD32 target; \ CARD32 level; \ CARD32 xoffset; \ CARD32 yoffset; \ CARD32 width; \ CARD32 height; \ CARD32 format; \ CARD32 type; \ CARD32 nullImage \ #define __GLX_TEXSUBIMAGE_HDR_SIZE 36 #define __GLX_TEXSUBIMAGE_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_PIXEL_HDR_SIZE + __GLX_TEXSUBIMAGE_HDR_SIZE) #define __GLX_TEXSUBIMAGE_CMD_DISPATCH_HDR_SIZE \ (__GLX_PIXEL_HDR_SIZE + __GLX_TEXSUBIMAGE_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_PIXEL_HDR; __GLX_TEXSUBIMAGE_HDR; } __GLXtexSubImageHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_PIXEL_HDR; __GLX_TEXSUBIMAGE_HDR; } __GLXtexSubImageLargeHeader; typedef struct { __GLX_PIXEL_HDR; __GLX_TEXSUBIMAGE_HDR; } __GLXdispatchTexSubImageHeader; /* ** Data that is specific to a glTexSubImage3D and 4D calls. The ** data is sent in the following order: ** Render or RenderLarge header ** Pixel 3D header ** TexSubImage 3D header ** When a glTexSubImage3D call is made, the woffset and size4d fields ** are unexamined by the server and are considered to be padding. */ #define __GLX_TEXSUBIMAGE_3D_HDR \ CARD32 target; \ CARD32 level; \ CARD32 xoffset; \ CARD32 yoffset; \ CARD32 zoffset; \ CARD32 woffset; \ CARD32 width; \ CARD32 height; \ CARD32 depth; \ CARD32 size4d; \ CARD32 format; \ CARD32 type; \ CARD32 nullImage \ #define __GLX_TEXSUBIMAGE_3D_HDR_SIZE 52 #define __GLX_TEXSUBIMAGE_3D_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_PIXEL_3D_HDR_SIZE + \ __GLX_TEXSUBIMAGE_3D_HDR_SIZE) #define __GLX_TEXSUBIMAGE_3D_CMD_DISPATCH_HDR_SIZE \ (__GLX_PIXEL_3D_HDR_SIZE + __GLX_TEXSUBIMAGE_3D_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_PIXEL_3D_HDR; __GLX_TEXSUBIMAGE_3D_HDR; } __GLXtexSubImage3DHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_PIXEL_3D_HDR; __GLX_TEXSUBIMAGE_3D_HDR; } __GLXtexSubImage3DLargeHeader; typedef struct { __GLX_PIXEL_3D_HDR; __GLX_TEXSUBIMAGE_3D_HDR; } __GLXdispatchTexSubImage3DHeader; /** * Data that is specific to a \c glCompressedTexImage1D or * \c glCompressedTexImage2D call. The data is sent in the following * order: * - Render or RenderLarge header * - CompressedTexImage header * * When a \c glCompressedTexImage1D call is made, the \c height field is * not examined by the server and is considered padding. */ #define __GLX_COMPRESSED_TEXIMAGE_HDR \ CARD32 target; \ CARD32 level; \ CARD32 internalFormat; \ CARD32 width; \ CARD32 height; \ CARD32 border; \ CARD32 imageSize #define __GLX_COMPRESSED_TEXIMAGE_HDR_SIZE 28 #define __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_COMPRESSED_TEXIMAGE_HDR_SIZE) #define __GLX_COMPRESSED_TEXIMAGE_DISPATCH_HDR_SIZE \ (__GLX_COMPRESSED_TEXIMAGE_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_COMPRESSED_TEXIMAGE_HDR; } __GLXcompressedTexImageHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_COMPRESSED_TEXIMAGE_HDR; } __GLXcompressedTexImageLargeHeader; typedef struct { __GLX_COMPRESSED_TEXIMAGE_HDR; } __GLXdispatchCompressedTexImageHeader; /** * Data that is specifi to a \c glCompressedTexSubImage1D or * \c glCompressedTexSubImage2D call. The data is sent in the following * order: * - Render or RenderLarge header * - CompressedTexSubImage header * * When a \c glCompressedTexSubImage1D call is made, the \c yoffset and * \c height fields are not examined by the server and are considered padding. */ #define __GLX_COMPRESSED_TEXSUBIMAGE_HDR \ CARD32 target; \ CARD32 level; \ CARD32 xoffset; \ CARD32 yoffset; \ CARD32 width; \ CARD32 height; \ CARD32 format; \ CARD32 imageSize #define __GLX_COMPRESSED_TEXSUBIMAGE_HDR_SIZE 32 #define __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_COMPRESSED_TEXSUBIMAGE_HDR_SIZE) #define __GLX_COMPRESSED_TEXSUBIMAGE_DISPATCH_HDR_SIZE \ (__GLX_COMPRESSED_TEXSUBIMAGE_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_COMPRESSED_TEXSUBIMAGE_HDR; } __GLXcompressedTexSubImageHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_COMPRESSED_TEXSUBIMAGE_HDR; } __GLXcompressedTexSubImageLargeHeader; typedef struct { __GLX_COMPRESSED_TEXSUBIMAGE_HDR; } __GLXdispatchCompressedTexSubImageHeader; /** * Data that is specific to a \c glCompressedTexImage3D call. The data is * sent in the following order: * - Render or RenderLarge header * - CompressedTexImage3D header */ #define __GLX_COMPRESSED_TEXIMAGE_3D_HDR \ CARD32 target; \ CARD32 level; \ CARD32 internalFormat; \ CARD32 width; \ CARD32 height; \ CARD32 depth; \ CARD32 border; \ CARD32 imageSize #define __GLX_COMPRESSED_TEXIMAGE_3D_HDR_SIZE 32 #define __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_COMPRESSED_TEXIMAGE_3D_HDR_SIZE) #define __GLX_COMPRESSED_TEXIMAGE_3D_DISPATCH_HDR_SIZE \ (__GLX_COMPRESSED_TEXIMAGE_3D_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_COMPRESSED_TEXIMAGE_3D_HDR; } __GLXcompressedTexImage3DHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_COMPRESSED_TEXIMAGE_3D_HDR; } __GLXcompressedTexImage3DLargeHeader; typedef struct { __GLX_COMPRESSED_TEXIMAGE_3D_HDR; } __GLXdispatchCompressedTexImage3DHeader; /** * Data that is specifi to a \c glCompressedTexSubImage3D call. The data is * sent in the following order: * - Render or RenderLarge header * - CompressedTexSubImage3D header */ #define __GLX_COMPRESSED_TEXSUBIMAGE_3D_HDR \ CARD32 target; \ CARD32 level; \ CARD32 xoffset; \ CARD32 yoffset; \ CARD32 zoffset; \ CARD32 width; \ CARD32 height; \ CARD32 depth; \ CARD32 format; \ CARD32 imageSize #define __GLX_COMPRESSED_TEXSUBIMAGE_3D_HDR_SIZE 32 #define __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_COMPRESSED_TEXSUBIMAGE_3D_HDR_SIZE) #define __GLX_COMPRESSED_TEXSUBIMAGE_3D_DISPATCH_HDR_SIZE \ (__GLX_COMPRESSED_TEXSUBIMAGE_3D_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_COMPRESSED_TEXSUBIMAGE_3D_HDR; } __GLXcompressedTexSubImage3DHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_COMPRESSED_TEXSUBIMAGE_3D_HDR; } __GLXcompressedTexSubImage3DLargeHeader; typedef struct { __GLX_COMPRESSED_TEXSUBIMAGE_3D_HDR; } __GLXdispatchCompressedTexSubImage3DHeader; /* ** Data that is specific to a glDrawPixels call. The data is sent in the ** following order: ** Render or RenderLarge header ** Pixel header ** DrawPixels header */ #define __GLX_DRAWPIXELS_HDR \ CARD32 width; \ CARD32 height; \ CARD32 format; \ CARD32 type #define __GLX_DRAWPIXELS_HDR_SIZE 16 #define __GLX_DRAWPIXELS_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_PIXEL_HDR_SIZE + __GLX_DRAWPIXELS_HDR_SIZE) #define __GLX_DRAWPIXELS_CMD_DISPATCH_HDR_SIZE \ (__GLX_PIXEL_HDR_SIZE + __GLX_DRAWPIXELS_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_PIXEL_HDR; __GLX_DRAWPIXELS_HDR; } __GLXdrawPixelsHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_PIXEL_HDR; __GLX_DRAWPIXELS_HDR; } __GLXdrawPixelsLargeHeader; typedef struct { __GLX_PIXEL_HDR; __GLX_DRAWPIXELS_HDR; } __GLXdispatchDrawPixelsHeader; /* ** Data that is specific to a glConvolutionFilter1D or glConvolutionFilter2D ** call. The data is sent in the following order: ** Render or RenderLarge header ** Pixel header ** ConvolutionFilter header ** When a glConvolutionFilter1D call the height field is unexamined by the server. */ #define __GLX_CONV_FILT_HDR \ CARD32 target; \ CARD32 internalformat; \ CARD32 width; \ CARD32 height; \ CARD32 format; \ CARD32 type #define __GLX_CONV_FILT_HDR_SIZE 24 #define __GLX_CONV_FILT_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_PIXEL_HDR_SIZE + __GLX_CONV_FILT_HDR_SIZE) #define __GLX_CONV_FILT_CMD_DISPATCH_HDR_SIZE \ (__GLX_PIXEL_HDR_SIZE + __GLX_CONV_FILT_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_PIXEL_HDR; __GLX_CONV_FILT_HDR; } __GLXConvolutionFilterHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_PIXEL_HDR; __GLX_CONV_FILT_HDR; } __GLXConvolutionFilterLargeHeader; typedef struct { __GLX_PIXEL_HDR; __GLX_CONV_FILT_HDR; } __GLXdispatchConvolutionFilterHeader; /* ** Data that is specific to a glDrawArraysEXT call. The data is sent in the ** following order: ** Render or RenderLarge header ** Draw Arrays header ** a variable number of Component headers ** vertex data for each component type */ #define __GLX_DRAWARRAYS_HDR \ CARD32 numVertexes; \ CARD32 numComponents; \ CARD32 primType #define __GLX_DRAWARRAYS_HDR_SIZE 12 #define __GLX_DRAWARRAYS_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_DRAWARRAYS_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_DRAWARRAYS_HDR; } __GLXdrawArraysHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_DRAWARRAYS_HDR; } __GLXdrawArraysLargeHeader; typedef struct { __GLX_DRAWARRAYS_HDR; } __GLXdispatchDrawArraysHeader; #define __GLX_COMPONENT_HDR \ CARD32 datatype; \ INT32 numVals; \ CARD32 component typedef struct { __GLX_COMPONENT_HDR; } __GLXdispatchDrawArraysComponentHeader; #define __GLX_COMPONENT_HDR_SIZE 12 /* ** Data that is specific to a glColorTable call ** The data is sent in the following order: ** Render or RenderLarge header ** Pixel header ** ColorTable header */ #define __GLX_COLOR_TABLE_HDR \ CARD32 target; \ CARD32 internalformat; \ CARD32 width; \ CARD32 format; \ CARD32 type #define __GLX_COLOR_TABLE_HDR_SIZE 20 #define __GLX_COLOR_TABLE_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_PIXEL_HDR_SIZE + __GLX_COLOR_TABLE_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_PIXEL_HDR; __GLX_COLOR_TABLE_HDR; } __GLXColorTableHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_PIXEL_HDR; __GLX_COLOR_TABLE_HDR; } __GLXColorTableLargeHeader; typedef struct { __GLX_PIXEL_HDR; __GLX_COLOR_TABLE_HDR; } __GLXdispatchColorTableHeader; /* ** Data that is specific to a glColorSubTable call ** The data is sent in the following order: ** Render or RenderLarge header ** Pixel header ** ColorTable header */ #define __GLX_COLOR_SUBTABLE_HDR \ CARD32 target; \ CARD32 start; \ CARD32 count; \ CARD32 format; \ CARD32 type #define __GLX_COLOR_SUBTABLE_HDR_SIZE 20 #define __GLX_COLOR_SUBTABLE_CMD_HDR_SIZE \ (__GLX_RENDER_HDR_SIZE + __GLX_PIXEL_HDR_SIZE + \ __GLX_COLOR_SUBTABLE_HDR_SIZE) typedef struct { __GLX_RENDER_HDR; __GLX_PIXEL_HDR; __GLX_COLOR_SUBTABLE_HDR; } __GLXColorSubTableHeader; typedef struct { __GLX_RENDER_LARGE_HDR; __GLX_PIXEL_HDR; __GLX_COLOR_SUBTABLE_HDR; } __GLXColorSubTableLargeHeader; typedef struct { __GLX_PIXEL_HDR; __GLX_COLOR_SUBTABLE_HDR; } __GLXdispatchColorSubTableHeader; #define GLX_WINDOW_TYPE 1 #define GLX_PIXMAP_TYPE 2 #define GLX_VIDEO_SOURCE_TYPE 3 #define GLX_PBUFFER_TYPE 4 /* 5 is for DM_PBUFFER */ #define GLX_GLXWINDOW_TYPE 6 /*****************************************************************************/ /* ** Restore these definitions back to the typedefs in glx.h */ #undef GLXContextID #undef GLXPixmap #undef GLXDrawable #undef GLXPbuffer #undef GLXWindow #undef GLXFBConfigID #undef GLXFBConfigIDSGIX #undef GLXPbufferSGIX /* Opcodes for GLX commands */ #define X_GLXRender 1 #define X_GLXRenderLarge 2 #define X_GLXCreateContext 3 #define X_GLXDestroyContext 4 #define X_GLXMakeCurrent 5 #define X_GLXIsDirect 6 #define X_GLXQueryVersion 7 #define X_GLXWaitGL 8 #define X_GLXWaitX 9 #define X_GLXCopyContext 10 #define X_GLXSwapBuffers 11 #define X_GLXUseXFont 12 #define X_GLXCreateGLXPixmap 13 #define X_GLXGetVisualConfigs 14 #define X_GLXDestroyGLXPixmap 15 #define X_GLXVendorPrivate 16 #define X_GLXVendorPrivateWithReply 17 #define X_GLXQueryExtensionsString 18 #define X_GLXQueryServerString 19 #define X_GLXClientInfo 20 #define X_GLXGetFBConfigs 21 #define X_GLXCreatePixmap 22 #define X_GLXDestroyPixmap 23 #define X_GLXCreateNewContext 24 #define X_GLXQueryContext 25 #define X_GLXMakeContextCurrent 26 #define X_GLXCreatePbuffer 27 #define X_GLXDestroyPbuffer 28 #define X_GLXGetDrawableAttributes 29 #define X_GLXChangeDrawableAttributes 30 #define X_GLXCreateWindow 31 #define X_GLXDestroyWindow 32 #define X_GLXSetClientInfoARB 33 #define X_GLXCreateContextAttribsARB 34 #define X_GLXSetClientInfo2ARB 35 /* typo compatibility with older headers */ #define X_GLXCreateContextAtrribsARB 34 #define X_GLXSetConfigInfo2ARB 35 /* Opcodes for single commands (part of GLX command space) */ #define X_GLsop_NewList 101 #define X_GLsop_EndList 102 #define X_GLsop_DeleteLists 103 #define X_GLsop_GenLists 104 #define X_GLsop_FeedbackBuffer 105 #define X_GLsop_SelectBuffer 106 #define X_GLsop_RenderMode 107 #define X_GLsop_Finish 108 #define X_GLsop_Flush 142 #define X_GLsop_PixelStoref 109 #define X_GLsop_PixelStorei 110 #define X_GLsop_ReadPixels 111 #define X_GLsop_GetBooleanv 112 #define X_GLsop_GetClipPlane 113 #define X_GLsop_GetDoublev 114 #define X_GLsop_GetError 115 #define X_GLsop_GetFloatv 116 #define X_GLsop_GetIntegerv 117 #define X_GLsop_GetLightfv 118 #define X_GLsop_GetLightiv 119 #define X_GLsop_GetMapdv 120 #define X_GLsop_GetMapfv 121 #define X_GLsop_GetMapiv 122 #define X_GLsop_GetMaterialfv 123 #define X_GLsop_GetMaterialiv 124 #define X_GLsop_GetPixelMapfv 125 #define X_GLsop_GetPixelMapuiv 126 #define X_GLsop_GetPixelMapusv 127 #define X_GLsop_GetPolygonStipple 128 #define X_GLsop_GetString 129 #define X_GLsop_GetTexEnvfv 130 #define X_GLsop_GetTexEnviv 131 #define X_GLsop_GetTexGendv 132 #define X_GLsop_GetTexGenfv 133 #define X_GLsop_GetTexGeniv 134 #define X_GLsop_GetTexImage 135 #define X_GLsop_GetTexParameterfv 136 #define X_GLsop_GetTexParameteriv 137 #define X_GLsop_GetTexLevelParameterfv 138 #define X_GLsop_GetTexLevelParameteriv 139 #define X_GLsop_IsEnabled 140 #define X_GLsop_IsList 141 #define X_GLsop_AreTexturesResident 143 #define X_GLsop_DeleteTextures 144 #define X_GLsop_GenTextures 145 #define X_GLsop_IsTexture 146 #define X_GLsop_GetColorTable 147 #define X_GLsop_GetColorTableParameterfv 148 #define X_GLsop_GetColorTableParameteriv 149 #define X_GLsop_GetConvolutionFilter 150 #define X_GLsop_GetConvolutionParameterfv 151 #define X_GLsop_GetConvolutionParameteriv 152 #define X_GLsop_GetSeparableFilter 153 #define X_GLsop_GetHistogram 154 #define X_GLsop_GetHistogramParameterfv 155 #define X_GLsop_GetHistogramParameteriv 156 #define X_GLsop_GetMinmax 157 #define X_GLsop_GetMinmaxParameterfv 158 #define X_GLsop_GetMinmaxParameteriv 159 #define X_GLsop_GetCompressedTexImage 160 /* Opcodes for rendering commands */ #define X_GLrop_CallList 1 #define X_GLrop_CallLists 2 #define X_GLrop_ListBase 3 #define X_GLrop_Begin 4 #define X_GLrop_Bitmap 5 #define X_GLrop_Color3bv 6 #define X_GLrop_Color3dv 7 #define X_GLrop_Color3fv 8 #define X_GLrop_Color3iv 9 #define X_GLrop_Color3sv 10 #define X_GLrop_Color3ubv 11 #define X_GLrop_Color3uiv 12 #define X_GLrop_Color3usv 13 #define X_GLrop_Color4bv 14 #define X_GLrop_Color4dv 15 #define X_GLrop_Color4fv 16 #define X_GLrop_Color4iv 17 #define X_GLrop_Color4sv 18 #define X_GLrop_Color4ubv 19 #define X_GLrop_Color4uiv 20 #define X_GLrop_Color4usv 21 #define X_GLrop_EdgeFlagv 22 #define X_GLrop_End 23 #define X_GLrop_Indexdv 24 #define X_GLrop_Indexfv 25 #define X_GLrop_Indexiv 26 #define X_GLrop_Indexsv 27 #define X_GLrop_Normal3bv 28 #define X_GLrop_Normal3dv 29 #define X_GLrop_Normal3fv 30 #define X_GLrop_Normal3iv 31 #define X_GLrop_Normal3sv 32 #define X_GLrop_RasterPos2dv 33 #define X_GLrop_RasterPos2fv 34 #define X_GLrop_RasterPos2iv 35 #define X_GLrop_RasterPos2sv 36 #define X_GLrop_RasterPos3dv 37 #define X_GLrop_RasterPos3fv 38 #define X_GLrop_RasterPos3iv 39 #define X_GLrop_RasterPos3sv 40 #define X_GLrop_RasterPos4dv 41 #define X_GLrop_RasterPos4fv 42 #define X_GLrop_RasterPos4iv 43 #define X_GLrop_RasterPos4sv 44 #define X_GLrop_Rectdv 45 #define X_GLrop_Rectfv 46 #define X_GLrop_Rectiv 47 #define X_GLrop_Rectsv 48 #define X_GLrop_TexCoord1dv 49 #define X_GLrop_TexCoord1fv 50 #define X_GLrop_TexCoord1iv 51 #define X_GLrop_TexCoord1sv 52 #define X_GLrop_TexCoord2dv 53 #define X_GLrop_TexCoord2fv 54 #define X_GLrop_TexCoord2iv 55 #define X_GLrop_TexCoord2sv 56 #define X_GLrop_TexCoord3dv 57 #define X_GLrop_TexCoord3fv 58 #define X_GLrop_TexCoord3iv 59 #define X_GLrop_TexCoord3sv 60 #define X_GLrop_TexCoord4dv 61 #define X_GLrop_TexCoord4fv 62 #define X_GLrop_TexCoord4iv 63 #define X_GLrop_TexCoord4sv 64 #define X_GLrop_Vertex2dv 65 #define X_GLrop_Vertex2fv 66 #define X_GLrop_Vertex2iv 67 #define X_GLrop_Vertex2sv 68 #define X_GLrop_Vertex3dv 69 #define X_GLrop_Vertex3fv 70 #define X_GLrop_Vertex3iv 71 #define X_GLrop_Vertex3sv 72 #define X_GLrop_Vertex4dv 73 #define X_GLrop_Vertex4fv 74 #define X_GLrop_Vertex4iv 75 #define X_GLrop_Vertex4sv 76 #define X_GLrop_ClipPlane 77 #define X_GLrop_ColorMaterial 78 #define X_GLrop_CullFace 79 #define X_GLrop_Fogf 80 #define X_GLrop_Fogfv 81 #define X_GLrop_Fogi 82 #define X_GLrop_Fogiv 83 #define X_GLrop_FrontFace 84 #define X_GLrop_Hint 85 #define X_GLrop_Lightf 86 #define X_GLrop_Lightfv 87 #define X_GLrop_Lighti 88 #define X_GLrop_Lightiv 89 #define X_GLrop_LightModelf 90 #define X_GLrop_LightModelfv 91 #define X_GLrop_LightModeli 92 #define X_GLrop_LightModeliv 93 #define X_GLrop_LineStipple 94 #define X_GLrop_LineWidth 95 #define X_GLrop_Materialf 96 #define X_GLrop_Materialfv 97 #define X_GLrop_Materiali 98 #define X_GLrop_Materialiv 99 #define X_GLrop_PointSize 100 #define X_GLrop_PolygonMode 101 #define X_GLrop_PolygonStipple 102 #define X_GLrop_Scissor 103 #define X_GLrop_ShadeModel 104 #define X_GLrop_TexParameterf 105 #define X_GLrop_TexParameterfv 106 #define X_GLrop_TexParameteri 107 #define X_GLrop_TexParameteriv 108 #define X_GLrop_TexImage1D 109 #define X_GLrop_TexImage2D 110 #define X_GLrop_TexEnvf 111 #define X_GLrop_TexEnvfv 112 #define X_GLrop_TexEnvi 113 #define X_GLrop_TexEnviv 114 #define X_GLrop_TexGend 115 #define X_GLrop_TexGendv 116 #define X_GLrop_TexGenf 117 #define X_GLrop_TexGenfv 118 #define X_GLrop_TexGeni 119 #define X_GLrop_TexGeniv 120 #define X_GLrop_InitNames 121 #define X_GLrop_LoadName 122 #define X_GLrop_PassThrough 123 #define X_GLrop_PopName 124 #define X_GLrop_PushName 125 #define X_GLrop_DrawBuffer 126 #define X_GLrop_Clear 127 #define X_GLrop_ClearAccum 128 #define X_GLrop_ClearIndex 129 #define X_GLrop_ClearColor 130 #define X_GLrop_ClearStencil 131 #define X_GLrop_ClearDepth 132 #define X_GLrop_StencilMask 133 #define X_GLrop_ColorMask 134 #define X_GLrop_DepthMask 135 #define X_GLrop_IndexMask 136 #define X_GLrop_Accum 137 #define X_GLrop_Disable 138 #define X_GLrop_Enable 139 #define X_GLrop_PopAttrib 141 #define X_GLrop_PushAttrib 142 #define X_GLrop_Map1d 143 #define X_GLrop_Map1f 144 #define X_GLrop_Map2d 145 #define X_GLrop_Map2f 146 #define X_GLrop_MapGrid1d 147 #define X_GLrop_MapGrid1f 148 #define X_GLrop_MapGrid2d 149 #define X_GLrop_MapGrid2f 150 #define X_GLrop_EvalCoord1dv 151 #define X_GLrop_EvalCoord1fv 152 #define X_GLrop_EvalCoord2dv 153 #define X_GLrop_EvalCoord2fv 154 #define X_GLrop_EvalMesh1 155 #define X_GLrop_EvalPoint1 156 #define X_GLrop_EvalMesh2 157 #define X_GLrop_EvalPoint2 158 #define X_GLrop_AlphaFunc 159 #define X_GLrop_BlendFunc 160 #define X_GLrop_LogicOp 161 #define X_GLrop_StencilFunc 162 #define X_GLrop_StencilOp 163 #define X_GLrop_DepthFunc 164 #define X_GLrop_PixelZoom 165 #define X_GLrop_PixelTransferf 166 #define X_GLrop_PixelTransferi 167 #define X_GLrop_PixelMapfv 168 #define X_GLrop_PixelMapuiv 169 #define X_GLrop_PixelMapusv 170 #define X_GLrop_ReadBuffer 171 #define X_GLrop_CopyPixels 172 #define X_GLrop_DrawPixels 173 #define X_GLrop_DepthRange 174 #define X_GLrop_Frustum 175 #define X_GLrop_LoadIdentity 176 #define X_GLrop_LoadMatrixf 177 #define X_GLrop_LoadMatrixd 178 #define X_GLrop_MatrixMode 179 #define X_GLrop_MultMatrixf 180 #define X_GLrop_MultMatrixd 181 #define X_GLrop_Ortho 182 #define X_GLrop_PopMatrix 183 #define X_GLrop_PushMatrix 184 #define X_GLrop_Rotated 185 #define X_GLrop_Rotatef 186 #define X_GLrop_Scaled 187 #define X_GLrop_Scalef 188 #define X_GLrop_Translated 189 #define X_GLrop_Translatef 190 #define X_GLrop_Viewport 191 #define X_GLrop_DrawArrays 193 #define X_GLrop_PolygonOffset 192 #define X_GLrop_CopyTexImage1D 4119 #define X_GLrop_CopyTexImage2D 4120 #define X_GLrop_CopyTexSubImage1D 4121 #define X_GLrop_CopyTexSubImage2D 4122 #define X_GLrop_TexSubImage1D 4099 #define X_GLrop_TexSubImage2D 4100 #define X_GLrop_BindTexture 4117 #define X_GLrop_PrioritizeTextures 4118 #define X_GLrop_Indexubv 194 #define X_GLrop_BlendColor 4096 #define X_GLrop_BlendEquation 4097 #define X_GLrop_ColorTable 2053 #define X_GLrop_ColorTableParameterfv 2054 #define X_GLrop_ColorTableParameteriv 2055 #define X_GLrop_CopyColorTable 2056 #define X_GLrop_ColorSubTable 195 #define X_GLrop_CopyColorSubTable 196 #define X_GLrop_ConvolutionFilter1D 4101 #define X_GLrop_ConvolutionFilter2D 4102 #define X_GLrop_ConvolutionParameterf 4103 #define X_GLrop_ConvolutionParameterfv 4104 #define X_GLrop_ConvolutionParameteri 4105 #define X_GLrop_ConvolutionParameteriv 4106 #define X_GLrop_CopyConvolutionFilter1D 4107 #define X_GLrop_CopyConvolutionFilter2D 4108 #define X_GLrop_SeparableFilter2D 4109 #define X_GLrop_Histogram 4110 #define X_GLrop_Minmax 4111 #define X_GLrop_ResetHistogram 4112 #define X_GLrop_ResetMinmax 4113 #define X_GLrop_TexImage3D 4114 #define X_GLrop_TexSubImage3D 4115 #define X_GLrop_CopyTexSubImage3D 4123 #define X_GLrop_DrawArraysEXT 4116 /* Added for core GL version 1.3 */ #define X_GLrop_ActiveTextureARB 197 #define X_GLrop_MultiTexCoord1dvARB 198 #define X_GLrop_MultiTexCoord1fvARB 199 #define X_GLrop_MultiTexCoord1ivARB 200 #define X_GLrop_MultiTexCoord1svARB 201 #define X_GLrop_MultiTexCoord2dvARB 202 #define X_GLrop_MultiTexCoord2fvARB 203 #define X_GLrop_MultiTexCoord2ivARB 204 #define X_GLrop_MultiTexCoord2svARB 205 #define X_GLrop_MultiTexCoord3dvARB 206 #define X_GLrop_MultiTexCoord3fvARB 207 #define X_GLrop_MultiTexCoord3ivARB 208 #define X_GLrop_MultiTexCoord3svARB 209 #define X_GLrop_MultiTexCoord4dvARB 210 #define X_GLrop_MultiTexCoord4fvARB 211 #define X_GLrop_MultiTexCoord4ivARB 212 #define X_GLrop_MultiTexCoord4svARB 213 #define X_GLrop_CompressedTexImage1D 214 #define X_GLrop_CompressedTexImage2D 215 #define X_GLrop_CompressedTexImage3D 216 #define X_GLrop_CompressedTexSubImage1D 217 #define X_GLrop_CompressedTexSubImage2D 218 #define X_GLrop_CompressedTexSubImage3D 219 #define X_GLrop_SampleCoverageARB 229 /* Added for core GL version 1.4 */ #define X_GLrop_WindowPos3fARB 230 #define X_GLrop_FogCoordfv 4124 #define X_GLrop_FogCoorddv 4125 #define X_GLrop_PointParameterfARB 2065 #define X_GLrop_PointParameterfvARB 2066 #define X_GLrop_SecondaryColor3bv 4126 #define X_GLrop_SecondaryColor3sv 4127 #define X_GLrop_SecondaryColor3iv 4128 #define X_GLrop_SecondaryColor3fv 4129 #define X_GLrop_SecondaryColor3dv 4130 #define X_GLrop_SecondaryColor3ubv 4131 #define X_GLrop_SecondaryColor3usv 4132 #define X_GLrop_SecondaryColor3uiv 4133 #define X_GLrop_BlendFuncSeparate 4134 #define X_GLrop_PointParameteri 4221 #define X_GLrop_PointParameteriv 4222 /* Added for core GL version 1.5 */ /* XXX opcodes not defined in the spec */ /* Opcodes for Vendor Private commands */ #define X_GLvop_GetConvolutionFilterEXT 1 #define X_GLvop_GetConvolutionParameterfvEXT 2 #define X_GLvop_GetConvolutionParameterivEXT 3 #define X_GLvop_GetSeparableFilterEXT 4 #define X_GLvop_GetHistogramEXT 5 #define X_GLvop_GetHistogramParameterfvEXT 6 #define X_GLvop_GetHistogramParameterivEXT 7 #define X_GLvop_GetMinmaxEXT 8 #define X_GLvop_GetMinmaxParameterfvEXT 9 #define X_GLvop_GetMinmaxParameterivEXT 10 #define X_GLvop_AreTexturesResidentEXT 11 #define X_GLvop_DeleteTexturesEXT 12 #define X_GLvop_GenTexturesEXT 13 #define X_GLvop_IsTextureEXT 14 #define X_GLvop_GetCombinerInputParameterfvNV 1270 #define X_GLvop_GetCombinerInputParameterivNV 1271 #define X_GLvop_GetCombinerOutputParameterfvNV 1272 #define X_GLvop_GetCombinerOutputParameterivNV 1273 #define X_GLvop_GetFinalCombinerOutputParameterfvNV 1274 #define X_GLvop_GetFinalCombinerOutputParameterivNV 1275 #define X_GLvop_DeleteFenceNV 1276 #define X_GLvop_GenFencesNV 1277 #define X_GLvop_IsFenceNV 1278 #define X_GLvop_TestFenceNV 1279 #define X_GLvop_GetFenceivNV 1280 #define X_GLvop_AreProgramsResidentNV 1293 #define X_GLvop_DeleteProgramARB 1294 #define X_GLvop_GenProgramsARB 1295 #define X_GLvop_GetProgramEnvParameterfvARB 1296 #define X_GLvop_GetProgramEnvParameterdvARB 1297 #define X_GLvop_GetProgramEnvParameterivNV 1298 #define X_GLvop_GetProgramStringNV 1299 #define X_GLvop_GetTrackMatrixivNV 1300 #define X_GLvop_GetVertexAttribdvARB 1301 #define X_GLvop_GetVertexAttribfvARB 1302 #define X_GLvop_GetVertexAttribivARB 1303 #define X_GLvop_IsProgramARB 1304 #define X_GLvop_GetProgramLocalParameterfvARB 1305 #define X_GLvop_GetProgramLocalParameterdvARB 1306 #define X_GLvop_GetProgramivARB 1307 #define X_GLvop_GetProgramStringARB 1308 #define X_GLvop_GetProgramNamedParameter4fvNV 1310 #define X_GLvop_GetProgramNamedParameter4dvNV 1311 #define X_GLvop_SampleMaskSGIS 2048 #define X_GLvop_SamplePatternSGIS 2049 #define X_GLvop_GetDetailTexFuncSGIS 4096 #define X_GLvop_GetSharpenTexFuncSGIS 4097 #define X_GLvop_GetColorTableSGI 4098 #define X_GLvop_GetColorTableParameterfvSGI 4099 #define X_GLvop_GetColorTableParameterivSGI 4100 #define X_GLvop_GetTexFilterFuncSGIS 4101 #define X_GLvop_GetInstrumentsSGIX 4102 #define X_GLvop_InstrumentsBufferSGIX 4103 #define X_GLvop_PollInstrumentsSGIX 4104 #define X_GLvop_FlushRasterSGIX 4105 /* Opcodes for GLX vendor private commands */ #define X_GLXvop_QueryContextInfoEXT 1024 #define X_GLXvop_BindTexImageEXT 1330 #define X_GLXvop_ReleaseTexImageEXT 1331 #define X_GLXvop_SwapIntervalSGI 65536 #define X_GLXvop_MakeCurrentReadSGI 65537 #define X_GLXvop_CreateGLXVideoSourceSGIX 65538 #define X_GLXvop_DestroyGLXVideoSourceSGIX 65539 #define X_GLXvop_GetFBConfigsSGIX 65540 #define X_GLXvop_CreateContextWithConfigSGIX 65541 #define X_GLXvop_CreateGLXPixmapWithConfigSGIX 65542 #define X_GLXvop_CreateGLXPbufferSGIX 65543 #define X_GLXvop_DestroyGLXPbufferSGIX 65544 #define X_GLXvop_ChangeDrawableAttributesSGIX 65545 #define X_GLXvop_GetDrawableAttributesSGIX 65546 #define X_GLXvop_JoinSwapGroupSGIX 65547 #define X_GLXvop_BindSwapBarrierSGIX 65548 #define X_GLXvop_QueryMaxSwapBarriersSGIX 65549 #define X_GLXvop_QueryHyperpipeNetworkSGIX 65550 #define X_GLXvop_QueryHyperpipeConfigSGIX 65551 #define X_GLXvop_HyperpipeConfigSGIX 65552 #define X_GLXvop_DestroyHyperpipeConfigSGIX 65553 /* ARB extension opcodes */ /* 1. GL_ARB_multitexture - see GL 1.2 opcodes */ /* 5. GL_ARB_multisample - see GL 1.3 opcodes */ /* 12. GL_ARB_texture_compression - see GL 1.3 opcodes */ /* 14. GL_ARB_point_parameters - see GL 1.4 opcodees */ /* 15. GL_ARB_vertex_blend */ #define X_GLrop_WeightbvARB 220 #define X_GLrop_WeightubvARB 221 #define X_GLrop_WeightsvARB 222 #define X_GLrop_WeightusvARB 223 #define X_GLrop_WeightivARB 224 #define X_GLrop_WeightuivARB 225 #define X_GLrop_VertexBlendARB 226 #define X_GLrop_WeightfvARB 227 #define X_GLrop_WeightdvARB 228 /* 16. GL_ARB_matrix_palette */ /* XXX opcodes not defined in the spec */ /* 25. GL_ARB_window_pos - see GL 1.4 opcodes */ /* 26. GL_ARB_vertex_program */ #define X_GLrop_BindProgramARB 4180 #define X_GLrop_ProgramEnvParameter4fvARB 4184 #define X_GLrop_ProgramEnvParameter4dvARB 4185 #define X_GLrop_VertexAttrib1svARB 4189 #define X_GLrop_VertexAttrib2svARB 4190 #define X_GLrop_VertexAttrib3svARB 4191 #define X_GLrop_VertexAttrib4svARB 4192 #define X_GLrop_VertexAttrib1fvARB 4193 #define X_GLrop_VertexAttrib2fvARB 4194 #define X_GLrop_VertexAttrib3fvARB 4195 #define X_GLrop_VertexAttrib4fvARB 4196 #define X_GLrop_VertexAttrib1dvARB 4197 #define X_GLrop_VertexAttrib2dvARB 4198 #define X_GLrop_VertexAttrib3dvARB 4199 #define X_GLrop_ProgramLocalParameter4fvARB 4215 #define X_GLrop_ProgramLocalParameter4dvARB 4216 #define X_GLrop_ProgramStringARB 4217 #define X_GLrop_VertexAttrib4dvARB 4200 #define X_GLrop_VertexAttrib4NubvARB 4201 #define X_GLrop_VertexAttrib4bvARB 4230 #define X_GLrop_VertexAttrib4ivARB 4231 #define X_GLrop_VertexAttrib4ubvARB 4232 #define X_GLrop_VertexAttrib4usvARB 4233 #define X_GLrop_VertexAttrib4uivARB 4234 #define X_GLrop_VertexAttrib4NbvARB 4235 #define X_GLrop_VertexAttrib4NsvARB 4236 #define X_GLrop_VertexAttrib4NivARB 4237 #define X_GLrop_VertexAttrib4NusvARB 4238 #define X_GLrop_VertexAttrib4NuivARB 4239 /* 27. GL_ARB_fragment_program - see GL_ARB_vertex_program opcodes */ /* 29. GL_ARB_occlusion_query */ /* XXX opcodes not defined in the spec */ /* New extension opcodes */ /* 145. GL_EXT_secondary_color - see GL 1.4 opcodes */ /* 188. GL_EXT_vertex_weighting */ #define X_GLrop_VertexWeightfvEXT 4135 /* 191. GL_NV_register_combiners */ #define X_GLrop_CombinerParameterfNV 4136 #define X_GLrop_CombinerParameterfvNV 4137 #define X_GLrop_CombinerParameteriNV 4138 #define X_GLrop_CombinerParameterivNV 4139 #define X_GLrop_CombinerInputNV 4140 #define X_GLrop_CombinerOutputNV 4141 #define X_GLrop_FinalCombinerInputNV 4142 /* 222. GL_NV_fence */ #define X_GLrop_SetFenceNV 4143 #define X_GLrop_FinishFenceNV 4144 /* 227. GL_NV_register_combiners2 */ /* XXX opcodes not defined in the spec */ /* 233. GL_NV_vertex_program - see also GL_ARB_vertex_program opcodes */ #define X_GLrop_ExecuteProgramNV 4181 #define X_GLrop_RequestResidentProgramsNV 4182 #define X_GLrop_LoadProgamNV 4183 #define X_GLrop_ProgramParameters4fvNV 4186 #define X_GLrop_ProgramParameters4dvNV 4187 #define X_GLrop_TrackMatrixNV 4188 #define X_GLrop_VertexAttribs1svNV 4202 #define X_GLrop_VertexAttribs2svNV 4203 #define X_GLrop_VertexAttribs3svNV 4204 #define X_GLrop_VertexAttribs4svNV 4205 #define X_GLrop_VertexAttribs1fvNV 4206 #define X_GLrop_VertexAttribs2fvNV 4207 #define X_GLrop_VertexAttribs3fvNV 4208 #define X_GLrop_VertexAttribs4fvNV 4209 #define X_GLrop_VertexAttribs1dvNV 4210 #define X_GLrop_VertexAttribs2dvNV 4211 #define X_GLrop_VertexAttribs3dvNV 4212 #define X_GLrop_VertexAttribs4dvNV 4213 #define X_GLrop_VertexAttribs4ubvNV 4214 /* 261. GL_NV_occlusion_query */ /* XXX opcodes not defined in the spec */ /* 262. GL_NV_point_sprite - see GL 1.4 opcodes */ /* 268. GL_EXT_stencil_two_side */ #define X_GLrop_ActiveStencilFaceEXT 4220 /* 282. GL_NV_fragment_program - see also GL_NV_vertex_program and GL_ARB_vertex_program opcodes */ #define X_GLrop_ProgramNamedParameter4fvNV 4218 #define X_GLrop_ProgramNamedParameter4dvNV 4219 /* 285. GL_NV_primitive_restart */ /* XXX opcodes not defined in the spec */ /* 297. GL_EXT_depth_bounds_test */ #define X_GLrop_DepthBoundsEXT 4229 /* 299. GL_EXT_blend_equation_separate */ #define X_GLrop_BlendEquationSeparateEXT 4228 /* 310. GL_EXT_framebuffer_object */ #define X_GLvop_IsRenderbufferEXT 1422 #define X_GLvop_GenRenderbuffersEXT 1423 #define X_GLvop_GetRenderbufferParameterivEXT 1424 #define X_GLvop_IsFramebufferEXT 1425 #define X_GLvop_GenFramebuffersEXT 1426 #define X_GLvop_CheckFramebufferStatusEXT 1427 #define X_GLvop_GetFramebufferAttachmentParameterivEXT 1428 #endif /* _GLX_glxproto_h_ */ #ifndef __gl_core_h_ #define __gl_core_h_ /* * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice including the dates of first publication and * either this permission notice or a reference to * http://oss.sgi.com/projects/FreeB/ * shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Except as contained in this notice, the name of Silicon Graphics, Inc. * shall not be used in advertising or otherwise to promote the sale, use or * other dealings in this Software without prior written authorization from * Silicon Graphics, Inc. */ #if !defined(_WIN32_WCE) #include <sys/types.h> #endif #define GL_CORE_SGI 1 #define GL_CORE_MESA 2 #define GL_CORE_APPLE 4 #define GL_CORE_WINDOWS 8 typedef struct __GLcontextRec __GLcontext; /* ** This file defines the interface between the GL core and the surrounding ** "operating system" that supports it (currently the GLX or WGL extensions). ** ** Members (data and function pointers) are documented as imported or ** exported according to how they are used by the core rendering functions. ** Imported members are initialized by the "operating system" and used by ** the core functions. Exported members are initialized by the core functions ** and used by the "operating system". */ /** * Mode and limit information for a context. This information is * kept around in the context so that values can be used during * command execution, and for returning information about the * context to the application. * * Instances of this structure are shared by the driver and the loader. To * maintain binary compatibility, new fields \b must be added only to the * end of the structure. * * \sa _gl_context_modes_create */ typedef struct __GLcontextModesRec { struct __GLcontextModesRec * next; GLboolean rgbMode; GLboolean floatMode; GLboolean colorIndexMode; GLuint doubleBufferMode; GLuint stereoMode; GLboolean haveAccumBuffer; GLboolean haveDepthBuffer; GLboolean haveStencilBuffer; GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */ GLuint redMask, greenMask, blueMask, alphaMask; GLint rgbBits; /* total bits for rgb */ GLint indexBits; /* total bits for colorindex */ GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits; GLint depthBits; GLint stencilBits; GLint numAuxBuffers; GLint level; GLint pixmapMode; /* GLX */ GLint visualID; GLint visualType; /**< One of the GLX X visual types. (i.e., * \c GLX_TRUE_COLOR, etc.) */ /* EXT_visual_rating / GLX 1.2 */ GLint visualRating; /* EXT_visual_info / GLX 1.2 */ GLint transparentPixel; /* colors are floats scaled to ints */ GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha; GLint transparentIndex; /* ARB_multisample / SGIS_multisample */ GLint sampleBuffers; GLint samples; /* SGIX_fbconfig / GLX 1.3 */ GLint drawableType; GLint renderType; GLint xRenderable; GLint fbconfigID; /* SGIX_pbuffer / GLX 1.3 */ GLint maxPbufferWidth; GLint maxPbufferHeight; GLint maxPbufferPixels; GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */ GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */ /* SGIX_visual_select_group */ GLint visualSelectGroup; /* OML_swap_method */ GLint swapMethod; GLint screen; /* EXT_texture_from_pixmap */ GLint bindToTextureRgb; GLint bindToTextureRgba; GLint bindToMipmapTexture; GLint bindToTextureTargets; GLint yInverted; } __GLcontextModes; /* Several fields of __GLcontextModes can take these as values. Since * GLX header files may not be available everywhere they need to be used, * redefine them here. */ #define GLX_NONE 0x8000 #define GLX_SLOW_CONFIG 0x8001 #define GLX_TRUE_COLOR 0x8002 #define GLX_DIRECT_COLOR 0x8003 #define GLX_PSEUDO_COLOR 0x8004 #define GLX_STATIC_COLOR 0x8005 #define GLX_GRAY_SCALE 0x8006 #define GLX_STATIC_GRAY 0x8007 #define GLX_TRANSPARENT_RGB 0x8008 #define GLX_TRANSPARENT_INDEX 0x8009 #define GLX_NON_CONFORMANT_CONFIG 0x800D #define GLX_SWAP_EXCHANGE_OML 0x8061 #define GLX_SWAP_COPY_OML 0x8062 #define GLX_SWAP_UNDEFINED_OML 0x8063 #define GLX_DONT_CARE 0xFFFFFFFF #define GLX_RGBA_BIT 0x00000001 #define GLX_COLOR_INDEX_BIT 0x00000002 #define GLX_WINDOW_BIT 0x00000001 #define GLX_PIXMAP_BIT 0x00000002 #define GLX_PBUFFER_BIT 0x00000004 #define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 #define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 #define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 #define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 #define GLX_Y_INVERTED_EXT 0x20D4 #define GLX_TEXTURE_1D_BIT_EXT 0x00000001 #define GLX_TEXTURE_2D_BIT_EXT 0x00000002 #define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 #endif /* __gl_core_h_ */ #ifndef __GLX_glxtokens_h__ #define __GLX_glxtokens_h__ /* * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice including the dates of first publication and * either this permission notice or a reference to * http://oss.sgi.com/projects/FreeB/ * shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Except as contained in this notice, the name of Silicon Graphics, Inc. * shall not be used in advertising or otherwise to promote the sale, use or * other dealings in this Software without prior written authorization from * Silicon Graphics, Inc. */ #ifdef __cplusplus extern "C" { #endif #define GLX_VERSION_1_1 1 #define GLX_VERSION_1_2 1 #define GLX_VERSION_1_3 1 #define GLX_VERSION_1_4 1 /* ** Visual Config Attributes (glXGetConfig, glXGetFBConfigAttrib) */ #define GLX_USE_GL 1 /* support GLX rendering */ #define GLX_BUFFER_SIZE 2 /* depth of the color buffer */ #define GLX_LEVEL 3 /* level in plane stacking */ #define GLX_RGBA 4 /* true if RGBA mode */ #define GLX_DOUBLEBUFFER 5 /* double buffering supported */ #define GLX_STEREO 6 /* stereo buffering supported */ #define GLX_AUX_BUFFERS 7 /* number of aux buffers */ #define GLX_RED_SIZE 8 /* number of red component bits */ #define GLX_GREEN_SIZE 9 /* number of green component bits */ #define GLX_BLUE_SIZE 10 /* number of blue component bits */ #define GLX_ALPHA_SIZE 11 /* number of alpha component bits */ #define GLX_DEPTH_SIZE 12 /* number of depth bits */ #define GLX_STENCIL_SIZE 13 /* number of stencil bits */ #define GLX_ACCUM_RED_SIZE 14 /* number of red accum bits */ #define GLX_ACCUM_GREEN_SIZE 15 /* number of green accum bits */ #define GLX_ACCUM_BLUE_SIZE 16 /* number of blue accum bits */ #define GLX_ACCUM_ALPHA_SIZE 17 /* number of alpha accum bits */ /* ** FBConfig-specific attributes */ #define GLX_X_VISUAL_TYPE 0x22 #define GLX_CONFIG_CAVEAT 0x20 /* Like visual_info VISUAL_CAVEAT_EXT */ #define GLX_TRANSPARENT_TYPE 0x23 #define GLX_TRANSPARENT_INDEX_VALUE 0x24 #define GLX_TRANSPARENT_RED_VALUE 0x25 #define GLX_TRANSPARENT_GREEN_VALUE 0x26 #define GLX_TRANSPARENT_BLUE_VALUE 0x27 #define GLX_TRANSPARENT_ALPHA_VALUE 0x28 #define GLX_DRAWABLE_TYPE 0x8010 #define GLX_RENDER_TYPE 0x8011 #define GLX_X_RENDERABLE 0x8012 #define GLX_FBCONFIG_ID 0x8013 #define GLX_MAX_PBUFFER_WIDTH 0x8016 #define GLX_MAX_PBUFFER_HEIGHT 0x8017 #define GLX_MAX_PBUFFER_PIXELS 0x8018 #define GLX_VISUAL_ID 0x800B /* FBConfigSGIX Attributes */ #define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 #define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A /* ** Error return values from glXGetConfig. Success is indicated by ** a value of 0. */ #define GLX_BAD_SCREEN 1 /* screen # is bad */ #define GLX_BAD_ATTRIBUTE 2 /* attribute to get is bad */ #define GLX_NO_EXTENSION 3 /* no glx extension on server */ #define GLX_BAD_VISUAL 4 /* visual # not known by GLX */ #define GLX_BAD_CONTEXT 5 /* returned only by import_context EXT? */ #define GLX_BAD_VALUE 6 /* returned only by glXSwapIntervalSGI? */ #define GLX_BAD_ENUM 7 /* unused? */ /* FBConfig attribute values */ /* ** Generic "don't care" value for glX ChooseFBConfig attributes (except ** GLX_LEVEL) */ #define GLX_DONT_CARE 0xFFFFFFFF /* GLX_RENDER_TYPE bits */ #define GLX_RGBA_BIT 0x00000001 #define GLX_COLOR_INDEX_BIT 0x00000002 #define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 #define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 /* GLX_DRAWABLE_TYPE bits */ #define GLX_WINDOW_BIT 0x00000001 #define GLX_PIXMAP_BIT 0x00000002 #define GLX_PBUFFER_BIT 0x00000004 /* GLX_CONFIG_CAVEAT attribute values */ #define GLX_NONE 0x8000 #define GLX_SLOW_CONFIG 0x8001 #define GLX_NON_CONFORMANT_CONFIG 0x800D /* GLX_X_VISUAL_TYPE attribute values */ #define GLX_TRUE_COLOR 0x8002 #define GLX_DIRECT_COLOR 0x8003 #define GLX_PSEUDO_COLOR 0x8004 #define GLX_STATIC_COLOR 0x8005 #define GLX_GRAY_SCALE 0x8006 #define GLX_STATIC_GRAY 0x8007 /* GLX_TRANSPARENT_TYPE attribute values */ /* #define GLX_NONE 0x8000 */ #define GLX_TRANSPARENT_RGB 0x8008 #define GLX_TRANSPARENT_INDEX 0x8009 /* glXCreateGLXPbuffer attributes */ #define GLX_PRESERVED_CONTENTS 0x801B #define GLX_LARGEST_PBUFFER 0x801C #define GLX_PBUFFER_HEIGHT 0x8040 /* New for GLX 1.3 */ #define GLX_PBUFFER_WIDTH 0x8041 /* New for GLX 1.3 */ /* glXQueryGLXPBuffer attributes */ #define GLX_WIDTH 0x801D #define GLX_HEIGHT 0x801E #define GLX_EVENT_MASK 0x801F /* glXCreateNewContext render_type attribute values */ #define GLX_RGBA_TYPE 0x8014 #define GLX_COLOR_INDEX_TYPE 0x8015 /* glXQueryContext attributes */ /* #define GLX_FBCONFIG_ID 0x8013 */ /* #define GLX_RENDER_TYPE 0x8011 */ #define GLX_SCREEN 0x800C /* glXSelectEvent event mask bits */ #define GLX_PBUFFER_CLOBBER_MASK 0x08000000 #define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000 /* GLXPbufferClobberEvent event_type values */ #define GLX_DAMAGED 0x8020 #define GLX_SAVED 0x8021 #define GLX_EXCHANGE_COMPLETE_INTEL 0x8180 #define GLX_BLIT_COMPLETE_INTEL 0x8181 #define GLX_FLIP_COMPLETE_INTEL 0x8182 /* GLXPbufferClobberEvent draw_type values */ #define GLX_WINDOW 0x8022 #define GLX_PBUFFER 0x8023 /* GLXPbufferClobberEvent buffer_mask bits */ #define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 #define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 #define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 #define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 #define GLX_AUX_BUFFERS_BIT 0x00000010 #define GLX_DEPTH_BUFFER_BIT 0x00000020 #define GLX_STENCIL_BUFFER_BIT 0x00000040 #define GLX_ACCUM_BUFFER_BIT 0x00000080 /* ** Extension return values from glXGetConfig. These are also ** accepted as parameter values for glXChooseVisual. */ #define GLX_X_VISUAL_TYPE_EXT 0x22 /* visual_info extension type */ #define GLX_TRANSPARENT_TYPE_EXT 0x23 /* visual_info extension */ #define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 /* visual_info extension */ #define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 /* visual_info extension */ #define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 /* visual_info extension */ #define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 /* visual_info extension */ #define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 /* visual_info extension */ /* Property values for visual_type */ #define GLX_TRUE_COLOR_EXT 0x8002 #define GLX_DIRECT_COLOR_EXT 0x8003 #define GLX_PSEUDO_COLOR_EXT 0x8004 #define GLX_STATIC_COLOR_EXT 0x8005 #define GLX_GRAY_SCALE_EXT 0x8006 #define GLX_STATIC_GRAY_EXT 0x8007 /* Property values for transparent pixel */ #define GLX_NONE_EXT 0x8000 #define GLX_TRANSPARENT_RGB_EXT 0x8008 #define GLX_TRANSPARENT_INDEX_EXT 0x8009 /* Property values for visual_rating */ #define GLX_VISUAL_CAVEAT_EXT 0x20 /* visual_rating extension type */ #define GLX_SLOW_VISUAL_EXT 0x8001 #define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D /* Property values for swap method (GLX_OML_swap_method) */ #define GLX_SWAP_METHOD_OML 0x8060 #define GLX_SWAP_EXCHANGE_OML 0x8061 #define GLX_SWAP_COPY_OML 0x8062 #define GLX_SWAP_UNDEFINED_OML 0x8063 /* Property values for multi-sampling */ #define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 /* visuals grouped by select priority */ /* ** Names for attributes to glXGetClientString. */ #define GLX_VENDOR 0x1 #define GLX_VERSION 0x2 #define GLX_EXTENSIONS 0x3 /* ** Names for attributes to glXQueryContextInfoEXT. */ #define GLX_SHARE_CONTEXT_EXT 0x800A /* id of share context */ #define GLX_VISUAL_ID_EXT 0x800B /* id of context's visual */ #define GLX_SCREEN_EXT 0x800C /* screen number */ /* ** GLX_EXT_texture_from_pixmap */ #define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 #define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 #define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 #define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 #define GLX_Y_INVERTED_EXT 0x20D4 #define GLX_TEXTURE_FORMAT_EXT 0x20D5 #define GLX_TEXTURE_TARGET_EXT 0x20D6 #define GLX_MIPMAP_TEXTURE_EXT 0x20D7 #define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 #define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 #define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA #define GLX_TEXTURE_1D_BIT_EXT 0x00000001 #define GLX_TEXTURE_2D_BIT_EXT 0x00000002 #define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 #define GLX_TEXTURE_1D_EXT 0x20DB #define GLX_TEXTURE_2D_EXT 0x20DC #define GLX_TEXTURE_RECTANGLE_EXT 0x20DD #define GLX_FRONT_LEFT_EXT 0x20DE #define GLX_FRONT_RIGHT_EXT 0x20DF #define GLX_BACK_LEFT_EXT 0x20E0 #define GLX_BACK_RIGHT_EXT 0x20E1 #define GLX_FRONT_EXT GLX_FRONT_LEFT_EXT #define GLX_BACK_EXT GLX_BACK_LEFT_EXT #define GLX_AUX0_EXT 0x20E2 #define GLX_AUX1_EXT 0x20E3 #define GLX_AUX2_EXT 0x20E4 #define GLX_AUX3_EXT 0x20E5 #define GLX_AUX4_EXT 0x20E6 #define GLX_AUX5_EXT 0x20E7 #define GLX_AUX6_EXT 0x20E8 #define GLX_AUX7_EXT 0x20E9 #define GLX_AUX8_EXT 0x20EA #define GLX_AUX9_EXT 0x20EB /* * GLX 1.4 and later: */ #define GLX_SAMPLE_BUFFERS_SGIS 100000 #define GLX_SAMPLES_SGIS 100001 /* * GLX_EXT_framebuffer_SRGB */ #define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 /* * GLX_ARB_create_context * GLX_ARB_create_context_profile * GLX_EXT_create_context_es2_profile */ #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 #define GLX_CONTEXT_FLAGS_ARB 0x2094 #define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 #define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x0001 #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x0002 #define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x0004 /* * GLX_ARB_create_context_robustness */ #define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x0004 #define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 #define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 #define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 #ifdef __cplusplus } #endif #endif /* !__GLX_glxtokens_h__ */ #ifndef __GLX_glxint_h__ #define __GLX_glxint_h__ /* * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice including the dates of first publication and * either this permission notice or a reference to * http://oss.sgi.com/projects/FreeB/ * shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Except as contained in this notice, the name of Silicon Graphics, Inc. * shall not be used in advertising or otherwise to promote the sale, use or * other dealings in this Software without prior written authorization from * Silicon Graphics, Inc. */ #include <X11/X.h> #include <X11/Xdefs.h> #include "GL/gl.h" typedef struct __GLXvisualConfigRec __GLXvisualConfig; typedef struct __GLXFBConfigRec __GLXFBConfig; struct __GLXvisualConfigRec { VisualID vid; int class; Bool rgba; int redSize, greenSize, blueSize, alphaSize; unsigned long redMask, greenMask, blueMask, alphaMask; int accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize; Bool doubleBuffer; Bool stereo; int bufferSize; int depthSize; int stencilSize; int auxBuffers; int level; /* Start of Extended Visual Properties */ int visualRating; /* visual_rating extension */ int transparentPixel; /* visual_info extension */ /* colors are floats scaled to ints */ int transparentRed, transparentGreen, transparentBlue, transparentAlpha; int transparentIndex; int multiSampleSize; int nMultiSampleBuffers; int visualSelectGroup; }; #define __GLX_MIN_CONFIG_PROPS 18 #define __GLX_MAX_CONFIG_PROPS 500 #define __GLX_EXT_CONFIG_PROPS 10 /* ** Since we send all non-core visual properties as token, value pairs, ** we require 2 words across the wire. In order to maintain backwards ** compatibility, we need to send the total number of words that the ** VisualConfigs are sent back in so old libraries can simply "ignore" ** the new properties. */ #define __GLX_TOTAL_CONFIG (__GLX_MIN_CONFIG_PROPS + \ 2 * __GLX_EXT_CONFIG_PROPS) struct __GLXFBConfigRec { int visualType; int transparentType; /* colors are floats scaled to ints */ int transparentRed, transparentGreen, transparentBlue, transparentAlpha; int transparentIndex; int visualCaveat; int associatedVisualId; int screen; int drawableType; int renderType; int maxPbufferWidth, maxPbufferHeight, maxPbufferPixels; int optimalPbufferWidth, optimalPbufferHeight; /* for SGIX_pbuffer */ int visualSelectGroup; /* visuals grouped by select priority */ unsigned int id; GLboolean rgbMode; GLboolean colorIndexMode; GLboolean doubleBufferMode; GLboolean stereoMode; GLboolean haveAccumBuffer; GLboolean haveDepthBuffer; GLboolean haveStencilBuffer; /* The number of bits present in various buffers */ GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits; GLint depthBits; GLint stencilBits; GLint indexBits; GLint redBits, greenBits, blueBits, alphaBits; GLuint redMask, greenMask, blueMask, alphaMask; GLuint multiSampleSize; /* Number of samples per pixel (0 if no ms) */ GLuint nMultiSampleBuffers; /* Number of available ms buffers */ GLint maxAuxBuffers; /* frame buffer level */ GLint level; /* color ranges (for SGI_color_range) */ GLboolean extendedRange; GLdouble minRed, maxRed; GLdouble minGreen, maxGreen; GLdouble minBlue, maxBlue; GLdouble minAlpha, maxAlpha; }; #define __GLX_TOTAL_FBCONFIG_PROPS 35 #endif /* !__GLX_glxint_h__ */ #ifndef _GLX_glxmd_h_ #define _GLX_glxmd_h_ /* * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice including the dates of first publication and * either this permission notice or a reference to * http://oss.sgi.com/projects/FreeB/ * shall be included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Except as contained in this notice, the name of Silicon Graphics, Inc. * shall not be used in advertising or otherwise to promote the sale, use or * other dealings in this Software without prior written authorization from * Silicon Graphics, Inc. */ /* ** Machine dependent declarations. */ /* ** Define floating point wire types. These are in IEEE format on the wire. */ typedef float FLOAT32; typedef double FLOAT64; /* ** Like B32, but this is used to store floats in a request. ** ** NOTE: Machines that have a native 32-bit IEEE float can define this as ** nothing. Machines that don't might mimic the float with an integer, ** and then define this to :32. */ #define F32 #endif /* _GLX_glxmd_h_ */ /* Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* * POSIX Standard: 5.6.6 Set File Access and Modification Times <utime.h> */ #ifndef _UTIME_H #define _UTIME_H 1 #include <features.h> __BEGIN_DECLS #include <bits/types.h> #if defined __USE_XOPEN || defined __USE_XOPEN2K # include <bits/types/time_t.h> #endif /* Structure describing file times. */ struct utimbuf { #ifdef __USE_TIME_BITS64 __time64_t actime; /* Access time. */ __time64_t modtime; /* Modification time. */ #else __time_t actime; /* Access time. */ __time_t modtime; /* Modification time. */ #endif }; /* Set the access and modification times of FILE to those given in *FILE_TIMES. If FILE_TIMES is NULL, set them to the current time. */ #ifndef __USE_TIME_BITS64 extern int utime (const char *__file, const struct utimbuf *__file_times) __THROW __nonnull ((1)); #else # ifdef __REDIRECT_NTH extern int __REDIRECT_NTH (utime, (const char *__file, const struct utimbuf *__file_times), __utime64); # else # define utime __utime64 # endif #endif __END_DECLS #endif /* utime.h */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* * ISO C99 Standard: 7.22 Type-generic math <tgmath.h> */ #ifndef _TGMATH_H #define _TGMATH_H 1 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION #include <bits/libc-header-start.h> /* Include the needed headers. */ #include <bits/floatn.h> #include <math.h> #include <complex.h> /* There are two variant implementations of type-generic macros in this file: one for GCC 8 and later, using __builtin_tgmath and where each macro expands each of its arguments only once, and one for older GCC, using other compiler extensions but with macros expanding their arguments many times (so resulting in exponential blowup of the size of expansions when calls to such macros are nested inside arguments to such macros). Because of a long series of defect fixes made after the initial release of TS 18661-1, GCC versions before GCC 13 have __builtin_tgmath semantics that, when integer arguments are passed to narrowing macros returning _Float32x, or non-narrowing macros with at least two generic arguments, do not always correspond to the C2X semantics, so more complicated macro definitions are also used in some cases for versions from GCC 8 to GCC 12. */ #define __HAVE_BUILTIN_TGMATH __GNUC_PREREQ (8, 0) #define __HAVE_BUILTIN_TGMATH_C2X __GNUC_PREREQ (13, 0) #if __GNUC_PREREQ (2, 7) /* Certain cases of narrowing macros only need to call a single function so cannot use __builtin_tgmath and do not need any complicated logic. */ # if __HAVE_FLOAT128X # error "Unsupported _Float128x type for <tgmath.h>." # endif # if ((__HAVE_FLOAT64X && !__HAVE_FLOAT128) \ || (__HAVE_FLOAT128 && !__HAVE_FLOAT64X)) # error "Unsupported combination of types for <tgmath.h>." # endif # define __TGMATH_2_NARROW_D(F, X, Y) \ (F ## l (X, Y)) # define __TGMATH_2_NARROW_F64X(F, X, Y) \ (F ## f128 (X, Y)) # if !__HAVE_FLOAT128 # define __TGMATH_2_NARROW_F32X(F, X, Y) \ (F ## f64 (X, Y)) # endif # if __HAVE_BUILTIN_TGMATH # if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT) # define __TG_F16_ARG(X) X ## f16, # else # define __TG_F16_ARG(X) # endif # if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT) # define __TG_F32_ARG(X) X ## f32, # else # define __TG_F32_ARG(X) # endif # if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT) # define __TG_F64_ARG(X) X ## f64, # else # define __TG_F64_ARG(X) # endif # if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) # define __TG_F128_ARG(X) X ## f128, # else # define __TG_F128_ARG(X) # endif # if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT) # define __TG_F32X_ARG(X) X ## f32x, # else # define __TG_F32X_ARG(X) # endif # if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT) # define __TG_F64X_ARG(X) X ## f64x, # else # define __TG_F64X_ARG(X) # endif # if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT) # define __TG_F128X_ARG(X) X ## f128x, # else # define __TG_F128X_ARG(X) # endif # define __TGMATH_FUNCS(X) X ## f, X, X ## l, \ __TG_F16_ARG (X) __TG_F32_ARG (X) __TG_F64_ARG (X) __TG_F128_ARG (X) \ __TG_F32X_ARG (X) __TG_F64X_ARG (X) __TG_F128X_ARG (X) # define __TGMATH_RCFUNCS(F, C) __TGMATH_FUNCS (F) __TGMATH_FUNCS (C) # define __TGMATH_1(F, X) __builtin_tgmath (__TGMATH_FUNCS (F) (X)) # define __TGMATH_2(F, X, Y) __builtin_tgmath (__TGMATH_FUNCS (F) (X), (Y)) # define __TGMATH_2STD(F, X, Y) __builtin_tgmath (F ## f, F, F ## l, (X), (Y)) # define __TGMATH_3(F, X, Y, Z) __builtin_tgmath (__TGMATH_FUNCS (F) \ (X), (Y), (Z)) # define __TGMATH_1C(F, C, X) __builtin_tgmath (__TGMATH_RCFUNCS (F, C) (X)) # define __TGMATH_2C(F, C, X, Y) __builtin_tgmath (__TGMATH_RCFUNCS (F, C) \ (X), (Y)) # define __TGMATH_NARROW_FUNCS_F(X) X, X ## l, # define __TGMATH_NARROW_FUNCS_F16(X) \ __TG_F32_ARG (X) __TG_F64_ARG (X) __TG_F128_ARG (X) \ __TG_F32X_ARG (X) __TG_F64X_ARG (X) __TG_F128X_ARG (X) # define __TGMATH_NARROW_FUNCS_F32(X) \ __TG_F64_ARG (X) __TG_F128_ARG (X) \ __TG_F32X_ARG (X) __TG_F64X_ARG (X) __TG_F128X_ARG (X) # define __TGMATH_NARROW_FUNCS_F64(X) \ __TG_F128_ARG (X) \ __TG_F64X_ARG (X) __TG_F128X_ARG (X) # define __TGMATH_NARROW_FUNCS_F32X(X) \ __TG_F64X_ARG (X) __TG_F128X_ARG (X) \ __TG_F64_ARG (X) __TG_F128_ARG (X) # define __TGMATH_2_NARROW_F(F, X, Y) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F (F) (X), (Y)) # define __TGMATH_2_NARROW_F16(F, X, Y) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F16 (F) (X), (Y)) # define __TGMATH_2_NARROW_F32(F, X, Y) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32 (F) (X), (Y)) # define __TGMATH_2_NARROW_F64(F, X, Y) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F64 (F) (X), (Y)) # if __HAVE_FLOAT128 && __HAVE_BUILTIN_TGMATH_C2X # define __TGMATH_2_NARROW_F32X(F, X, Y) \ __builtin_tgmath (__TGMATH_NARROW_FUNCS_F32X (F) (X), (Y)) # endif # endif # if !__HAVE_BUILTIN_TGMATH_C2X # ifdef __NO_LONG_DOUBLE_MATH # define __tgml(fct) fct # else # define __tgml(fct) fct ## l # endif /* __floating_type expands to 1 if TYPE is a floating type (including complex floating types), 0 if TYPE is an integer type (including complex integer types). __real_integer_type expands to 1 if TYPE is a real integer type. __complex_integer_type expands to 1 if TYPE is a complex integer type. All these macros expand to integer constant expressions. All these macros can assume their argument has an arithmetic type (not vector, decimal floating-point or fixed-point), valid to pass to tgmath.h macros. */ # if __GNUC_PREREQ (3, 1) /* __builtin_classify_type expands to an integer constant expression in GCC 3.1 and later. Default conversions applied to the argument of __builtin_classify_type mean it always returns 1 for real integer types rather than ever returning different values for character, boolean or enumerated types. */ # define __floating_type(type) \ (__builtin_classify_type (__real__ ((type) 0)) == 8) # define __real_integer_type(type) \ (__builtin_classify_type ((type) 0) == 1) # define __complex_integer_type(type) \ (__builtin_classify_type ((type) 0) == 9 \ && __builtin_classify_type (__real__ ((type) 0)) == 1) # else /* GCC versions predating __builtin_classify_type are also looser on what counts as an integer constant expression. */ # define __floating_type(type) (((type) 1.25) != 1) # define __real_integer_type(type) (((type) (1.25 + _Complex_I)) == 1) # define __complex_integer_type(type) \ (((type) (1.25 + _Complex_I)) == (1 + _Complex_I)) # endif /* Whether an expression (of arithmetic type) has a real type. */ # define __expr_is_real(E) (__builtin_classify_type (E) != 9) /* Type T1 if E is 1, type T2 is E is 0. */ # define __tgmath_type_if(T1, T2, E) \ __typeof__ (*(0 ? (__typeof__ (0 ? (T2 *) 0 : (void *) (E))) 0 \ : (__typeof__ (0 ? (T1 *) 0 : (void *) (!(E)))) 0)) /* The tgmath real type for T, where E is 0 if T is an integer type and 1 for a floating type. If T has a complex type, it is unspecified whether the return type is real or complex (but it has the correct corresponding real type). */ # define __tgmath_real_type_sub(T, E) \ __tgmath_type_if (T, double, E) /* The tgmath real type of EXPR. */ # define __tgmath_real_type(expr) \ __tgmath_real_type_sub (__typeof__ ((__typeof__ (+(expr))) 0), \ __floating_type (__typeof__ (+(expr)))) /* The tgmath complex type for T, where E1 is 1 if T has a floating type and 0 otherwise, E2 is 1 if T has a real integer type and 0 otherwise, and E3 is 1 if T has a complex type and 0 otherwise. */ # define __tgmath_complex_type_sub(T, E1, E2, E3) \ __typeof__ (*(0 \ ? (__typeof__ (0 ? (T *) 0 : (void *) (!(E1)))) 0 \ : (__typeof__ (0 \ ? (__typeof__ (0 \ ? (double *) 0 \ : (void *) (!(E2)))) 0 \ : (__typeof__ (0 \ ? (_Complex double *) 0 \ : (void *) (!(E3)))) 0)) 0)) /* The tgmath complex type of EXPR. */ # define __tgmath_complex_type(expr) \ __tgmath_complex_type_sub (__typeof__ ((__typeof__ (+(expr))) 0), \ __floating_type (__typeof__ (+(expr))), \ __real_integer_type (__typeof__ (+(expr))), \ __complex_integer_type (__typeof__ (+(expr)))) /* The tgmath real type of EXPR1 combined with EXPR2, without handling the C2X rule of interpreting integer arguments as _Float32x if any argument is _FloatNx. */ # define __tgmath_real_type2_base(expr1, expr2) \ __typeof ((__tgmath_real_type (expr1)) 0 + (__tgmath_real_type (expr2)) 0) /* The tgmath complex type of EXPR1 combined with EXPR2, without handling the C2X rule of interpreting integer arguments as _Float32x if any argument is _FloatNx. */ # define __tgmath_complex_type2_base(expr1, expr2) \ __typeof ((__tgmath_complex_type (expr1)) 0 \ + (__tgmath_complex_type (expr2)) 0) /* The tgmath real type of EXPR1 combined with EXPR2 and EXPR3, without handling the C2X rule of interpreting integer arguments as _Float32x if any argument is _FloatNx. */ # define __tgmath_real_type3_base(expr1, expr2, expr3) \ __typeof ((__tgmath_real_type (expr1)) 0 \ + (__tgmath_real_type (expr2)) 0 \ + (__tgmath_real_type (expr3)) 0) /* The tgmath real or complex type of EXPR1 combined with EXPR2 (and EXPR3 if applicable). */ # if __HAVE_FLOATN_NOT_TYPEDEF # define __tgmath_real_type2(expr1, expr2) \ __tgmath_type_if (_Float32x, __tgmath_real_type2_base (expr1, expr2), \ _Generic ((expr1) + (expr2), _Float32x: 1, default: 0)) # define __tgmath_complex_type2(expr1, expr2) \ __tgmath_type_if (_Float32x, \ __tgmath_type_if (_Complex _Float32x, \ __tgmath_complex_type2_base (expr1, \ expr2), \ _Generic ((expr1) + (expr2), \ _Complex _Float32x: 1, \ default: 0)), \ _Generic ((expr1) + (expr2), _Float32x: 1, default: 0)) # define __tgmath_real_type3(expr1, expr2, expr3) \ __tgmath_type_if (_Float32x, \ __tgmath_real_type3_base (expr1, expr2, expr3), \ _Generic ((expr1) + (expr2) + (expr3), \ _Float32x: 1, default: 0)) # else # define __tgmath_real_type2(expr1, expr2) \ __tgmath_real_type2_base (expr1, expr2) # define __tgmath_complex_type2(expr1, expr2) \ __tgmath_complex_type2_base (expr1, expr2) # define __tgmath_real_type3(expr1, expr2, expr3) \ __tgmath_real_type3_base (expr1, expr2, expr3) # endif # if (__HAVE_DISTINCT_FLOAT16 \ || __HAVE_DISTINCT_FLOAT32 \ || __HAVE_DISTINCT_FLOAT64 \ || __HAVE_DISTINCT_FLOAT32X \ || __HAVE_DISTINCT_FLOAT64X \ || __HAVE_DISTINCT_FLOAT128X) # error "Unsupported _FloatN or _FloatNx types for <tgmath.h>." # endif /* Expand to text that checks if ARG_COMB has type _Float128, and if so calls the appropriately suffixed FCT (which may include a cast), or FCT and CFCT for complex functions, with arguments ARG_CALL. __TGMATH_F128LD (only used in the __HAVE_FLOAT64X_LONG_DOUBLE case, for narrowing macros) handles long double the same as _Float128. */ # if __HAVE_DISTINCT_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) # if (!__HAVE_FLOAT64X \ || __HAVE_FLOAT64X_LONG_DOUBLE \ || !__HAVE_FLOATN_NOT_TYPEDEF) # define __TGMATH_F128(arg_comb, fct, arg_call) \ __builtin_types_compatible_p (__typeof (+(arg_comb)), _Float128) \ ? fct ## f128 arg_call : # define __TGMATH_F128LD(arg_comb, fct, arg_call) \ (__builtin_types_compatible_p (__typeof (+(arg_comb)), _Float128) \ || __builtin_types_compatible_p (__typeof (+(arg_comb)), long double)) \ ? fct ## f128 arg_call : # define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) \ __builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), _Float128) \ ? (__expr_is_real (arg_comb) \ ? fct ## f128 arg_call \ : cfct ## f128 arg_call) : # else /* _Float64x is a distinct type at the C language level, which must be handled like _Float128. */ # define __TGMATH_F128(arg_comb, fct, arg_call) \ (__builtin_types_compatible_p (__typeof (+(arg_comb)), _Float128) \ || __builtin_types_compatible_p (__typeof (+(arg_comb)), _Float64x)) \ ? fct ## f128 arg_call : # define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) \ (__builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), _Float128) \ || __builtin_types_compatible_p (__typeof (+__real__ (arg_comb)), \ _Float64x)) \ ? (__expr_is_real (arg_comb) \ ? fct ## f128 arg_call \ : cfct ## f128 arg_call) : # endif # else # define __TGMATH_F128(arg_comb, fct, arg_call) /* Nothing. */ # define __TGMATH_CF128(arg_comb, fct, cfct, arg_call) /* Nothing. */ # endif # endif /* !__HAVE_BUILTIN_TGMATH_C2X. */ /* We have two kinds of generic macros: to support functions which are only defined on real valued parameters and those which are defined for complex functions as well. */ # if __HAVE_BUILTIN_TGMATH # define __TGMATH_UNARY_REAL_ONLY(Val, Fct) __TGMATH_1 (Fct, (Val)) # define __TGMATH_UNARY_REAL_RET_ONLY(Val, Fct) __TGMATH_1 (Fct, (Val)) # define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \ __TGMATH_2 (Fct, (Val1), (Val2)) # define __TGMATH_BINARY_FIRST_REAL_STD_ONLY(Val1, Val2, Fct) \ __TGMATH_2STD (Fct, (Val1), (Val2)) # if __HAVE_BUILTIN_TGMATH_C2X # define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \ __TGMATH_2 (Fct, (Val1), (Val2)) # endif # define __TGMATH_BINARY_REAL_STD_ONLY(Val1, Val2, Fct) \ __TGMATH_2STD (Fct, (Val1), (Val2)) # if __HAVE_BUILTIN_TGMATH_C2X # define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \ __TGMATH_3 (Fct, (Val1), (Val2), (Val3)) # define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \ __TGMATH_3 (Fct, (Val1), (Val2), (Val3)) # endif # define __TGMATH_TERNARY_FIRST_REAL_RET_ONLY(Val1, Val2, Val3, Fct) \ __TGMATH_3 (Fct, (Val1), (Val2), (Val3)) # define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \ __TGMATH_1C (Fct, Cfct, (Val)) # define __TGMATH_UNARY_IMAG(Val, Cfct) __TGMATH_1 (Cfct, (Val)) # define __TGMATH_UNARY_REAL_IMAG_RET_REAL(Val, Fct, Cfct) \ __TGMATH_1C (Fct, Cfct, (Val)) # define __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME(Val, Cfct) \ __TGMATH_1 (Cfct, (Val)) # if __HAVE_BUILTIN_TGMATH_C2X # define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \ __TGMATH_2C (Fct, Cfct, (Val1), (Val2)) # endif # endif # if !__HAVE_BUILTIN_TGMATH # define __TGMATH_UNARY_REAL_ONLY(Val, Fct) \ (__extension__ ((sizeof (+(Val)) == sizeof (double) \ || __builtin_classify_type (Val) != 8) \ ? (__tgmath_real_type (Val)) Fct (Val) \ : (sizeof (+(Val)) == sizeof (float)) \ ? (__tgmath_real_type (Val)) Fct##f (Val) \ : __TGMATH_F128 ((Val), (__tgmath_real_type (Val)) Fct, \ (Val)) \ (__tgmath_real_type (Val)) __tgml(Fct) (Val))) # define __TGMATH_UNARY_REAL_RET_ONLY(Val, Fct) \ (__extension__ ((sizeof (+(Val)) == sizeof (double) \ || __builtin_classify_type (Val) != 8) \ ? Fct (Val) \ : (sizeof (+(Val)) == sizeof (float)) \ ? Fct##f (Val) \ : __TGMATH_F128 ((Val), Fct, (Val)) \ __tgml(Fct) (Val))) # define __TGMATH_BINARY_FIRST_REAL_ONLY(Val1, Val2, Fct) \ (__extension__ ((sizeof (+(Val1)) == sizeof (double) \ || __builtin_classify_type (Val1) != 8) \ ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \ : (sizeof (+(Val1)) == sizeof (float)) \ ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \ : __TGMATH_F128 ((Val1), (__tgmath_real_type (Val1)) Fct, \ (Val1, Val2)) \ (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2))) # define __TGMATH_BINARY_FIRST_REAL_STD_ONLY(Val1, Val2, Fct) \ (__extension__ ((sizeof (+(Val1)) == sizeof (double) \ || __builtin_classify_type (Val1) != 8) \ ? (__tgmath_real_type (Val1)) Fct (Val1, Val2) \ : (sizeof (+(Val1)) == sizeof (float)) \ ? (__tgmath_real_type (Val1)) Fct##f (Val1, Val2) \ : (__tgmath_real_type (Val1)) __tgml(Fct) (Val1, Val2))) # endif # if !__HAVE_BUILTIN_TGMATH_C2X # define __TGMATH_BINARY_REAL_ONLY(Val1, Val2, Fct) \ (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \ && __builtin_classify_type ((Val1) + (Val2)) == 8) \ ? __TGMATH_F128 ((Val1) + (Val2), \ (__tgmath_real_type2 (Val1, Val2)) Fct, \ (Val1, Val2)) \ (__tgmath_real_type2 (Val1, Val2)) \ __tgml(Fct) (Val1, Val2) \ : (sizeof (+(Val1)) == sizeof (double) \ || sizeof (+(Val2)) == sizeof (double) \ || __builtin_classify_type (Val1) != 8 \ || __builtin_classify_type (Val2) != 8) \ ? (__tgmath_real_type2 (Val1, Val2)) \ Fct (Val1, Val2) \ : (__tgmath_real_type2 (Val1, Val2)) \ Fct##f (Val1, Val2))) # endif # if !__HAVE_BUILTIN_TGMATH # define __TGMATH_BINARY_REAL_STD_ONLY(Val1, Val2, Fct) \ (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \ && __builtin_classify_type ((Val1) + (Val2)) == 8) \ ? (__typeof ((__tgmath_real_type (Val1)) 0 \ + (__tgmath_real_type (Val2)) 0)) \ __tgml(Fct) (Val1, Val2) \ : (sizeof (+(Val1)) == sizeof (double) \ || sizeof (+(Val2)) == sizeof (double) \ || __builtin_classify_type (Val1) != 8 \ || __builtin_classify_type (Val2) != 8) \ ? (__typeof ((__tgmath_real_type (Val1)) 0 \ + (__tgmath_real_type (Val2)) 0)) \ Fct (Val1, Val2) \ : (__typeof ((__tgmath_real_type (Val1)) 0 \ + (__tgmath_real_type (Val2)) 0)) \ Fct##f (Val1, Val2))) # endif # if !__HAVE_BUILTIN_TGMATH_C2X # define __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY(Val1, Val2, Val3, Fct) \ (__extension__ ((sizeof ((Val1) + (Val2)) > sizeof (double) \ && __builtin_classify_type ((Val1) + (Val2)) == 8) \ ? __TGMATH_F128 ((Val1) + (Val2), \ (__tgmath_real_type2 (Val1, Val2)) Fct, \ (Val1, Val2, Val3)) \ (__tgmath_real_type2 (Val1, Val2)) \ __tgml(Fct) (Val1, Val2, Val3) \ : (sizeof (+(Val1)) == sizeof (double) \ || sizeof (+(Val2)) == sizeof (double) \ || __builtin_classify_type (Val1) != 8 \ || __builtin_classify_type (Val2) != 8) \ ? (__tgmath_real_type2 (Val1, Val2)) \ Fct (Val1, Val2, Val3) \ : (__tgmath_real_type2 (Val1, Val2)) \ Fct##f (Val1, Val2, Val3))) # define __TGMATH_TERNARY_REAL_ONLY(Val1, Val2, Val3, Fct) \ (__extension__ ((sizeof ((Val1) + (Val2) + (Val3)) > sizeof (double) \ && __builtin_classify_type ((Val1) + (Val2) + (Val3)) \ == 8) \ ? __TGMATH_F128 ((Val1) + (Val2) + (Val3), \ (__tgmath_real_type3 (Val1, Val2, \ Val3)) Fct, \ (Val1, Val2, Val3)) \ (__tgmath_real_type3 (Val1, Val2, Val3)) \ __tgml(Fct) (Val1, Val2, Val3) \ : (sizeof (+(Val1)) == sizeof (double) \ || sizeof (+(Val2)) == sizeof (double) \ || sizeof (+(Val3)) == sizeof (double) \ || __builtin_classify_type (Val1) != 8 \ || __builtin_classify_type (Val2) != 8 \ || __builtin_classify_type (Val3) != 8) \ ? (__tgmath_real_type3 (Val1, Val2, Val3)) \ Fct (Val1, Val2, Val3) \ : (__tgmath_real_type3 (Val1, Val2, Val3)) \ Fct##f (Val1, Val2, Val3))) # endif # if !__HAVE_BUILTIN_TGMATH # define __TGMATH_TERNARY_FIRST_REAL_RET_ONLY(Val1, Val2, Val3, Fct) \ (__extension__ ((sizeof (+(Val1)) == sizeof (double) \ || __builtin_classify_type (Val1) != 8) \ ? Fct (Val1, Val2, Val3) \ : (sizeof (+(Val1)) == sizeof (float)) \ ? Fct##f (Val1, Val2, Val3) \ : __TGMATH_F128 ((Val1), Fct, (Val1, Val2, Val3)) \ __tgml(Fct) (Val1, Val2, Val3))) /* XXX This definition has to be changed as soon as the compiler understands the imaginary keyword. */ # define __TGMATH_UNARY_REAL_IMAG(Val, Fct, Cfct) \ (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \ || __builtin_classify_type (__real__ (Val)) != 8) \ ? (__expr_is_real (Val) \ ? (__tgmath_complex_type (Val)) Fct (Val) \ : (__tgmath_complex_type (Val)) Cfct (Val)) \ : (sizeof (+__real__ (Val)) == sizeof (float)) \ ? (__expr_is_real (Val) \ ? (__tgmath_complex_type (Val)) Fct##f (Val) \ : (__tgmath_complex_type (Val)) Cfct##f (Val)) \ : __TGMATH_CF128 ((Val), \ (__tgmath_complex_type (Val)) Fct, \ (__tgmath_complex_type (Val)) Cfct, \ (Val)) \ (__expr_is_real (Val) \ ? (__tgmath_complex_type (Val)) __tgml(Fct) (Val) \ : (__tgmath_complex_type (Val)) __tgml(Cfct) (Val)))) # define __TGMATH_UNARY_IMAG(Val, Cfct) \ (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \ || __builtin_classify_type (__real__ (Val)) != 8) \ ? (__typeof__ ((__tgmath_real_type (Val)) 0 \ + _Complex_I)) Cfct (Val) \ : (sizeof (+__real__ (Val)) == sizeof (float)) \ ? (__typeof__ ((__tgmath_real_type (Val)) 0 \ + _Complex_I)) Cfct##f (Val) \ : __TGMATH_F128 (__real__ (Val), \ (__typeof__ \ ((__tgmath_real_type (Val)) 0 \ + _Complex_I)) Cfct, (Val)) \ (__typeof__ ((__tgmath_real_type (Val)) 0 \ + _Complex_I)) __tgml(Cfct) (Val))) /* XXX This definition has to be changed as soon as the compiler understands the imaginary keyword. */ # define __TGMATH_UNARY_REAL_IMAG_RET_REAL(Val, Fct, Cfct) \ (__extension__ ((sizeof (+__real__ (Val)) == sizeof (double) \ || __builtin_classify_type (__real__ (Val)) != 8) \ ? (__expr_is_real (Val) \ ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\ Fct (Val) \ : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\ Cfct (Val)) \ : (sizeof (+__real__ (Val)) == sizeof (float)) \ ? (__expr_is_real (Val) \ ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\ Fct##f (Val) \ : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0))\ Cfct##f (Val)) \ : __TGMATH_CF128 ((Val), \ (__typeof__ \ (__real__ \ (__tgmath_real_type (Val)) 0)) Fct, \ (__typeof__ \ (__real__ \ (__tgmath_real_type (Val)) 0)) Cfct, \ (Val)) \ (__expr_is_real (Val) \ ? (__typeof__ (__real__ (__tgmath_real_type (Val)) 0)) \ __tgml(Fct) (Val) \ : (__typeof__ (__real__ (__tgmath_real_type (Val)) 0)) \ __tgml(Cfct) (Val)))) # define __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME(Val, Cfct) \ __TGMATH_UNARY_REAL_IMAG_RET_REAL ((Val), Cfct, Cfct) # endif # if !__HAVE_BUILTIN_TGMATH_C2X /* XXX This definition has to be changed as soon as the compiler understands the imaginary keyword. */ # define __TGMATH_BINARY_REAL_IMAG(Val1, Val2, Fct, Cfct) \ (__extension__ ((sizeof (__real__ (Val1) \ + __real__ (Val2)) > sizeof (double) \ && __builtin_classify_type (__real__ (Val1) \ + __real__ (Val2)) == 8) \ ? __TGMATH_CF128 ((Val1) + (Val2), \ (__tgmath_complex_type2 (Val1, Val2)) \ Fct, \ (__tgmath_complex_type2 (Val1, Val2)) \ Cfct, \ (Val1, Val2)) \ (__expr_is_real ((Val1) + (Val2)) \ ? (__tgmath_complex_type2 (Val1, Val2)) \ __tgml(Fct) (Val1, Val2) \ : (__tgmath_complex_type2 (Val1, Val2)) \ __tgml(Cfct) (Val1, Val2)) \ : (sizeof (+__real__ (Val1)) == sizeof (double) \ || sizeof (+__real__ (Val2)) == sizeof (double) \ || __builtin_classify_type (__real__ (Val1)) != 8 \ || __builtin_classify_type (__real__ (Val2)) != 8) \ ? (__expr_is_real ((Val1) + (Val2)) \ ? (__tgmath_complex_type2 (Val1, Val2)) \ Fct (Val1, Val2) \ : (__tgmath_complex_type2 (Val1, Val2)) \ Cfct (Val1, Val2)) \ : (__expr_is_real ((Val1) + (Val2)) \ ? (__tgmath_complex_type2 (Val1, Val2)) \ Fct##f (Val1, Val2) \ : (__tgmath_complex_type2 (Val1, Val2)) \ Cfct##f (Val1, Val2)))) # endif # if !__HAVE_BUILTIN_TGMATH # define __TGMATH_2_NARROW_F(F, X, Y) \ (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ + (__tgmath_real_type (Y)) 0) > sizeof (double) \ ? F ## l (X, Y) \ : F (X, Y))) # endif /* In most cases, these narrowing macro definitions based on sizeof ensure that the function called has the right argument format, as for other <tgmath.h> macros for compilers before GCC 8, but may not have exactly the argument type (among the types with that format) specified in the standard logic. In the case of macros for _Float32x return type, when _Float64x exists, _Float64 arguments should result in the *f64 function being called while _Float32x, float and double arguments should result in the *f64x function being called (and integer arguments are considered to have type _Float32x if any argument has type _FloatNx, or double otherwise). These cases cannot be distinguished using sizeof (or at all if the types are typedefs rather than different types, in which case we err on the side of using the wider type if unsure). */ # if !__HAVE_BUILTIN_TGMATH_C2X # if __HAVE_FLOATN_NOT_TYPEDEF # define __TGMATH_NARROW_F32X_USE_F64X(X) \ !__builtin_types_compatible_p (__typeof (+(X)), _Float64) # else # define __TGMATH_NARROW_F32X_USE_F64X(X) \ (__builtin_types_compatible_p (__typeof (+(X)), double) \ || __builtin_types_compatible_p (__typeof (+(X)), float) \ || !__floating_type (__typeof (+(X)))) # endif # endif # if __HAVE_FLOAT64X_LONG_DOUBLE && __HAVE_DISTINCT_FLOAT128 # if !__HAVE_BUILTIN_TGMATH # define __TGMATH_2_NARROW_F32(F, X, Y) \ (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ + (__tgmath_real_type (Y)) 0) > sizeof (_Float64) \ ? __TGMATH_F128LD ((X) + (Y), F, (X, Y)) \ F ## f64x (X, Y) \ : F ## f64 (X, Y))) # define __TGMATH_2_NARROW_F64(F, X, Y) \ (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ + (__tgmath_real_type (Y)) 0) > sizeof (_Float64) \ ? __TGMATH_F128LD ((X) + (Y), F, (X, Y)) \ F ## f64x (X, Y) \ : F ## f128 (X, Y))) # endif # if !__HAVE_BUILTIN_TGMATH_C2X # define __TGMATH_2_NARROW_F32X(F, X, Y) \ (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ + (__tgmath_real_type (Y)) 0) > sizeof (_Float64) \ || __TGMATH_NARROW_F32X_USE_F64X ((X) + (Y)) \ ? __TGMATH_F128 ((X) + (Y), F, (X, Y)) \ F ## f64x (X, Y) \ : F ## f64 (X, Y))) # endif # elif __HAVE_FLOAT128 # if !__HAVE_BUILTIN_TGMATH # define __TGMATH_2_NARROW_F32(F, X, Y) \ (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ + (__tgmath_real_type (Y)) 0) > sizeof (_Float64) \ ? F ## f128 (X, Y) \ : F ## f64 (X, Y))) # define __TGMATH_2_NARROW_F64(F, X, Y) \ (F ## f128 (X, Y)) # endif # if !__HAVE_BUILTIN_TGMATH_C2X # define __TGMATH_2_NARROW_F32X(F, X, Y) \ (__extension__ (sizeof ((__tgmath_real_type (X)) 0 \ + (__tgmath_real_type (Y)) 0) > sizeof (_Float32x) \ || __TGMATH_NARROW_F32X_USE_F64X ((X) + (Y)) \ ? F ## f64x (X, Y) \ : F ## f64 (X, Y))) # endif # else # if !__HAVE_BUILTIN_TGMATH # define __TGMATH_2_NARROW_F32(F, X, Y) \ (F ## f64 (X, Y)) # endif # endif #else # error "Unsupported compiler; you cannot use <tgmath.h>" #endif /* Unary functions defined for real and complex values. */ /* Trigonometric functions. */ /* Arc cosine of X. */ #define acos(Val) __TGMATH_UNARY_REAL_IMAG (Val, acos, cacos) /* Arc sine of X. */ #define asin(Val) __TGMATH_UNARY_REAL_IMAG (Val, asin, casin) /* Arc tangent of X. */ #define atan(Val) __TGMATH_UNARY_REAL_IMAG (Val, atan, catan) /* Arc tangent of Y/X. */ #define atan2(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, atan2) /* Cosine of X. */ #define cos(Val) __TGMATH_UNARY_REAL_IMAG (Val, cos, ccos) /* Sine of X. */ #define sin(Val) __TGMATH_UNARY_REAL_IMAG (Val, sin, csin) /* Tangent of X. */ #define tan(Val) __TGMATH_UNARY_REAL_IMAG (Val, tan, ctan) /* Hyperbolic functions. */ /* Hyperbolic arc cosine of X. */ #define acosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, acosh, cacosh) /* Hyperbolic arc sine of X. */ #define asinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, asinh, casinh) /* Hyperbolic arc tangent of X. */ #define atanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, atanh, catanh) /* Hyperbolic cosine of X. */ #define cosh(Val) __TGMATH_UNARY_REAL_IMAG (Val, cosh, ccosh) /* Hyperbolic sine of X. */ #define sinh(Val) __TGMATH_UNARY_REAL_IMAG (Val, sinh, csinh) /* Hyperbolic tangent of X. */ #define tanh(Val) __TGMATH_UNARY_REAL_IMAG (Val, tanh, ctanh) /* Exponential and logarithmic functions. */ /* Exponential function of X. */ #define exp(Val) __TGMATH_UNARY_REAL_IMAG (Val, exp, cexp) /* Break VALUE into a normalized fraction and an integral power of 2. */ #define frexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, frexp) /* X times (two to the EXP power). */ #define ldexp(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, ldexp) /* Natural logarithm of X. */ #define log(Val) __TGMATH_UNARY_REAL_IMAG (Val, log, clog) /* Base-ten logarithm of X. */ #ifdef __USE_GNU # define log10(Val) __TGMATH_UNARY_REAL_IMAG (Val, log10, clog10) #else # define log10(Val) __TGMATH_UNARY_REAL_ONLY (Val, log10) #endif /* Return exp(X) - 1. */ #define expm1(Val) __TGMATH_UNARY_REAL_ONLY (Val, expm1) /* Return log(1 + X). */ #define log1p(Val) __TGMATH_UNARY_REAL_ONLY (Val, log1p) /* Return the base 2 signed integral exponent of X. */ #define logb(Val) __TGMATH_UNARY_REAL_ONLY (Val, logb) /* Compute base-2 exponential of X. */ #define exp2(Val) __TGMATH_UNARY_REAL_ONLY (Val, exp2) /* Compute base-2 logarithm of X. */ #define log2(Val) __TGMATH_UNARY_REAL_ONLY (Val, log2) /* Power functions. */ /* Return X to the Y power. */ #define pow(Val1, Val2) __TGMATH_BINARY_REAL_IMAG (Val1, Val2, pow, cpow) /* Return the square root of X. */ #define sqrt(Val) __TGMATH_UNARY_REAL_IMAG (Val, sqrt, csqrt) /* Return `sqrt(X*X + Y*Y)'. */ #define hypot(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, hypot) /* Return the cube root of X. */ #define cbrt(Val) __TGMATH_UNARY_REAL_ONLY (Val, cbrt) /* Nearest integer, absolute value, and remainder functions. */ /* Smallest integral value not less than X. */ #define ceil(Val) __TGMATH_UNARY_REAL_ONLY (Val, ceil) /* Absolute value of X. */ #define fabs(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL (Val, fabs, cabs) /* Largest integer not greater than X. */ #define floor(Val) __TGMATH_UNARY_REAL_ONLY (Val, floor) /* Floating-point modulo remainder of X/Y. */ #define fmod(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmod) /* Round X to integral valuein floating-point format using current rounding direction, but do not raise inexact exception. */ #define nearbyint(Val) __TGMATH_UNARY_REAL_ONLY (Val, nearbyint) /* Round X to nearest integral value, rounding halfway cases away from zero. */ #define round(Val) __TGMATH_UNARY_REAL_ONLY (Val, round) /* Round X to the integral value in floating-point format nearest but not larger in magnitude. */ #define trunc(Val) __TGMATH_UNARY_REAL_ONLY (Val, trunc) /* Compute remainder of X and Y and put in *QUO a value with sign of x/y and magnitude congruent `mod 2^n' to the magnitude of the integral quotient x/y, with n >= 3. */ #define remquo(Val1, Val2, Val3) \ __TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY (Val1, Val2, Val3, remquo) /* Round X to nearest integral value according to current rounding direction. */ #define lrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, lrint) #define llrint(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llrint) /* Round X to nearest integral value, rounding halfway cases away from zero. */ #define lround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, lround) #define llround(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llround) /* Return X with its signed changed to Y's. */ #define copysign(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, copysign) /* Error and gamma functions. */ #define erf(Val) __TGMATH_UNARY_REAL_ONLY (Val, erf) #define erfc(Val) __TGMATH_UNARY_REAL_ONLY (Val, erfc) #define tgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, tgamma) #define lgamma(Val) __TGMATH_UNARY_REAL_ONLY (Val, lgamma) /* Return the integer nearest X in the direction of the prevailing rounding mode. */ #define rint(Val) __TGMATH_UNARY_REAL_ONLY (Val, rint) #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) /* Return X - epsilon. */ # define nextdown(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextdown) /* Return X + epsilon. */ # define nextup(Val) __TGMATH_UNARY_REAL_ONLY (Val, nextup) #endif /* Return X + epsilon if X < Y, X - epsilon if X > Y. */ #define nextafter(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, nextafter) #define nexttoward(Val1, Val2) \ __TGMATH_BINARY_FIRST_REAL_STD_ONLY (Val1, Val2, nexttoward) /* Return the remainder of integer divison X / Y with infinite precision. */ #define remainder(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, remainder) /* Return X times (2 to the Nth power). */ #ifdef __USE_MISC # define scalb(Val1, Val2) __TGMATH_BINARY_REAL_STD_ONLY (Val1, Val2, scalb) #endif /* Return X times (2 to the Nth power). */ #define scalbn(Val1, Val2) __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbn) /* Return X times (2 to the Nth power). */ #define scalbln(Val1, Val2) \ __TGMATH_BINARY_FIRST_REAL_ONLY (Val1, Val2, scalbln) /* Return the binary exponent of X, which must be nonzero. */ #define ilogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, ilogb) /* Return positive difference between X and Y. */ #define fdim(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fdim) /* Return maximum numeric value from X and Y. */ #define fmax(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmax) /* Return minimum numeric value from X and Y. */ #define fmin(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmin) /* Multiply-add function computed as a ternary operation. */ #define fma(Val1, Val2, Val3) \ __TGMATH_TERNARY_REAL_ONLY (Val1, Val2, Val3, fma) #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) /* Round X to nearest integer value, rounding halfway cases to even. */ # define roundeven(Val) __TGMATH_UNARY_REAL_ONLY (Val, roundeven) # define fromfp(Val1, Val2, Val3) \ __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, fromfp) # define ufromfp(Val1, Val2, Val3) \ __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, ufromfp) # define fromfpx(Val1, Val2, Val3) \ __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, fromfpx) # define ufromfpx(Val1, Val2, Val3) \ __TGMATH_TERNARY_FIRST_REAL_RET_ONLY (Val1, Val2, Val3, ufromfpx) /* Like ilogb, but returning long int. */ # define llogb(Val) __TGMATH_UNARY_REAL_RET_ONLY (Val, llogb) /* Return value with maximum magnitude. */ # define fmaxmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmaxmag) /* Return value with minimum magnitude. */ # define fminmag(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fminmag) #endif /* Absolute value, conjugates, and projection. */ /* Argument value of Z. */ #define carg(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME (Val, carg) /* Complex conjugate of Z. */ #define conj(Val) __TGMATH_UNARY_IMAG (Val, conj) /* Projection of Z onto the Riemann sphere. */ #define cproj(Val) __TGMATH_UNARY_IMAG (Val, cproj) /* Decomposing complex values. */ /* Imaginary part of Z. */ #define cimag(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME (Val, cimag) /* Real part of Z. */ #define creal(Val) __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME (Val, creal) /* Narrowing functions. */ #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) /* Add. */ # define fadd(Val1, Val2) __TGMATH_2_NARROW_F (fadd, Val1, Val2) # define dadd(Val1, Val2) __TGMATH_2_NARROW_D (dadd, Val1, Val2) /* Divide. */ # define fdiv(Val1, Val2) __TGMATH_2_NARROW_F (fdiv, Val1, Val2) # define ddiv(Val1, Val2) __TGMATH_2_NARROW_D (ddiv, Val1, Val2) /* Multiply. */ # define fmul(Val1, Val2) __TGMATH_2_NARROW_F (fmul, Val1, Val2) # define dmul(Val1, Val2) __TGMATH_2_NARROW_D (dmul, Val1, Val2) /* Subtract. */ # define fsub(Val1, Val2) __TGMATH_2_NARROW_F (fsub, Val1, Val2) # define dsub(Val1, Val2) __TGMATH_2_NARROW_D (dsub, Val1, Val2) #endif #if __GLIBC_USE (IEC_60559_TYPES_EXT) # if __HAVE_FLOAT16 # define f16add(Val1, Val2) __TGMATH_2_NARROW_F16 (f16add, Val1, Val2) # define f16div(Val1, Val2) __TGMATH_2_NARROW_F16 (f16div, Val1, Val2) # define f16mul(Val1, Val2) __TGMATH_2_NARROW_F16 (f16mul, Val1, Val2) # define f16sub(Val1, Val2) __TGMATH_2_NARROW_F16 (f16sub, Val1, Val2) # endif # if __HAVE_FLOAT32 # define f32add(Val1, Val2) __TGMATH_2_NARROW_F32 (f32add, Val1, Val2) # define f32div(Val1, Val2) __TGMATH_2_NARROW_F32 (f32div, Val1, Val2) # define f32mul(Val1, Val2) __TGMATH_2_NARROW_F32 (f32mul, Val1, Val2) # define f32sub(Val1, Val2) __TGMATH_2_NARROW_F32 (f32sub, Val1, Val2) # endif # if __HAVE_FLOAT64 && (__HAVE_FLOAT64X || __HAVE_FLOAT128) # define f64add(Val1, Val2) __TGMATH_2_NARROW_F64 (f64add, Val1, Val2) # define f64div(Val1, Val2) __TGMATH_2_NARROW_F64 (f64div, Val1, Val2) # define f64mul(Val1, Val2) __TGMATH_2_NARROW_F64 (f64mul, Val1, Val2) # define f64sub(Val1, Val2) __TGMATH_2_NARROW_F64 (f64sub, Val1, Val2) # endif # if __HAVE_FLOAT32X # define f32xadd(Val1, Val2) __TGMATH_2_NARROW_F32X (f32xadd, Val1, Val2) # define f32xdiv(Val1, Val2) __TGMATH_2_NARROW_F32X (f32xdiv, Val1, Val2) # define f32xmul(Val1, Val2) __TGMATH_2_NARROW_F32X (f32xmul, Val1, Val2) # define f32xsub(Val1, Val2) __TGMATH_2_NARROW_F32X (f32xsub, Val1, Val2) # endif # if __HAVE_FLOAT64X && (__HAVE_FLOAT128X || __HAVE_FLOAT128) # define f64xadd(Val1, Val2) __TGMATH_2_NARROW_F64X (f64xadd, Val1, Val2) # define f64xdiv(Val1, Val2) __TGMATH_2_NARROW_F64X (f64xdiv, Val1, Val2) # define f64xmul(Val1, Val2) __TGMATH_2_NARROW_F64X (f64xmul, Val1, Val2) # define f64xsub(Val1, Val2) __TGMATH_2_NARROW_F64X (f64xsub, Val1, Val2) # endif #endif #endif /* tgmath.h */ /* Define ISO C stdio on top of C++ iostreams. Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* * ISO C99 Standard: 7.19 Input/output <stdio.h> */ #ifndef _STDIO_H #define _STDIO_H 1 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION #include <bits/libc-header-start.h> __BEGIN_DECLS #define __need_size_t #define __need_NULL #include <stddef.h> #define __need___va_list #include <stdarg.h> #include <bits/types.h> #include <bits/types/__fpos_t.h> #include <bits/types/__fpos64_t.h> #include <bits/types/__FILE.h> #include <bits/types/FILE.h> #include <bits/types/struct_FILE.h> #ifdef __USE_GNU # include <bits/types/cookie_io_functions_t.h> #endif #if defined __USE_XOPEN || defined __USE_XOPEN2K8 # ifdef __GNUC__ # ifndef _VA_LIST_DEFINED typedef __gnuc_va_list va_list; # define _VA_LIST_DEFINED # endif # else # include <stdarg.h> # endif #endif #if defined __USE_UNIX98 || defined __USE_XOPEN2K # ifndef __off_t_defined # ifndef __USE_FILE_OFFSET64 typedef __off_t off_t; # else typedef __off64_t off_t; # endif # define __off_t_defined # endif # if defined __USE_LARGEFILE64 && !defined __off64_t_defined typedef __off64_t off64_t; # define __off64_t_defined # endif #endif #ifdef __USE_XOPEN2K8 # ifndef __ssize_t_defined typedef __ssize_t ssize_t; # define __ssize_t_defined # endif #endif /* The type of the second argument to `fgetpos' and `fsetpos'. */ #ifndef __USE_FILE_OFFSET64 typedef __fpos_t fpos_t; #else typedef __fpos64_t fpos_t; #endif #ifdef __USE_LARGEFILE64 typedef __fpos64_t fpos64_t; #endif /* The possibilities for the third argument to `setvbuf'. */ #define _IOFBF 0 /* Fully buffered. */ #define _IOLBF 1 /* Line buffered. */ #define _IONBF 2 /* No buffering. */ /* Default buffer size. */ #define BUFSIZ 8192 /* The value returned by fgetc and similar functions to indicate the end of the file. */ #define EOF (-1) /* The possibilities for the third argument to `fseek'. These values should not be changed. */ #define SEEK_SET 0 /* Seek from beginning of file. */ #define SEEK_CUR 1 /* Seek from current position. */ #define SEEK_END 2 /* Seek from end of file. */ #ifdef __USE_GNU # define SEEK_DATA 3 /* Seek to next data. */ # define SEEK_HOLE 4 /* Seek to next hole. */ #endif #if defined __USE_MISC || defined __USE_XOPEN /* Default path prefix for `tempnam' and `tmpnam'. */ # define P_tmpdir "/tmp" #endif /* Get the values: L_tmpnam How long an array of chars must be to be passed to `tmpnam'. TMP_MAX The minimum number of unique filenames generated by tmpnam (and tempnam when it uses tmpnam's name space), or tempnam (the two are separate). L_ctermid How long an array to pass to `ctermid'. L_cuserid How long an array to pass to `cuserid'. FOPEN_MAX Minimum number of files that can be open at once. FILENAME_MAX Maximum length of a filename. */ #include <bits/stdio_lim.h> /* Standard streams. */ extern FILE *stdin; /* Standard input stream. */ extern FILE *stdout; /* Standard output stream. */ extern FILE *stderr; /* Standard error output stream. */ /* C89/C99 say they're macros. Make them happy. */ #define stdin stdin #define stdout stdout #define stderr stderr /* Remove file FILENAME. */ extern int remove (const char *__filename) __THROW; /* Rename file OLD to NEW. */ extern int rename (const char *__old, const char *__new) __THROW; #ifdef __USE_ATFILE /* Rename file OLD relative to OLDFD to NEW relative to NEWFD. */ extern int renameat (int __oldfd, const char *__old, int __newfd, const char *__new) __THROW; #endif #ifdef __USE_GNU /* Flags for renameat2. */ # define RENAME_NOREPLACE (1 << 0) # define RENAME_EXCHANGE (1 << 1) # define RENAME_WHITEOUT (1 << 2) /* Rename file OLD relative to OLDFD to NEW relative to NEWFD, with additional flags. */ extern int renameat2 (int __oldfd, const char *__old, int __newfd, const char *__new, unsigned int __flags) __THROW; #endif /* Close STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int fclose (FILE *__stream); #undef __attr_dealloc_fclose #define __attr_dealloc_fclose __attr_dealloc (fclose, 1) /* Create a temporary file and open it read/write. This function is a possible cancellation point and therefore not marked with __THROW. */ #ifndef __USE_FILE_OFFSET64 extern FILE *tmpfile (void) __attribute_malloc__ __attr_dealloc_fclose __wur; #else # ifdef __REDIRECT extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __attribute_malloc__ __attr_dealloc_fclose __wur; # else # define tmpfile tmpfile64 # endif #endif #ifdef __USE_LARGEFILE64 extern FILE *tmpfile64 (void) __attribute_malloc__ __attr_dealloc_fclose __wur; #endif /* Generate a temporary filename. */ extern char *tmpnam (char[L_tmpnam]) __THROW __wur; #ifdef __USE_MISC /* This is the reentrant variant of `tmpnam'. The only difference is that it does not allow S to be NULL. */ extern char *tmpnam_r (char __s[L_tmpnam]) __THROW __wur; #endif #if defined __USE_MISC || defined __USE_XOPEN /* Generate a unique temporary filename using up to five characters of PFX if it is not NULL. The directory to put this file in is searched for as follows: First the environment variable "TMPDIR" is checked. If it contains the name of a writable directory, that directory is used. If not and if DIR is not NULL, that value is checked. If that fails, P_tmpdir is tried and finally "/tmp". The storage for the filename is allocated by `malloc'. */ extern char *tempnam (const char *__dir, const char *__pfx) __THROW __attribute_malloc__ __wur __attr_dealloc_free; #endif /* Flush STREAM, or all streams if STREAM is NULL. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int fflush (FILE *__stream); #ifdef __USE_MISC /* Faster versions when locking is not required. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern int fflush_unlocked (FILE *__stream); #endif #ifdef __USE_GNU /* Close all streams. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern int fcloseall (void); #endif #ifndef __USE_FILE_OFFSET64 /* Open a file and create a new stream for it. This function is a possible cancellation point and therefore not marked with __THROW. */ extern FILE *fopen (const char *__restrict __filename, const char *__restrict __modes) __attribute_malloc__ __attr_dealloc_fclose __wur; /* Open a file, replacing an existing stream with it. This function is a possible cancellation point and therefore not marked with __THROW. */ extern FILE *freopen (const char *__restrict __filename, const char *__restrict __modes, FILE *__restrict __stream) __wur; #else # ifdef __REDIRECT extern FILE *__REDIRECT (fopen, (const char *__restrict __filename, const char *__restrict __modes), fopen64) __attribute_malloc__ __attr_dealloc_fclose __wur; extern FILE *__REDIRECT (freopen, (const char *__restrict __filename, const char *__restrict __modes, FILE *__restrict __stream), freopen64) __wur; # else # define fopen fopen64 # define freopen freopen64 # endif #endif #ifdef __USE_LARGEFILE64 extern FILE *fopen64 (const char *__restrict __filename, const char *__restrict __modes) __attribute_malloc__ __attr_dealloc_fclose __wur; extern FILE *freopen64 (const char *__restrict __filename, const char *__restrict __modes, FILE *__restrict __stream) __wur; #endif #ifdef __USE_POSIX /* Create a new stream that refers to an existing system file descriptor. */ extern FILE *fdopen (int __fd, const char *__modes) __THROW __attribute_malloc__ __attr_dealloc_fclose __wur; #endif #ifdef __USE_GNU /* Create a new stream that refers to the given magic cookie, and uses the given functions for input and output. */ extern FILE *fopencookie (void *__restrict __magic_cookie, const char *__restrict __modes, cookie_io_functions_t __io_funcs) __THROW __attribute_malloc__ __attr_dealloc_fclose __wur; #endif #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) /* Create a new stream that refers to a memory buffer. */ extern FILE *fmemopen (void *__s, size_t __len, const char *__modes) __THROW __attribute_malloc__ __attr_dealloc_fclose __wur; /* Open a stream that writes into a malloc'd buffer that is expanded as necessary. *BUFLOC and *SIZELOC are updated with the buffer's location and the number of characters written on fflush or fclose. */ extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __attribute_malloc__ __attr_dealloc_fclose __wur; #ifdef _WCHAR_H /* Like OPEN_MEMSTREAM, but the stream is wide oriented and produces a wide character string. Declared here only to add attribute malloc and only if <wchar.h> has been previously #included. */ extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW __attribute_malloc__ __attr_dealloc_fclose; # endif #endif /* If BUF is NULL, make STREAM unbuffered. Else make it use buffer BUF, of size BUFSIZ. */ extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __THROW; /* Make STREAM use buffering mode MODE. If BUF is not NULL, use N bytes of it for buffering; else allocate an internal buffer N bytes long. */ extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf, int __modes, size_t __n) __THROW; #ifdef __USE_MISC /* If BUF is NULL, make STREAM unbuffered. Else make it use SIZE bytes of BUF for buffering. */ extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf, size_t __size) __THROW; /* Make STREAM line-buffered. */ extern void setlinebuf (FILE *__stream) __THROW; #endif /* Write formatted output to STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int fprintf (FILE *__restrict __stream, const char *__restrict __format, ...); /* Write formatted output to stdout. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int printf (const char *__restrict __format, ...); /* Write formatted output to S. */ extern int sprintf (char *__restrict __s, const char *__restrict __format, ...) __THROWNL; /* Write formatted output to S from argument list ARG. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int vfprintf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg); /* Write formatted output to stdout from argument list ARG. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg); /* Write formatted output to S from argument list ARG. */ extern int vsprintf (char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __THROWNL; #if defined __USE_ISOC99 || defined __USE_UNIX98 /* Maximum chars of output to write in MAXLEN. */ extern int snprintf (char *__restrict __s, size_t __maxlen, const char *__restrict __format, ...) __THROWNL __attribute__ ((__format__ (__printf__, 3, 4))); extern int vsnprintf (char *__restrict __s, size_t __maxlen, const char *__restrict __format, __gnuc_va_list __arg) __THROWNL __attribute__ ((__format__ (__printf__, 3, 0))); #endif #if __GLIBC_USE (LIB_EXT2) /* Write formatted output to a string dynamically allocated with `malloc'. Store the address of the string in *PTR. */ extern int vasprintf (char **__restrict __ptr, const char *__restrict __f, __gnuc_va_list __arg) __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur; extern int __asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...) __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur; extern int asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...) __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur; #endif #ifdef __USE_XOPEN2K8 /* Write formatted output to a file descriptor. */ extern int vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __arg) __attribute__ ((__format__ (__printf__, 2, 0))); extern int dprintf (int __fd, const char *__restrict __fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); #endif /* Read formatted input from STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __wur; /* Read formatted input from stdin. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int scanf (const char *__restrict __format, ...) __wur; /* Read formatted input from S. */ extern int sscanf (const char *__restrict __s, const char *__restrict __format, ...) __THROW; /* For historical reasons, the C99-compliant versions of the scanf functions are at alternative names. When __LDBL_COMPAT or __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI are in effect, this is handled in bits/stdio-ldbl.h. */ #include <bits/floatn.h> #if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \ && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0 # ifdef __REDIRECT extern int __REDIRECT (fscanf, (FILE *__restrict __stream, const char *__restrict __format, ...), __isoc99_fscanf) __wur; extern int __REDIRECT (scanf, (const char *__restrict __format, ...), __isoc99_scanf) __wur; extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s, const char *__restrict __format, ...), __isoc99_sscanf); # else extern int __isoc99_fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __wur; extern int __isoc99_scanf (const char *__restrict __format, ...) __wur; extern int __isoc99_sscanf (const char *__restrict __s, const char *__restrict __format, ...) __THROW; # define fscanf __isoc99_fscanf # define scanf __isoc99_scanf # define sscanf __isoc99_sscanf # endif #endif #ifdef __USE_ISOC99 /* Read formatted input from S into argument list ARG. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __attribute__ ((__format__ (__scanf__, 2, 0))) __wur; /* Read formatted input from stdin into argument list ARG. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) __attribute__ ((__format__ (__scanf__, 1, 0))) __wur; /* Read formatted input from S into argument list ARG. */ extern int vsscanf (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __THROW __attribute__ ((__format__ (__scanf__, 2, 0))); /* Same redirection as above for the v*scanf family. */ # if !__GLIBC_USE (DEPRECATED_SCANF) # if defined __REDIRECT && !defined __LDBL_COMPAT \ && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0 extern int __REDIRECT (vfscanf, (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg), __isoc99_vfscanf) __attribute__ ((__format__ (__scanf__, 2, 0))) __wur; extern int __REDIRECT (vscanf, (const char *__restrict __format, __gnuc_va_list __arg), __isoc99_vscanf) __attribute__ ((__format__ (__scanf__, 1, 0))) __wur; extern int __REDIRECT_NTH (vsscanf, (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg), __isoc99_vsscanf) __attribute__ ((__format__ (__scanf__, 2, 0))); # elif !defined __REDIRECT extern int __isoc99_vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __wur; extern int __isoc99_vscanf (const char *__restrict __format, __gnuc_va_list __arg) __wur; extern int __isoc99_vsscanf (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __THROW; # define vfscanf __isoc99_vfscanf # define vscanf __isoc99_vscanf # define vsscanf __isoc99_vsscanf # endif # endif #endif /* Use ISO C9x. */ /* Read a character from STREAM. These functions are possible cancellation points and therefore not marked with __THROW. */ extern int fgetc (FILE *__stream); extern int getc (FILE *__stream); /* Read a character from stdin. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int getchar (void); #ifdef __USE_POSIX199506 /* These are defined in POSIX.1:1996. These functions are possible cancellation points and therefore not marked with __THROW. */ extern int getc_unlocked (FILE *__stream); extern int getchar_unlocked (void); #endif /* Use POSIX. */ #ifdef __USE_MISC /* Faster version when locking is not necessary. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern int fgetc_unlocked (FILE *__stream); #endif /* Use MISC. */ /* Write a character to STREAM. These functions are possible cancellation points and therefore not marked with __THROW. These functions is a possible cancellation point and therefore not marked with __THROW. */ extern int fputc (int __c, FILE *__stream); extern int putc (int __c, FILE *__stream); /* Write a character to stdout. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int putchar (int __c); #ifdef __USE_MISC /* Faster version when locking is not necessary. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern int fputc_unlocked (int __c, FILE *__stream); #endif /* Use MISC. */ #ifdef __USE_POSIX199506 /* These are defined in POSIX.1:1996. These functions are possible cancellation points and therefore not marked with __THROW. */ extern int putc_unlocked (int __c, FILE *__stream); extern int putchar_unlocked (int __c); #endif /* Use POSIX. */ #if defined __USE_MISC \ || (defined __USE_XOPEN && !defined __USE_XOPEN2K) /* Get a word (int) from STREAM. */ extern int getw (FILE *__stream); /* Write a word (int) to STREAM. */ extern int putw (int __w, FILE *__stream); #endif /* Get a newline-terminated string of finite length from STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream) __wur __fortified_attr_access (__write_only__, 1, 2); #if __GLIBC_USE (DEPRECATED_GETS) /* Get a newline-terminated string from stdin, removing the newline. This function is impossible to use safely. It has been officially removed from ISO C11 and ISO C++14, and we have also removed it from the _GNU_SOURCE feature list. It remains available when explicitly using an old ISO C, Unix, or POSIX standard. This function is a possible cancellation point and therefore not marked with __THROW. */ extern char *gets (char *__s) __wur __attribute_deprecated__; #endif #ifdef __USE_GNU /* This function does the same as `fgets' but does not lock the stream. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern char *fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream) __wur __fortified_attr_access (__write_only__, 1, 2); #endif #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2) /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR (and null-terminate it). *LINEPTR is a pointer returned from malloc (or NULL), pointing to *N characters of space. It is realloc'd as necessary. Returns the number of characters read (not including the null terminator), or -1 on error or EOF. These functions are not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation they are cancellation points and therefore not marked with __THROW. */ extern __ssize_t __getdelim (char **__restrict __lineptr, size_t *__restrict __n, int __delimiter, FILE *__restrict __stream) __wur; extern __ssize_t getdelim (char **__restrict __lineptr, size_t *__restrict __n, int __delimiter, FILE *__restrict __stream) __wur; /* Like `getdelim', but reads up to a newline. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern __ssize_t getline (char **__restrict __lineptr, size_t *__restrict __n, FILE *__restrict __stream) __wur; #endif /* Write a string to STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int fputs (const char *__restrict __s, FILE *__restrict __stream); /* Write a string, followed by a newline, to stdout. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int puts (const char *__s); /* Push a character back onto the input buffer of STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int ungetc (int __c, FILE *__stream); /* Read chunks of generic data from STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern size_t fread (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) __wur; /* Write chunks of generic data to STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern size_t fwrite (const void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __s); #ifdef __USE_GNU /* This function does the same as `fputs' but does not lock the stream. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern int fputs_unlocked (const char *__restrict __s, FILE *__restrict __stream); #endif #ifdef __USE_MISC /* Faster versions when locking is not necessary. These functions are not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation they are cancellation points and therefore not marked with __THROW. */ extern size_t fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) __wur; extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream); #endif /* Seek to a certain position on STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int fseek (FILE *__stream, long int __off, int __whence); /* Return the current position of STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern long int ftell (FILE *__stream) __wur; /* Rewind to the beginning of STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern void rewind (FILE *__stream); /* The Single Unix Specification, Version 2, specifies an alternative, more adequate interface for the two functions above which deal with file offset. `long int' is not the right type. These definitions are originally defined in the Large File Support API. */ #if defined __USE_LARGEFILE || defined __USE_XOPEN2K # ifndef __USE_FILE_OFFSET64 /* Seek to a certain position on STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int fseeko (FILE *__stream, __off_t __off, int __whence); /* Return the current position of STREAM. This function is a possible cancellation point and therefore not marked with __THROW. */ extern __off_t ftello (FILE *__stream) __wur; # else # ifdef __REDIRECT extern int __REDIRECT (fseeko, (FILE *__stream, __off64_t __off, int __whence), fseeko64); extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64); # else # define fseeko fseeko64 # define ftello ftello64 # endif # endif #endif #ifndef __USE_FILE_OFFSET64 /* Get STREAM's position. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos); /* Set STREAM's position. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int fsetpos (FILE *__stream, const fpos_t *__pos); #else # ifdef __REDIRECT extern int __REDIRECT (fgetpos, (FILE *__restrict __stream, fpos_t *__restrict __pos), fgetpos64); extern int __REDIRECT (fsetpos, (FILE *__stream, const fpos_t *__pos), fsetpos64); # else # define fgetpos fgetpos64 # define fsetpos fsetpos64 # endif #endif #ifdef __USE_LARGEFILE64 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence); extern __off64_t ftello64 (FILE *__stream) __wur; extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos); extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos); #endif /* Clear the error and EOF indicators for STREAM. */ extern void clearerr (FILE *__stream) __THROW; /* Return the EOF indicator for STREAM. */ extern int feof (FILE *__stream) __THROW __wur; /* Return the error indicator for STREAM. */ extern int ferror (FILE *__stream) __THROW __wur; #ifdef __USE_MISC /* Faster versions when locking is not required. */ extern void clearerr_unlocked (FILE *__stream) __THROW; extern int feof_unlocked (FILE *__stream) __THROW __wur; extern int ferror_unlocked (FILE *__stream) __THROW __wur; #endif /* Print a message describing the meaning of the value of errno. This function is a possible cancellation point and therefore not marked with __THROW. */ extern void perror (const char *__s); #ifdef __USE_POSIX /* Return the system file descriptor for STREAM. */ extern int fileno (FILE *__stream) __THROW __wur; #endif /* Use POSIX. */ #ifdef __USE_MISC /* Faster version when locking is not required. */ extern int fileno_unlocked (FILE *__stream) __THROW __wur; #endif #ifdef __USE_POSIX2 /* Close a stream opened by popen and return the status of its child. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int pclose (FILE *__stream); /* Create a new stream connected to a pipe running the given command. This function is a possible cancellation point and therefore not marked with __THROW. */ extern FILE *popen (const char *__command, const char *__modes) __attribute_malloc__ __attr_dealloc (pclose, 1) __wur; #endif #ifdef __USE_POSIX /* Return the name of the controlling terminal. */ extern char *ctermid (char *__s) __THROW __attr_access ((__write_only__, 1)); #endif /* Use POSIX. */ #if (defined __USE_XOPEN && !defined __USE_XOPEN2K) || defined __USE_GNU /* Return the name of the current user. */ extern char *cuserid (char *__s) __attr_access ((__write_only__, 1)); #endif /* Use X/Open, but not issue 6. */ #ifdef __USE_GNU struct obstack; /* See <obstack.h>. */ /* Write formatted output to an obstack. */ extern int obstack_printf (struct obstack *__restrict __obstack, const char *__restrict __format, ...) __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))); extern int obstack_vprintf (struct obstack *__restrict __obstack, const char *__restrict __format, __gnuc_va_list __args) __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))); #endif /* Use GNU. */ #ifdef __USE_POSIX199506 /* These are defined in POSIX.1:1996. */ /* Acquire ownership of STREAM. */ extern void flockfile (FILE *__stream) __THROW; /* Try to acquire ownership of STREAM but do not block if it is not possible. */ extern int ftrylockfile (FILE *__stream) __THROW __wur; /* Relinquish the ownership granted for STREAM. */ extern void funlockfile (FILE *__stream) __THROW; #endif /* POSIX */ #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU /* X/Open Issues 1-5 required getopt to be declared in this header. It was removed in Issue 6. GNU follows Issue 6. */ # include <bits/getopt_posix.h> #endif /* Slow-path routines used by the optimized inline functions in bits/stdio.h. */ extern int __uflow (FILE *); extern int __overflow (FILE *, int); #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function /* Declare all functions from bits/stdio2-decl.h first. */ # include <bits/stdio2-decl.h> #endif /* The following headers provide asm redirections. These redirections must appear before the first usage of these functions, e.g. in bits/stdio.h. */ #if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 # include <bits/stdio-ldbl.h> #endif /* If we are compiling with optimizing read this file. It contains several optimizing inline functions and macros. */ #ifdef __USE_EXTERN_INLINES # include <bits/stdio.h> #endif #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function /* Now include the function definitions and redirects too. */ # include <bits/stdio2.h> #endif __END_DECLS #endif /* <stdio.h> included. */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _NETROM_NETROM_H #define _NETROM_NETROM_H 1 #include <netax25/ax25.h> /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx. */ #define SOL_NETROM 259 /* NetRom control values: */ #define NETROM_T1 1 #define NETROM_T2 2 #define NETROM_N2 3 #define NETROM_PACLEN 5 #define NETROM_T4 6 #define NETROM_IDLE 7 #define NETROM_KILL 99 /* Type of route: */ #define NETROM_NEIGH 0 #define NETROM_NODE 1 struct nr_route_struct { int type; ax25_address callsign; char device[16]; unsigned int quality; char mnemonic[7]; ax25_address neighbour; unsigned int obs_count; unsigned int ndigis; ax25_address digipeaters[AX25_MAX_DIGIS]; }; /* NetRom socket ioctls: */ #define SIOCNRGETPARMS (SIOCPROTOPRIVATE+0) #define SIOCNRSETPARMS (SIOCPROTOPRIVATE+1) #define SIOCNRDECOBS (SIOCPROTOPRIVATE+2) #define SIOCNRRTCTL (SIOCPROTOPRIVATE+3) #define SIOCNRCTLCON (SIOCPROTOPRIVATE+4) /* NetRom parameter structure: */ struct nr_parms_struct { unsigned int quality; unsigned int obs_count; unsigned int ttl; unsigned int timeout; unsigned int ack_delay; unsigned int busy_delay; unsigned int tries; unsigned int window; unsigned int paclen; }; /* NetRom control structure: */ struct nr_ctl_struct { unsigned char index; unsigned char id; unsigned int cmd; unsigned long arg; }; #endif /* netrom/netrom.h */ /* Compatible <termio.h> for old `struct termio' ioctl interface. This is obsolete; use the POSIX.1 `struct termios' interface defined in <termios.h> instead. */ #include <termios.h> #include <sys/ioctl.h> /* Routines for dealing with '\0' separated environment vectors Copyright (C) 1995-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _ENVZ_H #define _ENVZ_H 1 #include <features.h> #include <errno.h> /* Envz's are argz's too, and should be created etc., using the same routines. */ #include <argz.h> __BEGIN_DECLS /* Returns a pointer to the entry in ENVZ for NAME, or 0 if there is none. */ extern char *envz_entry (const char *__restrict __envz, size_t __envz_len, const char *__restrict __name) __THROW __attribute_pure__; /* Returns a pointer to the value portion of the entry in ENVZ for NAME, or 0 if there is none. */ extern char *envz_get (const char *__restrict __envz, size_t __envz_len, const char *__restrict __name) __THROW __attribute_pure__; /* Adds an entry for NAME with value VALUE to ENVZ & ENVZ_LEN. If an entry with the same name already exists in ENVZ, it is removed. If VALUE is NULL, then the new entry will a special null one, for which envz_get will return NULL, although envz_entry will still return an entry; this is handy because when merging with another envz, the null entry can override an entry in the other one. Null entries can be removed with envz_strip (). */ extern error_t envz_add (char **__restrict __envz, size_t *__restrict __envz_len, const char *__restrict __name, const char *__restrict __value) __THROW; /* Adds each entry in ENVZ2 to ENVZ & ENVZ_LEN, as if with envz_add(). If OVERRIDE is true, then values in ENVZ2 will supersede those with the same name in ENV, otherwise not. */ extern error_t envz_merge (char **__restrict __envz, size_t *__restrict __envz_len, const char *__restrict __envz2, size_t __envz2_len, int __override) __THROW; /* Remove the entry for NAME from ENVZ & ENVZ_LEN, if any. */ extern void envz_remove (char **__restrict __envz, size_t *__restrict __envz_len, const char *__restrict __name) __THROW; /* Remove null entries. */ extern void envz_strip (char **__restrict __envz, size_t *__restrict __envz_len) __THROW; __END_DECLS #endif /* envz.h */ /* Definitions for Rose packet radio address family. Copyright (C) 1998-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* What follows is copied from the 2.1.93 <linux/rose.h>. */ #ifndef _NETROSE_ROSE_H #define _NETROSE_ROSE_H 1 #include <sys/socket.h> #include <netax25/ax25.h> /* Socket level values. */ #define SOL_ROSE 260 /* These are the public elements of the Linux kernel Rose implementation. For kernel AX.25 see the file ax25.h. This file requires ax25.h for the definition of the ax25_address structure. */ #define ROSE_MTU 251 #define ROSE_MAX_DIGIS 6 #define ROSE_DEFER 1 #define ROSE_T1 2 #define ROSE_T2 3 #define ROSE_T3 4 #define ROSE_IDLE 5 #define ROSE_QBITINCL 6 #define ROSE_HOLDBACK 7 #define SIOCRSGCAUSE (SIOCPROTOPRIVATE + 0) #define SIOCRSSCAUSE (SIOCPROTOPRIVATE + 1) #define SIOCRSL2CALL (SIOCPROTOPRIVATE + 2) #define SIOCRSSL2CALL (SIOCPROTOPRIVATE + 2) #define SIOCRSACCEPT (SIOCPROTOPRIVATE + 3) #define SIOCRSCLRRT (SIOCPROTOPRIVATE + 4) #define SIOCRSGL2CALL (SIOCPROTOPRIVATE + 5) #define SIOCRSGFACILITIES (SIOCPROTOPRIVATE + 6) #define ROSE_DTE_ORIGINATED 0x00 #define ROSE_NUMBER_BUSY 0x01 #define ROSE_INVALID_FACILITY 0x03 #define ROSE_NETWORK_CONGESTION 0x05 #define ROSE_OUT_OF_ORDER 0x09 #define ROSE_ACCESS_BARRED 0x0B #define ROSE_NOT_OBTAINABLE 0x0D #define ROSE_REMOTE_PROCEDURE 0x11 #define ROSE_LOCAL_PROCEDURE 0x13 #define ROSE_SHIP_ABSENT 0x39 typedef struct { char rose_addr[5]; } rose_address; struct sockaddr_rose { sa_family_t srose_family; rose_address srose_addr; ax25_address srose_call; int srose_ndigis; ax25_address srose_digi; }; struct full_sockaddr_rose { sa_family_t srose_family; rose_address srose_addr; ax25_address srose_call; unsigned int srose_ndigis; ax25_address srose_digis[ROSE_MAX_DIGIS]; }; struct rose_route_struct { rose_address address; unsigned short int mask; ax25_address neighbour; char device[16]; unsigned char ndigis; ax25_address digipeaters[AX25_MAX_DIGIS]; }; struct rose_cause_struct { unsigned char cause; unsigned char diagnostic; }; struct rose_facilities_struct { rose_address source_addr, dest_addr; ax25_address source_call, dest_call; unsigned char source_ndigis, dest_ndigis; ax25_address source_digis[ROSE_MAX_DIGIS]; ax25_address dest_digis[ROSE_MAX_DIGIS]; unsigned int rand; rose_address fail_addr; ax25_address fail_call; }; #endif /* netrose/rose.h */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _UTMPX_H #define _UTMPX_H 1 #include <features.h> #include <sys/time.h> /* Required according to Unix98. */ #ifndef __pid_t_defined typedef __pid_t pid_t; # define __pid_t_defined #endif /* Get system dependent values and data structures. */ #include <bits/utmpx.h> #ifdef __USE_GNU /* Compatibility names for the strings of the canonical file names. */ # define UTMPX_FILE _PATH_UTMPX # define UTMPX_FILENAME _PATH_UTMPX # define WTMPX_FILE _PATH_WTMPX # define WTMPX_FILENAME _PATH_WTMPX #endif /* For the getutmp{,x} functions we need the `struct utmp'. */ #ifdef __USE_GNU struct utmp; #endif __BEGIN_DECLS /* Open user accounting database. This function is a possible cancellation point and therefore not marked with __THROW. */ extern void setutxent (void); /* Close user accounting database. This function is a possible cancellation point and therefore not marked with __THROW. */ extern void endutxent (void); /* Get the next entry from the user accounting database. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct utmpx *getutxent (void); /* Get the user accounting database entry corresponding to ID. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct utmpx *getutxid (const struct utmpx *__id); /* Get the user accounting database entry corresponding to LINE. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct utmpx *getutxline (const struct utmpx *__line); /* Write the entry UTMPX into the user accounting database. This function is a possible cancellation point and therefore not marked with __THROW. */ extern struct utmpx *pututxline (const struct utmpx *__utmpx); #ifdef __USE_GNU /* Change name of the utmpx file to be examined. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern int utmpxname (const char *__file); /* Append entry UTMP to the wtmpx-like file WTMPX_FILE. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern void updwtmpx (const char *__wtmpx_file, const struct utmpx *__utmpx); /* Copy the information in UTMPX to UTMP. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern void getutmp (const struct utmpx *__utmpx, struct utmp *__utmp); /* Copy the information in UTMP to UTMPX. This function is not part of POSIX and therefore no official cancellation point. But due to similarity with an POSIX interface or due to the implementation it is a cancellation point and therefore not marked with __THROW. */ extern void getutmpx (const struct utmp *__utmp, struct utmpx *__utmpx); #endif __END_DECLS #endif /* utmpx.h */ /* Definitions for POSIX spawn interface. Copyright (C) 2000-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _SPAWN_H #define _SPAWN_H 1 #include <features.h> #include <sched.h> #include <sys/types.h> #include <bits/types/sigset_t.h> /* Data structure to contain attributes for thread creation. */ typedef struct { short int __flags; pid_t __pgrp; sigset_t __sd; sigset_t __ss; struct sched_param __sp; int __policy; int __pad[16]; } posix_spawnattr_t; /* Data structure to contain information about the actions to be performed in the new process with respect to file descriptors. */ typedef struct { int __allocated; int __used; struct __spawn_action *__actions; int __pad[16]; } posix_spawn_file_actions_t; /* Flags to be set in the `posix_spawnattr_t'. */ #define POSIX_SPAWN_RESETIDS 0x01 #define POSIX_SPAWN_SETPGROUP 0x02 #define POSIX_SPAWN_SETSIGDEF 0x04 #define POSIX_SPAWN_SETSIGMASK 0x08 #define POSIX_SPAWN_SETSCHEDPARAM 0x10 #define POSIX_SPAWN_SETSCHEDULER 0x20 #ifdef __USE_GNU # define POSIX_SPAWN_USEVFORK 0x40 # define POSIX_SPAWN_SETSID 0x80 #endif __BEGIN_DECLS /* Spawn a new process executing PATH with the attributes describes in *ATTRP. Before running the process perform the actions described in FILE-ACTIONS. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int posix_spawn (pid_t *__restrict __pid, const char *__restrict __path, const posix_spawn_file_actions_t *__restrict __file_actions, const posix_spawnattr_t *__restrict __attrp, char *const __argv[__restrict_arr], char *const __envp[__restrict_arr]) __nonnull ((2, 5)); /* Similar to `posix_spawn' but search for FILE in the PATH. This function is a possible cancellation point and therefore not marked with __THROW. */ extern int posix_spawnp (pid_t *__pid, const char *__file, const posix_spawn_file_actions_t *__file_actions, const posix_spawnattr_t *__attrp, char *const __argv[], char *const __envp[]) __nonnull ((2, 5)); /* Initialize data structure with attributes for `spawn' to default values. */ extern int posix_spawnattr_init (posix_spawnattr_t *__attr) __THROW __nonnull ((1)); /* Free resources associated with ATTR. */ extern int posix_spawnattr_destroy (posix_spawnattr_t *__attr) __THROW __nonnull ((1)); /* Store signal mask for signals with default handling from ATTR in SIGDEFAULT. */ extern int posix_spawnattr_getsigdefault (const posix_spawnattr_t * __restrict __attr, sigset_t *__restrict __sigdefault) __THROW __nonnull ((1, 2)); /* Set signal mask for signals with default handling in ATTR to SIGDEFAULT. */ extern int posix_spawnattr_setsigdefault (posix_spawnattr_t *__restrict __attr, const sigset_t *__restrict __sigdefault) __THROW __nonnull ((1, 2)); /* Store signal mask for the new process from ATTR in SIGMASK. */ extern int posix_spawnattr_getsigmask (const posix_spawnattr_t *__restrict __attr, sigset_t *__restrict __sigmask) __THROW __nonnull ((1, 2)); /* Set signal mask for the new process in ATTR to SIGMASK. */ extern int posix_spawnattr_setsigmask (posix_spawnattr_t *__restrict __attr, const sigset_t *__restrict __sigmask) __THROW __nonnull ((1, 2)); /* Get flag word from the attribute structure. */ extern int posix_spawnattr_getflags (const posix_spawnattr_t *__restrict __attr, short int *__restrict __flags) __THROW __nonnull ((1, 2)); /* Store flags in the attribute structure. */ extern int posix_spawnattr_setflags (posix_spawnattr_t *_attr, short int __flags) __THROW __nonnull ((1)); /* Get process group ID from the attribute structure. */ extern int posix_spawnattr_getpgroup (const posix_spawnattr_t *__restrict __attr, pid_t *__restrict __pgroup) __THROW __nonnull ((1, 2)); /* Store process group ID in the attribute structure. */ extern int posix_spawnattr_setpgroup (posix_spawnattr_t *__attr, pid_t __pgroup) __THROW __nonnull ((1)); /* Get scheduling policy from the attribute structure. */ extern int posix_spawnattr_getschedpolicy (const posix_spawnattr_t * __restrict __attr, int *__restrict __schedpolicy) __THROW __nonnull ((1, 2)); /* Store scheduling policy in the attribute structure. */ extern int posix_spawnattr_setschedpolicy (posix_spawnattr_t *__attr, int __schedpolicy) __THROW __nonnull ((1)); /* Get scheduling parameters from the attribute structure. */ extern int posix_spawnattr_getschedparam (const posix_spawnattr_t * __restrict __attr, struct sched_param *__restrict __schedparam) __THROW __nonnull ((1, 2)); /* Store scheduling parameters in the attribute structure. */ extern int posix_spawnattr_setschedparam (posix_spawnattr_t *__restrict __attr, const struct sched_param * __restrict __schedparam) __THROW __nonnull ((1, 2)); /* Initialize data structure for file attribute for `spawn' call. */ extern int posix_spawn_file_actions_init (posix_spawn_file_actions_t * __file_actions) __THROW __nonnull ((1)); /* Free resources associated with FILE-ACTIONS. */ extern int posix_spawn_file_actions_destroy (posix_spawn_file_actions_t * __file_actions) __THROW __nonnull ((1)); /* Add an action to FILE-ACTIONS which tells the implementation to call `open' for the given file during the `spawn' call. */ extern int posix_spawn_file_actions_addopen (posix_spawn_file_actions_t * __restrict __file_actions, int __fd, const char *__restrict __path, int __oflag, mode_t __mode) __THROW __nonnull ((1, 3)); /* Add an action to FILE-ACTIONS which tells the implementation to call `close' for the given file descriptor during the `spawn' call. */ extern int posix_spawn_file_actions_addclose (posix_spawn_file_actions_t * __file_actions, int __fd) __THROW __nonnull ((1)); /* Add an action to FILE-ACTIONS which tells the implementation to call `dup2' for the given file descriptors during the `spawn' call. */ extern int posix_spawn_file_actions_adddup2 (posix_spawn_file_actions_t * __file_actions, int __fd, int __newfd) __THROW __nonnull ((1)); #ifdef __USE_MISC /* Add an action changing the directory to PATH during spawn. This affects the subsequent file actions. */ extern int posix_spawn_file_actions_addchdir_np (posix_spawn_file_actions_t * __restrict __actions, const char *__restrict __path) __THROW __nonnull ((1, 2)); /* Add an action changing the directory to FD during spawn. This affects the subsequent file actions. FD is not duplicated and must be open when the file action is executed. */ extern int posix_spawn_file_actions_addfchdir_np (posix_spawn_file_actions_t *, int __fd) __THROW __nonnull ((1)); /* Add an action to close all file descriptor greater than or equal to FROM during spawn. This affects the subsequent file actions. */ extern int posix_spawn_file_actions_addclosefrom_np (posix_spawn_file_actions_t *, int __from) __THROW __nonnull ((1)); /* Add an action to set the process group of the forground process group associated with the terminal TCFD. */ extern int posix_spawn_file_actions_addtcsetpgrp_np (posix_spawn_file_actions_t *, int __tcfd) __THROW __nonnull ((1)); #endif /* __USE_MISC */ __END_DECLS #endif /* spawn.h */ /* pngconf.h - machine-configurable file for libpng * * libpng version 1.6.37 * * Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h * * Any machine specific code is near the front of this file, so if you * are configuring libpng for a machine, you may want to read the section * starting here down to where it starts to typedef png_color, png_text, * and png_info. */ #ifndef PNGCONF_H #define PNGCONF_H #ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ /* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C * compiler for correct compilation. The following header files are required by * the standard. If your compiler doesn't provide these header files, or they * do not match the standard, you will need to provide/improve them. */ #include <limits.h> #include <stddef.h> /* Library header files. These header files are all defined by ISOC90; libpng * expects conformant implementations, however, an ISOC90 conformant system need * not provide these header files if the functionality cannot be implemented. * In this case it will be necessary to disable the relevant parts of libpng in * the build of pnglibconf.h. * * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not * include this unnecessary header file. */ #ifdef PNG_STDIO_SUPPORTED /* Required for the definition of FILE: */ # include <stdio.h> #endif #ifdef PNG_SETJMP_SUPPORTED /* Required for the definition of jmp_buf and the declaration of longjmp: */ # include <setjmp.h> #endif #ifdef PNG_CONVERT_tIME_SUPPORTED /* Required for struct tm: */ # include <time.h> #endif #endif /* PNG_BUILDING_SYMBOL_TABLE */ /* Prior to 1.6.0, it was possible to turn off 'const' in declarations, * using PNG_NO_CONST. This is no longer supported. */ #define PNG_CONST const /* backward compatibility only */ /* This controls optimization of the reading of 16-bit and 32-bit * values from PNG files. It can be set on a per-app-file basis: it * just changes whether a macro is used when the function is called. * The library builder sets the default; if read functions are not * built into the library the macro implementation is forced on. */ #ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED # define PNG_USE_READ_MACROS #endif #if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) # if PNG_DEFAULT_READ_MACROS # define PNG_USE_READ_MACROS # endif #endif /* COMPILER SPECIFIC OPTIONS. * * These options are provided so that a variety of difficult compilers * can be used. Some are fixed at build time (e.g. PNG_API_RULE * below) but still have compiler specific implementations, others * may be changed on a per-file basis when compiling against libpng. */ /* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect * against legacy (pre ISOC90) compilers that did not understand function * prototypes. It is not required for modern C compilers. */ #ifndef PNGARG # define PNGARG(arglist) arglist #endif /* Function calling conventions. * ============================= * Normally it is not necessary to specify to the compiler how to call * a function - it just does it - however on x86 systems derived from * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems * and some others) there are multiple ways to call a function and the * default can be changed on the compiler command line. For this reason * libpng specifies the calling convention of every exported function and * every function called via a user supplied function pointer. This is * done in this file by defining the following macros: * * PNGAPI Calling convention for exported functions. * PNGCBAPI Calling convention for user provided (callback) functions. * PNGCAPI Calling convention used by the ANSI-C library (required * for longjmp callbacks and sometimes used internally to * specify the calling convention for zlib). * * These macros should never be overridden. If it is necessary to * change calling convention in a private build this can be done * by setting PNG_API_RULE (which defaults to 0) to one of the values * below to select the correct 'API' variants. * * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. * This is correct in every known environment. * PNG_API_RULE=1 Use the operating system convention for PNGAPI and * the 'C' calling convention (from PNGCAPI) for * callbacks (PNGCBAPI). This is no longer required * in any known environment - if it has to be used * please post an explanation of the problem to the * libpng mailing list. * * These cases only differ if the operating system does not use the C * calling convention, at present this just means the above cases * (x86 DOS/Windows systems) and, even then, this does not apply to * Cygwin running on those systems. * * Note that the value must be defined in pnglibconf.h so that what * the application uses to call the library matches the conventions * set when building the library. */ /* Symbol export * ============= * When building a shared library it is almost always necessary to tell * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' * is used to mark the symbols. On some systems these symbols can be * extracted at link time and need no special processing by the compiler, * on other systems the symbols are flagged by the compiler and just * the declaration requires a special tag applied (unfortunately) in a * compiler dependent way. Some systems can do either. * * A small number of older systems also require a symbol from a DLL to * be flagged to the program that calls it. This is a problem because * we do not know in the header file included by application code that * the symbol will come from a shared library, as opposed to a statically * linked one. For this reason the application must tell us by setting * the magic flag PNG_USE_DLL to turn on the special processing before * it includes png.h. * * Four additional macros are used to make this happen: * * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from * the build or imported if PNG_USE_DLL is set - compiler * and system specific. * * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to * 'type', compiler specific. * * PNG_DLL_EXPORT Set to the magic to use during a libpng build to * make a symbol exported from the DLL. Not used in the * public header files; see pngpriv.h for how it is used * in the libpng build. * * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come * from a DLL - used to define PNG_IMPEXP when * PNG_USE_DLL is set. */ /* System specific discovery. * ========================== * This code is used at build time to find PNG_IMPEXP, the API settings * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL * import processing is possible. On Windows systems it also sets * compiler-specific macros to the values required to change the calling * conventions of the various functions. */ #if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or * MinGW on any architecture currently supported by Windows. Also includes * Watcom builds but these need special treatment because they are not * compatible with GCC or Visual C because of different calling conventions. */ # if PNG_API_RULE == 2 /* If this line results in an error, either because __watcall is not * understood or because of a redefine just below you cannot use *this* * build of the library with the compiler you are using. *This* build was * build using Watcom and applications must also be built using Watcom! */ # define PNGCAPI __watcall # endif # if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) # define PNGCAPI __cdecl # if PNG_API_RULE == 1 /* If this line results in an error __stdcall is not understood and * PNG_API_RULE should not have been set to '1'. */ # define PNGAPI __stdcall # endif # else /* An older compiler, or one not detected (erroneously) above, * if necessary override on the command line to get the correct * variants for the compiler. */ # ifndef PNGCAPI # define PNGCAPI _cdecl # endif # if PNG_API_RULE == 1 && !defined(PNGAPI) # define PNGAPI _stdcall # endif # endif /* compiler/api */ /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) # error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed" # endif # if (defined(_MSC_VER) && _MSC_VER < 800) ||\ (defined(__BORLANDC__) && __BORLANDC__ < 0x500) /* older Borland and MSC * compilers used '__export' and required this to be after * the type. */ # ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP # endif # define PNG_DLL_EXPORT __export # else /* newer compiler */ # define PNG_DLL_EXPORT __declspec(dllexport) # ifndef PNG_DLL_IMPORT # define PNG_DLL_IMPORT __declspec(dllimport) # endif # endif /* compiler */ #else /* !Windows */ # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) # define PNGAPI _System # else /* !Windows/x86 && !OS/2 */ /* Use the defaults, or define PNG*API on the command line (but * this will have to be done for every compile!) */ # endif /* other system, !OS/2 */ #endif /* !Windows/x86 */ /* Now do all the defaulting . */ #ifndef PNGCAPI # define PNGCAPI #endif #ifndef PNGCBAPI # define PNGCBAPI PNGCAPI #endif #ifndef PNGAPI # define PNGAPI PNGCAPI #endif /* PNG_IMPEXP may be set on the compilation system command line or (if not set) * then in an internal header file when building the library, otherwise (when * using the library) it is set here. */ #ifndef PNG_IMPEXP # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) /* This forces use of a DLL, disallowing static linking */ # define PNG_IMPEXP PNG_DLL_IMPORT # endif # ifndef PNG_IMPEXP # define PNG_IMPEXP # endif #endif /* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat * 'attributes' as a storage class - the attributes go at the start of the * function definition, and attributes are always appended regardless of the * compiler. This considerably simplifies these macros but may cause problems * if any compilers both need function attributes and fail to handle them as * a storage class (this is unlikely.) */ #ifndef PNG_FUNCTION # define PNG_FUNCTION(type, name, args, attributes) attributes type name args #endif #ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) PNG_IMPEXP type #endif /* The ordinal value is only relevant when preprocessing png.h for symbol * table entries, so we discard it here. See the .dfn files in the * scripts directory. */ #ifndef PNG_EXPORTA # define PNG_EXPORTA(ordinal, type, name, args, attributes) \ PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \ PNG_LINKAGE_API attributes) #endif /* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, * so make something non-empty to satisfy the requirement: */ #define PNG_EMPTY /*empty list*/ #define PNG_EXPORT(ordinal, type, name, args) \ PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) /* Use PNG_REMOVED to comment out a removed interface. */ #ifndef PNG_REMOVED # define PNG_REMOVED(ordinal, type, name, args, attributes) #endif #ifndef PNG_CALLBACK # define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) #endif /* Support for compiler specific function attributes. These are used * so that where compiler support is available incorrect use of API * functions in png.h will generate compiler warnings. * * Added at libpng-1.2.41. */ #ifndef PNG_NO_PEDANTIC_WARNINGS # ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED # define PNG_PEDANTIC_WARNINGS_SUPPORTED # endif #endif #ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED /* Support for compiler specific function attributes. These are used * so that where compiler support is available, incorrect use of API * functions in png.h will generate compiler warnings. Added at libpng * version 1.2.41. Disabling these removes the warnings but may also produce * less efficient code. */ # if defined(__clang__) && defined(__has_attribute) /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */ # if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__) # define PNG_USE_RESULT __attribute__((__warn_unused_result__)) # endif # if !defined(PNG_NORETURN) && __has_attribute(__noreturn__) # define PNG_NORETURN __attribute__((__noreturn__)) # endif # if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__) # define PNG_ALLOCATED __attribute__((__malloc__)) # endif # if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__) # define PNG_DEPRECATED __attribute__((__deprecated__)) # endif # if !defined(PNG_PRIVATE) # ifdef __has_extension # if __has_extension(attribute_unavailable_with_message) # define PNG_PRIVATE __attribute__((__unavailable__(\ "This function is not exported by libpng."))) # endif # endif # endif # ifndef PNG_RESTRICT # define PNG_RESTRICT __restrict # endif # elif defined(__GNUC__) # ifndef PNG_USE_RESULT # define PNG_USE_RESULT __attribute__((__warn_unused_result__)) # endif # ifndef PNG_NORETURN # define PNG_NORETURN __attribute__((__noreturn__)) # endif # if __GNUC__ >= 3 # ifndef PNG_ALLOCATED # define PNG_ALLOCATED __attribute__((__malloc__)) # endif # ifndef PNG_DEPRECATED # define PNG_DEPRECATED __attribute__((__deprecated__)) # endif # ifndef PNG_PRIVATE # if 0 /* Doesn't work so we use deprecated instead*/ # define PNG_PRIVATE \ __attribute__((warning("This function is not exported by libpng."))) # else # define PNG_PRIVATE \ __attribute__((__deprecated__)) # endif # endif # if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1)) # ifndef PNG_RESTRICT # define PNG_RESTRICT __restrict # endif # endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */ # endif /* __GNUC__ >= 3 */ # elif defined(_MSC_VER) && (_MSC_VER >= 1300) # ifndef PNG_USE_RESULT # define PNG_USE_RESULT /* not supported */ # endif # ifndef PNG_NORETURN # define PNG_NORETURN __declspec(noreturn) # endif # ifndef PNG_ALLOCATED # if (_MSC_VER >= 1400) # define PNG_ALLOCATED __declspec(restrict) # endif # endif # ifndef PNG_DEPRECATED # define PNG_DEPRECATED __declspec(deprecated) # endif # ifndef PNG_PRIVATE # define PNG_PRIVATE __declspec(deprecated) # endif # ifndef PNG_RESTRICT # if (_MSC_VER >= 1400) # define PNG_RESTRICT __restrict # endif # endif # elif defined(__WATCOMC__) # ifndef PNG_RESTRICT # define PNG_RESTRICT __restrict # endif # endif #endif /* PNG_PEDANTIC_WARNINGS */ #ifndef PNG_DEPRECATED # define PNG_DEPRECATED /* Use of this function is deprecated */ #endif #ifndef PNG_USE_RESULT # define PNG_USE_RESULT /* The result of this function must be checked */ #endif #ifndef PNG_NORETURN # define PNG_NORETURN /* This function does not return */ #endif #ifndef PNG_ALLOCATED # define PNG_ALLOCATED /* The result of the function is new memory */ #endif #ifndef PNG_PRIVATE # define PNG_PRIVATE /* This is a private libpng function */ #endif #ifndef PNG_RESTRICT # define PNG_RESTRICT /* The C99 "restrict" feature */ #endif #ifndef PNG_FP_EXPORT /* A floating point API. */ # ifdef PNG_FLOATING_POINT_SUPPORTED # define PNG_FP_EXPORT(ordinal, type, name, args)\ PNG_EXPORT(ordinal, type, name, args); # else /* No floating point APIs */ # define PNG_FP_EXPORT(ordinal, type, name, args) # endif #endif #ifndef PNG_FIXED_EXPORT /* A fixed point API. */ # ifdef PNG_FIXED_POINT_SUPPORTED # define PNG_FIXED_EXPORT(ordinal, type, name, args)\ PNG_EXPORT(ordinal, type, name, args); # else /* No fixed point APIs */ # define PNG_FIXED_EXPORT(ordinal, type, name, args) # endif #endif #ifndef PNG_BUILDING_SYMBOL_TABLE /* Some typedefs to get us started. These should be safe on most of the common * platforms. * * png_uint_32 and png_int_32 may, currently, be larger than required to hold a * 32-bit value however this is not normally advisable. * * png_uint_16 and png_int_16 should always be two bytes in size - this is * verified at library build time. * * png_byte must always be one byte in size. * * The checks below use constants from limits.h, as defined by the ISOC90 * standard. */ #if CHAR_BIT == 8 && UCHAR_MAX == 255 typedef unsigned char png_byte; #else # error "libpng requires 8-bit bytes" #endif #if INT_MIN == -32768 && INT_MAX == 32767 typedef int png_int_16; #elif SHRT_MIN == -32768 && SHRT_MAX == 32767 typedef short png_int_16; #else # error "libpng requires a signed 16-bit type" #endif #if UINT_MAX == 65535 typedef unsigned int png_uint_16; #elif USHRT_MAX == 65535 typedef unsigned short png_uint_16; #else # error "libpng requires an unsigned 16-bit type" #endif #if INT_MIN < -2147483646 && INT_MAX > 2147483646 typedef int png_int_32; #elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 typedef long int png_int_32; #else # error "libpng requires a signed 32-bit (or more) type" #endif #if UINT_MAX > 4294967294U typedef unsigned int png_uint_32; #elif ULONG_MAX > 4294967294U typedef unsigned long int png_uint_32; #else # error "libpng requires an unsigned 32-bit (or more) type" #endif /* Prior to 1.6.0, it was possible to disable the use of size_t and ptrdiff_t. * From 1.6.0 onwards, an ISO C90 compiler, as well as a standard-compliant * behavior of sizeof and ptrdiff_t are required. * The legacy typedefs are provided here for backwards compatibility. */ typedef size_t png_size_t; typedef ptrdiff_t png_ptrdiff_t; /* libpng needs to know the maximum value of 'size_t' and this controls the * definition of png_alloc_size_t, below. This maximum value of size_t limits * but does not control the maximum allocations the library makes - there is * direct application control of this through png_set_user_limits(). */ #ifndef PNG_SMALL_SIZE_T /* Compiler specific tests for systems where size_t is known to be less than * 32 bits (some of these systems may no longer work because of the lack of * 'far' support; see above.) */ # if (defined(__TURBOC__) && !defined(__FLAT__)) ||\ (defined(_MSC_VER) && defined(MAXSEG_64K)) # define PNG_SMALL_SIZE_T # endif #endif /* png_alloc_size_t is guaranteed to be no smaller than size_t, and no smaller * than png_uint_32. Casts from size_t or png_uint_32 to png_alloc_size_t are * not necessary; in fact, it is recommended not to use them at all, so that * the compiler can complain when something turns out to be problematic. * * Casts in the other direction (from png_alloc_size_t to size_t or * png_uint_32) should be explicitly applied; however, we do not expect to * encounter practical situations that require such conversions. * * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than * 4294967295 - i.e. less than the maximum value of png_uint_32. */ #ifdef PNG_SMALL_SIZE_T typedef png_uint_32 png_alloc_size_t; #else typedef size_t png_alloc_size_t; #endif /* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler * implementations of Intel CPU specific support of user-mode segmented address * spaces, where 16-bit pointers address more than 65536 bytes of memory using * separate 'segment' registers. The implementation requires two different * types of pointer (only one of which includes the segment value.) * * If required this support is available in version 1.2 of libpng and may be * available in versions through 1.5, although the correctness of the code has * not been verified recently. */ /* Typedef for floating-point numbers that are converted to fixed-point with a * multiple of 100,000, e.g., gamma */ typedef png_int_32 png_fixed_point; /* Add typedefs for pointers */ typedef void * png_voidp; typedef const void * png_const_voidp; typedef png_byte * png_bytep; typedef const png_byte * png_const_bytep; typedef png_uint_32 * png_uint_32p; typedef const png_uint_32 * png_const_uint_32p; typedef png_int_32 * png_int_32p; typedef const png_int_32 * png_const_int_32p; typedef png_uint_16 * png_uint_16p; typedef const png_uint_16 * png_const_uint_16p; typedef png_int_16 * png_int_16p; typedef const png_int_16 * png_const_int_16p; typedef char * png_charp; typedef const char * png_const_charp; typedef png_fixed_point * png_fixed_point_p; typedef const png_fixed_point * png_const_fixed_point_p; typedef size_t * png_size_tp; typedef const size_t * png_const_size_tp; #ifdef PNG_STDIO_SUPPORTED typedef FILE * png_FILE_p; #endif #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double * png_doublep; typedef const double * png_const_doublep; #endif /* Pointers to pointers; i.e. arrays */ typedef png_byte * * png_bytepp; typedef png_uint_32 * * png_uint_32pp; typedef png_int_32 * * png_int_32pp; typedef png_uint_16 * * png_uint_16pp; typedef png_int_16 * * png_int_16pp; typedef const char * * png_const_charpp; typedef char * * png_charpp; typedef png_fixed_point * * png_fixed_point_pp; #ifdef PNG_FLOATING_POINT_SUPPORTED typedef double * * png_doublepp; #endif /* Pointers to pointers to pointers; i.e., pointer to array */ typedef char * * * png_charppp; #endif /* PNG_BUILDING_SYMBOL_TABLE */ #endif /* PNGCONF_H */ /* png.h - header file for PNG reference library * * libpng version 1.6.37 - April 14, 2019 * * Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. (See LICENSE, below.) * * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.97, January 1998, through 1.6.35, July 2018: * Glenn Randers-Pehrson * libpng versions 1.6.36, December 2018, through 1.6.37, April 2019: * Cosmin Truta * See also "Contributing Authors", below. */ /* * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE * ========================================= * * PNG Reference Library License version 2 * --------------------------------------- * * * Copyright (c) 1995-2019 The PNG Reference Library Authors. * * Copyright (c) 2018-2019 Cosmin Truta. * * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. * * Copyright (c) 1996-1997 Andreas Dilger. * * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * The software is supplied "as is", without warranty of any kind, * express or implied, including, without limitation, the warranties * of merchantability, fitness for a particular purpose, title, and * non-infringement. In no event shall the Copyright owners, or * anyone distributing the software, be liable for any damages or * other liability, whether in contract, tort or otherwise, arising * from, out of, or in connection with the software, or the use or * other dealings in the software, even if advised of the possibility * of such damage. * * Permission is hereby granted to use, copy, modify, and distribute * this software, or portions hereof, for any purpose, without fee, * subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you * must not claim that you wrote the original software. If you * use this software in a product, an acknowledgment in the product * documentation would be appreciated, but is not required. * * 2. Altered source versions must be plainly marked as such, and must * not be misrepresented as being the original software. * * 3. This Copyright notice may not be removed or altered from any * source or altered source distribution. * * * PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35) * ----------------------------------------------------------------------- * * libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are * derived from libpng-1.0.6, and are distributed according to the same * disclaimer and license as libpng-1.0.6 with the following individuals * added to the list of Contributing Authors: * * Simon-Pierre Cadieux * Eric S. Raymond * Mans Rullgard * Cosmin Truta * Gilles Vollant * James Yu * Mandar Sahastrabuddhe * Google Inc. * Vadim Barkov * * and with the following additions to the disclaimer: * * There is no warranty against interference with your enjoyment of * the library or against infringement. There is no warranty that our * efforts or the library will fulfill any of your particular purposes * or needs. This library is provided with all faults, and the entire * risk of satisfactory quality, performance, accuracy, and effort is * with the user. * * Some files in the "contrib" directory and some configure-generated * files that are distributed with libpng have other copyright owners, and * are released under other open source licenses. * * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from * libpng-0.96, and are distributed according to the same disclaimer and * license as libpng-0.96, with the following individuals added to the * list of Contributing Authors: * * Tom Lane * Glenn Randers-Pehrson * Willem van Schaik * * libpng versions 0.89, June 1996, through 0.96, May 1997, are * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, * and are distributed according to the same disclaimer and license as * libpng-0.88, with the following individuals added to the list of * Contributing Authors: * * John Bowler * Kevin Bracey * Sam Bushell * Magnus Holmgren * Greg Roelofs * Tom Tanner * * Some files in the "scripts" directory have other copyright owners, * but are released under this license. * * libpng versions 0.5, May 1995, through 0.88, January 1996, are * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * For the purposes of this copyright and license, "Contributing Authors" * is defined as the following set of individuals: * * Andreas Dilger * Dave Martindale * Guy Eric Schalnat * Paul Schmidt * Tim Wegner * * The PNG Reference Library is supplied "AS IS". The Contributing * Authors and Group 42, Inc. disclaim all warranties, expressed or * implied, including, without limitation, the warranties of * merchantability and of fitness for any purpose. The Contributing * Authors and Group 42, Inc. assume no liability for direct, indirect, * incidental, special, exemplary, or consequential damages, which may * result from the use of the PNG Reference Library, even if advised of * the possibility of such damage. * * Permission is hereby granted to use, copy, modify, and distribute this * source code, or portions hereof, for any purpose, without fee, subject * to the following restrictions: * * 1. The origin of this source code must not be misrepresented. * * 2. Altered versions must be plainly marked as such and must not * be misrepresented as being the original source. * * 3. This Copyright notice may not be removed or altered from any * source or altered source distribution. * * The Contributing Authors and Group 42, Inc. specifically permit, * without fee, and encourage the use of this source code as a component * to supporting the PNG file format in commercial products. If you use * this source code in a product, acknowledgment is not required but would * be appreciated. * * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE. * * TRADEMARK * ========= * * The name "libpng" has not been registered by the Copyright owners * as a trademark in any jurisdiction. However, because libpng has * been distributed and maintained world-wide, continually since 1995, * the Copyright owners claim "common-law trademark protection" in any * jurisdiction where common-law trademark is recognized. */ /* * A "png_get_copyright" function is available, for convenient use in "about" * boxes and the like: * * printf("%s", png_get_copyright(NULL)); * * Also, the PNG logo (in PNG format, of course) is supplied in the * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). */ /* * The contributing authors would like to thank all those who helped * with testing, bug fixes, and patience. This wouldn't have been * possible without all of you. * * Thanks to Frank J. T. Wojcik for helping with the documentation. */ /* Note about libpng version numbers: * * Due to various miscommunications, unforeseen code incompatibilities * and occasional factors outside the authors' control, version numbering * on the library has not always been consistent and straightforward. * The following table summarizes matters since version 0.89c, which was * the first widely used release: * * source png.h png.h shared-lib * version string int version * ------- ------ ----- ---------- * 0.89c "1.0 beta 3" 0.89 89 1.0.89 * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] * 0.97c 0.97 97 2.0.97 * 0.98 0.98 98 2.0.98 * 0.99 0.99 98 2.0.99 * 0.99a-m 0.99 99 2.0.99 * 1.00 1.00 100 2.1.0 [100 should be 10000] * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] * 1.0.1 png.h string is 10001 2.1.0 * 1.0.1a-e identical to the 10002 from here on, the shared library * 1.0.2 source version) 10002 is 2.V where V is the source code * 1.0.2a-b 10003 version, except as noted. * 1.0.3 10003 * 1.0.3a-d 10004 * 1.0.4 10004 * 1.0.4a-f 10005 * 1.0.5 (+ 2 patches) 10005 * 1.0.5a-d 10006 * 1.0.5e-r 10100 (not source compatible) * 1.0.5s-v 10006 (not binary compatible) * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) * 1.0.6d-f 10007 (still binary incompatible) * 1.0.6g 10007 * 1.0.6h 10007 10.6h (testing xy.z so-numbering) * 1.0.6i 10007 10.6i * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) * 1.0.7 1 10007 (still compatible) * ... * 1.0.69 10 10069 10.so.0.69[.0] * ... * 1.2.59 13 10259 12.so.0.59[.0] * ... * 1.4.20 14 10420 14.so.0.20[.0] * ... * 1.5.30 15 10530 15.so.15.30[.0] * ... * 1.6.37 16 10637 16.so.16.37[.0] * * Henceforth the source version will match the shared-library major and * minor numbers; the shared-library major version number will be used for * changes in backward compatibility, as it is intended. * The PNG_LIBPNG_VER macro, which is not used within libpng but is * available for applications, is an unsigned integer of the form XYYZZ * corresponding to the source version X.Y.Z (leading zeros in Y and Z). * Beta versions were given the previous public release number plus a * letter, until version 1.0.6j; from then on they were given the upcoming * public release number plus "betaNN" or "rcNN". * * Binary incompatibility exists only when applications make direct access * to the info_ptr or png_ptr members through png.h, and the compiled * application is loaded with a different version of the library. * * DLLNUM will change each time there are forward or backward changes * in binary compatibility (e.g., when a new feature is added). * * See libpng.txt or libpng.3 for more information. The PNG specification * is available as a W3C Recommendation and as an ISO/IEC Standard; see * <https://www.w3.org/TR/2003/REC-PNG-20031110/> */ #ifndef PNG_H #define PNG_H /* This is not the place to learn how to use libpng. The file libpng-manual.txt * describes how to use libpng, and the file example.c summarizes it * with some code on which to build. This file is useful for looking * at the actual function definitions and structure components. If that * file has been stripped from your copy of libpng, you can find it at * <http://www.libpng.org/pub/png/libpng-manual.txt> * * If you just need to read a PNG file and don't want to read the documentation * skip to the end of this file and read the section entitled 'simplified API'. */ /* Version information for png.h - this should match the version in png.c */ #define PNG_LIBPNG_VER_STRING "1.6.37" #define PNG_HEADER_VERSION_STRING " libpng version 1.6.37 - April 14, 2019\n" #define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_DLLNUM 16 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 6 #define PNG_LIBPNG_VER_RELEASE 37 /* This should be zero for a public release, or non-zero for a * development version. [Deprecated] */ #define PNG_LIBPNG_VER_BUILD 0 /* Release Status */ #define PNG_LIBPNG_BUILD_ALPHA 1 #define PNG_LIBPNG_BUILD_BETA 2 #define PNG_LIBPNG_BUILD_RC 3 #define PNG_LIBPNG_BUILD_STABLE 4 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 /* Release-Specific Flags */ #define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with PNG_LIBPNG_BUILD_STABLE only */ #define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_SPECIAL */ #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with PNG_LIBPNG_BUILD_PRIVATE */ #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE /* Careful here. At one time, Guy wanted to use 082, but that * would be octal. We must not include leading zeros. * Versions 0.7 through 1.0.0 were in the range 0 to 100 here * (only version 1.0.0 was mis-numbered 100 instead of 10000). * From version 1.0.1 it is: * XXYYZZ, where XX=major, YY=minor, ZZ=release */ #define PNG_LIBPNG_VER 10637 /* 1.6.37 */ /* Library configuration: these options cannot be changed after * the library has been built. */ #ifndef PNGLCONF_H /* If pnglibconf.h is missing, you can * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h */ # include "pnglibconf.h" #endif #ifndef PNG_VERSION_INFO_ONLY /* Machine specific configuration. */ # include "pngconf.h" #endif /* * Added at libpng-1.2.8 * * Ref MSDN: Private as priority over Special * VS_FF_PRIVATEBUILD File *was not* built using standard release * procedures. If this value is given, the StringFileInfo block must * contain a PrivateBuild string. * * VS_FF_SPECIALBUILD File *was* built by the original company using * standard release procedures but is a variation of the standard * file of the same version number. If this value is given, the * StringFileInfo block must contain a SpecialBuild string. */ #ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */ # define PNG_LIBPNG_BUILD_TYPE \ (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) #else # ifdef PNG_LIBPNG_SPECIALBUILD # define PNG_LIBPNG_BUILD_TYPE \ (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL) # else # define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE) # endif #endif #ifndef PNG_VERSION_INFO_ONLY /* Inhibit C++ name-mangling for libpng functions but not for system calls. */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* Version information for C files, stored in png.c. This had better match * the version above. */ #define png_libpng_ver png_get_header_ver(NULL) /* This file is arranged in several sections: * * 1. [omitted] * 2. Any configuration options that can be specified by for the application * code when it is built. (Build time configuration is in pnglibconf.h) * 3. Type definitions (base types are defined in pngconf.h), structure * definitions. * 4. Exported library functions. * 5. Simplified API. * 6. Implementation options. * * The library source code has additional files (principally pngpriv.h) that * allow configuration of the library. */ /* Section 1: [omitted] */ /* Section 2: run time configuration * See pnglibconf.h for build time configuration * * Run time configuration allows the application to choose between * implementations of certain arithmetic APIs. The default is set * at build time and recorded in pnglibconf.h, but it is safe to * override these (and only these) settings. Note that this won't * change what the library does, only application code, and the * settings can (and probably should) be made on a per-file basis * by setting the #defines before including png.h * * Use macros to read integers from PNG data or use the exported * functions? * PNG_USE_READ_MACROS: use the macros (see below) Note that * the macros evaluate their argument multiple times. * PNG_NO_USE_READ_MACROS: call the relevant library function. * * Use the alternative algorithm for compositing alpha samples that * does not use division? * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division' * algorithm. * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm. * * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is * false? * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error * APIs to png_warning. * Otherwise the calls are mapped to png_error. */ /* Section 3: type definitions, including structures and compile time * constants. * See pngconf.h for base types that vary by machine/system */ /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ typedef char* png_libpng_version_1_6_37; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * * png_struct is the cache of information used while reading or writing a single * PNG file. One of these is always required, although the simplified API * (below) hides the creation and destruction of it. */ typedef struct png_struct_def png_struct; typedef const png_struct * png_const_structp; typedef png_struct * png_structp; typedef png_struct * * png_structpp; /* png_info contains information read from or to be written to a PNG file. One * or more of these must exist while reading or creating a PNG file. The * information is not used by libpng during read but is used to control what * gets written when a PNG file is created. "png_get_" function calls read * information during read and "png_set_" functions calls write information * when creating a PNG. * been moved into a separate header file that is not accessible to * applications. Read libpng-manual.txt or libpng.3 for more info. */ typedef struct png_info_def png_info; typedef png_info * png_infop; typedef const png_info * png_const_infop; typedef png_info * * png_infopp; /* Types with names ending 'p' are pointer types. The corresponding types with * names ending 'rp' are identical pointer types except that the pointer is * marked 'restrict', which means that it is the only pointer to the object * passed to the function. Applications should not use the 'restrict' types; * it is always valid to pass 'p' to a pointer with a function argument of the * corresponding 'rp' type. Different compilers have different rules with * regard to type matching in the presence of 'restrict'. For backward * compatibility libpng callbacks never have 'restrict' in their parameters and, * consequentially, writing portable application code is extremely difficult if * an attempt is made to use 'restrict'. */ typedef png_struct * PNG_RESTRICT png_structrp; typedef const png_struct * PNG_RESTRICT png_const_structrp; typedef png_info * PNG_RESTRICT png_inforp; typedef const png_info * PNG_RESTRICT png_const_inforp; /* Three color definitions. The order of the red, green, and blue, (and the * exact size) is not important, although the size of the fields need to * be png_byte or png_uint_16 (as defined below). */ typedef struct png_color_struct { png_byte red; png_byte green; png_byte blue; } png_color; typedef png_color * png_colorp; typedef const png_color * png_const_colorp; typedef png_color * * png_colorpp; typedef struct png_color_16_struct { png_byte index; /* used for palette files */ png_uint_16 red; /* for use in red green blue files */ png_uint_16 green; png_uint_16 blue; png_uint_16 gray; /* for use in grayscale files */ } png_color_16; typedef png_color_16 * png_color_16p; typedef const png_color_16 * png_const_color_16p; typedef png_color_16 * * png_color_16pp; typedef struct png_color_8_struct { png_byte red; /* for use in red green blue files */ png_byte green; png_byte blue; png_byte gray; /* for use in grayscale files */ png_byte alpha; /* for alpha channel files */ } png_color_8; typedef png_color_8 * png_color_8p; typedef const png_color_8 * png_const_color_8p; typedef png_color_8 * * png_color_8pp; /* * The following two structures are used for the in-core representation * of sPLT chunks. */ typedef struct png_sPLT_entry_struct { png_uint_16 red; png_uint_16 green; png_uint_16 blue; png_uint_16 alpha; png_uint_16 frequency; } png_sPLT_entry; typedef png_sPLT_entry * png_sPLT_entryp; typedef const png_sPLT_entry * png_const_sPLT_entryp; typedef png_sPLT_entry * * png_sPLT_entrypp; /* When the depth of the sPLT palette is 8 bits, the color and alpha samples * occupy the LSB of their respective members, and the MSB of each member * is zero-filled. The frequency member always occupies the full 16 bits. */ typedef struct png_sPLT_struct { png_charp name; /* palette name */ png_byte depth; /* depth of palette samples */ png_sPLT_entryp entries; /* palette entries */ png_int_32 nentries; /* number of palette entries */ } png_sPLT_t; typedef png_sPLT_t * png_sPLT_tp; typedef const png_sPLT_t * png_const_sPLT_tp; typedef png_sPLT_t * * png_sPLT_tpp; #ifdef PNG_TEXT_SUPPORTED /* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, * and whether that contents is compressed or not. The "key" field * points to a regular zero-terminated C string. The "text" fields can be a * regular C string, an empty string, or a NULL pointer. * However, the structure returned by png_get_text() will always contain * the "text" field as a regular zero-terminated C string (possibly * empty), never a NULL pointer, so it can be safely used in printf() and * other string-handling functions. Note that the "itxt_length", "lang", and * "lang_key" members of the structure only exist when the library is built * with iTXt chunk support. Prior to libpng-1.4.0 the library was built by * default without iTXt support. Also note that when iTXt *is* supported, * the "lang" and "lang_key" fields contain NULL pointers when the * "compression" field contains * PNG_TEXT_COMPRESSION_NONE or * PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the * same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag" * which is always 0 or 1, or its "compression method" which is always 0. */ typedef struct png_text_struct { int compression; /* compression value: -1: tEXt, none 0: zTXt, deflate 1: iTXt, none 2: iTXt, deflate */ png_charp key; /* keyword, 1-79 character description of "text" */ png_charp text; /* comment, may be an empty string (ie "") or a NULL pointer */ size_t text_length; /* length of the text string */ size_t itxt_length; /* length of the itxt string */ png_charp lang; /* language code, 0-79 characters or a NULL pointer */ png_charp lang_key; /* keyword translated UTF-8 string, 0 or more chars or a NULL pointer */ } png_text; typedef png_text * png_textp; typedef const png_text * png_const_textp; typedef png_text * * png_textpp; #endif /* Supported compression types for text in PNG files (tEXt, and zTXt). * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ #define PNG_TEXT_COMPRESSION_NONE_WR -3 #define PNG_TEXT_COMPRESSION_zTXt_WR -2 #define PNG_TEXT_COMPRESSION_NONE -1 #define PNG_TEXT_COMPRESSION_zTXt 0 #define PNG_ITXT_COMPRESSION_NONE 1 #define PNG_ITXT_COMPRESSION_zTXt 2 #define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ /* png_time is a way to hold the time in an machine independent way. * Two conversions are provided, both from time_t and struct tm. There * is no portable way to convert to either of these structures, as far * as I know. If you know of a portable way, send it to me. As a side * note - PNG has always been Year 2000 compliant! */ typedef struct png_time_struct { png_uint_16 year; /* full year, as in, 1995 */ png_byte month; /* month of year, 1 - 12 */ png_byte day; /* day of month, 1 - 31 */ png_byte hour; /* hour of day, 0 - 23 */ png_byte minute; /* minute of hour, 0 - 59 */ png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ } png_time; typedef png_time * png_timep; typedef const png_time * png_const_timep; typedef png_time * * png_timepp; #if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) ||\ defined(PNG_USER_CHUNKS_SUPPORTED) /* png_unknown_chunk is a structure to hold queued chunks for which there is * no specific support. The idea is that we can use this to queue * up private chunks for output even though the library doesn't actually * know about their semantics. * * The data in the structure is set by libpng on read and used on write. */ typedef struct png_unknown_chunk_t { png_byte name[5]; /* Textual chunk name with '\0' terminator */ png_byte *data; /* Data, should not be modified on read! */ size_t size; /* On write 'location' must be set using the flag values listed below. * Notice that on read it is set by libpng however the values stored have * more bits set than are listed below. Always treat the value as a * bitmask. On write set only one bit - setting multiple bits may cause the * chunk to be written in multiple places. */ png_byte location; /* mode of operation at read time */ } png_unknown_chunk; typedef png_unknown_chunk * png_unknown_chunkp; typedef const png_unknown_chunk * png_const_unknown_chunkp; typedef png_unknown_chunk * * png_unknown_chunkpp; #endif /* Flag values for the unknown chunk location byte. */ #define PNG_HAVE_IHDR 0x01 #define PNG_HAVE_PLTE 0x02 #define PNG_AFTER_IDAT 0x08 /* Maximum positive integer used in PNG is (2^31)-1 */ #define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) #define PNG_UINT_32_MAX ((png_uint_32)(-1)) #define PNG_SIZE_MAX ((size_t)(-1)) /* These are constants for fixed point values encoded in the * PNG specification manner (x100000) */ #define PNG_FP_1 100000 #define PNG_FP_HALF 50000 #define PNG_FP_MAX ((png_fixed_point)0x7fffffffL) #define PNG_FP_MIN (-PNG_FP_MAX) /* These describe the color_type field in png_info. */ /* color type masks */ #define PNG_COLOR_MASK_PALETTE 1 #define PNG_COLOR_MASK_COLOR 2 #define PNG_COLOR_MASK_ALPHA 4 /* color types. Note that not all combinations are legal */ #define PNG_COLOR_TYPE_GRAY 0 #define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) #define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) #define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) #define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) /* aliases */ #define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA #define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA /* This is for compression type. PNG 1.0-1.2 only define the single type. */ #define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ #define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE /* This is for filter type. PNG 1.0-1.2 only define the single type. */ #define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ #define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ #define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE /* These are for the interlacing type. These values should NOT be changed. */ #define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ #define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ #define PNG_INTERLACE_LAST 2 /* Not a valid value */ /* These are for the oFFs chunk. These values should NOT be changed. */ #define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ #define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ #define PNG_OFFSET_LAST 2 /* Not a valid value */ /* These are for the pCAL chunk. These values should NOT be changed. */ #define PNG_EQUATION_LINEAR 0 /* Linear transformation */ #define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ #define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ #define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ #define PNG_EQUATION_LAST 4 /* Not a valid value */ /* These are for the sCAL chunk. These values should NOT be changed. */ #define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ #define PNG_SCALE_METER 1 /* meters per pixel */ #define PNG_SCALE_RADIAN 2 /* radians per pixel */ #define PNG_SCALE_LAST 3 /* Not a valid value */ /* These are for the pHYs chunk. These values should NOT be changed. */ #define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ #define PNG_RESOLUTION_METER 1 /* pixels/meter */ #define PNG_RESOLUTION_LAST 2 /* Not a valid value */ /* These are for the sRGB chunk. These values should NOT be changed. */ #define PNG_sRGB_INTENT_PERCEPTUAL 0 #define PNG_sRGB_INTENT_RELATIVE 1 #define PNG_sRGB_INTENT_SATURATION 2 #define PNG_sRGB_INTENT_ABSOLUTE 3 #define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ /* This is for text chunks */ #define PNG_KEYWORD_MAX_LENGTH 79 /* Maximum number of entries in PLTE/sPLT/tRNS arrays */ #define PNG_MAX_PALETTE_LENGTH 256 /* These determine if an ancillary chunk's data has been successfully read * from the PNG header, or if the application has filled in the corresponding * data in the info_struct to be written into the output file. The values * of the PNG_INFO_<chunk> defines should NOT be changed. */ #define PNG_INFO_gAMA 0x0001U #define PNG_INFO_sBIT 0x0002U #define PNG_INFO_cHRM 0x0004U #define PNG_INFO_PLTE 0x0008U #define PNG_INFO_tRNS 0x0010U #define PNG_INFO_bKGD 0x0020U #define PNG_INFO_hIST 0x0040U #define PNG_INFO_pHYs 0x0080U #define PNG_INFO_oFFs 0x0100U #define PNG_INFO_tIME 0x0200U #define PNG_INFO_pCAL 0x0400U #define PNG_INFO_sRGB 0x0800U /* GR-P, 0.96a */ #define PNG_INFO_iCCP 0x1000U /* ESR, 1.0.6 */ #define PNG_INFO_sPLT 0x2000U /* ESR, 1.0.6 */ #define PNG_INFO_sCAL 0x4000U /* ESR, 1.0.6 */ #define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */ #define PNG_INFO_eXIf 0x10000U /* GR-P, 1.6.31 */ /* This is used for the transformation routines, as some of them * change these values for the row. It also should enable using * the routines for other purposes. */ typedef struct png_row_info_struct { png_uint_32 width; /* width of row */ size_t rowbytes; /* number of bytes in row */ png_byte color_type; /* color type of row */ png_byte bit_depth; /* bit depth of row */ png_byte channels; /* number of channels (1, 2, 3, or 4) */ png_byte pixel_depth; /* bits per pixel (depth * channels) */ } png_row_info; typedef png_row_info * png_row_infop; typedef png_row_info * * png_row_infopp; /* These are the function types for the I/O functions and for the functions * that allow the user to override the default I/O functions with his or her * own. The png_error_ptr type should match that of user-supplied warning * and error functions, while the png_rw_ptr type should match that of the * user read/write data functions. Note that the 'write' function must not * modify the buffer it is passed. The 'read' function, on the other hand, is * expected to return the read data in the buffer. */ typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp)); typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, size_t)); typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp)); typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, int)); typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, int)); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop)); typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop)); /* The following callback receives png_uint_32 row_number, int pass for the * png_bytep data of the row. When transforming an interlaced image the * row number is the row number within the sub-image of the interlace pass, so * the value will increase to the height of the sub-image (not the full image) * then reset to 0 for the next pass. * * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to * find the output pixel (x,y) given an interlaced sub-image pixel * (row,col,pass). (See below for these macros.) */ typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep, png_uint_32, int)); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop, png_bytep)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, png_unknown_chunkp)); #endif #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED /* not used anywhere */ /* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */ #endif #ifdef PNG_SETJMP_SUPPORTED /* This must match the function definition in <setjmp.h>, and the application * must include this before png.h to obtain the definition of jmp_buf. The * function is required to be PNG_NORETURN, but this is not checked. If the * function does return the application will crash via an abort() or similar * system level call. * * If you get a warning here while building the library you may need to make * changes to ensure that pnglibconf.h records the calling convention used by * your compiler. This may be very difficult - try using a different compiler * to build the library! */ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); #endif /* Transform masks for the high-level interface */ #define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ #define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ #define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ #define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ #define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ #define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ #define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ #define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ #define PNG_TRANSFORM_BGR 0x0080 /* read and write */ #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ #define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */ /* Added to libpng-1.2.34 */ #define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER #define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ /* Added to libpng-1.4.0 */ #define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ /* Added to libpng-1.5.4 */ #define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ #if INT_MAX >= 0x8000 /* else this might break */ #define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ #endif /* Flags for MNG supported features */ #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 #define PNG_FLAG_MNG_FILTER_64 0x04 #define PNG_ALL_MNG_FEATURES 0x05 /* NOTE: prior to 1.5 these functions had no 'API' style declaration, * this allowed the zlib default functions to be used on Windows * platforms. In 1.5 the zlib default malloc (which just calls malloc and * ignores the first argument) should be completely compatible with the * following. */ typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, png_alloc_size_t)); typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp)); /* Section 4: exported functions * Here are the function definitions most commonly used. This is not * the place to find out how to use libpng. See libpng-manual.txt for the * full explanation, see example.c for the summary. This just provides * a simple one line description of the use of each function. * * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in * pngconf.h and in the *.dfn files in the scripts directory. * * PNG_EXPORT(ordinal, type, name, (args)); * * ordinal: ordinal that is used while building * *.def files. The ordinal value is only * relevant when preprocessing png.h with * the *.dfn files for building symbol table * entries, and are removed by pngconf.h. * type: return type of the function * name: function name * args: function arguments, with types * * When we wish to append attributes to a function prototype we use * the PNG_EXPORTA() macro instead. * * PNG_EXPORTA(ordinal, type, name, (args), attributes); * * ordinal, type, name, and args: same as in PNG_EXPORT(). * attributes: function attributes */ /* Returns the version number of the library */ PNG_EXPORT(1, png_uint_32, png_access_version_number, (void)); /* Tell lib we have already handled the first <num_bytes> magic bytes. * Handling more than 8 bytes from the beginning of the file is an error. */ PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes)); /* Check sig[start] through sig[start + num_to_check - 1] to see if it's a * PNG file. Returns zero if the supplied bytes match the 8-byte PNG * signature, and non-zero otherwise. Having num_to_check == 0 or * start > 7 will always fail (ie return non-zero). */ PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, size_t start, size_t num_to_check)); /* Simple signature checking function. This is the same as calling * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). */ #define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n)) /* Allocate and initialize png_ptr struct for reading, and any other memory. */ PNG_EXPORTA(4, png_structp, png_create_read_struct, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn), PNG_ALLOCATED); /* Allocate and initialize png_ptr struct for writing, and any other memory */ PNG_EXPORTA(5, png_structp, png_create_write_struct, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn), PNG_ALLOCATED); PNG_EXPORT(6, size_t, png_get_compression_buffer_size, (png_const_structrp png_ptr)); PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr, size_t size)); /* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp * match up. */ #ifdef PNG_SETJMP_SUPPORTED /* This function returns the jmp_buf built in to *png_ptr. It must be * supplied with an appropriate 'longjmp' function to use on that jmp_buf * unless the default error function is overridden in which case NULL is * acceptable. The size of the jmp_buf is checked against the actual size * allocated by the library - the call will return NULL on a mismatch * indicating an ABI mismatch. */ PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr, png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)); # define png_jmpbuf(png_ptr) \ (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf)))) #else # define png_jmpbuf(png_ptr) \ (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) #endif /* This function should be used by libpng applications in place of * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it * will use it; otherwise it will call PNG_ABORT(). This function was * added in libpng-1.5.0. */ PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val), PNG_NORETURN); #ifdef PNG_READ_SUPPORTED /* Reset the compression stream */ PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED); #endif /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ #ifdef PNG_USER_MEM_SUPPORTED PNG_EXPORTA(11, png_structp, png_create_read_struct_2, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), PNG_ALLOCATED); PNG_EXPORTA(12, png_structp, png_create_write_struct_2, (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), PNG_ALLOCATED); #endif /* Write the PNG file signature. */ PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr)); /* Write a PNG chunk - size, type, (optional) data, CRC. */ PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep chunk_name, png_const_bytep data, size_t length)); /* Write the start of a PNG chunk - length and chunk name. */ PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr, png_const_bytep chunk_name, png_uint_32 length)); /* Write the data of a PNG chunk started with png_write_chunk_start(). */ PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr, png_const_bytep data, size_t length)); /* Finish a chunk started with png_write_chunk_start() (includes CRC). */ PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr)); /* Allocate and initialize the info structure */ PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr), PNG_ALLOCATED); /* DEPRECATED: this function allowed init structures to be created using the * default allocation method (typically malloc). Use is deprecated in 1.6.0 and * the API will be removed in the future. */ PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr, size_t png_info_struct_size), PNG_DEPRECATED); /* Writes all the PNG information before the image. */ PNG_EXPORT(20, void, png_write_info_before_PLTE, (png_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(21, void, png_write_info, (png_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the information before the actual image data. */ PNG_EXPORT(22, void, png_read_info, (png_structrp png_ptr, png_inforp info_ptr)); #endif #ifdef PNG_TIME_RFC1123_SUPPORTED /* Convert to a US string format: there is no localization support in this * routine. The original implementation used a 29 character buffer in * png_struct, this will be removed in future versions. */ #if PNG_LIBPNG_VER < 10700 /* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */ PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr, png_const_timep ptime),PNG_DEPRECATED); #endif PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29], png_const_timep ptime)); #endif #ifdef PNG_CONVERT_tIME_SUPPORTED /* Convert from a struct tm to png_time */ PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, const struct tm * ttime)); /* Convert from time_t to png_time. Uses gmtime() */ PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime)); #endif /* CONVERT_tIME */ #ifdef PNG_READ_EXPAND_SUPPORTED /* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr)); PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr)); PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr)); PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr)); #endif #ifdef PNG_READ_EXPAND_16_SUPPORTED /* Expand to 16-bit channels, forces conversion of palette to RGB and expansion * of a tRNS chunk if present. */ PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr)); #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) /* Use blue, green, red order for pixels. */ PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr)); #endif #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED /* Expand the grayscale to 24-bit RGB if necessary. */ PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr)); #endif #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED /* Reduce RGB to grayscale. */ #define PNG_ERROR_ACTION_NONE 1 #define PNG_ERROR_ACTION_WARN 2 #define PNG_ERROR_ACTION_ERROR 3 #define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr, int error_action, double red, double green)) PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr, int error_action, png_fixed_point red, png_fixed_point green)) PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp png_ptr)); #endif #ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, png_colorp palette)); #endif #ifdef PNG_READ_ALPHA_MODE_SUPPORTED /* How the alpha channel is interpreted - this affects how the color channels * of a PNG file are returned to the calling application when an alpha channel, * or a tRNS chunk in a palette file, is present. * * This has no effect on the way pixels are written into a PNG output * datastream. The color samples in a PNG datastream are never premultiplied * with the alpha samples. * * The default is to return data according to the PNG specification: the alpha * channel is a linear measure of the contribution of the pixel to the * corresponding composited pixel, and the color channels are unassociated * (not premultiplied). The gamma encoded color channels must be scaled * according to the contribution and to do this it is necessary to undo * the encoding, scale the color values, perform the composition and re-encode * the values. This is the 'PNG' mode. * * The alternative is to 'associate' the alpha with the color information by * storing color channel values that have been scaled by the alpha. * image. These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes * (the latter being the two common names for associated alpha color channels). * * For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha * value is equal to the maximum value. * * The final choice is to gamma encode the alpha channel as well. This is * broken because, in practice, no implementation that uses this choice * correctly undoes the encoding before handling alpha composition. Use this * choice only if other serious errors in the software or hardware you use * mandate it; the typical serious error is for dark halos to appear around * opaque areas of the composited PNG image because of arithmetic overflow. * * The API function png_set_alpha_mode specifies which of these choices to use * with an enumerated 'mode' value and the gamma of the required output: */ #define PNG_ALPHA_PNG 0 /* according to the PNG standard */ #define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ #define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ #define PNG_ALPHA_PREMULTIPLIED 1 /* as above */ #define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ #define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode, double output_gamma)) PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr, int mode, png_fixed_point output_gamma)) #endif #if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) /* The output_gamma value is a screen gamma in libpng terminology: it expresses * how to decode the output values, not how they are encoded. */ #define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */ #define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */ #define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */ #define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */ #endif /* The following are examples of calls to png_set_alpha_mode to achieve the * required overall gamma correction and, where necessary, alpha * premultiplication. * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); * This is the default libpng handling of the alpha channel - it is not * pre-multiplied into the color components. In addition the call states * that the output is for a sRGB system and causes all PNG files without gAMA * chunks to be assumed to be encoded using sRGB. * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); * In this case the output is assumed to be something like an sRGB conformant * display preceded by a power-law lookup table of power 1.45. This is how * early Mac systems behaved. * * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR); * This is the classic Jim Blinn approach and will work in academic * environments where everything is done by the book. It has the shortcoming * of assuming that input PNG data with no gamma information is linear - this * is unlikely to be correct unless the PNG files where generated locally. * Most of the time the output precision will be so low as to show * significant banding in dark areas of the image. * * png_set_expand_16(pp); * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB); * This is a somewhat more realistic Jim Blinn inspired approach. PNG files * are assumed to have the sRGB encoding if not marked with a gamma value and * the output is always 16 bits per component. This permits accurate scaling * and processing of the data. If you know that your input PNG files were * generated locally you might need to replace PNG_DEFAULT_sRGB with the * correct value for your system. * * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB); * If you just need to composite the PNG image onto an existing background * and if you control the code that does this you can use the optimization * setting. In this case you just copy completely opaque pixels to the * output. For pixels that are not completely transparent (you just skip * those) you do the composition math using png_composite or png_composite_16 * below then encode the resultant 8-bit or 16-bit values to match the output * encoding. * * Other cases * If neither the PNG nor the standard linear encoding work for you because * of the software or hardware you use then you have a big problem. The PNG * case will probably result in halos around the image. The linear encoding * will probably result in a washed out, too bright, image (it's actually too * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably * substantially reduce the halos. Alternatively try: * * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB); * This option will also reduce the halos, but there will be slight dark * halos round the opaque parts of the image where the background is light. * In the OPTIMIZED mode the halos will be light halos where the background * is dark. Take your pick - the halos are unavoidable unless you can get * your hardware/software fixed! (The OPTIMIZED approach is slightly * faster.) * * When the default gamma of PNG files doesn't match the output gamma. * If you have PNG files with no gamma information png_set_alpha_mode allows * you to provide a default gamma, but it also sets the output gamma to the * matching value. If you know your PNG files have a gamma that doesn't * match the output you can take advantage of the fact that * png_set_alpha_mode always sets the output gamma but only sets the PNG * default if it is not already set: * * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); * The first call sets both the default and the output gamma values, the * second call overrides the output gamma without changing the default. This * is easier than achieving the same effect with png_set_gamma. You must use * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will * fire if more than one call to png_set_alpha_mode and png_set_background is * made in the same read operation, however multiple calls with PNG_ALPHA_PNG * are ignored. */ #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr)); #endif #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) /* Add a filler byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */ PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler, int flags)); /* The values of the PNG_FILLER_ defines should NOT be changed */ # define PNG_FILLER_BEFORE 0 # define PNG_FILLER_AFTER 1 /* Add an alpha byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */ PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr, png_uint_32 filler, int flags)); #endif /* READ_FILLER || WRITE_FILLER */ #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) /* Swap bytes in 16-bit depth files. */ PNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr)); #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) /* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ PNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr)); #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ defined(PNG_WRITE_PACKSWAP_SUPPORTED) /* Swap packing order of pixels in bytes. */ PNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr)); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) /* Converts files to legal bit depths. */ PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p true_bits)); #endif #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) /* Have the code handle the interlacing. Returns the number of passes. * MUST be called before png_read_update_info or png_start_read_image, * otherwise it will not have the desired effect. Note that it is still * necessary to call png_read_row or png_read_rows png_get_image_height * times for each pass. */ PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr)); #endif #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) /* Invert monochrome files */ PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr)); #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED /* Handle alpha and tRNS by replacing with a background color. Prior to * libpng-1.5.4 this API must not be called before the PNG file header has been * read. Doing so will result in unexpected behavior and possible warnings or * errors if the PNG file contains a bKGD chunk. */ PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma)) PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, png_fixed_point background_gamma)) #endif #ifdef PNG_READ_BACKGROUND_SUPPORTED # define PNG_BACKGROUND_GAMMA_UNKNOWN 0 # define PNG_BACKGROUND_GAMMA_SCREEN 1 # define PNG_BACKGROUND_GAMMA_FILE 2 # define PNG_BACKGROUND_GAMMA_UNIQUE 3 #endif #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED /* Scale a 16-bit depth file down to 8-bit, accurately. */ PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr)); #endif #ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_16_TO_8_SUPPORTED /* Name prior to 1.5.4 */ /* Strip the second byte of information from a 16-bit depth file. */ PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr)); #endif #ifdef PNG_READ_QUANTIZE_SUPPORTED /* Turn on quantizing, and reduce the palette to the number of colors * available. */ PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_const_uint_16p histogram, int full_quantize)); #endif #ifdef PNG_READ_GAMMA_SUPPORTED /* The threshold on gamma processing is configurable but hard-wired into the * library. The following is the floating point variant. */ #define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) /* Handle gamma correction. Screen_gamma=(display_exponent). * NOTE: this API simply sets the screen and file gamma values. It will * therefore override the value for gamma in a PNG file if it is called after * the file header has been read - use with care - call before reading the PNG * file for best results! * * These routines accept the same gamma values as png_set_alpha_mode (described * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either * API (floating point or fixed.) Notice, however, that the 'file_gamma' value * is the inverse of a 'screen gamma' value. */ PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr, double screen_gamma, double override_file_gamma)) PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr, png_fixed_point screen_gamma, png_fixed_point override_file_gamma)) #endif #ifdef PNG_WRITE_FLUSH_SUPPORTED /* Set how many lines between output flushes - 0 for no flushing */ PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows)); /* Flush the current PNG output buffer */ PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr)); #endif /* Optional update palette with requested transformations */ PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr)); /* Optional call to update the users info structure */ PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr, png_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read one or more rows of image data. */ PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); #endif #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read a row of data. */ PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row, png_bytep display_row)); #endif #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the whole image into memory at once. */ PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image)); #endif /* Write a row of image data */ PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr, png_const_bytep row)); /* Write a few rows of image data: (*row) is not written; however, the type * is declared as writeable to maintain compatibility with previous versions * of libpng and to allow the 'display_row' array from read_rows to be passed * unchanged to write_rows. */ PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row, png_uint_32 num_rows)); /* Write the image data */ PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image)); /* Write the end of the PNG file. */ PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr, png_inforp info_ptr)); #ifdef PNG_SEQUENTIAL_READ_SUPPORTED /* Read the end of the PNG file. */ PNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr)); #endif /* Free any memory associated with the png_info_struct */ PNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr, png_infopp info_ptr_ptr)); /* Free any memory associated with the png_struct and the png_info_structs */ PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); /* Free any memory associated with the png_struct and the png_info_structs */ PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); /* Set the libpng method of handling chunk CRC errors */ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action, int ancil_action)); /* Values for png_set_crc_action() say how to handle CRC errors in * ancillary and critical chunks, and whether to use the data contained * therein. Note that it is impossible to "discard" data in a critical * chunk. For versions prior to 0.90, the action was always error/quit, * whereas in version 0.90 and later, the action for CRC errors in ancillary * chunks is warn/discard. These values should NOT be changed. * * value action:critical action:ancillary */ #define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ #define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ #define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ #define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ #define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ #define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ #ifdef PNG_WRITE_SUPPORTED /* These functions give the user control over the scan-line filtering in * libpng and the compression methods used by zlib. These functions are * mainly useful for testing, as the defaults should work with most users. * Those users who are tight on memory or want faster performance at the * expense of compression can modify them. See the compression library * header file (zlib.h) for an explination of the compression functions. */ /* Set the filtering method(s) used by libpng. Currently, the only valid * value for "method" is 0. */ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, int filters)); #endif /* WRITE */ /* Flags for png_set_filter() to say which filters to use. The flags * are chosen so that they don't conflict with real filter types * below, in case they are supplied instead of the #defined constants. * These values should NOT be changed. */ #define PNG_NO_FILTERS 0x00 #define PNG_FILTER_NONE 0x08 #define PNG_FILTER_SUB 0x10 #define PNG_FILTER_UP 0x20 #define PNG_FILTER_AVG 0x40 #define PNG_FILTER_PAETH 0x80 #define PNG_FAST_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP) #define PNG_ALL_FILTERS (PNG_FAST_FILTERS | PNG_FILTER_AVG | PNG_FILTER_PAETH) /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. * These defines should NOT be changed. */ #define PNG_FILTER_VALUE_NONE 0 #define PNG_FILTER_VALUE_SUB 1 #define PNG_FILTER_VALUE_UP 2 #define PNG_FILTER_VALUE_AVG 3 #define PNG_FILTER_VALUE_PAETH 4 #define PNG_FILTER_VALUE_LAST 5 #ifdef PNG_WRITE_SUPPORTED #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */ PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr, int heuristic_method, int num_weights, png_const_doublep filter_weights, png_const_doublep filter_costs)) PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, (png_structrp png_ptr, int heuristic_method, int num_weights, png_const_fixed_point_p filter_weights, png_const_fixed_point_p filter_costs)) #endif /* WRITE_WEIGHTED_FILTER */ /* The following are no longer used and will be removed from libpng-1.7: */ #define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ #define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ #define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ #define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ /* Set the library compression level. Currently, valid values range from * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 * (0 - no compression, 9 - "maximal" compression). Note that tests have * shown that zlib compression levels 3-6 usually perform as well as level 9 * for PNG images, and do considerably fewer caclulations. In the future, * these values may not correspond directly to the zlib compression levels. */ #ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr, int level)); PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr, int mem_level)); PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr, int strategy)); /* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a * smaller value of window_bits if it can do so safely. */ PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr, int window_bits)); PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr, int method)); #endif /* WRITE_CUSTOMIZE_COMPRESSION */ #ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED /* Also set zlib parameters for compressing non-IDAT chunks */ PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr, int level)); PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr, int mem_level)); PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr, int strategy)); /* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a * smaller value of window_bits if it can do so safely. */ PNG_EXPORT(225, void, png_set_text_compression_window_bits, (png_structrp png_ptr, int window_bits)); PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr, int method)); #endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */ #endif /* WRITE */ /* These next functions are called for input/output, memory, and error * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, * and call standard C I/O routines such as fread(), fwrite(), and * fprintf(). These functions can be made to use other I/O routines * at run time for those applications that need to handle I/O in a * different manner by calling png_set_???_fn(). See libpng-manual.txt for * more information. */ #ifdef PNG_STDIO_SUPPORTED /* Initialize the input/output for the PNG file to the default functions. */ PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp)); #endif /* Replace the (error and abort), and warning functions with user * supplied functions. If no messages are to be printed you must still * write and use replacement functions. The replacement error_fn should * still do a longjmp to the last setjmp location if you are using this * method of error handling. If error_fn or warning_fn is NULL, the * default function will be used. */ PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); /* Return the user pointer associated with the error functions */ PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr)); /* Replace the default data output functions with a user supplied one(s). * If buffered output is not used, then output_flush_fn can be set to NULL. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time * output_flush_fn will be ignored (and thus can be NULL). * It is probably a mistake to use NULL for output_flush_fn if * write_data_fn is not also NULL unless you have built libpng with * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's * default flush function, which uses the standard *FILE structure, will * be used. */ PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); /* Replace the default data input function with a user supplied one. */ PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn)); /* Return the user pointer associated with the I/O functions */ PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr)); PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr, png_read_status_ptr read_row_fn)); PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr, png_write_status_ptr write_row_fn)); #ifdef PNG_USER_MEM_SUPPORTED /* Replace the default memory allocation functions with user supplied one(s). */ PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn)); /* Return the user pointer associated with the memory functions */ PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr, png_user_transform_ptr read_user_transform_fn)); #endif #ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr, png_user_transform_ptr write_user_transform_fn)); #endif #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels)); /* Return the user pointer associated with the user transform functions */ PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED /* Return information about the row currently being processed. Note that these * APIs do not fail but will return unexpected results if called outside a user * transform callback. Also note that when transforming an interlaced image the * row number is the row number within the sub-image of the interlace pass, so * the value will increase to the height of the sub-image (not the full image) * then reset to 0 for the next pass. * * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to * find the output pixel (x,y) given an interlaced sub-image pixel * (row,col,pass). (See below for these macros.) */ PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp)); PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp)); #endif #ifdef PNG_READ_USER_CHUNKS_SUPPORTED /* This callback is called only for *unknown* chunks. If * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known * chunks to be treated as unknown, however in this case the callback must do * any processing required by the chunk (e.g. by calling the appropriate * png_set_ APIs.) * * There is no write support - on write, by default, all the chunks in the * 'unknown' list are written in the specified position. * * The integer return from the callback function is interpreted thus: * * negative: An error occurred; png_chunk_error will be called. * zero: The chunk was not handled, the chunk will be saved. A critical * chunk will cause an error at this point unless it is to be saved. * positive: The chunk was handled, libpng will ignore/discard it. * * See "INTERACTION WITH USER CHUNK CALLBACKS" below for important notes about * how this behavior will change in libpng 1.7 */ PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); #endif #ifdef PNG_USER_CHUNKS_SUPPORTED PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr)); #endif #ifdef PNG_PROGRESSIVE_READ_SUPPORTED /* Sets the function callbacks for the push reader, and a pointer to a * user-defined structure available to the callback functions. */ PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr, png_voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); /* Returns the user pointer associated with the push read functions */ PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_const_structrp png_ptr)); /* Function to be called when data becomes available */ PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr, png_inforp info_ptr, png_bytep buffer, size_t buffer_size)); /* A function which may be called *only* within png_process_data to stop the * processing of any more data. The function returns the number of bytes * remaining, excluding any that libpng has cached internally. A subsequent * call to png_process_data must supply these bytes again. If the argument * 'save' is set to true the routine will first save all the pending data and * will always return 0. */ PNG_EXPORT(219, size_t, png_process_data_pause, (png_structrp, int save)); /* A function which may be called *only* outside (after) a call to * png_process_data. It returns the number of bytes of data to skip in the * input. Normally it will return 0, but if it returns a non-zero value the * application must skip than number of bytes of input data and pass the * following data to the next call to png_process_data. */ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp)); /* Function that combines rows. 'new_row' is a flag that should come from * the callback and be non-NULL if anything needs to be done; the library * stores its own version of the new data internally and ignores the passed * in value. */ PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr, png_bytep old_row, png_const_bytep new_row)); #endif /* PROGRESSIVE_READ */ PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Added at libpng version 1.4.0 */ PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Added at libpng version 1.2.4 */ PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED); /* Frees a pointer allocated by png_malloc() */ PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr)); /* Free data that was allocated internally */ PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 free_me, int num)); /* Reassign responsibility for freeing existing data, whether allocated * by libpng or by the application; this works on the png_info structure passed * in, it does not change the state for other png_info structures. * * It is unlikely that this function works correctly as of 1.6.0 and using it * may result either in memory leaks or double free of allocated data. */ PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr, png_inforp info_ptr, int freer, png_uint_32 mask)); /* Assignments for png_data_freer */ #define PNG_DESTROY_WILL_FREE_DATA 1 #define PNG_SET_WILL_FREE_DATA 1 #define PNG_USER_WILL_FREE_DATA 2 /* Flags for png_ptr->free_me and info_ptr->free_me */ #define PNG_FREE_HIST 0x0008U #define PNG_FREE_ICCP 0x0010U #define PNG_FREE_SPLT 0x0020U #define PNG_FREE_ROWS 0x0040U #define PNG_FREE_PCAL 0x0080U #define PNG_FREE_SCAL 0x0100U #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED # define PNG_FREE_UNKN 0x0200U #endif /* PNG_FREE_LIST 0x0400U removed in 1.6.0 because it is ignored */ #define PNG_FREE_PLTE 0x1000U #define PNG_FREE_TRNS 0x2000U #define PNG_FREE_TEXT 0x4000U #define PNG_FREE_EXIF 0x8000U /* Added at libpng-1.6.31 */ #define PNG_FREE_ALL 0xffffU #define PNG_FREE_MUL 0x4220U /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ #ifdef PNG_USER_MEM_SUPPORTED PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr, png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED); PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr, png_voidp ptr), PNG_DEPRECATED); #endif #ifdef PNG_ERROR_TEXT_SUPPORTED /* Fatal error in PNG image of libpng - can't continue */ PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr, png_const_charp error_message), PNG_NORETURN); /* The same, but the chunk name is prepended to the error string. */ PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr, png_const_charp error_message), PNG_NORETURN); #else /* Fatal error in PNG image of libpng - can't continue */ PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN); # define png_error(s1,s2) png_err(s1) # define png_chunk_error(s1,s2) png_err(s1) #endif #ifdef PNG_WARNINGS_SUPPORTED /* Non-fatal error in libpng. Can continue, but may have a problem. */ PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr, png_const_charp warning_message)); /* Non-fatal error in libpng, chunk name is prepended to message. */ PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr, png_const_charp warning_message)); #else # define png_warning(s1,s2) ((void)(s1)) # define png_chunk_warning(s1,s2) ((void)(s1)) #endif #ifdef PNG_BENIGN_ERRORS_SUPPORTED /* Benign error in libpng. Can continue, but may have a problem. * User can choose whether to handle as a fatal error or as a warning. */ PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr, png_const_charp warning_message)); #ifdef PNG_READ_SUPPORTED /* Same, chunk name is prepended to message (only during read) */ PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr, png_const_charp warning_message)); #endif PNG_EXPORT(109, void, png_set_benign_errors, (png_structrp png_ptr, int allowed)); #else # ifdef PNG_ALLOW_BENIGN_ERRORS # define png_benign_error png_warning # define png_chunk_benign_error png_chunk_warning # else # define png_benign_error png_error # define png_chunk_benign_error png_chunk_error # endif #endif /* The png_set_<chunk> functions are for storing values in the png_info_struct. * Similarly, the png_get_<chunk> calls are used to read values from the * png_info_struct, either storing the parameters in the passed variables, or * setting pointers into the png_info_struct where the data is stored. The * png_get_<chunk> functions return a non-zero value if the data was available * in info_ptr, or return zero and do not change any of the parameters if the * data was not available. * * These functions should be used instead of directly accessing png_info * to avoid problems with future changes in the size and internal layout of * png_info_struct. */ /* Returns "flag" if chunk data is valid in info_ptr. */ PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 flag)); /* Returns number of bytes needed to hold a transformed row. */ PNG_EXPORT(111, size_t, png_get_rowbytes, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_INFO_IMAGE_SUPPORTED /* Returns row_pointers, which is an array of pointers to scanlines that was * returned from png_read_png(). */ PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Set row_pointers, which is an array of pointers to scanlines for use * by png_write_png(). */ PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytepp row_pointers)); #endif /* Returns number of color channels in image. */ PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #ifdef PNG_EASY_ACCESS_SUPPORTED /* Returns image width in pixels. */ PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image height in pixels. */ PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image bit_depth. */ PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image color_type. */ PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image filter_type. */ PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image interlace_type. */ PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image compression_type. */ PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns image resolution in pixels per meter, from pHYs chunk data. */ PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, (png_const_structrp png_ptr, png_const_inforp info_ptr)); /* Returns pixel aspect ratio, computed from pHYs chunk data. */ PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, (png_const_structrp png_ptr, png_const_inforp info_ptr)) PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) /* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #endif /* EASY_ACCESS */ #ifdef PNG_READ_SUPPORTED /* Returns pointer to signature string read from PNG header */ PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr, png_const_inforp info_ptr)); #endif #ifdef PNG_bKGD_SUPPORTED PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr, png_inforp info_ptr, png_color_16p *background)); #endif #ifdef PNG_bKGD_SUPPORTED PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_16p background)); #endif #ifdef PNG_cHRM_SUPPORTED PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x, double *red_y, double *green_x, double *green_y, double *blue_x, double *blue_y)) PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z, double *green_X, double *green_Y, double *green_Z, double *blue_X, double *blue_Y, double *blue_Z)) PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_white_x, png_fixed_point *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y, png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point *int_blue_x, png_fixed_point *int_blue_y)) PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_red_X, png_fixed_point *int_red_Y, png_fixed_point *int_red_Z, png_fixed_point *int_green_X, png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, png_fixed_point *int_blue_Z)) #endif #ifdef PNG_cHRM_SUPPORTED PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr, png_inforp info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y)) PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr, png_inforp info_ptr, double red_X, double red_Y, double red_Z, double green_X, double green_Y, double green_Z, double blue_X, double blue_Y, double blue_Z)) PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y, png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, png_fixed_point int_blue_y)) PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, png_fixed_point int_red_Z, png_fixed_point int_green_X, png_fixed_point int_green_Y, png_fixed_point int_green_Z, png_fixed_point int_blue_X, png_fixed_point int_blue_Y, png_fixed_point int_blue_Z)) #endif #ifdef PNG_eXIf_SUPPORTED PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *exif)); PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep exif)); PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif)); PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 num_exif, png_bytep exif)); #endif #ifdef PNG_gAMA_SUPPORTED PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr, png_const_inforp info_ptr, double *file_gamma)) PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_fixed_point *int_file_gamma)) #endif #ifdef PNG_gAMA_SUPPORTED PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma)) PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, png_fixed_point int_file_gamma)) #endif #ifdef PNG_hIST_SUPPORTED PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_16p *hist)); PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_uint_16p hist)); #endif PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method)); PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_method, int compression_method, int filter_method)); #ifdef PNG_oFFs_SUPPORTED PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)); #endif #ifdef PNG_oFFs_SUPPORTED PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr, png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type)); #endif #ifdef PNG_pCAL_SUPPORTED PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr, png_inforp info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, png_charp *units, png_charpp *params)); #endif #ifdef PNG_pCAL_SUPPORTED PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_const_charp units, png_charpp params)); #endif #ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif #ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); #endif PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr, png_inforp info_ptr, png_colorp *palette, int *num_palette)); PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr, png_inforp info_ptr, png_const_colorp palette, int num_palette)); #ifdef PNG_sBIT_SUPPORTED PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr, png_inforp info_ptr, png_color_8p *sig_bit)); #endif #ifdef PNG_sBIT_SUPPORTED PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_color_8p sig_bit)); #endif #ifdef PNG_sRGB_SUPPORTED PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *file_srgb_intent)); #endif #ifdef PNG_sRGB_SUPPORTED PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)); PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)); #endif #ifdef PNG_iCCP_SUPPORTED PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr, png_inforp info_ptr, png_charpp name, int *compression_type, png_bytepp profile, png_uint_32 *proflen)); #endif #ifdef PNG_iCCP_SUPPORTED PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_charp name, int compression_type, png_const_bytep profile, png_uint_32 proflen)); #endif #ifdef PNG_sPLT_SUPPORTED PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr, png_inforp info_ptr, png_sPLT_tpp entries)); #endif #ifdef PNG_sPLT_SUPPORTED PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)); #endif #ifdef PNG_TEXT_SUPPORTED /* png_get_text also returns the number of text chunks in *num_text */ PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr, png_inforp info_ptr, png_textp *text_ptr, int *num_text)); #endif /* Note while png_set_text() will accept a structure whose text, * language, and translated keywords are NULL pointers, the structure * returned by png_get_text will always contain regular * zero-terminated C strings. They might be empty strings but * they will never be NULL pointers. */ #ifdef PNG_TEXT_SUPPORTED PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr, int num_text)); #endif #ifdef PNG_tIME_SUPPORTED PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr, png_inforp info_ptr, png_timep *mod_time)); #endif #ifdef PNG_tIME_SUPPORTED PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_timep mod_time)); #endif #ifdef PNG_tRNS_SUPPORTED PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)); #endif #ifdef PNG_tRNS_SUPPORTED PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color)); #endif #ifdef PNG_sCAL_SUPPORTED PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, double *width, double *height)) #if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ defined(PNG_FLOATING_POINT_SUPPORTED) /* NOTE: this API is currently implemented using floating point arithmetic, * consequently it can only be used on systems with floating point support. * In any case the range of values supported by png_fixed_point is small and it * is highly recommended that png_get_sCAL_s be used instead. */ PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_fixed_point *width, png_fixed_point *height)) #endif PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, png_charpp swidth, png_charpp sheight)); PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, double width, double height)) PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_fixed_point width, png_fixed_point height)) PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_const_charp swidth, png_const_charp sheight)); #endif /* sCAL */ #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED /* Provide the default handling for all unknown chunks or, optionally, for * specific unknown chunks. * * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was * ignored and the default was used, the per-chunk setting only had an effect on * write. If you wish to have chunk-specific handling on read in code that must * work on earlier versions you must use a user chunk callback to specify the * desired handling (keep or discard.) * * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The * parameter is interpreted as follows: * * READ: * PNG_HANDLE_CHUNK_AS_DEFAULT: * Known chunks: do normal libpng processing, do not keep the chunk (but * see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED) * Unknown chunks: for a specific chunk use the global default, when used * as the default discard the chunk data. * PNG_HANDLE_CHUNK_NEVER: * Discard the chunk data. * PNG_HANDLE_CHUNK_IF_SAFE: * Keep the chunk data if the chunk is not critical else raise a chunk * error. * PNG_HANDLE_CHUNK_ALWAYS: * Keep the chunk data. * * If the chunk data is saved it can be retrieved using png_get_unknown_chunks, * below. Notice that specifying "AS_DEFAULT" as a global default is equivalent * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks * it simply resets the behavior to the libpng default. * * INTERACTION WITH USER CHUNK CALLBACKS: * The per-chunk handling is always used when there is a png_user_chunk_ptr * callback and the callback returns 0; the chunk is then always stored *unless* * it is critical and the per-chunk setting is other than ALWAYS. Notice that * the global default is *not* used in this case. (In effect the per-chunk * value is incremented to at least IF_SAFE.) * * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and * per-chunk defaults will be honored. If you want to preserve the current * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE * as the default - if you don't do this libpng 1.6 will issue a warning. * * If you want unhandled unknown chunks to be discarded in libpng 1.6 and * earlier simply return '1' (handled). * * PNG_HANDLE_AS_UNKNOWN_SUPPORTED: * If this is *not* set known chunks will always be handled by libpng and * will never be stored in the unknown chunk list. Known chunks listed to * png_set_keep_unknown_chunks will have no effect. If it is set then known * chunks listed with a keep other than AS_DEFAULT will *never* be processed * by libpng, in addition critical chunks must either be processed by the * callback or saved. * * The IHDR and IEND chunks must not be listed. Because this turns off the * default handling for chunks that would otherwise be recognized the * behavior of libpng transformations may well become incorrect! * * WRITE: * When writing chunks the options only apply to the chunks specified by * png_set_unknown_chunks (below), libpng will *always* write known chunks * required by png_set_ calls and will always write the core critical chunks * (as required for PLTE). * * Each chunk in the png_set_unknown_chunks list is looked up in the * png_set_keep_unknown_chunks list to find the keep setting, this is then * interpreted as follows: * * PNG_HANDLE_CHUNK_AS_DEFAULT: * Write safe-to-copy chunks and write other chunks if the global * default is set to _ALWAYS, otherwise don't write this chunk. * PNG_HANDLE_CHUNK_NEVER: * Do not write the chunk. * PNG_HANDLE_CHUNK_IF_SAFE: * Write the chunk if it is safe-to-copy, otherwise do not write it. * PNG_HANDLE_CHUNK_ALWAYS: * Write the chunk. * * Note that the default behavior is effectively the opposite of the read case - * in read unknown chunks are not stored by default, in write they are written * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different * - on write the safe-to-copy bit is checked, on read the critical bit is * checked and on read if the chunk is critical an error will be raised. * * num_chunks: * =========== * If num_chunks is positive, then the "keep" parameter specifies the manner * for handling only those chunks appearing in the chunk_list array, * otherwise the chunk list array is ignored. * * If num_chunks is 0 the "keep" parameter specifies the default behavior for * unknown chunks, as described above. * * If num_chunks is negative, then the "keep" parameter specifies the manner * for handling all unknown chunks plus all chunks recognized by libpng * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to * be processed by libpng. */ #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, int keep, png_const_bytep chunk_list, int num_chunks)); #endif /* HANDLE_AS_UNKNOWN */ /* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned; * the result is therefore true (non-zero) if special handling is required, * false for the default handling. */ PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr, png_const_bytep chunk_name)); #endif /* SET_UNKNOWN_CHUNKS */ #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)); /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added * unknowns to the location currently stored in the png_struct. This is * invariably the wrong value on write. To fix this call the following API * for each chunk in the list with the correct location. If you know your * code won't be compiled on earlier versions you can rely on * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing * the correct thing. */ PNG_EXPORT(175, void, png_set_unknown_chunk_location, (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location)); PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr, png_inforp info_ptr, png_unknown_chunkpp entries)); #endif /* Png_free_data() will turn off the "valid" flag for anything it frees. * If you need to turn it off for a chunk that your application has freed, * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr, png_inforp info_ptr, int mask)); #ifdef PNG_INFO_IMAGE_SUPPORTED /* The "params" pointer is currently not used and is for future expansion. */ #ifdef PNG_SEQUENTIAL_READ_SUPPORTED PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)); #endif #ifdef PNG_WRITE_SUPPORTED PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)); #endif #endif PNG_EXPORT(180, png_const_charp, png_get_copyright, (png_const_structrp png_ptr)); PNG_EXPORT(181, png_const_charp, png_get_header_ver, (png_const_structrp png_ptr)); PNG_EXPORT(182, png_const_charp, png_get_header_version, (png_const_structrp png_ptr)); PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, (png_const_structrp png_ptr)); #ifdef PNG_MNG_FEATURES_SUPPORTED PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr, png_uint_32 mng_features_permitted)); #endif /* For use in png_set_keep_unknown, added to version 1.2.6 */ #define PNG_HANDLE_CHUNK_AS_DEFAULT 0 #define PNG_HANDLE_CHUNK_NEVER 1 #define PNG_HANDLE_CHUNK_IF_SAFE 2 #define PNG_HANDLE_CHUNK_ALWAYS 3 #define PNG_HANDLE_CHUNK_LAST 4 /* Strip the prepended error numbers ("#nnn ") from error and warning * messages before passing them to the error or warning handler. */ #ifdef PNG_ERROR_NUMBERS_SUPPORTED PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr, png_uint_32 strip_mode)); #endif /* Added in libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED PNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max)); PNG_EXPORT(187, png_uint_32, png_get_user_width_max, (png_const_structrp png_ptr)); PNG_EXPORT(188, png_uint_32, png_get_user_height_max, (png_const_structrp png_ptr)); /* Added in libpng-1.4.0 */ PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)); PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, (png_const_structrp png_ptr)); /* Added in libpng-1.4.1 */ PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr, png_alloc_size_t user_chunk_cache_max)); PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max, (png_const_structrp png_ptr)); #endif #if defined(PNG_INCH_CONVERSIONS_SUPPORTED) PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, (png_const_structrp png_ptr, png_const_inforp info_ptr)); PNG_FP_EXPORT(196, float, png_get_x_offset_inches, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #endif PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, (png_const_structrp png_ptr, png_const_inforp info_ptr)) #endif # ifdef PNG_pHYs_SUPPORTED PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); # endif /* pHYs */ #endif /* INCH_CONVERSIONS */ /* Added in libpng-1.4.0 */ #ifdef PNG_IO_STATE_SUPPORTED PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr)); /* Removed from libpng 1.6; use png_get_io_chunk_type. */ PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr), PNG_DEPRECATED) PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, (png_const_structrp png_ptr)); /* The flags returned by png_get_io_state() are the following: */ # define PNG_IO_NONE 0x0000 /* no I/O at this moment */ # define PNG_IO_READING 0x0001 /* currently reading */ # define PNG_IO_WRITING 0x0002 /* currently writing */ # define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ # define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ # define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ # define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ # define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ # define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ #endif /* IO_STATE */ /* Interlace support. The following macros are always defined so that if * libpng interlace handling is turned off the macros may be used to handle * interlaced images within the application. */ #define PNG_INTERLACE_ADAM7_PASSES 7 /* Two macros to return the first row and first column of the original, * full, image which appears in a given pass. 'pass' is in the range 0 * to 6 and the result is in the range 0 to 7. */ #define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7) #define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7) /* A macro to return the offset between pixels in the output row for a pair of * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that * follows. Note that ROW_OFFSET is the offset from one row to the next whereas * COL_OFFSET is from one column to the next, within a row. */ #define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8) #define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1)) /* Two macros to help evaluate the number of rows or columns in each * pass. This is expressed as a shift - effectively log2 of the number or * rows or columns in each 8x8 tile of the original image. */ #define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) #define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) /* Hence two macros to determine the number of rows or columns in a given * pass of an image given its height or width. In fact these macros may * return non-zero even though the sub-image is empty, because the other * dimension may be empty for a small image. */ #define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\ -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass)) #define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\ -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass)) /* For the reader row callbacks (both progressive and sequential) it is * necessary to find the row in the output image given a row in an interlaced * image, so two more macros: */ #define PNG_ROW_FROM_PASS_ROW(y_in, pass) \ (((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass)) #define PNG_COL_FROM_PASS_COL(x_in, pass) \ (((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass)) /* Two macros which return a boolean (0 or 1) saying whether the given row * or column is in a particular pass. These use a common utility macro that * returns a mask for a given pass - the offset 'off' selects the row or * column version. The mask has the appropriate bit set for each column in * the tile. */ #define PNG_PASS_MASK(pass,off) ( \ ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \ ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0)) #define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) #define PNG_COL_IN_INTERLACE_PASS(x, pass) \ ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on * most machines. However, it does take more operations than the corresponding * divide method, so it may be slower on a few RISC systems. There are two * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. * * Note that the rounding factors are NOT supposed to be the same! 128 and * 32768 are correct for the NODIV code; 127 and 32767 are correct for the * standard method. * * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] */ /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ # define png_composite(composite, fg, alpha, bg) \ { \ png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ * (png_uint_16)(alpha) \ + (png_uint_16)(bg)*(png_uint_16)(255 \ - (png_uint_16)(alpha)) + 128); \ (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); \ } # define png_composite_16(composite, fg, alpha, bg) \ { \ png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ * (png_uint_32)(alpha) \ + (png_uint_32)(bg)*(65535 \ - (png_uint_32)(alpha)) + 32768); \ (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \ } #else /* Standard method using integer division */ # define png_composite(composite, fg, alpha, bg) \ (composite) = \ (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \ (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ 127) / 255)) # define png_composite_16(composite, fg, alpha, bg) \ (composite) = \ (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \ (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ 32767) / 65535)) #endif /* READ_COMPOSITE_NODIV */ #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf)); PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf)); PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf)); #endif PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr, png_const_bytep buf)); /* No png_get_int_16 -- may be added if there's a real need for it. */ /* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i)); #endif #ifdef PNG_SAVE_INT_32_SUPPORTED PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i)); #endif /* Place a 16-bit number into a buffer in PNG byte order. * The parameter is declared unsigned int, not png_uint_16, * just to avoid potential problems on pre-ANSI C compilers. */ #ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); /* No png_save_int_16 -- may be added if there's a real need for it. */ #endif #ifdef PNG_USE_READ_MACROS /* Inline macros to do direct reads of bytes from the input buffer. * The png_get_int_32() routine assumes we are using two's complement * format for negative values, which is almost certainly true. */ # define PNG_get_uint_32(buf) \ (((png_uint_32)(*(buf)) << 24) + \ ((png_uint_32)(*((buf) + 1)) << 16) + \ ((png_uint_32)(*((buf) + 2)) << 8) + \ ((png_uint_32)(*((buf) + 3)))) /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the * function) incorrectly returned a value of type png_uint_32. */ # define PNG_get_uint_16(buf) \ ((png_uint_16) \ (((unsigned int)(*(buf)) << 8) + \ ((unsigned int)(*((buf) + 1))))) # define PNG_get_int_32(buf) \ ((png_int_32)((*(buf) & 0x80) \ ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \ : (png_int_32)png_get_uint_32(buf))) /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, * but defining a macro name prefixed with PNG_PREFIX. */ # ifndef PNG_PREFIX # define png_get_uint_32(buf) PNG_get_uint_32(buf) # define png_get_uint_16(buf) PNG_get_uint_16(buf) # define png_get_int_32(buf) PNG_get_int_32(buf) # endif #else # ifdef PNG_PREFIX /* No macros; revert to the (redefined) function */ # define PNG_get_uint_32 (png_get_uint_32) # define PNG_get_uint_16 (png_get_uint_16) # define PNG_get_int_32 (png_get_int_32) # endif #endif #ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED PNG_EXPORT(242, void, png_set_check_for_invalid_index, (png_structrp png_ptr, int allowed)); # ifdef PNG_GET_PALETTE_MAX_SUPPORTED PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, png_const_infop info_ptr)); # endif #endif /* CHECK_FOR_INVALID_INDEX */ /******************************************************************************* * Section 5: SIMPLIFIED API ******************************************************************************* * * Please read the documentation in libpng-manual.txt (TODO: write said * documentation) if you don't understand what follows. * * The simplified API hides the details of both libpng and the PNG file format * itself. It allows PNG files to be read into a very limited number of * in-memory bitmap formats or to be written from the same formats. If these * formats do not accommodate your needs then you can, and should, use the more * sophisticated APIs above - these support a wide variety of in-memory formats * and a wide variety of sophisticated transformations to those formats as well * as a wide variety of APIs to manipulate ancillary information. * * To read a PNG file using the simplified API: * * 1) Declare a 'png_image' structure (see below) on the stack, set the * version field to PNG_IMAGE_VERSION and the 'opaque' pointer to NULL * (this is REQUIRED, your program may crash if you don't do it.) * 2) Call the appropriate png_image_begin_read... function. * 3) Set the png_image 'format' member to the required sample format. * 4) Allocate a buffer for the image and, if required, the color-map. * 5) Call png_image_finish_read to read the image and, if required, the * color-map into your buffers. * * There are no restrictions on the format of the PNG input itself; all valid * color types, bit depths, and interlace methods are acceptable, and the * input image is transformed as necessary to the requested in-memory format * during the png_image_finish_read() step. The only caveat is that if you * request a color-mapped image from a PNG that is full-color or makes * complex use of an alpha channel the transformation is extremely lossy and the * result may look terrible. * * To write a PNG file using the simplified API: * * 1) Declare a 'png_image' structure on the stack and memset() it to all zero. * 2) Initialize the members of the structure that describe the image, setting * the 'format' member to the format of the image samples. * 3) Call the appropriate png_image_write... function with a pointer to the * image and, if necessary, the color-map to write the PNG data. * * png_image is a structure that describes the in-memory format of an image * when it is being read or defines the in-memory format of an image that you * need to write: */ #if defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \ defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) #define PNG_IMAGE_VERSION 1 typedef struct png_control *png_controlp; typedef struct { png_controlp opaque; /* Initialize to NULL, free with png_image_free */ png_uint_32 version; /* Set to PNG_IMAGE_VERSION */ png_uint_32 width; /* Image width in pixels (columns) */ png_uint_32 height; /* Image height in pixels (rows) */ png_uint_32 format; /* Image format as defined below */ png_uint_32 flags; /* A bit mask containing informational flags */ png_uint_32 colormap_entries; /* Number of entries in the color-map */ /* In the event of an error or warning the following field will be set to a * non-zero value and the 'message' field will contain a '\0' terminated * string with the libpng error or warning message. If both warnings and * an error were encountered, only the error is recorded. If there * are multiple warnings, only the first one is recorded. * * The upper 30 bits of this value are reserved, the low two bits contain * a value as follows: */ # define PNG_IMAGE_WARNING 1 # define PNG_IMAGE_ERROR 2 /* * The result is a two-bit code such that a value more than 1 indicates * a failure in the API just called: * * 0 - no warning or error * 1 - warning * 2 - error * 3 - error preceded by warning */ # define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1) png_uint_32 warning_or_error; char message[64]; } png_image, *png_imagep; /* The samples of the image have one to four channels whose components have * original values in the range 0 to 1.0: * * 1: A single gray or luminance channel (G). * 2: A gray/luminance channel and an alpha channel (GA). * 3: Three red, green, blue color channels (RGB). * 4: Three color channels and an alpha channel (RGBA). * * The components are encoded in one of two ways: * * a) As a small integer, value 0..255, contained in a single byte. For the * alpha channel the original value is simply value/255. For the color or * luminance channels the value is encoded according to the sRGB specification * and matches the 8-bit format expected by typical display devices. * * The color/gray channels are not scaled (pre-multiplied) by the alpha * channel and are suitable for passing to color management software. * * b) As a value in the range 0..65535, contained in a 2-byte integer. All * channels can be converted to the original value by dividing by 65535; all * channels are linear. Color channels use the RGB encoding (RGB end-points) of * the sRGB specification. This encoding is identified by the * PNG_FORMAT_FLAG_LINEAR flag below. * * When the simplified API needs to convert between sRGB and linear colorspaces, * the actual sRGB transfer curve defined in the sRGB specification (see the * article at <https://en.wikipedia.org/wiki/SRGB>) is used, not the gamma=1/2.2 * approximation used elsewhere in libpng. * * When an alpha channel is present it is expected to denote pixel coverage * of the color or luminance channels and is returned as an associated alpha * channel: the color/gray channels are scaled (pre-multiplied) by the alpha * value. * * The samples are either contained directly in the image data, between 1 and 8 * bytes per pixel according to the encoding, or are held in a color-map indexed * by bytes in the image data. In the case of a color-map the color-map entries * are individual samples, encoded as above, and the image data has one byte per * pixel to select the relevant sample from the color-map. */ /* PNG_FORMAT_* * * #defines to be used in png_image::format. Each #define identifies a * particular layout of sample data and, if present, alpha values. There are * separate defines for each of the two component encodings. * * A format is built up using single bit flag values. All combinations are * valid. Formats can be built up from the flag values or you can use one of * the predefined values below. When testing formats always use the FORMAT_FLAG * macros to test for individual features - future versions of the library may * add new flags. * * When reading or writing color-mapped images the format should be set to the * format of the entries in the color-map then png_image_{read,write}_colormap * called to read or write the color-map and set the format correctly for the * image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly! * * NOTE: libpng can be built with particular features disabled. If you see * compiler errors because the definition of one of the following flags has been * compiled out it is because libpng does not have the required support. It is * possible, however, for the libpng configuration to enable the format on just * read or just write; in that case you may see an error at run time. You can * guard against this by checking for the definition of the appropriate * "_SUPPORTED" macro, one of: * * PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED */ #define PNG_FORMAT_FLAG_ALPHA 0x01U /* format with an alpha channel */ #define PNG_FORMAT_FLAG_COLOR 0x02U /* color format: otherwise grayscale */ #define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2-byte channels else 1-byte */ #define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */ #ifdef PNG_FORMAT_BGR_SUPPORTED # define PNG_FORMAT_FLAG_BGR 0x10U /* BGR colors, else order is RGB */ #endif #ifdef PNG_FORMAT_AFIRST_SUPPORTED # define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */ #endif #define PNG_FORMAT_FLAG_ASSOCIATED_ALPHA 0x40U /* alpha channel is associated */ /* Commonly used formats have predefined macros. * * First the single byte (sRGB) formats: */ #define PNG_FORMAT_GRAY 0 #define PNG_FORMAT_GA PNG_FORMAT_FLAG_ALPHA #define PNG_FORMAT_AG (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST) #define PNG_FORMAT_RGB PNG_FORMAT_FLAG_COLOR #define PNG_FORMAT_BGR (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR) #define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST) #define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST) /* Then the linear 2-byte formats. When naming these "Y" is used to * indicate a luminance (gray) channel. */ #define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR #define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA) #define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR) #define PNG_FORMAT_LINEAR_RGB_ALPHA \ (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA) /* With color-mapped formats the image data is one byte for each pixel, the byte * is an index into the color-map which is formatted as above. To obtain a * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP * to one of the above definitions, or you can use one of the definitions below. */ #define PNG_FORMAT_RGB_COLORMAP (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_BGR_COLORMAP (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP) #define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP) /* PNG_IMAGE macros * * These are convenience macros to derive information from a png_image * structure. The PNG_IMAGE_SAMPLE_ macros return values appropriate to the * actual image sample values - either the entries in the color-map or the * pixels in the image. The PNG_IMAGE_PIXEL_ macros return corresponding values * for the pixels and will always return 1 for color-mapped formats. The * remaining macros return information about the rows in the image and the * complete image. * * NOTE: All the macros that take a png_image::format parameter are compile time * constants if the format parameter is, itself, a constant. Therefore these * macros can be used in array declarations and case labels where required. * Similarly the macros are also pre-processor constants (sizeof is not used) so * they can be used in #if tests. * * First the information about the samples. */ #define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\ (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1) /* Return the total number of channels in a given format: 1..4 */ #define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\ ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1) /* Return the size in bytes of a single component of a pixel or color-map * entry (as appropriate) in the image: 1 or 2. */ #define PNG_IMAGE_SAMPLE_SIZE(fmt)\ (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)) /* This is the size of the sample data for one sample. If the image is * color-mapped it is the size of one color-map entry (and image pixels are * one byte in size), otherwise it is the size of one image pixel. */ #define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\ (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256) /* The maximum size of the color-map required by the format expressed in a * count of components. This can be used to compile-time allocate a * color-map: * * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)]; * * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)]; * * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the * information from one of the png_image_begin_read_ APIs and dynamically * allocate the required memory. */ /* Corresponding information about the pixels */ #define PNG_IMAGE_PIXEL_(test,fmt)\ (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt)) #define PNG_IMAGE_PIXEL_CHANNELS(fmt)\ PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt) /* The number of separate channels (components) in a pixel; 1 for a * color-mapped image. */ #define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\ PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt) /* The size, in bytes, of each component in a pixel; 1 for a color-mapped * image. */ #define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt) /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */ /* Information about the whole row, or whole image */ #define PNG_IMAGE_ROW_STRIDE(image)\ (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width) /* Return the total number of components in a single row of the image; this * is the minimum 'row stride', the minimum count of components between each * row. For a color-mapped image this is the minimum number of bytes in a * row. * * WARNING: this macro overflows for some images with more than one component * and very large image widths. libpng will refuse to process an image where * this macro would overflow. */ #define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\ (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride)) /* Return the size, in bytes, of an image buffer given a png_image and a row * stride - the number of components to leave space for in each row. * * WARNING: this macro overflows a 32-bit integer for some large PNG images, * libpng will refuse to process an image where such an overflow would occur. */ #define PNG_IMAGE_SIZE(image)\ PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image)) /* Return the size, in bytes, of the image in memory given just a png_image; * the row stride is the minimum stride required for the image. */ #define PNG_IMAGE_COLORMAP_SIZE(image)\ (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries) /* Return the size, in bytes, of the color-map of this image. If the image * format is not a color-map format this will return a size sufficient for * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if * you don't want to allocate a color-map in this case. */ /* PNG_IMAGE_FLAG_* * * Flags containing additional information about the image are held in the * 'flags' field of png_image. */ #define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01 /* This indicates that the RGB values of the in-memory bitmap do not * correspond to the red, green and blue end-points defined by sRGB. */ #define PNG_IMAGE_FLAG_FAST 0x02 /* On write emphasise speed over compression; the resultant PNG file will be * larger but will be produced significantly faster, particular for large * images. Do not use this option for images which will be distributed, only * used it when producing intermediate files that will be read back in * repeatedly. For a typical 24-bit image the option will double the read * speed at the cost of increasing the image size by 25%, however for many * more compressible images the PNG file can be 10 times larger with only a * slight speed gain. */ #define PNG_IMAGE_FLAG_16BIT_sRGB 0x04 /* On read if the image is a 16-bit per component image and there is no gAMA * or sRGB chunk assume that the components are sRGB encoded. Notice that * images output by the simplified API always have gamma information; setting * this flag only affects the interpretation of 16-bit images from an * external source. It is recommended that the application expose this flag * to the user; the user can normally easily recognize the difference between * linear and sRGB encoding. This flag has no effect on write - the data * passed to the write APIs must have the correct encoding (as defined * above.) * * If the flag is not set (the default) input 16-bit per component data is * assumed to be linear. * * NOTE: the flag can only be set after the png_image_begin_read_ call, * because that call initializes the 'flags' field. */ #ifdef PNG_SIMPLIFIED_READ_SUPPORTED /* READ APIs * --------- * * The png_image passed to the read APIs must have been initialized by setting * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.) */ #ifdef PNG_STDIO_SUPPORTED PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image, const char *file_name)); /* The named file is opened for read and the image header is filled in * from the PNG header in the file. */ PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image, FILE* file)); /* The PNG header is read from the stdio FILE object. */ #endif /* STDIO */ PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image, png_const_voidp memory, size_t size)); /* The PNG header is read from the given memory buffer. */ PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image, png_const_colorp background, void *buffer, png_int_32 row_stride, void *colormap)); /* Finish reading the image into the supplied buffer and clean up the * png_image structure. * * row_stride is the step, in byte or 2-byte units as appropriate, * between adjacent rows. A positive stride indicates that the top-most row * is first in the buffer - the normal top-down arrangement. A negative * stride indicates that the bottom-most row is first in the buffer. * * background need only be supplied if an alpha channel must be removed from * a png_byte format and the removal is to be done by compositing on a solid * color; otherwise it may be NULL and any composition will be done directly * onto the buffer. The value is an sRGB color to use for the background, * for grayscale output the green channel is used. * * background must be supplied when an alpha channel must be removed from a * single byte color-mapped output format, in other words if: * * 1) The original format from png_image_begin_read_from_* had * PNG_FORMAT_FLAG_ALPHA set. * 2) The format set by the application does not. * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and * PNG_FORMAT_FLAG_LINEAR *not* set. * * For linear output removing the alpha channel is always done by compositing * on black and background is ignored. * * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE. * image->colormap_entries will be updated to the actual number of entries * written to the colormap; this may be less than the original value. */ PNG_EXPORT(238, void, png_image_free, (png_imagep image)); /* Free any data allocated by libpng in image->opaque, setting the pointer to * NULL. May be called at any time after the structure is initialized. */ #endif /* SIMPLIFIED_READ */ #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED /* WRITE APIS * ---------- * For write you must initialize a png_image structure to describe the image to * be written. To do this use memset to set the whole structure to 0 then * initialize fields describing your image. * * version: must be set to PNG_IMAGE_VERSION * opaque: must be initialized to NULL * width: image width in pixels * height: image height in rows * format: the format of the data (image and color-map) you wish to write * flags: set to 0 unless one of the defined flags applies; set * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB * values do not correspond to the colors in sRGB. * colormap_entries: set to the number of entries in the color-map (0 to 256) */ #ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image, const char *file, int convert_to_8bit, const void *buffer, png_int_32 row_stride, const void *colormap)); /* Write the image to the named file. */ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, int convert_to_8_bit, const void *buffer, png_int_32 row_stride, const void *colormap)); /* Write the image to the given (FILE*). */ #endif /* SIMPLIFIED_WRITE_STDIO */ /* With all write APIs if image is in one of the linear formats with 16-bit * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG * gamma encoded according to the sRGB specification, otherwise a 16-bit linear * encoded PNG file is written. * * With color-mapped data formats the colormap parameter point to a color-map * with at least image->colormap_entries encoded in the specified format. If * the format is linear the written PNG color-map will be converted to sRGB * regardless of the convert_to_8_bit flag. * * With all APIs row_stride is handled as in the read APIs - it is the spacing * from one row to the next in component sized units (1 or 2 bytes) and if * negative indicates a bottom-up row layout in the buffer. If row_stride is * zero, libpng will calculate it for you from the image width and number of * channels. * * Note that the write API does not support interlacing, sub-8-bit pixels or * most ancillary chunks. If you need to write text chunks (e.g. for copyright * notices) you need to use one of the other APIs. */ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory, png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8_bit, const void *buffer, png_int_32 row_stride, const void *colormap)); /* Write the image to the given memory buffer. The function both writes the * whole PNG data stream to *memory and updates *memory_bytes with the count * of bytes written. * * 'memory' may be NULL. In this case *memory_bytes is not read however on * success the number of bytes which would have been written will still be * stored in *memory_bytes. On failure *memory_bytes will contain 0. * * If 'memory' is not NULL it must point to memory[*memory_bytes] of * writeable memory. * * If the function returns success memory[*memory_bytes] (if 'memory' is not * NULL) contains the written PNG data. *memory_bytes will always be less * than or equal to the original value. * * If the function returns false and *memory_bytes was not changed an error * occurred during write. If *memory_bytes was changed, or is not 0 if * 'memory' was NULL, the write would have succeeded but for the memory * buffer being too small. *memory_bytes contains the required number of * bytes and will be bigger that the original value. */ #define png_image_write_get_memory_size(image, size, convert_to_8_bit, buffer,\ row_stride, colormap)\ png_image_write_to_memory(&(image), 0, &(size), convert_to_8_bit, buffer,\ row_stride, colormap) /* Return the amount of memory in 'size' required to compress this image. * The png_image structure 'image' must be filled in as in the above * function and must not be changed before the actual write call, the buffer * and all other parameters must also be identical to that in the final * write call. The 'size' variable need not be initialized. * * NOTE: the macro returns true/false, if false is returned 'size' will be * set to zero and the write failed and probably will fail if tried again. */ /* You can pre-allocate the buffer by making sure it is of sufficient size * regardless of the amount of compression achieved. The buffer size will * always be bigger than the original image and it will never be filled. The * following macros are provided to assist in allocating the buffer. */ #define PNG_IMAGE_DATA_SIZE(image) (PNG_IMAGE_SIZE(image)+(image).height) /* The number of uncompressed bytes in the PNG byte encoding of the image; * uncompressing the PNG IDAT data will give this number of bytes. * * NOTE: while PNG_IMAGE_SIZE cannot overflow for an image in memory this * macro can because of the extra bytes used in the PNG byte encoding. You * need to avoid this macro if your image size approaches 2^30 in width or * height. The same goes for the remainder of these macros; they all produce * bigger numbers than the actual in-memory image size. */ #ifndef PNG_ZLIB_MAX_SIZE # define PNG_ZLIB_MAX_SIZE(b) ((b)+(((b)+7U)>>3)+(((b)+63U)>>6)+11U) /* An upper bound on the number of compressed bytes given 'b' uncompressed * bytes. This is based on deflateBounds() in zlib; different * implementations of zlib compression may conceivably produce more data so * if your zlib implementation is not zlib itself redefine this macro * appropriately. */ #endif #define PNG_IMAGE_COMPRESSED_SIZE_MAX(image)\ PNG_ZLIB_MAX_SIZE((png_alloc_size_t)PNG_IMAGE_DATA_SIZE(image)) /* An upper bound on the size of the data in the PNG IDAT chunks. */ #define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\ ((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\ (((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\ 12U+3U*(image).colormap_entries/*PLTE data*/+\ (((image).format&PNG_FORMAT_FLAG_ALPHA)?\ 12U/*tRNS*/+(image).colormap_entries:0U):0U)+\ 12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size)) /* A helper for the following macro; if your compiler cannot handle the * following macro use this one with the result of * PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most * compilers should handle this just fine.) */ #define PNG_IMAGE_PNG_SIZE_MAX(image)\ PNG_IMAGE_PNG_SIZE_MAX_(image, PNG_IMAGE_COMPRESSED_SIZE_MAX(image)) /* An upper bound on the total length of the PNG data stream for 'image'. * The result is of type png_alloc_size_t, on 32-bit systems this may * overflow even though PNG_IMAGE_DATA_SIZE does not overflow; the write will * run out of buffer space but return a corrected size which should work. */ #endif /* SIMPLIFIED_WRITE */ /******************************************************************************* * END OF SIMPLIFIED API ******************************************************************************/ #endif /* SIMPLIFIED_{READ|WRITE} */ /******************************************************************************* * Section 6: IMPLEMENTATION OPTIONS ******************************************************************************* * * Support for arbitrary implementation-specific optimizations. The API allows * particular options to be turned on or off. 'Option' is the number of the * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given * by the PNG_OPTION_ defines below. * * HARDWARE: normally hardware capabilities, such as the Intel SSE instructions, * are detected at run time, however sometimes it may be impossible * to do this in user mode, in which case it is necessary to discover * the capabilities in an OS specific way. Such capabilities are * listed here when libpng has support for them and must be turned * ON by the application if present. * * SOFTWARE: sometimes software optimizations actually result in performance * decrease on some architectures or systems, or with some sets of * PNG images. 'Software' options allow such optimizations to be * selected at run time. */ #ifdef PNG_SET_OPTION_SUPPORTED #ifdef PNG_ARM_NEON_API_SUPPORTED # define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */ #endif #define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */ #define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */ #ifdef PNG_MIPS_MSA_API_SUPPORTED # define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */ #endif #define PNG_IGNORE_ADLER32 8 #ifdef PNG_POWERPC_VSX_API_SUPPORTED # define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions supported */ #endif #define PNG_OPTION_NEXT 12 /* Next option - numbers must be even */ /* Return values: NOTE: there are four values and 'off' is *not* zero */ #define PNG_OPTION_UNSET 0 /* Unset - defaults to off */ #define PNG_OPTION_INVALID 1 /* Option number out of range */ #define PNG_OPTION_OFF 2 #define PNG_OPTION_ON 3 PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, int onoff)); #endif /* SET_OPTION */ /******************************************************************************* * END OF HARDWARE AND SOFTWARE OPTIONS ******************************************************************************/ /* Maintainer: Put new public prototypes here ^, in libpng.3, in project * defs, and in scripts/symbols.def. */ /* The last ordinal number (this is the *last* one already used; the next * one to use is one more than this.) */ #ifdef PNG_EXPORT_LAST_ORDINAL PNG_EXPORT_LAST_ORDINAL(249); #endif #ifdef __cplusplus } #endif #endif /* PNG_VERSION_INFO_ONLY */ /* Do not put anything past this line */ #endif /* PNG_H */ /* pnglibconf.h - library build configuration */ /* libpng version 1.6.37 */ /* Copyright (c) 2018-2019 Cosmin Truta */ /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */ /* This code is released under the libpng license. */ /* For conditions of distribution and use, see the disclaimer */ /* and license in png.h */ /* pnglibconf.h */ /* Machine generated file: DO NOT EDIT */ /* Derived from: scripts/pnglibconf.dfa */ #ifndef PNGLCONF_H #define PNGLCONF_H /* options */ #define PNG_16BIT_SUPPORTED #define PNG_ALIGNED_MEMORY_SUPPORTED /*#undef PNG_ARM_NEON_API_SUPPORTED*/ /*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/ #define PNG_BENIGN_ERRORS_SUPPORTED #define PNG_BENIGN_READ_ERRORS_SUPPORTED /*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/ #define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED #define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_COLORSPACE_SUPPORTED #define PNG_CONSOLE_IO_SUPPORTED #define PNG_CONVERT_tIME_SUPPORTED #define PNG_EASY_ACCESS_SUPPORTED /*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ #define PNG_ERROR_TEXT_SUPPORTED #define PNG_FIXED_POINT_SUPPORTED #define PNG_FLOATING_ARITHMETIC_SUPPORTED #define PNG_FLOATING_POINT_SUPPORTED #define PNG_FORMAT_AFIRST_SUPPORTED #define PNG_FORMAT_BGR_SUPPORTED #define PNG_GAMMA_SUPPORTED #define PNG_GET_PALETTE_MAX_SUPPORTED #define PNG_HANDLE_AS_UNKNOWN_SUPPORTED #define PNG_INCH_CONVERSIONS_SUPPORTED #define PNG_INFO_IMAGE_SUPPORTED #define PNG_IO_STATE_SUPPORTED #define PNG_MNG_FEATURES_SUPPORTED #define PNG_POINTER_INDEXING_SUPPORTED /*#undef PNG_POWERPC_VSX_API_SUPPORTED*/ /*#undef PNG_POWERPC_VSX_CHECK_SUPPORTED*/ #define PNG_PROGRESSIVE_READ_SUPPORTED #define PNG_READ_16BIT_SUPPORTED #define PNG_READ_ALPHA_MODE_SUPPORTED #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED #define PNG_READ_BACKGROUND_SUPPORTED #define PNG_READ_BGR_SUPPORTED #define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_READ_COMPOSITE_NODIV_SUPPORTED #define PNG_READ_COMPRESSED_TEXT_SUPPORTED #define PNG_READ_EXPAND_16_SUPPORTED #define PNG_READ_EXPAND_SUPPORTED #define PNG_READ_FILLER_SUPPORTED #define PNG_READ_GAMMA_SUPPORTED #define PNG_READ_GET_PALETTE_MAX_SUPPORTED #define PNG_READ_GRAY_TO_RGB_SUPPORTED #define PNG_READ_INTERLACING_SUPPORTED #define PNG_READ_INT_FUNCTIONS_SUPPORTED #define PNG_READ_INVERT_ALPHA_SUPPORTED #define PNG_READ_INVERT_SUPPORTED #define PNG_READ_OPT_PLTE_SUPPORTED #define PNG_READ_PACKSWAP_SUPPORTED #define PNG_READ_PACK_SUPPORTED #define PNG_READ_QUANTIZE_SUPPORTED #define PNG_READ_RGB_TO_GRAY_SUPPORTED #define PNG_READ_SCALE_16_TO_8_SUPPORTED #define PNG_READ_SHIFT_SUPPORTED #define PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_STRIP_ALPHA_SUPPORTED #define PNG_READ_SUPPORTED #define PNG_READ_SWAP_ALPHA_SUPPORTED #define PNG_READ_SWAP_SUPPORTED #define PNG_READ_TEXT_SUPPORTED #define PNG_READ_TRANSFORMS_SUPPORTED #define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED #define PNG_READ_USER_CHUNKS_SUPPORTED #define PNG_READ_USER_TRANSFORM_SUPPORTED #define PNG_READ_bKGD_SUPPORTED #define PNG_READ_cHRM_SUPPORTED #define PNG_READ_eXIf_SUPPORTED #define PNG_READ_gAMA_SUPPORTED #define PNG_READ_hIST_SUPPORTED #define PNG_READ_iCCP_SUPPORTED #define PNG_READ_iTXt_SUPPORTED #define PNG_READ_oFFs_SUPPORTED #define PNG_READ_pCAL_SUPPORTED #define PNG_READ_pHYs_SUPPORTED #define PNG_READ_sBIT_SUPPORTED #define PNG_READ_sCAL_SUPPORTED #define PNG_READ_sPLT_SUPPORTED #define PNG_READ_sRGB_SUPPORTED #define PNG_READ_tEXt_SUPPORTED #define PNG_READ_tIME_SUPPORTED #define PNG_READ_tRNS_SUPPORTED #define PNG_READ_zTXt_SUPPORTED #define PNG_SAVE_INT_32_SUPPORTED #define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_SEQUENTIAL_READ_SUPPORTED #define PNG_SETJMP_SUPPORTED #define PNG_SET_OPTION_SUPPORTED #define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED #define PNG_SET_USER_LIMITS_SUPPORTED #define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED #define PNG_SIMPLIFIED_READ_BGR_SUPPORTED #define PNG_SIMPLIFIED_READ_SUPPORTED #define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED #define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED #define PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED #define PNG_SIMPLIFIED_WRITE_SUPPORTED #define PNG_STDIO_SUPPORTED #define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_TEXT_SUPPORTED #define PNG_TIME_RFC1123_SUPPORTED #define PNG_UNKNOWN_CHUNKS_SUPPORTED #define PNG_USER_CHUNKS_SUPPORTED #define PNG_USER_LIMITS_SUPPORTED #define PNG_USER_MEM_SUPPORTED #define PNG_USER_TRANSFORM_INFO_SUPPORTED #define PNG_USER_TRANSFORM_PTR_SUPPORTED #define PNG_WARNINGS_SUPPORTED #define PNG_WRITE_16BIT_SUPPORTED #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED #define PNG_WRITE_BGR_SUPPORTED #define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED #define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED #define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED #define PNG_WRITE_FILLER_SUPPORTED #define PNG_WRITE_FILTER_SUPPORTED #define PNG_WRITE_FLUSH_SUPPORTED #define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED #define PNG_WRITE_INTERLACING_SUPPORTED #define PNG_WRITE_INT_FUNCTIONS_SUPPORTED #define PNG_WRITE_INVERT_ALPHA_SUPPORTED #define PNG_WRITE_INVERT_SUPPORTED #define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED #define PNG_WRITE_PACKSWAP_SUPPORTED #define PNG_WRITE_PACK_SUPPORTED #define PNG_WRITE_SHIFT_SUPPORTED #define PNG_WRITE_SUPPORTED #define PNG_WRITE_SWAP_ALPHA_SUPPORTED #define PNG_WRITE_SWAP_SUPPORTED #define PNG_WRITE_TEXT_SUPPORTED #define PNG_WRITE_TRANSFORMS_SUPPORTED #define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED #define PNG_WRITE_USER_TRANSFORM_SUPPORTED #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED #define PNG_WRITE_bKGD_SUPPORTED #define PNG_WRITE_cHRM_SUPPORTED #define PNG_WRITE_eXIf_SUPPORTED #define PNG_WRITE_gAMA_SUPPORTED #define PNG_WRITE_hIST_SUPPORTED #define PNG_WRITE_iCCP_SUPPORTED #define PNG_WRITE_iTXt_SUPPORTED #define PNG_WRITE_oFFs_SUPPORTED #define PNG_WRITE_pCAL_SUPPORTED #define PNG_WRITE_pHYs_SUPPORTED #define PNG_WRITE_sBIT_SUPPORTED #define PNG_WRITE_sCAL_SUPPORTED #define PNG_WRITE_sPLT_SUPPORTED #define PNG_WRITE_sRGB_SUPPORTED #define PNG_WRITE_tEXt_SUPPORTED #define PNG_WRITE_tIME_SUPPORTED #define PNG_WRITE_tRNS_SUPPORTED #define PNG_WRITE_zTXt_SUPPORTED #define PNG_bKGD_SUPPORTED #define PNG_cHRM_SUPPORTED #define PNG_eXIf_SUPPORTED #define PNG_gAMA_SUPPORTED #define PNG_hIST_SUPPORTED #define PNG_iCCP_SUPPORTED #define PNG_iTXt_SUPPORTED #define PNG_oFFs_SUPPORTED #define PNG_pCAL_SUPPORTED #define PNG_pHYs_SUPPORTED #define PNG_sBIT_SUPPORTED #define PNG_sCAL_SUPPORTED #define PNG_sPLT_SUPPORTED #define PNG_sRGB_SUPPORTED #define PNG_tEXt_SUPPORTED #define PNG_tIME_SUPPORTED #define PNG_tRNS_SUPPORTED #define PNG_zTXt_SUPPORTED /* end of options */ /* settings */ #define PNG_API_RULE 0 #define PNG_DEFAULT_READ_MACROS 1 #define PNG_GAMMA_THRESHOLD_FIXED 5000 #define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE #define PNG_INFLATE_BUF_SIZE 1024 #define PNG_LINKAGE_API extern #define PNG_LINKAGE_CALLBACK extern #define PNG_LINKAGE_DATA extern #define PNG_LINKAGE_FUNCTION extern #define PNG_MAX_GAMMA_8 11 #define PNG_QUANTIZE_BLUE_BITS 5 #define PNG_QUANTIZE_GREEN_BITS 5 #define PNG_QUANTIZE_RED_BITS 5 #define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1) #define PNG_TEXT_Z_DEFAULT_STRATEGY 0 #define PNG_USER_CHUNK_CACHE_MAX 1000 #define PNG_USER_CHUNK_MALLOC_MAX 1000000000 #define PNG_USER_HEIGHT_MAX 1000000 #define PNG_USER_WIDTH_MAX 1000000 #define PNG_ZBUF_SIZE 8192 #define PNG_ZLIB_VERNUM 0x12b0 #define PNG_Z_DEFAULT_COMPRESSION (-1) #define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 #define PNG_Z_DEFAULT_STRATEGY 1 #define PNG_sCAL_PRECISION 5 #define PNG_sRGB_PROFILE_CHECKS 2 /* end of settings */ #endif /* PNGLCONF_H */ /* Definitions for use with Linux AF_PACKET sockets. Copyright (C) 1998-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef __NETPACKET_PACKET_H #define __NETPACKET_PACKET_H 1 struct sockaddr_ll { unsigned short int sll_family; unsigned short int sll_protocol; int sll_ifindex; unsigned short int sll_hatype; unsigned char sll_pkttype; unsigned char sll_halen; unsigned char sll_addr[8]; }; /* Packet types. */ #define PACKET_HOST 0 /* To us. */ #define PACKET_BROADCAST 1 /* To all. */ #define PACKET_MULTICAST 2 /* To group. */ #define PACKET_OTHERHOST 3 /* To someone else. */ #define PACKET_OUTGOING 4 /* Originated by us . */ #define PACKET_LOOPBACK 5 #define PACKET_FASTROUTE 6 /* Packet socket options. */ #define PACKET_ADD_MEMBERSHIP 1 #define PACKET_DROP_MEMBERSHIP 2 #define PACKET_RECV_OUTPUT 3 #define PACKET_RX_RING 5 #define PACKET_STATISTICS 6 #define PACKET_COPY_THRESH 7 #define PACKET_AUXDATA 8 #define PACKET_ORIGDEV 9 #define PACKET_VERSION 10 #define PACKET_HDRLEN 11 #define PACKET_RESERVE 12 #define PACKET_TX_RING 13 #define PACKET_LOSS 14 #define PACKET_VNET_HDR 15 #define PACKET_TX_TIMESTAMP 16 #define PACKET_TIMESTAMP 17 #define PACKET_FANOUT 18 #define PACKET_TX_HAS_OFF 19 #define PACKET_QDISC_BYPASS 20 #define PACKET_ROLLOVER_STATS 21 #define PACKET_FANOUT_DATA 22 #define PACKET_IGNORE_OUTGOING 23 struct packet_mreq { int mr_ifindex; unsigned short int mr_type; unsigned short int mr_alen; unsigned char mr_address[8]; }; #define PACKET_MR_MULTICAST 0 #define PACKET_MR_PROMISC 1 #define PACKET_MR_ALLMULTI 2 #define PACKET_MR_UNICAST 3 #endif /* netpacket/packet.h */ # # Copyright (c) 2012-2022 Red Hat. # Copyright (c) 2008 Aconex. All Rights Reserved. # Copyright (c) 2000,2003,2004 Silicon Graphics, Inc. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # Common gmake macros for building # # src/include/builddefs. Generated from builddefs.in by configure. # ifndef _BUILDDEFS_INCLUDED_ _BUILDDEFS_INCLUDED_ = 1 ifndef _PCP_CONF_INCLUDED_ _PCP_CONF_INCLUDED_ = 1 include $(PCP_DIR)/etc/pcp.conf endif # General package information PACKAGE_VERSION ?= 6.3.7 PACKAGE_MAJOR ?= 6 PACKAGE_MINOR ?= 3 PACKAGE_REVISION ?= 7 PACKAGE_BUILD ?= 13 PACKAGE_NAME ?= pcp PACKAGE_CONFIGURE ?= --with-infiniband=yes --with-python=no --with-dstat-symlink=yes --with-perfevent=yes --with-pmdagfs2=yes --with-pmdastatsd=yes --with-pmdabcc=yes --with-pmdabpf=yes --with-pmdabpftrace=yes --with-pmdajson=yes --with-pmdamongodb=yes --with-pmdamysql=yes --with-pmdanutcracker=no --with-pmdasnmp=yes --enable-multilib=yes PACKAGE_DISTRIBUTION ?= redhat SGI_CHROOT_BUILD ?= 0 SGI_ISSP_BUILD ?= 0 # see build/containers/GNUlocalrules and build/containers/*/GNUmakefile CONTAINER_VERSION = $(PACKAGE_VERSION)-$(PACKAGE_BUILD) CONTAINER_ARCH = $(shell uname -p) BUILDRULES = $(PCP_INC_DIR)/buildrules # LCFLAGS, LLDFLAGS, LLDLIBS, LDIRT may be specified in local makefiles. # turn on all warnings by default ifeq "yes" "yes" WARN_OFF = -Wall else WARN_OFF = endif LIBPCP_ABIDIR ?= src PCPLIB_LDFLAGS = -L$(PCP_LIB_DIR) # backward compatibility PCP_LIBS = $(PCPLIB_LDFLAGS) # platform-specific CFLAGS, LDLIBS, and shared library extension # # Note: # Need PCFLAGS setting here to match the CFLAGS settings in # ../../configure.ac (likewise for PLDFLAGS and LDFLAGS). # TARGET_OS = linux CROSS_COMPILING = no CASE_INSENSITIVE_FS = no C99_CFLAGS = --std=c99 PCFLAGS = -fPIC -fno-strict-aliasing -D_GNU_SOURCE -Wshadow -Wno-array-bounds PLDFLAGS = -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 ifneq (, $(filter linux kfreebsd gnu, $(TARGET_OS))) DSOSUFFIX = so endif ifeq "$(TARGET_OS)" "darwin" DSOSUFFIX = dylib CASE_INSENSITIVE_FS = yes endif ifeq "$(TARGET_OS)" "mingw" DSOSUFFIX = dll EXECSUFFIX = .exe SHELLSUFFIX = .sh PLDLIBS = -lwsock32 -liphlpapi endif ifeq "$(TARGET_OS)" "solaris" PLDFLAGS += -fPIC PLDLIBS = -lnsl -lsocket -lresolv -ldl -lposix4 DSOSUFFIX = so endif ifeq "$(TARGET_OS)" "aix" DSOSUFFIX = so # -qcpluscmt # allow C++-style // as comment preamble # -brtl # use run-time linker # -bnoipath # do not use path to DSOs from the build, use default search path # rules # (and does not accept -Wall as a valid option) PLDFLAGS += -brtl -bnoipath WARN_OFF = endif ifeq "$(TARGET_OS)" "freebsd" DSOSUFFIX = so endif ifeq "$(TARGET_OS)" "netbsd" DSOSUFFIX = so LDFLAGS += -Wl,-rpath=/usr/pkg/lib endif ifeq "$(TARGET_OS)" "openbsd" DSOSUFFIX = so endif CFLAGS_DEV = CFLAGS_ABI = CFLAGS_OPT = -O2 -g CFLAGS_SANITIZER = CFLAGS += -I$(PCP_INC_DIR)/.. -I$(PCP_INC_DIR) \ -DPCP_VERSION=\"$(PCP_VERSION)\" \ $(PCFLAGS) $(LCFLAGS) $(WARN_OFF) $(CFLAGS_OPT) $(CFLAGS_SANITIZER) $(CFLAGS_DEV) PIECFLAGS = -fPIE PIELDFLAGS = -pie -Wl,-z,relro -Wl,-z,now INVISIBILITY = -fvisibility=hidden # hide shared library symbols AVAHICFLAGS = -D_REENTRANT LZMACFLAGS = LIBUVCFLAGS = OPENSSLCFLAGS = SASLCFLAGS = CMOCKACFLAGS = LDFLAGS += $(PLDFLAGS) $(WARN_OFF) $(PCP_LIBS) $(LLDFLAGS) SRCFILES = GNUmakefile $(HFILES) $(CFILES) $(CXXFILES) $(MFILES) \ $(LSRCFILES) $(LFILES) $(YFILES) $(PYFILES) GPERFTOOLS_LIBS = # tcmalloc of gperftools must be linked last LDLIBS = $(LLDLIBS) $(PLDLIBS) $(GPERFTOOLS_LIBS) MAKEOPTS = --no-print-directory ifdef PROJECT QTDIRDIRT = build debug release .obj .ui .moc .qrc *.xcodeproj *.app QTDIRT = *.a *.o ui_* moc_* qrc_* Info.plist Makefile* object_script.* \ .qmake.stash endif DEPDIRT = dep dep.bak MANDIRT = *.[1-9].gz *.[1-9].bz2 *.[1-9].lzma *.[1-9].xz *.[1-9].tmp LIBDIRT = $(LIBTARGET) $(STATICLIBTARGET) CDIRT = $(OBJECTS) $(CMDTARGET) $(CXXMDTARGET) DIRT = $(LDIRT) $(DEPDIRT) $(MANDIRT) $(QTDIRT) $(CDIRT) $(LIBDIRT) DIRDIRT = $(LDIRDIRT) $(QTDIRDIRT) OBJECTS = $(ASFILES:.s=.o) \ $(CFILES:.c=.o) \ $(CXXFILES:.cxx=.o) \ $(FFILES:.f=.o) \ $(LFILES:.l=.o) \ $(RLFILES:.rl=.o) \ $(YFILES:%.y=%.tab.o) #NB: don't override $(MAKE); gnumake sets it well, propagating -j etc. #MAKE = /usr/bin/gmake AR = /usr/bin/gcc-ar CC = gcc CXX = g++ LD = /usr/bin/ld AWK = /usr/bin/gawk --posix SED = /usr/bin/sed CPP = gcc -E LEX = flex YACC = bison RAGEL = ECHO = /usr/bin/echo LN_S = ln -s GREP = grep GIT = git # man-lint should not break the build (-f) MANLINT = $(TOPDIR)/scripts/man-lint -f PYLINT = /bin/true --rcfile=$(TOPDIR)/.pylintrc --output-format=colorized PYTHON = PYTHON3 = /usr/bin/python3 DTRACE = dtrace ifeq "$(TARGET_OS)" "freebsd" QMAKE = /usr/lib64/qt5/bin/qmake else QMAKE = QT_SELECT=5 /usr/lib64/qt5/bin/qmake endif INSTALL_SH = $(PCP_BINADM_DIR)/install-sh INSTALL = $(INSTALL_SH) -o $(PCP_USER_INSTALL) -g $(PCP_GROUP_INSTALL) CCF = $(CC) $(CFLAGS) CXXF = $(CXX) $(CFLAGS) $(CXXFLAGS) # NB: don't use $(MAKEF), since that suppresses gnumake's subdir parallelization #MAKEF = $(MAKE) $(MAKEOPTS) LDF = $(LD) $(LDFLAGS) MAKEDEPEND = /usr/bin/true ifeq "$(TARGET_OS)" "freebsd" # gmake on FreeBSD has a strange default rule that passes insufficient # flags to cc/ld for the link step. This change prevents errors like # undefined reference to `__stack_chk_fail_local' # LDFLAGS += $(CFLAGS) endif ZIP = /usr/bin/gzip BZIP2 = /usr/bin/bzip2 LZMA = /usr/freeware/bin/lzma XZ = /usr/bin/xz TAR = /usr/bin/gtar RPMPROG = /usr/bin/rpmbuild HDIUTIL = MKINSTALLP = DLLTOOL = RPMBUILD= /usr/bin/rpmbuild RPM = /usr/bin/rpm POD2MAN = /usr/bin/pod2man DPKG = MAKEPKG = GENPMDA = $(PCP_BIN_DIR)/genpmda PKGMK = MD5SUM = /usr/bin/md5sum INKSCAPE = CLANG = /usr/bin/clang LLVM_STRIP = /usr/bin/llvm-strip BPFTOOL = $(TOPDIR)/vendor/github.com/libbpf/bpftool/src/bpftool PMDABPF_ARCH = x86 PMDABPF_VMLINUXH = /builddir/build/BUILD/pcp-6.3.7/vendor/github.com/iovisor/bcc/libbpf-tools/x86/vmlinux.h PMDABPF_MODULES = biolatency.so runqlat.so mountsnoop.so oomkill.so bashreadline.so biolatency.so execsnoop.so exitsnoop.so fsslower.so opensnoop.so runqlat.so statsnoop.so tcpconnect.so tcpconnlat.so vfsstat.so biosnoop.so netatop.so HAVE_MANPAGES = true HAVE_GZIPPED_MANPAGES = true HAVE_BZIP2ED_MANPAGES = false HAVE_LZMAED_MANPAGES = false HAVE_XZED_MANPAGES = false PCP_PREFIX = /usr PCP_MAN_DIR = /usr/share/man PCP_HTML_DIR = /usr/share/doc/pcp-doc/html PCP_ICONS_DIR = /usr/share/pcp-gui/pixmaps PCP_DESKTOP_DIR = /usr/share/applications PCP_PMNS_DIR = /var/lib/pcp/pmns PCP_PMNSADM_DIR = /usr/libexec/pcp/pmns PCP_SELINUX_DIR = /usr/share/selinux PCP_BASHSHARE_DIR = /usr/share/bash-completion NEED_OLD_TBL_HEADER = false RDYNAMIC_FLAG = -rdynamic QT_RELEASE = release QT_VERSION = 5 CLANG_MAJOR_VERSION = 22 # configuration state affecting the entire build ENABLE_MULTILIB = true ENABLE_SHARED = false ENABLE_SECURE = true ENABLE_PROBES = true ENABLE_AVAHI = true ENABLE_DSTAT = true ENABLE_QT = true ENABLE_QT3D = false ENABLE_PYTHON2 = false ENABLE_PYTHON3 = true ENABLE_SYSTEMD = true ENABLE_SELINUX = true ENABLE_DECOMPRESSION = true ENABLE_LZMA = true # for code supporting any modern version of perl HAVE_PERL = true # for code supporting both/either python2 and/or python3 HAVE_PYTHON = true # python dependent bits HAVE_PYTHON_SIX = true HAVE_PYTHON_REQUESTS = true HAVE_PYTHON_SETUPTOOLS = true HAVE_PYTHON_JSONPOINTER = true HAVE_PYTHON_ORDEREDDICT = true HAVE_PYTHON_INFLUXDB = true HAVE_PYTHON_OPENPYXL = false HAVE_PYTHON_PYARROW = false HAVE_PYTHON_BPF = false # for desktop icons in a variety of img sizes HAVE_HICOLOR_ICONS = true # additional libraries needed for particular functions LIB_FOR_ATOMIC = LIB_FOR_AVAHI = -lavahi-common -lavahi-client LIB_FOR_BASENAME = LIB_FOR_CHAN = -lchan LIB_FOR_CURSES = LIB_FOR_DLOPEN = LIB_FOR_HDR_HISTOGRAM = -lz -lhdr_histogram LIB_FOR_LZMA = -llzma LIB_FOR_MATH = -lm LIB_FOR_PTHREADS = LIB_FOR_READLINE = -lreadline LIB_FOR_REGEX = LIB_FOR_RT = LIB_FOR_BACKTRACE = HAVE_LIBUV = true LIB_FOR_LIBUV = -luv HAVE_LIBINIH = false LIB_FOR_INIH = HAVE_LIBBPF = true LIBBPF_VERSION = 1.5.0 LIB_FOR_LIBBPF = -lbpf HAVE_LIBELF = true LIB_FOR_LIBELF = -lelf HAVE_NCURSES = true LIB_FOR_NCURSES = -lncurses -ltinfo HAVE_NCURSESW = true LIB_FOR_NCURSESW = -lncursesw -ltinfo HAVE_DEVMAPPER = true LIB_FOR_DEVMAPPER = -ldevmapper HAVE_CMOCKA = false LIB_FOR_CMOCKA = HAVE_SASL = true LIB_FOR_LIBSASL2 = -lsasl2 HAVE_OPENSSL = true LIB_FOR_OPENSSL = -lssl -lcrypto HAVE_ZLIB = true LIB_FOR_ZLIB = -lz HAVE_LIBDRM = @HAVE_LIBDRM@ LIB_FOR_LIBDRM = -ldrm CFLAGS_FOR_LIBDRM = -I/usr/include/libdrm -I/usr/include/valgrind HAVE_LIBDRM_AMDGPU = @HAVE_LIBDRM_AMDGPU@ LIB_FOR_LIBDRM_AMDGPU = -ldrm_amdgpu CFLAGS_FOR_LIBDRM_AMDGPU = -I/usr/include/libdrm -I/usr/include/valgrind # configuration state for optional performance domains SYSTEMD_CFLAGS = SYSTEMD_LIBS = -lsystemd PFM_LIBS = -lpfm IB_LIBS = -libmad -libumad PMDA_BCC = true PMDA_BPF = true PMDA_BPFTRACE = true PMDA_JSON = true PMDA_GFS2 = true PMDA_STATSD = true PMDA_LIBVIRT = true PMDA_SYSTEMD = true PMDA_PERFEVENT = true PMDA_INFINIBAND = true PMDA_OPENMETRICS = true PMDA_ELASTICSEARCH = true PMDA_MYSQL = true PMDA_ORACLE = true PMDA_MONGODB = true PMDA_POSTGRESQL = true PMDA_SNMP = true PMDA_NGINX = true PMDA_ACTIVEMQ = true PMDA_POSTFIX = true PMDA_BIND2 = true PMDA_NUTCRACKER = false PMDA_LIO = true PMDA_MSSQL = true PMDA_RESCTRL = true PMDA_AMDGPU = true SHELL = /bin/sh IMAGES_DIR = $(TOPDIR)/all-images DIST_DIR = $(TOPDIR)/dist # env vars to be set before you can run a PCP binary in the build # environment ... needed for tools like newhelp # # default, then special case for different platforms # RUN_IN_BUILD_ENV = PCP_CONF=$(TOPDIR)/src/include/pcp.conf PCP_ALT_CPP=$(TOPDIR)/src/pmcpp/pmcpp.static$(EXECSUFFIX) # when cross-compiling, we cannot use RUN_IN_BUILD_ENV, so any binaries # from PCP we need in the build must be installed on the build machine. # ifeq "$(CROSS_COMPILING)" "yes" NEWHELP = . $$PCP_DIR/etc/pcp.conf && $$PCP_BINADM_DIR/newhelp PMIECONF = . $$PCP_DIR/etc/pcp.conf && $$PCP_BIN_DIR/pmieconf PMGENMAP = . $$PCP_DIR/etc/pcp.conf && $$PCP_BIN_DIR/pmgenmap PMCPP = . $$PCP_DIR/etc/pcp.conf && $$PCP_BINADM_DIR/pmcpp else NEWHELP = $(RUN_IN_BUILD_ENV) $(TOPDIR)/src/newhelp/newhelp.static$(EXECSUFFIX) PMIECONF = $(RUN_IN_BUILD_ENV) $(TOPDIR)/src/pmieconf/pmieconf.static$(EXECSUFFIX) PMGENMAP = $(RUN_IN_BUILD_ENV) sh ./pmgenmap.sh PMCPP = $(RUN_IN_BUILD_ENV) $(TOPDIR)/src/pmcpp/pmcpp.static$(EXECSUFFIX) endif SUBDIRS_MAKERULE = \ +for d in `echo $^ `; do \ if test -d "$$d" -a -f "$$d/GNUmakefile"; then \ $(ECHO) === $$d ===; \ $(MAKE) $(MAKEOPTS) -C $$d $@ || exit $$?; \ fi; \ done # special variant of SUBDIRS_MAKERULE when running QA # QA_SUBDIRS_MAKERULE = \ +@for d in `echo $^ `; do \ if test -d "$$d" ; then \ if test -f "$$d/GNUmakefile.install"; then \ $(MAKE) --silent -C $$d -f GNUmakefile.install $@ || exit $$?; \ else \ $(MAKE) --silent -C $$d $@ || exit $$?; \ fi; \ fi; \ done # prepare symbols file for the GNU toolchain (linker) for DSO PMDAs VERSION_SCRIPT_MAKERULE = \ @rm -f $@; \ echo "$(DOMAIN) {" >$@; \ echo " global: $(PMDAINIT);" >>$@; \ echo " local: *;" >>$@; \ echo "};" >>$@; \ # prepare symbols file for other platforms toolchain for shared libs # (convert one canonical format - GNU toolchain style - into others) ifeq "$(TARGET_OS)" "solaris" EXPORTS_MAKERULE = \ $(AWK) <$< >$@ '\ BEGIN { print "$$mapfile_version 2"; print } \ /\{$$/ { print "SYMBOL_VERSION", $$0; next } \ { print }' else EXPORTS_MAKERULE = endif # prepare domain.h used during the PMDA build process for each PMDA DOMAIN_MAKERULE = \ @rm -f $@; \ echo "/*" >$@; \ echo " * built from $<" >>$@; \ echo " */" >>$@; \ $(AWK) <$< '\ $$1=="\#define" && $$2 == "$(DOMAIN)" {\ print "\#define $(DOMAIN) " $$3 >>"$@"; found++ \ }\ END {\ if (found == 0) { \ print "Botch: no define for domain $(DOMAIN) in $<"; \ system("rm '$@'"); \ exit(1) \ }\ if (found > 1) { \ print "Botch: multiple defines for domain $(DOMAIN) in $<";\ print "... see $@ for details"; \ system("rm '$@'"); \ exit(1) \ }\ exit(0) \ }' || ( rm -f $@ && false ) DOMAIN_PERLRULE = \ @export perldomain=`sed -n \ -e '/PCP::PMDA->new/s/[^0-9]*$$//' \ -e '/PCP::PMDA->new/s/^[^0-9]*//p' pmda$(IAM).pl | \ $(AWK) '{ print $$NF }'`; \ $(AWK) <$< '\ BEGIN {\ domain = toupper("$(IAM)") \ }\ $$1=="\#define" && $$2 == domain { \ pmd=$$3; found++ \ }\ END {\ if (found == 0) {\ print "Botch: no define for domain " domain " in $<"; \ exit(1) \ }\ if (found > 1) {\ print "Botch: multiple defines of domain " domain " in $<";\ exit(1) \ }\ if (pmd != "'"$$perldomain"'") {\ print "Botch: domain number in ../../pmns/stdpmid (" pmd ") does not match domain number in Perl source ("'"$$perldomain"'")"; \ exit(1) \ }\ exit(0) \ }' DOMAIN_PYTHONRULE = \ @export pythondomain=`sed -n \ -e '/PMDA(/s/[^0-9]*$$//' \ -e '/PMDA(/s/^[^0-9]*//p' $(PYSCRIPT) | \ $(AWK) '{ print $$NF }'`; \ $(AWK) <$< '\ BEGIN {\ domain = toupper("$(IAM)") \ }\ $$1=="\#define" && $$2 == domain { \ pmd=$$3; found++ \ }\ END {\ if (found == 0) {\ print "Botch: no define for domain " domain " in $<"; \ exit(1) \ }\ if (found > 1) {\ print "Botch: multiple defines of domain " domain " in $<";\ exit(1) \ }\ if (pmd != "'"$$pythondomain"'") {\ print "Botch: domain number in ../../pmns/stdpmid (" pmd ") does not match domain number in Python source ("'"$$pythondomain"'")"; \ exit(1) \ }\ exit(0) \ }' POD_OPTIONS = --section=$(MAN_SECTION) --release=$(PCP_VERSION) \ --center="Performance Co-Pilot" --date="Performance Co-Pilot" POD_MAKERULE = $(POD2MAN) $(POD_OPTIONS) $^ $@ ifeq "$(TARGET_OS)" "mingw" INSTALL_MAN = else INSTALL_MAN = \ test -z "$$MAN_PAGES" && MAN_PAGES="$(MAN_PAGES)"; \ if [ "$(HAVE_MANPAGES)" = "true" ] ; then \ for d in `echo $$MAN_PAGES`; do \ first=true; \ base=`echo $$d | sed -e 's/\.[0-9]//g'`; \ section=`echo $$d | sed -e 's/.*\.//g'`; \ $(AWK) <$$d ' \ BEGIN { state=0 } \ $$1==".ds" && $$2=="xM" { print $$3; next } \ $$1==".ds" { ds["\\\\\\*\\("$$2] = $$3 } \ $$1==".SH" && $$2=="NAME" { state=1; next } \ $$1==".SH" && state==1 { exit } \ /^\./ { next } \ state==1 { for (i=1;i<=NF;i++) { \ if ($$i=="\\-" || $$i=="-") exit; \ gsub ("\\\\f3", "", $$i); gsub ("\\\\f1.*", "", $$i); \ for ( d in ds ) sub (d, ds[d], $$i); \ print $$i \ } \ }' \ | while read m; do \ [ -z "$$m" -o "$$m" = "\\" ] && continue; \ t=$(PCP_MAN_DIR)/man$$section/$$m.$$section; \ if $$first; then \ _tfx= ;\ if $(NEED_OLD_TBL_HEADER) ; then \ $(SED) -e "1s/^'\\\\\"! tbl.*/'\\\\\" t/" $$d > $$d.tmp; _tfx=.tmp; \ fi; \ if $(HAVE_GZIPPED_MANPAGES) ; then \ $(ZIP) -c $$d$$_tfx > $$d.gz; _tfx=.gz; _sfx=.gz; \ fi; \ if $(HAVE_BZIP2ED_MANPAGES) ; then \ $(BZIP2) -c $$d$$_tfx > $$d.bz2; _tfx=.bz2; _sfx=.bz2; \ fi; \ if $(HAVE_LZMAED_MANPAGES) ; then \ $(LZMA) -c $$d$$_tfx > $$d.lzma; _tfx=.lzma; _sfx=.lzma; \ fi; \ if $(HAVE_XZED_MANPAGES) ; then \ $(XZ) -c $$d$$_tfx > $$d.xz; _tfx=.xz; _sfx=.xz; \ fi; \ u=$$m.$$section$$_sfx; \ echo $(INSTALL) -m 644 $${d}$$_tfx $${t}$$_sfx; \ $(INSTALL) -m 644 $${d}$$_tfx $${t}$$_sfx; \ else \ echo $(INSTALL) -S $$u $${t}$$_sfx; \ $(INSTALL) -S $$u $${t}$$_sfx; \ fi; \ first=false; \ done; \ done; \ fi endif MANPAGE_SUFFIX = _sfx=.gz; \ $(HAVE_BZIP2ED_MANPAGES) && _sfx=.bz2; \ $(HAVE_LZMAED_MANPAGES) && _sfx=.lzma; \ $(HAVE_XZED_MANPAGES) && _sfx=.xz; \ PERL_INSTALL_BASE = /usr PERL_INSTALLDIRS = vendor # MakeMaker INSTALL_BASE needs to be unset for proper vendor_perl paths to be used for --prefix=/usr; ifeq "$(PERL_INSTALL_BASE)" "/usr" ifneq "$(TARGET_OS)" "darwin" MAKEMAKER_EXTRA_OPTIONS= else MAKEMAKER_EXTRA_OPTIONS=INSTALL_BASE=$(PERL_INSTALL_BASE) INSTALLBASE=$(PERL_INSTALL_BASE) endif else MAKEMAKER_EXTRA_OPTIONS=INSTALL_BASE=$(PERL_INSTALL_BASE) INSTALLBASE=$(PERL_INSTALL_BASE) endif PERL_MAKE_MAKEFILE = \ export PCP_TOPDIR="`cd $(TOPDIR) && pwd`"; \ TARGET_OS="$(TARGET_OS)" CC="$(CC) $(CFLAGS_ABI)" perl Makefile.PL $(MAKEMAKER_EXTRA_OPTIONS) $(MAKEMAKER_OPTIONS) # Collect files from a Perl "make -f Makefile install" below # src/perl to build the PCP Perl packaging list, and also clean up # the installed files to remove unwanted files and make the DSO # executable # # Usage is $(call PERL_GET_FILELIST,target,listfile,base) # where target is the Makefile target (install or install_perl), # listfile is something like $(TOPDIR)/perl-pcp-pmda.list and # base is the DSO basename like PMDA. # # We need different versions for the different installation and # packaging regimes. # ifeq "$(PACKAGE_DISTRIBUTION)" "debian" # For Debian packaging, this is not needed PERL_GET_FILELIST = else ifeq "$(PACKAGE_DISTRIBUTION)" "gentoo" # Gentoo cannot rely on the .packlist files from the install, so create # a temporary pack.list file PERL_GET_FILELIST = \ $(PERLMAKE) -f Makefile $(1) DESTDIR="$$DIST_ROOT" \ | tee pack.list; \ sed -n -e '/\.bs$$/d' -e 's/\.[0-9]pm$$/&.gz/' -e "s@^Installing $$DIST_ROOT@@p" <pack.list >$(2) || exit 1; \ if [ -s $(2) ]; then rm -f pack.list; \ else echo "Arrgh ... no files to include in package via $(2), see pack.list"; exit 1; \ fi; \ find "$$DIST_ROOT/$(PERL_INSTALL_BASE)" -name perllocal.pod -exec rm -f '{}' ';' ; \ find "$$DIST_ROOT/$(PERL_INSTALL_BASE)" -name \*.bs -exec rm -f '{}' ';' ; \ find "$$DIST_ROOT/$(PERL_INSTALL_BASE)" -name $(3).so -exec chmod 755 '{}' ';' else ifeq "$(PACKAGE_DISTRIBUTION)" "freebsd" # FreeBSD Perl packaging is a broken mystery at this point in time # 1. there is no .packlist files being created # 2. $(PERLMAKE) -f Makefile install DESTDIR=$$DIST_ROOT does not work # so disable the packaging pro tem PERL_GET_FILELIST = else # Everyone else ... includes the RPM-based packaging platforms ifeq "$(PACKAGE_DISTRIBUTION)" "mandriva" man_suffix=lzma else man_suffix=gz endif PERL_GET_FILELIST = \ $(PERLMAKE) -f Makefile $(1) DESTDIR="$$DIST_ROOT"; \ find "$$DIST_ROOT/$(PERL_INSTALL_BASE)" -name .packlist -exec mv '{}' $(2) ';' ; \ if [ -s $(2) ] ; then \ $(MANPAGE_SUFFIX) \ if [ "$(HAVE_MANPAGES)" = "false" ] ; then \ sed -e '/.*man[1-9].*/d' -e '/.*3pm.*/d' $(2) >$(2).tmp; \ mv $(2).tmp $(2); \ find "$$DIST_ROOT/$(PERL_INSTALL_BASE)" -name "*3pm*" -exec rm -rf '{}' ';' ; \ fi ;\ sed -n -e '/\.bs$$/d' -e 's/\.[0-9]pm$$/&'"$$_sfx/" -e "s@^$$DIST_ROOT@@p" $(2) >$(2).tmp; \ mv $(2).tmp $(2); \ else echo "Arrgh ... no files to include in package via $(2)"; exit 1; \ fi; \ find "$$DIST_ROOT/$(PERL_INSTALL_BASE)" -name perllocal.pod -exec rm -f '{}' ';' ; \ find "$$DIST_ROOT/$(PERL_INSTALL_BASE)" -name \*.bs -exec rm -f '{}' ';' ; \ find "$$DIST_ROOT/$(PERL_INSTALL_BASE)" -name $(3).so -exec chmod 755 '{}' ';' endif endif endif # Create perl manifest files explicitly for some distributions ifeq "$(shell [ '$(PACKAGE_DISTRIBUTION)' = cocoa \ -o '$(PACKAGE_DISTRIBUTION)' = macosx \ -o '$(PACKAGE_DISTRIBUTION)' = gentoo \ -o '$(PACKAGE_DISTRIBUTION)' = solaris \ -o '$(PACKAGE_DISTRIBUTION)' = freebsd \ -o '$(PACKAGE_DISTRIBUTION)' = openbsd \ ] && echo 1)" "1" # Gather installed Perl files before packaging PERL_INSTALL = \ if [ -n "$(DIST_MANIFEST)" ]; then \ if [ "`echo $(TOPDIR)/perl-pcp-*.list`" != "$(TOPDIR)/perl-pcp-*.list" ]; then \ cat $(TOPDIR)/perl-pcp-*.list | while read f; do \ bn=`basename $$f .gz`; \ dn=`dirname $$f`; \ $(INSTALL) -d $$dn || exit 1; \ src=`find */blib -name $$bn`; \ if [ -x $$src ] ; then mode=0755; else mode=0644; fi; \ $(INSTALL) -m $$mode $$src $$dn/$$bn || exit 1; \ done; \ fi; \ fi else PERL_INSTALL = endif # # Python platform-specific installation quirks PYTHON_PREFIX=/usr SETUP_PY_BUILD_OPTIONS = --include-dirs=$(TOPDIR)/src/include:$(TOPDIR)/src/include/pcp$(EXTRA_PY_INCLUDES) SETUP_PY_BUILD_OPTIONS += --library-dirs=$(TOPDIR)/src/libpcp/src:$(TOPDIR)/src/libpcp_pmda/src:$(TOPDIR)/src/libpcp_gui/src:$(TOPDIR)/src/libpcp_import/src:$(TOPDIR)/src/libpcp_mmv/src SETUP_PY_INSTALL_OPTIONS = --skip-build SETUP_PY_INSTALL_OPTIONS += --root="$${DIST_ROOT:-/}" ifeq "$(PYTHON_PREFIX)" "/usr" ifeq "$(PACKAGE_DISTRIBUTION)" "debian" SETUP_PY_INSTALL_OPTIONS += --install-layout=deb endif else SETUP_PY_INSTALL_OPTIONS += --prefix=$(PYTHON_PREFIX) endif ifeq "$(ENABLE_PYTHON3)" "true" SETUP_PY_BUILD_OPTIONS += -DENABLE_PYTHON3 endif # RPM byte-compiles and installs results in our DIST_ROOT, cater for this: ifeq "$(shell [ '$(TARGET_OS)' = linux -a '$(PACKAGE_DISTRIBUTION)' != gentoo \ ] && echo 1)" "1" # Linux and not Gentoo (which needs tarball packaging) PYTHON_INSTALL = \ cat $(TOPDIR)/python-pcp.list | while read f; do \ dirname $$f | $(SED) -e '/.*packages$$/d'; \ done | $(PCP_SORT_PROG) -u > $(TOPDIR)/python-pcp.list.rpm; \ $(AWK) '{print} /\.pyc$$/ {sub(/\.pyc$$/,".pyo"); print}' \ < $(TOPDIR)/python-pcp.list >> $(TOPDIR)/python-pcp.list.rpm; \ cat $(TOPDIR)/python-pcp.list.rpm | while read f; do \ touch "$${DIST_ROOT-/}$$f"; \ done PYTHON3_INSTALL = \ cat $(TOPDIR)/python3-pcp.list | while read f; do \ dirname $$f | $(SED) -e '/.*packages$$/d'; \ done | $(PCP_SORT_PROG) -u > $(TOPDIR)/python3-pcp.list.rpm; \ $(AWK) '{print} /\.pyc$$/ {sub(/\.pyc$$/,".pyo"); print}' \ < $(TOPDIR)/python3-pcp.list >> $(TOPDIR)/python3-pcp.list.rpm; \ $(AWK) '/\.pyc$$/ {sub(/\.pyc$$/,".opt-1.pyc"); print}' \ < $(TOPDIR)/python3-pcp.list >> $(TOPDIR)/python3-pcp.list.rpm; \ cat $(TOPDIR)/python3-pcp.list.rpm | while read f; do \ touch "$${DIST_ROOT-/}$$f"; \ done else ifeq "$(shell [ '$(PACKAGE_DISTRIBUTION)' = cocoa \ -o '$(PACKAGE_DISTRIBUTION)' = macosx \ -o '$(PACKAGE_DISTRIBUTION)' = gentoo \ -o '$(PACKAGE_DISTRIBUTION)' = solaris \ -o '$(PACKAGE_DISTRIBUTION)' = freebsd \ ] && echo 1)" "1" # Gather installed Python files before packaging # Lines in python-pcp.list are like this # /usr/lib/python2.7/site-packages/pcp.py # /usr/lib/python2.7/site-packages/pcp.pyc # /usr/lib/python2.7/site-packages/pmapi.so # /usr/lib/python2.7/site-packages/pcp-0.2-py2.7.egg-info # # Matching build artifacts are below src/python/build # PYTHON_INSTALL = \ if [ -n "$(DIST_MANIFEST)" ]; then \ cat $(TOPDIR)/python-pcp.list \ | while read f; do \ bn=`basename $$f`; \ dn=`dirname $$f`; \ pydir="$(TOPDIR)/src/python"; \ $(INSTALL) -d $$dn || exit 1; \ for src in `find $$pydir/build $$pydir/pcp.egg-info -name $$bn`; do \ $(INSTALL) $$src $$f || exit 1; \ done; \ done; \ fi PYTHON3_INSTALL = \ if [ -n "$(DIST_MANIFEST)" ]; then \ cat $(TOPDIR)/python3-pcp.list \ | while read f; do \ bn=`basename $$f`; \ dn=`dirname $$f`; \ pydir="$(TOPDIR)/src/python"; \ $(INSTALL) -d $$dn || exit 1; \ for src in `find $$pydir/build $$pydir/pcp.egg-info -name $$bn`; do \ $(INSTALL) $$src $$f || exit 1; \ done; \ done; \ fi else ifeq "$(shell [ '$(PACKAGE_DISTRIBUTION)' = openbsd \ ] && echo 1)" "1" # similar to above, but files already installed in DIST_ROOT so # just append to the manifest PYTHON_INSTALL = \ if [ -n "$(DIST_MANIFEST)" ]; then \ cat $(TOPDIR)/python-pcp.list \ | while read f; do \ bn=`basename $$f`; \ dn=`dirname $$f`; \ $(INSTALL) -d $$dn || exit 1; \ src=`find "$(DIST_ROOT)/usr/lib" -name $$bn`; \ $(INSTALL) $$src $$f || exit 1; \ done; \ fi PYTHON3_INSTALL = \ if [ -n "$(DIST_MANIFEST)" ]; then \ cat $(TOPDIR)/python3-pcp.list \ | while read f; do \ bn=`basename $$f`; \ dn=`dirname $$f`; \ $(INSTALL) -d $$dn || exit 1; \ src=`find "$(DIST_ROOT)/usr/lib" -name $$bn`; \ $(INSTALL) $$src $$f || exit 1; \ done; \ fi else # default case if all of the above tests fail PYTHON_INSTALL = endif # openbsd if endif # cocoa ... freebsd if endif # linux && !gentoo if # Linux and Unix platforms: ifeq "$(findstring $(PCP_PLATFORM),darwin mingw)" "" BINARY = build/$(QT_RELEASE)/$(COMMAND) LNMAKE = test ! -f $(BINARY) -o -L $(COMMAND) || ( rm -f $(COMMAND) && $(LN_S) $(BINARY) $(COMMAND) ) WINDOW = x11 # qmake botches the order of the -L arguments in the generated $(LIBS) # in the Makefile ... need to get the Qt libraries dir (begins with a /) # out from the head of the list and insert it before the first -l argument # (or the end of the list). # So, for example # LIBS = $(SUBLIBS) -L/usr/lib -L../libpcp/src -L../libpcp_qmc/src ... -lpcp_qmc ... # becomes # LIBS = $(SUBLIBS) -L../libpcp/src -L../libpcp_qmc/src ... -L/usr/lib -lpcp_qmc ... # QTFIX = sed -e 's/Makefile.new/Makefile/g' <Makefile.new | $(AWK) '$$1 == "LIBS" { printf $$1; for (i=2;i<=NF;i++) { if ($$i~/^-L\//) { save=save " " $$i; continue } else if (save!="" && $$i~/^-l/) { printf " %s",save; save="" } printf " %s",$$i } if (save!="") printf " %s",save; print ""; next } { print }' >Makefile.fix # # Qt magic for build/installs across all the supported platforms # because qmake does not always get it right, e.g. omitting -fPIC for # static libraries in Qt5 on Ubuntu x86_64, we need to push our CFLAGS, CXXFLAGS # (usually empty) and LDFLAGS down # QTMAKE = rm -f Makefile.new Makefile.fix; export CC='$(CC)'; export CXX='$(CXX)'; CFLAGS='$(CFLAGS)' CXXFLAGS='$(CXXFLAGS)' LDFLAGS='$(LDFLAGS)' $(QMAKE) -o Makefile.new CONFIG+=$(QT_RELEASE) && $(QTFIX) && ( if [ -f Makefile ]; then if diff Makefile Makefile.fix >/dev/null; then :; else rm -f Makefile; mv Makefile.fix Makefile; fi; else mv Makefile.fix Makefile; fi ); rm -f Makefile.new Makefile.fix; $(MAKE) $(MAKEOPTS) -f Makefile else # Windows and Mac platforms: QTMAKE = CFLAGS='$(CFLAGS)' CXXFLAGS='$(CXXFLAGS)' LDFLAGS='$(LDFLAGS)' $(QMAKE) CONFIG+=$(QT_RELEASE) && $(MAKE) $(MAKEOPTS) -f Makefile ifeq ($(PCP_PLATFORM),darwin) MACBUILD = build/$(QT_RELEASE)/$(COMMAND).app/Contents BINARY = $(MACBUILD)/MacOS/$(COMMAND) LNMAKE = test ! -f $(BINARY) -o -L $(COMMAND) || ( rm -f $(COMMAND) && $(LN_S) $(BINARY) $(COMMAND) ) WINDOW = mac endif ifeq ($(PCP_PLATFORM),mingw) BINARY = build/$(QT_RELEASE)/$(COMMAND)$(EXECSUFFIX) LNMAKE = WINDOW = win endif endif ifeq ($(PCP_PLATFORM),darwin) INSTALL_DIRECTORY_HIERARCHY=\ d=$(1); while [ "$$d" != "$(2)" -a "$$d" != "/" -a "$$d" != "." ] ; do \ echo $$d; d=`dirname $$d`; done | sort | while read id; do \ $(INSTALL) -m 755 -d $$id || exit 1; done INSTALL_QT_RESOURCES=\ printf "[Paths]\nPlugins=/Library/PCP/Plugins\n\n" > qt.conf; \ $(INSTALL) -m 644 qt.conf $(1)/qt.conf; \ rm qt.conf; \ find frameworks -type d -name qt_menu.nib | while read nib; do \ $(INSTALL) -m 755 -d $(1)/qt_menu.nib || exit 1; \ find $$nib -type f | while read nibs; do \ f=`basename $$nibs`; \ $(INSTALL) -m 644 $$nibs $(1)/qt_menu.nib/$$f || exit 1; \ done; \ done MAC_APPSUPPORT_DIR=/Library/PCP MAC_FRAMEWORKS_DIR=$(MAC_APPSUPPORT_DIR)/Frameworks # WARNING! # This rule modified the binary it was given, once modified the # binary cannot be used with this rule again. # If the binary is installed then it's important to call this # rule before calling install rule for the binary. INSTALL_QT_FRAMEWORKS=\ otool -L $(1) | awk '{if (NR != 1) {print $$1}}' |\ grep -E 'Qt.*\.framework' | while read qt; do \ tdir=`dirname $$qt`; \ install_name_tool -change $$qt $(MAC_FRAMEWORKS_DIR)/$$qt $(1);\ $(call INSTALL_DIRECTORY_HIERARCHY,$(MAC_FRAMEWORKS_DIR)/$$tdir,/Library/PCP); \ mkdir -p frameworks/$$tdir || exit 1; \ fwqt="frameworks/$$qt"; \ cp /Library/Frameworks/$$qt frameworks/$$qt || exit 1; \ otool -L $$fwqt | awk '{if (NR != 1) {print $$1}}' |\ grep -E 'Qt.*\.framework' | while read dep; do \ install_name_tool -change $$dep $(MAC_FRAMEWORKS_DIR)/$$dep $$fwqt;\ done; \ $(INSTALL) frameworks/$$qt $(MAC_FRAMEWORKS_DIR)/$$qt; \ if [ -d /Library/Frameworks/$$tdir/Resources ] ; then \ $(INSTALL) -d $(MAC_FRAMEWORKS_DIR)/$$tdir/Resources; \ (cd /Library/Frameworks/$$tdir; find Resources -type f) | \ while read rf; do \ rfpath="$$tdir/$$rf"; rfd=`dirname $$rfpath`; \ fwpath="frameworks/$$rfpath"; brfd=`basename $$rfd`; \ mkdir -p frameworks/$$rfd || exit 1; \ cp /Library/Frameworks/$$rfpath $$fwpath || exit 1; \ [ $$brfd != qt_menu.nib ] || continue; \ $(INSTALL) -d $(MAC_FRAMEWORKS_DIR)/$$rfd || exit 1; \ $(INSTALL) $$fwpath $(MAC_FRAMEWORKS_DIR)/$$rfpath;\ done \ fi; done endif # For targets that should always be rebuilt, # define a target that is never up-to-date. # Targets needing this should depend on $(_FORCE) _FORCE = __force_build PCP_USER = pcp PCP_GROUP = pcp PCP_USER_INSTALL = root PCP_GROUP_INSTALL = root # systemd service type for logutil scripts SD_SERVICE_TYPE=exec PCPLIB = -lpcp PCPLIB_EXTRAS = $(LIB_FOR_MATH) $(LIB_FOR_PTHREADS) $(LIB_FOR_DLOPEN) $(LIB_FOR_RT) ifneq "$(PCPLIB)" "$(LIB_FOR_BASENAME)" PCPLIB_EXTRAS += $(LIB_FOR_BASENAME) endif ifeq "$(ENABLE_SHARED)" "no" PCPLIB += $(PCPLIB_EXTRAS) endif PCP_GUILIB = -lpcp_gui $(PCPLIB) PCP_PMDALIB = -lpcp_pmda $(PCPLIB) PCP_TRACELIB = -lpcp_trace $(PCPLIB) PCP_MMVLIB = -lpcp_mmv $(PCPLIB) PCPWEBLIB_EXTRAS = $(LIB_FOR_LIBSASL2) $(LIB_FOR_OPENSSL) $(LIB_FOR_LIBUV) $(LIB_FOR_LIBINH) $(PCP_PMDALIB) $(PCP_MMVLIB) PCP_WEBLIB = -lpcp_web $(PCPWEBLIB_EXTRAS) PCP_ARCHIVELIB = -lpcp_archive ifdef PCP_ALTLIBS ifeq ($(PCP_LIB_DIR),$(PCP_LIB32_DIR)) PCP_ALTLIBS = else ifneq "$(findstring $(MAKECMDGOALS),clean clobber)" "" PCP_ALTLIBS = endif endif endif # (optional) hook for developer build definitions # -include $(TOPDIR)/src/include/builddefs_dev endif # _BUILDDEFS_INCLUDED_ # # Copyright (c) 2013-2014 Red Hat. # Copyright (c) 2007 Aconex. All Rights Reserved. # Copyright (c) 2000,2003,2004 Silicon Graphics, Inc. All Rights Reserved. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # Common build rules for gmake # ifndef _BUILDRULES_INCLUDED_ _BUILDRULES_INCLUDED_ = 1 ifndef _BUILDDEFS_INCLUDED_ include $(TOPDIR)/src/include/builddefs endif # # Standard targets # ifdef CMDTARGET $(CMDTARGET) : $(SUBDIRS) $(OBJECTS) $(CCF) -o $(CMDTARGET) $(LDFLAGS) $(OBJECTS) $(LDLIBS) endif ifdef CXXMDTARGET $(CXXMDTARGET) : $(SUBDIRS) $(OBJECTS) $(CXXF) -o $(CXXMDTARGET) $(LDFLAGS) $(OBJECTS) $(LDLIBS) endif # GNU make has a built-in recipe for .cc / .C / .cpp, but not for .cxx -> .o .cxx.o: $(CXXF) $(CXXFLAGS) -c $< -o $@ .SUFFIXES: .cxx ifdef LIBTARGET ifneq (, $(filter linux freebsd kfreebsd netbsd openbsd mingw gnu, $(TARGET_OS))) _SHAREDOPTS = -shared -Wl,-soname,$(LIBTARGET) endif ifeq ($(TARGET_OS), solaris) _SHAREDOPTS = -shared -fpic endif ifeq ($(TARGET_OS), darwin) # libtool doesnt understand -dynamiclib so we need both _SHAREDOPTS = -fPIC -dynamic -dynamiclib -flat_namespace -undefined suppress -headerpad_max_install_names endif ifeq ($(TARGET_OS), aix) _SHAREDOPTS = -qmkshrobj endif ifdef VERSION_SCRIPT ifneq ($(INVISIBILITY),) ifeq ($(TARGET_OS), darwin) # Mac OS X ld(1) takes a different format for the symbols file # EXPORTS = $(VERSION_SCRIPT).darwin # _SHAREDOPTS += -Wl,-exported_symbols_list $(EXPORTS) # LDIRT += $(EXPORTS) else ifeq ($(TARGET_OS), solaris) EXPORTS = $(VERSION_SCRIPT).solaris _SHAREDOPTS += -Wl,-M $(EXPORTS) LDIRT += $(EXPORTS) else EXPORTS = $(VERSION_SCRIPT) _SHAREDOPTS += -Wl,--version-script=$(EXPORTS) endif endif endif endif ifneq ($(EXPORTS), $(VERSION_SCRIPT)) $(EXPORTS) : $(VERSION_SCRIPT) $(EXPORTS_MAKERULE) endif $(LIBTARGET) : $(SUBDIRS) $(OBJECTS) $(EXPORTS) $(CC) $(LDFLAGS) $(_SHAREDOPTS) -o $(LIBTARGET) $(OBJECTS) $(LDLIBS) $(LIB_FOR_DLOPEN) $(LIB_FOR_BASENAME) endif ifdef STATICLIBTARGET $(STATICLIBTARGET) : $(SUBDIRS) $(OBJECTS) ifeq ($(TARGET_OS), darwin) libtool -static -o $(STATICLIBTARGET) $? else $(AR) cr $(STATICLIBTARGET) $? endif endif ifdef WINDOWLINKS windowlinks: @for l in $(WINDOWLINKS) ; do \ if [ ! -L $$l -a ! -f $$l ] ; then \ $(LN_S) $(WINDOW)_$$l $$l ; \ fi \ done endif # Suffix rule to support transition for YFILES to OBJECTS %.tab.h : %.y $(YACC) -d -b `basename $< .y` $< %.tab.c : %.y $(YACC) -d -b `basename $< .y` $< # Dealing with quirks of the various packaging mechanisms %.py: %.python rm -f $@ $(LN_S) $< $@ %.pl: %.perl rm -f $@ $(LN_S) $< $@ ifeq ($(TARGET_OS), mingw) # # .exe rule for Windows # .SUFFIXES: .exe .o.exe: $(CCF) -o $* $(LDFLAGS) $(OBJECTS) $(LDLIBS) endif check :: $(SUBDIRS) ifdef SUBDIRS $(SUBDIRS_MAKERULE) endif clean clobber :: $(SUBDIRS) $(PRO_SUBDIRS) $(SNIA_SUBDIRS) rm -rf $(DIRT) @rm -fr $(DIRDIRT) $(SUBDIRS_MAKERULE) realclean distclean: clean rm -f $(TOPDIR)/src/include/builddefs \ $(TOPDIR)/src/include/pcp.conf \ $(TOPDIR)/src/include/pcp/config.h \ $(TOPDIR)/src/include/pcp/configsz.h \ $(TOPDIR)/src/include/pcp/platform_defs.h \ $(TOPDIR)/src/libpcp/src/pmdbg.h rm -f $(TOPDIR)/build/GNUlocaldefs rm -f $(TOPDIR)/pcp.lsm # # Never blow away subdirs # ifdef SUBDIRS .PRECIOUS: $(SUBDIRS) endif endif $(_FORCE): # The depend target does not depend on any other targets (even though it # actually depends on CFILES and HFILES). This is because there are several # places where we generate header files (e.g. domain.h is generated for each # subdir below src/pmdas, and domain.h in turn depends on src/pmns/stdpmid, # which itself a generated file ...). As a result, you can't run make # depend after make clobber, because the generated files will be missing. # # So running makedepend is for development use when you change a header # somewhere and you need to be sure everything that depends on that header # will be remade properly. .PHONY : depend $(_FORCE) depend : $(SUBDIRS) $(SUBDIRS_MAKERULE) touch dep $(MAKEDEPEND) -fdep -- $(CFLAGS) -- $(CFILES) # # include dep, but only if it exists -include dep # Support for building multiple versions of the same library ifneq ($(PCP_ALTLIBS),) $(PCP_ALTLIBS): rm -rf $@ mkdir $@ cp GNUlocaldefs.$@ $@/GNUlocaldefs $(MAKE) -C src SLDEST=../$@ SLSRC=../src libsrc_symlinks endif libsrc_symlinks: test -n "$(SLDEST)" -a -d $(SLDEST) for f in $(SRCFILES); do \ if [ -e $(SLDEST)/$$f -a ! -L $(SLDEST)/$$f ] ; then \ echo "$$f exists in $(SLDEST) and not a symlink"; exit 1; \ fi; \ rm -f $(SLDEST)/$$f; $(LN_S) $(SLSRC)/$$f $(SLDEST)/$$f || exit 1; \ done /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Thomas E. Dickey 1996 on * ****************************************************************************/ /* * $Id: tic.h,v 1.82 2021/03/20 16:06:15 tom Exp $ * tic.h - Global variables and structures for the terminfo compiler. */ #ifndef __TIC_H #define __TIC_H /* *INDENT-OFF* */ #ifdef __cplusplus extern "C" { #endif #include <ncurses_cfg.h> #include <curses.h> /* for the _tracef() prototype, ERR/OK, bool defs */ /* ** The format of SVr2 compiled terminfo files is as follows: ** ** Header (12 bytes), containing information given below ** Names Section, containing the names of the terminal ** Boolean Section, containing the values of all of the ** boolean capabilities ** A null byte may be inserted here to make ** sure that the Number Section begins on an ** even word boundary. ** Number Section, containing the values of all of the numeric ** capabilities, each as a short integer ** String Section, containing short integer offsets into the ** String Table, one per string capability ** String Table, containing the actual characters of the string ** capabilities. ** ** In the SVr2 format, "short" means signed 16-bit numbers, which is sometimes ** inconvenient. The numbers are signed, to provide for absent and canceled ** values. ncurses6.1 introduced an extension to this compiled format, by ** making the Number Section a list of signed 32-bit integers. ** ** NOTE that all short integers in the file are stored using VAX/PDP-style ** byte-order, i.e., least-significant byte first. ** ** There is no structure definition here because it would only confuse ** matters. Terminfo format is a raw byte layout, not a structure ** dump. If you happen to be on a little-endian machine with 16-bit ** shorts that requires no padding between short members in a struct, ** then there is a natural C structure that captures the header, but ** not very helpfully. */ #define MAGIC 0432 /* first two bytes of a compiled entry */ #define MAGIC2 01036 /* first two bytes of a compiled 32-bit entry */ #undef BYTE #define BYTE(p,n) (unsigned char)((p)[n]) #define IS_NEG1(p) ((BYTE(p,0) == 0377) && (BYTE(p,1) == 0377)) #define IS_NEG2(p) ((BYTE(p,0) == 0376) && (BYTE(p,1) == 0377)) #define LOW_MSB(p) (BYTE(p,0) + 256*BYTE(p,1)) #define IS_TIC_MAGIC(p) (LOW_MSB(p) == MAGIC || LOW_MSB(p) == MAGIC2) #define quick_prefix(s) (!strncmp((s), "b64:", (size_t)4) || !strncmp((s), "hex:", (size_t)4)) /* * The "maximum" here is misleading; XSI guarantees minimum values, which a * given implementation may exceed. */ #define MAX_NAME_SIZE 512 /* maximum legal name field size (XSI:127) */ #define MAX_ENTRY_SIZE1 4096 /* maximum legal entry size (SVr2) */ #define MAX_ENTRY_SIZE2 32768 /* maximum legal entry size (ncurses6.1) */ #if NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR #define MAX_ENTRY_SIZE MAX_ENTRY_SIZE2 #else #define MAX_ENTRY_SIZE MAX_ENTRY_SIZE1 #endif /* * The maximum size of individual name or alias is guaranteed in XSI to be at * least 14, since that corresponds to the older filename lengths. Newer * systems allow longer aliases, though not many terminal descriptions are * written to use them. The MAX_ALIAS symbol is used for warnings. */ #if HAVE_LONG_FILE_NAMES #define MAX_ALIAS 32 /* smaller than POSIX minimum for PATH_MAX */ #else #define MAX_ALIAS 14 /* SVr3 filename length */ #endif /* location of user's personal info directory */ #define PRIVATE_INFO "%s/.terminfo" /* plug getenv("HOME") into %s */ /* * Some traces are designed to be used via tic's verbose option (and similar in * infocmp and toe) rather than the 'trace()' function. So we use the bits * above the normal trace() parameter as a debug-level. */ #define MAX_DEBUG_LEVEL 15 #define DEBUG_LEVEL(n) ((n) << TRACE_SHIFT) #define set_trace_level(n) \ _nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL) \ + DEBUG_LEVEL(MAX_DEBUG_LEVEL) - 1, \ _nc_tracing |= DEBUG_LEVEL(n) #ifdef TRACE #define DEBUG(n, a) if (_nc_tracing >= DEBUG_LEVEL(n)) _tracef a #else #define DEBUG(n, a) /*nothing*/ #endif /* * These are the types of tokens returned by the scanner. The first * three are also used in the hash table of capability names. The scanner * returns one of these values after loading the specifics into the global * structure curr_token. */ #define BOOLEAN 0 /* Boolean capability */ #define NUMBER 1 /* Numeric capability */ #define STRING 2 /* String-valued capability */ #define CANCEL 3 /* Capability to be cancelled in following tc's */ #define NAMES 4 /* The names for a terminal type */ #define UNDEF 5 /* Undefined */ #define NO_PUSHBACK -1 /* used in pushtype to indicate no pushback */ /* * The global structure in which the specific parts of a * scanned token are returned. */ struct token { char *tk_name; /* name of capability */ int tk_valnumber; /* value of capability (if a number) */ char *tk_valstring; /* value of capability (if a string) */ }; /* * Offsets to string capabilities, with the corresponding functionkey codes. */ struct tinfo_fkeys { unsigned offset; chtype code; }; typedef short HashValue; /* * The file comp_captab.c contains an array of these structures, one per * possible capability. These are indexed by a hash table array of pointers to * the same structures for use by the parser. */ struct name_table_entry { const char *nte_name; /* name to hash on */ int nte_type; /* BOOLEAN, NUMBER or STRING */ HashValue nte_index; /* index of associated variable in its array */ HashValue nte_link; /* index in table of next hash, or -1 */ }; /* * Use this structure to hide differences between terminfo and termcap tables. */ typedef struct { unsigned table_size; const HashValue *table_data; HashValue (*hash_of)(const char *); int (*compare_names)(const char *, const char *); } HashData; struct alias { const char *from; const char *to; const char *source; }; #define NOTFOUND ((struct name_table_entry *) 0) /* * The file comp_userdefs.c contains an array of these structures, one per * possible capability. These are indexed by a hash table array of pointers to * the same structures for use by the parser. */ struct user_table_entry { const char *ute_name; /* name to hash on */ int ute_type; /* mask (BOOLEAN, NUMBER, STRING) */ unsigned ute_argc; /* number of parameters */ unsigned ute_args; /* bit-mask for string parameters */ HashValue ute_index; /* index of associated variable in its array */ HashValue ute_link; /* index in table of next hash, or -1 */ }; /* * The casts are required for correct sign-propagation with systems such as * AIX, IRIX64, Solaris which default to unsigned characters. The C standard * leaves this detail unspecified. */ /* out-of-band values for representing absent capabilities */ #define ABSENT_BOOLEAN ((signed char)-1) /* 255 */ #define ABSENT_NUMERIC (-1) #define ABSENT_STRING (char *)0 /* out-of-band values for representing cancels */ #define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */ #define CANCELLED_NUMERIC (-2) #define CANCELLED_STRING (char *)(-1) #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */ #define VALID_NUMERIC(s) ((s) >= 0) #define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING) /* termcap entries longer than this may break old binaries */ #define MAX_TERMCAP_LENGTH 1023 /* this is a documented limitation of terminfo */ #define MAX_TERMINFO_LENGTH 4096 #ifndef TERMINFO #define TERMINFO "/usr/share/terminfo" #endif #ifdef NCURSES_TERM_ENTRY_H_incl /* * These entrypoints are used only by the ncurses utilities such as tic. */ #ifdef NCURSES_INTERNALS /* access.c */ extern NCURSES_EXPORT(unsigned) _nc_pathlast (const char *); extern NCURSES_EXPORT(bool) _nc_is_abs_path (const char *); extern NCURSES_EXPORT(bool) _nc_is_dir_path (const char *); extern NCURSES_EXPORT(bool) _nc_is_file_path (const char *); extern NCURSES_EXPORT(char *) _nc_basename (char *); extern NCURSES_EXPORT(char *) _nc_rootname (char *); /* comp_captab.c */ extern NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool); extern NCURSES_EXPORT(const HashData *) _nc_get_hash_info (bool); extern NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool); /* comp_hash.c: name lookup */ extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_type_entry (const char *, int, bool); extern NCURSES_EXPORT(struct user_table_entry const *) _nc_find_user_entry (const char *); /* comp_scan.c: lexical analysis */ extern NCURSES_EXPORT(int) _nc_get_token (bool); extern NCURSES_EXPORT(void) _nc_panic_mode (char); extern NCURSES_EXPORT(void) _nc_push_token (int); extern NCURSES_EXPORT_VAR(int) _nc_curr_col; extern NCURSES_EXPORT_VAR(int) _nc_curr_line; extern NCURSES_EXPORT_VAR(int) _nc_syntax; extern NCURSES_EXPORT_VAR(int) _nc_strict_bsd; extern NCURSES_EXPORT_VAR(long) _nc_comment_end; extern NCURSES_EXPORT_VAR(long) _nc_comment_start; extern NCURSES_EXPORT_VAR(long) _nc_curr_file_pos; extern NCURSES_EXPORT_VAR(long) _nc_start_line; #define SYN_TERMINFO 0 #define SYN_TERMCAP 1 /* comp_error.c: warning & abort messages */ extern NCURSES_EXPORT(const char *) _nc_get_source (void); extern GCC_NORETURN NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(void) _nc_get_type (char *name); extern NCURSES_EXPORT(void) _nc_set_source (const char *const); extern NCURSES_EXPORT(void) _nc_set_type (const char *const); extern GCC_NORETURN NCURSES_EXPORT(void) _nc_syserr_abort (const char *const,...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(void) _nc_warning (const char *const,...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings; /* comp_scan.c */ extern NCURSES_EXPORT_VAR(struct token) _nc_curr_token; /* comp_userdefs.c */ NCURSES_EXPORT(const struct user_table_entry *) _nc_get_userdefs_table (void); NCURSES_EXPORT(const HashData *) _nc_get_hash_user (void); /* captoinfo.c: capability conversion */ extern NCURSES_EXPORT(char *) _nc_captoinfo (const char *, const char *, int const); extern NCURSES_EXPORT(char *) _nc_infotocap (const char *, const char *, int const); /* home_terminfo.c */ extern NCURSES_EXPORT(char *) _nc_home_terminfo (void); /* init_keytry.c */ #if BROKEN_LINKER #define _nc_tinfo_fkeys _nc_tinfo_fkeysf() extern NCURSES_EXPORT(const struct tinfo_fkeys *) _nc_tinfo_fkeysf (void); #else extern NCURSES_EXPORT_VAR(const struct tinfo_fkeys) _nc_tinfo_fkeys[]; #endif /* lib_tparm.c */ #define NUM_PARM 9 extern NCURSES_EXPORT_VAR(int) _nc_tparm_err; extern NCURSES_EXPORT(int) _nc_tparm_analyze(const char *, char **, int *); /* lib_trace.c */ extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing; extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *); extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *); /* lib_tputs.c */ extern NCURSES_EXPORT_VAR(int) _nc_nulls_sent; /* Add one for every null sent */ /* comp_main.c: compiler main */ extern const char * _nc_progname; /* db_iterator.c */ extern NCURSES_EXPORT(const char *) _nc_next_db(DBDIRS *, int *); extern NCURSES_EXPORT(const char *) _nc_tic_dir (const char *); extern NCURSES_EXPORT(void) _nc_first_db(DBDIRS *, int *); extern NCURSES_EXPORT(void) _nc_last_db(void); /* write_entry.c */ extern NCURSES_EXPORT(int) _nc_tic_written (void); #endif /* NCURSES_INTERNALS */ /* * These entrypoints were used by tack before 1.08. */ #undef NCURSES_TACK_1_08 #ifdef NCURSES_INTERNALS #define NCURSES_TACK_1_08 /* nothing */ #else #define NCURSES_TACK_1_08 GCC_DEPRECATED("upgrade to tack 1.08") #endif /* comp_hash.c: name lookup */ extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry (const char *, const HashValue *) NCURSES_TACK_1_08; extern NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool) NCURSES_TACK_1_08; /* comp_scan.c: lexical analysis */ extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *) NCURSES_TACK_1_08; /* comp_expand.c: expand string into readable form */ extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int) NCURSES_TACK_1_08; /* comp_scan.c: decode string from readable form */ extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *) NCURSES_TACK_1_08; #endif /* NCURSES_TERM_ENTRY_H_incl */ #ifdef __cplusplus } #endif /* *INDENT-ON* */ #endif /* __TIC_H */ /* Copyright (C) 1992-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _ALLOCA_H #define _ALLOCA_H 1 #include <features.h> #define __need_size_t #include <stddef.h> __BEGIN_DECLS /* Remove any previous definition. */ #undef alloca /* Allocate a block that will be freed when the calling function exits. */ extern void *alloca (size_t __size) __THROW; #ifdef __GNUC__ # define alloca(size) __builtin_alloca (size) #endif /* GCC. */ __END_DECLS #endif /* alloca.h */ /* -----------------------------------------------------------------*-C-*- ffitarget.h - Copyright (c) 2012, 2014, 2018 Anthony Green Copyright (c) 1996-2003, 2010 Red Hat, Inc. Copyright (C) 2008 Free Software Foundation, Inc. Target configuration macros for x86 and x86-64. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ``Software''), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------- */ #ifndef LIBFFI_TARGET_H #define LIBFFI_TARGET_H #ifndef LIBFFI_H #error "Please do not include ffitarget.h directly into your source. Use ffi.h instead." #endif /* ---- System specific configurations ----------------------------------- */ /* For code common to all platforms on x86 and x86_64. */ #define X86_ANY #if defined (X86_64) && defined (__i386__) #undef X86_64 #define X86 #endif #ifdef X86_WIN64 #define FFI_SIZEOF_ARG 8 #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ #endif #define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION #ifndef _MSC_VER #define FFI_TARGET_HAS_COMPLEX_TYPE #endif /* ---- Generic type definitions ----------------------------------------- */ #ifndef LIBFFI_ASM #ifdef X86_WIN64 #ifdef _MSC_VER typedef unsigned __int64 ffi_arg; typedef __int64 ffi_sarg; #else typedef unsigned long long ffi_arg; typedef long long ffi_sarg; #endif #else #if defined __x86_64__ && defined __ILP32__ #define FFI_SIZEOF_ARG 8 #define FFI_SIZEOF_JAVA_RAW 4 typedef unsigned long long ffi_arg; typedef long long ffi_sarg; #else typedef unsigned long ffi_arg; typedef signed long ffi_sarg; #endif #endif typedef enum ffi_abi { #if defined(X86_WIN64) FFI_FIRST_ABI = 0, FFI_WIN64, /* sizeof(long double) == 8 - microsoft compilers */ FFI_GNUW64, /* sizeof(long double) == 16 - GNU compilers */ FFI_LAST_ABI, #ifdef __GNUC__ FFI_DEFAULT_ABI = FFI_GNUW64 #else FFI_DEFAULT_ABI = FFI_WIN64 #endif #elif defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN)) FFI_FIRST_ABI = 1, FFI_UNIX64, FFI_WIN64, FFI_EFI64 = FFI_WIN64, FFI_GNUW64, FFI_LAST_ABI, FFI_DEFAULT_ABI = FFI_UNIX64 #elif defined(X86_WIN32) FFI_FIRST_ABI = 0, FFI_SYSV = 1, FFI_STDCALL = 2, FFI_THISCALL = 3, FFI_FASTCALL = 4, FFI_MS_CDECL = 5, FFI_PASCAL = 6, FFI_REGISTER = 7, FFI_LAST_ABI, FFI_DEFAULT_ABI = FFI_MS_CDECL #else FFI_FIRST_ABI = 0, FFI_SYSV = 1, FFI_THISCALL = 3, FFI_FASTCALL = 4, FFI_STDCALL = 5, FFI_PASCAL = 6, FFI_REGISTER = 7, FFI_MS_CDECL = 8, FFI_LAST_ABI, FFI_DEFAULT_ABI = FFI_SYSV #endif } ffi_abi; #endif /* ---- Definitions for closures ----------------------------------------- */ #define FFI_CLOSURES 1 #define FFI_GO_CLOSURES 1 #define FFI_TYPE_SMALL_STRUCT_1B (FFI_TYPE_LAST + 1) #define FFI_TYPE_SMALL_STRUCT_2B (FFI_TYPE_LAST + 2) #define FFI_TYPE_SMALL_STRUCT_4B (FFI_TYPE_LAST + 3) #define FFI_TYPE_MS_STRUCT (FFI_TYPE_LAST + 4) #if defined (X86_64) || defined(X86_WIN64) \ || (defined (__x86_64__) && defined (X86_DARWIN)) /* 4 bytes of ENDBR64 + 7 bytes of LEA + 6 bytes of JMP + 7 bytes of NOP + 8 bytes of pointer. */ # define FFI_TRAMPOLINE_SIZE 32 # define FFI_NATIVE_RAW_API 0 #else /* 4 bytes of ENDBR32 + 5 bytes of MOV + 5 bytes of JMP + 2 unused bytes. */ # define FFI_TRAMPOLINE_SIZE 16 # define FFI_NATIVE_RAW_API 1 /* x86 has native raw api support */ #endif #if !defined(GENERATE_LIBFFI_MAP) && defined(__CET__) # include <cet.h> # if (__CET__ & 1) != 0 # define ENDBR_PRESENT # endif # define _CET_NOTRACK notrack #else # define _CET_ENDBR # define _CET_NOTRACK #endif #endif /* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #ifndef ZCONF_H #define ZCONF_H /* * If you *really* need a unique prefix for all types and library functions, * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. * Even better than compiling with -DZ_PREFIX would be to use configure to set * this permanently in zconf.h using "./configure --zprefix". */ #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ # define Z_PREFIX_SET /* all linked symbols and init macros */ # define _dist_code z__dist_code # define _length_code z__length_code # define _tr_align z__tr_align # define _tr_flush_bits z__tr_flush_bits # define _tr_flush_block z__tr_flush_block # define _tr_init z__tr_init # define _tr_stored_block z__tr_stored_block # define _tr_tally z__tr_tally # define adler32 z_adler32 # define adler32_combine z_adler32_combine # define adler32_combine64 z_adler32_combine64 # define adler32_z z_adler32_z # ifndef Z_SOLO # define compress z_compress # define compress2 z_compress2 # define compressBound z_compressBound # endif # define crc32 z_crc32 # define crc32_combine z_crc32_combine # define crc32_combine64 z_crc32_combine64 # define crc32_z z_crc32_z # define deflate z_deflate # define deflateBound z_deflateBound # define deflateCopy z_deflateCopy # define deflateEnd z_deflateEnd # define deflateGetDictionary z_deflateGetDictionary # define deflateInit z_deflateInit # define deflateInit2 z_deflateInit2 # define deflateInit2_ z_deflateInit2_ # define deflateInit_ z_deflateInit_ # define deflateParams z_deflateParams # define deflatePending z_deflatePending # define deflatePrime z_deflatePrime # define deflateReset z_deflateReset # define deflateResetKeep z_deflateResetKeep # define deflateSetDictionary z_deflateSetDictionary # define deflateSetHeader z_deflateSetHeader # define deflateTune z_deflateTune # define deflate_copyright z_deflate_copyright # define get_crc_table z_get_crc_table # ifndef Z_SOLO # define gz_error z_gz_error # define gz_intmax z_gz_intmax # define gz_strwinerror z_gz_strwinerror # define gzbuffer z_gzbuffer # define gzclearerr z_gzclearerr # define gzclose z_gzclose # define gzclose_r z_gzclose_r # define gzclose_w z_gzclose_w # define gzdirect z_gzdirect # define gzdopen z_gzdopen # define gzeof z_gzeof # define gzerror z_gzerror # define gzflush z_gzflush # define gzfread z_gzfread # define gzfwrite z_gzfwrite # define gzgetc z_gzgetc # define gzgetc_ z_gzgetc_ # define gzgets z_gzgets # define gzoffset z_gzoffset # define gzoffset64 z_gzoffset64 # define gzopen z_gzopen # define gzopen64 z_gzopen64 # ifdef _WIN32 # define gzopen_w z_gzopen_w # endif # define gzprintf z_gzprintf # define gzputc z_gzputc # define gzputs z_gzputs # define gzread z_gzread # define gzrewind z_gzrewind # define gzseek z_gzseek # define gzseek64 z_gzseek64 # define gzsetparams z_gzsetparams # define gztell z_gztell # define gztell64 z_gztell64 # define gzungetc z_gzungetc # define gzvprintf z_gzvprintf # define gzwrite z_gzwrite # endif # define inflate z_inflate # define inflateBack z_inflateBack # define inflateBackEnd z_inflateBackEnd # define inflateBackInit z_inflateBackInit # define inflateBackInit_ z_inflateBackInit_ # define inflateCodesUsed z_inflateCodesUsed # define inflateCopy z_inflateCopy # define inflateEnd z_inflateEnd # define inflateGetDictionary z_inflateGetDictionary # define inflateGetHeader z_inflateGetHeader # define inflateInit z_inflateInit # define inflateInit2 z_inflateInit2 # define inflateInit2_ z_inflateInit2_ # define inflateInit_ z_inflateInit_ # define inflateMark z_inflateMark # define inflatePrime z_inflatePrime # define inflateReset z_inflateReset # define inflateReset2 z_inflateReset2 # define inflateResetKeep z_inflateResetKeep # define inflateSetDictionary z_inflateSetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateUndermine z_inflateUndermine # define inflateValidate z_inflateValidate # define inflate_copyright z_inflate_copyright # define inflate_fast z_inflate_fast # define inflate_table z_inflate_table # ifndef Z_SOLO # define uncompress z_uncompress # define uncompress2 z_uncompress2 # endif # define zError z_zError # ifndef Z_SOLO # define zcalloc z_zcalloc # define zcfree z_zcfree # endif # define zlibCompileFlags z_zlibCompileFlags # define zlibVersion z_zlibVersion /* all zlib typedefs in zlib.h and zconf.h */ # define Byte z_Byte # define Bytef z_Bytef # define alloc_func z_alloc_func # define charf z_charf # define free_func z_free_func # ifndef Z_SOLO # define gzFile z_gzFile # endif # define gz_header z_gz_header # define gz_headerp z_gz_headerp # define in_func z_in_func # define intf z_intf # define out_func z_out_func # define uInt z_uInt # define uIntf z_uIntf # define uLong z_uLong # define uLongf z_uLongf # define voidp z_voidp # define voidpc z_voidpc # define voidpf z_voidpf /* all zlib structs in zlib.h and zconf.h */ # define gz_header_s z_gz_header_s # define internal_state z_internal_state #endif #if defined(__MSDOS__) && !defined(MSDOS) # define MSDOS #endif #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) # define OS2 #endif #if defined(_WINDOWS) && !defined(WINDOWS) # define WINDOWS #endif #if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) # ifndef WIN32 # define WIN32 # endif #endif #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) # ifndef SYS16BIT # define SYS16BIT # endif # endif #endif /* * Compile with -DMAXSEG_64K if the alloc function cannot allocate more * than 64k bytes at a time (needed on systems with 16-bit int). */ #ifdef SYS16BIT # define MAXSEG_64K #endif #ifdef MSDOS # define UNALIGNED_OK #endif #ifdef __STDC_VERSION__ # ifndef STDC # define STDC # endif # if __STDC_VERSION__ >= 199901L # ifndef STDC99 # define STDC99 # endif # endif #endif #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) # define STDC #endif #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) # define STDC #endif #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) # define STDC #endif #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) # define STDC #endif #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ # define STDC #endif #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const /* note: need a more gentle solution here */ # endif #endif #if defined(ZLIB_CONST) && !defined(z_const) # define z_const const #else # define z_const #endif #ifdef Z_SOLO typedef unsigned long z_size_t; #else # define z_longlong long long # if defined(NO_SIZE_T) typedef unsigned NO_SIZE_T z_size_t; # elif defined(STDC) # include <stddef.h> typedef size_t z_size_t; # else typedef unsigned long z_size_t; # endif # undef z_longlong #endif /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL # ifdef MAXSEG_64K # define MAX_MEM_LEVEL 8 # else # define MAX_MEM_LEVEL 9 # endif #endif /* Maximum value for windowBits in deflateInit2 and inflateInit2. * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files * created by gzip. (Files created by minigzip can still be extracted by * gzip.) */ #ifndef MAX_WBITS # define MAX_WBITS 15 /* 32K LZ77 window */ #endif /* The memory requirements for deflate are (in bytes): (1 << (windowBits+2)) + (1 << (memLevel+9)) that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) plus a few kilobytes for small objects. For example, if you want to reduce the default memory requirements from 256K to 128K, compile with make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" Of course this will generally degrade compression (there's no free lunch). The memory requirements for inflate are (in bytes) 1 << windowBits that is, 32K for windowBits=15 (default value) plus about 7 kilobytes for small objects. */ /* Type declarations */ #ifndef OF /* function prototypes */ # ifdef STDC # define OF(args) args # else # define OF(args) () # endif #endif #ifndef Z_ARG /* function prototypes for stdarg */ # if defined(STDC) || defined(Z_HAVE_STDARG_H) # define Z_ARG(args) args # else # define Z_ARG(args) () # endif #endif /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, * just define FAR to be empty. */ #ifdef SYS16BIT # if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */ # define SMALL_MEDIUM # ifdef _MSC_VER # define FAR _far # else # define FAR far # endif # endif # if (defined(__SMALL__) || defined(__MEDIUM__)) /* Turbo C small or medium model */ # define SMALL_MEDIUM # ifdef __BORLANDC__ # define FAR _far # else # define FAR far # endif # endif #endif #if defined(WINDOWS) || defined(WIN32) /* If building or using zlib as a DLL, define ZLIB_DLL. * This is not mandatory, but it offers a little performance increase. */ # ifdef ZLIB_DLL # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) # ifdef ZLIB_INTERNAL # define ZEXTERN extern __declspec(dllexport) # else # define ZEXTERN extern __declspec(dllimport) # endif # endif # endif /* ZLIB_DLL */ /* If building or using zlib with the WINAPI/WINAPIV calling convention, * define ZLIB_WINAPI. * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. */ # ifdef ZLIB_WINAPI # ifdef FAR # undef FAR # endif # include <windows.h> /* No need for _export, use ZLIB.DEF instead. */ /* For complete Windows compatibility, use WINAPI, not __stdcall. */ # define ZEXPORT WINAPI # ifdef WIN32 # define ZEXPORTVA WINAPIV # else # define ZEXPORTVA FAR CDECL # endif # endif #endif #if defined (__BEOS__) # ifdef ZLIB_DLL # ifdef ZLIB_INTERNAL # define ZEXPORT __declspec(dllexport) # define ZEXPORTVA __declspec(dllexport) # else # define ZEXPORT __declspec(dllimport) # define ZEXPORTVA __declspec(dllimport) # endif # endif #endif #ifndef ZEXTERN # define ZEXTERN extern #endif #ifndef ZEXPORT # define ZEXPORT #endif #ifndef ZEXPORTVA # define ZEXPORTVA #endif #ifndef FAR # define FAR #endif #if !defined(__MACTYPES__) typedef unsigned char Byte; /* 8 bits */ #endif typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned long uLong; /* 32 bits or more */ #ifdef SMALL_MEDIUM /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ # define Bytef Byte FAR #else typedef Byte FAR Bytef; #endif typedef char FAR charf; typedef int FAR intf; typedef uInt FAR uIntf; typedef uLong FAR uLongf; #ifdef STDC typedef void const *voidpc; typedef void FAR *voidpf; typedef void *voidp; #else typedef Byte const *voidpc; typedef Byte FAR *voidpf; typedef Byte *voidp; #endif #if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) # include <limits.h> # if (UINT_MAX == 0xffffffffUL) # define Z_U4 unsigned # elif (ULONG_MAX == 0xffffffffUL) # define Z_U4 unsigned long # elif (USHRT_MAX == 0xffffffffUL) # define Z_U4 unsigned short # endif #endif #ifdef Z_U4 typedef Z_U4 z_crc_t; #else typedef unsigned long z_crc_t; #endif #if 1 /* was set to #if 1 by ./configure */ # define Z_HAVE_UNISTD_H #endif #if 1 /* was set to #if 1 by ./configure */ # define Z_HAVE_STDARG_H #endif #ifdef STDC # ifndef Z_SOLO # include <sys/types.h> /* for off_t */ # endif #endif #if defined(STDC) || defined(Z_HAVE_STDARG_H) # ifndef Z_SOLO # include <stdarg.h> /* for va_list */ # endif #endif #ifdef _WIN32 # ifndef Z_SOLO # include <stddef.h> /* for wchar_t */ # endif #endif /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even * though the former does not conform to the LFS document), but considering * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as * equivalently requesting no 64-bit operations */ #if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 # undef _LARGEFILE64_SOURCE #endif #if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) # define Z_HAVE_UNISTD_H #endif #ifndef Z_SOLO # if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) # include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ # ifdef VMS # include <unixio.h> /* for off_t */ # endif # ifndef z_off_t # define z_off_t off_t # endif # endif #endif #if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 # define Z_LFS64 #endif #if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) # define Z_LARGE64 #endif #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) # define Z_WANT64 #endif #if !defined(SEEK_SET) && !defined(Z_SOLO) # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t # define z_off_t long #endif #if !defined(_WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #else # if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) # define z_off64_t __int64 # else # define z_off64_t z_off_t # endif #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) #pragma map(deflateInit_,"DEIN") #pragma map(deflateInit2_,"DEIN2") #pragma map(deflateEnd,"DEEND") #pragma map(deflateBound,"DEBND") #pragma map(inflateInit_,"ININ") #pragma map(inflateInit2_,"ININ2") #pragma map(inflateEnd,"INEND") #pragma map(inflateSync,"INSY") #pragma map(inflateSetDictionary,"INSEDI") #pragma map(compressBound,"CMBND") #pragma map(inflate_table,"INTABL") #pragma map(inflate_fast,"INFA") #pragma map(inflate_copyright,"INCOPY") #endif #endif /* ZCONF_H */ /* Callback interface for libthread_db, functions users must define. Copyright (C) 1999-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _PROC_SERVICE_H #define _PROC_SERVICE_H 1 /* The definitions in this file must correspond to those in the debugger. */ #include <sys/procfs.h> __BEGIN_DECLS /* Functions in this interface return one of these status codes. */ typedef enum { PS_OK, /* Generic "call succeeded". */ PS_ERR, /* Generic error. */ PS_BADPID, /* Bad process handle. */ PS_BADLID, /* Bad LWP identifier. */ PS_BADADDR, /* Bad address. */ PS_NOSYM, /* Could not find given symbol. */ PS_NOFREGS /* FPU register set not available for given LWP. */ } ps_err_e; /* This type is opaque in this interface. It's defined by the user of libthread_db. */ struct ps_prochandle; /* Read or write process memory at the given address. */ extern ps_err_e ps_pdread (struct ps_prochandle *, psaddr_t, void *, size_t); extern ps_err_e ps_pdwrite (struct ps_prochandle *, psaddr_t, const void *, size_t); extern ps_err_e ps_ptread (struct ps_prochandle *, psaddr_t, void *, size_t); extern ps_err_e ps_ptwrite (struct ps_prochandle *, psaddr_t, const void *, size_t); /* Get and set the given LWP's general or FPU register set. */ extern ps_err_e ps_lgetregs (struct ps_prochandle *, lwpid_t, prgregset_t); extern ps_err_e ps_lsetregs (struct ps_prochandle *, lwpid_t, const prgregset_t); extern ps_err_e ps_lgetfpregs (struct ps_prochandle *, lwpid_t, prfpregset_t *); extern ps_err_e ps_lsetfpregs (struct ps_prochandle *, lwpid_t, const prfpregset_t *); /* Return the PID of the process. */ extern pid_t ps_getpid (struct ps_prochandle *); /* Fetch the special per-thread address associated with the given LWP. This call is only used on a few platforms (most use a normal register). The meaning of the `int' parameter is machine-dependent. */ extern ps_err_e ps_get_thread_area (struct ps_prochandle *, lwpid_t, int, psaddr_t *); /* Look up the named symbol in the named DSO in the symbol tables associated with the process being debugged, filling in *SYM_ADDR with the corresponding run-time address. */ extern ps_err_e ps_pglobal_lookup (struct ps_prochandle *, const char *object_name, const char *sym_name, psaddr_t *sym_addr); /* Stop or continue the entire process. */ extern ps_err_e ps_pstop (struct ps_prochandle *); extern ps_err_e ps_pcontinue (struct ps_prochandle *); /* Stop or continue the given LWP alone. */ extern ps_err_e ps_lstop (struct ps_prochandle *, lwpid_t); extern ps_err_e ps_lcontinue (struct ps_prochandle *, lwpid_t); __END_DECLS #endif /* proc_service.h */ /* Message catalogs for internationalization. Copyright (C) 1995-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. This file is derived from the file libgettext.h in the GNU gettext package. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _LIBINTL_H #define _LIBINTL_H 1 #include <features.h> /* We define an additional symbol to signal that we use the GNU implementation of gettext. */ #define __USE_GNU_GETTEXT 1 /* Provide information about the supported file formats. Returns the maximum minor revision number supported for a given major revision. */ #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \ ((major) == 0 ? 1 : -1) __BEGIN_DECLS /* Look up MSGID in the current default message catalog for the current LC_MESSAGES locale. If not found, returns MSGID itself (the default text). */ extern char *gettext (const char *__msgid) __THROW __attribute_format_arg__ (1); /* Look up MSGID in the DOMAINNAME message catalog for the current LC_MESSAGES locale. */ extern char *dgettext (const char *__domainname, const char *__msgid) __THROW __attribute_format_arg__ (2); extern char *__dgettext (const char *__domainname, const char *__msgid) __THROW __attribute_format_arg__ (2); /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY locale. */ extern char *dcgettext (const char *__domainname, const char *__msgid, int __category) __THROW __attribute_format_arg__ (2); extern char *__dcgettext (const char *__domainname, const char *__msgid, int __category) __THROW __attribute_format_arg__ (2); /* Similar to `gettext' but select the plural form corresponding to the number N. */ extern char *ngettext (const char *__msgid1, const char *__msgid2, unsigned long int __n) __THROW __attribute_format_arg__ (1) __attribute_format_arg__ (2); /* Similar to `dgettext' but select the plural form corresponding to the number N. */ extern char *dngettext (const char *__domainname, const char *__msgid1, const char *__msgid2, unsigned long int __n) __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3); /* Similar to `dcgettext' but select the plural form corresponding to the number N. */ extern char *dcngettext (const char *__domainname, const char *__msgid1, const char *__msgid2, unsigned long int __n, int __category) __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3); /* Set the current default message catalog to DOMAINNAME. If DOMAINNAME is null, return the current default. If DOMAINNAME is "", reset to the default of "messages". */ extern char *textdomain (const char *__domainname) __THROW; /* Specify that the DOMAINNAME message catalog will be found in DIRNAME rather than in the system locale data base. */ extern char *bindtextdomain (const char *__domainname, const char *__dirname) __THROW; /* Specify the character encoding in which the messages from the DOMAINNAME message catalog will be returned. */ extern char *bind_textdomain_codeset (const char *__domainname, const char *__codeset) __THROW; /* Optimized version of the function above. */ #if defined __OPTIMIZE__ && !defined __cplusplus /* We need NULL for `gettext'. */ # define __need_NULL # include <stddef.h> /* We need LC_MESSAGES for `dgettext'. */ # include <locale.h> /* These must be macros. Inlined functions are useless because the `__builtin_constant_p' predicate in dcgettext would always return false. */ # define gettext(msgid) dgettext (NULL, msgid) # define dgettext(domainname, msgid) \ dcgettext (domainname, msgid, LC_MESSAGES) # define ngettext(msgid1, msgid2, n) dngettext (NULL, msgid1, msgid2, n) # define dngettext(domainname, msgid1, msgid2, n) \ dcngettext (domainname, msgid1, msgid2, n, LC_MESSAGES) #endif /* Optimizing. */ __END_DECLS #endif /* libintl.h */ /* Copyright (C) 1996-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* * ISO C99 Standard: 7.25 * Wide character classification and mapping utilities <wctype.h> */ #ifndef _WCTYPE_H #define _WCTYPE_H 1 #include <features.h> #include <bits/types.h> #include <bits/types/wint_t.h> /* Constant expression of type `wint_t' whose value does not correspond to any member of the extended character set. */ #ifndef WEOF # define WEOF (0xffffffffu) #endif /* Some definitions from this header also appear in <wchar.h> in Unix98 mode. */ #include <bits/wctype-wchar.h> /* * Extensible wide-character mapping functions: 7.15.3.2. */ __BEGIN_DECLS /* Scalar type that can hold values which represent locale-specific character mappings. */ typedef const __int32_t *wctrans_t; /* Construct value that describes a mapping between wide characters identified by the string argument PROPERTY. */ extern wctrans_t wctrans (const char *__property) __THROW; /* Map the wide character WC using the mapping described by DESC. */ extern wint_t towctrans (wint_t __wc, wctrans_t __desc) __THROW; # ifdef __USE_XOPEN2K8 /* POSIX.1-2008 extended locale interface (see locale.h). */ # include <bits/types/locale_t.h> /* Test for any wide character for which `iswalpha' or `iswdigit' is true. */ extern int iswalnum_l (wint_t __wc, locale_t __locale) __THROW; /* Test for any wide character for which `iswupper' or 'iswlower' is true, or any wide character that is one of a locale-specific set of wide-characters for which none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ extern int iswalpha_l (wint_t __wc, locale_t __locale) __THROW; /* Test for any control wide character. */ extern int iswcntrl_l (wint_t __wc, locale_t __locale) __THROW; /* Test for any wide character that corresponds to a decimal-digit character. */ extern int iswdigit_l (wint_t __wc, locale_t __locale) __THROW; /* Test for any wide character for which `iswprint' is true and `iswspace' is false. */ extern int iswgraph_l (wint_t __wc, locale_t __locale) __THROW; /* Test for any wide character that corresponds to a lowercase letter or is one of a locale-specific set of wide characters for which none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ extern int iswlower_l (wint_t __wc, locale_t __locale) __THROW; /* Test for any printing wide character. */ extern int iswprint_l (wint_t __wc, locale_t __locale) __THROW; /* Test for any printing wide character that is one of a locale-specific et of wide characters for which neither `iswspace' nor `iswalnum' is true. */ extern int iswpunct_l (wint_t __wc, locale_t __locale) __THROW; /* Test for any wide character that corresponds to a locale-specific set of wide characters for which none of `iswalnum', `iswgraph', or `iswpunct' is true. */ extern int iswspace_l (wint_t __wc, locale_t __locale) __THROW; /* Test for any wide character that corresponds to an uppercase letter or is one of a locale-specific set of wide character for which none of `iswcntrl', `iswdigit', `iswpunct', or `iswspace' is true. */ extern int iswupper_l (wint_t __wc, locale_t __locale) __THROW; /* Test for any wide character that corresponds to a hexadecimal-digit character equivalent to that performed be the functions described in the previous subclause. */ extern int iswxdigit_l (wint_t __wc, locale_t __locale) __THROW; /* Test for any wide character that corresponds to a standard blank wide character or a locale-specific set of wide characters for which `iswalnum' is false. */ extern int iswblank_l (wint_t __wc, locale_t __locale) __THROW; /* Construct value that describes a class of wide characters identified by the string argument PROPERTY. */ extern wctype_t wctype_l (const char *__property, locale_t __locale) __THROW; /* Determine whether the wide-character WC has the property described by DESC. */ extern int iswctype_l (wint_t __wc, wctype_t __desc, locale_t __locale) __THROW; /* * Wide-character case-mapping functions. */ /* Converts an uppercase letter to the corresponding lowercase letter. */ extern wint_t towlower_l (wint_t __wc, locale_t __locale) __THROW; /* Converts an lowercase letter to the corresponding uppercase letter. */ extern wint_t towupper_l (wint_t __wc, locale_t __locale) __THROW; /* Construct value that describes a mapping between wide characters identified by the string argument PROPERTY. */ extern wctrans_t wctrans_l (const char *__property, locale_t __locale) __THROW; /* Map the wide character WC using the mapping described by DESC. */ extern wint_t towctrans_l (wint_t __wc, wctrans_t __desc, locale_t __locale) __THROW; # endif /* Use POSIX 2008. */ __END_DECLS #endif /* wctype.h */ /* Copyright (C) 2002-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _PTHREAD_H #define _PTHREAD_H 1 #include <features.h> #include <sched.h> #include <time.h> #include <bits/endian.h> #include <bits/pthreadtypes.h> #include <bits/setjmp.h> #include <bits/wordsize.h> #include <bits/types/struct_timespec.h> #include <bits/types/__sigset_t.h> #include <bits/types/struct___jmp_buf_tag.h> #ifdef __USE_MISC # include <bits/pthread_stack_min-dynamic.h> #endif /* Detach state. */ enum { PTHREAD_CREATE_JOINABLE, #define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_DETACHED #define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED }; /* Mutex types. */ enum { PTHREAD_MUTEX_TIMED_NP, PTHREAD_MUTEX_RECURSIVE_NP, PTHREAD_MUTEX_ERRORCHECK_NP, PTHREAD_MUTEX_ADAPTIVE_NP #if defined __USE_UNIX98 || defined __USE_XOPEN2K8 , PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP, PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL #endif #ifdef __USE_GNU /* For compatibility. */ , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP #endif }; #ifdef __USE_XOPEN2K /* Robust mutex or not flags. */ enum { PTHREAD_MUTEX_STALLED, PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED, PTHREAD_MUTEX_ROBUST, PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST }; #endif #if defined __USE_POSIX199506 || defined __USE_UNIX98 /* Mutex protocols. */ enum { PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, PTHREAD_PRIO_PROTECT }; #endif #define PTHREAD_MUTEX_INITIALIZER \ { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_TIMED_NP) } } #ifdef __USE_GNU # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \ { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_RECURSIVE_NP) } } # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \ { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_ERRORCHECK_NP) } } # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \ { { __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_ADAPTIVE_NP) } } #endif /* Read-write lock types. */ #if defined __USE_UNIX98 || defined __USE_XOPEN2K enum { PTHREAD_RWLOCK_PREFER_READER_NP, PTHREAD_RWLOCK_PREFER_WRITER_NP, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP }; /* Read-write lock initializers. */ # define PTHREAD_RWLOCK_INITIALIZER \ { { __PTHREAD_RWLOCK_INITIALIZER (PTHREAD_RWLOCK_DEFAULT_NP) } } # ifdef __USE_GNU # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \ { { __PTHREAD_RWLOCK_INITIALIZER (PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP) } } # endif #endif /* Unix98 or XOpen2K */ /* Scheduler inheritance. */ enum { PTHREAD_INHERIT_SCHED, #define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED PTHREAD_EXPLICIT_SCHED #define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED }; /* Scope handling. */ enum { PTHREAD_SCOPE_SYSTEM, #define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_PROCESS #define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS }; /* Process shared or private flag. */ enum { PTHREAD_PROCESS_PRIVATE, #define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_SHARED #define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED }; /* Conditional variable handling. */ #define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, {0, 0}, 0, 0, {0, 0} } } /* Cleanup buffers */ struct _pthread_cleanup_buffer { void (*__routine) (void *); /* Function to call. */ void *__arg; /* Its argument. */ int __canceltype; /* Saved cancellation type. */ struct _pthread_cleanup_buffer *__prev; /* Chaining of cleanup functions. */ }; /* Cancellation */ enum { PTHREAD_CANCEL_ENABLE, #define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_DISABLE #define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE }; enum { PTHREAD_CANCEL_DEFERRED, #define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_ASYNCHRONOUS #define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS }; #define PTHREAD_CANCELED ((void *) -1) /* Single execution handling. */ #define PTHREAD_ONCE_INIT 0 #ifdef __USE_XOPEN2K /* Value returned by 'pthread_barrier_wait' for one of the threads after the required number of threads have called this function. -1 is distinct from 0 and all errno constants */ # define PTHREAD_BARRIER_SERIAL_THREAD -1 #endif __BEGIN_DECLS /* Create a new thread, starting with execution of START-ROUTINE getting passed ARG. Creation attributed come from ATTR. The new handle is stored in *NEWTHREAD. */ extern int pthread_create (pthread_t *__restrict __newthread, const pthread_attr_t *__restrict __attr, void *(*__start_routine) (void *), void *__restrict __arg) __THROWNL __nonnull ((1, 3)); /* Terminate calling thread. The registered cleanup handlers are called via exception handling so we cannot mark this function with __THROW.*/ extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__)); /* Make calling thread wait for termination of the thread TH. The exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN is not NULL. This function is a cancellation point and therefore not marked with __THROW. */ extern int pthread_join (pthread_t __th, void **__thread_return); #ifdef __USE_GNU /* Check whether thread TH has terminated. If yes return the status of the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL. */ extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW; # ifndef __USE_TIME_BITS64 /* Make calling thread wait for termination of the thread TH, but only until TIMEOUT. The exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN is not NULL. This function is a cancellation point and therefore not marked with __THROW. */ extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return, const struct timespec *__abstime); /* Make calling thread wait for termination of the thread TH, but only until TIMEOUT measured against the clock specified by CLOCKID. The exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN is not NULL. This function is a cancellation point and therefore not marked with __THROW. */ extern int pthread_clockjoin_np (pthread_t __th, void **__thread_return, clockid_t __clockid, const struct timespec *__abstime); # else # ifdef __REDIRECT extern int __REDIRECT (pthread_timedjoin_np, (pthread_t __th, void **__thread_return, const struct timespec *__abstime), __pthread_timedjoin_np64); extern int __REDIRECT (pthread_clockjoin_np, (pthread_t __th, void **__thread_return, clockid_t __clockid, const struct timespec *__abstime), __pthread_clockjoin_np64); # else # define pthread_timedjoin_np __pthread_timedjoin_np64 # define pthread_clockjoin_np __pthread_clockjoin_np64 # endif # endif #endif /* Indicate that the thread TH is never to be joined with PTHREAD_JOIN. The resources of TH will therefore be freed immediately when it terminates, instead of waiting for another thread to perform PTHREAD_JOIN on it. */ extern int pthread_detach (pthread_t __th) __THROW; /* Obtain the identifier of the current thread. */ extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__)); /* Compare two thread identifiers. */ extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) __THROW __attribute__ ((__const__)); /* Thread attribute handling. */ /* Initialize thread attribute *ATTR with default attributes (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER, no user-provided stack). */ extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1)); /* Destroy thread attribute *ATTR. */ extern int pthread_attr_destroy (pthread_attr_t *__attr) __THROW __nonnull ((1)); /* Get detach state attribute. */ extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr, int *__detachstate) __THROW __nonnull ((1, 2)); /* Set detach state attribute. */ extern int pthread_attr_setdetachstate (pthread_attr_t *__attr, int __detachstate) __THROW __nonnull ((1)); /* Get the size of the guard area created for stack overflow protection. */ extern int pthread_attr_getguardsize (const pthread_attr_t *__attr, size_t *__guardsize) __THROW __nonnull ((1, 2)); /* Set the size of the guard area created for stack overflow protection. */ extern int pthread_attr_setguardsize (pthread_attr_t *__attr, size_t __guardsize) __THROW __nonnull ((1)); /* Return in *PARAM the scheduling parameters of *ATTR. */ extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr, struct sched_param *__restrict __param) __THROW __nonnull ((1, 2)); /* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */ extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr, const struct sched_param *__restrict __param) __THROW __nonnull ((1, 2)); /* Return in *POLICY the scheduling policy of *ATTR. */ extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict __attr, int *__restrict __policy) __THROW __nonnull ((1, 2)); /* Set scheduling policy in *ATTR according to POLICY. */ extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy) __THROW __nonnull ((1)); /* Return in *INHERIT the scheduling inheritance mode of *ATTR. */ extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict __attr, int *__restrict __inherit) __THROW __nonnull ((1, 2)); /* Set scheduling inheritance mode in *ATTR according to INHERIT. */ extern int pthread_attr_setinheritsched (pthread_attr_t *__attr, int __inherit) __THROW __nonnull ((1)); /* Return in *SCOPE the scheduling contention scope of *ATTR. */ extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr, int *__restrict __scope) __THROW __nonnull ((1, 2)); /* Set scheduling contention scope in *ATTR according to SCOPE. */ extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope) __THROW __nonnull ((1)); /* Return the previously set address for the stack. */ extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict __attr, void **__restrict __stackaddr) __THROW __nonnull ((1, 2)) __attribute_deprecated__; /* Set the starting address of the stack of the thread to be created. Depending on whether the stack grows up or down the value must either be higher or lower than all the address in the memory block. The minimal size of the block must be PTHREAD_STACK_MIN. */ extern int pthread_attr_setstackaddr (pthread_attr_t *__attr, void *__stackaddr) __THROW __nonnull ((1)) __attribute_deprecated__; /* Return the currently used minimal stack size. */ extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict __attr, size_t *__restrict __stacksize) __THROW __nonnull ((1, 2)); /* Add information about the minimum stack size needed for the thread to be started. This size must never be less than PTHREAD_STACK_MIN and must also not exceed the system limits. */ extern int pthread_attr_setstacksize (pthread_attr_t *__attr, size_t __stacksize) __THROW __nonnull ((1)); #ifdef __USE_XOPEN2K /* Return the previously set address for the stack. */ extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr, void **__restrict __stackaddr, size_t *__restrict __stacksize) __THROW __nonnull ((1, 2, 3)); /* The following two interfaces are intended to replace the last two. They require setting the address as well as the size since only setting the address will make the implementation on some architectures impossible. */ extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr, size_t __stacksize) __THROW __nonnull ((1)); #endif #ifdef __USE_GNU /* Thread created with attribute ATTR will be limited to run only on the processors represented in CPUSET. */ extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr, size_t __cpusetsize, const cpu_set_t *__cpuset) __THROW __nonnull ((1, 3)); /* Get bit set in CPUSET representing the processors threads created with ATTR can run on. */ extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr, size_t __cpusetsize, cpu_set_t *__cpuset) __THROW __nonnull ((1, 3)); /* Get the default attributes used by pthread_create in this process. */ extern int pthread_getattr_default_np (pthread_attr_t *__attr) __THROW __nonnull ((1)); /* Store *SIGMASK as the signal mask for the new thread in *ATTR. */ extern int pthread_attr_setsigmask_np (pthread_attr_t *__attr, const __sigset_t *sigmask); /* Store the signal mask of *ATTR in *SIGMASK. If there is no signal mask stored, return PTHREAD_ATTR_NOSIGMASK_NP. Return zero on success. */ extern int pthread_attr_getsigmask_np (const pthread_attr_t *__attr, __sigset_t *sigmask); /* Special return value from pthread_attr_getsigmask_np if the signal mask has not been set. */ #define PTHREAD_ATTR_NO_SIGMASK_NP (-1) /* Set the default attributes to be used by pthread_create in this process. */ extern int pthread_setattr_default_np (const pthread_attr_t *__attr) __THROW __nonnull ((1)); /* Initialize thread attribute *ATTR with attributes corresponding to the already running thread TH. It shall be called on uninitialized ATTR and destroyed with pthread_attr_destroy when no longer needed. */ extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW __nonnull ((2)); #endif /* Functions for scheduling control. */ /* Set the scheduling parameters for TARGET_THREAD according to POLICY and *PARAM. */ extern int pthread_setschedparam (pthread_t __target_thread, int __policy, const struct sched_param *__param) __THROW __nonnull ((3)); /* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */ extern int pthread_getschedparam (pthread_t __target_thread, int *__restrict __policy, struct sched_param *__restrict __param) __THROW __nonnull ((2, 3)); /* Set the scheduling priority for TARGET_THREAD. */ extern int pthread_setschedprio (pthread_t __target_thread, int __prio) __THROW; #ifdef __USE_GNU /* Get thread name visible in the kernel and its interfaces. */ extern int pthread_getname_np (pthread_t __target_thread, char *__buf, size_t __buflen) __THROW __nonnull ((2)); /* Set thread name visible in the kernel and its interfaces. */ extern int pthread_setname_np (pthread_t __target_thread, const char *__name) __THROW __nonnull ((2)); #endif #ifdef __USE_UNIX98 /* Determine level of concurrency. */ extern int pthread_getconcurrency (void) __THROW; /* Set new concurrency level to LEVEL. */ extern int pthread_setconcurrency (int __level) __THROW; #endif #ifdef __USE_GNU extern int pthread_yield (void) __THROW; # ifdef __REDIRECT_NTH extern int __REDIRECT_NTH (pthread_yield, (void), sched_yield) __attribute_deprecated_msg__ ("\ pthread_yield is deprecated, use sched_yield instead"); # else # define pthread_yield sched_yield # endif /* Limit specified thread TH to run only on the processors represented in CPUSET. */ extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize, const cpu_set_t *__cpuset) __THROW __nonnull ((3)); /* Get bit set in CPUSET representing the processors TH can run on. */ extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize, cpu_set_t *__cpuset) __THROW __nonnull ((3)); #endif /* Functions for handling initialization. */ /* Guarantee that the initialization function INIT_ROUTINE will be called only once, even if pthread_once is executed several times with the same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or extern variable initialized to PTHREAD_ONCE_INIT. The initialization functions might throw exception which is why this function is not marked with __THROW. */ extern int pthread_once (pthread_once_t *__once_control, void (*__init_routine) (void)) __nonnull ((1, 2)); /* Functions for handling cancellation. Note that these functions are explicitly not marked to not throw an exception in C++ code. If cancellation is implemented by unwinding this is necessary to have the compiler generate the unwind information. */ /* Set cancelability state of current thread to STATE, returning old state in *OLDSTATE if OLDSTATE is not NULL. */ extern int pthread_setcancelstate (int __state, int *__oldstate); /* Set cancellation state of current thread to TYPE, returning the old type in *OLDTYPE if OLDTYPE is not NULL. */ extern int pthread_setcanceltype (int __type, int *__oldtype); /* Cancel THREAD immediately or at the next possibility. */ extern int pthread_cancel (pthread_t __th); /* Test for pending cancellation for the current thread and terminate the thread as per pthread_exit(PTHREAD_CANCELED) if it has been cancelled. */ extern void pthread_testcancel (void); /* Cancellation handling with integration into exception handling. */ struct __cancel_jmp_buf_tag { __jmp_buf __cancel_jmp_buf; int __mask_was_saved; }; typedef struct { struct __cancel_jmp_buf_tag __cancel_jmp_buf[1]; void *__pad[4]; } __pthread_unwind_buf_t __attribute__ ((__aligned__)); /* No special attributes by default. */ #ifndef __cleanup_fct_attribute # define __cleanup_fct_attribute #endif /* Structure to hold the cleanup handler information. */ struct __pthread_cleanup_frame { void (*__cancel_routine) (void *); void *__cancel_arg; int __do_it; int __cancel_type; }; #if defined __GNUC__ && defined __EXCEPTIONS # ifdef __cplusplus /* Class to handle cancellation handler invocation. */ class __pthread_cleanup_class { void (*__cancel_routine) (void *); void *__cancel_arg; int __do_it; int __cancel_type; public: __pthread_cleanup_class (void (*__fct) (void *), void *__arg) : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { } ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); } void __setdoit (int __newval) { __do_it = __newval; } void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &__cancel_type); } void __restore () const { pthread_setcanceltype (__cancel_type, 0); } }; /* Install a cleanup handler: ROUTINE will be called with arguments ARG when the thread is canceled or calls pthread_exit. ROUTINE will also be called with arguments ARG when the matching pthread_cleanup_pop is executed with non-zero EXECUTE argument. pthread_cleanup_push and pthread_cleanup_pop are macros and must always be used in matching pairs at the same nesting level of braces. */ # define pthread_cleanup_push(routine, arg) \ do { \ __pthread_cleanup_class __clframe (routine, arg) /* Remove a cleanup handler installed by the matching pthread_cleanup_push. If EXECUTE is non-zero, the handler function is called. */ # define pthread_cleanup_pop(execute) \ __clframe.__setdoit (execute); \ } while (0) # ifdef __USE_GNU /* Install a cleanup handler as pthread_cleanup_push does, but also saves the current cancellation type and sets it to deferred cancellation. */ # define pthread_cleanup_push_defer_np(routine, arg) \ do { \ __pthread_cleanup_class __clframe (routine, arg); \ __clframe.__defer () /* Remove a cleanup handler as pthread_cleanup_pop does, but also restores the cancellation type that was in effect when the matching pthread_cleanup_push_defer was called. */ # define pthread_cleanup_pop_restore_np(execute) \ __clframe.__restore (); \ __clframe.__setdoit (execute); \ } while (0) # endif # else /* Function called to call the cleanup handler. As an extern inline function the compiler is free to decide inlining the change when needed or fall back on the copy which must exist somewhere else. */ __extern_inline void __pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame) { if (__frame->__do_it) __frame->__cancel_routine (__frame->__cancel_arg); } /* Install a cleanup handler: ROUTINE will be called with arguments ARG when the thread is canceled or calls pthread_exit. ROUTINE will also be called with arguments ARG when the matching pthread_cleanup_pop is executed with non-zero EXECUTE argument. pthread_cleanup_push and pthread_cleanup_pop are macros and must always be used in matching pairs at the same nesting level of braces. */ # define pthread_cleanup_push(routine, arg) \ do { \ struct __pthread_cleanup_frame __clframe \ __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \ = { .__cancel_routine = (routine), .__cancel_arg = (arg), \ .__do_it = 1 }; /* Remove a cleanup handler installed by the matching pthread_cleanup_push. If EXECUTE is non-zero, the handler function is called. */ # define pthread_cleanup_pop(execute) \ __clframe.__do_it = (execute); \ } while (0) # ifdef __USE_GNU /* Install a cleanup handler as pthread_cleanup_push does, but also saves the current cancellation type and sets it to deferred cancellation. */ # define pthread_cleanup_push_defer_np(routine, arg) \ do { \ struct __pthread_cleanup_frame __clframe \ __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \ = { .__cancel_routine = (routine), .__cancel_arg = (arg), \ .__do_it = 1 }; \ (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, \ &__clframe.__cancel_type) /* Remove a cleanup handler as pthread_cleanup_pop does, but also restores the cancellation type that was in effect when the matching pthread_cleanup_push_defer was called. */ # define pthread_cleanup_pop_restore_np(execute) \ (void) pthread_setcanceltype (__clframe.__cancel_type, NULL); \ __clframe.__do_it = (execute); \ } while (0) # endif # endif #else /* Install a cleanup handler: ROUTINE will be called with arguments ARG when the thread is canceled or calls pthread_exit. ROUTINE will also be called with arguments ARG when the matching pthread_cleanup_pop is executed with non-zero EXECUTE argument. pthread_cleanup_push and pthread_cleanup_pop are macros and must always be used in matching pairs at the same nesting level of braces. */ # define pthread_cleanup_push(routine, arg) \ do { \ __pthread_unwind_buf_t __cancel_buf; \ void (*__cancel_routine) (void *) = (routine); \ void *__cancel_arg = (arg); \ int __not_first_call = __sigsetjmp_cancel (__cancel_buf.__cancel_jmp_buf, \ 0); \ if (__glibc_unlikely (__not_first_call)) \ { \ __cancel_routine (__cancel_arg); \ __pthread_unwind_next (&__cancel_buf); \ /* NOTREACHED */ \ } \ \ __pthread_register_cancel (&__cancel_buf); \ do { extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf) __cleanup_fct_attribute; /* Remove a cleanup handler installed by the matching pthread_cleanup_push. If EXECUTE is non-zero, the handler function is called. */ # define pthread_cleanup_pop(execute) \ do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\ } while (0); \ __pthread_unregister_cancel (&__cancel_buf); \ if (execute) \ __cancel_routine (__cancel_arg); \ } while (0) extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf) __cleanup_fct_attribute; # ifdef __USE_GNU /* Install a cleanup handler as pthread_cleanup_push does, but also saves the current cancellation type and sets it to deferred cancellation. */ # define pthread_cleanup_push_defer_np(routine, arg) \ do { \ __pthread_unwind_buf_t __cancel_buf; \ void (*__cancel_routine) (void *) = (routine); \ void *__cancel_arg = (arg); \ int __not_first_call = __sigsetjmp_cancel (__cancel_buf.__cancel_jmp_buf, \ 0); \ if (__glibc_unlikely (__not_first_call)) \ { \ __cancel_routine (__cancel_arg); \ __pthread_unwind_next (&__cancel_buf); \ /* NOTREACHED */ \ } \ \ __pthread_register_cancel_defer (&__cancel_buf); \ do { extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf) __cleanup_fct_attribute; /* Remove a cleanup handler as pthread_cleanup_pop does, but also restores the cancellation type that was in effect when the matching pthread_cleanup_push_defer was called. */ # define pthread_cleanup_pop_restore_np(execute) \ do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\ } while (0); \ __pthread_unregister_cancel_restore (&__cancel_buf); \ if (execute) \ __cancel_routine (__cancel_arg); \ } while (0) extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf) __cleanup_fct_attribute; # endif /* Internal interface to initiate cleanup. */ extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf) __cleanup_fct_attribute __attribute__ ((__noreturn__)) # ifndef SHARED __attribute__ ((__weak__)) # endif ; #endif /* Function used in the macros. Calling __sigsetjmp, with its first argument declared as an array, results in a -Wstringop-overflow warning from GCC 11 because struct pthread_unwind_buf is smaller than jmp_buf. The calls from the macros have __SAVEMASK set to 0, so nothing beyond the common prefix is used and this warning is a false positive. Use an alias with its first argument declared to use the type in the macros if possible to avoid this warning. */ #if __GNUC_PREREQ (11, 0) extern int __REDIRECT_NTHNL (__sigsetjmp_cancel, (struct __cancel_jmp_buf_tag __env[1], int __savemask), __sigsetjmp) __attribute_returns_twice__; #else # define __sigsetjmp_cancel(env, savemask) \ __sigsetjmp ((struct __jmp_buf_tag *) (void *) (env), (savemask)) extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROWNL; #endif /* Mutex handling. */ /* Initialize a mutex. */ extern int pthread_mutex_init (pthread_mutex_t *__mutex, const pthread_mutexattr_t *__mutexattr) __THROW __nonnull ((1)); /* Destroy a mutex. */ extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) __THROW __nonnull ((1)); /* Try locking a mutex. */ extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) __THROWNL __nonnull ((1)); /* Lock a mutex. */ extern int pthread_mutex_lock (pthread_mutex_t *__mutex) __THROWNL __nonnull ((1)); #ifdef __USE_XOPEN2K /* Wait until lock becomes available, or specified time passes. */ # ifndef __USE_TIME_BITS64 extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex, const struct timespec *__restrict __abstime) __THROWNL __nonnull ((1, 2)); # else # ifdef __REDIRECT_NTHNL extern int __REDIRECT_NTHNL (pthread_mutex_timedlock, (pthread_mutex_t *__restrict __mutex, const struct timespec *__restrict __abstime), __pthread_mutex_timedlock64) __nonnull ((1, 2)); # else # define pthread_mutex_timedlock __pthread_mutex_timedlock64 # endif # endif #endif #ifdef __USE_GNU # ifndef __USE_TIME_BITS64 extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex, clockid_t __clockid, const struct timespec *__restrict __abstime) __THROWNL __nonnull ((1, 3)); # else # ifdef __REDIRECT_NTHNL extern int __REDIRECT_NTHNL (pthread_mutex_clocklock, (pthread_mutex_t *__restrict __mutex, clockid_t __clockid, const struct timespec *__restrict __abstime), __pthread_mutex_clocklock64) __nonnull ((1, 3)); # else # define pthread_mutex_clocklock __pthread_mutex_clocklock64 # endif # endif #endif /* Unlock a mutex. */ extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROWNL __nonnull ((1)); /* Get the priority ceiling of MUTEX. */ extern int pthread_mutex_getprioceiling (const pthread_mutex_t * __restrict __mutex, int *__restrict __prioceiling) __THROW __nonnull ((1, 2)); /* Set the priority ceiling of MUTEX to PRIOCEILING, return old priority ceiling value in *OLD_CEILING. */ extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex, int __prioceiling, int *__restrict __old_ceiling) __THROW __nonnull ((1, 3)); #ifdef __USE_XOPEN2K8 /* Declare the state protected by MUTEX as consistent. */ extern int pthread_mutex_consistent (pthread_mutex_t *__mutex) __THROW __nonnull ((1)); # ifdef __USE_GNU # ifdef __REDIRECT_NTH extern int __REDIRECT_NTH (pthread_mutex_consistent_np, (pthread_mutex_t *), pthread_mutex_consistent) __nonnull ((1)) __attribute_deprecated_msg__ ("\ pthread_mutex_consistent_np is deprecated, use pthread_mutex_consistent"); # else # define pthread_mutex_consistent_np pthread_mutex_consistent # endif # endif #endif /* Functions for handling mutex attributes. */ /* Initialize mutex attribute object ATTR with default attributes (kind is PTHREAD_MUTEX_TIMED_NP). */ extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) __THROW __nonnull ((1)); /* Destroy mutex attribute object ATTR. */ extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) __THROW __nonnull ((1)); /* Get the process-shared flag of the mutex attribute ATTR. */ extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t * __restrict __attr, int *__restrict __pshared) __THROW __nonnull ((1, 2)); /* Set the process-shared flag of the mutex attribute ATTR. */ extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr, int __pshared) __THROW __nonnull ((1)); #if defined __USE_UNIX98 || defined __USE_XOPEN2K8 /* Return in *KIND the mutex kind attribute in *ATTR. */ extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict __attr, int *__restrict __kind) __THROW __nonnull ((1, 2)); /* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or PTHREAD_MUTEX_DEFAULT). */ extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind) __THROW __nonnull ((1)); #endif /* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */ extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t * __restrict __attr, int *__restrict __protocol) __THROW __nonnull ((1, 2)); /* Set the mutex protocol attribute in *ATTR to PROTOCOL (either PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */ extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr, int __protocol) __THROW __nonnull ((1)); /* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */ extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t * __restrict __attr, int *__restrict __prioceiling) __THROW __nonnull ((1, 2)); /* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */ extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr, int __prioceiling) __THROW __nonnull ((1)); #ifdef __USE_XOPEN2K /* Get the robustness flag of the mutex attribute ATTR. */ extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr, int *__robustness) __THROW __nonnull ((1, 2)); # ifdef __USE_GNU # ifdef __REDIRECT_NTH extern int __REDIRECT_NTH (pthread_mutexattr_getrobust_np, (pthread_mutexattr_t *, int *), pthread_mutexattr_getrobust) __nonnull ((1)) __attribute_deprecated_msg__ ("\ pthread_mutexattr_getrobust_np is deprecated, use pthread_mutexattr_getrobust"); # else # define pthread_mutexattr_getrobust_np pthread_mutexattr_getrobust # endif # endif /* Set the robustness flag of the mutex attribute ATTR. */ extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr, int __robustness) __THROW __nonnull ((1)); # ifdef __USE_GNU # ifdef __REDIRECT_NTH extern int __REDIRECT_NTH (pthread_mutexattr_setrobust_np, (pthread_mutexattr_t *, int), pthread_mutexattr_setrobust) __nonnull ((1)) __attribute_deprecated_msg__ ("\ pthread_mutexattr_setrobust_np is deprecated, use pthread_mutexattr_setrobust"); # else # define pthread_mutexattr_setrobust_np pthread_mutexattr_setrobust # endif # endif #endif #if defined __USE_UNIX98 || defined __USE_XOPEN2K /* Functions for handling read-write locks. */ /* Initialize read-write lock RWLOCK using attributes ATTR, or use the default values if later is NULL. */ extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock, const pthread_rwlockattr_t *__restrict __attr) __THROW __nonnull ((1)); /* Destroy read-write lock RWLOCK. */ extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) __THROW __nonnull ((1)); /* Acquire read lock for RWLOCK. */ extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) __THROWNL __nonnull ((1)); /* Try to acquire read lock for RWLOCK. */ extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) __THROWNL __nonnull ((1)); # ifdef __USE_XOPEN2K /* Try to acquire read lock for RWLOCK or return after specfied time. */ # ifndef __USE_TIME_BITS64 extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock, const struct timespec *__restrict __abstime) __THROWNL __nonnull ((1, 2)); # else # ifdef __REDIRECT_NTHNL extern int __REDIRECT_NTHNL (pthread_rwlock_timedrdlock, (pthread_rwlock_t *__restrict __rwlock, const struct timespec *__restrict __abstime), __pthread_rwlock_timedrdlock64) __nonnull ((1, 2)); # else # define pthread_rwlock_timedrdlock __pthread_rwlock_timedrdlock64 # endif # endif # endif # ifdef __USE_GNU # ifndef __USE_TIME_BITS64 extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock, clockid_t __clockid, const struct timespec *__restrict __abstime) __THROWNL __nonnull ((1, 3)); # else # ifdef __REDIRECT_NTHNL extern int __REDIRECT_NTHNL (pthread_rwlock_clockrdlock, (pthread_rwlock_t *__restrict __rwlock, clockid_t __clockid, const struct timespec *__restrict __abstime), __pthread_rwlock_clockrdlock64) __nonnull ((1, 3)); # else # define pthread_rwlock_clockrdlock __pthread_rwlock_clockrdlock64 # endif # endif # endif /* Acquire write lock for RWLOCK. */ extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) __THROWNL __nonnull ((1)); /* Try to acquire write lock for RWLOCK. */ extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) __THROWNL __nonnull ((1)); # ifdef __USE_XOPEN2K /* Try to acquire write lock for RWLOCK or return after specfied time. */ # ifndef __USE_TIME_BITS64 extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock, const struct timespec *__restrict __abstime) __THROWNL __nonnull ((1, 2)); # else # ifdef __REDIRECT_NTHNL extern int __REDIRECT_NTHNL (pthread_rwlock_timedwrlock, (pthread_rwlock_t *__restrict __rwlock, const struct timespec *__restrict __abstime), __pthread_rwlock_timedwrlock64) __nonnull ((1, 2)); # else # define pthread_rwlock_timedwrlock __pthread_rwlock_timedwrlock64 # endif # endif # endif # ifdef __USE_GNU # ifndef __USE_TIME_BITS64 extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock, clockid_t __clockid, const struct timespec *__restrict __abstime) __THROWNL __nonnull ((1, 3)); # else # ifdef __REDIRECT_NTHNL extern int __REDIRECT_NTHNL (pthread_rwlock_clockwrlock, (pthread_rwlock_t *__restrict __rwlock, clockid_t __clockid, const struct timespec *__restrict __abstime), __pthread_rwlock_clockwrlock64) __nonnull ((1, 3)); # else # define pthread_rwlock_clockwrlock __pthread_rwlock_clockwrlock64 # endif # endif # endif /* Unlock RWLOCK. */ extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) __THROWNL __nonnull ((1)); /* Functions for handling read-write lock attributes. */ /* Initialize attribute object ATTR with default values. */ extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) __THROW __nonnull ((1)); /* Destroy attribute object ATTR. */ extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) __THROW __nonnull ((1)); /* Return current setting of process-shared attribute of ATTR in PSHARED. */ extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * __restrict __attr, int *__restrict __pshared) __THROW __nonnull ((1, 2)); /* Set process-shared attribute of ATTR to PSHARED. */ extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr, int __pshared) __THROW __nonnull ((1)); /* Return current setting of reader/writer preference. */ extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t * __restrict __attr, int *__restrict __pref) __THROW __nonnull ((1, 2)); /* Set reader/write preference. */ extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr, int __pref) __THROW __nonnull ((1)); #endif /* Functions for handling conditional variables. */ /* Initialize condition variable COND using attributes ATTR, or use the default values if later is NULL. */ extern int pthread_cond_init (pthread_cond_t *__restrict __cond, const pthread_condattr_t *__restrict __cond_attr) __THROW __nonnull ((1)); /* Destroy condition variable COND. */ extern int pthread_cond_destroy (pthread_cond_t *__cond) __THROW __nonnull ((1)); /* Wake up one thread waiting for condition variable COND. */ extern int pthread_cond_signal (pthread_cond_t *__cond) __THROWNL __nonnull ((1)); /* Wake up all threads waiting for condition variables COND. */ extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROWNL __nonnull ((1)); /* Wait for condition variable COND to be signaled or broadcast. MUTEX is assumed to be locked before. This function is a cancellation point and therefore not marked with __THROW. */ extern int pthread_cond_wait (pthread_cond_t *__restrict __cond, pthread_mutex_t *__restrict __mutex) __nonnull ((1, 2)); /* Wait for condition variable COND to be signaled or broadcast until ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an absolute time specification; zero is the beginning of the epoch (00:00:00 GMT, January 1, 1970). This function is a cancellation point and therefore not marked with __THROW. */ # ifndef __USE_TIME_BITS64 extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond, pthread_mutex_t *__restrict __mutex, const struct timespec *__restrict __abstime) __nonnull ((1, 2, 3)); # else # ifdef __REDIRECT extern int __REDIRECT (pthread_cond_timedwait, (pthread_cond_t *__restrict __cond, pthread_mutex_t *__restrict __mutex, const struct timespec *__restrict __abstime), __pthread_cond_timedwait64) __nonnull ((1, 2, 3)); # else # define pthread_cond_timedwait __pthread_cond_timedwait64 # endif # endif # ifdef __USE_GNU /* Wait for condition variable COND to be signaled or broadcast until ABSTIME measured by the specified clock. MUTEX is assumed to be locked before. CLOCK is the clock to use. ABSTIME is an absolute time specification against CLOCK's epoch. This function is a cancellation point and therefore not marked with __THROW. */ # ifndef __USE_TIME_BITS64 extern int pthread_cond_clockwait (pthread_cond_t *__restrict __cond, pthread_mutex_t *__restrict __mutex, __clockid_t __clock_id, const struct timespec *__restrict __abstime) __nonnull ((1, 2, 4)); # else # ifdef __REDIRECT extern int __REDIRECT (pthread_cond_clockwait, (pthread_cond_t *__restrict __cond, pthread_mutex_t *__restrict __mutex, __clockid_t __clock_id, const struct timespec *__restrict __abstime), __pthread_cond_clockwait64) __nonnull ((1, 2, 4)); # else # define pthread_cond_clockwait __pthread_cond_clockwait64 # endif # endif # endif /* Functions for handling condition variable attributes. */ /* Initialize condition variable attribute ATTR. */ extern int pthread_condattr_init (pthread_condattr_t *__attr) __THROW __nonnull ((1)); /* Destroy condition variable attribute ATTR. */ extern int pthread_condattr_destroy (pthread_condattr_t *__attr) __THROW __nonnull ((1)); /* Get the process-shared flag of the condition variable attribute ATTR. */ extern int pthread_condattr_getpshared (const pthread_condattr_t * __restrict __attr, int *__restrict __pshared) __THROW __nonnull ((1, 2)); /* Set the process-shared flag of the condition variable attribute ATTR. */ extern int pthread_condattr_setpshared (pthread_condattr_t *__attr, int __pshared) __THROW __nonnull ((1)); #ifdef __USE_XOPEN2K /* Get the clock selected for the condition variable attribute ATTR. */ extern int pthread_condattr_getclock (const pthread_condattr_t * __restrict __attr, __clockid_t *__restrict __clock_id) __THROW __nonnull ((1, 2)); /* Set the clock selected for the condition variable attribute ATTR. */ extern int pthread_condattr_setclock (pthread_condattr_t *__attr, __clockid_t __clock_id) __THROW __nonnull ((1)); #endif #ifdef __USE_XOPEN2K /* Functions to handle spinlocks. */ /* Initialize the spinlock LOCK. If PSHARED is nonzero the spinlock can be shared between different processes. */ extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared) __THROW __nonnull ((1)); /* Destroy the spinlock LOCK. */ extern int pthread_spin_destroy (pthread_spinlock_t *__lock) __THROW __nonnull ((1)); /* Wait until spinlock LOCK is retrieved. */ extern int pthread_spin_lock (pthread_spinlock_t *__lock) __THROWNL __nonnull ((1)); /* Try to lock spinlock LOCK. */ extern int pthread_spin_trylock (pthread_spinlock_t *__lock) __THROWNL __nonnull ((1)); /* Release spinlock LOCK. */ extern int pthread_spin_unlock (pthread_spinlock_t *__lock) __THROWNL __nonnull ((1)); /* Functions to handle barriers. */ /* Initialize BARRIER with the attributes in ATTR. The barrier is opened when COUNT waiters arrived. */ extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier, const pthread_barrierattr_t *__restrict __attr, unsigned int __count) __THROW __nonnull ((1)); /* Destroy a previously dynamically initialized barrier BARRIER. */ extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) __THROW __nonnull ((1)); /* Wait on barrier BARRIER. */ extern int pthread_barrier_wait (pthread_barrier_t *__barrier) __THROWNL __nonnull ((1)); /* Initialize barrier attribute ATTR. */ extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) __THROW __nonnull ((1)); /* Destroy previously dynamically initialized barrier attribute ATTR. */ extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) __THROW __nonnull ((1)); /* Get the process-shared flag of the barrier attribute ATTR. */ extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t * __restrict __attr, int *__restrict __pshared) __THROW __nonnull ((1, 2)); /* Set the process-shared flag of the barrier attribute ATTR. */ extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr, int __pshared) __THROW __nonnull ((1)); #endif /* Functions for handling thread-specific data. */ /* Create a key value identifying a location in the thread-specific data area. Each thread maintains a distinct thread-specific data area. DESTR_FUNCTION, if non-NULL, is called with the value associated to that key when the key is destroyed. DESTR_FUNCTION is not called if the value associated is NULL when the key is destroyed. */ extern int pthread_key_create (pthread_key_t *__key, void (*__destr_function) (void *)) __THROW __nonnull ((1)); /* Destroy KEY. */ extern int pthread_key_delete (pthread_key_t __key) __THROW; /* Return current value of the thread-specific data slot identified by KEY. */ extern void *pthread_getspecific (pthread_key_t __key) __THROW; /* Store POINTER in the thread-specific data slot identified by KEY. */ extern int pthread_setspecific (pthread_key_t __key, const void *__pointer) __THROW __attr_access_none (2); #ifdef __USE_XOPEN2K /* Get ID of CPU-time clock for thread THREAD_ID. */ extern int pthread_getcpuclockid (pthread_t __thread_id, __clockid_t *__clock_id) __THROW __nonnull ((2)); #endif #ifdef __USE_GNU /* Return the Linux TID for THREAD_ID. Returns -1 on failure. */ extern pid_t pthread_gettid_np (pthread_t __thread_id); #endif /* Install handlers to be called when a new process is created with FORK. The PREPARE handler is called in the parent process just before performing FORK. The PARENT handler is called in the parent process just after FORK. The CHILD handler is called in the child process. Each of the three handlers can be NULL, meaning that no handler needs to be called at that point. PTHREAD_ATFORK can be called several times, in which case the PREPARE handlers are called in LIFO order (last added with PTHREAD_ATFORK, first called before FORK), and the PARENT and CHILD handlers are called in FIFO (first added, first called). */ extern int pthread_atfork (void (*__prepare) (void), void (*__parent) (void), void (*__child) (void)) __THROW; #ifdef __USE_EXTERN_INLINES /* Optimizations. */ __extern_inline int __NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2)) { return __thread1 == __thread2; } #endif __END_DECLS #endif /* pthread.h */ /* Copyright (C) 1996-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* * ISO/IEC 9945-1:1996 6.7: Asynchronous Input and Output */ #ifndef _AIO_H #define _AIO_H 1 #include <features.h> #include <sys/types.h> #include <bits/types/sigevent_t.h> #include <bits/sigevent-consts.h> #include <bits/types/struct_timespec.h> __BEGIN_DECLS /* Asynchronous I/O control block. */ struct aiocb { int aio_fildes; /* File descriptor. */ int aio_lio_opcode; /* Operation to be performed. */ int aio_reqprio; /* Request priority offset. */ volatile void *aio_buf; /* Location of buffer. */ size_t aio_nbytes; /* Length of transfer. */ struct sigevent aio_sigevent; /* Signal number and value. */ /* Internal members. */ struct aiocb *__next_prio; int __abs_prio; int __policy; int __error_code; __ssize_t __return_value; #ifndef __USE_FILE_OFFSET64 __off_t aio_offset; /* File offset. */ char __pad[sizeof (__off64_t) - sizeof (__off_t)]; #else __off64_t aio_offset; /* File offset. */ #endif char __glibc_reserved[32]; }; /* The same for the 64bit offsets. Please note that the members aio_fildes to __return_value have to be the same in aiocb and aiocb64. */ #ifdef __USE_LARGEFILE64 struct aiocb64 { int aio_fildes; /* File descriptor. */ int aio_lio_opcode; /* Operation to be performed. */ int aio_reqprio; /* Request priority offset. */ volatile void *aio_buf; /* Location of buffer. */ size_t aio_nbytes; /* Length of transfer. */ struct sigevent aio_sigevent; /* Signal number and value. */ /* Internal members. */ struct aiocb *__next_prio; int __abs_prio; int __policy; int __error_code; __ssize_t __return_value; __off64_t aio_offset; /* File offset. */ char __glibc_reserved[32]; }; #endif #ifdef __USE_GNU /* To optimize the implementation one can use the following struct. */ struct aioinit { int aio_threads; /* Maximum number of threads. */ int aio_num; /* Number of expected simultaneous requests. */ int aio_locks; /* Not used. */ int aio_usedba; /* Not used. */ int aio_debug; /* Not used. */ int aio_numusers; /* Not used. */ int aio_idle_time; /* Number of seconds before idle thread terminates. */ int aio_reserved; }; #endif /* Return values of the aio_cancel function. */ enum { AIO_CANCELED, #define AIO_CANCELED AIO_CANCELED AIO_NOTCANCELED, #define AIO_NOTCANCELED AIO_NOTCANCELED AIO_ALLDONE #define AIO_ALLDONE AIO_ALLDONE }; /* Operation codes for `aio_lio_opcode'. */ enum { LIO_READ, #define LIO_READ LIO_READ LIO_WRITE, #define LIO_WRITE LIO_WRITE LIO_NOP #define LIO_NOP LIO_NOP }; /* Synchronization options for `lio_listio' function. */ enum { LIO_WAIT, #define LIO_WAIT LIO_WAIT LIO_NOWAIT #define LIO_NOWAIT LIO_NOWAIT }; /* Allow user to specify optimization. */ #ifdef __USE_GNU extern void aio_init (const struct aioinit *__init) __THROW __nonnull ((1)); #endif #ifndef __USE_FILE_OFFSET64 /* Enqueue read request for given number of bytes and the given priority. */ extern int aio_read (struct aiocb *__aiocbp) __THROW __nonnull ((1)); /* Enqueue write request for given number of bytes and the given priority. */ extern int aio_write (struct aiocb *__aiocbp) __THROW __nonnull ((1)); /* Initiate list of I/O requests. */ extern int lio_listio (int __mode, struct aiocb *const __list[__restrict_arr], int __nent, struct sigevent *__restrict __sig) __THROW __nonnull ((2)); /* Retrieve error status associated with AIOCBP. */ extern int aio_error (const struct aiocb *__aiocbp) __THROW __nonnull ((1)); /* Return status associated with AIOCBP. */ extern __ssize_t aio_return (struct aiocb *__aiocbp) __THROW __nonnull ((1)); /* Try to cancel asynchronous I/O requests outstanding against file descriptor FILDES. */ extern int aio_cancel (int __fildes, struct aiocb *__aiocbp) __THROW; /* Suspend calling thread until at least one of the asynchronous I/O operations referenced by LIST has completed. This function is a cancellation point and therefore not marked with __THROW. */ extern int aio_suspend (const struct aiocb *const __list[], int __nent, const struct timespec *__restrict __timeout) __nonnull ((1)); /* Force all operations associated with file desriptor described by `aio_fildes' member of AIOCBP. */ extern int aio_fsync (int __operation, struct aiocb *__aiocbp) __THROW __nonnull ((2)); #else # ifdef __REDIRECT_NTH extern int __REDIRECT_NTH (aio_read, (struct aiocb *__aiocbp), aio_read64) __nonnull ((1)); extern int __REDIRECT_NTH (aio_write, (struct aiocb *__aiocbp), aio_write64) __nonnull ((1)); extern int __REDIRECT_NTH (lio_listio, (int __mode, struct aiocb *const __list[__restrict_arr], int __nent, struct sigevent *__restrict __sig), lio_listio64) __nonnull ((2)); extern int __REDIRECT_NTH (aio_error, (const struct aiocb *__aiocbp), aio_error64) __nonnull ((1)); extern __ssize_t __REDIRECT_NTH (aio_return, (struct aiocb *__aiocbp), aio_return64) __nonnull ((1)); extern int __REDIRECT_NTH (aio_cancel, (int __fildes, struct aiocb *__aiocbp), aio_cancel64); # ifdef __USE_TIME_BITS64 extern int __REDIRECT_NTH (aio_suspend, (const struct aiocb *const __list[], int __nent, const struct timespec *__restrict __timeout), __aio_suspend_time64) __nonnull ((1)); # else extern int __REDIRECT_NTH (aio_suspend, (const struct aiocb *const __list[], int __nent, const struct timespec *__restrict __timeout), aio_suspend64) __nonnull ((1)); # endif extern int __REDIRECT_NTH (aio_fsync, (int __operation, struct aiocb *__aiocbp), aio_fsync64) __nonnull ((2)); # else # define aio_read aio_read64 # define aio_write aio_write64 # define lio_listio lio_listio64 # define aio_error aio_error64 # define aio_return aio_return64 # define aio_cancel aio_cancel64 # ifdef __USE_TIME_BITS64 # define aio_suspend __aio_suspend_time64 # else # define aio_suspend aio_suspend64 # endif # define aio_fsync aio_fsync64 # endif #endif #ifdef __USE_LARGEFILE64 extern int aio_read64 (struct aiocb64 *__aiocbp) __THROW __nonnull ((1)); extern int aio_write64 (struct aiocb64 *__aiocbp) __THROW __nonnull ((1)); extern int lio_listio64 (int __mode, struct aiocb64 *const __list[__restrict_arr], int __nent, struct sigevent *__restrict __sig) __THROW __nonnull ((2)); extern int aio_error64 (const struct aiocb64 *__aiocbp) __THROW __nonnull ((1)); extern __ssize_t aio_return64 (struct aiocb64 *__aiocbp) __THROW __nonnull ((1)); extern int aio_cancel64 (int __fildes, struct aiocb64 *__aiocbp) __THROW; extern int aio_suspend64 (const struct aiocb64 *const __list[], int __nent, const struct timespec *__restrict __timeout) __THROW __nonnull ((1)); extern int aio_fsync64 (int __operation, struct aiocb64 *__aiocbp) __THROW __nonnull ((2)); #endif __END_DECLS #endif /* aio.h */ /* Features part to handle 64-bit time_t support. Copyright (C) 2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* We need to know the word size in order to check the time size. */ #include <bits/wordsize.h> #include <bits/timesize.h> #if defined _TIME_BITS # if _TIME_BITS == 64 # if ! defined (_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS != 64 # error "_TIME_BITS=64 is allowed only with _FILE_OFFSET_BITS=64" # elif __TIMESIZE == 32 # define __USE_TIME_BITS64 1 # endif # elif _TIME_BITS == 32 # if __TIMESIZE > 32 # error "_TIME_BITS=32 is not compatible with __TIMESIZE > 32" # endif # else # error Invalid _TIME_BITS value (can only be 32 or 64-bit) # endif #endif /* Definitions for use with Linux AF_ASH sockets. Copyright (C) 1998-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _NETASH_ASH_H #define _NETASH_ASH_H 1 #include <features.h> #include <bits/sockaddr.h> struct sockaddr_ash { __SOCKADDR_COMMON (sash_); /* Common data: address family etc. */ int sash_ifindex; /* Interface to use. */ unsigned char sash_channel; /* Realtime or control. */ unsigned int sash_plen; unsigned char sash_prefix[16]; }; /* Values for `channel' member. */ #define ASH_CHANNEL_ANY 0 #define ASH_CHANNEL_CONTROL 1 #define ASH_CHANNEL_REALTIME 2 #endif /* netash/ash.h */ /* GRAPHITE2 LICENSING Copyright 2010, SIL International 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 License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should also have received a copy of the GNU Lesser General Public License along with this library in the file named "LICENSE". If not, write to the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA or visit their web page on the internet at http://www.fsf.org/licenses/lgpl.html. Alternatively, the contents of this file may be used under the terms of the Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public License, as published by the Free Software Foundation, either version 2 of the License or (at your option) any later version. */ #pragma once #include "graphite2/Types.h" #include "graphite2/Font.h" #ifdef __cplusplus extern "C" { #endif enum gr_break_weight { gr_breakNone = 0, /* after break weights */ gr_breakWhitespace = 10, gr_breakWord = 15, gr_breakIntra = 20, gr_breakLetter = 30, gr_breakClip = 40, /* before break weights */ gr_breakBeforeWhitespace = -10, gr_breakBeforeWord = -15, gr_breakBeforeIntra = -20, gr_breakBeforeLetter = -30, gr_breakBeforeClip = -40 }; enum gr_justFlags { /// Indicates that this segment is a complete line gr_justCompleteLine = 0, /// Indicates that the start of the slot list is not at the start of a line gr_justStartInline = 1, /// Indicates that the end of the slot list is not at the end of a line gr_justEndInline = 2 }; /** Used for looking up slot attributes. Most are already available in other functions **/ enum gr_attrCode { /// adjusted glyph advance in x direction in design units gr_slatAdvX = 0, /// adjusted glyph advance in y direction (usually 0) in design units gr_slatAdvY, /// returns 0. Deprecated. gr_slatAttTo, /// This slot attaches to its parent at the given design units in the x direction gr_slatAttX, /// This slot attaches to its parent at the given design units in the y direction gr_slatAttY, /// This slot attaches to its parent at the given glyph point (not implemented) gr_slatAttGpt, /// x-direction adjustment from the given glyph point (not implemented) gr_slatAttXOff, /// y-direction adjustment from the given glyph point (not implemented) gr_slatAttYOff, /// Where on this glyph should align with the attachment point on the parent glyph in the x-direction. gr_slatAttWithX, /// Where on this glyph should align with the attachment point on the parent glyph in the y-direction gr_slatAttWithY, /// Which glyph point on this glyph should align with the attachment point on the parent glyph (not implemented). gr_slatWithGpt, /// Adjustment to gr_slatWithGpt in x-direction (not implemented) gr_slatAttWithXOff, /// Adjustment to gr_slatWithGpt in y-direction (not implemented) gr_slatAttWithYOff, /// Attach at given nesting level (not implemented) gr_slatAttLevel, /// Line break breakweight for this glyph gr_slatBreak, /// Ligature component reference (not implemented) gr_slatCompRef, /// bidi directionality of this glyph (not implemented) gr_slatDir, /// Whether insertion is allowed before this glyph gr_slatInsert, /// Final positioned position of this glyph relative to its parent in x-direction in pixels gr_slatPosX, /// Final positioned position of this glyph relative to its parent in y-direction in pixels gr_slatPosY, /// Amount to shift glyph by in x-direction design units gr_slatShiftX, /// Amount to shift glyph by in y-direction design units gr_slatShiftY, /// attribute user1 gr_slatUserDefnV1, /// not implemented gr_slatMeasureSol, /// not implemented gr_slatMeasureEol, /// Amount this slot can stretch (not implemented) gr_slatJStretch, /// Amount this slot can shrink (not implemented) gr_slatJShrink, /// Granularity by which this slot can stretch or shrink (not implemented) gr_slatJStep, /// Justification weight for this glyph (not implemented) gr_slatJWeight, /// Amount this slot mush shrink or stretch in design units gr_slatJWidth = 29, /// SubSegment split point gr_slatSegSplit = gr_slatJStretch + 29, /// User defined attribute, see subattr for user attr number gr_slatUserDefn, /// Bidi level gr_slatBidiLevel = 56, /// Collision flags gr_slatColFlags, /// Collision constraint rectangle left (bl.x) gr_slatColLimitblx, /// Collision constraint rectangle lower (bl.y) gr_slatColLimitbly, /// Collision constraint rectangle right (tr.x) gr_slatColLimittrx, /// Collision constraint rectangle upper (tr.y) gr_slatColLimittry, /// Collision shift x gr_slatColShiftx, /// Collision shift y gr_slatColShifty, /// Collision margin gr_slatColMargin, /// Margin cost weight gr_slatColMarginWt, // Additional glyph that excludes movement near this one: gr_slatColExclGlyph, gr_slatColExclOffx, gr_slatColExclOffy, // Collision sequence enforcing attributes: gr_slatSeqClass, gr_slatSeqProxClass, gr_slatSeqOrder, gr_slatSeqAboveXoff, gr_slatSeqAboveWt, gr_slatSeqBelowXlim, gr_slatSeqBelowWt, gr_slatSeqValignHt, gr_slatSeqValignWt, /// not implemented gr_slatMax, /// not implemented gr_slatNoEffect = gr_slatMax + 1 }; enum gr_bidirtl { /// Underlying paragraph direction is RTL gr_rtl = 1, /// Set this to not run the bidi pass internally, even if the font asks for it. /// This presumes that the segment is in a single direction. Most of the time /// this bit should be set unless you know you are passing full paragraphs of text. gr_nobidi = 2, /// Disable auto mirroring for rtl text gr_nomirror = 4 }; typedef struct gr_char_info gr_char_info; typedef struct gr_segment gr_segment; typedef struct gr_slot gr_slot; /** Returns Unicode character for a charinfo. * * @param p Pointer to charinfo to return information on. */ GR2_API unsigned int gr_cinfo_unicode_char(const gr_char_info* p/*not NULL*/); /** Returns breakweight for a charinfo. * * @return Breakweight is a number between -50 and 50 indicating the cost of a * break before or after this character. If the value < 0, the absolute value * is this character's contribution to the overall breakweight before it. If the value * > 0, then the value is this character's contribution to the overall breakweight after it. * The overall breakweight between two characters is the maximum of the breakweight * contributions from the characters either side of it. If a character makes no * contribution to the breakweight on one side of it, the contribution is considered * to be 0. * @param p Pointer to charinfo to return information on. */ GR2_API int gr_cinfo_break_weight(const gr_char_info* p/*not NULL*/); /** Returns the slot index that after this character is after in the slot stream * * In effect each character is associated with a set of slots and this returns * the index of the last slot in the segment this character is associated with. * * @return after slot index between 0 and gr_seg_n_slots() * @param p Pointer to charinfo to return information on. */ GR2_API int gr_cinfo_after(const gr_char_info* p/*not NULL*/); /** Returns the slot index that before this character is before in the slot stream * * In effect each character is associated with a set of slots and this returns * the index of the first slot in the segment this character is associated with. * * @return before slot index between 0 and gr_seg_n_slots() * @param p Pointer to charinfo to return information on. */ GR2_API int gr_cinfo_before(const gr_char_info* p/*not NULL*/); /** Returns the code unit index of this character in the input string * * @return code unit index between 0 and the end of the string * @param p Pointer to charinfo to return information on. */ GR2_API size_t gr_cinfo_base(const gr_char_info* p/*not NULL*/); /** Returns the number of unicode characters in a string. * * @return number of characters in the string * @param enc Specifies the type of data in the string: utf8, utf16, utf32 * @param buffer_begin The start of the string * @param buffer_end Measure up to the first nul or when end is reached, whichever is earliest. * This parameter may be NULL. * @param pError If there is a structural fault in the string, the location is returned * in this variable. If no error occurs, pError will contain NULL. NULL * may be passed for pError if no such information is required. */ GR2_API size_t gr_count_unicode_characters(enum gr_encform enc, const void* buffer_begin, const void* buffer_end, const void** pError); /** Creates and returns a segment. * * @return a segment that needs seg_destroy called on it. May return NULL if bad problems * in segment processing. * @param font Gives the size of the font in pixels per em for final positioning. If * NULL, positions are returned in design units, i.e. at a ppm of the upem * of the face. * @param face The face containing all the non-size dependent information. * @param script This is a tag containing a script identifier that is used to choose * which graphite table within the font to use. Maybe 0. Tag may be 4 chars * NULL padded in LSBs or space padded in LSBs. * @param pFeats Pointer to a feature values to be used for the segment. Only one * feature values may be used for a segment. If NULL the default features * for the font will be used. * @param enc Specifies what encoding form the string is in (utf8, utf16, utf32) * @param pStart Start of the string * @param nChars Number of unicode characters to process in the string. The string will * be processed either up to the first NULL or until nChars have been * processed. nChars is also used to initialise the internal memory * allocations of the segment. So it is wise not to make nChars too much * greater than the actual number of characters being processed. * @param dir Specifies whether the segment is processed right to left (1) or left to * right (0) and whether to run the internal bidi pass, if a font requests it. * See enum gr_bidirtl for details. */ GR2_API gr_segment* gr_make_seg(const gr_font* font, const gr_face* face, gr_uint32 script, const gr_feature_val* pFeats, enum gr_encform enc, const void* pStart, size_t nChars, int dir); /** Destroys a segment, freeing the memory. * * @param p The segment to destroy */ GR2_API void gr_seg_destroy(gr_segment* p); /** Returns the advance for the whole segment. * * Returns the width of the segment up to the next glyph origin after the segment */ GR2_API float gr_seg_advance_X(const gr_segment* pSeg/*not NULL*/); /** Returns the height advance for the segment. **/ GR2_API float gr_seg_advance_Y(const gr_segment* pSeg/*not NULL*/); /** Returns the number of gr_char_infos in the segment. **/ GR2_API unsigned int gr_seg_n_cinfo(const gr_segment* pSeg/*not NULL*/); /** Returns a gr_char_info at a given index in the segment. **/ GR2_API const gr_char_info* gr_seg_cinfo(const gr_segment* pSeg/*not NULL*/, unsigned int index/*must be <number_of_CharInfo*/); /** Returns the number of glyph gr_slots in the segment. **/ GR2_API unsigned int gr_seg_n_slots(const gr_segment* pSeg/*not NULL*/); //one slot per glyph /** Returns the first gr_slot in the segment. * * The first slot in a segment has a gr_slot_prev_in_segment() of NULL. Slots are owned * by their segment and are destroyed along with the segment. */ GR2_API const gr_slot* gr_seg_first_slot(gr_segment* pSeg/*not NULL*/); //may give a base slot or a slot which is attached to another /** Returns the last gr_slot in the segment. * * The last slot in a segment has a gr_slot_next_in_segment() of NULL */ GR2_API const gr_slot* gr_seg_last_slot(gr_segment* pSeg/*not NULL*/); //may give a base slot or a slot which is attached to another /** Justifies a linked list of slots for a line to a given width * * Passed a pointer to the start of a linked list of slots corresponding to a line, as * set up by gr_slot_linebreak_before, this function will position the glyphs in the line * to take up the given width. It is possible to specify a subrange within the line to process. * This allows skipping of line initial or final whitespace, for example. While this will ensure * that the subrange fits width, the line will still be positioned with the first glyph of the * line at 0. So the resulting positions may be beyond width. * * @return float The resulting width of the range of slots justified. * @param pSeg Pointer to the segment * @param pStart Pointer to the start of the line linked list (including skipped characters) * @param pFont Font to use for positioning * @param width Width in pixels in which to fit the line. If < 0. don't adjust natural width, just run justification passes * to handle line end contextuals, if there are any. * @param flags Indicates line ending types. Default is linked list is a full line * @param pFirst If not NULL, the first slot in the list to be considered part of the line (so can skip) * @param pLast If not NULL, the last slot to process in the line (allow say trailing whitespace to be skipped) */ GR2_API float gr_seg_justify(gr_segment* pSeg/*not NULL*/, const gr_slot* pStart/*not NULL*/, const gr_font *pFont, double width, enum gr_justFlags flags, const gr_slot* pFirst, const gr_slot* pLast); /** Returns the next slot along in the segment. * * Slots are held in a linked list. This returns the next in the linked list. The slot * may or may not be attached to another slot. Returns NULL at the end of the segment. */ GR2_API const gr_slot* gr_slot_next_in_segment(const gr_slot* p); /** Returns the previous slot along in the segment. * * Slots are held in a doubly linked list. This returns the previos slot in the linked * list. This slot may or may not be attached to it. Returns NULL at the start of the * segment. */ GR2_API const gr_slot* gr_slot_prev_in_segment(const gr_slot* p); /** Returns the attachment parent slot of this slot. * * Attached slots form a tree. This returns the parent of this slot in that tree. A * base glyph which is not attached to another glyph, always returns NULL. */ GR2_API const gr_slot* gr_slot_attached_to(const gr_slot* p); /** Returns the first slot attached to this slot. * * Attached slots form a singly linked list from the parent. This returns the first * slot in that list. Note that this is a reference to another slot that is also in * the main segment doubly linked list. * * if gr_slot_first_attachment(p) != NULL then gr_slot_attached_to(gr_slot_first_attachment(p)) == p. */ GR2_API const gr_slot* gr_slot_first_attachment(const gr_slot* p); /** Returns the next slot attached to our attachment parent. * * This returns the next slot in the singly linked list of slots attached to this * slot's parent. If there are no more such slots, NULL is returned. If there is * no parent, i.e. the passed slot is a cluster base, then the next cluster base * in graphical order (ltr, even for rtl text) is returned. * * if gr_slot_next_sibling_attachment(p) != NULL then gr_slot_attached_to(gr_slot_next_sibling_attachment(p)) == gr_slot_attached_to(p). */ GR2_API const gr_slot* gr_slot_next_sibling_attachment(const gr_slot* p); /** Returns glyph id of the slot * * Each slot has a glyphid which is rendered at the position given by the slot. This * glyphid is the real glyph to be rendered and never a pseudo glyph. */ GR2_API unsigned short gr_slot_gid(const gr_slot* p); /** Returns X offset of glyph from start of segment **/ GR2_API float gr_slot_origin_X(const gr_slot* p); /** Returns Y offset of glyph from start of segment **/ GR2_API float gr_slot_origin_Y(const gr_slot* p); /** Returns the glyph advance for this glyph as adjusted for kerning * * @param p Slot to give results for * @param face gr_face of the glyphs. May be NULL if unhinted advances used * @param font gr_font to scale for pixel results. If NULL returns design * units advance. If not NULL then returns pixel advance based * on hinted or scaled glyph advances in the font. face must be * passed for hinted advances to be used. */ GR2_API float gr_slot_advance_X(const gr_slot* p, const gr_face* face, const gr_font *font); /** Returns the vertical advance for the glyph in the slot adjusted for kerning * * Returns design units unless font is not NULL in which case the pixel value * is returned scaled for the given font */ GR2_API float gr_slot_advance_Y(const gr_slot* p, const gr_face* face, const gr_font *font); /** Returns the gr_char_info index before us * * Returns the index of the gr_char_info that a cursor before this slot, would put * an underlying cursor before. This may also be interpretted as each slot holding * a set of char_infos that it is associated with and this function returning the * index of the char_info with lowest index, from this set. */ GR2_API int gr_slot_before(const gr_slot* p/*not NULL*/); /** Returns the gr_char_info index after us * * Returns the index of the gr_char_info that a cursor after this slot would put an * underlying cursor after. This may also be interpretted as each slot holding a set * of char_infos that it is associated with and this function returning the index of * the char_info with the highest index, from this set. */ GR2_API int gr_slot_after(const gr_slot* p/*not NULL*/); /** Returns the index of this slot in the segment * * Returns the index given to this slot during final positioning. This corresponds * to the value returned br gr_cinfo_before() and gr_cinfo_after() */ GR2_API unsigned int gr_slot_index(const gr_slot* p/*not NULL*/); /** Return a slot attribute value * * Given a slot and an attribute along with a possible subattribute, return the * corresponding value in the slot. See enum gr_attrCode for details of each attribute. */ GR2_API int gr_slot_attr(const gr_slot* p/*not NULL*/, const gr_segment* pSeg/*not NULL*/, enum gr_attrCode index, gr_uint8 subindex); //tbd - do we need to expose this? /** Returns whether text may be inserted before this glyph. * * This indicates whether a cursor can be put before this slot. It applies to * base glyphs that have no parent as well as attached glyphs that have the * .insert attribute explicitly set to true. This is the primary mechanism * for identifying contiguous sequences of base plus diacritics. */ GR2_API int gr_slot_can_insert_before(const gr_slot* p); /** Returns the original gr_char_info index this slot refers to. * * Each Slot has a gr_char_info that it originates from. This is that gr_char_info. * The index is passed to gr_seg_cinfo(). This information is useful for testing. */ GR2_API int gr_slot_original(const gr_slot* p/*not NULL*/); /** Breaks a segment into lines. * * Breaks the slot linked list at the given point in the linked list. It is up * to the application to keep track of the first slot on each line. */ GR2_API void gr_slot_linebreak_before(gr_slot *p/*not NULL*/); #ifdef __cplusplus } #endif /* GRAPHITE2 LICENSING Copyright 2010, SIL International 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 License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should also have received a copy of the GNU Lesser General Public License along with this library in the file named "LICENSE". If not, write to the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA or visit their web page on the internet at http://www.fsf.org/licenses/lgpl.html. Alternatively, the contents of this file may be used under the terms of the Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public License, as published by the Free Software Foundation, either version 2 of the License or (at your option) any later version. */ #pragma once #include <stddef.h> typedef unsigned char gr_uint8; typedef gr_uint8 gr_byte; typedef signed char gr_int8; typedef unsigned short gr_uint16; typedef short gr_int16; typedef unsigned int gr_uint32; typedef int gr_int32; enum gr_encform { gr_utf8 = 1/*sizeof(uint8)*/, gr_utf16 = 2/*sizeof(uint16)*/, gr_utf32 = 4/*sizeof(uint32)*/ }; // Define API function declspec/attributes and how each supported compiler or OS // allows us to specify them. #if defined __GNUC__ #define _gr2_and , #define _gr2_tag_fn(a) __attribute__((a)) #define _gr2_deprecated_flag deprecated #define _gr2_export_flag visibility("default") #define _gr2_import_flag visibility("default") #define _gr2_static_flag visibility("hidden") #endif #if defined _WIN32 || defined __CYGWIN__ #if defined __GNUC__ // These three will be redefined for Windows #undef _gr2_export_flag #undef _gr2_import_flag #undef _gr2_static_flag #else // How MSVC sepcifies function level attributes adn deprecation #define _gr2_and #define _gr2_tag_fn(a) __declspec(a) #define _gr2_deprecated_flag deprecated #endif #define _gr2_export_flag dllexport #define _gr2_import_flag dllimport #define _gr2_static_flag #endif #if defined GRAPHITE2_STATIC #define GR2_API _gr2_tag_fn(_gr2_static_flag) #define GR2_DEPRECATED_API _gr2_tag_fn(_gr2_deprecated_flag _gr2_and _gr2_static_flag) #elif defined GRAPHITE2_EXPORTING #define GR2_API _gr2_tag_fn(_gr2_export_flag) #define GR2_DEPRECATED_API _gr2_tag_fn(_gr2_deprecated_flag _gr2_and _gr2_export_flag) #else #define GR2_API _gr2_tag_fn(_gr2_import_flag) #define GR2_DEPRECATED_API _gr2_tag_fn(_gr2_deprecated_flag _gr2_and _gr2_import_flag) #endif /* GRAPHITE2 LICENSING Copyright 2010, SIL International 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 License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should also have received a copy of the GNU Lesser General Public License along with this library in the file named "LICENSE". If not, write to the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA or visit their web page on the internet at http://www.fsf.org/licenses/lgpl.html. Alternatively, the contents of this file may be used under the terms of the Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public License, as published by the Free Software Foundation, either version 2 of the License or (at your option) any later version. */ #pragma once #include <graphite2/Types.h> #include <graphite2/Font.h> #include <stdio.h> #ifdef __cplusplus extern "C" { #endif /** deprecated mechanism that doesn't do anything now. */ typedef enum { GRLOG_NONE = 0x0, GRLOG_FACE = 0x01, GRLOG_SEGMENT = 0x02, GRLOG_PASS = 0x04, GRLOG_CACHE = 0x08, GRLOG_OPCODE = 0x80, GRLOG_ALL = 0xFF } GrLogMask; /** Start logging all segment creation and updates on the provided face. This * is logged to a JSON file, see "Segment JSON Schema.txt" for a precise * definition of the file * * @return true if the file was successfully created and logging is correctly * initialised. * @param face the gr_face whose segments you want to log to the given file * @param log_path a utf8 encoded file name and path to log to. */ GR2_API bool gr_start_logging(gr_face * face, const char *log_path); /** Stop logging on the given face. This will close the log file created by * gr_start_logging. * * @param face the gr_face whose segments you want to stop logging */ GR2_API void gr_stop_logging(gr_face * face); /** Start logging to a FILE object. * This function is deprecated as of 1.2.0, use the _face versions instead. * * @return True on success * @param logfile FILE reference to output logging to * @param mask What aspects of logging to report (ignored) */ GR2_API bool graphite_start_logging(FILE * logFile, GrLogMask mask); //may not do anthing if disabled in the implementation of the engine. /** Stop logging to a FILE object. * This function is deprecated as of 1.2.0, use the _face versions instead. */ GR2_API void graphite_stop_logging(); #ifdef __cplusplus } #endif /* GRAPHITE2 LICENSING Copyright 2010, SIL International 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 License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should also have received a copy of the GNU Lesser General Public License along with this library in the file named "LICENSE". If not, write to the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA or visit their web page on the internet at http://www.fsf.org/licenses/lgpl.html. Alternatively, the contents of this file may be used under the terms of the Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public License, as published by the Free Software Foundation, either version 2 of the License or (at your option) any later version. */ #pragma once #include "graphite2/Types.h" #define GR2_VERSION_MAJOR 1 #define GR2_VERSION_MINOR 3 #define GR2_VERSION_BUGFIX 14 #ifdef __cplusplus extern "C" { #endif typedef struct gr_face gr_face; typedef struct gr_font gr_font; typedef struct gr_feature_ref gr_feature_ref; typedef struct gr_feature_val gr_feature_val; /** * Returns version information on this engine */ GR2_API void gr_engine_version(int *nMajor, int *nMinor, int *nBugFix); /** * The Face Options allow the application to require that certain tables are * read during face construction. This may be of concern if the appFaceHandle * used in the gr_get_table_fn may change. * The values can be combined */ enum gr_face_options { /** No preload, no cmap caching, fail if the graphite tables are invalid */ gr_face_default = 0, /** Dumb rendering will be enabled if the graphite tables are invalid. @deprecated Since 1.311 */ gr_face_dumbRendering = 1, /** preload glyphs at construction time */ gr_face_preloadGlyphs = 2, /** Cache the lookup from code point to glyph ID at construction time */ gr_face_cacheCmap = 4, /** Preload everything */ gr_face_preloadAll = gr_face_preloadGlyphs | gr_face_cacheCmap }; /** Holds information about a particular Graphite silf table that has been loaded */ struct gr_faceinfo { gr_uint16 extra_ascent; /**< The extra_ascent in the GDL, in design units */ gr_uint16 extra_descent; /**< The extra_descent in the GDL, in design units */ gr_uint16 upem; /**< The design units for the font */ enum gr_space_contextuals { gr_space_unknown = 0, /**< no information is known. */ gr_space_none = 1, /**< the space character never occurs in any rules. */ gr_space_left_only = 2, /**< the space character only occurs as the first element in a rule. */ gr_space_right_only = 3, /**< the space character only occurs as the last element in a rule. */ gr_space_either_only = 4, /**< the space character only occurs as the only element in a rule. */ gr_space_both = 5, /**< the space character may occur as the first or last element of a rule. */ gr_space_cross = 6 /**< the space character occurs in a rule not as a first or last element. */ } space_contextuals; unsigned int has_bidi_pass : 1; /**< the table specifies that a bidirectional pass should run */ unsigned int line_ends : 1; /**< there are line end contextuals somewhere */ unsigned int justifies : 1; /**< there are .justify properties set somewhere on some glyphs */ }; typedef struct gr_faceinfo gr_faceinfo; /** type describing function to retrieve font table information * * @return a pointer to the table in memory. The pointed to memory must exist as * long as the gr_face which makes the call. * @param appFaceHandle is the unique information passed to gr_make_face() * @param name is a 32bit tag to the table name. * @param len returned by this function to say how long the table is in memory. */ typedef const void *(*gr_get_table_fn)(const void* appFaceHandle, unsigned int name, size_t *len); /** type describing function to release any resources allocated by the above get_table table function * * @param appFaceHandle is the unique information passed to gr_make_face() * @param pointer to table memory returned by get_table. */ typedef void (*gr_release_table_fn)(const void* appFaceHandle, const void *table_buffer); /** struct housing function pointers to manage font table buffers for the graphite engine. */ struct gr_face_ops { /** size in bytes of this structure */ size_t size; /** a pointer to a function to request a table from the client. */ gr_get_table_fn get_table; /** is a pointer to a function to notify the client the a table can be released. * This can be NULL to signify that the client does not wish to do any release handling. */ gr_release_table_fn release_table; }; typedef struct gr_face_ops gr_face_ops; /** Create a gr_face object given application information and a table functions. * * @return gr_face or NULL if the font fails to load for some reason. * @param appFaceHandle This is application specific information that is passed * to the getTable function. The appFaceHandle must stay * alive as long as the gr_face is alive. * @param face_ops Pointer to face specific callback structure for table * management. Must stay alive for the duration of the * call only. * @param faceOptions Bitfield describing various options. See enum gr_face_options for details. */ GR2_API gr_face* gr_make_face_with_ops(const void* appFaceHandle/*non-NULL*/, const gr_face_ops *face_ops, unsigned int faceOptions); /** @deprecated Since v1.2.0 in favour of gr_make_face_with_ops. * Create a gr_face object given application information and a getTable function. * * @return gr_face or NULL if the font fails to load for some reason. * @param appFaceHandle This is application specific information that is passed * to the getTable function. The appFaceHandle must stay * alive as long as the gr_face is alive. * @param getTable Callback function to get table data. * @param faceOptions Bitfield describing various options. See enum gr_face_options for details. */ GR2_DEPRECATED_API gr_face* gr_make_face(const void* appFaceHandle/*non-NULL*/, gr_get_table_fn getTable, unsigned int faceOptions); /** @deprecated Since 1.3.7 this function is now an alias for gr_make_face_with_ops(). * * Create a gr_face object given application information, with subsegmental caching support * * @return gr_face or NULL if the font fails to load. * @param appFaceHandle is a pointer to application specific information that is passed to getTable. * This may not be NULL and must stay alive as long as the gr_face is alive. * @param face_ops Pointer to face specific callback structure for table management. Must stay * alive for the duration of the call only. * @param segCacheMaxSize Unused. * @param faceOptions Bitfield of values from enum gr_face_options */ GR2_DEPRECATED_API gr_face* gr_make_face_with_seg_cache_and_ops(const void* appFaceHandle, const gr_face_ops *face_ops, unsigned int segCacheMaxSize, unsigned int faceOptions); /** @deprecated Since 1.3.7 this function is now an alias for gr_make_face(). * * Create a gr_face object given application information, with subsegmental caching support. * This function is deprecated as of v1.2.0 in favour of gr_make_face_with_seg_cache_and_ops. * * @return gr_face or NULL if the font fails to load. * @param appFaceHandle is a pointer to application specific information that is passed to getTable. * This may not be NULL and must stay alive as long as the gr_face is alive. * @param getTable The function graphite calls to access font table data * @param segCacheMaxSize How large the segment cache is. * @param faceOptions Bitfield of values from enum gr_face_options */ GR2_DEPRECATED_API gr_face* gr_make_face_with_seg_cache(const void* appFaceHandle, gr_get_table_fn getTable, unsigned int segCacheMaxSize, unsigned int faceOptions); /** Convert a tag in a string into a gr_uint32 * * @return gr_uint32 tag, zero padded * @param str a nul terminated string of which at most the first 4 characters are read */ GR2_API gr_uint32 gr_str_to_tag(const char *str); /** Convert a gr_uint32 tag into a string * * @param tag contains the tag to convert * @param str is a pointer to a char array of at least size 4 bytes. The first 4 bytes of this array * will be overwritten by this function. No nul is appended. */ GR2_API void gr_tag_to_str(gr_uint32 tag, char *str); /** Get feature values for a given language or default * * @return a copy of the default feature values for a given language. The application must call * gr_featureval_destroy() to free this object when done. * @param pFace The font face to get feature values from * @param langname The language tag to get feature values for. If there is no such language or * langname is 0, the default feature values for the font are returned. * langname is right 0 padded and assumes lowercase. Thus the en langauge * would be 0x656E0000. Langname may also be space padded, thus 0x656E2020. */ GR2_API gr_feature_val* gr_face_featureval_for_lang(const gr_face* pFace, gr_uint32 langname); /** Get feature reference for a given feature id from a face * * @return a feature reference corresponding to the given id. This data is part of the gr_face and * will be freed when the face is destroyed. * @param pFace Font face to get information on. * @param featId Feature id tag to get reference to. */ GR2_API const gr_feature_ref* gr_face_find_fref(const gr_face* pFace, gr_uint32 featId); /** Returns number of feature references in a face **/ GR2_API gr_uint16 gr_face_n_fref(const gr_face* pFace); /** Returns feature reference at given index in face **/ GR2_API const gr_feature_ref* gr_face_fref(const gr_face* pFace, gr_uint16 i); /** Return number of languages the face knows about **/ GR2_API unsigned short gr_face_n_languages(const gr_face* pFace); /** Returns a language id corresponding to a language of given index in the face **/ GR2_API gr_uint32 gr_face_lang_by_index(const gr_face* pFace, gr_uint16 i); /** Destroy the given face and free its memory **/ GR2_API void gr_face_destroy(gr_face *face); /** Returns the number of glyphs in the face **/ GR2_API unsigned short gr_face_n_glyphs(const gr_face* pFace); /** Returns a faceinfo for the face and script **/ GR2_API const gr_faceinfo *gr_face_info(const gr_face *pFace, gr_uint32 script); /** Returns whether the font supports a given Unicode character * * @return true if the character is supported. * @param pFace face to test within * @param usv Unicode Scalar Value of character to test * @param script Tag of script for selecting which set of pseudo glyphs to test. May be NULL. */ GR2_API int gr_face_is_char_supported(const gr_face *pFace, gr_uint32 usv, gr_uint32 script); #ifndef GRAPHITE2_NFILEFACE /** Create gr_face from a font file * * @return gr_face that accesses a font file directly. Returns NULL on failure. * @param filename Full path and filename to font file * @param faceOptions Bitfile from enum gr_face_options to control face options. */ GR2_API gr_face* gr_make_file_face(const char *filename, unsigned int faceOptions); /** @deprecated Since 1.3.7. This function is now an alias for gr_make_file_face(). * * Create gr_face from a font file, with subsegment caching support. * * @return gr_face that accesses a font file directly. Returns NULL on failure. * @param filename Full path and filename to font file * @param segCacheMaxSize Specifies how big to make the cache in segments. * @param faceOptions Bitfield from enum gr_face_options to control face options. */ GR2_DEPRECATED_API gr_face* gr_make_file_face_with_seg_cache(const char *filename, unsigned int segCacheMaxSize, unsigned int faceOptions); #endif // !GRAPHITE2_NFILEFACE /** Create a font from a face * * @return gr_font Call font_destroy to free this font * @param ppm Resolution of the font in pixels per em * @param face Face this font corresponds to. This must stay alive as long as the font is alive. */ GR2_API gr_font* gr_make_font(float ppm, const gr_face *face); /** query function to find the hinted advance of a glyph * * @param appFontHandle is the unique information passed to gr_make_font_with_advance() * @param glyphid is the glyph to retireve the hinted advance for. */ typedef float (*gr_advance_fn)(const void* appFontHandle, gr_uint16 glyphid); /** struct housing function pointers to manage font hinted metrics for the * graphite engine. */ struct gr_font_ops { /** size of the structure in bytes to allow for future extensibility */ size_t size; /** a pointer to a function to retrieve the hinted * advance width of a glyph which the font cannot * provide without client assistance. This can be * NULL to signify no horizontal hinted metrics are necessary. */ gr_advance_fn glyph_advance_x; /** a pointer to a function to retrieve the hinted * advance height of a glyph which the font cannot * provide without client assistance. This can be * NULL to signify no horizontal hinted metrics are necessary. */ gr_advance_fn glyph_advance_y; }; typedef struct gr_font_ops gr_font_ops; /** Creates a font with hinted advance width query functions * * @return gr_font to be destroyed via font_destroy * @param ppm size of font in pixels per em * @param appFontHandle font specific information that must stay alive as long * as the font does * @param font_ops pointer font specific callback structure for hinted metrics. * Need only stay alive for the duration of the call. * @param face the face this font corresponds to. Must stay alive as long as * the font does. */ GR2_API gr_font* gr_make_font_with_ops(float ppm, const void* appFontHandle, const gr_font_ops * font_ops, const gr_face *face); /** Creates a font with hinted advance width query function. * This function is deprecated. Use gr_make_font_with_ops instead. * * @return gr_font to be destroyed via font_destroy * @param ppm size of font in pixels per em * @param appFontHandle font specific information that must stay alive as long * as the font does * @param getAdvance callback function reference that returns horizontal advance in pixels for a glyph. * @param face the face this font corresponds to. Must stay alive as long as * the font does. */ GR2_API gr_font* gr_make_font_with_advance_fn(float ppm, const void* appFontHandle, gr_advance_fn getAdvance, const gr_face *face); /** Free a font **/ GR2_API void gr_font_destroy(gr_font *font); /** get a feature value * * @return value of specific feature or 0 if any problems. * @param pfeatureref gr_feature_ref to the feature * @param feats gr_feature_val containing all the values */ GR2_API gr_uint16 gr_fref_feature_value(const gr_feature_ref* pfeatureref, const gr_feature_val* feats); /** set a feature value * * @return false if there were any problems (value out of range, etc.) * @param pfeatureref gr_feature_ref to the feature * @param val value to set the feature to * @param pDest the gr_feature_val containing all the values for all the features */ GR2_API int gr_fref_set_feature_value(const gr_feature_ref* pfeatureref, gr_uint16 val, gr_feature_val* pDest); /** Returns the id tag for a gr_feature_ref **/ GR2_API gr_uint32 gr_fref_id(const gr_feature_ref* pfeatureref); /** Returns number of values a feature may take, given a gr_feature_ref **/ GR2_API gr_uint16 gr_fref_n_values(const gr_feature_ref* pfeatureref); /** Returns the value associated with a particular value in a feature * * @return value * @param pfeatureref gr_feature_ref of the feature of interest * @param settingno Index up to the return value of gr_fref_n_values() of the value */ GR2_API gr_int16 gr_fref_value(const gr_feature_ref* pfeatureref, gr_uint16 settingno); /** Returns a string of the UI name of a feature * * @return string of the UI name, in the encoding form requested. Call gr_label_destroy() after use. * @param pfeatureref gr_feature_ref of the feature * @param langId This is a pointer since the face may not support a string in the requested * language. The actual language of the string is returned in langId * @param utf Encoding form for the string * @param length Used to return the length of the string returned in bytes. */ GR2_API void* gr_fref_label(const gr_feature_ref* pfeatureref, gr_uint16 *langId, enum gr_encform utf, gr_uint32 *length); /** Return a UI string for a possible value of a feature * * @return string of the UI name, in the encoding form requested. nul terminated. Call gr_label_destroy() * after use. * @param pfeatureref gr_feature_ref of the feature * @param settingno Value setting index * @param langId This is a pointer to the requested language. The requested language id is * replaced by the actual language id of the string returned. * @param utf Encoding form for the string * @param length Returns the length of the string returned in bytes. */ GR2_API void* gr_fref_value_label(const gr_feature_ref* pfeatureref, gr_uint16 settingno/*rather than a value*/, gr_uint16 *langId, enum gr_encform utf, gr_uint32 *length); /** Destroy a previously returned label string **/ GR2_API void gr_label_destroy(void * label); /** Copies a gr_feature_val **/ GR2_API gr_feature_val* gr_featureval_clone(const gr_feature_val* pfeatures); /** Destroys a gr_feature_val **/ GR2_API void gr_featureval_destroy(gr_feature_val *pfeatures); #ifdef __cplusplus } #endif /* Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _NETINET_ICMP6_H #define _NETINET_ICMP6_H 1 #include <inttypes.h> #include <string.h> #include <sys/types.h> #include <netinet/in.h> #define ICMP6_FILTER 1 #define ICMP6_FILTER_BLOCK 1 #define ICMP6_FILTER_PASS 2 #define ICMP6_FILTER_BLOCKOTHERS 3 #define ICMP6_FILTER_PASSONLY 4 struct icmp6_filter { uint32_t icmp6_filt[8]; }; struct icmp6_hdr { uint8_t icmp6_type; /* type field */ uint8_t icmp6_code; /* code field */ uint16_t icmp6_cksum; /* checksum field */ union { uint32_t icmp6_un_data32[1]; /* type-specific field */ uint16_t icmp6_un_data16[2]; /* type-specific field */ uint8_t icmp6_un_data8[4]; /* type-specific field */ } icmp6_dataun; }; #define icmp6_data32 icmp6_dataun.icmp6_un_data32 #define icmp6_data16 icmp6_dataun.icmp6_un_data16 #define icmp6_data8 icmp6_dataun.icmp6_un_data8 #define icmp6_pptr icmp6_data32[0] /* parameter prob */ #define icmp6_mtu icmp6_data32[0] /* packet too big */ #define icmp6_id icmp6_data16[0] /* echo request/reply */ #define icmp6_seq icmp6_data16[1] /* echo request/reply */ #define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */ #define ICMP6_DST_UNREACH 1 #define ICMP6_PACKET_TOO_BIG 2 #define ICMP6_TIME_EXCEEDED 3 #define ICMP6_PARAM_PROB 4 #define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */ #define ICMP6_ECHO_REQUEST 128 #define ICMP6_ECHO_REPLY 129 #define MLD_LISTENER_QUERY 130 #define MLD_LISTENER_REPORT 131 #define MLD_LISTENER_REDUCTION 132 #define ICMPV6_EXT_ECHO_REQUEST 160 #define ICMPV6_EXT_ECHO_REPLY 161 #define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */ #define ICMP6_DST_UNREACH_ADMIN 1 /* communication with destination */ /* administratively prohibited */ #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */ #define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */ #define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */ #define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */ #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */ #define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */ #define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized Next Header */ #define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */ #define ICMP6_FILTER_WILLPASS(type, filterp) \ ((((filterp)->icmp6_filt[(type) >> 5]) & (1U << ((type) & 31))) == 0) #define ICMP6_FILTER_WILLBLOCK(type, filterp) \ ((((filterp)->icmp6_filt[(type) >> 5]) & (1U << ((type) & 31))) != 0) #define ICMP6_FILTER_SETPASS(type, filterp) \ ((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1U << ((type) & 31)))) #define ICMP6_FILTER_SETBLOCK(type, filterp) \ ((((filterp)->icmp6_filt[(type) >> 5]) |= (1U << ((type) & 31)))) #define ICMP6_FILTER_SETPASSALL(filterp) \ memset (filterp, 0, sizeof (struct icmp6_filter)); #define ICMP6_FILTER_SETBLOCKALL(filterp) \ memset (filterp, 0xFF, sizeof (struct icmp6_filter)); #define ND_ROUTER_SOLICIT 133 #define ND_ROUTER_ADVERT 134 #define ND_NEIGHBOR_SOLICIT 135 #define ND_NEIGHBOR_ADVERT 136 #define ND_REDIRECT 137 struct nd_router_solicit /* router solicitation */ { struct icmp6_hdr nd_rs_hdr; /* could be followed by options */ }; #define nd_rs_type nd_rs_hdr.icmp6_type #define nd_rs_code nd_rs_hdr.icmp6_code #define nd_rs_cksum nd_rs_hdr.icmp6_cksum #define nd_rs_reserved nd_rs_hdr.icmp6_data32[0] struct nd_router_advert /* router advertisement */ { struct icmp6_hdr nd_ra_hdr; uint32_t nd_ra_reachable; /* reachable time */ uint32_t nd_ra_retransmit; /* retransmit timer */ /* could be followed by options */ }; #define nd_ra_type nd_ra_hdr.icmp6_type #define nd_ra_code nd_ra_hdr.icmp6_code #define nd_ra_cksum nd_ra_hdr.icmp6_cksum #define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0] #define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1] #define ND_RA_FLAG_MANAGED 0x80 #define ND_RA_FLAG_OTHER 0x40 #define ND_RA_FLAG_HOME_AGENT 0x20 #define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1] struct nd_neighbor_solicit /* neighbor solicitation */ { struct icmp6_hdr nd_ns_hdr; struct in6_addr nd_ns_target; /* target address */ /* could be followed by options */ }; #define nd_ns_type nd_ns_hdr.icmp6_type #define nd_ns_code nd_ns_hdr.icmp6_code #define nd_ns_cksum nd_ns_hdr.icmp6_cksum #define nd_ns_reserved nd_ns_hdr.icmp6_data32[0] struct nd_neighbor_advert /* neighbor advertisement */ { struct icmp6_hdr nd_na_hdr; struct in6_addr nd_na_target; /* target address */ /* could be followed by options */ }; #define nd_na_type nd_na_hdr.icmp6_type #define nd_na_code nd_na_hdr.icmp6_code #define nd_na_cksum nd_na_hdr.icmp6_cksum #define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0] #if __BYTE_ORDER == __BIG_ENDIAN #define ND_NA_FLAG_ROUTER 0x80000000 #define ND_NA_FLAG_SOLICITED 0x40000000 #define ND_NA_FLAG_OVERRIDE 0x20000000 #else /* __BYTE_ORDER == __LITTLE_ENDIAN */ #define ND_NA_FLAG_ROUTER 0x00000080 #define ND_NA_FLAG_SOLICITED 0x00000040 #define ND_NA_FLAG_OVERRIDE 0x00000020 #endif struct nd_redirect /* redirect */ { struct icmp6_hdr nd_rd_hdr; struct in6_addr nd_rd_target; /* target address */ struct in6_addr nd_rd_dst; /* destination address */ /* could be followed by options */ }; #define nd_rd_type nd_rd_hdr.icmp6_type #define nd_rd_code nd_rd_hdr.icmp6_code #define nd_rd_cksum nd_rd_hdr.icmp6_cksum #define nd_rd_reserved nd_rd_hdr.icmp6_data32[0] struct nd_opt_hdr /* Neighbor discovery option header */ { uint8_t nd_opt_type; uint8_t nd_opt_len; /* in units of 8 octets */ /* followed by option specific data */ }; #define ND_OPT_SOURCE_LINKADDR 1 #define ND_OPT_TARGET_LINKADDR 2 #define ND_OPT_PREFIX_INFORMATION 3 #define ND_OPT_REDIRECTED_HEADER 4 #define ND_OPT_MTU 5 #define ND_OPT_RTR_ADV_INTERVAL 7 #define ND_OPT_HOME_AGENT_INFO 8 struct nd_opt_prefix_info /* prefix information */ { uint8_t nd_opt_pi_type; uint8_t nd_opt_pi_len; uint8_t nd_opt_pi_prefix_len; uint8_t nd_opt_pi_flags_reserved; uint32_t nd_opt_pi_valid_time; uint32_t nd_opt_pi_preferred_time; uint32_t nd_opt_pi_reserved2; struct in6_addr nd_opt_pi_prefix; }; #define ND_OPT_PI_FLAG_ONLINK 0x80 #define ND_OPT_PI_FLAG_AUTO 0x40 #define ND_OPT_PI_FLAG_RADDR 0x20 struct nd_opt_rd_hdr /* redirected header */ { uint8_t nd_opt_rh_type; uint8_t nd_opt_rh_len; uint16_t nd_opt_rh_reserved1; uint32_t nd_opt_rh_reserved2; /* followed by IP header and data */ }; struct nd_opt_mtu /* MTU option */ { uint8_t nd_opt_mtu_type; uint8_t nd_opt_mtu_len; uint16_t nd_opt_mtu_reserved; uint32_t nd_opt_mtu_mtu; }; struct mld_hdr { struct icmp6_hdr mld_icmp6_hdr; struct in6_addr mld_addr; /* multicast address */ }; #define mld_type mld_icmp6_hdr.icmp6_type #define mld_code mld_icmp6_hdr.icmp6_code #define mld_cksum mld_icmp6_hdr.icmp6_cksum #define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0] #define mld_reserved mld_icmp6_hdr.icmp6_data16[1] #define ICMP6_ROUTER_RENUMBERING 138 struct icmp6_router_renum /* router renumbering header */ { struct icmp6_hdr rr_hdr; uint8_t rr_segnum; uint8_t rr_flags; uint16_t rr_maxdelay; uint32_t rr_reserved; }; #define rr_type rr_hdr.icmp6_type #define rr_code rr_hdr.icmp6_code #define rr_cksum rr_hdr.icmp6_cksum #define rr_seqnum rr_hdr.icmp6_data32[0] /* Router renumbering flags */ #define ICMP6_RR_FLAGS_TEST 0x80 #define ICMP6_RR_FLAGS_REQRESULT 0x40 #define ICMP6_RR_FLAGS_FORCEAPPLY 0x20 #define ICMP6_RR_FLAGS_SPECSITE 0x10 #define ICMP6_RR_FLAGS_PREVDONE 0x08 struct rr_pco_match /* match prefix part */ { uint8_t rpm_code; uint8_t rpm_len; uint8_t rpm_ordinal; uint8_t rpm_matchlen; uint8_t rpm_minlen; uint8_t rpm_maxlen; uint16_t rpm_reserved; struct in6_addr rpm_prefix; }; /* PCO code values */ #define RPM_PCO_ADD 1 #define RPM_PCO_CHANGE 2 #define RPM_PCO_SETGLOBAL 3 struct rr_pco_use /* use prefix part */ { uint8_t rpu_uselen; uint8_t rpu_keeplen; uint8_t rpu_ramask; uint8_t rpu_raflags; uint32_t rpu_vltime; uint32_t rpu_pltime; uint32_t rpu_flags; struct in6_addr rpu_prefix; }; #define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20 #define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10 #if __BYTE_ORDER == __BIG_ENDIAN # define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000 # define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000 #elif __BYTE_ORDER == __LITTLE_ENDIAN # define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80 # define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40 #endif struct rr_result /* router renumbering result message */ { uint16_t rrr_flags; uint8_t rrr_ordinal; uint8_t rrr_matchedlen; uint32_t rrr_ifid; struct in6_addr rrr_prefix; }; #if __BYTE_ORDER == __BIG_ENDIAN # define ICMP6_RR_RESULT_FLAGS_OOB 0x0002 # define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001 #elif __BYTE_ORDER == __LITTLE_ENDIAN # define ICMP6_RR_RESULT_FLAGS_OOB 0x0200 # define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100 #endif /* Mobile IPv6 extension: Advertisement Interval. */ struct nd_opt_adv_interval { uint8_t nd_opt_adv_interval_type; uint8_t nd_opt_adv_interval_len; uint16_t nd_opt_adv_interval_reserved; uint32_t nd_opt_adv_interval_ival; }; /* Mobile IPv6 extension: Home Agent Info. */ struct nd_opt_home_agent_info { uint8_t nd_opt_home_agent_info_type; uint8_t nd_opt_home_agent_info_len; uint16_t nd_opt_home_agent_info_reserved; uint16_t nd_opt_home_agent_info_preference; uint16_t nd_opt_home_agent_info_lifetime; }; #endif /* netinet/icmpv6.h */ /* Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _NETINET_IP6_H #define _NETINET_IP6_H 1 #include <inttypes.h> #include <netinet/in.h> struct ip6_hdr { union { struct ip6_hdrctl { uint32_t ip6_un1_flow; /* 4 bits version, 8 bits TC, 20 bits flow-ID */ uint16_t ip6_un1_plen; /* payload length */ uint8_t ip6_un1_nxt; /* next header */ uint8_t ip6_un1_hlim; /* hop limit */ } ip6_un1; uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits tclass */ } ip6_ctlun; struct in6_addr ip6_src; /* source address */ struct in6_addr ip6_dst; /* destination address */ }; #define ip6_vfc ip6_ctlun.ip6_un2_vfc #define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow #define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen #define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt #define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim #define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim /* Generic extension header. */ struct ip6_ext { uint8_t ip6e_nxt; /* next header. */ uint8_t ip6e_len; /* length in units of 8 octets. */ }; /* Hop-by-Hop options header. */ struct ip6_hbh { uint8_t ip6h_nxt; /* next header. */ uint8_t ip6h_len; /* length in units of 8 octets. */ /* followed by options */ }; /* Destination options header */ struct ip6_dest { uint8_t ip6d_nxt; /* next header */ uint8_t ip6d_len; /* length in units of 8 octets */ /* followed by options */ }; /* Routing header */ struct ip6_rthdr { uint8_t ip6r_nxt; /* next header */ uint8_t ip6r_len; /* length in units of 8 octets */ uint8_t ip6r_type; /* routing type */ uint8_t ip6r_segleft; /* segments left */ /* followed by routing type specific data */ }; /* Type 0 Routing header */ struct ip6_rthdr0 { uint8_t ip6r0_nxt; /* next header */ uint8_t ip6r0_len; /* length in units of 8 octets */ uint8_t ip6r0_type; /* always zero */ uint8_t ip6r0_segleft; /* segments left */ uint8_t ip6r0_reserved; /* reserved field */ uint8_t ip6r0_slmap[3]; /* strict/loose bit map */ /* followed by up to 127 struct in6_addr */ struct in6_addr ip6r0_addr[0]; }; /* Fragment header */ struct ip6_frag { uint8_t ip6f_nxt; /* next header */ uint8_t ip6f_reserved; /* reserved field */ uint16_t ip6f_offlg; /* offset, reserved, and flag */ uint32_t ip6f_ident; /* identification */ }; #if __BYTE_ORDER == __BIG_ENDIAN # define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */ # define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */ # define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */ #else /* __BYTE_ORDER == __LITTLE_ENDIAN */ # define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */ # define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */ # define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */ #endif /* IPv6 options */ struct ip6_opt { uint8_t ip6o_type; uint8_t ip6o_len; }; /* The high-order 3 bits of the option type define the behavior * when processing an unknown option and whether or not the option * content changes in flight. */ #define IP6OPT_TYPE(o) ((o) & 0xc0) #define IP6OPT_TYPE_SKIP 0x00 #define IP6OPT_TYPE_DISCARD 0x40 #define IP6OPT_TYPE_FORCEICMP 0x80 #define IP6OPT_TYPE_ICMP 0xc0 #define IP6OPT_TYPE_MUTABLE 0x20 /* Special option types for padding. */ #define IP6OPT_PAD1 0 #define IP6OPT_PADN 1 #define IP6OPT_JUMBO 0xc2 #define IP6OPT_NSAP_ADDR 0xc3 #define IP6OPT_TUNNEL_LIMIT 0x04 #define IP6OPT_ROUTER_ALERT 0x05 /* Jumbo Payload Option */ struct ip6_opt_jumbo { uint8_t ip6oj_type; uint8_t ip6oj_len; uint8_t ip6oj_jumbo_len[4]; }; #define IP6OPT_JUMBO_LEN 6 /* NSAP Address Option */ struct ip6_opt_nsap { uint8_t ip6on_type; uint8_t ip6on_len; uint8_t ip6on_src_nsap_len; uint8_t ip6on_dst_nsap_len; /* followed by source NSAP */ /* followed by destination NSAP */ }; /* Tunnel Limit Option */ struct ip6_opt_tunnel { uint8_t ip6ot_type; uint8_t ip6ot_len; uint8_t ip6ot_encap_limit; }; /* Router Alert Option */ struct ip6_opt_router { uint8_t ip6or_type; uint8_t ip6or_len; uint8_t ip6or_value[2]; }; /* Router alert values (in network byte order) */ #if __BYTE_ORDER == __BIG_ENDIAN # define IP6_ALERT_MLD 0x0000 # define IP6_ALERT_RSVP 0x0001 # define IP6_ALERT_AN 0x0002 #else /* __BYTE_ORDER == __LITTLE_ENDIAN */ # define IP6_ALERT_MLD 0x0000 # define IP6_ALERT_RSVP 0x0100 # define IP6_ALERT_AN 0x0200 #endif #endif /* netinet/ip6.h */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _NETINET_IF_TR_H #define _NETINET_IF_TR_H 1 #include <sys/types.h> #include <stdint.h> /* IEEE 802.5 Token-Ring magic constants. The frame sizes omit the preamble and FCS/CRC (frame check sequence). */ #define TR_ALEN 6 /* Octets in one token-ring addr */ #define TR_HLEN (sizeof (struct trh_hdr) + sizeof (struct trllc)) #define AC 0x10 #define LLC_FRAME 0x40 /* LLC and SNAP constants */ #define EXTENDED_SAP 0xAA #define UI_CMD 0x03 /* This is an Token-Ring frame header. */ struct trh_hdr { uint8_t ac; /* access control field */ uint8_t fc; /* frame control field */ uint8_t daddr[TR_ALEN]; /* destination address */ uint8_t saddr[TR_ALEN]; /* source address */ uint16_t rcf; /* route control field */ uint16_t rseg[8]; /* routing registers */ }; /* This is an Token-Ring LLC structure */ struct trllc { uint8_t dsap; /* destination SAP */ uint8_t ssap; /* source SAP */ uint8_t llc; /* LLC control field */ uint8_t protid[3]; /* protocol id */ uint16_t ethertype; /* ether type field */ }; /* Token-Ring statistics collection data. */ struct tr_statistics { unsigned long rx_packets; /* total packets received */ unsigned long tx_packets; /* total packets transmitted */ unsigned long rx_bytes; /* total bytes received */ unsigned long tx_bytes; /* total bytes transmitted */ unsigned long rx_errors; /* bad packets received */ unsigned long tx_errors; /* packet transmit problems */ unsigned long rx_dropped; /* no space in linux buffers */ unsigned long tx_dropped; /* no space available in linux */ unsigned long multicast; /* multicast packets received */ unsigned long transmit_collision; /* detailed Token-Ring errors. See IBM Token-Ring Network Architecture for more info */ unsigned long line_errors; unsigned long internal_errors; unsigned long burst_errors; unsigned long A_C_errors; unsigned long abort_delimiters; unsigned long lost_frames; unsigned long recv_congest_count; unsigned long frame_copied_errors; unsigned long frequency_errors; unsigned long token_errors; unsigned long dummy1; }; /* source routing stuff */ #define TR_RII 0x80 #define TR_RCF_DIR_BIT 0x80 #define TR_RCF_LEN_MASK 0x1f00 #define TR_RCF_BROADCAST 0x8000 /* all-routes broadcast */ #define TR_RCF_LIMITED_BROADCAST 0xC000 /* single-route broadcast */ #define TR_RCF_FRAME2K 0x20 #define TR_RCF_BROADCAST_MASK 0xC000 #define TR_MAXRIFLEN 18 #ifdef __USE_MISC struct trn_hdr { uint8_t trn_ac; /* access control field */ uint8_t trn_fc; /* field control field */ uint8_t trn_dhost[TR_ALEN]; /* destination host */ uint8_t trn_shost[TR_ALEN]; /* source host */ uint16_t trn_rcf; /* route control field */ uint16_t trn_rseg[8]; /* routing registers */ }; #endif #endif /* netinet/if_tr.h */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _NETINET_IF_FDDI_H #define _NETINET_IF_FDDI_H 1 #include <sys/types.h> #include <stdint.h> #include <linux/if_fddi.h> #ifdef __USE_MISC struct fddi_header { uint8_t fddi_fc; /* Frame Control (FC) value */ uint8_t fddi_dhost[FDDI_K_ALEN]; /* Destination host */ uint8_t fddi_shost[FDDI_K_ALEN]; /* Source host */ }; #endif #endif /* netinet/if_fddi.h */ /* Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef __NETINET_IP_ICMP_H #define __NETINET_IP_ICMP_H 1 #include <sys/types.h> #include <stdint.h> __BEGIN_DECLS struct icmphdr { uint8_t type; /* message type */ uint8_t code; /* type sub-code */ uint16_t checksum; union { struct { uint16_t id; uint16_t sequence; } echo; /* echo datagram */ uint32_t gateway; /* gateway address */ struct { uint16_t __glibc_reserved; uint16_t mtu; } frag; /* path mtu discovery */ } un; }; #define ICMP_ECHOREPLY 0 /* Echo Reply */ #define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ #define ICMP_SOURCE_QUENCH 4 /* Source Quench */ #define ICMP_REDIRECT 5 /* Redirect (change route) */ #define ICMP_ECHO 8 /* Echo Request */ #define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */ #define ICMP_PARAMETERPROB 12 /* Parameter Problem */ #define ICMP_TIMESTAMP 13 /* Timestamp Request */ #define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */ #define ICMP_INFO_REQUEST 15 /* Information Request */ #define ICMP_INFO_REPLY 16 /* Information Reply */ #define ICMP_ADDRESS 17 /* Address Mask Request */ #define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ #define NR_ICMP_TYPES 18 /* Codes for UNREACH. */ #define ICMP_NET_UNREACH 0 /* Network Unreachable */ #define ICMP_HOST_UNREACH 1 /* Host Unreachable */ #define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */ #define ICMP_PORT_UNREACH 3 /* Port Unreachable */ #define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */ #define ICMP_SR_FAILED 5 /* Source Route failed */ #define ICMP_NET_UNKNOWN 6 #define ICMP_HOST_UNKNOWN 7 #define ICMP_HOST_ISOLATED 8 #define ICMP_NET_ANO 9 #define ICMP_HOST_ANO 10 #define ICMP_NET_UNR_TOS 11 #define ICMP_HOST_UNR_TOS 12 #define ICMP_PKT_FILTERED 13 /* Packet filtered */ #define ICMP_PREC_VIOLATION 14 /* Precedence violation */ #define ICMP_PREC_CUTOFF 15 /* Precedence cut off */ #define NR_ICMP_UNREACH 15 /* instead of hardcoding immediate value */ /* Codes for REDIRECT. */ #define ICMP_REDIR_NET 0 /* Redirect Net */ #define ICMP_REDIR_HOST 1 /* Redirect Host */ #define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */ #define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */ /* Codes for TIME_EXCEEDED. */ #define ICMP_EXC_TTL 0 /* TTL count exceeded */ #define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */ /* Codes for ICMP_EXT_ECHO (PROBE) */ #define ICMP_EXT_ECHO 42 #define ICMP_EXT_ECHOREPLY 43 #define ICMP_EXT_CODE_MAL_QUERY 1 /* Malformed Query */ #define ICMP_EXT_CODE_NO_IF 2 /* No such Interface */ #define ICMP_EXT_CODE_NO_TABLE_ENT 3 /* No table entry */ #define ICMP_EXT_CODE_MULT_IFS 4 /* Multiple Interfaces Satisfy Query */ /* Constants for EXT_ECHO (PROBE) */ #define ICMP_EXT_ECHOREPLY_ACTIVE (1 << 2)/* active bit in reply */ #define ICMP_EXT_ECHOREPLY_IPV4 (1 << 1)/* ipv4 bit in reply */ #define ICMP_EXT_ECHOREPLY_IPV6 1 /* ipv6 bit in reply */ #define ICMP_EXT_ECHO_CTYPE_NAME 1 #define ICMP_EXT_ECHO_CTYPE_INDEX 2 #define ICMP_EXT_ECHO_CTYPE_ADDR 3 #define ICMP_AFI_IP 1 /* Address Family Identifier for IPV4 */ #define ICMP_AFI_IP6 2 /* Address Family Identifier for IPV6 */ #ifdef __USE_MISC /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93 */ #include <netinet/in.h> #include <netinet/ip.h> /* * Internal of an ICMP Router Advertisement */ struct icmp_ra_addr { uint32_t ira_addr; uint32_t ira_preference; }; struct icmp { uint8_t icmp_type; /* type of message, see below */ uint8_t icmp_code; /* type sub code */ uint16_t icmp_cksum; /* ones complement checksum of struct */ union { unsigned char ih_pptr; /* ICMP_PARAMPROB */ struct in_addr ih_gwaddr; /* gateway address */ struct ih_idseq /* echo datagram */ { uint16_t icd_id; uint16_t icd_seq; } ih_idseq; uint32_t ih_void; /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */ struct ih_pmtu { uint16_t ipm_void; uint16_t ipm_nextmtu; } ih_pmtu; struct ih_rtradv { uint8_t irt_num_addrs; uint8_t irt_wpa; uint16_t irt_lifetime; } ih_rtradv; } icmp_hun; #define icmp_pptr icmp_hun.ih_pptr #define icmp_gwaddr icmp_hun.ih_gwaddr #define icmp_id icmp_hun.ih_idseq.icd_id #define icmp_seq icmp_hun.ih_idseq.icd_seq #define icmp_void icmp_hun.ih_void #define icmp_pmvoid icmp_hun.ih_pmtu.ipm_void #define icmp_nextmtu icmp_hun.ih_pmtu.ipm_nextmtu #define icmp_num_addrs icmp_hun.ih_rtradv.irt_num_addrs #define icmp_wpa icmp_hun.ih_rtradv.irt_wpa #define icmp_lifetime icmp_hun.ih_rtradv.irt_lifetime union { struct { uint32_t its_otime; uint32_t its_rtime; uint32_t its_ttime; } id_ts; struct { struct ip idi_ip; /* options and then 64 bits of data */ } id_ip; struct icmp_ra_addr id_radv; uint32_t id_mask; uint8_t id_data[1]; } icmp_dun; #define icmp_otime icmp_dun.id_ts.its_otime #define icmp_rtime icmp_dun.id_ts.its_rtime #define icmp_ttime icmp_dun.id_ts.its_ttime #define icmp_ip icmp_dun.id_ip.idi_ip #define icmp_radv icmp_dun.id_radv #define icmp_mask icmp_dun.id_mask #define icmp_data icmp_dun.id_data }; /* * Lower bounds on packet lengths for various types. * For the error advice packets must first insure that the * packet is large enough to contain the returned ip header. * Only then can we do the check to see if 64 bits of packet * data have been returned, since we need to check the returned * ip header length. */ #define ICMP_MINLEN 8 /* abs minimum */ #define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */ #define ICMP_MASKLEN 12 /* address mask */ #define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */ #ifndef _IP_VHL #define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8) /* N.B.: must separately check that ip_hl >= 5 */ #else #define ICMP_ADVLEN(p) (8 + (IP_VHL_HL((p)->icmp_ip.ip_vhl) << 2) + 8) /* N.B.: must separately check that header length >= 5 */ #endif /* Definition of type and code fields. */ /* defined above: ICMP_ECHOREPLY, ICMP_REDIRECT, ICMP_ECHO */ #define ICMP_UNREACH 3 /* dest unreachable, codes: */ #define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */ #define ICMP_ROUTERADVERT 9 /* router advertisement */ #define ICMP_ROUTERSOLICIT 10 /* router solicitation */ #define ICMP_TIMXCEED 11 /* time exceeded, code: */ #define ICMP_PARAMPROB 12 /* ip header bad */ #define ICMP_TSTAMP 13 /* timestamp request */ #define ICMP_TSTAMPREPLY 14 /* timestamp reply */ #define ICMP_IREQ 15 /* information request */ #define ICMP_IREQREPLY 16 /* information reply */ #define ICMP_MASKREQ 17 /* address mask request */ #define ICMP_MASKREPLY 18 /* address mask reply */ #define ICMP_MAXTYPE 18 /* UNREACH codes */ #define ICMP_UNREACH_NET 0 /* bad net */ #define ICMP_UNREACH_HOST 1 /* bad host */ #define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */ #define ICMP_UNREACH_PORT 3 /* bad port */ #define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */ #define ICMP_UNREACH_SRCFAIL 5 /* src route failed */ #define ICMP_UNREACH_NET_UNKNOWN 6 /* unknown net */ #define ICMP_UNREACH_HOST_UNKNOWN 7 /* unknown host */ #define ICMP_UNREACH_ISOLATED 8 /* src host isolated */ #define ICMP_UNREACH_NET_PROHIB 9 /* net denied */ #define ICMP_UNREACH_HOST_PROHIB 10 /* host denied */ #define ICMP_UNREACH_TOSNET 11 /* bad tos for net */ #define ICMP_UNREACH_TOSHOST 12 /* bad tos for host */ #define ICMP_UNREACH_FILTER_PROHIB 13 /* admin prohib */ #define ICMP_UNREACH_HOST_PRECEDENCE 14 /* host prec vio. */ #define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 /* prec cutoff */ /* REDIRECT codes */ #define ICMP_REDIRECT_NET 0 /* for network */ #define ICMP_REDIRECT_HOST 1 /* for host */ #define ICMP_REDIRECT_TOSNET 2 /* for tos and net */ #define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */ /* TIMEXCEED codes */ #define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */ #define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */ /* PARAMPROB code */ #define ICMP_PARAMPROB_OPTABSENT 1 /* req. opt. absent */ #define ICMP_INFOTYPE(type) \ ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO \ || (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT \ || (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY \ || (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY \ || (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY) #endif /* __USE_MISC */ __END_DECLS #endif /* netinet/ip_icmp.h */ /* Copyright (C) 1996-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef __NETINET_IF_ETHER_H #define __NETINET_IF_ETHER_H 1 #include <features.h> #include <sys/types.h> /* Get definitions from kernel header file. */ #include <linux/if_ether.h> #ifdef __USE_MISC /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)if_ether.h 8.3 (Berkeley) 5/2/95 * $FreeBSD$ */ #include <net/ethernet.h> #include <net/if_arp.h> __BEGIN_DECLS /* * Ethernet Address Resolution Protocol. * * See RFC 826 for protocol description. Structure below is adapted * to resolving internet addresses. Field names used correspond to * RFC 826. */ struct ether_arp { struct arphdr ea_hdr; /* fixed-size header */ uint8_t arp_sha[ETH_ALEN]; /* sender hardware address */ uint8_t arp_spa[4]; /* sender protocol address */ uint8_t arp_tha[ETH_ALEN]; /* target hardware address */ uint8_t arp_tpa[4]; /* target protocol address */ }; #define arp_hrd ea_hdr.ar_hrd #define arp_pro ea_hdr.ar_pro #define arp_hln ea_hdr.ar_hln #define arp_pln ea_hdr.ar_pln #define arp_op ea_hdr.ar_op /* * Macro to map an IP multicast address to an Ethernet multicast address. * The high-order 25 bits of the Ethernet address are statically assigned, * and the low-order 23 bits are taken from the low end of the IP address. */ #define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \ /* struct in_addr *ipaddr; */ \ /* uint8_t enaddr[ETH_ALEN]; */ \ { \ (enaddr)[0] = 0x01; \ (enaddr)[1] = 0x00; \ (enaddr)[2] = 0x5e; \ (enaddr)[3] = ((uint8_t *)ipaddr)[1] & 0x7f; \ (enaddr)[4] = ((uint8_t *)ipaddr)[2]; \ (enaddr)[5] = ((uint8_t *)ipaddr)[3]; \ } __END_DECLS #endif /* __USE_MISC */ #endif /* netinet/if_ether.h */ /* Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef __NETINET_IP_H #define __NETINET_IP_H 1 #include <features.h> #include <sys/types.h> #include <netinet/in.h> __BEGIN_DECLS struct timestamp { uint8_t len; uint8_t ptr; #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int flags:4; unsigned int overflow:4; #elif __BYTE_ORDER == __BIG_ENDIAN unsigned int overflow:4; unsigned int flags:4; #else # error "Please fix <bits/endian.h>" #endif uint32_t data[9]; }; struct iphdr { #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int ihl:4; unsigned int version:4; #elif __BYTE_ORDER == __BIG_ENDIAN unsigned int version:4; unsigned int ihl:4; #else # error "Please fix <bits/endian.h>" #endif uint8_t tos; uint16_t tot_len; uint16_t id; uint16_t frag_off; uint8_t ttl; uint8_t protocol; uint16_t check; uint32_t saddr; uint32_t daddr; /*The options start here. */ }; #ifdef __USE_MISC /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)ip.h 8.1 (Berkeley) 6/10/93 */ /* * Definitions for internet protocol version 4. * Per RFC 791, September 1981. */ /* * Structure of an internet header, naked of options. */ struct ip { #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int ip_hl:4; /* header length */ unsigned int ip_v:4; /* version */ #endif #if __BYTE_ORDER == __BIG_ENDIAN unsigned int ip_v:4; /* version */ unsigned int ip_hl:4; /* header length */ #endif uint8_t ip_tos; /* type of service */ unsigned short ip_len; /* total length */ unsigned short ip_id; /* identification */ unsigned short ip_off; /* fragment offset field */ #define IP_RF 0x8000 /* reserved fragment flag */ #define IP_DF 0x4000 /* dont fragment flag */ #define IP_MF 0x2000 /* more fragments flag */ #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ uint8_t ip_ttl; /* time to live */ uint8_t ip_p; /* protocol */ unsigned short ip_sum; /* checksum */ struct in_addr ip_src, ip_dst; /* source and dest address */ }; /* * Time stamp option structure. */ struct ip_timestamp { uint8_t ipt_code; /* IPOPT_TS */ uint8_t ipt_len; /* size of structure (variable) */ uint8_t ipt_ptr; /* index of current entry */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int ipt_flg:4; /* flags, see below */ unsigned int ipt_oflw:4; /* overflow counter */ #endif #if __BYTE_ORDER == __BIG_ENDIAN unsigned int ipt_oflw:4; /* overflow counter */ unsigned int ipt_flg:4; /* flags, see below */ #endif uint32_t data[9]; }; #endif /* __USE_MISC */ #define IPVERSION 4 /* IP version number */ #define IP_MAXPACKET 65535 /* maximum packet size */ /* * Definitions for Explicit Congestion Notification (ECN) * * Taken from RFC-3168, Section 5. */ #define IPTOS_ECN_MASK 0x03 #define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK) #define IPTOS_ECN_NOT_ECT 0x00 #define IPTOS_ECN_ECT1 0x01 #define IPTOS_ECN_ECT0 0x02 #define IPTOS_ECN_CE 0x03 /* * Definitions for IP differentiated services code points (DSCP) * * Taken from RFC-2597, Section 6 and RFC-2598, Section 2.3. */ #define IPTOS_DSCP_MASK 0xfc #define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK) #define IPTOS_DSCP_AF11 0x28 #define IPTOS_DSCP_AF12 0x30 #define IPTOS_DSCP_AF13 0x38 #define IPTOS_DSCP_AF21 0x48 #define IPTOS_DSCP_AF22 0x50 #define IPTOS_DSCP_AF23 0x58 #define IPTOS_DSCP_AF31 0x68 #define IPTOS_DSCP_AF32 0x70 #define IPTOS_DSCP_AF33 0x78 #define IPTOS_DSCP_AF41 0x88 #define IPTOS_DSCP_AF42 0x90 #define IPTOS_DSCP_AF43 0x98 #define IPTOS_DSCP_EF 0xb8 /* * In RFC 2474, Section 4.2.2.1, the Class Selector Codepoints subsume * the old ToS Precedence values. */ #define IPTOS_CLASS_MASK 0xe0 #define IPTOS_CLASS(class) ((class) & IPTOS_CLASS_MASK) #define IPTOS_CLASS_CS0 0x00 #define IPTOS_CLASS_CS1 0x20 #define IPTOS_CLASS_CS2 0x40 #define IPTOS_CLASS_CS3 0x60 #define IPTOS_CLASS_CS4 0x80 #define IPTOS_CLASS_CS5 0xa0 #define IPTOS_CLASS_CS6 0xc0 #define IPTOS_CLASS_CS7 0xe0 #define IPTOS_CLASS_DEFAULT IPTOS_CLASS_CS0 /* * Definitions for IP type of service (ip_tos) [deprecated; use DSCP * and CS definitions above instead.] */ #define IPTOS_TOS_MASK 0x1E #define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK) #define IPTOS_LOWDELAY 0x10 #define IPTOS_THROUGHPUT 0x08 #define IPTOS_RELIABILITY 0x04 #define IPTOS_LOWCOST 0x02 #define IPTOS_MINCOST IPTOS_LOWCOST /* * Definitions for IP precedence (also in ip_tos) [also deprecated.] */ #define IPTOS_PREC_MASK IPTOS_CLASS_MASK #define IPTOS_PREC(tos) IPTOS_CLASS(tos) #define IPTOS_PREC_NETCONTROL IPTOS_CLASS_CS7 #define IPTOS_PREC_INTERNETCONTROL IPTOS_CLASS_CS6 #define IPTOS_PREC_CRITIC_ECP IPTOS_CLASS_CS5 #define IPTOS_PREC_FLASHOVERRIDE IPTOS_CLASS_CS4 #define IPTOS_PREC_FLASH IPTOS_CLASS_CS3 #define IPTOS_PREC_IMMEDIATE IPTOS_CLASS_CS2 #define IPTOS_PREC_PRIORITY IPTOS_CLASS_CS1 #define IPTOS_PREC_ROUTINE IPTOS_CLASS_CS0 /* * Definitions for options. */ #define IPOPT_COPY 0x80 #define IPOPT_CLASS_MASK 0x60 #define IPOPT_NUMBER_MASK 0x1f #define IPOPT_COPIED(o) ((o) & IPOPT_COPY) #define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK) #define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK) #define IPOPT_CONTROL 0x00 #define IPOPT_RESERVED1 0x20 #define IPOPT_DEBMEAS 0x40 #define IPOPT_MEASUREMENT IPOPT_DEBMEAS #define IPOPT_RESERVED2 0x60 #define IPOPT_EOL 0 /* end of option list */ #define IPOPT_END IPOPT_EOL #define IPOPT_NOP 1 /* no operation */ #define IPOPT_NOOP IPOPT_NOP #define IPOPT_RR 7 /* record packet route */ #define IPOPT_TS 68 /* timestamp */ #define IPOPT_TIMESTAMP IPOPT_TS #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ #define IPOPT_SEC IPOPT_SECURITY #define IPOPT_LSRR 131 /* loose source route */ #define IPOPT_SATID 136 /* satnet id */ #define IPOPT_SID IPOPT_SATID #define IPOPT_SSRR 137 /* strict source route */ #define IPOPT_RA 148 /* router alert */ /* * Offsets to fields in options other than EOL and NOP. */ #define IPOPT_OPTVAL 0 /* option ID */ #define IPOPT_OLEN 1 /* option length */ #define IPOPT_OFFSET 2 /* offset within option */ #define IPOPT_MINOFF 4 /* min value of above */ #define MAX_IPOPTLEN 40 /* flag bits for ipt_flg */ #define IPOPT_TS_TSONLY 0 /* timestamps only */ #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ #define IPOPT_TS_PRESPEC 3 /* specified modules only */ /* bits for security (not byte swapped) */ #define IPOPT_SECUR_UNCLASS 0x0000 #define IPOPT_SECUR_CONFID 0xf135 #define IPOPT_SECUR_EFTO 0x789a #define IPOPT_SECUR_MMMM 0xbc4d #define IPOPT_SECUR_RESTR 0xaf13 #define IPOPT_SECUR_SECRET 0xd788 #define IPOPT_SECUR_TOPSECRET 0x6bc5 /* * Internet implementation parameters. */ #define MAXTTL 255 /* maximum time to live (seconds) */ #define IPDEFTTL 64 /* default ttl, from RFC 1340 */ #define IPFRAGTTL 60 /* time to live for frags, slowhz */ #define IPTTLDEC 1 /* subtracted when forwarding */ #define IP_MSS 576 /* default maximum segment size */ __END_DECLS #endif /* netinet/ip.h */ /* System specific type definitions for networking code. Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _NETINET_IN_SYSTM_H #define _NETINET_IN_SYSTM_H 1 #include <sys/types.h> #include <stdint.h> __BEGIN_DECLS /* * Network order versions of various data types. Unfortunately, BSD * assumes specific sizes for shorts (16 bit) and longs (32 bit) which * don't hold in general. As a consequence, the network order versions * may not reflect the actual size of the native data types. */ typedef uint16_t n_short; /* short as received from the net */ typedef uint32_t n_long; /* long as received from the net */ typedef uint32_t n_time; /* ms since 00:00 GMT, byte rev */ __END_DECLS #endif /* netinet/in_systm.h */ /* Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _NETINET_IN_H #define _NETINET_IN_H 1 #include <features.h> #include <bits/stdint-uintn.h> #include <sys/socket.h> #include <bits/types.h> __BEGIN_DECLS /* Internet address. */ typedef uint32_t in_addr_t; struct in_addr { in_addr_t s_addr; }; /* Get system-specific definitions. */ #include <bits/in.h> /* Standard well-defined IP protocols. */ enum { IPPROTO_IP = 0, /* Dummy protocol for TCP. */ #define IPPROTO_IP IPPROTO_IP IPPROTO_ICMP = 1, /* Internet Control Message Protocol. */ #define IPPROTO_ICMP IPPROTO_ICMP IPPROTO_IGMP = 2, /* Internet Group Management Protocol. */ #define IPPROTO_IGMP IPPROTO_IGMP IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94). */ #define IPPROTO_IPIP IPPROTO_IPIP IPPROTO_TCP = 6, /* Transmission Control Protocol. */ #define IPPROTO_TCP IPPROTO_TCP IPPROTO_EGP = 8, /* Exterior Gateway Protocol. */ #define IPPROTO_EGP IPPROTO_EGP IPPROTO_PUP = 12, /* PUP protocol. */ #define IPPROTO_PUP IPPROTO_PUP IPPROTO_UDP = 17, /* User Datagram Protocol. */ #define IPPROTO_UDP IPPROTO_UDP IPPROTO_IDP = 22, /* XNS IDP protocol. */ #define IPPROTO_IDP IPPROTO_IDP IPPROTO_TP = 29, /* SO Transport Protocol Class 4. */ #define IPPROTO_TP IPPROTO_TP IPPROTO_DCCP = 33, /* Datagram Congestion Control Protocol. */ #define IPPROTO_DCCP IPPROTO_DCCP IPPROTO_IPV6 = 41, /* IPv6 header. */ #define IPPROTO_IPV6 IPPROTO_IPV6 IPPROTO_RSVP = 46, /* Reservation Protocol. */ #define IPPROTO_RSVP IPPROTO_RSVP IPPROTO_GRE = 47, /* General Routing Encapsulation. */ #define IPPROTO_GRE IPPROTO_GRE IPPROTO_ESP = 50, /* encapsulating security payload. */ #define IPPROTO_ESP IPPROTO_ESP IPPROTO_AH = 51, /* authentication header. */ #define IPPROTO_AH IPPROTO_AH IPPROTO_MTP = 92, /* Multicast Transport Protocol. */ #define IPPROTO_MTP IPPROTO_MTP IPPROTO_BEETPH = 94, /* IP option pseudo header for BEET. */ #define IPPROTO_BEETPH IPPROTO_BEETPH IPPROTO_ENCAP = 98, /* Encapsulation Header. */ #define IPPROTO_ENCAP IPPROTO_ENCAP IPPROTO_PIM = 103, /* Protocol Independent Multicast. */ #define IPPROTO_PIM IPPROTO_PIM IPPROTO_COMP = 108, /* Compression Header Protocol. */ #define IPPROTO_COMP IPPROTO_COMP IPPROTO_SCTP = 132, /* Stream Control Transmission Protocol. */ #define IPPROTO_SCTP IPPROTO_SCTP IPPROTO_UDPLITE = 136, /* UDP-Lite protocol. */ #define IPPROTO_UDPLITE IPPROTO_UDPLITE IPPROTO_MPLS = 137, /* MPLS in IP. */ #define IPPROTO_MPLS IPPROTO_MPLS IPPROTO_ETHERNET = 143, /* Ethernet-within-IPv6 Encapsulation. */ #define IPPROTO_ETHERNET IPPROTO_ETHERNET IPPROTO_RAW = 255, /* Raw IP packets. */ #define IPPROTO_RAW IPPROTO_RAW IPPROTO_MPTCP = 262, /* Multipath TCP connection. */ #define IPPROTO_MPTCP IPPROTO_MPTCP IPPROTO_MAX }; /* If __USE_KERNEL_IPV6_DEFS is 1 then the user has included the kernel network headers first and we should use those ABI-identical definitions instead of our own, otherwise 0. */ #if !__USE_KERNEL_IPV6_DEFS enum { IPPROTO_HOPOPTS = 0, /* IPv6 Hop-by-Hop options. */ #define IPPROTO_HOPOPTS IPPROTO_HOPOPTS IPPROTO_ROUTING = 43, /* IPv6 routing header. */ #define IPPROTO_ROUTING IPPROTO_ROUTING IPPROTO_FRAGMENT = 44, /* IPv6 fragmentation header. */ #define IPPROTO_FRAGMENT IPPROTO_FRAGMENT IPPROTO_ICMPV6 = 58, /* ICMPv6. */ #define IPPROTO_ICMPV6 IPPROTO_ICMPV6 IPPROTO_NONE = 59, /* IPv6 no next header. */ #define IPPROTO_NONE IPPROTO_NONE IPPROTO_DSTOPTS = 60, /* IPv6 destination options. */ #define IPPROTO_DSTOPTS IPPROTO_DSTOPTS IPPROTO_MH = 135 /* IPv6 mobility header. */ #define IPPROTO_MH IPPROTO_MH }; #endif /* !__USE_KERNEL_IPV6_DEFS */ /* Type to represent a port. */ typedef uint16_t in_port_t; /* Standard well-known ports. */ enum { IPPORT_ECHO = 7, /* Echo service. */ IPPORT_DISCARD = 9, /* Discard transmissions service. */ IPPORT_SYSTAT = 11, /* System status service. */ IPPORT_DAYTIME = 13, /* Time of day service. */ IPPORT_NETSTAT = 15, /* Network status service. */ IPPORT_FTP = 21, /* File Transfer Protocol. */ IPPORT_TELNET = 23, /* Telnet protocol. */ IPPORT_SMTP = 25, /* Simple Mail Transfer Protocol. */ IPPORT_TIMESERVER = 37, /* Timeserver service. */ IPPORT_NAMESERVER = 42, /* Domain Name Service. */ IPPORT_WHOIS = 43, /* Internet Whois service. */ IPPORT_MTP = 57, IPPORT_TFTP = 69, /* Trivial File Transfer Protocol. */ IPPORT_RJE = 77, IPPORT_FINGER = 79, /* Finger service. */ IPPORT_TTYLINK = 87, IPPORT_SUPDUP = 95, /* SUPDUP protocol. */ IPPORT_EXECSERVER = 512, /* execd service. */ IPPORT_LOGINSERVER = 513, /* rlogind service. */ IPPORT_CMDSERVER = 514, IPPORT_EFSSERVER = 520, /* UDP ports. */ IPPORT_BIFFUDP = 512, IPPORT_WHOSERVER = 513, IPPORT_ROUTESERVER = 520, /* Ports less than this value are reserved for privileged processes. */ IPPORT_RESERVED = 1024, /* Ports greater this value are reserved for (non-privileged) servers. */ IPPORT_USERRESERVED = 5000 }; /* Definitions of the bits in an Internet address integer. On subnets, host and network parts are found according to the subnet mask, not these masks. */ #define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0) #define IN_CLASSA_NET 0xff000000 #define IN_CLASSA_NSHIFT 24 #define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET) #define IN_CLASSA_MAX 128 #define IN_CLASSB(a) ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000) #define IN_CLASSB_NET 0xffff0000 #define IN_CLASSB_NSHIFT 16 #define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET) #define IN_CLASSB_MAX 65536 #define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000) #define IN_CLASSC_NET 0xffffff00 #define IN_CLASSC_NSHIFT 8 #define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET) #define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000) #define IN_MULTICAST(a) IN_CLASSD(a) #define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000) #define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000) /* Address to accept any incoming messages. */ #define INADDR_ANY ((in_addr_t) 0x00000000) /* Address to send to all hosts. */ #define INADDR_BROADCAST ((in_addr_t) 0xffffffff) /* Address indicating an error return. */ #define INADDR_NONE ((in_addr_t) 0xffffffff) /* Network number for local host loopback. */ #define IN_LOOPBACKNET 127 /* Address to loopback in software to local host. */ #ifndef INADDR_LOOPBACK # define INADDR_LOOPBACK ((in_addr_t) 0x7f000001) /* Inet 127.0.0.1. */ #endif /* Defines for Multicast INADDR. */ #define INADDR_UNSPEC_GROUP ((in_addr_t) 0xe0000000) /* 224.0.0.0 */ #define INADDR_ALLHOSTS_GROUP ((in_addr_t) 0xe0000001) /* 224.0.0.1 */ #define INADDR_ALLRTRS_GROUP ((in_addr_t) 0xe0000002) /* 224.0.0.2 */ #define INADDR_ALLSNOOPERS_GROUP ((in_addr_t) 0xe000006a) /* 224.0.0.106 */ #define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) /* 224.0.0.255 */ #if !__USE_KERNEL_IPV6_DEFS /* IPv6 address */ struct in6_addr { union { uint8_t __u6_addr8[16]; uint16_t __u6_addr16[8]; uint32_t __u6_addr32[4]; } __in6_u; #define s6_addr __in6_u.__u6_addr8 #ifdef __USE_MISC # define s6_addr16 __in6_u.__u6_addr16 # define s6_addr32 __in6_u.__u6_addr32 #endif }; #endif /* !__USE_KERNEL_IPV6_DEFS */ extern const struct in6_addr in6addr_any; /* :: */ extern const struct in6_addr in6addr_loopback; /* ::1 */ #define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } } #define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } } #define INET_ADDRSTRLEN 16 #define INET6_ADDRSTRLEN 46 /* Structure describing an Internet socket address. */ struct sockaddr_in { __SOCKADDR_COMMON (sin_); in_port_t sin_port; /* Port number. */ struct in_addr sin_addr; /* Internet address. */ /* Pad to size of `struct sockaddr'. */ unsigned char sin_zero[sizeof (struct sockaddr) - __SOCKADDR_COMMON_SIZE - sizeof (in_port_t) - sizeof (struct in_addr)]; }; #if !__USE_KERNEL_IPV6_DEFS /* Ditto, for IPv6. */ struct sockaddr_in6 { __SOCKADDR_COMMON (sin6_); in_port_t sin6_port; /* Transport layer port # */ uint32_t sin6_flowinfo; /* IPv6 flow information */ struct in6_addr sin6_addr; /* IPv6 address */ uint32_t sin6_scope_id; /* IPv6 scope-id */ }; #endif /* !__USE_KERNEL_IPV6_DEFS */ #ifdef __USE_MISC /* IPv4 multicast request. */ struct ip_mreq { /* IP multicast address of group. */ struct in_addr imr_multiaddr; /* Local IP address of interface. */ struct in_addr imr_interface; }; struct ip_mreq_source { /* IP multicast address of group. */ struct in_addr imr_multiaddr; /* IP address of interface. */ struct in_addr imr_interface; /* IP address of source. */ struct in_addr imr_sourceaddr; }; #endif #if !__USE_KERNEL_IPV6_DEFS /* Likewise, for IPv6. */ struct ipv6_mreq { /* IPv6 multicast address of group */ struct in6_addr ipv6mr_multiaddr; /* local interface */ unsigned int ipv6mr_interface; }; #endif /* !__USE_KERNEL_IPV6_DEFS */ #ifdef __USE_MISC /* Multicast group request. */ struct group_req { /* Interface index. */ uint32_t gr_interface; /* Group address. */ struct sockaddr_storage gr_group; }; struct group_source_req { /* Interface index. */ uint32_t gsr_interface; /* Group address. */ struct sockaddr_storage gsr_group; /* Source address. */ struct sockaddr_storage gsr_source; }; /* Full-state filter operations. */ struct ip_msfilter { /* IP multicast address of group. */ struct in_addr imsf_multiaddr; /* Local IP address of interface. */ struct in_addr imsf_interface; /* Filter mode. */ uint32_t imsf_fmode; /* Number of source addresses. */ uint32_t imsf_numsrc; /* Source addresses. */ struct in_addr imsf_slist[1]; }; #define IP_MSFILTER_SIZE(numsrc) (sizeof (struct ip_msfilter) \ - sizeof (struct in_addr) \ + (numsrc) * sizeof (struct in_addr)) struct group_filter { /* Interface index. */ uint32_t gf_interface; /* Group address. */ struct sockaddr_storage gf_group; /* Filter mode. */ uint32_t gf_fmode; /* Number of source addresses. */ uint32_t gf_numsrc; /* Source addresses. */ struct sockaddr_storage gf_slist[1]; }; #define GROUP_FILTER_SIZE(numsrc) (sizeof (struct group_filter) \ - sizeof (struct sockaddr_storage) \ + ((numsrc) \ * sizeof (struct sockaddr_storage))) #endif /* Functions to convert between host and network byte order. Please note that these functions normally take `unsigned long int' or `unsigned short int' values as arguments and also return them. But this was a short-sighted decision since on different systems the types may have different representations but the values are always the same. */ extern uint32_t ntohl (uint32_t __netlong) __THROW __attribute__ ((__const__)); extern uint16_t ntohs (uint16_t __netshort) __THROW __attribute__ ((__const__)); extern uint32_t htonl (uint32_t __hostlong) __THROW __attribute__ ((__const__)); extern uint16_t htons (uint16_t __hostshort) __THROW __attribute__ ((__const__)); #include <endian.h> /* Get machine dependent optimized versions of byte swapping functions. */ #include <bits/byteswap.h> #include <bits/uintn-identity.h> #ifdef __OPTIMIZE__ /* We can optimize calls to the conversion functions. Either nothing has to be done or we are using directly the byte-swapping functions which often can be inlined. */ # if __BYTE_ORDER == __BIG_ENDIAN /* The host byte order is the same as network byte order, so these functions are all just identity. */ # define ntohl(x) __uint32_identity (x) # define ntohs(x) __uint16_identity (x) # define htonl(x) __uint32_identity (x) # define htons(x) __uint16_identity (x) # else # if __BYTE_ORDER == __LITTLE_ENDIAN # define ntohl(x) __bswap_32 (x) # define ntohs(x) __bswap_16 (x) # define htonl(x) __bswap_32 (x) # define htons(x) __bswap_16 (x) # endif # endif #endif #ifdef __GNUC__ # define IN6_IS_ADDR_UNSPECIFIED(a) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ __a->__in6_u.__u6_addr32[0] == 0 \ && __a->__in6_u.__u6_addr32[1] == 0 \ && __a->__in6_u.__u6_addr32[2] == 0 \ && __a->__in6_u.__u6_addr32[3] == 0; })) # define IN6_IS_ADDR_LOOPBACK(a) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ __a->__in6_u.__u6_addr32[0] == 0 \ && __a->__in6_u.__u6_addr32[1] == 0 \ && __a->__in6_u.__u6_addr32[2] == 0 \ && __a->__in6_u.__u6_addr32[3] == htonl (1); })) # define IN6_IS_ADDR_LINKLOCAL(a) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfe800000); })) # define IN6_IS_ADDR_SITELOCAL(a) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ (__a->__in6_u.__u6_addr32[0] & htonl (0xffc00000)) == htonl (0xfec00000); })) # define IN6_IS_ADDR_V4MAPPED(a) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ __a->__in6_u.__u6_addr32[0] == 0 \ && __a->__in6_u.__u6_addr32[1] == 0 \ && __a->__in6_u.__u6_addr32[2] == htonl (0xffff); })) # define IN6_IS_ADDR_V4COMPAT(a) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ __a->__in6_u.__u6_addr32[0] == 0 \ && __a->__in6_u.__u6_addr32[1] == 0 \ && __a->__in6_u.__u6_addr32[2] == 0 \ && ntohl (__a->__in6_u.__u6_addr32[3]) > 1; })) # define IN6_ARE_ADDR_EQUAL(a,b) \ (__extension__ \ ({ const struct in6_addr *__a = (const struct in6_addr *) (a); \ const struct in6_addr *__b = (const struct in6_addr *) (b); \ __a->__in6_u.__u6_addr32[0] == __b->__in6_u.__u6_addr32[0] \ && __a->__in6_u.__u6_addr32[1] == __b->__in6_u.__u6_addr32[1] \ && __a->__in6_u.__u6_addr32[2] == __b->__in6_u.__u6_addr32[2] \ && __a->__in6_u.__u6_addr32[3] == __b->__in6_u.__u6_addr32[3]; })) #else # define IN6_IS_ADDR_UNSPECIFIED(a) \ (((const uint32_t *) (a))[0] == 0 \ && ((const uint32_t *) (a))[1] == 0 \ && ((const uint32_t *) (a))[2] == 0 \ && ((const uint32_t *) (a))[3] == 0) # define IN6_IS_ADDR_LOOPBACK(a) \ (((const uint32_t *) (a))[0] == 0 \ && ((const uint32_t *) (a))[1] == 0 \ && ((const uint32_t *) (a))[2] == 0 \ && ((const uint32_t *) (a))[3] == htonl (1)) # define IN6_IS_ADDR_LINKLOCAL(a) \ ((((const uint32_t *) (a))[0] & htonl (0xffc00000)) \ == htonl (0xfe800000)) # define IN6_IS_ADDR_SITELOCAL(a) \ ((((const uint32_t *) (a))[0] & htonl (0xffc00000)) \ == htonl (0xfec00000)) # define IN6_IS_ADDR_V4MAPPED(a) \ ((((const uint32_t *) (a))[0] == 0) \ && (((const uint32_t *) (a))[1] == 0) \ && (((const uint32_t *) (a))[2] == htonl (0xffff))) # define IN6_IS_ADDR_V4COMPAT(a) \ ((((const uint32_t *) (a))[0] == 0) \ && (((const uint32_t *) (a))[1] == 0) \ && (((const uint32_t *) (a))[2] == 0) \ && (ntohl (((const uint32_t *) (a))[3]) > 1)) # define IN6_ARE_ADDR_EQUAL(a,b) \ ((((const uint32_t *) (a))[0] == ((const uint32_t *) (b))[0]) \ && (((const uint32_t *) (a))[1] == ((const uint32_t *) (b))[1]) \ && (((const uint32_t *) (a))[2] == ((const uint32_t *) (b))[2]) \ && (((const uint32_t *) (a))[3] == ((const uint32_t *) (b))[3])) #endif #define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff) #ifdef __USE_MISC /* Bind socket to a privileged IP port. */ extern int bindresvport (int __sockfd, struct sockaddr_in *__sock_in) __THROW; /* The IPv6 version of this function. */ extern int bindresvport6 (int __sockfd, struct sockaddr_in6 *__sock_in) __THROW; #endif #define IN6_IS_ADDR_MC_NODELOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) \ && ((((const uint8_t *) (a))[1] & 0xf) == 0x1)) #define IN6_IS_ADDR_MC_LINKLOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) \ && ((((const uint8_t *) (a))[1] & 0xf) == 0x2)) #define IN6_IS_ADDR_MC_SITELOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) \ && ((((const uint8_t *) (a))[1] & 0xf) == 0x5)) #define IN6_IS_ADDR_MC_ORGLOCAL(a) \ (IN6_IS_ADDR_MULTICAST(a) \ && ((((const uint8_t *) (a))[1] & 0xf) == 0x8)) #define IN6_IS_ADDR_MC_GLOBAL(a) \ (IN6_IS_ADDR_MULTICAST(a) \ && ((((const uint8_t *) (a))[1] & 0xf) == 0xe)) #ifdef __USE_GNU struct cmsghdr; /* Forward declaration. */ #if !__USE_KERNEL_IPV6_DEFS /* IPv6 packet information. */ struct in6_pktinfo { struct in6_addr ipi6_addr; /* src/dst IPv6 address */ unsigned int ipi6_ifindex; /* send/recv interface index */ }; /* IPv6 MTU information. */ struct ip6_mtuinfo { struct sockaddr_in6 ip6m_addr; /* dst address including zone ID */ uint32_t ip6m_mtu; /* path MTU in host byte order */ }; #endif /* !__USE_KERNEL_IPV6_DEFS */ /* Obsolete hop-by-hop and Destination Options Processing (RFC 2292). */ extern int inet6_option_space (int __nbytes) __THROW __attribute_deprecated__; extern int inet6_option_init (void *__bp, struct cmsghdr **__cmsgp, int __type) __THROW __attribute_deprecated__; extern int inet6_option_append (struct cmsghdr *__cmsg, const uint8_t *__typep, int __multx, int __plusy) __THROW __attribute_deprecated__; extern uint8_t *inet6_option_alloc (struct cmsghdr *__cmsg, int __datalen, int __multx, int __plusy) __THROW __attribute_deprecated__; extern int inet6_option_next (const struct cmsghdr *__cmsg, uint8_t **__tptrp) __THROW __attribute_deprecated__; extern int inet6_option_find (const struct cmsghdr *__cmsg, uint8_t **__tptrp, int __type) __THROW __attribute_deprecated__; /* Hop-by-Hop and Destination Options Processing (RFC 3542). */ extern int inet6_opt_init (void *__extbuf, socklen_t __extlen) __THROW; extern int inet6_opt_append (void *__extbuf, socklen_t __extlen, int __offset, uint8_t __type, socklen_t __len, uint8_t __align, void **__databufp) __THROW; extern int inet6_opt_finish (void *__extbuf, socklen_t __extlen, int __offset) __THROW; extern int inet6_opt_set_val (void *__databuf, int __offset, void *__val, socklen_t __vallen) __THROW; extern int inet6_opt_next (void *__extbuf, socklen_t __extlen, int __offset, uint8_t *__typep, socklen_t *__lenp, void **__databufp) __THROW; extern int inet6_opt_find (void *__extbuf, socklen_t __extlen, int __offset, uint8_t __type, socklen_t *__lenp, void **__databufp) __THROW; extern int inet6_opt_get_val (void *__databuf, int __offset, void *__val, socklen_t __vallen) __THROW; /* Routing Header Option (RFC 3542). */ extern socklen_t inet6_rth_space (int __type, int __segments) __THROW; extern void *inet6_rth_init (void *__bp, socklen_t __bp_len, int __type, int __segments) __THROW; extern int inet6_rth_add (void *__bp, const struct in6_addr *__addr) __THROW; extern int inet6_rth_reverse (const void *__in, void *__out) __THROW; extern int inet6_rth_segments (const void *__bp) __THROW; extern struct in6_addr *inet6_rth_getaddr (const void *__bp, int __index) __THROW; /* Multicast source filter support. */ /* Get IPv4 source filter. */ extern int getipv4sourcefilter (int __s, struct in_addr __interface_addr, struct in_addr __group, uint32_t *__fmode, uint32_t *__numsrc, struct in_addr *__slist) __THROW; /* Set IPv4 source filter. */ extern int setipv4sourcefilter (int __s, struct in_addr __interface_addr, struct in_addr __group, uint32_t __fmode, uint32_t __numsrc, const struct in_addr *__slist) __THROW; /* Get source filter. */ extern int getsourcefilter (int __s, uint32_t __interface_addr, const struct sockaddr *__group, socklen_t __grouplen, uint32_t *__fmode, uint32_t *__numsrc, struct sockaddr_storage *__slist) __THROW; /* Set source filter. */ extern int setsourcefilter (int __s, uint32_t __interface_addr, const struct sockaddr *__group, socklen_t __grouplen, uint32_t __fmode, uint32_t __numsrc, const struct sockaddr_storage *__slist) __THROW; #endif /* use GNU */ __END_DECLS #endif /* netinet/in.h */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)tcp.h 8.1 (Berkeley) 6/10/93 */ #ifndef _NETINET_TCP_H #define _NETINET_TCP_H 1 #include <features.h> /* * User-settable options (used with setsockopt). */ #define TCP_NODELAY 1 /* Don't delay send to coalesce packets */ #define TCP_MAXSEG 2 /* Set maximum segment size */ #define TCP_CORK 3 /* Control sending of partial frames */ #define TCP_KEEPIDLE 4 /* Start keeplives after this period */ #define TCP_KEEPINTVL 5 /* Interval between keepalives */ #define TCP_KEEPCNT 6 /* Number of keepalives before death */ #define TCP_SYNCNT 7 /* Number of SYN retransmits */ #define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */ #define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */ #define TCP_WINDOW_CLAMP 10 /* Bound advertised window */ #define TCP_INFO 11 /* Information about this connection. */ #define TCP_QUICKACK 12 /* Bock/reenable quick ACKs. */ #define TCP_CONGESTION 13 /* Congestion control algorithm. */ #define TCP_MD5SIG 14 /* TCP MD5 Signature (RFC2385) */ #define TCP_COOKIE_TRANSACTIONS 15 /* TCP Cookie Transactions */ #define TCP_THIN_LINEAR_TIMEOUTS 16 /* Use linear timeouts for thin streams*/ #define TCP_THIN_DUPACK 17 /* Fast retrans. after 1 dupack */ #define TCP_USER_TIMEOUT 18 /* How long for loss retry before timeout */ #define TCP_REPAIR 19 /* TCP sock is under repair right now */ #define TCP_REPAIR_QUEUE 20 /* Set TCP queue to repair */ #define TCP_QUEUE_SEQ 21 /* Set sequence number of repaired queue. */ #define TCP_REPAIR_OPTIONS 22 /* Repair TCP connection options */ #define TCP_FASTOPEN 23 /* Enable FastOpen on listeners */ #define TCP_TIMESTAMP 24 /* TCP time stamp */ #define TCP_NOTSENT_LOWAT 25 /* Limit number of unsent bytes in write queue. */ #define TCP_CC_INFO 26 /* Get Congestion Control (optional) info. */ #define TCP_SAVE_SYN 27 /* Record SYN headers for new connections. */ #define TCP_SAVED_SYN 28 /* Get SYN headers recorded for connection. */ #define TCP_REPAIR_WINDOW 29 /* Get/set window parameters. */ #define TCP_FASTOPEN_CONNECT 30 /* Attempt FastOpen with connect. */ #define TCP_ULP 31 /* Attach a ULP to a TCP connection. */ #define TCP_MD5SIG_EXT 32 /* TCP MD5 Signature with extensions. */ #define TCP_FASTOPEN_KEY 33 /* Set the key for Fast Open (cookie). */ #define TCP_FASTOPEN_NO_COOKIE 34 /* Enable TFO without a TFO cookie. */ #define TCP_ZEROCOPY_RECEIVE 35 #define TCP_INQ 36 /* Notify bytes available to read as a cmsg on read. */ #define TCP_CM_INQ TCP_INQ #define TCP_TX_DELAY 37 /* Delay outgoing packets by XX usec. */ #define TCP_REPAIR_ON 1 #define TCP_REPAIR_OFF 0 #define TCP_REPAIR_OFF_NO_WP -1 #ifdef __USE_MISC # include <sys/types.h> # include <sys/socket.h> # include <stdint.h> typedef uint32_t tcp_seq; /* * TCP header. * Per RFC 793, September, 1981. */ struct tcphdr { __extension__ union { struct { uint16_t th_sport; /* source port */ uint16_t th_dport; /* destination port */ tcp_seq th_seq; /* sequence number */ tcp_seq th_ack; /* acknowledgement number */ # if __BYTE_ORDER == __LITTLE_ENDIAN uint8_t th_x2:4; /* (unused) */ uint8_t th_off:4; /* data offset */ # endif # if __BYTE_ORDER == __BIG_ENDIAN uint8_t th_off:4; /* data offset */ uint8_t th_x2:4; /* (unused) */ # endif uint8_t th_flags; # define TH_FIN 0x01 # define TH_SYN 0x02 # define TH_RST 0x04 # define TH_PUSH 0x08 # define TH_ACK 0x10 # define TH_URG 0x20 uint16_t th_win; /* window */ uint16_t th_sum; /* checksum */ uint16_t th_urp; /* urgent pointer */ }; struct { uint16_t source; uint16_t dest; uint32_t seq; uint32_t ack_seq; # if __BYTE_ORDER == __LITTLE_ENDIAN uint16_t res1:4; uint16_t doff:4; uint16_t fin:1; uint16_t syn:1; uint16_t rst:1; uint16_t psh:1; uint16_t ack:1; uint16_t urg:1; uint16_t res2:2; # elif __BYTE_ORDER == __BIG_ENDIAN uint16_t doff:4; uint16_t res1:4; uint16_t res2:2; uint16_t urg:1; uint16_t ack:1; uint16_t psh:1; uint16_t rst:1; uint16_t syn:1; uint16_t fin:1; # else # error "Adjust your <bits/endian.h> defines" # endif uint16_t window; uint16_t check; uint16_t urg_ptr; }; }; }; enum { TCP_ESTABLISHED = 1, TCP_SYN_SENT, TCP_SYN_RECV, TCP_FIN_WAIT1, TCP_FIN_WAIT2, TCP_TIME_WAIT, TCP_CLOSE, TCP_CLOSE_WAIT, TCP_LAST_ACK, TCP_LISTEN, TCP_CLOSING /* now a valid state */ }; # define TCPOPT_EOL 0 # define TCPOPT_NOP 1 # define TCPOPT_MAXSEG 2 # define TCPOLEN_MAXSEG 4 # define TCPOPT_WINDOW 3 # define TCPOLEN_WINDOW 3 # define TCPOPT_SACK_PERMITTED 4 /* Experimental */ # define TCPOLEN_SACK_PERMITTED 2 # define TCPOPT_SACK 5 /* Experimental */ # define TCPOPT_TIMESTAMP 8 # define TCPOLEN_TIMESTAMP 10 # define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ # define TCPOPT_TSTAMP_HDR \ (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) /* * Default maximum segment size for TCP. * With an IP MSS of 576, this is 536, * but 512 is probably more convenient. * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). */ # define TCP_MSS 512 # define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ # define TCP_MAX_WINSHIFT 14 /* maximum window shift */ # define SOL_TCP 6 /* TCP level */ # define TCPI_OPT_TIMESTAMPS 1 # define TCPI_OPT_SACK 2 # define TCPI_OPT_WSCALE 4 # define TCPI_OPT_ECN 8 /* ECN was negociated at TCP session init */ # define TCPI_OPT_ECN_SEEN 16 /* we received at least one packet with ECT */ # define TCPI_OPT_SYN_DATA 32 /* SYN-ACK acked data in SYN sent or rcvd */ /* Values for tcpi_state. */ enum tcp_ca_state { TCP_CA_Open = 0, TCP_CA_Disorder = 1, TCP_CA_CWR = 2, TCP_CA_Recovery = 3, TCP_CA_Loss = 4 }; struct tcp_info { uint8_t tcpi_state; uint8_t tcpi_ca_state; uint8_t tcpi_retransmits; uint8_t tcpi_probes; uint8_t tcpi_backoff; uint8_t tcpi_options; uint8_t tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4; uint32_t tcpi_rto; uint32_t tcpi_ato; uint32_t tcpi_snd_mss; uint32_t tcpi_rcv_mss; uint32_t tcpi_unacked; uint32_t tcpi_sacked; uint32_t tcpi_lost; uint32_t tcpi_retrans; uint32_t tcpi_fackets; /* Times. */ uint32_t tcpi_last_data_sent; uint32_t tcpi_last_ack_sent; /* Not remembered, sorry. */ uint32_t tcpi_last_data_recv; uint32_t tcpi_last_ack_recv; /* Metrics. */ uint32_t tcpi_pmtu; uint32_t tcpi_rcv_ssthresh; uint32_t tcpi_rtt; uint32_t tcpi_rttvar; uint32_t tcpi_snd_ssthresh; uint32_t tcpi_snd_cwnd; uint32_t tcpi_advmss; uint32_t tcpi_reordering; uint32_t tcpi_rcv_rtt; uint32_t tcpi_rcv_space; uint32_t tcpi_total_retrans; }; /* For TCP_MD5SIG socket option. */ #define TCP_MD5SIG_MAXKEYLEN 80 /* tcp_md5sig extension flags for TCP_MD5SIG_EXT. */ #define TCP_MD5SIG_FLAG_PREFIX 1 /* Address prefix length. */ struct tcp_md5sig { struct sockaddr_storage tcpm_addr; /* Address associated. */ uint8_t tcpm_flags; /* Extension flags. */ uint8_t tcpm_prefixlen; /* Address prefix. */ uint16_t tcpm_keylen; /* Key length. */ uint32_t __tcpm_pad; /* Zero. */ uint8_t tcpm_key[TCP_MD5SIG_MAXKEYLEN]; /* Key (binary). */ }; /* For socket repair options. */ struct tcp_repair_opt { uint32_t opt_code; uint32_t opt_val; }; /* Queue to repair, for TCP_REPAIR_QUEUE. */ enum { TCP_NO_QUEUE, TCP_RECV_QUEUE, TCP_SEND_QUEUE, TCP_QUEUES_NR, }; /* For cookie transactions socket options. */ #define TCP_COOKIE_MIN 8 /* 64-bits */ #define TCP_COOKIE_MAX 16 /* 128-bits */ #define TCP_COOKIE_PAIR_SIZE (2*TCP_COOKIE_MAX) /* Flags for both getsockopt and setsockopt */ #define TCP_COOKIE_IN_ALWAYS (1 << 0) /* Discard SYN without cookie */ #define TCP_COOKIE_OUT_NEVER (1 << 1) /* Prohibit outgoing cookies, * supercedes everything. */ /* Flags for getsockopt */ #define TCP_S_DATA_IN (1 << 2) /* Was data received? */ #define TCP_S_DATA_OUT (1 << 3) /* Was data sent? */ #define TCP_MSS_DEFAULT 536U /* IPv4 (RFC1122, RFC2581) */ #define TCP_MSS_DESIRED 1220U /* IPv6 (tunneled), EDNS0 (RFC3226) */ struct tcp_cookie_transactions { uint16_t tcpct_flags; uint8_t __tcpct_pad1; uint8_t tcpct_cookie_desired; uint16_t tcpct_s_data_desired; uint16_t tcpct_used; uint8_t tcpct_value[TCP_MSS_DEFAULT]; }; /* For use with TCP_REPAIR_WINDOW. */ struct tcp_repair_window { uint32_t snd_wl1; uint32_t snd_wnd; uint32_t max_window; uint32_t rcv_wnd; uint32_t rcv_wup; }; /* For use with TCP_ZEROCOPY_RECEIVE. */ struct tcp_zerocopy_receive { uint64_t address; /* In: address of mapping. */ uint32_t length; /* In/out: number of bytes to map/mapped. */ uint32_t recv_skip_hint; /* Out: amount of bytes to skip. */ }; #endif /* Misc. */ #endif /* netinet/tcp.h */ /* Functions for storing Ethernet addresses in ASCII and mapping to hostnames. Copyright (C) 1996-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _NETINET_ETHER_H #define _NETINET_ETHER_H 1 #include <features.h> /* Get definition of `struct ether_addr'. */ #include <netinet/if_ether.h> #ifdef __USE_MISC __BEGIN_DECLS /* Convert 48 bit Ethernet ADDRess to ASCII. */ extern char *ether_ntoa (const struct ether_addr *__addr) __THROW; extern char *ether_ntoa_r (const struct ether_addr *__addr, char *__buf) __THROW; /* Convert ASCII string S to 48 bit Ethernet address. */ extern struct ether_addr *ether_aton (const char *__asc) __THROW; extern struct ether_addr *ether_aton_r (const char *__asc, struct ether_addr *__addr) __THROW; /* Map 48 bit Ethernet number ADDR to HOSTNAME. */ extern int ether_ntohost (char *__hostname, const struct ether_addr *__addr) __THROW; /* Map HOSTNAME to 48 bit Ethernet address. */ extern int ether_hostton (const char *__hostname, struct ether_addr *__addr) __THROW; /* Scan LINE and set ADDR and HOSTNAME. */ extern int ether_line (const char *__line, struct ether_addr *__addr, char *__hostname) __THROW; __END_DECLS #endif /* Use misc. */ #endif /* netinet/ether.h */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _NETINET_IGMP_H #define _NETINET_IGMP_H 1 #include <sys/cdefs.h> #include <sys/types.h> #ifdef __USE_MISC #include <netinet/in.h> __BEGIN_DECLS /* * Copyright (c) 1988 Stephen Deering. * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Stephen Deering of Stanford University. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)igmp.h 8.1 (Berkeley) 6/10/93 * $FreeBSD$ */ struct igmp { uint8_t igmp_type; /* IGMP type */ uint8_t igmp_code; /* routing code */ uint16_t igmp_cksum; /* checksum */ struct in_addr igmp_group; /* group address */ }; #define IGMP_MINLEN 8 /* * Message types, including version number. */ #define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */ #define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */ #define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */ #define IGMP_V2_LEAVE_GROUP 0x17 /* Leave-group message */ #define IGMP_DVMRP 0x13 /* DVMRP routing message */ #define IGMP_PIM 0x14 /* PIM routing message */ #define IGMP_TRACE 0x15 #define IGMP_MTRACE_RESP 0x1e /* traceroute resp.(to sender)*/ #define IGMP_MTRACE 0x1f /* mcast traceroute messages */ #define IGMP_MRDISC_ADV 0x30 /* From RFC4286. */ #define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */ /* query (in seconds) according */ /* to RFC1112 */ #define IGMP_TIMER_SCALE 10 /* denotes that the igmp code field */ /* specifies time in 10th of seconds*/ /* * States for the IGMP v2 state table. */ #define IGMP_DELAYING_MEMBER 1 #define IGMP_IDLE_MEMBER 2 #define IGMP_LAZY_MEMBER 3 #define IGMP_SLEEPING_MEMBER 4 #define IGMP_AWAKENING_MEMBER 5 /* * States for IGMP router version cache. */ #define IGMP_v1_ROUTER 1 #define IGMP_v2_ROUTER 2 /* * The following four defininitions are for backwards compatibility. * They should be removed as soon as all applications are updated to * use the new constant names. */ #define IGMP_HOST_MEMBERSHIP_QUERY IGMP_MEMBERSHIP_QUERY #define IGMP_HOST_MEMBERSHIP_REPORT IGMP_V1_MEMBERSHIP_REPORT #define IGMP_HOST_NEW_MEMBERSHIP_REPORT IGMP_V2_MEMBERSHIP_REPORT #define IGMP_HOST_LEAVE_MESSAGE IGMP_V2_LEAVE_GROUP __END_DECLS #endif #endif /* netinet/igmp.h */ /* Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* * Copyright (C) 1982, 1986 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef __NETINET_UDP_H #define __NETINET_UDP_H 1 #include <sys/types.h> #include <stdint.h> /* UDP header as specified by RFC 768, August 1980. */ struct udphdr { __extension__ union { struct { uint16_t uh_sport; /* source port */ uint16_t uh_dport; /* destination port */ uint16_t uh_ulen; /* udp length */ uint16_t uh_sum; /* udp checksum */ }; struct { uint16_t source; uint16_t dest; uint16_t len; uint16_t check; }; }; }; /* UDP socket options */ #define UDP_CORK 1 /* Never send partially complete segments. */ #define UDP_ENCAP 100 /* Set the socket to accept encapsulated packets. */ #define UDP_NO_CHECK6_TX 101 /* Disable sending checksum for UDP over IPv6. */ #define UDP_NO_CHECK6_RX 102 /* Disable accepting checksum for UDP over IPv6. */ #define UDP_SEGMENT 103 /* Set GSO segmentation size. */ #define UDP_GRO 104 /* This socket can receive UDP GRO packets. */ /* UDP encapsulation types */ #define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */ #define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 */ #define UDP_ENCAP_L2TPINUDP 3 /* rfc2661 */ #define UDP_ENCAP_GTP0 4 /* GSM TS 09.60 */ #define UDP_ENCAP_GTP1U 5 /* 3GPP TS 29.060 */ #define SOL_UDP 17 /* sockopt level for UDP */ #endif /* netinet/udp.h */ /* * Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2026 All Rights Reserved * * Licensed under CLOUD LINUX LICENSE AGREEMENT * http://cloudlinux.com/docs/LICENSE.TXT * * The part the support library for lsapi & proxy_lsapi Apache modules * author Alexander Demeshko <ademeshko@cloudlinux.com> * * Here you define exportable functions for libscapi clients. */ #ifndef _LSCAPI_H_ #define _LSCAPI_H_ #define LSCAPI_PATH_PREFIX "lsapi_" /* LSAPI_PRO_ONLY:BEGIN */ #ifdef WITH_CRIU #ifdef LSCAPI_DEFAULT_CRIU_SOCKET_PATH #undef LSCAPI_DEFAULT_CRIU_SOCKET_PATH #endif #define LSCAPI_DEFAULT_CRIU_SOCKET_PATH "/var/run/criu/criu_service.socket" #define CRIU_IMGS_SUFFIX "_criu_imgs" #define CRIU_IMGS_RESET_FLAG "mod_lsapi_reset_me" #define CRIU_IMGS_RESET_GLOBAL_FLAG "/usr/share/criu/mod_lsapi/lsphp.criu.reset" #endif //WITH_CRIU /* LSAPI_PRO_ONLY:END */ #include <sys/uio.h> #include <sys/types.h> #include <stdbool.h> #include <stdint.h> #include <lsapidef.h> #include <lscapi_config.h> #include <liblsapi-sha1.h> #define LSCAPI_SECRET_SIZE 16 #define LSCAPI_SALT_SIZE 16 #define LSCAPI_SHA1_SIGN_SIZE (LSCAPI_SALT_SIZE + SHA1_DIGEST_SIZE) #define LSCAPI_ENCODED_SHA1_SIGN_SIZE (2*LSCAPI_SHA1_SIGN_SIZE + 1) #define LSCAPI_ENCODED_SHA1_SIGN_WITHOUT_SALT_SIZE (2*SHA1_DIGEST_SIZE + 1) /* LSAPI_PRO_ONLY:BEGIN */ enum { PFL_RESEND_IF_CRASHED = 0, PFL_SOCKET_FAILED, PFL_BACKEND_CONNECT_FATAL_ERROR, PFL_BACKEND_WARM_CONNECT, PFL_BACKEND_WARM_CONNECT_MS, PFL_BACKEND_COLD_CONNECT, PFL_BACKEND_COLD_CONNECT_MS, PFL_BACKEND_CONNECT_FAILED, PFL_BACKEND_SPAWN_FAILED, PFL_BACKEND_SPAWN_SUCCESS, PFL_BACKEND_SPAWN_DELAYED, /* PFL_MODLS_NORM_REQ_MS, // 0 PFL_MODLS_NORM_REQ_NUM, // 0 PFL_MODLS_REQ_HAS_BODY_MS, // 0 PFL_MODLS_REQ_HAS_BODY_NUM, // 0 PFL_MODLS_REQ_WO_BODY_MS, // 0 PFL_MODLS_REQ_WO_BODY_NUM, // 0 */ PFL_LAST }; #ifdef WITH_LIBPERFLOG #include <perf_log.h> extern pfl_handle_t* lsapi_perf_handle; void lsapi_init_libperflog(void); static inline void lsapi_perf_inc(int event_id) { perf_inc(lsapi_perf_handle, event_id); } static inline void lsapi_perf_add(int event_id, pfl_event_count_t diff) { perf_add(lsapi_perf_handle, event_id, diff); } #else //WITH_LIBPERFLOG #define lsapi_perf_inc(event_id) #define lsapi_perf_add(event_id, diff) #endif //WITH_LIBPERFLOG /* LSAPI_PRO_ONLY:END */ // lsapi structs typedef struct lsapi_req_header lsapi_req_header_t; typedef struct lsapi_http_header_index lsapi_http_header_index_t; typedef struct lsapi_header_offset lsapi_header_offset_t; typedef struct lsapi_packet_header lsapi_packet_header_t; typedef struct lsapi_resp_info lsapi_resp_info; // lscapi opaque structures struct lscapi_rec; struct lsphp_conn_t; typedef struct lscapi_rec lscapi_rec; typedef struct lsphp_conn_t lsphp_conn_t; // allocator function pointer type typedef void *(*lscapi_alloc_fn)(size_t size, void *user_data); typedef long (*lscapi_user_get_body_fn)(char *buf, size_t bufLen, void *user_data); typedef int (*lscapi_should_get_block_fn)(void *user_data); typedef void (*lscapi_log_fn)(const char *file, int line, int level, int errcode, const void *user_data, const char *fmt, ...); typedef void (*lscapi_random_fn)(void *buf, size_t size); typedef int(*lsphp_conn_failed_fn)(lsphp_conn_t *conn); #ifndef WITHOUT_LVE typedef void* (*lscapi_lve_alloc_t)(size_t sz, void* user_data); typedef void (*lscapi_lve_register_t)(void* user_data, void* data, int (*destroy_fn)()); #endif struct lscapi_var_t { const char *key; int keyLen; const char *val; int valLen; int perdir; }; typedef struct lscapi_var_t lscapi_var_t; struct lscapi_header_index_t { unsigned keyOff; unsigned keyLen; unsigned valOff; unsigned valLen; }; typedef struct lscapi_header_index_t lscapi_header_index_t; /* From lsapilib.h of Litespeed API 6.11 In Litespeed API 7.4.2 increased to 1000 DEPRECATED For backward compatibility only. It it needed only for deprecated lscapi_resphdr_t */ #define LSAPI_MAX_RESP_HEADERS 100 /* LSAPI_PRO_ONLY:BEGIN */ /* DEPRECATED For backward compatibility only. Updated with lscapi_resphdr_t */ struct lscapi_resphdr_info_t { char buf[LSAPI_MAX_DATA_PACKET_LEN]; size_t dataLen; uint16_t *hdrSizes; int hdrNum; int respStatus; }; typedef struct lscapi_resphdr_info_t lscapi_resphdr_info_t; /* LSAPI_PRO_ONLY:END */ /* DEPRECATED For backward compatibility only. It it needed only for deprecated lscapi_receive_response_hdr function */ struct lscapi_resphdr_t { char buf[LSAPI_MAX_RESP_HEADERS * (LSAPI_RESP_HTTP_HEADER_MAX+2) + 1024]; size_t dataLen; uint16_t *hdrSizes; int hdrNum; int respStatus; }; typedef struct lscapi_resphdr_t lscapi_resphdr_t; struct lscapi_resp_hdr_t { char *respBuffer; size_t dataLen; uint16_t *hdrSizes; int hdrNum; int respStatus; }; typedef struct lscapi_resp_hdr_t lscapi_resp_hdr_t; enum { LSAPI_BACKEND_OWN_LOG_PATH_SOURCE_AUTO = 0, // path is generated based on a generic pattern, taking into account "lsapi_backend_common_own_log" cfg setting LSAPI_BACKEND_OWN_LOG_PATH_SOURCE_ENV // path is arbitrary, defined by "LSAPI_BACKEND_OWN_LOG_PATH" request property // literal path values in ".conf" aren't yet supported }; struct lscapi_backend_info_t { uint32_t connect_tries; uint32_t connect_timeout; uint32_t backend_children; uint32_t backend_pgrp_max_idle; uint32_t backend_max_idle; uint32_t backend_max_process_time; uint32_t backend_max_reqs; uint32_t backend_pgrp_max_reqs; uint32_t backend_pgrp_max_crashes; uint32_t backend_initial_start; uint32_t poll_timeout; int32_t backend_oom_score_adj; unsigned backend_coredump: 1; unsigned dump_backend_debug_info: 1; unsigned use_suexec: 1; unsigned enable_user_ini: 1; unsigned per_user: 1; unsigned user_ini_homedir: 1; unsigned backend_coredump_was_set: 1; unsigned dump_backend_debug_info_was_set: 1; unsigned use_suexec_was_set: 1; unsigned enable_user_ini_was_set: 1; unsigned per_user_was_set: 1; unsigned user_ini_homedir_was_set: 1; unsigned avoid_zombies: 1; unsigned avoid_zombies_was_set: 1; unsigned disable_reject_mode: 1; unsigned disable_reject_mode_was_set: 1; /* LSAPI_PRO_ONLY:BEGIN */ unsigned use_criu: 1; unsigned use_criu_was_set: 1; unsigned criu_debug: 1; unsigned criu_debug_was_set: 1; unsigned use_criu_signals: 2; unsigned use_criu_signals_was_set: 1; /* LSAPI_PRO_ONLY:END */ unsigned use_own_log: 1; unsigned use_own_log_was_set: 1; /* LSAPI_PRO_ONLY:BEGIN */ unsigned backend_semtimedwait: 1; unsigned backend_semtimedwait_was_set: 1; /* LSAPI_PRO_ONLY:END */ unsigned common_own_log: 1; unsigned common_own_log_was_set: 1; unsigned own_log_path_source: 2; unsigned own_log_path_source_was_set: 1; unsigned pwd_disabled: 1; unsigned pwd_disabled_was_set: 1; /* LSAPI_PRO_ONLY:BEGIN */ // This flag is global, not intended to change via tree config. So without _was_set unsigned change_cgroup: 1; /* LSAPI_PRO_ONLY:END */ unsigned backend_loglevel_info: 1; unsigned backend_loglevel_info_was_set: 1; unsigned backend_oom_score_adj_was_set: 1; }; typedef struct lscapi_backend_info_t lscapi_backend_info_t; #define LSCAPI_PATH_MAX 128 #define LSCAPI_PHPRC_MAX 128 /* struct sockaddr_un in <sys/un.h> contains integer constant instead of promised by unix(7) UNIX_PATH_MAX So we will use our own macro. */ #define LSCAPI_SOCKET_MAX 108 /* LSAPI_PRO_ONLY:BEGIN */ struct criu_info_t { char socket_name[4086]; /* Path to CRIU service socket */ char images_dir[4086]; /* Path to dir for CRIU images */ int sock_sulsphp; /* Socket for sulsphp to talk to lsphp */ int sock_lsphp; /* Socket for lsphp to talk to sulsphp */ int pipe_pid_read; /* Pipe end for dumper to read lsphp pid from */ int pipe_pid_write; /* Pipe end for sulsphp to write lsphp pid to */ }; /* LSAPI_PRO_ONLY:END */ typedef struct spawn_info_t { unsigned backend_children; int backend_oom_score_adj; unsigned backend_pgrp_max_idle; unsigned backend_max_idle; unsigned backend_max_process_time; unsigned backend_max_reqs; unsigned backend_pgrp_max_reqs; unsigned backend_pgrp_max_crashes; unsigned backend_initial_start; uid_t real_uid; gid_t real_gid; uid_t lve_uid; unsigned backend_coredump: 1; unsigned dump_backend_debug_info: 1; unsigned use_suexec: 1; unsigned backend_accept_notify: 1; unsigned use_own_log: 1; unsigned enable_user_ini: 1; unsigned common_own_log: 1; unsigned user_ini_homedir: 1; unsigned debug_enabled: 1; unsigned expose_phprc_as_lsphprc: 1; char phprc[LSCAPI_PHPRC_MAX]; char cmd[LSCAPI_PATH_MAX]; char socket_name[LSCAPI_SOCKET_MAX]; char handler[LSCAPI_SOCKET_MAX]; char docroot[LSCAPI_PATH_MAX]; char hostname[LSCAPI_PATH_MAX]; char own_log_path[LSCAPI_PATH_MAX]; lsapi_rlimits_t rlimits; // after zero init no limits are defined unsigned has_rlimits: 1; // redundant flag to speed up checks, true if any limit in "rlimits" is defined /* LSAPI_PRO_ONLY:BEGIN */ unsigned use_criu: 1; unsigned criu_debug: 1; unsigned use_criu_signals: 2; /* LSAPI_PRO_ONLY:END */ unsigned pwd_disabled: 1; unsigned avoid_zombies: 1; unsigned disable_reject_mode: 1; /* LSAPI_PRO_ONLY:BEGIN */ unsigned change_cgroup: 1; /* LSAPI_PRO_ONLY:END */ char uniq_socket_name[LSCAPI_SOCKET_MAX]; /* LSAPI_PRO_ONLY:BEGIN */ struct criu_info_t criu; /* LSAPI_PRO_ONLY:END */ } spawn_info_t; typedef struct spawn_context_t { int log_sock; int restore; } spawn_context_t; typedef pid_t (*lscapi_spawn_backend_fn)(const spawn_info_t *spawn_info, void *user_data, int force_start); // Event masks /* LSAPI_PRO_ONLY:BEGIN */ // DEPRECATED #define LSCAPI_BACKEND_LOG_RECEIVED (1u << 0) /* LSAPI_PRO_ONLY:END */ #define LSCAPI_RESPONSE_FINISHED (1u << 1) /* LSAPI_PRO_ONLY:BEGIN */ // DEPRECATED #define LSCAPI_BACKEND_LOG_FATAL (1u << 2) /* LSAPI_PRO_ONLY:END */ #define LSCAPI_SENDREQ_INTERNAL_ERROR (1u << 3) #define LSCAPI_SENDREQ_BACKEND_ERROR (1u << 4) #define LSCAPI_SENDREQ_CLIENT_ERROR (1u << 5) #define LSCAPI_CONNECT_REJECTED (1u << 6) #define LSCAPI_CONNECT_GENERIC_ERROR (1u << 7) #define LSCAPI_CONNECT_RESET_ERROR (1u << 8) enum lscapi_create_flags { LSCAPI_CREATE_WITH_LVE = 1 << 0, LSCAPI_OUT_ALREADY_INSIDE_LVE = 1 << 16, LSCAPI_OUT_RESOURCE_LIMIT_LVE = 1 << 17, }; /* * For backward compatibility with mod_lsapi * LSCAPI_SPECIAL_ENV_PHPVAL_SYSTEM should be 0 * LSCAPI_SPECIAL_ENV_PHPVAL_PERDIR should be 1 * */ enum lscapi_special_env_types { LSCAPI_SPECIAL_ENV_PHPVAL_SYSTEM = 0, LSCAPI_SPECIAL_ENV_PHPVAL_PERDIR = 1, LSCAPI_SPECIAL_ENV_ALTER_PHPINI = 2 }; extern const char defaultHandler[]; // "application/x-httpd-lsphp"; int lscapi_init(char *errbuf, size_t errlen); // Here caller must use memory pool associated with process void lscapi_child_init(lscapi_alloc_fn user_alloc, void *user_data); // for backward compatibility, use lscapi_get_backend_heuristic instead const char *lscapi_get_backend(const char *handler); // Here caller must use memory pool associated with HTTP request const char *lscapi_get_backend_heuristic(const char *handler, lscapi_alloc_fn user_alloc, void *user_data); uint32_t lscapi_get_real_uid(lscapi_rec *lscapi); /** * create opaque structure to store connection to lsphp on logical level * args: * user_alloc = pointer to allocator function * user_data = arbitrary user data to pass to allocator function * real_uid = uid for suexec * real_gid = gid for suexec * lve_uid = uid for lve * flags = * errbuf = buffer to store error description on error * errlen = length of the error buffer * return codes: * allocated and initialized structure = on success, NULL on error */ lscapi_rec *lscapi_create_ex(lscapi_alloc_fn user_alloc, lscapi_log_fn user_log, void *user_data, uint32_t real_uid, uint32_t real_gid, uint32_t lve_uid, unsigned *flagsPtr, char *errbuf, unsigned errlen); /** * close connection to lsphp on logical level * args: * lscapi = opaque structure created with lscapi_create */ void lscapi_destroy(lscapi_rec *lscapi); /** * Serialize the LSAPI request into caller-supplied buffer. * For use by consumers that manage their own socket writes (e.g. nginx). * return codes: 0 on success, non-zero on error (errbuf filled). */ int lscapi_compose_request(char *buf, size_t bufSize, size_t *reqLenPtr, lscapi_rec *lscapi, char *errbuf, unsigned errlen); /** * return codes: * 0 = on success, -1 on error and sets appropriate flag on eventMaskPtr */ int lscapi_send_request(lsphp_conn_t *conn, unsigned *eventMaskPtr, char *errbuf, unsigned errlen); void lscapi_set_socket_path(lscapi_rec *lscapi, char *socket_path); void lscapi_set_phprc(lscapi_rec *lscapi, const char *phprc, bool expose_as_lsphprc); void lscapi_set_user_body_info(lscapi_rec *lscapi, size_t body_len, lscapi_user_get_body_fn user_get_body, lscapi_should_get_block_fn user_should_get_block); void lscapi_set_use_request_scope_buffer(lscapi_rec *lscapi, bool value); size_t lscapi_get_body_len(lscapi_rec *lscapi); void lscapi_set_header_info(lscapi_rec *lscapi, lsapi_http_header_index_t *hdrIndexPtr, lsapi_header_offset_t *hdrOffsets, size_t hdrOffsetsNum, char *httpHeader, size_t httpHeaderLen); void lscapi_set_envs(lscapi_rec *lscapi, lscapi_var_t *envs, int envNum); void lscapi_set_special_envs(lscapi_rec *lscapi, lscapi_var_t *specialEnvs, int specialEnvNum); void lscapi_set_backend_path(lscapi_rec *lscapi, const char *handler, const char *backend_path); void lscapi_set_debug_enabled(lscapi_rec *lscapi, int debug_enabled); void lscapi_set_error(lscapi_rec *lscapi); void lscapi_set_recoverable_error(lscapi_rec *lscapi); bool lscapi_get_error(const lscapi_rec *lscapi, bool *outIsRecoverableError); void lscapi_reset_internal_error_state(lscapi_rec *lscapi); void lscapi_set_random(lscapi_rec *lscapi, lscapi_random_fn get_random_bytes); void lscapi_set_user_spawn_backend(lscapi_rec *lscapi, lscapi_spawn_backend_fn user_spawn_backend); void lscapi_set_accept_notify(lscapi_rec *lscapi, int accept_notify); void lscapi_set_domain(lscapi_rec *lscapi, const char *domain); void lscapi_set_docroot(lscapi_rec *lscapi, const char *docroot); void lscapi_set_rlimits(lscapi_rec *lscapi, const lsapi_rlimits_t *rlimits); void lscapi_set_protocol_log(lscapi_rec *lscapi, const char *protocol_log); void lscapi_set_backend_own_log_path(lscapi_rec *lscapi, const char *path); void lscapi_set_tmpdir(lscapi_rec *lscapi, const char *tmpdir); void lscapi_set_reqbody_maxlen(lscapi_rec *lscapi, size_t maxlen); /* LSAPI_PRO_ONLY:BEGIN */ /* DEPRECATED */ const char* lscapi_get_backend_log(lscapi_rec *lscapi); /* LSAPI_PRO_ONLY:END */ void lscapi_init_backend_info(lscapi_backend_info_t *infoPtr); void lscapi_merge_backend_info(lscapi_backend_info_t *base, lscapi_backend_info_t *cur, lscapi_backend_info_t *merged); lsphp_conn_t* lscapi_acquire_lsphp_conn(lscapi_rec *lscapi, char *errbuf, unsigned errlen); void lscapi_release_lsphp_conn(lsphp_conn_t *conn); /* LSAPI_PRO_ONLY:BEGIN */ /* This function creates a safe environment for spawning new lsphp process. Memory for this is allocated with call to calloc and calls to strdup. So this function is intended to be called just after call to fork from within a child process and just before call to exec. DO NOT USE it otherwise to avoid memory leaks. */ /* DEPRECATED */ int lscapi_prepare_env_for_lsphp(spawn_info_t *spawn_info, const char *customEnv, int envLen, int envNum, const char *safePath, char *errbuf, unsigned errlen); /* LSAPI_PRO_ONLY:END */ /* This function creates a safe environment for spawning new lsphp process. Memory for this is allocated with call to calloc and calls to strdup. So this function is intended to be called just after call to fork from within a child process and just before call to exec. DO NOT USE it otherwise to avoid memory leaks. */ char** lscapi_prepare_env(spawn_info_t *spawn_info, const char *customEnv, int envLen, int envNum, const char *safePath, char *errbuf, unsigned errlen); int lscapi_lsphp_conn_get_socket(lsphp_conn_t *conn); void lscapi_remove_stale_data_from_socket(lsphp_conn_t *conn); int lscapi_is_conn_closed(lsphp_conn_t *conn); /* LSAPI_PRO_ONLY:BEGIN */ /* DEPRECATED Do nothing. For compatibility with mod_lsapi ver. 0.2 only. */ void lscapi_set_userdir(lscapi_rec *lscapi, int userdir); /* DEPRECATED Do nothing. For compatibility with mod_lsapi ver. 0.2 only. */ void lscapi_set_backend_coredump(lscapi_rec *lscapi, int coredump_enabled); /* DEPRECATED Do nothing. For compatibility with mod_lsapi ver. 0.2 only. */ void lscapi_terminate_backends(void); /* LSAPI_PRO_ONLY:END */ int lscapi_determine_conn_lsphp(lsphp_conn_t *conn, lscapi_backend_info_t *backendInfoPtr, char *errbuf, unsigned errlen); int lscapi_determine_conn_lsphp_ex(lsphp_conn_t *conn, lscapi_backend_info_t *backendInfoPtr, const char *sockName, char *errbuf, unsigned errlen); /* LSAPI_PRO_ONLY:BEGIN */ /* DEPRECATED */ int lscapi_connect_lsphp(lsphp_conn_t *conn, char *errbuf, unsigned errlen); /* DEPRECATED */ int lscapi_connect_lsphp_ex(lsphp_conn_t *conn, char *errbuf, unsigned errlen, int chunked); /* LSAPI_PRO_ONLY:END */ int lscapi_connect_backend(lsphp_conn_t *conn, unsigned *eventMaskPtr, char *errbuf, unsigned errlen); int lscapi_connect_backend_ex(lsphp_conn_t *conn, unsigned *eventMaskPtr, char *errbuf, unsigned errlen, int chunked); void lscapi_conn_set_failed_cb(lsphp_conn_t *conn, lsphp_conn_failed_fn cb, void *opaque); lscapi_rec *lscapi_conn_get_lsapi_handle(lsphp_conn_t *conn); void *lscapi_conn_get_opaque(lsphp_conn_t *conn); const char *lscapi_conn_get_socket_name(lsphp_conn_t *conn); pid_t lscapi_conn_get_worker_pid(lsphp_conn_t *conn); /* DEPRECATED */ void lscapi_lsphp_use_sock(lsphp_conn_t *conn, int sock, char *errbuf, unsigned errlen); void lscapi_lsphp_use_sock_ext(lsphp_conn_t *conn, int sock, pid_t backend_pid, char *errbuf, unsigned errlen); /* LSAPI_PRO_ONLY:BEGIN */ /* DEPRECATED For backward compatibility only. Updated with lscapi_receive_response_hdr */ int lscapi_receive_response_header(lsphp_conn_t *conn, lscapi_resphdr_info_t *hdrInfoPtr, unsigned *eventMaskPtr, char *errbuf, unsigned errlen); /* LSAPI_PRO_ONLY:END */ /* DEPRECATED For backward compatibility only. Use lscapi_receive_resp_hdr and lscapi_free_resp_hdr instead */ int lscapi_receive_response_hdr(lsphp_conn_t *conn, lscapi_resphdr_t *hdrInfoPtr, unsigned *eventMaskPtr, char *errbuf, unsigned errlen); /* Use it instead of deprecated lscapi_receive_response_hdr to receive header of http response from backend. lscapi_free_resp_hdr should called to free allocated resources. */ int lscapi_receive_resp_hdr(lsphp_conn_t *conn, lscapi_resp_hdr_t *rspHdr, unsigned *eventMaskPtr, char *errbuf, unsigned errlen); void lscapi_free_resp_hdr(lsphp_conn_t *conn, lscapi_resp_hdr_t *rspHdr); int lscapi_receive_response_chunk(lsphp_conn_t *conn, char *buf, size_t *lenPtr, unsigned *eventMaskPtr, char *errbuf, unsigned errlen); /* LSAPI_PRO_ONLY:BEGIN */ // lve.c #ifndef WITHOUT_LVE /** * load LVE library by dlopen and initialize it * args: * lve_alloc = pointer to function to allocate memory * lve_register = pointer to function to register allocated block * lve_user_data = user data for lve_alloc and lve_register calls * errbuf = buffer to store error description on error * errlen = length of the error buffer * return codes: * 0 = on success, -1 on error */ int lscapi_load_lve(lscapi_lve_alloc_t lve_alloc, lscapi_lve_register_t lve_register, void *lve_user_data, char *errbuf, size_t errlen); /** * check whether lscapi_load_lve was successfully called previously * return codes: * 1 = in case of success, 0 otherwise */ int lscapi_is_lve_loaded(void); #endif /* LSAPI_PRO_ONLY:END */ /* socket_path - sockets with patterns lsapi_*.sock in this directory will be deleted after stop of backends */ void lscapi_terminate_backends_ex(const char *socket_path); /* LSAPI_PRO_ONLY:BEGIN */ #ifdef WITH_CRIU /* socket_path - sockets matched to pattern lsapi_*.sock in this directory will be deleted after stop of backends criu_imgs_dir_path - subdirectories matched to pattern lsapi_*_criu_imgs in this directory will be deleted after stop of backends */ void lscapi_terminate_backends_criu(const char *socket_path, const char *criu_imgs_dir_path); void lscapi_check_imgs_cleanup(const char *criu_imgs_dir_path); #endif /* LSAPI_PRO_ONLY:END */ void lscapi_sign_uidgid_md5(lscapi_rec *lscapi, const uint32_t ids[2], const uint8_t salt[LSCAPI_SALT_SIZE], unsigned char sign[32]); void lscapi_sign_uidgid_sha1(lscapi_rec *lscapi, const uint32_t ids[2], const uint8_t salt[LSCAPI_SALT_SIZE], uint8_t sign[LSCAPI_SHA1_SIGN_SIZE]); void lscapi_sign_string_sha1(lscapi_rec *lscapi, const char *to_sign, const uint8_t salt[LSCAPI_SALT_SIZE], uint8_t sign[LSCAPI_SHA1_SIGN_SIZE]); void lscapi_encode_bytes(const uint8_t *bytes, size_t len, char *buf); void lscapi_encode_sha1_sign_without_salt(const uint8_t sign[LSCAPI_SHA1_SIGN_SIZE], char *buf); pid_t lscapi_spawn_backend(spawn_info_t *spawn_info, const spawn_context_t *spawn_context); /* LSAPI_PRO_ONLY:BEGIN */ #ifdef WITH_CRIU void lscapi_set_criu_socket_path(lscapi_rec *lscapi, char *criu_socket_path); void lscapi_set_criu_imgs_dir_path(lscapi_rec *lscapi, char *criu_imgs_dir_path); pid_t lscapi_restore(spawn_info_t *spawn_info); int lscapi_prepare_dump(spawn_info_t *spawn_info); int lscapi_finish_prepare_dump(spawn_info_t *spawn_info, pid_t pid); int lscapi_dump(spawn_info_t *spawn_info); int lscapi_prepare_me(void); int lscapi_dump_me(void); void set_spawn_info_criu_opts(spawn_info_t *spawn_info, char *criu_socket_name, char *criu_images_dir, unsigned criu_backend_initial_start, unsigned use_criu, unsigned use_criu_debug, unsigned use_criu_signals); #endif //WITH_CRIU /* LSAPI_PRO_ONLY:END */ #define LSCAPI_PROC_CREATE_EXPORTED pid_t lscapi_proc_create(const char * const *args, const char * const *env ); /* #define PROFILE_ENABLED #ifndef PROFILE_LOG #define PROFILE_LOG #endif */ #ifdef PROFILE_ENABLED #include <sys/time.h> #include <sys/resource.h> extern __thread int PROFILE_counter; extern char *PROFILE_margins[]; #ifdef PROFILE_LOG #define PROFILE_START(pr) \ static __thread struct timeval pr##_U##__LINE__, pr##_S##__LINE__; \ static __thread int32_t pr##_CUMU##__LINE__, pr##_CUMS##__LINE__; \ static __thread int pr##_CNT##__LINE__; \ static __thread int pr##_ENTERED##__LINE__; \ do { \ struct rusage ruse; \ getrusage(RUSAGE_THREAD, &ruse); \ pr##_U##__LINE__ = ruse.ru_utime; \ pr##_S##__LINE__ = ruse.ru_stime; \ (pr##_CNT##__LINE__)++; \ if(!((pr##_CNT##__LINE__) % 100)) { \ fprintf(stderr, "%s%s.%d: " #pr ": ENTER\n", \ PROFILE_margins[PROFILE_counter], __FUNCTION__, __LINE__ ); \ PROFILE_counter++; \ pr##_ENTERED##__LINE__ = 1; \ } \ } while(0) #define PROFILE_STOP(pr) do { \ struct rusage ruse; \ struct timeval res_utime, res_stime; \ getrusage(RUSAGE_THREAD, &ruse); \ timersub(&ruse.ru_utime, &(pr##_U##__LINE__), &res_utime); \ timersub(&ruse.ru_stime, &(pr##_S##__LINE__), &res_stime); \ pr##_CUMU##__LINE__ += res_utime.tv_sec * 1000000 + res_utime.tv_usec; \ pr##_CUMS##__LINE__ += res_stime.tv_sec * 1000000 + res_stime.tv_usec; \ if(pr##_ENTERED##__LINE__) { \ pr##_ENTERED##__LINE__ = 0; \ PROFILE_counter--; \ double u = pr##_CUMU##__LINE__; u /= pr##_CNT##__LINE__; \ double s = pr##_CUMS##__LINE__; s /= pr##_CNT##__LINE__; \ fprintf(stderr, "%s%s.%d: " #pr ": u:%g; s:%g; cnt %d\n", \ PROFILE_margins[PROFILE_counter], __FUNCTION__, __LINE__, u, s, pr##_CNT##__LINE__ ); \ } \ } while(0) #else // PROFILE_LOG #define PROFILE_START(pr) #define PROFILE_STOP(pr) #endif // PROFILE_LOG #else // PROFILE_ENABLED #define PROFILE_START(pr) #define PROFILE_STOP(pr) #ifdef __clang__ #define ENVIRONMENT __environ #else #define ENVIRONMENT environ #endif #endif // PROFILE_ENABLED #endif // _LSCAPI_H_ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_core.h * @brief mod_core private header file * * @defgroup MOD_CORE mod_core * @ingroup APACHE_MODS * @{ */ #ifndef MOD_CORE_H #define MOD_CORE_H #include "apr.h" #include "apr_buckets.h" #include "httpd.h" #include "util_filter.h" #ifdef __cplusplus extern "C" { #endif /* Handles for core filters */ AP_DECLARE_DATA extern ap_filter_rec_t *ap_http_input_filter_handle; AP_DECLARE_DATA extern ap_filter_rec_t *ap_http_header_filter_handle; AP_DECLARE_DATA extern ap_filter_rec_t *ap_chunk_filter_handle; AP_DECLARE_DATA extern ap_filter_rec_t *ap_http_outerror_filter_handle; AP_DECLARE_DATA extern ap_filter_rec_t *ap_byterange_filter_handle; /* * These (input) filters are internal to the mod_core operation. */ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes); /* HTTP/1.1 chunked transfer encoding filter. */ apr_status_t ap_http_chunk_filter(ap_filter_t *f, apr_bucket_brigade *b); /* Filter to handle any error buckets on output */ apr_status_t ap_http_outerror_filter(ap_filter_t *f, apr_bucket_brigade *b); char *ap_response_code_string(request_rec *r, int error_index); /** * Send the minimal part of an HTTP response header. * @param r The current request * @param bb The brigade to add the header to. * @warning Modules should be very careful about using this, and should * the default behavior. Much of the HTTP/1.1 implementation * correctness depends on the full headers. * @fn void ap_basic_http_header(request_rec *r, apr_bucket_brigade *bb) */ AP_DECLARE(void) ap_basic_http_header(request_rec *r, apr_bucket_brigade *bb); /** * Send an appropriate response to an http TRACE request. * @param r The current request * @note returns DONE or the HTTP status error if it handles the TRACE, * or DECLINED if the request was not for TRACE. * request method was not TRACE. */ AP_DECLARE_NONSTD(int) ap_send_http_trace(request_rec *r); /** * Send an appropriate response to an http OPTIONS request. * @param r The current request */ AP_DECLARE(int) ap_send_http_options(request_rec *r); /* Used for multipart/byteranges boundary string */ AP_DECLARE_DATA extern const char *ap_multipart_boundary; /* Init RNG at startup */ AP_CORE_DECLARE(void) ap_init_rng(apr_pool_t *p); /* Update RNG state in parent after fork */ AP_CORE_DECLARE(void) ap_random_parent_after_fork(void); #ifdef __cplusplus } #endif #endif /* !MOD_CORE_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file ap_expr.h * @brief Expression parser * * @defgroup AP_EXPR Expression parser * @ingroup APACHE_CORE * @{ */ #ifndef AP_EXPR_H #define AP_EXPR_H #include "httpd.h" #include "http_config.h" #include "ap_regex.h" #ifdef __cplusplus extern "C" { #endif /** A node in the expression parse tree */ typedef struct ap_expr_node ap_expr_t; /** Struct describing a parsed expression */ typedef struct { /** The root of the actual expression parse tree */ ap_expr_t *root_node; /** The filename where the expression has been defined (for logging). * May be NULL */ const char *filename; /** The line number where the expression has been defined (for logging). */ unsigned int line_number; /** Flags relevant for the expression, see AP_EXPR_FLAG_* */ unsigned int flags; /** The module that is used for loglevel configuration */ int module_index; } ap_expr_info_t; /** Use ssl_expr compatibility mode (changes the meaning of the comparison * operators) */ #define AP_EXPR_FLAG_SSL_EXPR_COMPAT 1 /** Don't add significant request headers to the Vary response header */ #define AP_EXPR_FLAG_DONT_VARY 2 /** Don't allow functions/vars that bypass the current request's access * restrictions or would otherwise leak confidential information. * Used by e.g. mod_include. */ #define AP_EXPR_FLAG_RESTRICTED 4 /** Expression evaluates to a string, not to a bool */ #define AP_EXPR_FLAG_STRING_RESULT 8 /** Don't allow functions/vars that expose content from the filesystem. */ #define AP_EXPR_FLAG_RESTRICTED_FILE_FUNC 16 /** * Evaluate a parse tree, simple interface * @param r The current request * @param expr The expression to be evaluated * @param err Where an error message should be stored * @return > 0 if expression evaluates to true, == 0 if false, < 0 on error * @note err will be set to NULL on success, or to an error message on error * @note request headers used during evaluation will be added to the Vary: * response header, unless ::AP_EXPR_FLAG_DONT_VARY is set. */ AP_DECLARE(int) ap_expr_exec(request_rec *r, const ap_expr_info_t *expr, const char **err); /** * Evaluate a parse tree, with access to regexp backreference * @param r The current request * @param expr The expression to be evaluated * @param nmatch size of the regex match vector pmatch * @param pmatch information about regex matches * @param source the string that pmatch applies to * @param err Where an error message should be stored * @return > 0 if expression evaluates to true, == 0 if false, < 0 on error * @note err will be set to NULL on success, or to an error message on error * @note nmatch/pmatch/source can be used both to make previous matches * available to ap_expr_exec_re and to use ap_expr_exec_re's matches * later on. * @note request headers used during evaluation will be added to the Vary: * response header, unless ::AP_EXPR_FLAG_DONT_VARY is set. */ AP_DECLARE(int) ap_expr_exec_re(request_rec *r, const ap_expr_info_t *expr, apr_size_t nmatch, ap_regmatch_t *pmatch, const char **source, const char **err); /** Context used during evaluation of a parse tree, created by ap_expr_exec */ typedef struct { /** the current request */ request_rec *r; /** the current connection */ conn_rec *c; /** the current virtual host */ server_rec *s; /** the pool to use */ apr_pool_t *p; /** where to store the error string */ const char **err; /** ap_expr_info_t for the expression */ const ap_expr_info_t *info; /** regex match information for back references */ ap_regmatch_t *re_pmatch; /** size of the vector pointed to by re_pmatch */ apr_size_t re_nmatch; /** the string corresponding to the re_pmatch */ const char **re_source; /** A string where the comma separated names of headers are stored * to be later added to the Vary: header. If NULL, the caller is not * interested in this information. */ const char **vary_this; /** where to store the result string */ const char **result_string; /** Arbitrary context data provided by the caller for custom functions */ void *data; /** The current recursion level */ int reclvl; } ap_expr_eval_ctx_t; /** * Evaluate a parse tree, full featured version * @param ctx The evaluation context with all data filled in * @return > 0 if expression evaluates to true, == 0 if false, < 0 on error * @note *ctx->err will be set to NULL on success, or to an error message on * error * @note request headers used during evaluation will be added to the Vary: * response header if ctx->vary_this is set. */ AP_DECLARE(int) ap_expr_exec_ctx(ap_expr_eval_ctx_t *ctx); /** * Evaluate a parse tree of a string valued expression * @param r The current request * @param expr The expression to be evaluated * @param err Where an error message should be stored * @return The result string, NULL on error * @note err will be set to NULL on success, or to an error message on error * @note request headers used during evaluation will be added to the Vary: * response header, unless ::AP_EXPR_FLAG_DONT_VARY is set. */ AP_DECLARE(const char *) ap_expr_str_exec(request_rec *r, const ap_expr_info_t *expr, const char **err); /** * Evaluate a parse tree of a string valued expression * @param r The current request * @param expr The expression to be evaluated * @param nmatch size of the regex match vector pmatch * @param pmatch information about regex matches * @param source the string that pmatch applies to * @param err Where an error message should be stored * @return The result string, NULL on error * @note err will be set to NULL on success, or to an error message on error * @note nmatch/pmatch/source can be used both to make previous matches * available to ap_expr_exec_re and to use ap_expr_exec_re's matches * later on. * @note request headers used during evaluation will be added to the Vary: * response header, unless ::AP_EXPR_FLAG_DONT_VARY is set. */ AP_DECLARE(const char *) ap_expr_str_exec_re(request_rec *r, const ap_expr_info_t *expr, apr_size_t nmatch, ap_regmatch_t *pmatch, const char **source, const char **err); /** * The parser can be extended with variable lookup, functions, and * and operators. * * During parsing, the parser calls the lookup function to resolve a * name into a function pointer and an opaque context for the function. * If the argument to a function or operator is constant, the lookup function * may also parse that argument and store the parsed data in the context. * * The default lookup function is the hook ::ap_expr_lookup_default which just * calls ap_run_expr_lookup. Modules can use it to make functions and * variables generally available. * * An ap_expr consumer can also provide its own custom lookup function to * modify the set of variables and functions that are available. The custom * lookup function can in turn call 'ap_run_expr_lookup'. */ /** Unary operator, takes one string argument and returns a bool value. * The name must have the form '-z' (one letter only). * @param ctx The evaluation context * @param data An opaque context provided by the lookup hook function * @param arg The (right) operand * @return 0 or 1 */ typedef int ap_expr_op_unary_t(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg); /** Binary operator, takes two string arguments and returns a bool value. * The name must have the form '-cmp' (at least two letters). * @param ctx The evaluation context * @param data An opaque context provided by the lookup hook function * @param arg1 The left operand * @param arg2 The right operand * @return 0 or 1 */ typedef int ap_expr_op_binary_t(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg1, const char *arg2); /** String valued function, takes a string argument and returns a string * @param ctx The evaluation context * @param data An opaque context provided by the lookup hook function * @param arg The argument * @return The functions result string, may be NULL for 'empty string' */ typedef const char *(ap_expr_string_func_t)(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg); /** List valued function, takes a string argument and returns a list of strings * Can currently only be called following the builtin '-in' operator. * @param ctx The evaluation context * @param data An opaque context provided by the lookup hook function * @param arg The argument * @return The functions result list of strings, may be NULL for 'empty array' */ typedef apr_array_header_t *(ap_expr_list_func_t)(ap_expr_eval_ctx_t *ctx, const void *data, const char *arg); /** Variable lookup function, takes no argument and returns a string * @param ctx The evaluation context * @param data An opaque context provided by the lookup hook function * @return The expanded variable */ typedef const char *(ap_expr_var_func_t)(ap_expr_eval_ctx_t *ctx, const void *data); /** parameter struct passed to the lookup hook functions */ typedef struct { /** type of the looked up object */ int type; #define AP_EXPR_FUNC_VAR 0 #define AP_EXPR_FUNC_STRING 1 #define AP_EXPR_FUNC_LIST 2 #define AP_EXPR_FUNC_OP_UNARY 3 #define AP_EXPR_FUNC_OP_BINARY 4 /** name of the looked up object */ const char *name; int flags; apr_pool_t *pool; apr_pool_t *ptemp; /** where to store the function pointer */ const void **func; /** where to store the function's context */ const void **data; /** where to store the error message (if any) */ const char **err; /** arg for pre-parsing (only if a simple string). * For binary ops, this is the right argument. */ const char *arg; } ap_expr_lookup_parms; /** Function for looking up the provider function for a variable, operator * or function in an expression. * @param parms The parameter struct, also determines where the result is * stored. * @return OK on success, * !OK on failure, * DECLINED if the requested name is not handled by this function */ typedef int (ap_expr_lookup_fn_t)(ap_expr_lookup_parms *parms); /** Default lookup function which just calls ap_run_expr_lookup(). * ap_run_expr_lookup cannot be used directly because it has the wrong * calling convention under Windows. */ AP_DECLARE_NONSTD(int) ap_expr_lookup_default(ap_expr_lookup_parms *parms); AP_DECLARE_HOOK(int, expr_lookup, (ap_expr_lookup_parms *parms)) /** * Parse an expression into a parse tree * @param pool Pool * @param ptemp temp pool * @param info The ap_expr_info_t struct (with values filled in) * @param expr The expression string to parse * @param lookup_fn The lookup function to use, NULL for default * @return NULL on success, error message on error. * A pointer to the resulting parse tree will be stored in * info->root_node. */ AP_DECLARE(const char *) ap_expr_parse(apr_pool_t *pool, apr_pool_t *ptemp, ap_expr_info_t *info, const char *expr, ap_expr_lookup_fn_t *lookup_fn); /** * High level interface to ap_expr_parse that also creates ap_expr_info_t and * uses info from cmd_parms to fill in most of it. * @param cmd The cmd_parms struct * @param expr The expression string to parse * @param flags The flags to use, see AP_EXPR_FLAG_* * @param err Set to NULL on success, error message on error * @param lookup_fn The lookup function used to lookup vars, functions, and * operators * @param module_index The module_index to set for the expression * @return The parsed expression * @note Usually ap_expr_parse_cmd() should be used */ AP_DECLARE(ap_expr_info_t *) ap_expr_parse_cmd_mi(const cmd_parms *cmd, const char *expr, unsigned int flags, const char **err, ap_expr_lookup_fn_t *lookup_fn, int module_index); /** * Convenience wrapper for ap_expr_parse_cmd_mi() that sets * module_index = APLOG_MODULE_INDEX */ #define ap_expr_parse_cmd(cmd, expr, flags, err, lookup_fn) \ ap_expr_parse_cmd_mi(cmd, expr, flags, err, lookup_fn, APLOG_MODULE_INDEX) /** * Internal initialisation of ap_expr (for httpd internal use) */ void ap_expr_init(apr_pool_t *pool); #ifdef __cplusplus } #endif #endif /* AP_EXPR_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file ap_socache.h * @brief Small object cache provider interface. * * @defgroup AP_SOCACHE ap_socache * @ingroup APACHE_MODS * @{ */ #ifndef AP_SOCACHE_H #define AP_SOCACHE_H #include "httpd.h" #include "ap_provider.h" #include "apr_pools.h" #include "apr_time.h" #ifdef __cplusplus extern "C" { #endif /** If this flag is set, the store/retrieve/remove/status interfaces * of the provider are NOT safe to be called concurrently from * multiple processes or threads, and an external global mutex must be * used to serialize access to the provider. */ /* XXX: Even if store/retrieve/remove is atomic, isn't it useful to note * independently that status and iterate may or may not be? */ #define AP_SOCACHE_FLAG_NOTMPSAFE (0x0001) /** A cache instance. */ typedef struct ap_socache_instance_t ap_socache_instance_t; /** Hints which may be passed to the init function; providers may * ignore some or all of these hints. */ struct ap_socache_hints { /** Approximate average length of IDs: */ apr_size_t avg_id_len; /** Approximate average size of objects: */ apr_size_t avg_obj_size; /** Suggested interval between expiry cleanup runs; */ apr_interval_time_t expiry_interval; }; /** * Iterator callback prototype for the ap_socache_provider_t->iterate() method * @param instance The cache instance * @param s Associated server context (for logging) * @param userctx User defined pointer passed from the iterator call * @param id Unique ID for the object (binary blob) * with a trailing null char for convenience * @param idlen Length of id blob * @param data Output buffer to place retrieved data (binary blob) * with a trailing null char for convenience * @param datalen Length of data buffer * @param pool Pool for temporary allocations * @return APR status value; return APR_SUCCESS or the iteration will halt; * this value is returned to the ap_socache_provider_t->iterate() caller */ typedef apr_status_t (ap_socache_iterator_t)(ap_socache_instance_t *instance, server_rec *s, void *userctx, const unsigned char *id, unsigned int idlen, const unsigned char *data, unsigned int datalen, apr_pool_t *pool); /** A socache provider structure. socache providers are registered * with the ap_provider.h interface using the AP_SOCACHE_PROVIDER_* * constants. */ typedef struct ap_socache_provider_t { /** Canonical provider name. */ const char *name; /** Bitmask of AP_SOCACHE_FLAG_* flags. */ unsigned int flags; /** * Create a small object cache based on the given configuration * string. The instance pointer returned in the instance * parameter will be passed as the first argument to subsequent * invocations. * * @param instance Output parameter to which instance object is written. * @param arg User-specified configuration string. May be NULL to * force use of defaults. * @param tmp Pool to be used for any temporary allocations * @param p Pool to be use for any allocations lasting as long as * the created instance * @return NULL on success, or an error string on failure. */ const char *(*create)(ap_socache_instance_t **instance, const char *arg, apr_pool_t *tmp, apr_pool_t *p); /** * Initialize the cache. The cname must be of maximum length 16 * characters, and uniquely identifies the consumer of the cache * within the server; using the module name is recommended, e.g. * "mod_ssl-sess". This string may be used within a filesystem * path so use of only alphanumeric [a-z0-9_-] characters is * recommended. If hints is non-NULL, it gives a set of hints for * the provider. Returns APR error code. * * @param instance The cache instance * @param cname A unique string identifying the consumer of this API * @param hints Optional hints argument describing expected cache use * @param s Server structure to which the cache is associated * @param pool Pool for long-lived allocations * @return APR status value indicating success. */ apr_status_t (*init)(ap_socache_instance_t *instance, const char *cname, const struct ap_socache_hints *hints, server_rec *s, apr_pool_t *pool); /** * Destroy a given cache instance object. * @param instance The cache instance to destroy. * @param s Associated server structure (for logging purposes) */ void (*destroy)(ap_socache_instance_t *instance, server_rec *s); /** * Store an object in a cache instance. * @param instance The cache instance * @param s Associated server structure (for logging purposes) * @param id Unique ID for the object; binary blob * @param idlen Length of id blob * @param expiry Absolute time at which the object expires * @param data Data to store; binary blob * @param datalen Length of data blob * @param pool Pool for temporary allocations. * @return APR status value. */ apr_status_t (*store)(ap_socache_instance_t *instance, server_rec *s, const unsigned char *id, unsigned int idlen, apr_time_t expiry, unsigned char *data, unsigned int datalen, apr_pool_t *pool); /** * Retrieve a cached object. * * @param instance The cache instance * @param s Associated server structure (for logging purposes) * @param id Unique ID for the object; binary blob * @param idlen Length of id blob * @param data Output buffer to place retrievd data (binary blob) * @param datalen On entry, length of data buffer; on exit, the * number of bytes written to the data buffer. * @param pool Pool for temporary allocations. * @return APR status value; APR_NOTFOUND if the object was not * found */ apr_status_t (*retrieve)(ap_socache_instance_t *instance, server_rec *s, const unsigned char *id, unsigned int idlen, unsigned char *data, unsigned int *datalen, apr_pool_t *pool); /** * Remove an object from the cache * * @param instance The cache instance * @param s Associated server structure (for logging purposes) * @param id Unique ID for the object; binary blob * @param idlen Length of id blob * @param pool Pool for temporary allocations. */ apr_status_t (*remove)(ap_socache_instance_t *instance, server_rec *s, const unsigned char *id, unsigned int idlen, apr_pool_t *pool); /** * Dump the status of a cache instance for mod_status. Will use * the ap_r* interfaces to produce appropriate status output. * XXX: ap_r* are deprecated, bad dogfood * * @param instance The cache instance * @param r The request structure * @param flags The AP_STATUS_* constants used (see mod_status.h) */ void (*status)(ap_socache_instance_t *instance, request_rec *r, int flags); /** * Dump all cached objects through an iterator callback. * @param instance The cache instance * @param s Associated server context (for processing and logging) * @param userctx User defined pointer passed through to the iterator * @param iterator The user provided callback function which will receive * individual calls for each unexpired id/data pair * @param pool Pool for temporary allocations. * @return APR status value; APR_NOTFOUND if the object was not * found */ apr_status_t (*iterate)(ap_socache_instance_t *instance, server_rec *s, void *userctx, ap_socache_iterator_t *iterator, apr_pool_t *pool); } ap_socache_provider_t; /** The provider group used to register socache providers. */ #define AP_SOCACHE_PROVIDER_GROUP "socache" /** The provider version used to register socache providers. */ #define AP_SOCACHE_PROVIDER_VERSION "0" /** Default provider name. */ #define AP_SOCACHE_DEFAULT_PROVIDER "default" #ifdef __cplusplus } #endif #endif /* AP_SOCACHE_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file ap_config_layout.h * @brief Apache Config Layout */ #ifndef AP_CONFIG_LAYOUT_H #define AP_CONFIG_LAYOUT_H /* Configured Apache directory layout */ #define DEFAULT_PREFIX "/etc/apache2" #define DEFAULT_EXP_EXEC_PREFIX "/usr" #define DEFAULT_REL_EXEC_PREFIX "/usr" #define DEFAULT_EXP_BINDIR "/usr/bin" #define DEFAULT_REL_BINDIR "/usr/bin" #define DEFAULT_EXP_SBINDIR "/usr/sbin" #define DEFAULT_REL_SBINDIR "/usr/sbin" #define DEFAULT_EXP_MANDIR "/usr/share/man" #define DEFAULT_REL_MANDIR "/usr/share/man" #define DEFAULT_EXP_SYSCONFDIR "/etc/apache2/conf" #define DEFAULT_REL_SYSCONFDIR "conf" #define DEFAULT_EXP_DATADIR "/usr/share/apache2" #define DEFAULT_REL_DATADIR "/usr/share/apache2" #define DEFAULT_EXP_ERRORDIR "/usr/share/apache2/error" #define DEFAULT_REL_ERRORDIR "/usr/share/apache2/error" #define DEFAULT_EXP_ICONSDIR "/usr/share/apache2/icons" #define DEFAULT_REL_ICONSDIR "/usr/share/apache2/icons" #define DEFAULT_EXP_HTDOCSDIR "/var/www/html" #define DEFAULT_REL_HTDOCSDIR "/var/www/html" #define DEFAULT_EXP_MANUALDIR "/usr/share/apache2/manual" #define DEFAULT_REL_MANUALDIR "/usr/share/apache2/manual" #define DEFAULT_EXP_CGIDIR "/var/www/cgi-bin" #define DEFAULT_REL_CGIDIR "/var/www/cgi-bin" #define DEFAULT_EXP_INCLUDEDIR "/usr/include/apache2" #define DEFAULT_REL_INCLUDEDIR "/usr/include/apache2" #define DEFAULT_EXP_LOCALSTATEDIR "/var" #define DEFAULT_REL_LOCALSTATEDIR "/var" #define DEFAULT_EXP_RUNTIMEDIR "/var/run/apache2" #define DEFAULT_REL_RUNTIMEDIR "/var/run/apache2" #define DEFAULT_EXP_LOGFILEDIR "/var/log/apache2" #define DEFAULT_REL_LOGFILEDIR "/var/log/apache2" #define DEFAULT_EXP_PROXYCACHEDIR "/var/cache/apache2/proxy" #define DEFAULT_REL_PROXYCACHEDIR "/var/cache/apache2/proxy" #endif /* AP_CONFIG_LAYOUT_H */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file cache_common.h * @brief Common Cache structs * * @defgroup Cache_cache Cache Functions * @ingroup MOD_CACHE * @{ */ #ifndef CACHE_COMMON_H #define CACHE_COMMON_H /* a cache control header breakdown */ typedef struct cache_control { unsigned int parsed:1; unsigned int cache_control:1; unsigned int pragma:1; unsigned int no_cache:1; unsigned int no_cache_header:1; /* no cache by header match */ unsigned int no_store:1; unsigned int max_age:1; unsigned int max_stale:1; unsigned int min_fresh:1; unsigned int no_transform:1; unsigned int only_if_cached:1; unsigned int public:1; unsigned int private:1; unsigned int private_header:1; /* private by header match */ unsigned int must_revalidate:1; unsigned int proxy_revalidate:1; unsigned int s_maxage:1; unsigned int invalidated:1; /* has this entity been invalidated? */ apr_int64_t max_age_value; /* if positive, then set */ apr_int64_t max_stale_value; /* if positive, then set */ apr_int64_t min_fresh_value; /* if positive, then set */ apr_int64_t s_maxage_value; /* if positive, then set */ } cache_control_t; #endif /* CACHE_COMMON_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _APACHE_NOPROBES_H_ #define _APACHE_NOPROBES_H_ #define AP_ACCESS_CHECKER_DISPATCH_COMPLETE(arg0, arg1) #define AP_ACCESS_CHECKER_DISPATCH_COMPLETE_ENABLED() (0) #define AP_ACCESS_CHECKER_DISPATCH_INVOKE(arg0) #define AP_ACCESS_CHECKER_DISPATCH_INVOKE_ENABLED() (0) #define AP_ACCESS_CHECKER_ENTRY() #define AP_ACCESS_CHECKER_ENTRY_ENABLED() (0) #define AP_ACCESS_CHECKER_RETURN(arg0) #define AP_ACCESS_CHECKER_RETURN_ENABLED() (0) #define AP_AUTH_CHECKER_DISPATCH_COMPLETE(arg0, arg1) #define AP_AUTH_CHECKER_DISPATCH_COMPLETE_ENABLED() (0) #define AP_AUTH_CHECKER_DISPATCH_INVOKE(arg0) #define AP_AUTH_CHECKER_DISPATCH_INVOKE_ENABLED() (0) #define AP_AUTH_CHECKER_ENTRY() #define AP_AUTH_CHECKER_ENTRY_ENABLED() (0) #define AP_AUTH_CHECKER_RETURN(arg0) #define AP_AUTH_CHECKER_RETURN_ENABLED() (0) #define AP_CANON_HANDLER_DISPATCH_COMPLETE(arg0, arg1) #define AP_CANON_HANDLER_DISPATCH_COMPLETE_ENABLED() (0) #define AP_CANON_HANDLER_DISPATCH_INVOKE(arg0) #define AP_CANON_HANDLER_DISPATCH_INVOKE_ENABLED() (0) #define AP_CANON_HANDLER_ENTRY() #define AP_CANON_HANDLER_ENTRY_ENABLED() (0) #define AP_CANON_HANDLER_RETURN(arg0) #define AP_CANON_HANDLER_RETURN_ENABLED() (0) #define AP_CHECK_USER_ID_DISPATCH_COMPLETE(arg0, arg1) #define AP_CHECK_USER_ID_DISPATCH_COMPLETE_ENABLED() (0) #define AP_CHECK_USER_ID_DISPATCH_INVOKE(arg0) #define AP_CHECK_USER_ID_DISPATCH_INVOKE_ENABLED() (0) #define AP_CHECK_USER_ID_ENTRY() #define AP_CHECK_USER_ID_ENTRY_ENABLED() (0) #define AP_CHECK_USER_ID_RETURN(arg0) #define AP_CHECK_USER_ID_RETURN_ENABLED() (0) #define AP_CHILD_INIT_DISPATCH_COMPLETE(arg0, arg1) #define AP_CHILD_INIT_DISPATCH_COMPLETE_ENABLED() (0) #define AP_CHILD_INIT_DISPATCH_INVOKE(arg0) #define AP_CHILD_INIT_DISPATCH_INVOKE_ENABLED() (0) #define AP_CHILD_INIT_ENTRY() #define AP_CHILD_INIT_ENTRY_ENABLED() (0) #define AP_CHILD_INIT_RETURN(arg0) #define AP_CHILD_INIT_RETURN_ENABLED() (0) #define AP_CREATE_CONNECTION_DISPATCH_COMPLETE(arg0, arg1) #define AP_CREATE_CONNECTION_DISPATCH_COMPLETE_ENABLED() (0) #define AP_CREATE_CONNECTION_DISPATCH_INVOKE(arg0) #define AP_CREATE_CONNECTION_DISPATCH_INVOKE_ENABLED() (0) #define AP_CREATE_CONNECTION_ENTRY() #define AP_CREATE_CONNECTION_ENTRY_ENABLED() (0) #define AP_CREATE_CONNECTION_RETURN(arg0) #define AP_CREATE_CONNECTION_RETURN_ENABLED() (0) #define AP_CREATE_REQUEST_DISPATCH_COMPLETE(arg0, arg1) #define AP_CREATE_REQUEST_DISPATCH_COMPLETE_ENABLED() (0) #define AP_CREATE_REQUEST_DISPATCH_INVOKE(arg0) #define AP_CREATE_REQUEST_DISPATCH_INVOKE_ENABLED() (0) #define AP_CREATE_REQUEST_ENTRY() #define AP_CREATE_REQUEST_ENTRY_ENABLED() (0) #define AP_CREATE_REQUEST_RETURN(arg0) #define AP_CREATE_REQUEST_RETURN_ENABLED() (0) #define AP_DEFAULT_PORT_DISPATCH_COMPLETE(arg0, arg1) #define AP_DEFAULT_PORT_DISPATCH_COMPLETE_ENABLED() (0) #define AP_DEFAULT_PORT_DISPATCH_INVOKE(arg0) #define AP_DEFAULT_PORT_DISPATCH_INVOKE_ENABLED() (0) #define AP_DEFAULT_PORT_ENTRY() #define AP_DEFAULT_PORT_ENTRY_ENABLED() (0) #define AP_DEFAULT_PORT_RETURN(arg0) #define AP_DEFAULT_PORT_RETURN_ENABLED() (0) #define AP_ERROR_LOG_DISPATCH_COMPLETE(arg0, arg1) #define AP_ERROR_LOG_DISPATCH_COMPLETE_ENABLED() (0) #define AP_ERROR_LOG_DISPATCH_INVOKE(arg0) #define AP_ERROR_LOG_DISPATCH_INVOKE_ENABLED() (0) #define AP_ERROR_LOG_ENTRY() #define AP_ERROR_LOG_ENTRY_ENABLED() (0) #define AP_ERROR_LOG_RETURN(arg0) #define AP_ERROR_LOG_RETURN_ENABLED() (0) #define AP_FIND_LIVEPROP_DISPATCH_COMPLETE(arg0, arg1) #define AP_FIND_LIVEPROP_DISPATCH_COMPLETE_ENABLED() (0) #define AP_FIND_LIVEPROP_DISPATCH_INVOKE(arg0) #define AP_FIND_LIVEPROP_DISPATCH_INVOKE_ENABLED() (0) #define AP_FIND_LIVEPROP_ENTRY() #define AP_FIND_LIVEPROP_ENTRY_ENABLED() (0) #define AP_FIND_LIVEPROP_RETURN(arg0) #define AP_FIND_LIVEPROP_RETURN_ENABLED() (0) #define AP_FIXUPS_DISPATCH_COMPLETE(arg0, arg1) #define AP_FIXUPS_DISPATCH_COMPLETE_ENABLED() (0) #define AP_FIXUPS_DISPATCH_INVOKE(arg0) #define AP_FIXUPS_DISPATCH_INVOKE_ENABLED() (0) #define AP_FIXUPS_ENTRY() #define AP_FIXUPS_ENTRY_ENABLED() (0) #define AP_FIXUPS_RETURN(arg0) #define AP_FIXUPS_RETURN_ENABLED() (0) #define AP_GATHER_PROPSETS_DISPATCH_COMPLETE(arg0, arg1) #define AP_GATHER_PROPSETS_DISPATCH_COMPLETE_ENABLED() (0) #define AP_GATHER_PROPSETS_DISPATCH_INVOKE(arg0) #define AP_GATHER_PROPSETS_DISPATCH_INVOKE_ENABLED() (0) #define AP_GATHER_PROPSETS_ENTRY() #define AP_GATHER_PROPSETS_ENTRY_ENABLED() (0) #define AP_GATHER_PROPSETS_RETURN(arg0) #define AP_GATHER_PROPSETS_RETURN_ENABLED() (0) #define AP_GET_MGMT_ITEMS_DISPATCH_COMPLETE(arg0, arg1) #define AP_GET_MGMT_ITEMS_DISPATCH_COMPLETE_ENABLED() (0) #define AP_GET_MGMT_ITEMS_DISPATCH_INVOKE(arg0) #define AP_GET_MGMT_ITEMS_DISPATCH_INVOKE_ENABLED() (0) #define AP_GET_MGMT_ITEMS_ENTRY() #define AP_GET_MGMT_ITEMS_ENTRY_ENABLED() (0) #define AP_GET_MGMT_ITEMS_RETURN(arg0) #define AP_GET_MGMT_ITEMS_RETURN_ENABLED() (0) #define AP_GET_SUEXEC_IDENTITY_DISPATCH_COMPLETE(arg0, arg1) #define AP_GET_SUEXEC_IDENTITY_DISPATCH_COMPLETE_ENABLED() (0) #define AP_GET_SUEXEC_IDENTITY_DISPATCH_INVOKE(arg0) #define AP_GET_SUEXEC_IDENTITY_DISPATCH_INVOKE_ENABLED() (0) #define AP_GET_SUEXEC_IDENTITY_ENTRY() #define AP_GET_SUEXEC_IDENTITY_ENTRY_ENABLED() (0) #define AP_GET_SUEXEC_IDENTITY_RETURN(arg0) #define AP_GET_SUEXEC_IDENTITY_RETURN_ENABLED() (0) #define AP_HANDLER_DISPATCH_COMPLETE(arg0, arg1) #define AP_HANDLER_DISPATCH_COMPLETE_ENABLED() (0) #define AP_HANDLER_DISPATCH_INVOKE(arg0) #define AP_HANDLER_DISPATCH_INVOKE_ENABLED() (0) #define AP_HANDLER_ENTRY() #define AP_HANDLER_ENTRY_ENABLED() (0) #define AP_HANDLER_RETURN(arg0) #define AP_HANDLER_RETURN_ENABLED() (0) #define AP_HEADER_PARSER_DISPATCH_COMPLETE(arg0, arg1) #define AP_HEADER_PARSER_DISPATCH_COMPLETE_ENABLED() (0) #define AP_HEADER_PARSER_DISPATCH_INVOKE(arg0) #define AP_HEADER_PARSER_DISPATCH_INVOKE_ENABLED() (0) #define AP_HEADER_PARSER_ENTRY() #define AP_HEADER_PARSER_ENTRY_ENABLED() (0) #define AP_HEADER_PARSER_RETURN(arg0) #define AP_HEADER_PARSER_RETURN_ENABLED() (0) #define AP_HTTP_SCHEME_DISPATCH_COMPLETE(arg0, arg1) #define AP_HTTP_SCHEME_DISPATCH_COMPLETE_ENABLED() (0) #define AP_HTTP_SCHEME_DISPATCH_INVOKE(arg0) #define AP_HTTP_SCHEME_DISPATCH_INVOKE_ENABLED() (0) #define AP_HTTP_SCHEME_ENTRY() #define AP_HTTP_SCHEME_ENTRY_ENABLED() (0) #define AP_HTTP_SCHEME_RETURN(arg0) #define AP_HTTP_SCHEME_RETURN_ENABLED() (0) #define AP_INSERT_ALL_LIVEPROPS_DISPATCH_COMPLETE(arg0, arg1) #define AP_INSERT_ALL_LIVEPROPS_DISPATCH_COMPLETE_ENABLED() (0) #define AP_INSERT_ALL_LIVEPROPS_DISPATCH_INVOKE(arg0) #define AP_INSERT_ALL_LIVEPROPS_DISPATCH_INVOKE_ENABLED() (0) #define AP_INSERT_ALL_LIVEPROPS_ENTRY() #define AP_INSERT_ALL_LIVEPROPS_ENTRY_ENABLED() (0) #define AP_INSERT_ALL_LIVEPROPS_RETURN(arg0) #define AP_INSERT_ALL_LIVEPROPS_RETURN_ENABLED() (0) #define AP_INSERT_ERROR_FILTER_DISPATCH_COMPLETE(arg0, arg1) #define AP_INSERT_ERROR_FILTER_DISPATCH_COMPLETE_ENABLED() (0) #define AP_INSERT_ERROR_FILTER_DISPATCH_INVOKE(arg0) #define AP_INSERT_ERROR_FILTER_DISPATCH_INVOKE_ENABLED() (0) #define AP_INSERT_ERROR_FILTER_ENTRY() #define AP_INSERT_ERROR_FILTER_ENTRY_ENABLED() (0) #define AP_INSERT_ERROR_FILTER_RETURN(arg0) #define AP_INSERT_ERROR_FILTER_RETURN_ENABLED() (0) #define AP_INSERT_FILTER_DISPATCH_COMPLETE(arg0, arg1) #define AP_INSERT_FILTER_DISPATCH_COMPLETE_ENABLED() (0) #define AP_INSERT_FILTER_DISPATCH_INVOKE(arg0) #define AP_INSERT_FILTER_DISPATCH_INVOKE_ENABLED() (0) #define AP_INSERT_FILTER_ENTRY() #define AP_INSERT_FILTER_ENTRY_ENABLED() (0) #define AP_INSERT_FILTER_RETURN(arg0) #define AP_INSERT_FILTER_RETURN_ENABLED() (0) #define AP_INTERNAL_REDIRECT(arg0, arg1) #define AP_INTERNAL_REDIRECT_ENABLED() (0) #define AP_LOG_TRANSACTION_DISPATCH_COMPLETE(arg0, arg1) #define AP_LOG_TRANSACTION_DISPATCH_COMPLETE_ENABLED() (0) #define AP_LOG_TRANSACTION_DISPATCH_INVOKE(arg0) #define AP_LOG_TRANSACTION_DISPATCH_INVOKE_ENABLED() (0) #define AP_LOG_TRANSACTION_ENTRY() #define AP_LOG_TRANSACTION_ENTRY_ENABLED() (0) #define AP_LOG_TRANSACTION_RETURN(arg0) #define AP_LOG_TRANSACTION_RETURN_ENABLED() (0) #define AP_MAP_TO_STORAGE_DISPATCH_COMPLETE(arg0, arg1) #define AP_MAP_TO_STORAGE_DISPATCH_COMPLETE_ENABLED() (0) #define AP_MAP_TO_STORAGE_DISPATCH_INVOKE(arg0) #define AP_MAP_TO_STORAGE_DISPATCH_INVOKE_ENABLED() (0) #define AP_MAP_TO_STORAGE_ENTRY() #define AP_MAP_TO_STORAGE_ENTRY_ENABLED() (0) #define AP_MAP_TO_STORAGE_RETURN(arg0) #define AP_MAP_TO_STORAGE_RETURN_ENABLED() (0) #define AP_MONITOR_DISPATCH_COMPLETE(arg0, arg1) #define AP_MONITOR_DISPATCH_COMPLETE_ENABLED() (0) #define AP_MONITOR_DISPATCH_INVOKE(arg0) #define AP_MONITOR_DISPATCH_INVOKE_ENABLED() (0) #define AP_MONITOR_ENTRY() #define AP_MONITOR_ENTRY_ENABLED() (0) #define AP_MONITOR_RETURN(arg0) #define AP_MONITOR_RETURN_ENABLED() (0) #define AP_OPEN_LOGS_DISPATCH_COMPLETE(arg0, arg1) #define AP_OPEN_LOGS_DISPATCH_COMPLETE_ENABLED() (0) #define AP_OPEN_LOGS_DISPATCH_INVOKE(arg0) #define AP_OPEN_LOGS_DISPATCH_INVOKE_ENABLED() (0) #define AP_OPEN_LOGS_ENTRY() #define AP_OPEN_LOGS_ENTRY_ENABLED() (0) #define AP_OPEN_LOGS_RETURN(arg0) #define AP_OPEN_LOGS_RETURN_ENABLED() (0) #define AP_OPTIONAL_FN_RETRIEVE_DISPATCH_COMPLETE(arg0, arg1) #define AP_OPTIONAL_FN_RETRIEVE_DISPATCH_COMPLETE_ENABLED() (0) #define AP_OPTIONAL_FN_RETRIEVE_DISPATCH_INVOKE(arg0) #define AP_OPTIONAL_FN_RETRIEVE_DISPATCH_INVOKE_ENABLED() (0) #define AP_OPTIONAL_FN_RETRIEVE_ENTRY() #define AP_OPTIONAL_FN_RETRIEVE_ENTRY_ENABLED() (0) #define AP_OPTIONAL_FN_RETRIEVE_RETURN(arg0) #define AP_OPTIONAL_FN_RETRIEVE_RETURN_ENABLED() (0) #define AP_POST_CONFIG_DISPATCH_COMPLETE(arg0, arg1) #define AP_POST_CONFIG_DISPATCH_COMPLETE_ENABLED() (0) #define AP_POST_CONFIG_DISPATCH_INVOKE(arg0) #define AP_POST_CONFIG_DISPATCH_INVOKE_ENABLED() (0) #define AP_POST_CONFIG_ENTRY() #define AP_POST_CONFIG_ENTRY_ENABLED() (0) #define AP_POST_CONFIG_RETURN(arg0) #define AP_POST_CONFIG_RETURN_ENABLED() (0) #define AP_POST_READ_REQUEST_DISPATCH_COMPLETE(arg0, arg1) #define AP_POST_READ_REQUEST_DISPATCH_COMPLETE_ENABLED() (0) #define AP_POST_READ_REQUEST_DISPATCH_INVOKE(arg0) #define AP_POST_READ_REQUEST_DISPATCH_INVOKE_ENABLED() (0) #define AP_POST_READ_REQUEST_ENTRY() #define AP_POST_READ_REQUEST_ENTRY_ENABLED() (0) #define AP_POST_READ_REQUEST_RETURN(arg0) #define AP_POST_READ_REQUEST_RETURN_ENABLED() (0) #define AP_POST_REQUEST_DISPATCH_COMPLETE(arg0, arg1) #define AP_POST_REQUEST_DISPATCH_COMPLETE_ENABLED() (0) #define AP_POST_REQUEST_DISPATCH_INVOKE(arg0) #define AP_POST_REQUEST_DISPATCH_INVOKE_ENABLED() (0) #define AP_POST_REQUEST_ENTRY() #define AP_POST_REQUEST_ENTRY_ENABLED() (0) #define AP_POST_REQUEST_RETURN(arg0) #define AP_POST_REQUEST_RETURN_ENABLED() (0) #define AP_PRE_CONFIG_DISPATCH_COMPLETE(arg0, arg1) #define AP_PRE_CONFIG_DISPATCH_COMPLETE_ENABLED() (0) #define AP_PRE_CONFIG_DISPATCH_INVOKE(arg0) #define AP_PRE_CONFIG_DISPATCH_INVOKE_ENABLED() (0) #define AP_PRE_CONFIG_ENTRY() #define AP_PRE_CONFIG_ENTRY_ENABLED() (0) #define AP_PRE_CONFIG_RETURN(arg0) #define AP_PRE_CONFIG_RETURN_ENABLED() (0) #define AP_PRE_CONNECTION_DISPATCH_COMPLETE(arg0, arg1) #define AP_PRE_CONNECTION_DISPATCH_COMPLETE_ENABLED() (0) #define AP_PRE_CONNECTION_DISPATCH_INVOKE(arg0) #define AP_PRE_CONNECTION_DISPATCH_INVOKE_ENABLED() (0) #define AP_PRE_CONNECTION_ENTRY() #define AP_PRE_CONNECTION_ENTRY_ENABLED() (0) #define AP_PRE_CONNECTION_RETURN(arg0) #define AP_PRE_CONNECTION_RETURN_ENABLED() (0) #define AP_PRE_MPM_DISPATCH_COMPLETE(arg0, arg1) #define AP_PRE_MPM_DISPATCH_COMPLETE_ENABLED() (0) #define AP_PRE_MPM_DISPATCH_INVOKE(arg0) #define AP_PRE_MPM_DISPATCH_INVOKE_ENABLED() (0) #define AP_PRE_MPM_ENTRY() #define AP_PRE_MPM_ENTRY_ENABLED() (0) #define AP_PRE_MPM_RETURN(arg0) #define AP_PRE_MPM_RETURN_ENABLED() (0) #define AP_PRE_REQUEST_DISPATCH_COMPLETE(arg0, arg1) #define AP_PRE_REQUEST_DISPATCH_COMPLETE_ENABLED() (0) #define AP_PRE_REQUEST_DISPATCH_INVOKE(arg0) #define AP_PRE_REQUEST_DISPATCH_INVOKE_ENABLED() (0) #define AP_PRE_REQUEST_ENTRY() #define AP_PRE_REQUEST_ENTRY_ENABLED() (0) #define AP_PRE_REQUEST_RETURN(arg0) #define AP_PRE_REQUEST_RETURN_ENABLED() (0) #define AP_PROCESS_REQUEST_ENTRY(arg0, arg1) #define AP_PROCESS_REQUEST_ENTRY_ENABLED() (0) #define AP_PROCESS_REQUEST_RETURN(arg0, arg1, arg2) #define AP_PROCESS_REQUEST_RETURN_ENABLED() (0) #define AP_PROCESS_CONNECTION_DISPATCH_COMPLETE(arg0, arg1) #define AP_PROCESS_CONNECTION_DISPATCH_COMPLETE_ENABLED() (0) #define AP_PROCESS_CONNECTION_DISPATCH_INVOKE(arg0) #define AP_PROCESS_CONNECTION_DISPATCH_INVOKE_ENABLED() (0) #define AP_PROCESS_CONNECTION_ENTRY() #define AP_PROCESS_CONNECTION_ENTRY_ENABLED() (0) #define AP_PROCESS_CONNECTION_RETURN(arg0) #define AP_PROCESS_CONNECTION_RETURN_ENABLED() (0) #define AP_PROXY_RUN(arg0, arg1, arg2, arg3, arg4) #define AP_PROXY_RUN_ENABLED() (0) #define AP_PROXY_RUN_FINISHED(arg0, arg1, arg2) #define AP_PROXY_RUN_FINISHED_ENABLED() (0) #define AP_QUICK_HANDLER_DISPATCH_COMPLETE(arg0, arg1) #define AP_QUICK_HANDLER_DISPATCH_COMPLETE_ENABLED() (0) #define AP_QUICK_HANDLER_DISPATCH_INVOKE(arg0) #define AP_QUICK_HANDLER_DISPATCH_INVOKE_ENABLED() (0) #define AP_QUICK_HANDLER_ENTRY() #define AP_QUICK_HANDLER_ENTRY_ENABLED() (0) #define AP_QUICK_HANDLER_RETURN(arg0) #define AP_QUICK_HANDLER_RETURN_ENABLED() (0) #define AP_READ_REQUEST_ENTRY(arg0, arg1) #define AP_READ_REQUEST_ENTRY_ENABLED() (0) #define AP_READ_REQUEST_FAILURE(arg0) #define AP_READ_REQUEST_FAILURE_ENABLED() (0) #define AP_READ_REQUEST_SUCCESS(arg0, arg1, arg2, arg3, arg4) #define AP_READ_REQUEST_SUCCESS_ENABLED() (0) #define AP_REWRITE_LOG(arg0, arg1, arg2, arg3, arg4) #define AP_REWRITE_LOG_ENABLED() (0) #define AP_SCHEME_HANDLER_DISPATCH_COMPLETE(arg0, arg1) #define AP_SCHEME_HANDLER_DISPATCH_COMPLETE_ENABLED() (0) #define AP_SCHEME_HANDLER_DISPATCH_INVOKE(arg0) #define AP_SCHEME_HANDLER_DISPATCH_INVOKE_ENABLED() (0) #define AP_SCHEME_HANDLER_ENTRY() #define AP_SCHEME_HANDLER_ENTRY_ENABLED() (0) #define AP_SCHEME_HANDLER_RETURN(arg0) #define AP_SCHEME_HANDLER_RETURN_ENABLED() (0) #define AP_TEST_CONFIG_DISPATCH_COMPLETE(arg0, arg1) #define AP_TEST_CONFIG_DISPATCH_COMPLETE_ENABLED() (0) #define AP_TEST_CONFIG_DISPATCH_INVOKE(arg0) #define AP_TEST_CONFIG_DISPATCH_INVOKE_ENABLED() (0) #define AP_TEST_CONFIG_ENTRY() #define AP_TEST_CONFIG_ENTRY_ENABLED() (0) #define AP_TEST_CONFIG_RETURN(arg0) #define AP_TEST_CONFIG_RETURN_ENABLED() (0) #define AP_TRANSLATE_NAME_DISPATCH_COMPLETE(arg0, arg1) #define AP_TRANSLATE_NAME_DISPATCH_COMPLETE_ENABLED() (0) #define AP_TRANSLATE_NAME_DISPATCH_INVOKE(arg0) #define AP_TRANSLATE_NAME_DISPATCH_INVOKE_ENABLED() (0) #define AP_TRANSLATE_NAME_ENTRY() #define AP_TRANSLATE_NAME_ENTRY_ENABLED() (0) #define AP_TRANSLATE_NAME_RETURN(arg0) #define AP_TRANSLATE_NAME_RETURN_ENABLED() (0) #define AP_TYPE_CHECKER_DISPATCH_COMPLETE(arg0, arg1) #define AP_TYPE_CHECKER_DISPATCH_COMPLETE_ENABLED() (0) #define AP_TYPE_CHECKER_DISPATCH_INVOKE(arg0) #define AP_TYPE_CHECKER_DISPATCH_INVOKE_ENABLED() (0) #define AP_TYPE_CHECKER_ENTRY() #define AP_TYPE_CHECKER_ENTRY_ENABLED() (0) #define AP_TYPE_CHECKER_RETURN(arg0) #define AP_TYPE_CHECKER_RETURN_ENABLED() (0) #endif /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file ap_listen.h * @brief Apache Listeners Library * * @defgroup APACHE_CORE_LISTEN Apache Listeners Library * @ingroup APACHE_CORE * @{ */ #ifndef AP_LISTEN_H #define AP_LISTEN_H #include "apr_network_io.h" #include "httpd.h" #include "http_config.h" #include "apr_optional.h" #ifdef __cplusplus extern "C" { #endif typedef struct ap_slave_t ap_slave_t; typedef struct ap_listen_rec ap_listen_rec; typedef apr_status_t (*accept_function)(void **csd, ap_listen_rec *lr, apr_pool_t *ptrans); /** * @brief Apache's listeners record. * * These are used in the Multi-Processing Modules * to setup all of the sockets for the MPM to listen to and accept on. */ struct ap_listen_rec { /** * The next listener in the list */ ap_listen_rec *next; /** * The actual socket */ apr_socket_t *sd; /** * The sockaddr the socket should bind to */ apr_sockaddr_t *bind_addr; /** * The accept function for this socket */ accept_function accept_func; /** * Is this socket currently active */ int active; /** * The default protocol for this listening socket. */ const char* protocol; ap_slave_t *slave; }; /** * The global list of ap_listen_rec structures */ AP_DECLARE_DATA extern ap_listen_rec *ap_listeners; AP_DECLARE_DATA extern int ap_num_listen_buckets; AP_DECLARE_DATA extern int ap_have_so_reuseport; /** * Setup all of the defaults for the listener list */ AP_DECLARE(void) ap_listen_pre_config(void); /** * Loop through the global ap_listen_rec list and create all of the required * sockets. This executes the listen and bind on the sockets. * @param s The global server_rec * @return The number of open sockets. */ AP_DECLARE(int) ap_setup_listeners(server_rec *s); /** * This function duplicates ap_listeners into multiple buckets when configured * to (see ListenCoresBucketsRatio) and the platform supports it (eg. number of * online CPU cores and SO_REUSEPORT available). * @param p The config pool * @param s The global server_rec * @param buckets The array of listeners buckets. * @param num_buckets The total number of listeners buckets (array size). * @remark If the given *num_buckets is 0 (input), it will be computed * according to the platform capacities, otherwise (positive) it * will be preserved. The number of listeners duplicated will * always match *num_buckets, be it computed or given. */ AP_DECLARE(apr_status_t) ap_duplicate_listeners(apr_pool_t *p, server_rec *s, ap_listen_rec ***buckets, int *num_buckets); /** * Loop through the global ap_listen_rec list and close each of the sockets. */ AP_DECLARE_NONSTD(void) ap_close_listeners(void); /** * Loop through the given ap_listen_rec list and close each of the sockets. * @param listeners The listener to close. */ AP_DECLARE_NONSTD(void) ap_close_listeners_ex(ap_listen_rec *listeners); /** * FIXMEDOC */ AP_DECLARE_NONSTD(int) ap_close_selected_listeners(ap_slave_t *); /* Although these functions are exported from libmain, they are not really * public functions. These functions are actually called while parsing the * config file, when one of the LISTEN_COMMANDS directives is read. These * should not ever be called by external modules. ALL MPMs should include * LISTEN_COMMANDS in their command_rec table so that these functions are * called. */ AP_DECLARE_NONSTD(const char *) ap_set_listenbacklog(cmd_parms *cmd, void *dummy, const char *arg); AP_DECLARE_NONSTD(const char *) ap_set_listentcpdeferaccept(cmd_parms *cmd, void *dummy, const char *arg); AP_DECLARE_NONSTD(const char *) ap_set_listencbratio(cmd_parms *cmd, void *dummy, const char *arg); AP_DECLARE_NONSTD(const char *) ap_set_listener(cmd_parms *cmd, void *dummy, int argc, char *const argv[]); AP_DECLARE_NONSTD(const char *) ap_set_send_buffer_size(cmd_parms *cmd, void *dummy, const char *arg); AP_DECLARE_NONSTD(const char *) ap_set_receive_buffer_size(cmd_parms *cmd, void *dummy, const char *arg); #ifdef HAVE_SYSTEMD APR_DECLARE_OPTIONAL_FN(int, ap_find_systemd_socket, (process_rec *, apr_port_t)); APR_DECLARE_OPTIONAL_FN(int, ap_systemd_listen_fds, (int)); #endif #define LISTEN_COMMANDS \ AP_INIT_TAKE1("ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, \ "Maximum length of the queue of pending connections, as used by listen(2)"), \ AP_INIT_TAKE1("ListenCoresBucketsRatio", ap_set_listencbratio, NULL, RSRC_CONF, \ "Ratio between the number of CPU cores (online) and the number of listeners buckets"), \ AP_INIT_TAKE_ARGV("Listen", ap_set_listener, NULL, RSRC_CONF, \ "A port number or a numeric IP address and a port number, and an optional protocol"), \ AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \ "Send buffer size in bytes"), \ AP_INIT_TAKE1("ReceiveBufferSize", ap_set_receive_buffer_size, NULL, \ RSRC_CONF, "Receive buffer size in bytes"), \ AP_INIT_TAKE1("ListenTCPDeferAccept", ap_set_listentcpdeferaccept, NULL, RSRC_CONF, \ "Value set for the socket option TCP_DEFER_ACCEPT if it is set") #ifdef __cplusplus } #endif #endif /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_md5.h * @brief Apache MD5 library * * @defgroup APACHE_CORE_MD5 MD5 Package Library * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_UTIL_MD5_H #define APACHE_UTIL_MD5_H #ifdef __cplusplus extern "C" { #endif #include "apr_md5.h" /** * Create an MD5 checksum of a given string. * @param a Pool to allocate out of * @param string String to get the checksum of * @return The checksum */ AP_DECLARE(char *) ap_md5(apr_pool_t *a, const unsigned char *string); /** * Create an MD5 checksum of a string of binary data. * @param a Pool to allocate out of * @param buf Buffer to generate checksum for * @param len The length of the buffer * @return The checksum */ AP_DECLARE(char *) ap_md5_binary(apr_pool_t *a, const unsigned char *buf, int len); /** * Convert an MD5 checksum into a base64 encoding. * @param p The pool to allocate out of * @param context The context to convert * @return The converted encoding */ AP_DECLARE(char *) ap_md5contextTo64(apr_pool_t *p, apr_md5_ctx_t *context); /** * Create an MD5 Digest for a given file. * @param p The pool to allocate out of * @param infile The file to create the digest for */ AP_DECLARE(char *) ap_md5digest(apr_pool_t *p, apr_file_t *infile); #ifdef __cplusplus } #endif #endif /* !APACHE_UTIL_MD5_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file unix/os.h * @brief This file in included in all Apache source code. It contains definitions * of facilities available on _this_ operating system (HAVE_* macros), * and prototypes of OS specific functions defined in os.c or os-inline.c * * @defgroup APACHE_OS_UNIX unix * @ingroup APACHE_OS * @{ */ #ifndef APACHE_OS_H #define APACHE_OS_H #include "apr.h" #include "ap_config.h" #ifndef PLATFORM #define PLATFORM "cPanel" #endif /* On platforms where AP_NEED_SET_MUTEX_PERMS is defined, modules * should call unixd_set_*_mutex_perms on mutexes created in the * parent process. */ #define AP_NEED_SET_MUTEX_PERMS 1 /* Define command-line rewriting for this platform, handled by core. */ #define AP_PLATFORM_REWRITE_ARGS_HOOK ap_mpm_rewrite_args #ifdef _OSD_POSIX pid_t os_fork(const char *user); #endif #endif /* !APACHE_OS_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_script.h * @brief Apache script tools * * @defgroup APACHE_CORE_SCRIPT Script Tools * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_UTIL_SCRIPT_H #define APACHE_UTIL_SCRIPT_H #include "apr_buckets.h" #include "ap_config.h" #ifdef __cplusplus extern "C" { #endif #ifndef APACHE_ARG_MAX #ifdef _POSIX_ARG_MAX #define APACHE_ARG_MAX _POSIX_ARG_MAX #else #define APACHE_ARG_MAX 512 #endif #endif /** * Create an environment variable out of an Apache table of key-value pairs * @param p pool to allocate out of * @param t Apache table of key-value pairs * @return An array containing the same key-value pairs suitable for * use with an exec call. * @fn char **ap_create_environment(apr_pool_t *p, apr_table_t *t) */ AP_DECLARE(char **) ap_create_environment(apr_pool_t *p, apr_table_t *t); /** * This "cute" little function comes about because the path info on * filenames and URLs aren't always the same. So we take the two, * and find as much of the two that match as possible. * @param uri The uri we are currently parsing * @param path_info The current path info * @return The length of the path info * @fn int ap_find_path_info(const char *uri, const char *path_info) */ AP_DECLARE(int) ap_find_path_info(const char *uri, const char *path_info); /** * Add CGI environment variables required by HTTP/1.1 to the request's * environment table * @param r the current request * @fn void ap_add_cgi_vars(request_rec *r) */ AP_DECLARE(void) ap_add_cgi_vars(request_rec *r); /** * Add common CGI environment variables to the requests environment table * @param r The current request * @fn void ap_add_common_vars(request_rec *r) */ AP_DECLARE(void) ap_add_common_vars(request_rec *r); /** * Read headers output from a script, ensuring that the output is valid. If * the output is valid, then the headers are added to the headers out of the * current request * @param r The current request * @param f The file to read from * @param buffer Empty when calling the function. On output, if there was an * error, the string that cause the error is stored here. * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise * @fn int ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer) */ AP_DECLARE(int) ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer); /** * Read headers output from a script, ensuring that the output is valid. If * the output is valid, then the headers are added to the headers out of the * current request * @param r The current request * @param f The file to read from * @param buffer Empty when calling the function. On output, if there was an * error, the string that cause the error is stored here. * @param module_index The module index to be used for logging * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise */ AP_DECLARE(int) ap_scan_script_header_err_ex(request_rec *r, apr_file_t *f, char *buffer, int module_index); /** * Read headers output from a script, ensuring that the output is valid. If * the output is valid, then the headers are added to the headers out of the * current request * @param r The current request * @param bb The brigade from which to read * @param buffer Empty when calling the function. On output, if there was an * error, the string that cause the error is stored here. * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise * @fn int ap_scan_script_header_err_brigade(request_rec *r, apr_bucket_brigade *bb, char *buffer) */ AP_DECLARE(int) ap_scan_script_header_err_brigade(request_rec *r, apr_bucket_brigade *bb, char *buffer); /** * Read headers output from a script, ensuring that the output is valid. If * the output is valid, then the headers are added to the headers out of the * current request * @param r The current request * @param bb The brigade from which to read * @param buffer Empty when calling the function. On output, if there was an * error, the string that cause the error is stored here. * @param module_index The module index to be used for logging * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise */ AP_DECLARE(int) ap_scan_script_header_err_brigade_ex(request_rec *r, apr_bucket_brigade *bb, char *buffer, int module_index); /** * Read headers strings from a script, ensuring that the output is valid. If * the output is valid, then the headers are added to the headers out of the * current request * @param r The current request * @param buffer Empty when calling the function. On output, if there was an * error, the string that cause the error is stored here. * @param termch Pointer to the last character parsed. * @param termarg Pointer to an int to capture the last argument parsed. * * The varargs are string arguments to parse consecutively for headers, * with a NULL argument to terminate the list. * * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise */ AP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs(request_rec *r, char *buffer, const char **termch, int *termarg, ...) AP_FN_ATTR_SENTINEL; /** * Read headers strings from a script, ensuring that the output is valid. If * the output is valid, then the headers are added to the headers out of the * current request * @param r The current request * @param buffer Empty when calling the function. On output, if there was an * error, the string that cause the error is stored here. * @param module_index The module index to be used for logging * @param termch Pointer to the last character parsed. * @param termarg Pointer to an int to capture the last argument parsed. * * The varargs are string arguments to parse consecutively for headers, * with a NULL argument to terminate the list. * * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise */ AP_DECLARE_NONSTD(int) ap_scan_script_header_err_strs_ex(request_rec *r, char *buffer, int module_index, const char **termch, int *termarg, ...) AP_FN_ATTR_SENTINEL; /** * Read headers output from a script, ensuring that the output is valid. If * the output is valid, then the headers are added to the headers out of the * current request * @param r The current request * @param buffer Empty when calling the function. On output, if there was an * error, the string that cause the error is stored here. * @param getsfunc Function to read the headers from. This function should act like gets() * @param getsfunc_data The place to read from * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise */ AP_DECLARE(int) ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc) (char *, int, void *), void *getsfunc_data); /** * Read headers output from a script, ensuring that the output is valid. If * the output is valid, then the headers are added to the headers out of the * current request * @param r The current request * @param buffer Empty when calling the function. On output, if there was an * error, the string that cause the error is stored here. * @param getsfunc Function to read the headers from. This function should act like gets() * @param getsfunc_data The place to read from * @param module_index The module index to be used for logging * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise */ AP_DECLARE(int) ap_scan_script_header_err_core_ex(request_rec *r, char *buffer, int (*getsfunc) (char *, int, void *), void *getsfunc_data, int module_index); /** * Parse query args for the request and store in a new table allocated * from the request pool. * For args with no value, "1" will be used instead. * If no query args were specified, the table will be empty. * @param r The current request * @param table A new table on output. */ AP_DECLARE(void) ap_args_to_table(request_rec *r, apr_table_t **table); #define AP_TRUST_CGILIKE_CL_ENVVAR "ap_trust_cgilike_cl" #ifdef __cplusplus } #endif #endif /* !APACHE_UTIL_SCRIPT_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_dav.h * @brief DAV extension module for Apache 2.0.* * * @defgroup MOD_DAV mod_dav * @ingroup APACHE_MODS * @{ */ #ifndef _MOD_DAV_H_ #define _MOD_DAV_H_ #include "apr_hooks.h" #include "apr_hash.h" #include "apr_dbm.h" #include "apr_tables.h" #include "httpd.h" #include "util_filter.h" #include "util_xml.h" #include <limits.h> /* for INT_MAX */ #include <time.h> /* for time_t */ #ifdef __cplusplus extern "C" { #endif #define DAV_VERSION AP_SERVER_BASEREVISION #define DAV_XML_HEADER "<?xml version=\"1.0\" encoding=\"utf-8\"?>" #define DAV_XML_CONTENT_TYPE "text/xml; charset=\"utf-8\"" #define DAV_READ_BLOCKSIZE 2048 /* used for reading input blocks */ #define DAV_RESPONSE_BODY_1 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n<title>" #define DAV_RESPONSE_BODY_2 "</title>\n</head><body>\n<h1>" #define DAV_RESPONSE_BODY_3 "</h1>\n<p>" #define DAV_RESPONSE_BODY_4 "</p>\n" #define DAV_RESPONSE_BODY_5 "</body></html>\n" #define DAV_DO_COPY 0 #define DAV_DO_MOVE 1 #ifndef DAV_MAX_SHARED_LOCKS #define DAV_MAX_SHARED_LOCKS (1024) #endif #if 1 #define DAV_DEBUG 1 #define DEBUG_CR "\n" #define DBG0(f) ap_log_error(APLOG_MARK, \ APLOG_ERR, 0, NULL, (f)) #define DBG1(f,a1) ap_log_error(APLOG_MARK, \ APLOG_ERR, 0, NULL, f, a1) #define DBG2(f,a1,a2) ap_log_error(APLOG_MARK, \ APLOG_ERR, 0, NULL, f, a1, a2) #define DBG3(f,a1,a2,a3) ap_log_error(APLOG_MARK, \ APLOG_ERR, 0, NULL, f, a1, a2, a3) #else #undef DAV_DEBUG #define DEBUG_CR "" #endif #define DAV_INFINITY INT_MAX /* for the Depth: header */ /* Create a set of DAV_DECLARE(type), DAV_DECLARE_NONSTD(type) and * DAV_DECLARE_DATA with appropriate export and import tags for the platform */ #if !defined(WIN32) #define DAV_DECLARE(type) type #define DAV_DECLARE_NONSTD(type) type #define DAV_DECLARE_DATA #elif defined(DAV_DECLARE_STATIC) #define DAV_DECLARE(type) type __stdcall #define DAV_DECLARE_NONSTD(type) type #define DAV_DECLARE_DATA #elif defined(DAV_DECLARE_EXPORT) #define DAV_DECLARE(type) __declspec(dllexport) type __stdcall #define DAV_DECLARE_NONSTD(type) __declspec(dllexport) type #define DAV_DECLARE_DATA __declspec(dllexport) #else #define DAV_DECLARE(type) __declspec(dllimport) type __stdcall #define DAV_DECLARE_NONSTD(type) __declspec(dllimport) type #define DAV_DECLARE_DATA __declspec(dllimport) #endif /* -------------------------------------------------------------------- ** ** ERROR MANAGEMENT */ /* ** dav_error structure. ** ** In most cases, mod_dav uses a pointer to a dav_error structure. If the ** pointer is NULL, then no error has occurred. ** ** In certain cases, a dav_error structure is directly used. In these cases, ** a status value of 0 means that an error has not occurred. ** ** Note: this implies that status != 0 whenever an error occurs. ** ** The desc field is optional (it may be NULL). When NULL, it typically ** implies that Apache has a proper description for the specified status. */ typedef struct dav_error { int status; /* suggested HTTP status (0 for no error) */ int error_id; /* DAV-specific error ID */ const char *desc; /* DAV:responsedescription and error log */ apr_status_t aprerr; /* APR error if any, or 0/APR_SUCCESS */ const char *namespace; /* [optional] namespace of error */ const char *tagname; /* name of error-tag */ struct dav_error *prev; /* previous error (in stack) */ const char *childtags; /* error-tag may have children */ } dav_error; /* ** Create a new error structure. save_errno will be filled with the current ** errno value. */ DAV_DECLARE(dav_error*) dav_new_error(apr_pool_t *p, int status, int error_id, apr_status_t aprerr, const char *desc); /* ** Create a new error structure with tagname and (optional) namespace; ** namespace may be NULL, which means "DAV:". */ DAV_DECLARE(dav_error*) dav_new_error_tag(apr_pool_t *p, int status, int error_id, apr_status_t aprerr, const char *desc, const char *namespace, const char *tagname); /* ** Push a new error description onto the stack of errors. ** ** This function is used to provide an additional description to an existing ** error. ** ** <status> should contain the caller's view of what the current status is, ** given the underlying error. If it doesn't have a better idea, then the ** caller should pass prev->status. ** ** <error_id> can specify a new error_id since the topmost description has ** changed. */ DAV_DECLARE(dav_error*) dav_push_error(apr_pool_t *p, int status, int error_id, const char *desc, dav_error *prev); /* ** Join two errors together. ** ** This function is used to add a new error stack onto an existing error so ** that subsequent errors can be reported after the first error. It returns ** the correct error stack to use so that the caller can blindly call it ** without checking that both dest and src are not NULL. ** ** <dest> is the error stack that the error will be added to. ** ** <src> is the error stack that will be appended. */ DAV_DECLARE(dav_error*) dav_join_error(dav_error* dest, dav_error* src); typedef struct dav_response dav_response; /* ** dav_handle_err() ** ** Handle the standard error processing. <err> must be non-NULL. ** ** <response> is set by the following: ** - dav_validate_request() ** - dav_add_lock() ** - repos_hooks->remove_resource ** - repos_hooks->move_resource ** - repos_hooks->copy_resource ** - vsn_hooks->update */ DAV_DECLARE(int) dav_handle_err(request_rec *r, dav_error *err, dav_response *response); /* error ID values... */ /* IF: header errors */ #define DAV_ERR_IF_PARSE 100 /* general parsing error */ #define DAV_ERR_IF_MULTIPLE_NOT 101 /* multiple "Not" found */ #define DAV_ERR_IF_UNK_CHAR 102 /* unknown char in header */ #define DAV_ERR_IF_ABSENT 103 /* no locktokens given */ #define DAV_ERR_IF_TAGGED 104 /* in parsing tagged-list */ #define DAV_ERR_IF_UNCLOSED_PAREN 105 /* in no-tagged-list */ /* Prop DB errors */ #define DAV_ERR_PROP_BAD_MAJOR 200 /* major version was wrong */ #define DAV_ERR_PROP_READONLY 201 /* prop is read-only */ #define DAV_ERR_PROP_NO_DATABASE 202 /* writable db not avail */ #define DAV_ERR_PROP_NOT_FOUND 203 /* prop not found */ #define DAV_ERR_PROP_BAD_LOCKDB 204 /* could not open lockdb */ #define DAV_ERR_PROP_OPENING 205 /* problem opening propdb */ #define DAV_ERR_PROP_EXEC 206 /* problem exec'ing patch */ /* Predefined DB errors */ /* ### any to define?? */ /* Predefined locking system errors */ #define DAV_ERR_LOCK_OPENDB 400 /* could not open lockdb */ #define DAV_ERR_LOCK_NO_DB 401 /* no database defined */ #define DAV_ERR_LOCK_CORRUPT_DB 402 /* DB is corrupt */ #define DAV_ERR_LOCK_UNK_STATE_TOKEN 403 /* unknown State-token */ #define DAV_ERR_LOCK_PARSE_TOKEN 404 /* bad opaquelocktoken */ #define DAV_ERR_LOCK_SAVE_LOCK 405 /* err saving locks */ /* ** Some comments on Error ID values: ** ** The numbers do not necessarily need to be unique. Uniqueness simply means ** that two errors that have not been predefined above can be distinguished ** from each other. At the moment, mod_dav does not use this distinguishing ** feature, but it could be used in the future to collapse <response> elements ** into groups based on the error ID (and associated responsedescription). ** ** If a compute_desc is provided, then the error ID should be unique within ** the context of the compute_desc function (so the function can figure out ** what to filled into the desc). ** ** Basically, subsystems can ignore defining new error ID values if they want ** to. The subsystems *do* need to return the predefined errors when ** appropriate, so that mod_dav can figure out what to do. Subsystems can ** simply leave the error ID field unfilled (zero) if there isn't an error ** that must be placed there. */ /* -------------------------------------------------------------------- ** ** HOOK STRUCTURES ** ** These are here for forward-declaration purposes. For more info, see ** the section title "HOOK HANDLING" for more information, plus each ** structure definition. */ /* forward-declare this structure */ typedef struct dav_hooks_propdb dav_hooks_propdb; typedef struct dav_hooks_locks dav_hooks_locks; typedef struct dav_hooks_vsn dav_hooks_vsn; typedef struct dav_hooks_repository dav_hooks_repository; typedef struct dav_hooks_liveprop dav_hooks_liveprop; typedef struct dav_hooks_binding dav_hooks_binding; typedef struct dav_hooks_search dav_hooks_search; /* ### deprecated name */ typedef dav_hooks_propdb dav_hooks_db; /* -------------------------------------------------------------------- ** ** RESOURCE HANDLING */ /* ** Resource Types: ** The base protocol defines only file and collection resources. ** The versioning protocol defines several additional resource types ** to represent artifacts of a version control system. ** ** This enumeration identifies the type of URL used to identify the ** resource. Since the same resource may have more than one type of ** URL which can identify it, dav_resource_type cannot be used ** alone to determine the type of the resource; attributes of the ** dav_resource object must also be consulted. */ typedef enum { DAV_RESOURCE_TYPE_UNKNOWN, DAV_RESOURCE_TYPE_REGULAR, /* file or collection; could be * unversioned, or version selector, * or baseline selector */ DAV_RESOURCE_TYPE_VERSION, /* version or baseline URL */ DAV_RESOURCE_TYPE_HISTORY, /* version or baseline history URL */ DAV_RESOURCE_TYPE_WORKING, /* working resource URL */ DAV_RESOURCE_TYPE_WORKSPACE, /* workspace URL */ DAV_RESOURCE_TYPE_ACTIVITY, /* activity URL */ DAV_RESOURCE_TYPE_PRIVATE /* repository-private type */ } dav_resource_type; /* ** Opaque, repository-specific information for a resource. */ typedef struct dav_resource_private dav_resource_private; /* ** Resource descriptor, generated by a repository provider. ** ** Note: the lock-null state is not explicitly represented here, ** since it may be expensive to compute. Use dav_get_resource_state() ** to determine whether a non-existent resource is a lock-null resource. ** ** A quick explanation of how the flags can apply to different resources: ** ** unversioned file or collection: ** type = DAV_RESOURCE_TYPE_REGULAR ** exists = ? (1 if exists) ** collection = ? (1 if collection) ** versioned = 0 ** baselined = 0 ** working = 0 ** ** version-controlled resource or configuration: ** type = DAV_RESOURCE_TYPE_REGULAR ** exists = 1 ** collection = ? (1 if collection) ** versioned = 1 ** baselined = ? (1 if configuration) ** working = ? (1 if checked out) ** ** version/baseline history: ** type = DAV_RESOURCE_TYPE_HISTORY ** exists = 1 ** collection = 0 ** versioned = 0 ** baselined = 0 ** working = 0 ** ** version/baseline: ** type = DAV_RESOURCE_TYPE_VERSION ** exists = 1 ** collection = ? (1 if collection) ** versioned = 1 ** baselined = ? (1 if baseline) ** working = 0 ** ** working resource: ** type = DAV_RESOURCE_TYPE_WORKING ** exists = 1 ** collection = ? (1 if collection) ** versioned = 1 ** baselined = 0 ** working = 1 ** ** workspace: ** type = DAV_RESOURCE_TYPE_WORKSPACE ** exists = ? (1 if exists) ** collection = 1 ** versioned = ? (1 if version-controlled) ** baselined = ? (1 if baseline-controlled) ** working = ? (1 if checked out) ** ** activity: ** type = DAV_RESOURCE_TYPE_ACTIVITY ** exists = ? (1 if exists) ** collection = 0 ** versioned = 0 ** baselined = 0 ** working = 0 */ typedef struct dav_resource { dav_resource_type type; int exists; /* 0 => null resource */ int collection; /* 0 => file; can be 1 for * REGULAR, VERSION, and WORKING resources, * and is always 1 for WORKSPACE */ int versioned; /* 0 => unversioned; can be 1 for * REGULAR and WORKSPACE resources, * and is always 1 for VERSION and WORKING */ int baselined; /* 0 => not baselined; can be 1 for * REGULAR, VERSION, and WORKSPACE resources; * versioned == 1 when baselined == 1 */ int working; /* 0 => not checked out; can be 1 for * REGULAR and WORKSPACE resources, * and is always 1 for WORKING */ const char *uri; /* the URI for this resource; * currently has an ABI flaw where sometimes it is * assumed to be encoded and sometimes not */ dav_resource_private *info; /* the provider's private info */ const dav_hooks_repository *hooks; /* hooks used for this resource */ /* When allocating items related specifically to this resource, the following pool should be used. Its lifetime will be at least as long as the dav_resource structure. */ apr_pool_t *pool; } dav_resource; /* ** Lock token type. Lock providers define the details of a lock token. ** However, all providers are expected to at least be able to parse ** the "opaquelocktoken" scheme, which is represented by a uuid_t. */ typedef struct dav_locktoken dav_locktoken; DAV_DECLARE(dav_error *) dav_get_resource(request_rec *r, int label_allowed, int use_checked_in, dav_resource **res_p); /* ** If DavBasePath is configured for the request location, return the ** configured path, otherwise NULL. */ DAV_DECLARE(const char *) dav_get_base_path(request_rec *r); /* -------------------------------------------------------------------- ** ** BUFFER HANDLING ** ** These buffers are used as a lightweight buffer reuse mechanism. Apache ** provides sub-pool creation and destruction to much the same effect, but ** the sub-pools are a bit more general and heavyweight than these buffers. */ /* buffer for reuse; can grow to accommodate needed size */ typedef struct { apr_size_t alloc_len; /* how much has been allocated */ apr_size_t cur_len; /* how much is currently being used */ char *buf; /* buffer contents */ } dav_buffer; #define DAV_BUFFER_MINSIZE 256 /* minimum size for buffer */ #define DAV_BUFFER_PAD 64 /* amount of pad when growing */ /* set the cur_len to the given size and ensure space is available */ DAV_DECLARE(void) dav_set_bufsize(apr_pool_t *p, dav_buffer *pbuf, apr_size_t size); /* initialize a buffer and copy the specified (null-term'd) string into it */ DAV_DECLARE(void) dav_buffer_init(apr_pool_t *p, dav_buffer *pbuf, const char *str); /* check that the buffer can accommodate <extra_needed> more bytes */ DAV_DECLARE(void) dav_check_bufsize(apr_pool_t *p, dav_buffer *pbuf, apr_size_t extra_needed); /* append a string to the end of the buffer, adjust length */ DAV_DECLARE(void) dav_buffer_append(apr_pool_t *p, dav_buffer *pbuf, const char *str); /* place a string on the end of the buffer, do NOT adjust length */ DAV_DECLARE(void) dav_buffer_place(apr_pool_t *p, dav_buffer *pbuf, const char *str); /* place some memory on the end of a buffer; do NOT adjust length */ DAV_DECLARE(void) dav_buffer_place_mem(apr_pool_t *p, dav_buffer *pbuf, const void *mem, apr_size_t amt, apr_size_t pad); /* -------------------------------------------------------------------- ** ** HANDY UTILITIES */ /* contains results from one of the getprop functions */ typedef struct { apr_text * propstats; /* <propstat> element text */ apr_text * xmlns; /* namespace decls for <response> elem */ } dav_get_props_result; /* holds the contents of a <response> element */ struct dav_response { const char *href; /* always */ const char *desc; /* optional description at <response> level */ /* use status if propresult.propstats is NULL. */ dav_get_props_result propresult; int status; struct dav_response *next; }; typedef struct { request_rec *rnew; /* new subrequest */ dav_error err; /* potential error response */ } dav_lookup_result; DAV_DECLARE(dav_lookup_result) dav_lookup_uri(const char *uri, request_rec *r, int must_be_absolute); /* defines type of property info a provider is to return */ typedef enum { DAV_PROP_INSERT_NOTDEF, /* property is defined by this provider, but nothing was inserted because the (live) property is not defined for this resource (it may be present as a dead property). */ DAV_PROP_INSERT_NOTSUPP, /* property is recognized by this provider, but it is not supported, and cannot be treated as a dead property */ DAV_PROP_INSERT_NAME, /* a property name (empty elem) was inserted into the text block */ DAV_PROP_INSERT_VALUE, /* a property name/value pair was inserted into the text block */ DAV_PROP_INSERT_SUPPORTED /* a supported live property was added to the text block as a <DAV:supported-live-property> element */ } dav_prop_insert; /* ### this stuff is private to dav/fs/repos.c; move it... */ /* format a time string (buf must be at least DAV_TIMEBUF_SIZE chars) */ #define DAV_STYLE_ISO8601 1 #define DAV_STYLE_RFC822 2 #define DAV_TIMEBUF_SIZE 30 /* Write a complete RESPONSE object out as a <DAV:response> xml * element. Data is sent into brigade BB, which is auto-flushed into * the output filter stack for request R. Use POOL for any temporary * allocations. * * [Presumably the <multistatus> tag has already been written; this * routine is shared by dav_send_multistatus and dav_stream_response.] */ DAV_DECLARE(void) dav_send_one_response(dav_response *response, apr_bucket_brigade *bb, request_rec *r, apr_pool_t *pool); /* Factorized helper function: prep request_rec R for a multistatus * response and write <multistatus> tag into BB, destined for * R->output_filters. Use xml NAMESPACES in initial tag, if * non-NULL. */ DAV_DECLARE(void) dav_begin_multistatus(apr_bucket_brigade *bb, request_rec *r, int status, apr_array_header_t *namespaces); /* Finish a multistatus response started by dav_begin_multistatus: */ DAV_DECLARE(apr_status_t) dav_finish_multistatus(request_rec *r, apr_bucket_brigade *bb); /* Send a multistatus response */ DAV_DECLARE(void) dav_send_multistatus(request_rec *r, int status, dav_response *first, apr_array_header_t *namespaces); DAV_DECLARE(apr_text *) dav_failed_proppatch(apr_pool_t *p, apr_array_header_t *prop_ctx); DAV_DECLARE(apr_text *) dav_success_proppatch(apr_pool_t *p, apr_array_header_t *prop_ctx); DAV_DECLARE(int) dav_get_depth(request_rec *r, int def_depth); DAV_DECLARE(int) dav_validate_root(const apr_xml_doc *doc, const char *tagname); DAV_DECLARE(int) dav_validate_root_ns(const apr_xml_doc *doc, int ns, const char *tagname); DAV_DECLARE(apr_xml_elem *) dav_find_child(const apr_xml_elem *elem, const char *tagname); DAV_DECLARE(apr_xml_elem *) dav_find_child_ns(const apr_xml_elem *elem, int ns, const char *tagname); DAV_DECLARE(apr_xml_elem *) dav_find_next_ns(const apr_xml_elem *elem, int ns, const char *tagname); /* find and return the attribute with a name in the given namespace */ DAV_DECLARE(apr_xml_attr *) dav_find_attr_ns(const apr_xml_elem *elem, int ns, const char *attrname); /* find and return the attribute with a given DAV: tagname */ DAV_DECLARE(apr_xml_attr *) dav_find_attr(const apr_xml_elem *elem, const char *attrname); /* gather up all the CDATA into a single string */ DAV_DECLARE(const char *) dav_xml_get_cdata(const apr_xml_elem *elem, apr_pool_t *pool, int strip_white); /* ** XML namespace handling ** ** This structure tracks namespace declarations (xmlns:prefix="URI"). ** It maintains a one-to-many relationship of URIs-to-prefixes. In other ** words, one URI may be defined by many prefixes, but any specific ** prefix will specify only one URI. ** ** Prefixes using the "g###" pattern can be generated automatically if ** the caller does not have specific prefix requirements. */ typedef struct { apr_pool_t *pool; apr_hash_t *uri_prefix; /* map URIs to an available prefix */ apr_hash_t *prefix_uri; /* map all prefixes to their URIs */ int count; /* counter for "g###" prefixes */ } dav_xmlns_info; /* create an empty dav_xmlns_info structure */ DAV_DECLARE(dav_xmlns_info *) dav_xmlns_create(apr_pool_t *pool); /* add a specific prefix/URI pair. the prefix/uri should have a lifetime at least that of xmlns->pool */ DAV_DECLARE(void) dav_xmlns_add(dav_xmlns_info *xi, const char *prefix, const char *uri); /* add a URI (if not present); any prefix is acceptable and is returned. the uri should have a lifetime at least that xmlns->pool */ DAV_DECLARE(const char *) dav_xmlns_add_uri(dav_xmlns_info *xi, const char *uri); /* return the URI for a specified prefix (or NULL if the prefix is unknown) */ DAV_DECLARE(const char *) dav_xmlns_get_uri(dav_xmlns_info *xi, const char *prefix); /* return an available prefix for a specified URI (or NULL if the URI is unknown) */ DAV_DECLARE(const char *) dav_xmlns_get_prefix(dav_xmlns_info *xi, const char *uri); /* generate xmlns declarations (appending into the given text) */ DAV_DECLARE(void) dav_xmlns_generate(dav_xmlns_info *xi, apr_text_header *phdr); /* -------------------------------------------------------------------- ** ** DAV PLUGINS */ /* ### docco ... */ /* ** dav_provider ** ** This structure wraps up all of the hooks that a mod_dav provider can ** supply. The provider MUST supply <repos> and <propdb>. The rest are ** optional and should contain NULL if that feature is not supplied. ** ** Note that a provider cannot pick and choose portions from various ** underlying implementations (which was theoretically possible in ** mod_dav 1.0). There are too many dependencies between a dav_resource ** (defined by <repos>) and the other functionality. ** ** Live properties and report extensions are not part of the dav_provider ** structure because they are handled through the APR_HOOK interface (to ** allow for multiple providers). The core always provides some ** properties, and then a given provider will add more properties. ** ** Some providers may need to associate a context with the dav_provider ** structure -- the ctx field is available for storing this context. Just ** leave it NULL if it isn't required. */ typedef struct { const dav_hooks_repository *repos; const dav_hooks_propdb *propdb; const dav_hooks_locks *locks; const dav_hooks_vsn *vsn; const dav_hooks_binding *binding; const dav_hooks_search *search; void *ctx; } dav_provider; /* ** gather_propsets: gather all live property propset-URIs ** ** The hook implementor should push one or more URIs into the specified ** array. These URIs are returned in the DAV: header to let clients know ** what sets of live properties are supported by the installation. mod_dav ** will place open/close angle brackets around each value (much like ** a Coded-URL); quotes and brackets should not be in the value. ** ** Example: http://apache.org/dav/props/ ** ** (of course, use your own domain to ensure a unique value) */ APR_DECLARE_EXTERNAL_HOOK(dav, DAV, void, gather_propsets, (apr_array_header_t *uris)) /* ** find_liveprop: find a live property, returning a non-zero, unique, ** opaque identifier. ** ** If the hook implementor determines the specified URI/name refers to ** one of its properties, then it should fill in HOOKS and return a ** non-zero value. The returned value is the "property ID" and will ** be passed to the various liveprop hook functions. ** ** Return 0 if the property is not defined by the hook implementor. */ APR_DECLARE_EXTERNAL_HOOK(dav, DAV, int, find_liveprop, (const dav_resource *resource, const char *ns_uri, const char *name, const dav_hooks_liveprop **hooks)) /* ** insert_all_liveprops: insert all (known) live property names/values. ** ** The hook implementor should append XML text to PHDR, containing liveprop ** names. If INSVALUE is true, then the property values should also be ** inserted into the output XML stream. ** ** The liveprop provider should insert *all* known and *defined* live ** properties on the specified resource. If a particular liveprop is ** not defined for this resource, then it should not be inserted. */ APR_DECLARE_EXTERNAL_HOOK(dav, DAV, void, insert_all_liveprops, (request_rec *r, const dav_resource *resource, dav_prop_insert what, apr_text_header *phdr)) /* ** deliver_report: given a parsed report request, process the request ** an deliver the resulting report. ** ** The hook implementer should decide whether it should handle the given ** report, and if so, write the response to the output filter. If the ** report is not relevant, return DECLINED. */ APR_DECLARE_EXTERNAL_HOOK(dav, DAV, int, deliver_report, (request_rec *r, const dav_resource *resource, const apr_xml_doc *doc, ap_filter_t *output, dav_error **err)) /* ** gather_reports: get all reports. ** ** The hook implementor should push one or more dav_report_elem structures ** containing report names into the specified array. These names are returned ** in the DAV:supported-reports-set property to let clients know ** what reports are supported by the installation. ** */ APR_DECLARE_EXTERNAL_HOOK(dav, DAV, void, gather_reports, (request_rec *r, const dav_resource *resource, apr_array_header_t *reports, dav_error **err)) /* ** method_precondition: check method preconditions. ** ** If a WebDAV extension needs to set any preconditions on a method, this ** hook is where to do it. If the precondition fails, return an error ** response with the tagname set to the value of the failed precondition. ** ** If the method requires an XML body, this will be read and provided as ** the doc value. If not, doc is NULL. An extension that needs to verify ** the non-XML body of a request should register an input filter to do so ** within this hook. ** ** Methods like PUT will supply a single src resource, and the dst will ** be NULL. ** ** Methods like COPY or MOVE will trigger this hook twice. The first ** invocation will supply just the source resource. The second invocation ** will supply a source and destination. This allows preconditions on the ** source resource to be verified before making an attempt to get the ** destination resource. ** ** Methods like PROPFIND and LABEL will trigger this hook initially for ** the src resource, and then subsequently for each resource that has ** been walked during processing, with the walked resource passed in dst, ** and NULL passed in src. ** ** As a rule, the src resource originates from a request that has passed ** through httpd's authn/authz hooks, while the dst resource has not. */ APR_DECLARE_EXTERNAL_HOOK(dav, DAV, int, method_precondition, (request_rec *r, dav_resource *src, const dav_resource *dst, const apr_xml_doc *doc, dav_error **err)) DAV_DECLARE(const dav_hooks_locks *) dav_get_lock_hooks(request_rec *r); DAV_DECLARE(const dav_hooks_propdb *) dav_get_propdb_hooks(request_rec *r); DAV_DECLARE(const dav_hooks_vsn *) dav_get_vsn_hooks(request_rec *r); DAV_DECLARE(const dav_hooks_binding *) dav_get_binding_hooks(request_rec *r); DAV_DECLARE(const dav_hooks_search *) dav_get_search_hooks(request_rec *r); DAV_DECLARE(void) dav_register_provider(apr_pool_t *p, const char *name, const dav_provider *hooks); DAV_DECLARE(const dav_provider *) dav_lookup_provider(const char *name); DAV_DECLARE(const char *) dav_get_provider_name(request_rec *r); DAV_DECLARE(const dav_provider *) dav_get_provider(request_rec *r); /* ### deprecated */ #define DAV_GET_HOOKS_PROPDB(r) dav_get_propdb_hooks(r) #define DAV_GET_HOOKS_LOCKS(r) dav_get_lock_hooks(r) #define DAV_GET_HOOKS_VSN(r) dav_get_vsn_hooks(r) #define DAV_GET_HOOKS_BINDING(r) dav_get_binding_hooks(r) #define DAV_GET_HOOKS_SEARCH(r) dav_get_search_hooks(r) /* -------------------------------------------------------------------- ** ** IF HEADER PROCESSING ** ** Here is the definition of the If: header from RFC 2518, S9.4: ** ** If = "If" ":" (1*No-tag-list | 1*Tagged-list) ** No-tag-list = List ** Tagged-list = Resource 1*List ** Resource = Coded-URL ** List = "(" 1*(["Not"](State-token | "[" entity-tag "]")) ")" ** State-token = Coded-URL ** Coded-URL = "<" absoluteURI ">" ; absoluteURI from RFC 2616 ** ** List corresponds to dav_if_state_list. No-tag-list corresponds to ** dav_if_header with uri==NULL. Tagged-list corresponds to a sequence of ** dav_if_header structures with (duplicate) uri==Resource -- one ** dav_if_header per state_list. A second Tagged-list will start a new ** sequence of dav_if_header structures with the new URI. ** ** A summary of the semantics, mapped into our structures: ** - Chained dav_if_headers: OR ** - Chained dav_if_state_lists: AND ** - NULL uri matches all resources */ typedef enum { dav_if_etag, dav_if_opaquelock, dav_if_unknown /* the "unknown" state type; always matches false. */ } dav_if_state_type; typedef struct dav_if_state_list { dav_if_state_type type; int condition; #define DAV_IF_COND_NORMAL 0 #define DAV_IF_COND_NOT 1 /* "Not" was applied */ const char *etag; dav_locktoken *locktoken; struct dav_if_state_list *next; } dav_if_state_list; typedef struct dav_if_header { const char *uri; apr_size_t uri_len; struct dav_if_state_list *state; struct dav_if_header *next; int dummy_header; /* used internally by the lock/etag validation */ } dav_if_header; typedef struct dav_locktoken_list { dav_locktoken *locktoken; struct dav_locktoken_list *next; } dav_locktoken_list; DAV_DECLARE(dav_error *) dav_get_locktoken_list(request_rec *r, dav_locktoken_list **ltl); /* -------------------------------------------------------------------- ** ** LIVE PROPERTY HANDLING */ /* opaque type for PROPPATCH rollback information */ typedef struct dav_liveprop_rollback dav_liveprop_rollback; struct dav_hooks_liveprop { /* ** Insert property information into a text block. The property to ** insert is identified by the propid value. The information to insert ** is identified by the "what" argument, as follows: ** DAV_PROP_INSERT_NAME ** property name, as an empty XML element ** DAV_PROP_INSERT_VALUE ** property name/value, as an XML element ** DAV_PROP_INSERT_SUPPORTED ** if the property is defined on the resource, then ** a DAV:supported-live-property element, as defined ** by the DeltaV extensions to RFC2518. ** ** Providers should return DAV_PROP_INSERT_NOTDEF if the property is ** known and not defined for this resource, so should be handled as a ** dead property. If a provider recognizes, but does not support, a ** property, and does not want it handled as a dead property, it should ** return DAV_PROP_INSERT_NOTSUPP. ** ** Some DAV extensions, like CalDAV, specify both document elements ** and property elements that need to be taken into account when ** generating a property. The document element and property element ** are made available in the dav_liveprop_elem structure under the ** resource, accessible as follows: ** ** dav_get_liveprop_element(resource); ** ** Returns one of DAV_PROP_INSERT_* based on what happened. ** ** ### we may need more context... ie. the lock database */ dav_prop_insert (*insert_prop)(const dav_resource *resource, int propid, dav_prop_insert what, apr_text_header *phdr); /* ** Determine whether a given property is writable. ** ** ### we may want a different semantic. i.e. maybe it should be ** ### "can we write <value> into this property?" ** ** Returns 1 if the live property can be written, 0 if read-only. */ int (*is_writable)(const dav_resource *resource, int propid); /* ** This member defines the set of namespace URIs that the provider ** uses for its properties. When insert_all is called, it will be ** passed a list of integers that map from indices into this list ** to namespace IDs for output generation. ** ** The last entry in this list should be a NULL value (sentinel). */ const char * const * namespace_uris; /* ** ### this is not the final design. we want an open-ended way for ** ### liveprop providers to attach *new* properties. To this end, ** ### we'll have a "give me a list of the props you define", a way ** ### to check for a prop's existence, a way to validate a set/remove ** ### of a prop, and a way to execute/commit/rollback that change. */ /* ** Validate that the live property can be assigned a value, and that ** the provided value is valid. ** ** elem will point to the XML element that names the property. For ** example: ** <lp1:executable>T</lp1:executable> ** ** The provider can access the cdata fields and the child elements ** to extract the relevant pieces. ** ** operation is one of DAV_PROP_OP_SET or _DELETE. ** ** The provider may return a value in *context which will be passed ** to each of the exec/commit/rollback functions. For example, this ** may contain an internal value which has been processed from the ** input element. ** ** The provider must set defer_to_dead to true (non-zero) or false. ** If true, then the set/remove is deferred to the dead property ** database. Note: it will be set to zero on entry. */ dav_error * (*patch_validate)(const dav_resource *resource, const apr_xml_elem *elem, int operation, void **context, int *defer_to_dead); /* ### doc... */ dav_error * (*patch_exec)(const dav_resource *resource, const apr_xml_elem *elem, int operation, void *context, dav_liveprop_rollback **rollback_ctx); /* ### doc... */ void (*patch_commit)(const dav_resource *resource, int operation, void *context, dav_liveprop_rollback *rollback_ctx); /* ### doc... */ dav_error * (*patch_rollback)(const dav_resource *resource, int operation, void *context, dav_liveprop_rollback *rollback_ctx); /* ** If a provider needs a context to associate with this hooks structure, ** then this field may be used. In most cases, it will just be NULL. */ void *ctx; }; /* ** dav_liveprop_spec: specify a live property ** ** This structure is used as a standard way to determine if a particular ** property is a live property. Its use is not part of the mandated liveprop ** interface, but can be used by liveprop providers in conjunction with the ** utility routines below. ** ** spec->name == NULL is the defined end-sentinel for a list of specs. */ typedef struct { int ns; /* provider-local namespace index */ const char *name; /* name of the property */ int propid; /* provider-local property ID */ int is_writable; /* is the property writable? */ } dav_liveprop_spec; /* ** dav_liveprop_group: specify a group of liveprops ** ** This structure specifies a group of live properties, their namespaces, ** and how to handle them. */ typedef struct { const dav_liveprop_spec *specs; const char * const *namespace_uris; const dav_hooks_liveprop *hooks; } dav_liveprop_group; /* ### docco */ DAV_DECLARE(int) dav_do_find_liveprop(const char *ns_uri, const char *name, const dav_liveprop_group *group, const dav_hooks_liveprop **hooks); /* ### docco */ DAV_DECLARE(long) dav_get_liveprop_info(int propid, const dav_liveprop_group *group, const dav_liveprop_spec **info); /* ### docco */ DAV_DECLARE(void) dav_register_liveprop_group(apr_pool_t *pool, const dav_liveprop_group *group); /* ### docco */ DAV_DECLARE(long) dav_get_liveprop_ns_index(const char *uri); /* ### docco */ DAV_DECLARE(long) dav_get_liveprop_ns_count(void); /* ### docco */ DAV_DECLARE(void) dav_add_all_liveprop_xmlns(apr_pool_t *p, apr_text_header *phdr); typedef struct { const apr_xml_doc *doc; const apr_xml_elem *elem; } dav_liveprop_elem; /* ** When calling insert_prop(), the associated request element and ** document is accessible using the following call. */ DAV_DECLARE(dav_liveprop_elem *) dav_get_liveprop_element(const dav_resource *resource); /* ** The following three functions are part of mod_dav's internal handling ** for the core WebDAV properties. They are not part of mod_dav's API. */ DAV_DECLARE_NONSTD(int) dav_core_find_liveprop( const dav_resource *resource, const char *ns_uri, const char *name, const dav_hooks_liveprop **hooks); DAV_DECLARE_NONSTD(void) dav_core_insert_all_liveprops( request_rec *r, const dav_resource *resource, dav_prop_insert what, apr_text_header *phdr); DAV_DECLARE_NONSTD(void) dav_core_register_uris(apr_pool_t *p); /* ** Standard WebDAV Property Identifiers ** ** A live property provider does not need to use these; they are simply ** provided for convenience. ** ** Property identifiers need to be unique within a given provider, but not ** *across* providers (note: this uniqueness constraint was different in ** older versions of mod_dav). ** ** The identifiers start at 20000 to make it easier for providers to avoid ** conflicts with the standard properties. The properties are arranged ** alphabetically, and may be reordered from time to time (as properties ** are introduced). ** ** NOTE: there is no problem with reordering (e.g. binary compat) since the ** identifiers are only used within a given provider, which would pick up ** the entire set of changes upon a recompile. */ enum { DAV_PROPID_BEGIN = 20000, /* Standard WebDAV properties (RFC 2518) */ DAV_PROPID_creationdate, DAV_PROPID_displayname, DAV_PROPID_getcontentlanguage, DAV_PROPID_getcontentlength, DAV_PROPID_getcontenttype, DAV_PROPID_getetag, DAV_PROPID_getlastmodified, DAV_PROPID_lockdiscovery, DAV_PROPID_resourcetype, DAV_PROPID_source, DAV_PROPID_supportedlock, /* DeltaV properties (from the I-D (#14)) */ DAV_PROPID_activity_checkout_set, DAV_PROPID_activity_set, DAV_PROPID_activity_version_set, DAV_PROPID_auto_merge_set, DAV_PROPID_auto_version, DAV_PROPID_baseline_collection, DAV_PROPID_baseline_controlled_collection, DAV_PROPID_baseline_controlled_collection_set, DAV_PROPID_checked_in, DAV_PROPID_checked_out, DAV_PROPID_checkin_fork, DAV_PROPID_checkout_fork, DAV_PROPID_checkout_set, DAV_PROPID_comment, DAV_PROPID_creator_displayname, DAV_PROPID_current_activity_set, DAV_PROPID_current_workspace_set, DAV_PROPID_default_variant, DAV_PROPID_eclipsed_set, DAV_PROPID_label_name_set, DAV_PROPID_merge_set, DAV_PROPID_precursor_set, DAV_PROPID_predecessor_set, DAV_PROPID_root_version, DAV_PROPID_subactivity_set, DAV_PROPID_subbaseline_set, DAV_PROPID_successor_set, DAV_PROPID_supported_method_set, DAV_PROPID_supported_live_property_set, DAV_PROPID_supported_report_set, DAV_PROPID_unreserved, DAV_PROPID_variant_set, DAV_PROPID_version_controlled_binding_set, DAV_PROPID_version_controlled_configuration, DAV_PROPID_version_history, DAV_PROPID_version_name, DAV_PROPID_workspace, DAV_PROPID_workspace_checkout_set, DAV_PROPID_END }; /* ** Property Identifier Registration ** ** At the moment, mod_dav requires live property providers to ensure that ** each property returned has a unique value. For now, this is done through ** central registration (there are no known providers other than the default, ** so this remains manageable). ** ** WARNING: the TEST ranges should never be "shipped". */ #define DAV_PROPID_CORE 10000 /* ..10099. defined by mod_dav */ #define DAV_PROPID_FS 10100 /* ..10299. mod_dav filesystem provider. */ #define DAV_PROPID_TEST1 10300 /* ..10399 */ #define DAV_PROPID_TEST2 10400 /* ..10499 */ #define DAV_PROPID_TEST3 10500 /* ..10599 */ /* Next: 10600 */ /* -------------------------------------------------------------------- ** ** DATABASE FUNCTIONS */ typedef struct dav_db dav_db; typedef struct dav_namespace_map dav_namespace_map; typedef struct dav_deadprop_rollback dav_deadprop_rollback; typedef struct { const char *ns; /* "" signals "no namespace" */ const char *name; } dav_prop_name; /* hook functions to enable pluggable databases */ struct dav_hooks_propdb { dav_error * (*open)(apr_pool_t *p, const dav_resource *resource, int ro, dav_db **pdb); void (*close)(dav_db *db); /* ** In bulk, define any namespaces that the values and their name ** elements may need. ** ** Note: sometimes mod_dav will defer calling this until output_value ** returns found==1. If the output process needs the dav_xmlns_info ** filled for its work, then it will need to fill it on demand rather ** than depending upon this hook to fill in the structure. ** ** Note: this will *always* be called during an output sequence. Thus, ** the provider may rely solely on using this to fill the xmlns info. */ dav_error * (*define_namespaces)(dav_db *db, dav_xmlns_info *xi); /* ** Output the value from the database (i.e. add an element name and ** the value into *phdr). Set *found based on whether the name/value ** was found in the propdb. ** ** Note: it is NOT an error for the key/value pair to not exist. ** ** The dav_xmlns_info passed to define_namespaces() is also passed to ** each output_value() call so that namespaces can be added on-demand. ** It can also be used to look up prefixes or URIs during the output ** process. */ dav_error * (*output_value)(dav_db *db, const dav_prop_name *name, dav_xmlns_info *xi, apr_text_header *phdr, int *found); /* ** Build a mapping from "global" namespaces (stored in apr_xml_*) ** into provider-local namespace identifiers. ** ** This mapping should be done once per set of namespaces, and the ** resulting mapping should be passed into the store() hook function. ** ** Note: usually, there is just a single document/namespaces for all ** elements passed. However, the generality of creating multiple ** mappings and passing them to store() is provided here. ** ** Note: this is only in preparation for a series of store() calls. ** As a result, the propdb must be open for read/write access when ** this function is called. */ dav_error * (*map_namespaces)(dav_db *db, const apr_array_header_t *namespaces, dav_namespace_map **mapping); /* ** Store a property value for a given name. The value->combined field ** MUST be set for this call. ** ** ### WARNING: current providers will quote the text within ELEM. ** ### this implies you can call this function only once with a given ** ### element structure (a second time will quote it again). */ dav_error * (*store)(dav_db *db, const dav_prop_name *name, const apr_xml_elem *elem, dav_namespace_map *mapping); /* remove a given property */ dav_error * (*remove)(dav_db *db, const dav_prop_name *name); /* returns 1 if the record specified by "key" exists; 0 otherwise */ int (*exists)(dav_db *db, const dav_prop_name *name); /* ** Iterate over the property names in the database. ** ** iter->name.ns == iter->name.name == NULL when there are no more names. ** ** Note: only one iteration may occur over the propdb at a time. */ dav_error * (*first_name)(dav_db *db, dav_prop_name *pname); dav_error * (*next_name)(dav_db *db, dav_prop_name *pname); /* ** Rollback support: get rollback context, and apply it. ** ** struct dav_deadprop_rollback is a provider-private structure; it ** should remember the name, and the name's old value (or the fact that ** the value was not present, and should be deleted if a rollback occurs). */ dav_error * (*get_rollback)(dav_db *db, const dav_prop_name *name, dav_deadprop_rollback **prollback); dav_error * (*apply_rollback)(dav_db *db, dav_deadprop_rollback *rollback); /* ** If a provider needs a context to associate with this hooks structure, ** then this field may be used. In most cases, it will just be NULL. */ void *ctx; }; /* -------------------------------------------------------------------- ** ** LOCK FUNCTIONS */ /* Used to represent a Timeout header of "Infinity" */ #define DAV_TIMEOUT_INFINITE 0 DAV_DECLARE(time_t) dav_get_timeout(request_rec *r); /* ** Opaque, provider-specific information for a lock database. */ typedef struct dav_lockdb_private dav_lockdb_private; /* ** Opaque, provider-specific information for a lock record. */ typedef struct dav_lock_private dav_lock_private; /* ** Lock database type. Lock providers are urged to implement a "lazy" open, so ** doing an "open" is cheap until something is actually needed from the DB. */ typedef struct { const dav_hooks_locks *hooks; /* the hooks used for this lockdb */ int ro; /* was it opened readonly? */ dav_lockdb_private *info; } dav_lockdb; typedef enum { DAV_LOCKSCOPE_UNKNOWN, DAV_LOCKSCOPE_EXCLUSIVE, DAV_LOCKSCOPE_SHARED } dav_lock_scope; typedef enum { DAV_LOCKTYPE_UNKNOWN, DAV_LOCKTYPE_WRITE } dav_lock_type; typedef enum { DAV_LOCKREC_DIRECT, /* lock asserted on this resource */ DAV_LOCKREC_INDIRECT, /* lock inherited from a parent */ DAV_LOCKREC_INDIRECT_PARTIAL /* most info is not filled in */ } dav_lock_rectype; /* ** dav_lock: hold information about a lock on a resource. ** ** This structure is used for both direct and indirect locks. A direct lock ** is a lock applied to a specific resource by the client. An indirect lock ** is one that is inherited from a parent resource by virtue of a non-zero ** Depth: header when the lock was applied. ** ** mod_dav records both types of locks in the lock database, managing their ** addition/removal as resources are moved about the namespace. ** ** Note that the lockdb is free to marshal this structure in any form that ** it likes. ** ** For a "partial" lock, the <rectype> and <locktoken> fields must be filled ** in. All other (user) fields should be zeroed. The lock provider will ** usually fill in the <info> field, and the <next> field may be used to ** construct a list of partial locks. ** ** The lock provider MUST use the info field to store a value such that a ** dav_lock structure can locate itself in the underlying lock database. ** This requirement is needed for refreshing: when an indirect dav_lock is ** refreshed, its reference to the direct lock does not specify the direct's ** resource, so the only way to locate the (refreshed, direct) lock in the ** database is to use the info field. ** ** Note that <is_locknull> only refers to the resource where this lock was ** found. ** ### hrm. that says the abstraction is wrong. is_locknull may disappear. */ typedef struct dav_lock { dav_lock_rectype rectype; /* type of lock record */ int is_locknull; /* lock establishes a locknull resource */ /* ### put the resource in here? */ dav_lock_scope scope; /* scope of the lock */ dav_lock_type type; /* type of lock */ int depth; /* depth of the lock */ time_t timeout; /* when the lock will timeout */ const dav_locktoken *locktoken; /* the token that was issued */ const char *owner; /* (XML) owner of the lock */ const char *auth_user; /* auth'd username owning lock */ dav_lock_private *info; /* private to the lockdb */ struct dav_lock *next; /* for managing a list of locks */ } dav_lock; /* Property-related public lock functions */ DAV_DECLARE(const char *)dav_lock_get_activelock(request_rec *r, dav_lock *locks, dav_buffer *pbuf); /* LockDB-related public lock functions */ DAV_DECLARE(dav_error *) dav_open_lockdb(request_rec *r, int ro, dav_lockdb **lockdb); DAV_DECLARE(void) dav_close_lockdb(dav_lockdb *lockdb); DAV_DECLARE(dav_error *) dav_lock_parse_lockinfo(request_rec *r, const dav_resource *resource, dav_lockdb *lockdb, const apr_xml_doc *doc, dav_lock **lock_request); DAV_DECLARE(int) dav_unlock(request_rec *r, const dav_resource *resource, const dav_locktoken *locktoken); DAV_DECLARE(dav_error *) dav_add_lock(request_rec *r, const dav_resource *resource, dav_lockdb *lockdb, dav_lock *request, dav_response **response); DAV_DECLARE(dav_error *) dav_notify_created(request_rec *r, dav_lockdb *lockdb, const dav_resource *resource, int resource_state, int depth); DAV_DECLARE(dav_error*) dav_lock_query(dav_lockdb *lockdb, const dav_resource *resource, dav_lock **locks); DAV_DECLARE(dav_error *) dav_validate_request(request_rec *r, dav_resource *resource, int depth, dav_locktoken *locktoken, dav_response **response, int flags, dav_lockdb *lockdb); /* ** flags: ** 0x0F -- reserved for <dav_lock_scope> values ** ** other flags, detailed below */ #define DAV_VALIDATE_RESOURCE 0x0010 /* validate just the resource */ #define DAV_VALIDATE_PARENT 0x0020 /* validate resource AND its parent */ #define DAV_VALIDATE_ADD_LD 0x0040 /* add DAV:lockdiscovery into the 424 DAV:response */ #define DAV_VALIDATE_USE_424 0x0080 /* return 424 status, not 207 */ #define DAV_VALIDATE_IS_PARENT 0x0100 /* for internal use */ #define DAV_VALIDATE_NO_MODIFY 0x0200 /* resource is not being modified so allow even if lock token is not provided */ /* Lock-null related public lock functions */ DAV_DECLARE(int) dav_get_resource_state(request_rec *r, const dav_resource *resource); /* Lock provider hooks. Locking is optional, so there may be no * lock provider for a given repository. */ struct dav_hooks_locks { /* Return the supportedlock property for a resource */ const char * (*get_supportedlock)( const dav_resource *resource ); /* Parse a lock token URI, returning a lock token object allocated * in the given pool. */ dav_error * (*parse_locktoken)( apr_pool_t *p, const char *char_token, dav_locktoken **locktoken_p ); /* Format a lock token object into a URI string, allocated in * the given pool. * * Always returns non-NULL. */ const char * (*format_locktoken)( apr_pool_t *p, const dav_locktoken *locktoken ); /* Compare two lock tokens. * * Result < 0 => lt1 < lt2 * Result == 0 => lt1 == lt2 * Result > 0 => lt1 > lt2 */ int (*compare_locktoken)( const dav_locktoken *lt1, const dav_locktoken *lt2 ); /* Open the provider's lock database. * * The provider may or may not use a "real" database for locks * (a lock could be an attribute on a resource, for example). * * The provider may choose to use the value of the DAVLockDB directive * (as returned by dav_get_lockdb_path()) to decide where to place * any storage it may need. * * The request storage pool should be associated with the lockdb, * so it can be used in subsequent operations. * * If ro != 0, only readonly operations will be performed. * If force == 0, the open can be "lazy"; no subsequent locking operations * may occur. * If force != 0, locking operations will definitely occur. */ dav_error * (*open_lockdb)( request_rec *r, int ro, int force, dav_lockdb **lockdb ); /* Indicates completion of locking operations */ void (*close_lockdb)( dav_lockdb *lockdb ); /* Take a resource out of the lock-null state. */ dav_error * (*remove_locknull_state)( dav_lockdb *lockdb, const dav_resource *resource ); /* ** Create a (direct) lock structure for the given resource. A locktoken ** will be created. ** ** The lock provider may store private information into lock->info. */ dav_error * (*create_lock)(dav_lockdb *lockdb, const dav_resource *resource, dav_lock **lock); /* ** Get the locks associated with the specified resource. ** ** If resolve_locks is true (non-zero), then any indirect locks are ** resolved to their actual, direct lock (i.e. the reference to followed ** to the original lock). ** ** The locks, if any, are returned as a linked list in no particular ** order. If no locks are present, then *locks will be NULL. */ dav_error * (*get_locks)(dav_lockdb *lockdb, const dav_resource *resource, int calltype, dav_lock **locks); #define DAV_GETLOCKS_RESOLVED 0 /* resolve indirects to directs */ #define DAV_GETLOCKS_PARTIAL 1 /* leave indirects partially filled */ #define DAV_GETLOCKS_COMPLETE 2 /* fill out indirect locks */ /* ** Find a particular lock on a resource (specified by its locktoken). ** ** *lock will be set to NULL if the lock is not found. ** ** Note that the provider can optimize the unmarshalling -- only one ** lock (or none) must be constructed and returned. ** ** If partial_ok is true (non-zero), then an indirect lock can be ** partially filled in. Otherwise, another lookup is done and the ** lock structure will be filled out as a DAV_LOCKREC_INDIRECT. */ dav_error * (*find_lock)(dav_lockdb *lockdb, const dav_resource *resource, const dav_locktoken *locktoken, int partial_ok, dav_lock **lock); /* ** Quick test to see if the resource has *any* locks on it. ** ** This is typically used to determine if a non-existent resource ** has a lock and is (therefore) a locknull resource. ** ** WARNING: this function may return TRUE even when timed-out locks ** exist (i.e. it may not perform timeout checks). */ dav_error * (*has_locks)(dav_lockdb *lockdb, const dav_resource *resource, int *locks_present); /* ** Append the specified lock(s) to the set of locks on this resource. ** ** If "make_indirect" is true (non-zero), then the specified lock(s) ** should be converted to an indirect lock (if it is a direct lock) ** before appending. Note that the conversion to an indirect lock does ** not alter the passed-in lock -- the change is internal the ** append_locks function. ** ** Multiple locks are specified using the lock->next links. */ dav_error * (*append_locks)(dav_lockdb *lockdb, const dav_resource *resource, int make_indirect, const dav_lock *lock); /* ** Remove any lock that has the specified locktoken. ** ** If locktoken == NULL, then ALL locks are removed. */ dav_error * (*remove_lock)(dav_lockdb *lockdb, const dav_resource *resource, const dav_locktoken *locktoken); /* ** Refresh all locks, found on the specified resource, which has a ** locktoken in the provided list. ** ** If the lock is indirect, then the direct lock is referenced and ** refreshed. ** ** Each lock that is updated is returned in the <locks> argument. ** Note that the locks will be fully resolved. */ dav_error * (*refresh_locks)(dav_lockdb *lockdb, const dav_resource *resource, const dav_locktoken_list *ltl, time_t new_time, dav_lock **locks); /* ** Look up the resource associated with a particular locktoken. ** ** The search begins at the specified <start_resource> and the lock ** specified by <locktoken>. ** ** If the resource/token specifies an indirect lock, then the direct ** lock will be looked up, and THAT resource will be returned. In other ** words, this function always returns the resource where a particular ** lock (token) was asserted. ** ** NOTE: this function pointer is allowed to be NULL, indicating that ** the provider does not support this type of functionality. The ** caller should then traverse up the repository hierarchy looking ** for the resource defining a lock with this locktoken. */ dav_error * (*lookup_resource)(dav_lockdb *lockdb, const dav_locktoken *locktoken, const dav_resource *start_resource, const dav_resource **resource); /* ** If a provider needs a context to associate with this hooks structure, ** then this field may be used. In most cases, it will just be NULL. */ void *ctx; }; /* what types of resources can be discovered by dav_get_resource_state() */ #define DAV_RESOURCE_LOCK_NULL 10 /* resource lock-null */ #define DAV_RESOURCE_NULL 11 /* resource null */ #define DAV_RESOURCE_EXISTS 12 /* resource exists */ #define DAV_RESOURCE_ERROR 13 /* an error occurred */ /* -------------------------------------------------------------------- ** ** PROPERTY HANDLING */ typedef struct dav_propdb dav_propdb; #define DAV_PROPDB_NONE 0 #define DAV_PROPDB_RO 1 #define DAV_PROPDB_DISABLE_LOCKDISCOVERY 2 DAV_DECLARE(dav_error *) dav_open_propdb( request_rec *r, dav_lockdb *lockdb, const dav_resource *resource, int flags, apr_array_header_t *ns_xlate, dav_propdb **propdb); DAV_DECLARE(dav_error *) dav_popen_propdb( apr_pool_t *p, request_rec *r, dav_lockdb *lockdb, const dav_resource *resource, int flags, apr_array_header_t *ns_xlate, dav_propdb **propdb); DAV_DECLARE(void) dav_close_propdb(dav_propdb *db); DAV_DECLARE(dav_get_props_result) dav_get_props( dav_propdb *db, apr_xml_doc *doc); DAV_DECLARE(dav_get_props_result) dav_get_allprops( dav_propdb *db, dav_prop_insert what); DAV_DECLARE(void) dav_get_liveprop_supported( dav_propdb *propdb, const char *ns_uri, const char *propname, apr_text_header *body); /* ** 3-phase property modification. ** ** 1) validate props. readable? unlocked? ACLs allow access? ** 2) execute operation (set/delete) ** 3) commit or rollback ** ** ### eventually, auth must be available. a ref to the request_rec (which ** ### contains the auth info) should be in the shared context struct. ** ** Each function may alter the error values and information contained within ** the context record. This should be done as an "increasing" level of ** error, rather than overwriting any previous error. ** ** Note that commit() cannot generate errors. It should simply free the ** rollback information. ** ** rollback() may generate additional errors because the rollback operation ** can sometimes fail(!). ** ** The caller should allocate an array of these, one per operation. It should ** be zero-initialized, then the db, operation, and prop fields should be ** filled in before calling dav_prop_validate. Note that the set/delete ** operations are order-dependent. For a given (logical) context, the same ** pointer must be passed to each phase. ** ** error_type is an internal value, but will have the same numeric value ** for each possible "desc" value. This allows the caller to group the ** descriptions via the error_type variable, rather than through string ** comparisons. Note that "status" does not provide enough granularity to ** differentiate/group the "desc" values. ** ** Note that the propdb will maintain some (global) context across all ** of the property change contexts. This implies that you can have only ** one open transaction per propdb. */ typedef struct dav_prop_ctx { dav_propdb *propdb; apr_xml_elem *prop; /* property to affect */ int operation; #define DAV_PROP_OP_SET 1 /* set a property value */ #define DAV_PROP_OP_DELETE 2 /* delete a prop value */ /* ### add a GET? */ /* private items to the propdb */ int is_liveprop; void *liveprop_ctx; struct dav_rollback_item *rollback; /* optional rollback info */ dav_error *err; /* error (if any) */ /* private to mod_dav.c */ request_rec *r; } dav_prop_ctx; DAV_DECLARE_NONSTD(void) dav_prop_validate(dav_prop_ctx *ctx); DAV_DECLARE_NONSTD(void) dav_prop_exec(dav_prop_ctx *ctx); DAV_DECLARE_NONSTD(void) dav_prop_commit(dav_prop_ctx *ctx); DAV_DECLARE_NONSTD(void) dav_prop_rollback(dav_prop_ctx *ctx); #define DAV_PROP_CTX_HAS_ERR(dpc) ((dpc).err && (dpc).err->status >= HTTP_MULTIPLE_CHOICES) /* -------------------------------------------------------------------- ** ** WALKER STRUCTURE */ enum { DAV_CALLTYPE_MEMBER = 1, /* called for a member resource */ DAV_CALLTYPE_COLLECTION, /* called for a collection */ DAV_CALLTYPE_LOCKNULL /* called for a locknull resource */ }; typedef struct { /* the client-provided context */ void *walk_ctx; /* pool to use for allocations in the callback */ apr_pool_t *pool; /* the current resource */ const dav_resource *resource; /* OUTPUT: add responses to this */ dav_response *response; } dav_walk_resource; typedef struct { int walk_type; #define DAV_WALKTYPE_AUTH 0x0001 /* limit to authorized files */ #define DAV_WALKTYPE_NORMAL 0x0002 /* walk normal files */ #define DAV_WALKTYPE_LOCKNULL 0x0004 /* walk locknull resources */ #define DAV_WALKTYPE_TOLERANT 0x0008 /* tolerate non-fatal errors */ /* callback function and a client context for the walk */ dav_error * (*func)(dav_walk_resource *wres, int calltype); void *walk_ctx; /* what pool to use for allocations needed by walk logic */ apr_pool_t *pool; /* beginning root of the walk */ const dav_resource *root; /* lock database to enable walking LOCKNULL resources */ dav_lockdb *lockdb; } dav_walk_params; /* directory tree walking context */ typedef struct dav_walker_ctx { /* input: */ dav_walk_params w; /* ### client data... phasing out this big glom */ /* this brigade buffers data being sent to r->output_filters */ apr_bucket_brigade *bb; /* a scratch pool, used to stream responses and iteratively cleared. */ apr_pool_t *scratchpool; request_rec *r; /* original request */ /* for PROPFIND operations */ apr_xml_doc *doc; int propfind_type; #define DAV_PROPFIND_IS_ALLPROP 1 #define DAV_PROPFIND_IS_PROPNAME 2 #define DAV_PROPFIND_IS_PROP 3 apr_text *propstat_404; /* (cached) propstat giving a 404 error */ const dav_if_header *if_header; /* for validation */ const dav_locktoken *locktoken; /* for UNLOCK */ const dav_lock *lock; /* for LOCK */ int skip_root; /* for dav_inherit_locks() */ int flags; dav_buffer work_buf; /* for dav_validate_request() */ } dav_walker_ctx; DAV_DECLARE(void) dav_add_response(dav_walk_resource *wres, int status, dav_get_props_result *propstats); /* -------------------------------------------------------------------- ** ** "STREAM" STRUCTURE ** ** mod_dav uses this abstraction for interacting with the repository ** while fetching/storing resources. mod_dav views resources as a stream ** of bytes. ** ** Note that the structure is opaque -- it is private to the repository ** that created the stream in the repository's "open" function. ** ** ### THIS STUFF IS GOING AWAY ... GET/read requests are handled by ** ### having the provider jam stuff straight into the filter stack. ** ### this is only left for handling PUT/write requests. */ typedef struct dav_stream dav_stream; typedef enum { DAV_MODE_WRITE_TRUNC, /* truncate and open for writing */ DAV_MODE_WRITE_SEEKABLE /* open for writing; random access */ } dav_stream_mode; /* -------------------------------------------------------------------- ** ** REPOSITORY FUNCTIONS */ /* Repository provider hooks */ struct dav_hooks_repository { /* Flag for whether repository requires special GET handling. * If resources in the repository are not visible in the * filesystem location which URLs map to, then special handling * is required to first fetch a resource from the repository, * respond to the GET request, then free the resource copy. */ int handle_get; /* Get a resource descriptor for the URI in a request. A descriptor * should always be returned even if the resource does not exist. This * repository has been identified as handling the resource given by * the URI, so an answer must be given. If there is a problem with the * URI or accessing the resource or whatever, then an error should be * returned. * * root_dir: * the root of the directory for which this repository is configured. * * label: * if a Label: header is present (and allowed), this is the label * to use to identify a version resource from the resource's * corresponding version history. Otherwise, it will be NULL. * * use_checked_in: * use the DAV:checked-in property of the resource identified by the * Request-URI to identify and return a version resource * * The provider may associate the request storage pool with the resource * (in the resource->pool field), to use in other operations on that * resource. */ dav_error * (*get_resource)( request_rec *r, const char *root_dir, const char *label, int use_checked_in, dav_resource **resource ); /* Get a resource descriptor for the parent of the given resource. * The resources need not exist. NULL is returned if the resource * is the root collection. * * An error should be returned only if there is a fatal error in * fetching information about the parent resource. */ dav_error * (*get_parent_resource)( const dav_resource *resource, dav_resource **parent_resource ); /* Determine whether two resource descriptors refer to the same resource. * * Result != 0 => the resources are the same. */ int (*is_same_resource)( const dav_resource *res1, const dav_resource *res2 ); /* Determine whether one resource is a parent (immediate or otherwise) * of another. * * Result != 0 => res1 is a parent of res2. */ int (*is_parent_resource)( const dav_resource *res1, const dav_resource *res2 ); /* ** Open a stream for this resource, using the specified mode. The ** stream will be returned in *stream. */ dav_error * (*open_stream)(const dav_resource *resource, dav_stream_mode mode, dav_stream **stream); /* ** Close the specified stream. ** ** mod_dav will (ideally) make sure to call this. For safety purposes, ** a provider should (ideally) register a cleanup function with the ** request pool to get this closed and cleaned up. ** ** Note the possibility of an error from the close -- it is entirely ** feasible that the close does a "commit" of some kind, which can ** produce an error. ** ** commit should be TRUE (non-zero) or FALSE (0) if the stream was ** opened for writing. This flag states whether to retain the file ** or not. ** Note: the commit flag is ignored for streams opened for reading. */ dav_error * (*close_stream)(dav_stream *stream, int commit); /* ** Write data to the stream. ** ** All of the bytes must be written, or an error should be returned. */ dav_error * (*write_stream)(dav_stream *stream, const void *buf, apr_size_t bufsize); /* ** Seek to an absolute position in the stream. This is used to support ** Content-Range in a GET/PUT. ** ** NOTE: if this function is NULL (which is allowed), then any ** operations using Content-Range will be refused. */ dav_error * (*seek_stream)(dav_stream *stream, apr_off_t abs_position); /* ** If a GET is processed using a stream (open_stream, read_stream) ** rather than via a sub-request (on get_pathname), then this function ** is used to provide the repository with a way to set the headers ** in the response. ** ** This function may be called without a following deliver(), to ** handle a HEAD request. ** ** This may be NULL if handle_get is FALSE. */ dav_error * (*set_headers)(request_rec *r, const dav_resource *resource); /* ** The provider should deliver the resource into the specified filter. ** Basically, this is the response to the GET method. ** ** Note that this is called for all resources, including collections. ** The provider should determine what has content to deliver or not. ** ** set_headers will be called prior to this function, allowing the ** provider to set the appropriate response headers. ** ** This may be NULL if handle_get is FALSE. ** ### maybe toss handle_get and just use this function as the marker */ dav_error * (*deliver)(const dav_resource *resource, ap_filter_t *output); /* Create a collection resource. The resource must not already exist. * * Result == NULL if the collection was created successfully. Also, the * resource object is updated to reflect that the resource exists, and * is a collection. */ dav_error * (*create_collection)( dav_resource *resource ); /* Copy one resource to another. The destination may exist, if it is * versioned. * Handles both files and collections. Properties are copied as well. * If the destination exists and is versioned, the provider must update * the destination to have identical content to the source, * recursively for collections. * The depth argument is ignored for a file, and can be either 0 or * DAV_INFINITY for a collection. * If an error occurs in a child resource, then the return value is * non-NULL, and *response is set to a multistatus response. * If the copy is successful, the dst resource object is * updated to reflect that the resource exists. */ dav_error * (*copy_resource)( const dav_resource *src, dav_resource *dst, int depth, dav_response **response ); /* Move one resource to another. The destination must not exist. * Handles both files and collections. Properties are moved as well. * If an error occurs in a child resource, then the return value is * non-NULL, and *response is set to a multistatus response. * If the move is successful, the src and dst resource objects are * updated to reflect that the source no longer exists, and the * destination does. */ dav_error * (*move_resource)( dav_resource *src, dav_resource *dst, dav_response **response ); /* Remove a resource. Handles both files and collections. * Removes any associated properties as well. * If an error occurs in a child resource, then the return value is * non-NULL, and *response is set to a multistatus response. * If the delete is successful, the resource object is updated to * reflect that the resource no longer exists. */ dav_error * (*remove_resource)( dav_resource *resource, dav_response **response ); /* Walk a resource hierarchy. * * Iterates over the resource hierarchy specified by params->root. * Control of the walk and the callback are specified by 'params'. * * An error may be returned. *response will contain multistatus * responses (if any) suitable for the body of the error. It is also * possible to return NULL, yet still have multistatus responses. * In this case, typically the caller should return a 207 (Multistatus) * and the responses (in the body) as the HTTP response. */ dav_error * (*walk)(const dav_walk_params *params, int depth, dav_response **response); /* Get the entity tag for a resource */ const char * (*getetag)(const dav_resource *resource); /* ** If a provider needs a context to associate with this hooks structure, ** then this field may be used. In most cases, it will just be NULL. */ void *ctx; /* Get the request rec for a resource */ request_rec * (*get_request_rec)(const dav_resource *resource); /* Get the pathname for a resource */ const char * (*get_pathname)(const dav_resource *resource); }; /* -------------------------------------------------------------------- ** ** VERSIONING FUNCTIONS */ /* dav_add_vary_header * * If there were any headers in the request which require a Vary header * in the response, add it. */ DAV_DECLARE(void) dav_add_vary_header(request_rec *in_req, request_rec *out_req, const dav_resource *resource); /* ** Flags specifying auto-versioning behavior, returned by ** the auto_versionable hook. The value returned depends ** on both the state of the resource and the value of the ** DAV:auto-versioning property for the resource. ** ** If the resource does not exist (null or lock-null), ** DAV_AUTO_VERSION_ALWAYS causes creation of a new version-controlled resource ** ** If the resource is checked in, ** DAV_AUTO_VERSION_ALWAYS causes it to be checked out always, ** DAV_AUTO_VERSION_LOCKED causes it to be checked out only when locked ** ** If the resource is checked out, ** DAV_AUTO_VERSION_ALWAYS causes it to be checked in always, ** DAV_AUTO_VERSION_LOCKED causes it to be checked in when unlocked ** (note: a provider should allow auto-checkin only for resources which ** were automatically checked out) ** ** In all cases, DAV_AUTO_VERSION_NEVER results in no auto-versioning behavior. */ typedef enum { DAV_AUTO_VERSION_NEVER, DAV_AUTO_VERSION_ALWAYS, DAV_AUTO_VERSION_LOCKED } dav_auto_version; /* ** This structure is used to record what auto-versioning operations ** were done to make a resource writable, so that they can be undone ** at the end of a request. */ typedef struct { int resource_versioned; /* 1 => resource was auto-version-controlled */ int resource_checkedout; /* 1 => resource was auto-checked-out */ int parent_checkedout; /* 1 => parent was auto-checked-out */ dav_resource *parent_resource; /* parent resource, if it was needed */ } dav_auto_version_info; /* Ensure that a resource is writable. If there is no versioning * provider, then this is essentially a no-op. Versioning repositories * require explicit resource creation and checkout before they can * be written to. If a new resource is to be created, or an existing * resource deleted, the parent collection must be checked out as well. * * Set the parent_only flag to only make the parent collection writable. * Otherwise, both parent and child are made writable as needed. If the * child does not exist, then a new versioned resource is created and * checked out. * * If auto-versioning is not enabled for a versioned resource, then an error is * returned, since the resource cannot be modified. * * The dav_auto_version_info structure is filled in with enough information * to restore both parent and child resources to the state they were in * before the auto-versioning operations occurred. */ DAV_DECLARE(dav_error *) dav_auto_checkout( request_rec *r, dav_resource *resource, int parent_only, dav_auto_version_info *av_info); /* Revert the writability of resources back to what they were * before they were modified. If undo == 0, then the resource * modifications are maintained (i.e. they are checked in). * If undo != 0, then resource modifications are discarded * (i.e. they are unchecked out). * * Set the unlock flag to indicate that the resource is about * to be unlocked; it will be checked in if the resource * auto-versioning property indicates it should be. In this case, * av_info is ignored, so it can be NULL. * * The resource argument may be NULL if only the parent resource * was checked out (i.e. the parent_only was != 0 in the * dav_auto_checkout call). */ DAV_DECLARE(dav_error *) dav_auto_checkin( request_rec *r, dav_resource *resource, int undo, int unlock, dav_auto_version_info *av_info); /* ** This structure is used to describe available reports ** ** "nmspace" should be valid XML and URL-quoted. mod_dav will place ** double-quotes around it and use it in an xmlns declaration. */ typedef struct { const char *nmspace; /* namespace of the XML report element */ const char *name; /* element name for the XML report */ } dav_report_elem; /* Versioning provider hooks */ struct dav_hooks_vsn { /* ** MANDATORY HOOKS ** The following hooks are mandatory for all versioning providers; ** they define the functionality needed to implement "core" versioning. */ /* Return supported versioning options. * Each dav_text item in the list will be returned as a separate * DAV header. Providers are advised to limit the length of an * individual text item to 63 characters, to conform to the limit * used by MS Web Folders. */ void (*get_vsn_options)(apr_pool_t *p, apr_text_header *phdr); /* Get the value of a specific option for an OPTIONS request. * The option being requested is given by the parsed XML * element object "elem". The value of the option should be * appended to the "option" text object. */ dav_error * (*get_option)(const dav_resource *resource, const apr_xml_elem *elem, apr_text_header *option); /* Determine whether a non-versioned (or non-existent) resource * is versionable. Returns != 0 if resource can be versioned. */ int (*versionable)(const dav_resource *resource); /* Determine whether auto-versioning is enabled for a resource * (which may not exist, or may not be versioned). If the resource * is a checked-out resource, the provider must only enable * auto-checkin if the resource was automatically checked out. * * The value returned depends on both the state of the resource * and the value of its DAV:auto-version property. See the description * of the dav_auto_version enumeration above for the details. */ dav_auto_version (*auto_versionable)(const dav_resource *resource); /* Put a resource under version control. If the resource already * exists unversioned, then it becomes the initial version of the * new version history, and it is replaced by a version selector * which targets the new version. * * If the resource does not exist, then a new version-controlled * resource is created which either targets an existing version (if the * "target" argument is not NULL), or the initial, empty version * in a new history resource (if the "target" argument is NULL). * * If successful, the resource object state is updated appropriately * (that is, changed to refer to the new version-controlled resource). */ dav_error * (*vsn_control)(dav_resource *resource, const char *target); /* Checkout a resource. If successful, the resource * object state is updated appropriately. * * The auto_checkout flag will be set if this checkout is being * done automatically, as part of some method which modifies * the resource. The provider must remember that the resource * was automatically checked out, so it can determine whether it * can be automatically checked in. (Auto-checkin should only be * enabled for resources which were automatically checked out.) * * If the working resource has a different URL from the * target resource, a dav_resource descriptor is returned * for the new working resource. Otherwise, the original * resource descriptor will refer to the working resource. * The working_resource argument can be NULL if the caller * is not interested in the working resource. * * If the client has specified DAV:unreserved or DAV:fork-ok in the * checkout request, then the corresponding flags are set. If * DAV:activity-set has been specified, then create_activity is set * if DAV:new was specified; otherwise, the DAV:href elements' CDATA * (the actual href text) is passed in the "activities" array (each * element of the array is a const char *). activities will be NULL * no DAV:activity-set was provided or when create_activity is set. */ dav_error * (*checkout)(dav_resource *resource, int auto_checkout, int is_unreserved, int is_fork_ok, int create_activity, apr_array_header_t *activities, dav_resource **working_resource); /* Uncheckout a checked-out resource. If successful, the resource * object state is updated appropriately. */ dav_error * (*uncheckout)(dav_resource *resource); /* Checkin a checked-out resource. If successful, the resource * object state is updated appropriately, and the * version_resource descriptor will refer to the new version. * The version_resource argument can be NULL if the caller * is not interested in the new version resource. * * If the client has specified DAV:keep-checked-out in the checkin * request, then the keep_checked_out flag is set. The provider * should create a new version, but keep the resource in the * checked-out state. */ dav_error * (*checkin)(dav_resource *resource, int keep_checked_out, dav_resource **version_resource); /* ** Return the set of reports available at this resource. ** ** An array of report elements should be returned, with an end-marker ** element containing namespace==NULL. The value of the ** DAV:supported-report-set property will be constructed and ** returned. */ dav_error * (*avail_reports)(const dav_resource *resource, const dav_report_elem **reports); /* ** Determine whether a Label header can be used ** with a particular report. The dav_xml_doc structure ** contains the parsed report request body. ** Returns 0 if the Label header is not allowed. */ int (*report_label_header_allowed)(const apr_xml_doc *doc); /* ** Generate a report on a resource. Since a provider is free ** to define its own reports, and the value of request headers ** may affect the interpretation of a report, the request record ** must be passed to this routine. ** ** The dav_xml_doc structure contains the parsed report request ** body. The report response should be generated into the specified ** output filter. ** ** If an error occurs, and a response has not yet been generated, ** then an error can be returned from this function. mod_dav will ** construct an appropriate error response. Once some output has ** been placed into the filter, however, the provider should not ** return an error -- there is no way that mod_dav can deliver it ** properly. ** ** ### maybe we need a way to signal an error anyways, and then ** ### apache can abort the connection? */ dav_error * (*deliver_report)(request_rec *r, const dav_resource *resource, const apr_xml_doc *doc, ap_filter_t *output); /* ** OPTIONAL HOOKS ** The following hooks are optional; if not defined, then the ** corresponding protocol methods will be unsupported. */ /* ** Set the state of a checked-in version-controlled resource. ** ** If the request specified a version, the version resource ** represents that version. If the request specified a label, ** then "version" is NULL, and "label" is the label. ** ** The depth argument is ignored for a file, and can be 0, 1, or ** DAV_INFINITY for a collection. The depth argument only applies ** with a label, not a version. ** ** If an error occurs in a child resource, then the return value is ** non-NULL, and *response is set to a multistatus response. ** ** This hook is optional; if not defined, then the UPDATE method ** will not be supported. */ dav_error * (*update)(const dav_resource *resource, const dav_resource *version, const char *label, int depth, dav_response **response); /* ** Add a label to a version. The resource is either a specific ** version, or a version selector, in which case the label should ** be added to the current target of the version selector. The ** version selector cannot be checked out. ** ** If replace != 0, any existing label by the same name is ** effectively deleted first. Otherwise, it is an error to ** attempt to add a label which already exists on some version ** of the same history resource. ** ** This hook is optional; if not defined, then the LABEL method ** will not be supported. If it is defined, then the remove_label ** hook must be defined also. */ dav_error * (*add_label)(const dav_resource *resource, const char *label, int replace); /* ** Remove a label from a version. The resource is either a specific ** version, or a version selector, in which case the label should ** be added to the current target of the version selector. The ** version selector cannot be checked out. ** ** It is an error if no such label exists on the specified version. ** ** This hook is optional, but if defined, the add_label hook ** must be defined also. */ dav_error * (*remove_label)(const dav_resource *resource, const char *label); /* ** Determine whether a null resource can be created as a workspace. ** The provider may restrict workspaces to certain locations. ** Returns 0 if the resource cannot be a workspace. ** ** This hook is optional; if the provider does not support workspaces, ** it should be set to NULL. */ int (*can_be_workspace)(const dav_resource *resource); /* ** Create a workspace resource. The resource must not already ** exist. Any <DAV:mkworkspace> element is passed to the provider ** in the "doc" structure; it may be empty. ** ** If workspace creation is successful, the state of the resource ** object is updated appropriately. ** ** This hook is optional; if the provider does not support workspaces, ** it should be set to NULL. */ dav_error * (*make_workspace)(dav_resource *resource, apr_xml_doc *doc); /* ** Determine whether a null resource can be created as an activity. ** The provider may restrict activities to certain locations. ** Returns 0 if the resource cannot be an activity. ** ** This hook is optional; if the provider does not support activities, ** it should be set to NULL. */ int (*can_be_activity)(const dav_resource *resource); /* ** Create an activity resource. The resource must not already ** exist. ** ** If activity creation is successful, the state of the resource ** object is updated appropriately. ** ** This hook is optional; if the provider does not support activities, ** it should be set to NULL. */ dav_error * (*make_activity)(dav_resource *resource); /* ** Merge a resource (tree) into target resource (tree). ** ** ### more doc... ** ** This hook is optional; if the provider does not support merging, ** then this should be set to NULL. */ dav_error * (*merge)(dav_resource *target, dav_resource *source, int no_auto_merge, int no_checkout, apr_xml_elem *prop_elem, ap_filter_t *output); /* ** If a provider needs a context to associate with this hooks structure, ** then this field may be used. In most cases, it will just be NULL. */ void *ctx; }; /* -------------------------------------------------------------------- ** ** BINDING FUNCTIONS */ /* binding provider hooks */ struct dav_hooks_binding { /* Determine whether a resource can be the target of a binding. * Returns 0 if the resource cannot be a binding target. */ int (*is_bindable)(const dav_resource *resource); /* Create a binding to a resource. * The resource argument is the target of the binding; * the binding argument must be a resource which does not already * exist. */ dav_error * (*bind_resource)(const dav_resource *resource, dav_resource *binding); /* ** If a provider needs a context to associate with this hooks structure, ** then this field may be used. In most cases, it will just be NULL. */ void *ctx; }; /* -------------------------------------------------------------------- ** ** SEARCH(DASL) FUNCTIONS */ /* search provider hooks */ struct dav_hooks_search { /* Set header for a OPTION method * An error may be returned. * To set a hadder, this function might call * apr_table_setn(r->headers_out, "DASL", dasl_optin1); * * Examples: * DASL: <DAV:basicsearch> * DASL: <http://foo.bar.com/syntax1> * DASL: <http://akuma.com/syntax2> */ dav_error * (*set_option_head)(request_rec *r); /* Search resources * An error may be returned. *response will contain multistatus * responses (if any) suitable for the body of the error. It is also * possible to return NULL, yet still have multistatus responses. * In this case, typically the caller should return a 207 (Multistatus) * and the responses (in the body) as the HTTP response. */ dav_error * (*search_resource)(request_rec *r, dav_response **response); /* ** If a provider needs a context to associate with this hooks structure, ** then this field may be used. In most cases, it will just be NULL. */ void *ctx; }; /* -------------------------------------------------------------------- ** ** MISCELLANEOUS STUFF */ typedef struct { int propid; /* live property ID */ const dav_hooks_liveprop *provider; /* the provider defining this prop */ } dav_elem_private; /* -------------------------------------------------------------------- ** ** DAV OPTIONS */ #define DAV_OPTIONS_EXTENSION_GROUP "dav_options" typedef struct dav_options_provider { dav_error* (*dav_header)(request_rec *r, const dav_resource *resource, apr_text_header *phdr); dav_error* (*dav_method)(request_rec *r, const dav_resource *resource, apr_text_header *phdr); void *ctx; } dav_options_provider; extern DAV_DECLARE(const dav_options_provider *) dav_get_options_providers(const char *name); extern DAV_DECLARE(void) dav_options_provider_register(apr_pool_t *p, const char *name, const dav_options_provider *provider); /* -------------------------------------------------------------------- ** ** DAV RESOURCE TYPE HOOKS */ typedef struct dav_resource_type_provider { int (*get_resource_type)(const dav_resource *resource, const char **name, const char **uri); } dav_resource_type_provider; #define DAV_RESOURCE_TYPE_GROUP "dav_resource_type" DAV_DECLARE(void) dav_resource_type_provider_register(apr_pool_t *p, const char *name, const dav_resource_type_provider *provider); DAV_DECLARE(const dav_resource_type_provider *) dav_get_resource_type_providers(const char *name); #ifdef __cplusplus } #endif #endif /* _MOD_DAV_H_ */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MOD_SESSION_H #define MOD_SESSION_H /* Create a set of SESSION_DECLARE(type), SESSION_DECLARE_NONSTD(type) and * SESSION_DECLARE_DATA with appropriate export and import tags for the platform */ #if !defined(WIN32) #define SESSION_DECLARE(type) type #define SESSION_DECLARE_NONSTD(type) type #define SESSION_DECLARE_DATA #elif defined(SESSION_DECLARE_STATIC) #define SESSION_DECLARE(type) type __stdcall #define SESSION_DECLARE_NONSTD(type) type #define SESSION_DECLARE_DATA #elif defined(SESSION_DECLARE_EXPORT) #define SESSION_DECLARE(type) __declspec(dllexport) type __stdcall #define SESSION_DECLARE_NONSTD(type) __declspec(dllexport) type #define SESSION_DECLARE_DATA __declspec(dllexport) #else #define SESSION_DECLARE(type) __declspec(dllimport) type __stdcall #define SESSION_DECLARE_NONSTD(type) __declspec(dllimport) type #define SESSION_DECLARE_DATA __declspec(dllimport) #endif /** * @file mod_session.h * @brief Session Module for Apache * * @defgroup MOD_SESSION mod_session * @ingroup APACHE_MODS * @{ */ #include "apr_hooks.h" #include "apr_optional.h" #include "apr_tables.h" #include "apr_uuid.h" #include "apr_pools.h" #include "apr_time.h" #include "httpd.h" #include "http_config.h" #include "ap_config.h" #define MOD_SESSION_NOTES_KEY "mod_session_key" /** * Define the name of a username stored in the session, so that modules interested * in the username can find it in a standard place. */ #define MOD_SESSION_USER "user" /** * Define the name of a password stored in the session, so that modules interested * in the password can find it in a standard place. */ #define MOD_SESSION_PW "pw" /** * A session structure. * * At the core of the session is a set of name value pairs making up the * session. * * The session might be uniquely identified by an anonymous uuid, or * a remote_user value, or both. */ typedef struct { apr_pool_t *pool; /* pool to be used for this session */ apr_uuid_t *uuid; /* anonymous uuid of this particular session */ const char *remote_user; /* user who owns this particular session */ apr_table_t *entries; /* key value pairs */ const char *encoded; /* the encoded version of the key value pairs */ apr_time_t expiry; /* if > 0, the time of expiry of this session */ long maxage; /* if > 0, the maxage of the session, from * which expiry is calculated */ int dirty; /* dirty flag */ int cached; /* true if this session was loaded from a * cache of some kind */ int written; /* true if this session has already been * written */ } session_rec; /** * Structure to carry the per-dir session config. */ typedef struct { int enabled; /* whether the session has been enabled for * this directory */ int enabled_set; long maxage; /* seconds until session expiry */ int maxage_set; const char *header; /* header to inject session */ int header_set; int env; /* whether the session has been enabled for * this directory */ int env_set; apr_array_header_t *includes; /* URL prefixes to be included. All * URLs included if empty */ apr_array_header_t *excludes; /* URL prefixes to be excluded. No * URLs excluded if empty */ apr_time_t expiry_update_time; /* seconds the session expiry may change and * not have to be rewritten */ int expiry_update_set; } session_dir_conf; /** * Hook to load the session. * * If the session doesn't exist, a blank one will be created. * * @param r The request * @param z A pointer to where the session will be written. */ APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_load, (request_rec * r, session_rec ** z)) /** * Hook to save the session. * * In most implementations the session is only saved if the dirty flag is * true. This prevents the session being saved unnecessarily. * * @param r The request * @param z A pointer to where the session will be written. */ APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_save, (request_rec * r, session_rec * z)) /** * Hook to encode the session. * * In the default implementation, the key value pairs are encoded using * key value pairs separated by equals, in turn separated by ampersand, * like a web form. * * @param r The request * @param z A pointer to where the session will be written. */ APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_encode, (request_rec * r, session_rec * z)) /** * Hook to decode the session. * * In the default implementation, the key value pairs are encoded using * key value pairs separated by equals, in turn separated by ampersand, * like a web form. * * @param r The request * @param z A pointer to where the session will be written. */ APR_DECLARE_EXTERNAL_HOOK(ap, SESSION, apr_status_t, session_decode, (request_rec * r, session_rec * z)) APR_DECLARE_OPTIONAL_FN( apr_status_t, ap_session_get, (request_rec * r, session_rec * z, const char *key, const char **value)); APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_session_set, (request_rec * r, session_rec * z, const char *key, const char *value)); APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_session_load, (request_rec *, session_rec **)); APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_session_save, (request_rec *, session_rec *)); /** * The name of the module. */ extern module AP_MODULE_DECLARE_DATA session_module; #endif /* MOD_SESSION_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_ssl_openssl.h * @brief Interface to OpenSSL-specific APIs provided by mod_ssl * * @defgroup MOD_SSL mod_ssl_openssl * @ingroup APACHE_MODS * @{ */ #ifndef __MOD_SSL_OPENSSL_H__ #define __MOD_SSL_OPENSSL_H__ #include "mod_ssl.h" /* OpenSSL headers */ #include <openssl/opensslv.h> #if OPENSSL_VERSION_NUMBER >= 0x30000000 #include <openssl/macros.h> /* for OPENSSL_API_LEVEL */ #endif #if OPENSSL_VERSION_NUMBER >= 0x10001000 /* must be defined before including ssl.h */ #define OPENSSL_NO_SSL_INTERN #endif #include <openssl/ssl.h> #include <openssl/evp.h> #include <openssl/x509.h> /** * init_server hook -- allow SSL_CTX-specific initialization to be performed by * a module for each SSL-enabled server (one at a time) * @param s SSL-enabled [virtual] server * @param p pconf pool * @param is_proxy 1 if this server supports backend connections * over SSL/TLS, 0 if it supports client connections over SSL/TLS * @param ctx OpenSSL SSL Context for the server */ APR_DECLARE_EXTERNAL_HOOK(ssl, SSL, int, init_server, (server_rec *s, apr_pool_t *p, int is_proxy, SSL_CTX *ctx)) /** * pre_handshake hook * @param c conn_rec for new connection from client or to backend server * @param ssl OpenSSL SSL Connection for the client or backend server * @param is_proxy 1 if this handshake is for a backend connection, 0 otherwise */ APR_DECLARE_EXTERNAL_HOOK(ssl, SSL, int, pre_handshake, (conn_rec *c, SSL *ssl, int is_proxy)) /** * proxy_post_handshake hook -- allow module to abort after successful * handshake with backend server and subsequent peer checks * @param c conn_rec for connection to backend server * @param ssl OpenSSL SSL Connection for the client or backend server */ APR_DECLARE_EXTERNAL_HOOK(ssl, SSL, int, proxy_post_handshake, (conn_rec *c, SSL *ssl)) /** On TLS connections that do not relate to a configured virtual host, * allow other modules to provide a X509 certificate and EVP_PKEY to * be used on the connection. This first hook which does not * return DECLINED will determine the outcome. */ APR_DECLARE_EXTERNAL_HOOK(ssl, SSL, int, answer_challenge, (conn_rec *c, const char *server_name, X509 **pcert, EVP_PKEY **pkey)) /** During post_config phase, ask around if someone wants to provide * OCSP stapling status information for the given cert (with the also * provided issuer certificate). The first hook which does not * return DECLINED promises to take responsibility (and respond * in later calls via hook ssl_get_stapling_status). * If no hook takes over, mod_ssl's own stapling implementation will * be applied (if configured). */ APR_DECLARE_EXTERNAL_HOOK(ssl, SSL, int, init_stapling_status, (server_rec *s, apr_pool_t *p, X509 *cert, X509 *issuer)) /** Anyone answering positive to ssl_init_stapling_status for a * certificate, needs to register here and supply the actual OCSP stapling * status data (OCSP_RESP) for a new connection. * A hook supplying the response data must return APR_SUCCESS. * The data is returned in DER encoded bytes via pder and pderlen. The * returned pointer may be NULL, which indicates that data is (currently) * unavailable. * If DER data is returned, it MUST come from a response with * status OCSP_RESPONSE_STATUS_SUCCESSFUL and V_OCSP_CERTSTATUS_GOOD * or V_OCSP_CERTSTATUS_REVOKED, not V_OCSP_CERTSTATUS_UNKNOWN. This means * errors in OCSP retrieval are to be handled/logged by the hook and * are not done by mod_ssl. * Any DER bytes returned MUST be allocated via malloc() and ownership * passes to mod_ssl. Meaning, the hook must return a malloced copy of * the data it has. mod_ssl (or OpenSSL) will free it. */ APR_DECLARE_EXTERNAL_HOOK(ssl, SSL, int, get_stapling_status, (unsigned char **pder, int *pderlen, conn_rec *c, server_rec *s, X509 *cert)) #endif /* __MOD_SSL_OPENSSL_H__ */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_log_config.h * @brief Logging Configuration Extension Module for Apache * * @defgroup MOD_LOG_CONFIG mod_log_config * @ingroup APACHE_MODS * @{ */ #include "apr_optional.h" #include "httpd.h" #include "scoreboard.h" #ifndef _MOD_LOG_CONFIG_H #define _MOD_LOG_CONFIG_H 1 /** * callback function prototype for a external log handler */ typedef const char *ap_log_handler_fn_t(request_rec *r, char *a); /** * callback function prototype for external writer initialization. */ typedef void *ap_log_writer_init(apr_pool_t *p, server_rec *s, const char *name); /** * callback which gets called where there is a log line to write. */ typedef apr_status_t ap_log_writer( request_rec *r, void *handle, const char **portions, int *lengths, int nelts, apr_size_t len); typedef struct ap_log_handler { ap_log_handler_fn_t *func; int want_orig_default; } ap_log_handler; APR_DECLARE_OPTIONAL_FN(void, ap_register_log_handler, (apr_pool_t *p, char *tag, ap_log_handler_fn_t *func, int def)); /** * you will need to set your init handler *BEFORE* the open_logs * in mod_log_config gets executed */ APR_DECLARE_OPTIONAL_FN(ap_log_writer_init*, ap_log_set_writer_init,(ap_log_writer_init *func)); /** * you should probably set the writer at the same time (ie..before open_logs) */ APR_DECLARE_OPTIONAL_FN(ap_log_writer*, ap_log_set_writer, (ap_log_writer* func)); #endif /* MOD_LOG_CONFIG */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MOD_WATCHDOG_H #define MOD_WATCHDOG_H /** * @file mod_watchdog.h * @brief Watchdog module for Apache * * @defgroup MOD_WATCHDOG mod_watchdog * @ingroup APACHE_MODS * @{ */ #include "httpd.h" #include "http_config.h" #include "http_log.h" #include "ap_provider.h" #include "apr.h" #include "apr_strings.h" #include "apr_pools.h" #include "apr_shm.h" #include "apr_hash.h" #include "apr_hooks.h" #include "apr_optional.h" #include "apr_file_io.h" #include "apr_time.h" #include "apr_thread_proc.h" #include "apr_global_mutex.h" #include "apr_thread_mutex.h" #ifdef __cplusplus extern "C" { #endif /** * Default singleton watchdog instance name. * Singleton watchdog is protected by mutex and * guaranteed to be run inside a single child process * at any time. */ #define AP_WATCHDOG_SINGLETON "_singleton_" /** * Default watchdog instance name */ #define AP_WATCHDOG_DEFAULT "_default_" /** * Default Watchdog interval */ #define AP_WD_TM_INTERVAL APR_TIME_C(1000000) /* 1 second */ /** * Watchdog thread timer resolution */ #define AP_WD_TM_SLICE APR_TIME_C(100000) /* 100 ms */ /* State values for callback */ #define AP_WATCHDOG_STATE_STARTING 1 #define AP_WATCHDOG_STATE_RUNNING 2 #define AP_WATCHDOG_STATE_STOPPING 3 typedef struct ap_watchdog_t ap_watchdog_t; /* Create a set of AP_WD_DECLARE(type), AP_WD_DECLARE_NONSTD(type) and * AP_WD_DECLARE_DATA with appropriate export and import tags for the platform */ #if !defined(AP_WD_DECLARE) #if !defined(WIN32) #define AP_WD_DECLARE(type) type #define AP_WD_DECLARE_NONSTD(type) type #define AP_WD_DECLARE_DATA #elif defined(AP_WD_DECLARE_STATIC) #define AP_WD_DECLARE(type) type __stdcall #define AP_WD_DECLARE_NONSTD(type) type #define AP_WD_DECLARE_DATA #elif defined(AP_WD_DECLARE_EXPORT) #define AP_WD_DECLARE(type) __declspec(dllexport) type __stdcall #define AP_WD_DECLARE_NONSTD(type) __declspec(dllexport) type #define AP_WD_DECLARE_DATA __declspec(dllexport) #else #define AP_WD_DECLARE(type) __declspec(dllimport) type __stdcall #define AP_WD_DECLARE_NONSTD(type) __declspec(dllimport) type #define AP_WD_DECLARE_DATA __declspec(dllimport) #endif #endif /** * Callback function used for watchdog. * @param state Watchdog state function. See @p AP_WATCHDOG_STATE_ . * @param data is what was passed to @p ap_watchdog_register_callback function. * @param pool Temporary callback pool destroyed after the call. * @return APR_SUCCESS to continue calling this callback. */ typedef apr_status_t ap_watchdog_callback_fn_t(int state, void *data, apr_pool_t *pool); /** * Get watchdog instance. * @param watchdog Storage for watchdog instance. * @param name Watchdog name. * @param parent Non-zero to get the parent process watchdog instance. * @param singleton Non-zero to get the singleton watchdog instance. * @param p The pool to use. * @return APR_SUCCESS if all went well * @remark Use @p AP_WATCHDOG_DEFAULT to get default watchdog instance. * If separate watchdog thread is needed provide unique name * and function will create a new watchdog instance. * Note that default client process watchdog works in singleton mode. */ APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_watchdog_get_instance, (ap_watchdog_t **watchdog, const char *name, int parent, int singleton, apr_pool_t *p)); /** * Register watchdog callback. * @param watchdog Watchdog to use * @param interval Interval on which the callback function will execute. * @param callback The function to call on watchdog event. * @param data The data to pass to the callback function. * @return APR_SUCCESS if all went well. APR_EEXIST if already registered. */ APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_watchdog_register_callback, (ap_watchdog_t *watchdog, apr_interval_time_t interval, const void *data, ap_watchdog_callback_fn_t *callback)); /** * Update registered watchdog callback interval. * @param w Watchdog to use * @param interval New interval on which the callback function will execute. * @param callback The function to call on watchdog event. * @param data The data to pass to the callback function. * @return APR_SUCCESS if all went well. APR_EOF if callback was not found. */ APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_watchdog_set_callback_interval, (ap_watchdog_t *w, apr_interval_time_t interval, const void *data, ap_watchdog_callback_fn_t *callback)); /** * Watchdog require hook. * @param s The server record * @param name Watchdog name. * @param parent Non-zero to indicate the parent process watchdog mode. * @param singleton Non-zero to indicate the singleton watchdog mode. * @return OK to enable notifications from this watchdog, DECLINED otherwise. * @remark This is called in post config phase for all watchdog instances * that have no callbacks registered. Modules using this hook * should ensure that their post_config hook is called after watchdog * post_config. */ APR_DECLARE_EXTERNAL_HOOK(ap, AP_WD, int, watchdog_need, (server_rec *s, const char *name, int parent, int singleton)) /** * Watchdog initialize hook. * It is called after the watchdog thread is initialized. * @param s The server record * @param name Watchdog name. * @param pool The pool used to create the watchdog. */ APR_DECLARE_EXTERNAL_HOOK(ap, AP_WD, int, watchdog_init, ( server_rec *s, const char *name, apr_pool_t *pool)) /** * Watchdog terminate hook. * It is called when the watchdog thread is terminated. * @param s The server record * @param name Watchdog name. * @param pool The pool used to create the watchdog. */ APR_DECLARE_EXTERNAL_HOOK(ap, AP_WD, int, watchdog_exit, ( server_rec *s, const char *name, apr_pool_t *pool)) /** * Fixed interval watchdog hook. * It is called regularly on @p AP_WD_TM_INTERVAL interval. * @param s The server record * @param name Watchdog name. * @param pool Temporary pool destroyed after the call. */ APR_DECLARE_EXTERNAL_HOOK(ap, AP_WD, int, watchdog_step, ( server_rec *s, const char *name, apr_pool_t *pool)) #ifdef __cplusplus } #endif #endif /* MOD_WATCHDOG_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_request.h * @brief mod_request private header file * * @defgroup MOD_REQUEST mod_request * @ingroup APACHE_MODS * @{ */ #ifndef MOD_REQUEST_H #define MOD_REQUEST_H #include "apr.h" #include "apr_buckets.h" #include "apr_optional.h" #include "httpd.h" #include "util_filter.h" #ifdef __cplusplus extern "C" { #endif extern module AP_MODULE_DECLARE_DATA request_module; #define KEEP_BODY_FILTER "KEEP_BODY" #define KEPT_BODY_FILTER "KEPT_BODY" /** * Core per-directory configuration. */ typedef struct { apr_off_t keep_body; int keep_body_set; } request_dir_conf; APR_DECLARE_OPTIONAL_FN(void, ap_request_insert_filter, (request_rec * r)); APR_DECLARE_OPTIONAL_FN(void, ap_request_remove_filter, (request_rec * r)); #ifdef __cplusplus } #endif #endif /* !MOD_REQUEST_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file httpd.h * @brief HTTP Daemon routines * * @defgroup APACHE Apache HTTP Server * * Top level group of which all other groups are a member * @{ * * @defgroup APACHE_MODS Loadable modules * Top level group for modules * @defgroup APACHE_OS Operating System Specific * @defgroup APACHE_INTERNAL Internal interfaces * @defgroup APACHE_CORE Core routines * @{ * @defgroup APACHE_CORE_DAEMON HTTP Daemon Routine * @{ */ #ifndef APACHE_HTTPD_H #define APACHE_HTTPD_H /* XXX - We need to push more stuff to other .h files, or even .c files, to * make this file smaller */ /* Headers in which EVERYONE has an interest... */ #include "ap_config.h" #include "ap_mmn.h" #include "ap_release.h" #include "apr.h" #include "apr_version.h" #include "apr_general.h" #include "apr_tables.h" #include "apr_pools.h" #include "apr_time.h" #include "apr_network_io.h" #include "apr_buckets.h" #include "apr_poll.h" #include "apr_thread_proc.h" #include "os.h" #include "ap_regex.h" #if APR_HAVE_STDLIB_H #include <stdlib.h> #endif /* Note: apr_uri.h is also included, see below */ #ifdef __cplusplus extern "C" { #endif /* ----------------------------- config dir ------------------------------ */ /** Define this to be the default server home dir. Most things later in this * file with a relative pathname will have this added. */ #ifndef HTTPD_ROOT #ifdef OS2 /** Set default for OS/2 file system */ #define HTTPD_ROOT "/os2httpd" #elif defined(WIN32) /** Set default for Windows file system */ #define HTTPD_ROOT "/apache" #elif defined (NETWARE) /** Set the default for NetWare */ #define HTTPD_ROOT "/apache" #else /** Set for all other OSs */ #define HTTPD_ROOT "/usr/local/apache" #endif #endif /* HTTPD_ROOT */ /* * --------- You shouldn't have to edit anything below this line ---------- * * Any modifications to any defaults not defined above should be done in the * respective configuration file. * */ /** * Default location of documents. Can be overridden by the DocumentRoot * directive. */ #ifndef DOCUMENT_LOCATION #ifdef OS2 /* Set default for OS/2 file system */ #define DOCUMENT_LOCATION HTTPD_ROOT "/docs" #else /* Set default for non OS/2 file system */ #define DOCUMENT_LOCATION HTTPD_ROOT "/htdocs" #endif #endif /* DOCUMENT_LOCATION */ /** Maximum number of dynamically loaded modules */ #ifndef DYNAMIC_MODULE_LIMIT #define DYNAMIC_MODULE_LIMIT 256 #endif /** Default administrator's address */ #define DEFAULT_ADMIN "[no address given]" /** The name of the log files */ #ifndef DEFAULT_ERRORLOG #if defined(OS2) || defined(WIN32) #define DEFAULT_ERRORLOG "logs/error.log" #else #define DEFAULT_ERRORLOG "logs/error_log" #endif #endif /* DEFAULT_ERRORLOG */ /** Define this to be what your per-directory security files are called */ #ifndef DEFAULT_ACCESS_FNAME #ifdef OS2 /* Set default for OS/2 file system */ #define DEFAULT_ACCESS_FNAME "htaccess" #else #define DEFAULT_ACCESS_FNAME ".htaccess" #endif #endif /* DEFAULT_ACCESS_FNAME */ /** The name of the server config file */ #ifndef SERVER_CONFIG_FILE #define SERVER_CONFIG_FILE "conf/httpd.conf" #endif /** The default path for CGI scripts if none is currently set */ #ifndef DEFAULT_PATH #define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin" #endif /** The path to the suExec wrapper, can be overridden in Configuration */ #ifndef SUEXEC_BIN #define SUEXEC_BIN HTTPD_ROOT "/bin/suexec" #endif /** The timeout for waiting for messages */ #ifndef DEFAULT_TIMEOUT #define DEFAULT_TIMEOUT 60 #endif /** The timeout for waiting for keepalive timeout until next request */ #ifndef DEFAULT_KEEPALIVE_TIMEOUT #define DEFAULT_KEEPALIVE_TIMEOUT 5 #endif /** The number of requests to entertain per connection */ #ifndef DEFAULT_KEEPALIVE #define DEFAULT_KEEPALIVE 100 #endif /* * Limits on the size of various request items. These limits primarily * exist to prevent simple denial-of-service attacks on a server based * on misuse of the protocol. The recommended values will depend on the * nature of the server resources -- CGI scripts and database backends * might require large values, but most servers could get by with much * smaller limits than we use below. The request message body size can * be limited by the per-dir config directive LimitRequestBody. * * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190. * These two limits can be lowered or raised by the server config * directives LimitRequestLine and LimitRequestFieldsize, respectively. * * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by * the server config directive LimitRequestFields. */ /** default limit on bytes in Request-Line (Method+URI+HTTP-version) */ #ifndef DEFAULT_LIMIT_REQUEST_LINE #define DEFAULT_LIMIT_REQUEST_LINE 8190 #endif /** default limit on bytes in any one header field */ #ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE #define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190 #endif /** default limit on number of request header fields */ #ifndef DEFAULT_LIMIT_REQUEST_FIELDS #define DEFAULT_LIMIT_REQUEST_FIELDS 100 #endif /** default/hard limit on number of leading/trailing empty lines */ #ifndef DEFAULT_LIMIT_BLANK_LINES #define DEFAULT_LIMIT_BLANK_LINES 10 #endif /** * The default default character set name to add if AddDefaultCharset is * enabled. Overridden with AddDefaultCharsetName. */ #define DEFAULT_ADD_DEFAULT_CHARSET_NAME "iso-8859-1" /** default HTTP Server protocol */ #define AP_SERVER_PROTOCOL "HTTP/1.1" /* ------------------ stuff that modules are allowed to look at ----------- */ /** Define this to be what your HTML directory content files are called */ #ifndef AP_DEFAULT_INDEX #define AP_DEFAULT_INDEX "index.html" #endif /** The name of the MIME types file */ #ifndef AP_TYPES_CONFIG_FILE #define AP_TYPES_CONFIG_FILE "conf/mime.types" #endif /* * Define the HTML doctype strings centrally. */ /** HTML 2.0 Doctype */ #define DOCTYPE_HTML_2_0 "<!DOCTYPE HTML PUBLIC \"-//IETF//" \ "DTD HTML 2.0//EN\">\n" /** HTML 3.2 Doctype */ #define DOCTYPE_HTML_3_2 "<!DOCTYPE HTML PUBLIC \"-//W3C//" \ "DTD HTML 3.2 Final//EN\">\n" /** HTML 4.0 Strict Doctype */ #define DOCTYPE_HTML_4_0S "<!DOCTYPE HTML PUBLIC \"-//W3C//" \ "DTD HTML 4.0//EN\"\n" \ "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" /** HTML 4.0 Transitional Doctype */ #define DOCTYPE_HTML_4_0T "<!DOCTYPE HTML PUBLIC \"-//W3C//" \ "DTD HTML 4.0 Transitional//EN\"\n" \ "\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n" /** HTML 4.0 Frameset Doctype */ #define DOCTYPE_HTML_4_0F "<!DOCTYPE HTML PUBLIC \"-//W3C//" \ "DTD HTML 4.0 Frameset//EN\"\n" \ "\"http://www.w3.org/TR/REC-html40/frameset.dtd\">\n" /** HTML 4.01 Doctype */ #define DOCTYPE_HTML_4_01 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n" /** HTML 5 Doctype */ #define DOCTYPE_HTML_5 "<!DOCTYPE html>\n" /** XHTML 1.0 Strict Doctype */ #define DOCTYPE_XHTML_1_0S "<!DOCTYPE html PUBLIC \"-//W3C//" \ "DTD XHTML 1.0 Strict//EN\"\n" \ "\"http://www.w3.org/TR/xhtml1/DTD/" \ "xhtml1-strict.dtd\">\n" /** XHTML 1.0 Transitional Doctype */ #define DOCTYPE_XHTML_1_0T "<!DOCTYPE html PUBLIC \"-//W3C//" \ "DTD XHTML 1.0 Transitional//EN\"\n" \ "\"http://www.w3.org/TR/xhtml1/DTD/" \ "xhtml1-transitional.dtd\">\n" /** XHTML 1.0 Frameset Doctype */ #define DOCTYPE_XHTML_1_0F "<!DOCTYPE html PUBLIC \"-//W3C//" \ "DTD XHTML 1.0 Frameset//EN\"\n" \ "\"http://www.w3.org/TR/xhtml1/DTD/" \ "xhtml1-frameset.dtd\">" /** Internal representation for a HTTP protocol number, e.g., HTTP/1.1 */ #define HTTP_VERSION(major,minor) (1000*(major)+(minor)) /** Major part of HTTP protocol */ #define HTTP_VERSION_MAJOR(number) ((number)/1000) /** Minor part of HTTP protocol */ #define HTTP_VERSION_MINOR(number) ((number)%1000) /* -------------- Port number for server running standalone --------------- */ /** default HTTP Port */ #define DEFAULT_HTTP_PORT 80 /** default HTTPS Port */ #define DEFAULT_HTTPS_PORT 443 /** * Check whether @a port is the default port for the request @a r. * @param port The port number * @param r The request * @see #ap_default_port */ #define ap_is_default_port(port,r) ((port) == ap_default_port(r)) /** * Get the default port for a request (which depends on the scheme). * @param r The request */ #define ap_default_port(r) ap_run_default_port(r) /** * Get the scheme for a request. * @param r The request */ #define ap_http_scheme(r) ap_run_http_scheme(r) /** The default string length */ #define MAX_STRING_LEN HUGE_STRING_LEN /** The length of a Huge string */ #define HUGE_STRING_LEN 8192 /** The size of the server's internal read-write buffers */ #define AP_IOBUFSIZE 8192 /** The max number of regex captures that can be expanded by ap_pregsub */ #define AP_MAX_REG_MATCH 10 /** * APR_HAS_LARGE_FILES introduces the problem of splitting sendfile into * multiple buckets, no greater than MAX(apr_size_t), and more granular * than that in case the brigade code/filters attempt to read it directly. * ### 16mb is an invention, no idea if it is reasonable. */ #define AP_MAX_SENDFILE 16777216 /* 2^24 */ /** * MPM child process exit status values * The MPM parent process may check the status to see if special * error handling is required. */ /** a normal exit */ #define APEXIT_OK 0x0 /** A fatal error arising during the server's init sequence */ #define APEXIT_INIT 0x2 /** The child died during its init sequence */ #define APEXIT_CHILDINIT 0x3 /** * The child exited due to a resource shortage. * The parent should limit the rate of forking until * the situation is resolved. */ #define APEXIT_CHILDSICK 0x7 /** * A fatal error, resulting in the whole server aborting. * If a child exits with this error, the parent process * considers this a server-wide fatal error and aborts. */ #define APEXIT_CHILDFATAL 0xf #ifndef AP_DECLARE /** * Stuff marked #AP_DECLARE is part of the API, and intended for use * by modules. Its purpose is to allow us to add attributes that * particular platforms or compilers require to every exported function. */ # define AP_DECLARE(type) type #endif #ifndef AP_DECLARE_NONSTD /** * Stuff marked #AP_DECLARE_NONSTD is part of the API, and intended for * use by modules. The difference between #AP_DECLARE and * #AP_DECLARE_NONSTD is that the latter is required for any functions * which use varargs or are used via indirect function call. This * is to accommodate the two calling conventions in windows dlls. */ # define AP_DECLARE_NONSTD(type) type #endif #ifndef AP_DECLARE_DATA # define AP_DECLARE_DATA #endif #ifndef AP_MODULE_DECLARE # define AP_MODULE_DECLARE(type) type #endif #ifndef AP_MODULE_DECLARE_NONSTD # define AP_MODULE_DECLARE_NONSTD(type) type #endif #ifndef AP_MODULE_DECLARE_DATA # define AP_MODULE_DECLARE_DATA #endif /** * @internal * modules should not use functions marked AP_CORE_DECLARE */ #ifndef AP_CORE_DECLARE # define AP_CORE_DECLARE AP_DECLARE #endif /** * @internal * modules should not use functions marked AP_CORE_DECLARE_NONSTD */ #ifndef AP_CORE_DECLARE_NONSTD # define AP_CORE_DECLARE_NONSTD AP_DECLARE_NONSTD #endif /** * @defgroup APACHE_APR_STATUS_T HTTPD specific values of apr_status_t * @{ */ #define AP_START_USERERR (APR_OS_START_USERERR + 2000) #define AP_USERERR_LEN 1000 /** The function declines to handle the request */ #define AP_DECLINED (AP_START_USERERR + 0) /** @} */ /** * @brief The numeric version information is broken out into fields within this * structure. */ typedef struct { int major; /**< major number */ int minor; /**< minor number */ int patch; /**< patch number */ const char *add_string; /**< additional string like "-dev" */ } ap_version_t; /** * Return httpd's version information in a numeric form. * * @param version Pointer to a version structure for returning the version * information. */ AP_DECLARE(void) ap_get_server_revision(ap_version_t *version); /** * Get the server banner in a form suitable for sending over the * network, with the level of information controlled by the * ServerTokens directive. * @return The server banner */ AP_DECLARE(const char *) ap_get_server_banner(void); /** * Get the server description in a form suitable for local displays, * status reports, or logging. This includes the detailed server * version and information about some modules. It is not affected * by the ServerTokens directive. * @return The server description */ AP_DECLARE(const char *) ap_get_server_description(void); /** * Add a component to the server description and banner strings * @param pconf The pool to allocate the component from * @param component The string to add */ AP_DECLARE(void) ap_add_version_component(apr_pool_t *pconf, const char *component); /** * Get the date a time that the server was built * @return The server build time string */ AP_DECLARE(const char *) ap_get_server_built(void); /* non-HTTP status codes returned by hooks */ #define OK 0 /**< Module has handled this stage. */ #define DECLINED -1 /**< Module declines to handle */ #define DONE -2 /**< Module has served the response completely * - it's safe to die() with no more output */ #define SUSPENDED -3 /**< Module will handle the remainder of the request. * The core will never invoke the request again */ /** Returned by the bottom-most filter if no data was written. * @see ap_pass_brigade(). */ #define AP_NOBODY_WROTE -100 /** Returned by the bottom-most filter if no data was read. * @see ap_get_brigade(). */ #define AP_NOBODY_READ -101 /** Returned by any filter if the filter chain encounters an error * and has already dealt with the error response. */ #define AP_FILTER_ERROR -102 /** * @defgroup HTTP_Status HTTP Status Codes * @{ */ /** * The size of the static status_lines array in http_protocol.c for * storing all of the potential response status-lines (a sparse table). * When adding a new code here add it to status_lines as well. * A future version should dynamically generate the apr_table_t at startup. */ #define RESPONSE_CODES 104 #define HTTP_CONTINUE 100 #define HTTP_SWITCHING_PROTOCOLS 101 #define HTTP_PROCESSING 102 #define HTTP_EARLY_HINTS 103 #define HTTP_OK 200 #define HTTP_CREATED 201 #define HTTP_ACCEPTED 202 #define HTTP_NON_AUTHORITATIVE 203 #define HTTP_NO_CONTENT 204 #define HTTP_RESET_CONTENT 205 #define HTTP_PARTIAL_CONTENT 206 #define HTTP_MULTI_STATUS 207 #define HTTP_ALREADY_REPORTED 208 #define HTTP_IM_USED 226 #define HTTP_MULTIPLE_CHOICES 300 #define HTTP_MOVED_PERMANENTLY 301 #define HTTP_MOVED_TEMPORARILY 302 #define HTTP_SEE_OTHER 303 #define HTTP_NOT_MODIFIED 304 #define HTTP_USE_PROXY 305 #define HTTP_TEMPORARY_REDIRECT 307 #define HTTP_PERMANENT_REDIRECT 308 #define HTTP_BAD_REQUEST 400 #define HTTP_UNAUTHORIZED 401 #define HTTP_PAYMENT_REQUIRED 402 #define HTTP_FORBIDDEN 403 #define HTTP_NOT_FOUND 404 #define HTTP_METHOD_NOT_ALLOWED 405 #define HTTP_NOT_ACCEPTABLE 406 #define HTTP_PROXY_AUTHENTICATION_REQUIRED 407 #define HTTP_REQUEST_TIME_OUT 408 #define HTTP_CONFLICT 409 #define HTTP_GONE 410 #define HTTP_LENGTH_REQUIRED 411 #define HTTP_PRECONDITION_FAILED 412 #define HTTP_REQUEST_ENTITY_TOO_LARGE 413 #define HTTP_REQUEST_URI_TOO_LARGE 414 #define HTTP_UNSUPPORTED_MEDIA_TYPE 415 #define HTTP_RANGE_NOT_SATISFIABLE 416 #define HTTP_EXPECTATION_FAILED 417 #define HTTP_MISDIRECTED_REQUEST 421 #define HTTP_UNPROCESSABLE_ENTITY 422 #define HTTP_LOCKED 423 #define HTTP_FAILED_DEPENDENCY 424 #define HTTP_UPGRADE_REQUIRED 426 #define HTTP_PRECONDITION_REQUIRED 428 #define HTTP_TOO_MANY_REQUESTS 429 #define HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE 431 #define HTTP_UNAVAILABLE_FOR_LEGAL_REASONS 451 #define HTTP_INTERNAL_SERVER_ERROR 500 #define HTTP_NOT_IMPLEMENTED 501 #define HTTP_BAD_GATEWAY 502 #define HTTP_SERVICE_UNAVAILABLE 503 #define HTTP_GATEWAY_TIME_OUT 504 #define HTTP_VERSION_NOT_SUPPORTED 505 #define HTTP_VARIANT_ALSO_VARIES 506 #define HTTP_INSUFFICIENT_STORAGE 507 #define HTTP_LOOP_DETECTED 508 #define HTTP_NOT_EXTENDED 510 #define HTTP_NETWORK_AUTHENTICATION_REQUIRED 511 /** is the status code informational */ #define ap_is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200)) /** is the status code OK ?*/ #define ap_is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300)) /** is the status code a redirect */ #define ap_is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400)) /** is the status code a error (client or server) */ #define ap_is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600)) /** is the status code a client error */ #define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500)) /** is the status code a server error */ #define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600)) /** is the status code a (potentially) valid response code? */ #define ap_is_HTTP_VALID_RESPONSE(x) (((x) >= 100)&&((x) < 600)) /** should the status code drop the connection */ #define ap_status_drops_connection(x) \ (((x) == HTTP_BAD_REQUEST) || \ ((x) == HTTP_REQUEST_TIME_OUT) || \ ((x) == HTTP_LENGTH_REQUIRED) || \ ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \ ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \ ((x) == HTTP_INTERNAL_SERVER_ERROR) || \ ((x) == HTTP_SERVICE_UNAVAILABLE) || \ ((x) == HTTP_NOT_IMPLEMENTED)) /** does the status imply header only response (i.e. never w/ a body)? */ #define AP_STATUS_IS_HEADER_ONLY(x) ((x) == HTTP_NO_CONTENT || \ (x) == HTTP_NOT_MODIFIED) /** @} */ /** * @defgroup Methods List of Methods recognized by the server * @ingroup APACHE_CORE_DAEMON * @{ * * @brief Methods recognized (but not necessarily handled) by the server. * * These constants are used in bit shifting masks of size int, so it is * unsafe to have more methods than bits in an int. HEAD == M_GET. * This list must be tracked by the list in http_protocol.c in routine * ap_method_name_of(). * */ #define M_GET 0 /** RFC 2616: HTTP */ #define M_PUT 1 /* : */ #define M_POST 2 #define M_DELETE 3 #define M_CONNECT 4 #define M_OPTIONS 5 #define M_TRACE 6 /** RFC 2616: HTTP */ #define M_PATCH 7 /** RFC 5789: PATCH Method for HTTP */ #define M_PROPFIND 8 /** RFC 2518: WebDAV */ #define M_PROPPATCH 9 /* : */ #define M_MKCOL 10 #define M_COPY 11 #define M_MOVE 12 #define M_LOCK 13 #define M_UNLOCK 14 /** RFC 2518: WebDAV */ #define M_VERSION_CONTROL 15 /** RFC 3253: WebDAV Versioning */ #define M_CHECKOUT 16 /* : */ #define M_UNCHECKOUT 17 #define M_CHECKIN 18 #define M_UPDATE 19 #define M_LABEL 20 #define M_REPORT 21 #define M_MKWORKSPACE 22 #define M_MKACTIVITY 23 #define M_BASELINE_CONTROL 24 #define M_MERGE 25 #define M_INVALID 26 /** no valid method */ /** * METHODS needs to be equal to the number of bits * we are using for limit masks. */ #define METHODS 64 /** * The method mask bit to shift for anding with a bitmask. */ #define AP_METHOD_BIT ((apr_int64_t)1) /** @} */ /** @see ap_method_list_t */ typedef struct ap_method_list_t ap_method_list_t; /** * @struct ap_method_list_t * @brief Structure for handling HTTP methods. * * Methods known to the server are accessed via a bitmask shortcut; * extension methods are handled by an array. */ struct ap_method_list_t { /** The bitmask used for known methods */ apr_int64_t method_mask; /** the array used for extension methods */ apr_array_header_t *method_list; }; /** @} */ /** * @defgroup bnotes Binary notes recognized by the server * @ingroup APACHE_CORE_DAEMON * @{ * * @brief Binary notes recognized by the server. */ /** * The type used for request binary notes. */ typedef apr_uint64_t ap_request_bnotes_t; /** * These constants represent bitmasks for notes associated with this * request. There are space for 64 bits in the apr_uint64_t. * */ #define AP_REQUEST_STRONG_ETAG 1 >> 0 #define AP_REQUEST_TRUSTED_CT 1 << 1 /** * This is a convenience macro to ease with getting specific request * binary notes. */ #define AP_REQUEST_GET_BNOTE(r, mask) \ ((mask) & ((r)->bnotes)) /** * This is a convenience macro to ease with setting specific request * binary notes. */ #define AP_REQUEST_SET_BNOTE(r, mask, val) \ (r)->bnotes = (((r)->bnotes & ~(mask)) | (val)) /** * Returns true if the strong etag flag is set for this request. */ #define AP_REQUEST_IS_STRONG_ETAG(r) \ AP_REQUEST_GET_BNOTE((r), AP_REQUEST_STRONG_ETAG) /** @} */ /** * Returns true if the content-type field is from a trusted source */ #define AP_REQUEST_IS_TRUSTED_CT(r) \ (!!AP_REQUEST_GET_BNOTE((r), AP_REQUEST_TRUSTED_CT)) /** @} */ /** * @defgroup module_magic Module Magic mime types * @{ */ /** Magic for mod_cgi[d] */ #define CGI_MAGIC_TYPE "application/x-httpd-cgi" /** Magic for mod_include */ #define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html" /** Magic for mod_include */ #define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3" /** Magic for mod_dir */ #define DIR_MAGIC_TYPE "httpd/unix-directory" /** Default for r->handler if no content-type set by type_checker */ #define AP_DEFAULT_HANDLER_NAME "" #define AP_IS_DEFAULT_HANDLER_NAME(x) (*x == '\0') /** @} */ /* Just in case your linefeed isn't the one the other end is expecting. */ #if !APR_CHARSET_EBCDIC /** linefeed */ #define LF 10 /** carriage return */ #define CR 13 /** carriage return /Line Feed Combo */ #define CRLF "\015\012" #else /* APR_CHARSET_EBCDIC */ /* For platforms using the EBCDIC charset, the transition ASCII->EBCDIC is done * in the buff package (bread/bputs/bwrite). Everywhere else, we use * "native EBCDIC" CR and NL characters. These are therefore * defined as * '\r' and '\n'. */ #define CR '\r' #define LF '\n' #define CRLF "\r\n" #endif /* APR_CHARSET_EBCDIC */ /** Useful for common code with either platform charset. */ #define CRLF_ASCII "\015\012" /** * @defgroup values_request_rec_body Possible values for request_rec.read_body * @{ * Possible values for request_rec.read_body (set by handling module): */ /** Send 413 error if message has any body */ #define REQUEST_NO_BODY 0 /** Send 411 error if body without Content-Length */ #define REQUEST_CHUNKED_ERROR 1 /** If chunked, remove the chunks for me. */ #define REQUEST_CHUNKED_DECHUNK 2 /** @} // values_request_rec_body */ /** * @defgroup values_request_rec_used_path_info Possible values for request_rec.used_path_info * @ingroup APACHE_CORE_DAEMON * @{ * Possible values for request_rec.used_path_info: */ /** Accept the path_info from the request */ #define AP_REQ_ACCEPT_PATH_INFO 0 /** Return a 404 error if path_info was given */ #define AP_REQ_REJECT_PATH_INFO 1 /** Module may chose to use the given path_info */ #define AP_REQ_DEFAULT_PATH_INFO 2 /** @} // values_request_rec_used_path_info */ /* * Things which may vary per file-lookup WITHIN a request --- * e.g., state of MIME config. Basically, the name of an object, info * about the object, and any other info we may have which may need to * change as we go poking around looking for it (e.g., overridden by * .htaccess files). * * Note how the default state of almost all these things is properly * zero, so that allocating it with pcalloc does the right thing without * a whole lot of hairy initialization... so long as we are willing to * make the (fairly) portable assumption that the bit pattern of a NULL * pointer is, in fact, zero. */ /** * @brief This represents the result of calling htaccess; these are cached for * each request. */ struct htaccess_result { /** the directory to which this applies */ const char *dir; /** the overrides allowed for the .htaccess file */ int override; /** the override options allowed for the .htaccess file */ int override_opts; /** Table of allowed directives for override */ apr_table_t *override_list; /** the configuration directives */ struct ap_conf_vector_t *htaccess; /** the next one, or NULL if no more; N.B. never change this */ const struct htaccess_result *next; }; /* The following four types define a hierarchy of activities, so that * given a request_rec r you can write r->connection->server->process * to get to the process_rec. While this reduces substantially the * number of arguments that various hooks require beware that in * threaded versions of the server you must consider multiplexing * issues. */ /** A structure that represents one process */ typedef struct process_rec process_rec; /** A structure that represents a virtual server */ typedef struct server_rec server_rec; /** A structure that represents one connection */ typedef struct conn_rec conn_rec; /** A structure that represents the current request */ typedef struct request_rec request_rec; /** A structure that represents the status of the current connection */ typedef struct conn_state_t conn_state_t; /* ### would be nice to not include this from httpd.h ... */ /* This comes after we have defined the request_rec type */ #include "apr_uri.h" /** * @brief A structure that represents one process */ struct process_rec { /** Global pool. Cleared upon normal exit */ apr_pool_t *pool; /** Configuration pool. Cleared upon restart */ apr_pool_t *pconf; /** The program name used to execute the program */ const char *short_name; /** The command line arguments */ const char * const *argv; /** Number of command line arguments passed to the program */ int argc; }; /** * @brief A structure that represents the current request */ struct request_rec { /** The pool associated with the request */ apr_pool_t *pool; /** The connection to the client */ conn_rec *connection; /** The virtual host for this request */ server_rec *server; /** Pointer to the redirected request if this is an external redirect */ request_rec *next; /** Pointer to the previous request if this is an internal redirect */ request_rec *prev; /** Pointer to the main request if this is a sub-request * (see http_request.h) */ request_rec *main; /* Info about the request itself... we begin with stuff that only * protocol.c should ever touch... */ /** First line of request */ char *the_request; /** HTTP/0.9, "simple" request (e.g. GET /foo\n w/no headers) */ int assbackwards; /** A proxy request (calculated during post_read_request/translate_name) * possible values PROXYREQ_NONE, PROXYREQ_PROXY, PROXYREQ_REVERSE, * PROXYREQ_RESPONSE */ int proxyreq; /** HEAD request, as opposed to GET */ int header_only; /** Protocol version number of protocol; 1.1 = 1001 */ int proto_num; /** Protocol string, as given to us, or HTTP/0.9 */ char *protocol; /** Host, as set by full URI or Host: header. * For literal IPv6 addresses, this does NOT include the surrounding [ ] */ const char *hostname; /** Time when the request started */ apr_time_t request_time; /** Status line, if set by script */ const char *status_line; /** Status line */ int status; /* Request method, two ways; also, protocol, etc.. Outside of protocol.c, * look, but don't touch. */ /** M_GET, M_POST, etc. */ int method_number; /** Request method (eg. GET, HEAD, POST, etc.) */ const char *method; /** * 'allowed' is a bitvector of the allowed methods. * * A handler must ensure that the request method is one that * it is capable of handling. Generally modules should DECLINE * any request methods they do not handle. Prior to aborting the * handler like this the handler should set r->allowed to the list * of methods that it is willing to handle. This bitvector is used * to construct the "Allow:" header required for OPTIONS requests, * and HTTP_METHOD_NOT_ALLOWED and HTTP_NOT_IMPLEMENTED status codes. * * Since the default_handler deals with OPTIONS, all modules can * usually decline to deal with OPTIONS. TRACE is always allowed, * modules don't need to set it explicitly. * * Since the default_handler will always handle a GET, a * module which does *not* implement GET should probably return * HTTP_METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET * handler can't be installed by mod_actions. */ apr_int64_t allowed; /** Array of extension methods */ apr_array_header_t *allowed_xmethods; /** List of allowed methods */ ap_method_list_t *allowed_methods; /** byte count in stream is for body */ apr_off_t sent_bodyct; /** body byte count, for easy access */ apr_off_t bytes_sent; /** Last modified time of the requested resource */ apr_time_t mtime; /* HTTP/1.1 connection-level features */ /** The Range: header */ const char *range; /** The "real" content length */ apr_off_t clength; /** sending chunked transfer-coding */ int chunked; /** Method for reading the request body * (eg. REQUEST_CHUNKED_ERROR, REQUEST_NO_BODY, * REQUEST_CHUNKED_DECHUNK, etc...) */ int read_body; /** reading chunked transfer-coding */ int read_chunked; /** is client waiting for a 100 response? */ unsigned expecting_100; /** The optional kept body of the request. */ apr_bucket_brigade *kept_body; /** For ap_body_to_table(): parsed body */ /* XXX: ap_body_to_table has been removed. Remove body_table too or * XXX: keep it to reintroduce ap_body_to_table without major bump? */ apr_table_t *body_table; /** Remaining bytes left to read from the request body */ apr_off_t remaining; /** Number of bytes that have been read from the request body */ apr_off_t read_length; /* MIME header environments, in and out. Also, an array containing * environment variables to be passed to subprocesses, so people can * write modules to add to that environment. * * The difference between headers_out and err_headers_out is that the * latter are printed even on error, and persist across internal redirects * (so the headers printed for ErrorDocument handlers will have them). * * The 'notes' apr_table_t is for notes from one module to another, with no * other set purpose in mind... */ /** MIME header environment from the request */ apr_table_t *headers_in; /** MIME header environment for the response */ apr_table_t *headers_out; /** MIME header environment for the response, printed even on errors and * persist across internal redirects */ apr_table_t *err_headers_out; /** Array of environment variables to be used for sub processes */ apr_table_t *subprocess_env; /** Notes from one module to another */ apr_table_t *notes; /* content_type, handler, content_encoding, and all content_languages * MUST be lowercased strings. They may be pointers to static strings; * they should not be modified in place. */ /** The content-type for the current request */ const char *content_type; /* Break these out --- we dispatch on 'em */ /** The handler string that we use to call a handler function */ const char *handler; /* What we *really* dispatch on */ /** How to encode the data */ const char *content_encoding; /** Array of strings representing the content languages */ apr_array_header_t *content_languages; /** variant list validator (if negotiated) */ char *vlist_validator; /** If an authentication check was made, this gets set to the user name. */ char *user; /** If an authentication check was made, this gets set to the auth type. */ char *ap_auth_type; /* What object is being requested (either directly, or via include * or content-negotiation mapping). */ /** The URI without any parsing performed */ char *unparsed_uri; /** The path portion of the URI, or "/" if no path provided */ char *uri; /** The filename on disk corresponding to this response */ char *filename; /** The true filename stored in the filesystem, as in the true alpha case * and alias correction, e.g. "Image.jpeg" not "IMAGE$1.JPE" on Windows. * The core map_to_storage canonicalizes r->filename when they mismatch */ char *canonical_filename; /** The PATH_INFO extracted from this request */ char *path_info; /** The QUERY_ARGS extracted from this request */ char *args; /** * Flag for the handler to accept or reject path_info on * the current request. All modules should respect the * AP_REQ_ACCEPT_PATH_INFO and AP_REQ_REJECT_PATH_INFO * values, while AP_REQ_DEFAULT_PATH_INFO indicates they * may follow existing conventions. This is set to the * user's preference upon HOOK_VERY_FIRST of the fixups. */ int used_path_info; /** A flag to determine if the eos bucket has been sent yet */ int eos_sent; /* Various other config info which may change with .htaccess files * These are config vectors, with one void* pointer for each module * (the thing pointed to being the module's business). */ /** Options set in config files, etc. */ struct ap_conf_vector_t *per_dir_config; /** Notes on *this* request */ struct ap_conf_vector_t *request_config; /** Optional request log level configuration. Will usually point * to a server or per_dir config, i.e. must be copied before * modifying */ const struct ap_logconf *log; /** Id to identify request in access and error log. Set when the first * error log entry for this request is generated. */ const char *log_id; /** * A linked list of the .htaccess configuration directives * accessed by this request. * N.B. always add to the head of the list, _never_ to the end. * that way, a sub request's list can (temporarily) point to a parent's list */ const struct htaccess_result *htaccess; /** A list of output filters to be used for this request */ struct ap_filter_t *output_filters; /** A list of input filters to be used for this request */ struct ap_filter_t *input_filters; /** A list of protocol level output filters to be used for this * request */ struct ap_filter_t *proto_output_filters; /** A list of protocol level input filters to be used for this * request */ struct ap_filter_t *proto_input_filters; /** This response can not be cached */ int no_cache; /** There is no local copy of this response */ int no_local_copy; /** Mutex protect callbacks registered with ap_mpm_register_timed_callback * from being run before the original handler finishes running */ apr_thread_mutex_t *invoke_mtx; /** A struct containing the components of URI */ apr_uri_t parsed_uri; /** finfo.protection (st_mode) set to zero if no such file */ apr_finfo_t finfo; /** remote address information from conn_rec, can be overridden if * necessary by a module. * This is the address that originated the request. */ apr_sockaddr_t *useragent_addr; char *useragent_ip; /** MIME trailer environment from the request */ apr_table_t *trailers_in; /** MIME trailer environment from the response */ apr_table_t *trailers_out; /** Originator's DNS name, if known. NULL if DNS hasn't been checked, * "" if it has and no address was found. N.B. Only access this though * ap_get_useragent_host() */ char *useragent_host; /** have we done double-reverse DNS? -1 yes/failure, 0 not yet, * 1 yes/success */ int double_reverse; /** Request flags associated with this request. Use * AP_REQUEST_GET_BNOTE() and AP_REQUEST_SET_BNOTE() to access * the elements of this field. */ ap_request_bnotes_t bnotes; }; /** * @defgroup ProxyReq Proxy request types * * Possible values of request_rec->proxyreq. A request could be normal, * proxied or reverse proxied. Normally proxied and reverse proxied are * grouped together as just "proxied", but sometimes it's necessary to * tell the difference between the two, such as for authentication. * @{ */ #define PROXYREQ_NONE 0 /**< No proxy */ #define PROXYREQ_PROXY 1 /**< Standard proxy */ #define PROXYREQ_REVERSE 2 /**< Reverse proxy */ #define PROXYREQ_RESPONSE 3 /**< Origin response */ /* @} */ /** * @brief Enumeration of connection keepalive options */ typedef enum { AP_CONN_UNKNOWN, AP_CONN_CLOSE, AP_CONN_KEEPALIVE } ap_conn_keepalive_e; /** * @brief Structure to store things which are per connection */ struct conn_rec { /** Pool associated with this connection */ apr_pool_t *pool; /** Physical vhost this conn came in on */ server_rec *base_server; /** used by http_vhost.c */ void *vhost_lookup_data; /* Information about the connection itself */ /** local address */ apr_sockaddr_t *local_addr; /** remote address; this is the end-point of the next hop, for the address * of the request creator, see useragent_addr in request_rec */ apr_sockaddr_t *client_addr; /** Client's IP address; this is the end-point of the next hop, for the * IP of the request creator, see useragent_ip in request_rec */ char *client_ip; /** Client's DNS name, if known. NULL if DNS hasn't been checked, * "" if it has and no address was found. N.B. Only access this though * get_remote_host() */ char *remote_host; /** Only ever set if doing rfc1413 lookups. N.B. Only access this through * get_remote_logname() */ char *remote_logname; /** server IP address */ char *local_ip; /** used for ap_get_server_name when UseCanonicalName is set to DNS * (ignores setting of HostnameLookups) */ char *local_host; /** ID of this connection; unique at any point in time */ long id; /** Config vector containing pointers to connections per-server * config structures. */ struct ap_conf_vector_t *conn_config; /** Notes on *this* connection: send note from one module to * another. must remain valid for all requests on this conn */ apr_table_t *notes; /** A list of input filters to be used for this connection */ struct ap_filter_t *input_filters; /** A list of output filters to be used for this connection */ struct ap_filter_t *output_filters; /** handle to scoreboard information for this connection */ void *sbh; /** The bucket allocator to use for all bucket/brigade creations */ struct apr_bucket_alloc_t *bucket_alloc; /** The current state of this connection; may be NULL if not used by MPM */ conn_state_t *cs; /** Is there data pending in the input filters? */ int data_in_input_filters; /** Is there data pending in the output filters? */ int data_in_output_filters; /** Are there any filters that clogg/buffer the input stream, breaking * the event mpm. */ unsigned int clogging_input_filters:1; /** have we done double-reverse DNS? -1 yes/failure, 0 not yet, * 1 yes/success */ signed int double_reverse:2; /** Are we still talking? */ unsigned aborted; /** Are we going to keep the connection alive for another request? * @see ap_conn_keepalive_e */ ap_conn_keepalive_e keepalive; /** How many times have we used it? */ int keepalives; /** Optional connection log level configuration. May point to a server or * per_dir config, i.e. must be copied before modifying */ const struct ap_logconf *log; /** Id to identify this connection in error log. Set when the first * error log entry for this connection is generated. */ const char *log_id; /** This points to the current thread being used to process this request, * over the lifetime of a request, the value may change. Users of the connection * record should not rely upon it staying the same between calls that involve * the MPM. */ #if APR_HAS_THREADS apr_thread_t *current_thread; #endif /** The "real" master connection. NULL if I am the master. */ conn_rec *master; int outgoing; }; /** * Enumeration of connection states * The two states CONN_STATE_LINGER_NORMAL and CONN_STATE_LINGER_SHORT may * only be set by the MPM. Use CONN_STATE_LINGER outside of the MPM. */ typedef enum { CONN_STATE_KEEPALIVE, /* Kept alive in the MPM (using KeepAliveTimeout) */ CONN_STATE_PROCESSING, /* Processed by process_connection hooks */ CONN_STATE_HANDLER, /* Processed by the modules handlers */ CONN_STATE_WRITE_COMPLETION, /* Flushed by the MPM before entering CONN_STATE_KEEPALIVE */ CONN_STATE_SUSPENDED, /* Suspended in the MPM until ap_run_resume_suspended() */ CONN_STATE_LINGER, /* MPM flushes then closes the connection with lingering */ CONN_STATE_LINGER_NORMAL, /* MPM has started lingering close with normal timeout */ CONN_STATE_LINGER_SHORT, /* MPM has started lingering close with short timeout */ CONN_STATE_ASYNC_WAITIO, /* Returning this state to the MPM will make it wait for * the connection to be readable or writable according to * c->cs->sense (resp. CONN_SENSE_WANT_READ or _WRITE), * using the configured Timeout */ CONN_STATE_NUM, /* Number of states (keep here before aliases) */ /* Aliases (legacy) */ CONN_STATE_CHECK_REQUEST_LINE_READABLE = CONN_STATE_KEEPALIVE, CONN_STATE_READ_REQUEST_LINE = CONN_STATE_PROCESSING, } conn_state_e; typedef enum { CONN_SENSE_DEFAULT, CONN_SENSE_WANT_READ, /* next event must be read */ CONN_SENSE_WANT_WRITE /* next event must be write */ } conn_sense_e; /** * @brief A structure to contain connection state information */ struct conn_state_t { /** Current state of the connection */ conn_state_e state; /** Whether to read instead of write, or write instead of read */ conn_sense_e sense; }; /* Per-vhost config... */ /** * The address 255.255.255.255, when used as a virtualhost address, * will become the "default" server when the ip doesn't match other vhosts. */ #define DEFAULT_VHOST_ADDR 0xfffffffful /** * @struct server_addr_rec * @brief A structure to be used for Per-vhost config */ typedef struct server_addr_rec server_addr_rec; struct server_addr_rec { /** The next server in the list */ server_addr_rec *next; /** The name given in "<VirtualHost>" */ char *virthost; /** The bound address, for this server */ apr_sockaddr_t *host_addr; /** The bound port, for this server */ apr_port_t host_port; }; struct ap_logconf { /** The per-module log levels */ signed char *module_levels; /** The log level for this server */ int level; }; /** * @brief A structure to store information for each virtual server */ struct server_rec { /** The process this server is running in */ process_rec *process; /** The next server in the list */ server_rec *next; /* Log files --- note that transfer log is now in the modules... */ /** The name of the error log */ char *error_fname; /** A file descriptor that references the error log */ apr_file_t *error_log; /** The log level configuration */ struct ap_logconf log; /* Module-specific configuration for server, and defaults... */ /** Config vector containing pointers to modules' per-server config * structures. */ struct ap_conf_vector_t *module_config; /** MIME type info, etc., before we start checking per-directory info */ struct ap_conf_vector_t *lookup_defaults; /** The path to the config file that the server was defined in */ const char *defn_name; /** The line of the config file that the server was defined on */ unsigned defn_line_number; /** true if this is the virtual server */ char is_virtual; /* Information for redirects */ /** for redirects, etc. */ apr_port_t port; /** The server request scheme for redirect responses */ const char *server_scheme; /* Contact information */ /** The admin's contact information */ char *server_admin; /** The server hostname */ char *server_hostname; /* Transaction handling */ /** I haven't got a clue */ server_addr_rec *addrs; /** Timeout, as an apr interval, before we give up */ apr_interval_time_t timeout; /** The apr interval we will wait for another request */ apr_interval_time_t keep_alive_timeout; /** Maximum requests per connection */ int keep_alive_max; /** Use persistent connections? */ int keep_alive; /** Normal names for ServerAlias servers */ apr_array_header_t *names; /** Wildcarded names for ServerAlias servers */ apr_array_header_t *wild_names; /** Pathname for ServerPath */ const char *path; /** Length of path */ int pathlen; /** limit on size of the HTTP request line */ int limit_req_line; /** limit on size of any request header field */ int limit_req_fieldsize; /** limit on number of request header fields */ int limit_req_fields; /** Opaque storage location */ void *context; /** Whether the keepalive timeout is explicit (1) or * inherited (0) from the base server (either first * server on the same IP:port or main server) */ unsigned int keep_alive_timeout_set:1; }; /** * @struct ap_sload_t * @brief A structure to hold server load params */ typedef struct ap_sload_t ap_sload_t; struct ap_sload_t { /* percentage of process/threads ready/idle (0->100)*/ int idle; /* percentage of process/threads busy (0->100) */ int busy; /* total bytes served */ apr_off_t bytes_served; /* total access count */ unsigned long access_count; }; /** * @struct ap_loadavg_t * @brief A structure to hold various server loadavg */ typedef struct ap_loadavg_t ap_loadavg_t; struct ap_loadavg_t { /* current loadavg, ala getloadavg() */ float loadavg; /* 5 min loadavg */ float loadavg5; /* 15 min loadavg */ float loadavg15; }; /** * Get the context_document_root for a request. This is a generalization of * the document root, which is too limited in the presence of mappers like * mod_userdir and mod_alias. The context_document_root is the directory * on disk that maps to the context_prefix URI prefix. * @param r The request * @note For resources that do not map to the file system or for very complex * mappings, this information may still be wrong. */ AP_DECLARE(const char *) ap_context_document_root(request_rec *r); /** * Get the context_prefix for a request. The context_prefix URI prefix * maps to the context_document_root on disk. * @param r The request */ AP_DECLARE(const char *) ap_context_prefix(request_rec *r); /** Set context_prefix and context_document_root for a request. * @param r The request * @param prefix the URI prefix, without trailing slash * @param document_root the corresponding directory on disk, without trailing * slash * @note If one of prefix of document_root is NULL, the corrsponding * property will not be changed. */ AP_DECLARE(void) ap_set_context_info(request_rec *r, const char *prefix, const char *document_root); /** Set per-request document root. This is for mass virtual hosting modules * that want to provide the correct DOCUMENT_ROOT value to scripts. * @param r The request * @param document_root the document root for the request. */ AP_DECLARE(void) ap_set_document_root(request_rec *r, const char *document_root); /** * Examine a field value (such as a media-/content-type) string and return * it sans any parameters; e.g., strip off any ';charset=foo' and the like. * @param p Pool to allocate memory from * @param intype The field to examine * @return A copy of the field minus any parameters */ AP_DECLARE(char *) ap_field_noparam(apr_pool_t *p, const char *intype); /** * Convert a time from an integer into a string in a specified format * @param p The pool to allocate memory from * @param t The time to convert * @param fmt The format to use for the conversion * @param gmt Convert the time for GMT? * @return The string that represents the specified time */ AP_DECLARE(char *) ap_ht_time(apr_pool_t *p, apr_time_t t, const char *fmt, int gmt); /* String handling. The *_nc variants allow you to use non-const char **s as arguments (unfortunately C won't automatically convert a char ** to a const char **) */ /** * Get the characters until the first occurrence of a specified character * @param p The pool to allocate memory from * @param line The string to get the characters from * @param stop The character to stop at * @return A copy of the characters up to the first stop character */ AP_DECLARE(char *) ap_getword(apr_pool_t *p, const char **line, char stop); /** * Get the characters until the first occurrence of a specified character * @param p The pool to allocate memory from * @param line The string to get the characters from * @param stop The character to stop at * @return A copy of the characters up to the first stop character * @note This is the same as ap_getword(), except it doesn't use const char **. */ AP_DECLARE(char *) ap_getword_nc(apr_pool_t *p, char **line, char stop); /** * Get the first word from a given string. A word is defined as all characters * up to the first whitespace. * @param p The pool to allocate memory from * @param line The string to traverse * @return The first word in the line */ AP_DECLARE(char *) ap_getword_white(apr_pool_t *p, const char **line); /** * Get the first word from a given string. A word is defined as all characters * up to the first whitespace. * @param p The pool to allocate memory from * @param line The string to traverse * @return The first word in the line * @note The same as ap_getword_white(), except it doesn't use const char** */ AP_DECLARE(char *) ap_getword_white_nc(apr_pool_t *p, char **line); /** * Get all characters from the first occurrence of @a stop to the first "\0" * @param p The pool to allocate memory from * @param line The line to traverse * @param stop The character to start at * @return A copy of all characters after the first occurrence of the specified * character */ AP_DECLARE(char *) ap_getword_nulls(apr_pool_t *p, const char **line, char stop); /** * Get all characters from the first occurrence of @a stop to the first "\0" * @param p The pool to allocate memory from * @param line The line to traverse * @param stop The character to start at * @return A copy of all characters after the first occurrence of the specified * character * @note The same as ap_getword_nulls(), except it doesn't use const char **. */ AP_DECLARE(char *) ap_getword_nulls_nc(apr_pool_t *p, char **line, char stop); /** * Get the second word in the string paying attention to quoting * @param p The pool to allocate from * @param line The line to traverse * @return A copy of the string */ AP_DECLARE(char *) ap_getword_conf(apr_pool_t *p, const char **line); /** * Get the second word in the string paying attention to quoting * @param p The pool to allocate from * @param line The line to traverse * @return A copy of the string * @note The same as ap_getword_conf(), except it doesn't use const char **. */ AP_DECLARE(char *) ap_getword_conf_nc(apr_pool_t *p, char **line); /** * Get the second word in the string paying attention to quoting, * with {...} supported as well as "..." and '...' * @param p The pool to allocate from * @param line The line to traverse * @return A copy of the string */ AP_DECLARE(char *) ap_getword_conf2(apr_pool_t *p, const char **line); /** * Get the second word in the string paying attention to quoting, * with {...} supported as well as "..." and '...' * @param p The pool to allocate from * @param line The line to traverse * @return A copy of the string * @note The same as ap_getword_conf2(), except it doesn't use const char **. */ AP_DECLARE(char *) ap_getword_conf2_nc(apr_pool_t *p, char **line); /** * Check a string for any config define or environment variable construct * and replace each of them by the value of that variable, if it exists. * The default syntax of the constructs is ${ENV} but can be changed by * setting the define::* config defines. If the variable does not exist, * leave the ${ENV} construct alone but print a warning. * @param p The pool to allocate from * @param word The string to check * @return The string with the replaced environment variables */ AP_DECLARE(const char *) ap_resolve_env(apr_pool_t *p, const char * word); /** * Size an HTTP header field list item, as separated by a comma. * @param field The field to size * @param len The length of the field * @return The return value is a pointer to the beginning of the non-empty * list item within the original string (or NULL if there is none) and the * address of field is shifted to the next non-comma, non-whitespace * character. len is the length of the item excluding any beginning whitespace. */ AP_DECLARE(const char *) ap_size_list_item(const char **field, int *len); /** * Retrieve an HTTP header field list item, as separated by a comma, * while stripping insignificant whitespace and lowercasing anything not in * a quoted string or comment. * @param p The pool to allocate from * @param field The field to retrieve * @return The return value is a new string containing the converted list * item (or NULL if none) and the address pointed to by field is * shifted to the next non-comma, non-whitespace. */ AP_DECLARE(char *) ap_get_list_item(apr_pool_t *p, const char **field); /** * Find an item in canonical form (lowercase, no extra spaces) within * an HTTP field value list. * @param p The pool to allocate from * @param line The field value list to search * @param tok The token to search for * @return 1 if found, 0 if not found. */ AP_DECLARE(int) ap_find_list_item(apr_pool_t *p, const char *line, const char *tok); /** * Do a weak ETag comparison within an HTTP field value list. * @param p The pool to allocate from * @param line The field value list to search * @param tok The token to search for * @return 1 if found, 0 if not found. */ AP_DECLARE(int) ap_find_etag_weak(apr_pool_t *p, const char *line, const char *tok); /** * Do a strong ETag comparison within an HTTP field value list. * @param p The pool to allocate from * @param line The field value list to search * @param tok The token to search for * @return 1 if found, 0 if not found. */ AP_DECLARE(int) ap_find_etag_strong(apr_pool_t *p, const char *line, const char *tok); /* Scan a string for field content chars, as defined by RFC7230 section 3.2 * including VCHAR/obs-text, as well as HT and SP * @param ptr The string to scan * @return A pointer to the first (non-HT) ASCII ctrl character. * @note lws and trailing whitespace are scanned, the caller is responsible * for trimming leading and trailing whitespace */ AP_DECLARE(const char *) ap_scan_http_field_content(const char *ptr); /* Scan a string for token characters, as defined by RFC7230 section 3.2.6 * @param ptr The string to scan * @return A pointer to the first non-token character. */ AP_DECLARE(const char *) ap_scan_http_token(const char *ptr); /* Scan a string for visible ASCII (0x21-0x7E) or obstext (0x80+) * and return a pointer to the first SP/CTL/NUL character encountered. * @param ptr The string to scan * @return A pointer to the first SP/CTL character. */ AP_DECLARE(const char *) ap_scan_vchar_obstext(const char *ptr); /** * Retrieve an array of tokens in the format "1#token" defined in RFC2616. Only * accepts ',' as a delimiter, does not accept quoted strings, and errors on * any separator. * @param p The pool to allocate from * @param tok The line to read tokens from * @param tokens Pointer to an array of tokens. If not NULL, must be an array * of char*, otherwise it will be allocated on @a p when a token is found * @param skip_invalid If true, when an invalid separator is encountered, it * will be ignored. * @return NULL on success, an error string otherwise. * @remark *tokens may be NULL on output if NULL in input and no token is found */ AP_DECLARE(const char *) ap_parse_token_list_strict(apr_pool_t *p, const char *tok, apr_array_header_t **tokens, int skip_invalid); /** * Retrieve a token, spacing over it and adjusting the pointer to * the first non-white byte afterwards. Note that these tokens * are delimited by semis and commas and can also be delimited * by whitespace at the caller's option. * @param p The pool to allocate from * @param accept_line The line to retrieve the token from (adjusted afterwards) * @param accept_white Is it delimited by whitespace * @return the token */ AP_DECLARE(char *) ap_get_token(apr_pool_t *p, const char **accept_line, int accept_white); /** * Find http tokens, see the definition of token from RFC2068 * @param p The pool to allocate from * @param line The line to find the token * @param tok The token to find * @return 1 if the token is found, 0 otherwise */ AP_DECLARE(int) ap_find_token(apr_pool_t *p, const char *line, const char *tok); /** * find http tokens from the end of the line * @param p The pool to allocate from * @param line The line to find the token * @param tok The token to find * @return 1 if the token is found, 0 otherwise */ AP_DECLARE(int) ap_find_last_token(apr_pool_t *p, const char *line, const char *tok); /** * Check for an Absolute URI syntax * @param u The string to check * @return 1 if URI, 0 otherwise */ AP_DECLARE(int) ap_is_url(const char *u); /** * Unescape a string * @param url The string to unescape * @return 0 on success, non-zero otherwise */ AP_DECLARE(int) ap_unescape_all(char *url); /** * Unescape a URL * @param url The url to unescape * @return 0 on success, non-zero otherwise */ AP_DECLARE(int) ap_unescape_url(char *url); /** * Unescape a URL, but leaving %2f (slashes) escaped * @param url The url to unescape * @param decode_slashes Whether or not slashes should be decoded * @return 0 on success, non-zero otherwise */ AP_DECLARE(int) ap_unescape_url_keep2f(char *url, int decode_slashes); #define AP_UNESCAPE_URL_KEEP_UNRESERVED (1u << 0) #define AP_UNESCAPE_URL_FORBID_SLASHES (1u << 1) #define AP_UNESCAPE_URL_KEEP_SLASHES (1u << 2) /** * Unescape a URL, with options * @param url The url to unescape * @param flags Bitmask of AP_UNESCAPE_URL_* flags * @return 0 on success, non-zero otherwise */ AP_DECLARE(int) ap_unescape_url_ex(char *url, unsigned int flags); /** * Unescape an application/x-www-form-urlencoded string * @param query The query to unescape * @return 0 on success, non-zero otherwise */ AP_DECLARE(int) ap_unescape_urlencoded(char *query); /** * Convert all double slashes to single slashes, except where significant * to the filesystem on the current platform. * @param name The string to convert, assumed to be a filesystem path */ AP_DECLARE(void) ap_no2slash(char *name); /** * Convert all double slashes to single slashes, except where significant * to the filesystem on the current platform. * @param name The string to convert * @param is_fs_path if set to 0, the significance of any double-slashes is * ignored. */ AP_DECLARE(void) ap_no2slash_ex(char *name, int is_fs_path); #define AP_NORMALIZE_ALLOW_RELATIVE (1u << 0) #define AP_NORMALIZE_NOT_ABOVE_ROOT (1u << 1) #define AP_NORMALIZE_DECODE_UNRESERVED (1u << 2) #define AP_NORMALIZE_MERGE_SLASHES (1u << 3) #define AP_NORMALIZE_DROP_PARAMETERS (0) /* deprecated */ /** * Remove all ////, /./ and /xx/../ substrings from a path, and more * depending on passed in flags. * @param path The path to normalize * @param flags bitmask of AP_NORMALIZE_* flags * @return non-zero on success */ AP_DECLARE(int) ap_normalize_path(char *path, unsigned int flags); /** * Remove all ./ and xx/../ substrings from a file name. Also remove * any leading ../ or /../ substrings. * @param name the file name to parse */ AP_DECLARE(void) ap_getparents(char *name); /** * Escape a path segment, as defined in RFC 1808 * @param p The pool to allocate from * @param s The path to convert * @return The converted URL */ AP_DECLARE(char *) ap_escape_path_segment(apr_pool_t *p, const char *s); /** * Escape a path segment, as defined in RFC 1808, to a preallocated buffer. * @param c The preallocated buffer to write to * @param s The path to convert * @return The converted URL (c) */ AP_DECLARE(char *) ap_escape_path_segment_buffer(char *c, const char *s); /** * convert an OS path to a URL in an OS dependent way. * @param p The pool to allocate from * @param path The path to convert * @param partial if set, assume that the path will be appended to something * with a '/' in it (and thus does not prefix "./") * @return The converted URL */ AP_DECLARE(char *) ap_os_escape_path(apr_pool_t *p, const char *path, int partial); /** @see ap_os_escape_path */ #define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1) /** * Escape a string as application/x-www-form-urlencoded * @param p The pool to allocate from * @param s The path to convert * @return The converted URL */ AP_DECLARE(char *) ap_escape_urlencoded(apr_pool_t *p, const char *s); /** * Escape a string as application/x-www-form-urlencoded, to a preallocated buffer * @param c The preallocated buffer to write to * @param s The path to convert * @return The converted URL (c) */ AP_DECLARE(char *) ap_escape_urlencoded_buffer(char *c, const char *s); /** * Escape an html string * @param p The pool to allocate from * @param s The html to escape * @return The escaped string */ #define ap_escape_html(p,s) ap_escape_html2(p,s,0) /** * Escape an html string * @param p The pool to allocate from * @param s The html to escape * @param toasc Whether to escape all non-ASCII chars to \&\#nnn; * @return The escaped string */ AP_DECLARE(char *) ap_escape_html2(apr_pool_t *p, const char *s, int toasc); /** * Escape a string for logging * @param p The pool to allocate from * @param str The string to escape * @return The escaped string */ AP_DECLARE(char *) ap_escape_logitem(apr_pool_t *p, const char *str); /** * Escape a string for logging into the error log (without a pool) * @param dest The buffer to write to * @param source The string to escape * @param buflen The buffer size for the escaped string (including "\0") * @return The len of the escaped string (always < maxlen) */ AP_DECLARE(apr_size_t) ap_escape_errorlog_item(char *dest, const char *source, apr_size_t buflen); /** * Construct a full hostname * @param p The pool to allocate from * @param hostname The hostname of the server * @param port The port the server is running on * @param r The current request * @return The server's hostname */ AP_DECLARE(char *) ap_construct_server(apr_pool_t *p, const char *hostname, apr_port_t port, const request_rec *r); /** * Escape a shell command * @param p The pool to allocate from * @param s The command to escape * @return The escaped shell command */ AP_DECLARE(char *) ap_escape_shell_cmd(apr_pool_t *p, const char *s); /** * Count the number of directories in a path * @param path The path to count * @return The number of directories */ AP_DECLARE(int) ap_count_dirs(const char *path); /** * Copy at most @a n leading directories of @a s into @a d. @a d * should be at least as large as @a s plus 1 extra byte * * @param d The location to copy to * @param s The location to copy from * @param n The number of directories to copy * @return value is the ever useful pointer to the trailing "\0" of d * @note on platforms with drive letters, n = 0 returns the "/" root, * whereas n = 1 returns the "d:/" root. On all other platforms, n = 0 * returns the empty string. */ AP_DECLARE(char *) ap_make_dirstr_prefix(char *d, const char *s, int n); /** * Return the parent directory name (including trailing /) of the file * @a s * @param p The pool to allocate from * @param s The file to get the parent of * @return A copy of the file's parent directory */ AP_DECLARE(char *) ap_make_dirstr_parent(apr_pool_t *p, const char *s); /** * Given a directory and filename, create a single path from them. This * function is smart enough to ensure that there is a single '/' between the * directory and file names * @param a The pool to allocate from * @param dir The directory name * @param f The filename * @return A copy of the full path * @note Never consider using this function if you are dealing with filesystem * names that need to remain canonical, unless you are merging an apr_dir_read * path and returned filename. Otherwise, the result is not canonical. */ AP_DECLARE(char *) ap_make_full_path(apr_pool_t *a, const char *dir, const char *f); /** * Test if the given path has an absolute path. * @param p The pool to allocate from * @param dir The directory name * @note The converse is not necessarily true, some OS's (Win32/OS2/Netware) have * multiple forms of absolute paths. This only reports if the path is absolute * in a canonical sense. */ AP_DECLARE(int) ap_os_is_path_absolute(apr_pool_t *p, const char *dir); /** * Does the provided string contain wildcard characters? This is useful * for determining if the string should be passed to strcmp_match or to strcmp. * The only wildcard characters recognized are '?' and '*' * @param str The string to check * @return 1 if the string has wildcards, 0 otherwise */ AP_DECLARE(int) ap_is_matchexp(const char *str); /** * Determine if a string matches a pattern containing the wildcards '?' or '*' * @param str The string to check * @param expected The pattern to match against * @return 0 if the two strings match, 1 otherwise */ AP_DECLARE(int) ap_strcmp_match(const char *str, const char *expected); /** * Determine if a string matches a pattern containing the wildcards '?' or '*', * ignoring case * @param str The string to check * @param expected The pattern to match against * @return 0 if the two strings match, 1 otherwise */ AP_DECLARE(int) ap_strcasecmp_match(const char *str, const char *expected); /** * Find the first occurrence of the substring s2 in s1, regardless of case * @param s1 The string to search * @param s2 The substring to search for * @return A pointer to the beginning of the substring * @remark See apr_strmatch() for a faster alternative */ AP_DECLARE(char *) ap_strcasestr(const char *s1, const char *s2); /** * Return a pointer to the location inside of bigstring immediately after prefix * @param bigstring The input string * @param prefix The prefix to strip away * @return A pointer relative to bigstring after prefix */ AP_DECLARE(const char *) ap_stripprefix(const char *bigstring, const char *prefix); /** * Decode a base64 encoded string into memory allocated from a pool * @param p The pool to allocate from * @param bufcoded The encoded string * @return The decoded string */ AP_DECLARE(char *) ap_pbase64decode(apr_pool_t *p, const char *bufcoded); /** * Encode a string into memory allocated from a pool in base 64 format * @param p The pool to allocate from * @param string The plaintext string * @return The encoded string */ AP_DECLARE(char *) ap_pbase64encode(apr_pool_t *p, char *string); /** * Compile a regular expression to be used later. The regex is freed when * the pool is destroyed. * @param p The pool to allocate from * @param pattern the regular expression to compile * @param cflags The bitwise or of one or more of the following: * @li REG_EXTENDED - Use POSIX extended Regular Expressions * @li REG_ICASE - Ignore case * @li REG_NOSUB - Support for substring addressing of matches * not required * @li REG_NEWLINE - Match-any-character operators don't match new-line * @return The compiled regular expression */ AP_DECLARE(ap_regex_t *) ap_pregcomp(apr_pool_t *p, const char *pattern, int cflags); /** * Free the memory associated with a compiled regular expression * @param p The pool the regex was allocated from * @param reg The regular expression to free * @note This function is only necessary if the regex should be cleaned * up before the pool */ AP_DECLARE(void) ap_pregfree(apr_pool_t *p, ap_regex_t *reg); /** * After performing a successful regex match, you may use this function to * perform a series of string substitutions based on subexpressions that were * matched during the call to ap_regexec. This function is limited to * result strings of 64K. Consider using ap_pregsub_ex() instead. * @param p The pool to allocate from * @param input An arbitrary string containing $1 through $9. These are * replaced with the corresponding matched sub-expressions * @param source The string that was originally matched to the regex * @param nmatch the nmatch returned from ap_pregex * @param pmatch the pmatch array returned from ap_pregex * @return The substituted string, or NULL on error */ AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input, const char *source, apr_size_t nmatch, ap_regmatch_t pmatch[]); /** * After performing a successful regex match, you may use this function to * perform a series of string substitutions based on subexpressions that were * matched during the call to ap_regexec * @param p The pool to allocate from * @param result where to store the result, will be set to NULL on error * @param input An arbitrary string containing $1 through $9. These are * replaced with the corresponding matched sub-expressions * @param source The string that was originally matched to the regex * @param nmatch the nmatch returned from ap_pregex * @param pmatch the pmatch array returned from ap_pregex * @param maxlen the maximum string length to return, 0 for unlimited * @return APR_SUCCESS if successful, APR_ENOMEM or other error code otherwise. */ AP_DECLARE(apr_status_t) ap_pregsub_ex(apr_pool_t *p, char **result, const char *input, const char *source, apr_size_t nmatch, ap_regmatch_t pmatch[], apr_size_t maxlen); /** * We want to downcase the type/subtype for comparison purposes * but nothing else because ;parameter=foo values are case sensitive. * @param s The content-type to convert to lowercase */ AP_DECLARE(void) ap_content_type_tolower(char *s); /** * convert a string to all lowercase * @param s The string to convert to lowercase */ AP_DECLARE(void) ap_str_tolower(char *s); /** * convert a string to all uppercase * @param s The string to convert to uppercase */ AP_DECLARE(void) ap_str_toupper(char *s); /** * Search a string from left to right for the first occurrence of a * specific character * @param str The string to search * @param c The character to search for * @return The index of the first occurrence of c in str */ AP_DECLARE(int) ap_ind(const char *str, char c); /* Sigh... */ /** * Search a string from right to left for the first occurrence of a * specific character * @param str The string to search * @param c The character to search for * @return The index of the first occurrence of c in str */ AP_DECLARE(int) ap_rind(const char *str, char c); /** * Check whether two buffers of equal size have the same content, using a * constant time algorithm (branch-less with regard to the content of the * buffers and an execution time solely dependent on the number of bytes * compared, not the bytes themselves). * * @param buf1 first buffer to compare * @param buf2 second buffer to compare * @param n number of bytes to compare * @return 1 if equal, 0 otherwise */ AP_DECLARE(int) ap_memeq_timingsafe(const void *buf1, const void *buf2, apr_size_t n); /** * Check whether two NUL-terminated strings have the same content, using a * constant time algorithm (branch-less with regard to the content of the * secret string and an execution time solely dependent on the length of * the non-secret string). The secret string of the two should be set in * the first parameter \c sec1 to avoid leaking its length. * * @param sec1 first string to compare (the secret one) * @param str2 second string to compare * @return 1 if equal, 0 otherwise * @remark The function will compare as much characters as there are in * \c str2, so the length of \c str2 might leak through side channel, * while the length of \c sec1 does not. */ AP_DECLARE(int) ap_streq_timingsafe(const char *sec1, const char *str2); /** * Check whether two NUL-terminated strings have the same content, up to \c n * characters, using a constant time algorithm (branch-less with regard to the * content of the secret string and an execution time solely dependent on the * length of the non-secret string or \c n). The secret string of the two * should be set in the first parameter \c sec1 to avoid leaking its length. * * @param sec1 secret string to compare * @param str2 string to compare with * @param n max number of characters to compare * @return 1 if equal, 0 otherwise * @remark The function will compare as much characters as there are in * \c str2 if it's less than \c n, so the length of \c str2 might * leak through side channel, while the length of \c sec1 does not. */ AP_DECLARE(int) ap_strneq_timingsafe(const char *sec1, const char *str2, apr_size_t n); /** * Given a string, replace any bare " with \\" . * @param p The pool to allocate memory from * @param instring The string to search for " * @return A copy of the string with escaped quotes */ AP_DECLARE(char *) ap_escape_quotes(apr_pool_t *p, const char *instring); /** * Given a string, append the PID deliminated by delim. * Usually used to create a pid-appended filepath name * (eg: /a/b/foo -> /a/b/foo.6726). A function, and not * a macro, to avoid unistd.h dependency * @param p The pool to allocate memory from * @param string The string to append the PID to * @param delim The string to use to deliminate the string from the PID * @return A copy of the string with the PID appended */ AP_DECLARE(char *) ap_append_pid(apr_pool_t *p, const char *string, const char *delim); /** * Parse a length string with decimal characters only, no leading sign nor * trailing character, like Content-Length or (Content-)Range headers. * @param len The parsed length (apr_off_t) * @param str The string to parse * @return 1 (success), 0 (failure) */ AP_DECLARE(int) ap_parse_strict_length(apr_off_t *len, const char *str); /** * Parse a given timeout parameter string into an apr_interval_time_t value. * The unit of the time interval is given as postfix string to the numeric * string. Currently the following units are understood: * * ms : milliseconds * s : seconds * mi[n] : minutes * h : hours * * If no unit is contained in the given timeout parameter the default_time_unit * will be used instead. * @param timeout_parameter The string containing the timeout parameter. * @param timeout The timeout value to be returned. * @param default_time_unit The default time unit to use if none is specified * in timeout_parameter. * @return Status value indicating whether the parsing was successful or not. */ AP_DECLARE(apr_status_t) ap_timeout_parameter_parse( const char *timeout_parameter, apr_interval_time_t *timeout, const char *default_time_unit); /** * Determine if a request has a request body or not. * * @param r the request_rec of the request * @return truth value */ AP_DECLARE(int) ap_request_has_body(request_rec *r); /** * Cleanup a string (mainly to be filesystem safe) * We only allow '_' and alphanumeric chars. Non-printable * map to 'x' and all others map to '_' * * @param p pool to use to allocate dest * @param src string to clean up * @param dest cleaned up, allocated string * @return Status value indicating whether the cleaning was successful or not. */ AP_DECLARE(apr_status_t) ap_pstr2_alnum(apr_pool_t *p, const char *src, const char **dest); /** * Cleanup a string (mainly to be filesystem safe) * We only allow '_' and alphanumeric chars. Non-printable * map to 'x' and all others map to '_' * * @param src string to clean up * @param dest cleaned up, pre-allocated string * @return Status value indicating whether the cleaning was successful or not. */ AP_DECLARE(apr_status_t) ap_str2_alnum(const char *src, char *dest); /** * Structure to store the contents of an HTTP form of the type * application/x-www-form-urlencoded. * * Currently it contains the name as a char* of maximum length * HUGE_STRING_LEN, and a value in the form of a bucket brigade * of arbitrary length. */ typedef struct { const char *name; apr_bucket_brigade *value; } ap_form_pair_t; /** * Read the body and parse any form found, which must be of the * type application/x-www-form-urlencoded. * @param r request containing POSTed form data * @param f filter * @param ptr returned array of ap_form_pair_t * @param num max num of params or -1 for unlimited * @param size max size allowed for parsed data * @return OK or HTTP error */ AP_DECLARE(int) ap_parse_form_data(request_rec *r, struct ap_filter_t *f, apr_array_header_t **ptr, apr_size_t num, apr_size_t size); /* Misc system hackery */ /** * Given the name of an object in the file system determine if it is a directory * @param p The pool to allocate from * @param name The name of the object to check * @return 1 if it is a directory, 0 otherwise */ AP_DECLARE(int) ap_is_rdirectory(apr_pool_t *p, const char *name); /** * Given the name of an object in the file system determine if it is a directory - this version is symlink aware * @param p The pool to allocate from * @param name The name of the object to check * @return 1 if it is a directory, 0 otherwise */ AP_DECLARE(int) ap_is_directory(apr_pool_t *p, const char *name); #ifdef _OSD_POSIX extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process); #endif /* _OSD_POSIX */ /** * Determine the local host name for the current machine * @param p The pool to allocate from * @return A copy of the local host name */ char *ap_get_local_host(apr_pool_t *p); /** * Log an assertion to the error log * @param szExp The assertion that failed * @param szFile The file the assertion is in * @param nLine The line the assertion is defined on */ AP_DECLARE(void) ap_log_assert(const char *szExp, const char *szFile, int nLine) __attribute__((noreturn)); /** * @internal Internal Assert function */ #define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__)) /** * Redefine assert() to something more useful for an Apache... * * Use ap_assert() if the condition should always be checked. * Use AP_DEBUG_ASSERT() if the condition should only be checked when AP_DEBUG * is defined. */ #ifdef AP_DEBUG #define AP_DEBUG_ASSERT(exp) ap_assert(exp) #else #define AP_DEBUG_ASSERT(exp) ((void)0) #endif /** * @defgroup stopsignal Flags which indicate places where the server should stop for debugging. * @{ * A set of flags which indicate places where the server should raise(SIGSTOP). * This is useful for debugging, because you can then attach to that process * with gdb and continue. This is important in cases where one_process * debugging isn't possible. */ /** stop on a Detach */ #define SIGSTOP_DETACH 1 /** stop making a child process */ #define SIGSTOP_MAKE_CHILD 2 /** stop spawning a child process */ #define SIGSTOP_SPAWN_CHILD 4 /** stop spawning a child process with a piped log */ #define SIGSTOP_PIPED_LOG_SPAWN 8 /** stop spawning a CGI child process */ #define SIGSTOP_CGI_CHILD 16 /** Macro to get GDB started */ #ifdef DEBUG_SIGSTOP extern int raise_sigstop_flags; #define RAISE_SIGSTOP(x) do { \ if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\ } while (0) #else #define RAISE_SIGSTOP(x) #endif /** @} */ /** * Get HTML describing the address and (optionally) admin of the server. * @param prefix Text which is prepended to the return value * @param r The request_rec * @return HTML describing the server, allocated in @a r's pool. */ AP_DECLARE(const char *) ap_psignature(const char *prefix, request_rec *r); /* The C library has functions that allow const to be silently dropped ... these macros detect the drop in maintainer mode, but use the native methods for normal builds Note that on some platforms (e.g., AIX with gcc, Solaris with gcc), string.h needs to be included before the macros are defined or compilation will fail. */ #include <string.h> AP_DECLARE(char *) ap_strchr(char *s, int c); AP_DECLARE(const char *) ap_strchr_c(const char *s, int c); AP_DECLARE(char *) ap_strrchr(char *s, int c); AP_DECLARE(const char *) ap_strrchr_c(const char *s, int c); AP_DECLARE(char *) ap_strstr(char *s, const char *c); AP_DECLARE(const char *) ap_strstr_c(const char *s, const char *c); #ifdef AP_DEBUG #undef strchr # define strchr(s, c) ap_strchr(s,c) #undef strrchr # define strrchr(s, c) ap_strrchr(s,c) #undef strstr # define strstr(s, c) ap_strstr(s,c) #else /** use this instead of strchr */ # define ap_strchr(s, c) strchr(s, c) /** use this instead of strchr */ # define ap_strchr_c(s, c) strchr(s, c) /** use this instead of strrchr */ # define ap_strrchr(s, c) strrchr(s, c) /** use this instead of strrchr */ # define ap_strrchr_c(s, c) strrchr(s, c) /** use this instead of strrstr*/ # define ap_strstr(s, c) strstr(s, c) /** use this instead of strrstr*/ # define ap_strstr_c(s, c) strstr(s, c) #endif /** * Generate pseudo random bytes. * This is a convenience interface to apr_random. It is cheaper but less * secure than apr_generate_random_bytes(). * @param buf where to store the bytes * @param size number of bytes to generate * @note ap_random_insecure_bytes() is thread-safe, it uses a mutex on * threaded MPMs. */ AP_DECLARE(void) ap_random_insecure_bytes(void *buf, apr_size_t size); /** * Get a pseudo random number in a range. * @param min low end of range * @param max high end of range * @return a number in the range */ AP_DECLARE(apr_uint32_t) ap_random_pick(apr_uint32_t min, apr_uint32_t max); /** * Abort with a error message signifying out of memory */ AP_DECLARE(void) ap_abort_on_oom(void) __attribute__((noreturn)); /** * Wrapper for malloc() that calls ap_abort_on_oom() if out of memory * @param size size of the memory block * @return pointer to the allocated memory * @note ap_malloc may be implemented as a macro */ AP_DECLARE(void *) ap_malloc(size_t size) __attribute__((malloc)) AP_FN_ATTR_ALLOC_SIZE(1); /** * Wrapper for calloc() that calls ap_abort_on_oom() if out of memory * @param nelem number of elements to allocate memory for * @param size size of a single element * @return pointer to the allocated memory * @note ap_calloc may be implemented as a macro */ AP_DECLARE(void *) ap_calloc(size_t nelem, size_t size) __attribute__((malloc)) AP_FN_ATTR_ALLOC_SIZE2(1,2); /** * Wrapper for realloc() that calls ap_abort_on_oom() if out of memory * @param ptr pointer to the old memory block (or NULL) * @param size new size of the memory block * @return pointer to the reallocated memory * @note ap_realloc may be implemented as a macro */ AP_DECLARE(void *) ap_realloc(void *ptr, size_t size) AP_FN_ATTR_WARN_UNUSED_RESULT AP_FN_ATTR_ALLOC_SIZE(2); #if APR_HAS_THREADS #if APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) /** * APR 1.8+ implement those already. */ #if APR_HAS_THREAD_LOCAL #define AP_HAS_THREAD_LOCAL 1 #define AP_THREAD_LOCAL APR_THREAD_LOCAL #else #define AP_HAS_THREAD_LOCAL 0 #endif #define ap_thread_create apr_thread_create #define ap_thread_current apr_thread_current #define ap_thread_current_create apr_thread_current_create #define ap_thread_current_after_fork apr_thread_current_after_fork #else /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */ #ifndef AP_NO_THREAD_LOCAL /** * AP_THREAD_LOCAL keyword mapping the compiler's. */ #if defined(__cplusplus) && __cplusplus >= 201103L #define AP_THREAD_LOCAL thread_local #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112 && \ (!defined(__GNUC__) || \ __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) #define AP_THREAD_LOCAL _Thread_local #elif defined(__GNUC__) /* works for clang too */ #define AP_THREAD_LOCAL __thread #elif defined(WIN32) && defined(_MSC_VER) #define AP_THREAD_LOCAL __declspec(thread) #endif #endif /* ndef AP_NO_THREAD_LOCAL */ #ifndef AP_THREAD_LOCAL #define AP_HAS_THREAD_LOCAL 0 #define ap_thread_create apr_thread_create #else /* AP_THREAD_LOCAL */ #define AP_HAS_THREAD_LOCAL 1 AP_DECLARE(apr_status_t) ap_thread_create(apr_thread_t **thread, apr_threadattr_t *attr, apr_thread_start_t func, void *data, apr_pool_t *pool); #endif /* AP_THREAD_LOCAL */ AP_DECLARE(apr_status_t) ap_thread_current_create(apr_thread_t **current, apr_threadattr_t *attr, apr_pool_t *pool); AP_DECLARE(void) ap_thread_current_after_fork(void); AP_DECLARE(apr_thread_t *) ap_thread_current(void); #endif /* APR_VERSION_AT_LEAST(1,8,0) && !defined(AP_NO_THREAD_LOCAL) */ AP_DECLARE(apr_status_t) ap_thread_main_create(apr_thread_t **thread, apr_pool_t *pool); #else /* APR_HAS_THREADS */ #define AP_HAS_THREAD_LOCAL 0 #endif /* APR_HAS_THREADS */ /** * Get server load params * @param ld struct to populate: -1 in fields means error */ AP_DECLARE(void) ap_get_sload(ap_sload_t *ld); /** * Get server load averages (ala getloadavg) * @param ld struct to populate: -1 in fields means error */ AP_DECLARE(void) ap_get_loadavg(ap_loadavg_t *ld); /** * Convert binary data into a hex string * @param src pointer to the data * @param srclen length of the data * @param dest pointer to buffer of length (2 * srclen + 1). The resulting * string will be NUL-terminated. */ AP_DECLARE(void) ap_bin2hex(const void *src, apr_size_t srclen, char *dest); /** * Short function to execute a command and return the first line of * output minus \\r \\n. Useful for "obscuring" passwords via exec calls * @param p the pool to allocate from * @param cmd the command to execute * @param argv the arguments to pass to the cmd * @return ptr to characters or NULL on any error */ AP_DECLARE(char *) ap_get_exec_line(apr_pool_t *p, const char *cmd, const char * const *argv); #define AP_NORESTART APR_OS_START_USEERR + 1 /** * Get the first index of the string in the array or -1 if not found. Start * searching a start. * @param array The array the check * @param s The string to find * @param start Start index for search. If start is out of bounds (negative or equal to array length or greater), -1 will be returned. * @return index of string in array or -1 */ AP_DECLARE(int) ap_array_str_index(const apr_array_header_t *array, const char *s, int start); /** * Check if the string is member of the given array by strcmp. * @param array The array the check * @param s The string to find * @return !=0 iff string is member of array (via strcmp) */ AP_DECLARE(int) ap_array_str_contains(const apr_array_header_t *array, const char *s); /** * Perform a case-insensitive comparison of two strings @a str1 and @a str2, * treating upper and lower case values of the 26 standard C/POSIX alphabetic * characters as equivalent. Extended latin characters outside of this set * are treated as unique octets, irrespective of the current locale. * * Returns in integer greater than, equal to, or less than 0, * according to whether @a str1 is considered greater than, equal to, * or less than @a str2. * * @note Same code as apr_cstr_casecmp, which arrives in APR 1.6 */ AP_DECLARE(int) ap_cstr_casecmp(const char *s1, const char *s2); /** * Perform a case-insensitive comparison of two strings @a str1 and @a str2, * treating upper and lower case values of the 26 standard C/POSIX alphabetic * characters as equivalent. Extended latin characters outside of this set * are treated as unique octets, irrespective of the current locale. * * Returns in integer greater than, equal to, or less than 0, * according to whether @a str1 is considered greater than, equal to, * or less than @a str2. * * @note Same code as apr_cstr_casecmpn, which arrives in APR 1.6 */ AP_DECLARE(int) ap_cstr_casecmpn(const char *s1, const char *s2, apr_size_t n); /** * Default flags for ap_dir_*fnmatch(). */ #define AP_DIR_FLAG_NONE 0 /** * If set, wildcards that match no files or directories will be ignored, otherwise * an error is triggered. */ #define AP_DIR_FLAG_OPTIONAL 1 /** * If set, and the wildcard resolves to a directory, recursively find all files * below that directory, otherwise return the directory. */ #define AP_DIR_FLAG_RECURSIVE 2 /** * Structure to provide the state of a directory match. */ typedef struct ap_dir_match_t ap_dir_match_t; /** * Concrete structure to provide the state of a directory match. */ struct ap_dir_match_t { /** Pool to use for allocating the result */ apr_pool_t *p; /** Temporary pool used for directory traversal */ apr_pool_t *ptemp; /** Prefix for log messages */ const char *prefix; /** Callback for each file found that matches the wildcard. Return NULL on success, an error string on error. */ const char *(*cb)(ap_dir_match_t *w, const char *fname); /** Context for the callback */ void *ctx; /** Flags to indicate whether optional or recursive */ int flags; /** Recursion depth safety check */ unsigned int depth; }; /** * Search for files given a non wildcard filename with non native separators. * * If the provided filename points at a file, the callback within ap_dir_match_t is * triggered for that file, and this function returns the result of the callback. * * If the provided filename points at a directory, and recursive within ap_dir_match_t * is true, the callback will be triggered for every file found recursively beneath * that directory, otherwise the callback is triggered once for the directory itself. * This function returns the result of the callback. * * If the provided path points to neither a file nor a directory, and optional within * ap_dir_match_t is true, this function returns NULL. If optional within ap_dir_match_t * is false, this function will return an error string indicating that the path does not * exist. * * @param w Directory match structure containing callback and context. * @param fname The name of the file or directory, with non native separators. * @return NULL on success, or a string describing the error. */ AP_DECLARE(const char *)ap_dir_nofnmatch(ap_dir_match_t *w, const char *fname) __attribute__((nonnull(1,2))); /** * Search for files given a wildcard filename with non native separators. * * If the filename contains a wildcard, all files and directories that match the wildcard * will be returned. * * ap_dir_nofnmatch() is called for each directory and file found, and the callback * within ap_dir_match_t triggered as described above. * * Wildcards may appear in both directory and file components in the path, and * wildcards may appear more than once. * * @param w Directory match structure containing callback and context. * @param path Path prefix for search, with non native separators and no wildcards. * @param fname The name of the file or directory, with non native separators and * optional wildcards. * @return NULL on success, or a string describing the error. */ AP_DECLARE(const char *)ap_dir_fnmatch(ap_dir_match_t *w, const char *path, const char *fname) __attribute__((nonnull(1,3))); /** * Determine if the final Transfer-Encoding is "chunked". * * @param p The pool to allocate from * @param line the header field-value to scan * @return 1 if the last Transfer-Encoding is "chunked", else 0 */ AP_DECLARE(int) ap_is_chunked(apr_pool_t *p, const char *line); /** * apr_filepath_merge with an allow-list * Merge additional file path onto the previously processed rootpath * @param newpath the merged paths returned * @param rootpath the root file path (NULL uses the current working path) * @param addpath the path to add to the root path * @param flags the desired APR_FILEPATH_ rules to apply when merging * @param p the pool to allocate the new path string from * @remark if the flag APR_FILEPATH_TRUENAME is given, and the addpath * contains wildcard characters ('*', '?') on platforms that don't support * such characters within filenames, the paths will be merged, but the * result code will be APR_EPATHWILD, and all further segments will not * reflect the true filenames including the wildcard and following segments. */ AP_DECLARE(apr_status_t) ap_filepath_merge(char **newpath, const char *rootpath, const char *addpath, apr_int32_t flags, apr_pool_t *p); #ifdef WIN32 #define apr_filepath_merge ap_filepath_merge #endif /* Win32/NetWare/OS2 need to check for both forward and back slashes * in ap_normalize_path() and ap_escape_url(). */ #ifdef CASE_BLIND_FILESYSTEM #define AP_IS_SLASH(s) ((s == '/') || (s == '\\')) #define AP_SLASHES "/\\" #else #define AP_IS_SLASH(s) (s == '/') #define AP_SLASHES "/" #endif /** * Validates the path parameter is safe to pass to stat-like calls. * @param path The filesystem path to cehck * @param p a pool for temporary allocations * @return APR_SUCCESS if the stat-like call should be allowed */ AP_DECLARE(apr_status_t) ap_stat_check(const char *path, apr_pool_t *pool); #ifdef __cplusplus } #endif #endif /* !APACHE_HTTPD_H */ /** @} //APACHE Daemon */ /** @} //APACHE Core */ /** @} //APACHE super group */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_varbuf.h * @brief Apache resizable variable length buffer library * * @defgroup APACHE_CORE_VARBUF Variable length buffer library * @ingroup APACHE_CORE * * This set of functions provides resizable buffers. While the primary * usage is with NUL-terminated strings, most functions also work with * arbitrary binary data. * * @{ */ #ifndef AP_VARBUF_H #define AP_VARBUF_H #include "apr.h" #include "apr_allocator.h" #include "httpd.h" #ifdef __cplusplus extern "C" { #endif #define AP_VARBUF_UNKNOWN APR_SIZE_MAX struct ap_varbuf_info; /** A resizable buffer. */ struct ap_varbuf { /** The actual buffer; will point to a const '\\0' if avail == 0 and * to memory of the same lifetime as the pool otherwise. */ char *buf; /** Allocated size of the buffer (minus one for the final \\0); * must only be changed using ap_varbuf_grow(). */ apr_size_t avail; /** Length of string in buffer, or AP_VARBUF_UNKNOWN. This determines how * much memory is copied by ap_varbuf_grow() and where * ap_varbuf_strmemcat() will append to the buffer. */ apr_size_t strlen; /** The pool for memory allocations and for registering the cleanup; * the buffer memory will be released when this pool is cleared. */ apr_pool_t *pool; /** Opaque info for memory allocation. */ struct ap_varbuf_info *info; }; /** * Initialize a resizable buffer. It is safe to re-initialize a previously * used ap_varbuf. The old buffer will be released when the corresponding * pool is cleared. The buffer remains usable until the pool is cleared, * even if the ap_varbuf was located on the stack and has gone out of scope. * @param pool The pool to allocate small buffers from and to register * the cleanup with * @param vb Pointer to the ap_varbuf struct * @param init_size The initial size of the buffer (see ap_varbuf_grow() for * details) */ AP_DECLARE(void) ap_varbuf_init(apr_pool_t *pool, struct ap_varbuf *vb, apr_size_t init_size); /** * Grow a resizable buffer. If the vb->buf cannot be grown in place, it will * be reallocated and the first vb->strlen + 1 bytes of memory will be copied * to the new location. If vb->strlen == AP_VARBUF_UNKNOWN, the whole buffer * is copied. * @param vb Pointer to the ap_varbuf struct * @param new_size The minimum new size of the buffer * @note ap_varbuf_grow() will usually at least double vb->buf's size with * every invocation in order to reduce reallocations. * @note ap_varbuf_grow() will use pool memory for small and allocator * mem nodes for larger allocations. * @note ap_varbuf_grow() will call vb->pool's abort function if out of memory. */ AP_DECLARE(void) ap_varbuf_grow(struct ap_varbuf *vb, apr_size_t new_size); /** * Release memory from a ap_varbuf immediately, if possible. * This allows to free large buffers before the corresponding pool is * cleared. Only larger allocations using mem nodes will be freed. * @param vb Pointer to the ap_varbuf struct * @note After ap_varbuf_free(), vb must not be used unless ap_varbuf_init() * is called again. */ AP_DECLARE(void) ap_varbuf_free(struct ap_varbuf *vb); /** * Concatenate a string to an ap_varbuf. vb->strlen determines where * the string is appended in the buffer. If vb->strlen == AP_VARBUF_UNKNOWN, * the string will be appended at the first NUL byte in the buffer. * If len == 0, ap_varbuf_strmemcat() does nothing. * @param vb Pointer to the ap_varbuf struct * @param str The string to append; must be at least len bytes long * @param len The number of characters of *str to concatenate to the buf * @note vb->strlen will be set to the length of the new string * @note if len != 0, vb->buf will always be NUL-terminated */ AP_DECLARE(void) ap_varbuf_strmemcat(struct ap_varbuf *vb, const char *str, int len); /** * Duplicate an ap_varbuf's content into pool memory. * @param p The pool to allocate from * @param vb The ap_varbuf to copy from * @param prepend An optional buffer to prepend (may be NULL) * @param prepend_len Length of prepend * @param append An optional buffer to append (may be NULL) * @param append_len Length of append * @param new_len Where to store the length of the resulting string * (may be NULL) * @return The new string * @note ap_varbuf_pdup() uses vb->strlen to determine how much memory to * copy. It works even if 0-bytes are embedded in vb->buf, prepend, or * append. * @note If vb->strlen equals AP_VARBUF_UNKNOWN, it will be set to * strlen(vb->buf). */ AP_DECLARE(char *) ap_varbuf_pdup(apr_pool_t *p, struct ap_varbuf *vb, const char *prepend, apr_size_t prepend_len, const char *append, apr_size_t append_len, apr_size_t *new_len); /** * Concatenate a string to an ap_varbuf. * @param vb Pointer to the ap_varbuf struct * @param str The string to append * @note vb->strlen will be set to the length of the new string */ #define ap_varbuf_strcat(vb, str) ap_varbuf_strmemcat(vb, str, strlen(str)) /** * Perform string substitutions based on regexp match, using an ap_varbuf. * This function behaves like ap_pregsub(), but appends to an ap_varbuf * instead of allocating the result from a pool. * @param vb The ap_varbuf to which the string will be appended * @param input An arbitrary string containing $1 through $9. These are * replaced with the corresponding matched sub-expressions * @param source The string that was originally matched to the regex * @param nmatch The nmatch returned from ap_pregex * @param pmatch The pmatch array returned from ap_pregex * @param maxlen The maximum string length to append to vb, 0 for unlimited * @return APR_SUCCESS if successful * @note Just like ap_pregsub(), this function does not copy the part of * *source before the matching part (i.e. the first pmatch[0].rm_so * characters). * @note If vb->strlen equals AP_VARBUF_UNKNOWN, it will be set to * strlen(vb->buf) first. */ AP_DECLARE(apr_status_t) ap_varbuf_regsub(struct ap_varbuf *vb, const char *input, const char *source, apr_size_t nmatch, ap_regmatch_t pmatch[], apr_size_t maxlen); /** * Read a line from an ap_configfile_t and append it to an ap_varbuf. * @param vb Pointer to the ap_varbuf struct * @param cfp Pointer to the ap_configfile_t * @param max_len Maximum line length, including leading/trailing whitespace * @return See ap_cfg_getline() * @note vb->strlen will be set to the length of the line * @note If vb->strlen equals AP_VARBUF_UNKNOWN, it will be set to * strlen(vb->buf) first. */ AP_DECLARE(apr_status_t) ap_varbuf_cfg_getline(struct ap_varbuf *vb, ap_configfile_t *cfp, apr_size_t max_len); #ifdef __cplusplus } #endif #endif /* !AP_VARBUF_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file scoreboard.h * @brief Apache scoreboard library */ #ifndef APACHE_SCOREBOARD_H #define APACHE_SCOREBOARD_H #ifdef __cplusplus extern "C" { #endif #if APR_HAVE_SYS_TIME_H #include <sys/time.h> #include <sys/times.h> #endif #include "ap_config.h" #include "http_config.h" #include "apr_thread_proc.h" #include "apr_portable.h" #include "apr_shm.h" #include "apr_optional.h" /* Scoreboard file, if there is one */ #ifndef DEFAULT_SCOREBOARD #define DEFAULT_SCOREBOARD "logs/apache_runtime_status" #endif /* Scoreboard info on a process is, for now, kept very brief --- * just status value and pid (the latter so that the caretaker process * can properly update the scoreboard when a process dies). We may want * to eventually add a separate set of long_score structures which would * give, for each process, the number of requests serviced, and info on * the current, or most recent, request. * * Status values: */ #define SERVER_DEAD 0 #define SERVER_STARTING 1 /* Server Starting up */ #define SERVER_READY 2 /* Waiting for connection (or accept() lock) */ #define SERVER_BUSY_READ 3 /* Reading a client request */ #define SERVER_BUSY_WRITE 4 /* Processing a client request */ #define SERVER_BUSY_KEEPALIVE 5 /* Waiting for more requests via keepalive */ #define SERVER_BUSY_LOG 6 /* Logging the request */ #define SERVER_BUSY_DNS 7 /* Looking up a hostname */ #define SERVER_CLOSING 8 /* Closing the connection */ #define SERVER_GRACEFUL 9 /* server is gracefully finishing request */ #define SERVER_IDLE_KILL 10 /* Server is cleaning up idle children. */ #define SERVER_NUM_STATUS 11 /* number of status settings */ /* Type used for generation indices. Startup and every restart cause a * new generation of children to be spawned. Children within the same * generation share the same configuration information -- pointers to stuff * created at config time in the parent are valid across children. However, * this can't work effectively with non-forked architectures. So while the * arrays in the scoreboard never change between the parent and forked * children, so they do not require shm storage, the contents of the shm * may contain no pointers. */ typedef int ap_generation_t; /* Is the scoreboard shared between processes or not? * Set by the MPM when the scoreboard is created. */ typedef enum { SB_NOT_SHARED = 1, SB_SHARED = 2 } ap_scoreboard_e; /* stuff which is worker specific */ typedef struct worker_score worker_score; struct worker_score { #if APR_HAS_THREADS apr_os_thread_t tid; #endif int thread_num; /* With some MPMs (e.g., worker), a worker_score can represent * a thread in a terminating process which is no longer * represented by the corresponding process_score. These MPMs * should set pid and generation fields in the worker_score. */ pid_t pid; ap_generation_t generation; unsigned char status; unsigned short conn_count; apr_off_t conn_bytes; unsigned long access_count; apr_off_t bytes_served; unsigned long my_access_count; apr_off_t my_bytes_served; apr_time_t start_time; apr_time_t stop_time; apr_time_t last_used; #ifdef HAVE_TIMES struct tms times; #endif char client[32]; /* DEPRECATED: Keep 'em small... */ char request[64]; /* We just want an idea... */ char vhost[32]; /* What virtual host is being accessed? */ char protocol[16]; /* What protocol is used on the connection? */ apr_time_t duration; char client64[64]; }; typedef struct { int server_limit; int thread_limit; ap_generation_t running_generation; /* the generation of children which * should still be serving requests. */ apr_time_t restart_time; #ifdef HAVE_TIMES struct tms times; #endif } global_score; /* stuff which the parent generally writes and the children rarely read */ typedef struct process_score process_score; struct process_score { pid_t pid; ap_generation_t generation; /* generation of this child */ char quiescing; /* the process whose pid is stored above is * going down gracefully */ char not_accepting; /* the process is busy and is not accepting more * connections (for async MPMs) */ apr_uint32_t connections; /* total connections (for async MPMs) */ apr_uint32_t write_completion; /* async connections in write completion */ apr_uint32_t lingering_close; /* async connections in lingering close */ apr_uint32_t keep_alive; /* async connections in keep alive */ apr_uint32_t suspended; /* connections suspended by some module */ int bucket; /* Listener bucket used by this child; this field is DEPRECATED * and no longer updated by the MPMs (i.e. always zero). */ apr_uint32_t wait_io; /* async connections waiting an IO in the MPM */ }; /* Scoreboard is now in 'local' memory, since it isn't updated once created, * even in forked architectures. Child created-processes (non-fork) will * set up these indices into the (possibly relocated) shmem records. */ typedef struct { global_score *global; process_score *parent; worker_score **servers; } scoreboard; typedef struct ap_sb_handle_t ap_sb_handle_t; /* * Creation and deletion (internal) */ int ap_create_scoreboard(apr_pool_t *p, ap_scoreboard_e t); apr_status_t ap_cleanup_scoreboard(void *d); /* * APIs for MPMs and other modules */ AP_DECLARE(int) ap_exists_scoreboard_image(void); AP_DECLARE(void) ap_increment_counts(ap_sb_handle_t *sbh, request_rec *r); AP_DECLARE(void) ap_set_conn_count(ap_sb_handle_t *sb, request_rec *r, unsigned short conn_count); AP_DECLARE(apr_status_t) ap_reopen_scoreboard(apr_pool_t *p, apr_shm_t **shm, int detached); AP_DECLARE(void) ap_init_scoreboard(void *shared_score); AP_DECLARE(int) ap_calc_scoreboard_size(void); AP_DECLARE(void) ap_create_sb_handle(ap_sb_handle_t **new_sbh, apr_pool_t *p, int child_num, int thread_num); AP_DECLARE(void) ap_update_sb_handle(ap_sb_handle_t *sbh, int child_num, int thread_num); AP_DECLARE(int) ap_find_child_by_pid(apr_proc_t *pid); AP_DECLARE(int) ap_update_child_status(ap_sb_handle_t *sbh, int status, request_rec *r); AP_DECLARE(int) ap_update_child_status_from_indexes(int child_num, int thread_num, int status, request_rec *r); AP_DECLARE(int) ap_update_child_status_from_conn(ap_sb_handle_t *sbh, int status, conn_rec *c); AP_DECLARE(int) ap_update_child_status_from_server(ap_sb_handle_t *sbh, int status, conn_rec *c, server_rec *s); AP_DECLARE(int) ap_update_child_status_descr(ap_sb_handle_t *sbh, int status, const char *descr); AP_DECLARE(void) ap_time_process_request(ap_sb_handle_t *sbh, int status); AP_DECLARE(void) ap_set_time_process_request(ap_sb_handle_t* const sbh, const apr_time_t timebeg,const apr_time_t timeend); AP_DECLARE(int) ap_update_global_status(void); AP_DECLARE(worker_score *) ap_get_scoreboard_worker(ap_sb_handle_t *sbh); /** Return a pointer to the worker_score for a given child, thread pair. * @param child_num The child number. * @param thread_num The thread number. * @return A pointer to the worker_score structure. * @deprecated This function is deprecated, use ap_copy_scoreboard_worker instead. */ AP_DECLARE(worker_score *) ap_get_scoreboard_worker_from_indexes(int child_num, int thread_num); /** Copy the contents of a worker scoreboard entry. The contents of * the worker_score structure are copied verbatim into the dest * structure. * @param dest Output parameter. * @param child_num The child number. * @param thread_num The thread number. */ AP_DECLARE(void) ap_copy_scoreboard_worker(worker_score *dest, int child_num, int thread_num); AP_DECLARE(process_score *) ap_get_scoreboard_process(int x); AP_DECLARE(global_score *) ap_get_scoreboard_global(void); AP_DECLARE_DATA extern scoreboard *ap_scoreboard_image; AP_DECLARE_DATA extern const char *ap_scoreboard_fname; AP_DECLARE_DATA extern int ap_extended_status; AP_DECLARE_DATA extern int ap_mod_status_reqtail; /* * Command handlers [internal] */ const char *ap_set_scoreboard(cmd_parms *cmd, void *dummy, const char *arg); const char *ap_set_extended_status(cmd_parms *cmd, void *dummy, int arg); const char *ap_set_reqtail(cmd_parms *cmd, void *dummy, int arg); /* Hooks */ /** * Hook for post scoreboard creation, pre mpm. * @param p Apache pool to allocate from. * @param sb_type * @ingroup hooks * @return OK or DECLINE on success; anything else is a error */ AP_DECLARE_HOOK(int, pre_mpm, (apr_pool_t *p, ap_scoreboard_e sb_type)) /* for time_process_request() in http_main.c */ #define START_PREQUEST 1 #define STOP_PREQUEST 2 #ifdef __cplusplus } #endif #endif /* !APACHE_SCOREBOARD_H */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file ap_provider.h * @brief Apache Provider API * * @defgroup APACHE_CORE_PROVIDER Provider API * @ingroup APACHE_CORE * @{ */ #ifndef AP_PROVIDER_H #define AP_PROVIDER_H #include "ap_config.h" #ifdef __cplusplus extern "C" { #endif typedef struct { const char *provider_name; } ap_list_provider_names_t; typedef struct { const char *provider_group; const char *provider_version; } ap_list_provider_groups_t; /** * This function is used to register a provider with the global * provider pool. * @param pool The pool to create any storage from * @param provider_group The group to store the provider in * @param provider_name The name for this provider * @param provider_version The version for this provider * @param provider Opaque structure for this provider * @return APR_SUCCESS if all went well */ AP_DECLARE(apr_status_t) ap_register_provider(apr_pool_t *pool, const char *provider_group, const char *provider_name, const char *provider_version, const void *provider); /** * This function is used to retrieve a provider from the global * provider pool. * @param provider_group The group to look for this provider in * @param provider_name The name for the provider * @param provider_version The version for the provider * @return provider pointer to provider if found, NULL otherwise */ AP_DECLARE(void *) ap_lookup_provider(const char *provider_group, const char *provider_name, const char *provider_version); /** * This function is used to retrieve a list (array) of provider * names from the specified group with the specified version. * @param pool The pool to create any storage from * @param provider_group The group to look for this provider in * @param provider_version The version for the provider * @return pointer to array of ap_list_provider_names_t of provider names (could be empty) */ AP_DECLARE(apr_array_header_t *) ap_list_provider_names(apr_pool_t *pool, const char *provider_group, const char *provider_version); /** * This function is used to retrieve a list (array) of provider groups and versions * @param pool The pool to create any storage from * @return pointer to array of ap_list_provider_groups_t of provider groups * and versions (could be empty) */ AP_DECLARE(apr_array_header_t *) ap_list_provider_groups(apr_pool_t *pool); #ifdef __cplusplus } #endif #endif /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file http_request.h * @brief Apache Request library * * @defgroup APACHE_CORE_REQ Apache Request Processing * @ingroup APACHE_CORE * @{ */ /* * request.c is the code which handles the main line of request * processing, once a request has been read in (finding the right per- * directory configuration, building it if necessary, and calling all * the module dispatch functions in the right order). * * The pieces here which are public to the modules, allow them to learn * how the server would handle some other file or URI, or perhaps even * direct the server to serve that other file instead of the one the * client requested directly. * * There are two ways to do that. The first is the sub_request mechanism, * which handles looking up files and URIs as adjuncts to some other * request (e.g., directory entries for multiviews and directory listings); * the lookup functions stop short of actually running the request, but * (e.g., for includes), a module may call for the request to be run * by calling run_sub_req. The space allocated to create sub_reqs can be * reclaimed by calling destroy_sub_req --- be sure to copy anything you care * about which was allocated in its apr_pool_t elsewhere before doing this. */ #ifndef APACHE_HTTP_REQUEST_H #define APACHE_HTTP_REQUEST_H #include "apr_optional.h" #include "util_filter.h" #ifdef __cplusplus extern "C" { #endif #define AP_SUBREQ_NO_ARGS 0 #define AP_SUBREQ_MERGE_ARGS 1 /** * An internal handler used by the ap_process_request, all subrequest mechanisms * and the redirect mechanism. * @param r The request, subrequest or internal redirect to pre-process * @return The return code for the request */ AP_DECLARE(int) ap_process_request_internal(request_rec *r); /** * Create a subrequest from the given URI. This subrequest can be * inspected to find information about the requested URI * @param new_uri The URI to lookup * @param r The current request * @param next_filter The first filter the sub_request should use. If this is * NULL, it defaults to the first filter for the main request * @return The new request record */ AP_DECLARE(request_rec *) ap_sub_req_lookup_uri(const char *new_uri, const request_rec *r, ap_filter_t *next_filter); /** * Create a subrequest for the given file. This subrequest can be * inspected to find information about the requested file * @param new_file The file to lookup * @param r The current request * @param next_filter The first filter the sub_request should use. If this is * NULL, it defaults to the first filter for the main request * @return The new request record */ AP_DECLARE(request_rec *) ap_sub_req_lookup_file(const char *new_file, const request_rec *r, ap_filter_t *next_filter); /** * Create a subrequest for the given apr_dir_read result. This subrequest * can be inspected to find information about the requested file * @param finfo The apr_dir_read result to lookup * @param r The current request * @param subtype What type of subrequest to perform, one of; * <PRE> * AP_SUBREQ_NO_ARGS ignore r->args and r->path_info * AP_SUBREQ_MERGE_ARGS merge r->args and r->path_info * </PRE> * @param next_filter The first filter the sub_request should use. If this is * NULL, it defaults to the first filter for the main request * @return The new request record * @note The apr_dir_read flags value APR_FINFO_MIN|APR_FINFO_NAME flag is the * minimum recommended query if the results will be passed to apr_dir_read. * The file info passed must include the name, and must have the same relative * directory as the current request. */ AP_DECLARE(request_rec *) ap_sub_req_lookup_dirent(const apr_finfo_t *finfo, const request_rec *r, int subtype, ap_filter_t *next_filter); /** * Create a subrequest for the given URI using a specific method. This * subrequest can be inspected to find information about the requested URI * @param method The method to use in the new subrequest * @param new_uri The URI to lookup * @param r The current request * @param next_filter The first filter the sub_request should use. If this is * NULL, it defaults to the first filter for the main request * @return The new request record */ AP_DECLARE(request_rec *) ap_sub_req_method_uri(const char *method, const char *new_uri, const request_rec *r, ap_filter_t *next_filter); /** * An output filter to strip EOS buckets from sub-requests. This always * has to be inserted at the end of a sub-requests filter stack. * @param f The current filter * @param bb The brigade to filter * @return status code */ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_sub_req_output_filter(ap_filter_t *f, apr_bucket_brigade *bb); /** * Run the handler for the subrequest * @param r The subrequest to run * @return The return code for the subrequest */ AP_DECLARE(int) ap_run_sub_req(request_rec *r); /** * Free the memory associated with a subrequest * @param r The subrequest to finish */ AP_DECLARE(void) ap_destroy_sub_req(request_rec *r); /* * Then there's the case that you want some other request to be served * as the top-level request INSTEAD of what the client requested directly. * If so, call this from a handler, and then immediately return OK. */ /** * Redirect the current request to some other uri * @param new_uri The URI to replace the current request with * @param r The current request */ AP_DECLARE(void) ap_internal_redirect(const char *new_uri, request_rec *r); /** * This function is designed for things like actions or CGI scripts, when * using AddHandler, and you want to preserve the content type across * an internal redirect. * @param new_uri The URI to replace the current request with. * @param r The current request */ AP_DECLARE(void) ap_internal_redirect_handler(const char *new_uri, request_rec *r); /** * Redirect the current request to a sub_req, merging the pools * @param sub_req A subrequest created from this request * @param r The current request * @note the sub_req's pool will be merged into r's pool, be very careful * not to destroy this subrequest, it will be destroyed with the main request! */ AP_DECLARE(void) ap_internal_fast_redirect(request_rec *sub_req, request_rec *r); /** * Can be used within any handler to determine if any authentication * is required for the current request * @param r The current request * @return 1 if authentication is required, 0 otherwise * @bug Behavior changed in 2.4.x refactoring, API no longer usable * @deprecated @see ap_some_authn_required() */ AP_DECLARE(int) ap_some_auth_required(request_rec *r); /** * @defgroup APACHE_CORE_REQ_AUTH Access Control for Sub-Requests and * Internal Redirects * @ingroup APACHE_CORE_REQ * @{ */ #define AP_AUTH_INTERNAL_PER_URI 0 /**< Run access control hooks on all internal requests with URIs distinct from that of initial request */ #define AP_AUTH_INTERNAL_PER_CONF 1 /**< Run access control hooks only on internal requests with configurations distinct from that of initial request */ #define AP_AUTH_INTERNAL_MASK 0x000F /**< mask to extract internal request processing mode */ /** * Clear flag which determines when access control hooks will be run for * internal requests. */ AP_DECLARE(void) ap_clear_auth_internal(void); /** * Determine whether access control hooks will be run for all internal * requests with URIs distinct from that of the initial request, or only * those for which different configurations apply than those which applied * to the initial request. To accommodate legacy external modules which * may expect access control hooks to be run for all internal requests * with distinct URIs, this is the default behaviour unless all access * control hooks and authentication and authorization providers are * registered with AP_AUTH_INTERNAL_PER_CONF. * @param ptemp Pool used for temporary allocations */ AP_DECLARE(void) ap_setup_auth_internal(apr_pool_t *ptemp); /** * Register an authentication or authorization provider with the global * provider pool. * @param pool The pool to create any storage from * @param provider_group The group to store the provider in * @param provider_name The name for this provider * @param provider_version The version for this provider * @param provider Opaque structure for this provider * @param type Internal request processing mode, either * AP_AUTH_INTERNAL_PER_URI or AP_AUTH_INTERNAL_PER_CONF * @return APR_SUCCESS if all went well */ AP_DECLARE(apr_status_t) ap_register_auth_provider(apr_pool_t *pool, const char *provider_group, const char *provider_name, const char *provider_version, const void *provider, int type); /** @} */ /* Optional functions coming from mod_authn_core and mod_authz_core * that list all registered authn/z providers. */ APR_DECLARE_OPTIONAL_FN(apr_array_header_t *, authn_ap_list_provider_names, (apr_pool_t *ptemp)); APR_DECLARE_OPTIONAL_FN(apr_array_header_t *, authz_ap_list_provider_names, (apr_pool_t *ptemp)); /** * Determine if the current request is the main request or a subrequest * @param r The current request * @return 1 if this is the main request, 0 otherwise */ AP_DECLARE(int) ap_is_initial_req(request_rec *r); /** * Function to set the r->mtime field to the specified value if it's later * than what's already there. * @param r The current request * @param dependency_mtime Time to set the mtime to */ AP_DECLARE(void) ap_update_mtime(request_rec *r, apr_time_t dependency_mtime); /** * Add one or more methods to the list permitted to access the resource. * Usually executed by the content handler before the response header is * sent, but sometimes invoked at an earlier phase if a module knows it * can set the list authoritatively. Note that the methods are ADDED * to any already permitted unless the reset flag is non-zero. The * list is used to generate the Allow response header field when it * is needed. * @param r The pointer to the request identifying the resource. * @param reset Boolean flag indicating whether this list should * completely replace any current settings. * @param ... A NULL-terminated list of strings, each identifying a * method name to add. * @return None. */ AP_DECLARE(void) ap_allow_methods(request_rec *r, int reset, ...) AP_FN_ATTR_SENTINEL; /** * Add one or more methods to the list permitted to access the resource. * Usually executed by the content handler before the response header is * sent, but sometimes invoked at an earlier phase if a module knows it * can set the list authoritatively. Note that the methods are ADDED * to any already permitted unless the reset flag is non-zero. The * list is used to generate the Allow response header field when it * is needed. * @param r The pointer to the request identifying the resource. * @param reset Boolean flag indicating whether this list should * completely replace any current settings. * @param ... A list of method identifiers, from the "M_" series * defined in httpd.h, terminated with a value of -1 * (e.g., "M_GET, M_POST, M_OPTIONS, -1") * @return None. */ AP_DECLARE(void) ap_allow_standard_methods(request_rec *r, int reset, ...); #define MERGE_ALLOW 0 #define REPLACE_ALLOW 1 /** * Process a top-level request from a client, and synchronously write * the response to the client * @param r The current request */ AP_DECLARE(void) ap_process_request(request_rec *r); /* For post-processing after a handler has finished with a request. * (Commonly used after it was suspended) */ AP_DECLARE(void) ap_process_request_after_handler(request_rec *r); /** * Process a top-level request from a client, allowing some or all of * the response to remain buffered in the core output filter for later, * asynchronous write completion * @param r The current request */ void ap_process_async_request(request_rec *r); /** * Kill the current request * @param type Why the request is dying * @param r The current request */ AP_DECLARE(void) ap_die(int type, request_rec *r); /** * Check whether a connection is still established and has data available, * optionally consuming blank lines ([CR]LF). * @param c The current connection * @param bb The brigade to filter * @param max_blank_lines Max number of blank lines to consume, or zero * to consider them as data (single read). * @return APR_SUCCESS: connection established with data available, * APR_EAGAIN: connection established and empty, * APR_NOTFOUND: too much blank lines, * APR_E*: connection/general error. */ AP_DECLARE(apr_status_t) ap_check_pipeline(conn_rec *c, apr_bucket_brigade *bb, unsigned int max_blank_lines); /* Hooks */ /** * Gives modules a chance to create their request_config entry when the * request is created. * @param r The current request * @ingroup hooks */ AP_DECLARE_HOOK(int,create_request,(request_rec *r)) /** * This hook allow modules an opportunity to translate the URI into an * actual filename, before URL decoding happens. * @param r The current request * @return DECLINED to let other modules handle the pre-translation, * OK if it was handled and no other module should process it, * DONE if no further transformation should happen on the URI, * HTTP_... in case of error. * @ingroup hooks */ AP_DECLARE_HOOK(int,pre_translate_name,(request_rec *r)) /** * This hook allow modules an opportunity to translate the URI into an * actual filename. If no modules do anything special, the server's default * rules will be followed. * @param r The current request * @return OK, DECLINED, or HTTP_... * @ingroup hooks */ AP_DECLARE_HOOK(int,translate_name,(request_rec *r)) /** * This hook allow modules to set the per_dir_config based on their own * context (such as "<Proxy>" sections) and responds to contextless requests * such as TRACE that need no security or filesystem mapping. * based on the filesystem. * @param r The current request * @return DONE (or HTTP_) if this contextless request was just fulfilled * (such as TRACE), OK if this is not a file, and DECLINED if this is a file. * The core map_to_storage (HOOK_RUN_REALLY_LAST) will directory_walk * and file_walk the r->filename. * * @ingroup hooks */ AP_DECLARE_HOOK(int,map_to_storage,(request_rec *r)) /** * This hook is used to analyze the request headers, authenticate the user, * and set the user information in the request record (r->user and * r->ap_auth_type). This hook is only run when Apache determines that * authentication/authorization is required for this resource (as determined * by the 'Require' directive). It runs after the access_checker hook, and * before the auth_checker hook. This hook should be registered with * ap_hook_check_authn(). * * @param r The current request * @return OK, DECLINED, or HTTP_... * @ingroup hooks * @see ap_hook_check_authn */ AP_DECLARE_HOOK(int,check_user_id,(request_rec *r)) /** * Allows modules to perform module-specific fixing of header fields. This * is invoked just before any content-handler * @param r The current request * @return OK, DECLINED, or HTTP_... * @ingroup hooks */ AP_DECLARE_HOOK(int,fixups,(request_rec *r)) /** * This routine is called to determine and/or set the various document type * information bits, like Content-type (via r->content_type), language, et * cetera. * @param r the current request * @return OK, DECLINED, or HTTP_... * @ingroup hooks */ AP_DECLARE_HOOK(int,type_checker,(request_rec *r)) /** * This hook is used to apply additional access control to this resource. * It runs *before* a user is authenticated, so this hook is really to * apply additional restrictions independent of a user. It also runs * independent of 'Require' directive usage. This hook should be registered * with ap_hook_check_access(). * * @param r the current request * @return OK, DECLINED, or HTTP_... * @ingroup hooks * @see ap_hook_check_access */ AP_DECLARE_HOOK(int,access_checker,(request_rec *r)) /** * This hook is used to apply additional access control and/or bypass * authentication for this resource. It runs *before* a user is authenticated, * but after the auth_checker hook. * This hook should be registered with ap_hook_check_access_ex(). * * @param r the current request * @return OK (allow access), DECLINED (let later modules decide), * or HTTP_... (deny access) * @ingroup hooks * @see ap_hook_check_access_ex */ AP_DECLARE_HOOK(int,access_checker_ex,(request_rec *r)) /** * This hook is used to check to see if the resource being requested * is available for the authenticated user (r->user and r->ap_auth_type). * It runs after the access_checker and check_user_id hooks. Note that * it will *only* be called if Apache determines that access control has * been applied to this resource (through a 'Require' directive). This * hook should be registered with ap_hook_check_authz(). * * @param r the current request * @return OK, DECLINED, or HTTP_... * @ingroup hooks * @see ap_hook_check_authz */ AP_DECLARE_HOOK(int,auth_checker,(request_rec *r)) /** * Register a hook function that will apply additional access control to * the current request. * @param pf An access_checker hook function * @param aszPre A NULL-terminated array of strings that name modules whose * hooks should precede this one * @param aszSucc A NULL-terminated array of strings that name modules whose * hooks should succeed this one * @param nOrder An integer determining order before honouring aszPre and * aszSucc (for example, HOOK_MIDDLE) * @param type Internal request processing mode, either * AP_AUTH_INTERNAL_PER_URI or AP_AUTH_INTERNAL_PER_CONF */ AP_DECLARE(void) ap_hook_check_access(ap_HOOK_access_checker_t *pf, const char * const *aszPre, const char * const *aszSucc, int nOrder, int type); /** * Register a hook function that will apply additional access control * and/or bypass authentication for the current request. * @param pf An access_checker_ex hook function * @param aszPre A NULL-terminated array of strings that name modules whose * hooks should precede this one * @param aszSucc A NULL-terminated array of strings that name modules whose * hooks should succeed this one * @param nOrder An integer determining order before honouring aszPre and * aszSucc (for example, HOOK_MIDDLE) * @param type Internal request processing mode, either * AP_AUTH_INTERNAL_PER_URI or AP_AUTH_INTERNAL_PER_CONF */ AP_DECLARE(void) ap_hook_check_access_ex(ap_HOOK_access_checker_ex_t *pf, const char * const *aszPre, const char * const *aszSucc, int nOrder, int type); /** * Register a hook function that will analyze the request headers, * authenticate the user, and set the user information in the request record. * @param pf A check_user_id hook function * @param aszPre A NULL-terminated array of strings that name modules whose * hooks should precede this one * @param aszSucc A NULL-terminated array of strings that name modules whose * hooks should succeed this one * @param nOrder An integer determining order before honouring aszPre and * aszSucc (for example, HOOK_MIDDLE) * @param type Internal request processing mode, either * AP_AUTH_INTERNAL_PER_URI or AP_AUTH_INTERNAL_PER_CONF */ AP_DECLARE(void) ap_hook_check_authn(ap_HOOK_check_user_id_t *pf, const char * const *aszPre, const char * const *aszSucc, int nOrder, int type); /** * Register a hook function that determine if the resource being requested * is available for the currently authenticated user. * @param pf An auth_checker hook function * @param aszPre A NULL-terminated array of strings that name modules whose * hooks should precede this one * @param aszSucc A NULL-terminated array of strings that name modules whose * hooks should succeed this one * @param nOrder An integer determining order before honouring aszPre and * aszSucc (for example, HOOK_MIDDLE) * @param type Internal request processing mode, either * AP_AUTH_INTERNAL_PER_URI or AP_AUTH_INTERNAL_PER_CONF */ AP_DECLARE(void) ap_hook_check_authz(ap_HOOK_auth_checker_t *pf, const char * const *aszPre, const char * const *aszSucc, int nOrder, int type); /** * This hook allows modules to insert filters for the current request * @param r the current request * @ingroup hooks */ AP_DECLARE_HOOK(void,insert_filter,(request_rec *r)) /** * This hook allows modules to affect the request immediately after the * per-directory configuration for the request has been generated. * @param r The current request * @return OK (allow access), DECLINED (let later modules decide), * or HTTP_... (deny access) * @ingroup hooks */ AP_DECLARE_HOOK(int,post_perdir_config,(request_rec *r)) /** * This hook allows a module to force authn to be required when * processing a request. * This hook should be registered with ap_hook_force_authn(). * @param r The current request * @return OK (force authn), DECLINED (let later modules decide) * @ingroup hooks */ AP_DECLARE_HOOK(int,force_authn,(request_rec *r)) /** * This hook allows modules to handle/emulate the apr_stat() calls * needed for directory walk. * @param finfo where to put the stat data * @param r The current request * @param wanted APR_FINFO_* flags to pass to apr_stat() * @return apr_status_t or AP_DECLINED (let later modules decide) * @ingroup hooks */ AP_DECLARE_HOOK(apr_status_t,dirwalk_stat,(apr_finfo_t *finfo, request_rec *r, apr_int32_t wanted)) AP_DECLARE(int) ap_location_walk(request_rec *r); AP_DECLARE(int) ap_directory_walk(request_rec *r); AP_DECLARE(int) ap_file_walk(request_rec *r); AP_DECLARE(int) ap_if_walk(request_rec *r); /** End Of REQUEST (EOR) bucket */ AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_eor; /** * Determine if a bucket is an End Of REQUEST (EOR) bucket * @param e The bucket to inspect * @return true or false */ #define AP_BUCKET_IS_EOR(e) ((e)->type == &ap_bucket_type_eor) /** * Make the bucket passed in an End Of REQUEST (EOR) bucket * @param b The bucket to make into an EOR bucket * @param r The request to destroy when this bucket is destroyed * @return The new bucket, or NULL if allocation failed */ AP_DECLARE(apr_bucket *) ap_bucket_eor_make(apr_bucket *b, request_rec *r); /** * Create a bucket referring to an End Of REQUEST (EOR). This bucket * holds a pointer to the request_rec, so that the request can be * destroyed right after all of the output has been sent to the client. * * @param list The freelist from which this bucket should be allocated * @param r The request to destroy when this bucket is destroyed * @return The new bucket, or NULL if allocation failed */ AP_DECLARE(apr_bucket *) ap_bucket_eor_create(apr_bucket_alloc_t *list, request_rec *r); /** * Can be used within any handler to determine if any authentication * is required for the current request. Note that if used with an * access_checker hook, an access_checker_ex hook or an authz provider; the * caller should take steps to avoid a loop since this function is * implemented by calling these hooks. * @param r The current request * @return TRUE if authentication is required, FALSE otherwise */ AP_DECLARE(int) ap_some_authn_required(request_rec *r); #ifdef __cplusplus } #endif #endif /* !APACHE_HTTP_REQUEST_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file heartbeat.h * @brief commun structures for mod_heartmonitor.c and mod_lbmethod_heartbeat.c * * @defgroup HEARTBEAT heartbeat * @ingroup APACHE_MODS * @{ */ #ifndef HEARTBEAT_H #define HEARTBEAT_H #include "apr.h" #include "apr_time.h" #ifdef __cplusplus extern "C" { #endif /* * Worse Case: IPv4-Mapped IPv6 Address * 0000:0000:0000:0000:0000:FFFF:255.255.255.255 */ #define MAXIPSIZE 46 typedef struct hm_slot_server_t { char ip[MAXIPSIZE]; int busy; int ready; apr_time_t seen; int id; } hm_slot_server_t; /* default name of heartbeat data file, created in the configured * runtime directory when mod_slotmem_shm is not available */ #define DEFAULT_HEARTBEAT_STORAGE "hb.dat" #ifdef __cplusplus } #endif #endif /* HEARTBEAT_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file http_protocol.h * @brief HTTP protocol handling * * @defgroup APACHE_CORE_PROTO HTTP Protocol Handling * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_HTTP_PROTOCOL_H #define APACHE_HTTP_PROTOCOL_H #include "httpd.h" #include "apr_portable.h" #include "apr_mmap.h" #include "apr_buckets.h" #include "util_filter.h" #ifdef __cplusplus extern "C" { #endif /** * This hook allows modules to insert filters for the current error response * @param r the current request * @ingroup hooks */ AP_DECLARE_HOOK(void,insert_error_filter,(request_rec *r)) /** This is an optimization. We keep a record of the filter_rec that * stores the old_write filter, so that we can avoid strcmp's later. */ AP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func; /* * Prototypes for routines which either talk directly back to the user, * or control the ones that eventually do. */ /** * Read an empty request and set reasonable defaults. * @param c The current connection * @return The new request_rec */ AP_DECLARE(request_rec *) ap_create_request(conn_rec *c); /** * Read a request and fill in the fields. * @param c The current connection * @return The new request_rec */ request_rec *ap_read_request(conn_rec *c); /** * Parse and validate the request line. * @param r The current request * @return 1 on success, 0 on failure */ AP_DECLARE(int) ap_parse_request_line(request_rec *r); /** * Validate the request header and select vhost. * @param r The current request * @return 1 on success, 0 on failure */ AP_DECLARE(int) ap_check_request_header(request_rec *r); /** * Read the mime-encoded headers. * @param r The current request */ AP_DECLARE(void) ap_get_mime_headers(request_rec *r); /** * Optimized version of ap_get_mime_headers() that requires a * temporary brigade to work with * @param r The current request * @param bb temp brigade */ AP_DECLARE(void) ap_get_mime_headers_core(request_rec *r, apr_bucket_brigade *bb); /** * Run post_read_request hook and validate. * @param r The current request * @return OK or HTTP_... */ AP_DECLARE(int) ap_post_read_request(request_rec *r); /* Finish up stuff after a request */ /** * Called at completion of sending the response. It sends the terminating * protocol information. * @param r The current request */ AP_DECLARE(void) ap_finalize_request_protocol(request_rec *r); /** * Send error back to client. * @param r The current request * @param recursive_error last arg indicates error status in case we get * an error in the process of trying to deal with an ErrorDocument * to handle some other error. In that case, we print the default * report for the first thing that went wrong, and more briefly report * on the problem with the ErrorDocument. */ AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error); /* Set last modified header line from the lastmod date of the associated file. * Also, set content length. * * May return an error status, typically HTTP_NOT_MODIFIED (that when the * permit_cache argument is set to one). */ /** * Set the content length for this request * @param r The current request * @param length The new content length */ AP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t length); /** * Set the keepalive status for this request * @param r The current request * @return 1 if keepalive can be set, 0 otherwise */ AP_DECLARE(int) ap_set_keepalive(request_rec *r); /** * Return the latest rational time from a request/mtime pair. Mtime is * returned unless it's in the future, in which case we return the current time. * @param r The current request * @param mtime The last modified time * @return the latest rational time. */ AP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime); /** * Build the content-type that should be sent to the client from the * content-type specified. The following rules are followed: * - if type is NULL or "", return NULL (do not set content-type). * - if charset adding is disabled, stop processing and return type. * - then, if there are no parameters on type, add the default charset * - return type * @param r The current request * @param type The content type * @return The content-type */ AP_DECLARE(const char *) ap_make_content_type(request_rec *r, const char *type); /** * Precompile metadata structures used by ap_make_content_type() * @param pool The pool to use for allocations */ AP_DECLARE(void) ap_setup_make_content_type(apr_pool_t *pool); /** A structure with the ingredients for a file based etag */ typedef struct etag_rec etag_rec; /** * @brief A structure with the ingredients for a file based etag */ struct etag_rec { /** Optional vary list validator */ const char *vlist_validator; /** Time when the request started */ apr_time_t request_time; /** finfo.protection (st_mode) set to zero if no such file */ apr_finfo_t *finfo; /** File pathname used when generating a digest */ const char *pathname; /** File descriptor used when generating a digest */ apr_file_t *fd; /** Force a non-digest etag to be weak */ int force_weak; }; /** * Construct an entity tag from the resource information. If it's a real * file, build in some of the file characteristics. * @param r The current request * @param force_weak Force the entity tag to be weak - it could be modified * again in as short an interval. * @return The entity tag */ AP_DECLARE(char *) ap_make_etag(request_rec *r, int force_weak); /** * Construct an entity tag from information provided in the etag_rec * structure. * @param r The current request * @param er The etag record, containing ingredients for the etag. */ AP_DECLARE(char *) ap_make_etag_ex(request_rec *r, etag_rec *er); /** * Set the E-tag outgoing header * @param r The current request */ AP_DECLARE(void) ap_set_etag(request_rec *r); /** * Set the E-tag outgoing header, with the option of forcing a strong ETag. * @param r The current request * @param fd The file descriptor */ AP_DECLARE(void) ap_set_etag_fd(request_rec *r, apr_file_t *fd); /** * Set the last modified time for the file being sent * @param r The current request */ AP_DECLARE(void) ap_set_last_modified(request_rec *r); typedef enum { AP_CONDITION_NONE, AP_CONDITION_NOMATCH, AP_CONDITION_WEAK, AP_CONDITION_STRONG } ap_condition_e; /** * Tests conditional request rules for the If-Match header. * @param r The current request * @param headers The response headers to check against * @return AP_CONDITION_NONE if the header is missing, AP_CONDITION_NOMATCH * if the header does not match, AP_CONDITION_STRONG for a strong * match. Weak matches are not permitted for the If-Match header. */ AP_DECLARE(ap_condition_e) ap_condition_if_match(request_rec *r, apr_table_t *headers); /** * Tests conditional request rules for the If-Unmodified-Since header. * @param r The current request * @param headers The response headers to check against * @return AP_CONDITION_NONE if the header is missing, AP_CONDITION_NOMATCH * if the header does not match, AP_CONDITION_WEAK if a weak match * was present and allowed by RFC2616, AP_CONDITION_STRONG for a * strong match. */ AP_DECLARE(ap_condition_e) ap_condition_if_unmodified_since(request_rec *r, apr_table_t *headers); /** * Tests conditional request rules for the If-None-Match header. * @param r The current request * @param headers The response headers to check against * @return AP_CONDITION_NONE if the header is missing, AP_CONDITION_NOMATCH * if the header does not match, AP_CONDITION_WEAK if a weak match * was present and allowed by RFC2616, AP_CONDITION_STRONG for a * strong match. */ AP_DECLARE(ap_condition_e) ap_condition_if_none_match(request_rec *r, apr_table_t *headers); /** * Tests conditional request rules for the If-Modified-Since header. * @param r The current request * @param headers The response headers to check against * @return AP_CONDITION_NONE if the header is missing, AP_CONDITION_NOMATCH * if the header does not match, AP_CONDITION_WEAK if a weak match * was present and allowed by RFC2616, AP_CONDITION_STRONG for a * strong match. */ AP_DECLARE(ap_condition_e) ap_condition_if_modified_since(request_rec *r, apr_table_t *headers); /** * Tests conditional request rules for the If-Range header. * @param r The current request * @param headers The response headers to check against * @return AP_CONDITION_NONE if either the If-Range or Range header is * missing, AP_CONDITION_NOMATCH if the header does not match, * AP_CONDITION_STRONG for a strong match. Weak matches are not * permitted for the If-Range header. */ AP_DECLARE(ap_condition_e) ap_condition_if_range(request_rec *r, apr_table_t *headers); /** * Implements condition GET rules for HTTP/1.1 specification. This function * inspects the client headers and determines if the response fulfills * the requirements specified. * @param r The current request * @return OK if the response fulfills the condition GET rules, some * other status code otherwise */ AP_DECLARE(int) ap_meets_conditions(request_rec *r); /* Other ways to send stuff at the client. All of these keep track * of bytes_sent automatically. This indirection is intended to make * it a little more painless to slide things like HTTP-NG packetization * underneath the main body of the code later. In the meantime, it lets * us centralize a bit of accounting (bytes_sent). * * These also return the number of bytes written by the call. * They should only be called with a timeout registered, for obvious reaasons. * (Ditto the send_header stuff). */ /** * Send an entire file to the client, using sendfile if supported by the * current platform * @param fd The file to send. * @param r The current request * @param offset Offset into the file to start sending. * @param length Amount of data to send * @param nbytes Amount of data actually sent */ AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset, apr_size_t length, apr_size_t *nbytes); #if APR_HAS_MMAP /** * Send an MMAP'ed file to the client * @param mm The MMAP'ed file to send * @param r The current request * @param offset The offset into the MMAP to start sending * @param length The amount of data to send * @return The number of bytes sent */ AP_DECLARE(apr_size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, apr_size_t offset, apr_size_t length); #endif /** * Register a new request method, and return the offset that will be * associated with that method. * * @param p The pool to create registered method numbers from. * @param methname The name of the new method to register. * @return An int value representing an offset into a bitmask. */ AP_DECLARE(int) ap_method_register(apr_pool_t *p, const char *methname); /** * Initialize the method_registry and allocate memory for it. * * @param p Pool to allocate memory for the registry from. */ AP_DECLARE(void) ap_method_registry_init(apr_pool_t *p); /** * This is a convenience macro to ease with checking a mask * against a method name. */ #define AP_METHOD_CHECK_ALLOWED(mask, methname) \ ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname)))) /** * Create a new method list with the specified number of preallocated * slots for extension methods. * * @param p Pointer to a pool in which the structure should be * allocated. * @param nelts Number of preallocated extension slots * @return Pointer to the newly created structure. */ AP_DECLARE(ap_method_list_t *) ap_make_method_list(apr_pool_t *p, int nelts); /** * Copy a method list * * @param dest List to copy to * @param src List to copy from */ AP_DECLARE(void) ap_copy_method_list(ap_method_list_t *dest, ap_method_list_t *src); /** * Search for an HTTP method name in an ap_method_list_t structure, and * return true if found. * * @param method String containing the name of the method to check. * @param l Pointer to a method list, such as r->allowed_methods. * @return 1 if method is in the list, otherwise 0 */ AP_DECLARE(int) ap_method_in_list(ap_method_list_t *l, const char *method); /** * Add an HTTP method name to an ap_method_list_t structure if it isn't * already listed. * * @param method String containing the name of the method to check. * @param l Pointer to a method list, such as r->allowed_methods. * @return None. */ AP_DECLARE(void) ap_method_list_add(ap_method_list_t *l, const char *method); /** * Remove an HTTP method name from an ap_method_list_t structure. * * @param l Pointer to a method list, such as r->allowed_methods. * @param method String containing the name of the method to remove. * @return None. */ AP_DECLARE(void) ap_method_list_remove(ap_method_list_t *l, const char *method); /** * Reset a method list to be completely empty. * * @param l Pointer to a method list, such as r->allowed_methods. * @return None. */ AP_DECLARE(void) ap_clear_method_list(ap_method_list_t *l); /** * Set the content type for this request (r->content_type). * @param r The current request * @param ct The new content type * @warning This function must be called to set r->content_type in order * for the AddOutputFilterByType directive to work correctly. */ AP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct); /** * Set the content type for this request (r->content_type). * @param r The current request * @param ct The new content type * @param trusted If non-zero, The content-type should come from a * trusted source such as server configuration rather * than application output. * for the AddOutputFilterByType directive to work correctly. */ AP_DECLARE(void) ap_set_content_type_ex(request_rec *r, const char *ct, int trusted); /** * Set the Accept-Ranges header for this response * @param r The current request */ AP_DECLARE(void) ap_set_accept_ranges(request_rec *r); /* Hmmm... could macrofy these for now, and maybe forever, though the * definitions of the macros would get a whole lot hairier. */ /** * Output one character for this request * @param c the character to output * @param r the current request * @return The number of bytes sent */ AP_DECLARE(int) ap_rputc(int c, request_rec *r); /** * Write a buffer for the current request * @param buf The buffer to write * @param nbyte The number of bytes to send from the buffer * @param r The current request * @return The number of bytes sent */ AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r); /** * Output a string for the current request * @param str The string to output * @param r The current request * @return The number of bytes sent * @note ap_rputs may be implemented as macro or inline function */ static APR_INLINE int ap_rputs(const char *str, request_rec *r) { apr_size_t len; len = strlen(str); for (;;) { if (len <= INT_MAX) { return ap_rwrite(str, (int)len, r); } else { int rc; rc = ap_rwrite(str, INT_MAX, r); if (rc < 0) { return rc; } else { str += INT_MAX; len -= INT_MAX; } } } } /** * Write an unspecified number of strings to the request * @param r The current request * @param ... The strings to write * @return The number of bytes sent */ AP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...) AP_FN_ATTR_SENTINEL; /** * Output data to the client in a printf format * @param r The current request * @param fmt The format string * @param vlist The arguments to use to fill out the format string * @return The number of bytes sent */ AP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist); /** * Output data to the client in a printf format * @param r The current request * @param fmt The format string * @param ... The arguments to use to fill out the format string * @return The number of bytes sent */ AP_DECLARE_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...) __attribute__((format(printf,2,3))); /** * Flush all of the data for the current request to the client * @param r The current request * @return 0 on success, -1 if an error occurred */ AP_DECLARE(int) ap_rflush(request_rec *r); /** * Index used in custom_responses array for a specific error code * (only use outside protocol.c is in getting them configured). * @param status HTTP status code * @return The index of the response */ AP_DECLARE(int) ap_index_of_response(int status); /** * Return the Status-Line for a given status code (excluding the * HTTP-Version field). If an invalid or unknown status code is * passed, "500 Internal Server Error" will be returned. * @param status The HTTP status code * @return The Status-Line */ AP_DECLARE(const char *) ap_get_status_line(int status); /** * Return the Status-Line for a given status code (excluding the * HTTP-Version field). If an invalid status code is passed, * "500 Internal Server Error" will be returned, whereas an unknown * status will be returned like "xxx Status xxx". * @param p The pool to allocate from when status is unknown * @param status The HTTP status code * @return The Status-Line */ AP_DECLARE(const char *) ap_get_status_line_ex(apr_pool_t *p, int status); /* Reading a block of data from the client connection (e.g., POST arg) */ /** * Setup the client to allow Apache to read the request body. * @param r The current request * @param read_policy How the server should interpret a chunked * transfer-encoding. One of: <pre> * REQUEST_NO_BODY Send 413 error if message has any body * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me. * </pre> * @return either OK or an error code */ AP_DECLARE(int) ap_setup_client_block(request_rec *r, int read_policy); /** * Determine if the client has sent any data. This also sends a * 100 Continue response to HTTP/1.1 clients, so modules should not be called * until the module is ready to read content. * @warning Never call this function more than once. * @param r The current request * @return 0 if there is no message to read, 1 otherwise */ AP_DECLARE(int) ap_should_client_block(request_rec *r); /** * Call this in a loop. It will put data into a buffer and return the length * of the input block * @param r The current request * @param buffer The buffer in which to store the data * @param bufsiz The size of the buffer * @return Number of bytes inserted into the buffer. When done reading, 0 * if EOF, or -1 if there was an error */ AP_DECLARE(long) ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz); /** * Map specific APR codes returned by the filter stack to HTTP error * codes, or the default status code provided. Use it as follows: * * return ap_map_http_request_error(rv, HTTP_BAD_REQUEST); * * If the filter has already handled the error, AP_FILTER_ERROR will * be returned, which is cleanly passed through. * * These mappings imply that the filter stack is reading from the * downstream client, the proxy will map these codes differently. * @param rv APR status code * @param status Default HTTP code should the APR code not be recognised * @return Mapped HTTP status code */ AP_DECLARE(int) ap_map_http_request_error(apr_status_t rv, int status); /** * In HTTP/1.1, any method can have a body. However, most GET handlers * wouldn't know what to do with a request body if they received one. * This helper routine tests for and reads any message body in the request, * simply discarding whatever it receives. We need to do this because * failing to read the request body would cause it to be interpreted * as the next request on a persistent connection. * @param r The current request * @return error status if request is malformed, OK otherwise */ AP_DECLARE(int) ap_discard_request_body(request_rec *r); /** * Setup the output headers so that the client knows how to authenticate * itself the next time, if an authentication request failed. * @param r The current request */ AP_DECLARE(void) ap_note_auth_failure(request_rec *r); /** * @deprecated @see ap_note_auth_failure */ AP_DECLARE(void) ap_note_basic_auth_failure(request_rec *r); /** * @deprecated @see ap_note_auth_failure */ AP_DECLARE(void) ap_note_digest_auth_failure(request_rec *r); /** * This hook allows modules to add support for a specific auth type to * ap_note_auth_failure * @param r the current request * @param auth_type the configured auth_type * @return OK, DECLINED */ AP_DECLARE_HOOK(int, note_auth_failure, (request_rec *r, const char *auth_type)) /** * Get the password from the request headers. This function has multiple side * effects due to its prior use in the old authentication framework. * ap_get_basic_auth_components() should be preferred. * * @deprecated @see ap_get_basic_auth_components * @param r The current request * @param pw The password as set in the headers * @return 0 (OK) if it set the 'pw' argument (and assured * a correct value in r->user); otherwise it returns * an error code, either HTTP_INTERNAL_SERVER_ERROR if things are * really confused, HTTP_UNAUTHORIZED if no authentication at all * seemed to be in use, or DECLINED if there was authentication but * it wasn't Basic (in which case, the caller should presumably * decline as well). */ AP_DECLARE(int) ap_get_basic_auth_pw(request_rec *r, const char **pw); #define AP_GET_BASIC_AUTH_PW_NOTE "AP_GET_BASIC_AUTH_PW_NOTE" /** * Get the username and/or password from the request's Basic authentication * headers. Unlike ap_get_basic_auth_pw(), calling this function has no side * effects on the passed request_rec. * * @param r The current request * @param username If not NULL, set to the username sent by the client * @param password If not NULL, set to the password sent by the client * @return APR_SUCCESS if the credentials were successfully parsed and returned; * APR_EINVAL if there was no authentication header sent or if the * client was not using the Basic authentication scheme. username and * password are unchanged on failure. */ AP_DECLARE(apr_status_t) ap_get_basic_auth_components(const request_rec *r, const char **username, const char **password); /** * parse_uri: break apart the uri * @warning Side Effects: * @li sets r->args to rest after '?' (or NULL if no '?') * @li sets r->uri to request uri (without r->args part) * @li sets r->hostname (if not set already) from request (scheme://host:port) * @param r The current request * @param uri The uri to break apart */ AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri); #define AP_GETLINE_FOLD 1 /* Whether to merge continuation lines */ #define AP_GETLINE_CRLF 2 /* Whether line ends must be in the form CR LF */ #define AP_GETLINE_NOSPC_EOL 4 /* Whether to consume up to and including the end of line on APR_ENOSPC */ /** * Get the next line of input for the request * @param s The buffer into which to read the line * @param n The size of the buffer * @param r The request * @param flags Bit flag of multiple parsing options * AP_GETLINE_FOLD Whether to merge continuation lines * AP_GETLINE_CRLF Whether line ends must be in the form CR LF * @return The length of the line, if successful * n, if the line is too big to fit in the buffer * -1 for miscellaneous errors */ AP_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int flags); /** * Get the next line of input for the request * * Note: on ASCII boxes, ap_rgetline is a macro which simply calls * ap_rgetline_core to get the line of input. * * on EBCDIC boxes, ap_rgetline is a wrapper function which * translates ASCII protocol lines to the local EBCDIC code page * after getting the line of input. * * @param s Pointer to the pointer to the buffer into which the line * should be read; if *s==NULL, a buffer of the necessary size * to hold the data will be allocated from the request pool * @param n The size of the buffer * @param read The length of the line. * @param r The request * @param flags Bit flag of multiple parsing options * AP_GETLINE_FOLD Whether to merge continuation lines * AP_GETLINE_CRLF Whether line ends must be in the form CR LF * @param bb Working brigade to use when reading buckets * @return APR_SUCCESS, if successful * APR_ENOSPC, if the line is too big to fit in the buffer * Other errors where appropriate */ #if APR_CHARSET_EBCDIC AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n, apr_size_t *read, request_rec *r, int flags, apr_bucket_brigade *bb); #else /* ASCII box */ #define ap_rgetline(s, n, read, r, fold, bb) \ ap_rgetline_core((s), (n), (read), (r), (fold), (bb)) #endif /** @see ap_rgetline */ AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n, apr_size_t *read, request_rec *r, int flags, apr_bucket_brigade *bb); /** * Get the method number associated with the given string, assumed to * contain an HTTP method. Returns M_INVALID if not recognized. * @param method A string containing a valid HTTP method * @return The method number */ AP_DECLARE(int) ap_method_number_of(const char *method); /** * Get the method name associated with the given internal method * number. Returns NULL if not recognized. * @param p A pool to use for temporary allocations. * @param methnum An integer value corresponding to an internal method number * @return The name corresponding to the method number */ AP_DECLARE(const char *) ap_method_name_of(apr_pool_t *p, int methnum); /* Hooks */ /* * pre_read_request --- run right before read_request_line(), * and not run during any subrequests. */ /** * This hook allows modules to affect the request or connection immediately before * the request has been read, and before any other phases have been processes. * @param r The current request of the soon-to-be-read request * @param c The connection * @return None/void */ AP_DECLARE_HOOK(void,pre_read_request,(request_rec *r, conn_rec *c)) /* * post_read_request --- run right after read_request or internal_redirect, * and not run during any subrequests. */ /** * This hook allows modules to affect the request immediately after the request * has been read, and before any other phases have been processes. This allows * modules to make decisions based upon the input header fields * @param r The current request * @return OK or DECLINED */ AP_DECLARE_HOOK(int,post_read_request,(request_rec *r)) /** * This hook allows modules to perform any module-specific logging activities * over and above the normal server things. * @param r The current request * @return OK, DECLINED, or HTTP_... */ AP_DECLARE_HOOK(int,log_transaction,(request_rec *r)) /** * This hook allows modules to retrieve the http scheme for a request. This * allows Apache modules to easily extend the schemes that Apache understands * @param r The current request * @return The http scheme from the request */ AP_DECLARE_HOOK(const char *,http_scheme,(const request_rec *r)) /** * Return the default port from the current request * @param r The current request * @return The current port */ AP_DECLARE_HOOK(apr_port_t,default_port,(const request_rec *r)) #define AP_PROTOCOL_HTTP1 "http/1.1" /** * Determine the list of protocols available for a connection/request. This may * be collected with or without any request sent, in which case the request is * NULL. Or it may be triggered by the request received, e.g. through the * "Upgrade" header. * * This hook will be run whenever protocols are being negotiated (ALPN as * one example). It may also be invoked at other times, e.g. when the server * wants to advertise protocols it is capable of switching to. * * The identifiers for protocols are taken from the TLS extension type ALPN: * https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xml * * If no protocols are added to the proposals, the server not perform any * switch. If the protocol selected from the proposals is the protocol * already in place, also no protocol switch will be invoked. * * The client may already have announced the protocols it is willing to * accept. These will then be listed as offers. This parameter may also * be NULL, indicating that offers from the client are not known and * the hooks should propose all protocols that are valid for the * current connection/request. * * All hooks are run, unless one returns an error. Proposals may contain * duplicates. The order in which proposals are added is usually ignored. * * @param c The current connection * @param r The current request or NULL * @param s The server/virtual host selected * @param offers A list of protocol identifiers offered by the client or * NULL to indicated that the hooks are free to propose * @param proposals The list of protocol identifiers proposed by the hooks * @return OK or DECLINED * @bug This API or implementation and order of operations should be considered * experimental and will continue to evolve in future 2.4 releases, with * a corresponding minor module magic number (MMN) bump to indicate the * API revision level. */ AP_DECLARE_HOOK(int,protocol_propose,(conn_rec *c, request_rec *r, server_rec *s, const apr_array_header_t *offers, apr_array_header_t *proposals)) /** * Perform a protocol switch on the connection. The exact requirements for * that depend on the protocol in place and the one switched to. The first * protocol module to handle the switch is the last module run. * * For a connection level switch (r == NULL), the handler must on return * leave the conn_rec in a state suitable for processing the switched * protocol, e.g. correct filters in place. * * For a request triggered switch (r != NULL), the protocol switch is done * before the response is sent out. When switching from "http/1.1" via Upgrade * header, the 101 intermediate response will have been sent. The * hook needs then to process the connection until it can be closed. Which * the server will enforce on hook return. * Any error the hook might encounter must already be sent by the hook itself * to the client in whatever form the new protocol requires. * * @param c The current connection * @param r The current request or NULL * @param s The server/virtual host selected * @param protocol The protocol identifier we try to switch to * @return OK or DECLINED * @bug This API or implementation and order of operations should be considered * experimental and will continue to evolve in future 2.4 releases, with * a corresponding minor module magic number (MMN) bump to indicate the * API revision level. */ AP_DECLARE_HOOK(int,protocol_switch,(conn_rec *c, request_rec *r, server_rec *s, const char *protocol)) /** * Return the protocol used on the connection. Modules implementing * protocol switching must register here and return the correct protocol * identifier for connections they switched. * * To find out the protocol for the current connection, better call * @see ap_get_protocol which internally uses this hook. * * @param c The current connection * @return The identifier of the protocol in place or NULL * @bug This API or implementation and order of operations should be considered * experimental and will continue to evolve in future 2.4 releases, with * a corresponding minor module magic number (MMN) bump to indicate the * API revision level. */ AP_DECLARE_HOOK(const char *,protocol_get,(const conn_rec *c)) /** * Get the protocols that the connection and optional request may * upgrade to - besides the protocol currently active on the connection. These * values may be used to announce to a client what choices it has. * * If report_all == 0, only protocols more preferable than the one currently * being used, are reported. Otherwise, all available protocols beside the * current one are being reported. * * @param c The current connection * @param r The current request or NULL * @param s The server/virtual host selected or NULL * @param report_all include also protocols less preferred than the current one * @param pupgrades on return, possible protocols to upgrade to in descending order * of preference. Maybe NULL if none are available. * @bug This API or implementation and order of operations should be considered * experimental and will continue to evolve in future 2.4 releases, with * a corresponding minor module magic number (MMN) bump to indicate the * API revision level. */ AP_DECLARE(apr_status_t) ap_get_protocol_upgrades(conn_rec *c, request_rec *r, server_rec *s, int report_all, const apr_array_header_t **pupgrades); /** * Select a protocol for the given connection and optional request. Will return * the protocol identifier selected which may be the protocol already in place * on the connection. The selected protocol will be NULL if non of the given * choices could be agreed upon (e.g. no proposal as made). * * A special case is where the choices itself is NULL (instead of empty). In * this case there are no restrictions imposed on protocol selection. * * @param c The current connection * @param r The current request or NULL * @param s The server/virtual host selected * @param choices A list of protocol identifiers, normally the clients whishes * @return The selected protocol or NULL if no protocol could be agreed upon * @bug This API or implementation and order of operations should be considered * experimental and will continue to evolve in future 2.4 releases, with * a corresponding minor module magic number (MMN) bump to indicate the * API revision level. */ AP_DECLARE(const char *) ap_select_protocol(conn_rec *c, request_rec *r, server_rec *s, const apr_array_header_t *choices); /** * Perform the actual protocol switch. The protocol given must have been * selected before on the very same connection and request pair. * * @param c The current connection * @param r The current request or NULL * @param s The server/virtual host selected * @param protocol the protocol to switch to * @return APR_SUCCESS, if caller may continue processing as usual * APR_EOF, if caller needs to stop processing the connection * APR_EINVAL, if the protocol is already in place * APR_NOTIMPL, if no module performed the switch * Other errors where appropriate * @bug This API or implementation and order of operations should be considered * experimental and will continue to evolve in future 2.4 releases, with * a corresponding minor module magic number (MMN) bump to indicate the * API revision level. */ AP_DECLARE(apr_status_t) ap_switch_protocol(conn_rec *c, request_rec *r, server_rec *s, const char *protocol); /** * Call the protocol_get hook to determine the protocol currently in use * for the given connection. * * Unless another protocol has been switch to, will default to * @see AP_PROTOCOL_HTTP1 and modules implementing a new protocol must * report a switched connection via the protocol_get hook. * * @param c The connection to determine the protocol for * @return the protocol in use, never NULL * @bug This API or implementation and order of operations should be considered * experimental and will continue to evolve in future 2.4 releases, with * a corresponding minor module magic number (MMN) bump to indicate the * API revision level. */ AP_DECLARE(const char *) ap_get_protocol(conn_rec *c); /** * Check if the given protocol is an allowed choice on the given * combination of connection, request and server. * * When server is NULL, it is taken from request_rec, unless * request_rec is NULL. Then it is taken from the connection base * server. * * @param c The current connection * @param r The current request or NULL * @param s The server/virtual host selected or NULL * @param protocol the protocol to switch to * @return != 0 iff protocol is allowed * @bug This API or implementation and order of operations should be considered * experimental and will continue to evolve in future 2.4 releases, with * a corresponding minor module magic number (MMN) bump to indicate the * API revision level. */ AP_DECLARE(int) ap_is_allowed_protocol(conn_rec *c, request_rec *r, server_rec *s, const char *protocol); /** @see ap_bucket_type_error */ typedef struct ap_bucket_error ap_bucket_error; /** * @struct ap_bucket_error * @brief A bucket referring to an HTTP error * * This bucket can be passed down the filter stack to indicate that an * HTTP error occurred while running a filter. In order for this bucket * to be used successfully, it MUST be sent as the first bucket in the * first brigade to be sent from a given filter. */ struct ap_bucket_error { /** Number of buckets using this memory */ apr_bucket_refcount refcount; /** The error code */ int status; /** The error string */ const char *data; }; /** @see ap_bucket_type_error */ AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_error; /** * Determine if a bucket is an error bucket * @param e The bucket to inspect * @return true or false */ #define AP_BUCKET_IS_ERROR(e) (e->type == &ap_bucket_type_error) /** * Make the bucket passed in an error bucket * @param b The bucket to make into an error bucket * @param error The HTTP error code to put in the bucket. * @param buf An optional error string to put in the bucket. * @param p A pool to allocate out of. * @return The new bucket, or NULL if allocation failed */ AP_DECLARE(apr_bucket *) ap_bucket_error_make(apr_bucket *b, int error, const char *buf, apr_pool_t *p); /** * Create a bucket referring to an HTTP error. * @param error The HTTP error code to put in the bucket. * @param buf An optional error string to put in the bucket. * @param p A pool to allocate the error string out of. * @param list The bucket allocator from which to allocate the bucket * @return The new bucket, or NULL if allocation failed */ AP_DECLARE(apr_bucket *) ap_bucket_error_create(int error, const char *buf, apr_pool_t *p, apr_bucket_alloc_t *list); AP_DECLARE_NONSTD(apr_status_t) ap_byterange_filter(ap_filter_t *f, apr_bucket_brigade *b); AP_DECLARE_NONSTD(apr_status_t) ap_http_header_filter(ap_filter_t *f, apr_bucket_brigade *b); AP_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *, apr_bucket_brigade *); AP_DECLARE_NONSTD(apr_status_t) ap_old_write_filter(ap_filter_t *f, apr_bucket_brigade *b); /** * Sett up the protocol fields for subsidiary requests * @param rnew New Sub Request * @param r current request */ AP_DECLARE(void) ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r); /** * A wrapup function to keep the internal accounting straight. * Indicates that there is no more content coming. * @param sub_r Subrequest that is now compete */ AP_DECLARE(void) ap_finalize_sub_req_protocol(request_rec *sub_r); /** * Send an interim (HTTP 1xx) response immediately. * @param r The request * @param send_headers Whether to send&clear headers in r->headers_out */ AP_DECLARE(void) ap_send_interim_response(request_rec *r, int send_headers); #ifdef __cplusplus } #endif #endif /* !APACHE_HTTP_PROTOCOL_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_ldap.h * @brief Apache LDAP library */ #ifndef UTIL_LDAP_H #define UTIL_LDAP_H /* APR header files */ #include "apr.h" #include "apr_thread_mutex.h" #include "apr_thread_rwlock.h" #include "apr_tables.h" #include "apr_time.h" #include "apr_version.h" #if APR_MAJOR_VERSION < 2 /* The LDAP API is currently only present in APR 1.x */ #include "apr_ldap.h" #else #define APR_HAS_LDAP 0 #endif #if APR_HAS_SHARED_MEMORY #include "apr_rmm.h" #include "apr_shm.h" #endif /* this whole thing disappears if LDAP is not enabled */ #if APR_HAS_LDAP #if defined(LDAP_UNAVAILABLE) || APR_HAS_MICROSOFT_LDAPSDK #define AP_LDAP_IS_SERVER_DOWN(s) ((s) == LDAP_SERVER_DOWN \ ||(s) == LDAP_UNAVAILABLE) #else #define AP_LDAP_IS_SERVER_DOWN(s) ((s) == LDAP_SERVER_DOWN) #endif /* Apache header files */ #include "ap_config.h" #include "httpd.h" #include "http_config.h" #include "http_core.h" #include "http_log.h" #include "http_protocol.h" #include "http_request.h" #include "apr_optional.h" /* Create a set of LDAP_DECLARE macros with appropriate export * and import tags for the platform */ #if !defined(WIN32) #define LDAP_DECLARE(type) type #define LDAP_DECLARE_NONSTD(type) type #define LDAP_DECLARE_DATA #elif defined(LDAP_DECLARE_STATIC) #define LDAP_DECLARE(type) type __stdcall #define LDAP_DECLARE_NONSTD(type) type #define LDAP_DECLARE_DATA #elif defined(LDAP_DECLARE_EXPORT) #define LDAP_DECLARE(type) __declspec(dllexport) type __stdcall #define LDAP_DECLARE_NONSTD(type) __declspec(dllexport) type #define LDAP_DECLARE_DATA __declspec(dllexport) #else #define LDAP_DECLARE(type) __declspec(dllimport) type __stdcall #define LDAP_DECLARE_NONSTD(type) __declspec(dllimport) type #define LDAP_DECLARE_DATA __declspec(dllimport) #endif #if APR_HAS_MICROSOFT_LDAPSDK #define timeval l_timeval #endif #ifdef __cplusplus extern "C" { #endif /* * LDAP Connections */ /* Values that the deref member can have */ typedef enum { never=LDAP_DEREF_NEVER, searching=LDAP_DEREF_SEARCHING, finding=LDAP_DEREF_FINDING, always=LDAP_DEREF_ALWAYS } deref_options; /* Structure representing an LDAP connection */ typedef struct util_ldap_connection_t { LDAP *ldap; apr_pool_t *pool; /* Pool from which this connection is created */ #if APR_HAS_THREADS apr_thread_mutex_t *lock; /* Lock to indicate this connection is in use */ #endif const char *host; /* Name of the LDAP server (or space separated list) */ int port; /* Port of the LDAP server */ deref_options deref; /* how to handle alias dereferening */ const char *binddn; /* DN to bind to server (can be NULL) */ const char *bindpw; /* Password to bind to server (can be NULL) */ int bound; /* Flag to indicate whether this connection is bound yet */ int secure; /* SSL/TLS mode of the connection */ apr_array_header_t *client_certs; /* Client certificates on this connection */ const char *reason; /* Reason for an error failure */ struct util_ldap_connection_t *next; struct util_ldap_state_t *st; /* The LDAP vhost config this connection belongs to */ int keep; /* Will this connection be kept when it's unlocked */ int ChaseReferrals; /* [on|off] (default = AP_LDAP_CHASEREFERRALS_ON)*/ int ReferralHopLimit; /* # of referral hops to follow (default = AP_LDAP_DEFAULT_HOPLIMIT) */ apr_time_t freed; /* the time this conn was placed back in the pool */ apr_pool_t *rebind_pool; /* frequently cleared pool for rebind data */ int must_rebind; /* The connection was last bound with other then binddn/bindpw */ request_rec *r; /* request_rec used to find this util_ldap_connection_t */ apr_time_t last_backend_conn; /* the approximate time of the last backend LDAP request */ } util_ldap_connection_t; typedef struct util_ldap_config_t { int ChaseReferrals; int ReferralHopLimit; apr_array_header_t *client_certs; /* Client certificates */ } util_ldap_config_t; /* LDAP cache state information */ typedef struct util_ldap_state_t { apr_pool_t *pool; /* pool from which this state is allocated */ #if APR_HAS_THREADS apr_thread_mutex_t *mutex; /* mutex lock for the connection list */ #endif apr_global_mutex_t *util_ldap_cache_lock; apr_size_t cache_bytes; /* Size (in bytes) of shared memory cache */ char *cache_file; /* filename for shm */ long search_cache_ttl; /* TTL for search cache */ long search_cache_size; /* Size (in entries) of search cache */ long compare_cache_ttl; /* TTL for compare cache */ long compare_cache_size; /* Size (in entries) of compare cache */ struct util_ldap_connection_t *connections; apr_array_header_t *global_certs; /* Global CA certificates */ int ssl_supported; int secure; int secure_set; int verify_svr_cert; #if APR_HAS_SHARED_MEMORY apr_shm_t *cache_shm; apr_rmm_t *cache_rmm; #endif /* cache ald */ void *util_ldap_cache; long connectionTimeout; struct timeval *opTimeout; int debug_level; /* SDK debug level */ apr_interval_time_t connection_pool_ttl; int retries; /* number of retries for failed bind/search/compare */ apr_interval_time_t retry_delay; /* delay between retries of failed bind/search/compare */ } util_ldap_state_t; /* Used to store arrays of attribute labels/values. */ struct mod_auth_ldap_groupattr_entry_t { char *name; }; /** * Open a connection to an LDAP server * @param ldc A structure containing the expanded details of the server * to connect to. The handle to the LDAP connection is returned * as ldc->ldap. * @tip This function connects to the LDAP server and binds. It does not * connect if already connected (ldc->ldap != NULL). Does not bind * if already bound. * @return If successful LDAP_SUCCESS is returned. * @fn int util_ldap_connection_open(request_rec *r, * util_ldap_connection_t *ldc) */ APR_DECLARE_OPTIONAL_FN(int,uldap_connection_open,(request_rec *r, util_ldap_connection_t *ldc)); /** * Close a connection to an LDAP server * @param ldc A structure containing the expanded details of the server * that was connected. * @tip This function unbinds from the LDAP server, and clears ldc->ldap. * It is possible to rebind to this server again using the same ldc * structure, using apr_ldap_open_connection(). * @fn util_ldap_close_connection(util_ldap_connection_t *ldc) */ APR_DECLARE_OPTIONAL_FN(void,uldap_connection_close,(util_ldap_connection_t *ldc)); /** * Unbind a connection to an LDAP server * @param ldc A structure containing the expanded details of the server * that was connected. * @tip This function unbinds the LDAP connection, and disconnects from * the server. It is used during error conditions, to bring the LDAP * connection back to a known state. * @fn apr_status_t util_ldap_connection_unbind(util_ldap_connection_t *ldc) */ APR_DECLARE_OPTIONAL_FN(apr_status_t,uldap_connection_unbind,(void *param)); /** * Find a connection in a list of connections * @param r The request record * @param host The hostname to connect to (multiple hosts space separated) * @param port The port to connect to * @param binddn The DN to bind with * @param bindpw The password to bind with * @param deref The dereferencing behavior * @param secure use SSL on the connection * @tip Once a connection is found and returned, a lock will be acquired to * lock that particular connection, so that another thread does not try and * use this connection while it is busy. Once you are finished with a connection, * apr_ldap_connection_close() must be called to release this connection. * @fn util_ldap_connection_t *util_ldap_connection_find(request_rec *r, const char *host, int port, * const char *binddn, const char *bindpw, deref_options deref, * int netscapessl, int starttls) */ APR_DECLARE_OPTIONAL_FN(util_ldap_connection_t *,uldap_connection_find,(request_rec *r, const char *host, int port, const char *binddn, const char *bindpw, deref_options deref, int secure)); /** * Compare two DNs for sameness * @param r The request record * @param ldc The LDAP connection being used. * @param url The URL of the LDAP connection - used for deciding which cache to use. * @param dn The first DN to compare. * @param reqdn The DN to compare the first DN to. * @param compare_dn_on_server Flag to determine whether the DNs should be checked using * LDAP calls or with a direct string comparison. A direct * string comparison is faster, but not as accurate - false * negative comparisons are possible. * @tip Two DNs can be equal and still fail a string comparison. Eg "dc=example,dc=com" * and "dc=example, dc=com". Use the compare_dn_on_server unless there are serious * performance issues. * @fn int util_ldap_cache_comparedn(request_rec *r, util_ldap_connection_t *ldc, * const char *url, const char *dn, const char *reqdn, * int compare_dn_on_server) */ APR_DECLARE_OPTIONAL_FN(int,uldap_cache_comparedn,(request_rec *r, util_ldap_connection_t *ldc, const char *url, const char *dn, const char *reqdn, int compare_dn_on_server)); /** * A generic LDAP compare function * @param r The request record * @param ldc The LDAP connection being used. * @param url The URL of the LDAP connection - used for deciding which cache to use. * @param dn The DN of the object in which we do the compare. * @param attrib The attribute within the object we are comparing for. * @param value The value of the attribute we are trying to compare for. * @tip Use this function to determine whether an attribute/value pair exists within an * object. Typically this would be used to determine LDAP top-level group * membership. * @fn int util_ldap_cache_compare(request_rec *r, util_ldap_connection_t *ldc, * const char *url, const char *dn, const char *attrib, const char *value) */ APR_DECLARE_OPTIONAL_FN(int,uldap_cache_compare,(request_rec *r, util_ldap_connection_t *ldc, const char *url, const char *dn, const char *attrib, const char *value)); /** * An LDAP function that checks if the specified user is a member of a subgroup. * @param r The request record * @param ldc The LDAP connection being used. * @param url The URL of the LDAP connection - used for deciding which cache to use. * @param dn The DN of the object in which we find subgroups to search within. * @param attrib The attribute within group objects that identify users. * @param value The user attribute value we are trying to compare for. * @param subgroupAttrs The attributes within group objects that identify subgroups. * Array of strings. * @param subgroupclasses The objectClass values used to identify groups (and * subgroups). apr_array_header_t *. * @param cur_subgroup_depth Current recursive depth during subgroup processing. * @param max_subgroup_depth Maximum depth of recursion allowed during subgroup * processing. * @tip Use this function to determine whether an attribute/value pair exists within a * starting group object or one of its nested subgroups. Typically this would be * used to determine LDAP nested group membership. * @deffunc int util_ldap_cache_check_subgroups(request_rec *r, util_ldap_connection_t * *ldc, const char *url, const char *dn, * const char *attrib, const char value, * char **subgroupAttrs, apr_array_header_t * *subgroupclasses, int cur_subgroup_depth, int * max_subgroup_depth ) */ APR_DECLARE_OPTIONAL_FN(int,uldap_cache_check_subgroups,(request_rec *r, util_ldap_connection_t *ldc, const char *url, const char *dn, const char *attrib, const char *value, char **subgroupAttrs, apr_array_header_t *subgroupclasses, int cur_subgroup_depth, int max_subgroup_depth)); /** * Checks a username/password combination by binding to the LDAP server * @param r The request record * @param ldc The LDAP connection being used. * @param url The URL of the LDAP connection - used for deciding which cache to use. * @param basedn The Base DN to search for the user in. * @param scope LDAP scope of the search. * @param attrs LDAP attributes to return in search. * @param filter The user to search for in the form of an LDAP filter. This filter must return * exactly one user for the check to be successful. * @param bindpw The user password to bind as. * @param binddn The DN of the user will be returned in this variable. * @param retvals The values corresponding to the attributes requested in the attrs array. * @tip The filter supplied will be searched for. If a single entry is returned, an attempt * is made to bind as that user. If this bind succeeds, the user is not validated. * @fn int util_ldap_cache_checkuserid(request_rec *r, util_ldap_connection_t *ldc, * char *url, const char *basedn, int scope, char **attrs, * char *filter, char *bindpw, char **binddn, char ***retvals) */ APR_DECLARE_OPTIONAL_FN(int,uldap_cache_checkuserid,(request_rec *r, util_ldap_connection_t *ldc, const char *url, const char *basedn, int scope, char **attrs, const char *filter, const char *bindpw, const char **binddn, const char ***retvals)); /** * Searches for a specified user object in an LDAP directory * @param r The request record * @param ldc The LDAP connection being used. * @param url The URL of the LDAP connection - used for deciding which cache to use. * @param basedn The Base DN to search for the user in. * @param scope LDAP scope of the search. * @param attrs LDAP attributes to return in search. * @param filter The user to search for in the form of an LDAP filter. This filter must return * exactly one user for the check to be successful. * @param binddn The DN of the user will be returned in this variable. * @param retvals The values corresponding to the attributes requested in the attrs array. * @tip The filter supplied will be searched for. If a single entry is returned, an attempt * is made to bind as that user. If this bind succeeds, the user is not validated. * @fn int util_ldap_cache_getuserdn(request_rec *r, util_ldap_connection_t *ldc, * char *url, const char *basedn, int scope, char **attrs, * char *filter, char **binddn, char ***retvals) */ APR_DECLARE_OPTIONAL_FN(int,uldap_cache_getuserdn,(request_rec *r, util_ldap_connection_t *ldc, const char *url, const char *basedn, int scope, char **attrs, const char *filter, const char **binddn, const char ***retvals)); /** * Checks if SSL support is available in mod_ldap * @fn int util_ldap_ssl_supported(request_rec *r) */ APR_DECLARE_OPTIONAL_FN(int,uldap_ssl_supported,(request_rec *r)); /* from apr_ldap_cache.c */ /** * Init the LDAP cache * @param pool The pool to use to initialise the cache * @param reqsize The size of the shared memory segment to request. A size * of zero requests the max size possible from * apr_shmem_init() * @fn void util_ldap_cache_init(apr_pool_t *p, util_ldap_state_t *st) * @return The status code returned is the status code of the * apr_smmem_init() call. Regardless of the status, the cache * will be set up at least for in-process or in-thread operation. */ apr_status_t util_ldap_cache_init(apr_pool_t *pool, util_ldap_state_t *st); /* from apr_ldap_cache_mgr.c */ /** * Display formatted stats for cache * @param The pool to allocate the returned string from * @tip This function returns a string allocated from the provided pool that describes * various stats about the cache. * @fn char *util_ald_cache_display(apr_pool_t *pool, util_ldap_state_t *st) */ char *util_ald_cache_display(request_rec *r, util_ldap_state_t *st); #ifdef __cplusplus } #endif #endif /* APR_HAS_LDAP */ #endif /* UTIL_LDAP_H */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __MOD_HTTP2_H__ #define __MOD_HTTP2_H__ /** The http2_var_lookup() optional function retrieves HTTP2 environment * variables. */ APR_DECLARE_OPTIONAL_FN(char *, http2_var_lookup, (apr_pool_t *, server_rec *, conn_rec *, request_rec *, char *)); /** An optional function which returns non-zero if the given connection * or its master connection is using HTTP/2. */ APR_DECLARE_OPTIONAL_FN(int, http2_is_h2, (conn_rec *)); APR_DECLARE_OPTIONAL_FN(void, http2_get_num_workers, (server_rec *s, int *minw, int *max)); #define AP_HTTP2_HAS_GET_POLLFD /** * Get a apr_pollfd_t populated for a h2 connection where * (c->master != NULL) is true and pipes are supported. * To be used in Apache modules implementing WebSockets in Apache httpd * versions that do not support the corresponding `ap_get_pollfd_from_conn()` * function. * When available, use `ap_get_pollfd_from_conn()` instead of this function. * * How it works: pass in a `apr_pollfd_t` which gets populated for * monitoring the input of connection `c`. If `c` is not a HTTP/2 * stream connection, the function will return `APR_ENOTIMPL`. * `ptimeout` is optional and, if passed, will get the timeout in effect * * On platforms without support for pipes (e.g. Windows), this function * will return `APR_ENOTIMPL`. */ APR_DECLARE_OPTIONAL_FN(apr_status_t, http2_get_pollfd_from_conn, (conn_rec *c, struct apr_pollfd_t *pfd, apr_interval_time_t *ptimeout)); /******************************************************************************* * START HTTP/2 request engines (DEPRECATED) ******************************************************************************/ /* The following functions were introduced for the experimental mod_proxy_http2 * support, but have been abandoned since. * They are still declared here for backward compatibility, in case someone * tries to build an old mod_proxy_http2 against it, but will disappear * completely sometime in the future. */ struct apr_thread_cond_t; typedef struct h2_req_engine h2_req_engine; typedef void http2_output_consumed(void *ctx, conn_rec *c, apr_off_t consumed); typedef apr_status_t http2_req_engine_init(h2_req_engine *engine, const char *id, const char *type, apr_pool_t *pool, apr_size_t req_buffer_size, request_rec *r, http2_output_consumed **pconsumed, void **pbaton); APR_DECLARE_OPTIONAL_FN(apr_status_t, http2_req_engine_push, (const char *engine_type, request_rec *r, http2_req_engine_init *einit)); APR_DECLARE_OPTIONAL_FN(apr_status_t, http2_req_engine_pull, (h2_req_engine *engine, apr_read_type_e block, int capacity, request_rec **pr)); APR_DECLARE_OPTIONAL_FN(void, http2_req_engine_done, (h2_req_engine *engine, conn_rec *rconn, apr_status_t status)); /******************************************************************************* * END HTTP/2 request engines (DEPRECATED) ******************************************************************************/ #endif /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file unixd.h * @brief common stuff that unix MPMs will want * * @addtogroup APACHE_OS_UNIX * @{ */ #ifndef UNIXD_H #define UNIXD_H #include "httpd.h" #include "http_config.h" #include "scoreboard.h" #include "ap_listen.h" #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif #ifdef HAVE_SYS_RESOURCE_H #include <sys/resource.h> #endif #include "apr_hooks.h" #include "apr_thread_proc.h" #include "apr_proc_mutex.h" #include "apr_global_mutex.h" #include <pwd.h> #include <grp.h> #if APR_HAVE_SYS_TYPES_H #include <sys/types.h> #endif #ifdef HAVE_SYS_IPC_H #include <sys/ipc.h> #endif #ifdef __cplusplus extern "C" { #endif typedef struct { uid_t uid; gid_t gid; int userdir; } ap_unix_identity_t; AP_DECLARE_HOOK(ap_unix_identity_t *, get_suexec_identity,(const request_rec *r)) /* Default user name and group name. These may be specified as numbers by * placing a # before a number */ #ifndef DEFAULT_USER #define DEFAULT_USER "#-1" #endif #ifndef DEFAULT_GROUP #define DEFAULT_GROUP "#-1" #endif typedef struct { const char *user_name; const char *group_name; uid_t user_id; gid_t group_id; int suexec_enabled; const char *chroot_dir; const char *suexec_disabled_reason; /* suitable msg if !suexec_enabled */ } unixd_config_rec; AP_DECLARE_DATA extern unixd_config_rec ap_unixd_config; #if defined(RLIMIT_CPU) || defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_NPROC) || defined(RLIMIT_AS) AP_DECLARE(void) ap_unixd_set_rlimit(cmd_parms *cmd, struct rlimit **plimit, const char *arg, const char * arg2, int type); #endif /** * One of the functions to set mutex permissions should be called in * the parent process on platforms that switch identity when the * server is started as root. * If the child init logic is performed before switching identity * (e.g., MPM setup for an accept mutex), it should only be called * for SysV semaphores. Otherwise, it is safe to call it for all * mutex types. */ AP_DECLARE(apr_status_t) ap_unixd_set_proc_mutex_perms(apr_proc_mutex_t *pmutex); AP_DECLARE(apr_status_t) ap_unixd_set_global_mutex_perms(apr_global_mutex_t *gmutex); AP_DECLARE(apr_status_t) ap_unixd_accept(void **accepted, ap_listen_rec *lr, apr_pool_t *ptrans); #ifdef HAVE_KILLPG #define ap_unixd_killpg(x, y) (killpg ((x), (y))) #define ap_os_killpg(x, y) (killpg ((x), (y))) #else /* HAVE_KILLPG */ #define ap_unixd_killpg(x, y) (kill (-(x), (y))) #define ap_os_killpg(x, y) (kill (-(x), (y))) #endif /* HAVE_KILLPG */ typedef struct { void *baton; /* MPM's */ /* volatile because they're updated from signals' handlers */ int volatile mpm_state; int volatile shutdown_pending; int volatile restart_pending; int volatile is_ungraceful; ap_generation_t my_generation; int module_loads; int was_graceful; /* * Current number of listeners buckets and maximum reached across * restarts (to size retained data according to dynamic num_buckets, * eg. idle_spawn_rate). */ int num_buckets, max_buckets; } ap_unixd_mpm_retained_data; AP_DECLARE(ap_unixd_mpm_retained_data *) ap_unixd_mpm_get_retained_data(void); AP_DECLARE(void) ap_unixd_mpm_set_signals(apr_pool_t *pconf, int once_process); #ifdef __cplusplus } #endif #endif /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_filter.h * @brief Apache filter library */ #ifndef AP_FILTER_H #define AP_FILTER_H #include "apr.h" #include "apr_buckets.h" #include "httpd.h" #if APR_HAVE_STDARG_H #include <stdarg.h> #endif #ifdef __cplusplus extern "C" { #endif /** * @brief input filtering modes */ typedef enum { /** The filter should return at most readbytes data. */ AP_MODE_READBYTES, /** The filter should return at most one line of CRLF data. * (If a potential line is too long or no CRLF is found, the * filter may return partial data). */ AP_MODE_GETLINE, /** The filter should implicitly eat any CRLF pairs that it sees. */ AP_MODE_EATCRLF, /** The filter read should be treated as speculative and any returned * data should be stored for later retrieval in another mode. */ AP_MODE_SPECULATIVE, /** The filter read should be exhaustive and read until it can not * read any more. * Use this mode with extreme caution. */ AP_MODE_EXHAUSTIVE, /** The filter should initialize the connection if needed, * NNTP or FTP over SSL for example. */ AP_MODE_INIT } ap_input_mode_t; /** * @defgroup APACHE_CORE_FILTER Filter Chain * @ingroup APACHE_CORE * * Filters operate using a "chaining" mechanism. The filters are chained * together into a sequence. When output is generated, it is passed through * each of the filters on this chain, until it reaches the end (or "bottom") * and is placed onto the network. * * The top of the chain, the code generating the output, is typically called * a "content generator." The content generator's output is fed into the * filter chain using the standard Apache output mechanisms: ap_rputs(), * ap_rprintf(), ap_rwrite(), etc. * * Each filter is defined by a callback. This callback takes the output from * the previous filter (or the content generator if there is no previous * filter), operates on it, and passes the result to the next filter in the * chain. This pass-off is performed using the ap_fc_* functions, such as * ap_fc_puts(), ap_fc_printf(), ap_fc_write(), etc. * * When content generation is complete, the system will pass an "end of * stream" marker into the filter chain. The filters will use this to flush * out any internal state and to detect incomplete syntax (for example, an * unterminated SSI directive). * * @{ */ /* forward declare the filter type */ typedef struct ap_filter_t ap_filter_t; /** * @name Filter callbacks * * This function type is used for filter callbacks. It will be passed a * pointer to "this" filter, and a "bucket brigade" containing the content * to be filtered. * * In filter->ctx, the callback will find its context. This context is * provided here, so that a filter may be installed multiple times, each * receiving its own per-install context pointer. * * Callbacks are associated with a filter definition, which is specified * by name. See ap_register_input_filter() and ap_register_output_filter() * for setting the association between a name for a filter and its * associated callback (and other information). * * If the initialization function argument passed to the registration * functions is non-NULL, it will be called iff the filter is in the input * or output filter chains and before any data is generated to allow the * filter to prepare for processing. * * The bucket brigade always belongs to the caller, but the filter * is free to use the buckets within it as it sees fit. Normally, * the brigade will be returned empty. Buckets *may not* be retained * between successive calls to the filter unless they have been * "set aside" with a call apr_bucket_setaside. Typically this will * be done with ap_save_brigade(). Buckets removed from the brigade * become the responsibility of the filter, which must arrange for * them to be deleted, either by doing so directly or by inserting * them in a brigade which will subsequently be destroyed. * * For the input and output filters, the return value of a filter should be * an APR status value. For the init function, the return value should * be an HTTP error code or OK if it was successful. * * @ingroup filter * @{ */ typedef apr_status_t (*ap_out_filter_func)(ap_filter_t *f, apr_bucket_brigade *b); typedef apr_status_t (*ap_in_filter_func)(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes); typedef int (*ap_init_filter_func)(ap_filter_t *f); typedef union ap_filter_func { ap_out_filter_func out_func; ap_in_filter_func in_func; } ap_filter_func; /** @} */ /** * Filters have different types/classifications. These are used to group * and sort the filters to properly sequence their operation. * * The types have a particular sort order, which allows us to insert them * into the filter chain in a determistic order. Within a particular grouping, * the ordering is equivalent to the order of calls to ap_add_*_filter(). */ typedef enum { /** These filters are used to alter the content that is passed through * them. Examples are SSI or PHP. */ AP_FTYPE_RESOURCE = 10, /** These filters are used to alter the content as a whole, but after all * AP_FTYPE_RESOURCE filters are executed. These filters should not * change the content-type. An example is deflate. */ AP_FTYPE_CONTENT_SET = 20, /** These filters are used to handle the protocol between server and * client. Examples are HTTP and POP. */ AP_FTYPE_PROTOCOL = 30, /** These filters implement transport encodings (e.g., chunking). */ AP_FTYPE_TRANSCODE = 40, /** These filters will alter the content, but in ways that are * more strongly associated with the connection. Examples are * splitting an HTTP connection into multiple requests and * buffering HTTP responses across multiple requests. * * It is important to note that these types of filters are not * allowed in a sub-request. A sub-request's output can certainly * be filtered by ::AP_FTYPE_RESOURCE filters, but all of the "final * processing" is determined by the main request. */ AP_FTYPE_CONNECTION = 50, /** These filters don't alter the content. They are responsible for * sending/receiving data to/from the client. */ AP_FTYPE_NETWORK = 60 } ap_filter_type; /** * This is the request-time context structure for an installed filter (in * the output filter chain). It provides the callback to use for filtering, * the request this filter is associated with (which is important when * an output chain also includes sub-request filters), the context for this * installed filter, and the filter ordering/chaining fields. * * Filter callbacks are free to use ->ctx as they please, to store context * during the filter process. Generally, this is superior over associating * the state directly with the request. A callback should not change any of * the other fields. */ typedef struct ap_filter_rec_t ap_filter_rec_t; typedef struct ap_filter_provider_t ap_filter_provider_t; /** * @brief This structure is used for recording information about the * registered filters. It associates a name with the filter's callback * and filter type. * * At the moment, these are simply linked in a chain, so a ->next pointer * is available. * * It is used for any filter that can be inserted in the filter chain. * This may be either a httpd-2.0 filter or a mod_filter harness. * In the latter case it contains dispatch, provider and protocol information. * In the former case, the new fields (from dispatch) are ignored. */ struct ap_filter_rec_t { /** The registered name for this filter */ const char *name; /** The function to call when this filter is invoked. */ ap_filter_func filter_func; /** The function to call directly before the handlers are invoked * for a request. The init function is called once directly * before running the handlers for a request or subrequest. The * init function is never called for a connection filter (with * ftype >= AP_FTYPE_CONNECTION). Any use of this function for * filters for protocols other than HTTP is specified by the * module supported that protocol. */ ap_init_filter_func filter_init_func; /** The next filter_rec in the list */ struct ap_filter_rec_t *next; /** Providers for this filter */ ap_filter_provider_t *providers; /** The type of filter, either AP_FTYPE_CONTENT or AP_FTYPE_CONNECTION. * An AP_FTYPE_CONTENT filter modifies the data based on information * found in the content. An AP_FTYPE_CONNECTION filter modifies the * data based on the type of connection. */ ap_filter_type ftype; /** Trace level for this filter */ int debug; /** Protocol flags for this filter */ unsigned int proto_flags; }; /** * @brief The representation of a filter chain. * * Each request has a list * of these structures which are called in turn to filter the data. Sub * requests get an exact copy of the main requests filter chain. */ struct ap_filter_t { /** The internal representation of this filter. This includes * the filter's name, type, and the actual function pointer. */ ap_filter_rec_t *frec; /** A place to store any data associated with the current filter */ void *ctx; /** The next filter in the chain */ ap_filter_t *next; /** The request_rec associated with the current filter. If a sub-request * adds filters, then the sub-request is the request associated with the * filter. */ request_rec *r; /** The conn_rec associated with the current filter. This is analogous * to the request_rec, except that it is used for connection filters. */ conn_rec *c; }; /** * Get the current bucket brigade from the next filter on the filter * stack. The filter returns an apr_status_t value. If the bottom-most * filter doesn't read from the network, then ::AP_NOBODY_READ is returned. * The bucket brigade will be empty when there is nothing left to get. * @param filter The next filter in the chain * @param bucket The current bucket brigade. The original brigade passed * to ap_get_brigade() must be empty. * @param mode The way in which the data should be read * @param block How the operations should be performed * ::APR_BLOCK_READ, ::APR_NONBLOCK_READ * @param readbytes How many bytes to read from the next filter. */ AP_DECLARE(apr_status_t) ap_get_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes); /** * Pass the current bucket brigade down to the next filter on the filter * stack. The filter returns an apr_status_t value. If the bottom-most * filter doesn't write to the network, then ::AP_NOBODY_WROTE is returned. * @param filter The next filter in the chain * @param bucket The current bucket brigade * * @remark Ownership of the brigade is retained by the caller. On return, * the contents of the brigade are UNDEFINED, and the caller must * either call apr_brigade_cleanup or apr_brigade_destroy on * the brigade. */ AP_DECLARE(apr_status_t) ap_pass_brigade(ap_filter_t *filter, apr_bucket_brigade *bucket); /** * Pass the current bucket brigade down to the next filter on the filter * stack checking for filter errors. The filter returns an apr_status_t value. * Returns ::OK if the brigade is successfully passed * ::AP_FILTER_ERROR on a filter error * ::HTTP_INTERNAL_SERVER_ERROR on all other errors * @param r The request rec * @param bucket The current bucket brigade * @param fmt The format string. If NULL defaults to "ap_pass_brigade returned" * @param ... The arguments to use to fill out the format string * @remark Ownership of the brigade is retained by the caller. On return, * the contents of the brigade are UNDEFINED, and the caller must * either call apr_brigade_cleanup or apr_brigade_destroy on * the brigade. */ AP_DECLARE(apr_status_t) ap_pass_brigade_fchk(request_rec *r, apr_bucket_brigade *bucket, const char *fmt, ...) __attribute__((format(printf,3,4))); /** * This function is used to register an input filter with the system. * After this registration is performed, then a filter may be added * into the filter chain by using ap_add_input_filter() and simply * specifying the name. * * @param name The name to attach to the filter function * @param filter_func The filter function to name * @param filter_init The function to call before the filter handlers are invoked * @param ftype The type of filter function, either ::AP_FTYPE_CONTENT_SET or * ::AP_FTYPE_CONNECTION * @see add_input_filter() */ AP_DECLARE(ap_filter_rec_t *) ap_register_input_filter(const char *name, ap_in_filter_func filter_func, ap_init_filter_func filter_init, ap_filter_type ftype); /** @deprecated @see ap_register_output_filter_protocol */ AP_DECLARE(ap_filter_rec_t *) ap_register_output_filter(const char *name, ap_out_filter_func filter_func, ap_init_filter_func filter_init, ap_filter_type ftype); /* For httpd-?.? I suggest replacing the above with #define ap_register_output_filter(name,ffunc,init,ftype) \ ap_register_output_filter_protocol(name,ffunc,init,ftype,0) */ /** * This function is used to register an output filter with the system. * After this registration is performed, then a filter may be added * directly to the filter chain by using ap_add_output_filter() and * simply specifying the name, or as a provider under mod_filter. * * @param name The name to attach to the filter function * @param filter_func The filter function to name * @param filter_init The function to call before the filter handlers * are invoked * @param ftype The type of filter function, either ::AP_FTYPE_CONTENT_SET or * ::AP_FTYPE_CONNECTION * @param proto_flags Protocol flags: logical OR of AP_FILTER_PROTO_* bits * @return the filter rec * @see ap_add_output_filter() */ AP_DECLARE(ap_filter_rec_t *) ap_register_output_filter_protocol( const char *name, ap_out_filter_func filter_func, ap_init_filter_func filter_init, ap_filter_type ftype, unsigned int proto_flags); /** * Adds a named filter into the filter chain on the specified request record. * The filter will be installed with the specified context pointer. * * Filters added in this way will always be placed at the end of the filters * that have the same type (thus, the filters have the same order as the * calls to ap_add_filter). If the current filter chain contains filters * from another request, then this filter will be added before those other * filters. * * To re-iterate that last comment. This function is building a FIFO * list of filters. Take note of that when adding your filter to the chain. * * @param name The name of the filter to add * @param ctx Context data to provide to the filter * @param r The request to add this filter for (or NULL if it isn't associated with a request) * @param c The connection to add the fillter for */ AP_DECLARE(ap_filter_t *) ap_add_input_filter(const char *name, void *ctx, request_rec *r, conn_rec *c); /** * Variant of ap_add_input_filter() that accepts a registered filter handle * (as returned by ap_register_input_filter()) rather than a filter name * * @param f The filter handle to add * @param ctx Context data to provide to the filter * @param r The request to add this filter for (or NULL if it isn't associated with a request) * @param c The connection to add the fillter for */ AP_DECLARE(ap_filter_t *) ap_add_input_filter_handle(ap_filter_rec_t *f, void *ctx, request_rec *r, conn_rec *c); /** * Returns the filter handle for use with ap_add_input_filter_handle. * * @param name The filter name to look up */ AP_DECLARE(ap_filter_rec_t *) ap_get_input_filter_handle(const char *name); /** * Add a filter to the current request. Filters are added in a FIFO manner. * The first filter added will be the first filter called. * @param name The name of the filter to add * @param ctx Context data to set in the filter * @param r The request to add this filter for (or NULL if it isn't associated with a request) * @param c The connection to add this filter for * @note If adding a connection-level output filter (i.e. where the type * is >= AP_FTYPE_CONNECTION) during processing of a request, the request * object r must be passed in to ensure the filter chains are modified * correctly. f->r will still be initialized as NULL in the new filter. */ AP_DECLARE(ap_filter_t *) ap_add_output_filter(const char *name, void *ctx, request_rec *r, conn_rec *c); /** * Variant of ap_add_output_filter() that accepts a registered filter handle * (as returned by ap_register_output_filter()) rather than a filter name * * @param f The filter handle to add * @param ctx Context data to set in the filter * @param r The request to add this filter for (or NULL if it isn't associated with a request) * @param c The connection to add the filter for * @note If adding a connection-level output filter (i.e. where the type * is >= AP_FTYPE_CONNECTION) during processing of a request, the request * object r must be passed in to ensure the filter chains are modified * correctly. f->r will still be initialized as NULL in the new filter. */ AP_DECLARE(ap_filter_t *) ap_add_output_filter_handle(ap_filter_rec_t *f, void *ctx, request_rec *r, conn_rec *c); /** * Returns the filter handle for use with ap_add_output_filter_handle. * * @param name The filter name to look up */ AP_DECLARE(ap_filter_rec_t *) ap_get_output_filter_handle(const char *name); /** * Remove an input filter from either the request or connection stack * it is associated with. * @param f The filter to remove */ AP_DECLARE(void) ap_remove_input_filter(ap_filter_t *f); /** * Remove an output filter from either the request or connection stack * it is associated with. * @param f The filter to remove */ AP_DECLARE(void) ap_remove_output_filter(ap_filter_t *f); /** * Remove an input filter from either the request or connection stack * it is associated with. * @param next The filter stack to search * @param handle The filter handle (name) to remove * @return APR_SUCCESS on removal or error */ AP_DECLARE(apr_status_t) ap_remove_input_filter_byhandle(ap_filter_t *next, const char *handle); /** * Remove an output filter from either the request or connection stack * it is associated with. * @param next The filter stack to search * @param handle The filter handle (name) to remove * @return APR_SUCCESS on removal or error */ AP_DECLARE(apr_status_t) ap_remove_output_filter_byhandle(ap_filter_t *next, const char *handle); /* The next two filters are for abstraction purposes only. They could be * done away with, but that would require that we break modules if we ever * want to change our filter registration method. The basic idea, is that * all filters have a place to store data, the ctx pointer. These functions * fill out that pointer with a bucket brigade, and retrieve that data on * the next call. The nice thing about these functions, is that they * automatically concatenate the bucket brigades together for you. This means * that if you have already stored a brigade in the filters ctx pointer, then * when you add more it will be tacked onto the end of that brigade. When * you retrieve data, if you pass in a bucket brigade to the get function, * it will append the current brigade onto the one that you are retrieving. */ /** * prepare a bucket brigade to be setaside. If a different brigade was * set-aside earlier, then the two brigades are concatenated together. * @param f The current filter * @param save_to The brigade that was previously set-aside. Regardless, the * new bucket brigade is returned in this location. * @param b The bucket brigade to save aside. This brigade is always empty * on return * @param p Ensure that all data in the brigade lives as long as this pool */ AP_DECLARE(apr_status_t) ap_save_brigade(ap_filter_t *f, apr_bucket_brigade **save_to, apr_bucket_brigade **b, apr_pool_t *p); /** * Flush function for apr_brigade_* calls. This calls ap_pass_brigade * to flush the brigade if the brigade buffer overflows. * @param bb The brigade to flush * @param ctx The filter to pass the brigade to * @note this function has nothing to do with FLUSH buckets. It is simply * a way to flush content out of a brigade and down a filter stack. */ AP_DECLARE_NONSTD(apr_status_t) ap_filter_flush(apr_bucket_brigade *bb, void *ctx); /** * Flush the current brigade down the filter stack. * @param f The filter we are passing to * @param bb The brigade to flush */ AP_DECLARE(apr_status_t) ap_fflush(ap_filter_t *f, apr_bucket_brigade *bb); /** * Write a buffer for the current filter, buffering if possible. * @param f the filter we are writing to * @param bb The brigade to buffer into * @param data The data to write * @param nbyte The number of bytes in the data */ #define ap_fwrite(f, bb, data, nbyte) \ apr_brigade_write(bb, ap_filter_flush, f, data, nbyte) /** * Write a buffer for the current filter, buffering if possible. * @param f the filter we are writing to * @param bb The brigade to buffer into * @param str The string to write */ #define ap_fputs(f, bb, str) \ apr_brigade_write(bb, ap_filter_flush, f, str, strlen(str)) /** * Write a character for the current filter, buffering if possible. * @param f the filter we are writing to * @param bb The brigade to buffer into * @param c The character to write */ #define ap_fputc(f, bb, c) \ apr_brigade_putc(bb, ap_filter_flush, f, c) /** * Write an unspecified number of strings to the current filter * @param f the filter we are writing to * @param bb The brigade to buffer into * @param ... The strings to write */ AP_DECLARE_NONSTD(apr_status_t) ap_fputstrs(ap_filter_t *f, apr_bucket_brigade *bb, ...) AP_FN_ATTR_SENTINEL; /** * Output data to the filter in printf format * @param f the filter we are writing to * @param bb The brigade to buffer into * @param fmt The format string * @param ... The arguments to use to fill out the format string */ AP_DECLARE_NONSTD(apr_status_t) ap_fprintf(ap_filter_t *f, apr_bucket_brigade *bb, const char *fmt, ...) __attribute__((format(printf,3,4))); /** * set protocol requirements for an output content filter * (only works with AP_FTYPE_RESOURCE and AP_FTYPE_CONTENT_SET) * @param f the filter in question * @param proto_flags Logical OR of AP_FILTER_PROTO_* bits */ AP_DECLARE(void) ap_filter_protocol(ap_filter_t* f, unsigned int proto_flags); /** Filter changes contents (so invalidating checksums/etc) */ #define AP_FILTER_PROTO_CHANGE 0x1 /** Filter changes length of contents (so invalidating content-length/etc) */ #define AP_FILTER_PROTO_CHANGE_LENGTH 0x2 /** Filter requires complete input and can't work on byteranges */ #define AP_FILTER_PROTO_NO_BYTERANGE 0x4 /** Filter should not run in a proxy */ #define AP_FILTER_PROTO_NO_PROXY 0x8 /** Filter makes output non-cacheable */ #define AP_FILTER_PROTO_NO_CACHE 0x10 /** Filter is incompatible with "Cache-Control: no-transform" */ #define AP_FILTER_PROTO_TRANSFORM 0x20 /** * @} */ #ifdef __cplusplus } #endif #endif /* !AP_FILTER_H */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_xml.h * @brief Apache XML library * * @defgroup APACHE_CORE_XML XML Library * @ingroup APACHE_CORE * @{ */ #ifndef UTIL_XML_H #define UTIL_XML_H #include "apr_xml.h" #include "httpd.h" #ifdef __cplusplus extern "C" { #endif /** * Get XML post data and parse it. * @param r The current request * @param pdoc The XML post data * @return HTTP status code */ AP_DECLARE(int) ap_xml_parse_input(request_rec *r, apr_xml_doc **pdoc); #ifdef __cplusplus } #endif #endif /* UTIL_XML_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_ebcdic.h * @brief Utilities for EBCDIC conversion * * @defgroup APACHE_CORE_EBCDIC Utilities for EBCDIC conversion * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_UTIL_EBCDIC_H #define APACHE_UTIL_EBCDIC_H #ifdef __cplusplus extern "C" { #endif #include "apr_xlate.h" #include "httpd.h" #include "util_charset.h" #if APR_CHARSET_EBCDIC || defined(DOXYGEN) /** * Setup all of the global translation handlers. * @param pool The pool to allocate out of. * @note On non-EBCDIC system, this function does <b>not</b> exist. * So, its use should be guarded by \#if APR_CHARSET_EBCDIC. */ apr_status_t ap_init_ebcdic(apr_pool_t *pool); /** * Convert protocol data from the implementation character * set to ASCII. * @param buffer Buffer to translate. * @param len Number of bytes to translate. * @note On non-EBCDIC system, this function is replaced by an * empty macro. */ void ap_xlate_proto_to_ascii(char *buffer, apr_size_t len); /** * Convert protocol data to the implementation character * set from ASCII. * @param buffer Buffer to translate. * @param len Number of bytes to translate. * @note On non-EBCDIC system, this function is replaced by an * empty macro. */ void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len); /** * Convert protocol data from the implementation character * set to ASCII, then send it. * @param r The current request. * @param ... The strings to write, followed by a NULL pointer. * @note On non-EBCDIC system, this function is replaced by a call to * #ap_rvputs. */ int ap_rvputs_proto_in_ascii(request_rec *r, ...); #else /* APR_CHARSET_EBCDIC */ #define ap_xlate_proto_to_ascii(x,y) /* NOOP */ #define ap_xlate_proto_from_ascii(x,y) /* NOOP */ #define ap_rvputs_proto_in_ascii ap_rvputs #endif /* APR_CHARSET_EBCDIC */ #ifdef __cplusplus } #endif #endif /* !APACHE_UTIL_EBCDIC_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* The purpose of this file is to store the code that MOST mpm's will need * this does not mean a function only goes into this file if every MPM needs * it. It means that if a function is needed by more than one MPM, and * future maintenance would be served by making the code common, then the * function belongs here. * * This is going in src/main because it is not platform specific, it is * specific to multi-process servers, but NOT to Unix. Which is why it * does not belong in src/os/unix */ /** * @file mpm_common.h * @brief Multi-Processing Modules functions * * @defgroup APACHE_MPM Multi-Processing Modules * @ingroup APACHE * @{ */ #ifndef APACHE_MPM_COMMON_H #define APACHE_MPM_COMMON_H #include "ap_config.h" #include "ap_mpm.h" #include "scoreboard.h" #if APR_HAVE_NETINET_TCP_H #include <netinet/tcp.h> /* for TCP_NODELAY */ #endif #include "apr_proc_mutex.h" #ifdef __cplusplus extern "C" { #endif /* The maximum length of the queue of pending connections, as defined * by listen(2). Under some systems, it should be increased if you * are experiencing a heavy TCP SYN flood attack. * * It defaults to 511 instead of 512 because some systems store it * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is * 255 when truncated. */ #ifndef DEFAULT_LISTENBACKLOG #define DEFAULT_LISTENBACKLOG 511 #endif /* * Define the default value set for the socket option TCP_DEFER_ACCEPT * if it is set. */ #ifndef DEFAULT_TCP_DEFER_ACCEPT #define DEFAULT_TCP_DEFER_ACCEPT 30 #endif /* Signal used to gracefully restart */ #define AP_SIG_GRACEFUL SIGUSR1 /* Signal used to gracefully restart (without SIG prefix) */ #define AP_SIG_GRACEFUL_SHORT USR1 /* Signal used to gracefully restart (as a quoted string) */ #define AP_SIG_GRACEFUL_STRING "SIGUSR1" /* Signal used to gracefully stop */ #define AP_SIG_GRACEFUL_STOP SIGWINCH /* Signal used to gracefully stop (without SIG prefix) */ #define AP_SIG_GRACEFUL_STOP_SHORT WINCH /* Signal used to gracefully stop (as a quoted string) */ #define AP_SIG_GRACEFUL_STOP_STRING "SIGWINCH" /** * Callback function used for ap_reclaim_child_processes() and * ap_relieve_child_processes(). The callback function will be * called for each terminated child process. */ typedef void ap_reclaim_callback_fn_t(int childnum, pid_t pid, ap_generation_t gen); #if (!defined(WIN32) && !defined(NETWARE)) || defined(DOXYGEN) /** * Make sure all child processes that have been spawned by the parent process * have died. This includes process registered as "other_children". * * @param terminate Either 1 or 0. If 1, send the child processes SIGTERM * each time through the loop. If 0, give the process time to die * on its own before signalling it. * @param mpm_callback Callback invoked for each dead child process * * @note The MPM child processes which are reclaimed are those listed * in the scoreboard as well as those currently registered via * ap_register_extra_mpm_process(). */ AP_DECLARE(void) ap_reclaim_child_processes(int terminate, ap_reclaim_callback_fn_t *mpm_callback); /** * Catch any child processes that have been spawned by the parent process * which have exited. This includes processes registered as "other_children". * * @param mpm_callback Callback invoked for each dead child process * @note The MPM child processes which are relieved are those listed * in the scoreboard as well as those currently registered via * ap_register_extra_mpm_process(). */ AP_DECLARE(void) ap_relieve_child_processes(ap_reclaim_callback_fn_t *mpm_callback); /** * Tell ap_reclaim_child_processes() and ap_relieve_child_processes() about * an MPM child process which has no entry in the scoreboard. * @param pid The process id of an MPM child process which should be * reclaimed when ap_reclaim_child_processes() is called. * @param gen The generation of this MPM child process. * * @note If an extra MPM child process terminates prior to calling * ap_reclaim_child_processes(), remove it from the list of such processes * by calling ap_unregister_extra_mpm_process(). */ AP_DECLARE(void) ap_register_extra_mpm_process(pid_t pid, ap_generation_t gen); /** * Unregister an MPM child process which was previously registered by a * call to ap_register_extra_mpm_process(). * @param pid The process id of an MPM child process which no longer needs to * be reclaimed. * @param old_gen Set to the server generation of the process, if found. * @return 1 if the process was found and removed, 0 otherwise */ AP_DECLARE(int) ap_unregister_extra_mpm_process(pid_t pid, ap_generation_t *old_gen); /** * Safely signal an MPM child process, if the process is in the * current process group. Otherwise fail. * @param pid the process id of a child process to signal * @param sig the signal number to send * @return APR_SUCCESS if signal is sent, otherwise an error as per kill(3); * APR_EINVAL is returned if passed either an invalid (< 1) pid, or if * the pid is not in the current process group */ AP_DECLARE(apr_status_t) ap_mpm_safe_kill(pid_t pid, int sig); /** * Log why a child died to the error log, if the child died without the * parent signalling it. * @param pid The child that has died * @param why The return code of the child process * @param status The status returned from ap_wait_or_timeout * @return 0 on success, APEXIT_CHILDFATAL if MPM should terminate */ AP_DECLARE(int) ap_process_child_status(apr_proc_t *pid, apr_exit_why_e why, int status); AP_DECLARE(apr_status_t) ap_fatal_signal_setup(server_rec *s, apr_pool_t *in_pconf); AP_DECLARE(apr_status_t) ap_fatal_signal_child_setup(server_rec *s); #endif /* (!WIN32 && !NETWARE) || DOXYGEN */ /** * Pool cleanup for end-generation hook implementation * (core httpd function) */ apr_status_t ap_mpm_end_gen_helper(void *unused); /** * Run the monitor hook (once every ten calls), determine if any child * process has died and, if none died, sleep one second. * @param status The return code if a process has died * @param exitcode The returned exit status of the child, if a child process * dies, or the signal that caused the child to die. * @param ret The process id of the process that died * @param p The pool to allocate out of * @param s The server_rec to pass */ AP_DECLARE(void) ap_wait_or_timeout(apr_exit_why_e *status, int *exitcode, apr_proc_t *ret, apr_pool_t *p, server_rec *s); #if defined(TCP_NODELAY) /** * Turn off the nagle algorithm for the specified socket. The nagle algorithm * says that we should delay sending partial packets in the hopes of getting * more data. There are bad interactions between persistent connections and * Nagle's algorithm that have severe performance penalties. * @param s The socket to disable nagle for. */ void ap_sock_disable_nagle(apr_socket_t *s); #else #define ap_sock_disable_nagle(s) /* NOOP */ #endif #ifdef HAVE_GETPWNAM /** * Convert a username to a numeric ID * @param name The name to convert * @return The user id corresponding to a name * @fn uid_t ap_uname2id(const char *name) */ AP_DECLARE(uid_t) ap_uname2id(const char *name); #endif #ifdef HAVE_GETGRNAM /** * Convert a group name to a numeric ID * @param name The name to convert * @return The group id corresponding to a name * @fn gid_t ap_gname2id(const char *name) */ AP_DECLARE(gid_t) ap_gname2id(const char *name); #endif #ifndef HAVE_INITGROUPS /** * The initgroups() function initializes the group access list by reading the * group database /etc/group and using all groups of which user is a member. * The additional group basegid is also added to the list. * @param name The user name - must be non-NULL * @param basegid The basegid to add * @return returns 0 on success * @fn int initgroups(const char *name, gid_t basegid) */ int initgroups(const char *name, gid_t basegid); #endif #if (!defined(WIN32) && !defined(NETWARE)) || defined(DOXYGEN) typedef struct ap_pod_t ap_pod_t; struct ap_pod_t { apr_file_t *pod_in; apr_file_t *pod_out; apr_pool_t *p; }; /** * Open the pipe-of-death. The pipe of death is used to tell all child * processes that it is time to die gracefully. * @param p The pool to use for allocating the pipe * @param pod the pipe-of-death that is created. */ AP_DECLARE(apr_status_t) ap_mpm_pod_open(apr_pool_t *p, ap_pod_t **pod); /** * Check the pipe to determine if the process has been signalled to die. */ AP_DECLARE(apr_status_t) ap_mpm_pod_check(ap_pod_t *pod); /** * Close the pipe-of-death * * @param pod the pipe-of-death to close. */ AP_DECLARE(apr_status_t) ap_mpm_pod_close(ap_pod_t *pod); /** * Write data to the pipe-of-death, signalling that one child process * should die. * @param pod the pipe-of-death to write to. */ AP_DECLARE(apr_status_t) ap_mpm_pod_signal(ap_pod_t *pod); /** * Write data to the pipe-of-death, signalling that all child process * should die. * @param pod The pipe-of-death to write to. * @param num The number of child processes to kill */ AP_DECLARE(void) ap_mpm_pod_killpg(ap_pod_t *pod, int num); #define AP_MPM_PODX_RESTART_CHAR '$' #define AP_MPM_PODX_GRACEFUL_CHAR '!' typedef enum { AP_MPM_PODX_NORESTART, AP_MPM_PODX_RESTART, AP_MPM_PODX_GRACEFUL } ap_podx_restart_t; /** * Open the extended pipe-of-death. * @param p The pool to use for allocating the pipe * @param pod The pipe-of-death that is created. */ AP_DECLARE(apr_status_t) ap_mpm_podx_open(apr_pool_t *p, ap_pod_t **pod); /** * Check the extended pipe to determine if the process has been signalled to die. */ AP_DECLARE(int) ap_mpm_podx_check(ap_pod_t *pod); /** * Close the pipe-of-death * * @param pod The pipe-of-death to close. */ AP_DECLARE(apr_status_t) ap_mpm_podx_close(ap_pod_t *pod); /** * Write data to the extended pipe-of-death, signalling that one child process * should die. * @param pod the pipe-of-death to write to. * @param graceful restart-type */ AP_DECLARE(apr_status_t) ap_mpm_podx_signal(ap_pod_t *pod, ap_podx_restart_t graceful); /** * Write data to the extended pipe-of-death, signalling that all child process * should die. * @param pod The pipe-of-death to write to. * @param num The number of child processes to kill * @param graceful restart-type */ AP_DECLARE(void) ap_mpm_podx_killpg(ap_pod_t *pod, int num, ap_podx_restart_t graceful); #endif /* (!WIN32 && !NETWARE) || DOXYGEN */ /** * Check that exactly one MPM is loaded * Returns NULL if yes, error string if not. */ AP_DECLARE(const char *) ap_check_mpm(void); /* * These data members are common to all mpms. Each new mpm * should either use the appropriate ap_mpm_set_* function * in their command table or create their own for custom or * OS specific needs. These should work for most. */ /** * The maximum number of requests each child thread or * process handles before dying off */ AP_DECLARE_DATA extern int ap_max_requests_per_child; const char *ap_mpm_set_max_requests(cmd_parms *cmd, void *dummy, const char *arg); /** * The filename used to store the process id. */ AP_DECLARE_DATA extern const char *ap_pid_fname; const char *ap_mpm_set_pidfile(cmd_parms *cmd, void *dummy, const char *arg); void ap_mpm_dump_pidfile(apr_pool_t *p, apr_file_t *out); /* * The directory that the server changes directory to dump core. */ AP_DECLARE_DATA extern char ap_coredump_dir[MAX_STRING_LEN]; AP_DECLARE_DATA extern int ap_coredumpdir_configured; const char *ap_mpm_set_coredumpdir(cmd_parms *cmd, void *dummy, const char *arg); /** * Set the timeout period for a graceful shutdown. */ AP_DECLARE_DATA extern int ap_graceful_shutdown_timeout; AP_DECLARE(const char *)ap_mpm_set_graceful_shutdown(cmd_parms *cmd, void *dummy, const char *arg); #define AP_GRACEFUL_SHUTDOWN_TIMEOUT_COMMAND \ AP_INIT_TAKE1("GracefulShutdownTimeout", ap_mpm_set_graceful_shutdown, NULL, \ RSRC_CONF, "Maximum time in seconds to wait for child " \ "processes to complete transactions during shutdown") int ap_signal_server(int *, apr_pool_t *); void ap_mpm_rewrite_args(process_rec *); AP_DECLARE_DATA extern apr_uint32_t ap_max_mem_free; extern const char *ap_mpm_set_max_mem_free(cmd_parms *cmd, void *dummy, const char *arg); AP_DECLARE_DATA extern apr_size_t ap_thread_stacksize; extern const char *ap_mpm_set_thread_stacksize(cmd_parms *cmd, void *dummy, const char *arg); /* core's implementation of child_status hook */ extern void ap_core_child_status(server_rec *s, pid_t pid, ap_generation_t gen, int slot, mpm_child_status status); #if defined(AP_ENABLE_EXCEPTION_HOOK) && AP_ENABLE_EXCEPTION_HOOK extern const char *ap_mpm_set_exception_hook(cmd_parms *cmd, void *dummy, const char *arg); #endif AP_DECLARE_HOOK(int,monitor,(apr_pool_t *p, server_rec *s)) /* register modules that undertake to manage system security */ AP_DECLARE(int) ap_sys_privileges_handlers(int inc); AP_DECLARE_HOOK(int, drop_privileges, (apr_pool_t * pchild, server_rec * s)) /* implement the ap_mpm_query() function * The MPM should return OK+APR_ENOTIMPL for any unimplemented query codes; * modules which intercede for specific query codes should DECLINE for others. */ AP_DECLARE_HOOK(int, mpm_query, (int query_code, int *result, apr_status_t *rv)) /* register the specified callback */ AP_DECLARE_HOOK(apr_status_t, mpm_register_timed_callback, (apr_time_t t, ap_mpm_callback_fn_t *cbfn, void *baton)) /* get MPM name (e.g., "prefork" or "event") */ AP_DECLARE_HOOK(const char *,mpm_get_name,(void)) /** * Notification that connection handling is suspending (disassociating from the * current thread) * @param c The current connection * @param r The current request, or NULL if there is no active request * @ingroup hooks * @see ap_hook_resume_connection * @note This hook is not implemented by MPMs like Prefork and Worker which * handle all processing of a particular connection on the same thread. * @note This hook will be called on the thread that was previously * processing the connection. * @note This hook is not called at the end of connection processing. This * hook only notifies a module when processing of an active connection is * suspended. * @note Resumption and subsequent suspension of a connection solely to perform * I/O by the MPM, with no execution of non-MPM code, may not necessarily result * in a call to this hook. */ AP_DECLARE_HOOK(void, suspend_connection, (conn_rec *c, request_rec *r)) /** * Notification that connection handling is resuming (associating with a thread) * @param c The current connection * @param r The current request, or NULL if there is no active request * @ingroup hooks * @see ap_hook_suspend_connection * @note This hook is not implemented by MPMs like Prefork and Worker which * handle all processing of a particular connection on the same thread. * @note This hook will be called on the thread that will resume processing * the connection. * @note This hook is not called at the beginning of connection processing. * This hook only notifies a module when processing resumes for a * previously-suspended connection. * @note Resumption and subsequent suspension of a connection solely to perform * I/O by the MPM, with no execution of non-MPM code, may not necessarily result * in a call to this hook. */ AP_DECLARE_HOOK(void, resume_connection, (conn_rec *c, request_rec *r)) /** * Notification that the child is stopping. If graceful, ongoing * requests will be served. * @param pchild The child pool * @param graceful != 0 iff this is a graceful shutdown. */ AP_DECLARE_HOOK(void, child_stopping, (apr_pool_t *pchild, int graceful)) /* mutex type string for accept mutex, if any; MPMs should use the * same mutex type for ease of configuration */ #define AP_ACCEPT_MUTEX_TYPE "mpm-accept" /* internal pre-config logic for MPM-related settings, callable only from * core's pre-config hook */ void mpm_common_pre_config(apr_pool_t *pconf); #ifdef __cplusplus } #endif #endif /* !APACHE_MPM_COMMON_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MOD_XML2ENC #define MOD_XML2ENC #define ENCIO_INPUT 0x01 #define ENCIO_OUTPUT 0x02 #define ENCIO_INPUT_CHECKS 0x04 #define ENCIO (ENCIO_INPUT|ENCIO_OUTPUT|ENCIO_INPUT_CHECKS) #define ENCIO_SKIPTO 0x10 /* declarations to deal with WIN32 compile-flag-in-source-code crap */ #if !defined(WIN32) #define XML2ENC_DECLARE(type) type #define XML2ENC_DECLARE_NONSTD(type) type #define XML2ENC_DECLARE_DATA #elif defined(XML2ENC_DECLARE_STATIC) #define XML2ENC_DECLARE(type) type __stdcall #define XML2ENC_DECLARE_NONSTD(type) type #define XML2ENC_DECLARE_DATA #elif defined(XML2ENC_DECLARE_EXPORT) #define XML2ENC_DECLARE(type) __declspec(dllexport) type __stdcall #define XML2ENC_DECLARE_NONSTD(type) __declspec(dllexport) type #define XML2ENC_DECLARE_DATA __declspec(dllexport) #else #define XML2ENC_DECLARE(type) __declspec(dllimport) type __stdcall #define XML2ENC_DECLARE_NONSTD(type) __declspec(dllimport) type #define XML2ENC_DECLARE_DATA __declspec(dllimport) #endif APR_DECLARE_OPTIONAL_FN(apr_status_t, xml2enc_charset, (request_rec* r, xmlCharEncoding* enc, const char** cenc)); APR_DECLARE_OPTIONAL_FN(apr_status_t, xml2enc_filter, (request_rec* r, const char* enc, unsigned int mode)); APR_DECLARE_EXTERNAL_HOOK(xml2enc, XML2ENC, int, preprocess, (ap_filter_t *f, char** bufp, apr_size_t* bytesp)) #endif /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_cfgtree.h * @brief Config Tree Package * * @defgroup APACHE_CORE_CONFIG_TREE Config Tree Package * @ingroup APACHE_CORE_CONFIG * @{ */ #ifndef AP_CONFTREE_H #define AP_CONFTREE_H #include "ap_config.h" #ifdef __cplusplus extern "C" { #endif typedef struct ap_directive_t ap_directive_t; /** * @brief Structure used to build the config tree. * * The config tree only stores * the directives that will be active in the running server. Directives * that contain other directions, such as <Directory ...> cause a sub-level * to be created, where the included directives are stored. The closing * directive (</Directory>) is not stored in the tree. */ struct ap_directive_t { /** The current directive */ const char *directive; /** The arguments for the current directive, stored as a space * separated list */ const char *args; /** The next directive node in the tree */ struct ap_directive_t *next; /** The first child node of this directive */ struct ap_directive_t *first_child; /** The parent node of this directive */ struct ap_directive_t *parent; /** directive's module can store add'l data here */ void *data; /* ### these may go away in the future, but are needed for now */ /** The name of the file this directive was found in */ const char *filename; /** The line number the directive was on */ int line_num; /** A short-cut towards the last directive node in the tree. * The value may not always be up-to-date but it always points to * somewhere in the tree, nearer to the tail. * This value is only set in the first node */ struct ap_directive_t *last; }; /** * The root of the configuration tree */ AP_DECLARE_DATA extern ap_directive_t *ap_conftree; /** * Add a node to the configuration tree. * @param parent The current parent node. If the added node is a first_child, then this is changed to the current node * @param current The current node * @param toadd The node to add to the tree * @param child Is the node to add a child node * @return the added node */ ap_directive_t *ap_add_node(ap_directive_t **parent, ap_directive_t *current, ap_directive_t *toadd, int child); #ifdef __cplusplus } #endif #endif /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef MOD_PROXY_H #define MOD_PROXY_H /** * @file mod_proxy.h * @brief Proxy Extension Module for Apache * * @defgroup MOD_PROXY mod_proxy * @ingroup APACHE_MODS * @{ */ #include "apr_hooks.h" #include "apr_optional.h" #include "apr.h" #include "apr_lib.h" #include "apr_strings.h" #include "apr_buckets.h" #include "apr_md5.h" #include "apr_network_io.h" #include "apr_pools.h" #include "apr_strings.h" #include "apr_uri.h" #include "apr_date.h" #include "apr_strmatch.h" #include "apr_fnmatch.h" #include "apr_reslist.h" #define APR_WANT_STRFUNC #include "apr_want.h" #include "apr_uuid.h" #include "util_mutex.h" #include "apr_global_mutex.h" #include "apr_thread_mutex.h" #include "httpd.h" #include "http_config.h" #include "ap_config.h" #include "http_core.h" #include "http_protocol.h" #include "http_request.h" #include "http_vhost.h" #include "http_main.h" #include "http_log.h" #include "http_connection.h" #include "http_ssl.h" #include "util_filter.h" #include "util_ebcdic.h" #include "ap_provider.h" #include "ap_slotmem.h" #if APR_HAVE_NETINET_IN_H #include <netinet/in.h> #endif #if APR_HAVE_ARPA_INET_H #include <arpa/inet.h> #endif /* for proxy_canonenc() */ enum enctype { enc_path, enc_search, enc_user, enc_fpath, enc_parm }; /* Flags for ap_proxy_canonenc_ex */ #define PROXY_CANONENC_FORCEDEC 0x01 #define PROXY_CANONENC_NOENCODEDSLASHENCODING 0x02 typedef enum { NONE, TCP, OPTIONS, HEAD, GET, CPING, PROVIDER, OPTIONS11, HEAD11, GET11, EOT } hcmethod_t; typedef struct { hcmethod_t method; char *name; int implemented; } proxy_hcmethods_t; typedef struct { unsigned int bit; char flag; const char *name; } proxy_wstat_t; #define BALANCER_PREFIX "balancer://" #if APR_CHARSET_EBCDIC #define CRLF "\r\n" #else /*APR_CHARSET_EBCDIC*/ #define CRLF "\015\012" #endif /*APR_CHARSET_EBCDIC*/ /* default Max-Forwards header setting */ /* Set this to -1, which complies with RFC2616 by not setting * max-forwards if the client didn't send it to us. */ #define DEFAULT_MAX_FORWARDS -1 typedef struct proxy_balancer proxy_balancer; typedef struct proxy_worker proxy_worker; typedef struct proxy_conn_pool proxy_conn_pool; typedef struct proxy_balancer_method proxy_balancer_method; /* static information about a remote proxy */ struct proxy_remote { const char *scheme; /* the schemes handled by this proxy, or '*' */ const char *protocol; /* the scheme used to talk to this proxy */ const char *hostname; /* the hostname of this proxy */ ap_regex_t *regexp; /* compiled regex (if any) for the remote */ const char *creds; /* auth credentials (if any) for the proxy */ int use_regex; /* simple boolean. True if we have a regex pattern */ apr_port_t port; /* the port for this proxy */ }; #define PROXYPASS_NOCANON 0x01 #define PROXYPASS_INTERPOLATE 0x02 #define PROXYPASS_NOQUERY 0x04 #define PROXYPASS_MAP_ENCODED 0x08 #define PROXYPASS_MAP_SERVLET 0x18 /* + MAP_ENCODED */ struct proxy_alias { const char *real; const char *fake; ap_regex_t *regex; unsigned int flags; proxy_balancer *balancer; /* only valid for reverse-proxys */ }; struct dirconn_entry { char *name; struct in_addr addr, mask; struct apr_sockaddr_t *hostaddr; int (*matcher) (struct dirconn_entry * This, request_rec *r); }; struct noproxy_entry { const char *name; struct apr_sockaddr_t *addr; }; typedef struct { apr_array_header_t *proxies; apr_array_header_t *sec_proxy; apr_array_header_t *aliases; apr_array_header_t *noproxies; apr_array_header_t *dirconn; apr_array_header_t *workers; /* non-balancer workers, eg ProxyPass http://example.com */ apr_array_header_t *balancers; /* list of balancers @ config time */ proxy_worker *forward; /* forward proxy worker */ proxy_worker *reverse; /* reverse "module-driven" proxy worker */ const char *domain; /* domain name to use in absence of a domain name in the request */ const char *id; apr_pool_t *pool; /* Pool used for allocating this struct's elements */ int req; /* true if proxy requests are enabled */ int max_balancers; /* maximum number of allowed balancers */ int bgrowth; /* number of post-config balancers can added */ enum { via_off, via_on, via_block, via_full } viaopt; /* how to deal with proxy Via: headers */ apr_size_t recv_buffer_size; apr_size_t io_buffer_size; long maxfwd; apr_interval_time_t timeout; enum { bad_error, bad_ignore, bad_body } badopt; /* how to deal with bad headers */ enum { status_off, status_on, status_full } proxy_status; /* Status display options */ apr_sockaddr_t *source_address; apr_global_mutex_t *mutex; /* global lock, for pool, etc */ ap_slotmem_instance_t *bslot; /* balancers shm data - runtime */ ap_slotmem_provider_t *storage; unsigned int req_set:1; unsigned int viaopt_set:1; unsigned int recv_buffer_size_set:1; unsigned int io_buffer_size_set:1; unsigned int maxfwd_set:1; unsigned int timeout_set:1; unsigned int badopt_set:1; unsigned int proxy_status_set:1; unsigned int source_address_set:1; unsigned int bgrowth_set:1; unsigned int bal_persist:1; unsigned int inherit:1; unsigned int inherit_set:1; unsigned int ppinherit:1; unsigned int ppinherit_set:1; unsigned int map_encoded_one:1; unsigned int map_encoded_all:1; } proxy_server_conf; typedef struct { const char *p; /* The path */ ap_regex_t *r; /* Is this a regex? */ /* FIXME * ProxyPassReverse and friends are documented as working inside * <Location>. But in fact they never have done in the case of * more than one <Location>, because the server_conf can't see it. * We need to move them to the per-dir config. * Discussed in February 2005: * http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=110726027118798&w=2 */ apr_array_header_t *raliases; apr_array_header_t* cookie_paths; apr_array_header_t* cookie_domains; signed char p_is_fnmatch; /* Is the path an fnmatch candidate? */ signed char interpolate_env; struct proxy_alias *alias; /** * the following setting masks the error page * returned from the 'proxied server' and just * forwards the status code upwards. * This allows the main server (us) to generate * the error page, (so it will look like a error * returned from the rest of the system */ unsigned int error_override:1; unsigned int preserve_host:1; unsigned int preserve_host_set:1; unsigned int error_override_set:1; unsigned int alias_set:1; unsigned int add_forwarded_headers:1; unsigned int add_forwarded_headers_set:1; /** Named back references */ apr_array_header_t *refs; unsigned int forward_100_continue:1; unsigned int forward_100_continue_set:1; apr_array_header_t *error_override_codes; } proxy_dir_conf; /* if we interpolate env vars per-request, we'll need a per-request * copy of the reverse proxy config */ typedef struct { apr_array_header_t *raliases; apr_array_header_t* cookie_paths; apr_array_header_t* cookie_domains; } proxy_req_conf; struct proxy_address; /* opaque TTL'ed and refcount'ed address */ typedef struct { conn_rec *connection; request_rec *r; /* Request record of the backend request * that is used over the backend connection. */ proxy_worker *worker; /* Connection pool this connection belongs to */ apr_pool_t *pool; /* Subpool for hostname and addr data */ const char *hostname; apr_sockaddr_t *addr; /* Preparsed remote address info */ apr_pool_t *scpool; /* Subpool used for socket and connection data */ apr_socket_t *sock; /* Connection socket */ void *data; /* per scheme connection data */ void *forward; /* opaque forward proxy data */ apr_uint32_t flags; /* Connection flags */ apr_port_t port; unsigned int is_ssl:1; unsigned int close:1; /* Close 'this' connection */ unsigned int need_flush:1; /* Flag to decide whether we need to flush the * filter chain or not */ unsigned int inreslist:1; /* connection in apr_reslist? */ const char *uds_path; /* Unix domain socket path */ const char *ssl_hostname;/* Hostname (SNI) in use by SSL connection */ apr_bucket_brigade *tmp_bb;/* Temporary brigade created with the connection * and its scpool/bucket_alloc (NULL before), * must be left cleaned when used (locally). */ apr_pool_t *uds_pool; /* Subpool for reusing UDS paths */ apr_pool_t *fwd_pool; /* Subpool for reusing ProxyRemote infos */ struct proxy_address *address; /* Current remote address */ } proxy_conn_rec; typedef struct { float cache_completion; /* completion percentage */ int content_length; /* length of the content */ } proxy_completion; /* Connection pool */ struct proxy_conn_pool { apr_pool_t *pool; /* The pool used in constructor and destructor calls */ apr_sockaddr_t *addr; /* Preparsed remote address info */ apr_reslist_t *res; /* Connection resource list */ proxy_conn_rec *conn; /* Single connection for prefork mpm */ apr_pool_t *dns_pool; /* The pool used for worker scoped DNS resolutions */ }; #define AP_VOLATILIZE_T(T, x) (*(T volatile *)&(x)) /* worker status bits */ /* * NOTE: Keep up-to-date w/ proxy_wstat_tbl[] * in mod_proxy.c ! */ #define PROXY_WORKER_INITIALIZED 0x0001 #define PROXY_WORKER_IGNORE_ERRORS 0x0002 #define PROXY_WORKER_DRAIN 0x0004 #define PROXY_WORKER_GENERIC 0x0008 #define PROXY_WORKER_IN_SHUTDOWN 0x0010 #define PROXY_WORKER_DISABLED 0x0020 #define PROXY_WORKER_STOPPED 0x0040 #define PROXY_WORKER_IN_ERROR 0x0080 #define PROXY_WORKER_HOT_STANDBY 0x0100 #define PROXY_WORKER_FREE 0x0200 #define PROXY_WORKER_HC_FAIL 0x0400 #define PROXY_WORKER_HOT_SPARE 0x0800 /* worker status flags */ #define PROXY_WORKER_INITIALIZED_FLAG 'O' #define PROXY_WORKER_IGNORE_ERRORS_FLAG 'I' #define PROXY_WORKER_DRAIN_FLAG 'N' #define PROXY_WORKER_GENERIC_FLAG 'G' #define PROXY_WORKER_IN_SHUTDOWN_FLAG 'U' #define PROXY_WORKER_DISABLED_FLAG 'D' #define PROXY_WORKER_STOPPED_FLAG 'S' #define PROXY_WORKER_IN_ERROR_FLAG 'E' #define PROXY_WORKER_HOT_STANDBY_FLAG 'H' #define PROXY_WORKER_FREE_FLAG 'F' #define PROXY_WORKER_HC_FAIL_FLAG 'C' #define PROXY_WORKER_HOT_SPARE_FLAG 'R' #define PROXY_WORKER_NOT_USABLE_BITMAP ( PROXY_WORKER_IN_SHUTDOWN | \ PROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR | \ PROXY_WORKER_HC_FAIL ) /* NOTE: these check the shared status */ #define PROXY_WORKER_IS_INITIALIZED(f) ( (f)->s->status & PROXY_WORKER_INITIALIZED ) #define PROXY_WORKER_IS_STANDBY(f) ( (f)->s->status & PROXY_WORKER_HOT_STANDBY ) #define PROXY_WORKER_IS_SPARE(f) ( (f)->s->status & PROXY_WORKER_HOT_SPARE ) #define PROXY_WORKER_IS_USABLE(f) ( ( !( (f)->s->status & PROXY_WORKER_NOT_USABLE_BITMAP) ) && \ PROXY_WORKER_IS_INITIALIZED(f) ) #define PROXY_WORKER_IS_DRAINING(f) ( (f)->s->status & PROXY_WORKER_DRAIN ) #define PROXY_WORKER_IS_GENERIC(f) ( (f)->s->status & PROXY_WORKER_GENERIC ) #define PROXY_WORKER_IS_HCFAILED(f) ( (f)->s->status & PROXY_WORKER_HC_FAIL ) #define PROXY_WORKER_IS_ERROR(f) ( (f)->s->status & PROXY_WORKER_IN_ERROR ) #define PROXY_WORKER_IS(f, b) ( (f)->s->status & (b) ) /* default worker retry timeout in seconds */ #define PROXY_WORKER_DEFAULT_RETRY 60 /* Some max char string sizes, for shm fields */ #define PROXY_WORKER_MAX_SCHEME_SIZE 16 #define PROXY_WORKER_MAX_ROUTE_SIZE 64 #define PROXY_BALANCER_MAX_ROUTE_SIZE PROXY_WORKER_MAX_ROUTE_SIZE #define PROXY_WORKER_MAX_NAME_SIZE 96 #define PROXY_BALANCER_MAX_NAME_SIZE PROXY_WORKER_MAX_NAME_SIZE #define PROXY_WORKER_MAX_HOSTNAME_SIZE 64 #define PROXY_BALANCER_MAX_HOSTNAME_SIZE PROXY_WORKER_MAX_HOSTNAME_SIZE #define PROXY_BALANCER_MAX_STICKY_SIZE 64 #define PROXY_WORKER_MAX_SECRET_SIZE 64 #define PROXY_RFC1035_HOSTNAME_SIZE 256 #define PROXY_WORKER_EXT_NAME_SIZE 384 /* RFC-1035 mentions limits of 255 for host-names and 253 for domain-names, * dotted together(?) this would fit the below size (+ trailing NUL). */ #define PROXY_WORKER_RFC1035_NAME_SIZE 512 #define PROXY_MAX_PROVIDER_NAME_SIZE 16 #define PROXY_STRNCPY(dst, src) ap_proxy_strncpy((dst), (src), (sizeof(dst))) #define PROXY_COPY_CONF_PARAMS(w, c) \ do { \ (w)->s->timeout = (c)->timeout; \ (w)->s->timeout_set = (c)->timeout_set; \ (w)->s->recv_buffer_size = (c)->recv_buffer_size; \ (w)->s->recv_buffer_size_set = (c)->recv_buffer_size_set; \ (w)->s->io_buffer_size = (c)->io_buffer_size; \ (w)->s->io_buffer_size_set = (c)->io_buffer_size_set; \ } while (0) #define PROXY_SHOULD_PING_100_CONTINUE(w, r) \ ((w)->s->ping_timeout_set \ && (PROXYREQ_REVERSE == (r)->proxyreq) \ && ap_request_has_body((r))) #define PROXY_DO_100_CONTINUE(w, r) \ (PROXY_SHOULD_PING_100_CONTINUE(w, r) \ && !apr_table_get((r)->subprocess_env, "force-proxy-request-1.0")) /* use 2 hashes */ typedef struct { unsigned int def; unsigned int fnv; } proxy_hashes ; /* Runtime worker status information. Shared in scoreboard */ /* The addition of member uds_path in 2.4.7 was an incompatible API change. */ typedef struct { char name[PROXY_WORKER_MAX_NAME_SIZE]; char scheme[PROXY_WORKER_MAX_SCHEME_SIZE]; /* scheme to use ajp|http|https */ char hostname[PROXY_WORKER_MAX_HOSTNAME_SIZE]; /* remote backend address (deprecated, use hostname_ex below) */ char route[PROXY_WORKER_MAX_ROUTE_SIZE]; /* balancing route */ char redirect[PROXY_WORKER_MAX_ROUTE_SIZE]; /* temporary balancing redirection route */ char flusher[PROXY_WORKER_MAX_SCHEME_SIZE]; /* flush provider used by mod_proxy_fdpass */ char uds_path[PROXY_WORKER_MAX_NAME_SIZE]; /* path to worker's unix domain socket if applicable */ int lbset; /* load balancer cluster set */ int retries; /* number of retries on this worker */ int lbstatus; /* Current lbstatus */ int lbfactor; /* dynamic lbfactor */ int min; /* Desired minimum number of available connections */ int smax; /* Soft maximum on the total number of connections */ int hmax; /* Hard maximum on the total number of connections */ int flush_wait; /* poll wait time in microseconds if flush_auto */ int index; /* shm array index */ proxy_hashes hash; /* hash of worker name */ unsigned int status; /* worker status bitfield */ enum { flush_off, flush_on, flush_auto } flush_packets; /* control AJP flushing */ apr_time_t updated; /* timestamp of last update for dynamic workers, or queue-time of HC workers */ apr_time_t error_time; /* time of the last error */ apr_interval_time_t ttl; /* maximum amount of time in seconds a connection * may be available while exceeding the soft limit */ apr_interval_time_t retry; /* retry interval */ apr_interval_time_t timeout; /* connection timeout */ apr_interval_time_t acquire; /* acquire timeout when the maximum number of connections is exceeded */ apr_interval_time_t ping_timeout; apr_interval_time_t conn_timeout; apr_size_t recv_buffer_size; apr_size_t io_buffer_size; apr_size_t elected; /* Number of times the worker was elected */ apr_size_t busy; /* busyness factor */ apr_port_t port; apr_off_t transferred;/* Number of bytes transferred to remote */ apr_off_t read; /* Number of bytes read from remote */ void *context; /* general purpose storage */ unsigned int keepalive:1; unsigned int disablereuse:1; unsigned int is_address_reusable:1; unsigned int retry_set:1; unsigned int timeout_set:1; unsigned int acquire_set:1; unsigned int ping_timeout_set:1; unsigned int conn_timeout_set:1; unsigned int recv_buffer_size_set:1; unsigned int io_buffer_size_set:1; unsigned int keepalive_set:1; unsigned int disablereuse_set:1; unsigned int was_malloced:1; unsigned int is_name_matchable:1; char hcuri[PROXY_WORKER_MAX_ROUTE_SIZE]; /* health check uri */ char hcexpr[PROXY_WORKER_MAX_SCHEME_SIZE]; /* name of condition expr for health check */ int passes; /* number of successes for check to pass */ int pcount; /* current count of passes */ int fails; /* number of failures for check to fail */ int fcount; /* current count of failures */ hcmethod_t method; /* method to use for health check */ apr_interval_time_t interval; char upgrade[PROXY_WORKER_MAX_SCHEME_SIZE];/* upgrade protocol used by mod_proxy_wstunnel */ char hostname_ex[PROXY_RFC1035_HOSTNAME_SIZE]; /* RFC1035 compliant version of the remote backend address */ apr_size_t response_field_size; /* Size of proxy response buffer in bytes. */ unsigned int response_field_size_set:1; char secret[PROXY_WORKER_MAX_SECRET_SIZE]; /* authentication secret (e.g. AJP13) */ char name_ex[PROXY_WORKER_EXT_NAME_SIZE]; /* Extended name (>96 chars for 2.4.x) */ unsigned int address_ttl_set:1; apr_int32_t address_ttl; /* backend address' TTL (seconds) */ apr_uint32_t address_expiry; /* backend address' next expiry time */ unsigned int is_host_matchable:1; } proxy_worker_shared; #define ALIGNED_PROXY_WORKER_SHARED_SIZE (APR_ALIGN_DEFAULT(sizeof(proxy_worker_shared))) /* Worker configuration */ struct proxy_worker { proxy_hashes hash; /* hash of worker name */ unsigned int local_status; /* status of per-process worker */ proxy_conn_pool *cp; /* Connection pool to use */ proxy_worker_shared *s; /* Shared data */ proxy_balancer *balancer; /* which balancer am I in? */ #if APR_HAS_THREADS apr_thread_mutex_t *tmutex; /* Thread lock for updating address cache */ #endif void *context; /* general purpose storage */ ap_conf_vector_t *section_config; /* <Proxy>-section wherein defined */ struct proxy_address *volatile address; /* current worker address (if reusable) */ }; /* default to health check every 30 seconds */ #define HCHECK_WATHCHDOG_DEFAULT_INTERVAL (30) /* The watchdog runs every 2 seconds, which is also the minimal check */ #define HCHECK_WATHCHDOG_INTERVAL (2) /* * Time to wait (in microseconds) to find out if more data is currently * available at the backend. */ #define PROXY_FLUSH_WAIT 10000 typedef struct { char sticky_path[PROXY_BALANCER_MAX_STICKY_SIZE]; /* URL sticky session identifier */ char sticky[PROXY_BALANCER_MAX_STICKY_SIZE]; /* sticky session identifier */ char lbpname[PROXY_MAX_PROVIDER_NAME_SIZE]; /* lbmethod provider name */ char nonce[APR_UUID_FORMATTED_LENGTH + 1]; char name[PROXY_BALANCER_MAX_NAME_SIZE]; char sname[PROXY_BALANCER_MAX_NAME_SIZE]; char vpath[PROXY_BALANCER_MAX_ROUTE_SIZE]; char vhost[PROXY_BALANCER_MAX_HOSTNAME_SIZE]; apr_interval_time_t timeout; /* Timeout for waiting on free connection */ apr_time_t wupdated; /* timestamp of last change to workers list */ int max_attempts; /* Number of attempts before failing */ int index; /* shm array index */ proxy_hashes hash; unsigned int sticky_force:1; /* Disable failover for sticky sessions */ unsigned int scolonsep:1; /* true if ';' seps sticky session paths */ unsigned int max_attempts_set:1; unsigned int was_malloced:1; unsigned int need_reset:1; unsigned int vhosted:1; unsigned int inactive:1; unsigned int forcerecovery:1; char sticky_separator; /* separator for sessionid/route */ unsigned int forcerecovery_set:1; unsigned int scolonsep_set:1; unsigned int sticky_force_set:1; unsigned int nonce_set:1; unsigned int sticky_separator_set:1; } proxy_balancer_shared; #define ALIGNED_PROXY_BALANCER_SHARED_SIZE (APR_ALIGN_DEFAULT(sizeof(proxy_balancer_shared))) struct proxy_balancer { apr_array_header_t *workers; /* initially configured workers */ apr_array_header_t *errstatuses; /* statuses to force members into error */ ap_slotmem_instance_t *wslot; /* worker shm data - runtime */ ap_slotmem_provider_t *storage; int growth; /* number of post-config workers can added */ int max_workers; /* maximum number of allowed workers */ proxy_hashes hash; apr_time_t wupdated; /* timestamp of last change to workers list */ proxy_balancer_method *lbmethod; apr_global_mutex_t *gmutex; /* global lock for updating list of workers */ #if APR_HAS_THREADS apr_thread_mutex_t *tmutex; /* Thread lock for updating shm */ #endif proxy_server_conf *sconf; void *context; /* general purpose storage */ proxy_balancer_shared *s; /* Shared data */ int failontimeout; /* Whether to mark a member in Err if IO timeout occurs */ unsigned int failontimeout_set:1; unsigned int growth_set:1; unsigned int lbmethod_set:1; ap_conf_vector_t *section_config; /* <Proxy>-section wherein defined */ }; struct proxy_balancer_method { const char *name; /* name of the load balancer method*/ proxy_worker *(*finder)(proxy_balancer *balancer, request_rec *r); void *context; /* general purpose storage */ apr_status_t (*reset)(proxy_balancer *balancer, server_rec *s); apr_status_t (*age)(proxy_balancer *balancer, server_rec *s); apr_status_t (*updatelbstatus)(proxy_balancer *balancer, proxy_worker *elected, server_rec *s); }; #define PROXY_THREAD_LOCK(x) ( (x) && (x)->tmutex ? apr_thread_mutex_lock((x)->tmutex) : APR_SUCCESS) #define PROXY_THREAD_UNLOCK(x) ( (x) && (x)->tmutex ? apr_thread_mutex_unlock((x)->tmutex) : APR_SUCCESS) #define PROXY_GLOBAL_LOCK(x) ( (x) && (x)->gmutex ? apr_global_mutex_lock((x)->gmutex) : APR_SUCCESS) #define PROXY_GLOBAL_UNLOCK(x) ( (x) && (x)->gmutex ? apr_global_mutex_unlock((x)->gmutex) : APR_SUCCESS) /* hooks */ /* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and * PROXY_DECLARE_DATA with appropriate export and import tags for the platform */ #if !defined(WIN32) #define PROXY_DECLARE(type) type #define PROXY_DECLARE_NONSTD(type) type #define PROXY_DECLARE_DATA #elif defined(PROXY_DECLARE_STATIC) #define PROXY_DECLARE(type) type __stdcall #define PROXY_DECLARE_NONSTD(type) type #define PROXY_DECLARE_DATA #elif defined(PROXY_DECLARE_EXPORT) #define PROXY_DECLARE(type) __declspec(dllexport) type __stdcall #define PROXY_DECLARE_NONSTD(type) __declspec(dllexport) type #define PROXY_DECLARE_DATA __declspec(dllexport) #else #define PROXY_DECLARE(type) __declspec(dllimport) type __stdcall #define PROXY_DECLARE_NONSTD(type) __declspec(dllimport) type #define PROXY_DECLARE_DATA __declspec(dllimport) #endif /* Using PROXY_DECLARE_OPTIONAL_HOOK instead of * APR_DECLARE_EXTERNAL_HOOK allows build/make_nw_export.awk * to distinguish between hooks that implement * proxy_hook_xx and proxy_hook_get_xx in mod_proxy.c and * those which don't. */ #define PROXY_DECLARE_OPTIONAL_HOOK APR_DECLARE_EXTERNAL_HOOK /* These 2 are in mod_proxy.c */ extern PROXY_DECLARE_DATA proxy_hcmethods_t proxy_hcmethods[]; extern PROXY_DECLARE_DATA proxy_wstat_t proxy_wstat_tbl[]; /* Following 4 from health check */ APR_DECLARE_OPTIONAL_FN(void, hc_show_exprs, (request_rec *)); APR_DECLARE_OPTIONAL_FN(void, hc_select_exprs, (request_rec *, const char *)); APR_DECLARE_OPTIONAL_FN(int, hc_valid_expr, (request_rec *, const char *)); APR_DECLARE_OPTIONAL_FN(const char *, set_worker_hc_param, (apr_pool_t *, server_rec *, proxy_worker *, const char *, const char *, void *)); APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, section_post_config, (apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s, ap_conf_vector_t *section_config)) APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r, proxy_worker *worker, proxy_server_conf *conf, char *url, const char *proxyhost, apr_port_t proxyport)) APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, check_trans, (request_rec *r, const char *url)) APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r, char *url)) APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr)) APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, fixups, (request_rec *r)) /** * pre request hook. * It will return the most suitable worker at the moment * and corresponding balancer. * The url is rewritten from balancer://cluster/uri to scheme://host:port/uri * and then the scheme_handler is called. * */ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, pre_request, (proxy_worker **worker, proxy_balancer **balancer, request_rec *r, proxy_server_conf *conf, char **url)) /** * post request hook. * It is called after request for updating runtime balancer status. */ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, post_request, (proxy_worker *worker, proxy_balancer *balancer, request_rec *r, proxy_server_conf *conf)) /** * request status hook * It is called after all proxy processing has been done. This gives other * modules a chance to create default content on failure, for example */ APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, request_status, (int *status, request_rec *r)) /* proxy_util.c */ PROXY_DECLARE(apr_status_t) ap_proxy_strncpy(char *dst, const char *src, apr_size_t dlen); PROXY_DECLARE(int) ap_proxy_hex2c(const char *x); PROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x); PROXY_DECLARE(char *)ap_proxy_canonenc_ex(apr_pool_t *p, const char *x, int len, enum enctype t, int flags, int proxyreq); PROXY_DECLARE(char *)ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t, int forcedec, int proxyreq); PROXY_DECLARE(char *)ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp, char **passwordp, char **hostp, apr_port_t *port); PROXY_DECLARE(int) ap_proxyerror(request_rec *r, int statuscode, const char *message); PROXY_DECLARE(int) ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, apr_sockaddr_t *uri_addr); /** Test whether the hostname/address of the request are blocked by the ProxyBlock * configuration. * @param r request * @param conf server configuration * @param hostname hostname from request URI * @param addr resolved address of hostname, or NULL if not known * @return OK on success, or else an error */ PROXY_DECLARE(int) ap_proxy_checkproxyblock2(request_rec *r, proxy_server_conf *conf, const char *hostname, apr_sockaddr_t *addr); PROXY_DECLARE(int) ap_proxy_pre_http_request(conn_rec *c, request_rec *r); /* DEPRECATED (will be replaced with ap_proxy_connect_backend */ PROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **, const char *, apr_sockaddr_t *, const char *, proxy_server_conf *, request_rec *); /* DEPRECATED (will be replaced with ap_proxy_check_connection */ PROXY_DECLARE(apr_status_t) ap_proxy_ssl_connection_cleanup(proxy_conn_rec *conn, request_rec *r); PROXY_DECLARE(int) ap_proxy_ssl_enable(conn_rec *c); PROXY_DECLARE(int) ap_proxy_ssl_disable(conn_rec *c); PROXY_DECLARE(int) ap_proxy_ssl_engine(conn_rec *c, ap_conf_vector_t *per_dir_config, int enable); PROXY_DECLARE(int) ap_proxy_conn_is_https(conn_rec *c); PROXY_DECLARE(const char *) ap_proxy_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r, const char *var); /* Header mapping functions, and a typedef of their signature */ PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *url); PROXY_DECLARE(const char *) ap_proxy_cookie_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *str); #if !defined(WIN32) typedef const char *(*ap_proxy_header_reverse_map_fn)(request_rec *, proxy_dir_conf *, const char *); #elif defined(PROXY_DECLARE_STATIC) typedef const char *(__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *, proxy_dir_conf *, const char *); #elif defined(PROXY_DECLARE_EXPORT) typedef __declspec(dllexport) const char * (__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *, proxy_dir_conf *, const char *); #else typedef __declspec(dllimport) const char * (__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *, proxy_dir_conf *, const char *); #endif /* Connection pool API */ /** * Return the user-land, UDS aware worker name * @param p memory pool used for displaying worker name * @param worker the worker * @return name */ PROXY_DECLARE(char *) ap_proxy_worker_name(apr_pool_t *p, proxy_worker *worker); /** * Return whether a worker upgrade configuration matches Upgrade header * @param p memory pool used for displaying worker name * @param worker the worker * @param upgrade the Upgrade header to match * @param dflt default protocol (NULL for none) * @return 1 (true) or 0 (false) */ PROXY_DECLARE(int) ap_proxy_worker_can_upgrade(apr_pool_t *p, const proxy_worker *worker, const char *upgrade, const char *dflt); /* Bitmask for ap_proxy_{define,get}_worker_ex(). */ #define AP_PROXY_WORKER_IS_PREFIX (1u << 0) #define AP_PROXY_WORKER_IS_MATCH (1u << 1) #define AP_PROXY_WORKER_IS_MALLOCED (1u << 2) #define AP_PROXY_WORKER_NO_UDS (1u << 3) /** * Get the worker from proxy configuration, looking for either PREFIXED or * MATCHED or both types of workers according to given mask * @param p memory pool used for finding worker * @param balancer the balancer that the worker belongs to * @param conf current proxy server configuration * @param url url to find the worker from * @param mask bitmask of AP_PROXY_WORKER_IS_* * @return proxy_worker or NULL if not found */ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker_ex(apr_pool_t *p, proxy_balancer *balancer, proxy_server_conf *conf, const char *url, unsigned int mask); /** * Get the worker from proxy configuration, both types * @param p memory pool used for finding worker * @param balancer the balancer that the worker belongs to * @param conf current proxy server configuration * @param url url to find the worker from * @return proxy_worker or NULL if not found */ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p, proxy_balancer *balancer, proxy_server_conf *conf, const char *url); /** * Define and Allocate space for the worker to proxy configuration, of either * PREFIXED or MATCHED type according to given mask * @param p memory pool to allocate worker from * @param worker the new worker * @param balancer the balancer that the worker belongs to * @param conf current proxy server configuration * @param url url containing worker name * @param mask bitmask of AP_PROXY_WORKER_IS_* * @return error message or NULL if successful (*worker is new worker) */ PROXY_DECLARE(char *) ap_proxy_define_worker_ex(apr_pool_t *p, proxy_worker **worker, proxy_balancer *balancer, proxy_server_conf *conf, const char *url, unsigned int mask); /** * Define and Allocate space for the worker to proxy configuration * @param p memory pool to allocate worker from * @param worker the new worker * @param balancer the balancer that the worker belongs to * @param conf current proxy server configuration * @param url url containing worker name * @param do_malloc true if shared struct should be malloced * @return error message or NULL if successful (*worker is new worker) */ PROXY_DECLARE(char *) ap_proxy_define_worker(apr_pool_t *p, proxy_worker **worker, proxy_balancer *balancer, proxy_server_conf *conf, const char *url, int do_malloc); /** * Define and Allocate space for the ap_strcmp_match()able worker to proxy * configuration. * @param p memory pool to allocate worker from * @param worker the new worker * @param balancer the balancer that the worker belongs to * @param conf current proxy server configuration * @param url url containing worker name (produces match pattern) * @param do_malloc true if shared struct should be malloced * @return error message or NULL if successful (*worker is new worker) * @deprecated Replaced by ap_proxy_define_worker_ex() */ PROXY_DECLARE(char *) ap_proxy_define_match_worker(apr_pool_t *p, proxy_worker **worker, proxy_balancer *balancer, proxy_server_conf *conf, const char *url, int do_malloc); /** * Share a defined proxy worker via shm * @param worker worker to be shared * @param shm location of shared info * @param i index into shm * @return APR_SUCCESS or error code */ PROXY_DECLARE(apr_status_t) ap_proxy_share_worker(proxy_worker *worker, proxy_worker_shared *shm, int i); /** * Initialize the worker by setting up worker connection pool and mutex * @param worker worker to initialize * @param s current server record * @param p memory pool used for mutex and connection pool * @return APR_SUCCESS or error code */ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker, server_rec *s, apr_pool_t *p); /** * Verifies valid balancer name (eg: balancer://foo) * @param name name to test * @param i number of chars to test; 0 for all. * @return true/false */ PROXY_DECLARE(int) ap_proxy_valid_balancer_name(char *name, int i); /** * Get the balancer from proxy configuration * @param p memory pool used for temporary storage while finding balancer * @param conf current proxy server configuration * @param url url to find the worker from; must have balancer:// prefix * @param careactive true if we care if the balancer is active or not * @return proxy_balancer or NULL if not found */ PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p, proxy_server_conf *conf, const char *url, int careactive); /** * Update the balancer's vhost related fields * @param p memory pool used for temporary storage while finding balancer * @param balancer balancer to be updated * @param url url to find vhost info * @return error string or NULL if OK */ PROXY_DECLARE(char *) ap_proxy_update_balancer(apr_pool_t *p, proxy_balancer *balancer, const char *url); /** * Define and Allocate space for the balancer to proxy configuration * @param p memory pool to allocate balancer from * @param balancer the new balancer * @param conf current proxy server configuration * @param url url containing balancer name * @param alias alias/fake-path to this balancer * @param do_malloc true if shared struct should be malloced * @return error message or NULL if successful */ PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p, proxy_balancer **balancer, proxy_server_conf *conf, const char *url, const char *alias, int do_malloc); /** * Share a defined proxy balancer via shm * @param balancer balancer to be shared * @param shm location of shared info * @param i index into shm * @return APR_SUCCESS or error code */ PROXY_DECLARE(apr_status_t) ap_proxy_share_balancer(proxy_balancer *balancer, proxy_balancer_shared *shm, int i); /** * Initialize the balancer as needed * @param balancer balancer to initialize * @param s current server record * @param p memory pool used for mutex and connection pool * @return APR_SUCCESS or error code */ PROXY_DECLARE(apr_status_t) ap_proxy_initialize_balancer(proxy_balancer *balancer, server_rec *s, apr_pool_t *p); typedef int (proxy_is_best_callback_fn_t)(proxy_worker *current, proxy_worker *prev_best, void *baton); /** * Retrieve the best worker in a balancer for the current request * @param balancer balancer for which to find the best worker * @param r current request record * @param is_best a callback function provide by the lbmethod * that determines if the current worker is best * @param baton an lbmethod-specific context pointer (baton) * passed to the is_best callback * @return the best worker to be used for the request */ PROXY_DECLARE(proxy_worker *) ap_proxy_balancer_get_best_worker(proxy_balancer *balancer, request_rec *r, proxy_is_best_callback_fn_t *is_best, void *baton); /* * Needed by the lb modules. */ APR_DECLARE_OPTIONAL_FN(proxy_worker *, proxy_balancer_get_best_worker, (proxy_balancer *balancer, request_rec *r, proxy_is_best_callback_fn_t *is_best, void *baton)); /** * Find the shm of the worker as needed * @param storage slotmem provider * @param slot slotmem instance * @param worker worker to find * @param index pointer to index within slotmem of worker * @return pointer to shm of worker, or NULL */ PROXY_DECLARE(proxy_worker_shared *) ap_proxy_find_workershm(ap_slotmem_provider_t *storage, ap_slotmem_instance_t *slot, proxy_worker *worker, unsigned int *index); /** * Find the shm of the balancer as needed * @param storage slotmem provider * @param slot slotmem instance * @param balancer balancer of shm to find * @param index pointer to index within slotmem of balancer * @return pointer to shm of balancer, or NULL */ PROXY_DECLARE(proxy_balancer_shared *) ap_proxy_find_balancershm(ap_slotmem_provider_t *storage, ap_slotmem_instance_t *slot, proxy_balancer *balancer, unsigned int *index); /* * Strip the UDS part of r->filename if any, and put the UDS path in * r->notes ("uds_path") * @param r current request * @return OK if fixed up, DECLINED if not UDS, or an HTTP_XXX error * @remark Deprecated (for internal use only) */ PROXY_DECLARE(int) ap_proxy_fixup_uds_filename(request_rec *r); /** * Get the most suitable worker and/or balancer for the request * @param worker worker used for processing request * @param balancer balancer used for processing request * @param r current request * @param conf current proxy server configuration * @param url request url that balancer can rewrite. * @return OK or HTTP_XXX error * @note It calls balancer pre_request hook if the url starts with balancer:// * The balancer then rewrites the url to particular worker, like http://host:port */ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker, proxy_balancer **balancer, request_rec *r, proxy_server_conf *conf, char **url); /** * Post request worker and balancer cleanup * @param worker worker used for processing request * @param balancer balancer used for processing request * @param r current request * @param conf current proxy server configuration * @return OK or HTTP_XXX error * @note Whenever the pre_request is called, the post_request has to be * called too. */ PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker, proxy_balancer *balancer, request_rec *r, proxy_server_conf *conf); /* Bitmask for ap_proxy_determine_address() */ #define PROXY_DETERMINE_ADDRESS_CHECK (1u << 0) /** * Resolve an address, reusing the one of the worker if any. * @param proxy_function calling proxy scheme (http, ajp, ...) * @param conn proxy connection the address is used for * @param hostname host to resolve (should be the worker's if reusable) * @param hostport port to resolve (should be the worker's if reusable) * @param flags bitmask of PROXY_DETERMINE_ADDRESS_* * @param r current request (if any) * @param s current server (or NULL if r != NULL and ap_proxyerror() * should be called on error) * @return APR_SUCCESS or an error, APR_EEXIST if the address is still * the same and PROXY_DETERMINE_ADDRESS_CHECK is asked */ PROXY_DECLARE(apr_status_t) ap_proxy_determine_address(const char *proxy_function, proxy_conn_rec *conn, const char *hostname, apr_port_t hostport, unsigned int flags, request_rec *r, server_rec *s); /** * Determine backend hostname and port * @param p memory pool used for processing * @param r current request * @param conf current proxy server configuration * @param worker worker used for processing request * @param conn proxy connection struct * @param uri processed uri * @param url request url * @param proxyname are we connecting directly or via a proxy * @param proxyport proxy host port * @param server_portstr Via headers server port, must be non-NULL * @param server_portstr_size size of the server_portstr buffer; must * be at least one, even if the protocol doesn't use this * @return OK or HTTP_XXX error */ PROXY_DECLARE(int) ap_proxy_determine_connection(apr_pool_t *p, request_rec *r, proxy_server_conf *conf, proxy_worker *worker, proxy_conn_rec *conn, apr_uri_t *uri, char **url, const char *proxyname, apr_port_t proxyport, char *server_portstr, int server_portstr_size); /** * Mark a worker for retry * @param proxy_function calling proxy scheme (http, ajp, ...) * @param worker worker used for retrying * @param s current server record * @return OK if marked for retry, DECLINED otherwise * @note The error status of the worker will cleared if the retry interval has * elapsed since the last error. */ APR_DECLARE_OPTIONAL_FN(int, ap_proxy_retry_worker, (const char *proxy_function, proxy_worker *worker, server_rec *s)); /** * Acquire a connection from worker connection pool * @param proxy_function calling proxy scheme (http, ajp, ...) * @param conn acquired connection * @param worker worker used for obtaining connection * @param s current server record * @return OK or HTTP_XXX error * @note If the connection limit has been reached, the function will * block until a connection becomes available or the timeout has * elapsed. */ PROXY_DECLARE(int) ap_proxy_acquire_connection(const char *proxy_function, proxy_conn_rec **conn, proxy_worker *worker, server_rec *s); /** * Release a connection back to worker connection pool * @param proxy_function calling proxy scheme (http, ajp, ...) * @param conn acquired connection * @param s current server record * @return OK or HTTP_XXX error * @note The connection will be closed if conn->close_on_release is set */ PROXY_DECLARE(int) ap_proxy_release_connection(const char *proxy_function, proxy_conn_rec *conn, server_rec *s); #define PROXY_CHECK_CONN_EMPTY (1 << 0) /** * Check a connection to the backend * @param scheme calling proxy scheme (http, ajp, ...) * @param conn acquired connection * @param server current server record * @param max_blank_lines how many blank lines to consume, * or zero for none (considered data) * @param flags PROXY_CHECK_* bitmask * @return APR_SUCCESS: connection established, * APR_ENOTEMPTY: connection established with data, * APR_ENOSOCKET: not connected, * APR_EINVAL: worker in error state (unusable), * other: connection closed/aborted (remotely) */ PROXY_DECLARE(apr_status_t) ap_proxy_check_connection(const char *scheme, proxy_conn_rec *conn, server_rec *server, unsigned max_blank_lines, int flags); /** * Make a connection to the backend * @param proxy_function calling proxy scheme (http, ajp, ...) * @param conn acquired connection * @param worker connection worker * @param s current server record * @return OK or HTTP_XXX error * @note In case the socket already exists for conn, just check the link * status. */ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function, proxy_conn_rec *conn, proxy_worker *worker, server_rec *s); /** * Make a connection to a Unix Domain Socket (UDS) path * @param sock UDS to connect * @param uds_path UDS path to connect to * @param p pool to make the sock addr * @return APR_SUCCESS or error status */ PROXY_DECLARE(apr_status_t) ap_proxy_connect_uds(apr_socket_t *sock, const char *uds_path, apr_pool_t *p); /** * Make a connection record for backend connection * @param proxy_function calling proxy scheme (http, ajp, ...) * @param conn acquired connection * @param c client connection record (unused, deprecated) * @param s current server record * @return OK or HTTP_XXX error * @note The function will return immediately if conn->connection * is already set, */ PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function, proxy_conn_rec *conn, conn_rec *c, server_rec *s); /** * Make a connection record for backend connection, using request dir config * @param proxy_function calling proxy scheme (http, ajp, ...) * @param conn acquired connection * @param r current request record * @return OK or HTTP_XXX error * @note The function will return immediately if conn->connection * is already set, */ PROXY_DECLARE(int) ap_proxy_connection_create_ex(const char *proxy_function, proxy_conn_rec *conn, request_rec *r); /** * Determine if proxy connection can potentially be reused at the * end of this request. * @param conn proxy connection * @return non-zero if reusable, 0 otherwise * @note Even if this function returns non-zero, the connection may * be subsequently marked for closure. */ PROXY_DECLARE(int) ap_proxy_connection_reusable(proxy_conn_rec *conn); /** * Signal the upstream chain that the connection to the backend broke in the * middle of the response. This is done by sending an error bucket with * status HTTP_BAD_GATEWAY and an EOS bucket up the filter chain. * @param r current request record of client request * @param brigade The brigade that is sent through the output filter chain */ PROXY_DECLARE(void) ap_proxy_backend_broke(request_rec *r, apr_bucket_brigade *brigade); /** * Return a hash based on the passed string * @param str string to produce hash from * @param method hashing method to use * @return hash as unsigned int */ typedef enum { PROXY_HASHFUNC_DEFAULT, PROXY_HASHFUNC_APR, PROXY_HASHFUNC_FNV } proxy_hash_t; PROXY_DECLARE(unsigned int) ap_proxy_hashfunc(const char *str, proxy_hash_t method); /** * Set/unset the worker status bitfield depending on flag * @param c flag * @param set set or unset bit * @param w worker to use * @return APR_SUCCESS if valid flag */ PROXY_DECLARE(apr_status_t) ap_proxy_set_wstatus(char c, int set, proxy_worker *w); /** * Create readable representation of worker status bitfield * @param p pool * @param w worker to use * @return string representation of status */ PROXY_DECLARE(char *) ap_proxy_parse_wstatus(apr_pool_t *p, proxy_worker *w); /** * Sync balancer and workers based on any updates w/i shm * @param b balancer to check/update member list of * @param s server rec * @param conf config * @return APR_SUCCESS if all goes well */ PROXY_DECLARE(apr_status_t) ap_proxy_sync_balancer(proxy_balancer *b, server_rec *s, proxy_server_conf *conf); /** * Configure and create workers (and balancer) in mod_balancer. * @param r request * @param params table with the parameters like b=mycluster etc. * @return 404 when the worker/balancer doesn't exist, * 400 if something is invalid * 200 for success. */ APR_DECLARE_OPTIONAL_FN(apr_status_t, balancer_manage, (request_rec *, apr_table_t *params)); /** * Find the matched alias for this request and setup for proxy handler * @param r request * @param ent proxy_alias record * @param dconf per-dir config or NULL * @return OK if the alias matched, * DONE if the alias matched and r->uri was normalized so * no further transformation should happen on it, * DECLINED if proxying is disabled for this alias, * HTTP_CONTINUE if the alias did not match */ PROXY_DECLARE(int) ap_proxy_trans_match(request_rec *r, struct proxy_alias *ent, proxy_dir_conf *dconf); /** * Create a HTTP request header brigade, old_cl_val and old_te_val as required. * @param p pool * @param header_brigade header brigade to use/fill * @param r request * @param p_conn proxy connection rec * @param worker selected worker * @param conf per-server proxy config * @param uri uri * @param url url * @param server_portstr port as string * @param old_cl_val stored old content-len val * @param old_te_val stored old TE val * @return OK or HTTP_EXPECTATION_FAILED */ PROXY_DECLARE(int) ap_proxy_create_hdrbrgd(apr_pool_t *p, apr_bucket_brigade *header_brigade, request_rec *r, proxy_conn_rec *p_conn, proxy_worker *worker, proxy_server_conf *conf, apr_uri_t *uri, char *url, char *server_portstr, char **old_cl_val, char **old_te_val); /** * Prefetch the client request body (in memory), up to a limit. * Read what's in the client pipe. If nonblocking is set and read is EAGAIN, * pass a FLUSH bucket to the backend and read again in blocking mode. * @param r client request * @param backend backend connection * @param input_brigade input brigade to use/fill * @param block blocking or non-blocking mode * @param bytes_read number of bytes read * @param max_read maximum number of bytes to read * @return OK or HTTP_* error code * @note max_read is rounded up to APR_BUCKET_BUFF_SIZE */ PROXY_DECLARE(int) ap_proxy_prefetch_input(request_rec *r, proxy_conn_rec *backend, apr_bucket_brigade *input_brigade, apr_read_type_e block, apr_off_t *bytes_read, apr_off_t max_read); /** * Spool the client request body to memory, or disk above given limit. * @param r client request * @param backend backend connection * @param input_brigade input brigade to use/fill * @param bytes_spooled number of bytes spooled * @param max_mem_spool maximum number of in-memory bytes * @return OK or HTTP_* error code */ PROXY_DECLARE(int) ap_proxy_spool_input(request_rec *r, proxy_conn_rec *backend, apr_bucket_brigade *input_brigade, apr_off_t *bytes_spooled, apr_off_t max_mem_spool); /** * Read what's in the client pipe. If the read would block (EAGAIN), * pass a FLUSH bucket to the backend and read again in blocking mode. * @param r client request * @param backend backend connection * @param input_brigade brigade to use/fill * @param max_read maximum number of bytes to read * @return OK or HTTP_* error code */ PROXY_DECLARE(int) ap_proxy_read_input(request_rec *r, proxy_conn_rec *backend, apr_bucket_brigade *input_brigade, apr_off_t max_read); /** * @param bucket_alloc bucket allocator * @param r request * @param p_conn proxy connection * @param origin connection rec of origin * @param bb brigade to send to origin * @param flush flush * @return status (OK) */ PROXY_DECLARE(int) ap_proxy_pass_brigade(apr_bucket_alloc_t *bucket_alloc, request_rec *r, proxy_conn_rec *p_conn, conn_rec *origin, apr_bucket_brigade *bb, int flush); struct proxy_tunnel_conn; /* opaque */ typedef struct { request_rec *r; const char *scheme; apr_pollset_t *pollset; apr_array_header_t *pfds; apr_interval_time_t timeout; struct proxy_tunnel_conn *client, *origin; apr_size_t read_buf_size; int replied; /* TODO 2.5+: one bit to merge in below bitmask */ unsigned int nohalfclose :1; } proxy_tunnel_rec; /** * Create a tunnel, to be activated by ap_proxy_tunnel_run(). * @param tunnel tunnel created * @param r client request * @param c_o connection to origin * @param scheme caller proxy scheme (connect, ws(s), http(s), ...) * @return APR_SUCCESS or error status */ PROXY_DECLARE(apr_status_t) ap_proxy_tunnel_create(proxy_tunnel_rec **tunnel, request_rec *r, conn_rec *c_o, const char *scheme); /** * Forward anything from either side of the tunnel to the other, * until one end aborts or a polling timeout/error occurs. * @param tunnel tunnel to run * @return OK if completion is full, HTTP_GATEWAY_TIME_OUT on timeout * or another HTTP_ error otherwise. */ PROXY_DECLARE(int) ap_proxy_tunnel_run(proxy_tunnel_rec *tunnel); /** * Clear the headers referenced by the Connection header from the given * table, and remove the Connection header. * @param r request * @param headers table of headers to clear * @return 1 if "close" was present, 0 otherwise. */ APR_DECLARE_OPTIONAL_FN(int, ap_proxy_clear_connection, (request_rec *r, apr_table_t *headers)); /** * Do a AJP CPING and wait for CPONG on the socket * */ APR_DECLARE_OPTIONAL_FN(apr_status_t, ajp_handle_cping_cpong, (apr_socket_t *sock, request_rec *r, apr_interval_time_t timeout)); /** * @param socket socket to test * @return TRUE if socket is connected/active */ PROXY_DECLARE(int) ap_proxy_is_socket_connected(apr_socket_t *socket); #define PROXY_LBMETHOD "proxylbmethod" /* The number of dynamic workers that can be added when reconfiguring. * If this limit is reached you must stop and restart the server. */ #define PROXY_DYNAMIC_BALANCER_LIMIT 16 /** * Calculate maximum number of workers in scoreboard. * @return number of workers to allocate in the scoreboard */ int ap_proxy_lb_workers(void); /** * Returns 1 if a response with the given status should be overridden. * * @param conf proxy directory configuration * @param code http status code * @return 1 if code is considered an error-code, 0 otherwise */ PROXY_DECLARE(int) ap_proxy_should_override(proxy_dir_conf *conf, int code); /** * Return the port number of a known scheme (eg: http -> 80). * @param scheme scheme to test * @return port number or 0 if unknown */ PROXY_DECLARE(apr_port_t) ap_proxy_port_of_scheme(const char *scheme); /** * Return the name of the health check method (eg: "OPTIONS"). * @param method method enum * @return name of method */ PROXY_DECLARE (const char *) ap_proxy_show_hcmethod(hcmethod_t method); /** * Strip a unix domain socket (UDS) prefix from the input URL * @param p pool to allocate result from * @param url a URL potentially prefixed with a UDS path * @return URL with the UDS prefix removed */ PROXY_DECLARE(const char *) ap_proxy_de_socketfy(apr_pool_t *p, const char *url); /* * Transform buckets from one bucket allocator to another one by creating a * transient bucket for each data bucket and let it use the data read from * the old bucket. Metabuckets are transformed by just recreating them. * Attention: Currently only the following bucket types are handled: * * All data buckets * FLUSH * EOS * * If an other bucket type is found its type is logged as a debug message * and APR_EGENERAL is returned. * * @param r request_rec of the actual request. Used for logging purposes * @param from the bucket brigade to take the buckets from * @param to the bucket brigade to store the transformed buckets * @return apr_status_t of the operation. Either APR_SUCCESS or * APR_EGENERAL */ PROXY_DECLARE(apr_status_t) ap_proxy_buckets_lifetime_transform(request_rec *r, apr_bucket_brigade *from, apr_bucket_brigade *to); /* * The flags for ap_proxy_transfer_between_connections(), where for legacy and * compatibility reasons FLUSH_EACH and FLUSH_AFTER are boolean values. */ #define AP_PROXY_TRANSFER_FLUSH_EACH (0x00) #define AP_PROXY_TRANSFER_FLUSH_AFTER (0x01) #define AP_PROXY_TRANSFER_YIELD_PENDING (0x02) #define AP_PROXY_TRANSFER_YIELD_MAX_READS (0x04) /* * Sends all data that can be read non blocking from the input filter chain of * c_i and send it down the output filter chain of c_o. For reading it uses * the bucket brigade bb_i which should be created from the bucket allocator * associated with c_i. For sending through the output filter chain it uses * the bucket brigade bb_o which should be created from the bucket allocator * associated with c_o. In order to get the buckets from bb_i to bb_o * ap_proxy_buckets_lifetime_transform is used. * * @param r request_rec of the actual request. Used for logging purposes * @param c_i inbound connection conn_rec * @param c_o outbound connection conn_rec * @param bb_i bucket brigade for pulling data from the inbound connection * @param bb_o bucket brigade for sending data through the outbound connection * @param name string for logging from where data was pulled * @param sent if not NULL will be set to 1 if data was sent through c_o * @param bsize maximum amount of data pulled in one iteration from c_i * @param flags AP_PROXY_TRANSFER_* bitmask * @return apr_status_t of the operation. Could be any error returned from * either the input filter chain of c_i or the output filter chain * of c_o, APR_EPIPE if the outgoing connection was aborted, or * APR_INCOMPLETE if AP_PROXY_TRANSFER_YIELD_PENDING was set and * the output stack gets full before the input stack is exhausted. */ PROXY_DECLARE(apr_status_t) ap_proxy_transfer_between_connections( request_rec *r, conn_rec *c_i, conn_rec *c_o, apr_bucket_brigade *bb_i, apr_bucket_brigade *bb_o, const char *name, int *sent, apr_off_t bsize, int flags); extern module PROXY_DECLARE_DATA proxy_module; #endif /*MOD_PROXY_H*/ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file ap_config.h * @brief Symbol export macros and hook functions */ #ifndef AP_CONFIG_H #define AP_CONFIG_H #include "ap_hooks.h" /* Although this file doesn't declare any hooks, declare the exports group here */ /** * @defgroup exports Apache exports * @ingroup APACHE_CORE */ #ifdef DOXYGEN /* define these just so doxygen documents them */ /** * AP_DECLARE_STATIC is defined when including Apache's Core headers, * to provide static linkage when the dynamic library may be unavailable. * * @see AP_DECLARE_EXPORT * * AP_DECLARE_STATIC and AP_DECLARE_EXPORT are left undefined when * including Apache's Core headers, to import and link the symbols from the * dynamic Apache Core library and assure appropriate indirection and calling * conventions at compile time. */ # define AP_DECLARE_STATIC /** * AP_DECLARE_EXPORT is defined when building the Apache Core dynamic * library, so that all public symbols are exported. * * @see AP_DECLARE_STATIC */ # define AP_DECLARE_EXPORT #endif /* def DOXYGEN */ #if !defined(WIN32) /** * Apache Core dso functions are declared with AP_DECLARE(), so they may * use the most appropriate calling convention. Hook functions and other * Core functions with variable arguments must use AP_DECLARE_NONSTD(). * @code * AP_DECLARE(rettype) ap_func(args) * @endcode */ #define AP_DECLARE(type) type /** * Apache Core dso variable argument and hook functions are declared with * AP_DECLARE_NONSTD(), as they must use the C language calling convention. * @see AP_DECLARE * @code * AP_DECLARE_NONSTD(rettype) ap_func(args [...]) * @endcode */ #define AP_DECLARE_NONSTD(type) type /** * Apache Core dso variables are declared with AP_MODULE_DECLARE_DATA. * This assures the appropriate indirection is invoked at compile time. * * @note AP_DECLARE_DATA extern type apr_variable; syntax is required for * declarations within headers to properly import the variable. * @code * AP_DECLARE_DATA type apr_variable * @endcode */ #define AP_DECLARE_DATA #elif defined(AP_DECLARE_STATIC) #define AP_DECLARE(type) type __stdcall #define AP_DECLARE_NONSTD(type) type #define AP_DECLARE_DATA #elif defined(AP_DECLARE_EXPORT) #define AP_DECLARE(type) __declspec(dllexport) type __stdcall #define AP_DECLARE_NONSTD(type) __declspec(dllexport) type #define AP_DECLARE_DATA __declspec(dllexport) #else #define AP_DECLARE(type) __declspec(dllimport) type __stdcall #define AP_DECLARE_NONSTD(type) __declspec(dllimport) type #define AP_DECLARE_DATA __declspec(dllimport) #endif #if !defined(WIN32) || defined(AP_MODULE_DECLARE_STATIC) /** * Declare a dso module's exported module structure as AP_MODULE_DECLARE_DATA. * * Unless AP_MODULE_DECLARE_STATIC is defined at compile time, symbols * declared with AP_MODULE_DECLARE_DATA are always exported. * @code * module AP_MODULE_DECLARE_DATA mod_tag * @endcode */ #if defined(WIN32) #define AP_MODULE_DECLARE(type) type __stdcall #else #define AP_MODULE_DECLARE(type) type #endif #define AP_MODULE_DECLARE_NONSTD(type) type #define AP_MODULE_DECLARE_DATA #else /** * AP_MODULE_DECLARE_EXPORT is a no-op. Unless contradicted by the * AP_MODULE_DECLARE_STATIC compile-time symbol, it is assumed and defined. * * The old SHARED_MODULE compile-time symbol is now the default behavior, * so it is no longer referenced anywhere with Apache 2.0. */ #define AP_MODULE_DECLARE_EXPORT #define AP_MODULE_DECLARE(type) __declspec(dllexport) type __stdcall #define AP_MODULE_DECLARE_NONSTD(type) __declspec(dllexport) type #define AP_MODULE_DECLARE_DATA __declspec(dllexport) #endif #include "os.h" #if (!defined(WIN32) && !defined(NETWARE)) || defined(__MINGW32__) #include "ap_config_auto.h" #endif #include "ap_config_layout.h" /* Where the main/parent process's pid is logged */ #ifndef DEFAULT_PIDLOG #define DEFAULT_PIDLOG DEFAULT_REL_RUNTIMEDIR "/httpd.pid" #endif #if defined(NETWARE) #define AP_NONBLOCK_WHEN_MULTI_LISTEN 1 #endif #if defined(AP_ENABLE_DTRACE) && HAVE_SYS_SDT_H #include <sys/sdt.h> #else #undef _DTRACE_VERSION #endif #ifdef _DTRACE_VERSION #include "apache_probes.h" #else #include "apache_noprobes.h" #endif /* If APR has OTHER_CHILD logic, use reliable piped logs. */ #if APR_HAS_OTHER_CHILD #define AP_HAVE_RELIABLE_PIPED_LOGS TRUE #endif #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define AP_HAVE_C99 #endif /* Presume that the compiler supports C99-style designated * initializers if using GCC (but not G++), or for any other compiler * which claims C99 support. */ #if (defined(__GNUC__) && !defined(__cplusplus)) || defined(AP_HAVE_C99) #define AP_HAVE_DESIGNATED_INITIALIZER #endif #ifndef __has_attribute /* check for supported attributes on clang */ #define __has_attribute(x) 0 #endif #if (defined(__GNUC__) && __GNUC__ >= 4) || __has_attribute(sentinel) #define AP_FN_ATTR_SENTINEL __attribute__((sentinel)) #else #define AP_FN_ATTR_SENTINEL #endif #if ( defined(__GNUC__) && \ (__GNUC__ >= 4 || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4))) \ || __has_attribute(warn_unused_result) #define AP_FN_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) #else #define AP_FN_ATTR_WARN_UNUSED_RESULT #endif #if ( defined(__GNUC__) && \ (__GNUC__ >= 4 && __GNUC_MINOR__ >= 3)) \ || __has_attribute(alloc_size) #define AP_FN_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x))) #define AP_FN_ATTR_ALLOC_SIZE2(x,y) __attribute__((alloc_size(x,y))) #else #define AP_FN_ATTR_ALLOC_SIZE(x) #define AP_FN_ATTR_ALLOC_SIZE2(x,y) #endif #endif /* AP_CONFIG_H */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_mutex.h * @brief Apache Mutex support library * * @defgroup APACHE_CORE_MUTEX Mutex Library * @ingroup APACHE_CORE * @{ */ #ifndef UTIL_MUTEX_H #define UTIL_MUTEX_H #include "httpd.h" #include "http_config.h" #include "apr_global_mutex.h" #if APR_HAS_FLOCK_SERIALIZE # define AP_LIST_FLOCK_SERIALIZE ", 'flock:/path/to/file'" #else # define AP_LIST_FLOCK_SERIALIZE #endif #if APR_HAS_FCNTL_SERIALIZE # define AP_LIST_FCNTL_SERIALIZE ", 'fcntl:/path/to/file'" #else # define AP_LIST_FCNTL_SERIALIZE #endif #if APR_HAS_SYSVSEM_SERIALIZE # define AP_LIST_SYSVSEM_SERIALIZE ", 'sysvsem'" #else # define AP_LIST_SYSVSEM_SERIALIZE #endif #if APR_HAS_POSIXSEM_SERIALIZE # define AP_LIST_POSIXSEM_SERIALIZE ", 'posixsem'" #else # define AP_LIST_POSIXSEM_SERIALIZE #endif #if APR_HAS_PROC_PTHREAD_SERIALIZE # define AP_LIST_PTHREAD_SERIALIZE ", 'pthread'" #else # define AP_LIST_PTHREAD_SERIALIZE #endif #if APR_HAS_FLOCK_SERIALIZE || APR_HAS_FCNTL_SERIALIZE # define AP_LIST_FILE_SERIALIZE ", 'file:/path/to/file'" #else # define AP_LIST_FILE_SERIALIZE #endif #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_POSIXSEM_SERIALIZE # define AP_LIST_SEM_SERIALIZE ", 'sem'" #else # define AP_LIST_SEM_SERIALIZE #endif #define AP_ALL_AVAILABLE_MUTEXES_STRING \ "Mutex mechanisms are: 'none', 'default'" \ AP_LIST_FLOCK_SERIALIZE AP_LIST_FCNTL_SERIALIZE \ AP_LIST_FILE_SERIALIZE AP_LIST_PTHREAD_SERIALIZE \ AP_LIST_SYSVSEM_SERIALIZE AP_LIST_POSIXSEM_SERIALIZE \ AP_LIST_SEM_SERIALIZE #define AP_AVAILABLE_MUTEXES_STRING \ "Mutex mechanisms are: 'default'" \ AP_LIST_FLOCK_SERIALIZE AP_LIST_FCNTL_SERIALIZE \ AP_LIST_FILE_SERIALIZE AP_LIST_PTHREAD_SERIALIZE \ AP_LIST_SYSVSEM_SERIALIZE AP_LIST_POSIXSEM_SERIALIZE \ AP_LIST_SEM_SERIALIZE #ifdef __cplusplus extern "C" { #endif /** * Get Mutex config data and parse it * @param arg The mutex config string * @param pool The allocation pool * @param mutexmech The APR mutex locking mechanism * @param mutexfile The lockfile to use as required * @return APR status code * @fn apr_status_t ap_parse_mutex(const char *arg, apr_pool_t *pool, apr_lockmech_e *mutexmech, const char **mutexfile) */ AP_DECLARE(apr_status_t) ap_parse_mutex(const char *arg, apr_pool_t *pool, apr_lockmech_e *mutexmech, const char **mutexfile); /* private function to process the Mutex directive */ AP_DECLARE_NONSTD(const char *) ap_set_mutex(cmd_parms *cmd, void *dummy, const char *arg); /* private function to initialize Mutex infrastructure */ AP_DECLARE_NONSTD(void) ap_mutex_init(apr_pool_t *p); /** * option flags for ap_mutex_register(), ap_global_mutex_create(), and * ap_proc_mutex_create() */ #define AP_MUTEX_ALLOW_NONE 1 /* allow "none" as mutex implementation; * respected only on ap_mutex_register() */ #define AP_MUTEX_DEFAULT_NONE 2 /* default to "none" for this mutex; * respected only on ap_mutex_register() */ /** * Register a module's mutex type with core to allow configuration * with the Mutex directive. This must be called in the pre_config * hook; otherwise, configuration directives referencing this mutex * type will be rejected. * * The default_dir and default_mech parameters allow a module to set * defaults for the lock file directory and mechanism. These could * be based on compile-time settings. These aren't required except * in special circumstances. * * The order of precedence for the choice of mechanism and lock file * directory is: * * 1. Mutex directive specifically for this mutex * e.g., Mutex mpm-default flock:/tmp/mpmlocks * 2. Mutex directive for global default * e.g., Mutex default flock:/tmp/httpdlocks * 3. Defaults for this mutex provided on the ap_mutex_register() * 4. Built-in defaults for all mutexes, which are * APR_LOCK_DEFAULT and DEFAULT_REL_RUNTIMEDIR. * * @param pconf The pconf pool * @param type The type name of the mutex, used as the basename of the * file associated with the mutex, if any. This must be unique among * all mutex types (mutex creation accommodates multi-instance mutex * types); mod_foo might have mutex types "foo-pipe" and "foo-shm" * @param default_dir Default dir for any lock file required for this * lock, to override built-in defaults; should be NULL for most * modules, to respect built-in defaults * @param default_mech Default mechanism for this lock, to override * built-in defaults; should be APR_LOCK_DEFAULT for most modules, to * respect built-in defaults * or NULL if there are no defaults for this mutex. * @param options combination of AP_MUTEX_* constants, or 0 for defaults */ AP_DECLARE(apr_status_t) ap_mutex_register(apr_pool_t *pconf, const char *type, const char *default_dir, apr_lockmech_e default_mech, apr_int32_t options); /** * Create an APR global mutex that has been registered previously with * ap_mutex_register(). Mutex files, permissions, and error logging will * be handled internally. * @param mutex The memory address where the newly created mutex will be * stored. If this mutex is disabled, mutex will be set to NULL on * output. (That is allowed only if the AP_MUTEX_ALLOW_NONE flag is * passed to ap_mutex_register().) * @param name The generated filename of the created mutex, or NULL if * no file was created. Pass NULL if this result is not needed. * @param type The type name of the mutex, matching the type name passed * to ap_mutex_register(). * @param instance_id A unique string to be used in the lock filename IFF * this mutex type is multi-instance, NULL otherwise. * @param server server_rec of main server * @param pool pool lifetime of the mutex * @param options combination of AP_MUTEX_* constants, or 0 for defaults * (currently none are defined for this function) */ AP_DECLARE(apr_status_t) ap_global_mutex_create(apr_global_mutex_t **mutex, const char **name, const char *type, const char *instance_id, server_rec *server, apr_pool_t *pool, apr_int32_t options); /** * Create an APR proc mutex that has been registered previously with * ap_mutex_register(). Mutex files, permissions, and error logging will * be handled internally. * @param mutex The memory address where the newly created mutex will be * stored. If this mutex is disabled, mutex will be set to NULL on * output. (That is allowed only if the AP_MUTEX_ALLOW_NONE flag is * passed to ap_mutex_register().) * @param name The generated filename of the created mutex, or NULL if * no file was created. Pass NULL if this result is not needed. * @param type The type name of the mutex, matching the type name passed * to ap_mutex_register(). * @param instance_id A unique string to be used in the lock filename IFF * this mutex type is multi-instance, NULL otherwise. * @param server server_rec of main server * @param pool pool lifetime of the mutex * @param options combination of AP_MUTEX_* constants, or 0 for defaults * (currently none are defined for this function) */ AP_DECLARE(apr_status_t) ap_proc_mutex_create(apr_proc_mutex_t **mutex, const char **name, const char *type, const char *instance_id, server_rec *server, apr_pool_t *pool, apr_int32_t options); AP_CORE_DECLARE(void) ap_dump_mutexes(apr_pool_t *p, server_rec *s, apr_file_t *out); #ifdef __cplusplus } #endif #endif /* UTIL_MUTEX_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_ssl.h * @brief SSL extension module for Apache * * @defgroup MOD_SSL mod_ssl * @ingroup APACHE_MODS * @{ */ #ifndef __MOD_SSL_H__ #define __MOD_SSL_H__ #include "httpd.h" #include "http_config.h" #include "apr_optional.h" #include "apr_tables.h" /* for apr_array_header_t */ /* Create a set of SSL_DECLARE(type), SSL_DECLARE_NONSTD(type) and * SSL_DECLARE_DATA with appropriate export and import tags for the platform */ #if !defined(WIN32) #define SSL_DECLARE(type) type #define SSL_DECLARE_NONSTD(type) type #define SSL_DECLARE_DATA #elif defined(SSL_DECLARE_STATIC) #define SSL_DECLARE(type) type __stdcall #define SSL_DECLARE_NONSTD(type) type #define SSL_DECLARE_DATA #elif defined(SSL_DECLARE_EXPORT) #define SSL_DECLARE(type) __declspec(dllexport) type __stdcall #define SSL_DECLARE_NONSTD(type) __declspec(dllexport) type #define SSL_DECLARE_DATA __declspec(dllexport) #else #define SSL_DECLARE(type) __declspec(dllimport) type __stdcall #define SSL_DECLARE_NONSTD(type) __declspec(dllimport) type #define SSL_DECLARE_DATA __declspec(dllimport) #endif /** The ssl_var_lookup() optional function retrieves SSL environment * variables. */ APR_DECLARE_OPTIONAL_FN(char *, ssl_var_lookup, (apr_pool_t *, server_rec *, conn_rec *, request_rec *, char *)); /** The ssl_ext_list() optional function attempts to build an array * of all the values contained in the named X.509 extension. The * returned array will be created in the supplied pool. * The client certificate is used if peer is non-zero; the server * certificate is used otherwise. * Extension specifies the extensions to use as a string. This can be * one of the "known" long or short names, or a numeric OID, * e.g. "1.2.3.4", 'nsComment' and 'DN' are all valid. * A pointer to an apr_array_header_t structure is returned if at * least one matching extension is found, NULL otherwise. */ APR_DECLARE_OPTIONAL_FN(apr_array_header_t *, ssl_ext_list, (apr_pool_t *p, conn_rec *c, int peer, const char *extension)); /** An optional function which returns non-zero if the given connection * is using SSL/TLS. */ APR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *)); /** The ssl_proxy_enable() and ssl_engine_{set,disable}() optional * functions are used by mod_proxy to enable use of SSL for outgoing * connections. */ APR_DECLARE_OPTIONAL_FN(int, ssl_proxy_enable, (conn_rec *)); APR_DECLARE_OPTIONAL_FN(int, ssl_engine_disable, (conn_rec *)); APR_DECLARE_OPTIONAL_FN(int, ssl_engine_set, (conn_rec *, ap_conf_vector_t *, int proxy, int enable)); /* Check for availability of new hooks */ #define SSL_CERT_HOOKS #ifdef SSL_CERT_HOOKS /** Lets others add certificate and key files to the given server. * For each cert a key must also be added. * @param cert_file and array of const char* with the path to the certificate chain * @param key_file and array of const char* with the path to the private key file */ APR_DECLARE_EXTERNAL_HOOK(ssl, SSL, int, add_cert_files, (server_rec *s, apr_pool_t *p, apr_array_header_t *cert_files, apr_array_header_t *key_files)) /** In case no certificates are available for a server, this * lets other modules add a fallback certificate for the time * being. Regular requests against this server will be answered * with a 503. * @param cert_file and array of const char* with the path to the certificate chain * @param key_file and array of const char* with the path to the private key file */ APR_DECLARE_EXTERNAL_HOOK(ssl, SSL, int, add_fallback_cert_files, (server_rec *s, apr_pool_t *p, apr_array_header_t *cert_files, apr_array_header_t *key_files)) #endif /* SSL_CERT_HOOKS */ #endif /* __MOD_SSL_H__ */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_cache.h * @brief Main include file for the Apache Transparent Cache * * @defgroup MOD_CACHE mod_cache * @ingroup APACHE_MODS * @{ */ #ifndef MOD_CACHE_H #define MOD_CACHE_H #include "httpd.h" #include "apr_date.h" #include "apr_optional.h" #include "apr_hooks.h" #include "cache_common.h" /* Create a set of CACHE_DECLARE(type), CACHE_DECLARE_NONSTD(type) and * CACHE_DECLARE_DATA with appropriate export and import tags for the platform */ #if !defined(WIN32) #define CACHE_DECLARE(type) type #define CACHE_DECLARE_NONSTD(type) type #define CACHE_DECLARE_DATA #elif defined(CACHE_DECLARE_STATIC) #define CACHE_DECLARE(type) type __stdcall #define CACHE_DECLARE_NONSTD(type) type #define CACHE_DECLARE_DATA #elif defined(CACHE_DECLARE_EXPORT) #define CACHE_DECLARE(type) __declspec(dllexport) type __stdcall #define CACHE_DECLARE_NONSTD(type) __declspec(dllexport) type #define CACHE_DECLARE_DATA __declspec(dllexport) #else #define CACHE_DECLARE(type) __declspec(dllimport) type __stdcall #define CACHE_DECLARE_NONSTD(type) __declspec(dllimport) type #define CACHE_DECLARE_DATA __declspec(dllimport) #endif /* cache info information */ typedef struct cache_info cache_info; struct cache_info { /** * the original time corresponding to the 'Date:' header of the request * served */ apr_time_t date; /** a time when the cached entity is due to expire */ apr_time_t expire; /** r->request_time from the same request */ apr_time_t request_time; /** apr_time_now() at the time the entity was actually cached */ apr_time_t response_time; /** * HTTP status code of the cached entity. Though not necessarily the * status code finally issued to the request. */ int status; /* cached cache-control */ cache_control_t control; }; /* cache handle information */ typedef struct cache_object cache_object_t; struct cache_object { const char *key; cache_object_t *next; cache_info info; /* Opaque portion (specific to the implementation) of the cache object */ void *vobj; }; typedef struct cache_handle cache_handle_t; struct cache_handle { cache_object_t *cache_obj; apr_table_t *req_hdrs; /* cached request headers */ apr_table_t *resp_hdrs; /* cached response headers */ }; #define CACHE_PROVIDER_GROUP "cache" typedef struct { int (*remove_entity) (cache_handle_t *h); apr_status_t (*store_headers)(cache_handle_t *h, request_rec *r, cache_info *i); apr_status_t (*store_body)(cache_handle_t *h, request_rec *r, apr_bucket_brigade *in, apr_bucket_brigade *out); apr_status_t (*recall_headers) (cache_handle_t *h, request_rec *r); apr_status_t (*recall_body) (cache_handle_t *h, apr_pool_t *p, apr_bucket_brigade *bb); int (*create_entity) (cache_handle_t *h, request_rec *r, const char *urlkey, apr_off_t len, apr_bucket_brigade *bb); int (*open_entity) (cache_handle_t *h, request_rec *r, const char *urlkey); int (*remove_url) (cache_handle_t *h, request_rec *r); apr_status_t (*commit_entity)(cache_handle_t *h, request_rec *r); apr_status_t (*invalidate_entity)(cache_handle_t *h, request_rec *r); } cache_provider; typedef enum { AP_CACHE_HIT, AP_CACHE_REVALIDATE, AP_CACHE_MISS, AP_CACHE_INVALIDATE } ap_cache_status_e; #define AP_CACHE_HIT_ENV "cache-hit" #define AP_CACHE_REVALIDATE_ENV "cache-revalidate" #define AP_CACHE_MISS_ENV "cache-miss" #define AP_CACHE_INVALIDATE_ENV "cache-invalidate" #define AP_CACHE_STATUS_ENV "cache-status" /* cache_util.c */ /* do a HTTP/1.1 age calculation */ CACHE_DECLARE(apr_time_t) ap_cache_current_age(cache_info *info, const apr_time_t age_value, apr_time_t now); CACHE_DECLARE(apr_time_t) ap_cache_hex2usec(const char *x); CACHE_DECLARE(void) ap_cache_usec2hex(apr_time_t j, char *y); CACHE_DECLARE(char *) ap_cache_generate_name(apr_pool_t *p, int dirlevels, int dirlength, const char *name); CACHE_DECLARE(const char *)ap_cache_tokstr(apr_pool_t *p, const char *list, const char **str); /* Create a new table consisting of those elements from an * headers table that are allowed to be stored in a cache. */ CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers(apr_pool_t *pool, apr_table_t *t, server_rec *s); /* Create a new table consisting of those elements from an input * headers table that are allowed to be stored in a cache. */ CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers_in(request_rec *r); /* Create a new table consisting of those elements from an output * headers table that are allowed to be stored in a cache; * ensure there is a content type and capture any errors. */ CACHE_DECLARE(apr_table_t *)ap_cache_cacheable_headers_out(request_rec *r); /** * Parse the Cache-Control and Pragma headers in one go, marking * which tokens appear within the header. Populate the structure * passed in. */ int ap_cache_control(request_rec *r, cache_control_t *cc, const char *cc_header, const char *pragma_header, apr_table_t *headers); /* hooks */ /** * Cache status hook. * This hook is called as soon as the cache has made a decision as to whether * an entity should be served from cache (hit), should be served from cache * after a successful validation (revalidate), or served from the backend * and potentially cached (miss). * * A basic implementation of this hook exists in mod_cache which writes this * information to the subprocess environment, and optionally to request * headers. Further implementations may add hooks as appropriate to perform * more advanced processing, or to store statistics about the cache behaviour. */ APR_DECLARE_EXTERNAL_HOOK(cache, CACHE, int, cache_status, (cache_handle_t *h, request_rec *r, apr_table_t *headers, ap_cache_status_e status, const char *reason)) APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_cache_generate_key, (request_rec *r, apr_pool_t*p, const char **key)); #endif /*MOD_CACHE_H*/ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_status.h * @brief Status Report Extension Module to Apache * * @defgroup MOD_STATUS mod_status * @ingroup APACHE_MODS * @{ */ #ifndef MOD_STATUS_H #define MOD_STATUS_H #include "ap_config.h" #include "httpd.h" #define AP_STATUS_SHORT (0x1) /* short, non-HTML report requested */ #define AP_STATUS_NOTABLE (0x2) /* HTML report without tables */ #define AP_STATUS_EXTENDED (0x4) /* detailed report */ #if !defined(WIN32) #define STATUS_DECLARE(type) type #define STATUS_DECLARE_NONSTD(type) type #define STATUS_DECLARE_DATA #elif defined(STATUS_DECLARE_STATIC) #define STATUS_DECLARE(type) type __stdcall #define STATUS_DECLARE_NONSTD(type) type #define STATUS_DECLARE_DATA #elif defined(STATUS_DECLARE_EXPORT) #define STATUS_DECLARE(type) __declspec(dllexport) type __stdcall #define STATUS_DECLARE_NONSTD(type) __declspec(dllexport) type #define STATUS_DECLARE_DATA __declspec(dllexport) #else #define STATUS_DECLARE(type) __declspec(dllimport) type __stdcall #define STATUS_DECLARE_NONSTD(type) __declspec(dllimport) type #define STATUS_DECLARE_DATA __declspec(dllimport) #endif /* Optional hooks which can insert extra content into the mod_status * output. FLAGS will be set to the bitwise OR of any of the * AP_STATUS_* flags. * * Implementations of this hook should generate content using * functions in the ap_rputs/ap_rprintf family; each hook should * return OK or DECLINED. */ APR_DECLARE_EXTERNAL_HOOK(ap, STATUS, int, status_hook, (request_rec *r, int flags)) #endif /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_cookies.h * @brief Apache cookie library */ #ifndef UTIL_COOKIES_H #define UTIL_COOKIES_H #ifdef __cplusplus extern "C" { #endif /** * @defgroup APACHE_CORE_COOKIE Cookies * @ingroup APACHE_CORE * * RFC2109 and RFC2965 compliant HTTP cookies can be read from and written * to using this set of functions. * * @{ * */ #include "apr_errno.h" #include "httpd.h" #define SET_COOKIE "Set-Cookie" #define SET_COOKIE2 "Set-Cookie2" #define DEFAULT_ATTRS "HttpOnly;Secure;Version=1" #define CLEAR_ATTRS "Version=1" typedef struct { request_rec *r; const char *name; const char *encoded; apr_table_t *new_cookies; int duplicated; } ap_cookie_do; /** * Write an RFC2109 compliant cookie. * * @param r The request * @param name The name of the cookie. * @param val The value to place in the cookie. * @param attrs The string containing additional cookie attributes. If NULL, the * DEFAULT_ATTRS will be used. * @param maxage If non zero, a Max-Age header will be added to the cookie. * @param ... A varargs array of zero or more (apr_table_t *) tables followed by NULL * to which the cookies should be added. */ AP_DECLARE(apr_status_t) ap_cookie_write(request_rec * r, const char *name, const char *val, const char *attrs, long maxage, ...) AP_FN_ATTR_SENTINEL; /** * Write an RFC2965 compliant cookie. * * @param r The request * @param name2 The name of the cookie. * @param val The value to place in the cookie. * @param attrs2 The string containing additional cookie attributes. If NULL, the * DEFAULT_ATTRS will be used. * @param maxage If non zero, a Max-Age header will be added to the cookie. * @param ... A varargs array of zero or more (apr_table_t *) tables followed by NULL * to which the cookies should be added. */ AP_DECLARE(apr_status_t) ap_cookie_write2(request_rec * r, const char *name2, const char *val, const char *attrs2, long maxage, ...) AP_FN_ATTR_SENTINEL; /** * Remove an RFC2109 compliant cookie. * * @param r The request * @param name The name of the cookie. * @param attrs The string containing additional cookie attributes. If NULL, the * CLEAR_ATTRS will be used. * @param ... A varargs array of zero or more (apr_table_t *) tables followed by NULL * to which the cookies should be added. */ AP_DECLARE(apr_status_t) ap_cookie_remove(request_rec * r, const char *name, const char *attrs, ...) AP_FN_ATTR_SENTINEL; /** * Remove an RFC2965 compliant cookie. * * @param r The request * @param name2 The name of the cookie. * @param attrs2 The string containing additional cookie attributes. If NULL, the * CLEAR_ATTRS will be used. * @param ... A varargs array of zero or more (apr_table_t *) tables followed by NULL * to which the cookies should be added. */ AP_DECLARE(apr_status_t) ap_cookie_remove2(request_rec * r, const char *name2, const char *attrs2, ...) AP_FN_ATTR_SENTINEL; /** * Read a cookie called name, placing its value in val. * * Both the Cookie and Cookie2 headers are scanned for the cookie. * * If the cookie is duplicated, this function returns APR_EGENERAL. If found, * and if remove is non zero, the cookie will be removed from the headers, and * thus kept private from the backend. */ AP_DECLARE(apr_status_t) ap_cookie_read(request_rec * r, const char *name, const char **val, int remove); /** * Sanity check a given string that it exists, is not empty, * and does not contain the special characters '=', ';' and '&'. * * It is used to sanity check the cookie names. */ AP_DECLARE(apr_status_t) ap_cookie_check_string(const char *string); /** * @} */ #ifdef __cplusplus } #endif #endif /* !UTIL_COOKIES_H */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file ap_hooks.h * @brief ap hook functions and macros */ #ifndef AP_HOOKS_H #define AP_HOOKS_H /* Although this file doesn't declare any hooks, declare the hook group here */ /** * @defgroup hooks Apache Hooks * @ingroup APACHE_CORE */ #if defined(AP_HOOK_PROBES_ENABLED) && !defined(APR_HOOK_PROBES_ENABLED) #define APR_HOOK_PROBES_ENABLED 1 #endif #ifdef APR_HOOK_PROBES_ENABLED #include "ap_hook_probes.h" #endif #include "apr.h" #include "apr_hooks.h" #include "apr_optional_hooks.h" #ifdef DOXYGEN /* define these just so doxygen documents them */ /** * AP_DECLARE_STATIC is defined when including Apache's Core headers, * to provide static linkage when the dynamic library may be unavailable. * * @see AP_DECLARE_EXPORT * * AP_DECLARE_STATIC and AP_DECLARE_EXPORT are left undefined when * including Apache's Core headers, to import and link the symbols from the * dynamic Apache Core library and assure appropriate indirection and calling * conventions at compile time. */ # define AP_DECLARE_STATIC /** * AP_DECLARE_EXPORT is defined when building the Apache Core dynamic * library, so that all public symbols are exported. * * @see AP_DECLARE_STATIC */ # define AP_DECLARE_EXPORT #endif /* def DOXYGEN */ /** * Declare a hook function * @param ret The return type of the hook * @param name The hook's name (as a literal) * @param args The arguments the hook function takes, in brackets. */ #define AP_DECLARE_HOOK(ret,name,args) \ APR_DECLARE_EXTERNAL_HOOK(ap,AP,ret,name,args) /** @internal */ #define AP_IMPLEMENT_HOOK_BASE(name) \ APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ap,AP,name) /** * Implement an Apache core hook that has no return code, and * therefore runs all of the registered functions. The implementation * is called ap_run_<i>name</i>. * * @param name The name of the hook * @param args_decl The declaration of the arguments for the hook, for example * "(int x,void *y)" * @param args_use The arguments for the hook as used in a call, for example * "(x,y)" * @note If IMPLEMENTing a hook that is not linked into the Apache core, * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_VOID. */ #define AP_IMPLEMENT_HOOK_VOID(name,args_decl,args_use) \ APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ap,AP,name,args_decl,args_use) /** * Implement an Apache core hook that runs until one of the functions * returns something other than ok or decline. That return value is * then returned from the hook runner. If the hooks run to completion, * then ok is returned. Note that if no hook runs it would probably be * more correct to return decline, but this currently does not do * so. The implementation is called ap_run_<i>name</i>. * * @param ret The return type of the hook (and the hook runner) * @param name The name of the hook * @param args_decl The declaration of the arguments for the hook, for example * "(int x,void *y)" * @param args_use The arguments for the hook as used in a call, for example * "(x,y)" * @param ok The "ok" return value * @param decline The "decline" return value * @return ok, decline or an error. * @note If IMPLEMENTing a hook that is not linked into the Apache core, * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL. */ #define AP_IMPLEMENT_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \ APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \ args_use,ok,decline) /** * Implement a hook that runs until a function returns something other than * decline. If all functions return decline, the hook runner returns decline. * The implementation is called ap_run_<i>name</i>. * * @param ret The return type of the hook (and the hook runner) * @param name The name of the hook * @param args_decl The declaration of the arguments for the hook, for example * "(int x,void *y)" * @param args_use The arguments for the hook as used in a call, for example * "(x,y)" * @param decline The "decline" return value * @return decline or an error. * @note If IMPLEMENTing a hook that is not linked into the Apache core * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST. */ #define AP_IMPLEMENT_HOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \ APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap,AP,ret,name,args_decl, \ args_use,decline) /* Note that the other optional hook implementations are straightforward but * have not yet been needed */ /** * Implement an optional hook. This is exactly the same as a standard hook * implementation, except the hook is optional. * @see AP_IMPLEMENT_HOOK_RUN_ALL */ #define AP_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok, \ decline) \ APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \ args_use,ok,decline) /** * Hook an optional hook. Unlike static hooks, this uses a macro instead of a * function. */ #define AP_OPTIONAL_HOOK(name,fn,pre,succ,order) \ APR_OPTIONAL_HOOK(ap,name,fn,pre,succ,order) #endif /* AP_HOOKS_H */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* This code is based on pcreposix.h from the PCRE Library distribution, * as originally written by Philip Hazel <ph10@cam.ac.uk>, and forked by * the Apache HTTP Server project to provide POSIX-style regex function * wrappers around underlying PCRE library functions for httpd. * * The original source file pcreposix.h is copyright and licensed as follows; Copyright (c) 1997-2004 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of Cambridge nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------------- */ /** * @file ap_regex.h * @brief Apache Regex defines */ #ifndef AP_REGEX_H #define AP_REGEX_H #include "apr.h" /* Allow for C++ users */ #ifdef __cplusplus extern "C" { #endif /* Options for ap_regcomp, ap_regexec, and ap_rxplus versions: */ #define AP_REG_ICASE 0x01 /** use a case-insensitive match */ #define AP_REG_NEWLINE 0x02 /** don't match newlines against '.' etc */ #define AP_REG_NOTBOL 0x04 /** ^ will not match against start-of-string */ #define AP_REG_NOTEOL 0x08 /** $ will not match against end-of-string */ #define AP_REG_EXTENDED (0) /** unused */ #define AP_REG_NOSUB (0) /** unused */ #define AP_REG_MULTI 0x10 /* perl's /g (needs fixing) */ #define AP_REG_NOMEM 0x20 /* nomem in our code */ #define AP_REG_DOTALL 0x40 /* perl's /s flag */ #define AP_REG_DOLLAR_ENDONLY 0x200 /* '$' matches at end of subject string only */ #define AP_REG_NO_DEFAULT 0x400 /**< Don't implicitely add AP_REG_DEFAULT options */ #define AP_REG_MATCH "MATCH_" /**< suggested prefix for ap_regname */ #define AP_REG_DEFAULT (AP_REG_DOTALL|AP_REG_DOLLAR_ENDONLY) /* Arguments for ap_pcre_version_string */ enum { AP_REG_PCRE_COMPILED = 0, /** PCRE version used during program compilation */ AP_REG_PCRE_LOADED /** PCRE version loaded at runtime */ }; /* Error values: */ enum { AP_REG_ASSERT = 1, /** internal error ? */ AP_REG_ESPACE, /** failed to get memory */ AP_REG_INVARG, /** invalid argument */ AP_REG_NOMATCH /** match failed */ }; /* The structure representing a compiled regular expression. */ typedef struct { void *re_pcre; int re_nsub; apr_size_t re_erroffset; } ap_regex_t; /* The structure in which a captured offset is returned. */ typedef struct { int rm_so; int rm_eo; } ap_regmatch_t; /* The functions */ /** * Return PCRE version string. * @param which Either AP_REG_PCRE_COMPILED (PCRE version used * during program compilation) or AP_REG_PCRE_LOADED * (PCRE version used at runtime) * @return The PCRE version string */ AP_DECLARE(const char *) ap_pcre_version_string(int which); /** * Get default compile flags * @return Bitwise OR of AP_REG_* flags */ AP_DECLARE(int) ap_regcomp_get_default_cflags(void); /** * Set default compile flags * @param cflags Bitwise OR of AP_REG_* flags */ AP_DECLARE(void) ap_regcomp_set_default_cflags(int cflags); /** * Get the AP_REG_* corresponding to the string. * @param name The name (i.e. AP_REG_<name>) * @return The AP_REG_*, or zero if the string is unknown * */ AP_DECLARE(int) ap_regcomp_default_cflag_by_name(const char *name); /** * Compile a regular expression. * @param preg Returned compiled regex * @param regex The regular expression string * @param cflags Bitwise OR of AP_REG_* flags (ICASE and NEWLINE supported, * other flags are ignored) * @return Zero on success or non-zero on error */ AP_DECLARE(int) ap_regcomp(ap_regex_t *preg, const char *regex, int cflags); /** * Match a NUL-terminated string against a pre-compiled regex. * @param preg The pre-compiled regex * @param string The string to match * @param nmatch Provide information regarding the location of any matches * @param pmatch Provide information regarding the location of any matches * @param eflags Bitwise OR of AP_REG_* flags (NOTBOL and NOTEOL supported, * other flags are ignored) * @return 0 for successful match, \p AP_REG_NOMATCH otherwise */ AP_DECLARE(int) ap_regexec(const ap_regex_t *preg, const char *string, apr_size_t nmatch, ap_regmatch_t *pmatch, int eflags); /** * Match a string with given length against a pre-compiled regex. The string * does not need to be NUL-terminated. * @param preg The pre-compiled regex * @param buff The string to match * @param len Length of the string to match * @param nmatch Provide information regarding the location of any matches * @param pmatch Provide information regarding the location of any matches * @param eflags Bitwise OR of AP_REG_* flags (NOTBOL and NOTEOL supported, * other flags are ignored) * @return 0 for successful match, AP_REG_NOMATCH otherwise */ AP_DECLARE(int) ap_regexec_len(const ap_regex_t *preg, const char *buff, apr_size_t len, apr_size_t nmatch, ap_regmatch_t *pmatch, int eflags); /** * Return the error code returned by regcomp or regexec into error messages * @param errcode the error code returned by regexec or regcomp * @param preg The precompiled regex * @param errbuf A buffer to store the error in * @param errbuf_size The size of the buffer */ AP_DECLARE(apr_size_t) ap_regerror(int errcode, const ap_regex_t *preg, char *errbuf, apr_size_t errbuf_size); /** * Return an array of named regex backreferences * @param preg The precompiled regex * @param names The array to which the names will be added * @param prefix An optional prefix to add to the returned names. AP_REG_MATCH * is the recommended prefix. * @param upper If non zero, uppercase the names * @return number of regex backrefernces returned, -1 for error * for successful match, AP_REG_NOMATCH otherwise */ AP_DECLARE(int) ap_regname(const ap_regex_t *preg, apr_array_header_t *names, const char *prefix, int upper); /** Destroy a pre-compiled regex. * @param preg The pre-compiled regex to free. */ AP_DECLARE(void) ap_regfree(ap_regex_t *preg); /* ap_rxplus: higher-level regexps */ typedef struct { ap_regex_t rx; apr_uint32_t flags; const char *subs; const char *match; apr_size_t nmatch; ap_regmatch_t *pmatch; } ap_rxplus_t; /** * Compile a pattern into a regexp. * supports perl-like formats * match-string * /match-string/flags * s/match-string/replacement-string/flags * Intended to support more perl-like stuff as and when round tuits happen * match-string is anything supported by ap_regcomp * replacement-string is a substitution string as supported in ap_pregsub * flags should correspond with perl syntax: treat failure to do so as a bug * (documentation TBD) * @param pool Pool to allocate from * @param pattern Pattern to compile * @return Compiled regexp, or NULL in case of compile/syntax error */ AP_DECLARE(ap_rxplus_t*) ap_rxplus_compile(apr_pool_t *pool, const char *pattern); /** * Apply a regexp operation to a string. * @param pool Pool to allocate from * @param rx The regex match to apply * @param pattern The string to apply it to * NOTE: This MUST be kept in scope to use regexp memory * @param newpattern The modified string (ignored if the operation doesn't * modify the string) * @return Number of times a match happens. Normally 0 (no match) or 1 * (match found), but may be greater if a transforming pattern * is applied with the 'g' flag. */ AP_DECLARE(int) ap_rxplus_exec(apr_pool_t *pool, ap_rxplus_t *rx, const char *pattern, char **newpattern); #ifdef DOXYGEN /** * Number of matches in the regexp operation's memory * This may be 0 if no match is in memory, or up to nmatch from compilation * @param rx The regexp * @return Number of matches in memory */ AP_DECLARE(int) ap_rxplus_nmatch(ap_rxplus_t *rx); #else #define ap_rxplus_nmatch(rx) (((rx)->match != NULL) ? (rx)->nmatch : 0) #endif /** * Get a pointer to a match from regex memory * NOTE: this relies on the match pattern from the last call to * ap_rxplus_exec still being valid (i.e. not freed or out-of-scope) * @param rx The regexp * @param n The match number to retrieve (must be between 0 and nmatch) * @param len Returns the length of the match. * @param match Returns the match pattern */ AP_DECLARE(void) ap_rxplus_match(ap_rxplus_t *rx, int n, int *len, const char **match); /** * Get a match from regex memory in a string copy * NOTE: this relies on the match pattern from the last call to * ap_rxplus_exec still being valid (i.e. not freed or out-of-scope) * @param pool Pool to allocate from * @param rx The regexp * @param n The match number to retrieve (must be between 0 and nmatch) * @return The matched string */ AP_DECLARE(char*) ap_rxplus_pmatch(apr_pool_t *pool, ap_rxplus_t *rx, int n); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* AP_REGEX_T */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_so.h * @brief Shared Object Loader Extension Module for Apache * * @defgroup MOD_SO mod_so * @ingroup APACHE_MODS * @{ */ #ifndef MOD_SO_H #define MOD_SO_H 1 #include "apr_optional.h" #include "httpd.h" /* optional function declaration */ APR_DECLARE_OPTIONAL_FN(module *, ap_find_loaded_module_symbol, (server_rec *s, const char *modname)); #endif /* MOD_SO_H */ /** @} */ /* include/ap_config_auto.h. Generated from ap_config_auto.h.in by configure. */ /* include/ap_config_auto.h.in. Generated from configure.in by autoheader. */ /* SuExec root directory */ #define AP_DOC_ROOT "/" /* Enable DTrace probes */ /* #undef AP_ENABLE_DTRACE */ /* Allow modules to run hook after a fatal exception */ /* #undef AP_ENABLE_EXCEPTION_HOOK */ /* Allow IPv4 connections on IPv6 listening sockets */ /* #undef AP_ENABLE_V4_MAPPED */ /* Minimum allowed GID */ #define AP_GID_MIN 100 /* Enable the APR hook probes capability, reading from ap_hook_probes.h */ /* #undef AP_HOOK_PROBES_ENABLED */ /* User allowed to call SuExec */ #define AP_HTTPD_USER "nobody" /* SuExec log file */ #define AP_LOG_EXEC "/etc/apache2/logs/suexec_log" /* SuExec log to syslog */ /* #undef AP_LOG_SYSLOG */ /* Listening sockets are non-blocking when there are more than 1 */ #define AP_NONBLOCK_WHEN_MULTI_LISTEN 1 /* safe dir */ /* #undef AP_SAFE_DIRECTORY */ /* safe shell path for SuExec */ /* #undef AP_SAFE_PATH */ /* Enable if suexec is installed with Linux capabilities, not setuid */ #define AP_SUEXEC_CAPABILITIES 1 /* umask for suexec'd process */ /* #undef AP_SUEXEC_UMASK */ /* Location of the MIME types config file, relative to the Apache root directory */ #define AP_TYPES_CONFIG_FILE "conf/mime.types" /* Minimum allowed UID */ #define AP_UID_MIN 100 /* User subdirectory */ /* #undef AP_USERDIR_SUFFIX */ /* Using autoconf to configure Apache */ #define AP_USING_AUTOCONF 1 /* Define as default argument for thread id in error logging */ #define DEFAULT_LOG_TID "g" /* Define to 1 if you have the `arc4random_buf' function. */ /* #undef HAVE_ARC4RANDOM_BUF */ /* Define to 1 if you have the `bindprocessor' function. */ /* #undef HAVE_BINDPROCESSOR */ /* Define to 1 if you have the <bstring.h> header file. */ /* #undef HAVE_BSTRING_H */ /* Enable FD passing support in mod_cgid */ /* #undef HAVE_CGID_FDPASSING */ /* Define if crypt() supports SHA-2 hashes */ #define HAVE_CRYPT_SHA2 1 /* Define if curl is available */ /* #undef HAVE_CURL */ /* Define to 1 if you have the <curl/curl.h> header file. */ /* #undef HAVE_CURL_CURL_H */ /* Define if distcache support is enabled */ /* #undef HAVE_DISTCACHE */ /* Define to 1 if you have the <distcache/dc_client.h> header file. */ /* #undef HAVE_DISTCACHE_DC_CLIENT_H */ /* Define to 1 if you have the `ENGINE_init' function. */ #define HAVE_ENGINE_INIT 1 /* Define to 1 if you have the `ENGINE_load_builtin_engines' function. */ #define HAVE_ENGINE_LOAD_BUILTIN_ENGINES 1 /* Define to 1 if you have the `epoll_create' function. */ #define HAVE_EPOLL_CREATE 1 /* Define to 1 if you have the `fopen64' function. */ #define HAVE_FOPEN64 1 /* Define to 1 if you have the `getgrnam' function. */ #define HAVE_GETGRNAM 1 /* Define to 1 if you have the `getloadavg' function. */ #define HAVE_GETLOADAVG 1 /* Define to 1 if you have the `getpgid' function. */ #define HAVE_GETPGID 1 /* Define to 1 if you have the `getpwnam' function. */ #define HAVE_GETPWNAM 1 /* Define to 1 if you have the `gettid' function. */ #define HAVE_GETTID 1 /* Define if struct tm has a tm_gmtoff field */ #define HAVE_GMTOFF 1 /* Define to 1 if you have the <grp.h> header file. */ #define HAVE_GRP_H 1 /* Define to 1 if you have the `initgroups' function. */ #define HAVE_INITGROUPS 1 /* Define to 1 if you have the <inttypes.h> header file. */ #define HAVE_INTTYPES_H 1 /* Define if jansson is available */ /* #undef HAVE_JANSSON */ /* Define to 1 if you have the `killpg' function. */ #define HAVE_KILLPG 1 /* Define to 1 if you have the `kqueue' function. */ /* #undef HAVE_KQUEUE */ /* Define to 1 if you have the <limits.h> header file. */ #define HAVE_LIMITS_H 1 /* Define to 1 if you have the <memory.h> header file. */ #define HAVE_MEMORY_H 1 /* Define if nghttp2 is available */ #define HAVE_NGHTTP2 1 /* Define to 1 if you have the <nghttp2/nghttp2.h> header file. */ #define HAVE_NGHTTP2_NGHTTP2_H 1 /* Define to 1 if you have the `nghttp2_option_set_no_closed_streams' function. */ #define HAVE_NGHTTP2_OPTION_SET_NO_CLOSED_STREAMS 1 /* Define to 1 if you have the `nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation' function. */ #define HAVE_NGHTTP2_OPTION_SET_NO_RFC9113_LEADING_AND_TRAILING_WS_VALIDATION 1 /* Define to 1 if you have the `nghttp2_session_callbacks_set_on_invalid_header_callback' function. */ #define HAVE_NGHTTP2_SESSION_CALLBACKS_SET_ON_INVALID_HEADER_CALLBACK 1 /* Define to 1 if you have the `nghttp2_session_change_stream_priority' function. */ #define HAVE_NGHTTP2_SESSION_CHANGE_STREAM_PRIORITY 1 /* Define to 1 if you have the `nghttp2_session_get_stream_local_window_size' function. */ #define HAVE_NGHTTP2_SESSION_GET_STREAM_LOCAL_WINDOW_SIZE 1 /* Define to 1 if you have the `nghttp2_session_server_new2' function. */ #define HAVE_NGHTTP2_SESSION_SERVER_NEW2 1 /* Define to 1 if you have the `nghttp2_stream_get_weight' function. */ #define HAVE_NGHTTP2_STREAM_GET_WEIGHT 1 /* Define if OpenSSL is available */ #define HAVE_OPENSSL 1 /* Define to 1 if you have the <openssl/engine.h> header file. */ #define HAVE_OPENSSL_ENGINE_H 1 /* Define to 1 if you have the `OPENSSL_init_ssl' function. */ #define HAVE_OPENSSL_INIT_SSL 1 /* Detected PCRE2 */ #define HAVE_PCRE2 1 /* Define to 1 if you have the `port_create' function. */ /* #undef HAVE_PORT_CREATE */ /* Define to 1 if you have the `prctl' function. */ #define HAVE_PRCTL 1 /* Define to 1 if you have the <priv.h> header file. */ /* #undef HAVE_PRIV_H */ /* Define to 1 if you have the `procctl' function. */ /* #undef HAVE_PROCCTL */ /* Define to 1 if you have the `pthread_kill' function. */ #define HAVE_PTHREAD_KILL 1 /* Define to 1 if you have the <pwd.h> header file. */ #define HAVE_PWD_H 1 /* Define to 1 if you have the `RAND_egd' function. */ /* #undef HAVE_RAND_EGD */ /* Defined if SELinux is supported */ #define HAVE_SELINUX 1 /* Define to 1 if you have the `setsid' function. */ #define HAVE_SETSID 1 /* Define to 1 if you have the `SSL_CTX_new' function. */ #define HAVE_SSL_CTX_NEW 1 /* Define to 1 if you have the <stdint.h> header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the <stdlib.h> header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the <strings.h> header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the <string.h> header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the `syslog' function. */ #define HAVE_SYSLOG 1 /* Define if systemd is supported */ #define HAVE_SYSTEMD 1 /* Define to 1 if you have the <systemd/sd-daemon.h> header file. */ #define HAVE_SYSTEMD_SD_DAEMON_H 1 /* Define if you have gettid() via syscall() */ /* #undef HAVE_SYS_GETTID */ /* Define to 1 if you have the <sys/ipc.h> header file. */ #define HAVE_SYS_IPC_H 1 /* Define to 1 if you have the <sys/loadavg.h> header file. */ /* #undef HAVE_SYS_LOADAVG_H */ /* Define to 1 if you have the <sys/prctl.h> header file. */ #define HAVE_SYS_PRCTL_H 1 /* Define to 1 if you have the <sys/procctl.h> header file. */ /* #undef HAVE_SYS_PROCCTL_H */ /* Define to 1 if you have the <sys/processor.h> header file. */ /* #undef HAVE_SYS_PROCESSOR_H */ /* Define to 1 if you have the <sys/resource.h> header file. */ #define HAVE_SYS_RESOURCE_H 1 /* Define to 1 if you have the <sys/sdt.h> header file. */ #define HAVE_SYS_SDT_H 1 /* Define to 1 if you have the <sys/sem.h> header file. */ #define HAVE_SYS_SEM_H 1 /* Define to 1 if you have the <sys/socket.h> header file. */ #define HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the <sys/stat.h> header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the <sys/times.h> header file. */ #define HAVE_SYS_TIMES_H 1 /* Define to 1 if you have the <sys/time.h> header file. */ #define HAVE_SYS_TIME_H 1 /* Define to 1 if you have the <sys/types.h> header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */ #define HAVE_SYS_WAIT_H 1 /* Define to 1 if you have the `timegm' function. */ #define HAVE_TIMEGM 1 /* Define to 1 if you have the `times' function. */ #define HAVE_TIMES 1 /* Define to 1 if you have the <unistd.h> header file. */ #define HAVE_UNISTD_H 1 /* Define to 1 if you have the `vsyslog' function. */ /* #undef HAVE_VSYSLOG */ /* Root directory of the Apache install area */ #define HTTPD_ROOT "/etc/apache2" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define PACKAGE_NAME "" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "" /* Location of the config file, relative to the Apache root directory */ #define SERVER_CONFIG_FILE "conf/httpd.conf" /* This platform doesn't suffer from the thundering herd problem */ #define SINGLE_LISTEN_UNSERIALIZED_ACCEPT 1 /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Path to suexec binary */ #define SUEXEC_BIN "/usr/sbin/suexec" /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # define _ALL_SOURCE 1 #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # define _POSIX_PTHREAD_SEMANTICS 1 #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # define _TANDEM_SOURCE 1 #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # define __EXTENSIONS__ 1 #endif /* Define to 1 if on MINIX. */ /* #undef _MINIX */ /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ /* #undef _POSIX_1_SOURCE */ /* Define to 1 if you need to in order for `stat' and other things to work. */ /* #undef _POSIX_SOURCE */ /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ /* Define to 'int' if <sys/resource.h> doesn't define it for us */ /* #undef rlim_t */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_unixd.h * @brief common stuff that unix MPMs will want * * @addtogroup APACHE_OS_UNIX * @{ */ #ifndef MOD_UNIXD_H #define MOD_UNIXD_H #include "ap_config.h" #ifdef __cplusplus extern "C" { #endif AP_DECLARE(int) ap_unixd_setup_child(void); #ifdef __cplusplus } #endif #endif /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file http_config.h * @brief Apache Configuration * * @defgroup APACHE_CORE_CONFIG Configuration * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_HTTP_CONFIG_H #define APACHE_HTTP_CONFIG_H #include "util_cfgtree.h" #include "ap_config.h" #include "apr_tables.h" #ifdef __cplusplus extern "C" { #endif /* * The central data structures around here... */ /* Command dispatch structures... */ /** * How the directives arguments should be parsed. * @remark Note that for all of these except RAW_ARGS, the config routine is * passed a freshly allocated string which can be modified or stored * or whatever... */ enum cmd_how { RAW_ARGS, /**< cmd_func parses command line itself */ TAKE1, /**< one argument only */ TAKE2, /**< two arguments only */ ITERATE, /**< one argument, occurring multiple times * (e.g., IndexIgnore) */ ITERATE2, /**< two arguments, 2nd occurs multiple times * (e.g., AddIcon) */ FLAG, /**< One of 'On' or 'Off' */ NO_ARGS, /**< No args at all, e.g. </Directory> */ TAKE12, /**< one or two arguments */ TAKE3, /**< three arguments only */ TAKE23, /**< two or three arguments */ TAKE123, /**< one, two or three arguments */ TAKE13, /**< one or three arguments */ TAKE_ARGV /**< an argc and argv are passed */ }; /** * This structure is passed to a command which is being invoked, * to carry a large variety of miscellaneous data which is all of * use to *somebody*... */ typedef struct cmd_parms_struct cmd_parms; #if defined(AP_HAVE_DESIGNATED_INITIALIZER) || defined(DOXYGEN) /** * All the types of functions that can be used in directives * @internal */ typedef union { /** function to call for a no-args */ const char *(*no_args) (cmd_parms *parms, void *mconfig); /** function to call for a raw-args */ const char *(*raw_args) (cmd_parms *parms, void *mconfig, const char *args); /** function to call for a argv/argc */ const char *(*take_argv) (cmd_parms *parms, void *mconfig, int argc, char *const argv[]); /** function to call for a take1 */ const char *(*take1) (cmd_parms *parms, void *mconfig, const char *w); /** function to call for a take2 */ const char *(*take2) (cmd_parms *parms, void *mconfig, const char *w, const char *w2); /** function to call for a take3 */ const char *(*take3) (cmd_parms *parms, void *mconfig, const char *w, const char *w2, const char *w3); /** function to call for a flag */ const char *(*flag) (cmd_parms *parms, void *mconfig, int on); } cmd_func; /** This configuration directive does not take any arguments */ # define AP_NO_ARGS func.no_args /** This configuration directive will handle its own parsing of arguments*/ # define AP_RAW_ARGS func.raw_args /** This configuration directive will handle its own parsing of arguments*/ # define AP_TAKE_ARGV func.take_argv /** This configuration directive takes 1 argument*/ # define AP_TAKE1 func.take1 /** This configuration directive takes 2 arguments */ # define AP_TAKE2 func.take2 /** This configuration directive takes 3 arguments */ # define AP_TAKE3 func.take3 /** This configuration directive takes a flag (on/off) as a argument*/ # define AP_FLAG func.flag /** mechanism for declaring a directive with no arguments */ # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \ { directive, { .no_args=func }, mconfig, where, RAW_ARGS, help } /** mechanism for declaring a directive with raw argument parsing */ # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \ { directive, { .raw_args=func }, mconfig, where, RAW_ARGS, help } /** mechanism for declaring a directive with raw argument parsing */ # define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \ { directive, { .take_argv=func }, mconfig, where, TAKE_ARGV, help } /** mechanism for declaring a directive which takes 1 argument */ # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \ { directive, { .take1=func }, mconfig, where, TAKE1, help } /** mechanism for declaring a directive which takes multiple arguments */ # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \ { directive, { .take1=func }, mconfig, where, ITERATE, help } /** mechanism for declaring a directive which takes 2 arguments */ # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \ { directive, { .take2=func }, mconfig, where, TAKE2, help } /** mechanism for declaring a directive which takes 1 or 2 arguments */ # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \ { directive, { .take2=func }, mconfig, where, TAKE12, help } /** mechanism for declaring a directive which takes multiple 2 arguments */ # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \ { directive, { .take2=func }, mconfig, where, ITERATE2, help } /** mechanism for declaring a directive which takes 1 or 3 arguments */ # define AP_INIT_TAKE13(directive, func, mconfig, where, help) \ { directive, { .take3=func }, mconfig, where, TAKE13, help } /** mechanism for declaring a directive which takes 2 or 3 arguments */ # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \ { directive, { .take3=func }, mconfig, where, TAKE23, help } /** mechanism for declaring a directive which takes 1 to 3 arguments */ # define AP_INIT_TAKE123(directive, func, mconfig, where, help) \ { directive, { .take3=func }, mconfig, where, TAKE123, help } /** mechanism for declaring a directive which takes 3 arguments */ # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \ { directive, { .take3=func }, mconfig, where, TAKE3, help } /** mechanism for declaring a directive which takes a flag (on/off) argument */ # define AP_INIT_FLAG(directive, func, mconfig, where, help) \ { directive, { .flag=func }, mconfig, where, FLAG, help } #else /* AP_HAVE_DESIGNATED_INITIALIZER */ typedef const char *(*cmd_func) (); # define AP_NO_ARGS func # define AP_RAW_ARGS func # define AP_TAKE_ARGV func # define AP_TAKE1 func # define AP_TAKE2 func # define AP_TAKE3 func # define AP_FLAG func # define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, RAW_ARGS, help } # define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, RAW_ARGS, help } # define AP_INIT_TAKE_ARGV(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, TAKE_ARGV, help } # define AP_INIT_TAKE1(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, TAKE1, help } # define AP_INIT_ITERATE(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, ITERATE, help } # define AP_INIT_TAKE2(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, TAKE2, help } # define AP_INIT_TAKE12(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, TAKE12, help } # define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, ITERATE2, help } # define AP_INIT_TAKE13(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, TAKE13, help } # define AP_INIT_TAKE23(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, TAKE23, help } # define AP_INIT_TAKE123(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, TAKE123, help } # define AP_INIT_TAKE3(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, TAKE3, help } # define AP_INIT_FLAG(directive, func, mconfig, where, help) \ { directive, func, mconfig, where, FLAG, help } #endif /* AP_HAVE_DESIGNATED_INITIALIZER */ /** * The command record structure. Modules can define a table of these * to define the directives it will implement. */ typedef struct command_struct command_rec; struct command_struct { /** Name of this command */ const char *name; /** The function to be called when this directive is parsed */ cmd_func func; /** Extra data, for functions which implement multiple commands... */ void *cmd_data; /** What overrides need to be allowed to enable this command. */ int req_override; /** What the command expects as arguments */ enum cmd_how args_how; /** 'usage' message, in case of syntax errors */ const char *errmsg; }; /** * @defgroup ConfigDirectives Allowed locations for configuration directives. * * The allowed locations for a configuration directive are the union of * those indicated by each set bit in the req_override mask. * * @{ */ #define OR_NONE 0 /**< *.conf is not available anywhere in this override */ #define OR_LIMIT 1 /**< *.conf inside <Directory> or <Location> and .htaccess when AllowOverride Limit */ #define OR_OPTIONS 2 /**< *.conf anywhere and .htaccess when AllowOverride Options */ #define OR_FILEINFO 4 /**< *.conf anywhere and .htaccess when AllowOverride FileInfo */ #define OR_AUTHCFG 8 /**< *.conf inside <Directory> or <Location> and .htaccess when AllowOverride AuthConfig */ #define OR_INDEXES 16 /**< *.conf anywhere and .htaccess when AllowOverride Indexes */ #define OR_UNSET 32 /**< bit to indicate that AllowOverride has not been set */ #define ACCESS_CONF 64 /**< *.conf inside <Directory> or <Location> */ #define RSRC_CONF 128 /**< *.conf outside <Directory> or <Location> */ #define EXEC_ON_READ 256 /**< force directive to execute a command which would modify the configuration (like including another file, or IFModule */ /* Flags to determine whether syntax errors in .htaccess should be * treated as nonfatal (log and ignore errors) */ #define NONFATAL_OVERRIDE 512 /* Violation of AllowOverride rule */ #define NONFATAL_UNKNOWN 1024 /* Unrecognised directive */ #define NONFATAL_ALL (NONFATAL_OVERRIDE|NONFATAL_UNKNOWN) #define PROXY_CONF 2048 /**< *.conf inside <Proxy> only */ /** this directive can be placed anywhere */ #define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|OR_INDEXES) /** @} */ /** * This can be returned by a function if they don't wish to handle * a command. Make it something not likely someone will actually use * as an error code. */ #define DECLINE_CMD "\a\b" /** Common structure for reading of config files / passwd files etc. */ typedef struct ap_configfile_t ap_configfile_t; struct ap_configfile_t { /**< an apr_file_getc()-like function */ apr_status_t (*getch) (char *ch, void *param); /**< an apr_file_gets()-like function */ apr_status_t (*getstr) (void *buf, apr_size_t bufsiz, void *param); /**< a close handler function */ apr_status_t (*close) (void *param); /**< the argument passed to getch/getstr/close */ void *param; /**< the filename / description */ const char *name; /**< current line number, starting at 1 */ unsigned line_number; }; /** * This structure is passed to a command which is being invoked, * to carry a large variety of miscellaneous data which is all of * use to *somebody*... */ struct cmd_parms_struct { /** Argument to command from cmd_table */ void *info; /** Which allow-override bits are set */ int override; /** Which allow-override-opts bits are set */ int override_opts; /** Table of directives allowed per AllowOverrideList */ apr_table_t *override_list; /** Which methods are <Limit>ed */ apr_int64_t limited; /** methods which are limited */ apr_array_header_t *limited_xmethods; /** methods which are xlimited */ ap_method_list_t *xlimited; /** Config file structure. */ ap_configfile_t *config_file; /** the directive specifying this command */ ap_directive_t *directive; /** Pool to allocate new storage in */ apr_pool_t *pool; /** Pool for scratch memory; persists during configuration, but * wiped before the first request is served... */ apr_pool_t *temp_pool; /** Server_rec being configured for */ server_rec *server; /** If configuring for a directory, pathname of that directory. * NOPE! That's what it meant previous to the existence of <Files>, * <Location> and regex matching. Now the only usefulness that can be * derived from this field is whether a command is being called in a * server context (path == NULL) or being called in a dir context * (path != NULL). */ char *path; /** configuration command */ const command_rec *cmd; /** per_dir_config vector passed to handle_command */ struct ap_conf_vector_t *context; /** directive with syntax error */ const ap_directive_t *err_directive; }; /** * Flags associated with a module. */ #define AP_MODULE_FLAG_NONE (0) #define AP_MODULE_FLAG_ALWAYS_MERGE (1 << 0) /** * Module structures. Just about everything is dispatched through * these, directly or indirectly (through the command and handler * tables). */ typedef struct module_struct module; struct module_struct { /** API version, *not* module version; check that module is * compatible with this version of the server. */ int version; /** API minor version. Provides API feature milestones. Not checked * during module init */ int minor_version; /** Index to this modules structures in config vectors. */ int module_index; /** The name of the module's C file */ const char *name; /** The handle for the DSO. Internal use only */ void *dynamic_load_handle; /** A pointer to the next module in the list * @var module_struct *next */ struct module_struct *next; /** Magic Cookie to identify a module structure; It's mainly * important for the DSO facility (see also mod_so). */ unsigned long magic; /** Function to allow MPMs to re-write command line arguments. This * hook is only available to MPMs. * @param The process that the server is running in. */ void (*rewrite_args) (process_rec *process); /** Function to allow all modules to create per directory configuration * structures. * @param p The pool to use for all allocations. * @param dir The directory currently being processed. * @return The per-directory structure created */ void *(*create_dir_config) (apr_pool_t *p, char *dir); /** Function to allow all modules to merge the per directory configuration * structures for two directories. * @param p The pool to use for all allocations. * @param base_conf The directory structure created for the parent directory. * @param new_conf The directory structure currently being processed. * @return The new per-directory structure created */ void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf); /** Function to allow all modules to create per server configuration * structures. * @param p The pool to use for all allocations. * @param s The server currently being processed. * @return The per-server structure created */ void *(*create_server_config) (apr_pool_t *p, server_rec *s); /** Function to allow all modules to merge the per server configuration * structures for two servers. * @param p The pool to use for all allocations. * @param base_conf The directory structure created for the parent directory. * @param new_conf The directory structure currently being processed. * @return The new per-directory structure created */ void *(*merge_server_config) (apr_pool_t *p, void *base_conf, void *new_conf); /** A command_rec table that describes all of the directives this module * defines. */ const command_rec *cmds; /** A hook to allow modules to hook other points in the request processing. * In this function, modules should call the ap_hook_*() functions to * register an interest in a specific step in processing the current * request. * @param p the pool to use for all allocations */ void (*register_hooks) (apr_pool_t *p); /** A bitmask of AP_MODULE_FLAG_* */ int flags; }; /** * The AP_MAYBE_UNUSED macro is used for variable declarations that * might potentially exhibit "unused var" warnings on some compilers if * left untreated. * Since static intializers are not part of the C language (C89), making * (void) usage is not possible. However many compiler have proprietary * mechanism to suppress those warnings. */ #ifdef AP_MAYBE_UNUSED #elif defined(__GNUC__) # define AP_MAYBE_UNUSED(x) x __attribute__((unused)) #elif defined(__LCLINT__) # define AP_MAYBE_UNUSED(x) /*@unused@*/ x #else # define AP_MAYBE_UNUSED(x) x #endif /** * The APLOG_USE_MODULE macro is used choose which module a file belongs to. * This is necessary to allow per-module loglevel configuration. * * APLOG_USE_MODULE indirectly sets APLOG_MODULE_INDEX and APLOG_MARK. * * If a module should be backward compatible with versions before 2.3.6, * APLOG_USE_MODULE needs to be enclosed in a ifdef APLOG_USE_MODULE block. * * @param foo name of the module symbol of the current module, without the * trailing "_module" part * @see APLOG_MARK */ #define APLOG_USE_MODULE(foo) \ extern module AP_MODULE_DECLARE_DATA foo##_module; \ AP_MAYBE_UNUSED(static int * const aplog_module_index) = &(foo##_module.module_index) /** * AP_DECLARE_MODULE is a convenience macro that combines a call of * APLOG_USE_MODULE with the definition of the module symbol. * * If a module should be backward compatible with versions before 2.3.6, * APLOG_USE_MODULE should be used explicitly instead of AP_DECLARE_MODULE. */ #define AP_DECLARE_MODULE(foo) \ APLOG_USE_MODULE(foo); \ module AP_MODULE_DECLARE_DATA foo##_module /** * @defgroup ModuleInit Module structure initializers * * Initializer for the first few module slots, which are only * really set up once we start running. Note that the first two slots * provide a version check; this should allow us to deal with changes to * the API. The major number should reflect changes to the API handler table * itself or removal of functionality. The minor number should reflect * additions of functionality to the existing API. (the server can detect * an old-format module, and either handle it back-compatibly, or at least * signal an error). See src/include/ap_mmn.h for MMN version history. * @{ */ /** The one used in Apache 1.3, which will deliberately cause an error */ #define STANDARD_MODULE_STUFF this_module_needs_to_be_ported_to_apache_2_0 /** Use this in all standard modules */ #define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \ MODULE_MAGIC_NUMBER_MINOR, \ -1, \ __FILE__, \ NULL, \ NULL, \ MODULE_MAGIC_COOKIE, \ NULL /* rewrite args spot */ /** Use this only in MPMs */ #define MPM20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \ MODULE_MAGIC_NUMBER_MINOR, \ -1, \ __FILE__, \ NULL, \ NULL, \ MODULE_MAGIC_COOKIE /** @} */ /* CONFIGURATION VECTOR FUNCTIONS */ /** configuration vector structure */ typedef struct ap_conf_vector_t ap_conf_vector_t; /** * Generic accessors for other modules to get at their own module-specific * data * @param cv The vector in which the modules configuration is stored. * usually r->per_dir_config or s->module_config * @param m The module to get the data for. * @return The module-specific data */ AP_DECLARE(void *) ap_get_module_config(const ap_conf_vector_t *cv, const module *m); /** * Generic accessors for other modules to set their own module-specific * data * @param cv The vector in which the modules configuration is stored. * usually r->per_dir_config or s->module_config * @param m The module to set the data for. * @param val The module-specific data to set */ AP_DECLARE(void) ap_set_module_config(ap_conf_vector_t *cv, const module *m, void *val); /** * When module flags have been introduced, and a way to check this. */ #define AP_MODULE_FLAGS_MMN_MAJOR 20120211 #define AP_MODULE_FLAGS_MMN_MINOR 70 #define AP_MODULE_HAS_FLAGS(m) \ AP_MODULE_MAGIC_AT_LEAST(AP_MODULE_FLAGS_MMN_MAJOR, \ AP_MODULE_FLAGS_MMN_MINOR) /** * Generic accessor for the module's flags * @param m The module to get the flags from. * @return The module-specific flags */ AP_DECLARE(int) ap_get_module_flags(const module *m); #if !defined(AP_DEBUG) #define ap_get_module_config(v,m) \ (((void **)(v))[(m)->module_index]) #define ap_set_module_config(v,m,val) \ ((((void **)(v))[(m)->module_index]) = (val)) #endif /* AP_DEBUG */ /** * Generic accessor for modules to get the module-specific loglevel * @param s The server from which to get the loglevel. * @param index The module_index of the module to get the loglevel for. * @return The module-specific loglevel */ AP_DECLARE(int) ap_get_server_module_loglevel(const server_rec *s, int index); /** * Generic accessor for modules the module-specific loglevel * @param c The connection from which to get the loglevel. * @param index The module_index of the module to get the loglevel for. * @return The module-specific loglevel */ AP_DECLARE(int) ap_get_conn_module_loglevel(const conn_rec *c, int index); /** * Generic accessor for modules the module-specific loglevel * @param c The connection from which to get the loglevel. * @param s The server from which to get the loglevel if c does not have a * specific loglevel configuration. * @param index The module_index of the module to get the loglevel for. * @return The module-specific loglevel */ AP_DECLARE(int) ap_get_conn_server_module_loglevel(const conn_rec *c, const server_rec *s, int index); /** * Generic accessor for modules to get the module-specific loglevel * @param r The request from which to get the loglevel. * @param index The module_index of the module to get the loglevel for. * @return The module-specific loglevel */ AP_DECLARE(int) ap_get_request_module_loglevel(const request_rec *r, int index); /** * Accessor to set module-specific loglevel * @param p A pool * @param l The ap_logconf struct to modify. * @param index The module_index of the module to set the loglevel for. * @param level The new log level */ AP_DECLARE(void) ap_set_module_loglevel(apr_pool_t *p, struct ap_logconf *l, int index, int level); #if !defined(AP_DEBUG) #define ap_get_conn_logconf(c) \ ((c)->log ? (c)->log : \ &(c)->base_server->log) #define ap_get_conn_server_logconf(c,s) \ ( ( (c)->log != &(c)->base_server->log && (c)->log != NULL ) ? \ (c)->log : \ &(s)->log ) #define ap_get_request_logconf(r) \ ((r)->log ? (r)->log : \ (r)->connection->log ? (r)->connection->log : \ &(r)->server->log) #define ap_get_module_loglevel(l,i) \ (((i) < 0 || (l)->module_levels == NULL || (l)->module_levels[i] < 0) ? \ (l)->level : \ (l)->module_levels[i]) #define ap_get_server_module_loglevel(s,i) \ (ap_get_module_loglevel(&(s)->log,i)) #define ap_get_conn_module_loglevel(c,i) \ (ap_get_module_loglevel(ap_get_conn_logconf(c),i)) #define ap_get_conn_server_module_loglevel(c,s,i) \ (ap_get_module_loglevel(ap_get_conn_server_logconf(c,s),i)) #define ap_get_request_module_loglevel(r,i) \ (ap_get_module_loglevel(ap_get_request_logconf(r),i)) #endif /* AP_DEBUG */ /** * Set all module-specific loglevels to val * @param l The log config for which to set the loglevels. * @param val the value to set all loglevels to */ AP_DECLARE(void) ap_reset_module_loglevels(struct ap_logconf *l, int val); /** * Generic command handling function for strings * @param cmd The command parameters for this directive * @param struct_ptr pointer into a given type * @param arg The argument to the directive * @return An error string or NULL on success */ AP_DECLARE_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd, void *struct_ptr, const char *arg); /** * Generic command handling function for integers * @param cmd The command parameters for this directive * @param struct_ptr pointer into a given type * @param arg The argument to the directive * @return An error string or NULL on success */ AP_DECLARE_NONSTD(const char *) ap_set_int_slot(cmd_parms *cmd, void *struct_ptr, const char *arg); /** * Parsing function for log level * @param str The string to parse * @param val The parsed log level * @return An error string or NULL on success */ AP_DECLARE(const char *) ap_parse_log_level(const char *str, int *val); /** * Return true if the specified method is limited by being listed in * a <Limit> container, or by *not* being listed in a <LimitExcept> * container. * * @param method Pointer to a string specifying the method to check. * @param cmd Pointer to the cmd_parms structure passed to the * directive handler. * @return 0 if the method is not limited in the current scope */ AP_DECLARE(int) ap_method_is_limited(cmd_parms *cmd, const char *method); /** * Generic command handling function for strings, always sets the value * to a lowercase string * @param cmd The command parameters for this directive * @param struct_ptr pointer into a given type * @param arg The argument to the directive * @return An error string or NULL on success */ AP_DECLARE_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd, void *struct_ptr, const char *arg); /** * Generic command handling function for flags stored in an int * @param cmd The command parameters for this directive * @param struct_ptr pointer into a given type * @param arg The argument to the directive (either 1 or 0) * @return An error string or NULL on success */ AP_DECLARE_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd, void *struct_ptr, int arg); /** * Generic command handling function for flags stored in a char * @param cmd The command parameters for this directive * @param struct_ptr pointer into a given type * @param arg The argument to the directive (either 1 or 0) * @return An error string or NULL on success */ AP_DECLARE_NONSTD(const char *) ap_set_flag_slot_char(cmd_parms *cmd, void *struct_ptr, int arg); /** * Generic command handling function for files * @param cmd The command parameters for this directive * @param struct_ptr pointer into a given type * @param arg The argument to the directive * @return An error string or NULL on success */ AP_DECLARE_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, void *struct_ptr, const char *arg); /** * Generic command handling function to respond with cmd->help as an error * @param cmd The command parameters for this directive * @param struct_ptr pointer into a given type * @param arg The argument to the directive * @return The cmd->help value as the error string * @note This allows simple declarations such as: * @code * AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL, * "The Foo directive is no longer supported, use Bar"), * @endcode */ AP_DECLARE_NONSTD(const char *) ap_set_deprecated(cmd_parms *cmd, void *struct_ptr, const char *arg); /** * For modules which need to read config files, open logs, etc. this returns * the canonical form of fname made absolute to ap_server_root. * @param p pool to allocate data from * @param fname The file name */ AP_DECLARE(char *) ap_server_root_relative(apr_pool_t *p, const char *fname); /** * Compute the name of a run-time file (e.g., shared memory "file") relative * to the appropriate run-time directory. Absolute paths are returned as-is. * The run-time directory is configured via the DefaultRuntimeDir directive or * at build time. */ AP_DECLARE(char *) ap_runtime_dir_relative(apr_pool_t *p, const char *fname); /* Finally, the hook for dynamically loading modules in... */ /** * Add a module to the server * @param m The module structure of the module to add * @param p The pool of the same lifetime as the module * @param s The module's symbol name (used for logging) */ AP_DECLARE(const char *) ap_add_module(module *m, apr_pool_t *p, const char *s); /** * Remove a module from the server. There are some caveats: * when the module is removed, its slot is lost so all the current * per-dir and per-server configurations are invalid. So we should * only ever call this function when you are invalidating almost * all our current data. I.e. when doing a restart. * @param m the module structure of the module to remove */ AP_DECLARE(void) ap_remove_module(module *m); /** * Add a module to the chained modules list and the list of loaded modules * @param mod The module structure of the module to add * @param p The pool with the same lifetime as the module * @param s The module's symbol name (used for logging) */ AP_DECLARE(const char *) ap_add_loaded_module(module *mod, apr_pool_t *p, const char *s); /** * Remove a module from the chained modules list and the list of loaded modules * @param mod the module structure of the module to remove */ AP_DECLARE(void) ap_remove_loaded_module(module *mod); /** * Find the name of the specified module * @param m The module to get the name for * @return the name of the module */ AP_DECLARE(const char *) ap_find_module_name(module *m); /** * Find the short name of the module identified by the specified module index * @param module_index The module index to get the name for * @return the name of the module, NULL if not found */ AP_DECLARE(const char *) ap_find_module_short_name(int module_index); /** * Find a module based on the name of the module * @param name the name of the module * @return the module structure if found, NULL otherwise */ AP_DECLARE(module *) ap_find_linked_module(const char *name); /** * Open a ap_configfile_t as apr_file_t * @param ret_cfg open ap_configfile_t struct pointer * @param p The pool to allocate the structure from * @param name the name of the file to open */ AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg, apr_pool_t *p, const char *name); /** * Allocate a ap_configfile_t handle with user defined functions and params * @param p The pool to allocate from * @param descr The name of the file * @param param The argument passed to getch/getstr/close * @param getc_func The getch function * @param gets_func The getstr function * @param close_func The close function */ AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p, const char *descr, void *param, apr_status_t (*getc_func) (char *ch, void *param), apr_status_t (*gets_func) (void *buf, apr_size_t bufsiz, void *param), apr_status_t (*close_func) (void *param)); /** * Read one line from open ap_configfile_t, strip leading and trailing * whitespace, increase line number * @param buf place to store the line read * @param bufsize size of the buffer * @param cfp File to read from * @return error status, APR_ENOSPC if bufsize is too small for the line */ AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, apr_size_t bufsize, ap_configfile_t *cfp); /** * Read one char from open configfile_t, increase line number upon LF * @param ch place to store the char read * @param cfp The file to read from * @return error status */ AP_DECLARE(apr_status_t) ap_cfg_getc(char *ch, ap_configfile_t *cfp); /** * Detach from open ap_configfile_t, calling the close handler * @param cfp The file to close * @return 1 on success, 0 on failure */ AP_DECLARE(int) ap_cfg_closefile(ap_configfile_t *cfp); /** * Convert a return value from ap_cfg_getline or ap_cfg_getc to a user friendly * string. * @param p The pool to allocate the string from * @param cfp The config file * @param rc The return value to convert * @return The error string, NULL if rc == APR_SUCCESS */ AP_DECLARE(const char *) ap_pcfg_strerror(apr_pool_t *p, ap_configfile_t *cfp, apr_status_t rc); /** * Read all data between the current <foo> and the matching </foo>. All * of this data is forgotten immediately. * @param cmd The cmd_parms to pass to the directives inside the container * @param directive The directive name to read until * @return Error string on failure, NULL on success * @note If cmd->pool == cmd->temp_pool, ap_soak_end_container() will assume * .htaccess context and use a lower maximum line length. */ AP_DECLARE(const char *) ap_soak_end_container(cmd_parms *cmd, char *directive); /** * Read all data between the current <foo> and the matching </foo> and build * a config tree from it * @param p pool to allocate from * @param temp_pool Temporary pool to allocate from * @param parms The cmd_parms to pass to all directives read * @param current The current node in the tree * @param curr_parent The current parent node * @param orig_directive The directive to read until hit. * @return Error string on failure, NULL on success * @note If p == temp_pool, ap_build_cont_config() will assume .htaccess * context and use a lower maximum line length. */ AP_DECLARE(const char *) ap_build_cont_config(apr_pool_t *p, apr_pool_t *temp_pool, cmd_parms *parms, ap_directive_t **current, ap_directive_t **curr_parent, char *orig_directive); /** * Build a config tree from a config file * @param parms The cmd_parms to pass to all of the directives in the file * @param conf_pool The pconf pool * @param temp_pool The temporary pool * @param conftree Place to store the root node of the config tree * @return Error string on error, NULL otherwise * @note If conf_pool == temp_pool, ap_build_config() will assume .htaccess * context and use a lower maximum line length. */ AP_DECLARE(const char *) ap_build_config(cmd_parms *parms, apr_pool_t *conf_pool, apr_pool_t *temp_pool, ap_directive_t **conftree); /** * Walk a config tree and setup the server's internal structures * @param conftree The config tree to walk * @param parms The cmd_parms to pass to all functions * @param section_vector The per-section config vector. * @return Error string on error, NULL otherwise */ AP_DECLARE(const char *) ap_walk_config(ap_directive_t *conftree, cmd_parms *parms, ap_conf_vector_t *section_vector); /** * Convenience function to create a ap_dir_match_t structure from a cmd_parms. * * @param cmd The command. * @param flags Flags to indicate whether optional or recursive. * @param cb Callback for each file found that matches the wildcard. Return NULL on * success, an error string on error. * @param ctx Context for the callback. * @return Structure ap_dir_match_t with fields populated, allocated from the * cmd->temp_pool. */ AP_DECLARE(ap_dir_match_t *)ap_dir_cfgmatch(cmd_parms *cmd, int flags, const char *(*cb)(ap_dir_match_t *w, const char *fname), void *ctx) __attribute__((nonnull(1,3))); /** * @defgroup ap_check_cmd_context Check command context * @{ */ /** * Check the context a command is used in. * @param cmd The command to check * @param forbidden Where the command is forbidden. * @return Error string on error, NULL on success */ AP_DECLARE(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden); #define NOT_IN_VIRTUALHOST 0x01 /**< Forbidden in <VirtualHost> */ #define NOT_IN_LIMIT 0x02 /**< Forbidden in <Limit> */ #define NOT_IN_DIRECTORY 0x04 /**< Forbidden in <Directory> */ #define NOT_IN_LOCATION 0x08 /**< Forbidden in <Location> */ #define NOT_IN_FILES 0x10 /**< Forbidden in <Files> or <If>*/ #define NOT_IN_HTACCESS 0x20 /**< Forbidden in .htaccess files */ #define NOT_IN_PROXY 0x40 /**< Forbidden in <Proxy> */ /** Forbidden in <Directory>/<Location>/<Files><If>*/ #define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES) /** Forbidden in <Directory>/<Location>/<Files><If><Proxy>*/ #define NOT_IN_DIR_CONTEXT (NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE|NOT_IN_PROXY) /** Forbidden in <VirtualHost>/<Limit>/<Directory>/<Location>/<Files>/<If><Proxy>*/ #define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_DIR_CONTEXT) /** @} */ /** * @brief This structure is used to assign symbol names to module pointers */ typedef struct { const char *name; module *modp; } ap_module_symbol_t; /** * The topmost module in the list * @var module *ap_top_module */ AP_DECLARE_DATA extern module *ap_top_module; /** * Array of all statically linked modules * @var module *ap_prelinked_modules[] */ AP_DECLARE_DATA extern module *ap_prelinked_modules[]; /** * Array of all statically linked modulenames (symbols) * @var ap_module_symbol_t ap_prelinked_module_symbols[] */ AP_DECLARE_DATA extern ap_module_symbol_t ap_prelinked_module_symbols[]; /** * Array of all preloaded modules * @var module *ap_preloaded_modules[] */ AP_DECLARE_DATA extern module *ap_preloaded_modules[]; /** * Array of all loaded modules * @var module **ap_loaded_modules */ AP_DECLARE_DATA extern module **ap_loaded_modules; /* For mod_so.c... */ /** Run a single module's two create_config hooks * @param p the pool to allocate from * @param s The server to configure for. * @param m The module to configure */ AP_DECLARE(void) ap_single_module_configure(apr_pool_t *p, server_rec *s, module *m); /* For http_main.c... */ /** * Add all of the prelinked modules into the loaded module list * @param process The process that is currently running the server */ AP_DECLARE(const char *) ap_setup_prelinked_modules(process_rec *process); /** * Show the preloaded configuration directives, the help string explaining * the directive arguments, in what module they are handled, and in * what parts of the configuration they are allowed. Used for httpd -h. */ AP_DECLARE(void) ap_show_directives(void); /** * Returns non-zero if a configuration directive of the given name has * been registered by a module at the time of calling. * @param p Pool for temporary allocations * @param name Directive name */ AP_DECLARE(int) ap_exists_directive(apr_pool_t *p, const char *name); /** * Show the preloaded module names. Used for httpd -l. */ AP_DECLARE(void) ap_show_modules(void); /** * Show the MPM name. Used in reporting modules such as mod_info to * provide extra information to the user */ AP_DECLARE(const char *) ap_show_mpm(void); /** * Read all config files and setup the server * @param process The process running the server * @param temp_pool A pool to allocate temporary data from. * @param config_name The name of the config file * @param conftree Place to store the root of the config tree * @return The setup server_rec list. */ AP_DECLARE(server_rec *) ap_read_config(process_rec *process, apr_pool_t *temp_pool, const char *config_name, ap_directive_t **conftree); /** * Run all rewrite args hooks for loaded modules * @param process The process currently running the server */ AP_DECLARE(void) ap_run_rewrite_args(process_rec *process); /** * Run the register hooks function for a specified module * @param m The module to run the register hooks function from * @param p The pool valid for the lifetime of the module */ AP_DECLARE(void) ap_register_hooks(module *m, apr_pool_t *p); /** * Setup all virtual hosts * @param p The pool to allocate from * @param main_server The head of the server_rec list */ AP_DECLARE(void) ap_fixup_virtual_hosts(apr_pool_t *p, server_rec *main_server); /** * Reserve some modules slots for modules loaded by other means than * EXEC_ON_READ directives. * Relevant modules should call this in the pre_config stage. * @param count The number of slots to reserve. */ AP_DECLARE(void) ap_reserve_module_slots(int count); /** * Reserve some modules slots for modules loaded by a specific * non-EXEC_ON_READ config directive. * This counts how often the given directive is used in the config and calls * ap_reserve_module_slots() accordingly. * @param directive The name of the directive */ AP_DECLARE(void) ap_reserve_module_slots_directive(const char *directive); /* For http_request.c... */ /** * Setup the config vector for a request_rec * @param p The pool to allocate the config vector from * @return The config vector */ AP_DECLARE(ap_conf_vector_t*) ap_create_request_config(apr_pool_t *p); /** * Setup the config vector for per dir module configs * @param p The pool to allocate the config vector from * @return The config vector */ AP_CORE_DECLARE(ap_conf_vector_t *) ap_create_per_dir_config(apr_pool_t *p); /** * Run all of the modules merge per dir config functions * @param p The pool to pass to the merge functions * @param base The base directory config structure * @param new_conf The new directory config structure */ AP_CORE_DECLARE(ap_conf_vector_t*) ap_merge_per_dir_configs(apr_pool_t *p, ap_conf_vector_t *base, ap_conf_vector_t *new_conf); /** * Allocate new ap_logconf and make (deep) copy of old ap_logconf * @param p The pool to alloc from * @param old The ap_logconf to copy (may be NULL) * @return The new ap_logconf struct */ AP_DECLARE(struct ap_logconf *) ap_new_log_config(apr_pool_t *p, const struct ap_logconf *old); /** * Merge old ap_logconf into new ap_logconf. * old and new must have the same life time. * @param old_conf The ap_logconf to merge from * @param new_conf The ap_logconf to merge into */ AP_DECLARE(void) ap_merge_log_config(const struct ap_logconf *old_conf, struct ap_logconf *new_conf); /* For http_connection.c... */ /** * Setup the config vector for a connection_rec * @param p The pool to allocate the config vector from * @return The config vector */ AP_CORE_DECLARE(ap_conf_vector_t*) ap_create_conn_config(apr_pool_t *p); /* For http_core.c... (<Directory> command and virtual hosts) */ /** * parse an htaccess file * @param result htaccess_result * @param r The request currently being served * @param override Which overrides are active * @param override_opts Which allow-override-opts bits are set * @param override_list Table of directives allowed for override * @param path The path to the htaccess file * @param access_name The list of possible names for .htaccess files * int The status of the current request */ AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result, request_rec *r, int override, int override_opts, apr_table_t *override_list, const char *path, const char *access_name); /** * Setup a virtual host * @param p The pool to allocate all memory from * @param hostname The hostname of the virtual hsot * @param main_server The main server for this Apache configuration * @param ps Place to store the new server_rec * return Error string on error, NULL on success */ AP_CORE_DECLARE(const char *) ap_init_virtual_host(apr_pool_t *p, const char *hostname, server_rec *main_server, server_rec **ps); /** * Process a config file for Apache * @param s The server rec to use for the command parms * @param fname The name of the config file * @param conftree The root node of the created config tree * @param p Pool for general allocation * @param ptemp Pool for temporary allocation */ AP_DECLARE(const char *) ap_process_resource_config(server_rec *s, const char *fname, ap_directive_t **conftree, apr_pool_t *p, apr_pool_t *ptemp); /** * Process all matching files as Apache configs * @param s The server rec to use for the command parms * @param fname The filename pattern of the config file * @param conftree The root node of the created config tree * @param p Pool for general allocation * @param ptemp Pool for temporary allocation * @param optional Whether a no-match wildcard is allowed * @see apr_fnmatch for pattern handling */ AP_DECLARE(const char *) ap_process_fnmatch_configs(server_rec *s, const char *fname, ap_directive_t **conftree, apr_pool_t *p, apr_pool_t *ptemp, int optional); /** * Process all directives in the config tree * @param s The server rec to use in the command parms * @param conftree The config tree to process * @param p The pool for general allocation * @param ptemp The pool for temporary allocations * @return OK if no problems */ AP_DECLARE(int) ap_process_config_tree(server_rec *s, ap_directive_t *conftree, apr_pool_t *p, apr_pool_t *ptemp); /** * Store data which will be retained across unload/load of modules * @param key The unique key associated with this module's retained data * @param size in bytes of the retained data (to be allocated) * @return Address of new retained data structure, initially cleared */ AP_DECLARE(void *) ap_retained_data_create(const char *key, apr_size_t size); /** * Retrieve data which was stored by ap_retained_data_create() * @param key The unique key associated with this module's retained data * @return Address of previously retained data structure, or NULL if not yet saved */ AP_DECLARE(void *) ap_retained_data_get(const char *key); /* Module-method dispatchers, also for http_request.c */ /** * Run the handler phase of each module until a module accepts the * responsibility of serving the request * @param r The current request * @return The status of the current request */ AP_CORE_DECLARE(int) ap_invoke_handler(request_rec *r); /* for mod_perl */ /** * Find a given directive in a command_rec table * @param name The directive to search for * @param cmds The table to search * @return The directive definition of the specified directive */ AP_CORE_DECLARE(const command_rec *) ap_find_command(const char *name, const command_rec *cmds); /** * Find a given directive in a list of modules. * @param cmd_name The directive to search for * @param mod Pointer to the first module in the linked list; will be set to * the module providing cmd_name * @return The directive definition of the specified directive. * *mod will be changed to point to the module containing the * directive. */ AP_CORE_DECLARE(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod); /** * Ask a module to create per-server and per-section (dir/loc/file) configs * (if it hasn't happened already). The results are stored in the server's * config, and the specified per-section config vector. * @param server The server to operate upon. * @param section_vector The per-section config vector. * @param section Which section to create a config for. * @param mod The module which is defining the config data. * @param pconf A pool for all configuration allocations. * @return The (new) per-section config data. */ AP_CORE_DECLARE(void *) ap_set_config_vectors(server_rec *server, ap_conf_vector_t *section_vector, const char *section, module *mod, apr_pool_t *pconf); /* Hooks */ /** * Run the header parser functions for each module * @param r The current request * @return OK or DECLINED * @ingroup hooks */ AP_DECLARE_HOOK(int,header_parser,(request_rec *r)) /** * Run the pre_config function for each module * @param pconf The config pool * @param plog The logging streams pool * @param ptemp The temporary pool * @return OK or DECLINED on success anything else is a error * @ingroup hooks */ AP_DECLARE_HOOK(int,pre_config,(apr_pool_t *pconf,apr_pool_t *plog, apr_pool_t *ptemp)) /** * Run the check_config function for each module * @param pconf The config pool * @param plog The logging streams pool * @param ptemp The temporary pool * @param s the server to operate upon * @return OK or DECLINED on success anything else is a error * @ingroup hooks */ AP_DECLARE_HOOK(int,check_config,(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)) /** * Run the test_config function for each module; this hook is run * only if the server was invoked to test the configuration syntax. * @param pconf The config pool * @param s The list of server_recs * @note To avoid reordering problems due to different buffering, hook * functions should only apr_file_*() to print to stdout/stderr and * not simple printf()/fprintf(). * @ingroup hooks */ AP_DECLARE_HOOK(void,test_config,(apr_pool_t *pconf, server_rec *s)) /** * Run the post_config function for each module * * The function might be called multiple times. @a pconf, @a plog, and * @a ptemp may be cleared and/or destroyed between calls. * * The function will be called zero or one times with the server's state being * #AP_SQ_MS_CREATE_PRE_CONFIG, and will be called one or more times with * the server's state being #AP_SQ_MS_CREATE_CONFIG. * * @see ap_state_query(), #AP_SQ_MAIN_STATE * * @param pconf The config pool * @param plog The logging streams pool * @param ptemp The temporary pool * @param s The list of server_recs * @return OK or DECLINED on success anything else is a error * @ingroup hooks */ AP_DECLARE_HOOK(int,post_config,(apr_pool_t *pconf,apr_pool_t *plog, apr_pool_t *ptemp,server_rec *s)) /** * Run the open_logs functions for each module * @param pconf The config pool * @param plog The logging streams pool * @param ptemp The temporary pool * @param s The list of server_recs * @return OK or DECLINED on success anything else is a error * @ingroup hooks */ AP_DECLARE_HOOK(int,open_logs,(apr_pool_t *pconf,apr_pool_t *plog, apr_pool_t *ptemp,server_rec *s)) /** * Run the child_init functions for each module * @param pchild The child pool * @param s The list of server_recs in this server * @ingroup hooks */ AP_DECLARE_HOOK(void,child_init,(apr_pool_t *pchild, server_rec *s)) /** * Run the handler functions for each module * @param r The request_rec * @remark non-wildcard handlers should HOOK_MIDDLE, wildcard HOOK_LAST * @ingroup hooks */ AP_DECLARE_HOOK(int,handler,(request_rec *r)) /** * Run the quick handler functions for each module. The quick_handler * is run before any other requests hooks are called (location_walk, * directory_walk, access checking, et. al.). This hook was added * to provide a quick way to serve content from a URI keyed cache. * * @param r The request_rec * @param lookup_uri Controls whether the caller actually wants content or not. * lookup is set when the quick_handler is called out of * ap_sub_req_lookup_uri() * @ingroup hooks */ AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri)) /** * Retrieve the optional functions for each module. * This is run immediately before the server starts. Optional functions should * be registered during the hook registration phase. * @ingroup hooks */ AP_DECLARE_HOOK(void,optional_fn_retrieve,(void)) /** * Allow modules to open htaccess files or perform operations before doing so * @param r The current request * @param dir_name The directory for which the htaccess file should be opened * @param access_name The filename for which the htaccess file should be opened * @param conffile Where the pointer to the opened ap_configfile_t must be * stored * @param full_name Where the full file name of the htaccess file must be * stored. * @return APR_SUCCESS on success, * APR_ENOENT or APR_ENOTDIR if no htaccess file exists, * AP_DECLINED to let later modules do the opening, * any other error code on error. * @ingroup hooks */ AP_DECLARE_HOOK(apr_status_t,open_htaccess, (request_rec *r, const char *dir_name, const char *access_name, ap_configfile_t **conffile, const char **full_name)) /** * Core internal function, use ap_run_open_htaccess() instead. */ apr_status_t ap_open_htaccess(request_rec *r, const char *dir_name, const char *access_name, ap_configfile_t **conffile, const char **full_name); /** * A generic pool cleanup that will reset a pointer to NULL. For use with * apr_pool_cleanup_register. * @param data The address of the pointer * @return APR_SUCCESS */ AP_DECLARE_NONSTD(apr_status_t) ap_pool_cleanup_set_null(void *data); #ifdef __cplusplus } #endif #endif /* !APACHE_HTTP_CONFIG_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_cgi.h * @brief CGI Script Execution Extension Module for Apache * * @defgroup MOD_CGI mod_cgi * @ingroup APACHE_MODS * @{ */ #ifndef _MOD_CGI_H #define _MOD_CGI_H 1 #include "mod_include.h" typedef enum {RUN_AS_SSI, RUN_AS_CGI} prog_types; typedef struct { apr_int32_t in_pipe; apr_int32_t out_pipe; apr_int32_t err_pipe; int process_cgi; apr_cmdtype_e cmd_type; apr_int32_t detached; prog_types prog_type; apr_bucket_brigade **bb; include_ctx_t *ctx; ap_filter_t *next; apr_int32_t addrspace; } cgi_exec_info_t; /** * Registerable optional function to override CGI behavior; * Reprocess the command and arguments to execute the given CGI script. * @param cmd Pointer to the command to execute (may be overridden) * @param argv Pointer to the arguments to pass (may be overridden) * @param r The current request * @param p The pool to allocate correct cmd/argv elements within. * @param e_info pass e_info.cmd_type (Set to APR_SHELLCMD or APR_PROGRAM on entry) and e_info.detached (Should the child start in detached state?) * @remark This callback may be registered by the os-specific module * to correct the command and arguments for apr_proc_create invocation * on a given os. mod_cgi will call the function if registered. */ APR_DECLARE_OPTIONAL_FN(apr_status_t, ap_cgi_build_command, (const char **cmd, const char ***argv, request_rec *r, apr_pool_t *p, cgi_exec_info_t *e_info)); #endif /* _MOD_CGI_H */ /** @} */ 20120211x8664 /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_time.h * @brief Apache date-time handling functions * * @defgroup APACHE_CORE_TIME Date-time handling functions * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_UTIL_TIME_H #define APACHE_UTIL_TIME_H #include "apr.h" #include "apr_time.h" #include "httpd.h" #ifdef __cplusplus extern "C" { #endif /* Maximum delta from the current time, in seconds, for a past time * to qualify as "recent" for use in the ap_explode_recent_*() functions: * (Must be a power of two minus one!) */ #define AP_TIME_RECENT_THRESHOLD 15 /* Options for ap_recent_ctime_ex */ /* No extension */ #define AP_CTIME_OPTION_NONE 0x0 /* Add sub second timestamps with micro second resolution */ #define AP_CTIME_OPTION_USEC 0x1 /* Use more compact ISO 8601 format */ #define AP_CTIME_OPTION_COMPACT 0x2 /* Add timezone offset from GMT ([+-]hhmm) */ #define AP_CTIME_OPTION_GMTOFF 0x4 /* Add sub second timestamps with millisecond resolution */ #define AP_CTIME_OPTION_MSEC 0x8 /** * convert a recent time to its human readable components in local timezone * @param tm the exploded time * @param t the time to explode: MUST be within the last * AP_TIME_RECENT_THRESHOLD seconds * @note This is a faster alternative to apr_time_exp_lt that uses * a cache of pre-exploded time structures. It is useful for things * that need to explode the current time multiple times per second, * like loggers. * @return APR_SUCCESS iff successful */ AP_DECLARE(apr_status_t) ap_explode_recent_localtime(apr_time_exp_t *tm, apr_time_t t); /** * convert a recent time to its human readable components in GMT timezone * @param tm the exploded time * @param t the time to explode: MUST be within the last * AP_TIME_RECENT_THRESHOLD seconds * @note This is a faster alternative to apr_time_exp_gmt that uses * a cache of pre-exploded time structures. It is useful for things * that need to explode the current time multiple times per second, * like loggers. * @return APR_SUCCESS iff successful */ AP_DECLARE(apr_status_t) ap_explode_recent_gmt(apr_time_exp_t *tm, apr_time_t t); /** * format a recent timestamp in the ctime() format. * @param date_str String to write to. * @param t the time to convert * @note Consider using ap_recent_ctime_ex instead. * @return APR_SUCCESS iff successful */ AP_DECLARE(apr_status_t) ap_recent_ctime(char *date_str, apr_time_t t); /** * format a recent timestamp in an extended ctime() format. * @param date_str String to write to. * @param t the time to convert * @param option Additional formatting options (AP_CTIME_OPTION_*). * @param len Pointer to an int containing the length of the provided buffer. * On successful return it contains the number of bytes written to the * buffer (including trailing NUL byte). * @return APR_SUCCESS iff successful, APR_ENOMEM if buffer was to short. */ AP_DECLARE(apr_status_t) ap_recent_ctime_ex(char *date_str, apr_time_t t, int option, int *len); /** * format a recent timestamp in the RFC822 format * @param date_str String to write to (must have length >= APR_RFC822_DATE_LEN) * @param t the time to convert */ AP_DECLARE(apr_status_t) ap_recent_rfc822_date(char *date_str, apr_time_t t); #ifdef __cplusplus } #endif #endif /* !APACHE_UTIL_TIME_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file http_core.h * @brief CORE HTTP Daemon * * @defgroup APACHE_CORE_HTTPD Core HTTP Daemon * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_HTTP_CORE_H #define APACHE_HTTP_CORE_H #include "apr.h" #include "apr_hash.h" #include "apr_optional.h" #include "util_filter.h" #include "ap_expr.h" #include "apr_poll.h" #include "apr_tables.h" #include "http_config.h" #if APR_HAVE_STRUCT_RLIMIT #include <sys/time.h> #include <sys/resource.h> #endif #ifdef __cplusplus extern "C" { #endif /* **************************************************************** * * The most basic server code is encapsulated in a single module * known as the core, which is just *barely* functional enough to * serve documents, though not terribly well. * * Largely for NCSA back-compatibility reasons, the core needs to * make pieces of its config structures available to other modules. * The accessors are declared here, along with the interpretation * of one of them (allow_options). */ /** * @defgroup APACHE_CORE_HTTPD_ACESSORS Acessors * * @brief File/Directory Accessor directives * * @{ */ /** No directives */ #define OPT_NONE 0 /** Indexes directive */ #define OPT_INDEXES 1 /** SSI is enabled without exec= permission */ #define OPT_INCLUDES 2 /** FollowSymLinks directive */ #define OPT_SYM_LINKS 4 /** ExecCGI directive */ #define OPT_EXECCGI 8 /** directive unset */ #define OPT_UNSET 16 /** SSI exec= permission is permitted, iff OPT_INCLUDES is also set */ #define OPT_INC_WITH_EXEC 32 /** SymLinksIfOwnerMatch directive */ #define OPT_SYM_OWNER 64 /** MultiViews directive */ #define OPT_MULTI 128 /** All directives */ #define OPT_ALL (OPT_INDEXES|OPT_INCLUDES|OPT_INC_WITH_EXEC|OPT_SYM_LINKS|OPT_EXECCGI) /** @} */ /** * @defgroup get_remote_host Remote Host Resolution * @ingroup APACHE_CORE_HTTPD * @{ */ /** REMOTE_HOST returns the hostname, or NULL if the hostname * lookup fails. It will force a DNS lookup according to the * HostnameLookups setting. */ #define REMOTE_HOST (0) /** REMOTE_NAME returns the hostname, or the dotted quad if the * hostname lookup fails. It will force a DNS lookup according * to the HostnameLookups setting. */ #define REMOTE_NAME (1) /** REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is * never forced. */ #define REMOTE_NOLOOKUP (2) /** REMOTE_DOUBLE_REV will always force a DNS lookup, and also force * a double reverse lookup, regardless of the HostnameLookups * setting. The result is the (double reverse checked) hostname, * or NULL if any of the lookups fail. */ #define REMOTE_DOUBLE_REV (3) /** @} // get_remote_host */ /** all of the requirements must be met */ #define SATISFY_ALL 0 /** any of the requirements must be met */ #define SATISFY_ANY 1 /** There are no applicable satisfy lines */ #define SATISFY_NOSPEC 2 /** Make sure we don't write less than 8000 bytes at any one time. */ #define AP_MIN_BYTES_TO_WRITE 8000 /** default maximum of internal redirects */ # define AP_DEFAULT_MAX_INTERNAL_REDIRECTS 10 /** default maximum subrequest nesting level */ # define AP_DEFAULT_MAX_SUBREQ_DEPTH 10 /** * Retrieve the value of Options for this request * @param r The current request * @return the Options bitmask */ AP_DECLARE(int) ap_allow_options(request_rec *r); /** * Retrieve the value of the AllowOverride for this request * @param r The current request * @return the overrides bitmask */ AP_DECLARE(int) ap_allow_overrides(request_rec *r); /** * Retrieve the document root for this server * @param r The current request * @warning Don't use this! If your request went through a Userdir, or * something like that, it'll screw you. But it's back-compatible... * @return The document root */ AP_DECLARE(const char *) ap_document_root(request_rec *r); /** * Lookup the remote user agent's DNS name or IP address * @ingroup get_remote_host * @param req The current request * @param type The type of lookup to perform. One of: * <pre> * REMOTE_HOST returns the hostname, or NULL if the hostname * lookup fails. It will force a DNS lookup according to the * HostnameLookups setting. * REMOTE_NAME returns the hostname, or the dotted quad if the * hostname lookup fails. It will force a DNS lookup according * to the HostnameLookups setting. * REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is * never forced. * REMOTE_DOUBLE_REV will always force a DNS lookup, and also force * a double reverse lookup, regardless of the HostnameLookups * setting. The result is the (double reverse checked) * hostname, or NULL if any of the lookups fail. * </pre> * @param str_is_ip unless NULL is passed, this will be set to non-zero on * output when an IP address string is returned * @return The remote hostname (based on the request useragent_ip) */ AP_DECLARE(const char *) ap_get_useragent_host(request_rec *req, int type, int *str_is_ip); /** * Lookup the remote client's DNS name or IP address * @ingroup get_remote_host * @param conn The current connection * @param dir_config The directory config vector from the request * @param type The type of lookup to perform. One of: * <pre> * REMOTE_HOST returns the hostname, or NULL if the hostname * lookup fails. It will force a DNS lookup according to the * HostnameLookups setting. * REMOTE_NAME returns the hostname, or the dotted quad if the * hostname lookup fails. It will force a DNS lookup according * to the HostnameLookups setting. * REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is * never forced. * REMOTE_DOUBLE_REV will always force a DNS lookup, and also force * a double reverse lookup, regardless of the HostnameLookups * setting. The result is the (double reverse checked) * hostname, or NULL if any of the lookups fail. * </pre> * @param str_is_ip unless NULL is passed, this will be set to non-zero on output when an IP address * string is returned * @return The remote hostname (based on the connection client_ip) */ AP_DECLARE(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip); /** * Retrieve the login name of the remote user. Undef if it could not be * determined * @param r The current request * @return The user logged in to the client machine */ AP_DECLARE(const char *) ap_get_remote_logname(request_rec *r); /* Used for constructing self-referencing URLs, and things like SERVER_PORT, * and SERVER_NAME. */ /** * build a fully qualified URL from the uri and information in the request rec * @param p The pool to allocate the URL from * @param uri The path to the requested file * @param r The current request * @return A fully qualified URL */ AP_DECLARE(char *) ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r); /** * Get the current server name from the request * @param r The current request * @return the server name */ AP_DECLARE(const char *) ap_get_server_name(request_rec *r); /** * Get the current server name from the request for the purposes * of using in a URL. If the server name is an IPv6 literal * address, it will be returned in URL format (e.g., "[fe80::1]"). * @param r The current request * @return the server name */ AP_DECLARE(const char *) ap_get_server_name_for_url(request_rec *r); /** * Get the current server port * @param r The current request * @return The server's port */ AP_DECLARE(apr_port_t) ap_get_server_port(const request_rec *r); /** * Get the size of read buffers * @param r The current request * @return The read buffers size */ AP_DECLARE(apr_size_t) ap_get_read_buf_size(const request_rec *r); /** * Return the limit on bytes in request msg body * @param r The current request * @return the maximum number of bytes in the request msg body */ AP_DECLARE(apr_off_t) ap_get_limit_req_body(const request_rec *r); /** * Return the limit on bytes in XML request msg body * @param r The current request * @return the maximum number of bytes in XML request msg body */ AP_DECLARE(apr_size_t) ap_get_limit_xml_body(const request_rec *r); /** * Install a custom response handler for a given status * @param r The current request * @param status The status for which the custom response should be used * @param string The custom response. This can be a static string, a file * or a URL */ AP_DECLARE(void) ap_custom_response(request_rec *r, int status, const char *string); /** * Check if the current request is beyond the configured max. number of redirects or subrequests * @param r The current request * @return true (is exceeded) or false */ AP_DECLARE(int) ap_is_recursion_limit_exceeded(const request_rec *r); /** * Check for a definition from the server command line * @param name The define to check for * @return 1 if defined, 0 otherwise */ AP_DECLARE(int) ap_exists_config_define(const char *name); /* FIXME! See STATUS about how */ AP_DECLARE_NONSTD(int) ap_core_translate(request_rec *r); /* Authentication stuff. This is one of the places where compatibility * with the old config files *really* hurts; they don't discriminate at * all between different authentication schemes, meaning that we need * to maintain common state for all of them in the core, and make it * available to the other modules through interfaces. */ /** @see require_line */ typedef struct require_line require_line; /** * @brief A structure to keep track of authorization requirements */ struct require_line { /** Where the require line is in the config file. */ apr_int64_t method_mask; /** The complete string from the command line */ char *requirement; }; /** * Return the type of authorization required for this request * @param r The current request * @return The authorization required */ AP_DECLARE(const char *) ap_auth_type(request_rec *r); /** * Return the current Authorization realm * @param r The current request * @return The current authorization realm */ AP_DECLARE(const char *) ap_auth_name(request_rec *r); /** * How the requires lines must be met. * @param r The current request * @return How the requirements must be met. One of: * <pre> * SATISFY_ANY -- any of the requirements must be met. * SATISFY_ALL -- all of the requirements must be met. * SATISFY_NOSPEC -- There are no applicable satisfy lines * </pre> */ AP_DECLARE(int) ap_satisfies(request_rec *r); /** * Core is also unlike other modules in being implemented in more than * one file... so, data structures are declared here, even though most of * the code that cares really is in http_core.c. Also, another accessor. */ AP_DECLARE_DATA extern module core_module; /** * Accessor for core_module's specific data. Equivalent to * ap_get_module_config(cv, &core_module) but more efficient. * @param cv The vector in which the modules configuration is stored. * usually r->per_dir_config or s->module_config * @return The module-specific data */ AP_DECLARE(void *) ap_get_core_module_config(const ap_conf_vector_t *cv); /** * Accessor to set core_module's specific data. Equivalent to * ap_set_module_config(cv, &core_module, val) but more efficient. * @param cv The vector in which the modules configuration is stored. * usually r->per_dir_config or s->module_config * @param val The module-specific data to set */ AP_DECLARE(void) ap_set_core_module_config(ap_conf_vector_t *cv, void *val); /** Get the socket from the core network filter. This should be used instead of * accessing the core connection config directly. * @param c The connection record * @return The socket */ AP_DECLARE(apr_socket_t *) ap_get_conn_socket(conn_rec *c); #ifndef AP_DEBUG #define AP_CORE_MODULE_INDEX 0 #define ap_get_core_module_config(v) \ (((void **)(v))[AP_CORE_MODULE_INDEX]) #define ap_set_core_module_config(v, val) \ ((((void **)(v))[AP_CORE_MODULE_INDEX]) = (val)) #else #define AP_CORE_MODULE_INDEX (AP_DEBUG_ASSERT(core_module.module_index == 0), 0) #endif /** * @brief Per-request configuration */ typedef struct { /** bucket brigade used by getline for look-ahead and * ap_get_client_block for holding left-over request body */ struct apr_bucket_brigade *bb; /** an array of per-request working data elements, accessed * by ID using ap_get_request_note() * (Use ap_register_request_note() during initialization * to add elements) */ void **notes; /** Custom response strings registered via ap_custom_response(), * or NULL; check per-dir config if nothing found here */ char **response_code_strings; /* from ap_custom_response(), not from * ErrorDocument */ /** per-request document root of the server. This allows mass vhosting * modules better compatibility with some scripts. Normally the * context_* info should be used instead */ const char *document_root; /* * more fine-grained context information which is set by modules like * mod_alias and mod_userdir */ /** the context root directory on disk for the current resource, * without trailing slash */ const char *context_document_root; /** the URI prefix that corresponds to the context_document_root directory, * without trailing slash */ const char *context_prefix; /** There is a script processor installed on the output filter chain, * so it needs the default_handler to deliver a (script) file into * the chain so it can process it. Normally, default_handler only * serves files on a GET request (assuming the file is actual content), * since other methods are not content-retrieval. This flag overrides * that behavior, stating that the "content" is actually a script and * won't actually be delivered as the response for the non-GET method. */ int deliver_script; /** Should addition of charset= be suppressed for this request? */ int suppress_charset; } core_request_config; /* Standard entries that are guaranteed to be accessible via * ap_get_request_note() for each request (additional entries * can be added with ap_register_request_note()) */ #define AP_NOTE_DIRECTORY_WALK 0 #define AP_NOTE_LOCATION_WALK 1 #define AP_NOTE_FILE_WALK 2 #define AP_NOTE_IF_WALK 3 #define AP_NUM_STD_NOTES 4 /** * Reserve an element in the core_request_config->notes array * for some application-specific data * @return An integer key that can be passed to ap_get_request_note() * during request processing to access this element for the * current request. */ AP_DECLARE(apr_size_t) ap_register_request_note(void); /** * Retrieve a pointer to an element in the core_request_config->notes array * @param r The request * @param note_num A key for the element: either a value obtained from * ap_register_request_note() or one of the predefined AP_NOTE_* * values. * @return NULL if the note_num is invalid, otherwise a pointer to the * requested note element. * @remark At the start of a request, each note element is NULL. The * handle provided by ap_get_request_note() is a pointer-to-pointer * so that the caller can point the element to some app-specific * data structure. The caller should guarantee that any such * structure will last as long as the request itself. */ AP_DECLARE(void **) ap_get_request_note(request_rec *r, apr_size_t note_num); typedef unsigned char allow_options_t; typedef unsigned int overrides_t; /* * Bits of info that go into making an ETag for a file * document. Why a long? Because char historically * proved too short for Options, and int can be different * sizes on different platforms. */ typedef unsigned long etag_components_t; #define ETAG_UNSET 0 #define ETAG_NONE (1 << 0) #define ETAG_MTIME (1 << 1) #define ETAG_INODE (1 << 2) #define ETAG_SIZE (1 << 3) #define ETAG_DIGEST (1 << 4) #define ETAG_ALL (ETAG_MTIME | ETAG_INODE | ETAG_SIZE) /* This is the default value used */ #define ETAG_BACKWARD (ETAG_MTIME | ETAG_SIZE) /* Generic ON/OFF/UNSET for unsigned int foo :2 */ #define AP_CORE_CONFIG_OFF (0) #define AP_CORE_CONFIG_ON (1) #define AP_CORE_CONFIG_UNSET (2) /* Generic merge of flag */ #define AP_CORE_MERGE_FLAG(field, to, base, over) to->field = \ over->field != AP_CORE_CONFIG_UNSET \ ? over->field \ : base->field /** * @brief Server Signature Enumeration */ typedef enum { srv_sig_unset, srv_sig_off, srv_sig_on, srv_sig_withmail } server_signature_e; /** * @brief Per-directory configuration */ typedef struct { /** path of the directory/regex/etc. see also d_is_fnmatch/absolute below */ char *d; /** the number of slashes in d */ unsigned d_components; /** If (opts & OPT_UNSET) then no absolute assignment to options has * been made. * invariant: (opts_add & opts_remove) == 0 * Which said another way means that the last relative (options + or -) * assignment made to each bit is recorded in exactly one of opts_add * or opts_remove. */ allow_options_t opts; allow_options_t opts_add; allow_options_t opts_remove; overrides_t override; allow_options_t override_opts; /* Used to be the custom response config. No longer used. */ char **response_code_strings; /* from ErrorDocument, not from * ap_custom_response() */ /* Hostname resolution etc */ #define HOSTNAME_LOOKUP_OFF 0 #define HOSTNAME_LOOKUP_ON 1 #define HOSTNAME_LOOKUP_DOUBLE 2 #define HOSTNAME_LOOKUP_UNSET 3 unsigned int hostname_lookups : 4; unsigned int content_md5 : 2; /* calculate Content-MD5? */ #define USE_CANONICAL_NAME_OFF (0) #define USE_CANONICAL_NAME_ON (1) #define USE_CANONICAL_NAME_DNS (2) #define USE_CANONICAL_NAME_UNSET (3) unsigned use_canonical_name : 2; /* since is_fnmatch(conf->d) was being called so frequently in * directory_walk() and its relatives, this field was created and * is set to the result of that call. */ unsigned d_is_fnmatch : 1; /* should we force a charset on any outgoing parameterless content-type? * if so, which charset? */ #define ADD_DEFAULT_CHARSET_OFF (0) #define ADD_DEFAULT_CHARSET_ON (1) #define ADD_DEFAULT_CHARSET_UNSET (2) unsigned add_default_charset : 2; const char *add_default_charset_name; /* System Resource Control */ #ifdef RLIMIT_CPU struct rlimit *limit_cpu; #endif #if defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS) struct rlimit *limit_mem; #endif #ifdef RLIMIT_NPROC struct rlimit *limit_nproc; #endif apr_off_t limit_req_body; /* limit on bytes in request msg body */ long limit_xml_body; /* limit on bytes in XML request msg body */ /* logging options */ server_signature_e server_signature; /* Access control */ apr_array_header_t *sec_file; apr_array_header_t *sec_if; ap_regex_t *r; const char *mime_type; /* forced with ForceType */ const char *handler; /* forced by something other than SetHandler */ const char *output_filters; /* forced with SetOutputFilters */ const char *input_filters; /* forced with SetInputFilters */ int accept_path_info; /* forced with AcceptPathInfo */ /* * What attributes/data should be included in ETag generation? */ etag_components_t etag_bits; etag_components_t etag_add; etag_components_t etag_remove; /* * Run-time performance tuning */ #define ENABLE_MMAP_OFF (0) #define ENABLE_MMAP_ON (1) #define ENABLE_MMAP_UNSET (2) unsigned int enable_mmap : 2; /* whether files in this dir can be mmap'ed */ #define ENABLE_SENDFILE_OFF (0) #define ENABLE_SENDFILE_ON (1) #define ENABLE_SENDFILE_UNSET (2) unsigned int enable_sendfile : 2; /* files in this dir can be sendfile'ed */ #define USE_CANONICAL_PHYS_PORT_OFF (0) #define USE_CANONICAL_PHYS_PORT_ON (1) #define USE_CANONICAL_PHYS_PORT_UNSET (2) unsigned int use_canonical_phys_port : 2; unsigned int allow_encoded_slashes : 1; /* URLs may contain %2f w/o being * pitched indiscriminately */ unsigned int decode_encoded_slashes : 1; /* whether to decode encoded slashes in URLs */ #define AP_CONDITION_IF 1 #define AP_CONDITION_ELSE 2 #define AP_CONDITION_ELSEIF (AP_CONDITION_ELSE|AP_CONDITION_IF) unsigned int condition_ifelse : 2; /* is this an <If>, <ElseIf>, or <Else> */ ap_expr_info_t *condition; /* Conditionally merge <If> sections */ /** per-dir log config */ struct ap_logconf *log; /** Table of directives allowed per AllowOverrideList */ apr_table_t *override_list; #define AP_MAXRANGES_UNSET -1 #define AP_MAXRANGES_DEFAULT -2 #define AP_MAXRANGES_UNLIMITED -3 #define AP_MAXRANGES_NORANGES 0 /** Number of Ranges before returning HTTP_OK. **/ int max_ranges; /** Max number of Range overlaps (merges) allowed **/ int max_overlaps; /** Max number of Range reversals (eg: 200-300, 100-125) allowed **/ int max_reversals; /** Named back references */ apr_array_header_t *refs; /** Custom response config with expression support. The hash table * contains compiled expressions keyed against the custom response * code. */ apr_hash_t *response_code_exprs; #define AP_CGI_PASS_AUTH_OFF (0) #define AP_CGI_PASS_AUTH_ON (1) #define AP_CGI_PASS_AUTH_UNSET (2) /** CGIPassAuth: Whether HTTP authorization headers will be passed to * scripts as CGI variables; affects all modules calling * ap_add_common_vars(), as well as any others using this field as * advice */ unsigned int cgi_pass_auth : 2; unsigned int qualify_redirect_url :2; ap_expr_info_t *expr_handler; /* forced with SetHandler */ /** Table of rules for building CGI variables, NULL if none configured */ apr_hash_t *cgi_var_rules; apr_size_t read_buf_size; } core_dir_config; /* macro to implement off by default behaviour */ #define AP_SENDFILE_ENABLED(x) \ ((x) == ENABLE_SENDFILE_ON ? APR_SENDFILE_ENABLED : 0) /* Per-server core configuration */ typedef struct { char *gprof_dir; /* Name translations --- we want the core to be able to do *something* * so it's at least a minimally functional web server on its own (and * can be tested that way). But let's keep it to the bare minimum: */ const char *ap_document_root; /* Access control */ char *access_name; apr_array_header_t *sec_dir; apr_array_header_t *sec_url; /* recursion backstopper */ int redirect_limit; /* maximum number of internal redirects */ int subreq_limit; /* maximum nesting level of subrequests */ const char *protocol; apr_table_t *accf_map; /* array of ap_errorlog_format_item for error log format string */ apr_array_header_t *error_log_format; /* * two arrays of arrays of ap_errorlog_format_item for additional information * logged to the error log once per connection/request */ apr_array_header_t *error_log_conn; apr_array_header_t *error_log_req; /* TRACE control */ #define AP_TRACE_UNSET -1 #define AP_TRACE_DISABLE 0 #define AP_TRACE_ENABLE 1 #define AP_TRACE_EXTENDED 2 int trace_enable; #define AP_MERGE_TRAILERS_UNSET 0 #define AP_MERGE_TRAILERS_ENABLE 1 #define AP_MERGE_TRAILERS_DISABLE 2 int merge_trailers; apr_array_header_t *protocols; int protocols_honor_order; #define AP_HTTP09_UNSET 0 #define AP_HTTP09_ENABLE 1 #define AP_HTTP09_DISABLE 2 char http09_enable; #define AP_HTTP_CONFORMANCE_UNSET 0 #define AP_HTTP_CONFORMANCE_UNSAFE 1 #define AP_HTTP_CONFORMANCE_STRICT 2 char http_conformance; #define AP_HTTP_METHODS_UNSET 0 #define AP_HTTP_METHODS_LENIENT 1 #define AP_HTTP_METHODS_REGISTERED 2 char http_methods; unsigned int merge_slashes; /* symlink protection */ #define AP_SYMLINK_PROTECT_UNSET 0 #define AP_SYMLINK_PROTECT_ENABLE 1 #define AP_SYMLINK_PROTECT_DISABLE 2 int symlink_protect; const char *symlink_protect_root; apr_size_t flush_max_threshold; apr_int32_t flush_max_pipelined; unsigned int strict_host_check; #ifdef WIN32 apr_array_header_t *unc_list; #endif } core_server_config; /* for AddOutputFiltersByType in core.c */ void ap_add_output_filters_by_type(request_rec *r); /* for http_config.c */ void ap_core_reorder_directories(apr_pool_t *, server_rec *); /* for mod_perl */ AP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config); AP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config); AP_CORE_DECLARE(void) ap_add_file_conf(apr_pool_t *p, core_dir_config *conf, void *url_config); AP_CORE_DECLARE(const char *) ap_add_if_conf(apr_pool_t *p, core_dir_config *conf, void *url_config); AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, const char *arg); /* Core filters; not exported. */ apr_status_t ap_core_input_filter(ap_filter_t *f, apr_bucket_brigade *b, ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes); apr_status_t ap_core_output_filter(ap_filter_t *f, apr_bucket_brigade *b); AP_DECLARE(const char*) ap_get_server_protocol(server_rec* s); AP_DECLARE(void) ap_set_server_protocol(server_rec* s, const char* proto); typedef struct core_output_filter_ctx core_output_filter_ctx_t; typedef struct core_filter_ctx core_ctx_t; struct core_filter_ctx { apr_bucket_brigade *b; apr_bucket_brigade *tmpbb; }; typedef struct core_net_rec { /** Connection to the client */ apr_socket_t *client_socket; /** connection record */ conn_rec *c; core_output_filter_ctx_t *out_ctx; core_ctx_t *in_ctx; } core_net_rec; /** * Insert the network bucket into the core input filter's input brigade. * This hook is intended for MPMs or protocol modules that need to do special * socket setup. * @param c The connection * @param bb The brigade to insert the bucket into * @param socket The socket to put into a bucket * @return AP_DECLINED if the current function does not handle this connection, * APR_SUCCESS or an error otherwise. */ AP_DECLARE_HOOK(apr_status_t, insert_network_bucket, (conn_rec *c, apr_bucket_brigade *bb, apr_socket_t *socket)) /* ---------------------------------------------------------------------- * * Runtime status/management */ typedef enum { ap_mgmt_type_string, ap_mgmt_type_long, ap_mgmt_type_hash } ap_mgmt_type_e; typedef union { const char *s_value; long i_value; apr_hash_t *h_value; } ap_mgmt_value; typedef struct { const char *description; const char *name; ap_mgmt_type_e vtype; ap_mgmt_value v; } ap_mgmt_item_t; /* Handles for core filters */ AP_DECLARE_DATA extern ap_filter_rec_t *ap_subreq_core_filter_handle; AP_DECLARE_DATA extern ap_filter_rec_t *ap_core_output_filter_handle; AP_DECLARE_DATA extern ap_filter_rec_t *ap_content_length_filter_handle; AP_DECLARE_DATA extern ap_filter_rec_t *ap_core_input_filter_handle; /** * This hook provdes a way for modules to provide metrics/statistics about * their operational status. * * @param p A pool to use to create entries in the hash table * @param val The name of the parameter(s) that is wanted. This is * tree-structured would be in the form ('*' is all the tree, * 'module.*' all of the module , 'module.foo.*', or * 'module.foo.bar' ) * @param ht The hash table to store the results. Keys are item names, and * the values point to ap_mgmt_item_t structures. * @ingroup hooks */ AP_DECLARE_HOOK(int, get_mgmt_items, (apr_pool_t *p, const char * val, apr_hash_t *ht)) /* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- * * I/O logging with mod_logio */ APR_DECLARE_OPTIONAL_FN(void, ap_logio_add_bytes_out, (conn_rec *c, apr_off_t bytes)); APR_DECLARE_OPTIONAL_FN(void, ap_logio_add_bytes_in, (conn_rec *c, apr_off_t bytes)); APR_DECLARE_OPTIONAL_FN(apr_off_t, ap_logio_get_last_bytes, (conn_rec *c)); /* ---------------------------------------------------------------------- * * Error log formats */ /** * The info structure passed to callback functions of errorlog handlers. * Not all information is available in all contexts. In particular, all * pointers may be NULL. */ typedef struct ap_errorlog_info { /** current server_rec. * Should be preferred over c->base_server and r->server */ const server_rec *s; /** current conn_rec. * Should be preferred over r->connection */ const conn_rec *c; /** current request_rec. */ const request_rec *r; /** r->main if r is a subrequest, otherwise equal to r */ const request_rec *rmain; /** pool passed to ap_log_perror, NULL otherwise */ apr_pool_t *pool; /** name of source file where the log message was produced, NULL if N/A. */ const char *file; /** line number in the source file, 0 if N/A */ int line; /** module index of module that produced the log message, APLOG_NO_MODULE if N/A. */ int module_index; /** log level of error message (flags like APLOG_STARTUP have been removed), -1 if N/A */ int level; /** apr error status related to the log message, 0 if no error */ apr_status_t status; /** 1 if logging to syslog, 0 otherwise */ int using_syslog; /** 1 if APLOG_STARTUP was set for the log message, 0 otherwise */ int startup; /** message format */ const char *format; } ap_errorlog_info; /** * callback function prototype for a external errorlog handler * @note To avoid unbounded memory usage, these functions must not allocate * memory from the server, connection, or request pools. If an errorlog * handler absolutely needs a pool to pass to other functions, it must create * and destroy a sub-pool. */ typedef int ap_errorlog_handler_fn_t(const ap_errorlog_info *info, const char *arg, char *buf, int buflen); /** * Register external errorlog handler * @param p config pool to use * @param tag the new format specifier (i.e. the letter after the %) * @param handler the handler function * @param flags flags (reserved, set to 0) */ AP_DECLARE(void) ap_register_errorlog_handler(apr_pool_t *p, char *tag, ap_errorlog_handler_fn_t *handler, int flags); typedef struct ap_errorlog_handler { ap_errorlog_handler_fn_t *func; int flags; /* for future extensions */ } ap_errorlog_handler; /** item starts a new field */ #define AP_ERRORLOG_FLAG_FIELD_SEP 1 /** item is the actual error message */ #define AP_ERRORLOG_FLAG_MESSAGE 2 /** skip whole line if item is zero-length */ #define AP_ERRORLOG_FLAG_REQUIRED 4 /** log zero-length item as '-' */ #define AP_ERRORLOG_FLAG_NULL_AS_HYPHEN 8 typedef struct { /** ap_errorlog_handler function */ ap_errorlog_handler_fn_t *func; /** argument passed to item in {} */ const char *arg; /** a combination of the AP_ERRORLOG_* flags */ unsigned int flags; /** only log item if the message's log level is higher than this */ unsigned int min_loglevel; } ap_errorlog_format_item; /** * hook method to log error messages * @ingroup hooks * @param info pointer to ap_errorlog_info struct which contains all * the details * @param errstr the (unformatted) message to log * @warning Allocating from the usual pools (pool, info->c->pool, info->p->pool) * must be avoided because it can cause memory leaks. * Use a subpool if necessary. */ AP_DECLARE_HOOK(void, error_log, (const ap_errorlog_info *info, const char *errstr)) AP_CORE_DECLARE(void) ap_register_log_hooks(apr_pool_t *p); AP_CORE_DECLARE(void) ap_register_config_hooks(apr_pool_t *p); /* ---------------------------------------------------------------------- * * ident lookups with mod_ident */ APR_DECLARE_OPTIONAL_FN(const char *, ap_ident_lookup, (request_rec *r)); /* ---------------------------------------------------------------------- * * authorization values with mod_authz_core */ APR_DECLARE_OPTIONAL_FN(int, authz_some_auth_required, (request_rec *r)); APR_DECLARE_OPTIONAL_FN(const char *, authn_ap_auth_type, (request_rec *r)); APR_DECLARE_OPTIONAL_FN(const char *, authn_ap_auth_name, (request_rec *r)); /* ---------------------------------------------------------------------- * * authorization values with mod_access_compat */ APR_DECLARE_OPTIONAL_FN(int, access_compat_ap_satisfies, (request_rec *r)); /* ---------------------------------------------------------------------- */ /** Query the server for some state information * @param query_code Which information is requested * @return the requested state information */ AP_DECLARE(int) ap_state_query(int query_code); /* * possible values for query_code in ap_state_query() */ /** current status of the server */ #define AP_SQ_MAIN_STATE 0 /** are we going to serve requests or are we just testing/dumping config */ #define AP_SQ_RUN_MODE 1 /** generation of the top-level apache parent */ #define AP_SQ_CONFIG_GEN 2 /* * return values for ap_state_query() */ /** return value for unknown query_code */ #define AP_SQ_NOT_SUPPORTED -1 /* values returned for AP_SQ_MAIN_STATE */ /** before the config preflight */ #define AP_SQ_MS_INITIAL_STARTUP 1 /** initial configuration run for setting up log config, etc. */ #define AP_SQ_MS_CREATE_PRE_CONFIG 2 /** tearing down configuration */ #define AP_SQ_MS_DESTROY_CONFIG 3 /** normal configuration run */ #define AP_SQ_MS_CREATE_CONFIG 4 /** running the MPM */ #define AP_SQ_MS_RUN_MPM 5 /** cleaning up for exit */ #define AP_SQ_MS_EXITING 6 /* values returned for AP_SQ_RUN_MODE */ /** command line not yet parsed */ #define AP_SQ_RM_UNKNOWN 1 /** normal operation (server requests or signal server) */ #define AP_SQ_RM_NORMAL 2 /** config test only */ #define AP_SQ_RM_CONFIG_TEST 3 /** only dump some parts of the config */ #define AP_SQ_RM_CONFIG_DUMP 4 /** Get a apr_pollfd_t populated with descriptor and descriptor type * and the timeout to use for it. * @return APR_ENOTIMPL if not supported for a connection. */ AP_DECLARE_HOOK(apr_status_t, get_pollfd_from_conn, (conn_rec *c, struct apr_pollfd_t *pfd, apr_interval_time_t *ptimeout)) /** * Pass in a `struct apr_pollfd_t*` and get `desc_type` and `desc` * populated with a suitable value for polling connection input. * For primary connection (c->master == NULL), this will be the connection * socket. For secondary connections this may differ or not be available * at all. * Note that APR_NO_DESC may be set to indicate that the connection * input is already closed. * * @param pfd the pollfd to set the descriptor in * @param ptimeout != NULL to retrieve the timeout in effect * @return ARP_SUCCESS when the information was assigned. */ AP_CORE_DECLARE(apr_status_t) ap_get_pollfd_from_conn(conn_rec *c, struct apr_pollfd_t *pfd, apr_interval_time_t *ptimeout); #ifdef __cplusplus } #endif #endif /* !APACHE_HTTP_CORE_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_rewrite.h * @brief Rewrite Extension module for Apache * * @defgroup MOD_REWRITE mod_rewrite * @ingroup APACHE_MODS * @{ */ #ifndef MOD_REWRITE_H #define MOD_REWRITE_H 1 #include "apr_optional.h" #include "httpd.h" #define REWRITE_REDIRECT_HANDLER_NAME "redirect-handler" /* rewrite map function prototype */ typedef char *(rewrite_mapfunc_t)(request_rec *r, char *key); /* optional function declaration */ APR_DECLARE_OPTIONAL_FN(void, ap_register_rewrite_mapfunc, (char *name, rewrite_mapfunc_t *func)); #endif /* MOD_REWRITE_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file ap_mpm.h * @brief Apache Multi-Processing Module library * * @defgroup APACHE_CORE_MPM Multi-Processing Module library * @ingroup APACHE_CORE * @{ */ #ifndef AP_MPM_H #define AP_MPM_H #include "apr_thread_proc.h" #include "httpd.h" #include "scoreboard.h" #ifdef __cplusplus extern "C" { #endif /* The MPM, "multi-processing model" provides an abstraction of the interface with the OS for distributing incoming connections to threads/process for processing. http_main invokes the MPM, and the MPM runs until a shutdown/restart has been indicated. The MPM calls out to the apache core via the ap_process_connection function when a connection arrives. The MPM may or may not be multithreaded. In the event that it is multithreaded, at any instant it guarantees a 1:1 mapping of threads ap_process_connection invocations. Note: In the future it will be possible for ap_process_connection to return to the MPM prior to finishing the entire connection; and the MPM will proceed with asynchronous handling for the connection; in the future the MPM may call ap_process_connection again -- but does not guarantee it will occur on the same thread as the first call. The MPM further guarantees that no asynchronous behaviour such as longjmps and signals will interfere with the user code that is invoked through ap_process_connection. The MPM may reserve some signals for its use (i.e. SIGUSR1), but guarantees that these signals are ignored when executing outside the MPM code itself. (This allows broken user code that does not handle EINTR to function properly.) The suggested server restart and stop behaviour will be "graceful". However the MPM may choose to terminate processes when the user requests a non-graceful restart/stop. When this occurs, the MPM kills all threads with extreme prejudice, and destroys the pchild pool. User cleanups registered in the pchild apr_pool_t will be invoked at this point. (This can pose some complications, the user cleanups are asynchronous behaviour not unlike longjmp/signal... but if the admin is asking for a non-graceful shutdown, how much effort should we put into doing it in a nice way?) unix/posix notes: - The MPM does not set a SIGALRM handler, user code may use SIGALRM. But the preferred method of handling timeouts is to use the timeouts provided by the BUFF abstraction. - The proper setting for SIGPIPE is SIG_IGN, if user code changes it for any of their own processing, it must be restored to SIG_IGN prior to executing or returning to any apache code. TODO: add SIGPIPE debugging check somewhere to make sure it's SIG_IGN */ /** * Pass control to the MPM for steady-state processing. It is responsible * for controlling the parent and child processes. It will run until a * restart/shutdown is indicated. * @param pconf the configuration pool, reset before the config file is read * @param plog the log pool, reset after the config file is read * @param server_conf the global server config. * @return DONE for shutdown OK otherwise. * @ingroup hooks */ AP_DECLARE_HOOK(int, mpm, (apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf)) /** * Spawn a process with privileges that another module has requested * @param r The request_rec of the current request * @param newproc The resulting process handle. * @param progname The program to run * @param args the arguments to pass to the new program. The first * one should be the program name. * @param env The new environment apr_table_t for the new process. This * should be a list of NULL-terminated strings. * @param attr the procattr we should use to determine how to create the new * process * @param p The pool to use. */ AP_DECLARE(apr_status_t) ap_os_create_privileged_process( const request_rec *r, apr_proc_t *newproc, const char *progname, const char * const *args, const char * const *env, apr_procattr_t *attr, apr_pool_t *p); /** @defgroup mpmq MPM query * @{ */ /** @defgroup thrdfrk Subtypes/Values returned for AP_MPMQ_IS_THREADED and AP_MPMQ_IS_FORKED * @ingroup mpmq * @{ */ #define AP_MPMQ_NOT_SUPPORTED 0 /**< This value specifies that an * MPM is not capable of * threading or forking. */ #define AP_MPMQ_STATIC 1 /**< This value specifies that * an MPM is using a static * number of threads or daemons */ #define AP_MPMQ_DYNAMIC 2 /**< This value specifies that * an MPM is using a dynamic * number of threads or daemons */ /** @} */ /** @defgroup qstate Values returned for AP_MPMQ_MPM_STATE * @ingroup mpmq * @{ */ #define AP_MPMQ_STARTING 0 #define AP_MPMQ_RUNNING 1 #define AP_MPMQ_STOPPING 2 /** @} */ /** @defgroup qcodes Query codes for ap_mpm_query() * @ingroup mpmq * @{ */ /** Max # of daemons used so far */ #define AP_MPMQ_MAX_DAEMON_USED 1 /** MPM can do threading */ #define AP_MPMQ_IS_THREADED 2 /** MPM can do forking */ #define AP_MPMQ_IS_FORKED 3 /** The compiled max # daemons */ #define AP_MPMQ_HARD_LIMIT_DAEMONS 4 /** The compiled max # threads */ #define AP_MPMQ_HARD_LIMIT_THREADS 5 /** \# of threads/child by config */ #define AP_MPMQ_MAX_THREADS 6 /** Min # of spare daemons */ #define AP_MPMQ_MIN_SPARE_DAEMONS 7 /** Min # of spare threads */ #define AP_MPMQ_MIN_SPARE_THREADS 8 /** Max # of spare daemons */ #define AP_MPMQ_MAX_SPARE_DAEMONS 9 /** Max # of spare threads */ #define AP_MPMQ_MAX_SPARE_THREADS 10 /** Max # of requests per daemon */ #define AP_MPMQ_MAX_REQUESTS_DAEMON 11 /** Max # of daemons by config */ #define AP_MPMQ_MAX_DAEMONS 12 /** starting, running, stopping */ #define AP_MPMQ_MPM_STATE 13 /** MPM can process async connections */ #define AP_MPMQ_IS_ASYNC 14 /** MPM generation */ #define AP_MPMQ_GENERATION 15 /** MPM can drive serf internally */ #define AP_MPMQ_HAS_SERF 16 /* 17-18 are trunk only */ /** MPM supports CONN_STATE_ASYNC_WAITIO */ #define AP_MPMQ_CAN_WAITIO 19 /** @} */ /** * Query a property of the current MPM. * @param query_code One of AP_MPMQ_* * @param result A location to place the result of the query * @return APR_EGENERAL if an mpm-query hook has not been registered; * APR_SUCCESS or APR_ENOTIMPL otherwise * @remark The MPM doesn't register the implementing hook until the * register_hooks hook is called, so modules cannot use ap_mpm_query() * until after that point. * @fn int ap_mpm_query(int query_code, int *result) */ AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result); /** @} */ typedef void (ap_mpm_callback_fn_t)(void *baton); /* only added support in the Event MPM.... check for APR_ENOTIMPL */ AP_DECLARE(apr_status_t) ap_mpm_register_timed_callback(apr_time_t t, ap_mpm_callback_fn_t *cbfn, void *baton); typedef enum mpm_child_status { MPM_CHILD_STARTED, MPM_CHILD_EXITED, MPM_CHILD_LOST_SLOT } mpm_child_status; /** * Allow a module to remain aware of MPM child process state changes, * along with the generation and scoreboard slot of the process changing * state. * * With some MPMs (event and worker), an active MPM child process may lose * its scoreboard slot if the child process is exiting and the scoreboard * slot is needed by other processes. When this occurs, the hook will be * called with the MPM_CHILD_LOST_SLOT state. * * @param s The main server_rec. * @param pid The id of the MPM child process. * @param gen The server generation of that child process. * @param slot The scoreboard slot number, or -1. It will be -1 when an * MPM child process exits, and that child had previously lost its * scoreboard slot. * @param state One of the mpm_child_status values. Modules should ignore * unrecognized values. * @ingroup hooks */ AP_DECLARE_HOOK(void,child_status,(server_rec *s, pid_t pid, ap_generation_t gen, int slot, mpm_child_status state)) /** * Allow a module to be notified when the last child process of a generation * exits. * * @param s The main server_rec. * @param gen The server generation which is now completely finished. * @ingroup hooks */ AP_DECLARE_HOOK(void,end_generation,(server_rec *s, ap_generation_t gen)) /* Defining GPROF when compiling uses the moncontrol() function to * disable gprof profiling in the parent, and enable it only for * request processing in children (or in one_process mode). It's * absolutely required to get useful gprof results under linux * because the profile itimers and such are disabled across a * fork(). It's probably useful elsewhere as well. */ #ifdef GPROF extern void moncontrol(int); #define AP_MONCONTROL(x) moncontrol(x) #else #define AP_MONCONTROL(x) #endif #ifdef AP_ENABLE_EXCEPTION_HOOK typedef struct ap_exception_info_t { int sig; pid_t pid; } ap_exception_info_t; /** * Run the fatal_exception hook for each module; this hook is run * from some MPMs in the event of a child process crash, if the * server was built with --enable-exception-hook and the * EnableExceptionHook directive is On. * @param ei information about the exception * @ingroup hooks */ AP_DECLARE_HOOK(int,fatal_exception,(ap_exception_info_t *ei)) #endif /*AP_ENABLE_EXCEPTION_HOOK*/ #ifdef __cplusplus } #endif #endif /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_include.h * @brief Server Side Include Filter Extension Module for Apache * * @defgroup MOD_INCLUDE mod_include * @ingroup APACHE_MODS * @{ */ #ifndef _MOD_INCLUDE_H #define _MOD_INCLUDE_H 1 #include "apr_pools.h" #include "apr_optional.h" /* * Constants used for ap_ssi_get_tag_and_value's decode parameter */ #define SSI_VALUE_DECODED 1 #define SSI_VALUE_RAW 0 /* * Constants used for ap_ssi_parse_string's leave_name parameter */ #define SSI_EXPAND_LEAVE_NAME 1 #define SSI_EXPAND_DROP_NAME 0 /* * This macro creates a bucket which contains an error message and appends it * to the current pass brigade */ #define SSI_CREATE_ERROR_BUCKET(ctx, f, bb) APR_BRIGADE_INSERT_TAIL((bb), \ apr_bucket_pool_create(apr_pstrdup((ctx)->pool, (ctx)->error_str), \ strlen((ctx)->error_str), (ctx)->pool, \ (f)->c->bucket_alloc)) /* * These constants are used to set or clear flag bits. */ #define SSI_FLAG_PRINTING (1<<0) /* Printing conditional lines. */ #define SSI_FLAG_COND_TRUE (1<<1) /* Conditional eval'd to true. */ #define SSI_FLAG_SIZE_IN_BYTES (1<<2) /* Sizes displayed in bytes. */ #define SSI_FLAG_NO_EXEC (1<<3) /* No Exec in current context. */ #define SSI_FLAG_COND_ERROR (1<<4) /* Conditional evaluation was in error */ #define SSI_FLAG_SIZE_ABBREV (~(SSI_FLAG_SIZE_IN_BYTES)) #define SSI_FLAG_CLEAR_PRINT_COND (~((SSI_FLAG_PRINTING) | \ (SSI_FLAG_COND_TRUE))) #define SSI_FLAG_CLEAR_PRINTING (~(SSI_FLAG_PRINTING)) /* * The public SSI context structure */ typedef struct { /* permanent pool, use this for creating bucket data */ apr_pool_t *pool; /* temp pool; will be cleared after the execution of every directive */ apr_pool_t *dpool; /* See the SSI_FLAG_XXXXX definitions. */ int flags; /* nesting of *invisible* ifs */ int if_nesting_level; /* if true, the current buffer will be passed down the filter chain before * continuing with next input bucket and the variable will be reset to * false. */ int flush_now; /* argument counter (of the current directive) */ unsigned argc; /* currently configured error string */ const char *error_str; /* currently configured time format */ const char *time_str; /* the current request */ request_rec *r; /* pointer to internal (non-public) data, don't touch */ struct ssi_internal_ctx *intern; } include_ctx_t; typedef apr_status_t (include_handler_fn_t)(include_ctx_t *, ap_filter_t *, apr_bucket_brigade *); APR_DECLARE_OPTIONAL_FN(void, ap_ssi_get_tag_and_value, (include_ctx_t *ctx, char **tag, char **tag_val, int dodecode)); APR_DECLARE_OPTIONAL_FN(char*, ap_ssi_parse_string, (include_ctx_t *ctx, const char *in, char *out, apr_size_t length, int leave_name)); APR_DECLARE_OPTIONAL_FN(void, ap_register_include_handler, (char *tag, include_handler_fn_t *func)); #endif /* MOD_INCLUDE */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SLOTMEM_H #define SLOTMEM_H /* Memory handler for a shared memory divided in slot. */ /** * @file ap_slotmem.h * @brief Memory Slot Extension Storage Module for Apache * * @defgroup MEM mem * @ingroup APACHE_MODS * @{ */ #include "httpd.h" #include "http_config.h" #include "http_log.h" #include "ap_provider.h" #include "apr.h" #include "apr_strings.h" #include "apr_pools.h" #include "apr_shm.h" #include "apr_global_mutex.h" #include "apr_file_io.h" #include "apr_md5.h" #if APR_HAVE_UNISTD_H #include <unistd.h> /* for getpid() */ #endif #ifdef __cplusplus extern "C" { #endif #define AP_SLOTMEM_PROVIDER_GROUP "slotmem" #define AP_SLOTMEM_PROVIDER_VERSION "0" typedef unsigned int ap_slotmem_type_t; /* * Values for ap_slotmem_type_t:: * * AP_SLOTMEM_TYPE_PERSIST: For transitory providers, persist * the data on the file-system * * AP_SLOTMEM_TYPE_NOTMPSAFE: * * AP_SLOTMEM_TYPE_PREALLOC: Access to slots require they be grabbed 1st * * AP_SLOTMEM_TYPE_CLEARINUSE: If persisting, clear 'inuse' array before * storing */ #define AP_SLOTMEM_TYPE_PERSIST (1 << 0) #define AP_SLOTMEM_TYPE_NOTMPSAFE (1 << 1) #define AP_SLOTMEM_TYPE_PREGRAB (1 << 2) #define AP_SLOTMEM_TYPE_CLEARINUSE (1 << 3) typedef struct ap_slotmem_instance_t ap_slotmem_instance_t; /** * callback function used for slotmem doall. * @param mem is the memory associated with a worker. * @param data is what is passed to slotmem. * @param pool is pool used * @return APR_SUCCESS if all went well */ typedef apr_status_t ap_slotmem_callback_fn_t(void* mem, void *data, apr_pool_t *pool); struct ap_slotmem_provider_t { /* * Name of the provider method */ const char *name; /** * call the callback on all worker slots * @param s ap_slotmem_instance_t to use. * @param funct callback function to call for each element. * @param data parameter for the callback function. * @param pool is pool used * @return APR_SUCCESS if all went well */ apr_status_t (* doall)(ap_slotmem_instance_t *s, ap_slotmem_callback_fn_t *func, void *data, apr_pool_t *pool); /** * create a new slotmem with each item size is item_size. * This would create shared memory, basically. * @param inst where to store pointer to slotmem * @param name a key used for debugging and in mod_status output or allow another process to share this space. * @param item_size size of each item * @param item_num number of item to create. * @param type type of slotmem. * @param pool is pool used * @return APR_SUCCESS if all went well */ apr_status_t (* create)(ap_slotmem_instance_t **inst, const char *name, apr_size_t item_size, unsigned int item_num, ap_slotmem_type_t type, apr_pool_t *pool); /** * attach to an existing slotmem. * This would attach to shared memory, basically. * @param inst where to store pointer to slotmem * @param name a key used for debugging and in mod_status output or allow another process to share this space. * @param item_size size of each item * @param item_num max number of item. * @param pool is pool to memory allocate. * @return APR_SUCCESS if all went well */ apr_status_t (* attach)(ap_slotmem_instance_t **inst, const char *name, apr_size_t *item_size, unsigned int *item_num, apr_pool_t *pool); /** * get the memory ptr associated with this worker slot. * @param s ap_slotmem_instance_t to use. * @param item_id item to return for 0 to item_num * @param mem address to store the pointer to the slot * @return APR_SUCCESS if all went well */ apr_status_t (* dptr)(ap_slotmem_instance_t *s, unsigned int item_id, void**mem); /** * get/read the data associated with this worker slot. * @param s ap_slotmem_instance_t to use. * @param item_id item to return for 0 to item_num * @param dest address to store the data * @param dest_len length of dataset to retrieve * @return APR_SUCCESS if all went well */ apr_status_t (* get)(ap_slotmem_instance_t *s, unsigned int item_id, unsigned char *dest, apr_size_t dest_len); /** * put/write the data associated with this worker slot. * @param s ap_slotmem_instance_t to use. * @param item_id item to return for 0 to item_num * @param src address of the data to store in the slot * @param src_len length of dataset to store in the slot * @return APR_SUCCESS if all went well */ apr_status_t (* put)(ap_slotmem_instance_t *slot, unsigned int item_id, unsigned char *src, apr_size_t src_len); /** * return number of slots allocated for this entry. * @param s ap_slotmem_instance_t to use. * @return number of slots */ unsigned int (* num_slots)(ap_slotmem_instance_t *s); /** * return number of free (not used) slots allocated for this entry. * Valid for slots which are AP_SLOTMEM_TYPE_PREGRAB as well as * any which use get/release. * @param s ap_slotmem_instance_t to use. * @return number of slots */ unsigned int (* num_free_slots)(ap_slotmem_instance_t *s); /** * return slot size allocated for this entry. * @param s ap_slotmem_instance_t to use. * @return size of slot */ apr_size_t (* slot_size)(ap_slotmem_instance_t *s); /** * grab (or alloc) a free slot * @param s ap_slotmem_instance_t to use. * @param item_id ptr to the available slot id and marked as in-use * @return APR_SUCCESS if all went well */ apr_status_t (* grab)(ap_slotmem_instance_t *s, unsigned int *item_id); /** * release (or free) the slot associated with this item_id * @param s ap_slotmem_instance_t to use. * @param item_id slot id to free and mark as no longer in-use * @return APR_SUCCESS if all went well */ apr_status_t (* release)(ap_slotmem_instance_t *s, unsigned int item_id); /** * forced grab (or alloc) a slot associated with this item_id * @param s ap_slotmem_instance_t to use. * @param item_id to the specified slot id and marked as in-use * @return APR_SUCCESS if all went well */ apr_status_t (* fgrab)(ap_slotmem_instance_t *s, unsigned int item_id); }; typedef struct ap_slotmem_provider_t ap_slotmem_provider_t; #ifdef __cplusplus } #endif #endif /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file ap_mmn.h * @brief Module Magic Number * * @defgroup APACHE_CORE_MMN Module Magic Number * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_AP_MMN_H #define APACHE_AP_MMN_H /* * MODULE_MAGIC_NUMBER_MAJOR * Major API changes that could cause compatibility problems for older modules * such as structure size changes. No binary compatibility is possible across * a change in the major version. * * MODULE_MAGIC_NUMBER_MINOR * Minor API changes that do not cause binary compatibility problems. * Should be reset to 0 when upgrading MODULE_MAGIC_NUMBER_MAJOR. * * See the AP_MODULE_MAGIC_AT_LEAST macro below for an example. */ /* * 20010224 (2.0.13-dev) MODULE_MAGIC_COOKIE reset to "AP20" * 20010523 (2.0.19-dev) bump for scoreboard structure reordering * 20010627 (2.0.19-dev) more API changes than I can count * 20010726 (2.0.22-dev) more big API changes * 20010808 (2.0.23-dev) dir d_is_absolute bit introduced, bucket changes, etc * 20010825 (2.0.25-dev) removed d_is_absolute, introduced map_to_storage hook * 20011002 (2.0.26-dev) removed 1.3-deprecated request_rec.content_language * 20011127 (2.0.29-dev) bump for postconfig hook change, and removal of * socket from connection record * 20011212 (2.0.30-dev) bump for new used_path_info member of request_rec * 20011218 (2.0.30-dev) bump for new sbh member of conn_rec, different * declarations for scoreboard, new parameter to * create_connection hook * 20020102 (2.0.30-dev) bump for changed type of limit_req_body in * core_dir_config * 20020109 (2.0.31-dev) bump for changed shm and scoreboard declarations * 20020111 (2.0.31-dev) bump for ETag fields added at end of cor_dir_config * 20020114 (2.0.31-dev) mod_dav changed how it asks its provider to fulfill * a GET request * 20020118 (2.0.31-dev) Input filtering split of blocking and mode * 20020127 (2.0.31-dev) bump for pre_mpm hook change * 20020128 (2.0.31-dev) bump for pre_config hook change * 20020218 (2.0.33-dev) bump for AddOutputFilterByType directive * 20020220 (2.0.33-dev) bump for scoreboard.h structure change * 20020302 (2.0.33-dev) bump for protocol_filter additions. * 20020306 (2.0.34-dev) bump for filter type renames. * 20020318 (2.0.34-dev) mod_dav's API for REPORT generation changed * 20020319 (2.0.34-dev) M_INVALID changed, plus new M_* methods for RFC 3253 * 20020327 (2.0.35-dev) Add parameter to quick_handler hook * 20020329 (2.0.35-dev) bump for addition of freelists to bucket API * 20020329.1 (2.0.36) minor bump for new arg to opt fn ap_cgi_build_command * 20020506 (2.0.37-dev) Removed r->boundary in request_rec. * 20020529 (2.0.37-dev) Standardized the names of some apr_pool_*_set funcs * 20020602 (2.0.37-dev) Bucket API change (metadata buckets) * 20020612 (2.0.38-dev) Changed server_rec->[keep_alive_]timeout to apr time * 20020625 (2.0.40-dev) Changed conn_rec->keepalive to an enumeration * 20020628 (2.0.40-dev) Added filter_init to filter registration functions * 20020903 (2.0.41-dev) APR's error constants changed * 20020903.1 (2.1.0-dev) allow_encoded_slashes added to core_dir_config * 20020903.2 (2.0.46-dev) add ap_escape_logitem * 20030213.1 (2.1.0-dev) changed log_writer optional fn's to return previous * handler * 20030821 (2.1.0-dev) bumped mod_include's entire API * 20030821.1 (2.1.0-dev) added XHTML doctypes * 20030821.2 (2.1.0-dev) added ap_escape_errorlog_item * 20030821.3 (2.1.0-dev) added ap_get_server_revision / ap_version_t * 20040425 (2.1.0-dev) removed ap_add_named_module API * changed ap_add_module, ap_add_loaded_module, * ap_setup_prelinked_modules, * ap_process_resource_config * 20040425.1 (2.1.0-dev) Added ap_module_symbol_t and * ap_prelinked_module_symbols * 20050101.0 (2.1.2-dev) Axed misnamed http_method for http_scheme * (which it was!) * 20050127.0 (2.1.3-dev) renamed regex_t->ap_regex_t, * regmatch_t->ap_regmatch_t, REG_*->AP_REG_*, * removed reg* in place of ap_reg*; added ap_regex.h * 20050217.0 (2.1.3-dev) Axed find_child_by_pid, mpm_*_completion_context * (winnt mpm) symbols from the public sector, and * decorated real_exit_code with ap_ in the win32/os.h. * 20050305.0 (2.1.4-dev) added pid and generation fields to worker_score * 20050305.1 (2.1.5-dev) added ap_vhost_iterate_given_conn. * 20050305.2 (2.1.5-dev) added AP_INIT_TAKE_ARGV. * 20050305.3 (2.1.5-dev) added Protocol Framework. * 20050701.0 (2.1.7-dev) Bump MODULE_MAGIC_COOKIE to "AP21"! * 20050701.1 (2.1.7-dev) trace_enable member added to core server_config * 20050708.0 (2.1.7-dev) Bump MODULE_MAGIC_COOKIE to "AP22"! * 20050708.1 (2.1.7-dev) add proxy request_status hook (minor) * 20050919.0 (2.1.8-dev) mod_ssl ssl_ext_list optional function added * 20051005.0 (2.1.8-dev) NET_TIME filter eliminated * 20051005.0 (2.3.0-dev) Bump MODULE_MAGIC_COOKIE to "AP24"! * 20051115.0 (2.3.0-dev) Added use_canonical_phys_port to core_dir_config * 20060110.0 (2.3.0-dev) Conversion of Authz to be provider based * addition of <SatisfyAll><SatisfyOne> * removal of Satisfy, Allow, Deny, Order * 20060110.1 (2.3.0-dev) minex and minex_set members added to * cache_server_conf (minor) * 20060110.2 (2.3.0-dev) flush_packets and flush_wait members added to * proxy_server (minor) * 20060110.3 (2.3.0-dev) added inreslist member to proxy_conn_rec (minor) * 20060110.4 (2.3.0-dev) Added server_scheme member to server_rec (minor) * 20060905.0 (2.3.0-dev) Replaced ap_get_server_version() with * ap_get_server_banner() and ap_get_server_description() * 20060905.1 (2.3.0-dev) Enable retry=0 for the worker (minor) * 20060905.2 (2.3.0-dev) Added ap_all_available_mutexes_string, * ap_available_mutexes_string and * ap_parse_mutex() * 20060905.3 (2.3.0-dev) Added conn_rec::clogging_input_filters. * 20060905.4 (2.3.0-dev) Added proxy_balancer::sticky_path. * 20060905.5 (2.3.0-dev) Added ap_mpm_safe_kill() * 20070823.0 (2.3.0-dev) Removed ap_all_available_mutexes_string, * ap_available_mutexes_string for macros * 20070823.1 (2.3.0-dev) add ap_send_interim_response() * 20071023.0 (2.3.0-dev) add ap_get_scoreboard(sbh) split from the less * conventional ap_get_scoreboard(proc, thread) * 20071023.1 (2.3.0-dev) Add flags field to struct proxy_alias * 20071023.2 (2.3.0-dev) Add ap_mod_status_reqtail * 20071023.3 (2.3.0-dev) Declare ap_time_process_request() as part of the * public scoreboard API. * 20071108.1 (2.3.0-dev) Add the optional kept_body brigade to request_rec * 20071108.2 (2.3.0-dev) Add st and keep fields to struct util_ldap_connection_t * 20071108.3 (2.3.0-dev) Add API guarantee for adding connection filters * with non-NULL request_rec pointer (ap_add_*_filter*) * 20071108.4 (2.3.0-dev) Add ap_proxy_ssl_connection_cleanup * 20071108.5 (2.3.0-dev) Add *scpool to proxy_conn_rec structure * 20071108.6 (2.3.0-dev) Add *r and need_flush to proxy_conn_rec structure * 20071108.7 (2.3.0-dev) Add *ftp_directory_charset to proxy_dir_conf * 20071108.8 (2.3.0-dev) Add optional function ap_logio_add_bytes_in() to mog_logio * 20071108.9 (2.3.0-dev) Add chroot support to unixd_config * 20071108.10(2.3.0-dev) Introduce new ap_expr API * 20071108.11(2.3.0-dev) Revise/Expand new ap_expr API * 20071108.12(2.3.0-dev) Remove ap_expr_clone from the API (same day it was added) * 20080403.0 (2.3.0-dev) Add condition field to core dir config * 20080403.1 (2.3.0-dev) Add authn/z hook and provider registration wrappers. * 20080403.2 (2.3.0-dev) Add ap_escape_path_segment_buffer() and ap_unescape_all(). * 20080407.0 (2.3.0-dev) Remove ap_graceful_stop_signalled. * 20080407.1 Deprecate ap_cache_cacheable_hdrs_out and add two * generalized ap_cache_cacheable_headers_(in|out). * 20080528.0 (2.3.0-dev) Switch order of ftp_directory_charset and * interpolate_env in proxy_dir_conf. * Rationale: see r661069. * 20080528.1 (2.3.0-dev) add has_realm_hash() to authn_provider struct * 20080722.0 (2.3.0-dev) remove has_realm_hash() from authn_provider struct * 20080722.1 (2.3.0-dev) Add conn_timeout and conn_timeout_set to * proxy_worker struct. * 20080722.2 (2.3.0-dev) Add scolonsep to proxy_balancer * 20080829.0 (2.3.0-dev) Add cookie attributes when removing cookies * 20080830.0 (2.3.0-dev) Cookies can be set on headers_out and err_headers_out * 20080920.0 (2.3.0-dev) Add ap_mpm_register_timed_callback. * 20080920.1 (2.3.0-dev) Export mod_rewrite.h in the public API. * 20080920.2 (2.3.0-dev) Added ap_timeout_parameter_parse to util.c / httpd.h * 20081101.0 (2.3.0-dev) Remove unused AUTHZ_GROUP_NOTE define. * 20081102.0 (2.3.0-dev) Remove authz_provider_list, authz_request_state, * and AUTHZ_ACCESS_PASSED_NOTE. * 20081104.0 (2.3.0-dev) Remove r and need_flush fields from proxy_conn_rec * as they are no longer used and add * ap_proxy_buckets_lifetime_transform to mod_proxy.h * 20081129.0 (2.3.0-dev) Move AP_FILTER_ERROR and AP_NOBODY_READ|WROTE * from util_filter.h to httpd.h and change their * numeric values so they do not overlap with other * potential status codes * 20081201.0 (2.3.0-dev) Rename several APIs to include ap_ prefix. * 20081201.1 (2.3.0-dev) Added ap_args_to_table and ap_body_to_table. * 20081212.0 (2.3.0-dev) Remove sb_type from process_score in scoreboard.h. * 20081231.0 (2.3.0-dev) Switch ap_escape_html API: add ap_escape_html2, * and make ap_escape_html a macro for it. * 20090130.0 (2.3.2-dev) Add ap_ prefix to unixd_setup_child(). * 20090131.0 (2.3.2-dev) Remove ap_default_type(), disable DefaultType * 20090208.0 (2.3.2-dev) Add conn_rec::current_thread. * 20090208.1 (2.3.3-dev) Add ap_retained_data_create()/ap_retained_data_get() * 20090401.0 (2.3.3-dev) Remove ap_threads_per_child, ap_max_daemons_limit, * ap_my_generation, etc. ap_mpm_query() can't be called * until after the register-hooks phase. * 20090401.1 (2.3.3-dev) Protected log.c internals, http_log.h changes * 20090401.2 (2.3.3-dev) Added tmp_flush_bb to core_output_filter_ctx_t * 20090401.3 (2.3.3-dev) Added DAV options provider to mod_dav.h * 20090925.0 (2.3.3-dev) Added server_rec::context and added *server_rec * param to ap_wait_or_timeout() * 20090925.1 (2.3.3-dev) Add optional function ap_logio_get_last_bytes() to * mod_logio * 20091011.0 (2.3.3-dev) Move preserve_host{,_set} from proxy_server_conf to * proxy_dir_conf * 20091011.1 (2.3.3-dev) add debug_level to util_ldap_state_t * 20091031.0 (2.3.3-dev) remove public LDAP referral-related macros * 20091119.0 (2.3.4-dev) dav_error interface uses apr_status_t parm, not errno * 20091119.1 (2.3.4-dev) ap_mutex_register(), ap_{proc,global}_mutex_create() * 20091229.0 (2.3.5-dev) Move allowed_connect_ports from proxy_server_conf * to mod_proxy_connect * 20091230.0 (2.3.5-dev) Move ftp_directory_charset from proxy_dir_conf * to proxy_ftp_dir_conf(mod_proxy_ftp) * 20091230.1 (2.3.5-dev) add util_ldap_state_t.opTimeout * 20091230.2 (2.3.5-dev) add ap_get_server_name_for_url() * 20091230.3 (2.3.6-dev) add ap_parse_log_level() * 20091230.4 (2.3.6-dev) export ap_process_request_after_handler() for mod_serf * 20100208.0 (2.3.6-dev) ap_socache_provider_t API changes to store and iterate * 20100208.1 (2.3.6-dev) Added forward member to proxy_conn_rec * 20100208.2 (2.3.6-dev) Added ap_log_command_line(). * 20100223.0 (2.3.6-dev) LDAP client_certs per-server moved to per-dir * 20100223.1 (2.3.6-dev) Added ap_process_fnmatch_configs(). * 20100504.0 (2.3.6-dev) Added name arg to ap_{proc,global}_mutex_create(). * 20100604.0 (2.3.6-dev) Remove unused core_dir_config::loglevel * 20100606.0 (2.3.6-dev) Make ap_log_*error macro wrappers around * ap_log_*error_ to save argument preparation and * function call overhead. * Introduce per-module loglevels, including new APIs * APLOG_USE_MODULE() and AP_DECLARE_MODULE(). * 20100606.1 (2.3.6-dev) Added extended timestamp formatting via * ap_recent_ctime_ex(). * 20100609.0 (2.3.6-dev) Dropped ap_body_to_table due to missing constraints. * 20100609.1 (2.3.7-dev) Introduce ap_log_cserror() * 20100609.2 (2.3.7-dev) Add deferred write pool to core_output_filter_ctx * 20100625.0 (2.3.7-dev) Add 'userctx' to socache iterator callback prototype * 20100630.0 (2.3.7-dev) make module_levels vector of char instead of int * 20100701.0 (2.3.7-dev) re-order struct members to improve alignment * 20100701.1 (2.3.7-dev) add note_auth_failure hook * 20100701.2 (2.3.7-dev) add ap_proxy_*_wid() functions * 20100714.0 (2.3.7-dev) add access_checker_ex hook, add AUTHZ_DENIED_NO_USER * to authz_status, call authz providers twice to allow * authz without authenticated user * 20100719.0 (2.3.7-dev) Add symbol name parameter to ap_add_module and * ap_add_loaded_module. Add ap_find_module_short_name * 20100723.0 (2.3.7-dev) Remove ct_output_filters from core rec * 20100723.1 (2.3.7-dev) Added ap_proxy_hashfunc() and hash elements to * proxy worker structs * 20100723.2 (2.3.7-dev) Add ap_request_has_body() * 20100723.3 (2.3.8-dev) Add ap_check_mpm() * 20100905.0 (2.3.9-dev) Add log_id to conn and req recs. Add error log * format handlers. Support AP_CTIME_OPTION_COMPACT in * ap_recent_ctime_ex(). * 20100905.1 (2.3.9-dev) Add ap_cache_check_allowed() * 20100912.0 (2.3.9-dev) Add an additional "out" brigade parameter to the * mod_cache store_body() provider function. * 20100916.0 (2.3.9-dev) Add commit_entity() to the mod_cache provider * interface. * 20100918.0 (2.3.9-dev) Move the request_rec within mod_include to be * exposed within include_ctx_t. * 20100919.0 (2.3.9-dev) Authz providers: Add parsed_require_line parameter * to check_authorization() function. Add * parse_require_line() function. * 20100919.1 (2.3.9-dev) Introduce ap_rxplus util/API * 20100921.0 (2.3.9-dev) Add an apr_bucket_brigade to the create_entity * provider interface for mod_cache.h. * 20100922.0 (2.3.9-dev) Move cache_* functions from mod_cache.h to a * private header file. * 20100923.0 (2.3.9-dev) Remove MOD_CACHE_REQUEST_REC, remove deprecated * ap_cache_cacheable_hdrs_out, trim cache_object_t, * make ap_cache_accept_headers, ap_cache_accept_headers * ap_cache_try_lock, ap_cache_check_freshness, * cache_server_conf, cache_enable, cache_disable, * cache_request_rec and cache_provider_list private. * 20100923.1 (2.3.9-dev) Add cache_status hook. * 20100923.2 (2.3.9-dev) Add generate_log_id hook. * Make root parameter of ap_expr_eval() const. * 20100923.3 (2.3.9-dev) Add "last" member to ap_directive_t * 20101012.0 (2.3.9-dev) Add header to cache_status hook. * 20101016.0 (2.3.9-dev) Remove ap_cache_check_allowed(). * 20101017.0 (2.3.9-dev) Make ap_cache_control() public, add cache_control_t * to mod_disk_cache format. * 20101106.0 (2.3.9-dev) Replace the ap_expr parser derived from * mod_include's parser with one derived from * mod_ssl's parser. Clean up ap_expr's public * interface. * 20101106.1 (2.3.9-dev) Add ap_pool_cleanup_set_null() generic cleanup * 20101106.2 (2.3.9-dev) Add suexec_disabled_reason field to ap_unixd_config * 20101113.0 (2.3.9-dev) Add source address to mod_proxy.h * 20101113.1 (2.3.9-dev) Add ap_set_flag_slot_char() * 20101113.2 (2.3.9-dev) Add ap_expr_exec_re() * 20101204.0 (2.3.10-dev) Add _t to ap_expr's typedef names * 20101223.0 (2.3.11-dev) Remove cleaned from proxy_conn_rec. * 20101223.1 (2.3.11-dev) Rework mod_proxy, et.al. Remove proxy_worker_stat * and replace w/ proxy_worker_shared; remove worker * info from scoreboard and use slotmem; Allow * dynamic growth of balancer members; Remove * BalancerNonce in favor of 'nonce' parameter. * 20110117.0 (2.3.11-dev) Merge <If> sections in separate step (ap_if_walk). * Add core_dir_config->sec_if. Add ap_add_if_conf(). * Add pool argument to ap_add_file_conf(). * 20110117.1 (2.3.11-dev) Add ap_pstr2_alnum() and ap_str2_alnum() * 20110203.0 (2.3.11-dev) Raise DYNAMIC_MODULE_LIMIT to 256 * 20110203.1 (2.3.11-dev) Add ap_state_query() * 20110203.2 (2.3.11-dev) Add ap_run_pre_read_request() hook and * ap_parse_form_data() util * 20110312.0 (2.3.12-dev) remove uldap_connection_cleanup and add util_ldap_state_t.connectionPoolTTL, util_ldap_connection_t.freed, and util_ldap_connection_t.rebind_pool. * 20110312.1 (2.3.12-dev) Add core_dir_config.decode_encoded_slashes. * 20110328.0 (2.3.12-dev) change type and name of connectionPoolTTL in util_ldap_state_t connectionPoolTTL (connection_pool_ttl, int->apr_interval_t) * 20110329.0 (2.3.12-dev) Change single-bit signed fields to unsigned in * proxy and cache interfaces. * Change ap_configfile_t/ap_cfg_getline()/ * ap_cfg_getc() API, add ap_pcfg_strerror() * Axe mpm_note_child_killed hook, change * ap_reclaim_child_process and ap_recover_child_process * interfaces. * 20110329.1 (2.3.12-dev) Add ap_reserve_module_slots()/ap_reserve_module_slots_directive() * change AP_CORE_DECLARE to AP_DECLARE: ap_create_request_config() * change AP_DECLARE to AP_CORE_DECLARE: ap_register_log_hooks() * 20110329.2 (2.3.12-dev) Add child_status and end_generation hooks. * 20110329.3 (2.3.12-dev) Add format field to ap_errorlog_info. * 20110329.4 (2.3.13-dev) bgrowth and max_balancers to proxy_server_conf. * 20110329.5 (2.3.13-dev) Add ap_regexec_len() * 20110329.6 (2.3.13-dev) Add AP_EXPR_FLAGS_RESTRICTED, ap_expr_eval_ctx_t->data, * ap_expr_exec_ctx() * 20110604.0 (2.3.13-dev) Make ap_rputs() inline * 20110605.0 (2.3.13-dev) add core_dir_config->condition_ifelse, change return * type of ap_add_if_conf(). * Add members of core_request_config: document_root, * context_document_root, context_prefix. * Add ap_context_*(), ap_set_context_info(), ap_set_document_root() * 20110605.1 (2.3.13-dev) add ap_(get|set)_core_module_config() * 20110605.2 (2.3.13-dev) add ap_get_conn_socket() * 20110619.0 (2.3.13-dev) add async connection infos to process_score in scoreboard, * add ap_start_lingering_close(), * add conn_state_e:CONN_STATE_LINGER_NORMAL and CONN_STATE_LINGER_SHORT * 20110619.1 (2.3.13-dev) add ap_str_toupper() * 20110702.0 (2.3.14-dev) make ap_expr_parse_cmd() macro wrapper for new * ap_expr_parse_cmd_mi() function, add ap_expr_str_*() functions, * rename AP_EXPR_FLAGS_* -> AP_EXPR_FLAG_* * 20110702.1 (2.3.14-dev) Add ap_scan_script_header_err*_ex functions * 20110723.0 (2.3.14-dev) Revert addition of ap_ldap* * 20110724.0 (2.3.14-dev) Add override_list as parameter to ap_parse_htaccess * Add member override_list to cmd_parms_struct, * core_dir_config and htaccess_result * 20110724.1 (2.3.15-dev) add NOT_IN_HTACCESS * 20110724.2 (2.3.15-dev) retries and retry_delay in util_ldap_state_t * 20110724.3 (2.3.15-dev) add util_varbuf.h / ap_varbuf API * 20110724.4 (2.3.15-dev) add max_ranges to core_dir_config * 20110724.5 (2.3.15-dev) add ap_set_accept_ranges() * 20110724.6 (2.3.15-dev) add max_overlaps and max_reversals to core_dir_config * 20110724.7 (2.3.15-dev) add ap_random_insecure_bytes(), ap_random_pick() * 20110724.8 (2.3.15-dev) add ap_abort_on_oom(), ap_malloc(), ap_calloc(), * ap_realloc() * 20110724.9 (2.3.15-dev) add ap_varbuf_pdup() and ap_varbuf_regsub() * 20110724.10(2.3.15-dev) Export ap_max_mem_free * 20111009.0 (2.3.15-dev) Remove ap_proxy_removestr(), * add ap_unixd_config.group_name * 20111014.0 (2.3.15-dev) Remove cookie_path_str and cookie_domain_str from * proxy_dir_conf * 20111025.0 (2.3.15-dev) Add return value and maxlen to ap_varbuf_regsub(), * add ap_pregsub_ex() * 20111025.1 (2.3.15-dev) Add ap_escape_urlencoded(), ap_escape_urlencoded_buffer() * and ap_unescape_urlencoded(). * 20111025.2 (2.3.15-dev) Add ap_lua_ssl_val to mod_lua * 20111025.3 (2.4.0-dev) Add reclvl to ap_expr_eval_ctx_t * 20111122.0 (2.4.0-dev) Remove parts of conn_state_t that are private to the MPM * 20111123.0 (2.4.0-dev) Pass ap_errorlog_info struct to error_log hook, * add pool to ap_errorlog_info. * 20111130.0 (2.4.0-dev) c->remote_ip becomes c->peer_ip and r->client_ip, * c->remote_addr becomes c->peer_addr and r->client_addr * 20111201.0 (2.4.0-dev) Add invalidate_entity() to the cache provider. * 20111202.0 (2.4.0-dev) Use apr_status_t across mod_session API. * 20111202.1 (2.4.0-dev) add APLOGNO() * 20111203.0 (2.4.0-dev) Optional ap_proxy_retry_worker(), remove * ap_proxy_string_read(), ap_cache_liststr(), * ap_proxy_buckets_lifetime_transform(), * ap_proxy_date_canon(), ap_proxy_is_ipaddr(), * ap_proxy_is_domainname(), ap_proxy_is_hostname(), * ap_proxy_is_word(), ap_proxy_hex2sec(), * ap_proxy_sec2hex(), ap_proxy_make_fake_req(), * ap_proxy_strmatch_path, ap_proxy_strmatch_domain, * ap_proxy_table_unmerge(), proxy_lb_workers. * 20120109.0 (2.4.1-dev) Changes sizeof(overrides_t) in core config. * 20120109.1 (2.4.1-dev) remove sb_type in global_score. * 20120109.2 (2.4.1-dev) Make core_output_filter_ctx_t and core_ctx_t * private; * move core_net rec definition to http_core.h; * add insert_network_bucket hook, AP_DECLINED * 20120211.0 (2.4.1-dev) Change re_nsub in ap_regex_t from apr_size_t to int. * 20120211.1 (2.4.2-dev) Add AP_HAVE_C99 * 20120211.2 (2.4.2-dev) Add ap_runtime_dir_relative * 20120211.3 (2.4.2-dev) Add forcerecovery to proxy_balancer_shared struct * 20120211.4 (2.4.3-dev) Add ap_list_provider_groups() * 20120211.5 (2.4.3-dev) Add missing HTTP status codes registered with IANA. * 20120211.6 (2.4.3-dev) Add ap_proxy_checkproxyblock2. * 20120211.7 (2.4.3-dev) Add ap_get_loadavg() * 20120211.8 (2.4.3-dev) Add sticky_separator to proxy_balancer_shared struct. * 20120211.9 (2.4.4-dev) Add fgrab() to ap_slotmem_provider_t. * 20120211.10 (2.4.4-dev) Add in bal_persist field to proxy_server_conf * 20120211.11 (2.4.4-dev) Add ap_bin2hex() * 20120211.12 (2.4.5-dev) Add ap_remove_input|output_filter_byhandle() * 20120211.13 (2.4.5-dev) Add ap_get_exec_line * 20120211.14 (2.4.5-dev) Add ppinherit and inherit to proxy_server_conf * 20120211.15 (2.4.5-dev) Add dav_join_error() * 20120211.16 (2.4.5-dev) Add cache_control_t.invalidated * 20120211.17 (2.4.5-dev) Add ap_find_etag_weak(), ap_find_etag_strong() * 20120211.18 (2.4.5-dev) Add ap_condition_e, ap_condition_if_match(), * ap_condition_if_unmodified_since(), * ap_condition_if_none_match(), * ap_condition_if_modified_since(), * ap_condition_if_range() * 20120211.19 (2.4.5-dev) Add post_perdir_config hook. * 20120211.20 (2.4.5-dev) Add dirwalk_stat hook. * 20120211.21 (2.4.5-dev) Add in ap_proxy_create_hdrbrgd() and * ap_proxy_pass_brigade() * 20120211.22 (2.4.5-dev) No longer prevent usage of strtoul() * 20120211.23 (2.4.5-dev) Add ap_proxy_clear_connection() * 20120211.24 (2.4.7-dev) add open_htaccess hook. * 20120211.25 (2.4.7-dev) Add conn_sense_e * 20120211.26 (2.4.7-dev) Add util_fcgi.h, FastCGI protocol support * 20120211.27 (2.4.7-dev) Add ap_podx_restart_t and ap_mpm_podx_* * 20120211.28 (2.4.7-dev) Add ap_regname * 20120211.29 (2.4.7-dev) Add uds_path to proxy_conn_rec and proxy_worker_shared. * The change to proxy_worker_shared is an * unintended API break, especially for balancer * lbmethod modules. * 20120211.30 (2.4.7-dev) REWRITE_REDIRECT_HANDLER_NAME in mod_rewrite.h * 20120211.31 (2.4.7-dev) Add ap_proxy_port_of_scheme() * 20120211.32 (2.4.10-dev) Add SSL reusable SNI to mod_proxy.h's proxy_conn_rec * 20120211.33 (2.4.10-dev) Add suspend_connection and resume_connection hooks * 20120211.34 (2.4.10-dev) AP_DEFAULT_HANDLER_NAME/AP_IS_DEFAULT_HANDLER_NAME * 20120211.35 (2.4.10-dev) Add "r", "must_rebind", and last_backend_conn to util_ldap_connection_t * 20120211.36 (2.4.10-dev) Add ap_copy_scoreboard_worker() * 20120211.37 (2.4.11-dev) Add r->trailers_{in,out} * 20120211.38 (2.4.11-dev) Added ap_shutdown_conn(). * 20120211.39 (2.4.11-dev) Add ap_proxy_connect_uds(). * 20120211.40 (2.4.11-dev) Add ap_log_data(), ap_log_rdata(), etc. * 20120211.41 (2.4.11-dev) Add ap_proxy_de_socketfy to mod_proxy.h * 20120211.42 (2.4.13-dev) Add response_code_exprs to http_core.h * 20120211.43 (2.4.13-dev) Add keep_alive_timeout_set to server_rec * 20120211.44 (2.4.13-dev) Add cgi_pass_auth and AP_CGI_PASS_AUTH_* to * core_dir_config * 20120211.45 (2.4.13-dev) Add ap_proxy_connection_reusable() * 20120211.46 (2.4.13-dev) Add ap_map_http_request_error() * 20120211.47 (2.4.13-dev) Add ap_some_authn_required, ap_force_authn hook. * Deprecate broken ap_some_auth_required. * 20120211.48 (2.4.17-dev) Added ap_log_mpm_common(). * 20120211.49 (2.4.17-dev) Add listener bucket in scoreboard.h's process_score. * 20120211.50 (2.4.17-dev) Add ap_set_listencbratio(), ap_close_listeners_ex(), * ap_duplicate_listeners(), ap_num_listen_buckets and * ap_have_so_reuseport to ap_listen.h. * 20120211.51 (2.4.17-dev) Add protocols and protocols_honor_order to * core_server_config. Add hooks protocol_propose * protocol_switch and protocol_get. Add * ap_select_protocol(), ap_switch_protocol(), * ap_get_protocol(). Add HTTP_MISDIRECTED_REQUEST. * Added ap_parse_token_list_strict() to httpd.h * 20120211.52 (2.4.17-dev) Add master conn_rec* member in conn_rec. * 20120211.53 (2.4.19-dev) Add expr_handler to core_dir_config. * 20120211.54 (2.4.19-dev) Add ap_proxy_buckets_lifetime_transform and * ap_proxy_transfer_between_connections to * mod_proxy.h * 20120211.55 (2.4.19-dev) Add new ap_update_child_status...() methods, * add protocol to worker_score in scoreboard.h, * Add pre_close connection hook and * ap_prep_lingering_close(). * 20120211.56 (2.4.19-dev) Split useragent_host from the conn_rec into * the request_rec, with ap_get_useragent_host() * 20120211.57 (2.4.19-dev) Add mod_ssl_openssl.h and OpenSSL-specific hooks * 20120211.58 (2.4.21-dev) Add cgi_var_rules to core_dir_config. * 20120211.59 (2.4.21-dev) Add ap_getword_conf2[_nc](), * ap_proxy_is_socket_connected() and * extended proxy_worker_shared. * 20120211.60 (2.4.21-dev) Add dav_get_provider_name. * 20120211.61 (2.4.21-dev) Add ap_cstr_casecmp[n]() - placeholder of apr_ fns * 20120211.62 (2.4.24-dev) Add childtags to dav_error. * 20120211.63 (2.4.24-dev) Add dav_begin_multistatus, dav_send_one_response, * dav_finish_multistatus, dav_send_multistatus, * dav_handle_err, dav_failed_proppatch, * dav_success_proppatch. * 20120211.64 (2.4.24-dev) Add ap_proxy_check_backend(), and tmp_bb to struct * proxy_conn_rec. * 20120211.65 (2.4.24-dev) Add ap_check_pipeline(). * 20120211.66 (2.4.24-dev) Rename ap_proxy_check_backend() to * ap_proxy_check_connection(). * 20120211.67 (2.4.24-dev) Add http09_enable, http_conformance, and * http_methods to core_server_config * Add ap_scan_http_field_token(), * ap_scan_http_field_content(), * and ap_scan_vchar_obstext() * Replaced fold boolean with with multiple bit flags * to ap_[r]getline() * 20120211.68 (2.4.26-dev) Add ap_get_basic_auth_components() and deprecate * ap_get_basic_auth_pw() * 20120211.69 (2.4.30-dev) Add ap_update_sb_handle() * 20120211.70 (2.4.30-dev) Add flags field to module_struct and function * ap_get_module_flags() * 20120211.71 (2.4.30-dev) Add optional proxy_{hook,run}_section_post_config(), * ap_proxy_connection_create_ex() and section_config * to struct proxy_{worker,balancer} in mod_proxy.h, * and optional ssl_engine_set() to mod_ssl.h. * 20120211.72 (2.4.30-dev) Add NOT_IN_DIR_CONTEXT replacing NOT_IN_DIR_LOC_FILE * semantics * 20120211.73 (2.4.30-dev) Add failontimeout_set, growth_set and lbmethod_set * to proxy_balancer struct * 20120211.74 (2.4.30-dev) Add AP_REG_DOLLAR_ENDONLY, ap_regcomp_get_default_cflags * ap_regcomp_set_default_cflags and * ap_regcomp_default_cflag_by_name * 20120211.75 (2.4.30-dev) Add hostname_ex to proxy_worker_shared * 20120211.76 (2.4.30-dev) Add CONN_STATE_NUM to enum conn_state_e * 20120211.77 (2.4.34-dev) Add ap_exists_directive() * 20120211.78 (2.4.34-dev) Add response_field_size to proxy_worker_shared * 20120211.79 (2.4.34-dev) Add AP_GETLINE_NOSPC_EOL flag to http_protocol.h * 20120211.80 (2.4.35-dev) Add new ap_update_global_status() method and * times field in the global_score structure in * scoreboard.h. * 20120211.81 (2.4.35-dev) Add new duration field to worker_score struct in * scoreboard.h * 20120211.82 (2.4.35-dev) Add optional function declaration for * ap_proxy_balancer_get_best_worker to mod_proxy.h. * 20120211.83 (2.4.35-dev) Add client64 field to worker_score struct * 20120211.84 (2.4.35-dev) Add ap_no2slash_ex() and merge_slashes to * core_server_conf. * 20120211.85 (2.4.40-dev) add ap_set_conn_count(). * 20120211.86 (2.4.40-dev) Add forward_100_continue{,_set} to proxy_dir_conf * 20120211.87 (2.4.40-dev) Add dav_popen_propdb * 20120211.88 (2.4.40-dev) Add ap_dir_nofnmatch() and ap_dir_fnmatch(). * 20120211.89 (2.4.42-dev) Add add dns_pool to proxy_conn_pool and define * AP_VOLATILIZE_T. * 20120211.90 (2.4.42-dev) AP_REG_DEFAULT macro in ap_regex.h * 20120211.91 (2.4.42-dev) Add ap_is_chunked() in httpd.h * 20120211.92 (2.4.42-dev) AP_REG_NO_DEFAULT macro in ap_regex.h * 20120211.93 (2.4.44-dev) Add ap_parse_strict_length() * 20120211.94 (2.4.47-dev) Add ap_proxy_define_match_worker() * 20120211.95 (2.4.47-dev) Add proxy check_trans hook * 20120211.96 (2.4.47-dev) Add ap_get_status_line_ex() * 20120211.97 (2.4.47-dev) Add read_buf_size member to core_dir_config, * flush_max_threshold and flush_max_pipelined to * core_server_config, and ap_get_read_buf_size(). * 20120211.98 (2.4.47-dev) Add ap_proxy_should_override to mod_proxy.h * 20120211.99 (2.4.47-dev) Add proxy_tunnel_rec, ap_proxy_tunnel_create() * and ap_proxy_tunnel_run() to proxy_util. * 20120211.99 (2.4.47-dev) Add ap_proxy_worker_can_upgrade() * 20120211.100 (2.4.47-dev) Add ap_proxy_prefetch_input(), * ap_proxy_spool_input() and * ap_proxy_read_input(). * 20120211.101 (2.4.47-dev) ETAG_DIGEST in http_core.h. struct etag_rec, * ap_make_etag_ex() and ap_set_etag_fd() in * http_protocol.h. ap_request_bnotes_t, * AP_REQUEST_STRONG_ETAG, AP_REQUEST_GET_BNOTE, * AP_REQUEST_SET_BNOTE and AP_REQUEST_IS_STRONG_ETAG * in httpd.h. * 20120211.102 (2.4.47-dev) Add ap_ssl_conn_is_ssl()/ap_ssl_var_lookup() and hooks * 20120211.103 (2.4.47-dev) Add ap_ssl_add_cert_files, ap_ssl_add_fallback_cert_files * and ap_ssl_answer_challenge and hooks. * 20120211.104 (2.4.47-dev) Move ap_ssl_* into new http_ssl.h header file * 20120211.105 (2.4.47-dev) Add ap_ssl_ocsp* hooks and functions to http_ssl.h. * 20120211.106 (2.4.49-dev) Add ap_create_request(). * 20120211.107 (2.4.49-dev) Add ap_parse_request_line() and * ap_check_request_header() * 20120211.108 (2.4.49-dev) Add ajp_handle_cping_cpong * 20120211.109 (2.4.49-dev) Add ap_normalize_path(), * pre_translate_name hook and * Add map_encoded_one and map_encoded_all bits to * proxy_server_conf. * 20120211.110 (2.4.49-dev) Add hook child_stopping to get informed that a child * is being shut down. * 20120211.111 (2.4.49-dev) Add dav_get_provider(), dav_open_lockdb(), * dav_close_lockdb() and dav_get_resource() to * mod_dav.h. * 20120211.112 (2.4.49-dev) Add deliver_report and gather_reports hooks. * 20120211.113 (2.4.49-dev) Add method_precondition hook. * 20120211.114 (2.4.49-dev) Add optional balancer_manage function. * 20120211.115 (2.4.49-dev) Add ap_proxy_get_worker_ex() and * ap_proxy_define_worker_ex() to mod_proxy.h * 20120211.116 (2.4.49-dev) add conn_rec->outgoing and ap_ssl_bind_outgoing() * 20120211.117 (2.4.50-dev) Add ap_pre_connection * 20120211.118 (2.4.51-dev) Add ap_unescape_url_ex() and deprecate * AP_NORMALIZE_DROP_PARAMETERS * 20120211.119 (2.4.51-dev) Add dav_validate_root_ns(), dav_find_child_ns(), * dav_find_next_ns(), dav_find_attr_ns() and * dav_find_attr(). * 20120211.120 (2.4.51-dev) Add dav_liveprop_elem structure and * dav_get_liveprop_element(). * 20120211.121 (2.4.51-dev) Add ap_post_read_request() * 20120211.122 (2.4.51-dev) Add ap_thread_create(), ap_thread_main_create() * and ap_thread_current() * 20120211.123 (2.4.51-dev) Added ap_pcre_version_string(), AP_REG_PCRE_COMPILED * and AP_REG_PCRE_LOADED to ap_regex.h. * 20120211.124 (2.4.51-dev) Add name_ex to struct proxy_worker_shared * 20120211.125 (2.4.55-dev) Export mod_http2.h as public header * 20120211.126 (2.4.55-dev) Add additional hcmethod_t enums and PROXY_WORKER_IS_ERROR * 20120211.127 (2.4.56-dev) Add ap_proxy_canonenc_ex * 20120211.128 (2.4.55-dev) Add AP_CTIME_OPTION_GMTOFF to util_time.h * 20120211.129 (2.4.58-dev) Add ap_get_pollfd_from_conn() * 20120211.130 (2.4.59-dev) Add ap_proxy_determine_address() * 20120211.131 (2.4.59-dev) Add DAV_WALKTYPE_TOLERANT * 20120211.132 (2.4.60-dev) Add ap_set_content_type_ex(), ap_filepath_merge(), * and AP_REQUEST_TRUSTED_CT BNOTE. * 20120211.133 (2.4.60-dev) Add ap_proxy_fixup_uds_filename() * 20120211.134 (2.4.60-dev) AP_SLASHES and AP_IS_SLASH * 20120211.135 (2.4.63-dev) Add CONN_STATE_ASYNC_WAITIO, CONN_STATE_KEEPALIVE * and CONN_STATE_PROCESSING * 20120211.136 (2.4.63-dev) Add wait_io field to struct process_score * 20120211.137 (2.4.63-dev) Add AP_MPMQ_CAN_WAITIO * 20120211.138 (2.4.63-dev) Add is_host_matchable to proxy_worker_shared * 20120211.139 (2.4.63-dev) Add dav_get_base_path() to mod_dav * 20120211.140 (2.4.64-dev) Add ap_set_time_process_request() to scoreboard.h * 20120211.141 (2.4.64-dev) add ap_stat_check() to httpd.h * 20120211.142 (2.4.64-dev) Add ap_*_timingsafe() to httpd.h */ #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20120211 #endif #define MODULE_MAGIC_NUMBER_MINOR 142 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a * specified value. * * Useful for testing for features. * For example, suppose you wish to use the apr_table_overlap * function. You can do this: * * \code * #if AP_MODULE_MAGIC_AT_LEAST(19980812,2) * ... use apr_table_overlap() * #else * ... alternative code which doesn't use apr_table_overlap() * #endif * \endcode * * @param major The major module magic number * @param minor The minor module magic number * @def AP_MODULE_MAGIC_AT_LEAST(int major, int minor) */ #define AP_MODULE_MAGIC_AT_LEAST(major,minor) \ ((major) < MODULE_MAGIC_NUMBER_MAJOR \ || ((major) == MODULE_MAGIC_NUMBER_MAJOR \ && (minor) <= MODULE_MAGIC_NUMBER_MINOR)) /** @deprecated present for backwards compatibility */ #define MODULE_MAGIC_NUMBER MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_AT_LEAST old_broken_macro_we_hope_you_are_not_using #endif /* !APACHE_AP_MMN_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file ap_release.h * @brief Version Release defines */ #ifndef AP_RELEASE_H #define AP_RELEASE_H #define AP_SERVER_COPYRIGHT \ "Copyright 2026 The Apache Software Foundation." /* * The below defines the base string of the Server: header. Additional * tokens can be added via the ap_add_version_component() API call. * * The tokens are listed in order of their significance for identifying the * application. * * "Product tokens should be short and to the point -- use of them for * advertizing or other non-essential information is explicitly forbidden." * * Example: "Apache/1.1.0 MrWidget/0.1-alpha" */ #define AP_SERVER_BASEVENDOR "Apache Software Foundation" #define AP_SERVER_BASEPROJECT "Apache HTTP Server" #define AP_SERVER_BASEPRODUCT "Apache" #define AP_SERVER_MAJORVERSION_NUMBER 2 #define AP_SERVER_MINORVERSION_NUMBER 4 #define AP_SERVER_PATCHLEVEL_NUMBER 71 #define AP_SERVER_DEVBUILD_BOOLEAN 0 /* Synchronize the above with docs/manual/style/version.ent */ #if !AP_SERVER_DEVBUILD_BOOLEAN #define AP_SERVER_ADD_STRING "" #else #ifndef AP_SERVER_ADD_STRING #define AP_SERVER_ADD_STRING "-dev" #endif #endif /* APR_STRINGIFY is defined here, and also in apr_general.h, so wrap it */ #ifndef APR_STRINGIFY /** Properly quote a value as a string in the C preprocessor */ #define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n) /** Helper macro for APR_STRINGIFY */ #define APR_STRINGIFY_HELPER(n) #n #endif /* keep old macros as well */ #define AP_SERVER_MAJORVERSION APR_STRINGIFY(AP_SERVER_MAJORVERSION_NUMBER) #define AP_SERVER_MINORVERSION APR_STRINGIFY(AP_SERVER_MINORVERSION_NUMBER) #define AP_SERVER_PATCHLEVEL APR_STRINGIFY(AP_SERVER_PATCHLEVEL_NUMBER) \ AP_SERVER_ADD_STRING #define AP_SERVER_MINORREVISION AP_SERVER_MAJORVERSION "." AP_SERVER_MINORVERSION #define AP_SERVER_BASEREVISION AP_SERVER_MINORREVISION "." AP_SERVER_PATCHLEVEL #define AP_SERVER_BASEVERSION AP_SERVER_BASEPRODUCT "/" AP_SERVER_BASEREVISION #define AP_SERVER_VERSION AP_SERVER_BASEVERSION /* macro for Win32 .rc files using numeric csv representation */ #define AP_SERVER_PATCHLEVEL_CSV AP_SERVER_MAJORVERSION_NUMBER, \ AP_SERVER_MINORVERSION_NUMBER, \ AP_SERVER_PATCHLEVEL_NUMBER #endif /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_auth.h * @brief Authentication and Authorization Extension for Apache * * @defgroup MOD_AUTH mod_auth * @ingroup APACHE_MODS */ #ifndef APACHE_MOD_AUTH_H #define APACHE_MOD_AUTH_H #include "apr_pools.h" #include "apr_hash.h" #include "apr_optional.h" #include "httpd.h" #include "http_config.h" #ifdef __cplusplus extern "C" { #endif #define AUTHN_PROVIDER_GROUP "authn" #define AUTHZ_PROVIDER_GROUP "authz" #define AUTHN_PROVIDER_VERSION "0" #define AUTHZ_PROVIDER_VERSION "0" #define AUTHN_DEFAULT_PROVIDER "file" #define AUTHN_PROVIDER_NAME_NOTE "authn_provider_name" #define AUTHZ_PROVIDER_NAME_NOTE "authz_provider_name" #define AUTHN_PREFIX "AUTHENTICATE_" #define AUTHZ_PREFIX "AUTHORIZE_" /** all of the requirements must be met */ #ifndef SATISFY_ALL #define SATISFY_ALL 0 #endif /** any of the requirements must be met */ #ifndef SATISFY_ANY #define SATISFY_ANY 1 #endif /** There are no applicable satisfy lines */ #ifndef SATISFY_NOSPEC #define SATISFY_NOSPEC 2 #endif typedef enum { AUTH_DENIED, AUTH_GRANTED, AUTH_USER_FOUND, AUTH_USER_NOT_FOUND, AUTH_GENERAL_ERROR } authn_status; typedef enum { AUTHZ_DENIED, AUTHZ_GRANTED, AUTHZ_NEUTRAL, AUTHZ_GENERAL_ERROR, AUTHZ_DENIED_NO_USER /* denied because r->user == NULL */ } authz_status; typedef struct { /* Given a username and password, expected to return AUTH_GRANTED * if we can validate this user/password combination. */ authn_status (*check_password)(request_rec *r, const char *user, const char *password); /* Given a user and realm, expected to return AUTH_USER_FOUND if we * can find a md5 hash of 'user:realm:password' */ authn_status (*get_realm_hash)(request_rec *r, const char *user, const char *realm, char **rethash); } authn_provider; /* A linked-list of authn providers. */ typedef struct authn_provider_list authn_provider_list; struct authn_provider_list { const char *provider_name; const authn_provider *provider; authn_provider_list *next; }; typedef struct { /* Given a request_rec, expected to return AUTHZ_GRANTED * if we can authorize user access. * @param r the request record * @param require_line the argument to the authz provider * @param parsed_require_line the value set by parse_require_line(), if any */ authz_status (*check_authorization)(request_rec *r, const char *require_line, const void *parsed_require_line); /** Check the syntax of a require line and optionally cache the parsed * line. This function may be NULL. * @param cmd the config directive * @param require_line the argument to the authz provider * @param parsed_require_line place to store parsed require_line for use by provider * @return Error message or NULL on success */ const char *(*parse_require_line)(cmd_parms *cmd, const char *require_line, const void **parsed_require_line); } authz_provider; /* ap_authn_cache_store: Optional function for authn providers * to enable caching their lookups with mod_authn_cache * @param r The request rec * @param module Module identifier * @param user User name to authenticate * @param realm Digest authn realm (NULL for basic authn) * @param data The value looked up by the authn provider, to cache */ APR_DECLARE_OPTIONAL_FN(void, ap_authn_cache_store, (request_rec*, const char*, const char*, const char*, const char*)); #ifdef __cplusplus } #endif #endif /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file ap_compat.h * @brief Redefine Apache 1.3 symbols */ #ifndef AP_COMPAT_H #define AP_COMPAT_H /* redefine 1.3.x symbols to the new symbol names */ #define MODULE_VAR_EXPORT AP_MODULE_DECLARE_DATA #define ap_send_http_header(r) ; #endif /* AP_COMPAT_H */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_fcgi.h * @brief FastCGI protocol definitions and support routines * * @defgroup APACHE_CORE_FASTCGI FastCGI Tools * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_UTIL_FCGI_H #define APACHE_UTIL_FCGI_H #ifdef __cplusplus extern "C" { #endif #include "httpd.h" /** * @brief A structure that represents the fixed header fields * at the beginning of a "FastCGI record" (i.e., the data prior * to content data and padding). */ typedef struct { /** See values for version, below */ unsigned char version; /** See values for type, below */ unsigned char type; /** request id, in two parts */ unsigned char requestIdB1; unsigned char requestIdB0; /** content length, in two parts */ unsigned char contentLengthB1; unsigned char contentLengthB0; /** padding length */ unsigned char paddingLength; /** 8-bit reserved field */ unsigned char reserved; } ap_fcgi_header; /* * Number of bytes in the header portion of a FastCGI record * (i.e., ap_fcgi_header structure). Future versions of the * protocol may increase the size. */ #define AP_FCGI_HEADER_LEN 8 /* * Maximum number of bytes in the content portion of a FastCGI record. */ #define AP_FCGI_MAX_CONTENT_LEN 65535 /** * Possible values for the version field of ap_fcgi_header */ #define AP_FCGI_VERSION_1 1 /** * Possible values for the type field of ap_fcgi_header */ #define AP_FCGI_BEGIN_REQUEST 1 #define AP_FCGI_ABORT_REQUEST 2 #define AP_FCGI_END_REQUEST 3 #define AP_FCGI_PARAMS 4 #define AP_FCGI_STDIN 5 #define AP_FCGI_STDOUT 6 #define AP_FCGI_STDERR 7 #define AP_FCGI_DATA 8 #define AP_FCGI_GET_VALUES 9 #define AP_FCGI_GET_VALUES_RESULT 10 #define AP_FCGI_UNKNOWN_TYPE 11 #define AP_FCGI_MAXTYPE (AP_FCGI_UNKNOWN_TYPE) /** * Offsets of the various fields of ap_fcgi_header */ #define AP_FCGI_HDR_VERSION_OFFSET 0 #define AP_FCGI_HDR_TYPE_OFFSET 1 #define AP_FCGI_HDR_REQUEST_ID_B1_OFFSET 2 #define AP_FCGI_HDR_REQUEST_ID_B0_OFFSET 3 #define AP_FCGI_HDR_CONTENT_LEN_B1_OFFSET 4 #define AP_FCGI_HDR_CONTENT_LEN_B0_OFFSET 5 #define AP_FCGI_HDR_PADDING_LEN_OFFSET 6 #define AP_FCGI_HDR_RESERVED_OFFSET 7 /** * @brief This represents the content data of the FastCGI record when * the type is AP_FCGI_BEGIN_REQUEST. */ typedef struct { /** * role, in two parts * See values for role, below */ unsigned char roleB1; unsigned char roleB0; /** * flags * See values for flags bits, below */ unsigned char flags; /** reserved */ unsigned char reserved[5]; } ap_fcgi_begin_request_body; /* * Values for role component of ap_fcgi_begin_request_body */ #define AP_FCGI_RESPONDER 1 #define AP_FCGI_AUTHORIZER 2 #define AP_FCGI_FILTER 3 /* * Values for flags bits of ap_fcgi_begin_request_body */ #define AP_FCGI_KEEP_CONN 1 /* otherwise the application closes */ /** * Offsets of the various fields of ap_fcgi_begin_request_body */ #define AP_FCGI_BRB_ROLEB1_OFFSET 0 #define AP_FCGI_BRB_ROLEB0_OFFSET 1 #define AP_FCGI_BRB_FLAGS_OFFSET 2 #define AP_FCGI_BRB_RESERVED0_OFFSET 3 #define AP_FCGI_BRB_RESERVED1_OFFSET 4 #define AP_FCGI_BRB_RESERVED2_OFFSET 5 #define AP_FCGI_BRB_RESERVED3_OFFSET 6 #define AP_FCGI_BRB_RESERVED4_OFFSET 7 /** * Pack ap_fcgi_header * @param h The header to read from * @param a The array to write to, of size AP_FCGI_HEADER_LEN */ AP_DECLARE(void) ap_fcgi_header_to_array(ap_fcgi_header *h, unsigned char a[]); /** * Unpack header of FastCGI record into ap_fcgi_header * @param h The header to write to * @param a The array to read from, of size AP_FCGI_HEADER_LEN */ AP_DECLARE(void) ap_fcgi_header_from_array(ap_fcgi_header *h, unsigned char a[]); /** * Unpack header of FastCGI record into individual fields * @param version The version, on output * @param type The type, on output * @param request_id The request id, on output * @param content_len The content length, on output * @param padding_len The amount of padding following the content, on output * @param a The array to read from, of size AP_FCGI_HEADER_LEN */ AP_DECLARE(void) ap_fcgi_header_fields_from_array(unsigned char *version, unsigned char *type, apr_uint16_t *request_id, apr_uint16_t *content_len, unsigned char *padding_len, unsigned char a[]); /** * Pack ap_fcgi_begin_request_body * @param h The begin-request body to read from * @param a The array to write to, of size AP_FCGI_HEADER_LEN */ AP_DECLARE(void) ap_fcgi_begin_request_body_to_array(ap_fcgi_begin_request_body *h, unsigned char a[]); /** * Fill in a FastCGI request header with the required field values. * @param header The header to fill in * @param type The type of record * @param request_id The request id * @param content_len The amount of content which follows the header * @param padding_len The amount of padding which follows the content * * The header array must be at least AP_FCGI_HEADER_LEN bytes long. */ AP_DECLARE(void) ap_fcgi_fill_in_header(ap_fcgi_header *header, unsigned char type, apr_uint16_t request_id, apr_uint16_t content_len, unsigned char padding_len); /** * Fill in a FastCGI begin request body with the required field values. * @param brb The begin-request-body to fill in * @param role AP_FCGI_RESPONDER or other roles * @param flags 0 or a combination of flags like AP_FCGI_KEEP_CONN */ AP_DECLARE(void) ap_fcgi_fill_in_request_body(ap_fcgi_begin_request_body *brb, int role, unsigned char flags); /** * Compute the buffer size needed to encode the next portion of * the provided environment table. * @param env The environment table * @param maxlen The maximum buffer size allowable, capped at * AP_FCGI_MAX_CONTENT_LEN. * @param starting_elem On input, the next element of the table array * to process in this FastCGI record. On output, the next element to * process on the *next* FastCGI record. * @return Size of buffer needed to encode the next part, or 0 * if no more can be encoded. When 0 is returned: If starting_elem * has reached the end of the table array, all has been encoded; * otherwise, the next envvar can't be encoded within the specified * limit. * @note If an envvar can't be encoded within the specified limit, * the caller can log a warning and increment starting_elem and try * again or increase the limit or fail, as appropriate for the module. */ AP_DECLARE(apr_size_t) ap_fcgi_encoded_env_len(apr_table_t *env, apr_size_t maxlen, int *starting_elem); /** * Encode the next portion of the provided environment table using * a buffer previously allocated. * @param r The request, for logging * @param env The environment table * @param buffer A buffer to contain the encoded environment table * @param buflen The length of the buffer, previously computed by * ap_fcgi_encoded_env_len(). * @param starting_elem On input, the next element of the table array * to process in this FastCGI record. On output, the next element to * process on the *next* FastCGI record. * @return APR_SUCCESS if a section could be encoded or APR_ENOSPC * otherwise. * @note The output starting_elem from ap_fcgi_encoded_env_len * shouldn't be used as input to ap_fcgi_encode_env when building the * same FastCGI record. */ AP_DECLARE(apr_status_t) ap_fcgi_encode_env(request_rec *r, apr_table_t *env, void *buffer, apr_size_t buflen, int *starting_elem); /** * String forms for the value of the FCGI_ROLE envvar */ #define AP_FCGI_RESPONDER_STR "RESPONDER" #define AP_FCGI_AUTHORIZER_STR "AUTHORIZER" #define AP_FCGI_FILTER_STR "FILTER" /** * FastCGI implementations that implement the AUTHORIZER role * for Apache httpd and allow the application to participate in * any of the Apache httpd AAA phases typically set the variable * FCGI_APACHE_ROLE to one of these strings to indicate the * specific AAA phase. */ #define AP_FCGI_APACHE_ROLE_AUTHENTICATOR_STR "AUTHENTICATOR" #define AP_FCGI_APACHE_ROLE_AUTHORIZER_STR "AUTHORIZER" #define AP_FCGI_APACHE_ROLE_ACCESS_CHECKER_STR "ACCESS_CHECKER" #ifdef __cplusplus } #endif #endif /* !APACHE_UTIL_FCGI_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file util_charset.h * @brief charset conversion * * @defgroup APACHE_CORE_CHARSET Charset Conversion * @ingroup APACHE_CORE * * These are the translation handles used to translate between the network * format of protocol headers and the local machine format. * * For an EBCDIC machine, these are valid handles which are set up at * initialization to translate between ISO-8859-1 and the code page of * the source code.\n * For an ASCII machine, they are undefined. * * @see ap_init_ebcdic() * @{ */ #ifndef APACHE_UTIL_CHARSET_H #define APACHE_UTIL_CHARSET_H #ifdef __cplusplus extern "C" { #endif #include "apr.h" #if APR_CHARSET_EBCDIC || defined(DOXYGEN) #include "apr_xlate.h" /** * On EBCDIC machine this is a translation handle used to translate the * headers from the local machine format to ASCII for network transmission. * @note On ASCII system, this variable does <b>not</b> exist. * So, its use should be guarded by \#if APR_CHARSET_EBCDIC. */ extern apr_xlate_t *ap_hdrs_to_ascii; /** * On EBCDIC machine this is a translation handle used to translate the * headers from ASCII to the local machine format after network transmission. * @note On ASCII system, this variable does <b>not</b> exist. * So, its use should be guarded by \#if APR_CHARSET_EBCDIC. */ extern apr_xlate_t *ap_hdrs_from_ascii; #endif /* APR_CHARSET_EBCDIC */ #ifdef __cplusplus } #endif #endif /* !APACHE_UTIL_CHARSET_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file http_connection.h * @brief Apache connection library * * @defgroup APACHE_CORE_CONNECTION Connection Library * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_HTTP_CONNECTION_H #define APACHE_HTTP_CONNECTION_H #include "apr_network_io.h" #include "apr_buckets.h" #ifdef __cplusplus extern "C" { #endif /** * This is the protocol module driver. This calls all of the * pre-connection and connection hooks for all protocol modules. * @param c The connection on which the request is read * @param csd The mechanism on which this connection is to be read. * Most times this will be a socket, but it is up to the module * that accepts the request to determine the exact type. */ AP_CORE_DECLARE(void) ap_process_connection(conn_rec *c, void *csd); /** * Shutdown the connection for writing. * @param c The connection to shutdown * @param flush Whether or not to flush pending data before * @return APR_SUCCESS or the underlying error */ AP_CORE_DECLARE(apr_status_t) ap_shutdown_conn(conn_rec *c, int flush); /** * Flushes all remain data in the client send buffer * @param c The connection to flush * @remark calls ap_shutdown_conn(c, 1) */ AP_CORE_DECLARE(void) ap_flush_conn(conn_rec *c); /** * This function is responsible for the following cases: * <pre> * we now proceed to read from the client until we get EOF, or until * MAX_SECS_TO_LINGER has passed. The reasons for doing this are * documented in a draft: * * http://tools.ietf.org/html/draft-ietf-http-connection-00.txt * * in a nutshell -- if we don't make this effort we risk causing * TCP RST packets to be sent which can tear down a connection before * all the response data has been sent to the client. * </pre> * @param c The connection we are closing */ AP_DECLARE(void) ap_lingering_close(conn_rec *c); AP_DECLARE(int) ap_prep_lingering_close(conn_rec *c); AP_DECLARE(int) ap_start_lingering_close(conn_rec *c); /* Hooks */ /** * create_connection is a RUN_FIRST hook which allows modules to create * connections. In general, you should not install filters with the * create_connection hook. If you require vhost configuration information * to make filter installation decisions, you must use the pre_connection * or install_network_transport hook. This hook should close the connection * if it encounters a fatal error condition. * * @param p The pool from which to allocate the connection record * @param server The server record to create the connection too. * @param csd The socket that has been accepted * @param conn_id A unique identifier for this connection. The ID only * needs to be unique at that time, not forever. * @param sbh A handle to scoreboard information for this connection. * @param alloc The bucket allocator to use for all bucket/brigade creations * @return An allocated connection record or NULL. */ AP_DECLARE_HOOK(conn_rec *, create_connection, (apr_pool_t *p, server_rec *server, apr_socket_t *csd, long conn_id, void *sbh, apr_bucket_alloc_t *alloc)) /** * This hook gives protocol modules an opportunity to set everything up * before calling the protocol handler. All pre-connection hooks are * run until one returns something other than ok or decline * @param c The connection on which the request has been received. * @param csd The mechanism on which this connection is to be read. * Most times this will be a socket, but it is up to the module * that accepts the request to determine the exact type. * @return OK or DECLINED */ AP_DECLARE_HOOK(int,pre_connection,(conn_rec *c, void *csd)) /** * This hook implements different protocols. After a connection has been * established, the protocol module must read and serve the request. This * function does that for each protocol module. The first protocol module * to handle the request is the last module run. * @param c The connection on which the request has been received. * @return OK or DECLINED */ AP_DECLARE_HOOK(int,process_connection,(conn_rec *c)) /** * This hook implements different protocols. Before a connection is closed, * protocols might have to perform some housekeeping actions, such as * sending one last goodbye packet. The connection is, unless some other * error already happened before, still open and operational. * All pre-close-connection hooks are run until one returns something * other than ok or decline * @param c The connection on which the request has been received. * @return OK or DECLINED */ AP_DECLARE_HOOK(int,pre_close_connection,(conn_rec *c)) /** * This is a wrapper around ap_run_pre_connection. In case that * ap_run_pre_connection returns an error it marks the connection as * aborted and ensures that the basic connection setup normally done * by the core module is done in case it was not done so far. * @param c The connection on which the request has been received. * Same as for the pre_connection hook. * @param csd The mechanism on which this connection is to be read. * Most times this will be a socket, but it is up to the module * that accepts the request to determine the exact type. * Same as for the pre_connection hook. * @return The result of ap_run_pre_connection */ AP_DECLARE(int) ap_pre_connection(conn_rec *c, void *csd); /** End Of Connection (EOC) bucket */ AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_eoc; /** * Determine if a bucket is an End Of Connection (EOC) bucket * @param e The bucket to inspect * @return true or false */ #define AP_BUCKET_IS_EOC(e) (e->type == &ap_bucket_type_eoc) /** * Make the bucket passed in an End Of Connection (EOC) bucket * @param b The bucket to make into an EOC bucket * @return The new bucket, or NULL if allocation failed */ AP_DECLARE(apr_bucket *) ap_bucket_eoc_make(apr_bucket *b); /** * Create a bucket referring to an End Of Connection (EOC). This indicates * that the connection will be closed. * @param list The freelist from which this bucket should be allocated * @return The new bucket, or NULL if allocation failed */ AP_DECLARE(apr_bucket *) ap_bucket_eoc_create(apr_bucket_alloc_t *list); #ifdef __cplusplus } #endif #endif /* !APACHE_HTTP_CONNECTION_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file mod_dbd.h * @brief Database Access Extension Module for Apache * * Overview of what this is and does: * http://www.apache.org/~niq/dbd.html * or * http://apache.webthing.com/database/ * * @defgroup MOD_DBD mod_dbd * @ingroup APACHE_MODS * @{ */ #ifndef DBD_H #define DBD_H /* Create a set of DBD_DECLARE(type), DBD_DECLARE_NONSTD(type) and * DBD_DECLARE_DATA with appropriate export and import tags for the platform */ #if !defined(WIN32) #define DBD_DECLARE(type) type #define DBD_DECLARE_NONSTD(type) type #define DBD_DECLARE_DATA #elif defined(DBD_DECLARE_STATIC) #define DBD_DECLARE(type) type __stdcall #define DBD_DECLARE_NONSTD(type) type #define DBD_DECLARE_DATA #elif defined(DBD_DECLARE_EXPORT) #define DBD_DECLARE(type) __declspec(dllexport) type __stdcall #define DBD_DECLARE_NONSTD(type) __declspec(dllexport) type #define DBD_DECLARE_DATA __declspec(dllexport) #else #define DBD_DECLARE(type) __declspec(dllimport) type __stdcall #define DBD_DECLARE_NONSTD(type) __declspec(dllimport) type #define DBD_DECLARE_DATA __declspec(dllimport) #endif #include <httpd.h> #include <apr_optional.h> #include <apr_hash.h> #include <apr_hooks.h> typedef struct { server_rec *server; const char *name; const char *params; int persist; #if APR_HAS_THREADS int nmin; int nkeep; int nmax; int exptime; int set; #endif apr_hash_t *queries; apr_array_header_t *init_queries; } dbd_cfg_t; typedef struct { apr_dbd_t *handle; const apr_dbd_driver_t *driver; apr_hash_t *prepared; apr_pool_t *pool; } ap_dbd_t; /* Export functions to access the database */ /* acquire a connection that MUST be explicitly closed. * Returns NULL on error */ DBD_DECLARE_NONSTD(ap_dbd_t*) ap_dbd_open(apr_pool_t*, server_rec*); /* release a connection acquired with ap_dbd_open */ DBD_DECLARE_NONSTD(void) ap_dbd_close(server_rec*, ap_dbd_t*); /* acquire a connection that will have the lifetime of a request * and MUST NOT be explicitly closed. Return NULL on error. * This is the preferred function for most applications. */ DBD_DECLARE_NONSTD(ap_dbd_t*) ap_dbd_acquire(request_rec*); /* acquire a connection that will have the lifetime of a connection * and MUST NOT be explicitly closed. Return NULL on error. * This is the preferred function for most applications. */ DBD_DECLARE_NONSTD(ap_dbd_t*) ap_dbd_cacquire(conn_rec*); /* Prepare a statement for use by a client module during * the server startup/configuration phase. Can't be called * after the server has created its children (use apr_dbd_*). */ DBD_DECLARE_NONSTD(void) ap_dbd_prepare(server_rec*, const char*, const char*); /* Also export them as optional functions for modules that prefer it */ APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_open, (apr_pool_t*, server_rec*)); APR_DECLARE_OPTIONAL_FN(void, ap_dbd_close, (server_rec*, ap_dbd_t*)); APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_acquire, (request_rec*)); APR_DECLARE_OPTIONAL_FN(ap_dbd_t*, ap_dbd_cacquire, (conn_rec*)); APR_DECLARE_OPTIONAL_FN(void, ap_dbd_prepare, (server_rec*, const char*, const char*)); APR_DECLARE_EXTERNAL_HOOK(dbd, DBD, apr_status_t, post_connect, (apr_pool_t *, dbd_cfg_t *, ap_dbd_t *)) #endif /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file http_ssl.h * @brief SSL protocol handling * * @defgroup APACHE_CORE_PROTO SSL Protocol Handling * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_HTTP_SSL_H #define APACHE_HTTP_SSL_H #include "httpd.h" #include "apr_portable.h" #include "apr_mmap.h" #ifdef __cplusplus extern "C" { #endif struct ap_conf_vector_t; /** * This hook allows modules that manage SSL connection to register their * inquiry function for checking if a connection is using SSL from them. * @param c The current connection * @return OK if the connection is using SSL, DECLINED if not. * @ingroup hooks */ AP_DECLARE_HOOK(int,ssl_conn_is_ssl,(conn_rec *c)) /** * Return != 0 iff the connection is encrypted with SSL. * @param c the connection */ AP_DECLARE(int) ap_ssl_conn_is_ssl(conn_rec *c); /** * This hook declares a connection to be outgoing and the configuration that applies to it. * This hook can be called several times in the lifetime of an outgoing connection, e.g. * when it is re-used in different request contexts. It will at least be called after the * connection was created and before the pre-connection hooks is invoked. * All outgoing-connection hooks are run until one returns something other than DECLINE. * if enable_ssl != 0, a hook that sets up SSL for the connection needs to return OK * to prevent subsequent hooks from doing the same. * * @param c The connection on which requests/data are to be sent. * @param dir_conf The directory configuration in which this connection is being used. * @param enable_ssl If != 0, the SSL protocol should be enabled for this connection. * @return DECLINED, OK when ssl was enabled */ AP_DECLARE_HOOK(int, ssl_bind_outgoing, (conn_rec *c, struct ap_conf_vector_t *dir_conf, int enable_ssl)) /** * Assures the connection is marked as outgoing and invokes the ssl_bind_outgoing hook. * This may be called several times on an outgoing connection with varying dir_conf * values. require_ssl is not allowed to change on the same connection. * * @param c The connection on which requests/data are to be sent. * @param dir_conf The directory configuration in which this connection is being used. * @param require_ssl != 0 iff this connection needs to be secured by SSL/TLS protocol. * @return OK iff ssl was required and is enabled, DECLINED otherwise */ AP_DECLARE(int) ap_ssl_bind_outgoing(conn_rec *c, struct ap_conf_vector_t *dir_conf, int require_ssl); /** * Return != 0 iff handlers/hooks for outgoing connections are registered. */ AP_DECLARE(int) ap_ssl_has_outgoing_handlers(void); /** * This hook allows modules to look up SSL related variables for a * server/connection/request, depending on what they inquire. Some * variables will only be available for a connection/request, for example. * @param p The pool to allocate a returned value in, MUST be provided * @param s The server to inquire a value for, maybe NULL * @param c The current connection, maybe NULL * @param r The current request, maybe NULL * @param name The name of the variable to retrieve, MUST be provided * @return value or the variable or NULL if not provided/available * @ingroup hooks */ AP_DECLARE_HOOK(const char *,ssl_var_lookup, (apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r, const char *name)) /** * Lookup an SSL related variable for the server/connection/request or a global * value when all those parameters are set to NULL. Pool and name must always be * provided and the returned value (if not NULL) will be allocated from the pool. * @param p The pool to allocate a returned value in, MUST be provided * @param s The server to inquire a value for, maybe NULL * @param c The current connection, maybe NULL * @param r The current request, maybe NULL * @param name The name of the variable to retrieve, MUST be provided * @return value or the variable or NULL if not provided/available */ AP_DECLARE(const char *) ap_ssl_var_lookup(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r, const char *name); /** * Register to provide certificate/key files for servers. Certificate files are * expected to contain the certificate chain, beginning with the server's certificate, * excluding the trust anchor, in PEM format. * They must be accompanied by a private key file, also in PEM format. * * @param s the server certificates are collected for * @param p the pool to use for allocations * @param cert_files an array of const char* with the path to the certificate chain * @param key_files an array of const char* with the path to the private key file * @return OK if files were added, DECLINED if not, or other for error. */ AP_DECLARE_HOOK(int, ssl_add_cert_files, (server_rec *s, apr_pool_t *p, apr_array_header_t *cert_files, apr_array_header_t *key_files)) /** * Collect certificate/key files from all providers registered. This includes * providers registered at the global 'ssl_add_cert_files', as well as those * installed in the OPTIONAL 'ssl_add_cert_files' hook as may be provided by * ssl modules. * * @param s the server certificates are collected for * @param p the pool to use for allocations * @param cert_files an array of const char* with the path to the certificate chain * @param key_files an array of const char* with the path to the private key file */ AP_DECLARE(apr_status_t) ap_ssl_add_cert_files(server_rec *s, apr_pool_t *p, apr_array_header_t *cert_files, apr_array_header_t *key_files); /** * Register to provide 'fallback' certificates in case no 'real' certificates * have been configured/added by other providers. Modules using these certificates * are encouraged to answer requests to this server with a 503 response code. * * @param s the server certificates are collected for * @param p the pool to use for allocations * @param cert_files an array of const char* with the path to the certificate chain * @param key_files an array of const char* with the path to the private key file * @return OK if files were added, DECLINED if not, or other for error. */ AP_DECLARE_HOOK(int, ssl_add_fallback_cert_files, (server_rec *s, apr_pool_t *p, apr_array_header_t *cert_files, apr_array_header_t *key_files)) /** * Collect 'fallback' certificate/key files from all registered providers, either * in the global 'ssl_add_fallback_cert_files' hook or the optional one of similar * name as provided by mod_ssl and sorts. * Certificates obtained this way are commonly self signed, temporary crutches. * To be used to the time it takes to retrieve a 'read', trusted certificate. * A module using fallbacks is encouraged to answer all requests with a 503. * * @param s the server certificates are collected for * @param p the pool to use for allocations * @param cert_files an array of const char* with the path to the certificate chain * @param key_files an array of const char* with the path to the private key file */ AP_DECLARE(apr_status_t) ap_ssl_add_fallback_cert_files(server_rec *s, apr_pool_t *p, apr_array_header_t *cert_files, apr_array_header_t *key_files); /** * On TLS connections that do not relate to a configured virtual host * allow modules to provide a certificate and key to be used on the connection. * * A Certificate PEM added must be accompanied by a private key PEM. The private * key PEM may be given by a NULL pointer, in which case it is expected to be found in * the certificate PEM string. */ AP_DECLARE_HOOK(int, ssl_answer_challenge, (conn_rec *c, const char *server_name, const char **pcert_pem, const char **pkey_pem)) /** * Returns != 0 iff the connection is a challenge to the server, for example * as defined in RFC 8555 for the 'tls-alpn-01' domain verification, and needs * a specific certificate as answer in the handshake. * * ALPN protocol negotiation via the hooks 'protocol_propose' and 'protocol_switch' * need to have run before this call is made. * * Certificate PEMs added must be accompanied by a private key PEM. The private * key PEM may be given by a NULL pointer, in which case it is expected to be found in * the certificate PEM string. * * A certificate provided this way needs to replace any other certificates selected * by configuration or 'ssl_add_cert_pems` on this connection. */ AP_DECLARE(int) ap_ssl_answer_challenge(conn_rec *c, const char *server_name, const char **pcert_pem, const char **pkey_pem); /** * Setup optional functions for ssl related queries so that functions * registered by old-style SSL module functions are interrogated by the * the new ap_is_ssl() and friends. Installs own optional functions, so that * old modules looking for these find one and get the correct results (shadowing). * * Needs to run in core's very early POST_CONFIG hook. * Modules providing such functions register their own optionals during * register_hooks(). Modules using such functions retrieve them often * in their own post-config or in the even later retrieval hook. When shadowing * other modules functions, core's early post-config is a good time. * @param pool The pool to use for allocations */ AP_DECLARE(void) ap_setup_ssl_optional_fns(apr_pool_t *pool); /** * Providers of OCSP status responses register at this hook. Installed hooks returning OK * are expected to provide later OCSP responses via a 'ap_ssl_ocsp_get_resp_hook'. * @param s the server being configured * @params p a memory pool to use * @param id opaque data uniquely identifying the certificate, provided by caller * @param pem PEM data of certificate first, followed by PEM of issuer cert * @return OK iff stapling is being provided */ AP_DECLARE_HOOK(int, ssl_ocsp_prime_hook, (server_rec *s, apr_pool_t *p, const char *id, apr_size_t id_len, const char *pem)) /** * Registering a certificate for Provisioning of OCSP responses. It is the caller's * responsibility to provide a global (apache instance) unique id for the certificate * that is then used later in retrieving the OCSP response. * A certificate can be primed this way more than once, however the same identifier * has to be provided each time (byte-wise same, not pointer same). * The memory pointed to by `id` and `pem` is only valid for the duration of the call. * * @param s the server being configured * @params p a memory pool to use * @param id opaque data uniquely identifying the certificate, provided by caller * @param pem PEM data of certificate first, followed by chain certs, at least the issuer * @return APR_SUCCESS iff OCSP responses will be provided. * APR_ENOENT when no provided was found or took responsibility. */ AP_DECLARE(apr_status_t) ap_ssl_ocsp_prime(server_rec *s, apr_pool_t *p, const char *id, apr_size_t id_len, const char *pem); /** * Callback to copy over the OCSP response data. If OCSP response data is not * available, this will be called with NULL, 0 parameters! * * Memory allocation methods and lifetime of data will vary per module and * SSL library used. The caller requesting OCSP data will need to make a copy * for his own use. * Any passed data may only be valid for the duration of the call. */ typedef void ap_ssl_ocsp_copy_resp(const unsigned char *der, apr_size_t der_len, void *userdata); /** * Asking for OCSP response DER data for a certificate formerly primed. * @param s the (SNI selected) server of the connection * @param c the connection * @param id identifier for the certifate, as used in ocsp_stapling_prime() * @param cb callback to invoke when response data is available * @param userdata caller supplied data passed to callback * @return OK iff response data has been provided, DECLINED otherwise */ AP_DECLARE_HOOK(int, ssl_ocsp_get_resp_hook, (server_rec *s, conn_rec *c, const char *id, apr_size_t id_len, ap_ssl_ocsp_copy_resp *cb, void *userdata)) /** * Retrieve the OCSP response data for a previously primed certificate. The id needs * to be byte-wise identical to the one used on priming. If the call return ARP_SUCCESS, * the callback has been invoked with the OCSP response DER data. * Otherwise, a different status code must be returned. Callers in SSL connection * handshakes are encouraged to continue the handshake without OCSP data for * server reliability. The decision to accept or reject a handshake with missing * OCSP stapling data needs to be done by the client. * For similar reasons, providers of responses might return seemingly expired ones * if they were unable to refresh a response in time. * * The memory pointed to by `id` is only valid for the duration of the call. * Also, the DER data passed to the callback is only valid for the duration * of the call. * * @param s the (SNI selected) server of the connection * @param c the connection * @param id identifier for the certifate, as used in ocsp_stapling_prime() * @param cb callback to invoke when response data is available * @param userdata caller supplied data passed to callback * @return APR_SUCCESS iff data has been provided */ AP_DECLARE(apr_status_t) ap_ssl_ocsp_get_resp(server_rec *s, conn_rec *c, const char *id, apr_size_t id_len, ap_ssl_ocsp_copy_resp *cb, void *userdata); #ifdef __cplusplus } #endif #endif /* !APACHE_HTTP_SSL_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file http_log.h * @brief Apache Logging library * * @defgroup APACHE_CORE_LOG Logging library * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_HTTP_LOG_H #define APACHE_HTTP_LOG_H #ifdef __cplusplus extern "C" { #endif #include "apr_thread_proc.h" #include "http_config.h" #ifdef HAVE_SYSLOG #include <syslog.h> #ifndef LOG_PRIMASK #define LOG_PRIMASK 7 #endif #define APLOG_EMERG LOG_EMERG /* system is unusable */ #define APLOG_ALERT LOG_ALERT /* action must be taken immediately */ #define APLOG_CRIT LOG_CRIT /* critical conditions */ #define APLOG_ERR LOG_ERR /* error conditions */ #define APLOG_WARNING LOG_WARNING /* warning conditions */ #define APLOG_NOTICE LOG_NOTICE /* normal but significant condition */ #define APLOG_INFO LOG_INFO /* informational */ #define APLOG_DEBUG LOG_DEBUG /* debug-level messages */ #define APLOG_TRACE1 (LOG_DEBUG + 1) /* trace-level 1 messages */ #define APLOG_TRACE2 (LOG_DEBUG + 2) /* trace-level 2 messages */ #define APLOG_TRACE3 (LOG_DEBUG + 3) /* trace-level 3 messages */ #define APLOG_TRACE4 (LOG_DEBUG + 4) /* trace-level 4 messages */ #define APLOG_TRACE5 (LOG_DEBUG + 5) /* trace-level 5 messages */ #define APLOG_TRACE6 (LOG_DEBUG + 6) /* trace-level 6 messages */ #define APLOG_TRACE7 (LOG_DEBUG + 7) /* trace-level 7 messages */ #define APLOG_TRACE8 (LOG_DEBUG + 8) /* trace-level 8 messages */ #define APLOG_LEVELMASK 15 /* mask off the level value */ #else #define APLOG_EMERG 0 /* system is unusable */ #define APLOG_ALERT 1 /* action must be taken immediately */ #define APLOG_CRIT 2 /* critical conditions */ #define APLOG_ERR 3 /* error conditions */ #define APLOG_WARNING 4 /* warning conditions */ #define APLOG_NOTICE 5 /* normal but significant condition */ #define APLOG_INFO 6 /* informational */ #define APLOG_DEBUG 7 /* debug-level messages */ #define APLOG_TRACE1 8 /* trace-level 1 messages */ #define APLOG_TRACE2 9 /* trace-level 2 messages */ #define APLOG_TRACE3 10 /* trace-level 3 messages */ #define APLOG_TRACE4 11 /* trace-level 4 messages */ #define APLOG_TRACE5 12 /* trace-level 5 messages */ #define APLOG_TRACE6 13 /* trace-level 6 messages */ #define APLOG_TRACE7 14 /* trace-level 7 messages */ #define APLOG_TRACE8 15 /* trace-level 8 messages */ #define APLOG_LEVELMASK 15 /* mask off the level value */ #endif /* APLOG_NOERRNO is ignored and should not be used. It will be * removed in a future release of Apache. */ #define APLOG_NOERRNO (APLOG_LEVELMASK + 1) /** Use APLOG_TOCLIENT on ap_log_rerror() to give content * handlers the option of including the error text in the * ErrorDocument sent back to the client. Setting APLOG_TOCLIENT * will cause the error text to be saved in the request_rec->notes * table, keyed to the string "error-notes", if and only if: * - the severity level of the message is APLOG_WARNING or greater * - there are no other "error-notes" set in request_rec->notes * Once error-notes is set, it is up to the content handler to * determine whether this text should be sent back to the client. * Note: Client generated text streams sent back to the client MUST * be escaped to prevent CSS attacks. */ #define APLOG_TOCLIENT ((APLOG_LEVELMASK + 1) * 2) /* normal but significant condition on startup, usually printed to stderr */ #define APLOG_STARTUP ((APLOG_LEVELMASK + 1) * 4) #ifndef DEFAULT_LOGLEVEL #define DEFAULT_LOGLEVEL APLOG_WARNING #endif /** * APLOGNO() should be used at the start of the format string passed * to ap_log_error() and friends. The argument must be a 5 digit decimal * number. It creates a tag of the form "AH02182: " * See docs/log-message-tags/README for details. */ #define APLOGNO(n) "AH" #n ": " /** * APLOG_NO_MODULE may be passed as module_index to ap_log_error() and related * functions if the module causing the log message is not known. Normally this * should not be used directly. Use ::APLOG_MARK or ::APLOG_MODULE_INDEX * instead. * * @see APLOG_MARK * @see APLOG_MODULE_INDEX * @see ap_log_error */ #define APLOG_NO_MODULE -1 #ifdef __cplusplus /** * C++ modules must invoke ::APLOG_USE_MODULE or ::AP_DECLARE_MODULE in * every file which uses ap_log_* before the first use of ::APLOG_MARK * or ::APLOG_MODULE_INDEX. * (C modules *should* do that as well, to enable module-specific log * levels. C modules need not obey the ordering, though). */ #else /* __cplusplus */ /** * Constant to store module_index for the current file. * Objects with static storage duration are set to NULL if not * initialized explicitly. This means that if aplog_module_index * is not initialized using the ::APLOG_USE_MODULE or the * ::AP_DECLARE_MODULE macro, we can safely fall back to * use ::APLOG_NO_MODULE. This variable will usually be optimized away. */ static int * const aplog_module_index; #endif /* __cplusplus */ /** * APLOG_MODULE_INDEX contains the module_index of the current module if * it has been set via the ::APLOG_USE_MODULE or ::AP_DECLARE_MODULE macro. * Otherwise it contains ::APLOG_NO_MODULE (for example in unmodified httpd * 2.2 modules). * * If ::APLOG_MARK is used in ap_log_error() and related functions, * ::APLOG_MODULE_INDEX will be passed as module_index. In cases where * ::APLOG_MARK cannot be used, ::APLOG_MODULE_INDEX should normally be passed * as module_index. * * @see APLOG_MARK * @see ap_log_error */ #ifdef __cplusplus #define APLOG_MODULE_INDEX (*aplog_module_index) #else /* __cplusplus */ #define APLOG_MODULE_INDEX \ (aplog_module_index ? *aplog_module_index : APLOG_NO_MODULE) #endif /* __cplusplus */ /** * APLOG_MAX_LOGLEVEL can be defined to remove logging above some * specified level at compile time. * * This requires a C99 compiler. */ #ifdef DOXYGEN #define APLOG_MAX_LOGLEVEL #endif #ifndef APLOG_MAX_LOGLEVEL #define APLOG_MODULE_IS_LEVEL(s,module_index,level) \ ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \ (s == NULL) || \ (ap_get_server_module_loglevel(s, module_index) \ >= ((level)&APLOG_LEVELMASK) ) ) #define APLOG_C_MODULE_IS_LEVEL(c,module_index,level) \ ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \ (ap_get_conn_module_loglevel(c, module_index) \ >= ((level)&APLOG_LEVELMASK) ) ) #define APLOG_CS_MODULE_IS_LEVEL(c,s,module_index,level) \ ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \ (ap_get_conn_server_module_loglevel(c, s, module_index) \ >= ((level)&APLOG_LEVELMASK) ) ) #define APLOG_R_MODULE_IS_LEVEL(r,module_index,level) \ ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \ (ap_get_request_module_loglevel(r, module_index) \ >= ((level)&APLOG_LEVELMASK) ) ) #else #define APLOG_MODULE_IS_LEVEL(s,module_index,level) \ ( (((level)&APLOG_LEVELMASK) <= APLOG_MAX_LOGLEVEL) && \ ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \ (s == NULL) || \ (ap_get_server_module_loglevel(s, module_index) \ >= ((level)&APLOG_LEVELMASK) ) ) ) #define APLOG_CS_MODULE_IS_LEVEL(c,s,module_index,level) \ ( (((level)&APLOG_LEVELMASK) <= APLOG_MAX_LOGLEVEL) && \ ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \ (ap_get_conn_server_module_loglevel(c, s, module_index) \ >= ((level)&APLOG_LEVELMASK) ) ) ) #define APLOG_C_MODULE_IS_LEVEL(c,module_index,level) \ ( (((level)&APLOG_LEVELMASK) <= APLOG_MAX_LOGLEVEL) && \ ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \ (ap_get_conn_module_loglevel(c, module_index) \ >= ((level)&APLOG_LEVELMASK) ) ) ) #define APLOG_R_MODULE_IS_LEVEL(r,module_index,level) \ ( (((level)&APLOG_LEVELMASK) <= APLOG_MAX_LOGLEVEL) && \ ( (((level)&APLOG_LEVELMASK) <= APLOG_NOTICE) || \ (ap_get_request_module_loglevel(r, module_index) \ >= ((level)&APLOG_LEVELMASK) ) ) ) #endif #define APLOG_IS_LEVEL(s,level) \ APLOG_MODULE_IS_LEVEL(s,APLOG_MODULE_INDEX,level) #define APLOG_C_IS_LEVEL(c,level) \ APLOG_C_MODULE_IS_LEVEL(c,APLOG_MODULE_INDEX,level) #define APLOG_CS_IS_LEVEL(c,s,level) \ APLOG_CS_MODULE_IS_LEVEL(c,s,APLOG_MODULE_INDEX,level) #define APLOG_R_IS_LEVEL(r,level) \ APLOG_R_MODULE_IS_LEVEL(r,APLOG_MODULE_INDEX,level) #define APLOGinfo(s) APLOG_IS_LEVEL(s,APLOG_INFO) #define APLOGdebug(s) APLOG_IS_LEVEL(s,APLOG_DEBUG) #define APLOGtrace1(s) APLOG_IS_LEVEL(s,APLOG_TRACE1) #define APLOGtrace2(s) APLOG_IS_LEVEL(s,APLOG_TRACE2) #define APLOGtrace3(s) APLOG_IS_LEVEL(s,APLOG_TRACE3) #define APLOGtrace4(s) APLOG_IS_LEVEL(s,APLOG_TRACE4) #define APLOGtrace5(s) APLOG_IS_LEVEL(s,APLOG_TRACE5) #define APLOGtrace6(s) APLOG_IS_LEVEL(s,APLOG_TRACE6) #define APLOGtrace7(s) APLOG_IS_LEVEL(s,APLOG_TRACE7) #define APLOGtrace8(s) APLOG_IS_LEVEL(s,APLOG_TRACE8) #define APLOGrinfo(r) APLOG_R_IS_LEVEL(r,APLOG_INFO) #define APLOGrdebug(r) APLOG_R_IS_LEVEL(r,APLOG_DEBUG) #define APLOGrtrace1(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE1) #define APLOGrtrace2(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE2) #define APLOGrtrace3(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE3) #define APLOGrtrace4(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE4) #define APLOGrtrace5(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE5) #define APLOGrtrace6(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE6) #define APLOGrtrace7(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE7) #define APLOGrtrace8(r) APLOG_R_IS_LEVEL(r,APLOG_TRACE8) #define APLOGcinfo(c) APLOG_C_IS_LEVEL(c,APLOG_INFO) #define APLOGcdebug(c) APLOG_C_IS_LEVEL(c,APLOG_DEBUG) #define APLOGctrace1(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE1) #define APLOGctrace2(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE2) #define APLOGctrace3(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE3) #define APLOGctrace4(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE4) #define APLOGctrace5(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE5) #define APLOGctrace6(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE6) #define APLOGctrace7(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE7) #define APLOGctrace8(c) APLOG_C_IS_LEVEL(c,APLOG_TRACE8) AP_DECLARE_DATA extern int ap_default_loglevel; /** * APLOG_MARK is a convenience macro for use as the first three parameters in * ap_log_error() and related functions, i.e. file, line, and module_index. * * The module_index parameter was introduced in version 2.3.6. Before that * version, APLOG_MARK only replaced the file and line parameters. * This means that APLOG_MARK can be used with ap_log_*error in all versions * of Apache httpd. * * @see APLOG_MODULE_INDEX * @see ap_log_error * @see ap_log_cerror * @see ap_log_rerror * @see ap_log_cserror */ #define APLOG_MARK __FILE__,__LINE__,APLOG_MODULE_INDEX /** * Set up for logging to stderr. * @param p The pool to allocate out of */ AP_DECLARE(void) ap_open_stderr_log(apr_pool_t *p); /** * Replace logging to stderr with logging to the given file. * @param p The pool to allocate out of * @param file Name of the file to log stderr output */ AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p, const char *file); /** * Open the error log and replace stderr with it. * @param pconf Not used * @param plog The pool to allocate the logs from * @param ptemp Pool used for temporary allocations * @param s_main The main server * @note ap_open_logs isn't expected to be used by modules, it is * an internal core function */ int ap_open_logs(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s_main); /** * Perform special processing for piped loggers in MPM child * processes. * @param p Not used * @param s Not used * @note ap_logs_child_init is not for use by modules; it is an * internal core function */ void ap_logs_child_init(apr_pool_t *p, server_rec *s); /* * The primary logging functions, ap_log_error, ap_log_rerror, ap_log_cerror, * and ap_log_perror use a printf style format string to build the log message. * It is VERY IMPORTANT that you not include any raw data from the network, * such as the request-URI or request header fields, within the format * string. Doing so makes the server vulnerable to a denial-of-service * attack and other messy behavior. Instead, use a simple format string * like "%s", followed by the string containing the untrusted data. */ /** * ap_log_error() - log messages which are not related to a particular * request or connection. This uses a printf-like format to log messages * to the error_log. * @param file The file in which this function is called * @param line The line number on which this function is called * @param module_index The module_index of the module generating this message * @param level The level of this error message * @param status The status code from the previous command * @param s The server on which we are logging * @param fmt The format string * @param ... The arguments to use to fill out fmt. * @note ap_log_error is implemented as a macro * @note Use APLOG_MARK to fill out file and line * @note If a request_rec is available, use that with ap_log_rerror() * in preference to calling this function. Otherwise, if a conn_rec is * available, use that with ap_log_cerror() in preference to calling * this function. * @warning It is VERY IMPORTANT that you not include any raw data from * the network, such as the request-URI or request header fields, within * the format string. Doing so makes the server vulnerable to a * denial-of-service attack and other messy behavior. Instead, use a * simple format string like "%s", followed by the string containing the * untrusted data. */ #ifdef DOXYGEN AP_DECLARE(void) ap_log_error(const char *file, int line, int module_index, int level, apr_status_t status, const server_rec *s, const char *fmt, ...); #else #ifdef AP_HAVE_C99 /* need additional step to expand APLOG_MARK first */ #define ap_log_error(...) ap_log_error__(__VA_ARGS__) /* need server_rec *sr = ... for the case if s is verbatim NULL */ #define ap_log_error__(file, line, mi, level, status, s, ...) \ do { const server_rec *sr__ = s; if (APLOG_MODULE_IS_LEVEL(sr__, mi, level)) \ ap_log_error_(file, line, mi, level, status, sr__, __VA_ARGS__); \ } while(0) #else #define ap_log_error ap_log_error_ #endif AP_DECLARE(void) ap_log_error_(const char *file, int line, int module_index, int level, apr_status_t status, const server_rec *s, const char *fmt, ...) __attribute__((format(printf,7,8))); #endif /** * ap_log_perror() - log messages which are not related to a particular * request, connection, or virtual server. This uses a printf-like * format to log messages to the error_log. * @param file The file in which this function is called * @param line The line number on which this function is called * @param module_index ignored dummy value for use by APLOG_MARK * @param level The level of this error message * @param status The status code from the previous command * @param p The pool which we are logging for * @param fmt The format string * @param ... The arguments to use to fill out fmt. * @note ap_log_perror is implemented as a macro * @note Use APLOG_MARK to fill out file, line, and module_index * @warning It is VERY IMPORTANT that you not include any raw data from * the network, such as the request-URI or request header fields, within * the format string. Doing so makes the server vulnerable to a * denial-of-service attack and other messy behavior. Instead, use a * simple format string like "%s", followed by the string containing the * untrusted data. */ #ifdef DOXYGEN AP_DECLARE(void) ap_log_perror(const char *file, int line, int module_index, int level, apr_status_t status, apr_pool_t *p, const char *fmt, ...); #else #if defined(AP_HAVE_C99) && defined(APLOG_MAX_LOGLEVEL) /* need additional step to expand APLOG_MARK first */ #define ap_log_perror(...) ap_log_perror__(__VA_ARGS__) #define ap_log_perror__(file, line, mi, level, status, p, ...) \ do { if ((level) <= APLOG_MAX_LOGLEVEL ) \ ap_log_perror_(file, line, mi, level, status, p, \ __VA_ARGS__); } while(0) #else #define ap_log_perror ap_log_perror_ #endif AP_DECLARE(void) ap_log_perror_(const char *file, int line, int module_index, int level, apr_status_t status, apr_pool_t *p, const char *fmt, ...) __attribute__((format(printf,7,8))); #endif /** * ap_log_rerror() - log messages which are related to a particular * request. This uses a printf-like format to log messages to the * error_log. * @param file The file in which this function is called * @param line The line number on which this function is called * @param module_index The module_index of the module generating this message * @param level The level of this error message * @param status The status code from the previous command * @param r The request which we are logging for * @param fmt The format string * @param ... The arguments to use to fill out fmt. * @note ap_log_rerror is implemented as a macro * @note Use APLOG_MARK to fill out file, line, and module_index * @warning It is VERY IMPORTANT that you not include any raw data from * the network, such as the request-URI or request header fields, within * the format string. Doing so makes the server vulnerable to a * denial-of-service attack and other messy behavior. Instead, use a * simple format string like "%s", followed by the string containing the * untrusted data. */ #ifdef DOXYGEN AP_DECLARE(void) ap_log_rerror(const char *file, int line, int module_index, int level, apr_status_t status, const request_rec *r, const char *fmt, ...); #else #ifdef AP_HAVE_C99 /* need additional step to expand APLOG_MARK first */ #define ap_log_rerror(...) ap_log_rerror__(__VA_ARGS__) #define ap_log_rerror__(file, line, mi, level, status, r, ...) \ do { if (APLOG_R_MODULE_IS_LEVEL(r, mi, level)) \ ap_log_rerror_(file, line, mi, level, status, r, __VA_ARGS__); \ } while(0) #else #define ap_log_rerror ap_log_rerror_ #endif AP_DECLARE(void) ap_log_rerror_(const char *file, int line, int module_index, int level, apr_status_t status, const request_rec *r, const char *fmt, ...) __attribute__((format(printf,7,8))); #endif /** * ap_log_cerror() - log messages which are related to a particular * connection. This uses a printf-like format to log messages to the * error_log. * @param file The file in which this function is called * @param line The line number on which this function is called * @param level The level of this error message * @param module_index The module_index of the module generating this message * @param status The status code from the previous command * @param c The connection which we are logging for * @param fmt The format string * @param ... The arguments to use to fill out fmt. * @note ap_log_cerror is implemented as a macro * @note Use APLOG_MARK to fill out file, line, and module_index * @note If a request_rec is available, use that with ap_log_rerror() * in preference to calling this function. * @warning It is VERY IMPORTANT that you not include any raw data from * the network, such as the request-URI or request header fields, within * the format string. Doing so makes the server vulnerable to a * denial-of-service attack and other messy behavior. Instead, use a * simple format string like "%s", followed by the string containing the * untrusted data. */ #ifdef DOXYGEN AP_DECLARE(void) ap_log_cerror(const char *file, int line, int module_index, int level, apr_status_t status, const conn_rec *c, const char *fmt, ...); #else #ifdef AP_HAVE_C99 /* need additional step to expand APLOG_MARK first */ #define ap_log_cerror(...) ap_log_cerror__(__VA_ARGS__) #define ap_log_cerror__(file, line, mi, level, status, c, ...) \ do { if (APLOG_C_MODULE_IS_LEVEL(c, mi, level)) \ ap_log_cerror_(file, line, mi, level, status, c, __VA_ARGS__); \ } while(0) #else #define ap_log_cerror ap_log_cerror_ #endif AP_DECLARE(void) ap_log_cerror_(const char *file, int line, int module_index, int level, apr_status_t status, const conn_rec *c, const char *fmt, ...) __attribute__((format(printf,7,8))); #endif /** * ap_log_cserror() - log messages which are related to a particular * connection and to a vhost other than c->base_server. This uses a * printf-like format to log messages to the error_log. * @param file The file in which this function is called * @param line The line number on which this function is called * @param level The level of this error message * @param module_index The module_index of the module generating this message * @param status The status code from the previous command * @param c The connection which we are logging for * @param s The server which we are logging for * @param fmt The format string * @param ... The arguments to use to fill out fmt. * @note ap_log_cserror is implemented as a macro * @note Use APLOG_MARK to fill out file, line, and module_index * @note If a request_rec is available, use that with ap_log_rerror() * in preference to calling this function. This function is mainly useful for * modules like mod_ssl to use before the request_rec is created. * @warning It is VERY IMPORTANT that you not include any raw data from * the network, such as the request-URI or request header fields, within * the format string. Doing so makes the server vulnerable to a * denial-of-service attack and other messy behavior. Instead, use a * simple format string like "%s", followed by the string containing the * untrusted data. */ #ifdef DOXYGEN AP_DECLARE(void) ap_log_cserror(const char *file, int line, int module_index, int level, apr_status_t status, const conn_rec *c, const server_rec *s, const char *fmt, ...); #else #ifdef AP_HAVE_C99 /* need additional step to expand APLOG_MARK first */ #define ap_log_cserror(...) ap_log_cserror__(__VA_ARGS__) #define ap_log_cserror__(file, line, mi, level, status, c, s, ...) \ do { if (APLOG_CS_MODULE_IS_LEVEL(c, s, mi, level)) \ ap_log_cserror_(file, line, mi, level, status, c, s, \ __VA_ARGS__); \ } while(0) #else #define ap_log_cserror ap_log_cserror_ #endif AP_DECLARE(void) ap_log_cserror_(const char *file, int line, int module_index, int level, apr_status_t status, const conn_rec *c, const server_rec *s, const char *fmt, ...) __attribute__((format(printf,8,9))); #endif /* * The buffer logging functions, ap_log_data, ap_log_rdata, ap_log_cdata, * and ap_log_csdata log a buffer in printable and hex format. The exact * format is controlled by processing flags, described next. */ /** * Processing flags for ap_log_data() et al * * AP_LOG_DATA_DEFAULT - default formatting, with printable chars and hex * AP_LOG_DATA_SHOW_OFFSET - prefix each line with hex offset from the start * of the buffer */ #define AP_LOG_DATA_DEFAULT 0 #define AP_LOG_DATA_SHOW_OFFSET 1 /** * ap_log_data() - log buffers which are not related to a particular request * or connection. * @param file The file in which this function is called * @param line The line number on which this function is called * @param module_index The module_index of the module logging this buffer * @param level The log level * @param s The server on which we are logging * @param label A label for the buffer, to be logged preceding the buffer * @param data The buffer to be logged * @param len The length of the buffer * @param flags Special processing flags like AP_LOG_DATA_SHOW_OFFSET * @note ap_log_data is implemented as a macro. * @note Use APLOG_MARK to fill out file, line, and module_index * @note If a request_rec is available, use that with ap_log_rdata() * in preference to calling this function. Otherwise, if a conn_rec is * available, use that with ap_log_cdata() in preference to calling * this function. */ #ifdef DOXYGEN AP_DECLARE(void) ap_log_data(const char *file, int line, int module_index, int level, const server_rec *s, const char *label, const void *data, apr_size_t len, unsigned int flags); #else #ifdef AP_HAVE_C99 /* need additional step to expand APLOG_MARK first */ #define ap_log_data(...) ap_log_data__(__VA_ARGS__) /* need server_rec *sr = ... for the case if s is verbatim NULL */ #define ap_log_data__(file, line, mi, level, s, ...) \ do { const server_rec *sr__ = s; if (APLOG_MODULE_IS_LEVEL(sr__, mi, level)) \ ap_log_data_(file, line, mi, level, sr__, __VA_ARGS__); \ } while(0) #else #define ap_log_data ap_log_data_ #endif AP_DECLARE(void) ap_log_data_(const char *file, int line, int module_index, int level, const server_rec *s, const char *label, const void *data, apr_size_t len, unsigned int flags); #endif /** * ap_log_rdata() - log buffers which are related to a particular request. * @param file The file in which this function is called * @param line The line number on which this function is called * @param module_index The module_index of the module logging this buffer * @param level The log level * @param r The request which we are logging for * @param label A label for the buffer, to be logged preceding the buffer * @param data The buffer to be logged * @param len The length of the buffer * @param flags Special processing flags like AP_LOG_DATA_SHOW_OFFSET * @note ap_log_rdata is implemented as a macro. * @note Use APLOG_MARK to fill out file, line, and module_index * @note If a request_rec is available, use that with ap_log_rerror() * in preference to calling this function. Otherwise, if a conn_rec is * available, use that with ap_log_cerror() in preference to calling * this function. */ #ifdef DOXYGEN AP_DECLARE(void) ap_log_rdata(const char *file, int line, int module_index, int level, const request_rec *r, const char *label, const void *data, apr_size_t len, unsigned int flags); #else #ifdef AP_HAVE_C99 /* need additional step to expand APLOG_MARK first */ #define ap_log_rdata(...) ap_log_rdata__(__VA_ARGS__) #define ap_log_rdata__(file, line, mi, level, r, ...) \ do { if (APLOG_R_MODULE_IS_LEVEL(r, mi, level)) \ ap_log_rdata_(file, line, mi, level, r, __VA_ARGS__); \ } while(0) #else #define ap_log_rdata ap_log_rdata_ #endif AP_DECLARE(void) ap_log_rdata_(const char *file, int line, int module_index, int level, const request_rec *r, const char *label, const void *data, apr_size_t len, unsigned int flags); #endif /** * ap_log_cdata() - log buffers which are related to a particular connection. * @param file The file in which this function is called * @param line The line number on which this function is called * @param module_index The module_index of the module logging this buffer * @param level The log level * @param c The connection which we are logging for * @param label A label for the buffer, to be logged preceding the buffer * @param data The buffer to be logged * @param len The length of the buffer * @param flags Special processing flags like AP_LOG_DATA_SHOW_OFFSET * @note ap_log_cdata is implemented as a macro * @note Use APLOG_MARK to fill out file, line, and module_index * @note If a request_rec is available, use that with ap_log_rerror() * in preference to calling this function. Otherwise, if a conn_rec is * available, use that with ap_log_cerror() in preference to calling * this function. */ #ifdef DOXYGEN AP_DECLARE(void) ap_log_cdata(const char *file, int line, int module_index, int level, const conn_rec *c, const char *label, const void *data, apr_size_t len, unsigned int flags); #else #ifdef AP_HAVE_C99 /* need additional step to expand APLOG_MARK first */ #define ap_log_cdata(...) ap_log_cdata__(__VA_ARGS__) #define ap_log_cdata__(file, line, mi, level, c, ...) \ do { if (APLOG_C_MODULE_IS_LEVEL(c, mi, level)) \ ap_log_cdata_(file, line, mi, level, c, __VA_ARGS__); \ } while(0) #else #define ap_log_cdata ap_log_cdata_ #endif AP_DECLARE(void) ap_log_cdata_(const char *file, int line, int module_index, int level, const conn_rec *c, const char *label, const void *data, apr_size_t len, unsigned int flags); #endif /** * ap_log_csdata() - log buffers which are related to a particular connection * and to a vhost other than c->base_server. * @param file The file in which this function is called * @param line The line number on which this function is called * @param module_index The module_index of the module logging this buffer * @param level The log level * @param c The connection which we are logging for * @param s The server which we are logging for * @param label A label for the buffer, to be logged preceding the buffer * @param data The buffer to be logged * @param len The length of the buffer * @param flags Special processing flags like AP_LOG_DATA_SHOW_OFFSET * @note ap_log_csdata is implemented as a macro * @note Use APLOG_MARK to fill out file, line, and module_index * @note If a request_rec is available, use that with ap_log_rerror() * in preference to calling this function. Otherwise, if a conn_rec is * available, use that with ap_log_cerror() in preference to calling * this function. */ #ifdef DOXYGEN AP_DECLARE(void) ap_log_csdata(const char *file, int line, int module_index, int level, const conn_rec *c, const server_rec *s, const char *label, const void *data, apr_size_t len, unsigned int flags); #else #ifdef AP_HAVE_C99 /* need additional step to expand APLOG_MARK first */ #define ap_log_csdata(...) ap_log_csdata__(__VA_ARGS__) #define ap_log_csdata__(file, line, mi, level, c, s, ...) \ do { if (APLOG_CS_MODULE_IS_LEVEL(c, s, mi, level)) \ ap_log_csdata_(file, line, mi, level, c, s, __VA_ARGS__); \ } while(0) #else #define ap_log_cdata ap_log_cdata_ #endif AP_DECLARE(void) ap_log_csdata_(const char *file, int line, int module_index, int level, const conn_rec *c, const server_rec *s, const char *label, const void *data, apr_size_t len, unsigned int flags); #endif /** * Convert stderr to the error log * @param s The current server */ AP_DECLARE(void) ap_error_log2stderr(server_rec *s); /** * Log the command line used to start the server. * @param p The pool to use for logging * @param s The server_rec whose process's command line we want to log. * The command line is logged to that server's error log. */ AP_DECLARE(void) ap_log_command_line(apr_pool_t *p, server_rec *s); /** * Log common (various) MPM shared data at startup. * @param s The server_rec of the error log we want to log to. * Misc commonly logged data is logged to that server's error log. */ AP_DECLARE(void) ap_log_mpm_common(server_rec *s); /** * Log the current pid of the parent process * @param p The pool to use for processing * @param fname The name of the file to log to. If the filename is not * absolute then it is assumed to be relative to ServerRoot. */ AP_DECLARE(void) ap_log_pid(apr_pool_t *p, const char *fname); /** * Remove the pidfile. * @param p The pool to use for processing * @param fname The name of the pid file to remove. If the filename is not * absolute then it is assumed to be relative to ServerRoot. */ AP_DECLARE(void) ap_remove_pid(apr_pool_t *p, const char *fname); /** * Retrieve the pid from a pidfile. * @param p The pool to use for processing * @param filename The name of the file containing the pid. If the filename is not * absolute then it is assumed to be relative to ServerRoot. * @param mypid Pointer to pid_t (valid only if return APR_SUCCESS) */ AP_DECLARE(apr_status_t) ap_read_pid(apr_pool_t *p, const char *filename, pid_t *mypid); /** @see piped_log */ typedef struct piped_log piped_log; /** * Open the piped log process * @param p The pool to allocate out of * @param program The program to run in the logging process * @return The piped log structure * @note The log program is invoked as @p APR_PROGRAM_ENV, * @see ap_open_piped_log_ex to modify this behavior */ AP_DECLARE(piped_log *) ap_open_piped_log(apr_pool_t *p, const char *program); /** * Open the piped log process specifying the execution choice for program * @param p The pool to allocate out of * @param program The program to run in the logging process * @param cmdtype How to invoke program, e.g. APR_PROGRAM, APR_SHELLCMD_ENV, etc * @return The piped log structure */ AP_DECLARE(piped_log *) ap_open_piped_log_ex(apr_pool_t *p, const char *program, apr_cmdtype_e cmdtype); /** * Close the piped log and kill the logging process * @param pl The piped log structure */ AP_DECLARE(void) ap_close_piped_log(piped_log *pl); /** * A function to return the read side of the piped log pipe * @param pl The piped log structure * @return The native file descriptor */ AP_DECLARE(apr_file_t *) ap_piped_log_read_fd(piped_log *pl); /** * A function to return the write side of the piped log pipe * @param pl The piped log structure * @return The native file descriptor */ AP_DECLARE(apr_file_t *) ap_piped_log_write_fd(piped_log *pl); /** * hook method to generate unique id for connection or request * @ingroup hooks * @param c the conn_rec of the connections * @param r the request_req (may be NULL) * @param id the place where to store the unique id * @return OK or DECLINE */ AP_DECLARE_HOOK(int, generate_log_id, (const conn_rec *c, const request_rec *r, const char **id)) #ifdef __cplusplus } #endif #endif /* !APACHE_HTTP_LOG_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file ap_regkey.h * @brief APR-style Win32 Registry Manipulation */ #ifndef AP_REGKEY_H #define AP_REGKEY_H #if defined(WIN32) || defined(DOXYGEN) #include "apr.h" #include "apr_pools.h" #include "ap_config.h" /* Just for AP_DECLARE */ #ifdef __cplusplus extern "C" { #endif typedef struct ap_regkey_t ap_regkey_t; /* Used to recover AP_REGKEY_* constants */ AP_DECLARE(const ap_regkey_t *) ap_regkey_const(int i); /** * Win32 Only: Constants for ap_regkey_open() */ #define AP_REGKEY_CLASSES_ROOT ap_regkey_const(0) #define AP_REGKEY_CURRENT_CONFIG ap_regkey_const(1) #define AP_REGKEY_CURRENT_USER ap_regkey_const(2) #define AP_REGKEY_LOCAL_MACHINE ap_regkey_const(3) #define AP_REGKEY_USERS ap_regkey_const(4) #define AP_REGKEY_PERFORMANCE_DATA ap_regkey_const(5) #define AP_REGKEY_DYN_DATA ap_regkey_const(6) /** * Win32 Only: Flags for ap_regkey_value_set() */ #define AP_REGKEY_EXPAND 0x0001 /** * Win32 Only: Open the specified registry key. * @param newkey The opened registry key * @param parentkey The open registry key of the parent, or one of * <PRE> * AP_REGKEY_CLASSES_ROOT * AP_REGKEY_CURRENT_CONFIG * AP_REGKEY_CURRENT_USER * AP_REGKEY_LOCAL_MACHINE * AP_REGKEY_USERS * AP_REGKEY_PERFORMANCE_DATA * AP_REGKEY_DYN_DATA * </PRE> * @param keyname The path of the key relative to the parent key * @param flags Or'ed value of: * <PRE> * APR_READ open key for reading * APR_WRITE open key for writing * APR_CREATE create the key if it doesn't exist * APR_EXCL return error if APR_CREATE and key exists * </PRE> * @param pool The pool in which newkey is allocated */ AP_DECLARE(apr_status_t) ap_regkey_open(ap_regkey_t **newkey, const ap_regkey_t *parentkey, const char *keyname, apr_int32_t flags, apr_pool_t *pool); /** * Win32 Only: Close the registry key opened or created by ap_regkey_open(). * @param key The registry key to close */ AP_DECLARE(apr_status_t) ap_regkey_close(ap_regkey_t *key); /** * Win32 Only: Remove the given registry key. * @param parent The open registry key of the parent, or one of * <PRE> * AP_REGKEY_CLASSES_ROOT * AP_REGKEY_CURRENT_CONFIG * AP_REGKEY_CURRENT_USER * AP_REGKEY_LOCAL_MACHINE * AP_REGKEY_USERS * AP_REGKEY_PERFORMANCE_DATA * AP_REGKEY_DYN_DATA * </PRE> * @param keyname The path of the key relative to the parent key * @param pool The pool used for temp allocations * @remark ap_regkey_remove() is not recursive, although it removes * all values within the given keyname, it will not remove a key * containing subkeys. */ AP_DECLARE(apr_status_t) ap_regkey_remove(const ap_regkey_t *parent, const char *keyname, apr_pool_t *pool); /** * Win32 Only: Retrieve a registry value string from an open key. * @param result The string value retrieved * @param key The registry key to retrieve the value from * @param valuename The named value to retrieve (pass "" for the default) * @param pool The pool used to store the result * @remark There is no toggle to prevent environment variable expansion * if the registry value is set with AP_REG_EXPAND (REG_EXPAND_SZ), such * expansions are always performed. */ AP_DECLARE(apr_status_t) ap_regkey_value_get(char **result, ap_regkey_t *key, const char *valuename, apr_pool_t *pool); /** * Win32 Only: Store a registry value string into an open key. * @param key The registry key to store the value into * @param valuename The named value to store (pass "" for the default) * @param value The string to store for the named value * @param flags The option AP_REGKEY_EXPAND or 0, where AP_REGKEY_EXPAND * values will find all %foo% variables expanded from the environment. * @param pool The pool used for temp allocations */ AP_DECLARE(apr_status_t) ap_regkey_value_set(ap_regkey_t *key, const char *valuename, const char *value, apr_int32_t flags, apr_pool_t *pool); /** * Win32 Only: Retrieve a raw byte value from an open key. * @param result The raw bytes value retrieved * @param resultsize Pointer to a variable to store the number raw bytes retrieved * @param resulttype Pointer to a variable to store the registry type of the value retrieved * @param key The registry key to retrieve the value from * @param valuename The named value to retrieve (pass "" for the default) * @param pool The pool used to store the result */ AP_DECLARE(apr_status_t) ap_regkey_value_raw_get(void **result, apr_size_t *resultsize, apr_int32_t *resulttype, ap_regkey_t *key, const char *valuename, apr_pool_t *pool); /** * Win32 Only: Store a raw bytes value into an open key. * @param key The registry key to store the value into * @param valuename The named value to store (pass "" for the default) * @param value The bytes to store for the named value * @param valuesize The number of bytes for value * @param valuetype The * values will find all %foo% variables expanded from the environment. * @param pool The pool used for temp allocations */ AP_DECLARE(apr_status_t) ap_regkey_value_raw_set(ap_regkey_t *key, const char *valuename, const void *value, apr_size_t valuesize, apr_int32_t valuetype, apr_pool_t *pool); /** * Win32 Only: Retrieve a registry value string from an open key. * @param result The string elements retrieved from a REG_MULTI_SZ string array * @param key The registry key to retrieve the value from * @param valuename The named value to retrieve (pass "" for the default) * @param pool The pool used to store the result */ AP_DECLARE(apr_status_t) ap_regkey_value_array_get(apr_array_header_t **result, ap_regkey_t *key, const char *valuename, apr_pool_t *pool); /** * Win32 Only: Store a registry value string array into an open key. * @param key The registry key to store the value into * @param valuename The named value to store (pass "" for the default) * @param nelts The string elements to store in a REG_MULTI_SZ string array * @param elts The number of elements in the elts string array * @param pool The pool used for temp allocations */ AP_DECLARE(apr_status_t) ap_regkey_value_array_set(ap_regkey_t *key, const char *valuename, int nelts, const char * const * elts, apr_pool_t *pool); /** * Win32 Only: Remove a registry value from an open key. * @param key The registry key to remove the value from * @param valuename The named value to remove (pass "" for the default) * @param pool The pool used for temp allocations */ AP_DECLARE(apr_status_t) ap_regkey_value_remove(const ap_regkey_t *key, const char *valuename, apr_pool_t *pool); #ifdef __cplusplus } #endif #endif /* def WIN32 || def DOXYGEN */ #endif /* AP_REGKEY_H */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file http_main.h * @brief Command line options * * @defgroup APACHE_CORE_MAIN Command line options * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_HTTP_MAIN_H #define APACHE_HTTP_MAIN_H #include "httpd.h" #include "apr_optional.h" /** AP_SERVER_BASEARGS is the command argument list parsed by http_main.c * in apr_getopt() format. Use this for default'ing args that the MPM * can safely ignore and pass on from its rewrite_args() handler. */ #define AP_SERVER_BASEARGS "C:c:D:d:E:e:f:vVlLtTSMh?X" #ifdef __cplusplus extern "C" { #endif /** The name of the Apache executable */ AP_DECLARE_DATA extern const char *ap_server_argv0; /** The global server's ServerRoot */ AP_DECLARE_DATA extern const char *ap_server_root; /** The global server's DefaultRuntimeDir * This is not usable directly in the general case; use * ap_runtime_dir_relative() instead. */ AP_DECLARE_DATA extern const char *ap_runtime_dir; /** The global server's server_rec */ AP_DECLARE_DATA extern server_rec *ap_server_conf; /** global pool, for access prior to creation of server_rec */ AP_DECLARE_DATA extern apr_pool_t *ap_pglobal; /** state of the server (startup, exiting, ...) */ AP_DECLARE_DATA extern int ap_main_state; /** run mode (normal, config test, config dump, ...) */ AP_DECLARE_DATA extern int ap_run_mode; /** run mode (normal, config test, config dump, ...) */ AP_DECLARE_DATA extern int ap_config_generation; /* for -C, -c and -D switches */ /** An array of all -C directives. These are processed before the server's * config file */ AP_DECLARE_DATA extern apr_array_header_t *ap_server_pre_read_config; /** An array of all -c directives. These are processed after the server's * config file */ AP_DECLARE_DATA extern apr_array_header_t *ap_server_post_read_config; /** An array of all -D defines on the command line. This allows people to * effect the server based on command line options */ AP_DECLARE_DATA extern apr_array_header_t *ap_server_config_defines; /** Available integer for using the -T switch */ AP_DECLARE_DATA extern int ap_document_root_check; /** * An optional function to send signal to server on presence of '-k' * command line argument. * @param status The exit status after sending signal * @param pool Memory pool to allocate from */ APR_DECLARE_OPTIONAL_FN(int, ap_signal_server, (int *status, apr_pool_t *pool)); #ifdef __cplusplus } #endif #endif /* !APACHE_HTTP_MAIN_H */ /** @} */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @file http_vhost.h * @brief Virtual Host package * * @defgroup APACHE_CORE_VHOST Virtual Host Package * @ingroup APACHE_CORE * @{ */ #ifndef APACHE_HTTP_VHOST_H #define APACHE_HTTP_VHOST_H #ifdef __cplusplus extern "C" { #endif /** * called before any config is read * @param p Pool to allocate out of */ AP_DECLARE(void) ap_init_vhost_config(apr_pool_t *p); /** * called after the config has been read to compile the tables needed to do * the run-time vhost lookups * @param p The pool to allocate out of * @param main_server The start of the virtual host list */ AP_DECLARE(void) ap_fini_vhost_config(apr_pool_t *p, server_rec *main_server); /** * handle addresses in "<VirtualHost>" statement * @param p The pool to allocate out of * @param hostname The hostname in the VirtualHost statement * @param s The list of Virtual Hosts. */ const char *ap_parse_vhost_addrs(apr_pool_t *p, const char *hostname, server_rec *s); /** * handle NameVirtualHost directive * @param cmd Command Parameters structure * @param dummy NOT USED * @param arg a host of the form "<address>[:port]" */ AP_DECLARE_NONSTD(const char *)ap_set_name_virtual_host(cmd_parms *cmd, void *dummy, const char *arg); /** * Callback function for every Name Based Virtual Host. * @param baton Opaque user object * @param conn The current Connection * @param s The current Server * @see ap_vhost_iterate_given_conn * @return 0 on success, any non-zero return will stop the iteration. */ typedef int(*ap_vhost_iterate_conn_cb)(void* baton, conn_rec* conn, server_rec* s); /** * For every virtual host on this connection, call func_cb. * @param conn The current connection * @param func_cb Function called for every Name Based Virtual Host for this * connection. * @param baton Opaque object passed to func_cb. * @return The return value from func_cb. * @note If func_cb returns non-zero, the function will return at this point, * and not continue iterating the virtual hosts. */ AP_DECLARE(int) ap_vhost_iterate_given_conn(conn_rec *conn, ap_vhost_iterate_conn_cb func_cb, void* baton); /** * given an ip address only, give our best guess as to what vhost it is * @param conn The current connection */ AP_DECLARE(void) ap_update_vhost_given_ip(conn_rec *conn); /** * ap_update_vhost_given_ip is never enough, and this is always called after * the headers have been read. It may change r->server. * @param r The current request */ AP_DECLARE(void) ap_update_vhost_from_headers(request_rec *r); /** * Updates r->server with the best name-based virtual host match, within * the chain of matching virtual hosts selected by ap_update_vhost_given_ip. * @param r The current request * @param require_match 1 to return an HTTP error if the requested hostname is * not explicitly matched to a VirtualHost. * @return return HTTP_OK unless require_match was specified and the requested * hostname did not match any ServerName, ServerAlias, or VirtualHost * address-spec. */ AP_DECLARE(int) ap_update_vhost_from_headers_ex(request_rec *r, int require_match); /** * Match the host in the header with the hostname of the server for this * request. * @param r The current request * @param host The hostname in the headers * @param port The port from the headers * @return return 1 if the host:port matches any of the aliases of r->server, * return 0 otherwise */ AP_DECLARE(int) ap_matches_request_vhost(request_rec *r, const char *host, apr_port_t port); #ifdef __cplusplus } #endif #endif /* !APACHE_HTTP_VHOST_H */ /** @} */ /* public api for steve reid's public domain SHA-1 implementation */ /* this file is in the public domain */ #ifndef __SHA1_H #define __SHA1_H /* SHA1_DIGEST_SIZE must always be visible regardless of OpenSSL. */ #define SHA1_DIGEST_SIZE 20 /* * When OpenSSL headers are already present, their SHA1_Init/Update/Final * declarations take precedence. Redeclaring with incompatible signatures * causes compile errors in consumers (e.g. nginx) that include both * lscapi.h and OpenSSL. Use OpenSSL's SHA_CTX as an alias so internal * callers that hold a SHA1_CTX* still work. * * Guard macros differ by OpenSSL version: * OpenSSL 1.1.x -> HEADER_SHA_H * OpenSSL 3.x -> OPENSSL_SHA_H */ #if !defined(OPENSSL_SHA_H) && !defined(HEADER_SHA_H) #include <stdint.h> #ifdef __cplusplus extern "C" { #endif typedef struct { uint32_t state[5]; uint32_t count[2]; uint8_t buffer[64]; } SHA1_CTX; void SHA1_Init(SHA1_CTX* context); void SHA1_Update(SHA1_CTX* context, const uint8_t* data, const size_t len); void SHA1_Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE]); #ifdef __cplusplus } #endif #else /* OpenSSL sha.h already included */ /* openssl/sha.h is already loaded; avoid redeclaring SHA1_* with * incompatible types. Alias SHA1_CTX to OpenSSL's SHA_CTX so any * code holding a pointer to SHA1_CTX still compiles. */ #include <openssl/sha.h> typedef SHA_CTX SHA1_CTX; #endif /* !OPENSSL_SHA_H && !HEADER_SHA_H */ #endif /* __SHA1_H */ /* Functions to access FILE structure internals. Copyright (C) 2000-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* This header contains the same definitions as the header of the same name on Sun's Solaris OS. */ #ifndef _STDIO_EXT_H #define _STDIO_EXT_H 1 #include <stdio.h> enum { /* Query current state of the locking status. */ FSETLOCKING_QUERY = 0, #define FSETLOCKING_QUERY FSETLOCKING_QUERY /* The library protects all uses of the stream functions, except for uses of the *_unlocked functions, by calls equivalent to flockfile(). */ FSETLOCKING_INTERNAL, #define FSETLOCKING_INTERNAL FSETLOCKING_INTERNAL /* The user will take care of locking. */ FSETLOCKING_BYCALLER #define FSETLOCKING_BYCALLER FSETLOCKING_BYCALLER }; __BEGIN_DECLS /* Return the size of the buffer of FP in bytes currently in use by the given stream. */ extern size_t __fbufsize (FILE *__fp) __THROW; /* Return non-zero value iff the stream FP is opened readonly, or if the last operation on the stream was a read operation. */ extern int __freading (FILE *__fp) __THROW; /* Return non-zero value iff the stream FP is opened write-only or append-only, or if the last operation on the stream was a write operation. */ extern int __fwriting (FILE *__fp) __THROW; /* Return non-zero value iff stream FP is not opened write-only or append-only. */ extern int __freadable (FILE *__fp) __THROW; /* Return non-zero value iff stream FP is not opened read-only. */ extern int __fwritable (FILE *__fp) __THROW; /* Return non-zero value iff the stream FP is line-buffered. */ extern int __flbf (FILE *__fp) __THROW; /* Discard all pending buffered I/O on the stream FP. */ extern void __fpurge (FILE *__fp) __THROW; /* Return amount of output in bytes pending on a stream FP. */ extern size_t __fpending (FILE *__fp) __THROW; /* Flush all line-buffered files. */ extern void _flushlbf (void); /* Set locking status of stream FP to TYPE. */ extern int __fsetlocking (FILE *__fp, int __type) __THROW; __END_DECLS #endif /* stdio_ext.h */ /** ******************************************************************************* * @file json_object_iterator.h * * Copyright (c) 2009-2012 Hewlett-Packard Development Company, L.P. * * This library is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. * * @brief An API for iterating over json_type_object objects, * styled to be familiar to C++ programmers. * Unlike json_object_object_foreach() and * json_object_object_foreachC(), this avoids the need to expose * json-c internals like lh_entry. * * API attributes: <br> * * Thread-safe: NO<br> * * Reentrant: NO * ******************************************************************************* */ #ifndef JSON_OBJECT_ITERATOR_H #define JSON_OBJECT_ITERATOR_H #include "json_types.h" #include <stddef.h> #ifdef __cplusplus extern "C" { #endif /** * Forward declaration for the opaque iterator information. */ struct json_object_iter_info_; /** * The opaque iterator that references a name/value pair within * a JSON Object instance or the "end" iterator value. */ struct json_object_iterator { const void *opaque_; }; /** * forward declaration of json-c's JSON value instance structure */ struct json_object; /** * Initializes an iterator structure to a "default" value that * is convenient for initializing an iterator variable to a * default state (e.g., initialization list in a class' * constructor). * * @code * struct json_object_iterator iter = json_object_iter_init_default(); * MyClass() : iter_(json_object_iter_init_default()) * @endcode * * @note The initialized value doesn't reference any specific * pair, is considered an invalid iterator, and MUST NOT * be passed to any json-c API that expects a valid * iterator. * * @note User and internal code MUST NOT make any assumptions * about and dependencies on the value of the "default" * iterator value. * * @return json_object_iterator */ JSON_EXPORT struct json_object_iterator json_object_iter_init_default(void); /** Retrieves an iterator to the first pair of the JSON Object. * * @warning Any modification of the underlying pair invalidates all * iterators to that pair. * * @param obj JSON Object instance (MUST be of type json_object) * * @return json_object_iterator If the JSON Object has at * least one pair, on return, the iterator refers * to the first pair. If the JSON Object doesn't * have any pairs, the returned iterator is * equivalent to the "end" iterator for the same * JSON Object instance. * * @code * struct json_object_iterator it; * struct json_object_iterator itEnd; * struct json_object* obj; * * obj = json_tokener_parse("{'first':'george', 'age':100}"); * it = json_object_iter_begin(obj); * itEnd = json_object_iter_end(obj); * * while (!json_object_iter_equal(&it, &itEnd)) { * printf("%s\n", * json_object_iter_peek_name(&it)); * json_object_iter_next(&it); * } * * @endcode */ JSON_EXPORT struct json_object_iterator json_object_iter_begin(struct json_object *obj); /** Retrieves the iterator that represents the position beyond the * last pair of the given JSON Object instance. * * @warning Do NOT write code that assumes that the "end" * iterator value is NULL, even if it is so in a * particular instance of the implementation. * * @note The reason we do not (and MUST NOT) provide * "json_object_iter_is_end(json_object_iterator* iter)" * type of API is because it would limit the underlying * representation of name/value containment (or force us * to add additional, otherwise unnecessary, fields to * the iterator structure). The "end" iterator and the * equality test method, on the other hand, permit us to * cleanly abstract pretty much any reasonable underlying * representation without burdening the iterator * structure with unnecessary data. * * @note For performance reasons, memorize the "end" iterator prior * to any loop. * * @param obj JSON Object instance (MUST be of type json_object) * * @return json_object_iterator On return, the iterator refers * to the "end" of the Object instance's pairs * (i.e., NOT the last pair, but "beyond the last * pair" value) */ JSON_EXPORT struct json_object_iterator json_object_iter_end(const struct json_object *obj); /** Returns an iterator to the next pair, if any * * @warning Any modification of the underlying pair * invalidates all iterators to that pair. * * @param iter [IN/OUT] Pointer to iterator that references a * name/value pair; MUST be a valid, non-end iterator. * WARNING: bad things will happen if invalid or "end" * iterator is passed. Upon return will contain the * reference to the next pair if there is one; if there * are no more pairs, will contain the "end" iterator * value, which may be compared against the return value * of json_object_iter_end() for the same JSON Object * instance. */ JSON_EXPORT void json_object_iter_next(struct json_object_iterator *iter); /** Returns a const pointer to the name of the pair referenced * by the given iterator. * * @param iter pointer to iterator that references a name/value * pair; MUST be a valid, non-end iterator. * * @warning bad things will happen if an invalid or * "end" iterator is passed. * * @return const char* Pointer to the name of the referenced * name/value pair. The name memory belongs to the * name/value pair, will be freed when the pair is * deleted or modified, and MUST NOT be modified or * freed by the user. */ JSON_EXPORT const char *json_object_iter_peek_name(const struct json_object_iterator *iter); /** Returns a pointer to the json-c instance representing the * value of the referenced name/value pair, without altering * the instance's reference count. * * @param iter pointer to iterator that references a name/value * pair; MUST be a valid, non-end iterator. * * @warning bad things will happen if invalid or * "end" iterator is passed. * * @return struct json_object* Pointer to the json-c value * instance of the referenced name/value pair; the * value's reference count is not changed by this * function: if you plan to hold on to this json-c node, * take a look at json_object_get() and * json_object_put(). IMPORTANT: json-c API represents * the JSON Null value as a NULL json_object instance * pointer. */ JSON_EXPORT struct json_object * json_object_iter_peek_value(const struct json_object_iterator *iter); /** Tests two iterators for equality. Typically used to test * for end of iteration by comparing an iterator to the * corresponding "end" iterator (that was derived from the same * JSON Object instance). * * @note The reason we do not (and MUST NOT) provide * "json_object_iter_is_end(json_object_iterator* iter)" * type of API is because it would limit the underlying * representation of name/value containment (or force us * to add additional, otherwise unnecessary, fields to * the iterator structure). The equality test method, on * the other hand, permits us to cleanly abstract pretty * much any reasonable underlying representation. * * @param iter1 Pointer to first valid, non-NULL iterator * @param iter2 POinter to second valid, non-NULL iterator * * @warning if a NULL iterator pointer or an uninitialized * or invalid iterator, or iterators derived from * different JSON Object instances are passed, bad things * will happen! * * @return json_bool non-zero if iterators are equal (i.e., both * reference the same name/value pair or are both at * "end"); zero if they are not equal. */ JSON_EXPORT json_bool json_object_iter_equal(const struct json_object_iterator *iter1, const struct json_object_iterator *iter2); #ifdef __cplusplus } #endif #endif /* JSON_OBJECT_ITERATOR_H */ /* * $Id: json_tokener.h,v 1.10 2006/07/25 03:24:50 mclark Exp $ * * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. * Michael Clark <michael@metaparadigm.com> * * This library is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. * */ /** * @file * @brief Methods to parse an input string into a tree of json_object objects. */ #ifndef _json_tokener_h_ #define _json_tokener_h_ #include "json_object.h" #include <stddef.h> #ifdef __cplusplus extern "C" { #endif enum json_tokener_error { json_tokener_success, json_tokener_continue, json_tokener_error_depth, json_tokener_error_parse_eof, json_tokener_error_parse_unexpected, json_tokener_error_parse_null, json_tokener_error_parse_boolean, json_tokener_error_parse_number, json_tokener_error_parse_array, json_tokener_error_parse_object_key_name, json_tokener_error_parse_object_key_sep, json_tokener_error_parse_object_value_sep, json_tokener_error_parse_string, json_tokener_error_parse_comment, json_tokener_error_parse_utf8_string, json_tokener_error_size }; /** * @deprecated Don't use this outside of json_tokener.c, it will be made private in a future release. */ enum json_tokener_state { json_tokener_state_eatws, json_tokener_state_start, json_tokener_state_finish, json_tokener_state_null, json_tokener_state_comment_start, json_tokener_state_comment, json_tokener_state_comment_eol, json_tokener_state_comment_end, json_tokener_state_string, json_tokener_state_string_escape, json_tokener_state_escape_unicode, json_tokener_state_boolean, json_tokener_state_number, json_tokener_state_array, json_tokener_state_array_add, json_tokener_state_array_sep, json_tokener_state_object_field_start, json_tokener_state_object_field, json_tokener_state_object_field_end, json_tokener_state_object_value, json_tokener_state_object_value_add, json_tokener_state_object_sep, json_tokener_state_array_after_sep, json_tokener_state_object_field_start_after_sep, json_tokener_state_inf }; /** * @deprecated Don't use this outside of json_tokener.c, it will be made private in a future release. */ struct json_tokener_srec { enum json_tokener_state state, saved_state; struct json_object *obj; struct json_object *current; char *obj_field_name; }; #define JSON_TOKENER_DEFAULT_DEPTH 32 /** * Internal state of the json parser. * Do not access any fields of this structure directly. * Its definition is published due to historical limitations * in the json tokener API, and will be changed to be an opaque * type in the future. */ struct json_tokener { /** * @deprecated Do not access any of these fields outside of json_tokener.c */ char *str; struct printbuf *pb; int max_depth, depth, is_double, st_pos; /** * @deprecated See json_tokener_get_parse_end() instead. */ int char_offset; /** * @deprecated See json_tokener_get_error() instead. */ enum json_tokener_error err; unsigned int ucs_char; char quote_char; struct json_tokener_srec *stack; int flags; }; /** * Return the offset of the byte after the last byte parsed * relative to the start of the most recent string passed in * to json_tokener_parse_ex(). i.e. this is where parsing * would start again if the input contains another JSON object * after the currently parsed one. * * Note that when multiple parse calls are issued, this is *not* the * total number of characters parsed. * * In the past this would have been accessed as tok->char_offset. * * See json_tokener_parse_ex() for an example of how to use this. */ JSON_EXPORT size_t json_tokener_get_parse_end(struct json_tokener *tok); /** * @deprecated Unused in json-c code */ typedef struct json_tokener json_tokener; /** * Be strict when parsing JSON input. Use caution with * this flag as what is considered valid may become more * restrictive from one release to the next, causing your * code to fail on previously working input. * * This flag is not set by default. * * @see json_tokener_set_flags() */ #define JSON_TOKENER_STRICT 0x01 /** * Cause json_tokener_parse_ex() to validate that input is UTF8. * If this flag is specified and validation fails, then * json_tokener_get_error(tok) will return * json_tokener_error_parse_utf8_string * * This flag is not set by default. * * @see json_tokener_set_flags() */ #define JSON_TOKENER_VALIDATE_UTF8 0x10 /** * Given an error previously returned by json_tokener_get_error(), * return a human readable description of the error. * * @return a generic error message is returned if an invalid error value is provided. */ JSON_EXPORT const char *json_tokener_error_desc(enum json_tokener_error jerr); /** * Retrieve the error caused by the last call to json_tokener_parse_ex(), * or json_tokener_success if there is no error. * * When parsing a JSON string in pieces, if the tokener is in the middle * of parsing this will return json_tokener_continue. * * @see json_tokener_error_desc(). */ JSON_EXPORT enum json_tokener_error json_tokener_get_error(struct json_tokener *tok); JSON_EXPORT struct json_tokener *json_tokener_new(void); JSON_EXPORT struct json_tokener *json_tokener_new_ex(int depth); JSON_EXPORT void json_tokener_free(struct json_tokener *tok); JSON_EXPORT void json_tokener_reset(struct json_tokener *tok); JSON_EXPORT struct json_object *json_tokener_parse(const char *str); JSON_EXPORT struct json_object *json_tokener_parse_verbose(const char *str, enum json_tokener_error *error); /** * Set flags that control how parsing will be done. */ JSON_EXPORT void json_tokener_set_flags(struct json_tokener *tok, int flags); /** * Parse a string and return a non-NULL json_object if a valid JSON value * is found. The string does not need to be a JSON object or array; * it can also be a string, number or boolean value. * * A partial JSON string can be parsed. If the parsing is incomplete, * NULL will be returned and json_tokener_get_error() will return * json_tokener_continue. * json_tokener_parse_ex() can then be called with additional bytes in str * to continue the parsing. * * If json_tokener_parse_ex() returns NULL and the error is anything other than * json_tokener_continue, a fatal error has occurred and parsing must be * halted. Then, the tok object must not be reused until json_tokener_reset() is * called. * * When a valid JSON value is parsed, a non-NULL json_object will be * returned, with a reference count of one which belongs to the caller. Also, * json_tokener_get_error() will return json_tokener_success. Be sure to check * the type with json_object_is_type() or json_object_get_type() before using * the object. * * Trailing characters after the parsed value do not automatically cause an * error. It is up to the caller to decide whether to treat this as an * error or to handle the additional characters, perhaps by parsing another * json value starting from that point. * * Extra characters can be detected by comparing the value returned by * json_tokener_get_parse_end() against * the length of the last len parameter passed in. * * The tokener does \b not maintain an internal buffer so the caller is * responsible for calling json_tokener_parse_ex with an appropriate str * parameter starting with the extra characters. * * This interface is presently not 64-bit clean due to the int len argument * so the function limits the maximum string size to INT32_MAX (2GB). * If the function is called with len == -1 then strlen is called to check * the string length is less than INT32_MAX (2GB) * * Example: * @code json_object *jobj = NULL; const char *mystring = NULL; int stringlen = 0; enum json_tokener_error jerr; do { mystring = ... // get JSON string, e.g. read from file, etc... stringlen = strlen(mystring); jobj = json_tokener_parse_ex(tok, mystring, stringlen); } while ((jerr = json_tokener_get_error(tok)) == json_tokener_continue); if (jerr != json_tokener_success) { fprintf(stderr, "Error: %s\n", json_tokener_error_desc(jerr)); // Handle errors, as appropriate for your application. } if (json_tokener_get_parse_end(tok) < stringlen) { // Handle extra characters after parsed object as desired. // e.g. issue an error, parse another object from that point, etc... } // Success, use jobj here. @endcode * * @param tok a json_tokener previously allocated with json_tokener_new() * @param str an string with any valid JSON expression, or portion of. This does not need to be null terminated. * @param len the length of str */ JSON_EXPORT struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char *str, int len); #ifdef __cplusplus } #endif #endif /* * $Id: linkhash.h,v 1.6 2006/01/30 23:07:57 mclark Exp $ * * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. * Michael Clark <michael@metaparadigm.com> * Copyright (c) 2009 Hewlett-Packard Development Company, L.P. * * This library is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. * */ /** * @file * @brief Internal methods for working with json_type_object objects. Although * this is exposed by the json_object_get_object() function and within the * json_object_iter type, it is not recommended for direct use. */ #ifndef _linkhash_h_ #define _linkhash_h_ #include "json_object.h" #ifdef __cplusplus extern "C" { #endif /** * golden prime used in hash functions */ #define LH_PRIME 0x9e370001UL /** * The fraction of filled hash buckets until an insert will cause the table * to be resized. * This can range from just above 0 up to 1.0. */ #define LH_LOAD_FACTOR 0.66 /** * sentinel pointer value for empty slots */ #define LH_EMPTY (void *)-1 /** * sentinel pointer value for freed slots */ #define LH_FREED (void *)-2 /** * default string hash function */ #define JSON_C_STR_HASH_DFLT 0 /** * perl-like string hash function */ #define JSON_C_STR_HASH_PERLLIKE 1 /** * This function sets the hash function to be used for strings. * Must be one of the JSON_C_STR_HASH_* values. * @returns 0 - ok, -1 if parameter was invalid */ int json_global_set_string_hash(const int h); struct lh_entry; /** * callback function prototypes */ typedef void(lh_entry_free_fn)(struct lh_entry *e); /** * callback function prototypes */ typedef unsigned long(lh_hash_fn)(const void *k); /** * callback function prototypes */ typedef int(lh_equal_fn)(const void *k1, const void *k2); /** * An entry in the hash table */ struct lh_entry { /** * The key. Use lh_entry_k() instead of accessing this directly. */ const void *k; /** * A flag for users of linkhash to know whether or not they * need to free k. */ int k_is_constant; /** * The value. Use lh_entry_v() instead of accessing this directly. */ const void *v; /** * The next entry */ struct lh_entry *next; /** * The previous entry. */ struct lh_entry *prev; }; /** * The hash table structure. */ struct lh_table { /** * Size of our hash. */ int size; /** * Numbers of entries. */ int count; /** * The first entry. */ struct lh_entry *head; /** * The last entry. */ struct lh_entry *tail; struct lh_entry *table; /** * A pointer onto the function responsible for freeing an entry. */ lh_entry_free_fn *free_fn; lh_hash_fn *hash_fn; lh_equal_fn *equal_fn; }; typedef struct lh_table lh_table; /** * Convenience list iterator. */ #define lh_foreach(table, entry) for (entry = table->head; entry; entry = entry->next) /** * lh_foreach_safe allows calling of deletion routine while iterating. * * @param table a struct lh_table * to iterate over * @param entry a struct lh_entry * variable to hold each element * @param tmp a struct lh_entry * variable to hold a temporary pointer to the next element */ #define lh_foreach_safe(table, entry, tmp) \ for (entry = table->head; entry && ((tmp = entry->next) || 1); entry = tmp) /** * Create a new linkhash table. * * @param size initial table size. The table is automatically resized * although this incurs a performance penalty. * @param free_fn callback function used to free memory for entries * when lh_table_free or lh_table_delete is called. * If NULL is provided, then memory for keys and values * must be freed by the caller. * @param hash_fn function used to hash keys. 2 standard ones are defined: * lh_ptr_hash and lh_char_hash for hashing pointer values * and C strings respectively. * @param equal_fn comparison function to compare keys. 2 standard ones defined: * lh_ptr_hash and lh_char_hash for comparing pointer values * and C strings respectively. * @return On success, a pointer to the new linkhash table is returned. * On error, a null pointer is returned. */ extern struct lh_table *lh_table_new(int size, lh_entry_free_fn *free_fn, lh_hash_fn *hash_fn, lh_equal_fn *equal_fn); /** * Convenience function to create a new linkhash table with char keys. * * @param size initial table size. * @param free_fn callback function used to free memory for entries. * @return On success, a pointer to the new linkhash table is returned. * On error, a null pointer is returned. */ extern struct lh_table *lh_kchar_table_new(int size, lh_entry_free_fn *free_fn); /** * Convenience function to create a new linkhash table with ptr keys. * * @param size initial table size. * @param free_fn callback function used to free memory for entries. * @return On success, a pointer to the new linkhash table is returned. * On error, a null pointer is returned. */ extern struct lh_table *lh_kptr_table_new(int size, lh_entry_free_fn *free_fn); /** * Free a linkhash table. * * If a lh_entry_free_fn callback free function was provided then it is * called for all entries in the table. * * @param t table to free. */ extern void lh_table_free(struct lh_table *t); /** * Insert a record into the table. * * @param t the table to insert into. * @param k a pointer to the key to insert. * @param v a pointer to the value to insert. * * @return On success, <code>0</code> is returned. * On error, a negative value is returned. */ extern int lh_table_insert(struct lh_table *t, const void *k, const void *v); /** * Insert a record into the table using a precalculated key hash. * * The hash h, which should be calculated with lh_get_hash() on k, is provided by * the caller, to allow for optimization when multiple operations with the same * key are known to be needed. * * @param t the table to insert into. * @param k a pointer to the key to insert. * @param v a pointer to the value to insert. * @param h hash value of the key to insert * @param opts if set to JSON_C_OBJECT_KEY_IS_CONSTANT, sets lh_entry.k_is_constant * so t's free function knows to avoid freeing the key. */ extern int lh_table_insert_w_hash(struct lh_table *t, const void *k, const void *v, const unsigned long h, const unsigned opts); /** * Lookup a record in the table. * * @param t the table to lookup * @param k a pointer to the key to lookup * @return a pointer to the record structure of the value or NULL if it does not exist. */ extern struct lh_entry *lh_table_lookup_entry(struct lh_table *t, const void *k); /** * Lookup a record in the table using a precalculated key hash. * * The hash h, which should be calculated with lh_get_hash() on k, is provided by * the caller, to allow for optimization when multiple operations with the same * key are known to be needed. * * @param t the table to lookup * @param k a pointer to the key to lookup * @param h hash value of the key to lookup * @return a pointer to the record structure of the value or NULL if it does not exist. */ extern struct lh_entry *lh_table_lookup_entry_w_hash(struct lh_table *t, const void *k, const unsigned long h); /** * Lookup a record in the table. * * @param t the table to lookup * @param k a pointer to the key to lookup * @param v a pointer to a where to store the found value (set to NULL if it doesn't exist). * @return whether or not the key was found */ extern json_bool lh_table_lookup_ex(struct lh_table *t, const void *k, void **v); /** * Delete a record from the table. * * If a callback free function is provided then it is called for the * for the item being deleted. * @param t the table to delete from. * @param e a pointer to the entry to delete. * @return 0 if the item was deleted. * @return -1 if it was not found. */ extern int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e); /** * Delete a record from the table. * * If a callback free function is provided then it is called for the * for the item being deleted. * @param t the table to delete from. * @param k a pointer to the key to delete. * @return 0 if the item was deleted. * @return -1 if it was not found. */ extern int lh_table_delete(struct lh_table *t, const void *k); extern int lh_table_length(struct lh_table *t); /** * Resizes the specified table. * * @param t Pointer to table to resize. * @param new_size New table size. Must be positive. * * @return On success, <code>0</code> is returned. * On error, a negative value is returned. */ int lh_table_resize(struct lh_table *t, int new_size); /** * @deprecated Don't use this outside of linkhash.h: */ #if !defined(_MSC_VER) || (_MSC_VER > 1800) /* VS2010 can't handle inline funcs, so skip it there */ #define _LH_INLINE inline #else #define _LH_INLINE #endif /** * Calculate the hash of a key for a given table. * * This is an exension to support functions that need to calculate * the hash several times and allows them to do it just once and then pass * in the hash to all utility functions. Depending on use case, this can be a * considerable performance improvement. * @param t the table (used to obtain hash function) * @param k a pointer to the key to lookup * @return the key's hash */ static _LH_INLINE unsigned long lh_get_hash(const struct lh_table *t, const void *k) { return t->hash_fn(k); } #undef _LH_INLINE /** * @deprecated Don't use this outside of linkhash.h: */ #ifdef __UNCONST #define _LH_UNCONST(a) __UNCONST(a) #else #define _LH_UNCONST(a) ((void *)(uintptr_t)(const void *)(a)) #endif /** * Return a non-const version of lh_entry.k. * * lh_entry.k is const to indicate and help ensure that linkhash itself doesn't modify * it, but callers are allowed to do what they want with it. * See also lh_entry.k_is_constant */ #define lh_entry_k(entry) _LH_UNCONST((entry)->k) /** * Return a non-const version of lh_entry.v. * * v is const to indicate and help ensure that linkhash itself doesn't modify * it, but callers are allowed to do what they want with it. */ #define lh_entry_v(entry) _LH_UNCONST((entry)->v) #ifdef __cplusplus } #endif #endif /* * $Id: printbuf.h,v 1.4 2006/01/26 02:16:28 mclark Exp $ * * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. * Michael Clark <michael@metaparadigm.com> * * This library is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. * * * Copyright (c) 2008-2009 Yahoo! Inc. All rights reserved. * The copyrights to the contents of this file are licensed under the MIT License * (http://www.opensource.org/licenses/mit-license.php) */ /** * @file * @brief Internal string buffer handing. Unless you're writing a * json_object_to_json_string_fn implementation for use with * json_object_set_serializer() direct use of this is not * recommended. */ #ifndef _printbuf_h_ #define _printbuf_h_ #ifndef JSON_EXPORT #if defined(_MSC_VER) #define JSON_EXPORT __declspec(dllexport) #else #define JSON_EXPORT extern #endif #endif #ifdef __cplusplus extern "C" { #endif struct printbuf { char *buf; int bpos; int size; }; typedef struct printbuf printbuf; JSON_EXPORT struct printbuf *printbuf_new(void); /* As an optimization, printbuf_memappend_fast() is defined as a macro * that handles copying data if the buffer is large enough; otherwise * it invokes printbuf_memappend() which performs the heavy * lifting of realloc()ing the buffer and copying data. * * Your code should not use printbuf_memappend() directly unless it * checks the return code. Use printbuf_memappend_fast() instead. */ JSON_EXPORT int printbuf_memappend(struct printbuf *p, const char *buf, int size); #define printbuf_memappend_fast(p, bufptr, bufsize) \ do \ { \ if ((p->size - p->bpos) > bufsize) \ { \ memcpy(p->buf + p->bpos, (bufptr), bufsize); \ p->bpos += bufsize; \ p->buf[p->bpos] = '\0'; \ } \ else \ { \ printbuf_memappend(p, (bufptr), bufsize); \ } \ } while (0) #define printbuf_length(p) ((p)->bpos) /** * Results in a compile error if the argument is not a string literal. */ #define _printbuf_check_literal(mystr) ("" mystr) /** * This is an optimization wrapper around printbuf_memappend() that is useful * for appending string literals. Since the size of string constants is known * at compile time, using this macro can avoid a costly strlen() call. This is * especially helpful when a constant string must be appended many times. If * you got here because of a compilation error caused by passing something * other than a string literal, use printbuf_memappend_fast() in conjunction * with strlen(). * * See also: * printbuf_memappend_fast() * printbuf_memappend() * sprintbuf() */ #define printbuf_strappend(pb, str) \ printbuf_memappend((pb), _printbuf_check_literal(str), sizeof(str) - 1) /** * Set len bytes of the buffer to charvalue, starting at offset offset. * Similar to calling memset(x, charvalue, len); * * The memory allocated for the buffer is extended as necessary. * * If offset is -1, this starts at the end of the current data in the buffer. */ JSON_EXPORT int printbuf_memset(struct printbuf *pb, int offset, int charvalue, int len); /** * Formatted print to printbuf. * * This function is the most expensive of the available functions for appending * string data to a printbuf and should be used only where convenience is more * important than speed. Avoid using this function in high performance code or * tight loops; in these scenarios, consider using snprintf() with a static * buffer in conjunction with one of the printbuf_*append() functions. * * See also: * printbuf_memappend_fast() * printbuf_memappend() * printbuf_strappend() */ JSON_EXPORT int sprintbuf(struct printbuf *p, const char *msg, ...); JSON_EXPORT void printbuf_reset(struct printbuf *p); JSON_EXPORT void printbuf_free(struct printbuf *p); #ifdef __cplusplus } #endif #endif /* * Copyright (c) 2012,2017 Eric Haszlakiewicz * * This library is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. */ /** * @file * @brief Methods for retrieving the json-c version. */ #ifndef _json_c_version_h_ #define _json_c_version_h_ #define JSON_C_MAJOR_VERSION 0 #define JSON_C_MINOR_VERSION 14 #define JSON_C_MICRO_VERSION 0 #define JSON_C_VERSION_NUM \ ((JSON_C_MAJOR_VERSION << 16) | (JSON_C_MINOR_VERSION << 8) | JSON_C_MICRO_VERSION) #define JSON_C_VERSION "0.14" #ifndef JSON_EXPORT #if defined(_MSC_VER) #define JSON_EXPORT __declspec(dllexport) #else #define JSON_EXPORT extern #endif #endif /** * @see JSON_C_VERSION * @return the version of the json-c library as a string */ JSON_EXPORT const char *json_c_version(void); /* Returns JSON_C_VERSION */ /** * The json-c version encoded into an int, with the low order 8 bits * being the micro version, the next higher 8 bits being the minor version * and the next higher 8 bits being the major version. * For example, 7.12.99 would be 0x00070B63. * * @see JSON_C_VERSION_NUM * @return the version of the json-c library as an int */ JSON_EXPORT int json_c_version_num(void); /* Returns JSON_C_VERSION_NUM */ #endif /* * $Id: json.h,v 1.6 2006/01/26 02:16:28 mclark Exp $ * * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. * Michael Clark <michael@metaparadigm.com> * Copyright (c) 2009 Hewlett-Packard Development Company, L.P. * * This library is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. * */ /** * @file * @brief A convenience header that may be included instead of other individual ones. */ #ifndef _json_h_ #define _json_h_ #ifdef __cplusplus extern "C" { #endif #include "arraylist.h" #include "debug.h" #include "json_c_version.h" #include "json_object.h" #include "json_object_iterator.h" #include "json_pointer.h" #include "json_tokener.h" #include "json_util.h" #include "linkhash.h" #ifdef __cplusplus } #endif #endif /* * $Id: debug.h,v 1.5 2006/01/30 23:07:57 mclark Exp $ * * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. * Michael Clark <michael@metaparadigm.com> * Copyright (c) 2009 Hewlett-Packard Development Company, L.P. * * This library is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. * */ /** * @file * @brief Do not use, json-c internal, may be changed or removed at any time. */ #ifndef _DEBUG_H_ #define _DEBUG_H_ #include <stdlib.h> #ifdef __cplusplus extern "C" { #endif #ifndef JSON_EXPORT #if defined(_MSC_VER) #define JSON_EXPORT __declspec(dllexport) #else #define JSON_EXPORT extern #endif #endif JSON_EXPORT void mc_set_debug(int debug); JSON_EXPORT int mc_get_debug(void); JSON_EXPORT void mc_set_syslog(int syslog); JSON_EXPORT void mc_debug(const char *msg, ...); JSON_EXPORT void mc_error(const char *msg, ...); JSON_EXPORT void mc_info(const char *msg, ...); #ifndef __STRING #define __STRING(x) #x #endif #ifndef PARSER_BROKEN_FIXED #define JASSERT(cond) \ do \ { \ } while (0) #else #define JASSERT(cond) \ do \ { \ if (!(cond)) \ { \ mc_error("cjson assert failure %s:%d : cond \"" __STRING(cond) "failed\n", \ __FILE__, __LINE__); \ *(int *)0 = 1; \ abort(); \ } \ } while (0) #endif #define MC_ERROR(x, ...) mc_error(x, ##__VA_ARGS__) #ifdef MC_MAINTAINER_MODE #define MC_SET_DEBUG(x) mc_set_debug(x) #define MC_GET_DEBUG() mc_get_debug() #define MC_SET_SYSLOG(x) mc_set_syslog(x) #define MC_DEBUG(x, ...) mc_debug(x, ##__VA_ARGS__) #define MC_INFO(x, ...) mc_info(x, ##__VA_ARGS__) #else #define MC_SET_DEBUG(x) \ if (0) \ mc_set_debug(x) #define MC_GET_DEBUG() (0) #define MC_SET_SYSLOG(x) \ if (0) \ mc_set_syslog(x) #define MC_DEBUG(x, ...) \ if (0) \ mc_debug(x, ##__VA_ARGS__) #define MC_INFO(x, ...) \ if (0) \ mc_info(x, ##__VA_ARGS__) #endif #ifdef __cplusplus } #endif #endif /* * $Id: json_util.h,v 1.4 2006/01/30 23:07:57 mclark Exp $ * * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. * Michael Clark <michael@metaparadigm.com> * * This library is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. * */ /** * @file * @brief Miscllaneous utility functions and macros. */ #ifndef _json_util_h_ #define _json_util_h_ #include "json_object.h" #ifndef json_min #define json_min(a, b) ((a) < (b) ? (a) : (b)) #endif #ifndef json_max #define json_max(a, b) ((a) > (b) ? (a) : (b)) #endif #ifdef __cplusplus extern "C" { #endif #define JSON_FILE_BUF_SIZE 4096 /* utility functions */ /** * Read the full contents of the given file, then convert it to a * json_object using json_tokener_parse(). * * Returns NULL on failure. See json_util_get_last_err() for details. */ JSON_EXPORT struct json_object *json_object_from_file(const char *filename); /** * Create a JSON object from already opened file descriptor. * * This function can be helpful, when you opened the file already, * e.g. when you have a temp file. * Note, that the fd must be readable at the actual position, i.e. * use lseek(fd, 0, SEEK_SET) before. * * The depth argument specifies the maximum object depth to pass to * json_tokener_new_ex(). When depth == -1, JSON_TOKENER_DEFAULT_DEPTH * is used instead. * * Returns NULL on failure. See json_util_get_last_err() for details. */ JSON_EXPORT struct json_object *json_object_from_fd_ex(int fd, int depth); /** * Create a JSON object from an already opened file descriptor, using * the default maximum object depth. (JSON_TOKENER_DEFAULT_DEPTH) * * See json_object_from_fd_ex() for details. */ JSON_EXPORT struct json_object *json_object_from_fd(int fd); /** * Equivalent to: * json_object_to_file_ext(filename, obj, JSON_C_TO_STRING_PLAIN); * * Returns -1 if something fails. See json_util_get_last_err() for details. */ JSON_EXPORT int json_object_to_file(const char *filename, struct json_object *obj); /** * Open and truncate the given file, creating it if necessary, then * convert the json_object to a string and write it to the file. * * Returns -1 if something fails. See json_util_get_last_err() for details. */ JSON_EXPORT int json_object_to_file_ext(const char *filename, struct json_object *obj, int flags); /** * Convert the json_object to a string and write it to the file descriptor. * Handles partial writes and will keep writing until done, or an error * occurs. * * @param fd an open, writable file descriptor to write to * @param obj the object to serializer and write * @param flags flags to pass to json_object_to_json_string_ext() * @return -1 if something fails. See json_util_get_last_err() for details. */ JSON_EXPORT int json_object_to_fd(int fd, struct json_object *obj, int flags); /** * Return the last error from various json-c functions, including: * json_object_to_file{,_ext}, json_object_to_fd() or * json_object_from_{file,fd}, or NULL if there is none. */ JSON_EXPORT const char *json_util_get_last_err(void); /* these parsing helpers return zero on success */ JSON_EXPORT int json_parse_int64(const char *buf, int64_t *retval); JSON_EXPORT int json_parse_uint64(const char *buf, uint64_t *retval); JSON_EXPORT int json_parse_double(const char *buf, double *retval); /** * Return a string describing the type of the object. * e.g. "int", or "object", etc... */ JSON_EXPORT const char *json_type_to_name(enum json_type o_type); #ifdef __cplusplus } #endif #endif /* * $Id: arraylist.h,v 1.4 2006/01/26 02:16:28 mclark Exp $ * * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. * Michael Clark <michael@metaparadigm.com> * * This library is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. * */ /** * @file * @brief Internal methods for working with json_type_array objects. * Although this is exposed by the json_object_get_array() method, * it is not recommended for direct use. */ #ifndef _arraylist_h_ #define _arraylist_h_ #ifdef __cplusplus extern "C" { #endif #include <stddef.h> #define ARRAY_LIST_DEFAULT_SIZE 32 typedef void(array_list_free_fn)(void *data); struct array_list { void **array; size_t length; size_t size; array_list_free_fn *free_fn; }; typedef struct array_list array_list; extern struct array_list *array_list_new(array_list_free_fn *free_fn); extern void array_list_free(struct array_list *al); extern void *array_list_get_idx(struct array_list *al, size_t i); extern int array_list_put_idx(struct array_list *al, size_t i, void *data); extern int array_list_add(struct array_list *al, void *data); extern size_t array_list_length(struct array_list *al); extern void array_list_sort(struct array_list *arr, int (*compar)(const void *, const void *)); extern void *array_list_bsearch(const void **key, struct array_list *arr, int (*compar)(const void *, const void *)); extern int array_list_del_idx(struct array_list *arr, size_t idx, size_t count); #ifdef __cplusplus } #endif #endif /** * @file * @brief Do not use, json-c internal, may be changed or removed at any time. */ #ifndef _json_inttypes_h_ #define _json_inttypes_h_ #include "json_config.h" #ifdef JSON_C_HAVE_INTTYPES_H /* inttypes.h includes stdint.h */ #include <inttypes.h> #else #include <stdint.h> #define PRId64 "I64d" #define SCNd64 "I64d" #define PRIu64 "I64u" #endif #endif /* * $Id: json_object.h,v 1.12 2006/01/30 23:07:57 mclark Exp $ * * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd. * Michael Clark <michael@metaparadigm.com> * Copyright (c) 2009 Hewlett-Packard Development Company, L.P. * * This library is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. * */ /** * @file * @brief Core json-c API. Start here, or with json_tokener.h */ #ifndef _json_object_h_ #define _json_object_h_ #ifdef __GNUC__ #define THIS_FUNCTION_IS_DEPRECATED(func) func __attribute__((deprecated)) #elif defined(_MSC_VER) #define THIS_FUNCTION_IS_DEPRECATED(func) __declspec(deprecated) func #elif defined(__clang__) #define THIS_FUNCTION_IS_DEPRECATED(func) func __deprecated #else #define THIS_FUNCTION_IS_DEPRECATED(func) func #endif #ifdef __GNUC__ #define JSON_C_CONST_FUNCTION(func) func __attribute__((const)) #else #define JSON_C_CONST_FUNCTION(func) func #endif #include "json_inttypes.h" #include "json_types.h" #include "printbuf.h" #include <stddef.h> #ifdef __cplusplus extern "C" { #endif #define JSON_OBJECT_DEF_HASH_ENTRIES 16 /** * A flag for the json_object_to_json_string_ext() and * json_object_to_file_ext() functions which causes the output * to have no extra whitespace or formatting applied. */ #define JSON_C_TO_STRING_PLAIN 0 /** * A flag for the json_object_to_json_string_ext() and * json_object_to_file_ext() functions which causes the output to have * minimal whitespace inserted to make things slightly more readable. */ #define JSON_C_TO_STRING_SPACED (1 << 0) /** * A flag for the json_object_to_json_string_ext() and * json_object_to_file_ext() functions which causes * the output to be formatted. * * See the "Two Space Tab" option at http://jsonformatter.curiousconcept.com/ * for an example of the format. */ #define JSON_C_TO_STRING_PRETTY (1 << 1) /** * A flag for the json_object_to_json_string_ext() and * json_object_to_file_ext() functions which causes * the output to be formatted. * * Instead of a "Two Space Tab" this gives a single tab character. */ #define JSON_C_TO_STRING_PRETTY_TAB (1 << 3) /** * A flag to drop trailing zero for float values */ #define JSON_C_TO_STRING_NOZERO (1 << 2) /** * Don't escape forward slashes. */ #define JSON_C_TO_STRING_NOSLASHESCAPE (1 << 4) /** * A flag for the json_object_object_add_ex function which * causes the value to be added without a check if it already exists. * Note: it is the responsibility of the caller to ensure that no * key is added multiple times. If this is done, results are * unpredictable. While this option is somewhat dangerous, it * permits potentially large performance savings in code that * knows for sure the key values are unique (e.g. because the * code adds a well-known set of constant key values). */ #define JSON_C_OBJECT_ADD_KEY_IS_NEW (1 << 1) /** * A flag for the json_object_object_add_ex function which * flags the key as being constant memory. This means that * the key will NOT be copied via strdup(), resulting in a * potentially huge performance win (malloc, strdup and * free are usually performance hogs). It is acceptable to * use this flag for keys in non-constant memory blocks if * the caller ensure that the memory holding the key lives * longer than the corresponding json object. However, this * is somewhat dangerous and should only be done if really * justified. * The general use-case for this flag is cases where the * key is given as a real constant value in the function * call, e.g. as in * json_object_object_add_ex(obj, "ip", json, * JSON_C_OBJECT_KEY_IS_CONSTANT); */ #define JSON_C_OBJECT_KEY_IS_CONSTANT (1 << 2) /** * Set the global value of an option, which will apply to all * current and future threads that have not set a thread-local value. * * @see json_c_set_serialization_double_format */ #define JSON_C_OPTION_GLOBAL (0) /** * Set a thread-local value of an option, overriding the global value. * This will fail if json-c is not compiled with threading enabled, and * with the __thread specifier (or equivalent) available. * * @see json_c_set_serialization_double_format */ #define JSON_C_OPTION_THREAD (1) /* reference counting functions */ /** * Increment the reference count of json_object, thereby grabbing shared * ownership of obj. * * @param obj the json_object instance */ JSON_EXPORT struct json_object *json_object_get(struct json_object *obj); /** * Decrement the reference count of json_object and free if it reaches zero. * You must have ownership of obj prior to doing this or you will cause an * imbalance in the reference count. * An obj of NULL may be passed; in that case this call is a no-op. * * @param obj the json_object instance * @returns 1 if the object was freed. */ JSON_EXPORT int json_object_put(struct json_object *obj); /** * Check if the json_object is of a given type * @param obj the json_object instance * @param type one of: json_type_null (i.e. obj == NULL), json_type_boolean, json_type_double, json_type_int, json_type_object, json_type_array, json_type_string */ JSON_EXPORT int json_object_is_type(const struct json_object *obj, enum json_type type); /** * Get the type of the json_object. See also json_type_to_name() to turn this * into a string suitable, for instance, for logging. * * @param obj the json_object instance * @returns type being one of: json_type_null (i.e. obj == NULL), json_type_boolean, json_type_double, json_type_int, json_type_object, json_type_array, json_type_string */ JSON_EXPORT enum json_type json_object_get_type(const struct json_object *obj); /** Stringify object to json format. * Equivalent to json_object_to_json_string_ext(obj, JSON_C_TO_STRING_SPACED) * The pointer you get is an internal of your json object. You don't * have to free it, later use of json_object_put() should be sufficient. * If you can not ensure there's no concurrent access to *obj use * strdup(). * @param obj the json_object instance * @returns a string in JSON format */ JSON_EXPORT const char *json_object_to_json_string(struct json_object *obj); /** Stringify object to json format * @see json_object_to_json_string() for details on how to free string. * @param obj the json_object instance * @param flags formatting options, see JSON_C_TO_STRING_PRETTY and other constants * @returns a string in JSON format */ JSON_EXPORT const char *json_object_to_json_string_ext(struct json_object *obj, int flags); /** Stringify object to json format * @see json_object_to_json_string() for details on how to free string. * @param obj the json_object instance * @param flags formatting options, see JSON_C_TO_STRING_PRETTY and other constants * @param length a pointer where, if not NULL, the length (without null) is stored * @returns a string in JSON format and the length if not NULL */ JSON_EXPORT const char *json_object_to_json_string_length(struct json_object *obj, int flags, size_t *length); /** * Returns the userdata set by json_object_set_userdata() or * json_object_set_serializer() * * @param jso the object to return the userdata for */ JSON_EXPORT void *json_object_get_userdata(json_object *jso); /** * Set an opaque userdata value for an object * * The userdata can be retrieved using json_object_get_userdata(). * * If custom userdata is already set on this object, any existing user_delete * function is called before the new one is set. * * The user_delete parameter is optional and may be passed as NULL, even if * the userdata parameter is non-NULL. It will be called just before the * json_object is deleted, after it's reference count goes to zero * (see json_object_put()). * If this is not provided, it is up to the caller to free the userdata at * an appropriate time. (i.e. after the json_object is deleted) * * Note: Objects created by parsing strings may have custom serializers set * which expect the userdata to contain specific data (due to use of * json_object_new_double_s()). In this case, json_object_set_serialiser() with * NULL as to_string_func should be used instead to set the userdata and reset * the serializer to its default value. * * @param jso the object to set the userdata for * @param userdata an optional opaque cookie * @param user_delete an optional function from freeing userdata */ JSON_EXPORT void json_object_set_userdata(json_object *jso, void *userdata, json_object_delete_fn *user_delete); /** * Set a custom serialization function to be used when this particular object * is converted to a string by json_object_to_json_string. * * If custom userdata is already set on this object, any existing user_delete * function is called before the new one is set. * * If to_string_func is NULL the default behaviour is reset (but the userdata * and user_delete fields are still set). * * The userdata parameter is optional and may be passed as NULL. It can be used * to provide additional data for to_string_func to use. This parameter may * be NULL even if user_delete is non-NULL. * * The user_delete parameter is optional and may be passed as NULL, even if * the userdata parameter is non-NULL. It will be called just before the * json_object is deleted, after it's reference count goes to zero * (see json_object_put()). * If this is not provided, it is up to the caller to free the userdata at * an appropriate time. (i.e. after the json_object is deleted) * * Note that the userdata is the same as set by json_object_set_userdata(), so * care must be taken not to overwrite the value when both a custom serializer * and json_object_set_userdata() are used. * * @param jso the object to customize * @param to_string_func the custom serialization function * @param userdata an optional opaque cookie * @param user_delete an optional function from freeing userdata */ JSON_EXPORT void json_object_set_serializer(json_object *jso, json_object_to_json_string_fn *to_string_func, void *userdata, json_object_delete_fn *user_delete); #ifdef __clang__ /* * Clang doesn't pay attention to the parameters defined in the * function typedefs used here, so turn off spurious doc warnings. * { */ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdocumentation" #endif /** * Simply call free on the userdata pointer. * Can be used with json_object_set_serializer(). * * @param jso unused * @param userdata the pointer that is passed to free(). */ JSON_EXPORT json_object_delete_fn json_object_free_userdata; /** * Copy the jso->_userdata string over to pb as-is. * Can be used with json_object_set_serializer(). * * @param jso The object whose _userdata is used. * @param pb The destination buffer. * @param level Ignored. * @param flags Ignored. */ JSON_EXPORT json_object_to_json_string_fn json_object_userdata_to_json_string; #ifdef __clang__ /* } */ #pragma clang diagnostic pop #endif /* object type methods */ /** Create a new empty object with a reference count of 1. The caller of * this object initially has sole ownership. Remember, when using * json_object_object_add or json_object_array_put_idx, ownership will * transfer to the object/array. Call json_object_get if you want to maintain * shared ownership or also add this object as a child of multiple objects or * arrays. Any ownerships you acquired but did not transfer must be released * through json_object_put. * * @returns a json_object of type json_type_object */ JSON_EXPORT struct json_object *json_object_new_object(void); /** Get the hashtable of a json_object of type json_type_object * @param obj the json_object instance * @returns a linkhash */ JSON_EXPORT struct lh_table *json_object_get_object(const struct json_object *obj); /** Get the size of an object in terms of the number of fields it has. * @param obj the json_object whose length to return */ JSON_EXPORT int json_object_object_length(const struct json_object *obj); /** Get the sizeof (struct json_object). * @returns a size_t with the sizeof (struct json_object) */ JSON_C_CONST_FUNCTION(JSON_EXPORT size_t json_c_object_sizeof(void)); /** Add an object field to a json_object of type json_type_object * * The reference count will *not* be incremented. This is to make adding * fields to objects in code more compact. If you want to retain a reference * to an added object, independent of the lifetime of obj, you must wrap the * passed object with json_object_get. * * Upon calling this, the ownership of val transfers to obj. Thus you must * make sure that you do in fact have ownership over this object. For instance, * json_object_new_object will give you ownership until you transfer it, * whereas json_object_object_get does not. * * @param obj the json_object instance * @param key the object field name (a private copy will be duplicated) * @param val a json_object or NULL member to associate with the given field * * @return On success, <code>0</code> is returned. * On error, a negative value is returned. */ JSON_EXPORT int json_object_object_add(struct json_object *obj, const char *key, struct json_object *val); /** Add an object field to a json_object of type json_type_object * * The semantics are identical to json_object_object_add, except that an * additional flag fields gives you more control over some detail aspects * of processing. See the description of JSON_C_OBJECT_ADD_* flags for more * details. * * @param obj the json_object instance * @param key the object field name (a private copy will be duplicated) * @param val a json_object or NULL member to associate with the given field * @param opts process-modifying options. To specify multiple options, use * arithmetic or (OPT1|OPT2) */ JSON_EXPORT int json_object_object_add_ex(struct json_object *obj, const char *const key, struct json_object *const val, const unsigned opts); /** Get the json_object associate with a given object field. * Deprecated/discouraged: used json_object_object_get_ex instead. * * This returns NULL if the field is found but its value is null, or if * the field is not found, or if obj is not a json_type_object. If you * need to distinguish between these cases, use json_object_object_get_ex(). * * *No* reference counts will be changed. There is no need to manually adjust * reference counts through the json_object_put/json_object_get methods unless * you need to have the child (value) reference maintain a different lifetime * than the owning parent (obj). Ownership of the returned value is retained * by obj (do not do json_object_put unless you have done a json_object_get). * If you delete the value from obj (json_object_object_del) and wish to access * the returned reference afterwards, make sure you have first gotten shared * ownership through json_object_get (& don't forget to do a json_object_put * or transfer ownership to prevent a memory leak). * * @param obj the json_object instance * @param key the object field name * @returns the json_object associated with the given field name */ JSON_EXPORT struct json_object *json_object_object_get(const struct json_object *obj, const char *key); /** Get the json_object associated with a given object field. * * This returns true if the key is found, false in all other cases (including * if obj isn't a json_type_object). * * *No* reference counts will be changed. There is no need to manually adjust * reference counts through the json_object_put/json_object_get methods unless * you need to have the child (value) reference maintain a different lifetime * than the owning parent (obj). Ownership of value is retained by obj. * * @param obj the json_object instance * @param key the object field name * @param value a pointer where to store a reference to the json_object * associated with the given field name. * * It is safe to pass a NULL value. * @returns whether or not the key exists */ JSON_EXPORT json_bool json_object_object_get_ex(const struct json_object *obj, const char *key, struct json_object **value); /** Delete the given json_object field * * The reference count will be decremented for the deleted object. If there * are no more owners of the value represented by this key, then the value is * freed. Otherwise, the reference to the value will remain in memory. * * @param obj the json_object instance * @param key the object field name */ JSON_EXPORT void json_object_object_del(struct json_object *obj, const char *key); /** * Iterate through all keys and values of an object. * * Adding keys to the object while iterating is NOT allowed. * * Deleting an existing key, or replacing an existing key with a * new value IS allowed. * * @param obj the json_object instance * @param key the local name for the char* key variable defined in the body * @param val the local name for the json_object* object variable defined in * the body */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) && __STDC_VERSION__ >= 199901L #define json_object_object_foreach(obj, key, val) \ char *key = NULL; \ struct json_object *val __attribute__((__unused__)) = NULL; \ for (struct lh_entry *entry##key = json_object_get_object(obj)->head, \ *entry_next##key = NULL; \ ({ \ if (entry##key) \ { \ key = (char *)lh_entry_k(entry##key); \ val = (struct json_object *)lh_entry_v(entry##key); \ entry_next##key = entry##key->next; \ }; \ entry##key; \ }); \ entry##key = entry_next##key) #else /* ANSI C or MSC */ #define json_object_object_foreach(obj, key, val) \ char *key = NULL; \ struct json_object *val = NULL; \ struct lh_entry *entry##key; \ struct lh_entry *entry_next##key = NULL; \ for (entry##key = json_object_get_object(obj)->head; \ (entry##key ? (key = (char *)lh_entry_k(entry##key), \ val = (struct json_object *)lh_entry_v(entry##key), \ entry_next##key = entry##key->next, entry##key) \ : 0); \ entry##key = entry_next##key) #endif /* defined(__GNUC__) && !defined(__STRICT_ANSI__) && __STDC_VERSION__ >= 199901L */ /** Iterate through all keys and values of an object (ANSI C Safe) * @param obj the json_object instance * @param iter the object iterator, use type json_object_iter */ #define json_object_object_foreachC(obj, iter) \ for (iter.entry = json_object_get_object(obj)->head; \ (iter.entry ? (iter.key = (char *)lh_entry_k(iter.entry), \ iter.val = (struct json_object *)lh_entry_v(iter.entry), iter.entry) \ : 0); \ iter.entry = iter.entry->next) /* Array type methods */ /** Create a new empty json_object of type json_type_array * @returns a json_object of type json_type_array */ JSON_EXPORT struct json_object *json_object_new_array(void); /** Get the arraylist of a json_object of type json_type_array * @param obj the json_object instance * @returns an arraylist */ JSON_EXPORT struct array_list *json_object_get_array(const struct json_object *obj); /** Get the length of a json_object of type json_type_array * @param obj the json_object instance * @returns an int */ JSON_EXPORT size_t json_object_array_length(const struct json_object *obj); /** Sorts the elements of jso of type json_type_array * * Pointers to the json_object pointers will be passed as the two arguments * to sort_fn * * @param jso the json_object instance * @param sort_fn a sorting function */ JSON_EXPORT void json_object_array_sort(struct json_object *jso, int (*sort_fn)(const void *, const void *)); /** Binary search a sorted array for a specified key object. * * It depends on your compare function what's sufficient as a key. * Usually you create some dummy object with the parameter compared in * it, to identify the right item you're actually looking for. * * @see json_object_array_sort() for hints on the compare function. * * @param key a dummy json_object with the right key * @param jso the array object we're searching * @param sort_fn the sort/compare function * * @return the wanted json_object instance */ JSON_EXPORT struct json_object * json_object_array_bsearch(const struct json_object *key, const struct json_object *jso, int (*sort_fn)(const void *, const void *)); /** Add an element to the end of a json_object of type json_type_array * * The reference count will *not* be incremented. This is to make adding * fields to objects in code more compact. If you want to retain a reference * to an added object you must wrap the passed object with json_object_get * * @param obj the json_object instance * @param val the json_object to be added */ JSON_EXPORT int json_object_array_add(struct json_object *obj, struct json_object *val); /** Insert or replace an element at a specified index in an array (a json_object of type json_type_array) * * The reference count will *not* be incremented. This is to make adding * fields to objects in code more compact. If you want to retain a reference * to an added object you must wrap the passed object with json_object_get * * The reference count of a replaced object will be decremented. * * The array size will be automatically be expanded to the size of the * index if the index is larger than the current size. * * @param obj the json_object instance * @param idx the index to insert the element at * @param val the json_object to be added */ JSON_EXPORT int json_object_array_put_idx(struct json_object *obj, size_t idx, struct json_object *val); /** Get the element at specified index of the array (a json_object of type json_type_array) * @param obj the json_object instance * @param idx the index to get the element at * @returns the json_object at the specified index (or NULL) */ JSON_EXPORT struct json_object *json_object_array_get_idx(const struct json_object *obj, size_t idx); /** Delete an elements from a specified index in an array (a json_object of type json_type_array) * * The reference count will be decremented for each of the deleted objects. If there * are no more owners of an element that is being deleted, then the value is * freed. Otherwise, the reference to the value will remain in memory. * * @param obj the json_object instance * @param idx the index to start deleting elements at * @param count the number of elements to delete * @returns 0 if the elements were successfully deleted */ JSON_EXPORT int json_object_array_del_idx(struct json_object *obj, size_t idx, size_t count); /* json_bool type methods */ /** Create a new empty json_object of type json_type_boolean * @param b a json_bool 1 or 0 * @returns a json_object of type json_type_boolean */ JSON_EXPORT struct json_object *json_object_new_boolean(json_bool b); /** Get the json_bool value of a json_object * * The type is coerced to a json_bool if the passed object is not a json_bool. * integer and double objects will return 0 if there value is zero * or 1 otherwise. If the passed object is a string it will return * 1 if it has a non zero length. If any other object type is passed * 1 will be returned if the object is not NULL. * * @param obj the json_object instance * @returns a json_bool */ JSON_EXPORT json_bool json_object_get_boolean(const struct json_object *obj); /** Set the json_bool value of a json_object * * The type of obj is checked to be a json_type_boolean and 0 is returned * if it is not without any further actions. If type of obj is json_type_boolean * the object value is changed to new_value * * @param obj the json_object instance * @param new_value the value to be set * @returns 1 if value is set correctly, 0 otherwise */ JSON_EXPORT int json_object_set_boolean(struct json_object *obj, json_bool new_value); /* int type methods */ /** Create a new empty json_object of type json_type_int * Note that values are stored as 64-bit values internally. * To ensure the full range is maintained, use json_object_new_int64 instead. * @param i the integer * @returns a json_object of type json_type_int */ JSON_EXPORT struct json_object *json_object_new_int(int32_t i); /** Create a new empty json_object of type json_type_int * @param i the integer * @returns a json_object of type json_type_int */ JSON_EXPORT struct json_object *json_object_new_int64(int64_t i); /** Create a new empty json_object of type json_type_uint * @param i the integer * @returns a json_object of type json_type_uint */ JSON_EXPORT struct json_object *json_object_new_uint64(uint64_t i); /** Get the int value of a json_object * * The type is coerced to a int if the passed object is not a int. * double objects will return their integer conversion. Strings will be * parsed as an integer. If no conversion exists then 0 is returned * and errno is set to EINVAL. null is equivalent to 0 (no error values set) * * Note that integers are stored internally as 64-bit values. * If the value of too big or too small to fit into 32-bit, INT32_MAX or * INT32_MIN are returned, respectively. * * @param obj the json_object instance * @returns an int */ JSON_EXPORT int32_t json_object_get_int(const struct json_object *obj); /** Set the int value of a json_object * * The type of obj is checked to be a json_type_int and 0 is returned * if it is not without any further actions. If type of obj is json_type_int * the object value is changed to new_value * * @param obj the json_object instance * @param new_value the value to be set * @returns 1 if value is set correctly, 0 otherwise */ JSON_EXPORT int json_object_set_int(struct json_object *obj, int new_value); /** Increment a json_type_int object by the given amount, which may be negative. * * If the type of obj is not json_type_int then 0 is returned with no further * action taken. * If the addition would result in a overflow, the object value * is set to INT64_MAX. * If the addition would result in a underflow, the object value * is set to INT64_MIN. * Neither overflow nor underflow affect the return value. * * @param obj the json_object instance * @param val the value to add * @returns 1 if the increment succeded, 0 otherwise */ JSON_EXPORT int json_object_int_inc(struct json_object *obj, int64_t val); /** Get the int value of a json_object * * The type is coerced to a int64 if the passed object is not a int64. * double objects will return their int64 conversion. Strings will be * parsed as an int64. If no conversion exists then 0 is returned. * * NOTE: Set errno to 0 directly before a call to this function to determine * whether or not conversion was successful (it does not clear the value for * you). * * @param obj the json_object instance * @returns an int64 */ JSON_EXPORT int64_t json_object_get_int64(const struct json_object *obj); /** Get the uint value of a json_object * * The type is coerced to a uint64 if the passed object is not a uint64. * double objects will return their uint64 conversion. Strings will be * parsed as an uint64. If no conversion exists then 0 is returned. * * NOTE: Set errno to 0 directly before a call to this function to determine * whether or not conversion was successful (it does not clear the value for * you). * * @param obj the json_object instance * @returns an uint64 */ JSON_EXPORT uint64_t json_object_get_uint64(const struct json_object *obj); /** Set the int64_t value of a json_object * * The type of obj is checked to be a json_type_int and 0 is returned * if it is not without any further actions. If type of obj is json_type_int * the object value is changed to new_value * * @param obj the json_object instance * @param new_value the value to be set * @returns 1 if value is set correctly, 0 otherwise */ JSON_EXPORT int json_object_set_int64(struct json_object *obj, int64_t new_value); /** Set the uint64_t value of a json_object * * The type of obj is checked to be a json_type_uint and 0 is returned * if it is not without any further actions. If type of obj is json_type_uint * the object value is changed to new_value * * @param obj the json_object instance * @param new_value the value to be set * @returns 1 if value is set correctly, 0 otherwise */ JSON_EXPORT int json_object_set_uint64(struct json_object *obj, uint64_t new_value); /* double type methods */ /** Create a new empty json_object of type json_type_double * * @see json_object_double_to_json_string() for how to set a custom format string. * * @param d the double * @returns a json_object of type json_type_double */ JSON_EXPORT struct json_object *json_object_new_double(double d); /** * Create a new json_object of type json_type_double, using * the exact serialized representation of the value. * * This allows for numbers that would otherwise get displayed * inefficiently (e.g. 12.3 => "12.300000000000001") to be * serialized with the more convenient form. * * Notes: * * This is used by json_tokener_parse_ex() to allow for * an exact re-serialization of a parsed object. * * The userdata field is used to store the string representation, so it * can't be used for other data if this function is used. * * A roughly equivalent sequence of calls, with the difference being that * the serialization function won't be reset by json_object_set_double(), is: * @code * jso = json_object_new_double(d); * json_object_set_serializer(jso, json_object_userdata_to_json_string, * strdup(ds), json_object_free_userdata); * @endcode * * @param d the numeric value of the double. * @param ds the string representation of the double. This will be copied. */ JSON_EXPORT struct json_object *json_object_new_double_s(double d, const char *ds); /** * Set a global or thread-local json-c option, depending on whether * JSON_C_OPTION_GLOBAL or JSON_C_OPTION_THREAD is passed. * Thread-local options default to undefined, and inherit from the global * value, even if the global value is changed after the thread is created. * Attempting to set thread-local options when threading is not compiled in * will result in an error. Be sure to check the return value. * * double_format is a "%g" printf format, such as "%.20g" * * @return -1 on errors, 0 on success. */ JSON_EXPORT int json_c_set_serialization_double_format(const char *double_format, int global_or_thread); /** Serialize a json_object of type json_type_double to a string. * * This function isn't meant to be called directly. Instead, you can set a * custom format string for the serialization of this double using the * following call (where "%.17g" actually is the default): * * @code * jso = json_object_new_double(d); * json_object_set_serializer(jso, json_object_double_to_json_string, * "%.17g", NULL); * @endcode * * @see printf(3) man page for format strings * * @param jso The json_type_double object that is serialized. * @param pb The destination buffer. * @param level Ignored. * @param flags Ignored. */ JSON_EXPORT int json_object_double_to_json_string(struct json_object *jso, struct printbuf *pb, int level, int flags); /** Get the double floating point value of a json_object * * The type is coerced to a double if the passed object is not a double. * integer objects will return their double conversion. Strings will be * parsed as a double. If no conversion exists then 0.0 is returned and * errno is set to EINVAL. null is equivalent to 0 (no error values set) * * If the value is too big to fit in a double, then the value is set to * the closest infinity with errno set to ERANGE. If strings cannot be * converted to their double value, then EINVAL is set & NaN is returned. * * Arrays of length 0 are interpreted as 0 (with no error flags set). * Arrays of length 1 are effectively cast to the equivalent object and * converted using the above rules. All other arrays set the error to * EINVAL & return NaN. * * NOTE: Set errno to 0 directly before a call to this function to * determine whether or not conversion was successful (it does not clear * the value for you). * * @param obj the json_object instance * @returns a double floating point number */ JSON_EXPORT double json_object_get_double(const struct json_object *obj); /** Set the double value of a json_object * * The type of obj is checked to be a json_type_double and 0 is returned * if it is not without any further actions. If type of obj is json_type_double * the object value is changed to new_value * * If the object was created with json_object_new_double_s(), the serialization * function is reset to the default and the cached serialized value is cleared. * * @param obj the json_object instance * @param new_value the value to be set * @returns 1 if value is set correctly, 0 otherwise */ JSON_EXPORT int json_object_set_double(struct json_object *obj, double new_value); /* string type methods */ /** Create a new empty json_object of type json_type_string * * A copy of the string is made and the memory is managed by the json_object * * @param s the string * @returns a json_object of type json_type_string * @see json_object_new_string_len() */ JSON_EXPORT struct json_object *json_object_new_string(const char *s); /** Create a new empty json_object of type json_type_string and allocate * len characters for the new string. * * A copy of the string is made and the memory is managed by the json_object * * @param s the string * @param len max length of the new string * @returns a json_object of type json_type_string * @see json_object_new_string() */ JSON_EXPORT struct json_object *json_object_new_string_len(const char *s, const int len); /** Get the string value of a json_object * * If the passed object is of type json_type_null (i.e. obj == NULL), * NULL is returned. * * If the passed object of type json_type_string, the string contents * are returned. * * Otherwise the JSON representation of the object is returned. * * The returned string memory is managed by the json_object and will * be freed when the reference count of the json_object drops to zero. * * @param obj the json_object instance * @returns a string or NULL */ JSON_EXPORT const char *json_object_get_string(struct json_object *obj); /** Get the string length of a json_object * * If the passed object is not of type json_type_string then zero * will be returned. * * @param obj the json_object instance * @returns int */ JSON_EXPORT int json_object_get_string_len(const struct json_object *obj); /** Set the string value of a json_object with zero terminated strings * equivalent to json_object_set_string_len (obj, new_value, strlen(new_value)) * @returns 1 if value is set correctly, 0 otherwise */ JSON_EXPORT int json_object_set_string(json_object *obj, const char *new_value); /** Set the string value of a json_object str * * The type of obj is checked to be a json_type_string and 0 is returned * if it is not without any further actions. If type of obj is json_type_string * the object value is changed to new_value * * @param obj the json_object instance * @param new_value the value to be set; Since string length is given in len this need not be zero terminated * @param len the length of new_value * @returns 1 if value is set correctly, 0 otherwise */ JSON_EXPORT int json_object_set_string_len(json_object *obj, const char *new_value, int len); /** This method exists only to provide a complementary function * along the lines of the other json_object_new_* functions. * It always returns NULL, and it is entirely acceptable to simply use NULL directly. */ JSON_EXPORT struct json_object *json_object_new_null(void); /** Check if two json_object's are equal * * If the passed objects are equal 1 will be returned. * Equality is defined as follows: * - json_objects of different types are never equal * - json_objects of the same primitive type are equal if the * c-representation of their value is equal * - json-arrays are considered equal if all values at the same * indices are equal (same order) * - Complex json_objects are considered equal if all * contained objects referenced by their key are equal, * regardless their order. * * @param obj1 the first json_object instance * @param obj2 the second json_object instance * @returns whether both objects are equal or not */ JSON_EXPORT int json_object_equal(struct json_object *obj1, struct json_object *obj2); /** * Perform a shallow copy of src into *dst as part of an overall json_object_deep_copy(). * * If src is part of a containing object or array, parent will be non-NULL, * and key or index will be provided. * When shallow_copy is called *dst will be NULL, and must be non-NULL when it returns. * src will never be NULL. * * If shallow_copy sets the serializer on an object, return 2 to indicate to * json_object_deep_copy that it should not attempt to use the standard userdata * copy function. * * @return On success 1 or 2, -1 on errors */ typedef int(json_c_shallow_copy_fn)(json_object *src, json_object *parent, const char *key, size_t index, json_object **dst); /** * The default shallow copy implementation for use with json_object_deep_copy(). * This simply calls the appropriate json_object_new_<type>() function and * copies over the serializer function (_to_json_string internal field of * the json_object structure) but not any _userdata or _user_delete values. * * If you're writing a custom shallow_copy function, perhaps because you're using * your own custom serializer, you can call this first to create the new object * before customizing it with json_object_set_serializer(). * * @return 1 on success, -1 on errors, but never 2. */ JSON_EXPORT json_c_shallow_copy_fn json_c_shallow_copy_default; /** * Copy the contents of the JSON object. * The destination object must be initialized to NULL, * to make sure this function won't overwrite an existing JSON object. * * This does roughly the same thing as * `json_tokener_parse(json_object_get_string(src))`. * * @param src source JSON object whose contents will be copied * @param dst pointer to the destination object where the contents of `src`; * make sure this pointer is initialized to NULL * @param shallow_copy an optional function to copy individual objects, needed * when custom serializers are in use. See also * json_object set_serializer. * * @returns 0 if the copy went well, -1 if an error occured during copy * or if the destination pointer is non-NULL */ JSON_EXPORT int json_object_deep_copy(struct json_object *src, struct json_object **dst, json_c_shallow_copy_fn *shallow_copy); #ifdef __cplusplus } #endif #endif /* * Copyright (c) 2020 Eric Hawicz * * This library is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. */ #ifndef _json_types_h_ #define _json_types_h_ /** * @file * @brief Basic types used in a few places in json-c, but you should include "json_object.h" instead. */ #ifdef __cplusplus extern "C" { #endif #ifndef JSON_EXPORT #if defined(_MSC_VER) #define JSON_EXPORT __declspec(dllexport) #else #define JSON_EXPORT extern #endif #endif struct printbuf; /** * A structure to use with json_object_object_foreachC() loops. * Contains key, val and entry members. */ struct json_object_iter { char *key; struct json_object *val; struct lh_entry *entry; }; typedef struct json_object_iter json_object_iter; typedef int json_bool; /** * @brief The core type for all type of JSON objects handled by json-c */ typedef struct json_object json_object; /** * Type of custom user delete functions. See json_object_set_serializer. */ typedef void(json_object_delete_fn)(struct json_object *jso, void *userdata); /** * Type of a custom serialization function. See json_object_set_serializer. */ typedef int(json_object_to_json_string_fn)(struct json_object *jso, struct printbuf *pb, int level, int flags); /* supported object types */ typedef enum json_type { /* If you change this, be sure to update json_type_to_name() too */ json_type_null, json_type_boolean, json_type_double, json_type_int, json_type_object, json_type_array, json_type_string } json_type; #ifdef __cplusplus } #endif #endif /* * Copyright (c) 2016 Alexadru Ardelean. * * This is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See COPYING for details. * */ /** * @file * @brief JSON Pointer (RFC 6901) implementation for retrieving * objects from a json-c object tree. */ #ifndef _json_pointer_h_ #define _json_pointer_h_ #include "json_object.h" #ifdef __cplusplus extern "C" { #endif /** * Retrieves a JSON sub-object from inside another JSON object * using the JSON pointer notation as defined in RFC 6901 * https://tools.ietf.org/html/rfc6901 * * The returned JSON sub-object is equivalent to parsing manually the * 'obj' JSON tree ; i.e. it's not a new object that is created, but rather * a pointer inside the JSON tree. * * Internally, this is equivalent to doing a series of 'json_object_object_get()' * and 'json_object_array_get_idx()' along the given 'path'. * * Note that the 'path' string supports 'printf()' type arguments, so, whatever * is added after the 'res' param will be treated as an argument for 'path' * Example: json_pointer_get(obj, "/foo/%d/%s", &res, 0, bar) * This means, that you need to escape '%' with '%%' (just like in printf()) * * @param obj the json_object instance/tree from where to retrieve sub-objects * @param path a (RFC6901) string notation for the sub-object to retrieve * @param res a pointer that stores a reference to the json_object * associated with the given path * * @return negative if an error (or not found), or 0 if succeeded */ JSON_EXPORT int json_pointer_get(struct json_object *obj, const char *path, struct json_object **res); /** * This is a variant of 'json_pointer_get()' that supports printf() style arguments. * * Example: json_pointer_getf(obj, res, "/foo/%d/%s", 0, bak) * This also means that you need to escape '%' with '%%' (just like in printf()) * * Please take into consideration all recommended 'printf()' format security * aspects when using this function. * * @param obj the json_object instance/tree to which to add a sub-object * @param res a pointer that stores a reference to the json_object * associated with the given path * @param path_fmt a printf() style format for the path * * @return negative if an error (or not found), or 0 if succeeded */ JSON_EXPORT int json_pointer_getf(struct json_object *obj, struct json_object **res, const char *path_fmt, ...); /** * Sets JSON object 'value' in the 'obj' tree at the location specified * by the 'path'. 'path' is JSON pointer notation as defined in RFC 6901 * https://tools.ietf.org/html/rfc6901 * * Note that 'obj' is a double pointer, mostly for the "" (empty string) * case, where the entire JSON object would be replaced by 'value'. * In the case of the "" path, the object at '*obj' will have it's refcount * decremented with 'json_object_put()' and the 'value' object will be assigned to it. * * For other cases (JSON sub-objects) ownership of 'value' will be transferred into * '*obj' via 'json_object_object_add()' & 'json_object_array_put_idx()', so the * only time the refcount should be decremented for 'value' is when the return value of * 'json_pointer_set()' is negative (meaning the 'value' object did not get set into '*obj'). * * That also implies that 'json_pointer_set()' does not do any refcount incrementing. * (Just that single decrement that was mentioned above). * * Note that the 'path' string supports 'printf()' type arguments, so, whatever * is added after the 'value' param will be treated as an argument for 'path' * Example: json_pointer_set(obj, "/foo/%d/%s", value, 0, bak) * This means, that you need to escape '%' with '%%' (just like in printf()) * * @param obj the json_object instance/tree to which to add a sub-object * @param path a (RFC6901) string notation for the sub-object to set in the tree * @param value object to set at path * * @return negative if an error (or not found), or 0 if succeeded */ JSON_EXPORT int json_pointer_set(struct json_object **obj, const char *path, struct json_object *value); /** * This is a variant of 'json_pointer_set()' that supports printf() style arguments. * * Example: json_pointer_setf(obj, value, "/foo/%d/%s", 0, bak) * This also means that you need to escape '%' with '%%' (just like in printf()) * * Please take into consideration all recommended 'printf()' format security * aspects when using this function. * * @param obj the json_object instance/tree to which to add a sub-object * @param value object to set at path * @param path_fmt a printf() style format for the path * * @return negative if an error (or not found), or 0 if succeeded */ JSON_EXPORT int json_pointer_setf(struct json_object **obj, struct json_object *value, const char *path_fmt, ...); #ifdef __cplusplus } #endif #endif /* Define to 1 if you have the <inttypes.h> header file. */ #define JSON_C_HAVE_INTTYPES_H 1 #ifndef _json_c_json_visit_h_ #define _json_c_json_visit_h_ /** * @file * @brief Methods for walking a tree of objects. */ #include "json_object.h" typedef int(json_c_visit_userfunc)(json_object *jso, int flags, json_object *parent_jso, const char *jso_key, size_t *jso_index, void *userarg); /** * Visit each object in the JSON hierarchy starting at jso. * For each object, userfunc is called, passing the object and userarg. * If the object has a parent (i.e. anything other than jso itself) * its parent will be passed as parent_jso, and either jso_key or jso_index * will be set, depending on whether the parent is an object or an array. * * Nodes will be visited depth first, but containers (arrays and objects) * will be visited twice, the second time with JSON_C_VISIT_SECOND set in * flags. * * userfunc must return one of the defined return values, to indicate * whether and how to continue visiting nodes, or one of various ways to stop. * * Returns 0 if nodes were visited successfully, even if some were * intentionally skipped due to what userfunc returned. * Returns <0 if an error occurred during iteration, including if * userfunc returned JSON_C_VISIT_RETURN_ERROR. */ JSON_EXPORT int json_c_visit(json_object *jso, int future_flags, json_c_visit_userfunc *userfunc, void *userarg); /** * Passed to json_c_visit_userfunc as one of the flags values to indicate * that this is the second time a container (array or object) is being * called, after all of it's members have been iterated over. */ #define JSON_C_VISIT_SECOND 0x02 /** * This json_c_visit_userfunc return value indicates that iteration * should proceed normally. */ #define JSON_C_VISIT_RETURN_CONTINUE 0 /** * This json_c_visit_userfunc return value indicates that iteration * over the members of the current object should be skipped. * If the current object isn't a container (array or object), this * is no different than JSON_C_VISIT_RETURN_CONTINUE. */ #define JSON_C_VISIT_RETURN_SKIP 7547 /** * This json_c_visit_userfunc return value indicates that iteration * of the fields/elements of the <b>containing</b> object should stop * and continue "popped up" a level of the object hierarchy. * For example, returning this when handling arg will result in * arg3 and any other fields being skipped. The next call to userfunc * will be the JSON_C_VISIT_SECOND call on "foo", followed by a userfunc * call on "bar". * <pre> * { * "foo": { * "arg1": 1, * "arg2": 2, * "arg3": 3, * ... * }, * "bar": { * ... * } * } * </pre> */ #define JSON_C_VISIT_RETURN_POP 767 /** * This json_c_visit_userfunc return value indicates that iteration * should stop immediately, and cause json_c_visit to return success. */ #define JSON_C_VISIT_RETURN_STOP 7867 /** * This json_c_visit_userfunc return value indicates that iteration * should stop immediately, and cause json_c_visit to return an error. */ #define JSON_C_VISIT_RETURN_ERROR -1 #endif /* _json_c_json_visit_h_ */ /* * Generated file - do not edit directly. * * This file was generated from: * http://www.w3.org/TR/REC-html40/sgml/entities.html * by means of the script: * entities.tcl */ #ifdef __cplusplus extern "C" { #endif static struct entities_s { char *name; int value; } entities[] = { {"AElig", 198}, {"Aacute", 193}, {"Acirc", 194}, {"Agrave", 192}, {"Alpha", 913}, {"Aring", 197}, {"Atilde", 195}, {"Auml", 196}, {"Beta", 914}, {"Ccedil", 199}, {"Chi", 935}, {"Dagger", 8225}, {"Delta", 916}, {"ETH", 208}, {"Eacute", 201}, {"Ecirc", 202}, {"Egrave", 200}, {"Epsilon", 917}, {"Eta", 919}, {"Euml", 203}, {"Gamma", 915}, {"Iacute", 205}, {"Icirc", 206}, {"Igrave", 204}, {"Iota", 921}, {"Iuml", 207}, {"Kappa", 922}, {"Lambda", 923}, {"Mu", 924}, {"Ntilde", 209}, {"Nu", 925}, {"OElig", 338}, {"Oacute", 211}, {"Ocirc", 212}, {"Ograve", 210}, {"Omega", 937}, {"Omicron", 927}, {"Oslash", 216}, {"Otilde", 213}, {"Ouml", 214}, {"Phi", 934}, {"Pi", 928}, {"Prime", 8243}, {"Psi", 936}, {"Rho", 929}, {"Scaron", 352}, {"Sigma", 931}, {"THORN", 222}, {"Tau", 932}, {"Theta", 920}, {"Uacute", 218}, {"Ucirc", 219}, {"Ugrave", 217}, {"Upsilon", 933}, {"Uuml", 220}, {"Xi", 926}, {"Yacute", 221}, {"Yuml", 376}, {"Zeta", 918}, {"aacute", 225}, {"acirc", 226}, {"acute", 180}, {"aelig", 230}, {"agrave", 224}, {"alefsym", 8501}, {"alpha", 945}, {"amp", 38}, {"and", 8743}, {"ang", 8736}, {"aring", 229}, {"asymp", 8776}, {"atilde", 227}, {"auml", 228}, {"bdquo", 8222}, {"beta", 946}, {"brvbar", 166}, {"bull", 8226}, {"cap", 8745}, {"ccedil", 231}, {"cedil", 184}, {"cent", 162}, {"chi", 967}, {"circ", 710}, {"clubs", 9827}, {"cong", 8773}, {"copy", 169}, {"crarr", 8629}, {"cup", 8746}, {"curren", 164}, {"dArr", 8659}, {"dagger", 8224}, {"darr", 8595}, {"deg", 176}, {"delta", 948}, {"diams", 9830}, {"divide", 247}, {"eacute", 233}, {"ecirc", 234}, {"egrave", 232}, {"empty", 8709}, {"emsp", 8195}, {"ensp", 8194}, {"epsilon", 949}, {"equiv", 8801}, {"eta", 951}, {"eth", 240}, {"euml", 235}, {"euro", 8364}, {"exist", 8707}, {"fnof", 402}, {"forall", 8704}, {"frac12", 189}, {"frac14", 188}, {"frac34", 190}, {"frasl", 8260}, {"gamma", 947}, {"ge", 8805}, {"gt", 62}, {"hArr", 8660}, {"harr", 8596}, {"hearts", 9829}, {"hellip", 8230}, {"iacute", 237}, {"icirc", 238}, {"iexcl", 161}, {"igrave", 236}, {"image", 8465}, {"infin", 8734}, {"int", 8747}, {"iota", 953}, {"iquest", 191}, {"isin", 8712}, {"iuml", 239}, {"kappa", 954}, {"lArr", 8656}, {"lambda", 955}, {"lang", 9001}, {"laquo", 171}, {"larr", 8592}, {"lceil", 8968}, {"ldquo", 8220}, {"le", 8804}, {"lfloor", 8970}, {"lowast", 8727}, {"loz", 9674}, {"lrm", 8206}, {"lsaquo", 8249}, {"lsquo", 8216}, {"lt", 60}, {"macr", 175}, {"mdash", 8212}, {"micro", 181}, {"middot", 183}, {"minus", 8722}, {"mu", 956}, {"nabla", 8711}, {"nbsp", 160}, {"ndash", 8211}, {"ne", 8800}, {"ni", 8715}, {"not", 172}, {"notin", 8713}, {"nsub", 8836}, {"ntilde", 241}, {"nu", 957}, {"oacute", 243}, {"ocirc", 244}, {"oelig", 339}, {"ograve", 242}, {"oline", 8254}, {"omega", 969}, {"omicron", 959}, {"oplus", 8853}, {"or", 8744}, {"ordf", 170}, {"ordm", 186}, {"oslash", 248}, {"otilde", 245}, {"otimes", 8855}, {"ouml", 246}, {"para", 182}, {"part", 8706}, {"permil", 8240}, {"perp", 8869}, {"phi", 966}, {"pi", 960}, {"piv", 982}, {"plusmn", 177}, {"pound", 163}, {"prime", 8242}, {"prod", 8719}, {"prop", 8733}, {"psi", 968}, {"quot", 34}, {"rArr", 8658}, {"radic", 8730}, {"rang", 9002}, {"raquo", 187}, {"rarr", 8594}, {"rceil", 8969}, {"rdquo", 8221}, {"real", 8476}, {"reg", 174}, {"rfloor", 8971}, {"rho", 961}, {"rlm", 8207}, {"rsaquo", 8250}, {"rsquo", 8217}, {"sbquo", 8218}, {"scaron", 353}, {"sdot", 8901}, {"sect", 167}, {"shy", 173}, {"sigma", 963}, {"sigmaf", 962}, {"sim", 8764}, {"spades", 9824}, {"sub", 8834}, {"sube", 8838}, {"sum", 8721}, {"sup", 8835}, {"sup1", 185}, {"sup2", 178}, {"sup3", 179}, {"supe", 8839}, {"szlig", 223}, {"tau", 964}, {"there4", 8756}, {"theta", 952}, {"thetasym", 977}, {"thinsp", 8201}, {"thorn", 254}, {"tilde", 732}, {"times", 215}, {"trade", 8482}, {"uArr", 8657}, {"uacute", 250}, {"uarr", 8593}, {"ucirc", 251}, {"ugrave", 249}, {"uml", 168}, {"upsih", 978}, {"upsilon", 965}, {"uuml", 252}, {"weierp", 8472}, {"xi", 958}, {"yacute", 253}, {"yen", 165}, {"yuml", 255}, {"zeta", 950}, {"zwj", 8205}, {"zwnj", 8204}, }; #define ENTITY_NAME_LENGTH_MAX 8 #define NR_OF_ENTITIES 252 #ifdef __cplusplus } #endif /* Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _FNMATCH_H #define _FNMATCH_H 1 #ifdef __cplusplus extern "C" { #endif /* We #undef these before defining them because some losing systems (HP-UX A.08.07 for example) define these in <unistd.h>. */ #undef FNM_PATHNAME #undef FNM_NOESCAPE #undef FNM_PERIOD /* Bits set in the FLAGS argument to `fnmatch'. */ #define FNM_PATHNAME (1 << 0) /* No wildcard can ever match `/'. */ #define FNM_NOESCAPE (1 << 1) /* Backslashes don't quote special chars. */ #define FNM_PERIOD (1 << 2) /* Leading `.' is matched only explicitly. */ #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE # define FNM_FILE_NAME FNM_PATHNAME /* Preferred GNU name. */ # define FNM_LEADING_DIR (1 << 3) /* Ignore `/...' after a match. */ # define FNM_CASEFOLD (1 << 4) /* Compare without regard to case. */ # define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */ #endif /* Value returned by `fnmatch' if STRING does not match PATTERN. */ #define FNM_NOMATCH 1 /* This value is returned if the implementation does not support `fnmatch'. Since this is not the case here it will never be returned but the conformance test suites still require the symbol to be defined. */ #ifdef _XOPEN_SOURCE # define FNM_NOSYS (-1) #endif /* Match NAME against the filename pattern PATTERN, returning zero if it matches, FNM_NOMATCH if not. */ extern int fnmatch (const char *__pattern, const char *__name, int __flags); #ifdef __cplusplus } #endif #endif /* fnmatch.h */ /* User functions for run-time dynamic loading. Copyright (C) 1995-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _DLFCN_H #define _DLFCN_H 1 #include <features.h> #define __need_size_t #include <stddef.h> /* Collect various system dependent definitions and declarations. */ #include <bits/dlfcn.h> #ifdef __USE_GNU #include <bits/dl_find_object.h> /* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT the run-time address of the symbol called NAME in the next shared object is returned. The "next" relation is defined by the order the shared objects were loaded. */ # define RTLD_NEXT ((void *) -1l) /* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT the run-time address of the symbol called NAME in the global scope is returned. */ # define RTLD_DEFAULT ((void *) 0) /* Type for namespace indices. */ typedef long int Lmid_t; /* Special namespace ID values. */ # define LM_ID_BASE 0 /* Initial namespace. */ # define LM_ID_NEWLM -1 /* For dlmopen: request new namespace. */ #endif __BEGIN_DECLS /* Open the shared object FILE and map it in; return a handle that can be passed to `dlsym' to get symbol values from it. */ extern void *dlopen (const char *__file, int __mode) __THROWNL; /* Unmap and close a shared object opened by `dlopen'. The handle cannot be used again after calling `dlclose'. */ extern int dlclose (void *__handle) __THROWNL __nonnull ((1)); /* Find the run-time address in the shared object HANDLE refers to of the symbol called NAME. */ extern void *dlsym (void *__restrict __handle, const char *__restrict __name) __THROW __nonnull ((2)); #ifdef __USE_GNU /* Like `dlopen', but request object to be allocated in a new namespace. */ extern void *dlmopen (Lmid_t __nsid, const char *__file, int __mode) __THROWNL; /* Find the run-time address in the shared object HANDLE refers to of the symbol called NAME with VERSION. */ extern void *dlvsym (void *__restrict __handle, const char *__restrict __name, const char *__restrict __version) __THROW __nonnull ((2, 3)); #endif /* When any of the above functions fails, call this function to return a string describing the error. Each call resets the error string so that a following call returns null. */ extern char *dlerror (void) __THROW; #ifdef __USE_GNU /* Structure containing information about object searched using `dladdr'. */ typedef struct { const char *dli_fname; /* File name of defining object. */ void *dli_fbase; /* Load address of that object. */ const char *dli_sname; /* Name of nearest symbol. */ void *dli_saddr; /* Exact value of nearest symbol. */ } Dl_info; /* Fill in *INFO with the following information about ADDRESS. Returns 0 iff no shared object's segments contain that address. */ extern int dladdr (const void *__address, Dl_info *__info) __THROW __nonnull ((2)); /* Same as `dladdr', but additionally sets *EXTRA_INFO according to FLAGS. */ extern int dladdr1 (const void *__address, Dl_info *__info, void **__extra_info, int __flags) __THROW __nonnull ((2)); /* These are the possible values for the FLAGS argument to `dladdr1'. This indicates what extra information is stored at *EXTRA_INFO. It may also be zero, in which case the EXTRA_INFO argument is not used. */ enum { /* Matching symbol table entry (const ElfNN_Sym *). */ RTLD_DL_SYMENT = 1, /* The object containing the address (struct link_map *). */ RTLD_DL_LINKMAP = 2 }; /* Get information about the shared object HANDLE refers to. REQUEST is from among the values below, and determines the use of ARG. On success, returns zero. On failure, returns -1 and records an error message to be fetched with `dlerror'. */ extern int dlinfo (void *__restrict __handle, int __request, void *__restrict __arg) __THROW __nonnull ((1, 3)); /* These are the possible values for the REQUEST argument to `dlinfo'. */ enum { /* Treat ARG as `lmid_t *'; store namespace ID for HANDLE there. */ RTLD_DI_LMID = 1, /* Treat ARG as `struct link_map **'; store the `struct link_map *' for HANDLE there. */ RTLD_DI_LINKMAP = 2, RTLD_DI_CONFIGADDR = 3, /* Unsupported, defined by Solaris. */ /* Treat ARG as `Dl_serinfo *' (see below), and fill in to describe the directories that will be searched for dependencies of this object. RTLD_DI_SERINFOSIZE fills in just the `dls_cnt' and `dls_size' entries to indicate the size of the buffer that must be passed to RTLD_DI_SERINFO to fill in the full information. */ RTLD_DI_SERINFO = 4, RTLD_DI_SERINFOSIZE = 5, /* Treat ARG as `char *', and store there the directory name used to expand $ORIGIN in this shared object's dependency file names. */ RTLD_DI_ORIGIN = 6, RTLD_DI_PROFILENAME = 7, /* Unsupported, defined by Solaris. */ RTLD_DI_PROFILEOUT = 8, /* Unsupported, defined by Solaris. */ /* Treat ARG as `size_t *', and store there the TLS module ID of this object's PT_TLS segment, as used in TLS relocations; store zero if this object does not define a PT_TLS segment. */ RTLD_DI_TLS_MODID = 9, /* Treat ARG as `void **', and store there a pointer to the calling thread's TLS block corresponding to this object's PT_TLS segment. Store a null pointer if this object does not define a PT_TLS segment, or if the calling thread has not allocated a block for it. */ RTLD_DI_TLS_DATA = 10, /* Treat ARG as const ElfW(Phdr) **, and store the address of the program header array at that location. The dlinfo call returns the number of program headers in the array. */ RTLD_DI_PHDR = 11, /* Treat ARG as `const char **' and at that location, store the address of the directory name used to expand $ORIGIN in this shared object's dependency file names. */ RTLD_DI_ORIGIN_PATH = 12, RTLD_DI_MAX = 12 }; /* This is the type of elements in `Dl_serinfo', below. The `dls_name' member points to space in the buffer passed to `dlinfo'. */ typedef struct { char *dls_name; /* Name of library search path directory. */ unsigned int dls_flags; /* Indicates where this directory came from. */ } Dl_serpath; /* This is the structure that must be passed (by reference) to `dlinfo' for the RTLD_DI_SERINFO and RTLD_DI_SERINFOSIZE requests. */ typedef struct { size_t dls_size; /* Size in bytes of the whole buffer. */ unsigned int dls_cnt; /* Number of elements in `dls_serpath'. */ # if __GNUC_PREREQ (3, 0) /* The zero-length array avoids an unwanted array subscript check by the compiler, while the surrounding anonymous union preserves the historic size of the type. At the time of writing, GNU C does not support structs with flexible array members in unions. */ __extension__ union { Dl_serpath dls_serpath[0]; /* Actually longer, dls_cnt elements. */ Dl_serpath __dls_serpath_pad[1]; }; # else Dl_serpath dls_serpath[1]; /* Actually longer, dls_cnt elements. */ # endif } Dl_serinfo; struct dl_find_object { __extension__ unsigned long long int dlfo_flags; void *dlfo_map_start; /* Beginning of mapping containing address. */ void *dlfo_map_end; /* End of mapping. */ struct link_map *dlfo_link_map; void *dlfo_eh_frame; /* Exception handling data of the object. */ # if DLFO_STRUCT_HAS_EH_DBASE void *dlfo_eh_dbase; /* Base address for DW_EH_PE_datarel. */ # if __WORDSIZE == 32 unsigned int __dlfo_eh_dbase_pad; # endif # endif # if DLFO_STRUCT_HAS_EH_COUNT int dlfo_eh_count; /* Number of exception handling entries. */ unsigned int __dlfo_eh_count_pad; # endif __extension__ unsigned long long int __dflo_reserved[7]; }; /* If ADDRESS is found in an object, fill in *RESULT and return 0. Otherwise, return -1. */ int _dl_find_object (void *__address, struct dl_find_object *__result) __THROW; #endif /* __USE_GNU */ __END_DECLS #endif /* dlfcn.h */ /*-------------------------------------------------------------*/ /*--- Public header file for the library. ---*/ /*--- bzlib.h ---*/ /*-------------------------------------------------------------*/ /* ------------------------------------------------------------------ This file is part of bzip2/libbzip2, a program and library for lossless, block-sorting data compression. bzip2/libbzip2 version 1.0.8 of 13 July 2019 Copyright (C) 1996-2019 Julian Seward <jseward@acm.org> Please read the WARNING, DISCLAIMER and PATENTS sections in the README file. This program is released under the terms of the license contained in the file LICENSE. ------------------------------------------------------------------ */ #ifndef _BZLIB_H #define _BZLIB_H #ifdef __cplusplus extern "C" { #endif #define BZ_RUN 0 #define BZ_FLUSH 1 #define BZ_FINISH 2 #define BZ_OK 0 #define BZ_RUN_OK 1 #define BZ_FLUSH_OK 2 #define BZ_FINISH_OK 3 #define BZ_STREAM_END 4 #define BZ_SEQUENCE_ERROR (-1) #define BZ_PARAM_ERROR (-2) #define BZ_MEM_ERROR (-3) #define BZ_DATA_ERROR (-4) #define BZ_DATA_ERROR_MAGIC (-5) #define BZ_IO_ERROR (-6) #define BZ_UNEXPECTED_EOF (-7) #define BZ_OUTBUFF_FULL (-8) #define BZ_CONFIG_ERROR (-9) typedef struct { char *next_in; unsigned int avail_in; unsigned int total_in_lo32; unsigned int total_in_hi32; char *next_out; unsigned int avail_out; unsigned int total_out_lo32; unsigned int total_out_hi32; void *state; void *(*bzalloc)(void *,int,int); void (*bzfree)(void *,void *); void *opaque; } bz_stream; #ifndef BZ_IMPORT #define BZ_EXPORT #endif #ifndef BZ_NO_STDIO /* Need a definitition for FILE */ #include <stdio.h> #endif #ifdef _WIN32 # include <windows.h> # ifdef small /* windows.h define small to char */ # undef small # endif # ifdef BZ_EXPORT # define BZ_API(func) WINAPI func # define BZ_EXTERN extern # else /* import windows dll dynamically */ # define BZ_API(func) (WINAPI * func) # define BZ_EXTERN # endif #else # define BZ_API(func) func # define BZ_EXTERN extern #endif /*-- Core (low-level) library functions --*/ BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( bz_stream* strm, int blockSize100k, int verbosity, int workFactor ); BZ_EXTERN int BZ_API(BZ2_bzCompress) ( bz_stream* strm, int action ); BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( bz_stream* strm ); BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( bz_stream *strm, int verbosity, int small ); BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( bz_stream* strm ); BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ); /*-- High(er) level library functions --*/ #ifndef BZ_NO_STDIO #define BZ_MAX_UNUSED 5000 typedef void BZFILE; BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( int* bzerror, FILE* f, int verbosity, int small, void* unused, int nUnused ); BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( int* bzerror, BZFILE* b ); BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( int* bzerror, BZFILE* b, void** unused, int* nUnused ); BZ_EXTERN int BZ_API(BZ2_bzRead) ( int* bzerror, BZFILE* b, void* buf, int len ); BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( int* bzerror, FILE* f, int blockSize100k, int verbosity, int workFactor ); BZ_EXTERN void BZ_API(BZ2_bzWrite) ( int* bzerror, BZFILE* b, void* buf, int len ); BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( int* bzerror, BZFILE* b, int abandon, unsigned int* nbytes_in, unsigned int* nbytes_out ); BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( int* bzerror, BZFILE* b, int abandon, unsigned int* nbytes_in_lo32, unsigned int* nbytes_in_hi32, unsigned int* nbytes_out_lo32, unsigned int* nbytes_out_hi32 ); #endif /*-- Utility functions --*/ BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( char* dest, unsigned int* destLen, char* source, unsigned int sourceLen, int blockSize100k, int verbosity, int workFactor ); BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( char* dest, unsigned int* destLen, char* source, unsigned int sourceLen, int small, int verbosity ); /*-- Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) to support better zlib compatibility. This code is not _officially_ part of libbzip2 (yet); I haven't tested it, documented it, or considered the threading-safeness of it. If this code breaks, please contact both Yoshioka and me. --*/ BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( void ); #ifndef BZ_NO_STDIO BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( const char *path, const char *mode ); BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( int fd, const char *mode ); BZ_EXTERN int BZ_API(BZ2_bzread) ( BZFILE* b, void* buf, int len ); BZ_EXTERN int BZ_API(BZ2_bzwrite) ( BZFILE* b, void* buf, int len ); BZ_EXTERN int BZ_API(BZ2_bzflush) ( BZFILE* b ); BZ_EXTERN void BZ_API(BZ2_bzclose) ( BZFILE* b ); BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( BZFILE *b, int *errnum ); #endif #ifdef __cplusplus } #endif #endif /*-------------------------------------------------------------*/ /*--- end bzlib.h ---*/ /*-------------------------------------------------------------*/ /* SPDX-License-Identifier: GPL-2.0 */ #ifndef __CPUPOWER_CPUIDLE_H__ #define __CPUPOWER_CPUIDLE_H__ int cpuidle_is_state_disabled(unsigned int cpu, unsigned int idlestate); int cpuidle_state_disable(unsigned int cpu, unsigned int idlestate, unsigned int disable); unsigned long cpuidle_state_latency(unsigned int cpu, unsigned int idlestate); unsigned long cpuidle_state_residency(unsigned int cpu, unsigned int idlestate); unsigned long cpuidle_state_usage(unsigned int cpu, unsigned int idlestate); unsigned long long cpuidle_state_time(unsigned int cpu, unsigned int idlestate); char *cpuidle_state_name(unsigned int cpu, unsigned int idlestate); char *cpuidle_state_desc(unsigned int cpu, unsigned int idlestate); unsigned int cpuidle_state_count(unsigned int cpu); char *cpuidle_get_governor(void); char *cpuidle_get_driver(void); #endif /* __CPUPOWER_HELPERS_SYSFS_H__ */ /* Copyright (C) 1991-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _NETATALK_AT_H #define _NETATALK_AT_H 1 #include <asm/types.h> #include <bits/sockaddr.h> #include <linux/atalk.h> #include <sys/socket.h> #define SOL_ATALK 258 /* sockopt level for atalk */ #endif /* netatalk/at.h */ /* * bsock_bind - interfaces to bind to reserved ports * * Copyright (c) 2011, Glue Logic LLC. All rights reserved. code()gluelogic.com * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Glue Logic LLC nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef INCLUDED_BSOCK_BIND_H #define INCLUDED_BSOCK_BIND_H #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #ifdef _AIX #include "bsock_addrinfo.h" /* struct addrinfo */ #endif #ifdef __cplusplus extern "C" { #endif int __attribute__((nonnull)) bsock_bind_addrinfo (const int fd, const struct addrinfo * const restrict ai); #ifdef __cplusplus } #endif #endif /* * bsock_syslog - syslog() wrapper for error messages * * Copyright (c) 2011, Glue Logic LLC. All rights reserved. code()gluelogic.com * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Glue Logic LLC nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef INCLUDED_BSOCK_SYSLOG_H #define INCLUDED_BSOCK_SYSLOG_H #include <sys/types.h> /*(for __GNUC_PREREQ(), if available)*/ #ifndef __has_attribute #define __has_attribute(x) 0 #endif #ifndef __GNUC_PREREQ # ifdef __GNUC_PREREQ__ # define __GNUC_PREREQ __GNUC_PREREQ__ # elif defined __GNUC__ && defined __GNUC_MINOR__ # define __GNUC_PREREQ(maj, min) \ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) # else # define __GNUC_PREREQ(maj, min) 0 # endif #endif #if __GNUC_PREREQ(4,3) || __has_attribute(cold) #ifndef __attribute_cold__ #define __attribute_cold__ __attribute__ ((cold)) #endif #endif #ifndef __attribute_cold__ #define __attribute_cold__ #endif #ifdef __cplusplus extern "C" { #endif enum { BSOCK_SYSLOG_DAEMON = 0, BSOCK_SYSLOG_PERROR = 1, BSOCK_SYSLOG_PERROR_NOSYSLOG = 2 }; void __attribute_cold__ bsock_syslog_setlevel (const int level); void __attribute_cold__ bsock_syslog_setlogfd (const int fd); void __attribute_cold__ bsock_syslog_openlog (const char * const ident, const int option, const int facility); void __attribute_cold__ __attribute__((format(printf,3,4))) bsock_syslog (const int errnum, const int priority, const char * const restrict fmt, ...); #ifdef __cplusplus } #endif #endif /* * bsock_daemon - daemon initialization and signal setup * * Copyright (c) 2011, Glue Logic LLC. All rights reserved. code()gluelogic.com * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Glue Logic LLC nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef INCLUDED_BSOCK_DAEMON_H #define INCLUDED_BSOCK_DAEMON_H #include <sys/types.h> #include <stdbool.h> #ifdef __cplusplus extern "C" { #endif bool bsock_daemon_setuid_stdinit (void); bool bsock_daemon_init (const int supervised, const bool check); int __attribute__((nonnull)) bsock_daemon_init_socket (const char * const restrict sockpath, /*(persistent)*/ const uid_t uid, const gid_t gid, const mode_t mode); size_t bsock_daemon_msg_control_max (void); #ifdef __cplusplus } #endif #endif /* * bsock_addrinfo - struct addrinfo string manipulation * * Copyright (c) 2011, Glue Logic LLC. All rights reserved. code()gluelogic.com * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Glue Logic LLC nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef INCLUDED_BSOCK_ADDRINFO_H #define INCLUDED_BSOCK_ADDRINFO_H #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <stdbool.h> #ifdef __cplusplus extern "C" { #endif #if defined(_AIX) && !defined(_ALL_SOURCE) /* #define _ALL_SOURCE required for definition of struct addrinfo on AIX (!) */ /* !!Differs!! from Single Unix Specification SUSv6 (from 2004!) * http://pubs.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html */ struct addrinfo { /* AIX struct addrinfo DIFFERS FROM POSIX STANDARD! */ int ai_flags; int ai_family; int ai_socktype; int ai_protocol; size_t ai_addrlen; /* socklen_t in standard */ char *ai_canonname; /* order swapped with ai_addr in standard */ struct sockaddr *ai_addr; /* order swapped with ai_cannonname in standard*/ struct addrinfo *ai_next; }; #define AI_PASSIVE 0x02 /* specific to AIX */ #endif struct bsock_addrinfo_strs { const char *family; const char *socktype; const char *protocol; const char *service; const char *addr; }; /* ai->ai_addr must be provided containing usable storage of len ai->ai_addrlen * (recommended: #include <sys/socket.h> and use struct sockaddr_storage) */ bool __attribute__((nonnull)) bsock_addrinfo_from_strs(struct addrinfo * const restrict ai, const struct bsock_addrinfo_strs * const restrict aistr); bool __attribute__((nonnull)) bsock_addrinfo_to_strs(const struct addrinfo * const restrict ai, struct bsock_addrinfo_strs * const aistr, char * const restrict buf, const size_t bufsz); bool __attribute__((nonnull)) bsock_addrinfo_split_str(struct bsock_addrinfo_strs * const aistr, char * const restrict str); bool __attribute__((nonnull (2,3))) bsock_addrinfo_recv_ex (const int fd, struct addrinfo * const restrict ai, int * const restrict rfd, char * const restrict ctrlbuf, const size_t ctrlbuf_sz); #define bsock_addrinfo_recv(fd, ai, rfd) \ bsock_addrinfo_recv_ex((fd),(ai),(rfd),0,0) bool __attribute__((nonnull)) bsock_addrinfo_send (const int fd, const struct addrinfo * const restrict ai, const int sfd); #ifdef __cplusplus } #endif #endif /* * bsock_unix - unix domain socket sendmsg and recvmsg wrappers * * Copyright (c) 2011, Glue Logic LLC. All rights reserved. code()gluelogic.com * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Glue Logic LLC nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef INCLUDED_BSOCK_UNIX_H #define INCLUDED_BSOCK_UNIX_H #include <sys/types.h> #include <sys/uio.h> #ifdef __cplusplus extern "C" { #endif /* bsock stack allocation for recvmsg() ancillary data * On Linux, maximum length of ancillary data and user control data is set in * /proc/sys/net/core/optmem_max (man 3 cmsg, man 7 socket); customarily 10240. * RFC 3542: Advanced Sockets Application Program Interface (API) for IPv6 * RFC 3542 min ancillary data is 10240; recommends getsockopt SO_SNDBUF * (traditional BSD mbuf is 108, which is way too small for RFC 3542 spec) * * The reason this setting is important is because a client can send many file * descriptors. On Linux, even if recvmsg() reports MSG_CTRUNC, the file * descriptors that the client sent are still received by the server process * (up to sysconf(_SC_OPEN_MAX)), resulting in leakage of file descriptors * unless process takes extra measures to close fds it does not know about. * Such an undertaking is difficult to do correctly since process might not * know which fds have been opened by lower-level libraries, e.g. to syslog, * nscd, /etc/protocols, /etc/services, etc. Setting this buffer size to the * maximum allowed means that MSG_CTRUNC should not be possible. (Take care * if increasing size since buffer is allocated on stack (as of this writing.) * On Linux, client can send the same descriptor many times and it will be * dup'd and received many times by server. On Linux, there appears to be a * maximum of 255 file descriptors that can be sent with sendmsg() over unix * domain sockets, whether in one or many separate ancillary control buffers. * On Linux, these ancillary control buffers appear to be independent of * SO_RCVBUF and SO_SNDBUF sizes of either client or server; limiting size of * SO_RCVBUF and SO_SNDBUF has no effect on size of ancillary control buffers. * In any case, allocating /proc/sys/net/core/optmem_max for ancillary control * buffers prevents the possibility of MSG_CTRUNC on Linux. */ #ifndef BSOCK_ANCILLARY_DATA_MAX #define BSOCK_ANCILLARY_DATA_MAX 10240 #endif int __attribute__((nonnull)) bsock_unix_socket_connect (const char * const restrict sockpath); int __attribute__((nonnull)) bsock_unix_socket_bind_listen (const char * const restrict sockpath, int * const restrict bound); ssize_t __attribute__((nonnull (4))) bsock_unix_recv_fds (const int fd, int * const restrict rfds, unsigned int * const restrict nrfds, struct iovec * const restrict iov, const size_t iovlen); ssize_t __attribute__((nonnull (4,6))) bsock_unix_recv_fds_ex (const int fd, int * const restrict rfds, unsigned int * const restrict nrfds, struct iovec * const restrict iov, const size_t iovlen, char * const restrict ctrlbuf, const size_t ctrlbuf_sz); ssize_t __attribute__((nonnull (4))) bsock_unix_send_fds (const int fd, const int * const restrict sfds, unsigned int nsfds, struct iovec * const restrict iov, const size_t iovlen); int __attribute__((nonnull)) bsock_unix_getpeereid (const int s, uid_t * const restrict euid, gid_t * const restrict egid); #ifdef __cplusplus } #endif #endif /* Class autosprintf - formatted output to an ostream. Copyright (C) 2002, 2012-2016 Free Software Foundation, Inc. This program 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 program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _AUTOSPRINTF_H #define _AUTOSPRINTF_H /* This feature is available in gcc versions 2.5 and later. */ #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ # define _AUTOSPRINTF_ATTRIBUTE_FORMAT() /* empty */ #else /* The __-protected variants of 'format' and 'printf' attributes are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) # define _AUTOSPRINTF_ATTRIBUTE_FORMAT() \ __attribute__ ((__format__ (__printf__, 2, 3))) # else # define _AUTOSPRINTF_ATTRIBUTE_FORMAT() \ __attribute__ ((format (printf, 2, 3))) # endif #endif #include <string> #include <iostream> namespace gnu { /* A temporary object, usually allocated on the stack, representing the result of an asprintf() call. */ class autosprintf { public: /* Constructor: takes a format string and the printf arguments. */ autosprintf (const char *format, ...) _AUTOSPRINTF_ATTRIBUTE_FORMAT(); /* Copy constructor. */ autosprintf (const autosprintf& src); /* Assignment operator. */ autosprintf& operator = (autosprintf temporary); /* Destructor: frees the temporarily allocated string. */ ~autosprintf (); /* Conversion to string. */ operator char * () const; operator std::string () const; /* Output to an ostream. */ friend inline std::ostream& operator<< (std::ostream& stream, const autosprintf& tmp) { stream << (tmp.str ? tmp.str : "(error in autosprintf)"); return stream; } private: char *str; }; } #endif /* _AUTOSPRINTF_H */ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFF_ #define _TIFF_ #include "tiffconf.h" /* * Tag Image File Format (TIFF) * * Based on Rev 6.0 from: * Developer's Desk * Aldus Corporation * 411 First Ave. South * Suite 200 * Seattle, WA 98104 * 206-622-5500 * * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf) * * For BigTIFF design notes see the following links * http://www.remotesensing.org/libtiff/bigtiffdesign.html * http://www.awaresystems.be/imaging/tiff/bigtiff.html */ #define TIFF_VERSION_CLASSIC 42 #define TIFF_VERSION_BIG 43 #define TIFF_BIGENDIAN 0x4d4d #define TIFF_LITTLEENDIAN 0x4949 #define MDI_LITTLEENDIAN 0x5045 #define MDI_BIGENDIAN 0x4550 /* * Intrinsic data types required by the file format: * * 8-bit quantities int8_t/uint_8_t * 16-bit quantities int16_t/uint_16_t * 32-bit quantities int32_t/uint_32_t * 64-bit quantities int64_t/uint_64_t * strings unsigned char* */ #ifdef __GNUC__ #define TIFF_GCC_DEPRECATED __attribute__((deprecated)) #else #define TIFF_GCC_DEPRECATED #endif #ifdef _MSC_VER #define TIFF_MSC_DEPRECATED __declspec(deprecated("libtiff type deprecated; please use corresponding C99 stdint.h type")) #else #define TIFF_MSC_DEPRECATED #endif #ifndef TIFF_DISABLE_DEPRECATED typedef TIFF_MSC_DEPRECATED int8_t int8 TIFF_GCC_DEPRECATED; typedef TIFF_MSC_DEPRECATED uint8_t uint8 TIFF_GCC_DEPRECATED; typedef TIFF_MSC_DEPRECATED int16_t int16 TIFF_GCC_DEPRECATED; typedef TIFF_MSC_DEPRECATED uint16_t uint16 TIFF_GCC_DEPRECATED; typedef TIFF_MSC_DEPRECATED int32_t int32 TIFF_GCC_DEPRECATED; typedef TIFF_MSC_DEPRECATED uint32_t uint32 TIFF_GCC_DEPRECATED; typedef TIFF_MSC_DEPRECATED int64_t int64 TIFF_GCC_DEPRECATED; typedef TIFF_MSC_DEPRECATED uint64_t uint64 TIFF_GCC_DEPRECATED; #endif /* TIFF_DISABLE_DEPRECATED */ /* * Some types as promoted in a variable argument list * We use uint16_vap rather then directly using int, because this way * we document the type we actually want to pass through, conceptually, * rather then confusing the issue by merely stating the type it gets * promoted to */ typedef int uint16_vap; /* * TIFF header. */ typedef struct { uint16_t tiff_magic; /* magic number (defines byte order) */ uint16_t tiff_version; /* TIFF version number */ } TIFFHeaderCommon; typedef struct { uint16_t tiff_magic; /* magic number (defines byte order) */ uint16_t tiff_version; /* TIFF version number */ uint32_t tiff_diroff; /* byte offset to first directory */ } TIFFHeaderClassic; typedef struct { uint16_t tiff_magic; /* magic number (defines byte order) */ uint16_t tiff_version; /* TIFF version number */ uint16_t tiff_offsetsize; /* size of offsets, should be 8 */ uint16_t tiff_unused; /* unused word, should be 0 */ uint64_t tiff_diroff; /* byte offset to first directory */ } TIFFHeaderBig; /* * NB: In the comments below, * - items marked with a + are obsoleted by revision 5.0, * - items marked with a ! are introduced in revision 6.0. * - items marked with a % are introduced post revision 6.0. * - items marked with a $ are obsoleted by revision 6.0. * - items marked with a & are introduced by Adobe DNG specification. */ /* * Tag data type information. * * Note: RATIONALs are the ratio of two 32-bit integer values. *--: * Note2: TIFF_IFD8 data type is used in tiffFields[]-tag definition in order to distinguish the write-handling of those tags between ClassicTIFF and BigTiff: For ClassicTIFF libtiff writes a 32-bit value and the TIFF_IFD type-id into the file For BigTIFF libtiff writes a 64-bit value and the TIFF_IFD8 type-id into the file */ typedef enum { TIFF_NOTYPE = 0, /* placeholder */ TIFF_BYTE = 1, /* 8-bit unsigned integer */ TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ TIFF_SHORT = 3, /* 16-bit unsigned integer */ TIFF_LONG = 4, /* 32-bit unsigned integer */ TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ TIFF_SBYTE = 6, /* !8-bit signed integer */ TIFF_UNDEFINED = 7, /* !8-bit untyped data */ TIFF_SSHORT = 8, /* !16-bit signed integer */ TIFF_SLONG = 9, /* !32-bit signed integer */ TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ } TIFFDataType; /* * TIFF Tag Definitions. */ #define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ #define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ #define FILETYPE_PAGE 0x2 /* one page of many */ #define FILETYPE_MASK 0x4 /* transparency mask */ #define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ #define OFILETYPE_IMAGE 1 /* full resolution image data */ #define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ #define OFILETYPE_PAGE 3 /* one page of many */ #define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ #define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ #define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ #define TIFFTAG_COMPRESSION 259 /* data compression technique */ #define COMPRESSION_NONE 1 /* dump mode */ #define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ #define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ #define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ #define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ #define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ #define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ #define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ #define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ #define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ #define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ #define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ #define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ #define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ #define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ /* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT <dkelly@apago.com) */ #define COMPRESSION_IT8CTPAD 32895 /* IT8 CT w/padding */ #define COMPRESSION_IT8LW 32896 /* IT8 Linework RLE */ #define COMPRESSION_IT8MP 32897 /* IT8 Monochrome picture */ #define COMPRESSION_IT8BL 32898 /* IT8 Binary line art */ /* compression codes 32908-32911 are reserved for Pixar */ #define COMPRESSION_PIXARFILM 32908 /* Pixar companded 10bit LZW */ #define COMPRESSION_PIXARLOG 32909 /* Pixar companded 11bit ZIP */ #define COMPRESSION_DEFLATE 32946 /* Deflate compression, legacy tag */ #define COMPRESSION_ADOBE_DEFLATE 8 /* Deflate compression, as recognized by Adobe */ /* compression code 32947 is reserved for Oceana Matrix <dev@oceana.com> */ #define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ #define COMPRESSION_JBIG 34661 /* ISO JBIG */ #define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ #define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ #define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ #define COMPRESSION_LERC 34887 /* ESRI Lerc codec: https://github.com/Esri/lerc */ /* compression codes 34887-34889 are reserved for ESRI */ #define COMPRESSION_LZMA 34925 /* LZMA2 */ #define COMPRESSION_ZSTD 50000 /* ZSTD: WARNING not registered in Adobe-maintained registry */ #define COMPRESSION_WEBP 50001 /* WEBP: WARNING not registered in Adobe-maintained registry */ #define COMPRESSION_JXL 50002 /* JPEGXL: WARNING not registered in Adobe-maintained registry */ #define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ #define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ #define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ #define PHOTOMETRIC_RGB 2 /* RGB color model */ #define PHOTOMETRIC_PALETTE 3 /* color map indexed */ #define PHOTOMETRIC_MASK 4 /* $holdout mask */ #define PHOTOMETRIC_SEPARATED 5 /* !color separations */ #define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ #define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ #define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ #define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ #define PHOTOMETRIC_CFA 32803 /* color filter array */ #define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ #define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ #define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ #define THRESHHOLD_BILEVEL 1 /* b&w art scan */ #define THRESHHOLD_HALFTONE 2 /* or dithered scan */ #define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ #define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ #define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ #define TIFFTAG_FILLORDER 266 /* data order within a byte */ #define FILLORDER_MSB2LSB 1 /* most significant -> least */ #define FILLORDER_LSB2MSB 2 /* least significant -> most */ #define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ #define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ #define TIFFTAG_MAKE 271 /* scanner manufacturer name */ #define TIFFTAG_MODEL 272 /* scanner model name/number */ #define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ #define TIFFTAG_ORIENTATION 274 /* +image orientation */ #define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ #define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ #define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ #define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ #define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ #define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ #define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ #define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ #define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ #define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ #define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ #define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ #define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ #define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ #define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ #define TIFFTAG_PLANARCONFIG 284 /* storage organization */ #define PLANARCONFIG_CONTIG 1 /* single image plane */ #define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ #define TIFFTAG_PAGENAME 285 /* page name image is from */ #define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ #define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ #define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ #define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ #define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ #define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ #define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ #define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ #define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ #define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ #define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ #define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ #define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ #define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ #define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ #define RESUNIT_NONE 1 /* no meaningful units */ #define RESUNIT_INCH 2 /* english */ #define RESUNIT_CENTIMETER 3 /* metric */ #define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ #define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ #define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ #define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ #define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ #define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ #define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ #define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ #define TIFFTAG_SOFTWARE 305 /* name & release */ #define TIFFTAG_DATETIME 306 /* creation date and time */ #define TIFFTAG_ARTIST 315 /* creator of image */ #define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ #define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ #define PREDICTOR_NONE 1 /* no prediction scheme used */ #define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ #define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ #define TIFFTAG_WHITEPOINT 318 /* image white point */ #define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ #define TIFFTAG_COLORMAP 320 /* RGB map for palette image */ #define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ #define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ #define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ #define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ #define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ #define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ #define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ #define CLEANFAXDATA_CLEAN 0 /* no errors detected */ #define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ #define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ #define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ #define TIFFTAG_SUBIFD 330 /* subimage descriptors */ #define TIFFTAG_INKSET 332 /* !inks in separated image */ #define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ #define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ #define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ #define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ #define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ #define TIFFTAG_TARGETPRINTER 337 /* !separation target */ #define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ #define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ #define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ #define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ #define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ #define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ #define SAMPLEFORMAT_INT 2 /* !signed integer data */ #define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ #define SAMPLEFORMAT_VOID 4 /* !untyped data */ #define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ #define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ #define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ #define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ #define TIFFTAG_CLIPPATH 343 /* %ClipPath [Adobe TIFF technote 2] */ #define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits [Adobe TIFF technote 2] */ #define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits [Adobe TIFF technote 2] */ #define TIFFTAG_INDEXED 346 /* %Indexed [Adobe TIFF Technote 3] */ #define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ #define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ /* Tags 400-435 are from the TIFF/FX spec */ #define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ #define TIFFTAG_PROFILETYPE 401 /* ! */ #define PROFILETYPE_UNSPECIFIED 0 /* ! */ #define PROFILETYPE_G3_FAX 1 /* ! */ #define TIFFTAG_FAXPROFILE 402 /* ! */ #define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ #define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ #define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ #define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ #define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ #define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ #define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ #define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ #define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ #define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ #define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ #define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ #define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ #define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ #define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ #define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ #define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ #define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ /* * Tags 512-521 are obsoleted by Technical Note #2 which specifies a * revised JPEG-in-TIFF scheme. */ #define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ #define JPEGPROC_BASELINE 1 /* !baseline sequential */ #define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ #define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ #define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ #define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ #define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ #define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ #define TIFFTAG_JPEGQTABLES 519 /* !Q matrix offsets */ #define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ #define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ #define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ #define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ #define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ #define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ #define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ #define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ #define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ #define TIFFTAG_XMLPACKET 700 /* %XML packet [Adobe XMP Specification, January 2004 */ #define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID [Adobe TIFF technote] */ #define TIFFTAG_TIFFANNOTATIONDATA 32932 /* http://web.archive.org/web/20050309141348/http://www.kofile.com/support%20pro/faqs/annospec.htm */ /* tags 32952-32956 are private tags registered to Island Graphics */ #define TIFFTAG_REFPTS 32953 /* image reference points */ #define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ #define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ #define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ /* tags 32995-32999 are private tags registered to SGI */ #define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ #define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ #define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ #define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ /* tags 33300-33309 are private tags registered to Pixar */ /* * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH * are set when an image has been cropped out of a larger image. * They reflect the size of the original uncropped image. * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used * to determine the position of the smaller image in the larger one. */ #define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ #define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ /* Tags 33302-33306 are used to identify special image modes and data * used by Pixar's texture formats. */ #define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ #define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ #define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ #define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 #define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 /* tag 33405 is a private tag registered to Eastman Kodak */ #define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ #define TIFFTAG_CFAREPEATPATTERNDIM 33421 /* dimensions of CFA pattern */ #define TIFFTAG_CFAPATTERN 33422 /* color filter array pattern */ /* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ #define TIFFTAG_COPYRIGHT 33432 /* copyright string */ /* Tags 33445-33452 are used for GEL fileformat, see * http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ #define TIFFTAG_MD_FILETAG 33445 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ #define TIFFTAG_MD_SCALEPIXEL 33446 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ #define TIFFTAG_MD_COLORTABLE 33447 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ #define TIFFTAG_MD_LABNAME 33448 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ #define TIFFTAG_MD_SAMPLEINFO 33449 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ #define TIFFTAG_MD_PREPDATE 33450 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ #define TIFFTAG_MD_PREPTIME 33451 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ #define TIFFTAG_MD_FILEUNITS 33452 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ /* IPTC TAG from RichTIFF specifications */ #define TIFFTAG_RICHTIFFIPTC 33723 #define TIFFTAG_INGR_PACKET_DATA_TAG 33918 /* Intergraph Application specific storage. */ #define TIFFTAG_INGR_FLAG_REGISTERS 33919 /* Intergraph Application specific flags. */ #define TIFFTAG_IRASB_TRANSORMATION_MATRIX 33920 /* Originally part of Intergraph's GeoTIFF tags, but likely understood by IrasB only. */ #define TIFFTAG_MODELTIEPOINTTAG 33922 /* GeoTIFF */ /* 34016-34029 are reserved for ANSI IT8 TIFF/IT <dkelly@apago.com) */ #define TIFFTAG_IT8SITE 34016 /* site name */ #define TIFFTAG_IT8COLORSEQUENCE 34017 /* color seq. [RGB,CMYK,etc] */ #define TIFFTAG_IT8HEADER 34018 /* DDES Header */ #define TIFFTAG_IT8RASTERPADDING 34019 /* raster scanline padding */ #define TIFFTAG_IT8BITSPERRUNLENGTH 34020 /* # of bits in short run */ #define TIFFTAG_IT8BITSPEREXTENDEDRUNLENGTH 34021/* # of bits in long run */ #define TIFFTAG_IT8COLORTABLE 34022 /* LW colortable */ #define TIFFTAG_IT8IMAGECOLORINDICATOR 34023 /* BP/BL image color switch */ #define TIFFTAG_IT8BKGCOLORINDICATOR 34024 /* BP/BL bg color switch */ #define TIFFTAG_IT8IMAGECOLORVALUE 34025 /* BP/BL image color value */ #define TIFFTAG_IT8BKGCOLORVALUE 34026 /* BP/BL bg color value */ #define TIFFTAG_IT8PIXELINTENSITYRANGE 34027 /* MP pixel intensity value */ #define TIFFTAG_IT8TRANSPARENCYINDICATOR 34028 /* HC transparency switch */ #define TIFFTAG_IT8COLORCHARACTERIZATION 34029 /* color character. table */ #define TIFFTAG_IT8HCUSAGE 34030 /* HC usage indicator */ #define TIFFTAG_IT8TRAPINDICATOR 34031 /* Trapping indicator (untrapped=0, trapped=1) */ #define TIFFTAG_IT8CMYKEQUIVALENT 34032 /* CMYK color equivalents */ /* tags 34232-34236 are private tags registered to Texas Instruments */ #define TIFFTAG_FRAMECOUNT 34232 /* Sequence Frame Count */ #define TIFFTAG_MODELTRANSFORMATIONTAG 34264 /* Used in interchangeable GeoTIFF files */ /* tag 34377 is private tag registered to Adobe for PhotoShop */ #define TIFFTAG_PHOTOSHOP 34377 /* tags 34665, 34853 and 40965 are documented in EXIF specification */ #define TIFFTAG_EXIFIFD 34665 /* Pointer to EXIF private directory */ /* tag 34750 is a private tag registered to Adobe? */ #define TIFFTAG_ICCPROFILE 34675 /* ICC profile data */ #define TIFFTAG_IMAGELAYER 34732 /* !TIFF/FX image layer information */ /* tag 34750 is a private tag registered to Pixel Magic */ #define TIFFTAG_JBIGOPTIONS 34750 /* JBIG options */ #define TIFFTAG_GPSIFD 34853 /* Pointer to GPS private directory */ /* tags 34908-34914 are private tags registered to SGI */ #define TIFFTAG_FAXRECVPARAMS 34908 /* encoded Class 2 ses. params */ #define TIFFTAG_FAXSUBADDRESS 34909 /* received SubAddr string */ #define TIFFTAG_FAXRECVTIME 34910 /* receive time (secs) */ #define TIFFTAG_FAXDCS 34911 /* encoded fax ses. params, Table 2/T.30 */ /* tags 37439-37443 are registered to SGI <gregl@sgi.com> */ #define TIFFTAG_STONITS 37439 /* Sample value to Nits */ /* tag 34929 is a private tag registered to FedEx */ #define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ #define TIFFTAG_IMAGESOURCEDATA 37724 /* http://justsolve.archiveteam.org/wiki/PSD, http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/ */ #define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */ #define TIFFTAG_GDAL_METADATA 42112 /* Used by the GDAL library */ #define TIFFTAG_GDAL_NODATA 42113 /* Used by the GDAL library */ #define TIFFTAG_OCE_SCANJOB_DESCRIPTION 50215 /* Used in the Oce scanning process */ #define TIFFTAG_OCE_APPLICATION_SELECTOR 50216 /* Used in the Oce scanning process. */ #define TIFFTAG_OCE_IDENTIFICATION_NUMBER 50217 #define TIFFTAG_OCE_IMAGELOGIC_CHARACTERISTICS 50218 /* tags 50674 to 50677 are reserved for ESRI */ #define TIFFTAG_LERC_PARAMETERS 50674 /* Stores LERC version and additional compression method */ /* Adobe Digital Negative (DNG) format tags */ #define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ #define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ #define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ #define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model name */ #define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space mapping */ #define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ #define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ #define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for the BlackLevel tag */ #define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ #define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level differences (columns) */ #define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level differences (rows) */ #define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding level */ #define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ #define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image area */ #define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image area */ #define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space transformation matrix 1 */ #define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space transformation matrix 2 */ #define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ #define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ #define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction matrix 1 */ #define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction matrix 2 */ #define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw values*/ #define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in linear reference space */ #define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in x-y chromaticity coordinates */ #define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero point */ #define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ #define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of sharpening */ #define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of the green pixels in the blue/green rows track the values of the green pixels in the red/green rows */ #define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ #define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ #define TIFFTAG_LENSINFO 50736 /* info about the lens */ #define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ #define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the camera's anti-alias filter */ #define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ #define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ #define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote tag is safe to preserve along with the rest of the EXIF data */ #define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ #define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ #define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ #define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for the raw image data */ #define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original raw file */ #define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original raw file */ #define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels of the sensor */ #define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates of fully masked pixels */ #define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ #define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space into ICC profile space */ #define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ #define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ #define TIFFTAG_RPCCOEFFICIENT 50844 /* Define by GDAL for geospatial georeferencing through RPC: http://geotiff.maptools.org/rpc_prop.html */ #define TIFFTAG_ALIAS_LAYER_METADATA 50784 /* Alias Sketchbook Pro layer usage description. */ /* GeoTIFF DGIWG */ #define TIFFTAG_TIFF_RSID 50908 /* https://www.awaresystems.be/imaging/tiff/tifftags/tiff_rsid.html */ #define TIFFTAG_GEO_METADATA 50909 /* https://www.awaresystems.be/imaging/tiff/tifftags/geo_metadata.html */ #define TIFFTAG_EXTRACAMERAPROFILES 50933 /* http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/photoshop/pdfs/dng_spec_1.4.0.0.pdf */ /* tag 65535 is an undefined tag used by Eastman Kodak */ #define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ /* * The following are ``pseudo tags'' that can be used to control * codec-specific functionality. These tags are not written to file. * Note that these values start at 0xffff+1 so that they'll never * collide with Aldus-assigned tags. * * If you want your private pseudo tags ``registered'' (i.e. added to * this file), please post a bug report via the tracking system at * http://www.remotesensing.org/libtiff/bugs.html with the appropriate * C definitions to add. */ #define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ #define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ #define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ #define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ #define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ #define FAXMODE_WORDALIGN 0x0008 /* word align row */ #define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ #define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ /* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ #define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ #define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ #define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ #define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ #define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ #define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ /* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ #define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ #define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ #define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ #define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ #define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ #define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ #define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ #define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ /* 65550-65556 are allocated to Oceana Matrix <dev@oceana.com> */ #define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ #define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ #define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ #define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ #define DCSIMAGERFILTER_IR 0 /* infrared filter */ #define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ #define DCSIMAGERFILTER_CFA 2 /* color filter array */ #define DCSIMAGERFILTER_OTHER 3 /* other filter */ #define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ #define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ #define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ #define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ #define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ #define TIFFTAG_DCSGAMMA 65554 /* gamma value */ #define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ #define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ /* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ #define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ #define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ /* 65559 is allocated to Oceana Matrix <dev@oceana.com> */ #define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ #define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ #define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ #define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ #define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ #define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ #define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ #define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ #define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ #define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ #define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ #define PERSAMPLE_MERGED 0 /* present as a single value */ #define PERSAMPLE_MULTI 1 /* present as multiple values */ #define TIFFTAG_ZSTD_LEVEL 65564 /* ZSTD compression level */ #define TIFFTAG_LERC_VERSION 65565 /* LERC version */ #define LERC_VERSION_2_4 4 #define TIFFTAG_LERC_ADD_COMPRESSION 65566 /* LERC additional compression */ #define LERC_ADD_COMPRESSION_NONE 0 #define LERC_ADD_COMPRESSION_DEFLATE 1 #define LERC_ADD_COMPRESSION_ZSTD 2 #define TIFFTAG_LERC_MAXZERROR 65567 /* LERC maximum error */ #define TIFFTAG_WEBP_LEVEL 65568 /* WebP compression level */ #define TIFFTAG_WEBP_LOSSLESS 65569 /* WebP lossless/lossy */ #define TIFFTAG_DEFLATE_SUBCODEC 65570 /* ZIP codec: to get/set the sub-codec to use. Will default to libdeflate when available */ #define DEFLATE_SUBCODEC_ZLIB 0 #define DEFLATE_SUBCODEC_LIBDEFLATE 1 /* * EXIF tags */ #define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ #define EXIFTAG_FNUMBER 33437 /* F number */ #define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ #define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ #define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ #define EXIFTAG_PHOTOGRAPHICSENSITIVITY 34855 /* Photographic Sensitivity (new name for tag 34855) */ #define EXIFTAG_OECF 34856 /* Optoelectric conversion factor */ #define EXIFTAG_EXIFVERSION 36864 /* Exif version */ #define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original data generation */ #define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital data generation */ #define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ #define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ #define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ #define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ #define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ #define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ #define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ #define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ #define EXIFTAG_METERINGMODE 37383 /* Metering mode */ #define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ #define EXIFTAG_FLASH 37385 /* Flash */ #define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ #define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ #define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ #define EXIFTAG_USERCOMMENT 37510 /* User comments */ #define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ #define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ #define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ #define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ #define EXIFTAG_COLORSPACE 40961 /* Color space information */ #define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ #define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ #define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ #define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ #define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ #define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ #define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ #define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ #define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ #define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ #define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ #define EXIFTAG_FILESOURCE 41728 /* File source */ #define EXIFTAG_SCENETYPE 41729 /* Scene type */ #define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ #define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ #define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ #define EXIFTAG_WHITEBALANCE 41987 /* White balance */ #define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ #define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ #define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ #define EXIFTAG_GAINCONTROL 41991 /* Gain control */ #define EXIFTAG_CONTRAST 41992 /* Contrast */ #define EXIFTAG_SATURATION 41993 /* Saturation */ #define EXIFTAG_SHARPNESS 41994 /* Sharpness */ #define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ #define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ #define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ /*--: New for EXIF-Version 2.32, May 2019 ... */ #define EXIFTAG_SENSITIVITYTYPE 34864 /* The SensitivityType tag indicates which one of the parameters of ISO12232 is the PhotographicSensitivity tag. */ #define EXIFTAG_STANDARDOUTPUTSENSITIVITY 34865 /* This tag indicates the standard output sensitivity value of a camera or input device defined in ISO 12232. */ #define EXIFTAG_RECOMMENDEDEXPOSUREINDEX 34866 /* recommended exposure index */ #define EXIFTAG_ISOSPEED 34867 /* ISO speed value */ #define EXIFTAG_ISOSPEEDLATITUDEYYY 34868 /* ISO speed latitude yyy */ #define EXIFTAG_ISOSPEEDLATITUDEZZZ 34869 /* ISO speed latitude zzz */ #define EXIFTAG_OFFSETTIME 36880 /* offset from UTC of the time of DateTime tag. */ #define EXIFTAG_OFFSETTIMEORIGINAL 36881 /* offset from UTC of the time of DateTimeOriginal tag. */ #define EXIFTAG_OFFSETTIMEDIGITIZED 36882 /* offset from UTC of the time of DateTimeDigitized tag. */ #define EXIFTAG_TEMPERATURE 37888 /* Temperature as the ambient situation at the shot in dergee Celsius */ #define EXIFTAG_HUMIDITY 37889 /* Humidity as the ambient situation at the shot in percent */ #define EXIFTAG_PRESSURE 37890 /* Pressure as the ambient situation at the shot hecto-Pascal (hPa) */ #define EXIFTAG_WATERDEPTH 37891 /* WaterDepth as the ambient situation at the shot in meter (m) */ #define EXIFTAG_ACCELERATION 37892 /* Acceleration (a scalar regardless of direction) as the ambient situation at the shot in units of mGal (10-5 m/s^2) */ #define EXIFTAG_CAMERAELEVATIONANGLE 37893 /* Elevation/depression. angle of the orientation of the camera(imaging optical axis) as the ambient situation at the shot in degree from -180deg to +180deg. */ #define EXIFTAG_CAMERAOWNERNAME 42032 /* owner of a camera */ #define EXIFTAG_BODYSERIALNUMBER 42033 /* serial number of the body of the camera */ #define EXIFTAG_LENSSPECIFICATION 42034 /* minimum focal length (in mm), maximum focal length (in mm), minimum F number in the minimum focal length, and minimum F number in the maximum focal length, */ #define EXIFTAG_LENSMAKE 42035 /* the lens manufacturer */ #define EXIFTAG_LENSMODEL 42036 /* the lens model name and model number */ #define EXIFTAG_LENSSERIALNUMBER 42037 /* the serial number of the interchangeable lens */ #define EXIFTAG_GAMMA 42240 /* value of coefficient gamma */ #define EXIFTAG_COMPOSITEIMAGE 42080 /* composite image */ #define EXIFTAG_SOURCEIMAGENUMBEROFCOMPOSITEIMAGE 42081 /* source image number of composite image */ #define EXIFTAG_SOURCEEXPOSURETIMESOFCOMPOSITEIMAGE 42082 /* source exposure times of composite image */ /* * EXIF-GPS tags (Version 2.31, July 2016) */ #define GPSTAG_VERSIONID 0 /* Indicates the version of GPSInfoIFD. */ #define GPSTAG_LATITUDEREF 1 /* Indicates whether the latitude is north or south latitude. */ #define GPSTAG_LATITUDE 2 /* Indicates the latitude. */ #define GPSTAG_LONGITUDEREF 3 /* Indicates whether the longitude is east or west longitude. */ #define GPSTAG_LONGITUDE 4 /* Indicates the longitude. */ #define GPSTAG_ALTITUDEREF 5 /* Indicates the altitude used as the reference altitude. */ #define GPSTAG_ALTITUDE 6 /* Indicates the altitude based on the reference in GPSAltitudeRef. */ #define GPSTAG_TIMESTAMP 7 /* Indicates the time as UTC (Coordinated Universal Time). */ #define GPSTAG_SATELLITES 8 /* Indicates the GPS satellites used for measurements. */ #define GPSTAG_STATUS 9 /* Indicates the status of the GPS receiver when the image is recorded. */ #define GPSTAG_MEASUREMODE 10 /* Indicates the GPS measurement mode. */ #define GPSTAG_DOP 11 /* Indicates the GPS DOP (data degree of precision). */ #define GPSTAG_SPEEDREF 12 /* Indicates the unit used to express the GPS receiver speed of movement. */ #define GPSTAG_SPEED 13 /* Indicates the speed of GPS receiver movement. */ #define GPSTAG_TRACKREF 14 /* Indicates the reference for giving the direction of GPS receiver movement. */ #define GPSTAG_TRACK 15 /* Indicates the direction of GPS receiver movement. */ #define GPSTAG_IMGDIRECTIONREF 16 /* Indicates the reference for giving the direction of the image when it is captured. */ #define GPSTAG_IMGDIRECTION 17 /* Indicates the direction of the image when it was captured. */ #define GPSTAG_MAPDATUM 18 /* Indicates the geodetic survey data used by the GPS receiver. (e.g. WGS-84) */ #define GPSTAG_DESTLATITUDEREF 19 /* Indicates whether the latitude of the destination point is north or south latitude. */ #define GPSTAG_DESTLATITUDE 20 /* Indicates the latitude of the destination point. */ #define GPSTAG_DESTLONGITUDEREF 21 /* Indicates whether the longitude of the destination point is east or west longitude. */ #define GPSTAG_DESTLONGITUDE 22 /* Indicates the longitude of the destination point. */ #define GPSTAG_DESTBEARINGREF 23 /* Indicates the reference used for giving the bearing to the destination point. */ #define GPSTAG_DESTBEARING 24 /* Indicates the bearing to the destination point. */ #define GPSTAG_DESTDISTANCEREF 25 /* Indicates the unit used to express the distance to the destination point. */ #define GPSTAG_DESTDISTANCE 26 /* Indicates the distance to the destination point. */ #define GPSTAG_PROCESSINGMETHOD 27 /* A character string recording the name of the method used for location finding. */ #define GPSTAG_AREAINFORMATION 28 /* A character string recording the name of the GPS area. */ #define GPSTAG_DATESTAMP 29 /* A character string recording date and time information relative to UTC (Coordinated Universal Time). */ #define GPSTAG_DIFFERENTIAL 30 /* Indicates whether differential correction is applied to the GPS receiver. */ #define GPSTAG_GPSHPOSITIONINGERROR 31 /* Indicates horizontal positioning errors in meters. */ #endif /* _TIFF_ */ /* vim: set ts=8 sts=8 sw=8 noet: */ /* * Local Variables: * mode: c * c-basic-offset: 8 * fill-column: 78 * End: */ /* * Copyright (c) 2014 by Farsight Security, Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #ifndef FSTRM_UNIX_WRITER_H #define FSTRM_UNIX_WRITER_H /** * \defgroup fstrm_unix_writer fstrm_unix_writer * * `fstrm_unix_writer` is an interface for opening an \ref fstrm_writer object * that is backed by I/O on a stream-oriented (`SOCK_STREAM`) Unix socket. * * @{ */ /** * Initialize an `fstrm_unix_writer_options` object, which is needed to * configure the socket path to be opened by the writer. * * \return * `fstrm_unix_writer_options` object. */ struct fstrm_unix_writer_options * fstrm_unix_writer_options_init(void); /** * Destroy an `fstrm_unix_writer_options` object. * * \param uwopt * Pointer to `fstrm_unix_writer_options` object. */ void fstrm_unix_writer_options_destroy( struct fstrm_unix_writer_options **uwopt); /** * Set the `socket_path` option. This is a filesystem path that will be * connected to as an `AF_UNIX` socket. * * \param uwopt * `fstrm_unix_writer_options` object. * \param socket_path * The filesystem path to the `AF_UNIX` socket. */ void fstrm_unix_writer_options_set_socket_path( struct fstrm_unix_writer_options *uwopt, const char *socket_path); /** * Initialize the `fstrm_writer` object. Note that the `AF_UNIX` socket will not * actually be opened until a subsequent call to fstrm_writer_open(). * * \param uwopt * `fstrm_unix_writer_options` object. Must be non-NULL, and have the * `socket_path` option set. * \param wopt * `fstrm_writer_options` object. May be NULL, in which chase default * values will be used. * * \return * `fstrm_writer` object. * \retval * NULL on failure. */ struct fstrm_writer * fstrm_unix_writer_init( const struct fstrm_unix_writer_options *uwopt, const struct fstrm_writer_options *wopt); /**@}*/ #endif /* FSTRM_UNIX_WRITER_H */ /* * Copyright (c) 2014 by Farsight Security, Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #ifndef FSTRM_RDWR_H #define FSTRM_RDWR_H /** * \defgroup fstrm_rdwr fstrm_rdwr * * `fstrm_rdwr` is an interface for abstracting the process of reading and * writing data to byte streams. It allows extending the `fstrm` library to * support reading and writing Frame Streams data to new kinds of byte stream * transports. (It also allows building mock interfaces for testing the correct * functioning of the library.) * * `fstrm_rdwr` is a low-level interface that is used in conjunction with the * higher level \ref fstrm_reader and \ref fstrm_writer interfaces. The * following methods need to be defined for `fstrm_rdwr` implementations: * * Method name | Method type | Method description * ------------ | ----------------------------- | ------------------ * `destroy` | #fstrm_rdwr_destroy_func | Destroys the instance. * `open` | #fstrm_rdwr_open_func | Opens the stream. * `close` | #fstrm_rdwr_close_func | Closes the stream. * `read` | #fstrm_rdwr_read_func | Reads bytes from the stream. * `write` | #fstrm_rdwr_write_func | Writes bytes to the stream. * * The `destroy` method is optional. It cleans up any remaining resources * associated with the instance. * * The `open` method is required. It should perform the actual opening of the * byte stream and prepare it to read or write data. * * The `close` method is required. It should perform the actual closing of the * byte stream. * * If the `fstrm_rdwr` object is to be used in an `fstrm_reader` object, it must * have a `read` method. If the `fstrm_rdwr` object embedded in an * `fstrm_reader` object also has a `write` method, the stream will be * considered bi-directional (that is, it supports both reading and writing) and * handshaking will be performed. If a `read` method is supplied but a `write` * method is not, the reader's stream will instead be considered * uni-directional. See \ref fstrm_reader for details. * * If the `fstrm_rdwr` object is to be used in an `fstrm_writer` object, it must * have a `write` method. If the `fstrm_rdwr` object embedded in an * `fstrm_writer` object also has a `read` method, the stream will be considered * bi-directional and shaking will be performed. If a `write` method is supplied * but a `read` method is not, the writer's stream will instead be considered * uni-directional. See \ref fstrm_writer for details. * * An `fstrm_rdwr` instance is created with a call to `fstrm_rdwr_init()`, * optionally passing a pointer to some state object associated with the * instance. This pointer will be passed as the first argument to each of the * methods described above. Then, the various `fstrm_rdwr_set_*()` functions * should be used to configure the functions to be used to invoke the methods * required for the `fstrm_rdwr` object. * * @{ */ /** * `destroy` method function type. This method is invoked to deallocate any * per-stream resources used by an `fstrm_rdwr` implementation. * * \see fstrm_rdwr_set_destroy() * * \param obj * The `obj` value passed to `fstrm_rdwr_init()`. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ typedef fstrm_res (*fstrm_rdwr_destroy_func)(void *obj); /** * `open` method function type. This method is invoked to open the stream and * prepare it for reading or writing. For example, if an `fstrm_rdwr` * implementation is backed by file I/O, this method might be responsible for * opening a file descriptor. * * \see fstrm_rdwr_set_open() * * \param obj * The `obj` value passed to `fstrm_rdwr_init()`. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ typedef fstrm_res (*fstrm_rdwr_open_func)(void *obj); /** * `close` method function type. This method is invoked to close the stream. For * example, if an `fstrm_rdwr` implementation is backed by file I/O, this method * might be responsible for closing a file descriptor. * * \see fstrm_rdwr_set_close() * * \param obj * The `obj` value passed to `fstrm_rdwr_init()`. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ typedef fstrm_res (*fstrm_rdwr_close_func)(void *obj); /** * `read` method function type. This method is used to read data from a stream. * It must satisfy the full amount of data requested, unless the stream has * ended. * * \see fstrm_rdwr_set_read() * * \param obj * The `obj` value passed to `fstrm_rdwr_init()`. * \param data * The buffer in which to place the data read. * \param count * The number of bytes requested. * * \retval #fstrm_res_success * The data was read successfully. * \retval #fstrm_res_failure * An unexpected failure occurred. * \retval #fstrm_res_stop * The end of the stream has occurred. */ typedef fstrm_res (*fstrm_rdwr_read_func)(void *obj, void *data, size_t count); /** * `write` method function type. This method is used to write data to a stream. * It must perform the full write of all data, unless an error has occurred. * * \see fstrm_rdwr_set_write() * * \param obj * The `obj` value passed to `fstrm_rdwr_init()`. * \param iov * Array of `struct iovec` objects. * \param iovcnt * Number of `struct iovec` objects in `iov`. * * \return #fstrm_res_success * \return #fstrm_res_failure */ typedef fstrm_res (*fstrm_rdwr_write_func)(void *obj, const struct iovec *iov, int iovcnt); /** * Initialize a new `fstrm_rdwr` object. * * \param obj * Per-object state. * * \return * `fstrm_rdwr` object. * \retval * NULL on failure. */ struct fstrm_rdwr * fstrm_rdwr_init(void *obj); /** * Destroy an `fstrm_rdwr` object. This invokes the underlying `destroy` method * as well. * * \param rdwr * Pointer to an `fstrm_rdwr` object. * * \return #fstrm_res_success * \return #fstrm_res_failure */ fstrm_res fstrm_rdwr_destroy(struct fstrm_rdwr **rdwr); /** * Invoke the `open` method on an `fstrm_rdwr` object. * * \param rdwr * The `fstrm_rdwr` object. * * \return #fstrm_res_success * \return #fstrm_res_failure */ fstrm_res fstrm_rdwr_open(struct fstrm_rdwr *rdwr); /** * Invoke the `close` method on an `fstrm_rdwr` object. * * \param rdwr * The `fstrm_rdwr` object. * * \return #fstrm_res_success * \return #fstrm_res_failure */ fstrm_res fstrm_rdwr_close(struct fstrm_rdwr *rdwr); /** * Invoke the `read` method on an `fstrm_rdwr` object. * * \param rdwr * The `fstrm_rdwr` object. * \param data * The buffer in which to place the data read. * \param count * The number of bytes to read. * * \return #fstrm_res_success * \return #fstrm_res_failure * \return #fstrm_res_stop */ fstrm_res fstrm_rdwr_read(struct fstrm_rdwr *rdwr, void *data, size_t count); /** * Invoke the `write` method on an `fstrm_rdwr` object. * * \param rdwr * The `fstrm_rdwr` object. * \param iov * Array of `struct iovec` objects. * \param iovcnt * Number of `struct iovec` objects in `iov`. * * \return #fstrm_res_success * \return #fstrm_res_failure */ fstrm_res fstrm_rdwr_write(struct fstrm_rdwr *rdwr, const struct iovec *iov, int iovcnt); /** * Set the `destroy` method for an `fstrm_rdwr` object. * * \param rdwr * The `fstrm_rdwr` object. * \param fn * Function to use. */ void fstrm_rdwr_set_destroy( struct fstrm_rdwr *rdwr, fstrm_rdwr_destroy_func fn); /** * Set the `open` method for an `fstrm_rdwr` object. * * \param rdwr * The `fstrm_rdwr` object. * \param fn * Function to use. */ void fstrm_rdwr_set_open( struct fstrm_rdwr *rdwr, fstrm_rdwr_open_func fn); /** * Set the `close` method for an `fstrm_rdwr` object. * * \param rdwr * The `fstrm_rdwr` object. * \param fn * Function to use. */ void fstrm_rdwr_set_close( struct fstrm_rdwr *rdwr, fstrm_rdwr_close_func fn); /** * Set the `read` method for an `fstrm_rdwr` object. * * \param rdwr * The `fstrm_rdwr` object. * \param fn * Function to use. */ void fstrm_rdwr_set_read( struct fstrm_rdwr *rdwr, fstrm_rdwr_read_func fn); /** * Set the `write` method for an `fstrm_rdwr` object. * * \param rdwr * The `fstrm_rdwr` object. * \param fn * Function to use. */ void fstrm_rdwr_set_write( struct fstrm_rdwr *rdwr, fstrm_rdwr_write_func fn); /**@}*/ #endif /* FSTRM_RDWR_H */ /* * Copyright (c) 2014 by Farsight Security, Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #ifndef FSTRM_CONTROL_H #define FSTRM_CONTROL_H /** * \defgroup fstrm_control fstrm_control * * `fstrm_control` is an interface for encoding and decoding Frame Streams * control frames. * * Two types of frames are possible in a Frame Streams byte stream: **data * frames** and **control frames**. Both are variable length byte sequences * prefixed by a 32-bit big endian unsigned integer (the **frame length**) * specifying the length of the following byte sequence. If this frame length * value is greater than zero, the **frame length** specifies the **data frame * length**, and a data frame follows it. If the frame length is zero (i.e., it * is the four byte sequence `00 00 00 00`), this is an **escape sequence**, * which means that a control frame follows. The control frame itself is * prefixed by a 32-bit big endian unsigned integer (the **control frame * length**) specifying the length of the following **control frame payload**. * * There are two types of control frames used for uni-directional streams: * `START` and `STOP`. These control frame types bracket the stream of data * frames. `START` indicates the beginning of the stream and communicates * metadata about the stream to follow, and `STOP` indicates the end of the * stream. * * Bi-directional streams make use of three additional control frame types: * `READY`, `ACCEPT`, and `FINISH`. These control frame types are used in a * simple handshake protocol between sender and receiver. * * A uni-directional Frame Streams byte stream normally consists of the * following: * * 1. The `START` control frame. * 2. A sequence of zero or more data frames or control frames that are not of * the control frame types `START`, `STOP`, `ACCEPT`, `READY`, or * `FINISH`. * 3. The `STOP` control frame. * * The `START` and `STOP` control frames are not optional. The `START` control * frame must appear at the beginning of the byte stream, and the `STOP` control * frame must appear at the end of the byte stream. (If the byte stream has an * end.) `START` control frames must not appear anywhere other than at the * beginning of the byte stream, and `STOP` control frames must not appear * anywhere other than at the end of the byte stream. Only one `START` control * frame and only one `STOP` control frame may appear in a Frame Streams byte * stream. * * Control frames may optionally include zero or more **control frame fields**. * There is currently one type of control frame field defined: `CONTENT_TYPE`. * This field specifies a variable length byte sequence describing the encoding * of data frames that appear in the Frame Streams byte stream. This field is * used by cooperating programs to unambiguously identify how to interpret the * data frames in a particular Frame Streams byte stream. For instance, this * field may specify a particular schema to use to interpret the data frames * appearing in the byte stream. Zero, one, or more `CONTENT_TYPE` fields may * appear in `READY` or `ACCEPT` control frames. Zero or one `CONTENT_TYPE` * fields may appear in `START` control frames. No `CONTENT_TYPE` fields may * appear in `STOP` or `FINISH` control frames. * * A uni-directional Frame Streams encoder would normally produce a byte stream * as follows: * * 1. Write the `START` **control frame**. * + At the start of the byte stream, write the four byte **escape * sequence** `00 00 00 00` that precedes control frames. * + Write the **control frame length** as a 32-bit big endian unsigned * integer. * + Write the **control frame payload**. It must be a `START` control * frame. It may optionally specify a `CONTENT_TYPE` field. * 2. Write zero or more **data frames**. * 3. Write the `STOP` **control frame**. * + At the start of the byte stream, write the four byte **escape * sequence** `00 00 00 00` that precedes control frames. * + Write the **control frame length** as a 32-bit big endian unsigned * integer. * + Write the **control frame payload**. It must be a `STOP` control * frame. * * A uni-directional Frame Streams decoder would normally process the byte * stream as follows: * * 1. Read the `START` control frame. * + At the start of the byte stream, read the four byte **escape * sequence** `00 00 00 00` that precedes control frames. * + Read the 32-bit big endian unsigned integer specifying the **control * frame length**. * + Decode the **control frame payload**. It must be a `START` control * frame. It may optionally specify a `CONTENT_TYPE` field. * 2. Repeatedly read data frames or control frames following the `START` * control frame. * + Read the **frame length**, a 32-bit big endian unsigned integer. * + If the **frame length** is zero, a control frame follows: * + Read the 32-bit big endian unsigned integer specifying the * **control frame length**. * + Decode the **control frame payload**. If it is a `STOP` * control frame, the end of the Frame Streams byte stream has * occurred, and no frames follow. Break out of the decoding loop * and halt processing. (`READY`, `ACCEPT`, `START`, and `FINISH` * may not occur here. For forward compatibility, control frames of * types other than the types `READY`, `ACCEPT`, `START`, `STOP`, * and `FINISH` must be ignored here. No control frames specified * in the future may alter the encoding of succeeding frames.) * + If the **frame length** is non-zero, it specifies the number of bytes * in the following **data frame**. Consume these bytes from the byte * stream. * * The functions fstrm_control_encode() and fstrm_control_decode() are provided * to encode and decode control frames. See the detailed descriptions of those * functions for code examples showing their usage. * * @{ */ /** * The maximum length in bytes of an "Accept", "Start", or "Stop" control frame * payload. This excludes the escape sequence and the control frame length. */ #define FSTRM_CONTROL_FRAME_LENGTH_MAX 512 /** * The maximum length in bytes of a "Content Type" control frame field payload. * This excludes the field type and payload length. */ #define FSTRM_CONTROL_FIELD_CONTENT_TYPE_LENGTH_MAX 256 /** * Control frame types. */ typedef enum { /** Control frame type value for "Accept" control frames. */ FSTRM_CONTROL_ACCEPT = 0x01, /** Control frame type value for "Start" control frames. */ FSTRM_CONTROL_START = 0x02, /** Control frame type value for "Stop" control frames. */ FSTRM_CONTROL_STOP = 0x03, /** Control frame type value for "Ready" control frames. */ FSTRM_CONTROL_READY = 0x04, /** Control frame type value for "Finish" control frames. */ FSTRM_CONTROL_FINISH = 0x05, } fstrm_control_type; /** * Control frame field types. These are optional fields that can appear in * control frames. */ typedef enum { /** * Control frame field type value for the "Content Type" control frame * option. */ FSTRM_CONTROL_FIELD_CONTENT_TYPE = 0x01, } fstrm_control_field; /** * Flags for controlling the behavior of the encoding and decoding functions. */ typedef enum { /** * Set to control whether to include the control frame header in * encoding/decoding operations. * * Causes fstrm_control_encode() and fstrm_control_encoded_size() to * include the control frame header containing the escape sequence and * control frame payload length in the encoded output. Otherwise, only * the control frame payload itself is encoded. * * Tells fstrm_control_decode() that the input buffer to be decoded * begins with the control frame header containing the escape sequence * and control frame payload length. (Note that this requires the caller * to peek at the input buffer to calculate the right buffer length.) * Otherwise, the input buffer begins with the control frame payload. */ FSTRM_CONTROL_FLAG_WITH_HEADER = (1 << 0), } fstrm_control_flag; /** * Convert an `fstrm_control_type` enum value to a string representation. * Unknown values are represented as `"FSTRM_CONTROL_UNKNOWN"`. * * \param type The `fstrm_control_type` enum value. * \return The string representation of the enum value. (Always non-NULL.) */ const char * fstrm_control_type_to_str(fstrm_control_type type); /** * Convert an `fstrm_control_field` enum value to a string representation. * Unknown values are represented as `"FSTRM_CONTROL_FIELD_UNKNOWN"`. * * \param f_type The `fstrm_control_field` enum value. * \return The string representation of the enum value. (Always non-NULL.) */ const char * fstrm_control_field_type_to_str(fstrm_control_field f_type); /** * Initialize an `fstrm_control` object. This object represents Frame Streams * control frames and is used for encoding and decoding control frames. * * \return * An `fstrm_control` object. */ struct fstrm_control * fstrm_control_init(void); /** * Destroy an `fstrm_control` object. * * \param[in] c * Pointer to an `fstrm_control` object. */ void fstrm_control_destroy(struct fstrm_control **c); /** * Reinitialize an `fstrm_control` object. This resets the internal state to * default values. * * \param c * `fstrm_control` object. */ void fstrm_control_reset(struct fstrm_control *c); /** * Retrieve the type of the control frame. * * \param c * `fstrm_control` object. * \param[out] type * Type of the control frame. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_control_get_type( const struct fstrm_control *c, fstrm_control_type *type); /** * Set the type of the control frame. * * \param c * `fstrm_control` object. * \param[in] type * Type of the control frame. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_control_set_type( struct fstrm_control *c, fstrm_control_type type); /** * Retrieve the number of "Content Type" fields present in the control frame. * * \param c * `fstrm_control` object. * \param[out] n_content_type * The number of "Content Type" fields. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_control_get_num_field_content_type( const struct fstrm_control *c, size_t *n_content_type); /** * Retrieve a "Content Type" field from the control frame. This function * returns a reference which must not be modified. Control frames may contain * zero, one, or more "Content Type" fields. * * \see fstrm_control_get_num_field_content_type() * * \param c * `fstrm_control` object. * \param[in] idx * The index of the "Content Type" field to retrieve. * \param[out] content_type * Pointer to where the reference to the "Content Type" string will be * stored. Note that this string is not NUL-terminated and may contain * embedded NULs. * \param[out] len_content_type * The number of bytes in `content_type`. * * \retval #fstrm_res_success * The control frame has a "Content Type" field. * \retval #fstrm_res_failure * The control frame does not have a "Content Type" field. */ fstrm_res fstrm_control_get_field_content_type( const struct fstrm_control *c, const size_t idx, const uint8_t **content_type, size_t *len_content_type); /** * Add a "Content Type" field to the control frame. This function makes a copy * of the provided string. This function may be called multiple times, in which * case multiple "Content Type" fields will be added to the control frame. * * The "Content Type" fields are removed on a call to fstrm_control_reset(). * * \param c * `fstrm_control` object. * \param[in] content_type * The "Content Type" string to copy. Note that this string is not * NUL-terminated and may contain embedded NULs. * \param[in] len_content_type * The number of bytes in `content_type`. * * \retval #fstrm_res_success * The "Content Type" field was successfully added. * \retval #fstrm_res_failure * The "Content Type" string is too long. */ fstrm_res fstrm_control_add_field_content_type( struct fstrm_control *c, const uint8_t *content_type, size_t len_content_type); /** * Check if the control frame matches a particular content type value. That is, * the content type given in the `match` and `len_match` parameters is checked * for compatibility with the content types (if any) specified in the control * frame. * * \param c * `fstrm_control` object. * \param match * The "Content Type" string to match. Note that this string is not * NUL-terminated and may contain embedded NULs. May be NULL, in which case * the control frame must not have any content type fields in order to * match. * \param len_match * The number of bytes in `match`. * * \retval #fstrm_res_success * A match was found. * \retval #fstrm_res_failure * A match was not found. */ fstrm_res fstrm_control_match_field_content_type( const struct fstrm_control *c, const uint8_t *match, const size_t len_match); /** * Decode a control frame from a buffer. The buffer starts with either the * escape sequence or the control frame payload depending on whether the * `FSTRM_CONTROL_FLAG_WITH_HEADER` flag is set or not. In either case, the * 'len_control_frame' parameter must be exact. Underflow or overflow is not * permitted. * * The following code example shows a function that decodes a control frame * payload: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ static fstrm_res decode_control_frame(const void *control_frame, size_t len_control_frame) { fstrm_res res; fstrm_control_type c_type; struct fstrm_control *c; uint32_t flags = 0; c = fstrm_control_init(); res = fstrm_control_decode(c, control_frame, len_control_frame, flags); if (res != fstrm_res_success) { puts("fstrm_control_decode() failed."); fstrm_control_destroy(&c); return res; } res = fstrm_control_get_type(c, &c_type); if (res != fstrm_res_success) { puts("fstrm_control_get_type() failed."); fstrm_control_destroy(&c); return res; } printf("The control frame is of type %s (%u).\n", fstrm_control_type_to_str(c_type), c_type); size_t n_content_type; res = fstrm_control_get_num_field_content_type(c, &n_content_type); if (res != fstrm_res_success) { puts("fstrm_control_get_num_field_content_type() failed."); fstrm_control_destroy(&c); return res; } const uint8_t *content_type; size_t len_content_type; for (size_t idx = 0; idx < n_content_type; idx++) { res = fstrm_control_get_field_content_type(c, idx, &content_type, &len_content_type); if (res == fstrm_res_success) { printf("The control frame has a CONTENT_TYPE field of length %zd.\n", len_content_type); } } fstrm_control_destroy(&c); return fstrm_res_success; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * \param c * `fstrm_control` object. Its state will be overwritten. * \param[in] control_frame * Buffer containing the serialized control frame. * \param[in] len_control_frame * The number of bytes in `control_frame`. This parameter must specify the * exact number of bytes in the control frame. * \param flags * Flags controlling the decoding process. See #fstrm_control_flag. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_control_decode( struct fstrm_control *c, const void *control_frame, size_t len_control_frame, const uint32_t flags); /** * Calculate the number of bytes needed to serialize the control frame. * * \param c * `fstrm_control` object. * \param[out] len_control_frame * The number of bytes needed to encode `c`. * \param flags * Flags controlling the encoding process. See #fstrm_control_flag. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_control_encoded_size( const struct fstrm_control *c, size_t *len_control_frame, const uint32_t flags); /** * Encode a control frame into a buffer. Since a Frame Streams control frame is * a variable length byte sequence of up to #FSTRM_CONTROL_FRAME_LENGTH_MAX * bytes, this function can be used in two different ways. The first way is to * call fstrm_control_encoded_size() to obtain the exact number of bytes needed * to encode the frame, and then pass a buffer of this exact size to * fstrm_control_encode(). The following example shows this usage: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fstrm_res res; struct fstrm_control *c; uint8_t *control_frame; size_t len_control_frame; uint32_t flags = 0; c = fstrm_control_init(); res = fstrm_control_set_type(c, FSTRM_CONTROL_START); if (res != fstrm_res_success) { // Error handling goes here. } // Calculate the number of bytes needed. res = fstrm_control_encoded_size(c, &len_control_frame, flags); if (res != fstrm_res_success) { // Error handling goes here. } // 'len_control_frame' now specifies the number of bytes required for // the control frame. Allocate the needed space. control_frame = malloc(len_control_frame); if (!control_frame) { // Error handling goes here. } // Serialize the control frame into the allocated buffer. res = fstrm_control_encode(c, control_frame, &len_control_frame, 0); if (res != fstrm_res_success) { // Error handling goes here. } // Do something with 'control_frame' and 'len_control_frame'. // Clean up. free(control_frame); fstrm_control_destroy(&c); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * The second way to use fstrm_control_encode() is to allocate a statically * sized buffer of #FSTRM_CONTROL_FRAME_LENGTH_MAX bytes. The exact number of * bytes serialized by the encoder will be returned in the `len_control_frame` * parameter. The following example shows this usage: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fstrm_res res; struct fstrm_control *c; uint8_t control_frame[FSTRM_CONTROL_FRAME_LENGTH_MAX]; size_t len_control_frame = sizeof(control_frame); c = fstrm_control_init(); res = fstrm_control_set_type(c, FSTRM_CONTROL_START); if (res != fstrm_res_success) { // Error handling. } // Serialize the control frame. res = fstrm_control_encode(c, control_frame, &len_control_frame, 0); if (res != fstrm_res_success) { // Error handling goes here. } // Do something with 'control_frame' and 'len_control_frame'. // Clean up. fstrm_control_destroy(&c); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * \param c * `fstrm_control` object. * \param[out] control_frame * The buffer in which to serialize the control frame. * \param[in,out] len_control_frame * The size in bytes of `control_frame`. On a successful return, contains * the number of bytes actually written into `control_frame`. * \param flags * Flags controlling the encoding process. See #fstrm_control_flag. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_control_encode( const struct fstrm_control *c, void *control_frame, size_t *len_control_frame, const uint32_t flags); /**@}*/ #endif /* FSTRM_CONTROL_H */ /* * Copyright (c) 2014 by Farsight Security, Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #ifndef FSTRM_IOTHR_H #define FSTRM_IOTHR_H /** * \defgroup fstrm_iothr fstrm_iothr * * The `fstrm_iothr` interface creates a background I/O thread which writes * Frame Streams encapsulated data frames into an output stream specified by an * \ref fstrm_writer object. It exposes non-blocking input queues that can be * used by worker threads to asynchronously write data frames to the output * stream. A deferred deallocation callback is invoked after the I/O thread has * disposed of a queued data frame. * * In order to create an `fstrm_iothr` object, the caller must first configure * and instantiate an `fstrm_writer` object and pass this instance to the * fstrm_iothr_init() function. The `fstrm_iothr` object then takes ownership of * the `fstrm_writer` object. It is responsible for serializing writes and will * take care of destroying the captive `fstrm_writer` object at the same time * the `fstrm_iothr` object is destroyed. The caller should not perform any * operations on the captive `fstrm_writer` object after it has been passed to * `fstrm_iothr_init()`. * * Parameters used to configure the I/O thread are passed through an * `fstrm_iothr_options` object. These options have to be specified in advance * and are mostly performance knobs which have reasonable defaults. * * Once the `fstrm_iothr` object has been created, handles to the input queues * used to submit data frames can be obtained by calling * `fstrm_iothr_get_input_queue()`. This function can be called up to * **num_input_queues** times, and can be safely called concurrently. For * instance, in an application with a fixed number of worker threads, an input * queue can be dedicated to each worker thread by setting the * **num_input_queues** option to the number of worker threads, and then calling * `fstrm_iothr_get_input_queue()` from each worker thread's startup function to * obtain a per-thread input queue. * * @{ */ /** * Initialize an `fstrm_iothr_options` object. This is needed to pass * configuration parameters to fstrm_iothr_init(). * * \return * `fstrm_iothr_options` object. */ struct fstrm_iothr_options * fstrm_iothr_options_init(void); /** * Destroy an `fstrm_iothr_options` object. * * \param opt * Pointer to `fstrm_iothr_options` object. */ void fstrm_iothr_options_destroy(struct fstrm_iothr_options **opt); /** * Set the `buffer_hint` parameter. This is the threshold number of bytes to * accumulate in the output buffer before forcing a buffer flush. * * \param opt * `fstrm_iothr_options` object. * \param buffer_hint * New `buffer_hint` value. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_iothr_options_set_buffer_hint( struct fstrm_iothr_options *opt, unsigned buffer_hint); /** Minimum `buffer_hint` value. */ #define FSTRM_IOTHR_BUFFER_HINT_MIN 1024 /** Default `buffer_hint` value. */ #define FSTRM_IOTHR_BUFFER_HINT_DEFAULT 8192 /** Maximum `buffer_hint` value. */ #define FSTRM_IOTHR_BUFFER_HINT_MAX 65536 /** * Set the `flush_timeout` parameter. This is the number of seconds to allow * unflushed data to remain in the output buffer. * * \param opt * `fstrm_iothr_options` object. * \param flush_timeout * New `flush_timeout` value. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_iothr_options_set_flush_timeout( struct fstrm_iothr_options *opt, unsigned flush_timeout); /** Minimum `flush_timeout` value. */ #define FSTRM_IOTHR_FLUSH_TIMEOUT_MIN 1 /** Default `flush_timeout` value. */ #define FSTRM_IOTHR_FLUSH_TIMEOUT_DEFAULT 1 /** Maximum `flush_timeout` value. */ #define FSTRM_IOTHR_FLUSH_TIMEOUT_MAX 600 /** * Set the `input_queue_size` parameter. This is the number of queue entries to * allocate per each input queue. This option controls the number of outstanding * data frames per input queue that can be outstanding for deferred processing * by the `fstrm_iothr` object and thus affects performance and memory usage. * * This parameter must be a power-of-2. * * \param opt * `fstrm_iothr_options` object. * \param input_queue_size * New `input_queue_size` value. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_iothr_options_set_input_queue_size( struct fstrm_iothr_options *opt, unsigned input_queue_size); /** Minimum `input_queue_size` value. */ #define FSTRM_IOTHR_INPUT_QUEUE_SIZE_MIN 2 /** Default `input_queue_size` value. */ #define FSTRM_IOTHR_INPUT_QUEUE_SIZE_DEFAULT 512 /** Maximum `input_queue_size` value. */ #define FSTRM_IOTHR_INPUT_QUEUE_SIZE_MAX 16384 /** * Set the `num_input_queues` parameter. This is the number of input queues to * create and must match the number of times that fstrm_iothr_get_input_queue() * is called on the corresponding `fstrm_iothr` object. * * \param opt * `fstrm_iothr_options` object. * \param num_input_queues * New `num_input_queues` value. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_iothr_options_set_num_input_queues( struct fstrm_iothr_options *opt, unsigned num_input_queues); /** Minimum `num_input_queues` value. */ #define FSTRM_IOTHR_NUM_INPUT_QUEUES_MIN 1 /** Default `num_input_queues` value. */ #define FSTRM_IOTHR_NUM_INPUT_QUEUES_DEFAULT 1 /** * Set the `output_queue_size` parameter. This is the number of queue entries to * allocate for the output queue. This option controls the maximum number of * data frames that can be accumulated in the output queue before a buffer flush * must occur and thus affects performance and memory usage. * * \param opt * `fstrm_iothr_options` object. * \param output_queue_size * New `output_queue_size` value. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_iothr_options_set_output_queue_size( struct fstrm_iothr_options *opt, unsigned output_queue_size); /** Minimum `output_queue_size` value. */ #define FSTRM_IOTHR_OUTPUT_QUEUE_SIZE_MIN 2 /** Default `output_queue_size` value. */ #define FSTRM_IOTHR_OUTPUT_QUEUE_SIZE_DEFAULT 64 /** Maximum `output_queue_size` value. */ #define FSTRM_IOTHR_OUTPUT_QUEUE_SIZE_MAX IOV_MAX /** * Queue models. * \see fstrm_iothr_options_set_queue_model() */ typedef enum { /** Single Producer, Single Consumer. */ FSTRM_IOTHR_QUEUE_MODEL_SPSC, /** Multiple Producer, Single Consumer. */ FSTRM_IOTHR_QUEUE_MODEL_MPSC, } fstrm_iothr_queue_model; /** * Set the `queue_model` parameter. This controls what queueing semantics to use * for `fstrm_iothr_queue` objects. Single Producer queues * (#FSTRM_IOTHR_QUEUE_MODEL_SPSC) may only have a single thread at a time * calling fstrm_iothr_submit() on a given `fstrm_iothr_queue` object, while * Multiple Producer queues (#FSTRM_IOTHR_QUEUE_MODEL_MPSC) may have multiple * threads concurrently calling fstrm_iothr_submit() on a given * `fstrm_iothr_queue` object. * * \param opt * `fstrm_iothr_options` object. * \param queue_model * New `queue_model` value. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_iothr_options_set_queue_model( struct fstrm_iothr_options *opt, fstrm_iothr_queue_model queue_model); /** Default `queue_model` value. */ #define FSTRM_IOTHR_QUEUE_MODEL_DEFAULT FSTRM_IOTHR_QUEUE_MODEL_SPSC /** * Set the `queue_notify_threshold` parameter. This controls the number of * outstanding queue entries to allow on an input queue before waking the I/O * thread, which will cause the outstanding queue entries to begin draining. * * \param opt * `fstrm_iothr_options` object. * \param queue_notify_threshold * New `queue_notify_threshold` value. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_iothr_options_set_queue_notify_threshold( struct fstrm_iothr_options *opt, unsigned queue_notify_threshold); /** Minimum `queue_notify_threshold` value. */ #define FSTRM_IOTHR_QUEUE_NOTIFY_THRESHOLD_MIN 1 /** Default `queue_notify_threshold` value. */ #define FSTRM_IOTHR_QUEUE_NOTIFY_THRESHOLD_DEFAULT 32 /** * Set the `reopen_interval` parameter. This controls the number of seconds to * wait between attempts to reopen a closed `fstrm_writer` output stream. * * \param opt * `fstrm_iothr_options` object. * \param reopen_interval * New `queue_notify_threshold` value. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_iothr_options_set_reopen_interval( struct fstrm_iothr_options *opt, unsigned reopen_interval); /** Minimum `reopen_interval` value. */ #define FSTRM_IOTHR_REOPEN_INTERVAL_MIN 1 /** Default `reopen_interval` value. */ #define FSTRM_IOTHR_REOPEN_INTERVAL_DEFAULT 5 /** Maximum `reopen_interval` value. */ #define FSTRM_IOTHR_REOPEN_INTERVAL_MAX 600 /** * Initialize an `fstrm_iothr` object. This creates a background I/O thread * which asynchronously writes data frames submitted by other threads which call * fstrm_iothr_submit(). * * \param opt * `fstrm_iothr_options` object. May be NULL, in which case default values * will be used. * * \param writer * Pointer to `fstrm_writer` object. Must be non-NULL. * * \return * `fstrm_iothr` object. * \retval * NULL on failure. */ struct fstrm_iothr * fstrm_iothr_init( const struct fstrm_iothr_options *opt, struct fstrm_writer **writer); /** * Destroy an `fstrm_iothr` object. This signals the background I/O thread to * flush or discard any queued data frames and deallocates any resources used * internally. This function blocks until the I/O thread has terminated. * * \param iothr * Pointer to `fstrm_iothr` object. */ void fstrm_iothr_destroy(struct fstrm_iothr **iothr); /** * Obtain an `fstrm_iothr_queue` object for submitting data frames to the * `fstrm_iothr` object. `fstrm_iothr_queue` objects are child objects of their * parent `fstrm_iothr` object and will be destroyed when fstrm_iothr_destroy() * is called on the parent `fstrm_iothr` object. * * This function is thread-safe and may be called simultaneously from any * thread. For example, in a program which employs a fixed number of worker * threads to handle requests, fstrm_iothr_get_input_queue() may be called from * a thread startup routine without synchronization. * * `fstrm_iothr` objects allocate a fixed total number of `fstrm_iothr_queue` * objects during the call to fstrm_iothr_init(). To adjust this parameter, use * fstrm_iothr_options_set_num_input_queues(). * * This function will fail if it is called more than **num_input_queues** times. * By default, only one input queue is initialized per `fstrm_iothr` object. * * For optimum performance in a threaded program, each worker thread submitting * data frames should have a dedicated `fstrm_iothr_queue` object. This allows * each worker thread to have its own queue which is processed independently by * the I/O thread. If the queue model for the `fstrm_iothr` object is set to * #FSTRM_IOTHR_QUEUE_MODEL_SPSC, this results in contention-free access to the * input queue. * * \param iothr * `fstrm_iothr` object. * * \return * `fstrm_iothr_queue` object. * \retval * NULL on failure. */ struct fstrm_iothr_queue * fstrm_iothr_get_input_queue(struct fstrm_iothr *iothr); /** * Obtain an `fstrm_iothr_queue` object for submitting data frames to the * `fstrm_iothr` object. This function is like fstrm_iothr_get_input_queue() * except it indexes into the `fstrm_iothr_queue`'s array of input queues. * * \param iothr * `fstrm_iothr` object. * \param idx * Index of the `fstrm_iothr_queue` object to retrieve. This value is * limited by the **num_input_queues** option. * * \return * `fstrm_iothr_queue` object. * \retval * NULL on failure. */ struct fstrm_iothr_queue * fstrm_iothr_get_input_queue_idx(struct fstrm_iothr *iothr, size_t idx); /** * Submit a data frame to the background I/O thread. If successfully queued and * the I/O thread has an active output stream opened, the data frame will be * asynchronously written to the output stream. * * When this function returns #fstrm_res_success, responsibility for * deallocating the data frame specified by the `data` parameter passes to the * `fstrm` library. The caller **MUST** ensure that the `data` object remains * valid after fstrm_iothr_submit() returns. The callback function specified by * the `free_func` parameter will be invoked once the data frame is no longer * needed by the `fstrm` library. For example, if the data frame is dynamically * allocated, the data frame may be deallocated in the callback function. * * Note that if this function returns #fstrm_res_failure, the responsibility for * deallocating the data frame remains with the caller. * * As a convenience, if `data` is allocated with the system's `malloc()`, * `fstrm_free_wrapper` may be provided as the `free_func` parameter with the * `free_data` parameter set to `NULL`. This will cause the system's `free()` to * be invoked to deallocate `data`. * * `free_func` may be NULL, in which case no callback function will be invoked * to dispose of `buf`. This behavior may be useful if `data` is a global, * statically allocated object. * * \param iothr * `fstrm_iothr` object. * \param ioq * `fstrm_iothr_queue` object. * \param data * Data frame bytes. * \param len * Number of bytes in `data`. * \param free_func * Callback function to deallocate the data frame. The `data` and * `free_data` parameters passed to this callback will be the same values * originally supplied in the call to fstrm_iothr_submit(). * \param free_data * Parameter to pass to `free_func`. * * \retval #fstrm_res_success * The data frame was successfully queued. * \retval #fstrm_res_again * The queue is full. * \retval #fstrm_res_failure * Permanent failure. */ fstrm_res fstrm_iothr_submit( struct fstrm_iothr *iothr, struct fstrm_iothr_queue *ioq, void *data, size_t len, void (*free_func)(void *buf, void *free_data), void *free_data); /** * Wrapper function for the system's `free()`, suitable for use as the * `free_func` callback for fstrm_iothr_submit(). * * \param data * Object to call `free()` on. * \param free_data * Unused. */ void fstrm_free_wrapper(void *data, void *free_data); /**@}*/ #endif /* FSTRM_IOTHR_H */ /* * Copyright (c) 2014 by Farsight Security, Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #ifndef FSTRM_FILE_H #define FSTRM_FILE_H /** * \defgroup fstrm_file fstrm_file * * `fstrm_file` contains interfaces for opening \ref fstrm_reader or * \ref fstrm_writer objects that are backed by file I/O. * * @{ */ /** * Initialize an `fstrm_file_options` object, which is needed to configure the * file path to be opened by fstrm_file_reader_init() or * fstrm_file_writer_init(). * * \return * `fstrm_file_options` object. */ struct fstrm_file_options * fstrm_file_options_init(void); /** * Destroy an `fstrm_file_options` object. * * \param fopt * Pointer to `fstrm_file_options` object. */ void fstrm_file_options_destroy(struct fstrm_file_options **fopt); /** * Set the `file_path` option. This is a filesystem path to a regular file to be * opened for reading or writing. * * \param fopt * `fstrm_file_options` object. * \param file_path * The filesystem path for a regular file. */ void fstrm_file_options_set_file_path(struct fstrm_file_options *fopt, const char *file_path); /** * Open a file containing Frame Streams data for reading. * * \param fopt * `fstrm_file_options` object. Must be non-NULL, and have the `file_path` * option set. * \param ropt * `fstrm_reader_options` object. May be NULL, in which case default values * will be used. * * \return * `fstrm_reader` object. * \retval * NULL on failure. */ struct fstrm_reader * fstrm_file_reader_init(const struct fstrm_file_options *fopt, const struct fstrm_reader_options *ropt); /** * Open a file for writing Frame Streams data. The file will be truncated if it * already exists. * * \param fopt * `fstrm_file_options` object. Must be non-NULL, and have the `file_path` * option set. * \param wopt * `fstrm_writer_options` object. May be NULL, in which case default values * will be used. * * \return * `fstrm_writer` object. * \retval * NULL on failure. */ struct fstrm_writer * fstrm_file_writer_init(const struct fstrm_file_options *fopt, const struct fstrm_writer_options *wopt); /**@}*/ #endif /* FSTRM_FILE_H */ /* * Copyright (c) 2014 by Farsight Security, Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #ifndef FSTRM_READER_H #define FSTRM_READER_H /** * \defgroup fstrm_reader fstrm_reader * * `fstrm_reader` is an interface for reading Frame Streams data from a byte * stream. The underlying byte stream I/O operations are abstracted by the * \ref fstrm_rdwr interface. Thus, the `fstrm_reader` interface can be used to * read Frame Streams data from any source whose read/write operations are * wrapped by an `fstrm_rdwr` object. * * Some basic `fstrm_reader` implementations are already provided in the `fstrm` * library. See fstrm_file_reader_init() to create an `fstrm_reader` object that * reads Frame Streams data from a regular file. * * @{ */ /** * The default `max_frame_size` value. */ #define FSTRM_READER_MAX_FRAME_SIZE_DEFAULT 1048576 /** * Initialize an `fstrm_reader_options` object. * * \return * `fstrm_reader_options` object. */ struct fstrm_reader_options * fstrm_reader_options_init(void); /** * Destroy an `fstrm_reader_options` object. * * \param ropt * Pointer to `fstrm_reader_options` object. */ void fstrm_reader_options_destroy( struct fstrm_reader_options **ropt); /** * Add a "Content Type" value to the set of content types accepted by the * `fstrm_reader`. This function makes a copy of the provided string. This * function may be called multiple times, in which case multiple "Content Type" * values will be accepted by the reader. * * If the reader has no content types set, it will accept any content type. * * \param ropt * `fstrm_reader_options` object. * \param content_type * The "Content Type" string to copy. Note that this string is not * NUL-terminated and may contain embedded NULs. * \param len_content_type * The number of bytes in `content_type`. * * \retval #fstrm_res_success * The "Content Type" field was successfully added. * \retval #fstrm_res_failure * The "Content Type" string is too long. */ fstrm_res fstrm_reader_options_add_content_type( struct fstrm_reader_options *ropt, const void *content_type, size_t len_content_type); /** * Set the maximum frame size that the reader is willing to accept. This * enforces an upper limit on the amount of memory used to buffer incoming data * from the reader's byte stream. * * If this option is not set, it defaults to * #FSTRM_READER_MAX_FRAME_SIZE_DEFAULT. * * \param ropt * `fstrm_reader_options` object. * \param max_frame_size * The maximum frame size value. * * \retval #fstrm_res_success * The `max_frame_size` value was successfully set. * \retval #fstrm_res_failure * The `max_frame_size` value was too large or too small. */ fstrm_res fstrm_reader_options_set_max_frame_size( struct fstrm_reader_options *ropt, size_t max_frame_size); /** * Initialize a new `fstrm_reader` object based on an underlying `fstrm_rdwr` * object and an `fstrm_reader_options` object. * * The underlying `fstrm_rdwr` object MUST have a `read` method. It MAY * optionally have a `write` method, in which case the stream will be treated as * a bi-directional, handshaked stream. Otherwise, if there is no `write` method * the stream will be treated as a uni-directional stream. * * This function is useful for implementing functions that return new types of * `fstrm_reader` objects, such as fstrm_file_reader_init(). * * After a successful call to this function, the ownership of the `fstrm_rdwr` * object passes from the caller to the `fstrm_reader` object. The caller * should perform no further calls on the `fstrm_rdwr` object. The `fstrm_rdwr` * object will be cleaned up on a call to fstrm_reader_destroy(). * * \param ropt * `fstrm_reader_options` object. May be NULL, in which case default values * will be used. * * \param rdwr * Pointer to `fstrm_rdwr` object. Must be non-NULL. The `fstrm_rdwr` * object must have a `read` method, and may optionally have a `write` * method. * * \return * `fstrm_reader` object. * \retval * NULL on failure. */ struct fstrm_reader * fstrm_reader_init( const struct fstrm_reader_options *ropt, struct fstrm_rdwr **rdwr); /** * Destroy an `fstrm_reader` object. This implicitly calls fstrm_reader_close() * if necessary. * * \param r * Pointer to `fstrm_reader` object. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_reader_destroy(struct fstrm_reader **r); /** * Open an `fstrm_reader` object and prepare it to read data. * * This checks that the content type in the byte stream, if specified, matches * one of the content types specified in the `fstrm_reader_options` object used * to initialize the `fstrm_reader` object. * * This function may fail if there was an underlying problem opening the input * stream. * * \param r * `fstrm_reader` object. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_reader_open(struct fstrm_reader *r); /** * Close an `fstrm_reader` object. Once it has been closed, no data frames may * subsequently be read. * * Calling this function is optional; it may be implicitly invoked by a call to * fstrm_reader_destroy(). * * \param r * `fstrm_reader` object. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_reader_close(struct fstrm_reader *r); /** * Read a data frame from an `fstrm_reader` object. This frame is held in an * internal buffer owned by the `fstrm_reader` object and should not be modified * by the caller. The contents of this buffer will be overwritten by a * subsequent call to fstrm_reader_read(). * * This function implicitly calls fstrm_reader_open() if necessary. * * \param r * `fstrm_reader` object. * \param[out] data * Pointer to buffer containing the data frame payload. * \param[out] len_data * The number of bytes available in `data`. * * \retval #fstrm_res_success * A data frame was successfully read. * \retval #fstrm_res_stop * The end of the stream has been reached. * \retval #fstrm_res_failure */ fstrm_res fstrm_reader_read( struct fstrm_reader *r, const uint8_t **data, size_t *len_data); /** * Obtain a pointer to an `fstrm_control` object used during processing. Objects * returned by this function are owned by the `fstrm_reader` object and must not * be modified by the caller. After a call to fstrm_reader_destroy() these * pointers will no longer be valid. * * For example, this function can be used to obtain a pointer to the START * control frame, which can be queried to see which "Content Type" was * negotiated during the opening of the reader. * * This function implicitly calls fstrm_reader_open() if necessary. * * \param r * `fstrm_reader` object. * \param type * Which control frame to return. * \param[out] control * The `fstrm_control` object. * * \retval #fstrm_res_success * If an `fstrm_control` object was returned. * \retval #fstrm_res_failure */ fstrm_res fstrm_reader_get_control( struct fstrm_reader *r, fstrm_control_type type, const struct fstrm_control **control); /**@}*/ #endif /* FSTRM_READER_H */ /* * Copyright (c) 2014, 2018 by Farsight Security, Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #ifndef FSTRM_WRITER_H #define FSTRM_WRITER_H /** * \defgroup fstrm_writer fstrm_writer * * `fstrm_writer` is an interface for writing Frame Streams data into a byte * stream. The underlying byte stream I/O operations are abstracted by the * \ref fstrm_rdwr interface. Thus, the `fstrm_writer` interface can be used to * write Frame Streams data to any type of output whose read/write operations * are wrapped by an `fstrm_rdwr` object. * * Some basic `fstrm_writer` implementations are already provided in the `fstrm` * library. See fstrm_file_writer_init() for an implementation that writes to * a regular file, fstrm_tcp_writer_init() for an implementation that writes to * a TCP socket, and fstrm_unix_writer_init() for an implementation that writes * to a Unix socket. * * @{ */ /** * Initialize an `fstrm_writer_options` object. * * \return * `fstrm_writer_options` object. */ struct fstrm_writer_options * fstrm_writer_options_init(void); /** * Destroy an `fstrm_writer_options` object. * * \param wopt * Pointer to `fstrm_writer_options` object. */ void fstrm_writer_options_destroy( struct fstrm_writer_options **wopt); /** * Add a "Content Type" value to the set of content types that can be negotiated * by the writer. This function makes a copy of the provided string. This * function may be called multiple times, in which case multiple "Content Type" * values will be accepted by the reader. * * For uni-directional streams like regular files, the negotiated content type * will simply be the first content type provided to this function. For * bi-directional streams like sockets, a handshake occurs and the remote end * determines which content type should be sent. In the latter case, after the * writer has been successfully opened with a call to fstrm_writer_open(), the * fstrm_writer_get_control() function should be called with `type` set to * `FSTRM_CONTROL_ACCEPT` and the control frame queried in order to determine * the negotiated content type. * * \param wopt * `fstrm_writer_options` object. * \param content_type * The "Content Type" string to copy. Note that this string is not * NUL-terminated and may contain embedded NULs. * \param len_content_type * The number of bytes in `content_type`. * * \retval #fstrm_res_success * The "Content Type" field was successfully added. * \retval #fstrm_res_failure * The "Content Type" string is too long. */ fstrm_res fstrm_writer_options_add_content_type( struct fstrm_writer_options *wopt, const void *content_type, size_t len_content_type); /** * Initialize a new `fstrm_writer` object based on an underlying `fstrm_rdwr` * object and an `fstrm_writer_options` object. * * The underlying `fstrm_rdwr` object MUST have a `write` method. It MAY * optionally have a `read` method, in which case the stream will be treated as * a bi-directional, handshaked stream. Otherwise, if there is no `read` method * the stream will be treated as a uni-directional stream. * * This function is useful for implementing functions that return new types of * `fstrm_writer` objects, such as fstrm_file_writer_init() and * fstrm_unix_writer_init(). * * After a successful call to this function, the ownership of the `fstrm_rdwr` * object passes from the caller to the `fstrm_writer` object. The caller * should perform no further calls on the `fstrm_rdwr` object. The `fstrm_rdwr` * object will be cleaned up on a call to fstrm_writer_destroy(). * * \param wopt * `fstrm_writer_options` object. May be NULL, in which case default values * will be used. * * \param rdwr * Pointer to `fstrm_rdwr` object. Must be non-NULL. The `fstrm_rdwr` * object must have a `write` method, and may optionally have a `read` * method. * * \return * `fstrm_writer` object. * \retval * NULL on failure. */ struct fstrm_writer * fstrm_writer_init( const struct fstrm_writer_options *wopt, struct fstrm_rdwr **rdwr); /** * Destroy an `fstrm_writer` object. This implicitly calls fstrm_writer_close() * if necessary. * * \param w * Pointer to `fstrm_writer` object. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_writer_destroy(struct fstrm_writer **w); /** * Open an `fstrm_writer` object and prepare it to write data. For * bi-directional writer implementations, this performs content type * negotiation. * * This function may fail if there was an underlying problem opening the output * stream. * * \param w * `fstrm_writer` object. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_writer_open(struct fstrm_writer *w); /** * Close an `fstrm_writer` object. Open it has been closed, no data frames may * subsequently be written. * * Calling this function is optional; it may be implicitly invoked by a call to * fstrm_writer_destroy(). * * \param w * `fstrm_writer` object. * * \retval #fstrm_res_success * \retval #fstrm_res_failure */ fstrm_res fstrm_writer_close(struct fstrm_writer *w); /** * Write a data frame to an `fstrm_writer` object. * * This function implicitly calls fstrm_writer_open() if necessary. * * \param w * `fstrm_writer` object. * \param[in] data * Buffer containing the data frame payload. * \param[in] len_data * The number of bytes in `data`. * * \retval #fstrm_res_success * The data frame was successfully written. * \retval #fstrm_res_failure */ fstrm_res fstrm_writer_write( struct fstrm_writer *w, const void *data, size_t len_data); /** * Write multiple data frames to an `fstrm_writer` object. * * This function implicitly calls fstrm_writer_open() if necessary. * * Data frames are passed similarly to the `writev()` system call, with an array * of `struct iovec` objects describing the data frame payloads and their * lengths. The complete set of data frames will be written to the output * stream after a successful call. * * \param w * `fstrm_writer` object. * \param iov * Array of `struct iovec` objects. * \param iovcnt * Number of `struct iovec` objects in `iov`. * * \retval #fstrm_res_success * The data frames were successfully written. * \retval #fstrm_res_failure */ fstrm_res fstrm_writer_writev( struct fstrm_writer *w, const struct iovec *iov, int iovcnt); /** * Obtain a pointer to an `fstrm_control` object used during processing. Objects * returned by this function are owned by the `fstrm_reader` object and must not * be modified by the caller. After a call to fstrm_reader_destroy() these * pointers will no longer be valid. * * For example, with bi-directional streams this function can be used to obtain * a pointer to the ACCEPT control frame, which can be queried to see which * "Content Type" was negotiated during the opening of the writer. * * This function implicitly calls fstrm_writer_open() if necessary. * * \param w * `fstrm_writer` object. * \param type * Which control frame to return. * \param[out] control * The `fstrm_control` object. * * \retval #fstrm_res_success * If an `fstrm_control` object was returned. * \retval #fstrm_res_failure */ fstrm_res fstrm_writer_get_control( struct fstrm_writer *w, fstrm_control_type type, struct fstrm_control **control); /**@}*/ #endif /* FSTRM_WRITER_H */ /* * Copyright (c) 2014, 2018 by Farsight Security, Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ #ifndef FSTRM_TCP_WRITER_H #define FSTRM_TCP_WRITER_H /** * \defgroup fstrm_tcp_writer fstrm_tcp_writer * * `fstrm_tcp_writer` is an interface for opening an \ref fstrm_writer object * that is backed by I/O on a TCP socket. * * @{ */ /** * Initialize an `fstrm_tcp_writer_options` object, which is needed to * configure the socket address and socket port to be opened by the writer. * * \return * `fstrm_tcp_writer_options` object. */ struct fstrm_tcp_writer_options * fstrm_tcp_writer_options_init(void); /** * Destroy an `fstrm_tcp_writer_options` object. * * \param twopt * Pointer to `fstrm_tcp_writer_options` object. */ void fstrm_tcp_writer_options_destroy( struct fstrm_tcp_writer_options **twopt); /** * Set the `socket_address` option. This is the IPv4 or IPv6 address in * presentation format to be connected by the TCP socket. * * \param twopt * `fstrm_tcp_writer_options` object. * \param socket_address * The socket address. */ void fstrm_tcp_writer_options_set_socket_address( struct fstrm_tcp_writer_options *twopt, const char *socket_address); /** * Set the `socket_port` option. This is the TCP port number to be connected by * the TCP socket. * * \param twopt * `fstrm_tcp_writer_options` object. * \param socket_port * The TCP socket port number provided as a character string. * (When converted, the maximum allowed unsigned integer is 65535.) */ void fstrm_tcp_writer_options_set_socket_port( struct fstrm_tcp_writer_options *twopt, const char *socket_port); /** * Initialize the `fstrm_writer` object. Note that the TCP socket will not * actually be opened until a subsequent call to fstrm_writer_open(). * * \param twopt * `fstrm_tcp_writer_options` object. Must be non-NULL, and have the * `socket_address` and `socket_port` options set. * \param wopt * `fstrm_writer_options` object. May be NULL, in which chase default * values will be used. * * \return * `fstrm_writer` object. * \retval * NULL on failure. */ struct fstrm_writer * fstrm_tcp_writer_init( const struct fstrm_tcp_writer_options *twopt, const struct fstrm_writer_options *wopt); /**@}*/ #endif /* FSTRM_TCP_WRITER_H */ /* * Summary: SAX2 parser interface used to build the DOM tree * Description: those are the default SAX2 interfaces used by * the library when building DOM tree. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_SAX2_H__ #define __XML_SAX2_H__ #include <stdio.h> #include <stdlib.h> #include <libxml/xmlversion.h> #include <libxml/parser.h> #include <libxml/xlink.h> #ifdef __cplusplus extern "C" { #endif XMLPUBFUN const xmlChar * XMLCALL xmlSAX2GetPublicId (void *ctx); XMLPUBFUN const xmlChar * XMLCALL xmlSAX2GetSystemId (void *ctx); XMLPUBFUN void XMLCALL xmlSAX2SetDocumentLocator (void *ctx, xmlSAXLocatorPtr loc); XMLPUBFUN int XMLCALL xmlSAX2GetLineNumber (void *ctx); XMLPUBFUN int XMLCALL xmlSAX2GetColumnNumber (void *ctx); XMLPUBFUN int XMLCALL xmlSAX2IsStandalone (void *ctx); XMLPUBFUN int XMLCALL xmlSAX2HasInternalSubset (void *ctx); XMLPUBFUN int XMLCALL xmlSAX2HasExternalSubset (void *ctx); XMLPUBFUN void XMLCALL xmlSAX2InternalSubset (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); XMLPUBFUN void XMLCALL xmlSAX2ExternalSubset (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); XMLPUBFUN xmlEntityPtr XMLCALL xmlSAX2GetEntity (void *ctx, const xmlChar *name); XMLPUBFUN xmlEntityPtr XMLCALL xmlSAX2GetParameterEntity (void *ctx, const xmlChar *name); XMLPUBFUN xmlParserInputPtr XMLCALL xmlSAX2ResolveEntity (void *ctx, const xmlChar *publicId, const xmlChar *systemId); XMLPUBFUN void XMLCALL xmlSAX2EntityDecl (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content); XMLPUBFUN void XMLCALL xmlSAX2AttributeDecl (void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree); XMLPUBFUN void XMLCALL xmlSAX2ElementDecl (void *ctx, const xmlChar *name, int type, xmlElementContentPtr content); XMLPUBFUN void XMLCALL xmlSAX2NotationDecl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId); XMLPUBFUN void XMLCALL xmlSAX2UnparsedEntityDecl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName); XMLPUBFUN void XMLCALL xmlSAX2StartDocument (void *ctx); XMLPUBFUN void XMLCALL xmlSAX2EndDocument (void *ctx); #if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || \ defined(LIBXML_LEGACY_ENABLED) XMLPUBFUN void XMLCALL xmlSAX2StartElement (void *ctx, const xmlChar *fullname, const xmlChar **atts); XMLPUBFUN void XMLCALL xmlSAX2EndElement (void *ctx, const xmlChar *name); #endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED or LIBXML_LEGACY_ENABLED */ XMLPUBFUN void XMLCALL xmlSAX2StartElementNs (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes); XMLPUBFUN void XMLCALL xmlSAX2EndElementNs (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI); XMLPUBFUN void XMLCALL xmlSAX2Reference (void *ctx, const xmlChar *name); XMLPUBFUN void XMLCALL xmlSAX2Characters (void *ctx, const xmlChar *ch, int len); XMLPUBFUN void XMLCALL xmlSAX2IgnorableWhitespace (void *ctx, const xmlChar *ch, int len); XMLPUBFUN void XMLCALL xmlSAX2ProcessingInstruction (void *ctx, const xmlChar *target, const xmlChar *data); XMLPUBFUN void XMLCALL xmlSAX2Comment (void *ctx, const xmlChar *value); XMLPUBFUN void XMLCALL xmlSAX2CDataBlock (void *ctx, const xmlChar *value, int len); #ifdef LIBXML_SAX1_ENABLED XMLPUBFUN int XMLCALL xmlSAXDefaultVersion (int version); #endif /* LIBXML_SAX1_ENABLED */ XMLPUBFUN int XMLCALL xmlSAXVersion (xmlSAXHandler *hdlr, int version); XMLPUBFUN void XMLCALL xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr, int warning); #ifdef LIBXML_HTML_ENABLED XMLPUBFUN void XMLCALL xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr); XMLPUBFUN void XMLCALL htmlDefaultSAXHandlerInit (void); #endif #ifdef LIBXML_DOCB_ENABLED XMLPUBFUN void XMLCALL xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr); XMLPUBFUN void XMLCALL docbDefaultSAXHandlerInit (void); #endif XMLPUBFUN void XMLCALL xmlDefaultSAXHandlerInit (void); #ifdef __cplusplus } #endif #endif /* __XML_SAX2_H__ */ /* * Summary: pattern expression handling * Description: allows to compile and test pattern expressions for nodes * either in a tree or based on a parser state. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_PATTERN_H__ #define __XML_PATTERN_H__ #include <libxml/xmlversion.h> #include <libxml/tree.h> #include <libxml/dict.h> #ifdef LIBXML_PATTERN_ENABLED #ifdef __cplusplus extern "C" { #endif /** * xmlPattern: * * A compiled (XPath based) pattern to select nodes */ typedef struct _xmlPattern xmlPattern; typedef xmlPattern *xmlPatternPtr; /** * xmlPatternFlags: * * This is the set of options affecting the behaviour of pattern * matching with this module * */ typedef enum { XML_PATTERN_DEFAULT = 0, /* simple pattern match */ XML_PATTERN_XPATH = 1<<0, /* standard XPath pattern */ XML_PATTERN_XSSEL = 1<<1, /* XPath subset for schema selector */ XML_PATTERN_XSFIELD = 1<<2 /* XPath subset for schema field */ } xmlPatternFlags; XMLPUBFUN void XMLCALL xmlFreePattern (xmlPatternPtr comp); XMLPUBFUN void XMLCALL xmlFreePatternList (xmlPatternPtr comp); XMLPUBFUN xmlPatternPtr XMLCALL xmlPatterncompile (const xmlChar *pattern, xmlDict *dict, int flags, const xmlChar **namespaces); XMLPUBFUN int XMLCALL xmlPatternMatch (xmlPatternPtr comp, xmlNodePtr node); /* streaming interfaces */ typedef struct _xmlStreamCtxt xmlStreamCtxt; typedef xmlStreamCtxt *xmlStreamCtxtPtr; XMLPUBFUN int XMLCALL xmlPatternStreamable (xmlPatternPtr comp); XMLPUBFUN int XMLCALL xmlPatternMaxDepth (xmlPatternPtr comp); XMLPUBFUN int XMLCALL xmlPatternMinDepth (xmlPatternPtr comp); XMLPUBFUN int XMLCALL xmlPatternFromRoot (xmlPatternPtr comp); XMLPUBFUN xmlStreamCtxtPtr XMLCALL xmlPatternGetStreamCtxt (xmlPatternPtr comp); XMLPUBFUN void XMLCALL xmlFreeStreamCtxt (xmlStreamCtxtPtr stream); XMLPUBFUN int XMLCALL xmlStreamPushNode (xmlStreamCtxtPtr stream, const xmlChar *name, const xmlChar *ns, int nodeType); XMLPUBFUN int XMLCALL xmlStreamPush (xmlStreamCtxtPtr stream, const xmlChar *name, const xmlChar *ns); XMLPUBFUN int XMLCALL xmlStreamPushAttr (xmlStreamCtxtPtr stream, const xmlChar *name, const xmlChar *ns); XMLPUBFUN int XMLCALL xmlStreamPop (xmlStreamCtxtPtr stream); XMLPUBFUN int XMLCALL xmlStreamWantsAnyNode (xmlStreamCtxtPtr stream); #ifdef __cplusplus } #endif #endif /* LIBXML_PATTERN_ENABLED */ #endif /* __XML_PATTERN_H__ */ /* * Summary: unfinished XLink detection module * Description: unfinished XLink detection module * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_XLINK_H__ #define __XML_XLINK_H__ #include <libxml/xmlversion.h> #include <libxml/tree.h> #ifdef LIBXML_XPTR_ENABLED #ifdef __cplusplus extern "C" { #endif /** * Various defines for the various Link properties. * * NOTE: the link detection layer will try to resolve QName expansion * of namespaces. If "foo" is the prefix for "http://foo.com/" * then the link detection layer will expand role="foo:myrole" * to "http://foo.com/:myrole". * NOTE: the link detection layer will expand URI-References found on * href attributes by using the base mechanism if found. */ typedef xmlChar *xlinkHRef; typedef xmlChar *xlinkRole; typedef xmlChar *xlinkTitle; typedef enum { XLINK_TYPE_NONE = 0, XLINK_TYPE_SIMPLE, XLINK_TYPE_EXTENDED, XLINK_TYPE_EXTENDED_SET } xlinkType; typedef enum { XLINK_SHOW_NONE = 0, XLINK_SHOW_NEW, XLINK_SHOW_EMBED, XLINK_SHOW_REPLACE } xlinkShow; typedef enum { XLINK_ACTUATE_NONE = 0, XLINK_ACTUATE_AUTO, XLINK_ACTUATE_ONREQUEST } xlinkActuate; /** * xlinkNodeDetectFunc: * @ctx: user data pointer * @node: the node to check * * This is the prototype for the link detection routine. * It calls the default link detection callbacks upon link detection. */ typedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node); /* * The link detection module interact with the upper layers using * a set of callback registered at parsing time. */ /** * xlinkSimpleLinkFunk: * @ctx: user data pointer * @node: the node carrying the link * @href: the target of the link * @role: the role string * @title: the link title * * This is the prototype for a simple link detection callback. */ typedef void (*xlinkSimpleLinkFunk) (void *ctx, xmlNodePtr node, const xlinkHRef href, const xlinkRole role, const xlinkTitle title); /** * xlinkExtendedLinkFunk: * @ctx: user data pointer * @node: the node carrying the link * @nbLocators: the number of locators detected on the link * @hrefs: pointer to the array of locator hrefs * @roles: pointer to the array of locator roles * @nbArcs: the number of arcs detected on the link * @from: pointer to the array of source roles found on the arcs * @to: pointer to the array of target roles found on the arcs * @show: array of values for the show attributes found on the arcs * @actuate: array of values for the actuate attributes found on the arcs * @nbTitles: the number of titles detected on the link * @title: array of titles detected on the link * @langs: array of xml:lang values for the titles * * This is the prototype for a extended link detection callback. */ typedef void (*xlinkExtendedLinkFunk)(void *ctx, xmlNodePtr node, int nbLocators, const xlinkHRef *hrefs, const xlinkRole *roles, int nbArcs, const xlinkRole *from, const xlinkRole *to, xlinkShow *show, xlinkActuate *actuate, int nbTitles, const xlinkTitle *titles, const xmlChar **langs); /** * xlinkExtendedLinkSetFunk: * @ctx: user data pointer * @node: the node carrying the link * @nbLocators: the number of locators detected on the link * @hrefs: pointer to the array of locator hrefs * @roles: pointer to the array of locator roles * @nbTitles: the number of titles detected on the link * @title: array of titles detected on the link * @langs: array of xml:lang values for the titles * * This is the prototype for a extended link set detection callback. */ typedef void (*xlinkExtendedLinkSetFunk) (void *ctx, xmlNodePtr node, int nbLocators, const xlinkHRef *hrefs, const xlinkRole *roles, int nbTitles, const xlinkTitle *titles, const xmlChar **langs); /** * This is the structure containing a set of Links detection callbacks. * * There is no default xlink callbacks, if one want to get link * recognition activated, those call backs must be provided before parsing. */ typedef struct _xlinkHandler xlinkHandler; typedef xlinkHandler *xlinkHandlerPtr; struct _xlinkHandler { xlinkSimpleLinkFunk simple; xlinkExtendedLinkFunk extended; xlinkExtendedLinkSetFunk set; }; /* * The default detection routine, can be overridden, they call the default * detection callbacks. */ XMLPUBFUN xlinkNodeDetectFunc XMLCALL xlinkGetDefaultDetect (void); XMLPUBFUN void XMLCALL xlinkSetDefaultDetect (xlinkNodeDetectFunc func); /* * Routines to set/get the default handlers. */ XMLPUBFUN xlinkHandlerPtr XMLCALL xlinkGetDefaultHandler (void); XMLPUBFUN void XMLCALL xlinkSetDefaultHandler (xlinkHandlerPtr handler); /* * Link detection module itself. */ XMLPUBFUN xlinkType XMLCALL xlinkIsLink (xmlDocPtr doc, xmlNodePtr node); #ifdef __cplusplus } #endif #endif /* LIBXML_XPTR_ENABLED */ #endif /* __XML_XLINK_H__ */ /* * Summary: implementation of XInclude * Description: API to handle XInclude processing, * implements the * World Wide Web Consortium Last Call Working Draft 10 November 2003 * http://www.w3.org/TR/2003/WD-xinclude-20031110 * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_XINCLUDE_H__ #define __XML_XINCLUDE_H__ #include <libxml/xmlversion.h> #include <libxml/tree.h> #ifdef LIBXML_XINCLUDE_ENABLED #ifdef __cplusplus extern "C" { #endif /** * XINCLUDE_NS: * * Macro defining the Xinclude namespace: http://www.w3.org/2003/XInclude */ #define XINCLUDE_NS (const xmlChar *) "http://www.w3.org/2003/XInclude" /** * XINCLUDE_OLD_NS: * * Macro defining the draft Xinclude namespace: http://www.w3.org/2001/XInclude */ #define XINCLUDE_OLD_NS (const xmlChar *) "http://www.w3.org/2001/XInclude" /** * XINCLUDE_NODE: * * Macro defining "include" */ #define XINCLUDE_NODE (const xmlChar *) "include" /** * XINCLUDE_FALLBACK: * * Macro defining "fallback" */ #define XINCLUDE_FALLBACK (const xmlChar *) "fallback" /** * XINCLUDE_HREF: * * Macro defining "href" */ #define XINCLUDE_HREF (const xmlChar *) "href" /** * XINCLUDE_PARSE: * * Macro defining "parse" */ #define XINCLUDE_PARSE (const xmlChar *) "parse" /** * XINCLUDE_PARSE_XML: * * Macro defining "xml" */ #define XINCLUDE_PARSE_XML (const xmlChar *) "xml" /** * XINCLUDE_PARSE_TEXT: * * Macro defining "text" */ #define XINCLUDE_PARSE_TEXT (const xmlChar *) "text" /** * XINCLUDE_PARSE_ENCODING: * * Macro defining "encoding" */ #define XINCLUDE_PARSE_ENCODING (const xmlChar *) "encoding" /** * XINCLUDE_PARSE_XPOINTER: * * Macro defining "xpointer" */ #define XINCLUDE_PARSE_XPOINTER (const xmlChar *) "xpointer" typedef struct _xmlXIncludeCtxt xmlXIncludeCtxt; typedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr; /* * standalone processing */ XMLPUBFUN int XMLCALL xmlXIncludeProcess (xmlDocPtr doc); XMLPUBFUN int XMLCALL xmlXIncludeProcessFlags (xmlDocPtr doc, int flags); XMLPUBFUN int XMLCALL xmlXIncludeProcessFlagsData(xmlDocPtr doc, int flags, void *data); XMLPUBFUN int XMLCALL xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree, int flags, void *data); XMLPUBFUN int XMLCALL xmlXIncludeProcessTree (xmlNodePtr tree); XMLPUBFUN int XMLCALL xmlXIncludeProcessTreeFlags(xmlNodePtr tree, int flags); /* * contextual processing */ XMLPUBFUN xmlXIncludeCtxtPtr XMLCALL xmlXIncludeNewContext (xmlDocPtr doc); XMLPUBFUN int XMLCALL xmlXIncludeSetFlags (xmlXIncludeCtxtPtr ctxt, int flags); XMLPUBFUN void XMLCALL xmlXIncludeFreeContext (xmlXIncludeCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlXIncludeProcessNode (xmlXIncludeCtxtPtr ctxt, xmlNodePtr tree); #ifdef __cplusplus } #endif #endif /* LIBXML_XINCLUDE_ENABLED */ #endif /* __XML_XINCLUDE_H__ */ /* * Summary: Unicode character range checking * Description: this module exports interfaces for the character * range validation APIs * * This file is automatically generated from the cvs source * definition files using the genChRanges.py Python script * * Generation date: Mon Mar 27 11:09:48 2006 * Sources: chvalid.def * Author: William Brack <wbrack@mmm.com.hk> */ #ifndef __XML_CHVALID_H__ #define __XML_CHVALID_H__ #include <libxml/xmlversion.h> #include <libxml/xmlstring.h> #ifdef __cplusplus extern "C" { #endif /* * Define our typedefs and structures * */ typedef struct _xmlChSRange xmlChSRange; typedef xmlChSRange *xmlChSRangePtr; struct _xmlChSRange { unsigned short low; unsigned short high; }; typedef struct _xmlChLRange xmlChLRange; typedef xmlChLRange *xmlChLRangePtr; struct _xmlChLRange { unsigned int low; unsigned int high; }; typedef struct _xmlChRangeGroup xmlChRangeGroup; typedef xmlChRangeGroup *xmlChRangeGroupPtr; struct _xmlChRangeGroup { int nbShortRange; int nbLongRange; const xmlChSRange *shortRange; /* points to an array of ranges */ const xmlChLRange *longRange; }; /** * Range checking routine */ XMLPUBFUN int XMLCALL xmlCharInRange(unsigned int val, const xmlChRangeGroup *group); /** * xmlIsBaseChar_ch: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsBaseChar_ch(c) (((0x41 <= (c)) && ((c) <= 0x5a)) || \ ((0x61 <= (c)) && ((c) <= 0x7a)) || \ ((0xc0 <= (c)) && ((c) <= 0xd6)) || \ ((0xd8 <= (c)) && ((c) <= 0xf6)) || \ (0xf8 <= (c))) /** * xmlIsBaseCharQ: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsBaseCharQ(c) (((c) < 0x100) ? \ xmlIsBaseChar_ch((c)) : \ xmlCharInRange((c), &xmlIsBaseCharGroup)) XMLPUBVAR const xmlChRangeGroup xmlIsBaseCharGroup; /** * xmlIsBlank_ch: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsBlank_ch(c) (((c) == 0x20) || \ ((0x9 <= (c)) && ((c) <= 0xa)) || \ ((c) == 0xd)) /** * xmlIsBlankQ: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsBlankQ(c) (((c) < 0x100) ? \ xmlIsBlank_ch((c)) : 0) /** * xmlIsChar_ch: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsChar_ch(c) (((0x9 <= (c)) && ((c) <= 0xa)) || \ ((c) == 0xd) || \ (0x20 <= (c))) /** * xmlIsCharQ: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsCharQ(c) (((c) < 0x100) ? \ xmlIsChar_ch((c)) :\ (((0x100 <= (c)) && ((c) <= 0xd7ff)) || \ ((0xe000 <= (c)) && ((c) <= 0xfffd)) || \ ((0x10000 <= (c)) && ((c) <= 0x10ffff)))) XMLPUBVAR const xmlChRangeGroup xmlIsCharGroup; /** * xmlIsCombiningQ: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsCombiningQ(c) (((c) < 0x100) ? \ 0 : \ xmlCharInRange((c), &xmlIsCombiningGroup)) XMLPUBVAR const xmlChRangeGroup xmlIsCombiningGroup; /** * xmlIsDigit_ch: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsDigit_ch(c) (((0x30 <= (c)) && ((c) <= 0x39))) /** * xmlIsDigitQ: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsDigitQ(c) (((c) < 0x100) ? \ xmlIsDigit_ch((c)) : \ xmlCharInRange((c), &xmlIsDigitGroup)) XMLPUBVAR const xmlChRangeGroup xmlIsDigitGroup; /** * xmlIsExtender_ch: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsExtender_ch(c) (((c) == 0xb7)) /** * xmlIsExtenderQ: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsExtenderQ(c) (((c) < 0x100) ? \ xmlIsExtender_ch((c)) : \ xmlCharInRange((c), &xmlIsExtenderGroup)) XMLPUBVAR const xmlChRangeGroup xmlIsExtenderGroup; /** * xmlIsIdeographicQ: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsIdeographicQ(c) (((c) < 0x100) ? \ 0 :\ (((0x4e00 <= (c)) && ((c) <= 0x9fa5)) || \ ((c) == 0x3007) || \ ((0x3021 <= (c)) && ((c) <= 0x3029)))) XMLPUBVAR const xmlChRangeGroup xmlIsIdeographicGroup; XMLPUBVAR const unsigned char xmlIsPubidChar_tab[256]; /** * xmlIsPubidChar_ch: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsPubidChar_ch(c) (xmlIsPubidChar_tab[(c)]) /** * xmlIsPubidCharQ: * @c: char to validate * * Automatically generated by genChRanges.py */ #define xmlIsPubidCharQ(c) (((c) < 0x100) ? \ xmlIsPubidChar_ch((c)) : 0) XMLPUBFUN int XMLCALL xmlIsBaseChar(unsigned int ch); XMLPUBFUN int XMLCALL xmlIsBlank(unsigned int ch); XMLPUBFUN int XMLCALL xmlIsChar(unsigned int ch); XMLPUBFUN int XMLCALL xmlIsCombining(unsigned int ch); XMLPUBFUN int XMLCALL xmlIsDigit(unsigned int ch); XMLPUBFUN int XMLCALL xmlIsExtender(unsigned int ch); XMLPUBFUN int XMLCALL xmlIsIdeographic(unsigned int ch); XMLPUBFUN int XMLCALL xmlIsPubidChar(unsigned int ch); #ifdef __cplusplus } #endif #endif /* __XML_CHVALID_H__ */ /* * Summary: implementation of XML Schema Datatypes * Description: module providing the XML Schema Datatypes implementation * both definition and validity checking * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_SCHEMA_TYPES_H__ #define __XML_SCHEMA_TYPES_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_SCHEMAS_ENABLED #include <libxml/schemasInternals.h> #include <libxml/xmlschemas.h> #ifdef __cplusplus extern "C" { #endif typedef enum { XML_SCHEMA_WHITESPACE_UNKNOWN = 0, XML_SCHEMA_WHITESPACE_PRESERVE = 1, XML_SCHEMA_WHITESPACE_REPLACE = 2, XML_SCHEMA_WHITESPACE_COLLAPSE = 3 } xmlSchemaWhitespaceValueType; XMLPUBFUN void XMLCALL xmlSchemaInitTypes (void); XMLPUBFUN void XMLCALL xmlSchemaCleanupTypes (void); XMLPUBFUN xmlSchemaTypePtr XMLCALL xmlSchemaGetPredefinedType (const xmlChar *name, const xmlChar *ns); XMLPUBFUN int XMLCALL xmlSchemaValidatePredefinedType (xmlSchemaTypePtr type, const xmlChar *value, xmlSchemaValPtr *val); XMLPUBFUN int XMLCALL xmlSchemaValPredefTypeNode (xmlSchemaTypePtr type, const xmlChar *value, xmlSchemaValPtr *val, xmlNodePtr node); XMLPUBFUN int XMLCALL xmlSchemaValidateFacet (xmlSchemaTypePtr base, xmlSchemaFacetPtr facet, const xmlChar *value, xmlSchemaValPtr val); XMLPUBFUN int XMLCALL xmlSchemaValidateFacetWhtsp (xmlSchemaFacetPtr facet, xmlSchemaWhitespaceValueType fws, xmlSchemaValType valType, const xmlChar *value, xmlSchemaValPtr val, xmlSchemaWhitespaceValueType ws); XMLPUBFUN void XMLCALL xmlSchemaFreeValue (xmlSchemaValPtr val); XMLPUBFUN xmlSchemaFacetPtr XMLCALL xmlSchemaNewFacet (void); XMLPUBFUN int XMLCALL xmlSchemaCheckFacet (xmlSchemaFacetPtr facet, xmlSchemaTypePtr typeDecl, xmlSchemaParserCtxtPtr ctxt, const xmlChar *name); XMLPUBFUN void XMLCALL xmlSchemaFreeFacet (xmlSchemaFacetPtr facet); XMLPUBFUN int XMLCALL xmlSchemaCompareValues (xmlSchemaValPtr x, xmlSchemaValPtr y); XMLPUBFUN xmlSchemaTypePtr XMLCALL xmlSchemaGetBuiltInListSimpleTypeItemType (xmlSchemaTypePtr type); XMLPUBFUN int XMLCALL xmlSchemaValidateListSimpleTypeFacet (xmlSchemaFacetPtr facet, const xmlChar *value, unsigned long actualLen, unsigned long *expectedLen); XMLPUBFUN xmlSchemaTypePtr XMLCALL xmlSchemaGetBuiltInType (xmlSchemaValType type); XMLPUBFUN int XMLCALL xmlSchemaIsBuiltInTypeFacet (xmlSchemaTypePtr type, int facetType); XMLPUBFUN xmlChar * XMLCALL xmlSchemaCollapseString (const xmlChar *value); XMLPUBFUN xmlChar * XMLCALL xmlSchemaWhiteSpaceReplace (const xmlChar *value); XMLPUBFUN unsigned long XMLCALL xmlSchemaGetFacetValueAsULong (xmlSchemaFacetPtr facet); XMLPUBFUN int XMLCALL xmlSchemaValidateLengthFacet (xmlSchemaTypePtr type, xmlSchemaFacetPtr facet, const xmlChar *value, xmlSchemaValPtr val, unsigned long *length); XMLPUBFUN int XMLCALL xmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet, xmlSchemaValType valType, const xmlChar *value, xmlSchemaValPtr val, unsigned long *length, xmlSchemaWhitespaceValueType ws); XMLPUBFUN int XMLCALL xmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr type, const xmlChar *value, xmlSchemaValPtr *val, xmlNodePtr node); XMLPUBFUN int XMLCALL xmlSchemaGetCanonValue (xmlSchemaValPtr val, const xmlChar **retValue); XMLPUBFUN int XMLCALL xmlSchemaGetCanonValueWhtsp (xmlSchemaValPtr val, const xmlChar **retValue, xmlSchemaWhitespaceValueType ws); XMLPUBFUN int XMLCALL xmlSchemaValueAppend (xmlSchemaValPtr prev, xmlSchemaValPtr cur); XMLPUBFUN xmlSchemaValPtr XMLCALL xmlSchemaValueGetNext (xmlSchemaValPtr cur); XMLPUBFUN const xmlChar * XMLCALL xmlSchemaValueGetAsString (xmlSchemaValPtr val); XMLPUBFUN int XMLCALL xmlSchemaValueGetAsBoolean (xmlSchemaValPtr val); XMLPUBFUN xmlSchemaValPtr XMLCALL xmlSchemaNewStringValue (xmlSchemaValType type, const xmlChar *value); XMLPUBFUN xmlSchemaValPtr XMLCALL xmlSchemaNewNOTATIONValue (const xmlChar *name, const xmlChar *ns); XMLPUBFUN xmlSchemaValPtr XMLCALL xmlSchemaNewQNameValue (const xmlChar *namespaceName, const xmlChar *localName); XMLPUBFUN int XMLCALL xmlSchemaCompareValuesWhtsp (xmlSchemaValPtr x, xmlSchemaWhitespaceValueType xws, xmlSchemaValPtr y, xmlSchemaWhitespaceValueType yws); XMLPUBFUN xmlSchemaValPtr XMLCALL xmlSchemaCopyValue (xmlSchemaValPtr val); XMLPUBFUN xmlSchemaValType XMLCALL xmlSchemaGetValType (xmlSchemaValPtr val); #ifdef __cplusplus } #endif #endif /* LIBXML_SCHEMAS_ENABLED */ #endif /* __XML_SCHEMA_TYPES_H__ */ /* * Summary: dynamic module loading * Description: basic API for dynamic module loading, used by * libexslt added in 2.6.17 * * Copy: See Copyright for the status of this software. * * Author: Joel W. Reed */ #ifndef __XML_MODULE_H__ #define __XML_MODULE_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_MODULES_ENABLED #ifdef __cplusplus extern "C" { #endif /** * xmlModulePtr: * * A handle to a dynamically loaded module */ typedef struct _xmlModule xmlModule; typedef xmlModule *xmlModulePtr; /** * xmlModuleOption: * * enumeration of options that can be passed down to xmlModuleOpen() */ typedef enum { XML_MODULE_LAZY = 1, /* lazy binding */ XML_MODULE_LOCAL= 2 /* local binding */ } xmlModuleOption; XMLPUBFUN xmlModulePtr XMLCALL xmlModuleOpen (const char *filename, int options); XMLPUBFUN int XMLCALL xmlModuleSymbol (xmlModulePtr module, const char* name, void **result); XMLPUBFUN int XMLCALL xmlModuleClose (xmlModulePtr module); XMLPUBFUN int XMLCALL xmlModuleFree (xmlModulePtr module); #ifdef __cplusplus } #endif #endif /* LIBXML_MODULES_ENABLED */ #endif /*__XML_MODULE_H__ */ /* * Summary: interfaces for tree manipulation * Description: this module describes the structures found in an tree resulting * from an XML or HTML parsing, as well as the API provided for * various processing on that tree * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_TREE_H__ #define __XML_TREE_H__ #include <stdio.h> #include <limits.h> #include <libxml/xmlversion.h> #include <libxml/xmlstring.h> #ifdef __cplusplus extern "C" { #endif /* * Some of the basic types pointer to structures: */ /* xmlIO.h */ typedef struct _xmlParserInputBuffer xmlParserInputBuffer; typedef xmlParserInputBuffer *xmlParserInputBufferPtr; typedef struct _xmlOutputBuffer xmlOutputBuffer; typedef xmlOutputBuffer *xmlOutputBufferPtr; /* parser.h */ typedef struct _xmlParserInput xmlParserInput; typedef xmlParserInput *xmlParserInputPtr; typedef struct _xmlParserCtxt xmlParserCtxt; typedef xmlParserCtxt *xmlParserCtxtPtr; typedef struct _xmlSAXLocator xmlSAXLocator; typedef xmlSAXLocator *xmlSAXLocatorPtr; typedef struct _xmlSAXHandler xmlSAXHandler; typedef xmlSAXHandler *xmlSAXHandlerPtr; /* entities.h */ typedef struct _xmlEntity xmlEntity; typedef xmlEntity *xmlEntityPtr; /** * BASE_BUFFER_SIZE: * * default buffer size 4000. */ #define BASE_BUFFER_SIZE 4096 /** * LIBXML_NAMESPACE_DICT: * * Defines experimental behaviour: * 1) xmlNs gets an additional field @context (a xmlDoc) * 2) when creating a tree, xmlNs->href is stored in the dict of xmlDoc. */ /* #define LIBXML_NAMESPACE_DICT */ /** * xmlBufferAllocationScheme: * * A buffer allocation scheme can be defined to either match exactly the * need or double it's allocated size each time it is found too small. */ typedef enum { XML_BUFFER_ALLOC_DOUBLEIT, /* double each time one need to grow */ XML_BUFFER_ALLOC_EXACT, /* grow only to the minimal size */ XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */ XML_BUFFER_ALLOC_IO, /* special allocation scheme used for I/O */ XML_BUFFER_ALLOC_HYBRID, /* exact up to a threshold, and doubleit thereafter */ XML_BUFFER_ALLOC_BOUNDED /* limit the upper size of the buffer */ } xmlBufferAllocationScheme; /** * xmlBuffer: * * A buffer structure, this old construct is limited to 2GB and * is being deprecated, use API with xmlBuf instead */ typedef struct _xmlBuffer xmlBuffer; typedef xmlBuffer *xmlBufferPtr; struct _xmlBuffer { xmlChar *content; /* The buffer content UTF8 */ unsigned int use; /* The buffer size used */ unsigned int size; /* The buffer size */ xmlBufferAllocationScheme alloc; /* The realloc method */ xmlChar *contentIO; /* in IO mode we may have a different base */ }; /** * xmlBuf: * * A buffer structure, new one, the actual structure internals are not public */ typedef struct _xmlBuf xmlBuf; /** * xmlBufPtr: * * A pointer to a buffer structure, the actual structure internals are not * public */ typedef xmlBuf *xmlBufPtr; /* * A few public routines for xmlBuf. As those are expected to be used * mostly internally the bulk of the routines are internal in buf.h */ XMLPUBFUN xmlChar* XMLCALL xmlBufContent (const xmlBuf* buf); XMLPUBFUN xmlChar* XMLCALL xmlBufEnd (xmlBufPtr buf); XMLPUBFUN size_t XMLCALL xmlBufUse (const xmlBufPtr buf); XMLPUBFUN size_t XMLCALL xmlBufShrink (xmlBufPtr buf, size_t len); /* * LIBXML2_NEW_BUFFER: * * Macro used to express that the API use the new buffers for * xmlParserInputBuffer and xmlOutputBuffer. The change was * introduced in 2.9.0. */ #define LIBXML2_NEW_BUFFER /** * XML_XML_NAMESPACE: * * This is the namespace for the special xml: prefix predefined in the * XML Namespace specification. */ #define XML_XML_NAMESPACE \ (const xmlChar *) "http://www.w3.org/XML/1998/namespace" /** * XML_XML_ID: * * This is the name for the special xml:id attribute */ #define XML_XML_ID (const xmlChar *) "xml:id" /* * The different element types carried by an XML tree. * * NOTE: This is synchronized with DOM Level1 values * See http://www.w3.org/TR/REC-DOM-Level-1/ * * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should * be deprecated to use an XML_DTD_NODE. */ typedef enum { XML_ELEMENT_NODE= 1, XML_ATTRIBUTE_NODE= 2, XML_TEXT_NODE= 3, XML_CDATA_SECTION_NODE= 4, XML_ENTITY_REF_NODE= 5, XML_ENTITY_NODE= 6, XML_PI_NODE= 7, XML_COMMENT_NODE= 8, XML_DOCUMENT_NODE= 9, XML_DOCUMENT_TYPE_NODE= 10, XML_DOCUMENT_FRAG_NODE= 11, XML_NOTATION_NODE= 12, XML_HTML_DOCUMENT_NODE= 13, XML_DTD_NODE= 14, XML_ELEMENT_DECL= 15, XML_ATTRIBUTE_DECL= 16, XML_ENTITY_DECL= 17, XML_NAMESPACE_DECL= 18, XML_XINCLUDE_START= 19, XML_XINCLUDE_END= 20 #ifdef LIBXML_DOCB_ENABLED ,XML_DOCB_DOCUMENT_NODE= 21 #endif } xmlElementType; /** * xmlNotation: * * A DTD Notation definition. */ typedef struct _xmlNotation xmlNotation; typedef xmlNotation *xmlNotationPtr; struct _xmlNotation { const xmlChar *name; /* Notation name */ const xmlChar *PublicID; /* Public identifier, if any */ const xmlChar *SystemID; /* System identifier, if any */ }; /** * xmlAttributeType: * * A DTD Attribute type definition. */ typedef enum { XML_ATTRIBUTE_CDATA = 1, XML_ATTRIBUTE_ID, XML_ATTRIBUTE_IDREF , XML_ATTRIBUTE_IDREFS, XML_ATTRIBUTE_ENTITY, XML_ATTRIBUTE_ENTITIES, XML_ATTRIBUTE_NMTOKEN, XML_ATTRIBUTE_NMTOKENS, XML_ATTRIBUTE_ENUMERATION, XML_ATTRIBUTE_NOTATION } xmlAttributeType; /** * xmlAttributeDefault: * * A DTD Attribute default definition. */ typedef enum { XML_ATTRIBUTE_NONE = 1, XML_ATTRIBUTE_REQUIRED, XML_ATTRIBUTE_IMPLIED, XML_ATTRIBUTE_FIXED } xmlAttributeDefault; /** * xmlEnumeration: * * List structure used when there is an enumeration in DTDs. */ typedef struct _xmlEnumeration xmlEnumeration; typedef xmlEnumeration *xmlEnumerationPtr; struct _xmlEnumeration { struct _xmlEnumeration *next; /* next one */ const xmlChar *name; /* Enumeration name */ }; /** * xmlAttribute: * * An Attribute declaration in a DTD. */ typedef struct _xmlAttribute xmlAttribute; typedef xmlAttribute *xmlAttributePtr; struct _xmlAttribute { void *_private; /* application data */ xmlElementType type; /* XML_ATTRIBUTE_DECL, must be second ! */ const xmlChar *name; /* Attribute name */ struct _xmlNode *children; /* NULL */ struct _xmlNode *last; /* NULL */ struct _xmlDtd *parent; /* -> DTD */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ struct _xmlDoc *doc; /* the containing document */ struct _xmlAttribute *nexth; /* next in hash table */ xmlAttributeType atype; /* The attribute type */ xmlAttributeDefault def; /* the default */ const xmlChar *defaultValue; /* or the default value */ xmlEnumerationPtr tree; /* or the enumeration tree if any */ const xmlChar *prefix; /* the namespace prefix if any */ const xmlChar *elem; /* Element holding the attribute */ }; /** * xmlElementContentType: * * Possible definitions of element content types. */ typedef enum { XML_ELEMENT_CONTENT_PCDATA = 1, XML_ELEMENT_CONTENT_ELEMENT, XML_ELEMENT_CONTENT_SEQ, XML_ELEMENT_CONTENT_OR } xmlElementContentType; /** * xmlElementContentOccur: * * Possible definitions of element content occurrences. */ typedef enum { XML_ELEMENT_CONTENT_ONCE = 1, XML_ELEMENT_CONTENT_OPT, XML_ELEMENT_CONTENT_MULT, XML_ELEMENT_CONTENT_PLUS } xmlElementContentOccur; /** * xmlElementContent: * * An XML Element content as stored after parsing an element definition * in a DTD. */ typedef struct _xmlElementContent xmlElementContent; typedef xmlElementContent *xmlElementContentPtr; struct _xmlElementContent { xmlElementContentType type; /* PCDATA, ELEMENT, SEQ or OR */ xmlElementContentOccur ocur; /* ONCE, OPT, MULT or PLUS */ const xmlChar *name; /* Element name */ struct _xmlElementContent *c1; /* first child */ struct _xmlElementContent *c2; /* second child */ struct _xmlElementContent *parent; /* parent */ const xmlChar *prefix; /* Namespace prefix */ }; /** * xmlElementTypeVal: * * The different possibilities for an element content type. */ typedef enum { XML_ELEMENT_TYPE_UNDEFINED = 0, XML_ELEMENT_TYPE_EMPTY = 1, XML_ELEMENT_TYPE_ANY, XML_ELEMENT_TYPE_MIXED, XML_ELEMENT_TYPE_ELEMENT } xmlElementTypeVal; #ifdef __cplusplus } #endif #include <libxml/xmlregexp.h> #ifdef __cplusplus extern "C" { #endif /** * xmlElement: * * An XML Element declaration from a DTD. */ typedef struct _xmlElement xmlElement; typedef xmlElement *xmlElementPtr; struct _xmlElement { void *_private; /* application data */ xmlElementType type; /* XML_ELEMENT_DECL, must be second ! */ const xmlChar *name; /* Element name */ struct _xmlNode *children; /* NULL */ struct _xmlNode *last; /* NULL */ struct _xmlDtd *parent; /* -> DTD */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ struct _xmlDoc *doc; /* the containing document */ xmlElementTypeVal etype; /* The type */ xmlElementContentPtr content; /* the allowed element content */ xmlAttributePtr attributes; /* List of the declared attributes */ const xmlChar *prefix; /* the namespace prefix if any */ #ifdef LIBXML_REGEXP_ENABLED xmlRegexpPtr contModel; /* the validating regexp */ #else void *contModel; #endif }; /** * XML_LOCAL_NAMESPACE: * * A namespace declaration node. */ #define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL typedef xmlElementType xmlNsType; /** * xmlNs: * * An XML namespace. * Note that prefix == NULL is valid, it defines the default namespace * within the subtree (until overridden). * * xmlNsType is unified with xmlElementType. */ typedef struct _xmlNs xmlNs; typedef xmlNs *xmlNsPtr; struct _xmlNs { struct _xmlNs *next; /* next Ns link for this node */ xmlNsType type; /* global or local */ const xmlChar *href; /* URL for the namespace */ const xmlChar *prefix; /* prefix for the namespace */ void *_private; /* application data */ struct _xmlDoc *context; /* normally an xmlDoc */ }; /** * xmlDtd: * * An XML DTD, as defined by <!DOCTYPE ... There is actually one for * the internal subset and for the external subset. */ typedef struct _xmlDtd xmlDtd; typedef xmlDtd *xmlDtdPtr; struct _xmlDtd { void *_private; /* application data */ xmlElementType type; /* XML_DTD_NODE, must be second ! */ const xmlChar *name; /* Name of the DTD */ struct _xmlNode *children; /* the value of the property link */ struct _xmlNode *last; /* last child link */ struct _xmlDoc *parent; /* child->parent link */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ struct _xmlDoc *doc; /* the containing document */ /* End of common part */ void *notations; /* Hash table for notations if any */ void *elements; /* Hash table for elements if any */ void *attributes; /* Hash table for attributes if any */ void *entities; /* Hash table for entities if any */ const xmlChar *ExternalID; /* External identifier for PUBLIC DTD */ const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC DTD */ void *pentities; /* Hash table for param entities if any */ }; /** * xmlAttr: * * An attribute on an XML node. */ typedef struct _xmlAttr xmlAttr; typedef xmlAttr *xmlAttrPtr; struct _xmlAttr { void *_private; /* application data */ xmlElementType type; /* XML_ATTRIBUTE_NODE, must be second ! */ const xmlChar *name; /* the name of the property */ struct _xmlNode *children; /* the value of the property */ struct _xmlNode *last; /* NULL */ struct _xmlNode *parent; /* child->parent link */ struct _xmlAttr *next; /* next sibling link */ struct _xmlAttr *prev; /* previous sibling link */ struct _xmlDoc *doc; /* the containing document */ xmlNs *ns; /* pointer to the associated namespace */ xmlAttributeType atype; /* the attribute type if validating */ void *psvi; /* for type/PSVI information */ }; #define XML_ATTR_CLEAR_ATYPE(attr) (((attr)->atype) = 0) #define XML_ATTR_GET_ATYPE(attr) (((attr)->atype) & ~(15U << 27)) #define XML_ATTR_SET_ATYPE(attr, type) ((attr)->atype = ((((attr)->atype) & (15U << 27)) | ((type) & ~(15U << 27)))) /** * xmlID: * * An XML ID instance. */ typedef struct _xmlID xmlID; typedef xmlID *xmlIDPtr; struct _xmlID { struct _xmlID *next; /* next ID */ const xmlChar *value; /* The ID name */ xmlAttrPtr attr; /* The attribute holding it */ const xmlChar *name; /* The attribute if attr is not available */ int lineno; /* The line number if attr is not available */ struct _xmlDoc *doc; /* The document holding the ID */ }; /** * xmlRef: * * An XML IDREF instance. */ typedef struct _xmlRef xmlRef; typedef xmlRef *xmlRefPtr; struct _xmlRef { struct _xmlRef *next; /* next Ref */ const xmlChar *value; /* The Ref name */ xmlAttrPtr attr; /* The attribute holding it */ const xmlChar *name; /* The attribute if attr is not available */ int lineno; /* The line number if attr is not available */ }; /** * xmlNode: * * A node in an XML tree. */ typedef struct _xmlNode xmlNode; typedef xmlNode *xmlNodePtr; struct _xmlNode { void *_private; /* application data */ xmlElementType type; /* type number, must be second ! */ const xmlChar *name; /* the name of the node, or the entity */ struct _xmlNode *children; /* parent->childs link */ struct _xmlNode *last; /* last child link */ struct _xmlNode *parent; /* child->parent link */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ struct _xmlDoc *doc; /* the containing document */ /* End of common part */ xmlNs *ns; /* pointer to the associated namespace */ xmlChar *content; /* the content */ struct _xmlAttr *properties;/* properties list */ xmlNs *nsDef; /* namespace definitions on this node */ void *psvi; /* for type/PSVI information */ unsigned short line; /* line number */ unsigned short extra; /* extra data for XPath/XSLT */ }; #define XML_NODE_ADD_EXTRA(node, type) ((node)->extra |= ((type) & ~(15U << 12))) #define XML_NODE_CLEAR_EXTRA(node) (((node)->extra) = 0) #define XML_NODE_GET_EXTRA(node) (((node)->extra) & ~(15U << 12)) #define XML_NODE_SET_EXTRA(node, type) ((node)->extra = ((((node)->extra) & (15U << 12)) | ((type) & ~(15U << 12)))) /** * XML_GET_CONTENT: * * Macro to extract the content pointer of a node. */ #define XML_GET_CONTENT(n) \ ((n)->type == XML_ELEMENT_NODE ? NULL : (n)->content) /** * XML_GET_LINE: * * Macro to extract the line number of an element node. */ #define XML_GET_LINE(n) \ (xmlGetLineNo(n)) /** * xmlDocProperty * * Set of properties of the document as found by the parser * Some of them are linked to similarly named xmlParserOption */ typedef enum { XML_DOC_WELLFORMED = 1<<0, /* document is XML well formed */ XML_DOC_NSVALID = 1<<1, /* document is Namespace valid */ XML_DOC_OLD10 = 1<<2, /* parsed with old XML-1.0 parser */ XML_DOC_DTDVALID = 1<<3, /* DTD validation was successful */ XML_DOC_XINCLUDE = 1<<4, /* XInclude substitution was done */ XML_DOC_USERBUILT = 1<<5, /* Document was built using the API and not by parsing an instance */ XML_DOC_INTERNAL = 1<<6, /* built for internal processing */ XML_DOC_HTML = 1<<7 /* parsed or built HTML document */ } xmlDocProperties; /** * xmlDoc: * * An XML document. */ typedef struct _xmlDoc xmlDoc; typedef xmlDoc *xmlDocPtr; struct _xmlDoc { void *_private; /* application data */ xmlElementType type; /* XML_DOCUMENT_NODE, must be second ! */ char *name; /* name/filename/URI of the document */ struct _xmlNode *children; /* the document tree */ struct _xmlNode *last; /* last child link */ struct _xmlNode *parent; /* child->parent link */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ struct _xmlDoc *doc; /* autoreference to itself */ /* End of common part */ int compression;/* level of zlib compression */ int standalone; /* standalone document (no external refs) 1 if standalone="yes" 0 if standalone="no" -1 if there is no XML declaration -2 if there is an XML declaration, but no standalone attribute was specified */ struct _xmlDtd *intSubset; /* the document internal subset */ struct _xmlDtd *extSubset; /* the document external subset */ struct _xmlNs *oldNs; /* Global namespace, the old way */ const xmlChar *version; /* the XML version string */ const xmlChar *encoding; /* external initial encoding, if any */ void *ids; /* Hash table for ID attributes if any */ void *refs; /* Hash table for IDREFs attributes if any */ const xmlChar *URL; /* The URI for that document */ int charset; /* Internal flag for charset handling, actually an xmlCharEncoding */ struct _xmlDict *dict; /* dict used to allocate names or NULL */ void *psvi; /* for type/PSVI information */ int parseFlags; /* set of xmlParserOption used to parse the document */ int properties; /* set of xmlDocProperties for this document set at the end of parsing */ }; #define XML_DOC_ADD_PROPERTIES(doc, type) ((doc)->properties |= ((type) & ~(15U << 27))) #define XML_DOC_CLEAR_PROPERTIES(doc) (((doc)->properties) = 0) #define XML_DOC_GET_PROPERTIES(doc) (((doc)->properties) & ~(15U << 27)) #define XML_DOC_SET_PROPERTIES(doc, type) ((doc)->properties = ((((doc)->properties) & (15U << 27)) | ((type) & ~(15U << 27)))) typedef struct _xmlDOMWrapCtxt xmlDOMWrapCtxt; typedef xmlDOMWrapCtxt *xmlDOMWrapCtxtPtr; /** * xmlDOMWrapAcquireNsFunction: * @ctxt: a DOM wrapper context * @node: the context node (element or attribute) * @nsName: the requested namespace name * @nsPrefix: the requested namespace prefix * * A function called to acquire namespaces (xmlNs) from the wrapper. * * Returns an xmlNsPtr or NULL in case of an error. */ typedef xmlNsPtr (*xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxtPtr ctxt, xmlNodePtr node, const xmlChar *nsName, const xmlChar *nsPrefix); /** * xmlDOMWrapCtxt: * * Context for DOM wrapper-operations. */ struct _xmlDOMWrapCtxt { void * _private; /* * The type of this context, just in case we need specialized * contexts in the future. */ int type; /* * Internal namespace map used for various operations. */ void * namespaceMap; /* * Use this one to acquire an xmlNsPtr intended for node->ns. * (Note that this is not intended for elem->nsDef). */ xmlDOMWrapAcquireNsFunction getNsForNodeFunc; }; /** * xmlChildrenNode: * * Macro for compatibility naming layer with libxml1. Maps * to "children." */ #ifndef xmlChildrenNode #define xmlChildrenNode children #endif /** * xmlRootNode: * * Macro for compatibility naming layer with libxml1. Maps * to "children". */ #ifndef xmlRootNode #define xmlRootNode children #endif /* * Variables. */ /* * Some helper functions */ #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \ defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || \ defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || \ defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || \ defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED) XMLPUBFUN int XMLCALL xmlValidateNCName (const xmlChar *value, int space); #endif #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) XMLPUBFUN int XMLCALL xmlValidateQName (const xmlChar *value, int space); XMLPUBFUN int XMLCALL xmlValidateName (const xmlChar *value, int space); XMLPUBFUN int XMLCALL xmlValidateNMToken (const xmlChar *value, int space); #endif XMLPUBFUN xmlChar * XMLCALL xmlBuildQName (const xmlChar *ncname, const xmlChar *prefix, xmlChar *memory, int len); XMLPUBFUN xmlChar * XMLCALL xmlSplitQName2 (const xmlChar *name, xmlChar **prefix); XMLPUBFUN const xmlChar * XMLCALL xmlSplitQName3 (const xmlChar *name, int *len); /* * Handling Buffers, the old ones see @xmlBuf for the new ones. */ XMLPUBFUN void XMLCALL xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme); XMLPUBFUN xmlBufferAllocationScheme XMLCALL xmlGetBufferAllocationScheme(void); XMLPUBFUN xmlBufferPtr XMLCALL xmlBufferCreate (void); XMLPUBFUN xmlBufferPtr XMLCALL xmlBufferCreateSize (size_t size); XMLPUBFUN xmlBufferPtr XMLCALL xmlBufferCreateStatic (void *mem, size_t size); XMLPUBFUN int XMLCALL xmlBufferResize (xmlBufferPtr buf, unsigned int size); XMLPUBFUN void XMLCALL xmlBufferFree (xmlBufferPtr buf); XMLPUBFUN int XMLCALL xmlBufferDump (FILE *file, xmlBufferPtr buf); XMLPUBFUN int XMLCALL xmlBufferAdd (xmlBufferPtr buf, const xmlChar *str, int len); XMLPUBFUN int XMLCALL xmlBufferAddHead (xmlBufferPtr buf, const xmlChar *str, int len); XMLPUBFUN int XMLCALL xmlBufferCat (xmlBufferPtr buf, const xmlChar *str); XMLPUBFUN int XMLCALL xmlBufferCCat (xmlBufferPtr buf, const char *str); XMLPUBFUN int XMLCALL xmlBufferShrink (xmlBufferPtr buf, unsigned int len); XMLPUBFUN int XMLCALL xmlBufferGrow (xmlBufferPtr buf, unsigned int len); XMLPUBFUN void XMLCALL xmlBufferEmpty (xmlBufferPtr buf); XMLPUBFUN const xmlChar* XMLCALL xmlBufferContent (const xmlBuffer *buf); XMLPUBFUN xmlChar* XMLCALL xmlBufferDetach (xmlBufferPtr buf); XMLPUBFUN void XMLCALL xmlBufferSetAllocationScheme(xmlBufferPtr buf, xmlBufferAllocationScheme scheme); XMLPUBFUN int XMLCALL xmlBufferLength (const xmlBuffer *buf); /* * Creating/freeing new structures. */ XMLPUBFUN xmlDtdPtr XMLCALL xmlCreateIntSubset (xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); XMLPUBFUN xmlDtdPtr XMLCALL xmlNewDtd (xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); XMLPUBFUN xmlDtdPtr XMLCALL xmlGetIntSubset (const xmlDoc *doc); XMLPUBFUN void XMLCALL xmlFreeDtd (xmlDtdPtr cur); #ifdef LIBXML_LEGACY_ENABLED XMLPUBFUN xmlNsPtr XMLCALL xmlNewGlobalNs (xmlDocPtr doc, const xmlChar *href, const xmlChar *prefix); #endif /* LIBXML_LEGACY_ENABLED */ XMLPUBFUN xmlNsPtr XMLCALL xmlNewNs (xmlNodePtr node, const xmlChar *href, const xmlChar *prefix); XMLPUBFUN void XMLCALL xmlFreeNs (xmlNsPtr cur); XMLPUBFUN void XMLCALL xmlFreeNsList (xmlNsPtr cur); XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc (const xmlChar *version); XMLPUBFUN void XMLCALL xmlFreeDoc (xmlDocPtr cur); XMLPUBFUN xmlAttrPtr XMLCALL xmlNewDocProp (xmlDocPtr doc, const xmlChar *name, const xmlChar *value); #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ defined(LIBXML_SCHEMAS_ENABLED) XMLPUBFUN xmlAttrPtr XMLCALL xmlNewProp (xmlNodePtr node, const xmlChar *name, const xmlChar *value); #endif XMLPUBFUN xmlAttrPtr XMLCALL xmlNewNsProp (xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, const xmlChar *value); XMLPUBFUN xmlAttrPtr XMLCALL xmlNewNsPropEatName (xmlNodePtr node, xmlNsPtr ns, xmlChar *name, const xmlChar *value); XMLPUBFUN void XMLCALL xmlFreePropList (xmlAttrPtr cur); XMLPUBFUN void XMLCALL xmlFreeProp (xmlAttrPtr cur); XMLPUBFUN xmlAttrPtr XMLCALL xmlCopyProp (xmlNodePtr target, xmlAttrPtr cur); XMLPUBFUN xmlAttrPtr XMLCALL xmlCopyPropList (xmlNodePtr target, xmlAttrPtr cur); #ifdef LIBXML_TREE_ENABLED XMLPUBFUN xmlDtdPtr XMLCALL xmlCopyDtd (xmlDtdPtr dtd); #endif /* LIBXML_TREE_ENABLED */ #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) XMLPUBFUN xmlDocPtr XMLCALL xmlCopyDoc (xmlDocPtr doc, int recursive); #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */ /* * Creating new nodes. */ XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocNode (xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content); XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocNodeEatName (xmlDocPtr doc, xmlNsPtr ns, xmlChar *name, const xmlChar *content); XMLPUBFUN xmlNodePtr XMLCALL xmlNewNode (xmlNsPtr ns, const xmlChar *name); XMLPUBFUN xmlNodePtr XMLCALL xmlNewNodeEatName (xmlNsPtr ns, xmlChar *name); #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) XMLPUBFUN xmlNodePtr XMLCALL xmlNewChild (xmlNodePtr parent, xmlNsPtr ns, const xmlChar *name, const xmlChar *content); #endif XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocText (const xmlDoc *doc, const xmlChar *content); XMLPUBFUN xmlNodePtr XMLCALL xmlNewText (const xmlChar *content); XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocPI (xmlDocPtr doc, const xmlChar *name, const xmlChar *content); XMLPUBFUN xmlNodePtr XMLCALL xmlNewPI (const xmlChar *name, const xmlChar *content); XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocTextLen (xmlDocPtr doc, const xmlChar *content, int len); XMLPUBFUN xmlNodePtr XMLCALL xmlNewTextLen (const xmlChar *content, int len); XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocComment (xmlDocPtr doc, const xmlChar *content); XMLPUBFUN xmlNodePtr XMLCALL xmlNewComment (const xmlChar *content); XMLPUBFUN xmlNodePtr XMLCALL xmlNewCDataBlock (xmlDocPtr doc, const xmlChar *content, int len); XMLPUBFUN xmlNodePtr XMLCALL xmlNewCharRef (xmlDocPtr doc, const xmlChar *name); XMLPUBFUN xmlNodePtr XMLCALL xmlNewReference (const xmlDoc *doc, const xmlChar *name); XMLPUBFUN xmlNodePtr XMLCALL xmlCopyNode (xmlNodePtr node, int recursive); XMLPUBFUN xmlNodePtr XMLCALL xmlDocCopyNode (xmlNodePtr node, xmlDocPtr doc, int recursive); XMLPUBFUN xmlNodePtr XMLCALL xmlDocCopyNodeList (xmlDocPtr doc, xmlNodePtr node); XMLPUBFUN xmlNodePtr XMLCALL xmlCopyNodeList (xmlNodePtr node); #ifdef LIBXML_TREE_ENABLED XMLPUBFUN xmlNodePtr XMLCALL xmlNewTextChild (xmlNodePtr parent, xmlNsPtr ns, const xmlChar *name, const xmlChar *content); XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocRawNode (xmlDocPtr doc, xmlNsPtr ns, const xmlChar *name, const xmlChar *content); XMLPUBFUN xmlNodePtr XMLCALL xmlNewDocFragment (xmlDocPtr doc); #endif /* LIBXML_TREE_ENABLED */ /* * Navigating. */ XMLPUBFUN long XMLCALL xmlGetLineNo (const xmlNode *node); #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) XMLPUBFUN xmlChar * XMLCALL xmlGetNodePath (const xmlNode *node); #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) */ XMLPUBFUN xmlNodePtr XMLCALL xmlDocGetRootElement (const xmlDoc *doc); XMLPUBFUN xmlNodePtr XMLCALL xmlGetLastChild (const xmlNode *parent); XMLPUBFUN int XMLCALL xmlNodeIsText (const xmlNode *node); XMLPUBFUN int XMLCALL xmlIsBlankNode (const xmlNode *node); /* * Changing the structure. */ #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) XMLPUBFUN xmlNodePtr XMLCALL xmlDocSetRootElement (xmlDocPtr doc, xmlNodePtr root); #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */ #ifdef LIBXML_TREE_ENABLED XMLPUBFUN void XMLCALL xmlNodeSetName (xmlNodePtr cur, const xmlChar *name); #endif /* LIBXML_TREE_ENABLED */ XMLPUBFUN xmlNodePtr XMLCALL xmlAddChild (xmlNodePtr parent, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlAddChildList (xmlNodePtr parent, xmlNodePtr cur); #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) XMLPUBFUN xmlNodePtr XMLCALL xmlReplaceNode (xmlNodePtr old, xmlNodePtr cur); #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */ #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \ defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) XMLPUBFUN xmlNodePtr XMLCALL xmlAddPrevSibling (xmlNodePtr cur, xmlNodePtr elem); #endif /* LIBXML_TREE_ENABLED || LIBXML_HTML_ENABLED || LIBXML_SCHEMAS_ENABLED */ XMLPUBFUN xmlNodePtr XMLCALL xmlAddSibling (xmlNodePtr cur, xmlNodePtr elem); XMLPUBFUN xmlNodePtr XMLCALL xmlAddNextSibling (xmlNodePtr cur, xmlNodePtr elem); XMLPUBFUN void XMLCALL xmlUnlinkNode (xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlTextMerge (xmlNodePtr first, xmlNodePtr second); XMLPUBFUN int XMLCALL xmlTextConcat (xmlNodePtr node, const xmlChar *content, int len); XMLPUBFUN void XMLCALL xmlFreeNodeList (xmlNodePtr cur); XMLPUBFUN void XMLCALL xmlFreeNode (xmlNodePtr cur); XMLPUBFUN void XMLCALL xmlSetTreeDoc (xmlNodePtr tree, xmlDocPtr doc); XMLPUBFUN void XMLCALL xmlSetListDoc (xmlNodePtr list, xmlDocPtr doc); /* * Namespaces. */ XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNs (xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace); XMLPUBFUN xmlNsPtr XMLCALL xmlSearchNsByHref (xmlDocPtr doc, xmlNodePtr node, const xmlChar *href); #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \ defined(LIBXML_SCHEMAS_ENABLED) XMLPUBFUN xmlNsPtr * XMLCALL xmlGetNsList (const xmlDoc *doc, const xmlNode *node); #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) */ XMLPUBFUN void XMLCALL xmlSetNs (xmlNodePtr node, xmlNsPtr ns); XMLPUBFUN xmlNsPtr XMLCALL xmlCopyNamespace (xmlNsPtr cur); XMLPUBFUN xmlNsPtr XMLCALL xmlCopyNamespaceList (xmlNsPtr cur); /* * Changing the content. */ #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \ defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) XMLPUBFUN xmlAttrPtr XMLCALL xmlSetProp (xmlNodePtr node, const xmlChar *name, const xmlChar *value); XMLPUBFUN xmlAttrPtr XMLCALL xmlSetNsProp (xmlNodePtr node, xmlNsPtr ns, const xmlChar *name, const xmlChar *value); #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \ defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */ XMLPUBFUN xmlChar * XMLCALL xmlGetNoNsProp (const xmlNode *node, const xmlChar *name); XMLPUBFUN xmlChar * XMLCALL xmlGetProp (const xmlNode *node, const xmlChar *name); XMLPUBFUN xmlAttrPtr XMLCALL xmlHasProp (const xmlNode *node, const xmlChar *name); XMLPUBFUN xmlAttrPtr XMLCALL xmlHasNsProp (const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace); XMLPUBFUN xmlChar * XMLCALL xmlGetNsProp (const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace); XMLPUBFUN xmlNodePtr XMLCALL xmlStringGetNodeList (const xmlDoc *doc, const xmlChar *value); XMLPUBFUN xmlNodePtr XMLCALL xmlStringLenGetNodeList (const xmlDoc *doc, const xmlChar *value, int len); XMLPUBFUN xmlChar * XMLCALL xmlNodeListGetString (xmlDocPtr doc, const xmlNode *list, int inLine); #ifdef LIBXML_TREE_ENABLED XMLPUBFUN xmlChar * XMLCALL xmlNodeListGetRawString (const xmlDoc *doc, const xmlNode *list, int inLine); #endif /* LIBXML_TREE_ENABLED */ XMLPUBFUN void XMLCALL xmlNodeSetContent (xmlNodePtr cur, const xmlChar *content); #ifdef LIBXML_TREE_ENABLED XMLPUBFUN void XMLCALL xmlNodeSetContentLen (xmlNodePtr cur, const xmlChar *content, int len); #endif /* LIBXML_TREE_ENABLED */ XMLPUBFUN void XMLCALL xmlNodeAddContent (xmlNodePtr cur, const xmlChar *content); XMLPUBFUN void XMLCALL xmlNodeAddContentLen (xmlNodePtr cur, const xmlChar *content, int len); XMLPUBFUN xmlChar * XMLCALL xmlNodeGetContent (const xmlNode *cur); XMLPUBFUN int XMLCALL xmlNodeBufGetContent (xmlBufferPtr buffer, const xmlNode *cur); XMLPUBFUN int XMLCALL xmlBufGetNodeContent (xmlBufPtr buf, const xmlNode *cur); XMLPUBFUN xmlChar * XMLCALL xmlNodeGetLang (const xmlNode *cur); XMLPUBFUN int XMLCALL xmlNodeGetSpacePreserve (const xmlNode *cur); #ifdef LIBXML_TREE_ENABLED XMLPUBFUN void XMLCALL xmlNodeSetLang (xmlNodePtr cur, const xmlChar *lang); XMLPUBFUN void XMLCALL xmlNodeSetSpacePreserve (xmlNodePtr cur, int val); #endif /* LIBXML_TREE_ENABLED */ XMLPUBFUN xmlChar * XMLCALL xmlNodeGetBase (const xmlDoc *doc, const xmlNode *cur); #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) XMLPUBFUN void XMLCALL xmlNodeSetBase (xmlNodePtr cur, const xmlChar *uri); #endif /* * Removing content. */ XMLPUBFUN int XMLCALL xmlRemoveProp (xmlAttrPtr cur); #if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) XMLPUBFUN int XMLCALL xmlUnsetNsProp (xmlNodePtr node, xmlNsPtr ns, const xmlChar *name); XMLPUBFUN int XMLCALL xmlUnsetProp (xmlNodePtr node, const xmlChar *name); #endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */ /* * Internal, don't use. */ XMLPUBFUN void XMLCALL xmlBufferWriteCHAR (xmlBufferPtr buf, const xmlChar *string); XMLPUBFUN void XMLCALL xmlBufferWriteChar (xmlBufferPtr buf, const char *string); XMLPUBFUN void XMLCALL xmlBufferWriteQuotedString(xmlBufferPtr buf, const xmlChar *string); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN void xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr attr, const xmlChar *string); #endif /* LIBXML_OUTPUT_ENABLED */ #ifdef LIBXML_TREE_ENABLED /* * Namespace handling. */ XMLPUBFUN int XMLCALL xmlReconciliateNs (xmlDocPtr doc, xmlNodePtr tree); #endif #ifdef LIBXML_OUTPUT_ENABLED /* * Saving. */ XMLPUBFUN void XMLCALL xmlDocDumpFormatMemory (xmlDocPtr cur, xmlChar **mem, int *size, int format); XMLPUBFUN void XMLCALL xmlDocDumpMemory (xmlDocPtr cur, xmlChar **mem, int *size); XMLPUBFUN void XMLCALL xmlDocDumpMemoryEnc (xmlDocPtr out_doc, xmlChar **doc_txt_ptr, int * doc_txt_len, const char *txt_encoding); XMLPUBFUN void XMLCALL xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, xmlChar **doc_txt_ptr, int * doc_txt_len, const char *txt_encoding, int format); XMLPUBFUN int XMLCALL xmlDocFormatDump (FILE *f, xmlDocPtr cur, int format); XMLPUBFUN int XMLCALL xmlDocDump (FILE *f, xmlDocPtr cur); XMLPUBFUN void XMLCALL xmlElemDump (FILE *f, xmlDocPtr doc, xmlNodePtr cur); XMLPUBFUN int XMLCALL xmlSaveFile (const char *filename, xmlDocPtr cur); XMLPUBFUN int XMLCALL xmlSaveFormatFile (const char *filename, xmlDocPtr cur, int format); XMLPUBFUN size_t XMLCALL xmlBufNodeDump (xmlBufPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level, int format); XMLPUBFUN int XMLCALL xmlNodeDump (xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level, int format); XMLPUBFUN int XMLCALL xmlSaveFileTo (xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding); XMLPUBFUN int XMLCALL xmlSaveFormatFileTo (xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding, int format); XMLPUBFUN void XMLCALL xmlNodeDumpOutput (xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level, int format, const char *encoding); XMLPUBFUN int XMLCALL xmlSaveFormatFileEnc (const char *filename, xmlDocPtr cur, const char *encoding, int format); XMLPUBFUN int XMLCALL xmlSaveFileEnc (const char *filename, xmlDocPtr cur, const char *encoding); #endif /* LIBXML_OUTPUT_ENABLED */ /* * XHTML */ XMLPUBFUN int XMLCALL xmlIsXHTML (const xmlChar *systemID, const xmlChar *publicID); /* * Compression. */ XMLPUBFUN int XMLCALL xmlGetDocCompressMode (const xmlDoc *doc); XMLPUBFUN void XMLCALL xmlSetDocCompressMode (xmlDocPtr doc, int mode); XMLPUBFUN int XMLCALL xmlGetCompressMode (void); XMLPUBFUN void XMLCALL xmlSetCompressMode (int mode); /* * DOM-wrapper helper functions. */ XMLPUBFUN xmlDOMWrapCtxtPtr XMLCALL xmlDOMWrapNewCtxt (void); XMLPUBFUN void XMLCALL xmlDOMWrapFreeCtxt (xmlDOMWrapCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt, xmlNodePtr elem, int options); XMLPUBFUN int XMLCALL xmlDOMWrapAdoptNode (xmlDOMWrapCtxtPtr ctxt, xmlDocPtr sourceDoc, xmlNodePtr node, xmlDocPtr destDoc, xmlNodePtr destParent, int options); XMLPUBFUN int XMLCALL xmlDOMWrapRemoveNode (xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr node, int options); XMLPUBFUN int XMLCALL xmlDOMWrapCloneNode (xmlDOMWrapCtxtPtr ctxt, xmlDocPtr sourceDoc, xmlNodePtr node, xmlNodePtr *clonedNode, xmlDocPtr destDoc, xmlNodePtr destParent, int deep, int options); #ifdef LIBXML_TREE_ENABLED /* * 5 interfaces from DOM ElementTraversal, but different in entities * traversal. */ XMLPUBFUN unsigned long XMLCALL xmlChildElementCount (xmlNodePtr parent); XMLPUBFUN xmlNodePtr XMLCALL xmlNextElementSibling (xmlNodePtr node); XMLPUBFUN xmlNodePtr XMLCALL xmlFirstElementChild (xmlNodePtr parent); XMLPUBFUN xmlNodePtr XMLCALL xmlLastElementChild (xmlNodePtr parent); XMLPUBFUN xmlNodePtr XMLCALL xmlPreviousElementSibling (xmlNodePtr node); #endif #ifdef __cplusplus } #endif #ifndef __XML_PARSER_H__ #include <libxml/xmlmemory.h> #endif #endif /* __XML_TREE_H__ */ /* * Summary: interface for all global variables of the library * Description: all the global variables and thread handling for * those variables is handled by this module. * * The bottom of this file is automatically generated by build_glob.py * based on the description file global.data * * Copy: See Copyright for the status of this software. * * Author: Gary Pennington <Gary.Pennington@uk.sun.com>, Daniel Veillard */ #ifndef __XML_GLOBALS_H #define __XML_GLOBALS_H #include <libxml/xmlversion.h> #include <libxml/parser.h> #include <libxml/xmlerror.h> #include <libxml/SAX2.h> #include <libxml/xmlmemory.h> #ifdef __cplusplus extern "C" { #endif XMLPUBFUN void XMLCALL xmlInitGlobals(void); XMLPUBFUN void XMLCALL xmlCleanupGlobals(void); /** * xmlParserInputBufferCreateFilenameFunc: * @URI: the URI to read from * @enc: the requested source encoding * * Signature for the function doing the lookup for a suitable input method * corresponding to an URI. * * Returns the new xmlParserInputBufferPtr in case of success or NULL if no * method was found. */ typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI, xmlCharEncoding enc); /** * xmlOutputBufferCreateFilenameFunc: * @URI: the URI to write to * @enc: the requested target encoding * * Signature for the function doing the lookup for a suitable output method * corresponding to an URI. * * Returns the new xmlOutputBufferPtr in case of success or NULL if no * method was found. */ typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI, xmlCharEncodingHandlerPtr encoder, int compression); XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func); XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func); /* * Externally global symbols which need to be protected for backwards * compatibility support. */ #undef docbDefaultSAXHandler #undef htmlDefaultSAXHandler #undef oldXMLWDcompatibility #undef xmlBufferAllocScheme #undef xmlDefaultBufferSize #undef xmlDefaultSAXHandler #undef xmlDefaultSAXLocator #undef xmlDoValidityCheckingDefaultValue #undef xmlFree #undef xmlGenericError #undef xmlStructuredError #undef xmlGenericErrorContext #undef xmlStructuredErrorContext #undef xmlGetWarningsDefaultValue #undef xmlIndentTreeOutput #undef xmlTreeIndentString #undef xmlKeepBlanksDefaultValue #undef xmlLineNumbersDefaultValue #undef xmlLoadExtDtdDefaultValue #undef xmlMalloc #undef xmlMallocAtomic #undef xmlMemStrdup #undef xmlParserDebugEntities #undef xmlParserVersion #undef xmlPedanticParserDefaultValue #undef xmlRealloc #undef xmlSaveNoEmptyTags #undef xmlSubstituteEntitiesDefaultValue #undef xmlRegisterNodeDefaultValue #undef xmlDeregisterNodeDefaultValue #undef xmlLastError #undef xmlParserInputBufferCreateFilenameValue #undef xmlOutputBufferCreateFilenameValue /** * xmlRegisterNodeFunc: * @node: the current node * * Signature for the registration callback of a created node */ typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node); /** * xmlDeregisterNodeFunc: * @node: the current node * * Signature for the deregistration callback of a discarded node */ typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node); typedef struct _xmlGlobalState xmlGlobalState; typedef xmlGlobalState *xmlGlobalStatePtr; struct _xmlGlobalState { const char *xmlParserVersion; xmlSAXLocator xmlDefaultSAXLocator; xmlSAXHandlerV1 xmlDefaultSAXHandler; xmlSAXHandlerV1 docbDefaultSAXHandler; xmlSAXHandlerV1 htmlDefaultSAXHandler; xmlFreeFunc xmlFree; xmlMallocFunc xmlMalloc; xmlStrdupFunc xmlMemStrdup; xmlReallocFunc xmlRealloc; xmlGenericErrorFunc xmlGenericError; xmlStructuredErrorFunc xmlStructuredError; void *xmlGenericErrorContext; int oldXMLWDcompatibility; xmlBufferAllocationScheme xmlBufferAllocScheme; int xmlDefaultBufferSize; int xmlSubstituteEntitiesDefaultValue; int xmlDoValidityCheckingDefaultValue; int xmlGetWarningsDefaultValue; int xmlKeepBlanksDefaultValue; int xmlLineNumbersDefaultValue; int xmlLoadExtDtdDefaultValue; int xmlParserDebugEntities; int xmlPedanticParserDefaultValue; int xmlSaveNoEmptyTags; int xmlIndentTreeOutput; const char *xmlTreeIndentString; xmlRegisterNodeFunc xmlRegisterNodeDefaultValue; xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue; xmlMallocFunc xmlMallocAtomic; xmlError xmlLastError; xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue; xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue; void *xmlStructuredErrorContext; }; #ifdef __cplusplus } #endif #include <libxml/threads.h> #ifdef __cplusplus extern "C" { #endif XMLPUBFUN void XMLCALL xmlInitializeGlobalState(xmlGlobalStatePtr gs); XMLPUBFUN void XMLCALL xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler); XMLPUBFUN void XMLCALL xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler); XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlRegisterNodeDefault(xmlRegisterNodeFunc func); XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func); XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func); XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func); XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func); XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL xmlThrDefParserInputBufferCreateFilenameDefault( xmlParserInputBufferCreateFilenameFunc func); /** DOC_DISABLE */ /* * In general the memory allocation entry points are not kept * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED * - xmlMalloc * - xmlMallocAtomic * - xmlRealloc * - xmlMemStrdup * - xmlFree */ #ifdef LIBXML_THREAD_ALLOC_ENABLED #ifdef LIBXML_THREAD_ENABLED XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMalloc(void); #define xmlMalloc \ (*(__xmlMalloc())) #else XMLPUBVAR xmlMallocFunc xmlMalloc; #endif #ifdef LIBXML_THREAD_ENABLED XMLPUBFUN xmlMallocFunc * XMLCALL __xmlMallocAtomic(void); #define xmlMallocAtomic \ (*(__xmlMallocAtomic())) #else XMLPUBVAR xmlMallocFunc xmlMallocAtomic; #endif #ifdef LIBXML_THREAD_ENABLED XMLPUBFUN xmlReallocFunc * XMLCALL __xmlRealloc(void); #define xmlRealloc \ (*(__xmlRealloc())) #else XMLPUBVAR xmlReallocFunc xmlRealloc; #endif #ifdef LIBXML_THREAD_ENABLED XMLPUBFUN xmlFreeFunc * XMLCALL __xmlFree(void); #define xmlFree \ (*(__xmlFree())) #else XMLPUBVAR xmlFreeFunc xmlFree; #endif #ifdef LIBXML_THREAD_ENABLED XMLPUBFUN xmlStrdupFunc * XMLCALL __xmlMemStrdup(void); #define xmlMemStrdup \ (*(__xmlMemStrdup())) #else XMLPUBVAR xmlStrdupFunc xmlMemStrdup; #endif #else /* !LIBXML_THREAD_ALLOC_ENABLED */ XMLPUBVAR xmlMallocFunc xmlMalloc; XMLPUBVAR xmlMallocFunc xmlMallocAtomic; XMLPUBVAR xmlReallocFunc xmlRealloc; XMLPUBVAR xmlFreeFunc xmlFree; XMLPUBVAR xmlStrdupFunc xmlMemStrdup; #endif /* LIBXML_THREAD_ALLOC_ENABLED */ #ifdef LIBXML_DOCB_ENABLED XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __docbDefaultSAXHandler(void); #ifdef LIBXML_THREAD_ENABLED #define docbDefaultSAXHandler \ (*(__docbDefaultSAXHandler())) #else XMLPUBVAR xmlSAXHandlerV1 docbDefaultSAXHandler; #endif #endif #ifdef LIBXML_HTML_ENABLED XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __htmlDefaultSAXHandler(void); #ifdef LIBXML_THREAD_ENABLED #define htmlDefaultSAXHandler \ (*(__htmlDefaultSAXHandler())) #else XMLPUBVAR xmlSAXHandlerV1 htmlDefaultSAXHandler; #endif #endif XMLPUBFUN xmlError * XMLCALL __xmlLastError(void); #ifdef LIBXML_THREAD_ENABLED #define xmlLastError \ (*(__xmlLastError())) #else XMLPUBVAR xmlError xmlLastError; #endif /* * Everything starting from the line below is * Automatically generated by build_glob.py. * Do not modify the previous line. */ XMLPUBFUN int * XMLCALL __oldXMLWDcompatibility(void); #ifdef LIBXML_THREAD_ENABLED #define oldXMLWDcompatibility \ (*(__oldXMLWDcompatibility())) #else XMLPUBVAR int oldXMLWDcompatibility; #endif XMLPUBFUN xmlBufferAllocationScheme * XMLCALL __xmlBufferAllocScheme(void); #ifdef LIBXML_THREAD_ENABLED #define xmlBufferAllocScheme \ (*(__xmlBufferAllocScheme())) #else XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme; #endif XMLPUBFUN xmlBufferAllocationScheme XMLCALL xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v); XMLPUBFUN int * XMLCALL __xmlDefaultBufferSize(void); #ifdef LIBXML_THREAD_ENABLED #define xmlDefaultBufferSize \ (*(__xmlDefaultBufferSize())) #else XMLPUBVAR int xmlDefaultBufferSize; #endif XMLPUBFUN int XMLCALL xmlThrDefDefaultBufferSize(int v); XMLPUBFUN xmlSAXHandlerV1 * XMLCALL __xmlDefaultSAXHandler(void); #ifdef LIBXML_THREAD_ENABLED #define xmlDefaultSAXHandler \ (*(__xmlDefaultSAXHandler())) #else XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler; #endif XMLPUBFUN xmlSAXLocator * XMLCALL __xmlDefaultSAXLocator(void); #ifdef LIBXML_THREAD_ENABLED #define xmlDefaultSAXLocator \ (*(__xmlDefaultSAXLocator())) #else XMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator; #endif XMLPUBFUN int * XMLCALL __xmlDoValidityCheckingDefaultValue(void); #ifdef LIBXML_THREAD_ENABLED #define xmlDoValidityCheckingDefaultValue \ (*(__xmlDoValidityCheckingDefaultValue())) #else XMLPUBVAR int xmlDoValidityCheckingDefaultValue; #endif XMLPUBFUN int XMLCALL xmlThrDefDoValidityCheckingDefaultValue(int v); XMLPUBFUN xmlGenericErrorFunc * XMLCALL __xmlGenericError(void); #ifdef LIBXML_THREAD_ENABLED #define xmlGenericError \ (*(__xmlGenericError())) #else XMLPUBVAR xmlGenericErrorFunc xmlGenericError; #endif XMLPUBFUN xmlStructuredErrorFunc * XMLCALL __xmlStructuredError(void); #ifdef LIBXML_THREAD_ENABLED #define xmlStructuredError \ (*(__xmlStructuredError())) #else XMLPUBVAR xmlStructuredErrorFunc xmlStructuredError; #endif XMLPUBFUN void * * XMLCALL __xmlGenericErrorContext(void); #ifdef LIBXML_THREAD_ENABLED #define xmlGenericErrorContext \ (*(__xmlGenericErrorContext())) #else XMLPUBVAR void * xmlGenericErrorContext; #endif XMLPUBFUN void * * XMLCALL __xmlStructuredErrorContext(void); #ifdef LIBXML_THREAD_ENABLED #define xmlStructuredErrorContext \ (*(__xmlStructuredErrorContext())) #else XMLPUBVAR void * xmlStructuredErrorContext; #endif XMLPUBFUN int * XMLCALL __xmlGetWarningsDefaultValue(void); #ifdef LIBXML_THREAD_ENABLED #define xmlGetWarningsDefaultValue \ (*(__xmlGetWarningsDefaultValue())) #else XMLPUBVAR int xmlGetWarningsDefaultValue; #endif XMLPUBFUN int XMLCALL xmlThrDefGetWarningsDefaultValue(int v); XMLPUBFUN int * XMLCALL __xmlIndentTreeOutput(void); #ifdef LIBXML_THREAD_ENABLED #define xmlIndentTreeOutput \ (*(__xmlIndentTreeOutput())) #else XMLPUBVAR int xmlIndentTreeOutput; #endif XMLPUBFUN int XMLCALL xmlThrDefIndentTreeOutput(int v); XMLPUBFUN const char * * XMLCALL __xmlTreeIndentString(void); #ifdef LIBXML_THREAD_ENABLED #define xmlTreeIndentString \ (*(__xmlTreeIndentString())) #else XMLPUBVAR const char * xmlTreeIndentString; #endif XMLPUBFUN const char * XMLCALL xmlThrDefTreeIndentString(const char * v); XMLPUBFUN int * XMLCALL __xmlKeepBlanksDefaultValue(void); #ifdef LIBXML_THREAD_ENABLED #define xmlKeepBlanksDefaultValue \ (*(__xmlKeepBlanksDefaultValue())) #else XMLPUBVAR int xmlKeepBlanksDefaultValue; #endif XMLPUBFUN int XMLCALL xmlThrDefKeepBlanksDefaultValue(int v); XMLPUBFUN int * XMLCALL __xmlLineNumbersDefaultValue(void); #ifdef LIBXML_THREAD_ENABLED #define xmlLineNumbersDefaultValue \ (*(__xmlLineNumbersDefaultValue())) #else XMLPUBVAR int xmlLineNumbersDefaultValue; #endif XMLPUBFUN int XMLCALL xmlThrDefLineNumbersDefaultValue(int v); XMLPUBFUN int * XMLCALL __xmlLoadExtDtdDefaultValue(void); #ifdef LIBXML_THREAD_ENABLED #define xmlLoadExtDtdDefaultValue \ (*(__xmlLoadExtDtdDefaultValue())) #else XMLPUBVAR int xmlLoadExtDtdDefaultValue; #endif XMLPUBFUN int XMLCALL xmlThrDefLoadExtDtdDefaultValue(int v); XMLPUBFUN int * XMLCALL __xmlParserDebugEntities(void); #ifdef LIBXML_THREAD_ENABLED #define xmlParserDebugEntities \ (*(__xmlParserDebugEntities())) #else XMLPUBVAR int xmlParserDebugEntities; #endif XMLPUBFUN int XMLCALL xmlThrDefParserDebugEntities(int v); XMLPUBFUN const char * * XMLCALL __xmlParserVersion(void); #ifdef LIBXML_THREAD_ENABLED #define xmlParserVersion \ (*(__xmlParserVersion())) #else XMLPUBVAR const char * xmlParserVersion; #endif XMLPUBFUN int * XMLCALL __xmlPedanticParserDefaultValue(void); #ifdef LIBXML_THREAD_ENABLED #define xmlPedanticParserDefaultValue \ (*(__xmlPedanticParserDefaultValue())) #else XMLPUBVAR int xmlPedanticParserDefaultValue; #endif XMLPUBFUN int XMLCALL xmlThrDefPedanticParserDefaultValue(int v); XMLPUBFUN int * XMLCALL __xmlSaveNoEmptyTags(void); #ifdef LIBXML_THREAD_ENABLED #define xmlSaveNoEmptyTags \ (*(__xmlSaveNoEmptyTags())) #else XMLPUBVAR int xmlSaveNoEmptyTags; #endif XMLPUBFUN int XMLCALL xmlThrDefSaveNoEmptyTags(int v); XMLPUBFUN int * XMLCALL __xmlSubstituteEntitiesDefaultValue(void); #ifdef LIBXML_THREAD_ENABLED #define xmlSubstituteEntitiesDefaultValue \ (*(__xmlSubstituteEntitiesDefaultValue())) #else XMLPUBVAR int xmlSubstituteEntitiesDefaultValue; #endif XMLPUBFUN int XMLCALL xmlThrDefSubstituteEntitiesDefaultValue(int v); XMLPUBFUN xmlRegisterNodeFunc * XMLCALL __xmlRegisterNodeDefaultValue(void); #ifdef LIBXML_THREAD_ENABLED #define xmlRegisterNodeDefaultValue \ (*(__xmlRegisterNodeDefaultValue())) #else XMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue; #endif XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void); #ifdef LIBXML_THREAD_ENABLED #define xmlDeregisterNodeDefaultValue \ (*(__xmlDeregisterNodeDefaultValue())) #else XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue; #endif XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL \ __xmlParserInputBufferCreateFilenameValue(void); #ifdef LIBXML_THREAD_ENABLED #define xmlParserInputBufferCreateFilenameValue \ (*(__xmlParserInputBufferCreateFilenameValue())) #else XMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue; #endif XMLPUBFUN xmlOutputBufferCreateFilenameFunc * XMLCALL __xmlOutputBufferCreateFilenameValue(void); #ifdef LIBXML_THREAD_ENABLED #define xmlOutputBufferCreateFilenameValue \ (*(__xmlOutputBufferCreateFilenameValue())) #else XMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue; #endif #ifdef __cplusplus } #endif #endif /* __XML_GLOBALS_H */ /* * Summary: lists interfaces * Description: this module implement the list support used in * various place in the library. * * Copy: See Copyright for the status of this software. * * Author: Gary Pennington <Gary.Pennington@uk.sun.com> */ #ifndef __XML_LINK_INCLUDE__ #define __XML_LINK_INCLUDE__ #include <libxml/xmlversion.h> #ifdef __cplusplus extern "C" { #endif typedef struct _xmlLink xmlLink; typedef xmlLink *xmlLinkPtr; typedef struct _xmlList xmlList; typedef xmlList *xmlListPtr; /** * xmlListDeallocator: * @lk: the data to deallocate * * Callback function used to free data from a list. */ typedef void (*xmlListDeallocator) (xmlLinkPtr lk); /** * xmlListDataCompare: * @data0: the first data * @data1: the second data * * Callback function used to compare 2 data. * * Returns 0 is equality, -1 or 1 otherwise depending on the ordering. */ typedef int (*xmlListDataCompare) (const void *data0, const void *data1); /** * xmlListWalker: * @data: the data found in the list * @user: extra user provided data to the walker * * Callback function used when walking a list with xmlListWalk(). * * Returns 0 to stop walking the list, 1 otherwise. */ typedef int (*xmlListWalker) (const void *data, void *user); /* Creation/Deletion */ XMLPUBFUN xmlListPtr XMLCALL xmlListCreate (xmlListDeallocator deallocator, xmlListDataCompare compare); XMLPUBFUN void XMLCALL xmlListDelete (xmlListPtr l); /* Basic Operators */ XMLPUBFUN void * XMLCALL xmlListSearch (xmlListPtr l, void *data); XMLPUBFUN void * XMLCALL xmlListReverseSearch (xmlListPtr l, void *data); XMLPUBFUN int XMLCALL xmlListInsert (xmlListPtr l, void *data) ; XMLPUBFUN int XMLCALL xmlListAppend (xmlListPtr l, void *data) ; XMLPUBFUN int XMLCALL xmlListRemoveFirst (xmlListPtr l, void *data); XMLPUBFUN int XMLCALL xmlListRemoveLast (xmlListPtr l, void *data); XMLPUBFUN int XMLCALL xmlListRemoveAll (xmlListPtr l, void *data); XMLPUBFUN void XMLCALL xmlListClear (xmlListPtr l); XMLPUBFUN int XMLCALL xmlListEmpty (xmlListPtr l); XMLPUBFUN xmlLinkPtr XMLCALL xmlListFront (xmlListPtr l); XMLPUBFUN xmlLinkPtr XMLCALL xmlListEnd (xmlListPtr l); XMLPUBFUN int XMLCALL xmlListSize (xmlListPtr l); XMLPUBFUN void XMLCALL xmlListPopFront (xmlListPtr l); XMLPUBFUN void XMLCALL xmlListPopBack (xmlListPtr l); XMLPUBFUN int XMLCALL xmlListPushFront (xmlListPtr l, void *data); XMLPUBFUN int XMLCALL xmlListPushBack (xmlListPtr l, void *data); /* Advanced Operators */ XMLPUBFUN void XMLCALL xmlListReverse (xmlListPtr l); XMLPUBFUN void XMLCALL xmlListSort (xmlListPtr l); XMLPUBFUN void XMLCALL xmlListWalk (xmlListPtr l, xmlListWalker walker, void *user); XMLPUBFUN void XMLCALL xmlListReverseWalk (xmlListPtr l, xmlListWalker walker, void *user); XMLPUBFUN void XMLCALL xmlListMerge (xmlListPtr l1, xmlListPtr l2); XMLPUBFUN xmlListPtr XMLCALL xmlListDup (const xmlListPtr old); XMLPUBFUN int XMLCALL xmlListCopy (xmlListPtr cur, const xmlListPtr old); /* Link operators */ XMLPUBFUN void * XMLCALL xmlLinkGetData (xmlLinkPtr lk); /* xmlListUnique() */ /* xmlListSwap */ #ifdef __cplusplus } #endif #endif /* __XML_LINK_INCLUDE__ */ /* * Summary: interface for the XML entities handling * Description: this module provides some of the entity API needed * for the parser and applications. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_ENTITIES_H__ #define __XML_ENTITIES_H__ #include <libxml/xmlversion.h> #include <libxml/tree.h> #ifdef __cplusplus extern "C" { #endif /* * The different valid entity types. */ typedef enum { XML_INTERNAL_GENERAL_ENTITY = 1, XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2, XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3, XML_INTERNAL_PARAMETER_ENTITY = 4, XML_EXTERNAL_PARAMETER_ENTITY = 5, XML_INTERNAL_PREDEFINED_ENTITY = 6 } xmlEntityType; /* * An unit of storage for an entity, contains the string, the value * and the linkind data needed for the linking in the hash table. */ struct _xmlEntity { void *_private; /* application data */ xmlElementType type; /* XML_ENTITY_DECL, must be second ! */ const xmlChar *name; /* Entity name */ struct _xmlNode *children; /* First child link */ struct _xmlNode *last; /* Last child link */ struct _xmlDtd *parent; /* -> DTD */ struct _xmlNode *next; /* next sibling link */ struct _xmlNode *prev; /* previous sibling link */ struct _xmlDoc *doc; /* the containing document */ xmlChar *orig; /* content without ref substitution */ xmlChar *content; /* content or ndata if unparsed */ int length; /* the content length */ xmlEntityType etype; /* The entity type */ const xmlChar *ExternalID; /* External identifier for PUBLIC */ const xmlChar *SystemID; /* URI for a SYSTEM or PUBLIC Entity */ struct _xmlEntity *nexte; /* unused */ const xmlChar *URI; /* the full URI as computed */ int owner; /* does the entity own the childrens */ int checked; /* was the entity content checked */ /* this is also used to count entities * references done from that entity * and if it contains '<' */ int flags; /* various flags */ unsigned long expandedSize; /* expanded size */ }; /* * All entities are stored in an hash table. * There is 2 separate hash tables for global and parameter entities. */ typedef struct _xmlHashTable xmlEntitiesTable; typedef xmlEntitiesTable *xmlEntitiesTablePtr; /* * External functions: */ #ifdef LIBXML_LEGACY_ENABLED XMLPUBFUN void XMLCALL xmlInitializePredefinedEntities (void); #endif /* LIBXML_LEGACY_ENABLED */ XMLPUBFUN xmlEntityPtr XMLCALL xmlNewEntity (xmlDocPtr doc, const xmlChar *name, int type, const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *content); XMLPUBFUN xmlEntityPtr XMLCALL xmlAddDocEntity (xmlDocPtr doc, const xmlChar *name, int type, const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *content); XMLPUBFUN xmlEntityPtr XMLCALL xmlAddDtdEntity (xmlDocPtr doc, const xmlChar *name, int type, const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *content); XMLPUBFUN xmlEntityPtr XMLCALL xmlGetPredefinedEntity (const xmlChar *name); XMLPUBFUN xmlEntityPtr XMLCALL xmlGetDocEntity (const xmlDoc *doc, const xmlChar *name); XMLPUBFUN xmlEntityPtr XMLCALL xmlGetDtdEntity (xmlDocPtr doc, const xmlChar *name); XMLPUBFUN xmlEntityPtr XMLCALL xmlGetParameterEntity (xmlDocPtr doc, const xmlChar *name); #ifdef LIBXML_LEGACY_ENABLED XMLPUBFUN const xmlChar * XMLCALL xmlEncodeEntities (xmlDocPtr doc, const xmlChar *input); #endif /* LIBXML_LEGACY_ENABLED */ XMLPUBFUN xmlChar * XMLCALL xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input); XMLPUBFUN xmlChar * XMLCALL xmlEncodeSpecialChars (const xmlDoc *doc, const xmlChar *input); XMLPUBFUN xmlEntitiesTablePtr XMLCALL xmlCreateEntitiesTable (void); #ifdef LIBXML_TREE_ENABLED XMLPUBFUN xmlEntitiesTablePtr XMLCALL xmlCopyEntitiesTable (xmlEntitiesTablePtr table); #endif /* LIBXML_TREE_ENABLED */ XMLPUBFUN void XMLCALL xmlFreeEntitiesTable (xmlEntitiesTablePtr table); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN void XMLCALL xmlDumpEntitiesTable (xmlBufferPtr buf, xmlEntitiesTablePtr table); XMLPUBFUN void XMLCALL xmlDumpEntityDecl (xmlBufferPtr buf, xmlEntityPtr ent); #endif /* LIBXML_OUTPUT_ENABLED */ #ifdef LIBXML_LEGACY_ENABLED XMLPUBFUN void XMLCALL xmlCleanupPredefinedEntities(void); #endif /* LIBXML_LEGACY_ENABLED */ #ifdef __cplusplus } #endif # endif /* __XML_ENTITIES_H__ */ /** * Summary: library of generic URI related routines * Description: library of generic URI related routines * Implements RFC 2396 * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_URI_H__ #define __XML_URI_H__ #include <libxml/xmlversion.h> #include <libxml/tree.h> #ifdef __cplusplus extern "C" { #endif /** * xmlURI: * * A parsed URI reference. This is a struct containing the various fields * as described in RFC 2396 but separated for further processing. * * Note: query is a deprecated field which is incorrectly unescaped. * query_raw takes precedence over query if the former is set. * See: http://mail.gnome.org/archives/xml/2007-April/thread.html#00127 */ typedef struct _xmlURI xmlURI; typedef xmlURI *xmlURIPtr; struct _xmlURI { char *scheme; /* the URI scheme */ char *opaque; /* opaque part */ char *authority; /* the authority part */ char *server; /* the server part */ char *user; /* the user part */ int port; /* the port number */ char *path; /* the path string */ char *query; /* the query string (deprecated - use with caution) */ char *fragment; /* the fragment identifier */ int cleanup; /* parsing potentially unclean URI */ char *query_raw; /* the query string (as it appears in the URI) */ }; /* * This function is in tree.h: * xmlChar * xmlNodeGetBase (xmlDocPtr doc, * xmlNodePtr cur); */ XMLPUBFUN xmlURIPtr XMLCALL xmlCreateURI (void); XMLPUBFUN xmlChar * XMLCALL xmlBuildURI (const xmlChar *URI, const xmlChar *base); XMLPUBFUN xmlChar * XMLCALL xmlBuildRelativeURI (const xmlChar *URI, const xmlChar *base); XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI (const char *str); XMLPUBFUN xmlURIPtr XMLCALL xmlParseURIRaw (const char *str, int raw); XMLPUBFUN int XMLCALL xmlParseURIReference (xmlURIPtr uri, const char *str); XMLPUBFUN xmlChar * XMLCALL xmlSaveUri (xmlURIPtr uri); XMLPUBFUN void XMLCALL xmlPrintURI (FILE *stream, xmlURIPtr uri); XMLPUBFUN xmlChar * XMLCALL xmlURIEscapeStr (const xmlChar *str, const xmlChar *list); XMLPUBFUN char * XMLCALL xmlURIUnescapeString (const char *str, int len, char *target); XMLPUBFUN int XMLCALL xmlNormalizeURIPath (char *path); XMLPUBFUN xmlChar * XMLCALL xmlURIEscape (const xmlChar *str); XMLPUBFUN void XMLCALL xmlFreeURI (xmlURIPtr uri); XMLPUBFUN xmlChar* XMLCALL xmlCanonicPath (const xmlChar *path); XMLPUBFUN xmlChar* XMLCALL xmlPathToURI (const xmlChar *path); #ifdef __cplusplus } #endif #endif /* __XML_URI_H__ */ /* * Summary: Tree debugging APIs * Description: Interfaces to a set of routines used for debugging the tree * produced by the XML parser. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __DEBUG_XML__ #define __DEBUG_XML__ #include <stdio.h> #include <libxml/xmlversion.h> #include <libxml/tree.h> #ifdef LIBXML_DEBUG_ENABLED #include <libxml/xpath.h> #ifdef __cplusplus extern "C" { #endif /* * The standard Dump routines. */ XMLPUBFUN void XMLCALL xmlDebugDumpString (FILE *output, const xmlChar *str); XMLPUBFUN void XMLCALL xmlDebugDumpAttr (FILE *output, xmlAttrPtr attr, int depth); XMLPUBFUN void XMLCALL xmlDebugDumpAttrList (FILE *output, xmlAttrPtr attr, int depth); XMLPUBFUN void XMLCALL xmlDebugDumpOneNode (FILE *output, xmlNodePtr node, int depth); XMLPUBFUN void XMLCALL xmlDebugDumpNode (FILE *output, xmlNodePtr node, int depth); XMLPUBFUN void XMLCALL xmlDebugDumpNodeList (FILE *output, xmlNodePtr node, int depth); XMLPUBFUN void XMLCALL xmlDebugDumpDocumentHead(FILE *output, xmlDocPtr doc); XMLPUBFUN void XMLCALL xmlDebugDumpDocument (FILE *output, xmlDocPtr doc); XMLPUBFUN void XMLCALL xmlDebugDumpDTD (FILE *output, xmlDtdPtr dtd); XMLPUBFUN void XMLCALL xmlDebugDumpEntities (FILE *output, xmlDocPtr doc); /**************************************************************** * * * Checking routines * * * ****************************************************************/ XMLPUBFUN int XMLCALL xmlDebugCheckDocument (FILE * output, xmlDocPtr doc); /**************************************************************** * * * XML shell helpers * * * ****************************************************************/ XMLPUBFUN void XMLCALL xmlLsOneNode (FILE *output, xmlNodePtr node); XMLPUBFUN int XMLCALL xmlLsCountNode (xmlNodePtr node); XMLPUBFUN const char * XMLCALL xmlBoolToText (int boolval); /**************************************************************** * * * The XML shell related structures and functions * * * ****************************************************************/ #ifdef LIBXML_XPATH_ENABLED /** * xmlShellReadlineFunc: * @prompt: a string prompt * * This is a generic signature for the XML shell input function. * * Returns a string which will be freed by the Shell. */ typedef char * (* xmlShellReadlineFunc)(char *prompt); /** * xmlShellCtxt: * * A debugging shell context. * TODO: add the defined function tables. */ typedef struct _xmlShellCtxt xmlShellCtxt; typedef xmlShellCtxt *xmlShellCtxtPtr; struct _xmlShellCtxt { char *filename; xmlDocPtr doc; xmlNodePtr node; xmlXPathContextPtr pctxt; int loaded; FILE *output; xmlShellReadlineFunc input; }; /** * xmlShellCmd: * @ctxt: a shell context * @arg: a string argument * @node: a first node * @node2: a second node * * This is a generic signature for the XML shell functions. * * Returns an int, negative returns indicating errors. */ typedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node, xmlNodePtr node2); XMLPUBFUN void XMLCALL xmlShellPrintXPathError (int errorType, const char *arg); XMLPUBFUN void XMLCALL xmlShellPrintXPathResult(xmlXPathObjectPtr list); XMLPUBFUN int XMLCALL xmlShellList (xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node, xmlNodePtr node2); XMLPUBFUN int XMLCALL xmlShellBase (xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node, xmlNodePtr node2); XMLPUBFUN int XMLCALL xmlShellDir (xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node, xmlNodePtr node2); XMLPUBFUN int XMLCALL xmlShellLoad (xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node, xmlNodePtr node2); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN void XMLCALL xmlShellPrintNode (xmlNodePtr node); XMLPUBFUN int XMLCALL xmlShellCat (xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr node, xmlNodePtr node2); XMLPUBFUN int XMLCALL xmlShellWrite (xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node, xmlNodePtr node2); XMLPUBFUN int XMLCALL xmlShellSave (xmlShellCtxtPtr ctxt, char *filename, xmlNodePtr node, xmlNodePtr node2); #endif /* LIBXML_OUTPUT_ENABLED */ #ifdef LIBXML_VALID_ENABLED XMLPUBFUN int XMLCALL xmlShellValidate (xmlShellCtxtPtr ctxt, char *dtd, xmlNodePtr node, xmlNodePtr node2); #endif /* LIBXML_VALID_ENABLED */ XMLPUBFUN int XMLCALL xmlShellDu (xmlShellCtxtPtr ctxt, char *arg, xmlNodePtr tree, xmlNodePtr node2); XMLPUBFUN int XMLCALL xmlShellPwd (xmlShellCtxtPtr ctxt, char *buffer, xmlNodePtr node, xmlNodePtr node2); /* * The Shell interface. */ XMLPUBFUN void XMLCALL xmlShell (xmlDocPtr doc, char *filename, xmlShellReadlineFunc input, FILE *output); #endif /* LIBXML_XPATH_ENABLED */ #ifdef __cplusplus } #endif #endif /* LIBXML_DEBUG_ENABLED */ #endif /* __DEBUG_XML__ */ /* * Summary: internal interfaces for XML Path Language implementation * Description: internal interfaces for XML Path Language implementation * used to build new modules on top of XPath like XPointer and * XSLT * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_XPATH_INTERNALS_H__ #define __XML_XPATH_INTERNALS_H__ #include <libxml/xmlversion.h> #include <libxml/xpath.h> #ifdef LIBXML_XPATH_ENABLED #ifdef __cplusplus extern "C" { #endif /************************************************************************ * * * Helpers * * * ************************************************************************/ /* * Many of these macros may later turn into functions. They * shouldn't be used in #ifdef's preprocessor instructions. */ /** * xmlXPathSetError: * @ctxt: an XPath parser context * @err: an xmlXPathError code * * Raises an error. */ #define xmlXPathSetError(ctxt, err) \ { xmlXPatherror((ctxt), __FILE__, __LINE__, (err)); \ if ((ctxt) != NULL) (ctxt)->error = (err); } /** * xmlXPathSetArityError: * @ctxt: an XPath parser context * * Raises an XPATH_INVALID_ARITY error. */ #define xmlXPathSetArityError(ctxt) \ xmlXPathSetError((ctxt), XPATH_INVALID_ARITY) /** * xmlXPathSetTypeError: * @ctxt: an XPath parser context * * Raises an XPATH_INVALID_TYPE error. */ #define xmlXPathSetTypeError(ctxt) \ xmlXPathSetError((ctxt), XPATH_INVALID_TYPE) /** * xmlXPathGetError: * @ctxt: an XPath parser context * * Get the error code of an XPath context. * * Returns the context error. */ #define xmlXPathGetError(ctxt) ((ctxt)->error) /** * xmlXPathCheckError: * @ctxt: an XPath parser context * * Check if an XPath error was raised. * * Returns true if an error has been raised, false otherwise. */ #define xmlXPathCheckError(ctxt) ((ctxt)->error != XPATH_EXPRESSION_OK) /** * xmlXPathGetDocument: * @ctxt: an XPath parser context * * Get the document of an XPath context. * * Returns the context document. */ #define xmlXPathGetDocument(ctxt) ((ctxt)->context->doc) /** * xmlXPathGetContextNode: * @ctxt: an XPath parser context * * Get the context node of an XPath context. * * Returns the context node. */ #define xmlXPathGetContextNode(ctxt) ((ctxt)->context->node) XMLPUBFUN int XMLCALL xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt); XMLPUBFUN double XMLCALL xmlXPathPopNumber (xmlXPathParserContextPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlXPathPopString (xmlXPathParserContextPtr ctxt); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt); XMLPUBFUN void * XMLCALL xmlXPathPopExternal (xmlXPathParserContextPtr ctxt); /** * xmlXPathReturnBoolean: * @ctxt: an XPath parser context * @val: a boolean * * Pushes the boolean @val on the context stack. */ #define xmlXPathReturnBoolean(ctxt, val) \ valuePush((ctxt), xmlXPathNewBoolean(val)) /** * xmlXPathReturnTrue: * @ctxt: an XPath parser context * * Pushes true on the context stack. */ #define xmlXPathReturnTrue(ctxt) xmlXPathReturnBoolean((ctxt), 1) /** * xmlXPathReturnFalse: * @ctxt: an XPath parser context * * Pushes false on the context stack. */ #define xmlXPathReturnFalse(ctxt) xmlXPathReturnBoolean((ctxt), 0) /** * xmlXPathReturnNumber: * @ctxt: an XPath parser context * @val: a double * * Pushes the double @val on the context stack. */ #define xmlXPathReturnNumber(ctxt, val) \ valuePush((ctxt), xmlXPathNewFloat(val)) /** * xmlXPathReturnString: * @ctxt: an XPath parser context * @str: a string * * Pushes the string @str on the context stack. */ #define xmlXPathReturnString(ctxt, str) \ valuePush((ctxt), xmlXPathWrapString(str)) /** * xmlXPathReturnEmptyString: * @ctxt: an XPath parser context * * Pushes an empty string on the stack. */ #define xmlXPathReturnEmptyString(ctxt) \ valuePush((ctxt), xmlXPathNewCString("")) /** * xmlXPathReturnNodeSet: * @ctxt: an XPath parser context * @ns: a node-set * * Pushes the node-set @ns on the context stack. */ #define xmlXPathReturnNodeSet(ctxt, ns) \ valuePush((ctxt), xmlXPathWrapNodeSet(ns)) /** * xmlXPathReturnEmptyNodeSet: * @ctxt: an XPath parser context * * Pushes an empty node-set on the context stack. */ #define xmlXPathReturnEmptyNodeSet(ctxt) \ valuePush((ctxt), xmlXPathNewNodeSet(NULL)) /** * xmlXPathReturnExternal: * @ctxt: an XPath parser context * @val: user data * * Pushes user data on the context stack. */ #define xmlXPathReturnExternal(ctxt, val) \ valuePush((ctxt), xmlXPathWrapExternal(val)) /** * xmlXPathStackIsNodeSet: * @ctxt: an XPath parser context * * Check if the current value on the XPath stack is a node set or * an XSLT value tree. * * Returns true if the current object on the stack is a node-set. */ #define xmlXPathStackIsNodeSet(ctxt) \ (((ctxt)->value != NULL) \ && (((ctxt)->value->type == XPATH_NODESET) \ || ((ctxt)->value->type == XPATH_XSLT_TREE))) /** * xmlXPathStackIsExternal: * @ctxt: an XPath parser context * * Checks if the current value on the XPath stack is an external * object. * * Returns true if the current object on the stack is an external * object. */ #define xmlXPathStackIsExternal(ctxt) \ ((ctxt->value != NULL) && (ctxt->value->type == XPATH_USERS)) /** * xmlXPathEmptyNodeSet: * @ns: a node-set * * Empties a node-set. */ #define xmlXPathEmptyNodeSet(ns) \ { while ((ns)->nodeNr > 0) (ns)->nodeTab[--(ns)->nodeNr] = NULL; } /** * CHECK_ERROR: * * Macro to return from the function if an XPath error was detected. */ #define CHECK_ERROR \ if (ctxt->error != XPATH_EXPRESSION_OK) return /** * CHECK_ERROR0: * * Macro to return 0 from the function if an XPath error was detected. */ #define CHECK_ERROR0 \ if (ctxt->error != XPATH_EXPRESSION_OK) return(0) /** * XP_ERROR: * @X: the error code * * Macro to raise an XPath error and return. */ #define XP_ERROR(X) \ { xmlXPathErr(ctxt, X); return; } /** * XP_ERROR0: * @X: the error code * * Macro to raise an XPath error and return 0. */ #define XP_ERROR0(X) \ { xmlXPathErr(ctxt, X); return(0); } /** * CHECK_TYPE: * @typeval: the XPath type * * Macro to check that the value on top of the XPath stack is of a given * type. */ #define CHECK_TYPE(typeval) \ if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \ XP_ERROR(XPATH_INVALID_TYPE) /** * CHECK_TYPE0: * @typeval: the XPath type * * Macro to check that the value on top of the XPath stack is of a given * type. Return(0) in case of failure */ #define CHECK_TYPE0(typeval) \ if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \ XP_ERROR0(XPATH_INVALID_TYPE) /** * CHECK_ARITY: * @x: the number of expected args * * Macro to check that the number of args passed to an XPath function matches. */ #define CHECK_ARITY(x) \ if (ctxt == NULL) return; \ if (nargs != (x)) \ XP_ERROR(XPATH_INVALID_ARITY); \ if (ctxt->valueNr < ctxt->valueFrame + (x)) \ XP_ERROR(XPATH_STACK_ERROR); /** * CAST_TO_STRING: * * Macro to try to cast the value on the top of the XPath stack to a string. */ #define CAST_TO_STRING \ if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING)) \ xmlXPathStringFunction(ctxt, 1); /** * CAST_TO_NUMBER: * * Macro to try to cast the value on the top of the XPath stack to a number. */ #define CAST_TO_NUMBER \ if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER)) \ xmlXPathNumberFunction(ctxt, 1); /** * CAST_TO_BOOLEAN: * * Macro to try to cast the value on the top of the XPath stack to a boolean. */ #define CAST_TO_BOOLEAN \ if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \ xmlXPathBooleanFunction(ctxt, 1); /* * Variable Lookup forwarding. */ XMLPUBFUN void XMLCALL xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt, xmlXPathVariableLookupFunc f, void *data); /* * Function Lookup forwarding. */ XMLPUBFUN void XMLCALL xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt, xmlXPathFuncLookupFunc f, void *funcCtxt); /* * Error reporting. */ XMLPUBFUN void XMLCALL xmlXPatherror (xmlXPathParserContextPtr ctxt, const char *file, int line, int no); XMLPUBFUN void XMLCALL xmlXPathErr (xmlXPathParserContextPtr ctxt, int error); #ifdef LIBXML_DEBUG_ENABLED XMLPUBFUN void XMLCALL xmlXPathDebugDumpObject (FILE *output, xmlXPathObjectPtr cur, int depth); XMLPUBFUN void XMLCALL xmlXPathDebugDumpCompExpr(FILE *output, xmlXPathCompExprPtr comp, int depth); #endif /** * NodeSet handling. */ XMLPUBFUN int XMLCALL xmlXPathNodeSetContains (xmlNodeSetPtr cur, xmlNodePtr val); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathDifference (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathIntersection (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathDistinctSorted (xmlNodeSetPtr nodes); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathDistinct (xmlNodeSetPtr nodes); XMLPUBFUN int XMLCALL xmlXPathHasSameNodes (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes, xmlNodePtr node); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathLeadingSorted (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathNodeLeading (xmlNodeSetPtr nodes, xmlNodePtr node); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathLeading (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes, xmlNodePtr node); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathTrailingSorted (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathNodeTrailing (xmlNodeSetPtr nodes, xmlNodePtr node); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathTrailing (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2); /** * Extending a context. */ XMLPUBFUN int XMLCALL xmlXPathRegisterNs (xmlXPathContextPtr ctxt, const xmlChar *prefix, const xmlChar *ns_uri); XMLPUBFUN const xmlChar * XMLCALL xmlXPathNsLookup (xmlXPathContextPtr ctxt, const xmlChar *prefix); XMLPUBFUN void XMLCALL xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt); XMLPUBFUN int XMLCALL xmlXPathRegisterFunc (xmlXPathContextPtr ctxt, const xmlChar *name, xmlXPathFunction f); XMLPUBFUN int XMLCALL xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri, xmlXPathFunction f); XMLPUBFUN int XMLCALL xmlXPathRegisterVariable (xmlXPathContextPtr ctxt, const xmlChar *name, xmlXPathObjectPtr value); XMLPUBFUN int XMLCALL xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri, xmlXPathObjectPtr value); XMLPUBFUN xmlXPathFunction XMLCALL xmlXPathFunctionLookup (xmlXPathContextPtr ctxt, const xmlChar *name); XMLPUBFUN xmlXPathFunction XMLCALL xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri); XMLPUBFUN void XMLCALL xmlXPathRegisteredFuncsCleanup (xmlXPathContextPtr ctxt); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathVariableLookup (xmlXPathContextPtr ctxt, const xmlChar *name); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt, const xmlChar *name, const xmlChar *ns_uri); XMLPUBFUN void XMLCALL xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt); /** * Utilities to extend XPath. */ XMLPUBFUN xmlXPathParserContextPtr XMLCALL xmlXPathNewParserContext (const xmlChar *str, xmlXPathContextPtr ctxt); XMLPUBFUN void XMLCALL xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt); /* TODO: remap to xmlXPathValuePop and Push. */ XMLPUBFUN xmlXPathObjectPtr XMLCALL valuePop (xmlXPathParserContextPtr ctxt); XMLPUBFUN int XMLCALL valuePush (xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewString (const xmlChar *val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewCString (const char *val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathWrapString (xmlChar *val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathWrapCString (char * val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewFloat (double val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewBoolean (int val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewNodeSet (xmlNodePtr val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewValueTree (xmlNodePtr val); XMLPUBFUN int XMLCALL xmlXPathNodeSetAdd (xmlNodeSetPtr cur, xmlNodePtr val); XMLPUBFUN int XMLCALL xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur, xmlNodePtr val); XMLPUBFUN int XMLCALL xmlXPathNodeSetAddNs (xmlNodeSetPtr cur, xmlNodePtr node, xmlNsPtr ns); XMLPUBFUN void XMLCALL xmlXPathNodeSetSort (xmlNodeSetPtr set); XMLPUBFUN void XMLCALL xmlXPathRoot (xmlXPathParserContextPtr ctxt); XMLPUBFUN void XMLCALL xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlXPathParseName (xmlXPathParserContextPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlXPathParseNCName (xmlXPathParserContextPtr ctxt); /* * Existing functions. */ XMLPUBFUN double XMLCALL xmlXPathStringEvalNumber (const xmlChar *str); XMLPUBFUN int XMLCALL xmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr res); XMLPUBFUN void XMLCALL xmlXPathRegisterAllFunctions (xmlXPathContextPtr ctxt); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathNodeSetMerge (xmlNodeSetPtr val1, xmlNodeSetPtr val2); XMLPUBFUN void XMLCALL xmlXPathNodeSetDel (xmlNodeSetPtr cur, xmlNodePtr val); XMLPUBFUN void XMLCALL xmlXPathNodeSetRemove (xmlNodeSetPtr cur, int val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewNodeSetList (xmlNodeSetPtr val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathWrapNodeSet (xmlNodeSetPtr val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathWrapExternal (void *val); XMLPUBFUN int XMLCALL xmlXPathEqualValues(xmlXPathParserContextPtr ctxt); XMLPUBFUN int XMLCALL xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt); XMLPUBFUN int XMLCALL xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict); XMLPUBFUN void XMLCALL xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt); XMLPUBFUN void XMLCALL xmlXPathAddValues(xmlXPathParserContextPtr ctxt); XMLPUBFUN void XMLCALL xmlXPathSubValues(xmlXPathParserContextPtr ctxt); XMLPUBFUN void XMLCALL xmlXPathMultValues(xmlXPathParserContextPtr ctxt); XMLPUBFUN void XMLCALL xmlXPathDivValues(xmlXPathParserContextPtr ctxt); XMLPUBFUN void XMLCALL xmlXPathModValues(xmlXPathParserContextPtr ctxt); XMLPUBFUN int XMLCALL xmlXPathIsNodeType(const xmlChar *name); /* * Some of the axis navigation routines. */ XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextChild(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextParent(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur); /* * The official core of XPath functions. */ XMLPUBFUN void XMLCALL xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN void XMLCALL xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs); /** * Really internal functions */ XMLPUBFUN void XMLCALL xmlXPathNodeSetFreeNs(xmlNsPtr ns); #ifdef __cplusplus } #endif #endif /* LIBXML_XPATH_ENABLED */ #endif /* ! __XML_XPATH_INTERNALS_H__ */ /* * Summary: the core parser module * Description: Interfaces, constants and types related to the XML parser * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_PARSER_H__ #define __XML_PARSER_H__ #include <stdarg.h> #include <libxml/xmlversion.h> #include <libxml/tree.h> #include <libxml/dict.h> #include <libxml/hash.h> #include <libxml/valid.h> #include <libxml/entities.h> #include <libxml/xmlerror.h> #include <libxml/xmlstring.h> #ifdef __cplusplus extern "C" { #endif /** * XML_DEFAULT_VERSION: * * The default version of XML used: 1.0 */ #define XML_DEFAULT_VERSION "1.0" /** * xmlParserInput: * * An xmlParserInput is an input flow for the XML processor. * Each entity parsed is associated an xmlParserInput (except the * few predefined ones). This is the case both for internal entities * - in which case the flow is already completely in memory - or * external entities - in which case we use the buf structure for * progressive reading and I18N conversions to the internal UTF-8 format. */ /** * xmlParserInputDeallocate: * @str: the string to deallocate * * Callback for freeing some parser input allocations. */ typedef void (* xmlParserInputDeallocate)(xmlChar *str); struct _xmlParserInput { /* Input buffer */ xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */ const char *filename; /* The file analyzed, if any */ const char *directory; /* the directory/base of the file */ const xmlChar *base; /* Base of the array to parse */ const xmlChar *cur; /* Current char being parsed */ const xmlChar *end; /* end of the array to parse */ int length; /* length if known */ int line; /* Current line */ int col; /* Current column */ unsigned long consumed; /* How many xmlChars already consumed */ xmlParserInputDeallocate free; /* function to deallocate the base */ const xmlChar *encoding; /* the encoding string for entity */ const xmlChar *version; /* the version string for entity */ int standalone; /* Was that entity marked standalone */ int id; /* an unique identifier for the entity */ unsigned long parentConsumed; /* consumed bytes from parents */ xmlEntityPtr entity; /* entity, if any */ }; /** * xmlParserNodeInfo: * * The parser can be asked to collect Node information, i.e. at what * place in the file they were detected. * NOTE: This is off by default and not very well tested. */ typedef struct _xmlParserNodeInfo xmlParserNodeInfo; typedef xmlParserNodeInfo *xmlParserNodeInfoPtr; struct _xmlParserNodeInfo { const struct _xmlNode* node; /* Position & line # that text that created the node begins & ends on */ unsigned long begin_pos; unsigned long begin_line; unsigned long end_pos; unsigned long end_line; }; typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq; typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr; struct _xmlParserNodeInfoSeq { unsigned long maximum; unsigned long length; xmlParserNodeInfo* buffer; }; /** * xmlParserInputState: * * The parser is now working also as a state based parser. * The recursive one use the state info for entities processing. */ typedef enum { XML_PARSER_EOF = -1, /* nothing is to be parsed */ XML_PARSER_START = 0, /* nothing has been parsed */ XML_PARSER_MISC, /* Misc* before int subset */ XML_PARSER_PI, /* Within a processing instruction */ XML_PARSER_DTD, /* within some DTD content */ XML_PARSER_PROLOG, /* Misc* after internal subset */ XML_PARSER_COMMENT, /* within a comment */ XML_PARSER_START_TAG, /* within a start tag */ XML_PARSER_CONTENT, /* within the content */ XML_PARSER_CDATA_SECTION, /* within a CDATA section */ XML_PARSER_END_TAG, /* within a closing tag */ XML_PARSER_ENTITY_DECL, /* within an entity declaration */ XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */ XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */ XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */ XML_PARSER_EPILOG, /* the Misc* after the last end tag */ XML_PARSER_IGNORE, /* within an IGNORED section */ XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */ } xmlParserInputState; /** * XML_DETECT_IDS: * * Bit in the loadsubset context field to tell to do ID/REFs lookups. * Use it to initialize xmlLoadExtDtdDefaultValue. */ #define XML_DETECT_IDS 2 /** * XML_COMPLETE_ATTRS: * * Bit in the loadsubset context field to tell to do complete the * elements attributes lists with the ones defaulted from the DTDs. * Use it to initialize xmlLoadExtDtdDefaultValue. */ #define XML_COMPLETE_ATTRS 4 /** * XML_SKIP_IDS: * * Bit in the loadsubset context field to tell to not do ID/REFs registration. * Used to initialize xmlLoadExtDtdDefaultValue in some special cases. */ #define XML_SKIP_IDS 8 /** * xmlParserMode: * * A parser can operate in various modes */ typedef enum { XML_PARSE_UNKNOWN = 0, XML_PARSE_DOM = 1, XML_PARSE_SAX = 2, XML_PARSE_PUSH_DOM = 3, XML_PARSE_PUSH_SAX = 4, XML_PARSE_READER = 5 } xmlParserMode; typedef struct _xmlStartTag xmlStartTag; /** * xmlParserCtxt: * * The parser context. * NOTE This doesn't completely define the parser state, the (current ?) * design of the parser uses recursive function calls since this allow * and easy mapping from the production rules of the specification * to the actual code. The drawback is that the actual function call * also reflect the parser state. However most of the parsing routines * takes as the only argument the parser context pointer, so migrating * to a state based parser for progressive parsing shouldn't be too hard. */ struct _xmlParserCtxt { struct _xmlSAXHandler *sax; /* The SAX handler */ void *userData; /* For SAX interface only, used by DOM build */ xmlDocPtr myDoc; /* the document being built */ int wellFormed; /* is the document well formed */ int replaceEntities; /* shall we replace entities ? */ const xmlChar *version; /* the XML version string */ const xmlChar *encoding; /* the declared encoding, if any */ int standalone; /* standalone document */ int html; /* an HTML(1)/Docbook(2) document * 3 is HTML after <head> * 10 is HTML after <body> */ /* Input stream stack */ xmlParserInputPtr input; /* Current input stream */ int inputNr; /* Number of current input streams */ int inputMax; /* Max number of input streams */ xmlParserInputPtr *inputTab; /* stack of inputs */ /* Node analysis stack only used for DOM building */ xmlNodePtr node; /* Current parsed Node */ int nodeNr; /* Depth of the parsing stack */ int nodeMax; /* Max depth of the parsing stack */ xmlNodePtr *nodeTab; /* array of nodes */ int record_info; /* Whether node info should be kept */ xmlParserNodeInfoSeq node_seq; /* info about each node parsed */ int errNo; /* error code */ int hasExternalSubset; /* reference and external subset */ int hasPErefs; /* the internal subset has PE refs */ int external; /* are we parsing an external entity */ int valid; /* is the document valid */ int validate; /* shall we try to validate ? */ xmlValidCtxt vctxt; /* The validity context */ xmlParserInputState instate; /* current type of input */ int token; /* next char look-ahead */ char *directory; /* the data directory */ /* Node name stack */ const xmlChar *name; /* Current parsed Node */ int nameNr; /* Depth of the parsing stack */ int nameMax; /* Max depth of the parsing stack */ const xmlChar * *nameTab; /* array of nodes */ long nbChars; /* unused */ long checkIndex; /* used by progressive parsing lookup */ int keepBlanks; /* ugly but ... */ int disableSAX; /* SAX callbacks are disabled */ int inSubset; /* Parsing is in int 1/ext 2 subset */ const xmlChar * intSubName; /* name of subset */ xmlChar * extSubURI; /* URI of external subset */ xmlChar * extSubSystem; /* SYSTEM ID of external subset */ /* xml:space values */ int * space; /* Should the parser preserve spaces */ int spaceNr; /* Depth of the parsing stack */ int spaceMax; /* Max depth of the parsing stack */ int * spaceTab; /* array of space infos */ int depth; /* to prevent entity substitution loops */ xmlParserInputPtr entity; /* used to check entities boundaries */ int charset; /* encoding of the in-memory content actually an xmlCharEncoding */ int nodelen; /* Those two fields are there to */ int nodemem; /* Speed up large node parsing */ int pedantic; /* signal pedantic warnings */ void *_private; /* For user data, libxml won't touch it */ int loadsubset; /* should the external subset be loaded */ int linenumbers; /* set line number in element content */ void *catalogs; /* document's own catalog */ int recovery; /* run in recovery mode */ int progressive; /* is this a progressive parsing */ xmlDictPtr dict; /* dictionary for the parser */ const xmlChar * *atts; /* array for the attributes callbacks */ int maxatts; /* the size of the array */ int docdict; /* use strings from dict to build tree */ /* * pre-interned strings */ const xmlChar *str_xml; const xmlChar *str_xmlns; const xmlChar *str_xml_ns; /* * Everything below is used only by the new SAX mode */ int sax2; /* operating in the new SAX mode */ int nsNr; /* the number of inherited namespaces */ int nsMax; /* the size of the arrays */ const xmlChar * *nsTab; /* the array of prefix/namespace name */ int *attallocs; /* which attribute were allocated */ xmlStartTag *pushTab; /* array of data for push */ xmlHashTablePtr attsDefault; /* defaulted attributes if any */ xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */ int nsWellFormed; /* is the document XML Namespace okay */ int options; /* Extra options */ /* * Those fields are needed only for streaming parsing so far */ int dictNames; /* Use dictionary names for the tree */ int freeElemsNr; /* number of freed element nodes */ xmlNodePtr freeElems; /* List of freed element nodes */ int freeAttrsNr; /* number of freed attributes nodes */ xmlAttrPtr freeAttrs; /* List of freed attributes nodes */ /* * the complete error information for the last error. */ xmlError lastError; xmlParserMode parseMode; /* the parser mode */ unsigned long nbentities; /* number of entities references */ unsigned long sizeentities; /* size of parsed entities */ /* for use by HTML non-recursive parser */ xmlParserNodeInfo *nodeInfo; /* Current NodeInfo */ int nodeInfoNr; /* Depth of the parsing stack */ int nodeInfoMax; /* Max depth of the parsing stack */ xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */ int input_id; /* we need to label inputs */ unsigned long sizeentcopy; /* volume of entity copy */ }; /** * xmlSAXLocator: * * A SAX Locator. */ struct _xmlSAXLocator { const xmlChar *(*getPublicId)(void *ctx); const xmlChar *(*getSystemId)(void *ctx); int (*getLineNumber)(void *ctx); int (*getColumnNumber)(void *ctx); }; /** * xmlSAXHandler: * * A SAX handler is bunch of callbacks called by the parser when processing * of the input generate data or structure information. */ /** * resolveEntitySAXFunc: * @ctx: the user data (XML parser context) * @publicId: The public ID of the entity * @systemId: The system ID of the entity * * Callback: * The entity loader, to control the loading of external entities, * the application can either: * - override this resolveEntity() callback in the SAX block * - or better use the xmlSetExternalEntityLoader() function to * set up it's own entity resolution routine * * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. */ typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx, const xmlChar *publicId, const xmlChar *systemId); /** * internalSubsetSAXFunc: * @ctx: the user data (XML parser context) * @name: the root element name * @ExternalID: the external ID * @SystemID: the SYSTEM ID (e.g. filename or URL) * * Callback on internal subset declaration. */ typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); /** * externalSubsetSAXFunc: * @ctx: the user data (XML parser context) * @name: the root element name * @ExternalID: the external ID * @SystemID: the SYSTEM ID (e.g. filename or URL) * * Callback on external subset declaration. */ typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); /** * getEntitySAXFunc: * @ctx: the user data (XML parser context) * @name: The entity name * * Get an entity by name. * * Returns the xmlEntityPtr if found. */ typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx, const xmlChar *name); /** * getParameterEntitySAXFunc: * @ctx: the user data (XML parser context) * @name: The entity name * * Get a parameter entity by name. * * Returns the xmlEntityPtr if found. */ typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx, const xmlChar *name); /** * entityDeclSAXFunc: * @ctx: the user data (XML parser context) * @name: the entity name * @type: the entity type * @publicId: The public ID of the entity * @systemId: The system ID of the entity * @content: the entity value (without processing). * * An entity definition has been parsed. */ typedef void (*entityDeclSAXFunc) (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content); /** * notationDeclSAXFunc: * @ctx: the user data (XML parser context) * @name: The name of the notation * @publicId: The public ID of the entity * @systemId: The system ID of the entity * * What to do when a notation declaration has been parsed. */ typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId); /** * attributeDeclSAXFunc: * @ctx: the user data (XML parser context) * @elem: the name of the element * @fullname: the attribute name * @type: the attribute type * @def: the type of default value * @defaultValue: the attribute default value * @tree: the tree of enumerated value set * * An attribute definition has been parsed. */ typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree); /** * elementDeclSAXFunc: * @ctx: the user data (XML parser context) * @name: the element name * @type: the element type * @content: the element value tree * * An element definition has been parsed. */ typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name, int type, xmlElementContentPtr content); /** * unparsedEntityDeclSAXFunc: * @ctx: the user data (XML parser context) * @name: The name of the entity * @publicId: The public ID of the entity * @systemId: The system ID of the entity * @notationName: the name of the notation * * What to do when an unparsed entity declaration is parsed. */ typedef void (*unparsedEntityDeclSAXFunc)(void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName); /** * setDocumentLocatorSAXFunc: * @ctx: the user data (XML parser context) * @loc: A SAX Locator * * Receive the document locator at startup, actually xmlDefaultSAXLocator. * Everything is available on the context, so this is useless in our case. */ typedef void (*setDocumentLocatorSAXFunc) (void *ctx, xmlSAXLocatorPtr loc); /** * startDocumentSAXFunc: * @ctx: the user data (XML parser context) * * Called when the document start being processed. */ typedef void (*startDocumentSAXFunc) (void *ctx); /** * endDocumentSAXFunc: * @ctx: the user data (XML parser context) * * Called when the document end has been detected. */ typedef void (*endDocumentSAXFunc) (void *ctx); /** * startElementSAXFunc: * @ctx: the user data (XML parser context) * @name: The element name, including namespace prefix * @atts: An array of name/value attributes pairs, NULL terminated * * Called when an opening tag has been processed. */ typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name, const xmlChar **atts); /** * endElementSAXFunc: * @ctx: the user data (XML parser context) * @name: The element name * * Called when the end of an element has been detected. */ typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name); /** * attributeSAXFunc: * @ctx: the user data (XML parser context) * @name: The attribute name, including namespace prefix * @value: The attribute value * * Handle an attribute that has been read by the parser. * The default handling is to convert the attribute into an * DOM subtree and past it in a new xmlAttr element added to * the element. */ typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name, const xmlChar *value); /** * referenceSAXFunc: * @ctx: the user data (XML parser context) * @name: The entity name * * Called when an entity reference is detected. */ typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name); /** * charactersSAXFunc: * @ctx: the user data (XML parser context) * @ch: a xmlChar string * @len: the number of xmlChar * * Receiving some chars from the parser. */ typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch, int len); /** * ignorableWhitespaceSAXFunc: * @ctx: the user data (XML parser context) * @ch: a xmlChar string * @len: the number of xmlChar * * Receiving some ignorable whitespaces from the parser. * UNUSED: by default the DOM building will use characters. */ typedef void (*ignorableWhitespaceSAXFunc) (void *ctx, const xmlChar *ch, int len); /** * processingInstructionSAXFunc: * @ctx: the user data (XML parser context) * @target: the target name * @data: the PI data's * * A processing instruction has been parsed. */ typedef void (*processingInstructionSAXFunc) (void *ctx, const xmlChar *target, const xmlChar *data); /** * commentSAXFunc: * @ctx: the user data (XML parser context) * @value: the comment content * * A comment has been parsed. */ typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value); /** * cdataBlockSAXFunc: * @ctx: the user data (XML parser context) * @value: The pcdata content * @len: the block length * * Called when a pcdata block has been parsed. */ typedef void (*cdataBlockSAXFunc) ( void *ctx, const xmlChar *value, int len); /** * warningSAXFunc: * @ctx: an XML parser context * @msg: the message to display/transmit * @...: extra parameters for the message display * * Display and format a warning messages, callback. */ typedef void (XMLCDECL *warningSAXFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); /** * errorSAXFunc: * @ctx: an XML parser context * @msg: the message to display/transmit * @...: extra parameters for the message display * * Display and format an error messages, callback. */ typedef void (XMLCDECL *errorSAXFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); /** * fatalErrorSAXFunc: * @ctx: an XML parser context * @msg: the message to display/transmit * @...: extra parameters for the message display * * Display and format fatal error messages, callback. * Note: so far fatalError() SAX callbacks are not used, error() * get all the callbacks for errors. */ typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); /** * isStandaloneSAXFunc: * @ctx: the user data (XML parser context) * * Is this document tagged standalone? * * Returns 1 if true */ typedef int (*isStandaloneSAXFunc) (void *ctx); /** * hasInternalSubsetSAXFunc: * @ctx: the user data (XML parser context) * * Does this document has an internal subset. * * Returns 1 if true */ typedef int (*hasInternalSubsetSAXFunc) (void *ctx); /** * hasExternalSubsetSAXFunc: * @ctx: the user data (XML parser context) * * Does this document has an external subset? * * Returns 1 if true */ typedef int (*hasExternalSubsetSAXFunc) (void *ctx); /************************************************************************ * * * The SAX version 2 API extensions * * * ************************************************************************/ /** * XML_SAX2_MAGIC: * * Special constant found in SAX2 blocks initialized fields */ #define XML_SAX2_MAGIC 0xDEEDBEAF /** * startElementNsSAX2Func: * @ctx: the user data (XML parser context) * @localname: the local name of the element * @prefix: the element namespace prefix if available * @URI: the element namespace name if available * @nb_namespaces: number of namespace definitions on that node * @namespaces: pointer to the array of prefix/URI pairs namespace definitions * @nb_attributes: the number of attributes on that node * @nb_defaulted: the number of defaulted attributes. The defaulted * ones are at the end of the array * @attributes: pointer to the array of (localname/prefix/URI/value/end) * attribute values. * * SAX2 callback when an element start has been detected by the parser. * It provides the namespace information for the element, as well as * the new namespace declarations on the element. */ typedef void (*startElementNsSAX2Func) (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes, int nb_defaulted, const xmlChar **attributes); /** * endElementNsSAX2Func: * @ctx: the user data (XML parser context) * @localname: the local name of the element * @prefix: the element namespace prefix if available * @URI: the element namespace name if available * * SAX2 callback when an element end has been detected by the parser. * It provides the namespace information for the element. */ typedef void (*endElementNsSAX2Func) (void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI); struct _xmlSAXHandler { internalSubsetSAXFunc internalSubset; isStandaloneSAXFunc isStandalone; hasInternalSubsetSAXFunc hasInternalSubset; hasExternalSubsetSAXFunc hasExternalSubset; resolveEntitySAXFunc resolveEntity; getEntitySAXFunc getEntity; entityDeclSAXFunc entityDecl; notationDeclSAXFunc notationDecl; attributeDeclSAXFunc attributeDecl; elementDeclSAXFunc elementDecl; unparsedEntityDeclSAXFunc unparsedEntityDecl; setDocumentLocatorSAXFunc setDocumentLocator; startDocumentSAXFunc startDocument; endDocumentSAXFunc endDocument; startElementSAXFunc startElement; endElementSAXFunc endElement; referenceSAXFunc reference; charactersSAXFunc characters; ignorableWhitespaceSAXFunc ignorableWhitespace; processingInstructionSAXFunc processingInstruction; commentSAXFunc comment; warningSAXFunc warning; errorSAXFunc error; fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ getParameterEntitySAXFunc getParameterEntity; cdataBlockSAXFunc cdataBlock; externalSubsetSAXFunc externalSubset; unsigned int initialized; /* The following fields are extensions available only on version 2 */ void *_private; startElementNsSAX2Func startElementNs; endElementNsSAX2Func endElementNs; xmlStructuredErrorFunc serror; }; /* * SAX Version 1 */ typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1; typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr; struct _xmlSAXHandlerV1 { internalSubsetSAXFunc internalSubset; isStandaloneSAXFunc isStandalone; hasInternalSubsetSAXFunc hasInternalSubset; hasExternalSubsetSAXFunc hasExternalSubset; resolveEntitySAXFunc resolveEntity; getEntitySAXFunc getEntity; entityDeclSAXFunc entityDecl; notationDeclSAXFunc notationDecl; attributeDeclSAXFunc attributeDecl; elementDeclSAXFunc elementDecl; unparsedEntityDeclSAXFunc unparsedEntityDecl; setDocumentLocatorSAXFunc setDocumentLocator; startDocumentSAXFunc startDocument; endDocumentSAXFunc endDocument; startElementSAXFunc startElement; endElementSAXFunc endElement; referenceSAXFunc reference; charactersSAXFunc characters; ignorableWhitespaceSAXFunc ignorableWhitespace; processingInstructionSAXFunc processingInstruction; commentSAXFunc comment; warningSAXFunc warning; errorSAXFunc error; fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ getParameterEntitySAXFunc getParameterEntity; cdataBlockSAXFunc cdataBlock; externalSubsetSAXFunc externalSubset; unsigned int initialized; }; /** * xmlExternalEntityLoader: * @URL: The System ID of the resource requested * @ID: The Public ID of the resource requested * @context: the XML parser context * * External entity loaders types. * * Returns the entity input parser. */ typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL, const char *ID, xmlParserCtxtPtr context); #ifdef __cplusplus } #endif #include <libxml/encoding.h> #include <libxml/xmlIO.h> #include <libxml/globals.h> #ifdef __cplusplus extern "C" { #endif /* * Init/Cleanup */ XMLPUBFUN void XMLCALL xmlInitParser (void); XMLPUBFUN void XMLCALL xmlCleanupParser (void); /* * Input functions */ XMLPUBFUN int XMLCALL xmlParserInputRead (xmlParserInputPtr in, int len); XMLPUBFUN int XMLCALL xmlParserInputGrow (xmlParserInputPtr in, int len); /* * Basic parsing Interfaces */ #ifdef LIBXML_SAX1_ENABLED XMLPUBFUN xmlDocPtr XMLCALL xmlParseDoc (const xmlChar *cur); XMLPUBFUN xmlDocPtr XMLCALL xmlParseFile (const char *filename); XMLPUBFUN xmlDocPtr XMLCALL xmlParseMemory (const char *buffer, int size); #endif /* LIBXML_SAX1_ENABLED */ XMLPUBFUN int XMLCALL xmlSubstituteEntitiesDefault(int val); XMLPUBFUN int XMLCALL xmlKeepBlanksDefault (int val); XMLPUBFUN void XMLCALL xmlStopParser (xmlParserCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlPedanticParserDefault(int val); XMLPUBFUN int XMLCALL xmlLineNumbersDefault (int val); #ifdef LIBXML_SAX1_ENABLED /* * Recovery mode */ XMLPUBFUN xmlDocPtr XMLCALL xmlRecoverDoc (const xmlChar *cur); XMLPUBFUN xmlDocPtr XMLCALL xmlRecoverMemory (const char *buffer, int size); XMLPUBFUN xmlDocPtr XMLCALL xmlRecoverFile (const char *filename); #endif /* LIBXML_SAX1_ENABLED */ /* * Less common routines and SAX interfaces */ XMLPUBFUN int XMLCALL xmlParseDocument (xmlParserCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt); #ifdef LIBXML_SAX1_ENABLED XMLPUBFUN int XMLCALL xmlSAXUserParseFile (xmlSAXHandlerPtr sax, void *user_data, const char *filename); XMLPUBFUN int XMLCALL xmlSAXUserParseMemory (xmlSAXHandlerPtr sax, void *user_data, const char *buffer, int size); XMLPUBFUN xmlDocPtr XMLCALL xmlSAXParseDoc (xmlSAXHandlerPtr sax, const xmlChar *cur, int recovery); XMLPUBFUN xmlDocPtr XMLCALL xmlSAXParseMemory (xmlSAXHandlerPtr sax, const char *buffer, int size, int recovery); XMLPUBFUN xmlDocPtr XMLCALL xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax, const char *buffer, int size, int recovery, void *data); XMLPUBFUN xmlDocPtr XMLCALL xmlSAXParseFile (xmlSAXHandlerPtr sax, const char *filename, int recovery); XMLPUBFUN xmlDocPtr XMLCALL xmlSAXParseFileWithData (xmlSAXHandlerPtr sax, const char *filename, int recovery, void *data); XMLPUBFUN xmlDocPtr XMLCALL xmlSAXParseEntity (xmlSAXHandlerPtr sax, const char *filename); XMLPUBFUN xmlDocPtr XMLCALL xmlParseEntity (const char *filename); #endif /* LIBXML_SAX1_ENABLED */ #ifdef LIBXML_VALID_ENABLED XMLPUBFUN xmlDtdPtr XMLCALL xmlSAXParseDTD (xmlSAXHandlerPtr sax, const xmlChar *ExternalID, const xmlChar *SystemID); XMLPUBFUN xmlDtdPtr XMLCALL xmlParseDTD (const xmlChar *ExternalID, const xmlChar *SystemID); XMLPUBFUN xmlDtdPtr XMLCALL xmlIOParseDTD (xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input, xmlCharEncoding enc); #endif /* LIBXML_VALID_ENABLE */ #ifdef LIBXML_SAX1_ENABLED XMLPUBFUN int XMLCALL xmlParseBalancedChunkMemory(xmlDocPtr doc, xmlSAXHandlerPtr sax, void *user_data, int depth, const xmlChar *string, xmlNodePtr *lst); #endif /* LIBXML_SAX1_ENABLED */ XMLPUBFUN xmlParserErrors XMLCALL xmlParseInNodeContext (xmlNodePtr node, const char *data, int datalen, int options, xmlNodePtr *lst); #ifdef LIBXML_SAX1_ENABLED XMLPUBFUN int XMLCALL xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax, void *user_data, int depth, const xmlChar *string, xmlNodePtr *lst, int recover); XMLPUBFUN int XMLCALL xmlParseExternalEntity (xmlDocPtr doc, xmlSAXHandlerPtr sax, void *user_data, int depth, const xmlChar *URL, const xmlChar *ID, xmlNodePtr *lst); #endif /* LIBXML_SAX1_ENABLED */ XMLPUBFUN int XMLCALL xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL, const xmlChar *ID, xmlNodePtr *lst); /* * Parser contexts handling. */ XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt (void); XMLPUBFUN int XMLCALL xmlInitParserCtxt (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlClearParserCtxt (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); #ifdef LIBXML_SAX1_ENABLED XMLPUBFUN void XMLCALL xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt, const xmlChar* buffer, const char *filename); #endif /* LIBXML_SAX1_ENABLED */ XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateDocParserCtxt (const xmlChar *cur); #ifdef LIBXML_LEGACY_ENABLED /* * Reading/setting optional parsing features. */ XMLPUBFUN int XMLCALL xmlGetFeaturesList (int *len, const char **result); XMLPUBFUN int XMLCALL xmlGetFeature (xmlParserCtxtPtr ctxt, const char *name, void *result); XMLPUBFUN int XMLCALL xmlSetFeature (xmlParserCtxtPtr ctxt, const char *name, void *value); #endif /* LIBXML_LEGACY_ENABLED */ #ifdef LIBXML_PUSH_ENABLED /* * Interfaces for the Push mode. */ XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data, const char *chunk, int size, const char *filename); XMLPUBFUN int XMLCALL xmlParseChunk (xmlParserCtxtPtr ctxt, const char *chunk, int size, int terminate); #endif /* LIBXML_PUSH_ENABLED */ /* * Special I/O mode. */ XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, void *user_data, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc); XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream (xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc); /* * Node infos. */ XMLPUBFUN const xmlParserNodeInfo* XMLCALL xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt, const xmlNodePtr node); XMLPUBFUN void XMLCALL xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); XMLPUBFUN void XMLCALL xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); XMLPUBFUN unsigned long XMLCALL xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq, const xmlNodePtr node); XMLPUBFUN void XMLCALL xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, const xmlParserNodeInfoPtr info); /* * External entities handling actually implemented in xmlIO. */ XMLPUBFUN void XMLCALL xmlSetExternalEntityLoader(xmlExternalEntityLoader f); XMLPUBFUN xmlExternalEntityLoader XMLCALL xmlGetExternalEntityLoader(void); XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity (const char *URL, const char *ID, xmlParserCtxtPtr ctxt); /* * Index lookup, actually implemented in the encoding module */ XMLPUBFUN long XMLCALL xmlByteConsumed (xmlParserCtxtPtr ctxt); /* * New set of simpler/more flexible APIs */ /** * xmlParserOption: * * This is the set of XML parser options that can be passed down * to the xmlReadDoc() and similar calls. */ typedef enum { XML_PARSE_RECOVER = 1<<0, /* recover on errors */ XML_PARSE_NOENT = 1<<1, /* substitute entities */ XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */ XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */ XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */ XML_PARSE_NOERROR = 1<<5, /* suppress error reports */ XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */ XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */ XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */ XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */ XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitution */ XML_PARSE_NONET = 1<<11,/* Forbid network access */ XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionary */ XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */ XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */ XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */ XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of the tree allowed afterwards (will possibly crash if you try to modify the tree) */ XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */ XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */ XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */ XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */ XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */ XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */ } xmlParserOption; XMLPUBFUN void XMLCALL xmlCtxtReset (xmlParserCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlCtxtResetPush (xmlParserCtxtPtr ctxt, const char *chunk, int size, const char *filename, const char *encoding); XMLPUBFUN int XMLCALL xmlCtxtUseOptions (xmlParserCtxtPtr ctxt, int options); XMLPUBFUN xmlDocPtr XMLCALL xmlReadDoc (const xmlChar *cur, const char *URL, const char *encoding, int options); XMLPUBFUN xmlDocPtr XMLCALL xmlReadFile (const char *URL, const char *encoding, int options); XMLPUBFUN xmlDocPtr XMLCALL xmlReadMemory (const char *buffer, int size, const char *URL, const char *encoding, int options); XMLPUBFUN xmlDocPtr XMLCALL xmlReadFd (int fd, const char *URL, const char *encoding, int options); XMLPUBFUN xmlDocPtr XMLCALL xmlReadIO (xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options); XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadDoc (xmlParserCtxtPtr ctxt, const xmlChar *cur, const char *URL, const char *encoding, int options); XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadFile (xmlParserCtxtPtr ctxt, const char *filename, const char *encoding, int options); XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadMemory (xmlParserCtxtPtr ctxt, const char *buffer, int size, const char *URL, const char *encoding, int options); XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadFd (xmlParserCtxtPtr ctxt, int fd, const char *URL, const char *encoding, int options); XMLPUBFUN xmlDocPtr XMLCALL xmlCtxtReadIO (xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options); /* * Library wide options */ /** * xmlFeature: * * Used to examine the existence of features that can be enabled * or disabled at compile-time. * They used to be called XML_FEATURE_xxx but this clashed with Expat */ typedef enum { XML_WITH_THREAD = 1, XML_WITH_TREE = 2, XML_WITH_OUTPUT = 3, XML_WITH_PUSH = 4, XML_WITH_READER = 5, XML_WITH_PATTERN = 6, XML_WITH_WRITER = 7, XML_WITH_SAX1 = 8, XML_WITH_FTP = 9, XML_WITH_HTTP = 10, XML_WITH_VALID = 11, XML_WITH_HTML = 12, XML_WITH_LEGACY = 13, XML_WITH_C14N = 14, XML_WITH_CATALOG = 15, XML_WITH_XPATH = 16, XML_WITH_XPTR = 17, XML_WITH_XINCLUDE = 18, XML_WITH_ICONV = 19, XML_WITH_ISO8859X = 20, XML_WITH_UNICODE = 21, XML_WITH_REGEXP = 22, XML_WITH_AUTOMATA = 23, XML_WITH_EXPR = 24, XML_WITH_SCHEMAS = 25, XML_WITH_SCHEMATRON = 26, XML_WITH_MODULES = 27, XML_WITH_DEBUG = 28, XML_WITH_DEBUG_MEM = 29, XML_WITH_DEBUG_RUN = 30, XML_WITH_ZLIB = 31, XML_WITH_ICU = 32, XML_WITH_LZMA = 33, XML_WITH_NONE = 99999 /* just to be sure of allocation size */ } xmlFeature; XMLPUBFUN int XMLCALL xmlHasFeature (xmlFeature feature); #ifdef __cplusplus } #endif #endif /* __XML_PARSER_H__ */ /* * Summary: interface for an HTML 4.0 non-verifying parser * Description: this module implements an HTML 4.0 non-verifying parser * with API compatible with the XML parser ones. It should * be able to parse "real world" HTML, even if severely * broken from a specification point of view. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __HTML_PARSER_H__ #define __HTML_PARSER_H__ #include <libxml/xmlversion.h> #include <libxml/parser.h> #ifdef LIBXML_HTML_ENABLED #ifdef __cplusplus extern "C" { #endif /* * Most of the back-end structures from XML and HTML are shared. */ typedef xmlParserCtxt htmlParserCtxt; typedef xmlParserCtxtPtr htmlParserCtxtPtr; typedef xmlParserNodeInfo htmlParserNodeInfo; typedef xmlSAXHandler htmlSAXHandler; typedef xmlSAXHandlerPtr htmlSAXHandlerPtr; typedef xmlParserInput htmlParserInput; typedef xmlParserInputPtr htmlParserInputPtr; typedef xmlDocPtr htmlDocPtr; typedef xmlNodePtr htmlNodePtr; /* * Internal description of an HTML element, representing HTML 4.01 * and XHTML 1.0 (which share the same structure). */ typedef struct _htmlElemDesc htmlElemDesc; typedef htmlElemDesc *htmlElemDescPtr; struct _htmlElemDesc { const char *name; /* The tag name */ char startTag; /* Whether the start tag can be implied */ char endTag; /* Whether the end tag can be implied */ char saveEndTag; /* Whether the end tag should be saved */ char empty; /* Is this an empty element ? */ char depr; /* Is this a deprecated element ? */ char dtd; /* 1: only in Loose DTD, 2: only Frameset one */ char isinline; /* is this a block 0 or inline 1 element */ const char *desc; /* the description */ /* NRK Jan.2003 * New fields encapsulating HTML structure * * Bugs: * This is a very limited representation. It fails to tell us when * an element *requires* subelements (we only have whether they're * allowed or not), and it doesn't tell us where CDATA and PCDATA * are allowed. Some element relationships are not fully represented: * these are flagged with the word MODIFIER */ const char** subelts; /* allowed sub-elements of this element */ const char* defaultsubelt; /* subelement for suggested auto-repair if necessary or NULL */ const char** attrs_opt; /* Optional Attributes */ const char** attrs_depr; /* Additional deprecated attributes */ const char** attrs_req; /* Required attributes */ }; /* * Internal description of an HTML entity. */ typedef struct _htmlEntityDesc htmlEntityDesc; typedef htmlEntityDesc *htmlEntityDescPtr; struct _htmlEntityDesc { unsigned int value; /* the UNICODE value for the character */ const char *name; /* The entity name */ const char *desc; /* the description */ }; /* * There is only few public functions. */ XMLPUBFUN const htmlElemDesc * XMLCALL htmlTagLookup (const xmlChar *tag); XMLPUBFUN const htmlEntityDesc * XMLCALL htmlEntityLookup(const xmlChar *name); XMLPUBFUN const htmlEntityDesc * XMLCALL htmlEntityValueLookup(unsigned int value); XMLPUBFUN int XMLCALL htmlIsAutoClosed(htmlDocPtr doc, htmlNodePtr elem); XMLPUBFUN int XMLCALL htmlAutoCloseTag(htmlDocPtr doc, const xmlChar *name, htmlNodePtr elem); XMLPUBFUN const htmlEntityDesc * XMLCALL htmlParseEntityRef(htmlParserCtxtPtr ctxt, const xmlChar **str); XMLPUBFUN int XMLCALL htmlParseCharRef(htmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL htmlParseElement(htmlParserCtxtPtr ctxt); XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlNewParserCtxt(void); XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlCreateMemoryParserCtxt(const char *buffer, int size); XMLPUBFUN int XMLCALL htmlParseDocument(htmlParserCtxtPtr ctxt); XMLPUBFUN htmlDocPtr XMLCALL htmlSAXParseDoc (const xmlChar *cur, const char *encoding, htmlSAXHandlerPtr sax, void *userData); XMLPUBFUN htmlDocPtr XMLCALL htmlParseDoc (const xmlChar *cur, const char *encoding); XMLPUBFUN htmlDocPtr XMLCALL htmlSAXParseFile(const char *filename, const char *encoding, htmlSAXHandlerPtr sax, void *userData); XMLPUBFUN htmlDocPtr XMLCALL htmlParseFile (const char *filename, const char *encoding); XMLPUBFUN int XMLCALL UTF8ToHtml (unsigned char *out, int *outlen, const unsigned char *in, int *inlen); XMLPUBFUN int XMLCALL htmlEncodeEntities(unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int quoteChar); XMLPUBFUN int XMLCALL htmlIsScriptAttribute(const xmlChar *name); XMLPUBFUN int XMLCALL htmlHandleOmittedElem(int val); #ifdef LIBXML_PUSH_ENABLED /** * Interfaces for the Push mode. */ XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data, const char *chunk, int size, const char *filename, xmlCharEncoding enc); XMLPUBFUN int XMLCALL htmlParseChunk (htmlParserCtxtPtr ctxt, const char *chunk, int size, int terminate); #endif /* LIBXML_PUSH_ENABLED */ XMLPUBFUN void XMLCALL htmlFreeParserCtxt (htmlParserCtxtPtr ctxt); /* * New set of simpler/more flexible APIs */ /** * xmlParserOption: * * This is the set of XML parser options that can be passed down * to the xmlReadDoc() and similar calls. */ typedef enum { HTML_PARSE_RECOVER = 1<<0, /* Relaxed parsing */ HTML_PARSE_NODEFDTD = 1<<2, /* do not default a doctype if not found */ HTML_PARSE_NOERROR = 1<<5, /* suppress error reports */ HTML_PARSE_NOWARNING= 1<<6, /* suppress warning reports */ HTML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */ HTML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */ HTML_PARSE_NONET = 1<<11,/* Forbid network access */ HTML_PARSE_NOIMPLIED= 1<<13,/* Do not add implied html/body... elements */ HTML_PARSE_COMPACT = 1<<16,/* compact small text nodes */ HTML_PARSE_IGNORE_ENC=1<<21 /* ignore internal document encoding hint */ } htmlParserOption; XMLPUBFUN void XMLCALL htmlCtxtReset (htmlParserCtxtPtr ctxt); XMLPUBFUN int XMLCALL htmlCtxtUseOptions (htmlParserCtxtPtr ctxt, int options); XMLPUBFUN htmlDocPtr XMLCALL htmlReadDoc (const xmlChar *cur, const char *URL, const char *encoding, int options); XMLPUBFUN htmlDocPtr XMLCALL htmlReadFile (const char *URL, const char *encoding, int options); XMLPUBFUN htmlDocPtr XMLCALL htmlReadMemory (const char *buffer, int size, const char *URL, const char *encoding, int options); XMLPUBFUN htmlDocPtr XMLCALL htmlReadFd (int fd, const char *URL, const char *encoding, int options); XMLPUBFUN htmlDocPtr XMLCALL htmlReadIO (xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options); XMLPUBFUN htmlDocPtr XMLCALL htmlCtxtReadDoc (xmlParserCtxtPtr ctxt, const xmlChar *cur, const char *URL, const char *encoding, int options); XMLPUBFUN htmlDocPtr XMLCALL htmlCtxtReadFile (xmlParserCtxtPtr ctxt, const char *filename, const char *encoding, int options); XMLPUBFUN htmlDocPtr XMLCALL htmlCtxtReadMemory (xmlParserCtxtPtr ctxt, const char *buffer, int size, const char *URL, const char *encoding, int options); XMLPUBFUN htmlDocPtr XMLCALL htmlCtxtReadFd (xmlParserCtxtPtr ctxt, int fd, const char *URL, const char *encoding, int options); XMLPUBFUN htmlDocPtr XMLCALL htmlCtxtReadIO (xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options); /* NRK/Jan2003: further knowledge of HTML structure */ typedef enum { HTML_NA = 0 , /* something we don't check at all */ HTML_INVALID = 0x1 , HTML_DEPRECATED = 0x2 , HTML_VALID = 0x4 , HTML_REQUIRED = 0xc /* VALID bit set so ( & HTML_VALID ) is TRUE */ } htmlStatus ; /* Using htmlElemDesc rather than name here, to emphasise the fact that otherwise there's a lookup overhead */ XMLPUBFUN htmlStatus XMLCALL htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ; XMLPUBFUN int XMLCALL htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ; XMLPUBFUN htmlStatus XMLCALL htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ; XMLPUBFUN htmlStatus XMLCALL htmlNodeStatus(const htmlNodePtr, int) ; /** * htmlDefaultSubelement: * @elt: HTML element * * Returns the default subelement for this element */ #define htmlDefaultSubelement(elt) elt->defaultsubelt /** * htmlElementAllowedHereDesc: * @parent: HTML parent element * @elt: HTML element * * Checks whether an HTML element description may be a * direct child of the specified element. * * Returns 1 if allowed; 0 otherwise. */ #define htmlElementAllowedHereDesc(parent,elt) \ htmlElementAllowedHere((parent), (elt)->name) /** * htmlRequiredAttrs: * @elt: HTML element * * Returns the attributes required for the specified element. */ #define htmlRequiredAttrs(elt) (elt)->attrs_req #ifdef __cplusplus } #endif #endif /* LIBXML_HTML_ENABLED */ #endif /* __HTML_PARSER_H__ */ /* * Summary: minimal HTTP implementation * Description: minimal HTTP implementation allowing to fetch resources * like external subset. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __NANO_HTTP_H__ #define __NANO_HTTP_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_HTTP_ENABLED #ifdef __cplusplus extern "C" { #endif XMLPUBFUN void XMLCALL xmlNanoHTTPInit (void); XMLPUBFUN void XMLCALL xmlNanoHTTPCleanup (void); XMLPUBFUN void XMLCALL xmlNanoHTTPScanProxy (const char *URL); XMLPUBFUN int XMLCALL xmlNanoHTTPFetch (const char *URL, const char *filename, char **contentType); XMLPUBFUN void * XMLCALL xmlNanoHTTPMethod (const char *URL, const char *method, const char *input, char **contentType, const char *headers, int ilen); XMLPUBFUN void * XMLCALL xmlNanoHTTPMethodRedir (const char *URL, const char *method, const char *input, char **contentType, char **redir, const char *headers, int ilen); XMLPUBFUN void * XMLCALL xmlNanoHTTPOpen (const char *URL, char **contentType); XMLPUBFUN void * XMLCALL xmlNanoHTTPOpenRedir (const char *URL, char **contentType, char **redir); XMLPUBFUN int XMLCALL xmlNanoHTTPReturnCode (void *ctx); XMLPUBFUN const char * XMLCALL xmlNanoHTTPAuthHeader (void *ctx); XMLPUBFUN const char * XMLCALL xmlNanoHTTPRedir (void *ctx); XMLPUBFUN int XMLCALL xmlNanoHTTPContentLength( void * ctx ); XMLPUBFUN const char * XMLCALL xmlNanoHTTPEncoding (void *ctx); XMLPUBFUN const char * XMLCALL xmlNanoHTTPMimeType (void *ctx); XMLPUBFUN int XMLCALL xmlNanoHTTPRead (void *ctx, void *dest, int len); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN int XMLCALL xmlNanoHTTPSave (void *ctxt, const char *filename); #endif /* LIBXML_OUTPUT_ENABLED */ XMLPUBFUN void XMLCALL xmlNanoHTTPClose (void *ctx); #ifdef __cplusplus } #endif #endif /* LIBXML_HTTP_ENABLED */ #endif /* __NANO_HTTP_H__ */ /* * Summary: implementation of the Relax-NG validation * Description: implementation of the Relax-NG validation * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_RELAX_NG__ #define __XML_RELAX_NG__ #include <libxml/xmlversion.h> #include <libxml/hash.h> #include <libxml/xmlstring.h> #ifdef LIBXML_SCHEMAS_ENABLED #ifdef __cplusplus extern "C" { #endif typedef struct _xmlRelaxNG xmlRelaxNG; typedef xmlRelaxNG *xmlRelaxNGPtr; /** * xmlRelaxNGValidityErrorFunc: * @ctx: the validation context * @msg: the message * @...: extra arguments * * Signature of an error callback from a Relax-NG validation */ typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); /** * xmlRelaxNGValidityWarningFunc: * @ctx: the validation context * @msg: the message * @...: extra arguments * * Signature of a warning callback from a Relax-NG validation */ typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); /** * A schemas validation context */ typedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt; typedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr; typedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt; typedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr; /* * xmlRelaxNGValidErr: * * List of possible Relax NG validation errors */ typedef enum { XML_RELAXNG_OK = 0, XML_RELAXNG_ERR_MEMORY, XML_RELAXNG_ERR_TYPE, XML_RELAXNG_ERR_TYPEVAL, XML_RELAXNG_ERR_DUPID, XML_RELAXNG_ERR_TYPECMP, XML_RELAXNG_ERR_NOSTATE, XML_RELAXNG_ERR_NODEFINE, XML_RELAXNG_ERR_LISTEXTRA, XML_RELAXNG_ERR_LISTEMPTY, XML_RELAXNG_ERR_INTERNODATA, XML_RELAXNG_ERR_INTERSEQ, XML_RELAXNG_ERR_INTEREXTRA, XML_RELAXNG_ERR_ELEMNAME, XML_RELAXNG_ERR_ATTRNAME, XML_RELAXNG_ERR_ELEMNONS, XML_RELAXNG_ERR_ATTRNONS, XML_RELAXNG_ERR_ELEMWRONGNS, XML_RELAXNG_ERR_ATTRWRONGNS, XML_RELAXNG_ERR_ELEMEXTRANS, XML_RELAXNG_ERR_ATTREXTRANS, XML_RELAXNG_ERR_ELEMNOTEMPTY, XML_RELAXNG_ERR_NOELEM, XML_RELAXNG_ERR_NOTELEM, XML_RELAXNG_ERR_ATTRVALID, XML_RELAXNG_ERR_CONTENTVALID, XML_RELAXNG_ERR_EXTRACONTENT, XML_RELAXNG_ERR_INVALIDATTR, XML_RELAXNG_ERR_DATAELEM, XML_RELAXNG_ERR_VALELEM, XML_RELAXNG_ERR_LISTELEM, XML_RELAXNG_ERR_DATATYPE, XML_RELAXNG_ERR_VALUE, XML_RELAXNG_ERR_LIST, XML_RELAXNG_ERR_NOGRAMMAR, XML_RELAXNG_ERR_EXTRADATA, XML_RELAXNG_ERR_LACKDATA, XML_RELAXNG_ERR_INTERNAL, XML_RELAXNG_ERR_ELEMWRONG, XML_RELAXNG_ERR_TEXTWRONG } xmlRelaxNGValidErr; /* * xmlRelaxNGParserFlags: * * List of possible Relax NG Parser flags */ typedef enum { XML_RELAXNGP_NONE = 0, XML_RELAXNGP_FREE_DOC = 1, XML_RELAXNGP_CRNG = 2 } xmlRelaxNGParserFlag; XMLPUBFUN int XMLCALL xmlRelaxNGInitTypes (void); XMLPUBFUN void XMLCALL xmlRelaxNGCleanupTypes (void); /* * Interfaces for parsing. */ XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL xmlRelaxNGNewParserCtxt (const char *URL); XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL xmlRelaxNGNewMemParserCtxt (const char *buffer, int size); XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL xmlRelaxNGNewDocParserCtxt (xmlDocPtr doc); XMLPUBFUN int XMLCALL xmlRelaxParserSetFlag (xmlRelaxNGParserCtxtPtr ctxt, int flag); XMLPUBFUN void XMLCALL xmlRelaxNGFreeParserCtxt (xmlRelaxNGParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGValidityErrorFunc err, xmlRelaxNGValidityWarningFunc warn, void *ctx); XMLPUBFUN int XMLCALL xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGValidityErrorFunc *err, xmlRelaxNGValidityWarningFunc *warn, void **ctx); XMLPUBFUN void XMLCALL xmlRelaxNGSetParserStructuredErrors( xmlRelaxNGParserCtxtPtr ctxt, xmlStructuredErrorFunc serror, void *ctx); XMLPUBFUN xmlRelaxNGPtr XMLCALL xmlRelaxNGParse (xmlRelaxNGParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlRelaxNGFree (xmlRelaxNGPtr schema); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN void XMLCALL xmlRelaxNGDump (FILE *output, xmlRelaxNGPtr schema); XMLPUBFUN void XMLCALL xmlRelaxNGDumpTree (FILE * output, xmlRelaxNGPtr schema); #endif /* LIBXML_OUTPUT_ENABLED */ /* * Interfaces for validating */ XMLPUBFUN void XMLCALL xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGValidityErrorFunc err, xmlRelaxNGValidityWarningFunc warn, void *ctx); XMLPUBFUN int XMLCALL xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, xmlRelaxNGValidityErrorFunc *err, xmlRelaxNGValidityWarningFunc *warn, void **ctx); XMLPUBFUN void XMLCALL xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt, xmlStructuredErrorFunc serror, void *ctx); XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL xmlRelaxNGNewValidCtxt (xmlRelaxNGPtr schema); XMLPUBFUN void XMLCALL xmlRelaxNGFreeValidCtxt (xmlRelaxNGValidCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc); /* * Interfaces for progressive validation when possible */ XMLPUBFUN int XMLCALL xmlRelaxNGValidatePushElement (xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem); XMLPUBFUN int XMLCALL xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt, const xmlChar *data, int len); XMLPUBFUN int XMLCALL xmlRelaxNGValidatePopElement (xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem); XMLPUBFUN int XMLCALL xmlRelaxNGValidateFullElement (xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem); #ifdef __cplusplus } #endif #endif /* LIBXML_SCHEMAS_ENABLED */ #endif /* __XML_RELAX_NG__ */ /* * Summary: specific APIs to process HTML tree, especially serialization * Description: this module implements a few function needed to process * tree in an HTML specific way. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __HTML_TREE_H__ #define __HTML_TREE_H__ #include <stdio.h> #include <libxml/xmlversion.h> #include <libxml/tree.h> #include <libxml/HTMLparser.h> #ifdef LIBXML_HTML_ENABLED #ifdef __cplusplus extern "C" { #endif /** * HTML_TEXT_NODE: * * Macro. A text node in a HTML document is really implemented * the same way as a text node in an XML document. */ #define HTML_TEXT_NODE XML_TEXT_NODE /** * HTML_ENTITY_REF_NODE: * * Macro. An entity reference in a HTML document is really implemented * the same way as an entity reference in an XML document. */ #define HTML_ENTITY_REF_NODE XML_ENTITY_REF_NODE /** * HTML_COMMENT_NODE: * * Macro. A comment in a HTML document is really implemented * the same way as a comment in an XML document. */ #define HTML_COMMENT_NODE XML_COMMENT_NODE /** * HTML_PRESERVE_NODE: * * Macro. A preserved node in a HTML document is really implemented * the same way as a CDATA section in an XML document. */ #define HTML_PRESERVE_NODE XML_CDATA_SECTION_NODE /** * HTML_PI_NODE: * * Macro. A processing instruction in a HTML document is really implemented * the same way as a processing instruction in an XML document. */ #define HTML_PI_NODE XML_PI_NODE XMLPUBFUN htmlDocPtr XMLCALL htmlNewDoc (const xmlChar *URI, const xmlChar *ExternalID); XMLPUBFUN htmlDocPtr XMLCALL htmlNewDocNoDtD (const xmlChar *URI, const xmlChar *ExternalID); XMLPUBFUN const xmlChar * XMLCALL htmlGetMetaEncoding (htmlDocPtr doc); XMLPUBFUN int XMLCALL htmlSetMetaEncoding (htmlDocPtr doc, const xmlChar *encoding); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN void XMLCALL htmlDocDumpMemory (xmlDocPtr cur, xmlChar **mem, int *size); XMLPUBFUN void XMLCALL htmlDocDumpMemoryFormat (xmlDocPtr cur, xmlChar **mem, int *size, int format); XMLPUBFUN int XMLCALL htmlDocDump (FILE *f, xmlDocPtr cur); XMLPUBFUN int XMLCALL htmlSaveFile (const char *filename, xmlDocPtr cur); XMLPUBFUN int XMLCALL htmlNodeDump (xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur); XMLPUBFUN void XMLCALL htmlNodeDumpFile (FILE *out, xmlDocPtr doc, xmlNodePtr cur); XMLPUBFUN int XMLCALL htmlNodeDumpFileFormat (FILE *out, xmlDocPtr doc, xmlNodePtr cur, const char *encoding, int format); XMLPUBFUN int XMLCALL htmlSaveFileEnc (const char *filename, xmlDocPtr cur, const char *encoding); XMLPUBFUN int XMLCALL htmlSaveFileFormat (const char *filename, xmlDocPtr cur, const char *encoding, int format); XMLPUBFUN void XMLCALL htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const char *encoding, int format); XMLPUBFUN void XMLCALL htmlDocContentDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding); XMLPUBFUN void XMLCALL htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding, int format); XMLPUBFUN void XMLCALL htmlNodeDumpOutput (xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, const char *encoding); #endif /* LIBXML_OUTPUT_ENABLED */ XMLPUBFUN int XMLCALL htmlIsBooleanAttr (const xmlChar *name); #ifdef __cplusplus } #endif #endif /* LIBXML_HTML_ENABLED */ #endif /* __HTML_TREE_H__ */ /* * Summary: compile-time version information * Description: compile-time version information for the XML library * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_VERSION_H__ #define __XML_VERSION_H__ #include <libxml/xmlexports.h> #ifdef __cplusplus extern "C" { #endif /* * use those to be sure nothing nasty will happen if * your library and includes mismatch */ #ifndef LIBXML2_COMPILING_MSCCDEF XMLPUBFUN void XMLCALL xmlCheckVersion(int version); #endif /* LIBXML2_COMPILING_MSCCDEF */ /** * LIBXML_DOTTED_VERSION: * * the version string like "1.2.3" */ #define LIBXML_DOTTED_VERSION "2.9.13" /** * LIBXML_VERSION: * * the version number: 1.2.3 value is 10203 */ #define LIBXML_VERSION 20913 /** * LIBXML_VERSION_STRING: * * the version number string, 1.2.3 value is "10203" */ #define LIBXML_VERSION_STRING "20913" /** * LIBXML_VERSION_EXTRA: * * extra version information, used to show a git commit description */ #define LIBXML_VERSION_EXTRA "" /** * LIBXML_TEST_VERSION: * * Macro to check that the libxml version in use is compatible with * the version the software has been compiled against */ #define LIBXML_TEST_VERSION xmlCheckVersion(20913); #ifndef VMS #if 0 /** * WITH_TRIO: * * defined if the trio support need to be configured in */ #define WITH_TRIO #else /** * WITHOUT_TRIO: * * defined if the trio support should not be configured in */ #define WITHOUT_TRIO #endif #else /* VMS */ /** * WITH_TRIO: * * defined if the trio support need to be configured in */ #define WITH_TRIO 1 #endif /* VMS */ /** * LIBXML_THREAD_ENABLED: * * Whether the thread support is configured in */ #if 1 #define LIBXML_THREAD_ENABLED #endif /** * LIBXML_THREAD_ALLOC_ENABLED: * * Whether the allocation hooks are per-thread */ #if 0 #define LIBXML_THREAD_ALLOC_ENABLED #endif /** * LIBXML_TREE_ENABLED: * * Whether the DOM like tree manipulation API support is configured in */ #if 1 #define LIBXML_TREE_ENABLED #endif /** * LIBXML_OUTPUT_ENABLED: * * Whether the serialization/saving support is configured in */ #if 1 #define LIBXML_OUTPUT_ENABLED #endif /** * LIBXML_PUSH_ENABLED: * * Whether the push parsing interfaces are configured in */ #if 1 #define LIBXML_PUSH_ENABLED #endif /** * LIBXML_READER_ENABLED: * * Whether the xmlReader parsing interface is configured in */ #if 1 #define LIBXML_READER_ENABLED #endif /** * LIBXML_PATTERN_ENABLED: * * Whether the xmlPattern node selection interface is configured in */ #if 1 #define LIBXML_PATTERN_ENABLED #endif /** * LIBXML_WRITER_ENABLED: * * Whether the xmlWriter saving interface is configured in */ #if 1 #define LIBXML_WRITER_ENABLED #endif /** * LIBXML_SAX1_ENABLED: * * Whether the older SAX1 interface is configured in */ #if 1 #define LIBXML_SAX1_ENABLED #endif /** * LIBXML_FTP_ENABLED: * * Whether the FTP support is configured in */ #if 1 #define LIBXML_FTP_ENABLED #endif /** * LIBXML_HTTP_ENABLED: * * Whether the HTTP support is configured in */ #if 1 #define LIBXML_HTTP_ENABLED #endif /** * LIBXML_VALID_ENABLED: * * Whether the DTD validation support is configured in */ #if 1 #define LIBXML_VALID_ENABLED #endif /** * LIBXML_HTML_ENABLED: * * Whether the HTML support is configured in */ #if 1 #define LIBXML_HTML_ENABLED #endif /** * LIBXML_LEGACY_ENABLED: * * Whether the deprecated APIs are compiled in for compatibility */ #if 1 #define LIBXML_LEGACY_ENABLED #endif /** * LIBXML_C14N_ENABLED: * * Whether the Canonicalization support is configured in */ #if 1 #define LIBXML_C14N_ENABLED #endif /** * LIBXML_CATALOG_ENABLED: * * Whether the Catalog support is configured in */ #if 1 #define LIBXML_CATALOG_ENABLED #endif /** * LIBXML_DOCB_ENABLED: * * Whether the SGML Docbook support is configured in */ #if 1 #define LIBXML_DOCB_ENABLED #endif /** * LIBXML_XPATH_ENABLED: * * Whether XPath is configured in */ #if 1 #define LIBXML_XPATH_ENABLED #endif /** * LIBXML_XPTR_ENABLED: * * Whether XPointer is configured in */ #if 1 #define LIBXML_XPTR_ENABLED #endif /** * LIBXML_XINCLUDE_ENABLED: * * Whether XInclude is configured in */ #if 1 #define LIBXML_XINCLUDE_ENABLED #endif /** * LIBXML_ICONV_ENABLED: * * Whether iconv support is available */ #if 1 #define LIBXML_ICONV_ENABLED #endif /** * LIBXML_ICU_ENABLED: * * Whether icu support is available */ #if 0 #define LIBXML_ICU_ENABLED #endif /** * LIBXML_ISO8859X_ENABLED: * * Whether ISO-8859-* support is made available in case iconv is not */ #if 1 #define LIBXML_ISO8859X_ENABLED #endif /** * LIBXML_DEBUG_ENABLED: * * Whether Debugging module is configured in */ #if 1 #define LIBXML_DEBUG_ENABLED #endif /** * DEBUG_MEMORY_LOCATION: * * Whether the memory debugging is configured in */ #if 0 #define DEBUG_MEMORY_LOCATION #endif /** * LIBXML_DEBUG_RUNTIME: * * Whether the runtime debugging is configured in */ #if 0 #define LIBXML_DEBUG_RUNTIME #endif /** * LIBXML_UNICODE_ENABLED: * * Whether the Unicode related interfaces are compiled in */ #if 1 #define LIBXML_UNICODE_ENABLED #endif /** * LIBXML_REGEXP_ENABLED: * * Whether the regular expressions interfaces are compiled in */ #if 1 #define LIBXML_REGEXP_ENABLED #endif /** * LIBXML_AUTOMATA_ENABLED: * * Whether the automata interfaces are compiled in */ #if 1 #define LIBXML_AUTOMATA_ENABLED #endif /** * LIBXML_EXPR_ENABLED: * * Whether the formal expressions interfaces are compiled in * * This code is unused and disabled unconditionally for now. */ #if 0 #define LIBXML_EXPR_ENABLED #endif /** * LIBXML_SCHEMAS_ENABLED: * * Whether the Schemas validation interfaces are compiled in */ #if 1 #define LIBXML_SCHEMAS_ENABLED #endif /** * LIBXML_SCHEMATRON_ENABLED: * * Whether the Schematron validation interfaces are compiled in */ #if 1 #define LIBXML_SCHEMATRON_ENABLED #endif /** * LIBXML_MODULES_ENABLED: * * Whether the module interfaces are compiled in */ #if 1 #define LIBXML_MODULES_ENABLED /** * LIBXML_MODULE_EXTENSION: * * the string suffix used by dynamic modules (usually shared libraries) */ #define LIBXML_MODULE_EXTENSION ".so" #endif /** * LIBXML_ZLIB_ENABLED: * * Whether the Zlib support is compiled in */ #if 1 #define LIBXML_ZLIB_ENABLED #endif /** * LIBXML_LZMA_ENABLED: * * Whether the Lzma support is compiled in */ #if 1 #define LIBXML_LZMA_ENABLED #endif #ifdef __GNUC__ /** * ATTRIBUTE_UNUSED: * * Macro used to signal to GCC unused function parameters */ #ifndef ATTRIBUTE_UNUSED # if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7))) # define ATTRIBUTE_UNUSED __attribute__((unused)) # else # define ATTRIBUTE_UNUSED # endif #endif /** * LIBXML_ATTR_ALLOC_SIZE: * * Macro used to indicate to GCC this is an allocator function */ #ifndef LIBXML_ATTR_ALLOC_SIZE # if (!defined(__clang__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))) # define LIBXML_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x))) # else # define LIBXML_ATTR_ALLOC_SIZE(x) # endif #else # define LIBXML_ATTR_ALLOC_SIZE(x) #endif /** * LIBXML_ATTR_FORMAT: * * Macro used to indicate to GCC the parameter are printf like */ #ifndef LIBXML_ATTR_FORMAT # if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) # define LIBXML_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args))) # else # define LIBXML_ATTR_FORMAT(fmt,args) # endif #else # define LIBXML_ATTR_FORMAT(fmt,args) #endif #else /* ! __GNUC__ */ /** * ATTRIBUTE_UNUSED: * * Macro used to signal to GCC unused function parameters */ #define ATTRIBUTE_UNUSED /** * LIBXML_ATTR_ALLOC_SIZE: * * Macro used to indicate to GCC this is an allocator function */ #define LIBXML_ATTR_ALLOC_SIZE(x) /** * LIBXML_ATTR_FORMAT: * * Macro used to indicate to GCC the parameter are printf like */ #define LIBXML_ATTR_FORMAT(fmt,args) #endif /* __GNUC__ */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* * Summary: interface for the encoding conversion functions * Description: interface for the encoding conversion functions needed for * XML basic encoding and iconv() support. * * Related specs are * rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies * [ISO-10646] UTF-8 and UTF-16 in Annexes * [ISO-8859-1] ISO Latin-1 characters codes. * [UNICODE] The Unicode Consortium, "The Unicode Standard -- * Worldwide Character Encoding -- Version 1.0", Addison- * Wesley, Volume 1, 1991, Volume 2, 1992. UTF-8 is * described in Unicode Technical Report #4. * [US-ASCII] Coded Character Set--7-bit American Standard Code for * Information Interchange, ANSI X3.4-1986. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_CHAR_ENCODING_H__ #define __XML_CHAR_ENCODING_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_ICONV_ENABLED #include <iconv.h> #endif #ifdef LIBXML_ICU_ENABLED #include <unicode/ucnv.h> #endif #ifdef __cplusplus extern "C" { #endif /* * xmlCharEncoding: * * Predefined values for some standard encodings. * Libxml does not do beforehand translation on UTF8 and ISOLatinX. * It also supports ASCII, ISO-8859-1, and UTF16 (LE and BE) by default. * * Anything else would have to be translated to UTF8 before being * given to the parser itself. The BOM for UTF16 and the encoding * declaration are looked at and a converter is looked for at that * point. If not found the parser stops here as asked by the XML REC. A * converter can be registered by the user using xmlRegisterCharEncodingHandler * but the current form doesn't allow stateful transcoding (a serious * problem agreed !). If iconv has been found it will be used * automatically and allow stateful transcoding, the simplest is then * to be sure to enable iconv and to provide iconv libs for the encoding * support needed. * * Note that the generic "UTF-16" is not a predefined value. Instead, only * the specific UTF-16LE and UTF-16BE are present. */ typedef enum { XML_CHAR_ENCODING_ERROR= -1, /* No char encoding detected */ XML_CHAR_ENCODING_NONE= 0, /* No char encoding detected */ XML_CHAR_ENCODING_UTF8= 1, /* UTF-8 */ XML_CHAR_ENCODING_UTF16LE= 2, /* UTF-16 little endian */ XML_CHAR_ENCODING_UTF16BE= 3, /* UTF-16 big endian */ XML_CHAR_ENCODING_UCS4LE= 4, /* UCS-4 little endian */ XML_CHAR_ENCODING_UCS4BE= 5, /* UCS-4 big endian */ XML_CHAR_ENCODING_EBCDIC= 6, /* EBCDIC uh! */ XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */ XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */ XML_CHAR_ENCODING_UCS2= 9, /* UCS-2 */ XML_CHAR_ENCODING_8859_1= 10,/* ISO-8859-1 ISO Latin 1 */ XML_CHAR_ENCODING_8859_2= 11,/* ISO-8859-2 ISO Latin 2 */ XML_CHAR_ENCODING_8859_3= 12,/* ISO-8859-3 */ XML_CHAR_ENCODING_8859_4= 13,/* ISO-8859-4 */ XML_CHAR_ENCODING_8859_5= 14,/* ISO-8859-5 */ XML_CHAR_ENCODING_8859_6= 15,/* ISO-8859-6 */ XML_CHAR_ENCODING_8859_7= 16,/* ISO-8859-7 */ XML_CHAR_ENCODING_8859_8= 17,/* ISO-8859-8 */ XML_CHAR_ENCODING_8859_9= 18,/* ISO-8859-9 */ XML_CHAR_ENCODING_2022_JP= 19,/* ISO-2022-JP */ XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */ XML_CHAR_ENCODING_EUC_JP= 21,/* EUC-JP */ XML_CHAR_ENCODING_ASCII= 22 /* pure ASCII */ } xmlCharEncoding; /** * xmlCharEncodingInputFunc: * @out: a pointer to an array of bytes to store the UTF-8 result * @outlen: the length of @out * @in: a pointer to an array of chars in the original encoding * @inlen: the length of @in * * Take a block of chars in the original encoding and try to convert * it to an UTF-8 block of chars out. * * Returns the number of bytes written, -1 if lack of space, or -2 * if the transcoding failed. * The value of @inlen after return is the number of octets consumed * if the return value is positive, else unpredictiable. * The value of @outlen after return is the number of octets consumed. */ typedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen, const unsigned char *in, int *inlen); /** * xmlCharEncodingOutputFunc: * @out: a pointer to an array of bytes to store the result * @outlen: the length of @out * @in: a pointer to an array of UTF-8 chars * @inlen: the length of @in * * Take a block of UTF-8 chars in and try to convert it to another * encoding. * Note: a first call designed to produce heading info is called with * in = NULL. If stateful this should also initialize the encoder state. * * Returns the number of bytes written, -1 if lack of space, or -2 * if the transcoding failed. * The value of @inlen after return is the number of octets consumed * if the return value is positive, else unpredictiable. * The value of @outlen after return is the number of octets produced. */ typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen, const unsigned char *in, int *inlen); /* * Block defining the handlers for non UTF-8 encodings. * If iconv is supported, there are two extra fields. */ #ifdef LIBXML_ICU_ENABLED /* Size of pivot buffer, same as icu/source/common/ucnv.cpp CHUNK_SIZE */ #define ICU_PIVOT_BUF_SIZE 1024 struct _uconv_t { UConverter *uconv; /* for conversion between an encoding and UTF-16 */ UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */ UChar pivot_buf[ICU_PIVOT_BUF_SIZE]; UChar *pivot_source; UChar *pivot_target; }; typedef struct _uconv_t uconv_t; #endif typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler; typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr; struct _xmlCharEncodingHandler { char *name; xmlCharEncodingInputFunc input; xmlCharEncodingOutputFunc output; #ifdef LIBXML_ICONV_ENABLED iconv_t iconv_in; iconv_t iconv_out; #endif /* LIBXML_ICONV_ENABLED */ #ifdef LIBXML_ICU_ENABLED uconv_t *uconv_in; uconv_t *uconv_out; #endif /* LIBXML_ICU_ENABLED */ }; #ifdef __cplusplus } #endif #include <libxml/tree.h> #ifdef __cplusplus extern "C" { #endif /* * Interfaces for encoding handlers. */ XMLPUBFUN void XMLCALL xmlInitCharEncodingHandlers (void); XMLPUBFUN void XMLCALL xmlCleanupCharEncodingHandlers (void); XMLPUBFUN void XMLCALL xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler); XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlGetCharEncodingHandler (xmlCharEncoding enc); XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler (const char *name); XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlNewCharEncodingHandler (const char *name, xmlCharEncodingInputFunc input, xmlCharEncodingOutputFunc output); /* * Interfaces for encoding names and aliases. */ XMLPUBFUN int XMLCALL xmlAddEncodingAlias (const char *name, const char *alias); XMLPUBFUN int XMLCALL xmlDelEncodingAlias (const char *alias); XMLPUBFUN const char * XMLCALL xmlGetEncodingAlias (const char *alias); XMLPUBFUN void XMLCALL xmlCleanupEncodingAliases (void); XMLPUBFUN xmlCharEncoding XMLCALL xmlParseCharEncoding (const char *name); XMLPUBFUN const char * XMLCALL xmlGetCharEncodingName (xmlCharEncoding enc); /* * Interfaces directly used by the parsers. */ XMLPUBFUN xmlCharEncoding XMLCALL xmlDetectCharEncoding (const unsigned char *in, int len); XMLPUBFUN int XMLCALL xmlCharEncOutFunc (xmlCharEncodingHandler *handler, xmlBufferPtr out, xmlBufferPtr in); XMLPUBFUN int XMLCALL xmlCharEncInFunc (xmlCharEncodingHandler *handler, xmlBufferPtr out, xmlBufferPtr in); XMLPUBFUN int XMLCALL xmlCharEncFirstLine (xmlCharEncodingHandler *handler, xmlBufferPtr out, xmlBufferPtr in); XMLPUBFUN int XMLCALL xmlCharEncCloseFunc (xmlCharEncodingHandler *handler); /* * Export a few useful functions */ #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN int XMLCALL UTF8Toisolat1 (unsigned char *out, int *outlen, const unsigned char *in, int *inlen); #endif /* LIBXML_OUTPUT_ENABLED */ XMLPUBFUN int XMLCALL isolat1ToUTF8 (unsigned char *out, int *outlen, const unsigned char *in, int *inlen); #ifdef __cplusplus } #endif #endif /* __XML_CHAR_ENCODING_H__ */ /** * Summary: interfaces for thread handling * Description: set of generic threading related routines * should work with pthreads, Windows native or TLS threads * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_THREADS_H__ #define __XML_THREADS_H__ #include <libxml/xmlversion.h> #ifdef __cplusplus extern "C" { #endif /* * xmlMutex are a simple mutual exception locks. */ typedef struct _xmlMutex xmlMutex; typedef xmlMutex *xmlMutexPtr; /* * xmlRMutex are reentrant mutual exception locks. */ typedef struct _xmlRMutex xmlRMutex; typedef xmlRMutex *xmlRMutexPtr; #ifdef __cplusplus } #endif #include <libxml/globals.h> #ifdef __cplusplus extern "C" { #endif XMLPUBFUN xmlMutexPtr XMLCALL xmlNewMutex (void); XMLPUBFUN void XMLCALL xmlMutexLock (xmlMutexPtr tok); XMLPUBFUN void XMLCALL xmlMutexUnlock (xmlMutexPtr tok); XMLPUBFUN void XMLCALL xmlFreeMutex (xmlMutexPtr tok); XMLPUBFUN xmlRMutexPtr XMLCALL xmlNewRMutex (void); XMLPUBFUN void XMLCALL xmlRMutexLock (xmlRMutexPtr tok); XMLPUBFUN void XMLCALL xmlRMutexUnlock (xmlRMutexPtr tok); XMLPUBFUN void XMLCALL xmlFreeRMutex (xmlRMutexPtr tok); /* * Library wide APIs. */ XMLPUBFUN void XMLCALL xmlInitThreads (void); XMLPUBFUN void XMLCALL xmlLockLibrary (void); XMLPUBFUN void XMLCALL xmlUnlockLibrary(void); XMLPUBFUN int XMLCALL xmlGetThreadId (void); XMLPUBFUN int XMLCALL xmlIsMainThread (void); XMLPUBFUN void XMLCALL xmlCleanupThreads(void); XMLPUBFUN xmlGlobalStatePtr XMLCALL xmlGetGlobalState(void); #ifdef HAVE_PTHREAD_H #elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)) #if defined(LIBXML_STATIC_FOR_DLL) int XMLCALL xmlDllMain(void *hinstDLL, unsigned long fdwReason, void *lpvReserved); #endif #endif #ifdef __cplusplus } #endif #endif /* __XML_THREADS_H__ */ /* * Summary: API to build regexp automata * Description: the API to build regexp automata * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_AUTOMATA_H__ #define __XML_AUTOMATA_H__ #include <libxml/xmlversion.h> #include <libxml/tree.h> #ifdef LIBXML_REGEXP_ENABLED #ifdef LIBXML_AUTOMATA_ENABLED #include <libxml/xmlregexp.h> #ifdef __cplusplus extern "C" { #endif /** * xmlAutomataPtr: * * A libxml automata description, It can be compiled into a regexp */ typedef struct _xmlAutomata xmlAutomata; typedef xmlAutomata *xmlAutomataPtr; /** * xmlAutomataStatePtr: * * A state int the automata description, */ typedef struct _xmlAutomataState xmlAutomataState; typedef xmlAutomataState *xmlAutomataStatePtr; /* * Building API */ XMLPUBFUN xmlAutomataPtr XMLCALL xmlNewAutomata (void); XMLPUBFUN void XMLCALL xmlFreeAutomata (xmlAutomataPtr am); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataGetInitState (xmlAutomataPtr am); XMLPUBFUN int XMLCALL xmlAutomataSetFinalState (xmlAutomataPtr am, xmlAutomataStatePtr state); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataNewState (xmlAutomataPtr am); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataNewTransition (xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, void *data); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataNewTransition2 (xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, const xmlChar *token2, void *data); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataNewNegTrans (xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, const xmlChar *token2, void *data); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataNewCountTrans (xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, int min, int max, void *data); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataNewCountTrans2 (xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, const xmlChar *token2, int min, int max, void *data); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataNewOnceTrans (xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, int min, int max, void *data); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataNewOnceTrans2 (xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, const xmlChar *token, const xmlChar *token2, int min, int max, void *data); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataNewAllTrans (xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, int lax); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataNewEpsilon (xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataNewCountedTrans (xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, int counter); XMLPUBFUN xmlAutomataStatePtr XMLCALL xmlAutomataNewCounterTrans (xmlAutomataPtr am, xmlAutomataStatePtr from, xmlAutomataStatePtr to, int counter); XMLPUBFUN int XMLCALL xmlAutomataNewCounter (xmlAutomataPtr am, int min, int max); XMLPUBFUN xmlRegexpPtr XMLCALL xmlAutomataCompile (xmlAutomataPtr am); XMLPUBFUN int XMLCALL xmlAutomataIsDeterminist (xmlAutomataPtr am); #ifdef __cplusplus } #endif #endif /* LIBXML_AUTOMATA_ENABLED */ #endif /* LIBXML_REGEXP_ENABLED */ #endif /* __XML_AUTOMATA_H__ */ /* * Summary: Unicode character APIs * Description: API for the Unicode character APIs * * This file is automatically generated from the * UCS description files of the Unicode Character Database * http://www.unicode.org/Public/4.0-Update1/UCD-4.0.1.html * using the genUnicode.py Python script. * * Generation date: Mon Mar 27 11:09:52 2006 * Sources: Blocks-4.0.1.txt UnicodeData-4.0.1.txt * Author: Daniel Veillard */ #ifndef __XML_UNICODE_H__ #define __XML_UNICODE_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_UNICODE_ENABLED #ifdef __cplusplus extern "C" { #endif XMLPUBFUN int XMLCALL xmlUCSIsAegeanNumbers (int code); XMLPUBFUN int XMLCALL xmlUCSIsAlphabeticPresentationForms (int code); XMLPUBFUN int XMLCALL xmlUCSIsArabic (int code); XMLPUBFUN int XMLCALL xmlUCSIsArabicPresentationFormsA (int code); XMLPUBFUN int XMLCALL xmlUCSIsArabicPresentationFormsB (int code); XMLPUBFUN int XMLCALL xmlUCSIsArmenian (int code); XMLPUBFUN int XMLCALL xmlUCSIsArrows (int code); XMLPUBFUN int XMLCALL xmlUCSIsBasicLatin (int code); XMLPUBFUN int XMLCALL xmlUCSIsBengali (int code); XMLPUBFUN int XMLCALL xmlUCSIsBlockElements (int code); XMLPUBFUN int XMLCALL xmlUCSIsBopomofo (int code); XMLPUBFUN int XMLCALL xmlUCSIsBopomofoExtended (int code); XMLPUBFUN int XMLCALL xmlUCSIsBoxDrawing (int code); XMLPUBFUN int XMLCALL xmlUCSIsBraillePatterns (int code); XMLPUBFUN int XMLCALL xmlUCSIsBuhid (int code); XMLPUBFUN int XMLCALL xmlUCSIsByzantineMusicalSymbols (int code); XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibility (int code); XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityForms (int code); XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityIdeographs (int code); XMLPUBFUN int XMLCALL xmlUCSIsCJKCompatibilityIdeographsSupplement (int code); XMLPUBFUN int XMLCALL xmlUCSIsCJKRadicalsSupplement (int code); XMLPUBFUN int XMLCALL xmlUCSIsCJKSymbolsandPunctuation (int code); XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographs (int code); XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographsExtensionA (int code); XMLPUBFUN int XMLCALL xmlUCSIsCJKUnifiedIdeographsExtensionB (int code); XMLPUBFUN int XMLCALL xmlUCSIsCherokee (int code); XMLPUBFUN int XMLCALL xmlUCSIsCombiningDiacriticalMarks (int code); XMLPUBFUN int XMLCALL xmlUCSIsCombiningDiacriticalMarksforSymbols (int code); XMLPUBFUN int XMLCALL xmlUCSIsCombiningHalfMarks (int code); XMLPUBFUN int XMLCALL xmlUCSIsCombiningMarksforSymbols (int code); XMLPUBFUN int XMLCALL xmlUCSIsControlPictures (int code); XMLPUBFUN int XMLCALL xmlUCSIsCurrencySymbols (int code); XMLPUBFUN int XMLCALL xmlUCSIsCypriotSyllabary (int code); XMLPUBFUN int XMLCALL xmlUCSIsCyrillic (int code); XMLPUBFUN int XMLCALL xmlUCSIsCyrillicSupplement (int code); XMLPUBFUN int XMLCALL xmlUCSIsDeseret (int code); XMLPUBFUN int XMLCALL xmlUCSIsDevanagari (int code); XMLPUBFUN int XMLCALL xmlUCSIsDingbats (int code); XMLPUBFUN int XMLCALL xmlUCSIsEnclosedAlphanumerics (int code); XMLPUBFUN int XMLCALL xmlUCSIsEnclosedCJKLettersandMonths (int code); XMLPUBFUN int XMLCALL xmlUCSIsEthiopic (int code); XMLPUBFUN int XMLCALL xmlUCSIsGeneralPunctuation (int code); XMLPUBFUN int XMLCALL xmlUCSIsGeometricShapes (int code); XMLPUBFUN int XMLCALL xmlUCSIsGeorgian (int code); XMLPUBFUN int XMLCALL xmlUCSIsGothic (int code); XMLPUBFUN int XMLCALL xmlUCSIsGreek (int code); XMLPUBFUN int XMLCALL xmlUCSIsGreekExtended (int code); XMLPUBFUN int XMLCALL xmlUCSIsGreekandCoptic (int code); XMLPUBFUN int XMLCALL xmlUCSIsGujarati (int code); XMLPUBFUN int XMLCALL xmlUCSIsGurmukhi (int code); XMLPUBFUN int XMLCALL xmlUCSIsHalfwidthandFullwidthForms (int code); XMLPUBFUN int XMLCALL xmlUCSIsHangulCompatibilityJamo (int code); XMLPUBFUN int XMLCALL xmlUCSIsHangulJamo (int code); XMLPUBFUN int XMLCALL xmlUCSIsHangulSyllables (int code); XMLPUBFUN int XMLCALL xmlUCSIsHanunoo (int code); XMLPUBFUN int XMLCALL xmlUCSIsHebrew (int code); XMLPUBFUN int XMLCALL xmlUCSIsHighPrivateUseSurrogates (int code); XMLPUBFUN int XMLCALL xmlUCSIsHighSurrogates (int code); XMLPUBFUN int XMLCALL xmlUCSIsHiragana (int code); XMLPUBFUN int XMLCALL xmlUCSIsIPAExtensions (int code); XMLPUBFUN int XMLCALL xmlUCSIsIdeographicDescriptionCharacters (int code); XMLPUBFUN int XMLCALL xmlUCSIsKanbun (int code); XMLPUBFUN int XMLCALL xmlUCSIsKangxiRadicals (int code); XMLPUBFUN int XMLCALL xmlUCSIsKannada (int code); XMLPUBFUN int XMLCALL xmlUCSIsKatakana (int code); XMLPUBFUN int XMLCALL xmlUCSIsKatakanaPhoneticExtensions (int code); XMLPUBFUN int XMLCALL xmlUCSIsKhmer (int code); XMLPUBFUN int XMLCALL xmlUCSIsKhmerSymbols (int code); XMLPUBFUN int XMLCALL xmlUCSIsLao (int code); XMLPUBFUN int XMLCALL xmlUCSIsLatin1Supplement (int code); XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedA (int code); XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedB (int code); XMLPUBFUN int XMLCALL xmlUCSIsLatinExtendedAdditional (int code); XMLPUBFUN int XMLCALL xmlUCSIsLetterlikeSymbols (int code); XMLPUBFUN int XMLCALL xmlUCSIsLimbu (int code); XMLPUBFUN int XMLCALL xmlUCSIsLinearBIdeograms (int code); XMLPUBFUN int XMLCALL xmlUCSIsLinearBSyllabary (int code); XMLPUBFUN int XMLCALL xmlUCSIsLowSurrogates (int code); XMLPUBFUN int XMLCALL xmlUCSIsMalayalam (int code); XMLPUBFUN int XMLCALL xmlUCSIsMathematicalAlphanumericSymbols (int code); XMLPUBFUN int XMLCALL xmlUCSIsMathematicalOperators (int code); XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousMathematicalSymbolsA (int code); XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousMathematicalSymbolsB (int code); XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousSymbols (int code); XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousSymbolsandArrows (int code); XMLPUBFUN int XMLCALL xmlUCSIsMiscellaneousTechnical (int code); XMLPUBFUN int XMLCALL xmlUCSIsMongolian (int code); XMLPUBFUN int XMLCALL xmlUCSIsMusicalSymbols (int code); XMLPUBFUN int XMLCALL xmlUCSIsMyanmar (int code); XMLPUBFUN int XMLCALL xmlUCSIsNumberForms (int code); XMLPUBFUN int XMLCALL xmlUCSIsOgham (int code); XMLPUBFUN int XMLCALL xmlUCSIsOldItalic (int code); XMLPUBFUN int XMLCALL xmlUCSIsOpticalCharacterRecognition (int code); XMLPUBFUN int XMLCALL xmlUCSIsOriya (int code); XMLPUBFUN int XMLCALL xmlUCSIsOsmanya (int code); XMLPUBFUN int XMLCALL xmlUCSIsPhoneticExtensions (int code); XMLPUBFUN int XMLCALL xmlUCSIsPrivateUse (int code); XMLPUBFUN int XMLCALL xmlUCSIsPrivateUseArea (int code); XMLPUBFUN int XMLCALL xmlUCSIsRunic (int code); XMLPUBFUN int XMLCALL xmlUCSIsShavian (int code); XMLPUBFUN int XMLCALL xmlUCSIsSinhala (int code); XMLPUBFUN int XMLCALL xmlUCSIsSmallFormVariants (int code); XMLPUBFUN int XMLCALL xmlUCSIsSpacingModifierLetters (int code); XMLPUBFUN int XMLCALL xmlUCSIsSpecials (int code); XMLPUBFUN int XMLCALL xmlUCSIsSuperscriptsandSubscripts (int code); XMLPUBFUN int XMLCALL xmlUCSIsSupplementalArrowsA (int code); XMLPUBFUN int XMLCALL xmlUCSIsSupplementalArrowsB (int code); XMLPUBFUN int XMLCALL xmlUCSIsSupplementalMathematicalOperators (int code); XMLPUBFUN int XMLCALL xmlUCSIsSupplementaryPrivateUseAreaA (int code); XMLPUBFUN int XMLCALL xmlUCSIsSupplementaryPrivateUseAreaB (int code); XMLPUBFUN int XMLCALL xmlUCSIsSyriac (int code); XMLPUBFUN int XMLCALL xmlUCSIsTagalog (int code); XMLPUBFUN int XMLCALL xmlUCSIsTagbanwa (int code); XMLPUBFUN int XMLCALL xmlUCSIsTags (int code); XMLPUBFUN int XMLCALL xmlUCSIsTaiLe (int code); XMLPUBFUN int XMLCALL xmlUCSIsTaiXuanJingSymbols (int code); XMLPUBFUN int XMLCALL xmlUCSIsTamil (int code); XMLPUBFUN int XMLCALL xmlUCSIsTelugu (int code); XMLPUBFUN int XMLCALL xmlUCSIsThaana (int code); XMLPUBFUN int XMLCALL xmlUCSIsThai (int code); XMLPUBFUN int XMLCALL xmlUCSIsTibetan (int code); XMLPUBFUN int XMLCALL xmlUCSIsUgaritic (int code); XMLPUBFUN int XMLCALL xmlUCSIsUnifiedCanadianAboriginalSyllabics (int code); XMLPUBFUN int XMLCALL xmlUCSIsVariationSelectors (int code); XMLPUBFUN int XMLCALL xmlUCSIsVariationSelectorsSupplement (int code); XMLPUBFUN int XMLCALL xmlUCSIsYiRadicals (int code); XMLPUBFUN int XMLCALL xmlUCSIsYiSyllables (int code); XMLPUBFUN int XMLCALL xmlUCSIsYijingHexagramSymbols (int code); XMLPUBFUN int XMLCALL xmlUCSIsBlock (int code, const char *block); XMLPUBFUN int XMLCALL xmlUCSIsCatC (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatCc (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatCf (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatCo (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatCs (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatL (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatLl (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatLm (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatLo (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatLt (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatLu (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatM (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatMc (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatMe (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatMn (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatN (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatNd (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatNl (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatNo (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatP (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatPc (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatPd (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatPe (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatPf (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatPi (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatPo (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatPs (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatS (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatSc (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatSk (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatSm (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatSo (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatZ (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatZl (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatZp (int code); XMLPUBFUN int XMLCALL xmlUCSIsCatZs (int code); XMLPUBFUN int XMLCALL xmlUCSIsCat (int code, const char *cat); #ifdef __cplusplus } #endif #endif /* LIBXML_UNICODE_ENABLED */ #endif /* __XML_UNICODE_H__ */ /* * Summary: internals routines and limits exported by the parser. * Description: this module exports a number of internal parsing routines * they are not really all intended for applications but * can prove useful doing low level processing. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_PARSER_INTERNALS_H__ #define __XML_PARSER_INTERNALS_H__ #include <libxml/xmlversion.h> #include <libxml/parser.h> #include <libxml/HTMLparser.h> #include <libxml/chvalid.h> #ifdef __cplusplus extern "C" { #endif /** * xmlParserMaxDepth: * * arbitrary depth limit for the XML documents that we allow to * process. This is not a limitation of the parser but a safety * boundary feature, use XML_PARSE_HUGE option to override it. */ XMLPUBVAR unsigned int xmlParserMaxDepth; /** * XML_MAX_TEXT_LENGTH: * * Maximum size allowed for a single text node when building a tree. * This is not a limitation of the parser but a safety boundary feature, * use XML_PARSE_HUGE option to override it. * Introduced in 2.9.0 */ #define XML_MAX_TEXT_LENGTH 10000000 /** * XML_MAX_NAME_LENGTH: * * Maximum size allowed for a markup identifier. * This is not a limitation of the parser but a safety boundary feature, * use XML_PARSE_HUGE option to override it. * Note that with the use of parsing dictionaries overriding the limit * may result in more runtime memory usage in face of "unfriendly' content * Introduced in 2.9.0 */ #define XML_MAX_NAME_LENGTH 50000 /** * XML_MAX_DICTIONARY_LIMIT: * * Maximum size allowed by the parser for a dictionary by default * This is not a limitation of the parser but a safety boundary feature, * use XML_PARSE_HUGE option to override it. * Introduced in 2.9.0 */ #define XML_MAX_DICTIONARY_LIMIT 10000000 /** * XML_MAX_LOOKUP_LIMIT: * * Maximum size allowed by the parser for ahead lookup * This is an upper boundary enforced by the parser to avoid bad * behaviour on "unfriendly' content * Introduced in 2.9.0 */ #define XML_MAX_LOOKUP_LIMIT 10000000 /** * XML_MAX_NAMELEN: * * Identifiers can be longer, but this will be more costly * at runtime. */ #define XML_MAX_NAMELEN 100 /** * INPUT_CHUNK: * * The parser tries to always have that amount of input ready. * One of the point is providing context when reporting errors. */ #define INPUT_CHUNK 250 /************************************************************************ * * * UNICODE version of the macros. * * * ************************************************************************/ /** * IS_BYTE_CHAR: * @c: an byte value (int) * * Macro to check the following production in the XML spec: * * [2] Char ::= #x9 | #xA | #xD | [#x20...] * any byte character in the accepted range */ #define IS_BYTE_CHAR(c) xmlIsChar_ch(c) /** * IS_CHAR: * @c: an UNICODE value (int) * * Macro to check the following production in the XML spec: * * [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] * | [#x10000-#x10FFFF] * any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */ #define IS_CHAR(c) xmlIsCharQ(c) /** * IS_CHAR_CH: * @c: an xmlChar (usually an unsigned char) * * Behaves like IS_CHAR on single-byte value */ #define IS_CHAR_CH(c) xmlIsChar_ch(c) /** * IS_BLANK: * @c: an UNICODE value (int) * * Macro to check the following production in the XML spec: * * [3] S ::= (#x20 | #x9 | #xD | #xA)+ */ #define IS_BLANK(c) xmlIsBlankQ(c) /** * IS_BLANK_CH: * @c: an xmlChar value (normally unsigned char) * * Behaviour same as IS_BLANK */ #define IS_BLANK_CH(c) xmlIsBlank_ch(c) /** * IS_BASECHAR: * @c: an UNICODE value (int) * * Macro to check the following production in the XML spec: * * [85] BaseChar ::= ... long list see REC ... */ #define IS_BASECHAR(c) xmlIsBaseCharQ(c) /** * IS_DIGIT: * @c: an UNICODE value (int) * * Macro to check the following production in the XML spec: * * [88] Digit ::= ... long list see REC ... */ #define IS_DIGIT(c) xmlIsDigitQ(c) /** * IS_DIGIT_CH: * @c: an xmlChar value (usually an unsigned char) * * Behaves like IS_DIGIT but with a single byte argument */ #define IS_DIGIT_CH(c) xmlIsDigit_ch(c) /** * IS_COMBINING: * @c: an UNICODE value (int) * * Macro to check the following production in the XML spec: * * [87] CombiningChar ::= ... long list see REC ... */ #define IS_COMBINING(c) xmlIsCombiningQ(c) /** * IS_COMBINING_CH: * @c: an xmlChar (usually an unsigned char) * * Always false (all combining chars > 0xff) */ #define IS_COMBINING_CH(c) 0 /** * IS_EXTENDER: * @c: an UNICODE value (int) * * Macro to check the following production in the XML spec: * * * [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 | * #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] | * [#x309D-#x309E] | [#x30FC-#x30FE] */ #define IS_EXTENDER(c) xmlIsExtenderQ(c) /** * IS_EXTENDER_CH: * @c: an xmlChar value (usually an unsigned char) * * Behaves like IS_EXTENDER but with a single-byte argument */ #define IS_EXTENDER_CH(c) xmlIsExtender_ch(c) /** * IS_IDEOGRAPHIC: * @c: an UNICODE value (int) * * Macro to check the following production in the XML spec: * * * [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029] */ #define IS_IDEOGRAPHIC(c) xmlIsIdeographicQ(c) /** * IS_LETTER: * @c: an UNICODE value (int) * * Macro to check the following production in the XML spec: * * * [84] Letter ::= BaseChar | Ideographic */ #define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c)) /** * IS_LETTER_CH: * @c: an xmlChar value (normally unsigned char) * * Macro behaves like IS_LETTER, but only check base chars * */ #define IS_LETTER_CH(c) xmlIsBaseChar_ch(c) /** * IS_ASCII_LETTER: * @c: an xmlChar value * * Macro to check [a-zA-Z] * */ #define IS_ASCII_LETTER(c) (((0x41 <= (c)) && ((c) <= 0x5a)) || \ ((0x61 <= (c)) && ((c) <= 0x7a))) /** * IS_ASCII_DIGIT: * @c: an xmlChar value * * Macro to check [0-9] * */ #define IS_ASCII_DIGIT(c) ((0x30 <= (c)) && ((c) <= 0x39)) /** * IS_PUBIDCHAR: * @c: an UNICODE value (int) * * Macro to check the following production in the XML spec: * * * [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] */ #define IS_PUBIDCHAR(c) xmlIsPubidCharQ(c) /** * IS_PUBIDCHAR_CH: * @c: an xmlChar value (normally unsigned char) * * Same as IS_PUBIDCHAR but for single-byte value */ #define IS_PUBIDCHAR_CH(c) xmlIsPubidChar_ch(c) /** * SKIP_EOL: * @p: and UTF8 string pointer * * Skips the end of line chars. */ #define SKIP_EOL(p) \ if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \ if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; } /** * MOVETO_ENDTAG: * @p: and UTF8 string pointer * * Skips to the next '>' char. */ #define MOVETO_ENDTAG(p) \ while ((*p) && (*(p) != '>')) (p)++ /** * MOVETO_STARTTAG: * @p: and UTF8 string pointer * * Skips to the next '<' char. */ #define MOVETO_STARTTAG(p) \ while ((*p) && (*(p) != '<')) (p)++ /** * Global variables used for predefined strings. */ XMLPUBVAR const xmlChar xmlStringText[]; XMLPUBVAR const xmlChar xmlStringTextNoenc[]; XMLPUBVAR const xmlChar xmlStringComment[]; /* * Function to finish the work of the macros where needed. */ XMLPUBFUN int XMLCALL xmlIsLetter (int c); /** * Parser context. */ XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateFileParserCtxt (const char *filename); XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateURLParserCtxt (const char *filename, int options); XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateMemoryParserCtxt(const char *buffer, int size); XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateEntityParserCtxt(const xmlChar *URL, const xmlChar *ID, const xmlChar *base); XMLPUBFUN int XMLCALL xmlSwitchEncoding (xmlParserCtxtPtr ctxt, xmlCharEncoding enc); XMLPUBFUN int XMLCALL xmlSwitchToEncoding (xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler); XMLPUBFUN int XMLCALL xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler); #ifdef IN_LIBXML /* internal error reporting */ XMLPUBFUN void XMLCALL __xmlErrEncoding (xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, const char *msg, const xmlChar * str1, const xmlChar * str2) LIBXML_ATTR_FORMAT(3,0); #endif /** * Input Streams. */ XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewStringInputStream (xmlParserCtxtPtr ctxt, const xmlChar *buffer); XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewEntityInputStream (xmlParserCtxtPtr ctxt, xmlEntityPtr entity); XMLPUBFUN int XMLCALL xmlPushInput (xmlParserCtxtPtr ctxt, xmlParserInputPtr input); XMLPUBFUN xmlChar XMLCALL xmlPopInput (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlFreeInputStream (xmlParserInputPtr input); XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputFromFile (xmlParserCtxtPtr ctxt, const char *filename); XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream (xmlParserCtxtPtr ctxt); /** * Namespaces. */ XMLPUBFUN xmlChar * XMLCALL xmlSplitQName (xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix); /** * Generic production rules. */ XMLPUBFUN const xmlChar * XMLCALL xmlParseName (xmlParserCtxtPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlParseNmtoken (xmlParserCtxtPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlParseEntityValue (xmlParserCtxtPtr ctxt, xmlChar **orig); XMLPUBFUN xmlChar * XMLCALL xmlParseAttValue (xmlParserCtxtPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlParseSystemLiteral (xmlParserCtxtPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlParsePubidLiteral (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseCharData (xmlParserCtxtPtr ctxt, int cdata); XMLPUBFUN xmlChar * XMLCALL xmlParseExternalID (xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict); XMLPUBFUN void XMLCALL xmlParseComment (xmlParserCtxtPtr ctxt); XMLPUBFUN const xmlChar * XMLCALL xmlParsePITarget (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParsePI (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseNotationDecl (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseEntityDecl (xmlParserCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlParseDefaultDecl (xmlParserCtxtPtr ctxt, xmlChar **value); XMLPUBFUN xmlEnumerationPtr XMLCALL xmlParseNotationType (xmlParserCtxtPtr ctxt); XMLPUBFUN xmlEnumerationPtr XMLCALL xmlParseEnumerationType (xmlParserCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlParseEnumeratedType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree); XMLPUBFUN int XMLCALL xmlParseAttributeType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree); XMLPUBFUN void XMLCALL xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt); XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementMixedContentDecl (xmlParserCtxtPtr ctxt, int inputchk); XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk); XMLPUBFUN int XMLCALL xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result); XMLPUBFUN int XMLCALL xmlParseElementDecl (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseMarkupDecl (xmlParserCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlParseCharRef (xmlParserCtxtPtr ctxt); XMLPUBFUN xmlEntityPtr XMLCALL xmlParseEntityRef (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseReference (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParsePEReference (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt); #ifdef LIBXML_SAX1_ENABLED XMLPUBFUN const xmlChar * XMLCALL xmlParseAttribute (xmlParserCtxtPtr ctxt, xmlChar **value); XMLPUBFUN const xmlChar * XMLCALL xmlParseStartTag (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseEndTag (xmlParserCtxtPtr ctxt); #endif /* LIBXML_SAX1_ENABLED */ XMLPUBFUN void XMLCALL xmlParseCDSect (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseContent (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseElement (xmlParserCtxtPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlParseVersionNum (xmlParserCtxtPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlParseVersionInfo (xmlParserCtxtPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlParseEncName (xmlParserCtxtPtr ctxt); XMLPUBFUN const xmlChar * XMLCALL xmlParseEncodingDecl (xmlParserCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlParseSDDecl (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseXMLDecl (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseTextDecl (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseMisc (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseExternalSubset (xmlParserCtxtPtr ctxt, const xmlChar *ExternalID, const xmlChar *SystemID); /** * XML_SUBSTITUTE_NONE: * * If no entities need to be substituted. */ #define XML_SUBSTITUTE_NONE 0 /** * XML_SUBSTITUTE_REF: * * Whether general entities need to be substituted. */ #define XML_SUBSTITUTE_REF 1 /** * XML_SUBSTITUTE_PEREF: * * Whether parameter entities need to be substituted. */ #define XML_SUBSTITUTE_PEREF 2 /** * XML_SUBSTITUTE_BOTH: * * Both general and parameter entities need to be substituted. */ #define XML_SUBSTITUTE_BOTH 3 XMLPUBFUN xmlChar * XMLCALL xmlStringDecodeEntities (xmlParserCtxtPtr ctxt, const xmlChar *str, int what, xmlChar end, xmlChar end2, xmlChar end3); XMLPUBFUN xmlChar * XMLCALL xmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int what, xmlChar end, xmlChar end2, xmlChar end3); /* * Generated by MACROS on top of parser.c c.f. PUSH_AND_POP. */ XMLPUBFUN int XMLCALL nodePush (xmlParserCtxtPtr ctxt, xmlNodePtr value); XMLPUBFUN xmlNodePtr XMLCALL nodePop (xmlParserCtxtPtr ctxt); XMLPUBFUN int XMLCALL inputPush (xmlParserCtxtPtr ctxt, xmlParserInputPtr value); XMLPUBFUN xmlParserInputPtr XMLCALL inputPop (xmlParserCtxtPtr ctxt); XMLPUBFUN const xmlChar * XMLCALL namePop (xmlParserCtxtPtr ctxt); XMLPUBFUN int XMLCALL namePush (xmlParserCtxtPtr ctxt, const xmlChar *value); /* * other commodities shared between parser.c and parserInternals. */ XMLPUBFUN int XMLCALL xmlSkipBlankChars (xmlParserCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlStringCurrentChar (xmlParserCtxtPtr ctxt, const xmlChar *cur, int *len); XMLPUBFUN void XMLCALL xmlParserHandlePEReference(xmlParserCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlCheckLanguageID (const xmlChar *lang); /* * Really core function shared with HTML parser. */ XMLPUBFUN int XMLCALL xmlCurrentChar (xmlParserCtxtPtr ctxt, int *len); XMLPUBFUN int XMLCALL xmlCopyCharMultiByte (xmlChar *out, int val); XMLPUBFUN int XMLCALL xmlCopyChar (int len, xmlChar *out, int val); XMLPUBFUN void XMLCALL xmlNextChar (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParserInputShrink (xmlParserInputPtr in); #ifdef LIBXML_HTML_ENABLED /* * Actually comes from the HTML parser but launched from the init stuff. */ XMLPUBFUN void XMLCALL htmlInitAutoClose (void); XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlCreateFileParserCtxt(const char *filename, const char *encoding); #endif /* * Specific function to keep track of entities references * and used by the XSLT debugger. */ #ifdef LIBXML_LEGACY_ENABLED /** * xmlEntityReferenceFunc: * @ent: the entity * @firstNode: the fist node in the chunk * @lastNode: the last nod in the chunk * * Callback function used when one needs to be able to track back the * provenance of a chunk of nodes inherited from an entity replacement. */ typedef void (*xmlEntityReferenceFunc) (xmlEntityPtr ent, xmlNodePtr firstNode, xmlNodePtr lastNode); XMLPUBFUN void XMLCALL xmlSetEntityReferenceFunc (xmlEntityReferenceFunc func); XMLPUBFUN xmlChar * XMLCALL xmlParseQuotedString (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParseNamespace (xmlParserCtxtPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlScanName (xmlParserCtxtPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlParserHandleReference(xmlParserCtxtPtr ctxt); XMLPUBFUN xmlChar * XMLCALL xmlNamespaceParseQName (xmlParserCtxtPtr ctxt, xmlChar **prefix); /** * Entities */ XMLPUBFUN xmlChar * XMLCALL xmlDecodeEntities (xmlParserCtxtPtr ctxt, int len, int what, xmlChar end, xmlChar end2, xmlChar end3); XMLPUBFUN void XMLCALL xmlHandleEntity (xmlParserCtxtPtr ctxt, xmlEntityPtr entity); #endif /* LIBXML_LEGACY_ENABLED */ #ifdef IN_LIBXML /* * internal only */ XMLPUBFUN void XMLCALL xmlErrMemory (xmlParserCtxtPtr ctxt, const char *extra); #endif #ifdef __cplusplus } #endif #endif /* __XML_PARSER_INTERNALS_H__ */ /* * Summary: incomplete XML Schemas structure implementation * Description: interface to the XML Schemas handling and schema validity * checking, it is incomplete right now. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_SCHEMA_H__ #define __XML_SCHEMA_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_SCHEMAS_ENABLED #include <libxml/tree.h> #ifdef __cplusplus extern "C" { #endif /** * This error codes are obsolete; not used any more. */ typedef enum { XML_SCHEMAS_ERR_OK = 0, XML_SCHEMAS_ERR_NOROOT = 1, XML_SCHEMAS_ERR_UNDECLAREDELEM, XML_SCHEMAS_ERR_NOTTOPLEVEL, XML_SCHEMAS_ERR_MISSING, XML_SCHEMAS_ERR_WRONGELEM, XML_SCHEMAS_ERR_NOTYPE, XML_SCHEMAS_ERR_NOROLLBACK, XML_SCHEMAS_ERR_ISABSTRACT, XML_SCHEMAS_ERR_NOTEMPTY, XML_SCHEMAS_ERR_ELEMCONT, XML_SCHEMAS_ERR_HAVEDEFAULT, XML_SCHEMAS_ERR_NOTNILLABLE, XML_SCHEMAS_ERR_EXTRACONTENT, XML_SCHEMAS_ERR_INVALIDATTR, XML_SCHEMAS_ERR_INVALIDELEM, XML_SCHEMAS_ERR_NOTDETERMINIST, XML_SCHEMAS_ERR_CONSTRUCT, XML_SCHEMAS_ERR_INTERNAL, XML_SCHEMAS_ERR_NOTSIMPLE, XML_SCHEMAS_ERR_ATTRUNKNOWN, XML_SCHEMAS_ERR_ATTRINVALID, XML_SCHEMAS_ERR_VALUE, XML_SCHEMAS_ERR_FACET, XML_SCHEMAS_ERR_, XML_SCHEMAS_ERR_XXX } xmlSchemaValidError; /* * ATTENTION: Change xmlSchemaSetValidOptions's check * for invalid values, if adding to the validation * options below. */ /** * xmlSchemaValidOption: * * This is the set of XML Schema validation options. */ typedef enum { XML_SCHEMA_VAL_VC_I_CREATE = 1<<0 /* Default/fixed: create an attribute node * or an element's text node on the instance. */ } xmlSchemaValidOption; /* XML_SCHEMA_VAL_XSI_ASSEMBLE = 1<<1, * assemble schemata using * xsi:schemaLocation and * xsi:noNamespaceSchemaLocation */ /** * The schemas related types are kept internal */ typedef struct _xmlSchema xmlSchema; typedef xmlSchema *xmlSchemaPtr; /** * xmlSchemaValidityErrorFunc: * @ctx: the validation context * @msg: the message * @...: extra arguments * * Signature of an error callback from an XSD validation */ typedef void (XMLCDECL *xmlSchemaValidityErrorFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); /** * xmlSchemaValidityWarningFunc: * @ctx: the validation context * @msg: the message * @...: extra arguments * * Signature of a warning callback from an XSD validation */ typedef void (XMLCDECL *xmlSchemaValidityWarningFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); /** * A schemas validation context */ typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt; typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr; typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt; typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr; /** * xmlSchemaValidityLocatorFunc: * @ctx: user provided context * @file: returned file information * @line: returned line information * * A schemas validation locator, a callback called by the validator. * This is used when file or node information are not available * to find out what file and line number are affected * * Returns: 0 in case of success and -1 in case of error */ typedef int (XMLCDECL *xmlSchemaValidityLocatorFunc) (void *ctx, const char **file, unsigned long *line); /* * Interfaces for parsing. */ XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL xmlSchemaNewParserCtxt (const char *URL); XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL xmlSchemaNewMemParserCtxt (const char *buffer, int size); XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL xmlSchemaNewDocParserCtxt (xmlDocPtr doc); XMLPUBFUN void XMLCALL xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt, xmlSchemaValidityErrorFunc err, xmlSchemaValidityWarningFunc warn, void *ctx); XMLPUBFUN void XMLCALL xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt, xmlStructuredErrorFunc serror, void *ctx); XMLPUBFUN int XMLCALL xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt, xmlSchemaValidityErrorFunc * err, xmlSchemaValidityWarningFunc * warn, void **ctx); XMLPUBFUN int XMLCALL xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt); XMLPUBFUN xmlSchemaPtr XMLCALL xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlSchemaFree (xmlSchemaPtr schema); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN void XMLCALL xmlSchemaDump (FILE *output, xmlSchemaPtr schema); #endif /* LIBXML_OUTPUT_ENABLED */ /* * Interfaces for validating */ XMLPUBFUN void XMLCALL xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt, xmlSchemaValidityErrorFunc err, xmlSchemaValidityWarningFunc warn, void *ctx); XMLPUBFUN void XMLCALL xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt, xmlStructuredErrorFunc serror, void *ctx); XMLPUBFUN int XMLCALL xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt, xmlSchemaValidityErrorFunc *err, xmlSchemaValidityWarningFunc *warn, void **ctx); XMLPUBFUN int XMLCALL xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt, int options); XMLPUBFUN void XMLCALL xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt, const char *filename); XMLPUBFUN int XMLCALL xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt); XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL xmlSchemaNewValidCtxt (xmlSchemaPtr schema); XMLPUBFUN void XMLCALL xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt, xmlDocPtr instance); XMLPUBFUN int XMLCALL xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt, xmlNodePtr elem); XMLPUBFUN int XMLCALL xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc, xmlSAXHandlerPtr sax, void *user_data); XMLPUBFUN int XMLCALL xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt, const char * filename, int options); XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt); /* * Interface to insert Schemas SAX validation in a SAX stream */ typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct; typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr; XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt, xmlSAXHandlerPtr *sax, void **user_data); XMLPUBFUN int XMLCALL xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug); XMLPUBFUN void XMLCALL xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt, xmlSchemaValidityLocatorFunc f, void *ctxt); #ifdef __cplusplus } #endif #endif /* LIBXML_SCHEMAS_ENABLED */ #endif /* __XML_SCHEMA_H__ */ /* * Summary: the XMLReader implementation * Description: API of the XML streaming API based on C# interfaces. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_XMLREADER_H__ #define __XML_XMLREADER_H__ #include <libxml/xmlversion.h> #include <libxml/tree.h> #include <libxml/xmlIO.h> #ifdef LIBXML_SCHEMAS_ENABLED #include <libxml/relaxng.h> #include <libxml/xmlschemas.h> #endif #ifdef __cplusplus extern "C" { #endif /** * xmlParserSeverities: * * How severe an error callback is when the per-reader error callback API * is used. */ typedef enum { XML_PARSER_SEVERITY_VALIDITY_WARNING = 1, XML_PARSER_SEVERITY_VALIDITY_ERROR = 2, XML_PARSER_SEVERITY_WARNING = 3, XML_PARSER_SEVERITY_ERROR = 4 } xmlParserSeverities; #ifdef LIBXML_READER_ENABLED /** * xmlTextReaderMode: * * Internal state values for the reader. */ typedef enum { XML_TEXTREADER_MODE_INITIAL = 0, XML_TEXTREADER_MODE_INTERACTIVE = 1, XML_TEXTREADER_MODE_ERROR = 2, XML_TEXTREADER_MODE_EOF =3, XML_TEXTREADER_MODE_CLOSED = 4, XML_TEXTREADER_MODE_READING = 5 } xmlTextReaderMode; /** * xmlParserProperties: * * Some common options to use with xmlTextReaderSetParserProp, but it * is better to use xmlParserOption and the xmlReaderNewxxx and * xmlReaderForxxx APIs now. */ typedef enum { XML_PARSER_LOADDTD = 1, XML_PARSER_DEFAULTATTRS = 2, XML_PARSER_VALIDATE = 3, XML_PARSER_SUBST_ENTITIES = 4 } xmlParserProperties; /** * xmlReaderTypes: * * Predefined constants for the different types of nodes. */ typedef enum { XML_READER_TYPE_NONE = 0, XML_READER_TYPE_ELEMENT = 1, XML_READER_TYPE_ATTRIBUTE = 2, XML_READER_TYPE_TEXT = 3, XML_READER_TYPE_CDATA = 4, XML_READER_TYPE_ENTITY_REFERENCE = 5, XML_READER_TYPE_ENTITY = 6, XML_READER_TYPE_PROCESSING_INSTRUCTION = 7, XML_READER_TYPE_COMMENT = 8, XML_READER_TYPE_DOCUMENT = 9, XML_READER_TYPE_DOCUMENT_TYPE = 10, XML_READER_TYPE_DOCUMENT_FRAGMENT = 11, XML_READER_TYPE_NOTATION = 12, XML_READER_TYPE_WHITESPACE = 13, XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14, XML_READER_TYPE_END_ELEMENT = 15, XML_READER_TYPE_END_ENTITY = 16, XML_READER_TYPE_XML_DECLARATION = 17 } xmlReaderTypes; /** * xmlTextReader: * * Structure for an xmlReader context. */ typedef struct _xmlTextReader xmlTextReader; /** * xmlTextReaderPtr: * * Pointer to an xmlReader context. */ typedef xmlTextReader *xmlTextReaderPtr; /* * Constructors & Destructor */ XMLPUBFUN xmlTextReaderPtr XMLCALL xmlNewTextReader (xmlParserInputBufferPtr input, const char *URI); XMLPUBFUN xmlTextReaderPtr XMLCALL xmlNewTextReaderFilename(const char *URI); XMLPUBFUN void XMLCALL xmlFreeTextReader (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderSetup(xmlTextReaderPtr reader, xmlParserInputBufferPtr input, const char *URL, const char *encoding, int options); /* * Iterators */ XMLPUBFUN int XMLCALL xmlTextReaderRead (xmlTextReaderPtr reader); #ifdef LIBXML_WRITER_ENABLED XMLPUBFUN xmlChar * XMLCALL xmlTextReaderReadInnerXml(xmlTextReaderPtr reader); XMLPUBFUN xmlChar * XMLCALL xmlTextReaderReadOuterXml(xmlTextReaderPtr reader); #endif XMLPUBFUN xmlChar * XMLCALL xmlTextReaderReadString (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader); /* * Attributes of the node */ XMLPUBFUN int XMLCALL xmlTextReaderAttributeCount(xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderDepth (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderHasAttributes(xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderHasValue(xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderIsDefault (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderNodeType (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderQuoteChar (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderReadState (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader); XMLPUBFUN const xmlChar * XMLCALL xmlTextReaderConstBaseUri (xmlTextReaderPtr reader); XMLPUBFUN const xmlChar * XMLCALL xmlTextReaderConstLocalName (xmlTextReaderPtr reader); XMLPUBFUN const xmlChar * XMLCALL xmlTextReaderConstName (xmlTextReaderPtr reader); XMLPUBFUN const xmlChar * XMLCALL xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader); XMLPUBFUN const xmlChar * XMLCALL xmlTextReaderConstPrefix (xmlTextReaderPtr reader); XMLPUBFUN const xmlChar * XMLCALL xmlTextReaderConstXmlLang (xmlTextReaderPtr reader); XMLPUBFUN const xmlChar * XMLCALL xmlTextReaderConstString (xmlTextReaderPtr reader, const xmlChar *str); XMLPUBFUN const xmlChar * XMLCALL xmlTextReaderConstValue (xmlTextReaderPtr reader); /* * use the Const version of the routine for * better performance and simpler code */ XMLPUBFUN xmlChar * XMLCALL xmlTextReaderBaseUri (xmlTextReaderPtr reader); XMLPUBFUN xmlChar * XMLCALL xmlTextReaderLocalName (xmlTextReaderPtr reader); XMLPUBFUN xmlChar * XMLCALL xmlTextReaderName (xmlTextReaderPtr reader); XMLPUBFUN xmlChar * XMLCALL xmlTextReaderNamespaceUri(xmlTextReaderPtr reader); XMLPUBFUN xmlChar * XMLCALL xmlTextReaderPrefix (xmlTextReaderPtr reader); XMLPUBFUN xmlChar * XMLCALL xmlTextReaderXmlLang (xmlTextReaderPtr reader); XMLPUBFUN xmlChar * XMLCALL xmlTextReaderValue (xmlTextReaderPtr reader); /* * Methods of the XmlTextReader */ XMLPUBFUN int XMLCALL xmlTextReaderClose (xmlTextReaderPtr reader); XMLPUBFUN xmlChar * XMLCALL xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader, int no); XMLPUBFUN xmlChar * XMLCALL xmlTextReaderGetAttribute (xmlTextReaderPtr reader, const xmlChar *name); XMLPUBFUN xmlChar * XMLCALL xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader, const xmlChar *localName, const xmlChar *namespaceURI); XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlTextReaderGetRemainder (xmlTextReaderPtr reader); XMLPUBFUN xmlChar * XMLCALL xmlTextReaderLookupNamespace(xmlTextReaderPtr reader, const xmlChar *prefix); XMLPUBFUN int XMLCALL xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader, int no); XMLPUBFUN int XMLCALL xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader, const xmlChar *name); XMLPUBFUN int XMLCALL xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader, const xmlChar *localName, const xmlChar *namespaceURI); XMLPUBFUN int XMLCALL xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderMoveToElement (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderNormalization (xmlTextReaderPtr reader); XMLPUBFUN const xmlChar * XMLCALL xmlTextReaderConstEncoding (xmlTextReaderPtr reader); /* * Extensions */ XMLPUBFUN int XMLCALL xmlTextReaderSetParserProp (xmlTextReaderPtr reader, int prop, int value); XMLPUBFUN int XMLCALL xmlTextReaderGetParserProp (xmlTextReaderPtr reader, int prop); XMLPUBFUN xmlNodePtr XMLCALL xmlTextReaderCurrentNode (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader); XMLPUBFUN xmlNodePtr XMLCALL xmlTextReaderPreserve (xmlTextReaderPtr reader); #ifdef LIBXML_PATTERN_ENABLED XMLPUBFUN int XMLCALL xmlTextReaderPreservePattern(xmlTextReaderPtr reader, const xmlChar *pattern, const xmlChar **namespaces); #endif /* LIBXML_PATTERN_ENABLED */ XMLPUBFUN xmlDocPtr XMLCALL xmlTextReaderCurrentDoc (xmlTextReaderPtr reader); XMLPUBFUN xmlNodePtr XMLCALL xmlTextReaderExpand (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderNext (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderNextSibling (xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderIsValid (xmlTextReaderPtr reader); #ifdef LIBXML_SCHEMAS_ENABLED XMLPUBFUN int XMLCALL xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng); XMLPUBFUN int XMLCALL xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader, xmlRelaxNGValidCtxtPtr ctxt, int options); XMLPUBFUN int XMLCALL xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema); XMLPUBFUN int XMLCALL xmlTextReaderSchemaValidate (xmlTextReaderPtr reader, const char *xsd); XMLPUBFUN int XMLCALL xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader, xmlSchemaValidCtxtPtr ctxt, int options); XMLPUBFUN int XMLCALL xmlTextReaderSetSchema (xmlTextReaderPtr reader, xmlSchemaPtr schema); #endif XMLPUBFUN const xmlChar * XMLCALL xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader); XMLPUBFUN int XMLCALL xmlTextReaderStandalone (xmlTextReaderPtr reader); /* * Index lookup */ XMLPUBFUN long XMLCALL xmlTextReaderByteConsumed (xmlTextReaderPtr reader); /* * New more complete APIs for simpler creation and reuse of readers */ XMLPUBFUN xmlTextReaderPtr XMLCALL xmlReaderWalker (xmlDocPtr doc); XMLPUBFUN xmlTextReaderPtr XMLCALL xmlReaderForDoc (const xmlChar * cur, const char *URL, const char *encoding, int options); XMLPUBFUN xmlTextReaderPtr XMLCALL xmlReaderForFile (const char *filename, const char *encoding, int options); XMLPUBFUN xmlTextReaderPtr XMLCALL xmlReaderForMemory (const char *buffer, int size, const char *URL, const char *encoding, int options); XMLPUBFUN xmlTextReaderPtr XMLCALL xmlReaderForFd (int fd, const char *URL, const char *encoding, int options); XMLPUBFUN xmlTextReaderPtr XMLCALL xmlReaderForIO (xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options); XMLPUBFUN int XMLCALL xmlReaderNewWalker (xmlTextReaderPtr reader, xmlDocPtr doc); XMLPUBFUN int XMLCALL xmlReaderNewDoc (xmlTextReaderPtr reader, const xmlChar * cur, const char *URL, const char *encoding, int options); XMLPUBFUN int XMLCALL xmlReaderNewFile (xmlTextReaderPtr reader, const char *filename, const char *encoding, int options); XMLPUBFUN int XMLCALL xmlReaderNewMemory (xmlTextReaderPtr reader, const char *buffer, int size, const char *URL, const char *encoding, int options); XMLPUBFUN int XMLCALL xmlReaderNewFd (xmlTextReaderPtr reader, int fd, const char *URL, const char *encoding, int options); XMLPUBFUN int XMLCALL xmlReaderNewIO (xmlTextReaderPtr reader, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options); /* * Error handling extensions */ typedef void * xmlTextReaderLocatorPtr; /** * xmlTextReaderErrorFunc: * @arg: the user argument * @msg: the message * @severity: the severity of the error * @locator: a locator indicating where the error occurred * * Signature of an error callback from a reader parser */ typedef void (XMLCALL *xmlTextReaderErrorFunc)(void *arg, const char *msg, xmlParserSeverities severity, xmlTextReaderLocatorPtr locator); XMLPUBFUN int XMLCALL xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator); XMLPUBFUN xmlChar * XMLCALL xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator); XMLPUBFUN void XMLCALL xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader, xmlTextReaderErrorFunc f, void *arg); XMLPUBFUN void XMLCALL xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader, xmlStructuredErrorFunc f, void *arg); XMLPUBFUN void XMLCALL xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader, xmlTextReaderErrorFunc *f, void **arg); #endif /* LIBXML_READER_ENABLED */ #ifdef __cplusplus } #endif #endif /* __XML_XMLREADER_H__ */ /* * Summary: macros for marking symbols as exportable/importable. * Description: macros for marking symbols as exportable/importable. * * Copy: See Copyright for the status of this software. */ #ifndef __XML_EXPORTS_H__ #define __XML_EXPORTS_H__ #if defined(_WIN32) || defined(__CYGWIN__) /** DOC_DISABLE */ #ifdef LIBXML_STATIC #define XMLPUBLIC #elif defined(IN_LIBXML) #define XMLPUBLIC __declspec(dllexport) #else #define XMLPUBLIC __declspec(dllimport) #endif #if defined(LIBXML_FASTCALL) #define XMLCALL __fastcall #else #define XMLCALL __cdecl #endif #define XMLCDECL __cdecl /** DOC_ENABLE */ #else /* not Windows */ /** * XMLPUBLIC: * * Macro which declares a public symbol */ #define XMLPUBLIC /** * XMLCALL: * * Macro which declares the calling convention for exported functions */ #define XMLCALL /** * XMLCDECL: * * Macro which declares the calling convention for exported functions that * use '...'. */ #define XMLCDECL #endif /* platform switch */ /* * XMLPUBFUN: * * Macro which declares an exportable function */ #define XMLPUBFUN XMLPUBLIC /** * XMLPUBVAR: * * Macro which declares an exportable variable */ #define XMLPUBVAR XMLPUBLIC extern /* Compatibility */ #if !defined(LIBXML_DLL_IMPORT) #define LIBXML_DLL_IMPORT XMLPUBVAR #endif #endif /* __XML_EXPORTS_H__ */ /* * Summary: Old SAX version 1 handler, deprecated * Description: DEPRECATED set of SAX version 1 interfaces used to * build the DOM tree. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_SAX_H__ #define __XML_SAX_H__ #include <stdio.h> #include <stdlib.h> #include <libxml/xmlversion.h> #include <libxml/parser.h> #include <libxml/xlink.h> #ifdef LIBXML_LEGACY_ENABLED #ifdef __cplusplus extern "C" { #endif XMLPUBFUN const xmlChar * XMLCALL getPublicId (void *ctx); XMLPUBFUN const xmlChar * XMLCALL getSystemId (void *ctx); XMLPUBFUN void XMLCALL setDocumentLocator (void *ctx, xmlSAXLocatorPtr loc); XMLPUBFUN int XMLCALL getLineNumber (void *ctx); XMLPUBFUN int XMLCALL getColumnNumber (void *ctx); XMLPUBFUN int XMLCALL isStandalone (void *ctx); XMLPUBFUN int XMLCALL hasInternalSubset (void *ctx); XMLPUBFUN int XMLCALL hasExternalSubset (void *ctx); XMLPUBFUN void XMLCALL internalSubset (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); XMLPUBFUN void XMLCALL externalSubset (void *ctx, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID); XMLPUBFUN xmlEntityPtr XMLCALL getEntity (void *ctx, const xmlChar *name); XMLPUBFUN xmlEntityPtr XMLCALL getParameterEntity (void *ctx, const xmlChar *name); XMLPUBFUN xmlParserInputPtr XMLCALL resolveEntity (void *ctx, const xmlChar *publicId, const xmlChar *systemId); XMLPUBFUN void XMLCALL entityDecl (void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content); XMLPUBFUN void XMLCALL attributeDecl (void *ctx, const xmlChar *elem, const xmlChar *fullname, int type, int def, const xmlChar *defaultValue, xmlEnumerationPtr tree); XMLPUBFUN void XMLCALL elementDecl (void *ctx, const xmlChar *name, int type, xmlElementContentPtr content); XMLPUBFUN void XMLCALL notationDecl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId); XMLPUBFUN void XMLCALL unparsedEntityDecl (void *ctx, const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId, const xmlChar *notationName); XMLPUBFUN void XMLCALL startDocument (void *ctx); XMLPUBFUN void XMLCALL endDocument (void *ctx); XMLPUBFUN void XMLCALL attribute (void *ctx, const xmlChar *fullname, const xmlChar *value); XMLPUBFUN void XMLCALL startElement (void *ctx, const xmlChar *fullname, const xmlChar **atts); XMLPUBFUN void XMLCALL endElement (void *ctx, const xmlChar *name); XMLPUBFUN void XMLCALL reference (void *ctx, const xmlChar *name); XMLPUBFUN void XMLCALL characters (void *ctx, const xmlChar *ch, int len); XMLPUBFUN void XMLCALL ignorableWhitespace (void *ctx, const xmlChar *ch, int len); XMLPUBFUN void XMLCALL processingInstruction (void *ctx, const xmlChar *target, const xmlChar *data); XMLPUBFUN void XMLCALL globalNamespace (void *ctx, const xmlChar *href, const xmlChar *prefix); XMLPUBFUN void XMLCALL setNamespace (void *ctx, const xmlChar *name); XMLPUBFUN xmlNsPtr XMLCALL getNamespace (void *ctx); XMLPUBFUN int XMLCALL checkNamespace (void *ctx, xmlChar *nameSpace); XMLPUBFUN void XMLCALL namespaceDecl (void *ctx, const xmlChar *href, const xmlChar *prefix); XMLPUBFUN void XMLCALL comment (void *ctx, const xmlChar *value); XMLPUBFUN void XMLCALL cdataBlock (void *ctx, const xmlChar *value, int len); #ifdef LIBXML_SAX1_ENABLED XMLPUBFUN void XMLCALL initxmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr, int warning); #ifdef LIBXML_HTML_ENABLED XMLPUBFUN void XMLCALL inithtmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr); #endif #ifdef LIBXML_DOCB_ENABLED XMLPUBFUN void XMLCALL initdocbDefaultSAXHandler (xmlSAXHandlerV1 *hdlr); #endif #endif /* LIBXML_SAX1_ENABLED */ #ifdef __cplusplus } #endif #endif /* LIBXML_LEGACY_ENABLED */ #endif /* __XML_SAX_H__ */ /* * Summary: interface for the memory allocator * Description: provides interfaces for the memory allocator, * including debugging capabilities. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __DEBUG_MEMORY_ALLOC__ #define __DEBUG_MEMORY_ALLOC__ #include <stdio.h> #include <libxml/xmlversion.h> /** * DEBUG_MEMORY: * * DEBUG_MEMORY replaces the allocator with a collect and debug * shell to the libc allocator. * DEBUG_MEMORY should only be activated when debugging * libxml i.e. if libxml has been configured with --with-debug-mem too. */ /* #define DEBUG_MEMORY_FREED */ /* #define DEBUG_MEMORY_LOCATION */ #ifdef DEBUG #ifndef DEBUG_MEMORY #define DEBUG_MEMORY #endif #endif /** * DEBUG_MEMORY_LOCATION: * * DEBUG_MEMORY_LOCATION should be activated only when debugging * libxml i.e. if libxml has been configured with --with-debug-mem too. */ #ifdef DEBUG_MEMORY_LOCATION #endif #ifdef __cplusplus extern "C" { #endif /* * The XML memory wrapper support 4 basic overloadable functions. */ /** * xmlFreeFunc: * @mem: an already allocated block of memory * * Signature for a free() implementation. */ typedef void (XMLCALL *xmlFreeFunc)(void *mem); /** * xmlMallocFunc: * @size: the size requested in bytes * * Signature for a malloc() implementation. * * Returns a pointer to the newly allocated block or NULL in case of error. */ typedef void *(LIBXML_ATTR_ALLOC_SIZE(1) XMLCALL *xmlMallocFunc)(size_t size); /** * xmlReallocFunc: * @mem: an already allocated block of memory * @size: the new size requested in bytes * * Signature for a realloc() implementation. * * Returns a pointer to the newly reallocated block or NULL in case of error. */ typedef void *(XMLCALL *xmlReallocFunc)(void *mem, size_t size); /** * xmlStrdupFunc: * @str: a zero terminated string * * Signature for an strdup() implementation. * * Returns the copy of the string or NULL in case of error. */ typedef char *(XMLCALL *xmlStrdupFunc)(const char *str); /* * The 4 interfaces used for all memory handling within libxml. LIBXML_DLL_IMPORT xmlFreeFunc xmlFree; LIBXML_DLL_IMPORT xmlMallocFunc xmlMalloc; LIBXML_DLL_IMPORT xmlMallocFunc xmlMallocAtomic; LIBXML_DLL_IMPORT xmlReallocFunc xmlRealloc; LIBXML_DLL_IMPORT xmlStrdupFunc xmlMemStrdup; */ /* * The way to overload the existing functions. * The xmlGc function have an extra entry for atomic block * allocations useful for garbage collected memory allocators */ XMLPUBFUN int XMLCALL xmlMemSetup (xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc, xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc); XMLPUBFUN int XMLCALL xmlMemGet (xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc, xmlReallocFunc *reallocFunc, xmlStrdupFunc *strdupFunc); XMLPUBFUN int XMLCALL xmlGcMemSetup (xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc, xmlMallocFunc mallocAtomicFunc, xmlReallocFunc reallocFunc, xmlStrdupFunc strdupFunc); XMLPUBFUN int XMLCALL xmlGcMemGet (xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc, xmlMallocFunc *mallocAtomicFunc, xmlReallocFunc *reallocFunc, xmlStrdupFunc *strdupFunc); /* * Initialization of the memory layer. */ XMLPUBFUN int XMLCALL xmlInitMemory (void); /* * Cleanup of the memory layer. */ XMLPUBFUN void XMLCALL xmlCleanupMemory (void); /* * These are specific to the XML debug memory wrapper. */ XMLPUBFUN int XMLCALL xmlMemUsed (void); XMLPUBFUN int XMLCALL xmlMemBlocks (void); XMLPUBFUN void XMLCALL xmlMemDisplay (FILE *fp); XMLPUBFUN void XMLCALL xmlMemDisplayLast(FILE *fp, long nbBytes); XMLPUBFUN void XMLCALL xmlMemShow (FILE *fp, int nr); XMLPUBFUN void XMLCALL xmlMemoryDump (void); XMLPUBFUN void * XMLCALL xmlMemMalloc (size_t size) LIBXML_ATTR_ALLOC_SIZE(1); XMLPUBFUN void * XMLCALL xmlMemRealloc (void *ptr,size_t size); XMLPUBFUN void XMLCALL xmlMemFree (void *ptr); XMLPUBFUN char * XMLCALL xmlMemoryStrdup (const char *str); XMLPUBFUN void * XMLCALL xmlMallocLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1); XMLPUBFUN void * XMLCALL xmlReallocLoc (void *ptr, size_t size, const char *file, int line); XMLPUBFUN void * XMLCALL xmlMallocAtomicLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1); XMLPUBFUN char * XMLCALL xmlMemStrdupLoc (const char *str, const char *file, int line); #ifdef DEBUG_MEMORY_LOCATION /** * xmlMalloc: * @size: number of bytes to allocate * * Wrapper for the malloc() function used in the XML library. * * Returns the pointer to the allocated area or NULL in case of error. */ #define xmlMalloc(size) xmlMallocLoc((size), __FILE__, __LINE__) /** * xmlMallocAtomic: * @size: number of bytes to allocate * * Wrapper for the malloc() function used in the XML library for allocation * of block not containing pointers to other areas. * * Returns the pointer to the allocated area or NULL in case of error. */ #define xmlMallocAtomic(size) xmlMallocAtomicLoc((size), __FILE__, __LINE__) /** * xmlRealloc: * @ptr: pointer to the existing allocated area * @size: number of bytes to allocate * * Wrapper for the realloc() function used in the XML library. * * Returns the pointer to the allocated area or NULL in case of error. */ #define xmlRealloc(ptr, size) xmlReallocLoc((ptr), (size), __FILE__, __LINE__) /** * xmlMemStrdup: * @str: pointer to the existing string * * Wrapper for the strdup() function, xmlStrdup() is usually preferred. * * Returns the pointer to the allocated area or NULL in case of error. */ #define xmlMemStrdup(str) xmlMemStrdupLoc((str), __FILE__, __LINE__) #endif /* DEBUG_MEMORY_LOCATION */ #ifdef __cplusplus } #endif /* __cplusplus */ #ifndef __XML_GLOBALS_H #ifndef __XML_THREADS_H__ #include <libxml/threads.h> #include <libxml/globals.h> #endif #endif #endif /* __DEBUG_MEMORY_ALLOC__ */ /* * Summary: text writing API for XML * Description: text writing API for XML * * Copy: See Copyright for the status of this software. * * Author: Alfred Mickautsch <alfred@mickautsch.de> */ #ifndef __XML_XMLWRITER_H__ #define __XML_XMLWRITER_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_WRITER_ENABLED #include <stdarg.h> #include <libxml/xmlIO.h> #include <libxml/list.h> #include <libxml/xmlstring.h> #ifdef __cplusplus extern "C" { #endif typedef struct _xmlTextWriter xmlTextWriter; typedef xmlTextWriter *xmlTextWriterPtr; /* * Constructors & Destructor */ XMLPUBFUN xmlTextWriterPtr XMLCALL xmlNewTextWriter(xmlOutputBufferPtr out); XMLPUBFUN xmlTextWriterPtr XMLCALL xmlNewTextWriterFilename(const char *uri, int compression); XMLPUBFUN xmlTextWriterPtr XMLCALL xmlNewTextWriterMemory(xmlBufferPtr buf, int compression); XMLPUBFUN xmlTextWriterPtr XMLCALL xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression); XMLPUBFUN xmlTextWriterPtr XMLCALL xmlNewTextWriterDoc(xmlDocPtr * doc, int compression); XMLPUBFUN xmlTextWriterPtr XMLCALL xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node, int compression); XMLPUBFUN void XMLCALL xmlFreeTextWriter(xmlTextWriterPtr writer); /* * Functions */ /* * Document */ XMLPUBFUN int XMLCALL xmlTextWriterStartDocument(xmlTextWriterPtr writer, const char *version, const char *encoding, const char *standalone); XMLPUBFUN int XMLCALL xmlTextWriterEndDocument(xmlTextWriterPtr writer); /* * Comments */ XMLPUBFUN int XMLCALL xmlTextWriterStartComment(xmlTextWriterPtr writer); XMLPUBFUN int XMLCALL xmlTextWriterEndComment(xmlTextWriterPtr writer); XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer, const char *format, ...) LIBXML_ATTR_FORMAT(2,3); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(2,0); XMLPUBFUN int XMLCALL xmlTextWriterWriteComment(xmlTextWriterPtr writer, const xmlChar * content); /* * Elements */ XMLPUBFUN int XMLCALL xmlTextWriterStartElement(xmlTextWriterPtr writer, const xmlChar * name); XMLPUBFUN int XMLCALL xmlTextWriterStartElementNS(xmlTextWriterPtr writer, const xmlChar * prefix, const xmlChar * name, const xmlChar * namespaceURI); XMLPUBFUN int XMLCALL xmlTextWriterEndElement(xmlTextWriterPtr writer); XMLPUBFUN int XMLCALL xmlTextWriterFullEndElement(xmlTextWriterPtr writer); /* * Elements conveniency functions */ XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer, const xmlChar * name, const char *format, ...) LIBXML_ATTR_FORMAT(3,4); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer, const xmlChar * name, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(3,0); XMLPUBFUN int XMLCALL xmlTextWriterWriteElement(xmlTextWriterPtr writer, const xmlChar * name, const xmlChar * content); XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer, const xmlChar * prefix, const xmlChar * name, const xmlChar * namespaceURI, const char *format, ...) LIBXML_ATTR_FORMAT(5,6); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer, const xmlChar * prefix, const xmlChar * name, const xmlChar * namespaceURI, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(5,0); XMLPUBFUN int XMLCALL xmlTextWriterWriteElementNS(xmlTextWriterPtr writer, const xmlChar * prefix, const xmlChar * name, const xmlChar * namespaceURI, const xmlChar * content); /* * Text */ XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer, const char *format, ...) LIBXML_ATTR_FORMAT(2,3); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(2,0); XMLPUBFUN int XMLCALL xmlTextWriterWriteRawLen(xmlTextWriterPtr writer, const xmlChar * content, int len); XMLPUBFUN int XMLCALL xmlTextWriterWriteRaw(xmlTextWriterPtr writer, const xmlChar * content); XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatString(xmlTextWriterPtr writer, const char *format, ...) LIBXML_ATTR_FORMAT(2,3); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatString(xmlTextWriterPtr writer, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(2,0); XMLPUBFUN int XMLCALL xmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar * content); XMLPUBFUN int XMLCALL xmlTextWriterWriteBase64(xmlTextWriterPtr writer, const char *data, int start, int len); XMLPUBFUN int XMLCALL xmlTextWriterWriteBinHex(xmlTextWriterPtr writer, const char *data, int start, int len); /* * Attributes */ XMLPUBFUN int XMLCALL xmlTextWriterStartAttribute(xmlTextWriterPtr writer, const xmlChar * name); XMLPUBFUN int XMLCALL xmlTextWriterStartAttributeNS(xmlTextWriterPtr writer, const xmlChar * prefix, const xmlChar * name, const xmlChar * namespaceURI); XMLPUBFUN int XMLCALL xmlTextWriterEndAttribute(xmlTextWriterPtr writer); /* * Attributes conveniency functions */ XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer, const xmlChar * name, const char *format, ...) LIBXML_ATTR_FORMAT(3,4); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer, const xmlChar * name, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(3,0); XMLPUBFUN int XMLCALL xmlTextWriterWriteAttribute(xmlTextWriterPtr writer, const xmlChar * name, const xmlChar * content); XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer, const xmlChar * prefix, const xmlChar * name, const xmlChar * namespaceURI, const char *format, ...) LIBXML_ATTR_FORMAT(5,6); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer, const xmlChar * prefix, const xmlChar * name, const xmlChar * namespaceURI, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(5,0); XMLPUBFUN int XMLCALL xmlTextWriterWriteAttributeNS(xmlTextWriterPtr writer, const xmlChar * prefix, const xmlChar * name, const xmlChar * namespaceURI, const xmlChar * content); /* * PI's */ XMLPUBFUN int XMLCALL xmlTextWriterStartPI(xmlTextWriterPtr writer, const xmlChar * target); XMLPUBFUN int XMLCALL xmlTextWriterEndPI(xmlTextWriterPtr writer); /* * PI conveniency functions */ XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer, const xmlChar * target, const char *format, ...) LIBXML_ATTR_FORMAT(3,4); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer, const xmlChar * target, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(3,0); XMLPUBFUN int XMLCALL xmlTextWriterWritePI(xmlTextWriterPtr writer, const xmlChar * target, const xmlChar * content); /** * xmlTextWriterWriteProcessingInstruction: * * This macro maps to xmlTextWriterWritePI */ #define xmlTextWriterWriteProcessingInstruction xmlTextWriterWritePI /* * CDATA */ XMLPUBFUN int XMLCALL xmlTextWriterStartCDATA(xmlTextWriterPtr writer); XMLPUBFUN int XMLCALL xmlTextWriterEndCDATA(xmlTextWriterPtr writer); /* * CDATA conveniency functions */ XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer, const char *format, ...) LIBXML_ATTR_FORMAT(2,3); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(2,0); XMLPUBFUN int XMLCALL xmlTextWriterWriteCDATA(xmlTextWriterPtr writer, const xmlChar * content); /* * DTD */ XMLPUBFUN int XMLCALL xmlTextWriterStartDTD(xmlTextWriterPtr writer, const xmlChar * name, const xmlChar * pubid, const xmlChar * sysid); XMLPUBFUN int XMLCALL xmlTextWriterEndDTD(xmlTextWriterPtr writer); /* * DTD conveniency functions */ XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer, const xmlChar * name, const xmlChar * pubid, const xmlChar * sysid, const char *format, ...) LIBXML_ATTR_FORMAT(5,6); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer, const xmlChar * name, const xmlChar * pubid, const xmlChar * sysid, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(5,0); XMLPUBFUN int XMLCALL xmlTextWriterWriteDTD(xmlTextWriterPtr writer, const xmlChar * name, const xmlChar * pubid, const xmlChar * sysid, const xmlChar * subset); /** * xmlTextWriterWriteDocType: * * this macro maps to xmlTextWriterWriteDTD */ #define xmlTextWriterWriteDocType xmlTextWriterWriteDTD /* * DTD element definition */ XMLPUBFUN int XMLCALL xmlTextWriterStartDTDElement(xmlTextWriterPtr writer, const xmlChar * name); XMLPUBFUN int XMLCALL xmlTextWriterEndDTDElement(xmlTextWriterPtr writer); /* * DTD element definition conveniency functions */ XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer, const xmlChar * name, const char *format, ...) LIBXML_ATTR_FORMAT(3,4); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer, const xmlChar * name, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(3,0); XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDElement(xmlTextWriterPtr writer, const xmlChar * name, const xmlChar * content); /* * DTD attribute list definition */ XMLPUBFUN int XMLCALL xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer, const xmlChar * name); XMLPUBFUN int XMLCALL xmlTextWriterEndDTDAttlist(xmlTextWriterPtr writer); /* * DTD attribute list definition conveniency functions */ XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer, const xmlChar * name, const char *format, ...) LIBXML_ATTR_FORMAT(3,4); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer, const xmlChar * name, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(3,0); XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr writer, const xmlChar * name, const xmlChar * content); /* * DTD entity definition */ XMLPUBFUN int XMLCALL xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer, int pe, const xmlChar * name); XMLPUBFUN int XMLCALL xmlTextWriterEndDTDEntity(xmlTextWriterPtr writer); /* * DTD entity definition conveniency functions */ XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer, int pe, const xmlChar * name, const char *format, ...) LIBXML_ATTR_FORMAT(4,5); XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer, int pe, const xmlChar * name, const char *format, va_list argptr) LIBXML_ATTR_FORMAT(4,0); XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer, int pe, const xmlChar * name, const xmlChar * content); XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer, int pe, const xmlChar * name, const xmlChar * pubid, const xmlChar * sysid, const xmlChar * ndataid); XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr writer, const xmlChar * pubid, const xmlChar * sysid, const xmlChar * ndataid); XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDEntity(xmlTextWriterPtr writer, int pe, const xmlChar * name, const xmlChar * pubid, const xmlChar * sysid, const xmlChar * ndataid, const xmlChar * content); /* * DTD notation definition */ XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer, const xmlChar * name, const xmlChar * pubid, const xmlChar * sysid); /* * Indentation */ XMLPUBFUN int XMLCALL xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent); XMLPUBFUN int XMLCALL xmlTextWriterSetIndentString(xmlTextWriterPtr writer, const xmlChar * str); XMLPUBFUN int XMLCALL xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar); /* * misc */ XMLPUBFUN int XMLCALL xmlTextWriterFlush(xmlTextWriterPtr writer); #ifdef __cplusplus } #endif #endif /* LIBXML_WRITER_ENABLED */ #endif /* __XML_XMLWRITER_H__ */ /* * Summary: minimal FTP implementation * Description: minimal FTP implementation allowing to fetch resources * like external subset. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __NANO_FTP_H__ #define __NANO_FTP_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_FTP_ENABLED /* Needed for portability to Windows 64 bits */ #if defined(_WIN32) && !defined(__CYGWIN__) #include <winsock2.h> #else /** * SOCKET: * * macro used to provide portability of code to windows sockets */ #define SOCKET int /** * INVALID_SOCKET: * * macro used to provide portability of code to windows sockets * the value to be used when the socket is not valid */ #undef INVALID_SOCKET #define INVALID_SOCKET (-1) #endif #ifdef __cplusplus extern "C" { #endif /** * ftpListCallback: * @userData: user provided data for the callback * @filename: the file name (including "->" when links are shown) * @attrib: the attribute string * @owner: the owner string * @group: the group string * @size: the file size * @links: the link count * @year: the year * @month: the month * @day: the day * @hour: the hour * @minute: the minute * * A callback for the xmlNanoFTPList command. * Note that only one of year and day:minute are specified. */ typedef void (*ftpListCallback) (void *userData, const char *filename, const char *attrib, const char *owner, const char *group, unsigned long size, int links, int year, const char *month, int day, int hour, int minute); /** * ftpDataCallback: * @userData: the user provided context * @data: the data received * @len: its size in bytes * * A callback for the xmlNanoFTPGet command. */ typedef void (*ftpDataCallback) (void *userData, const char *data, int len); /* * Init */ XMLPUBFUN void XMLCALL xmlNanoFTPInit (void); XMLPUBFUN void XMLCALL xmlNanoFTPCleanup (void); /* * Creating/freeing contexts. */ XMLPUBFUN void * XMLCALL xmlNanoFTPNewCtxt (const char *URL); XMLPUBFUN void XMLCALL xmlNanoFTPFreeCtxt (void * ctx); XMLPUBFUN void * XMLCALL xmlNanoFTPConnectTo (const char *server, int port); /* * Opening/closing session connections. */ XMLPUBFUN void * XMLCALL xmlNanoFTPOpen (const char *URL); XMLPUBFUN int XMLCALL xmlNanoFTPConnect (void *ctx); XMLPUBFUN int XMLCALL xmlNanoFTPClose (void *ctx); XMLPUBFUN int XMLCALL xmlNanoFTPQuit (void *ctx); XMLPUBFUN void XMLCALL xmlNanoFTPScanProxy (const char *URL); XMLPUBFUN void XMLCALL xmlNanoFTPProxy (const char *host, int port, const char *user, const char *passwd, int type); XMLPUBFUN int XMLCALL xmlNanoFTPUpdateURL (void *ctx, const char *URL); /* * Rather internal commands. */ XMLPUBFUN int XMLCALL xmlNanoFTPGetResponse (void *ctx); XMLPUBFUN int XMLCALL xmlNanoFTPCheckResponse (void *ctx); /* * CD/DIR/GET handlers. */ XMLPUBFUN int XMLCALL xmlNanoFTPCwd (void *ctx, const char *directory); XMLPUBFUN int XMLCALL xmlNanoFTPDele (void *ctx, const char *file); XMLPUBFUN SOCKET XMLCALL xmlNanoFTPGetConnection (void *ctx); XMLPUBFUN int XMLCALL xmlNanoFTPCloseConnection(void *ctx); XMLPUBFUN int XMLCALL xmlNanoFTPList (void *ctx, ftpListCallback callback, void *userData, const char *filename); XMLPUBFUN SOCKET XMLCALL xmlNanoFTPGetSocket (void *ctx, const char *filename); XMLPUBFUN int XMLCALL xmlNanoFTPGet (void *ctx, ftpDataCallback callback, void *userData, const char *filename); XMLPUBFUN int XMLCALL xmlNanoFTPRead (void *ctx, void *dest, int len); #ifdef __cplusplus } #endif #endif /* LIBXML_FTP_ENABLED */ #endif /* __NANO_FTP_H__ */ /* * Summary: regular expressions handling * Description: basic API for libxml regular expressions handling used * for XML Schemas and validation. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_REGEXP_H__ #define __XML_REGEXP_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_REGEXP_ENABLED #ifdef __cplusplus extern "C" { #endif /** * xmlRegexpPtr: * * A libxml regular expression, they can actually be far more complex * thank the POSIX regex expressions. */ typedef struct _xmlRegexp xmlRegexp; typedef xmlRegexp *xmlRegexpPtr; /** * xmlRegExecCtxtPtr: * * A libxml progressive regular expression evaluation context */ typedef struct _xmlRegExecCtxt xmlRegExecCtxt; typedef xmlRegExecCtxt *xmlRegExecCtxtPtr; #ifdef __cplusplus } #endif #include <libxml/tree.h> #include <libxml/dict.h> #ifdef __cplusplus extern "C" { #endif /* * The POSIX like API */ XMLPUBFUN xmlRegexpPtr XMLCALL xmlRegexpCompile (const xmlChar *regexp); XMLPUBFUN void XMLCALL xmlRegFreeRegexp(xmlRegexpPtr regexp); XMLPUBFUN int XMLCALL xmlRegexpExec (xmlRegexpPtr comp, const xmlChar *value); XMLPUBFUN void XMLCALL xmlRegexpPrint (FILE *output, xmlRegexpPtr regexp); XMLPUBFUN int XMLCALL xmlRegexpIsDeterminist(xmlRegexpPtr comp); /** * xmlRegExecCallbacks: * @exec: the regular expression context * @token: the current token string * @transdata: transition data * @inputdata: input data * * Callback function when doing a transition in the automata */ typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec, const xmlChar *token, void *transdata, void *inputdata); /* * The progressive API */ XMLPUBFUN xmlRegExecCtxtPtr XMLCALL xmlRegNewExecCtxt (xmlRegexpPtr comp, xmlRegExecCallbacks callback, void *data); XMLPUBFUN void XMLCALL xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec); XMLPUBFUN int XMLCALL xmlRegExecPushString(xmlRegExecCtxtPtr exec, const xmlChar *value, void *data); XMLPUBFUN int XMLCALL xmlRegExecPushString2(xmlRegExecCtxtPtr exec, const xmlChar *value, const xmlChar *value2, void *data); XMLPUBFUN int XMLCALL xmlRegExecNextValues(xmlRegExecCtxtPtr exec, int *nbval, int *nbneg, xmlChar **values, int *terminal); XMLPUBFUN int XMLCALL xmlRegExecErrInfo (xmlRegExecCtxtPtr exec, const xmlChar **string, int *nbval, int *nbneg, xmlChar **values, int *terminal); #ifdef LIBXML_EXPR_ENABLED /* * Formal regular expression handling * Its goal is to do some formal work on content models */ /* expressions are used within a context */ typedef struct _xmlExpCtxt xmlExpCtxt; typedef xmlExpCtxt *xmlExpCtxtPtr; XMLPUBFUN void XMLCALL xmlExpFreeCtxt (xmlExpCtxtPtr ctxt); XMLPUBFUN xmlExpCtxtPtr XMLCALL xmlExpNewCtxt (int maxNodes, xmlDictPtr dict); XMLPUBFUN int XMLCALL xmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlExpCtxtNbCons(xmlExpCtxtPtr ctxt); /* Expressions are trees but the tree is opaque */ typedef struct _xmlExpNode xmlExpNode; typedef xmlExpNode *xmlExpNodePtr; typedef enum { XML_EXP_EMPTY = 0, XML_EXP_FORBID = 1, XML_EXP_ATOM = 2, XML_EXP_SEQ = 3, XML_EXP_OR = 4, XML_EXP_COUNT = 5 } xmlExpNodeType; /* * 2 core expressions shared by all for the empty language set * and for the set with just the empty token */ XMLPUBVAR xmlExpNodePtr forbiddenExp; XMLPUBVAR xmlExpNodePtr emptyExp; /* * Expressions are reference counted internally */ XMLPUBFUN void XMLCALL xmlExpFree (xmlExpCtxtPtr ctxt, xmlExpNodePtr expr); XMLPUBFUN void XMLCALL xmlExpRef (xmlExpNodePtr expr); /* * constructors can be either manual or from a string */ XMLPUBFUN xmlExpNodePtr XMLCALL xmlExpParse (xmlExpCtxtPtr ctxt, const char *expr); XMLPUBFUN xmlExpNodePtr XMLCALL xmlExpNewAtom (xmlExpCtxtPtr ctxt, const xmlChar *name, int len); XMLPUBFUN xmlExpNodePtr XMLCALL xmlExpNewOr (xmlExpCtxtPtr ctxt, xmlExpNodePtr left, xmlExpNodePtr right); XMLPUBFUN xmlExpNodePtr XMLCALL xmlExpNewSeq (xmlExpCtxtPtr ctxt, xmlExpNodePtr left, xmlExpNodePtr right); XMLPUBFUN xmlExpNodePtr XMLCALL xmlExpNewRange (xmlExpCtxtPtr ctxt, xmlExpNodePtr subset, int min, int max); /* * The really interesting APIs */ XMLPUBFUN int XMLCALL xmlExpIsNillable(xmlExpNodePtr expr); XMLPUBFUN int XMLCALL xmlExpMaxToken (xmlExpNodePtr expr); XMLPUBFUN int XMLCALL xmlExpGetLanguage(xmlExpCtxtPtr ctxt, xmlExpNodePtr expr, const xmlChar**langList, int len); XMLPUBFUN int XMLCALL xmlExpGetStart (xmlExpCtxtPtr ctxt, xmlExpNodePtr expr, const xmlChar**tokList, int len); XMLPUBFUN xmlExpNodePtr XMLCALL xmlExpStringDerive(xmlExpCtxtPtr ctxt, xmlExpNodePtr expr, const xmlChar *str, int len); XMLPUBFUN xmlExpNodePtr XMLCALL xmlExpExpDerive (xmlExpCtxtPtr ctxt, xmlExpNodePtr expr, xmlExpNodePtr sub); XMLPUBFUN int XMLCALL xmlExpSubsume (xmlExpCtxtPtr ctxt, xmlExpNodePtr expr, xmlExpNodePtr sub); XMLPUBFUN void XMLCALL xmlExpDump (xmlBufferPtr buf, xmlExpNodePtr expr); #endif /* LIBXML_EXPR_ENABLED */ #ifdef __cplusplus } #endif #endif /* LIBXML_REGEXP_ENABLED */ #endif /*__XML_REGEXP_H__ */ /* * Summary: set of routines to process strings * Description: type and interfaces needed for the internal string handling * of the library, especially UTF8 processing. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_STRING_H__ #define __XML_STRING_H__ #include <stdarg.h> #include <libxml/xmlversion.h> #ifdef __cplusplus extern "C" { #endif /** * xmlChar: * * This is a basic byte in an UTF-8 encoded string. * It's unsigned allowing to pinpoint case where char * are assigned * to xmlChar * (possibly making serialization back impossible). */ typedef unsigned char xmlChar; /** * BAD_CAST: * * Macro to cast a string to an xmlChar * when one know its safe. */ #define BAD_CAST (xmlChar *) /* * xmlChar handling */ XMLPUBFUN xmlChar * XMLCALL xmlStrdup (const xmlChar *cur); XMLPUBFUN xmlChar * XMLCALL xmlStrndup (const xmlChar *cur, int len); XMLPUBFUN xmlChar * XMLCALL xmlCharStrndup (const char *cur, int len); XMLPUBFUN xmlChar * XMLCALL xmlCharStrdup (const char *cur); XMLPUBFUN xmlChar * XMLCALL xmlStrsub (const xmlChar *str, int start, int len); XMLPUBFUN const xmlChar * XMLCALL xmlStrchr (const xmlChar *str, xmlChar val); XMLPUBFUN const xmlChar * XMLCALL xmlStrstr (const xmlChar *str, const xmlChar *val); XMLPUBFUN const xmlChar * XMLCALL xmlStrcasestr (const xmlChar *str, const xmlChar *val); XMLPUBFUN int XMLCALL xmlStrcmp (const xmlChar *str1, const xmlChar *str2); XMLPUBFUN int XMLCALL xmlStrncmp (const xmlChar *str1, const xmlChar *str2, int len); XMLPUBFUN int XMLCALL xmlStrcasecmp (const xmlChar *str1, const xmlChar *str2); XMLPUBFUN int XMLCALL xmlStrncasecmp (const xmlChar *str1, const xmlChar *str2, int len); XMLPUBFUN int XMLCALL xmlStrEqual (const xmlChar *str1, const xmlChar *str2); XMLPUBFUN int XMLCALL xmlStrQEqual (const xmlChar *pref, const xmlChar *name, const xmlChar *str); XMLPUBFUN int XMLCALL xmlStrlen (const xmlChar *str); XMLPUBFUN xmlChar * XMLCALL xmlStrcat (xmlChar *cur, const xmlChar *add); XMLPUBFUN xmlChar * XMLCALL xmlStrncat (xmlChar *cur, const xmlChar *add, int len); XMLPUBFUN xmlChar * XMLCALL xmlStrncatNew (const xmlChar *str1, const xmlChar *str2, int len); XMLPUBFUN int XMLCALL xmlStrPrintf (xmlChar *buf, int len, const char *msg, ...) LIBXML_ATTR_FORMAT(3,4); XMLPUBFUN int XMLCALL xmlStrVPrintf (xmlChar *buf, int len, const char *msg, va_list ap) LIBXML_ATTR_FORMAT(3,0); XMLPUBFUN int XMLCALL xmlGetUTF8Char (const unsigned char *utf, int *len); XMLPUBFUN int XMLCALL xmlCheckUTF8 (const unsigned char *utf); XMLPUBFUN int XMLCALL xmlUTF8Strsize (const xmlChar *utf, int len); XMLPUBFUN xmlChar * XMLCALL xmlUTF8Strndup (const xmlChar *utf, int len); XMLPUBFUN const xmlChar * XMLCALL xmlUTF8Strpos (const xmlChar *utf, int pos); XMLPUBFUN int XMLCALL xmlUTF8Strloc (const xmlChar *utf, const xmlChar *utfchar); XMLPUBFUN xmlChar * XMLCALL xmlUTF8Strsub (const xmlChar *utf, int start, int len); XMLPUBFUN int XMLCALL xmlUTF8Strlen (const xmlChar *utf); XMLPUBFUN int XMLCALL xmlUTF8Size (const xmlChar *utf); XMLPUBFUN int XMLCALL xmlUTF8Charcmp (const xmlChar *utf1, const xmlChar *utf2); #ifdef __cplusplus } #endif #endif /* __XML_STRING_H__ */ /* * Summary: the XML document serializer * Description: API to save document or subtree of document * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_XMLSAVE_H__ #define __XML_XMLSAVE_H__ #include <libxml/xmlversion.h> #include <libxml/tree.h> #include <libxml/encoding.h> #include <libxml/xmlIO.h> #ifdef LIBXML_OUTPUT_ENABLED #ifdef __cplusplus extern "C" { #endif /** * xmlSaveOption: * * This is the set of XML save options that can be passed down * to the xmlSaveToFd() and similar calls. */ typedef enum { XML_SAVE_FORMAT = 1<<0, /* format save output */ XML_SAVE_NO_DECL = 1<<1, /* drop the xml declaration */ XML_SAVE_NO_EMPTY = 1<<2, /* no empty tags */ XML_SAVE_NO_XHTML = 1<<3, /* disable XHTML1 specific rules */ XML_SAVE_XHTML = 1<<4, /* force XHTML1 specific rules */ XML_SAVE_AS_XML = 1<<5, /* force XML serialization on HTML doc */ XML_SAVE_AS_HTML = 1<<6, /* force HTML serialization on XML doc */ XML_SAVE_WSNONSIG = 1<<7 /* format with non-significant whitespace */ } xmlSaveOption; typedef struct _xmlSaveCtxt xmlSaveCtxt; typedef xmlSaveCtxt *xmlSaveCtxtPtr; XMLPUBFUN xmlSaveCtxtPtr XMLCALL xmlSaveToFd (int fd, const char *encoding, int options); XMLPUBFUN xmlSaveCtxtPtr XMLCALL xmlSaveToFilename (const char *filename, const char *encoding, int options); XMLPUBFUN xmlSaveCtxtPtr XMLCALL xmlSaveToBuffer (xmlBufferPtr buffer, const char *encoding, int options); XMLPUBFUN xmlSaveCtxtPtr XMLCALL xmlSaveToIO (xmlOutputWriteCallback iowrite, xmlOutputCloseCallback ioclose, void *ioctx, const char *encoding, int options); XMLPUBFUN long XMLCALL xmlSaveDoc (xmlSaveCtxtPtr ctxt, xmlDocPtr doc); XMLPUBFUN long XMLCALL xmlSaveTree (xmlSaveCtxtPtr ctxt, xmlNodePtr node); XMLPUBFUN int XMLCALL xmlSaveFlush (xmlSaveCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlSaveClose (xmlSaveCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlSaveSetEscape (xmlSaveCtxtPtr ctxt, xmlCharEncodingOutputFunc escape); XMLPUBFUN int XMLCALL xmlSaveSetAttrEscape (xmlSaveCtxtPtr ctxt, xmlCharEncodingOutputFunc escape); #ifdef __cplusplus } #endif #endif /* LIBXML_OUTPUT_ENABLED */ #endif /* __XML_XMLSAVE_H__ */ /* * Summary: XML Path Language implementation * Description: API for the XML Path Language implementation * * XML Path Language implementation * XPath is a language for addressing parts of an XML document, * designed to be used by both XSLT and XPointer * http://www.w3.org/TR/xpath * * Implements * W3C Recommendation 16 November 1999 * http://www.w3.org/TR/1999/REC-xpath-19991116 * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_XPATH_H__ #define __XML_XPATH_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_XPATH_ENABLED #include <libxml/xmlerror.h> #include <libxml/tree.h> #include <libxml/hash.h> #endif /* LIBXML_XPATH_ENABLED */ #if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) #ifdef __cplusplus extern "C" { #endif #endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED */ #ifdef LIBXML_XPATH_ENABLED typedef struct _xmlXPathContext xmlXPathContext; typedef xmlXPathContext *xmlXPathContextPtr; typedef struct _xmlXPathParserContext xmlXPathParserContext; typedef xmlXPathParserContext *xmlXPathParserContextPtr; /** * The set of XPath error codes. */ typedef enum { XPATH_EXPRESSION_OK = 0, XPATH_NUMBER_ERROR, XPATH_UNFINISHED_LITERAL_ERROR, XPATH_START_LITERAL_ERROR, XPATH_VARIABLE_REF_ERROR, XPATH_UNDEF_VARIABLE_ERROR, XPATH_INVALID_PREDICATE_ERROR, XPATH_EXPR_ERROR, XPATH_UNCLOSED_ERROR, XPATH_UNKNOWN_FUNC_ERROR, XPATH_INVALID_OPERAND, XPATH_INVALID_TYPE, XPATH_INVALID_ARITY, XPATH_INVALID_CTXT_SIZE, XPATH_INVALID_CTXT_POSITION, XPATH_MEMORY_ERROR, XPTR_SYNTAX_ERROR, XPTR_RESOURCE_ERROR, XPTR_SUB_RESOURCE_ERROR, XPATH_UNDEF_PREFIX_ERROR, XPATH_ENCODING_ERROR, XPATH_INVALID_CHAR_ERROR, XPATH_INVALID_CTXT, XPATH_STACK_ERROR, XPATH_FORBID_VARIABLE_ERROR, XPATH_OP_LIMIT_EXCEEDED, XPATH_RECURSION_LIMIT_EXCEEDED } xmlXPathError; /* * A node-set (an unordered collection of nodes without duplicates). */ typedef struct _xmlNodeSet xmlNodeSet; typedef xmlNodeSet *xmlNodeSetPtr; struct _xmlNodeSet { int nodeNr; /* number of nodes in the set */ int nodeMax; /* size of the array as allocated */ xmlNodePtr *nodeTab; /* array of nodes in no particular order */ /* @@ with_ns to check whether namespace nodes should be looked at @@ */ }; /* * An expression is evaluated to yield an object, which * has one of the following four basic types: * - node-set * - boolean * - number * - string * * @@ XPointer will add more types ! */ typedef enum { XPATH_UNDEFINED = 0, XPATH_NODESET = 1, XPATH_BOOLEAN = 2, XPATH_NUMBER = 3, XPATH_STRING = 4, XPATH_POINT = 5, XPATH_RANGE = 6, XPATH_LOCATIONSET = 7, XPATH_USERS = 8, XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */ } xmlXPathObjectType; typedef struct _xmlXPathObject xmlXPathObject; typedef xmlXPathObject *xmlXPathObjectPtr; struct _xmlXPathObject { xmlXPathObjectType type; xmlNodeSetPtr nodesetval; int boolval; double floatval; xmlChar *stringval; void *user; int index; void *user2; int index2; }; /** * xmlXPathConvertFunc: * @obj: an XPath object * @type: the number of the target type * * A conversion function is associated to a type and used to cast * the new type to primitive values. * * Returns -1 in case of error, 0 otherwise */ typedef int (*xmlXPathConvertFunc) (xmlXPathObjectPtr obj, int type); /* * Extra type: a name and a conversion function. */ typedef struct _xmlXPathType xmlXPathType; typedef xmlXPathType *xmlXPathTypePtr; struct _xmlXPathType { const xmlChar *name; /* the type name */ xmlXPathConvertFunc func; /* the conversion function */ }; /* * Extra variable: a name and a value. */ typedef struct _xmlXPathVariable xmlXPathVariable; typedef xmlXPathVariable *xmlXPathVariablePtr; struct _xmlXPathVariable { const xmlChar *name; /* the variable name */ xmlXPathObjectPtr value; /* the value */ }; /** * xmlXPathEvalFunc: * @ctxt: an XPath parser context * @nargs: the number of arguments passed to the function * * An XPath evaluation function, the parameters are on the XPath context stack. */ typedef void (*xmlXPathEvalFunc)(xmlXPathParserContextPtr ctxt, int nargs); /* * Extra function: a name and a evaluation function. */ typedef struct _xmlXPathFunct xmlXPathFunct; typedef xmlXPathFunct *xmlXPathFuncPtr; struct _xmlXPathFunct { const xmlChar *name; /* the function name */ xmlXPathEvalFunc func; /* the evaluation function */ }; /** * xmlXPathAxisFunc: * @ctxt: the XPath interpreter context * @cur: the previous node being explored on that axis * * An axis traversal function. To traverse an axis, the engine calls * the first time with cur == NULL and repeat until the function returns * NULL indicating the end of the axis traversal. * * Returns the next node in that axis or NULL if at the end of the axis. */ typedef xmlXPathObjectPtr (*xmlXPathAxisFunc) (xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr cur); /* * Extra axis: a name and an axis function. */ typedef struct _xmlXPathAxis xmlXPathAxis; typedef xmlXPathAxis *xmlXPathAxisPtr; struct _xmlXPathAxis { const xmlChar *name; /* the axis name */ xmlXPathAxisFunc func; /* the search function */ }; /** * xmlXPathFunction: * @ctxt: the XPath interprestation context * @nargs: the number of arguments * * An XPath function. * The arguments (if any) are popped out from the context stack * and the result is pushed on the stack. */ typedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs); /* * Function and Variable Lookup. */ /** * xmlXPathVariableLookupFunc: * @ctxt: an XPath context * @name: name of the variable * @ns_uri: the namespace name hosting this variable * * Prototype for callbacks used to plug variable lookup in the XPath * engine. * * Returns the XPath object value or NULL if not found. */ typedef xmlXPathObjectPtr (*xmlXPathVariableLookupFunc) (void *ctxt, const xmlChar *name, const xmlChar *ns_uri); /** * xmlXPathFuncLookupFunc: * @ctxt: an XPath context * @name: name of the function * @ns_uri: the namespace name hosting this function * * Prototype for callbacks used to plug function lookup in the XPath * engine. * * Returns the XPath function or NULL if not found. */ typedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt, const xmlChar *name, const xmlChar *ns_uri); /** * xmlXPathFlags: * Flags for XPath engine compilation and runtime */ /** * XML_XPATH_CHECKNS: * * check namespaces at compilation */ #define XML_XPATH_CHECKNS (1<<0) /** * XML_XPATH_NOVAR: * * forbid variables in expression */ #define XML_XPATH_NOVAR (1<<1) /** * xmlXPathContext: * * Expression evaluation occurs with respect to a context. * he context consists of: * - a node (the context node) * - a node list (the context node list) * - a set of variable bindings * - a function library * - the set of namespace declarations in scope for the expression * Following the switch to hash tables, this need to be trimmed up at * the next binary incompatible release. * The node may be modified when the context is passed to libxml2 * for an XPath evaluation so you may need to initialize it again * before the next call. */ struct _xmlXPathContext { xmlDocPtr doc; /* The current document */ xmlNodePtr node; /* The current node */ int nb_variables_unused; /* unused (hash table) */ int max_variables_unused; /* unused (hash table) */ xmlHashTablePtr varHash; /* Hash table of defined variables */ int nb_types; /* number of defined types */ int max_types; /* max number of types */ xmlXPathTypePtr types; /* Array of defined types */ int nb_funcs_unused; /* unused (hash table) */ int max_funcs_unused; /* unused (hash table) */ xmlHashTablePtr funcHash; /* Hash table of defined funcs */ int nb_axis; /* number of defined axis */ int max_axis; /* max number of axis */ xmlXPathAxisPtr axis; /* Array of defined axis */ /* the namespace nodes of the context node */ xmlNsPtr *namespaces; /* Array of namespaces */ int nsNr; /* number of namespace in scope */ void *user; /* function to free */ /* extra variables */ int contextSize; /* the context size */ int proximityPosition; /* the proximity position */ /* extra stuff for XPointer */ int xptr; /* is this an XPointer context? */ xmlNodePtr here; /* for here() */ xmlNodePtr origin; /* for origin() */ /* the set of namespace declarations in scope for the expression */ xmlHashTablePtr nsHash; /* The namespaces hash table */ xmlXPathVariableLookupFunc varLookupFunc;/* variable lookup func */ void *varLookupData; /* variable lookup data */ /* Possibility to link in an extra item */ void *extra; /* needed for XSLT */ /* The function name and URI when calling a function */ const xmlChar *function; const xmlChar *functionURI; /* function lookup function and data */ xmlXPathFuncLookupFunc funcLookupFunc;/* function lookup func */ void *funcLookupData; /* function lookup data */ /* temporary namespace lists kept for walking the namespace axis */ xmlNsPtr *tmpNsList; /* Array of namespaces */ int tmpNsNr; /* number of namespaces in scope */ /* error reporting mechanism */ void *userData; /* user specific data block */ xmlStructuredErrorFunc error; /* the callback in case of errors */ xmlError lastError; /* the last error */ xmlNodePtr debugNode; /* the source node XSLT */ /* dictionary */ xmlDictPtr dict; /* dictionary if any */ int flags; /* flags to control compilation */ /* Cache for reusal of XPath objects */ void *cache; /* Resource limits */ unsigned long opLimit; unsigned long opCount; int depth; }; /* * The structure of a compiled expression form is not public. */ typedef struct _xmlXPathCompExpr xmlXPathCompExpr; typedef xmlXPathCompExpr *xmlXPathCompExprPtr; /** * xmlXPathParserContext: * * An XPath parser context. It contains pure parsing information, * an xmlXPathContext, and the stack of objects. */ struct _xmlXPathParserContext { const xmlChar *cur; /* the current char being parsed */ const xmlChar *base; /* the full expression */ int error; /* error code */ xmlXPathContextPtr context; /* the evaluation context */ xmlXPathObjectPtr value; /* the current value */ int valueNr; /* number of values stacked */ int valueMax; /* max number of values stacked */ xmlXPathObjectPtr *valueTab; /* stack of values */ xmlXPathCompExprPtr comp; /* the precompiled expression */ int xptr; /* it this an XPointer expression */ xmlNodePtr ancestor; /* used for walking preceding axis */ int valueFrame; /* used to limit Pop on the stack */ }; /************************************************************************ * * * Public API * * * ************************************************************************/ /** * Objects and Nodesets handling */ XMLPUBVAR double xmlXPathNAN; XMLPUBVAR double xmlXPathPINF; XMLPUBVAR double xmlXPathNINF; /* These macros may later turn into functions */ /** * xmlXPathNodeSetGetLength: * @ns: a node-set * * Implement a functionality similar to the DOM NodeList.length. * * Returns the number of nodes in the node-set. */ #define xmlXPathNodeSetGetLength(ns) ((ns) ? (ns)->nodeNr : 0) /** * xmlXPathNodeSetItem: * @ns: a node-set * @index: index of a node in the set * * Implements a functionality similar to the DOM NodeList.item(). * * Returns the xmlNodePtr at the given @index in @ns or NULL if * @index is out of range (0 to length-1) */ #define xmlXPathNodeSetItem(ns, index) \ ((((ns) != NULL) && \ ((index) >= 0) && ((index) < (ns)->nodeNr)) ? \ (ns)->nodeTab[(index)] \ : NULL) /** * xmlXPathNodeSetIsEmpty: * @ns: a node-set * * Checks whether @ns is empty or not. * * Returns %TRUE if @ns is an empty node-set. */ #define xmlXPathNodeSetIsEmpty(ns) \ (((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL)) XMLPUBFUN void XMLCALL xmlXPathFreeObject (xmlXPathObjectPtr obj); XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathNodeSetCreate (xmlNodePtr val); XMLPUBFUN void XMLCALL xmlXPathFreeNodeSetList (xmlXPathObjectPtr obj); XMLPUBFUN void XMLCALL xmlXPathFreeNodeSet (xmlNodeSetPtr obj); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathObjectCopy (xmlXPathObjectPtr val); XMLPUBFUN int XMLCALL xmlXPathCmpNodes (xmlNodePtr node1, xmlNodePtr node2); /** * Conversion functions to basic types. */ XMLPUBFUN int XMLCALL xmlXPathCastNumberToBoolean (double val); XMLPUBFUN int XMLCALL xmlXPathCastStringToBoolean (const xmlChar * val); XMLPUBFUN int XMLCALL xmlXPathCastNodeSetToBoolean(xmlNodeSetPtr ns); XMLPUBFUN int XMLCALL xmlXPathCastToBoolean (xmlXPathObjectPtr val); XMLPUBFUN double XMLCALL xmlXPathCastBooleanToNumber (int val); XMLPUBFUN double XMLCALL xmlXPathCastStringToNumber (const xmlChar * val); XMLPUBFUN double XMLCALL xmlXPathCastNodeToNumber (xmlNodePtr node); XMLPUBFUN double XMLCALL xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns); XMLPUBFUN double XMLCALL xmlXPathCastToNumber (xmlXPathObjectPtr val); XMLPUBFUN xmlChar * XMLCALL xmlXPathCastBooleanToString (int val); XMLPUBFUN xmlChar * XMLCALL xmlXPathCastNumberToString (double val); XMLPUBFUN xmlChar * XMLCALL xmlXPathCastNodeToString (xmlNodePtr node); XMLPUBFUN xmlChar * XMLCALL xmlXPathCastNodeSetToString (xmlNodeSetPtr ns); XMLPUBFUN xmlChar * XMLCALL xmlXPathCastToString (xmlXPathObjectPtr val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathConvertBoolean (xmlXPathObjectPtr val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathConvertNumber (xmlXPathObjectPtr val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathConvertString (xmlXPathObjectPtr val); /** * Context handling. */ XMLPUBFUN xmlXPathContextPtr XMLCALL xmlXPathNewContext (xmlDocPtr doc); XMLPUBFUN void XMLCALL xmlXPathFreeContext (xmlXPathContextPtr ctxt); XMLPUBFUN int XMLCALL xmlXPathContextSetCache(xmlXPathContextPtr ctxt, int active, int value, int options); /** * Evaluation functions. */ XMLPUBFUN long XMLCALL xmlXPathOrderDocElems (xmlDocPtr doc); XMLPUBFUN int XMLCALL xmlXPathSetContextNode (xmlNodePtr node, xmlXPathContextPtr ctx); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNodeEval (xmlNodePtr node, const xmlChar *str, xmlXPathContextPtr ctx); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathEval (const xmlChar *str, xmlXPathContextPtr ctx); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathEvalExpression (const xmlChar *str, xmlXPathContextPtr ctxt); XMLPUBFUN int XMLCALL xmlXPathEvalPredicate (xmlXPathContextPtr ctxt, xmlXPathObjectPtr res); /** * Separate compilation/evaluation entry points. */ XMLPUBFUN xmlXPathCompExprPtr XMLCALL xmlXPathCompile (const xmlChar *str); XMLPUBFUN xmlXPathCompExprPtr XMLCALL xmlXPathCtxtCompile (xmlXPathContextPtr ctxt, const xmlChar *str); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathCompiledEval (xmlXPathCompExprPtr comp, xmlXPathContextPtr ctx); XMLPUBFUN int XMLCALL xmlXPathCompiledEvalToBoolean(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt); XMLPUBFUN void XMLCALL xmlXPathFreeCompExpr (xmlXPathCompExprPtr comp); #endif /* LIBXML_XPATH_ENABLED */ #if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) XMLPUBFUN void XMLCALL xmlXPathInit (void); XMLPUBFUN int XMLCALL xmlXPathIsNaN (double val); XMLPUBFUN int XMLCALL xmlXPathIsInf (double val); #ifdef __cplusplus } #endif #endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED*/ #endif /* ! __XML_XPATH_H__ */ /* * Summary: Provide Canonical XML and Exclusive XML Canonicalization * Description: the c14n modules provides a * * "Canonical XML" implementation * http://www.w3.org/TR/xml-c14n * * and an * * "Exclusive XML Canonicalization" implementation * http://www.w3.org/TR/xml-exc-c14n * Copy: See Copyright for the status of this software. * * Author: Aleksey Sanin <aleksey@aleksey.com> */ #ifndef __XML_C14N_H__ #define __XML_C14N_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_C14N_ENABLED #ifdef LIBXML_OUTPUT_ENABLED #include <libxml/tree.h> #include <libxml/xpath.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* * XML Canonicalization * http://www.w3.org/TR/xml-c14n * * Exclusive XML Canonicalization * http://www.w3.org/TR/xml-exc-c14n * * Canonical form of an XML document could be created if and only if * a) default attributes (if any) are added to all nodes * b) all character and parsed entity references are resolved * In order to achieve this in libxml2 the document MUST be loaded with * following global settings: * * xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS; * xmlSubstituteEntitiesDefault(1); * * or corresponding parser context setting: * xmlParserCtxtPtr ctxt; * * ... * ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS; * ctxt->replaceEntities = 1; * ... */ /* * xmlC14NMode: * * Predefined values for C14N modes * */ typedef enum { XML_C14N_1_0 = 0, /* Original C14N 1.0 spec */ XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */ XML_C14N_1_1 = 2 /* C14N 1.1 spec */ } xmlC14NMode; XMLPUBFUN int XMLCALL xmlC14NDocSaveTo (xmlDocPtr doc, xmlNodeSetPtr nodes, int mode, /* a xmlC14NMode */ xmlChar **inclusive_ns_prefixes, int with_comments, xmlOutputBufferPtr buf); XMLPUBFUN int XMLCALL xmlC14NDocDumpMemory (xmlDocPtr doc, xmlNodeSetPtr nodes, int mode, /* a xmlC14NMode */ xmlChar **inclusive_ns_prefixes, int with_comments, xmlChar **doc_txt_ptr); XMLPUBFUN int XMLCALL xmlC14NDocSave (xmlDocPtr doc, xmlNodeSetPtr nodes, int mode, /* a xmlC14NMode */ xmlChar **inclusive_ns_prefixes, int with_comments, const char* filename, int compression); /** * This is the core C14N function */ /** * xmlC14NIsVisibleCallback: * @user_data: user data * @node: the current node * @parent: the parent node * * Signature for a C14N callback on visible nodes * * Returns 1 if the node should be included */ typedef int (*xmlC14NIsVisibleCallback) (void* user_data, xmlNodePtr node, xmlNodePtr parent); XMLPUBFUN int XMLCALL xmlC14NExecute (xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback, void* user_data, int mode, /* a xmlC14NMode */ xmlChar **inclusive_ns_prefixes, int with_comments, xmlOutputBufferPtr buf); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_C14N_ENABLED */ #endif /* __XML_C14N_H__ */ /* * Summary: old DocBook SGML parser * Description: interface for a DocBook SGML non-verifying parser * This code is DEPRECATED, and should not be used anymore. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __DOCB_PARSER_H__ #define __DOCB_PARSER_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_DOCB_ENABLED #include <libxml/parser.h> #include <libxml/parserInternals.h> #ifndef IN_LIBXML #ifdef __GNUC__ #warning "The DOCBparser module has been deprecated in libxml2-2.6.0" #endif #endif #ifdef __cplusplus extern "C" { #endif /* * Most of the back-end structures from XML and SGML are shared. */ typedef xmlParserCtxt docbParserCtxt; typedef xmlParserCtxtPtr docbParserCtxtPtr; typedef xmlSAXHandler docbSAXHandler; typedef xmlSAXHandlerPtr docbSAXHandlerPtr; typedef xmlParserInput docbParserInput; typedef xmlParserInputPtr docbParserInputPtr; typedef xmlDocPtr docbDocPtr; /* * There is only few public functions. */ XMLPUBFUN int XMLCALL docbEncodeEntities(unsigned char *out, int *outlen, const unsigned char *in, int *inlen, int quoteChar); XMLPUBFUN docbDocPtr XMLCALL docbSAXParseDoc (xmlChar *cur, const char *encoding, docbSAXHandlerPtr sax, void *userData); XMLPUBFUN docbDocPtr XMLCALL docbParseDoc (xmlChar *cur, const char *encoding); XMLPUBFUN docbDocPtr XMLCALL docbSAXParseFile (const char *filename, const char *encoding, docbSAXHandlerPtr sax, void *userData); XMLPUBFUN docbDocPtr XMLCALL docbParseFile (const char *filename, const char *encoding); /** * Interfaces for the Push mode. */ XMLPUBFUN void XMLCALL docbFreeParserCtxt (docbParserCtxtPtr ctxt); XMLPUBFUN docbParserCtxtPtr XMLCALL docbCreatePushParserCtxt(docbSAXHandlerPtr sax, void *user_data, const char *chunk, int size, const char *filename, xmlCharEncoding enc); XMLPUBFUN int XMLCALL docbParseChunk (docbParserCtxtPtr ctxt, const char *chunk, int size, int terminate); XMLPUBFUN docbParserCtxtPtr XMLCALL docbCreateFileParserCtxt(const char *filename, const char *encoding); XMLPUBFUN int XMLCALL docbParseDocument (docbParserCtxtPtr ctxt); #ifdef __cplusplus } #endif #endif /* LIBXML_DOCB_ENABLED */ #endif /* __DOCB_PARSER_H__ */ /* * Summary: The DTD validation * Description: API for the DTD handling and the validity checking * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_VALID_H__ #define __XML_VALID_H__ #include <libxml/xmlversion.h> #include <libxml/xmlerror.h> #include <libxml/tree.h> #include <libxml/list.h> #include <libxml/xmlautomata.h> #include <libxml/xmlregexp.h> #ifdef __cplusplus extern "C" { #endif /* * Validation state added for non-determinist content model. */ typedef struct _xmlValidState xmlValidState; typedef xmlValidState *xmlValidStatePtr; /** * xmlValidityErrorFunc: * @ctx: usually an xmlValidCtxtPtr to a validity error context, * but comes from ctxt->userData (which normally contains such * a pointer); ctxt->userData can be changed by the user. * @msg: the string to format *printf like vararg * @...: remaining arguments to the format * * Callback called when a validity error is found. This is a message * oriented function similar to an *printf function. */ typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); /** * xmlValidityWarningFunc: * @ctx: usually an xmlValidCtxtPtr to a validity error context, * but comes from ctxt->userData (which normally contains such * a pointer); ctxt->userData can be changed by the user. * @msg: the string to format *printf like vararg * @...: remaining arguments to the format * * Callback called when a validity warning is found. This is a message * oriented function similar to an *printf function. */ typedef void (XMLCDECL *xmlValidityWarningFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); #ifdef IN_LIBXML /** * XML_CTXT_FINISH_DTD_0: * * Special value for finishDtd field when embedded in an xmlParserCtxt */ #define XML_CTXT_FINISH_DTD_0 0xabcd1234 /** * XML_CTXT_FINISH_DTD_1: * * Special value for finishDtd field when embedded in an xmlParserCtxt */ #define XML_CTXT_FINISH_DTD_1 0xabcd1235 #endif /* * xmlValidCtxt: * An xmlValidCtxt is used for error reporting when validating. */ typedef struct _xmlValidCtxt xmlValidCtxt; typedef xmlValidCtxt *xmlValidCtxtPtr; struct _xmlValidCtxt { void *userData; /* user specific data block */ xmlValidityErrorFunc error; /* the callback in case of errors */ xmlValidityWarningFunc warning; /* the callback in case of warning */ /* Node analysis stack used when validating within entities */ xmlNodePtr node; /* Current parsed Node */ int nodeNr; /* Depth of the parsing stack */ int nodeMax; /* Max depth of the parsing stack */ xmlNodePtr *nodeTab; /* array of nodes */ unsigned int finishDtd; /* finished validating the Dtd ? */ xmlDocPtr doc; /* the document */ int valid; /* temporary validity check result */ /* state state used for non-determinist content validation */ xmlValidState *vstate; /* current state */ int vstateNr; /* Depth of the validation stack */ int vstateMax; /* Max depth of the validation stack */ xmlValidState *vstateTab; /* array of validation states */ #ifdef LIBXML_REGEXP_ENABLED xmlAutomataPtr am; /* the automata */ xmlAutomataStatePtr state; /* used to build the automata */ #else void *am; void *state; #endif }; /* * ALL notation declarations are stored in a table. * There is one table per DTD. */ typedef struct _xmlHashTable xmlNotationTable; typedef xmlNotationTable *xmlNotationTablePtr; /* * ALL element declarations are stored in a table. * There is one table per DTD. */ typedef struct _xmlHashTable xmlElementTable; typedef xmlElementTable *xmlElementTablePtr; /* * ALL attribute declarations are stored in a table. * There is one table per DTD. */ typedef struct _xmlHashTable xmlAttributeTable; typedef xmlAttributeTable *xmlAttributeTablePtr; /* * ALL IDs attributes are stored in a table. * There is one table per document. */ typedef struct _xmlHashTable xmlIDTable; typedef xmlIDTable *xmlIDTablePtr; /* * ALL Refs attributes are stored in a table. * There is one table per document. */ typedef struct _xmlHashTable xmlRefTable; typedef xmlRefTable *xmlRefTablePtr; /* Notation */ XMLPUBFUN xmlNotationPtr XMLCALL xmlAddNotationDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, const xmlChar *PublicID, const xmlChar *SystemID); #ifdef LIBXML_TREE_ENABLED XMLPUBFUN xmlNotationTablePtr XMLCALL xmlCopyNotationTable (xmlNotationTablePtr table); #endif /* LIBXML_TREE_ENABLED */ XMLPUBFUN void XMLCALL xmlFreeNotationTable (xmlNotationTablePtr table); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN void XMLCALL xmlDumpNotationDecl (xmlBufferPtr buf, xmlNotationPtr nota); XMLPUBFUN void XMLCALL xmlDumpNotationTable (xmlBufferPtr buf, xmlNotationTablePtr table); #endif /* LIBXML_OUTPUT_ENABLED */ /* Element Content */ /* the non Doc version are being deprecated */ XMLPUBFUN xmlElementContentPtr XMLCALL xmlNewElementContent (const xmlChar *name, xmlElementContentType type); XMLPUBFUN xmlElementContentPtr XMLCALL xmlCopyElementContent (xmlElementContentPtr content); XMLPUBFUN void XMLCALL xmlFreeElementContent (xmlElementContentPtr cur); /* the new versions with doc argument */ XMLPUBFUN xmlElementContentPtr XMLCALL xmlNewDocElementContent (xmlDocPtr doc, const xmlChar *name, xmlElementContentType type); XMLPUBFUN xmlElementContentPtr XMLCALL xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr content); XMLPUBFUN void XMLCALL xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur); XMLPUBFUN void XMLCALL xmlSnprintfElementContent(char *buf, int size, xmlElementContentPtr content, int englob); #ifdef LIBXML_OUTPUT_ENABLED /* DEPRECATED */ XMLPUBFUN void XMLCALL xmlSprintfElementContent(char *buf, xmlElementContentPtr content, int englob); #endif /* LIBXML_OUTPUT_ENABLED */ /* DEPRECATED */ /* Element */ XMLPUBFUN xmlElementPtr XMLCALL xmlAddElementDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, xmlElementTypeVal type, xmlElementContentPtr content); #ifdef LIBXML_TREE_ENABLED XMLPUBFUN xmlElementTablePtr XMLCALL xmlCopyElementTable (xmlElementTablePtr table); #endif /* LIBXML_TREE_ENABLED */ XMLPUBFUN void XMLCALL xmlFreeElementTable (xmlElementTablePtr table); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN void XMLCALL xmlDumpElementTable (xmlBufferPtr buf, xmlElementTablePtr table); XMLPUBFUN void XMLCALL xmlDumpElementDecl (xmlBufferPtr buf, xmlElementPtr elem); #endif /* LIBXML_OUTPUT_ENABLED */ /* Enumeration */ XMLPUBFUN xmlEnumerationPtr XMLCALL xmlCreateEnumeration (const xmlChar *name); XMLPUBFUN void XMLCALL xmlFreeEnumeration (xmlEnumerationPtr cur); #ifdef LIBXML_TREE_ENABLED XMLPUBFUN xmlEnumerationPtr XMLCALL xmlCopyEnumeration (xmlEnumerationPtr cur); #endif /* LIBXML_TREE_ENABLED */ /* Attribute */ XMLPUBFUN xmlAttributePtr XMLCALL xmlAddAttributeDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name, const xmlChar *ns, xmlAttributeType type, xmlAttributeDefault def, const xmlChar *defaultValue, xmlEnumerationPtr tree); #ifdef LIBXML_TREE_ENABLED XMLPUBFUN xmlAttributeTablePtr XMLCALL xmlCopyAttributeTable (xmlAttributeTablePtr table); #endif /* LIBXML_TREE_ENABLED */ XMLPUBFUN void XMLCALL xmlFreeAttributeTable (xmlAttributeTablePtr table); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN void XMLCALL xmlDumpAttributeTable (xmlBufferPtr buf, xmlAttributeTablePtr table); XMLPUBFUN void XMLCALL xmlDumpAttributeDecl (xmlBufferPtr buf, xmlAttributePtr attr); #endif /* LIBXML_OUTPUT_ENABLED */ /* IDs */ XMLPUBFUN xmlIDPtr XMLCALL xmlAddID (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr); XMLPUBFUN void XMLCALL xmlFreeIDTable (xmlIDTablePtr table); XMLPUBFUN xmlAttrPtr XMLCALL xmlGetID (xmlDocPtr doc, const xmlChar *ID); XMLPUBFUN int XMLCALL xmlIsID (xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr); XMLPUBFUN int XMLCALL xmlRemoveID (xmlDocPtr doc, xmlAttrPtr attr); /* IDREFs */ XMLPUBFUN xmlRefPtr XMLCALL xmlAddRef (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr); XMLPUBFUN void XMLCALL xmlFreeRefTable (xmlRefTablePtr table); XMLPUBFUN int XMLCALL xmlIsRef (xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr); XMLPUBFUN int XMLCALL xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr); XMLPUBFUN xmlListPtr XMLCALL xmlGetRefs (xmlDocPtr doc, const xmlChar *ID); /** * The public function calls related to validity checking. */ #ifdef LIBXML_VALID_ENABLED /* Allocate/Release Validation Contexts */ XMLPUBFUN xmlValidCtxtPtr XMLCALL xmlNewValidCtxt(void); XMLPUBFUN void XMLCALL xmlFreeValidCtxt(xmlValidCtxtPtr); XMLPUBFUN int XMLCALL xmlValidateRoot (xmlValidCtxtPtr ctxt, xmlDocPtr doc); XMLPUBFUN int XMLCALL xmlValidateElementDecl (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlElementPtr elem); XMLPUBFUN xmlChar * XMLCALL xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem, const xmlChar *name, const xmlChar *value); XMLPUBFUN xmlChar * XMLCALL xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem, const xmlChar *name, const xmlChar *value); XMLPUBFUN int XMLCALL xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlAttributePtr attr); XMLPUBFUN int XMLCALL xmlValidateAttributeValue(xmlAttributeType type, const xmlChar *value); XMLPUBFUN int XMLCALL xmlValidateNotationDecl (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNotationPtr nota); XMLPUBFUN int XMLCALL xmlValidateDtd (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd); XMLPUBFUN int XMLCALL xmlValidateDtdFinal (xmlValidCtxtPtr ctxt, xmlDocPtr doc); XMLPUBFUN int XMLCALL xmlValidateDocument (xmlValidCtxtPtr ctxt, xmlDocPtr doc); XMLPUBFUN int XMLCALL xmlValidateElement (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem); XMLPUBFUN int XMLCALL xmlValidateOneElement (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem); XMLPUBFUN int XMLCALL xmlValidateOneAttribute (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr, const xmlChar *value); XMLPUBFUN int XMLCALL xmlValidateOneNamespace (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem, const xmlChar *prefix, xmlNsPtr ns, const xmlChar *value); XMLPUBFUN int XMLCALL xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc); #endif /* LIBXML_VALID_ENABLED */ #if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) XMLPUBFUN int XMLCALL xmlValidateNotationUse (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *notationName); #endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */ XMLPUBFUN int XMLCALL xmlIsMixedElement (xmlDocPtr doc, const xmlChar *name); XMLPUBFUN xmlAttributePtr XMLCALL xmlGetDtdAttrDesc (xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name); XMLPUBFUN xmlAttributePtr XMLCALL xmlGetDtdQAttrDesc (xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name, const xmlChar *prefix); XMLPUBFUN xmlNotationPtr XMLCALL xmlGetDtdNotationDesc (xmlDtdPtr dtd, const xmlChar *name); XMLPUBFUN xmlElementPtr XMLCALL xmlGetDtdQElementDesc (xmlDtdPtr dtd, const xmlChar *name, const xmlChar *prefix); XMLPUBFUN xmlElementPtr XMLCALL xmlGetDtdElementDesc (xmlDtdPtr dtd, const xmlChar *name); #ifdef LIBXML_VALID_ENABLED XMLPUBFUN int XMLCALL xmlValidGetPotentialChildren(xmlElementContent *ctree, const xmlChar **names, int *len, int max); XMLPUBFUN int XMLCALL xmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names, int max); XMLPUBFUN int XMLCALL xmlValidateNameValue (const xmlChar *value); XMLPUBFUN int XMLCALL xmlValidateNamesValue (const xmlChar *value); XMLPUBFUN int XMLCALL xmlValidateNmtokenValue (const xmlChar *value); XMLPUBFUN int XMLCALL xmlValidateNmtokensValue(const xmlChar *value); #ifdef LIBXML_REGEXP_ENABLED /* * Validation based on the regexp support */ XMLPUBFUN int XMLCALL xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem); XMLPUBFUN int XMLCALL xmlValidatePushElement (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem, const xmlChar *qname); XMLPUBFUN int XMLCALL xmlValidatePushCData (xmlValidCtxtPtr ctxt, const xmlChar *data, int len); XMLPUBFUN int XMLCALL xmlValidatePopElement (xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem, const xmlChar *qname); #endif /* LIBXML_REGEXP_ENABLED */ #endif /* LIBXML_VALID_ENABLED */ #ifdef __cplusplus } #endif #endif /* __XML_VALID_H__ */ /* * Summary: error handling * Description: the API used to report errors * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #include <libxml/parser.h> #ifndef __XML_ERROR_H__ #define __XML_ERROR_H__ #ifdef __cplusplus extern "C" { #endif /** * xmlErrorLevel: * * Indicates the level of an error */ typedef enum { XML_ERR_NONE = 0, XML_ERR_WARNING = 1, /* A simple warning */ XML_ERR_ERROR = 2, /* A recoverable error */ XML_ERR_FATAL = 3 /* A fatal error */ } xmlErrorLevel; /** * xmlErrorDomain: * * Indicates where an error may have come from */ typedef enum { XML_FROM_NONE = 0, XML_FROM_PARSER, /* The XML parser */ XML_FROM_TREE, /* The tree module */ XML_FROM_NAMESPACE, /* The XML Namespace module */ XML_FROM_DTD, /* The XML DTD validation with parser context*/ XML_FROM_HTML, /* The HTML parser */ XML_FROM_MEMORY, /* The memory allocator */ XML_FROM_OUTPUT, /* The serialization code */ XML_FROM_IO, /* The Input/Output stack */ XML_FROM_FTP, /* The FTP module */ XML_FROM_HTTP, /* The HTTP module */ XML_FROM_XINCLUDE, /* The XInclude processing */ XML_FROM_XPATH, /* The XPath module */ XML_FROM_XPOINTER, /* The XPointer module */ XML_FROM_REGEXP, /* The regular expressions module */ XML_FROM_DATATYPE, /* The W3C XML Schemas Datatype module */ XML_FROM_SCHEMASP, /* The W3C XML Schemas parser module */ XML_FROM_SCHEMASV, /* The W3C XML Schemas validation module */ XML_FROM_RELAXNGP, /* The Relax-NG parser module */ XML_FROM_RELAXNGV, /* The Relax-NG validator module */ XML_FROM_CATALOG, /* The Catalog module */ XML_FROM_C14N, /* The Canonicalization module */ XML_FROM_XSLT, /* The XSLT engine from libxslt */ XML_FROM_VALID, /* The XML DTD validation with valid context */ XML_FROM_CHECK, /* The error checking module */ XML_FROM_WRITER, /* The xmlwriter module */ XML_FROM_MODULE, /* The dynamically loaded module module*/ XML_FROM_I18N, /* The module handling character conversion */ XML_FROM_SCHEMATRONV,/* The Schematron validator module */ XML_FROM_BUFFER, /* The buffers module */ XML_FROM_URI /* The URI module */ } xmlErrorDomain; /** * xmlError: * * An XML Error instance. */ typedef struct _xmlError xmlError; typedef xmlError *xmlErrorPtr; struct _xmlError { int domain; /* What part of the library raised this error */ int code; /* The error code, e.g. an xmlParserError */ char *message;/* human-readable informative error message */ xmlErrorLevel level;/* how consequent is the error */ char *file; /* the filename */ int line; /* the line number if available */ char *str1; /* extra string information */ char *str2; /* extra string information */ char *str3; /* extra string information */ int int1; /* extra number information */ int int2; /* error column # or 0 if N/A (todo: rename field when we would brk ABI) */ void *ctxt; /* the parser context if available */ void *node; /* the node in the tree */ }; /** * xmlParserError: * * This is an error that the XML (or HTML) parser can generate */ typedef enum { XML_ERR_OK = 0, XML_ERR_INTERNAL_ERROR, /* 1 */ XML_ERR_NO_MEMORY, /* 2 */ XML_ERR_DOCUMENT_START, /* 3 */ XML_ERR_DOCUMENT_EMPTY, /* 4 */ XML_ERR_DOCUMENT_END, /* 5 */ XML_ERR_INVALID_HEX_CHARREF, /* 6 */ XML_ERR_INVALID_DEC_CHARREF, /* 7 */ XML_ERR_INVALID_CHARREF, /* 8 */ XML_ERR_INVALID_CHAR, /* 9 */ XML_ERR_CHARREF_AT_EOF, /* 10 */ XML_ERR_CHARREF_IN_PROLOG, /* 11 */ XML_ERR_CHARREF_IN_EPILOG, /* 12 */ XML_ERR_CHARREF_IN_DTD, /* 13 */ XML_ERR_ENTITYREF_AT_EOF, /* 14 */ XML_ERR_ENTITYREF_IN_PROLOG, /* 15 */ XML_ERR_ENTITYREF_IN_EPILOG, /* 16 */ XML_ERR_ENTITYREF_IN_DTD, /* 17 */ XML_ERR_PEREF_AT_EOF, /* 18 */ XML_ERR_PEREF_IN_PROLOG, /* 19 */ XML_ERR_PEREF_IN_EPILOG, /* 20 */ XML_ERR_PEREF_IN_INT_SUBSET, /* 21 */ XML_ERR_ENTITYREF_NO_NAME, /* 22 */ XML_ERR_ENTITYREF_SEMICOL_MISSING, /* 23 */ XML_ERR_PEREF_NO_NAME, /* 24 */ XML_ERR_PEREF_SEMICOL_MISSING, /* 25 */ XML_ERR_UNDECLARED_ENTITY, /* 26 */ XML_WAR_UNDECLARED_ENTITY, /* 27 */ XML_ERR_UNPARSED_ENTITY, /* 28 */ XML_ERR_ENTITY_IS_EXTERNAL, /* 29 */ XML_ERR_ENTITY_IS_PARAMETER, /* 30 */ XML_ERR_UNKNOWN_ENCODING, /* 31 */ XML_ERR_UNSUPPORTED_ENCODING, /* 32 */ XML_ERR_STRING_NOT_STARTED, /* 33 */ XML_ERR_STRING_NOT_CLOSED, /* 34 */ XML_ERR_NS_DECL_ERROR, /* 35 */ XML_ERR_ENTITY_NOT_STARTED, /* 36 */ XML_ERR_ENTITY_NOT_FINISHED, /* 37 */ XML_ERR_LT_IN_ATTRIBUTE, /* 38 */ XML_ERR_ATTRIBUTE_NOT_STARTED, /* 39 */ XML_ERR_ATTRIBUTE_NOT_FINISHED, /* 40 */ XML_ERR_ATTRIBUTE_WITHOUT_VALUE, /* 41 */ XML_ERR_ATTRIBUTE_REDEFINED, /* 42 */ XML_ERR_LITERAL_NOT_STARTED, /* 43 */ XML_ERR_LITERAL_NOT_FINISHED, /* 44 */ XML_ERR_COMMENT_NOT_FINISHED, /* 45 */ XML_ERR_PI_NOT_STARTED, /* 46 */ XML_ERR_PI_NOT_FINISHED, /* 47 */ XML_ERR_NOTATION_NOT_STARTED, /* 48 */ XML_ERR_NOTATION_NOT_FINISHED, /* 49 */ XML_ERR_ATTLIST_NOT_STARTED, /* 50 */ XML_ERR_ATTLIST_NOT_FINISHED, /* 51 */ XML_ERR_MIXED_NOT_STARTED, /* 52 */ XML_ERR_MIXED_NOT_FINISHED, /* 53 */ XML_ERR_ELEMCONTENT_NOT_STARTED, /* 54 */ XML_ERR_ELEMCONTENT_NOT_FINISHED, /* 55 */ XML_ERR_XMLDECL_NOT_STARTED, /* 56 */ XML_ERR_XMLDECL_NOT_FINISHED, /* 57 */ XML_ERR_CONDSEC_NOT_STARTED, /* 58 */ XML_ERR_CONDSEC_NOT_FINISHED, /* 59 */ XML_ERR_EXT_SUBSET_NOT_FINISHED, /* 60 */ XML_ERR_DOCTYPE_NOT_FINISHED, /* 61 */ XML_ERR_MISPLACED_CDATA_END, /* 62 */ XML_ERR_CDATA_NOT_FINISHED, /* 63 */ XML_ERR_RESERVED_XML_NAME, /* 64 */ XML_ERR_SPACE_REQUIRED, /* 65 */ XML_ERR_SEPARATOR_REQUIRED, /* 66 */ XML_ERR_NMTOKEN_REQUIRED, /* 67 */ XML_ERR_NAME_REQUIRED, /* 68 */ XML_ERR_PCDATA_REQUIRED, /* 69 */ XML_ERR_URI_REQUIRED, /* 70 */ XML_ERR_PUBID_REQUIRED, /* 71 */ XML_ERR_LT_REQUIRED, /* 72 */ XML_ERR_GT_REQUIRED, /* 73 */ XML_ERR_LTSLASH_REQUIRED, /* 74 */ XML_ERR_EQUAL_REQUIRED, /* 75 */ XML_ERR_TAG_NAME_MISMATCH, /* 76 */ XML_ERR_TAG_NOT_FINISHED, /* 77 */ XML_ERR_STANDALONE_VALUE, /* 78 */ XML_ERR_ENCODING_NAME, /* 79 */ XML_ERR_HYPHEN_IN_COMMENT, /* 80 */ XML_ERR_INVALID_ENCODING, /* 81 */ XML_ERR_EXT_ENTITY_STANDALONE, /* 82 */ XML_ERR_CONDSEC_INVALID, /* 83 */ XML_ERR_VALUE_REQUIRED, /* 84 */ XML_ERR_NOT_WELL_BALANCED, /* 85 */ XML_ERR_EXTRA_CONTENT, /* 86 */ XML_ERR_ENTITY_CHAR_ERROR, /* 87 */ XML_ERR_ENTITY_PE_INTERNAL, /* 88 */ XML_ERR_ENTITY_LOOP, /* 89 */ XML_ERR_ENTITY_BOUNDARY, /* 90 */ XML_ERR_INVALID_URI, /* 91 */ XML_ERR_URI_FRAGMENT, /* 92 */ XML_WAR_CATALOG_PI, /* 93 */ XML_ERR_NO_DTD, /* 94 */ XML_ERR_CONDSEC_INVALID_KEYWORD, /* 95 */ XML_ERR_VERSION_MISSING, /* 96 */ XML_WAR_UNKNOWN_VERSION, /* 97 */ XML_WAR_LANG_VALUE, /* 98 */ XML_WAR_NS_URI, /* 99 */ XML_WAR_NS_URI_RELATIVE, /* 100 */ XML_ERR_MISSING_ENCODING, /* 101 */ XML_WAR_SPACE_VALUE, /* 102 */ XML_ERR_NOT_STANDALONE, /* 103 */ XML_ERR_ENTITY_PROCESSING, /* 104 */ XML_ERR_NOTATION_PROCESSING, /* 105 */ XML_WAR_NS_COLUMN, /* 106 */ XML_WAR_ENTITY_REDEFINED, /* 107 */ XML_ERR_UNKNOWN_VERSION, /* 108 */ XML_ERR_VERSION_MISMATCH, /* 109 */ XML_ERR_NAME_TOO_LONG, /* 110 */ XML_ERR_USER_STOP, /* 111 */ XML_NS_ERR_XML_NAMESPACE = 200, XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */ XML_NS_ERR_QNAME, /* 202 */ XML_NS_ERR_ATTRIBUTE_REDEFINED, /* 203 */ XML_NS_ERR_EMPTY, /* 204 */ XML_NS_ERR_COLON, /* 205 */ XML_DTD_ATTRIBUTE_DEFAULT = 500, XML_DTD_ATTRIBUTE_REDEFINED, /* 501 */ XML_DTD_ATTRIBUTE_VALUE, /* 502 */ XML_DTD_CONTENT_ERROR, /* 503 */ XML_DTD_CONTENT_MODEL, /* 504 */ XML_DTD_CONTENT_NOT_DETERMINIST, /* 505 */ XML_DTD_DIFFERENT_PREFIX, /* 506 */ XML_DTD_ELEM_DEFAULT_NAMESPACE, /* 507 */ XML_DTD_ELEM_NAMESPACE, /* 508 */ XML_DTD_ELEM_REDEFINED, /* 509 */ XML_DTD_EMPTY_NOTATION, /* 510 */ XML_DTD_ENTITY_TYPE, /* 511 */ XML_DTD_ID_FIXED, /* 512 */ XML_DTD_ID_REDEFINED, /* 513 */ XML_DTD_ID_SUBSET, /* 514 */ XML_DTD_INVALID_CHILD, /* 515 */ XML_DTD_INVALID_DEFAULT, /* 516 */ XML_DTD_LOAD_ERROR, /* 517 */ XML_DTD_MISSING_ATTRIBUTE, /* 518 */ XML_DTD_MIXED_CORRUPT, /* 519 */ XML_DTD_MULTIPLE_ID, /* 520 */ XML_DTD_NO_DOC, /* 521 */ XML_DTD_NO_DTD, /* 522 */ XML_DTD_NO_ELEM_NAME, /* 523 */ XML_DTD_NO_PREFIX, /* 524 */ XML_DTD_NO_ROOT, /* 525 */ XML_DTD_NOTATION_REDEFINED, /* 526 */ XML_DTD_NOTATION_VALUE, /* 527 */ XML_DTD_NOT_EMPTY, /* 528 */ XML_DTD_NOT_PCDATA, /* 529 */ XML_DTD_NOT_STANDALONE, /* 530 */ XML_DTD_ROOT_NAME, /* 531 */ XML_DTD_STANDALONE_WHITE_SPACE, /* 532 */ XML_DTD_UNKNOWN_ATTRIBUTE, /* 533 */ XML_DTD_UNKNOWN_ELEM, /* 534 */ XML_DTD_UNKNOWN_ENTITY, /* 535 */ XML_DTD_UNKNOWN_ID, /* 536 */ XML_DTD_UNKNOWN_NOTATION, /* 537 */ XML_DTD_STANDALONE_DEFAULTED, /* 538 */ XML_DTD_XMLID_VALUE, /* 539 */ XML_DTD_XMLID_TYPE, /* 540 */ XML_DTD_DUP_TOKEN, /* 541 */ XML_HTML_STRUCURE_ERROR = 800, XML_HTML_UNKNOWN_TAG, /* 801 */ XML_RNGP_ANYNAME_ATTR_ANCESTOR = 1000, XML_RNGP_ATTR_CONFLICT, /* 1001 */ XML_RNGP_ATTRIBUTE_CHILDREN, /* 1002 */ XML_RNGP_ATTRIBUTE_CONTENT, /* 1003 */ XML_RNGP_ATTRIBUTE_EMPTY, /* 1004 */ XML_RNGP_ATTRIBUTE_NOOP, /* 1005 */ XML_RNGP_CHOICE_CONTENT, /* 1006 */ XML_RNGP_CHOICE_EMPTY, /* 1007 */ XML_RNGP_CREATE_FAILURE, /* 1008 */ XML_RNGP_DATA_CONTENT, /* 1009 */ XML_RNGP_DEF_CHOICE_AND_INTERLEAVE, /* 1010 */ XML_RNGP_DEFINE_CREATE_FAILED, /* 1011 */ XML_RNGP_DEFINE_EMPTY, /* 1012 */ XML_RNGP_DEFINE_MISSING, /* 1013 */ XML_RNGP_DEFINE_NAME_MISSING, /* 1014 */ XML_RNGP_ELEM_CONTENT_EMPTY, /* 1015 */ XML_RNGP_ELEM_CONTENT_ERROR, /* 1016 */ XML_RNGP_ELEMENT_EMPTY, /* 1017 */ XML_RNGP_ELEMENT_CONTENT, /* 1018 */ XML_RNGP_ELEMENT_NAME, /* 1019 */ XML_RNGP_ELEMENT_NO_CONTENT, /* 1020 */ XML_RNGP_ELEM_TEXT_CONFLICT, /* 1021 */ XML_RNGP_EMPTY, /* 1022 */ XML_RNGP_EMPTY_CONSTRUCT, /* 1023 */ XML_RNGP_EMPTY_CONTENT, /* 1024 */ XML_RNGP_EMPTY_NOT_EMPTY, /* 1025 */ XML_RNGP_ERROR_TYPE_LIB, /* 1026 */ XML_RNGP_EXCEPT_EMPTY, /* 1027 */ XML_RNGP_EXCEPT_MISSING, /* 1028 */ XML_RNGP_EXCEPT_MULTIPLE, /* 1029 */ XML_RNGP_EXCEPT_NO_CONTENT, /* 1030 */ XML_RNGP_EXTERNALREF_EMTPY, /* 1031 */ XML_RNGP_EXTERNAL_REF_FAILURE, /* 1032 */ XML_RNGP_EXTERNALREF_RECURSE, /* 1033 */ XML_RNGP_FORBIDDEN_ATTRIBUTE, /* 1034 */ XML_RNGP_FOREIGN_ELEMENT, /* 1035 */ XML_RNGP_GRAMMAR_CONTENT, /* 1036 */ XML_RNGP_GRAMMAR_EMPTY, /* 1037 */ XML_RNGP_GRAMMAR_MISSING, /* 1038 */ XML_RNGP_GRAMMAR_NO_START, /* 1039 */ XML_RNGP_GROUP_ATTR_CONFLICT, /* 1040 */ XML_RNGP_HREF_ERROR, /* 1041 */ XML_RNGP_INCLUDE_EMPTY, /* 1042 */ XML_RNGP_INCLUDE_FAILURE, /* 1043 */ XML_RNGP_INCLUDE_RECURSE, /* 1044 */ XML_RNGP_INTERLEAVE_ADD, /* 1045 */ XML_RNGP_INTERLEAVE_CREATE_FAILED, /* 1046 */ XML_RNGP_INTERLEAVE_EMPTY, /* 1047 */ XML_RNGP_INTERLEAVE_NO_CONTENT, /* 1048 */ XML_RNGP_INVALID_DEFINE_NAME, /* 1049 */ XML_RNGP_INVALID_URI, /* 1050 */ XML_RNGP_INVALID_VALUE, /* 1051 */ XML_RNGP_MISSING_HREF, /* 1052 */ XML_RNGP_NAME_MISSING, /* 1053 */ XML_RNGP_NEED_COMBINE, /* 1054 */ XML_RNGP_NOTALLOWED_NOT_EMPTY, /* 1055 */ XML_RNGP_NSNAME_ATTR_ANCESTOR, /* 1056 */ XML_RNGP_NSNAME_NO_NS, /* 1057 */ XML_RNGP_PARAM_FORBIDDEN, /* 1058 */ XML_RNGP_PARAM_NAME_MISSING, /* 1059 */ XML_RNGP_PARENTREF_CREATE_FAILED, /* 1060 */ XML_RNGP_PARENTREF_NAME_INVALID, /* 1061 */ XML_RNGP_PARENTREF_NO_NAME, /* 1062 */ XML_RNGP_PARENTREF_NO_PARENT, /* 1063 */ XML_RNGP_PARENTREF_NOT_EMPTY, /* 1064 */ XML_RNGP_PARSE_ERROR, /* 1065 */ XML_RNGP_PAT_ANYNAME_EXCEPT_ANYNAME, /* 1066 */ XML_RNGP_PAT_ATTR_ATTR, /* 1067 */ XML_RNGP_PAT_ATTR_ELEM, /* 1068 */ XML_RNGP_PAT_DATA_EXCEPT_ATTR, /* 1069 */ XML_RNGP_PAT_DATA_EXCEPT_ELEM, /* 1070 */ XML_RNGP_PAT_DATA_EXCEPT_EMPTY, /* 1071 */ XML_RNGP_PAT_DATA_EXCEPT_GROUP, /* 1072 */ XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE, /* 1073 */ XML_RNGP_PAT_DATA_EXCEPT_LIST, /* 1074 */ XML_RNGP_PAT_DATA_EXCEPT_ONEMORE, /* 1075 */ XML_RNGP_PAT_DATA_EXCEPT_REF, /* 1076 */ XML_RNGP_PAT_DATA_EXCEPT_TEXT, /* 1077 */ XML_RNGP_PAT_LIST_ATTR, /* 1078 */ XML_RNGP_PAT_LIST_ELEM, /* 1079 */ XML_RNGP_PAT_LIST_INTERLEAVE, /* 1080 */ XML_RNGP_PAT_LIST_LIST, /* 1081 */ XML_RNGP_PAT_LIST_REF, /* 1082 */ XML_RNGP_PAT_LIST_TEXT, /* 1083 */ XML_RNGP_PAT_NSNAME_EXCEPT_ANYNAME, /* 1084 */ XML_RNGP_PAT_NSNAME_EXCEPT_NSNAME, /* 1085 */ XML_RNGP_PAT_ONEMORE_GROUP_ATTR, /* 1086 */ XML_RNGP_PAT_ONEMORE_INTERLEAVE_ATTR, /* 1087 */ XML_RNGP_PAT_START_ATTR, /* 1088 */ XML_RNGP_PAT_START_DATA, /* 1089 */ XML_RNGP_PAT_START_EMPTY, /* 1090 */ XML_RNGP_PAT_START_GROUP, /* 1091 */ XML_RNGP_PAT_START_INTERLEAVE, /* 1092 */ XML_RNGP_PAT_START_LIST, /* 1093 */ XML_RNGP_PAT_START_ONEMORE, /* 1094 */ XML_RNGP_PAT_START_TEXT, /* 1095 */ XML_RNGP_PAT_START_VALUE, /* 1096 */ XML_RNGP_PREFIX_UNDEFINED, /* 1097 */ XML_RNGP_REF_CREATE_FAILED, /* 1098 */ XML_RNGP_REF_CYCLE, /* 1099 */ XML_RNGP_REF_NAME_INVALID, /* 1100 */ XML_RNGP_REF_NO_DEF, /* 1101 */ XML_RNGP_REF_NO_NAME, /* 1102 */ XML_RNGP_REF_NOT_EMPTY, /* 1103 */ XML_RNGP_START_CHOICE_AND_INTERLEAVE, /* 1104 */ XML_RNGP_START_CONTENT, /* 1105 */ XML_RNGP_START_EMPTY, /* 1106 */ XML_RNGP_START_MISSING, /* 1107 */ XML_RNGP_TEXT_EXPECTED, /* 1108 */ XML_RNGP_TEXT_HAS_CHILD, /* 1109 */ XML_RNGP_TYPE_MISSING, /* 1110 */ XML_RNGP_TYPE_NOT_FOUND, /* 1111 */ XML_RNGP_TYPE_VALUE, /* 1112 */ XML_RNGP_UNKNOWN_ATTRIBUTE, /* 1113 */ XML_RNGP_UNKNOWN_COMBINE, /* 1114 */ XML_RNGP_UNKNOWN_CONSTRUCT, /* 1115 */ XML_RNGP_UNKNOWN_TYPE_LIB, /* 1116 */ XML_RNGP_URI_FRAGMENT, /* 1117 */ XML_RNGP_URI_NOT_ABSOLUTE, /* 1118 */ XML_RNGP_VALUE_EMPTY, /* 1119 */ XML_RNGP_VALUE_NO_CONTENT, /* 1120 */ XML_RNGP_XMLNS_NAME, /* 1121 */ XML_RNGP_XML_NS, /* 1122 */ XML_XPATH_EXPRESSION_OK = 1200, XML_XPATH_NUMBER_ERROR, /* 1201 */ XML_XPATH_UNFINISHED_LITERAL_ERROR, /* 1202 */ XML_XPATH_START_LITERAL_ERROR, /* 1203 */ XML_XPATH_VARIABLE_REF_ERROR, /* 1204 */ XML_XPATH_UNDEF_VARIABLE_ERROR, /* 1205 */ XML_XPATH_INVALID_PREDICATE_ERROR, /* 1206 */ XML_XPATH_EXPR_ERROR, /* 1207 */ XML_XPATH_UNCLOSED_ERROR, /* 1208 */ XML_XPATH_UNKNOWN_FUNC_ERROR, /* 1209 */ XML_XPATH_INVALID_OPERAND, /* 1210 */ XML_XPATH_INVALID_TYPE, /* 1211 */ XML_XPATH_INVALID_ARITY, /* 1212 */ XML_XPATH_INVALID_CTXT_SIZE, /* 1213 */ XML_XPATH_INVALID_CTXT_POSITION, /* 1214 */ XML_XPATH_MEMORY_ERROR, /* 1215 */ XML_XPTR_SYNTAX_ERROR, /* 1216 */ XML_XPTR_RESOURCE_ERROR, /* 1217 */ XML_XPTR_SUB_RESOURCE_ERROR, /* 1218 */ XML_XPATH_UNDEF_PREFIX_ERROR, /* 1219 */ XML_XPATH_ENCODING_ERROR, /* 1220 */ XML_XPATH_INVALID_CHAR_ERROR, /* 1221 */ XML_TREE_INVALID_HEX = 1300, XML_TREE_INVALID_DEC, /* 1301 */ XML_TREE_UNTERMINATED_ENTITY, /* 1302 */ XML_TREE_NOT_UTF8, /* 1303 */ XML_SAVE_NOT_UTF8 = 1400, XML_SAVE_CHAR_INVALID, /* 1401 */ XML_SAVE_NO_DOCTYPE, /* 1402 */ XML_SAVE_UNKNOWN_ENCODING, /* 1403 */ XML_REGEXP_COMPILE_ERROR = 1450, XML_IO_UNKNOWN = 1500, XML_IO_EACCES, /* 1501 */ XML_IO_EAGAIN, /* 1502 */ XML_IO_EBADF, /* 1503 */ XML_IO_EBADMSG, /* 1504 */ XML_IO_EBUSY, /* 1505 */ XML_IO_ECANCELED, /* 1506 */ XML_IO_ECHILD, /* 1507 */ XML_IO_EDEADLK, /* 1508 */ XML_IO_EDOM, /* 1509 */ XML_IO_EEXIST, /* 1510 */ XML_IO_EFAULT, /* 1511 */ XML_IO_EFBIG, /* 1512 */ XML_IO_EINPROGRESS, /* 1513 */ XML_IO_EINTR, /* 1514 */ XML_IO_EINVAL, /* 1515 */ XML_IO_EIO, /* 1516 */ XML_IO_EISDIR, /* 1517 */ XML_IO_EMFILE, /* 1518 */ XML_IO_EMLINK, /* 1519 */ XML_IO_EMSGSIZE, /* 1520 */ XML_IO_ENAMETOOLONG, /* 1521 */ XML_IO_ENFILE, /* 1522 */ XML_IO_ENODEV, /* 1523 */ XML_IO_ENOENT, /* 1524 */ XML_IO_ENOEXEC, /* 1525 */ XML_IO_ENOLCK, /* 1526 */ XML_IO_ENOMEM, /* 1527 */ XML_IO_ENOSPC, /* 1528 */ XML_IO_ENOSYS, /* 1529 */ XML_IO_ENOTDIR, /* 1530 */ XML_IO_ENOTEMPTY, /* 1531 */ XML_IO_ENOTSUP, /* 1532 */ XML_IO_ENOTTY, /* 1533 */ XML_IO_ENXIO, /* 1534 */ XML_IO_EPERM, /* 1535 */ XML_IO_EPIPE, /* 1536 */ XML_IO_ERANGE, /* 1537 */ XML_IO_EROFS, /* 1538 */ XML_IO_ESPIPE, /* 1539 */ XML_IO_ESRCH, /* 1540 */ XML_IO_ETIMEDOUT, /* 1541 */ XML_IO_EXDEV, /* 1542 */ XML_IO_NETWORK_ATTEMPT, /* 1543 */ XML_IO_ENCODER, /* 1544 */ XML_IO_FLUSH, /* 1545 */ XML_IO_WRITE, /* 1546 */ XML_IO_NO_INPUT, /* 1547 */ XML_IO_BUFFER_FULL, /* 1548 */ XML_IO_LOAD_ERROR, /* 1549 */ XML_IO_ENOTSOCK, /* 1550 */ XML_IO_EISCONN, /* 1551 */ XML_IO_ECONNREFUSED, /* 1552 */ XML_IO_ENETUNREACH, /* 1553 */ XML_IO_EADDRINUSE, /* 1554 */ XML_IO_EALREADY, /* 1555 */ XML_IO_EAFNOSUPPORT, /* 1556 */ XML_XINCLUDE_RECURSION=1600, XML_XINCLUDE_PARSE_VALUE, /* 1601 */ XML_XINCLUDE_ENTITY_DEF_MISMATCH, /* 1602 */ XML_XINCLUDE_NO_HREF, /* 1603 */ XML_XINCLUDE_NO_FALLBACK, /* 1604 */ XML_XINCLUDE_HREF_URI, /* 1605 */ XML_XINCLUDE_TEXT_FRAGMENT, /* 1606 */ XML_XINCLUDE_TEXT_DOCUMENT, /* 1607 */ XML_XINCLUDE_INVALID_CHAR, /* 1608 */ XML_XINCLUDE_BUILD_FAILED, /* 1609 */ XML_XINCLUDE_UNKNOWN_ENCODING, /* 1610 */ XML_XINCLUDE_MULTIPLE_ROOT, /* 1611 */ XML_XINCLUDE_XPTR_FAILED, /* 1612 */ XML_XINCLUDE_XPTR_RESULT, /* 1613 */ XML_XINCLUDE_INCLUDE_IN_INCLUDE, /* 1614 */ XML_XINCLUDE_FALLBACKS_IN_INCLUDE, /* 1615 */ XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE, /* 1616 */ XML_XINCLUDE_DEPRECATED_NS, /* 1617 */ XML_XINCLUDE_FRAGMENT_ID, /* 1618 */ XML_CATALOG_MISSING_ATTR = 1650, XML_CATALOG_ENTRY_BROKEN, /* 1651 */ XML_CATALOG_PREFER_VALUE, /* 1652 */ XML_CATALOG_NOT_CATALOG, /* 1653 */ XML_CATALOG_RECURSION, /* 1654 */ XML_SCHEMAP_PREFIX_UNDEFINED = 1700, XML_SCHEMAP_ATTRFORMDEFAULT_VALUE, /* 1701 */ XML_SCHEMAP_ATTRGRP_NONAME_NOREF, /* 1702 */ XML_SCHEMAP_ATTR_NONAME_NOREF, /* 1703 */ XML_SCHEMAP_COMPLEXTYPE_NONAME_NOREF, /* 1704 */ XML_SCHEMAP_ELEMFORMDEFAULT_VALUE, /* 1705 */ XML_SCHEMAP_ELEM_NONAME_NOREF, /* 1706 */ XML_SCHEMAP_EXTENSION_NO_BASE, /* 1707 */ XML_SCHEMAP_FACET_NO_VALUE, /* 1708 */ XML_SCHEMAP_FAILED_BUILD_IMPORT, /* 1709 */ XML_SCHEMAP_GROUP_NONAME_NOREF, /* 1710 */ XML_SCHEMAP_IMPORT_NAMESPACE_NOT_URI, /* 1711 */ XML_SCHEMAP_IMPORT_REDEFINE_NSNAME, /* 1712 */ XML_SCHEMAP_IMPORT_SCHEMA_NOT_URI, /* 1713 */ XML_SCHEMAP_INVALID_BOOLEAN, /* 1714 */ XML_SCHEMAP_INVALID_ENUM, /* 1715 */ XML_SCHEMAP_INVALID_FACET, /* 1716 */ XML_SCHEMAP_INVALID_FACET_VALUE, /* 1717 */ XML_SCHEMAP_INVALID_MAXOCCURS, /* 1718 */ XML_SCHEMAP_INVALID_MINOCCURS, /* 1719 */ XML_SCHEMAP_INVALID_REF_AND_SUBTYPE, /* 1720 */ XML_SCHEMAP_INVALID_WHITE_SPACE, /* 1721 */ XML_SCHEMAP_NOATTR_NOREF, /* 1722 */ XML_SCHEMAP_NOTATION_NO_NAME, /* 1723 */ XML_SCHEMAP_NOTYPE_NOREF, /* 1724 */ XML_SCHEMAP_REF_AND_SUBTYPE, /* 1725 */ XML_SCHEMAP_RESTRICTION_NONAME_NOREF, /* 1726 */ XML_SCHEMAP_SIMPLETYPE_NONAME, /* 1727 */ XML_SCHEMAP_TYPE_AND_SUBTYPE, /* 1728 */ XML_SCHEMAP_UNKNOWN_ALL_CHILD, /* 1729 */ XML_SCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD, /* 1730 */ XML_SCHEMAP_UNKNOWN_ATTR_CHILD, /* 1731 */ XML_SCHEMAP_UNKNOWN_ATTRGRP_CHILD, /* 1732 */ XML_SCHEMAP_UNKNOWN_ATTRIBUTE_GROUP, /* 1733 */ XML_SCHEMAP_UNKNOWN_BASE_TYPE, /* 1734 */ XML_SCHEMAP_UNKNOWN_CHOICE_CHILD, /* 1735 */ XML_SCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD, /* 1736 */ XML_SCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD, /* 1737 */ XML_SCHEMAP_UNKNOWN_ELEM_CHILD, /* 1738 */ XML_SCHEMAP_UNKNOWN_EXTENSION_CHILD, /* 1739 */ XML_SCHEMAP_UNKNOWN_FACET_CHILD, /* 1740 */ XML_SCHEMAP_UNKNOWN_FACET_TYPE, /* 1741 */ XML_SCHEMAP_UNKNOWN_GROUP_CHILD, /* 1742 */ XML_SCHEMAP_UNKNOWN_IMPORT_CHILD, /* 1743 */ XML_SCHEMAP_UNKNOWN_LIST_CHILD, /* 1744 */ XML_SCHEMAP_UNKNOWN_NOTATION_CHILD, /* 1745 */ XML_SCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD, /* 1746 */ XML_SCHEMAP_UNKNOWN_REF, /* 1747 */ XML_SCHEMAP_UNKNOWN_RESTRICTION_CHILD, /* 1748 */ XML_SCHEMAP_UNKNOWN_SCHEMAS_CHILD, /* 1749 */ XML_SCHEMAP_UNKNOWN_SEQUENCE_CHILD, /* 1750 */ XML_SCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD, /* 1751 */ XML_SCHEMAP_UNKNOWN_SIMPLETYPE_CHILD, /* 1752 */ XML_SCHEMAP_UNKNOWN_TYPE, /* 1753 */ XML_SCHEMAP_UNKNOWN_UNION_CHILD, /* 1754 */ XML_SCHEMAP_ELEM_DEFAULT_FIXED, /* 1755 */ XML_SCHEMAP_REGEXP_INVALID, /* 1756 */ XML_SCHEMAP_FAILED_LOAD, /* 1757 */ XML_SCHEMAP_NOTHING_TO_PARSE, /* 1758 */ XML_SCHEMAP_NOROOT, /* 1759 */ XML_SCHEMAP_REDEFINED_GROUP, /* 1760 */ XML_SCHEMAP_REDEFINED_TYPE, /* 1761 */ XML_SCHEMAP_REDEFINED_ELEMENT, /* 1762 */ XML_SCHEMAP_REDEFINED_ATTRGROUP, /* 1763 */ XML_SCHEMAP_REDEFINED_ATTR, /* 1764 */ XML_SCHEMAP_REDEFINED_NOTATION, /* 1765 */ XML_SCHEMAP_FAILED_PARSE, /* 1766 */ XML_SCHEMAP_UNKNOWN_PREFIX, /* 1767 */ XML_SCHEMAP_DEF_AND_PREFIX, /* 1768 */ XML_SCHEMAP_UNKNOWN_INCLUDE_CHILD, /* 1769 */ XML_SCHEMAP_INCLUDE_SCHEMA_NOT_URI, /* 1770 */ XML_SCHEMAP_INCLUDE_SCHEMA_NO_URI, /* 1771 */ XML_SCHEMAP_NOT_SCHEMA, /* 1772 */ XML_SCHEMAP_UNKNOWN_MEMBER_TYPE, /* 1773 */ XML_SCHEMAP_INVALID_ATTR_USE, /* 1774 */ XML_SCHEMAP_RECURSIVE, /* 1775 */ XML_SCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE, /* 1776 */ XML_SCHEMAP_INVALID_ATTR_COMBINATION, /* 1777 */ XML_SCHEMAP_INVALID_ATTR_INLINE_COMBINATION, /* 1778 */ XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD, /* 1779 */ XML_SCHEMAP_INVALID_ATTR_NAME, /* 1780 */ XML_SCHEMAP_REF_AND_CONTENT, /* 1781 */ XML_SCHEMAP_CT_PROPS_CORRECT_1, /* 1782 */ XML_SCHEMAP_CT_PROPS_CORRECT_2, /* 1783 */ XML_SCHEMAP_CT_PROPS_CORRECT_3, /* 1784 */ XML_SCHEMAP_CT_PROPS_CORRECT_4, /* 1785 */ XML_SCHEMAP_CT_PROPS_CORRECT_5, /* 1786 */ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, /* 1787 */ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1, /* 1788 */ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2, /* 1789 */ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2, /* 1790 */ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3, /* 1791 */ XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER, /* 1792 */ XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE, /* 1793 */ XML_SCHEMAP_UNION_NOT_EXPRESSIBLE, /* 1794 */ XML_SCHEMAP_SRC_IMPORT_3_1, /* 1795 */ XML_SCHEMAP_SRC_IMPORT_3_2, /* 1796 */ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1, /* 1797 */ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2, /* 1798 */ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3, /* 1799 */ XML_SCHEMAP_COS_CT_EXTENDS_1_3, /* 1800 */ XML_SCHEMAV_NOROOT = 1801, XML_SCHEMAV_UNDECLAREDELEM, /* 1802 */ XML_SCHEMAV_NOTTOPLEVEL, /* 1803 */ XML_SCHEMAV_MISSING, /* 1804 */ XML_SCHEMAV_WRONGELEM, /* 1805 */ XML_SCHEMAV_NOTYPE, /* 1806 */ XML_SCHEMAV_NOROLLBACK, /* 1807 */ XML_SCHEMAV_ISABSTRACT, /* 1808 */ XML_SCHEMAV_NOTEMPTY, /* 1809 */ XML_SCHEMAV_ELEMCONT, /* 1810 */ XML_SCHEMAV_HAVEDEFAULT, /* 1811 */ XML_SCHEMAV_NOTNILLABLE, /* 1812 */ XML_SCHEMAV_EXTRACONTENT, /* 1813 */ XML_SCHEMAV_INVALIDATTR, /* 1814 */ XML_SCHEMAV_INVALIDELEM, /* 1815 */ XML_SCHEMAV_NOTDETERMINIST, /* 1816 */ XML_SCHEMAV_CONSTRUCT, /* 1817 */ XML_SCHEMAV_INTERNAL, /* 1818 */ XML_SCHEMAV_NOTSIMPLE, /* 1819 */ XML_SCHEMAV_ATTRUNKNOWN, /* 1820 */ XML_SCHEMAV_ATTRINVALID, /* 1821 */ XML_SCHEMAV_VALUE, /* 1822 */ XML_SCHEMAV_FACET, /* 1823 */ XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1, /* 1824 */ XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2, /* 1825 */ XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3, /* 1826 */ XML_SCHEMAV_CVC_TYPE_3_1_1, /* 1827 */ XML_SCHEMAV_CVC_TYPE_3_1_2, /* 1828 */ XML_SCHEMAV_CVC_FACET_VALID, /* 1829 */ XML_SCHEMAV_CVC_LENGTH_VALID, /* 1830 */ XML_SCHEMAV_CVC_MINLENGTH_VALID, /* 1831 */ XML_SCHEMAV_CVC_MAXLENGTH_VALID, /* 1832 */ XML_SCHEMAV_CVC_MININCLUSIVE_VALID, /* 1833 */ XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID, /* 1834 */ XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID, /* 1835 */ XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID, /* 1836 */ XML_SCHEMAV_CVC_TOTALDIGITS_VALID, /* 1837 */ XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID, /* 1838 */ XML_SCHEMAV_CVC_PATTERN_VALID, /* 1839 */ XML_SCHEMAV_CVC_ENUMERATION_VALID, /* 1840 */ XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, /* 1841 */ XML_SCHEMAV_CVC_COMPLEX_TYPE_2_2, /* 1842 */ XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, /* 1843 */ XML_SCHEMAV_CVC_COMPLEX_TYPE_2_4, /* 1844 */ XML_SCHEMAV_CVC_ELT_1, /* 1845 */ XML_SCHEMAV_CVC_ELT_2, /* 1846 */ XML_SCHEMAV_CVC_ELT_3_1, /* 1847 */ XML_SCHEMAV_CVC_ELT_3_2_1, /* 1848 */ XML_SCHEMAV_CVC_ELT_3_2_2, /* 1849 */ XML_SCHEMAV_CVC_ELT_4_1, /* 1850 */ XML_SCHEMAV_CVC_ELT_4_2, /* 1851 */ XML_SCHEMAV_CVC_ELT_4_3, /* 1852 */ XML_SCHEMAV_CVC_ELT_5_1_1, /* 1853 */ XML_SCHEMAV_CVC_ELT_5_1_2, /* 1854 */ XML_SCHEMAV_CVC_ELT_5_2_1, /* 1855 */ XML_SCHEMAV_CVC_ELT_5_2_2_1, /* 1856 */ XML_SCHEMAV_CVC_ELT_5_2_2_2_1, /* 1857 */ XML_SCHEMAV_CVC_ELT_5_2_2_2_2, /* 1858 */ XML_SCHEMAV_CVC_ELT_6, /* 1859 */ XML_SCHEMAV_CVC_ELT_7, /* 1860 */ XML_SCHEMAV_CVC_ATTRIBUTE_1, /* 1861 */ XML_SCHEMAV_CVC_ATTRIBUTE_2, /* 1862 */ XML_SCHEMAV_CVC_ATTRIBUTE_3, /* 1863 */ XML_SCHEMAV_CVC_ATTRIBUTE_4, /* 1864 */ XML_SCHEMAV_CVC_COMPLEX_TYPE_3_1, /* 1865 */ XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_1, /* 1866 */ XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_2, /* 1867 */ XML_SCHEMAV_CVC_COMPLEX_TYPE_4, /* 1868 */ XML_SCHEMAV_CVC_COMPLEX_TYPE_5_1, /* 1869 */ XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2, /* 1870 */ XML_SCHEMAV_ELEMENT_CONTENT, /* 1871 */ XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING, /* 1872 */ XML_SCHEMAV_CVC_COMPLEX_TYPE_1, /* 1873 */ XML_SCHEMAV_CVC_AU, /* 1874 */ XML_SCHEMAV_CVC_TYPE_1, /* 1875 */ XML_SCHEMAV_CVC_TYPE_2, /* 1876 */ XML_SCHEMAV_CVC_IDC, /* 1877 */ XML_SCHEMAV_CVC_WILDCARD, /* 1878 */ XML_SCHEMAV_MISC, /* 1879 */ XML_XPTR_UNKNOWN_SCHEME = 1900, XML_XPTR_CHILDSEQ_START, /* 1901 */ XML_XPTR_EVAL_FAILED, /* 1902 */ XML_XPTR_EXTRA_OBJECTS, /* 1903 */ XML_C14N_CREATE_CTXT = 1950, XML_C14N_REQUIRES_UTF8, /* 1951 */ XML_C14N_CREATE_STACK, /* 1952 */ XML_C14N_INVALID_NODE, /* 1953 */ XML_C14N_UNKNOW_NODE, /* 1954 */ XML_C14N_RELATIVE_NAMESPACE, /* 1955 */ XML_FTP_PASV_ANSWER = 2000, XML_FTP_EPSV_ANSWER, /* 2001 */ XML_FTP_ACCNT, /* 2002 */ XML_FTP_URL_SYNTAX, /* 2003 */ XML_HTTP_URL_SYNTAX = 2020, XML_HTTP_USE_IP, /* 2021 */ XML_HTTP_UNKNOWN_HOST, /* 2022 */ XML_SCHEMAP_SRC_SIMPLE_TYPE_1 = 3000, XML_SCHEMAP_SRC_SIMPLE_TYPE_2, /* 3001 */ XML_SCHEMAP_SRC_SIMPLE_TYPE_3, /* 3002 */ XML_SCHEMAP_SRC_SIMPLE_TYPE_4, /* 3003 */ XML_SCHEMAP_SRC_RESOLVE, /* 3004 */ XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE, /* 3005 */ XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE, /* 3006 */ XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES, /* 3007 */ XML_SCHEMAP_ST_PROPS_CORRECT_1, /* 3008 */ XML_SCHEMAP_ST_PROPS_CORRECT_2, /* 3009 */ XML_SCHEMAP_ST_PROPS_CORRECT_3, /* 3010 */ XML_SCHEMAP_COS_ST_RESTRICTS_1_1, /* 3011 */ XML_SCHEMAP_COS_ST_RESTRICTS_1_2, /* 3012 */ XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1, /* 3013 */ XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2, /* 3014 */ XML_SCHEMAP_COS_ST_RESTRICTS_2_1, /* 3015 */ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1, /* 3016 */ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2, /* 3017 */ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1, /* 3018 */ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2, /* 3019 */ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3, /* 3020 */ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4, /* 3021 */ XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_5, /* 3022 */ XML_SCHEMAP_COS_ST_RESTRICTS_3_1, /* 3023 */ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1, /* 3024 */ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2, /* 3025 */ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2, /* 3026 */ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1, /* 3027 */ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3, /* 3028 */ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4, /* 3029 */ XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5, /* 3030 */ XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, /* 3031 */ XML_SCHEMAP_COS_ST_DERIVED_OK_2_2, /* 3032 */ XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, /* 3033 */ XML_SCHEMAP_S4S_ELEM_MISSING, /* 3034 */ XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, /* 3035 */ XML_SCHEMAP_S4S_ATTR_MISSING, /* 3036 */ XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, /* 3037 */ XML_SCHEMAP_SRC_ELEMENT_1, /* 3038 */ XML_SCHEMAP_SRC_ELEMENT_2_1, /* 3039 */ XML_SCHEMAP_SRC_ELEMENT_2_2, /* 3040 */ XML_SCHEMAP_SRC_ELEMENT_3, /* 3041 */ XML_SCHEMAP_P_PROPS_CORRECT_1, /* 3042 */ XML_SCHEMAP_P_PROPS_CORRECT_2_1, /* 3043 */ XML_SCHEMAP_P_PROPS_CORRECT_2_2, /* 3044 */ XML_SCHEMAP_E_PROPS_CORRECT_2, /* 3045 */ XML_SCHEMAP_E_PROPS_CORRECT_3, /* 3046 */ XML_SCHEMAP_E_PROPS_CORRECT_4, /* 3047 */ XML_SCHEMAP_E_PROPS_CORRECT_5, /* 3048 */ XML_SCHEMAP_E_PROPS_CORRECT_6, /* 3049 */ XML_SCHEMAP_SRC_INCLUDE, /* 3050 */ XML_SCHEMAP_SRC_ATTRIBUTE_1, /* 3051 */ XML_SCHEMAP_SRC_ATTRIBUTE_2, /* 3052 */ XML_SCHEMAP_SRC_ATTRIBUTE_3_1, /* 3053 */ XML_SCHEMAP_SRC_ATTRIBUTE_3_2, /* 3054 */ XML_SCHEMAP_SRC_ATTRIBUTE_4, /* 3055 */ XML_SCHEMAP_NO_XMLNS, /* 3056 */ XML_SCHEMAP_NO_XSI, /* 3057 */ XML_SCHEMAP_COS_VALID_DEFAULT_1, /* 3058 */ XML_SCHEMAP_COS_VALID_DEFAULT_2_1, /* 3059 */ XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1, /* 3060 */ XML_SCHEMAP_COS_VALID_DEFAULT_2_2_2, /* 3061 */ XML_SCHEMAP_CVC_SIMPLE_TYPE, /* 3062 */ XML_SCHEMAP_COS_CT_EXTENDS_1_1, /* 3063 */ XML_SCHEMAP_SRC_IMPORT_1_1, /* 3064 */ XML_SCHEMAP_SRC_IMPORT_1_2, /* 3065 */ XML_SCHEMAP_SRC_IMPORT_2, /* 3066 */ XML_SCHEMAP_SRC_IMPORT_2_1, /* 3067 */ XML_SCHEMAP_SRC_IMPORT_2_2, /* 3068 */ XML_SCHEMAP_INTERNAL, /* 3069 non-W3C */ XML_SCHEMAP_NOT_DETERMINISTIC, /* 3070 non-W3C */ XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_1, /* 3071 */ XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_2, /* 3072 */ XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3, /* 3073 */ XML_SCHEMAP_MG_PROPS_CORRECT_1, /* 3074 */ XML_SCHEMAP_MG_PROPS_CORRECT_2, /* 3075 */ XML_SCHEMAP_SRC_CT_1, /* 3076 */ XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, /* 3077 */ XML_SCHEMAP_AU_PROPS_CORRECT_2, /* 3078 */ XML_SCHEMAP_A_PROPS_CORRECT_2, /* 3079 */ XML_SCHEMAP_C_PROPS_CORRECT, /* 3080 */ XML_SCHEMAP_SRC_REDEFINE, /* 3081 */ XML_SCHEMAP_SRC_IMPORT, /* 3082 */ XML_SCHEMAP_WARN_SKIP_SCHEMA, /* 3083 */ XML_SCHEMAP_WARN_UNLOCATED_SCHEMA, /* 3084 */ XML_SCHEMAP_WARN_ATTR_REDECL_PROH, /* 3085 */ XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, /* 3085 */ XML_SCHEMAP_AG_PROPS_CORRECT, /* 3086 */ XML_SCHEMAP_COS_CT_EXTENDS_1_2, /* 3087 */ XML_SCHEMAP_AU_PROPS_CORRECT, /* 3088 */ XML_SCHEMAP_A_PROPS_CORRECT_3, /* 3089 */ XML_SCHEMAP_COS_ALL_LIMITED, /* 3090 */ XML_SCHEMATRONV_ASSERT = 4000, /* 4000 */ XML_SCHEMATRONV_REPORT, XML_MODULE_OPEN = 4900, /* 4900 */ XML_MODULE_CLOSE, /* 4901 */ XML_CHECK_FOUND_ELEMENT = 5000, XML_CHECK_FOUND_ATTRIBUTE, /* 5001 */ XML_CHECK_FOUND_TEXT, /* 5002 */ XML_CHECK_FOUND_CDATA, /* 5003 */ XML_CHECK_FOUND_ENTITYREF, /* 5004 */ XML_CHECK_FOUND_ENTITY, /* 5005 */ XML_CHECK_FOUND_PI, /* 5006 */ XML_CHECK_FOUND_COMMENT, /* 5007 */ XML_CHECK_FOUND_DOCTYPE, /* 5008 */ XML_CHECK_FOUND_FRAGMENT, /* 5009 */ XML_CHECK_FOUND_NOTATION, /* 5010 */ XML_CHECK_UNKNOWN_NODE, /* 5011 */ XML_CHECK_ENTITY_TYPE, /* 5012 */ XML_CHECK_NO_PARENT, /* 5013 */ XML_CHECK_NO_DOC, /* 5014 */ XML_CHECK_NO_NAME, /* 5015 */ XML_CHECK_NO_ELEM, /* 5016 */ XML_CHECK_WRONG_DOC, /* 5017 */ XML_CHECK_NO_PREV, /* 5018 */ XML_CHECK_WRONG_PREV, /* 5019 */ XML_CHECK_NO_NEXT, /* 5020 */ XML_CHECK_WRONG_NEXT, /* 5021 */ XML_CHECK_NOT_DTD, /* 5022 */ XML_CHECK_NOT_ATTR, /* 5023 */ XML_CHECK_NOT_ATTR_DECL, /* 5024 */ XML_CHECK_NOT_ELEM_DECL, /* 5025 */ XML_CHECK_NOT_ENTITY_DECL, /* 5026 */ XML_CHECK_NOT_NS_DECL, /* 5027 */ XML_CHECK_NO_HREF, /* 5028 */ XML_CHECK_WRONG_PARENT,/* 5029 */ XML_CHECK_NS_SCOPE, /* 5030 */ XML_CHECK_NS_ANCESTOR, /* 5031 */ XML_CHECK_NOT_UTF8, /* 5032 */ XML_CHECK_NO_DICT, /* 5033 */ XML_CHECK_NOT_NCNAME, /* 5034 */ XML_CHECK_OUTSIDE_DICT, /* 5035 */ XML_CHECK_WRONG_NAME, /* 5036 */ XML_CHECK_NAME_NOT_NULL, /* 5037 */ XML_I18N_NO_NAME = 6000, XML_I18N_NO_HANDLER, /* 6001 */ XML_I18N_EXCESS_HANDLER, /* 6002 */ XML_I18N_CONV_FAILED, /* 6003 */ XML_I18N_NO_OUTPUT, /* 6004 */ XML_BUF_OVERFLOW = 7000 } xmlParserErrors; /** * xmlGenericErrorFunc: * @ctx: a parsing context * @msg: the message * @...: the extra arguments of the varargs to format the message * * Signature of the function to use when there is an error and * no parsing or validity context available . */ typedef void (XMLCDECL *xmlGenericErrorFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); /** * xmlStructuredErrorFunc: * @userData: user provided data for the error callback * @error: the error being raised. * * Signature of the function to use when there is an error and * the module handles the new error reporting mechanism. */ typedef void (XMLCALL *xmlStructuredErrorFunc) (void *userData, xmlErrorPtr error); /* * Use the following function to reset the two global variables * xmlGenericError and xmlGenericErrorContext. */ XMLPUBFUN void XMLCALL xmlSetGenericErrorFunc (void *ctx, xmlGenericErrorFunc handler); XMLPUBFUN void XMLCALL initGenericErrorDefaultFunc (xmlGenericErrorFunc *handler); XMLPUBFUN void XMLCALL xmlSetStructuredErrorFunc (void *ctx, xmlStructuredErrorFunc handler); /* * Default message routines used by SAX and Valid context for error * and warning reporting. */ XMLPUBFUN void XMLCDECL xmlParserError (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); XMLPUBFUN void XMLCDECL xmlParserWarning (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); XMLPUBFUN void XMLCDECL xmlParserValidityError (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); XMLPUBFUN void XMLCDECL xmlParserValidityWarning (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); XMLPUBFUN void XMLCALL xmlParserPrintFileInfo (xmlParserInputPtr input); XMLPUBFUN void XMLCALL xmlParserPrintFileContext (xmlParserInputPtr input); /* * Extended error information routines */ XMLPUBFUN xmlErrorPtr XMLCALL xmlGetLastError (void); XMLPUBFUN void XMLCALL xmlResetLastError (void); XMLPUBFUN xmlErrorPtr XMLCALL xmlCtxtGetLastError (void *ctx); XMLPUBFUN void XMLCALL xmlCtxtResetLastError (void *ctx); XMLPUBFUN void XMLCALL xmlResetError (xmlErrorPtr err); XMLPUBFUN int XMLCALL xmlCopyError (xmlErrorPtr from, xmlErrorPtr to); #ifdef IN_LIBXML /* * Internal callback reporting routine */ XMLPUBFUN void XMLCALL __xmlRaiseError (xmlStructuredErrorFunc schannel, xmlGenericErrorFunc channel, void *data, void *ctx, void *node, int domain, int code, xmlErrorLevel level, const char *file, int line, const char *str1, const char *str2, const char *str3, int int1, int col, const char *msg, ...) LIBXML_ATTR_FORMAT(16,17); XMLPUBFUN void XMLCALL __xmlSimpleError (int domain, int code, xmlNodePtr node, const char *msg, const char *extra) LIBXML_ATTR_FORMAT(4,0); #endif #ifdef __cplusplus } #endif #endif /* __XML_ERROR_H__ */ /* * Summary: Chained hash tables * Description: This module implements the hash table support used in * various places in the library. * * Copy: See Copyright for the status of this software. * * Author: Bjorn Reese <bjorn.reese@systematic.dk> */ #ifndef __XML_HASH_H__ #define __XML_HASH_H__ #ifdef __cplusplus extern "C" { #endif /* * The hash table. */ typedef struct _xmlHashTable xmlHashTable; typedef xmlHashTable *xmlHashTablePtr; #ifdef __cplusplus } #endif #include <libxml/xmlversion.h> #include <libxml/parser.h> #include <libxml/dict.h> #ifdef __cplusplus extern "C" { #endif /* * Recent version of gcc produce a warning when a function pointer is assigned * to an object pointer, or vice versa. The following macro is a dirty hack * to allow suppression of the warning. If your architecture has function * pointers which are a different size than a void pointer, there may be some * serious trouble within the library. */ /** * XML_CAST_FPTR: * @fptr: pointer to a function * * Macro to do a casting from an object pointer to a * function pointer without encountering a warning from * gcc * * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr)) * This macro violated ISO C aliasing rules (gcc4 on s390 broke) * so it is disabled now */ #define XML_CAST_FPTR(fptr) fptr /* * function types: */ /** * xmlHashDeallocator: * @payload: the data in the hash * @name: the name associated * * Callback to free data from a hash. */ typedef void (*xmlHashDeallocator)(void *payload, const xmlChar *name); /** * xmlHashCopier: * @payload: the data in the hash * @name: the name associated * * Callback to copy data from a hash. * * Returns a copy of the data or NULL in case of error. */ typedef void *(*xmlHashCopier)(void *payload, const xmlChar *name); /** * xmlHashScanner: * @payload: the data in the hash * @data: extra scanner data * @name: the name associated * * Callback when scanning data in a hash with the simple scanner. */ typedef void (*xmlHashScanner)(void *payload, void *data, const xmlChar *name); /** * xmlHashScannerFull: * @payload: the data in the hash * @data: extra scanner data * @name: the name associated * @name2: the second name associated * @name3: the third name associated * * Callback when scanning data in a hash with the full scanner. */ typedef void (*xmlHashScannerFull)(void *payload, void *data, const xmlChar *name, const xmlChar *name2, const xmlChar *name3); /* * Constructor and destructor. */ XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreate (int size); XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict); XMLPUBFUN void XMLCALL xmlHashFree (xmlHashTablePtr table, xmlHashDeallocator f); XMLPUBFUN void XMLCALL xmlHashDefaultDeallocator(void *entry, const xmlChar *name); /* * Add a new entry to the hash table. */ XMLPUBFUN int XMLCALL xmlHashAddEntry (xmlHashTablePtr table, const xmlChar *name, void *userdata); XMLPUBFUN int XMLCALL xmlHashUpdateEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata, xmlHashDeallocator f); XMLPUBFUN int XMLCALL xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata); XMLPUBFUN int XMLCALL xmlHashUpdateEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata, xmlHashDeallocator f); XMLPUBFUN int XMLCALL xmlHashAddEntry3(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3, void *userdata); XMLPUBFUN int XMLCALL xmlHashUpdateEntry3(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3, void *userdata, xmlHashDeallocator f); /* * Remove an entry from the hash table. */ XMLPUBFUN int XMLCALL xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name, xmlHashDeallocator f); XMLPUBFUN int XMLCALL xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, xmlHashDeallocator f); XMLPUBFUN int XMLCALL xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3, xmlHashDeallocator f); /* * Retrieve the userdata. */ XMLPUBFUN void * XMLCALL xmlHashLookup (xmlHashTablePtr table, const xmlChar *name); XMLPUBFUN void * XMLCALL xmlHashLookup2 (xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2); XMLPUBFUN void * XMLCALL xmlHashLookup3 (xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3); XMLPUBFUN void * XMLCALL xmlHashQLookup (xmlHashTablePtr table, const xmlChar *name, const xmlChar *prefix); XMLPUBFUN void * XMLCALL xmlHashQLookup2 (xmlHashTablePtr table, const xmlChar *name, const xmlChar *prefix, const xmlChar *name2, const xmlChar *prefix2); XMLPUBFUN void * XMLCALL xmlHashQLookup3 (xmlHashTablePtr table, const xmlChar *name, const xmlChar *prefix, const xmlChar *name2, const xmlChar *prefix2, const xmlChar *name3, const xmlChar *prefix3); /* * Helpers. */ XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCopy (xmlHashTablePtr table, xmlHashCopier f); XMLPUBFUN int XMLCALL xmlHashSize (xmlHashTablePtr table); XMLPUBFUN void XMLCALL xmlHashScan (xmlHashTablePtr table, xmlHashScanner f, void *data); XMLPUBFUN void XMLCALL xmlHashScan3 (xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3, xmlHashScanner f, void *data); XMLPUBFUN void XMLCALL xmlHashScanFull (xmlHashTablePtr table, xmlHashScannerFull f, void *data); XMLPUBFUN void XMLCALL xmlHashScanFull3(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3, xmlHashScannerFull f, void *data); #ifdef __cplusplus } #endif #endif /* ! __XML_HASH_H__ */ /* * Summary: API to handle XML Pointers * Description: API to handle XML Pointers * Base implementation was made accordingly to * W3C Candidate Recommendation 7 June 2000 * http://www.w3.org/TR/2000/CR-xptr-20000607 * * Added support for the element() scheme described in: * W3C Proposed Recommendation 13 November 2002 * http://www.w3.org/TR/2002/PR-xptr-element-20021113/ * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_XPTR_H__ #define __XML_XPTR_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_XPTR_ENABLED #include <libxml/tree.h> #include <libxml/xpath.h> #ifdef __cplusplus extern "C" { #endif /* * A Location Set */ typedef struct _xmlLocationSet xmlLocationSet; typedef xmlLocationSet *xmlLocationSetPtr; struct _xmlLocationSet { int locNr; /* number of locations in the set */ int locMax; /* size of the array as allocated */ xmlXPathObjectPtr *locTab;/* array of locations */ }; /* * Handling of location sets. */ XMLPUBFUN xmlLocationSetPtr XMLCALL xmlXPtrLocationSetCreate (xmlXPathObjectPtr val); XMLPUBFUN void XMLCALL xmlXPtrFreeLocationSet (xmlLocationSetPtr obj); XMLPUBFUN xmlLocationSetPtr XMLCALL xmlXPtrLocationSetMerge (xmlLocationSetPtr val1, xmlLocationSetPtr val2); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPtrNewRange (xmlNodePtr start, int startindex, xmlNodePtr end, int endindex); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPtrNewRangePoints (xmlXPathObjectPtr start, xmlXPathObjectPtr end); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPtrNewRangeNodePoint (xmlNodePtr start, xmlXPathObjectPtr end); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPtrNewRangePointNode (xmlXPathObjectPtr start, xmlNodePtr end); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPtrNewRangeNodes (xmlNodePtr start, xmlNodePtr end); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPtrNewLocationSetNodes (xmlNodePtr start, xmlNodePtr end); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPtrNewRangeNodeObject (xmlNodePtr start, xmlXPathObjectPtr end); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPtrNewCollapsedRange (xmlNodePtr start); XMLPUBFUN void XMLCALL xmlXPtrLocationSetAdd (xmlLocationSetPtr cur, xmlXPathObjectPtr val); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPtrWrapLocationSet (xmlLocationSetPtr val); XMLPUBFUN void XMLCALL xmlXPtrLocationSetDel (xmlLocationSetPtr cur, xmlXPathObjectPtr val); XMLPUBFUN void XMLCALL xmlXPtrLocationSetRemove (xmlLocationSetPtr cur, int val); /* * Functions. */ XMLPUBFUN xmlXPathContextPtr XMLCALL xmlXPtrNewContext (xmlDocPtr doc, xmlNodePtr here, xmlNodePtr origin); XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPtrEval (const xmlChar *str, xmlXPathContextPtr ctx); XMLPUBFUN void XMLCALL xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt, int nargs); XMLPUBFUN xmlNodePtr XMLCALL xmlXPtrBuildNodeList (xmlXPathObjectPtr obj); XMLPUBFUN void XMLCALL xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt); #ifdef __cplusplus } #endif #endif /* LIBXML_XPTR_ENABLED */ #endif /* __XML_XPTR_H__ */ /** * Summary: interfaces to the Catalog handling system * Description: the catalog module implements the support for * XML Catalogs and SGML catalogs * * SGML Open Technical Resolution TR9401:1997. * http://www.jclark.com/sp/catalog.htm * * XML Catalogs Working Draft 06 August 2001 * http://www.oasis-open.org/committees/entity/spec-2001-08-06.html * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_CATALOG_H__ #define __XML_CATALOG_H__ #include <stdio.h> #include <libxml/xmlversion.h> #include <libxml/xmlstring.h> #include <libxml/tree.h> #ifdef LIBXML_CATALOG_ENABLED #ifdef __cplusplus extern "C" { #endif /** * XML_CATALOGS_NAMESPACE: * * The namespace for the XML Catalogs elements. */ #define XML_CATALOGS_NAMESPACE \ (const xmlChar *) "urn:oasis:names:tc:entity:xmlns:xml:catalog" /** * XML_CATALOG_PI: * * The specific XML Catalog Processing Instruction name. */ #define XML_CATALOG_PI \ (const xmlChar *) "oasis-xml-catalog" /* * The API is voluntarily limited to general cataloging. */ typedef enum { XML_CATA_PREFER_NONE = 0, XML_CATA_PREFER_PUBLIC = 1, XML_CATA_PREFER_SYSTEM } xmlCatalogPrefer; typedef enum { XML_CATA_ALLOW_NONE = 0, XML_CATA_ALLOW_GLOBAL = 1, XML_CATA_ALLOW_DOCUMENT = 2, XML_CATA_ALLOW_ALL = 3 } xmlCatalogAllow; typedef struct _xmlCatalog xmlCatalog; typedef xmlCatalog *xmlCatalogPtr; /* * Operations on a given catalog. */ XMLPUBFUN xmlCatalogPtr XMLCALL xmlNewCatalog (int sgml); XMLPUBFUN xmlCatalogPtr XMLCALL xmlLoadACatalog (const char *filename); XMLPUBFUN xmlCatalogPtr XMLCALL xmlLoadSGMLSuperCatalog (const char *filename); XMLPUBFUN int XMLCALL xmlConvertSGMLCatalog (xmlCatalogPtr catal); XMLPUBFUN int XMLCALL xmlACatalogAdd (xmlCatalogPtr catal, const xmlChar *type, const xmlChar *orig, const xmlChar *replace); XMLPUBFUN int XMLCALL xmlACatalogRemove (xmlCatalogPtr catal, const xmlChar *value); XMLPUBFUN xmlChar * XMLCALL xmlACatalogResolve (xmlCatalogPtr catal, const xmlChar *pubID, const xmlChar *sysID); XMLPUBFUN xmlChar * XMLCALL xmlACatalogResolveSystem(xmlCatalogPtr catal, const xmlChar *sysID); XMLPUBFUN xmlChar * XMLCALL xmlACatalogResolvePublic(xmlCatalogPtr catal, const xmlChar *pubID); XMLPUBFUN xmlChar * XMLCALL xmlACatalogResolveURI (xmlCatalogPtr catal, const xmlChar *URI); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN void XMLCALL xmlACatalogDump (xmlCatalogPtr catal, FILE *out); #endif /* LIBXML_OUTPUT_ENABLED */ XMLPUBFUN void XMLCALL xmlFreeCatalog (xmlCatalogPtr catal); XMLPUBFUN int XMLCALL xmlCatalogIsEmpty (xmlCatalogPtr catal); /* * Global operations. */ XMLPUBFUN void XMLCALL xmlInitializeCatalog (void); XMLPUBFUN int XMLCALL xmlLoadCatalog (const char *filename); XMLPUBFUN void XMLCALL xmlLoadCatalogs (const char *paths); XMLPUBFUN void XMLCALL xmlCatalogCleanup (void); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN void XMLCALL xmlCatalogDump (FILE *out); #endif /* LIBXML_OUTPUT_ENABLED */ XMLPUBFUN xmlChar * XMLCALL xmlCatalogResolve (const xmlChar *pubID, const xmlChar *sysID); XMLPUBFUN xmlChar * XMLCALL xmlCatalogResolveSystem (const xmlChar *sysID); XMLPUBFUN xmlChar * XMLCALL xmlCatalogResolvePublic (const xmlChar *pubID); XMLPUBFUN xmlChar * XMLCALL xmlCatalogResolveURI (const xmlChar *URI); XMLPUBFUN int XMLCALL xmlCatalogAdd (const xmlChar *type, const xmlChar *orig, const xmlChar *replace); XMLPUBFUN int XMLCALL xmlCatalogRemove (const xmlChar *value); XMLPUBFUN xmlDocPtr XMLCALL xmlParseCatalogFile (const char *filename); XMLPUBFUN int XMLCALL xmlCatalogConvert (void); /* * Strictly minimal interfaces for per-document catalogs used * by the parser. */ XMLPUBFUN void XMLCALL xmlCatalogFreeLocal (void *catalogs); XMLPUBFUN void * XMLCALL xmlCatalogAddLocal (void *catalogs, const xmlChar *URL); XMLPUBFUN xmlChar * XMLCALL xmlCatalogLocalResolve (void *catalogs, const xmlChar *pubID, const xmlChar *sysID); XMLPUBFUN xmlChar * XMLCALL xmlCatalogLocalResolveURI(void *catalogs, const xmlChar *URI); /* * Preference settings. */ XMLPUBFUN int XMLCALL xmlCatalogSetDebug (int level); XMLPUBFUN xmlCatalogPrefer XMLCALL xmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer); XMLPUBFUN void XMLCALL xmlCatalogSetDefaults (xmlCatalogAllow allow); XMLPUBFUN xmlCatalogAllow XMLCALL xmlCatalogGetDefaults (void); /* DEPRECATED interfaces */ XMLPUBFUN const xmlChar * XMLCALL xmlCatalogGetSystem (const xmlChar *sysID); XMLPUBFUN const xmlChar * XMLCALL xmlCatalogGetPublic (const xmlChar *pubID); #ifdef __cplusplus } #endif #endif /* LIBXML_CATALOG_ENABLED */ #endif /* __XML_CATALOG_H__ */ /* * Summary: interface for the I/O interfaces used by the parser * Description: interface for the I/O interfaces used by the parser * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_IO_H__ #define __XML_IO_H__ #include <stdio.h> #include <libxml/xmlversion.h> #ifdef __cplusplus extern "C" { #endif /* * Those are the functions and datatypes for the parser input * I/O structures. */ /** * xmlInputMatchCallback: * @filename: the filename or URI * * Callback used in the I/O Input API to detect if the current handler * can provide input functionality for this resource. * * Returns 1 if yes and 0 if another Input module should be used */ typedef int (XMLCALL *xmlInputMatchCallback) (char const *filename); /** * xmlInputOpenCallback: * @filename: the filename or URI * * Callback used in the I/O Input API to open the resource * * Returns an Input context or NULL in case or error */ typedef void * (XMLCALL *xmlInputOpenCallback) (char const *filename); /** * xmlInputReadCallback: * @context: an Input context * @buffer: the buffer to store data read * @len: the length of the buffer in bytes * * Callback used in the I/O Input API to read the resource * * Returns the number of bytes read or -1 in case of error */ typedef int (XMLCALL *xmlInputReadCallback) (void * context, char * buffer, int len); /** * xmlInputCloseCallback: * @context: an Input context * * Callback used in the I/O Input API to close the resource * * Returns 0 or -1 in case of error */ typedef int (XMLCALL *xmlInputCloseCallback) (void * context); #ifdef LIBXML_OUTPUT_ENABLED /* * Those are the functions and datatypes for the library output * I/O structures. */ /** * xmlOutputMatchCallback: * @filename: the filename or URI * * Callback used in the I/O Output API to detect if the current handler * can provide output functionality for this resource. * * Returns 1 if yes and 0 if another Output module should be used */ typedef int (XMLCALL *xmlOutputMatchCallback) (char const *filename); /** * xmlOutputOpenCallback: * @filename: the filename or URI * * Callback used in the I/O Output API to open the resource * * Returns an Output context or NULL in case or error */ typedef void * (XMLCALL *xmlOutputOpenCallback) (char const *filename); /** * xmlOutputWriteCallback: * @context: an Output context * @buffer: the buffer of data to write * @len: the length of the buffer in bytes * * Callback used in the I/O Output API to write to the resource * * Returns the number of bytes written or -1 in case of error */ typedef int (XMLCALL *xmlOutputWriteCallback) (void * context, const char * buffer, int len); /** * xmlOutputCloseCallback: * @context: an Output context * * Callback used in the I/O Output API to close the resource * * Returns 0 or -1 in case of error */ typedef int (XMLCALL *xmlOutputCloseCallback) (void * context); #endif /* LIBXML_OUTPUT_ENABLED */ #ifdef __cplusplus } #endif #include <libxml/globals.h> #include <libxml/tree.h> #include <libxml/parser.h> #include <libxml/encoding.h> #ifdef __cplusplus extern "C" { #endif struct _xmlParserInputBuffer { void* context; xmlInputReadCallback readcallback; xmlInputCloseCallback closecallback; xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ xmlBufPtr buffer; /* Local buffer encoded in UTF-8 */ xmlBufPtr raw; /* if encoder != NULL buffer for raw input */ int compressed; /* -1=unknown, 0=not compressed, 1=compressed */ int error; unsigned long rawconsumed;/* amount consumed from raw */ }; #ifdef LIBXML_OUTPUT_ENABLED struct _xmlOutputBuffer { void* context; xmlOutputWriteCallback writecallback; xmlOutputCloseCallback closecallback; xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */ xmlBufPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */ xmlBufPtr conv; /* if encoder != NULL buffer for output */ int written; /* total number of byte written */ int error; }; #endif /* LIBXML_OUTPUT_ENABLED */ /* * Interfaces for input */ XMLPUBFUN void XMLCALL xmlCleanupInputCallbacks (void); XMLPUBFUN int XMLCALL xmlPopInputCallbacks (void); XMLPUBFUN void XMLCALL xmlRegisterDefaultInputCallbacks (void); XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlAllocParserInputBuffer (xmlCharEncoding enc); XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFilename (const char *URI, xmlCharEncoding enc); XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFile (FILE *file, xmlCharEncoding enc); XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFd (int fd, xmlCharEncoding enc); XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem (const char *mem, int size, xmlCharEncoding enc); XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateStatic (const char *mem, int size, xmlCharEncoding enc); XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateIO (xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc); XMLPUBFUN int XMLCALL xmlParserInputBufferRead (xmlParserInputBufferPtr in, int len); XMLPUBFUN int XMLCALL xmlParserInputBufferGrow (xmlParserInputBufferPtr in, int len); XMLPUBFUN int XMLCALL xmlParserInputBufferPush (xmlParserInputBufferPtr in, int len, const char *buf); XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer (xmlParserInputBufferPtr in); XMLPUBFUN char * XMLCALL xmlParserGetDirectory (const char *filename); XMLPUBFUN int XMLCALL xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc, xmlInputOpenCallback openFunc, xmlInputReadCallback readFunc, xmlInputCloseCallback closeFunc); xmlParserInputBufferPtr __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc); #ifdef LIBXML_OUTPUT_ENABLED /* * Interfaces for output */ XMLPUBFUN void XMLCALL xmlCleanupOutputCallbacks (void); XMLPUBFUN int XMLCALL xmlPopOutputCallbacks (void); XMLPUBFUN void XMLCALL xmlRegisterDefaultOutputCallbacks(void); XMLPUBFUN xmlOutputBufferPtr XMLCALL xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder); XMLPUBFUN xmlOutputBufferPtr XMLCALL xmlOutputBufferCreateFilename (const char *URI, xmlCharEncodingHandlerPtr encoder, int compression); XMLPUBFUN xmlOutputBufferPtr XMLCALL xmlOutputBufferCreateFile (FILE *file, xmlCharEncodingHandlerPtr encoder); XMLPUBFUN xmlOutputBufferPtr XMLCALL xmlOutputBufferCreateBuffer (xmlBufferPtr buffer, xmlCharEncodingHandlerPtr encoder); XMLPUBFUN xmlOutputBufferPtr XMLCALL xmlOutputBufferCreateFd (int fd, xmlCharEncodingHandlerPtr encoder); XMLPUBFUN xmlOutputBufferPtr XMLCALL xmlOutputBufferCreateIO (xmlOutputWriteCallback iowrite, xmlOutputCloseCallback ioclose, void *ioctx, xmlCharEncodingHandlerPtr encoder); /* Couple of APIs to get the output without digging into the buffers */ XMLPUBFUN const xmlChar * XMLCALL xmlOutputBufferGetContent (xmlOutputBufferPtr out); XMLPUBFUN size_t XMLCALL xmlOutputBufferGetSize (xmlOutputBufferPtr out); XMLPUBFUN int XMLCALL xmlOutputBufferWrite (xmlOutputBufferPtr out, int len, const char *buf); XMLPUBFUN int XMLCALL xmlOutputBufferWriteString (xmlOutputBufferPtr out, const char *str); XMLPUBFUN int XMLCALL xmlOutputBufferWriteEscape (xmlOutputBufferPtr out, const xmlChar *str, xmlCharEncodingOutputFunc escaping); XMLPUBFUN int XMLCALL xmlOutputBufferFlush (xmlOutputBufferPtr out); XMLPUBFUN int XMLCALL xmlOutputBufferClose (xmlOutputBufferPtr out); XMLPUBFUN int XMLCALL xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc, xmlOutputOpenCallback openFunc, xmlOutputWriteCallback writeFunc, xmlOutputCloseCallback closeFunc); xmlOutputBufferPtr __xmlOutputBufferCreateFilename(const char *URI, xmlCharEncodingHandlerPtr encoder, int compression); #ifdef LIBXML_HTTP_ENABLED /* This function only exists if HTTP support built into the library */ XMLPUBFUN void XMLCALL xmlRegisterHTTPPostCallbacks (void ); #endif /* LIBXML_HTTP_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */ XMLPUBFUN xmlParserInputPtr XMLCALL xmlCheckHTTPInput (xmlParserCtxtPtr ctxt, xmlParserInputPtr ret); /* * A predefined entity loader disabling network accesses */ XMLPUBFUN xmlParserInputPtr XMLCALL xmlNoNetExternalEntityLoader (const char *URL, const char *ID, xmlParserCtxtPtr ctxt); /* * xmlNormalizeWindowsPath is obsolete, don't use it. * Check xmlCanonicPath in uri.h for a better alternative. */ XMLPUBFUN xmlChar * XMLCALL xmlNormalizeWindowsPath (const xmlChar *path); XMLPUBFUN int XMLCALL xmlCheckFilename (const char *path); /** * Default 'file://' protocol callbacks */ XMLPUBFUN int XMLCALL xmlFileMatch (const char *filename); XMLPUBFUN void * XMLCALL xmlFileOpen (const char *filename); XMLPUBFUN int XMLCALL xmlFileRead (void * context, char * buffer, int len); XMLPUBFUN int XMLCALL xmlFileClose (void * context); /** * Default 'http://' protocol callbacks */ #ifdef LIBXML_HTTP_ENABLED XMLPUBFUN int XMLCALL xmlIOHTTPMatch (const char *filename); XMLPUBFUN void * XMLCALL xmlIOHTTPOpen (const char *filename); #ifdef LIBXML_OUTPUT_ENABLED XMLPUBFUN void * XMLCALL xmlIOHTTPOpenW (const char * post_uri, int compression ); #endif /* LIBXML_OUTPUT_ENABLED */ XMLPUBFUN int XMLCALL xmlIOHTTPRead (void * context, char * buffer, int len); XMLPUBFUN int XMLCALL xmlIOHTTPClose (void * context); #endif /* LIBXML_HTTP_ENABLED */ /** * Default 'ftp://' protocol callbacks */ #ifdef LIBXML_FTP_ENABLED XMLPUBFUN int XMLCALL xmlIOFTPMatch (const char *filename); XMLPUBFUN void * XMLCALL xmlIOFTPOpen (const char *filename); XMLPUBFUN int XMLCALL xmlIOFTPRead (void * context, char * buffer, int len); XMLPUBFUN int XMLCALL xmlIOFTPClose (void * context); #endif /* LIBXML_FTP_ENABLED */ #ifdef __cplusplus } #endif #endif /* __XML_IO_H__ */ /* * Summary: XML Schemastron implementation * Description: interface to the XML Schematron validity checking. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_SCHEMATRON_H__ #define __XML_SCHEMATRON_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_SCHEMATRON_ENABLED #include <libxml/tree.h> #ifdef __cplusplus extern "C" { #endif typedef enum { XML_SCHEMATRON_OUT_QUIET = 1 << 0, /* quiet no report */ XML_SCHEMATRON_OUT_TEXT = 1 << 1, /* build a textual report */ XML_SCHEMATRON_OUT_XML = 1 << 2, /* output SVRL */ XML_SCHEMATRON_OUT_ERROR = 1 << 3, /* output via xmlStructuredErrorFunc */ XML_SCHEMATRON_OUT_FILE = 1 << 8, /* output to a file descriptor */ XML_SCHEMATRON_OUT_BUFFER = 1 << 9, /* output to a buffer */ XML_SCHEMATRON_OUT_IO = 1 << 10 /* output to I/O mechanism */ } xmlSchematronValidOptions; /** * The schemas related types are kept internal */ typedef struct _xmlSchematron xmlSchematron; typedef xmlSchematron *xmlSchematronPtr; /** * xmlSchematronValidityErrorFunc: * @ctx: the validation context * @msg: the message * @...: extra arguments * * Signature of an error callback from a Schematron validation */ typedef void (*xmlSchematronValidityErrorFunc) (void *ctx, const char *msg, ...); /** * xmlSchematronValidityWarningFunc: * @ctx: the validation context * @msg: the message * @...: extra arguments * * Signature of a warning callback from a Schematron validation */ typedef void (*xmlSchematronValidityWarningFunc) (void *ctx, const char *msg, ...); /** * A schemas validation context */ typedef struct _xmlSchematronParserCtxt xmlSchematronParserCtxt; typedef xmlSchematronParserCtxt *xmlSchematronParserCtxtPtr; typedef struct _xmlSchematronValidCtxt xmlSchematronValidCtxt; typedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr; /* * Interfaces for parsing. */ XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL xmlSchematronNewParserCtxt (const char *URL); XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL xmlSchematronNewMemParserCtxt(const char *buffer, int size); XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL xmlSchematronNewDocParserCtxt(xmlDocPtr doc); XMLPUBFUN void XMLCALL xmlSchematronFreeParserCtxt (xmlSchematronParserCtxtPtr ctxt); /***** XMLPUBFUN void XMLCALL xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt, xmlSchematronValidityErrorFunc err, xmlSchematronValidityWarningFunc warn, void *ctx); XMLPUBFUN int XMLCALL xmlSchematronGetParserErrors(xmlSchematronParserCtxtPtr ctxt, xmlSchematronValidityErrorFunc * err, xmlSchematronValidityWarningFunc * warn, void **ctx); XMLPUBFUN int XMLCALL xmlSchematronIsValid (xmlSchematronValidCtxtPtr ctxt); *****/ XMLPUBFUN xmlSchematronPtr XMLCALL xmlSchematronParse (xmlSchematronParserCtxtPtr ctxt); XMLPUBFUN void XMLCALL xmlSchematronFree (xmlSchematronPtr schema); /* * Interfaces for validating */ XMLPUBFUN void XMLCALL xmlSchematronSetValidStructuredErrors( xmlSchematronValidCtxtPtr ctxt, xmlStructuredErrorFunc serror, void *ctx); /****** XMLPUBFUN void XMLCALL xmlSchematronSetValidErrors (xmlSchematronValidCtxtPtr ctxt, xmlSchematronValidityErrorFunc err, xmlSchematronValidityWarningFunc warn, void *ctx); XMLPUBFUN int XMLCALL xmlSchematronGetValidErrors (xmlSchematronValidCtxtPtr ctxt, xmlSchematronValidityErrorFunc *err, xmlSchematronValidityWarningFunc *warn, void **ctx); XMLPUBFUN int XMLCALL xmlSchematronSetValidOptions(xmlSchematronValidCtxtPtr ctxt, int options); XMLPUBFUN int XMLCALL xmlSchematronValidCtxtGetOptions(xmlSchematronValidCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlSchematronValidateOneElement (xmlSchematronValidCtxtPtr ctxt, xmlNodePtr elem); *******/ XMLPUBFUN xmlSchematronValidCtxtPtr XMLCALL xmlSchematronNewValidCtxt (xmlSchematronPtr schema, int options); XMLPUBFUN void XMLCALL xmlSchematronFreeValidCtxt (xmlSchematronValidCtxtPtr ctxt); XMLPUBFUN int XMLCALL xmlSchematronValidateDoc (xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance); #ifdef __cplusplus } #endif #endif /* LIBXML_SCHEMATRON_ENABLED */ #endif /* __XML_SCHEMATRON_H__ */ /* * Summary: internal interfaces for XML Schemas * Description: internal interfaces for the XML Schemas handling * and schema validity checking * The Schemas development is a Work In Progress. * Some of those interfaces are not guaranteed to be API or ABI stable ! * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_SCHEMA_INTERNALS_H__ #define __XML_SCHEMA_INTERNALS_H__ #include <libxml/xmlversion.h> #ifdef LIBXML_SCHEMAS_ENABLED #include <libxml/xmlregexp.h> #include <libxml/hash.h> #include <libxml/dict.h> #ifdef __cplusplus extern "C" { #endif typedef enum { XML_SCHEMAS_UNKNOWN = 0, XML_SCHEMAS_STRING = 1, XML_SCHEMAS_NORMSTRING = 2, XML_SCHEMAS_DECIMAL = 3, XML_SCHEMAS_TIME = 4, XML_SCHEMAS_GDAY = 5, XML_SCHEMAS_GMONTH = 6, XML_SCHEMAS_GMONTHDAY = 7, XML_SCHEMAS_GYEAR = 8, XML_SCHEMAS_GYEARMONTH = 9, XML_SCHEMAS_DATE = 10, XML_SCHEMAS_DATETIME = 11, XML_SCHEMAS_DURATION = 12, XML_SCHEMAS_FLOAT = 13, XML_SCHEMAS_DOUBLE = 14, XML_SCHEMAS_BOOLEAN = 15, XML_SCHEMAS_TOKEN = 16, XML_SCHEMAS_LANGUAGE = 17, XML_SCHEMAS_NMTOKEN = 18, XML_SCHEMAS_NMTOKENS = 19, XML_SCHEMAS_NAME = 20, XML_SCHEMAS_QNAME = 21, XML_SCHEMAS_NCNAME = 22, XML_SCHEMAS_ID = 23, XML_SCHEMAS_IDREF = 24, XML_SCHEMAS_IDREFS = 25, XML_SCHEMAS_ENTITY = 26, XML_SCHEMAS_ENTITIES = 27, XML_SCHEMAS_NOTATION = 28, XML_SCHEMAS_ANYURI = 29, XML_SCHEMAS_INTEGER = 30, XML_SCHEMAS_NPINTEGER = 31, XML_SCHEMAS_NINTEGER = 32, XML_SCHEMAS_NNINTEGER = 33, XML_SCHEMAS_PINTEGER = 34, XML_SCHEMAS_INT = 35, XML_SCHEMAS_UINT = 36, XML_SCHEMAS_LONG = 37, XML_SCHEMAS_ULONG = 38, XML_SCHEMAS_SHORT = 39, XML_SCHEMAS_USHORT = 40, XML_SCHEMAS_BYTE = 41, XML_SCHEMAS_UBYTE = 42, XML_SCHEMAS_HEXBINARY = 43, XML_SCHEMAS_BASE64BINARY = 44, XML_SCHEMAS_ANYTYPE = 45, XML_SCHEMAS_ANYSIMPLETYPE = 46 } xmlSchemaValType; /* * XML Schemas defines multiple type of types. */ typedef enum { XML_SCHEMA_TYPE_BASIC = 1, /* A built-in datatype */ XML_SCHEMA_TYPE_ANY, XML_SCHEMA_TYPE_FACET, XML_SCHEMA_TYPE_SIMPLE, XML_SCHEMA_TYPE_COMPLEX, XML_SCHEMA_TYPE_SEQUENCE = 6, XML_SCHEMA_TYPE_CHOICE, XML_SCHEMA_TYPE_ALL, XML_SCHEMA_TYPE_SIMPLE_CONTENT, XML_SCHEMA_TYPE_COMPLEX_CONTENT, XML_SCHEMA_TYPE_UR, XML_SCHEMA_TYPE_RESTRICTION, XML_SCHEMA_TYPE_EXTENSION, XML_SCHEMA_TYPE_ELEMENT, XML_SCHEMA_TYPE_ATTRIBUTE, XML_SCHEMA_TYPE_ATTRIBUTEGROUP, XML_SCHEMA_TYPE_GROUP, XML_SCHEMA_TYPE_NOTATION, XML_SCHEMA_TYPE_LIST, XML_SCHEMA_TYPE_UNION, XML_SCHEMA_TYPE_ANY_ATTRIBUTE, XML_SCHEMA_TYPE_IDC_UNIQUE, XML_SCHEMA_TYPE_IDC_KEY, XML_SCHEMA_TYPE_IDC_KEYREF, XML_SCHEMA_TYPE_PARTICLE = 25, XML_SCHEMA_TYPE_ATTRIBUTE_USE, XML_SCHEMA_FACET_MININCLUSIVE = 1000, XML_SCHEMA_FACET_MINEXCLUSIVE, XML_SCHEMA_FACET_MAXINCLUSIVE, XML_SCHEMA_FACET_MAXEXCLUSIVE, XML_SCHEMA_FACET_TOTALDIGITS, XML_SCHEMA_FACET_FRACTIONDIGITS, XML_SCHEMA_FACET_PATTERN, XML_SCHEMA_FACET_ENUMERATION, XML_SCHEMA_FACET_WHITESPACE, XML_SCHEMA_FACET_LENGTH, XML_SCHEMA_FACET_MAXLENGTH, XML_SCHEMA_FACET_MINLENGTH, XML_SCHEMA_EXTRA_QNAMEREF = 2000, XML_SCHEMA_EXTRA_ATTR_USE_PROHIB } xmlSchemaTypeType; typedef enum { XML_SCHEMA_CONTENT_UNKNOWN = 0, XML_SCHEMA_CONTENT_EMPTY = 1, XML_SCHEMA_CONTENT_ELEMENTS, XML_SCHEMA_CONTENT_MIXED, XML_SCHEMA_CONTENT_SIMPLE, XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS, /* Obsolete */ XML_SCHEMA_CONTENT_BASIC, XML_SCHEMA_CONTENT_ANY } xmlSchemaContentType; typedef struct _xmlSchemaVal xmlSchemaVal; typedef xmlSchemaVal *xmlSchemaValPtr; typedef struct _xmlSchemaType xmlSchemaType; typedef xmlSchemaType *xmlSchemaTypePtr; typedef struct _xmlSchemaFacet xmlSchemaFacet; typedef xmlSchemaFacet *xmlSchemaFacetPtr; /** * Annotation */ typedef struct _xmlSchemaAnnot xmlSchemaAnnot; typedef xmlSchemaAnnot *xmlSchemaAnnotPtr; struct _xmlSchemaAnnot { struct _xmlSchemaAnnot *next; xmlNodePtr content; /* the annotation */ }; /** * XML_SCHEMAS_ANYATTR_SKIP: * * Skip unknown attribute from validation * Obsolete, not used anymore. */ #define XML_SCHEMAS_ANYATTR_SKIP 1 /** * XML_SCHEMAS_ANYATTR_LAX: * * Ignore validation non definition on attributes * Obsolete, not used anymore. */ #define XML_SCHEMAS_ANYATTR_LAX 2 /** * XML_SCHEMAS_ANYATTR_STRICT: * * Apply strict validation rules on attributes * Obsolete, not used anymore. */ #define XML_SCHEMAS_ANYATTR_STRICT 3 /** * XML_SCHEMAS_ANY_SKIP: * * Skip unknown attribute from validation */ #define XML_SCHEMAS_ANY_SKIP 1 /** * XML_SCHEMAS_ANY_LAX: * * Used by wildcards. * Validate if type found, don't worry if not found */ #define XML_SCHEMAS_ANY_LAX 2 /** * XML_SCHEMAS_ANY_STRICT: * * Used by wildcards. * Apply strict validation rules */ #define XML_SCHEMAS_ANY_STRICT 3 /** * XML_SCHEMAS_ATTR_USE_PROHIBITED: * * Used by wildcards. * The attribute is prohibited. */ #define XML_SCHEMAS_ATTR_USE_PROHIBITED 0 /** * XML_SCHEMAS_ATTR_USE_REQUIRED: * * The attribute is required. */ #define XML_SCHEMAS_ATTR_USE_REQUIRED 1 /** * XML_SCHEMAS_ATTR_USE_OPTIONAL: * * The attribute is optional. */ #define XML_SCHEMAS_ATTR_USE_OPTIONAL 2 /** * XML_SCHEMAS_ATTR_GLOBAL: * * allow elements in no namespace */ #define XML_SCHEMAS_ATTR_GLOBAL 1 << 0 /** * XML_SCHEMAS_ATTR_NSDEFAULT: * * allow elements in no namespace */ #define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7 /** * XML_SCHEMAS_ATTR_INTERNAL_RESOLVED: * * this is set when the "type" and "ref" references * have been resolved. */ #define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED 1 << 8 /** * XML_SCHEMAS_ATTR_FIXED: * * the attribute has a fixed value */ #define XML_SCHEMAS_ATTR_FIXED 1 << 9 /** * xmlSchemaAttribute: * An attribute definition. */ typedef struct _xmlSchemaAttribute xmlSchemaAttribute; typedef xmlSchemaAttribute *xmlSchemaAttributePtr; struct _xmlSchemaAttribute { xmlSchemaTypeType type; struct _xmlSchemaAttribute *next; /* the next attribute (not used?) */ const xmlChar *name; /* the name of the declaration */ const xmlChar *id; /* Deprecated; not used */ const xmlChar *ref; /* Deprecated; not used */ const xmlChar *refNs; /* Deprecated; not used */ const xmlChar *typeName; /* the local name of the type definition */ const xmlChar *typeNs; /* the ns URI of the type definition */ xmlSchemaAnnotPtr annot; xmlSchemaTypePtr base; /* Deprecated; not used */ int occurs; /* Deprecated; not used */ const xmlChar *defValue; /* The initial value of the value constraint */ xmlSchemaTypePtr subtypes; /* the type definition */ xmlNodePtr node; const xmlChar *targetNamespace; int flags; const xmlChar *refPrefix; /* Deprecated; not used */ xmlSchemaValPtr defVal; /* The compiled value constraint */ xmlSchemaAttributePtr refDecl; /* Deprecated; not used */ }; /** * xmlSchemaAttributeLink: * Used to build a list of attribute uses on complexType definitions. * WARNING: Deprecated; not used. */ typedef struct _xmlSchemaAttributeLink xmlSchemaAttributeLink; typedef xmlSchemaAttributeLink *xmlSchemaAttributeLinkPtr; struct _xmlSchemaAttributeLink { struct _xmlSchemaAttributeLink *next;/* the next attribute link ... */ struct _xmlSchemaAttribute *attr;/* the linked attribute */ }; /** * XML_SCHEMAS_WILDCARD_COMPLETE: * * If the wildcard is complete. */ #define XML_SCHEMAS_WILDCARD_COMPLETE 1 << 0 /** * xmlSchemaCharValueLink: * Used to build a list of namespaces on wildcards. */ typedef struct _xmlSchemaWildcardNs xmlSchemaWildcardNs; typedef xmlSchemaWildcardNs *xmlSchemaWildcardNsPtr; struct _xmlSchemaWildcardNs { struct _xmlSchemaWildcardNs *next;/* the next constraint link ... */ const xmlChar *value;/* the value */ }; /** * xmlSchemaWildcard. * A wildcard. */ typedef struct _xmlSchemaWildcard xmlSchemaWildcard; typedef xmlSchemaWildcard *xmlSchemaWildcardPtr; struct _xmlSchemaWildcard { xmlSchemaTypeType type; /* The kind of type */ const xmlChar *id; /* Deprecated; not used */ xmlSchemaAnnotPtr annot; xmlNodePtr node; int minOccurs; /* Deprecated; not used */ int maxOccurs; /* Deprecated; not used */ int processContents; int any; /* Indicates if the ns constraint is of ##any */ xmlSchemaWildcardNsPtr nsSet; /* The list of allowed namespaces */ xmlSchemaWildcardNsPtr negNsSet; /* The negated namespace */ int flags; }; /** * XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED: * * The attribute wildcard has been built. */ #define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0 /** * XML_SCHEMAS_ATTRGROUP_GLOBAL: * * The attribute group has been defined. */ #define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1 /** * XML_SCHEMAS_ATTRGROUP_MARKED: * * Marks the attr group as marked; used for circular checks. */ #define XML_SCHEMAS_ATTRGROUP_MARKED 1 << 2 /** * XML_SCHEMAS_ATTRGROUP_REDEFINED: * * The attr group was redefined. */ #define XML_SCHEMAS_ATTRGROUP_REDEFINED 1 << 3 /** * XML_SCHEMAS_ATTRGROUP_HAS_REFS: * * Whether this attr. group contains attr. group references. */ #define XML_SCHEMAS_ATTRGROUP_HAS_REFS 1 << 4 /** * An attribute group definition. * * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures * must be kept similar */ typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup; typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr; struct _xmlSchemaAttributeGroup { xmlSchemaTypeType type; /* The kind of type */ struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */ const xmlChar *name; const xmlChar *id; const xmlChar *ref; /* Deprecated; not used */ const xmlChar *refNs; /* Deprecated; not used */ xmlSchemaAnnotPtr annot; xmlSchemaAttributePtr attributes; /* Deprecated; not used */ xmlNodePtr node; int flags; xmlSchemaWildcardPtr attributeWildcard; const xmlChar *refPrefix; /* Deprecated; not used */ xmlSchemaAttributeGroupPtr refItem; /* Deprecated; not used */ const xmlChar *targetNamespace; void *attrUses; }; /** * xmlSchemaTypeLink: * Used to build a list of types (e.g. member types of * simpleType with variety "union"). */ typedef struct _xmlSchemaTypeLink xmlSchemaTypeLink; typedef xmlSchemaTypeLink *xmlSchemaTypeLinkPtr; struct _xmlSchemaTypeLink { struct _xmlSchemaTypeLink *next;/* the next type link ... */ xmlSchemaTypePtr type;/* the linked type */ }; /** * xmlSchemaFacetLink: * Used to build a list of facets. */ typedef struct _xmlSchemaFacetLink xmlSchemaFacetLink; typedef xmlSchemaFacetLink *xmlSchemaFacetLinkPtr; struct _xmlSchemaFacetLink { struct _xmlSchemaFacetLink *next;/* the next facet link ... */ xmlSchemaFacetPtr facet;/* the linked facet */ }; /** * XML_SCHEMAS_TYPE_MIXED: * * the element content type is mixed */ #define XML_SCHEMAS_TYPE_MIXED 1 << 0 /** * XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION: * * the simple or complex type has a derivation method of "extension". */ #define XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION 1 << 1 /** * XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION: * * the simple or complex type has a derivation method of "restriction". */ #define XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION 1 << 2 /** * XML_SCHEMAS_TYPE_GLOBAL: * * the type is global */ #define XML_SCHEMAS_TYPE_GLOBAL 1 << 3 /** * XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD: * * the complexType owns an attribute wildcard, i.e. * it can be freed by the complexType */ #define XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD 1 << 4 /* Obsolete. */ /** * XML_SCHEMAS_TYPE_VARIETY_ABSENT: * * the simpleType has a variety of "absent". * TODO: Actually not necessary :-/, since if * none of the variety flags occur then it's * automatically absent. */ #define XML_SCHEMAS_TYPE_VARIETY_ABSENT 1 << 5 /** * XML_SCHEMAS_TYPE_VARIETY_LIST: * * the simpleType has a variety of "list". */ #define XML_SCHEMAS_TYPE_VARIETY_LIST 1 << 6 /** * XML_SCHEMAS_TYPE_VARIETY_UNION: * * the simpleType has a variety of "union". */ #define XML_SCHEMAS_TYPE_VARIETY_UNION 1 << 7 /** * XML_SCHEMAS_TYPE_VARIETY_ATOMIC: * * the simpleType has a variety of "union". */ #define XML_SCHEMAS_TYPE_VARIETY_ATOMIC 1 << 8 /** * XML_SCHEMAS_TYPE_FINAL_EXTENSION: * * the complexType has a final of "extension". */ #define XML_SCHEMAS_TYPE_FINAL_EXTENSION 1 << 9 /** * XML_SCHEMAS_TYPE_FINAL_RESTRICTION: * * the simpleType/complexType has a final of "restriction". */ #define XML_SCHEMAS_TYPE_FINAL_RESTRICTION 1 << 10 /** * XML_SCHEMAS_TYPE_FINAL_LIST: * * the simpleType has a final of "list". */ #define XML_SCHEMAS_TYPE_FINAL_LIST 1 << 11 /** * XML_SCHEMAS_TYPE_FINAL_UNION: * * the simpleType has a final of "union". */ #define XML_SCHEMAS_TYPE_FINAL_UNION 1 << 12 /** * XML_SCHEMAS_TYPE_FINAL_DEFAULT: * * the simpleType has a final of "default". */ #define XML_SCHEMAS_TYPE_FINAL_DEFAULT 1 << 13 /** * XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE: * * Marks the item as a builtin primitive. */ #define XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE 1 << 14 /** * XML_SCHEMAS_TYPE_MARKED: * * Marks the item as marked; used for circular checks. */ #define XML_SCHEMAS_TYPE_MARKED 1 << 16 /** * XML_SCHEMAS_TYPE_BLOCK_DEFAULT: * * the complexType did not specify 'block' so use the default of the * <schema> item. */ #define XML_SCHEMAS_TYPE_BLOCK_DEFAULT 1 << 17 /** * XML_SCHEMAS_TYPE_BLOCK_EXTENSION: * * the complexType has a 'block' of "extension". */ #define XML_SCHEMAS_TYPE_BLOCK_EXTENSION 1 << 18 /** * XML_SCHEMAS_TYPE_BLOCK_RESTRICTION: * * the complexType has a 'block' of "restriction". */ #define XML_SCHEMAS_TYPE_BLOCK_RESTRICTION 1 << 19 /** * XML_SCHEMAS_TYPE_ABSTRACT: * * the simple/complexType is abstract. */ #define XML_SCHEMAS_TYPE_ABSTRACT 1 << 20 /** * XML_SCHEMAS_TYPE_FACETSNEEDVALUE: * * indicates if the facets need a computed value */ #define XML_SCHEMAS_TYPE_FACETSNEEDVALUE 1 << 21 /** * XML_SCHEMAS_TYPE_INTERNAL_RESOLVED: * * indicates that the type was typefixed */ #define XML_SCHEMAS_TYPE_INTERNAL_RESOLVED 1 << 22 /** * XML_SCHEMAS_TYPE_INTERNAL_INVALID: * * indicates that the type is invalid */ #define XML_SCHEMAS_TYPE_INTERNAL_INVALID 1 << 23 /** * XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE: * * a whitespace-facet value of "preserve" */ #define XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE 1 << 24 /** * XML_SCHEMAS_TYPE_WHITESPACE_REPLACE: * * a whitespace-facet value of "replace" */ #define XML_SCHEMAS_TYPE_WHITESPACE_REPLACE 1 << 25 /** * XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE: * * a whitespace-facet value of "collapse" */ #define XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE 1 << 26 /** * XML_SCHEMAS_TYPE_HAS_FACETS: * * has facets */ #define XML_SCHEMAS_TYPE_HAS_FACETS 1 << 27 /** * XML_SCHEMAS_TYPE_NORMVALUENEEDED: * * indicates if the facets (pattern) need a normalized value */ #define XML_SCHEMAS_TYPE_NORMVALUENEEDED 1 << 28 /** * XML_SCHEMAS_TYPE_FIXUP_1: * * First stage of fixup was done. */ #define XML_SCHEMAS_TYPE_FIXUP_1 1 << 29 /** * XML_SCHEMAS_TYPE_REDEFINED: * * The type was redefined. */ #define XML_SCHEMAS_TYPE_REDEFINED 1 << 30 /** * XML_SCHEMAS_TYPE_REDEFINING: * * The type redefines an other type. */ /* #define XML_SCHEMAS_TYPE_REDEFINING 1 << 31 */ /** * _xmlSchemaType: * * Schemas type definition. */ struct _xmlSchemaType { xmlSchemaTypeType type; /* The kind of type */ struct _xmlSchemaType *next; /* the next type if in a sequence ... */ const xmlChar *name; const xmlChar *id ; /* Deprecated; not used */ const xmlChar *ref; /* Deprecated; not used */ const xmlChar *refNs; /* Deprecated; not used */ xmlSchemaAnnotPtr annot; xmlSchemaTypePtr subtypes; xmlSchemaAttributePtr attributes; /* Deprecated; not used */ xmlNodePtr node; int minOccurs; /* Deprecated; not used */ int maxOccurs; /* Deprecated; not used */ int flags; xmlSchemaContentType contentType; const xmlChar *base; /* Base type's local name */ const xmlChar *baseNs; /* Base type's target namespace */ xmlSchemaTypePtr baseType; /* The base type component */ xmlSchemaFacetPtr facets; /* Local facets */ struct _xmlSchemaType *redef; /* Deprecated; not used */ int recurse; /* Obsolete */ xmlSchemaAttributeLinkPtr *attributeUses; /* Deprecated; not used */ xmlSchemaWildcardPtr attributeWildcard; int builtInType; /* Type of built-in types. */ xmlSchemaTypeLinkPtr memberTypes; /* member-types if a union type. */ xmlSchemaFacetLinkPtr facetSet; /* All facets (incl. inherited) */ const xmlChar *refPrefix; /* Deprecated; not used */ xmlSchemaTypePtr contentTypeDef; /* Used for the simple content of complex types. Could we use @subtypes for this? */ xmlRegexpPtr contModel; /* Holds the automaton of the content model */ const xmlChar *targetNamespace; void *attrUses; }; /* * xmlSchemaElement: * An element definition. * * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of * structures must be kept similar */ /** * XML_SCHEMAS_ELEM_NILLABLE: * * the element is nillable */ #define XML_SCHEMAS_ELEM_NILLABLE 1 << 0 /** * XML_SCHEMAS_ELEM_GLOBAL: * * the element is global */ #define XML_SCHEMAS_ELEM_GLOBAL 1 << 1 /** * XML_SCHEMAS_ELEM_DEFAULT: * * the element has a default value */ #define XML_SCHEMAS_ELEM_DEFAULT 1 << 2 /** * XML_SCHEMAS_ELEM_FIXED: * * the element has a fixed value */ #define XML_SCHEMAS_ELEM_FIXED 1 << 3 /** * XML_SCHEMAS_ELEM_ABSTRACT: * * the element is abstract */ #define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4 /** * XML_SCHEMAS_ELEM_TOPLEVEL: * * the element is top level * obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead */ #define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5 /** * XML_SCHEMAS_ELEM_REF: * * the element is a reference to a type */ #define XML_SCHEMAS_ELEM_REF 1 << 6 /** * XML_SCHEMAS_ELEM_NSDEFAULT: * * allow elements in no namespace * Obsolete, not used anymore. */ #define XML_SCHEMAS_ELEM_NSDEFAULT 1 << 7 /** * XML_SCHEMAS_ELEM_INTERNAL_RESOLVED: * * this is set when "type", "ref", "substitutionGroup" * references have been resolved. */ #define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED 1 << 8 /** * XML_SCHEMAS_ELEM_CIRCULAR: * * a helper flag for the search of circular references. */ #define XML_SCHEMAS_ELEM_CIRCULAR 1 << 9 /** * XML_SCHEMAS_ELEM_BLOCK_ABSENT: * * the "block" attribute is absent */ #define XML_SCHEMAS_ELEM_BLOCK_ABSENT 1 << 10 /** * XML_SCHEMAS_ELEM_BLOCK_EXTENSION: * * disallowed substitutions are absent */ #define XML_SCHEMAS_ELEM_BLOCK_EXTENSION 1 << 11 /** * XML_SCHEMAS_ELEM_BLOCK_RESTRICTION: * * disallowed substitutions: "restriction" */ #define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION 1 << 12 /** * XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION: * * disallowed substitutions: "substitution" */ #define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION 1 << 13 /** * XML_SCHEMAS_ELEM_FINAL_ABSENT: * * substitution group exclusions are absent */ #define XML_SCHEMAS_ELEM_FINAL_ABSENT 1 << 14 /** * XML_SCHEMAS_ELEM_FINAL_EXTENSION: * * substitution group exclusions: "extension" */ #define XML_SCHEMAS_ELEM_FINAL_EXTENSION 1 << 15 /** * XML_SCHEMAS_ELEM_FINAL_RESTRICTION: * * substitution group exclusions: "restriction" */ #define XML_SCHEMAS_ELEM_FINAL_RESTRICTION 1 << 16 /** * XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD: * * the declaration is a substitution group head */ #define XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD 1 << 17 /** * XML_SCHEMAS_ELEM_INTERNAL_CHECKED: * * this is set when the elem decl has been checked against * all constraints */ #define XML_SCHEMAS_ELEM_INTERNAL_CHECKED 1 << 18 typedef struct _xmlSchemaElement xmlSchemaElement; typedef xmlSchemaElement *xmlSchemaElementPtr; struct _xmlSchemaElement { xmlSchemaTypeType type; /* The kind of type */ struct _xmlSchemaType *next; /* Not used? */ const xmlChar *name; const xmlChar *id; /* Deprecated; not used */ const xmlChar *ref; /* Deprecated; not used */ const xmlChar *refNs; /* Deprecated; not used */ xmlSchemaAnnotPtr annot; xmlSchemaTypePtr subtypes; /* the type definition */ xmlSchemaAttributePtr attributes; xmlNodePtr node; int minOccurs; /* Deprecated; not used */ int maxOccurs; /* Deprecated; not used */ int flags; const xmlChar *targetNamespace; const xmlChar *namedType; const xmlChar *namedTypeNs; const xmlChar *substGroup; const xmlChar *substGroupNs; const xmlChar *scope; const xmlChar *value; /* The original value of the value constraint. */ struct _xmlSchemaElement *refDecl; /* This will now be used for the substitution group affiliation */ xmlRegexpPtr contModel; /* Obsolete for WXS, maybe used for RelaxNG */ xmlSchemaContentType contentType; const xmlChar *refPrefix; /* Deprecated; not used */ xmlSchemaValPtr defVal; /* The compiled value constraint. */ void *idcs; /* The identity-constraint defs */ }; /* * XML_SCHEMAS_FACET_UNKNOWN: * * unknown facet handling */ #define XML_SCHEMAS_FACET_UNKNOWN 0 /* * XML_SCHEMAS_FACET_PRESERVE: * * preserve the type of the facet */ #define XML_SCHEMAS_FACET_PRESERVE 1 /* * XML_SCHEMAS_FACET_REPLACE: * * replace the type of the facet */ #define XML_SCHEMAS_FACET_REPLACE 2 /* * XML_SCHEMAS_FACET_COLLAPSE: * * collapse the types of the facet */ #define XML_SCHEMAS_FACET_COLLAPSE 3 /** * A facet definition. */ struct _xmlSchemaFacet { xmlSchemaTypeType type; /* The kind of type */ struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */ const xmlChar *value; /* The original value */ const xmlChar *id; /* Obsolete */ xmlSchemaAnnotPtr annot; xmlNodePtr node; int fixed; /* XML_SCHEMAS_FACET_PRESERVE, etc. */ int whitespace; xmlSchemaValPtr val; /* The compiled value */ xmlRegexpPtr regexp; /* The regex for patterns */ }; /** * A notation definition. */ typedef struct _xmlSchemaNotation xmlSchemaNotation; typedef xmlSchemaNotation *xmlSchemaNotationPtr; struct _xmlSchemaNotation { xmlSchemaTypeType type; /* The kind of type */ const xmlChar *name; xmlSchemaAnnotPtr annot; const xmlChar *identifier; const xmlChar *targetNamespace; }; /* * TODO: Actually all those flags used for the schema should sit * on the schema parser context, since they are used only * during parsing an XML schema document, and not available * on the component level as per spec. */ /** * XML_SCHEMAS_QUALIF_ELEM: * * Reflects elementFormDefault == qualified in * an XML schema document. */ #define XML_SCHEMAS_QUALIF_ELEM 1 << 0 /** * XML_SCHEMAS_QUALIF_ATTR: * * Reflects attributeFormDefault == qualified in * an XML schema document. */ #define XML_SCHEMAS_QUALIF_ATTR 1 << 1 /** * XML_SCHEMAS_FINAL_DEFAULT_EXTENSION: * * the schema has "extension" in the set of finalDefault. */ #define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION 1 << 2 /** * XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION: * * the schema has "restriction" in the set of finalDefault. */ #define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION 1 << 3 /** * XML_SCHEMAS_FINAL_DEFAULT_LIST: * * the schema has "list" in the set of finalDefault. */ #define XML_SCHEMAS_FINAL_DEFAULT_LIST 1 << 4 /** * XML_SCHEMAS_FINAL_DEFAULT_UNION: * * the schema has "union" in the set of finalDefault. */ #define XML_SCHEMAS_FINAL_DEFAULT_UNION 1 << 5 /** * XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION: * * the schema has "extension" in the set of blockDefault. */ #define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION 1 << 6 /** * XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION: * * the schema has "restriction" in the set of blockDefault. */ #define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION 1 << 7 /** * XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION: * * the schema has "substitution" in the set of blockDefault. */ #define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION 1 << 8 /** * XML_SCHEMAS_INCLUDING_CONVERT_NS: * * the schema is currently including an other schema with * no target namespace. */ #define XML_SCHEMAS_INCLUDING_CONVERT_NS 1 << 9 /** * _xmlSchema: * * A Schemas definition */ struct _xmlSchema { const xmlChar *name; /* schema name */ const xmlChar *targetNamespace; /* the target namespace */ const xmlChar *version; const xmlChar *id; /* Obsolete */ xmlDocPtr doc; xmlSchemaAnnotPtr annot; int flags; xmlHashTablePtr typeDecl; xmlHashTablePtr attrDecl; xmlHashTablePtr attrgrpDecl; xmlHashTablePtr elemDecl; xmlHashTablePtr notaDecl; xmlHashTablePtr schemasImports; void *_private; /* unused by the library for users or bindings */ xmlHashTablePtr groupDecl; xmlDictPtr dict; void *includes; /* the includes, this is opaque for now */ int preserve; /* whether to free the document */ int counter; /* used to give anonymous components unique names */ xmlHashTablePtr idcDef; /* All identity-constraint defs. */ void *volatiles; /* Obsolete */ }; XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type); XMLPUBFUN void XMLCALL xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard); #ifdef __cplusplus } #endif #endif /* LIBXML_SCHEMAS_ENABLED */ #endif /* __XML_SCHEMA_INTERNALS_H__ */ /* * Summary: string dictionary * Description: dictionary of reusable strings, just used to avoid allocation * and freeing operations. * * Copy: See Copyright for the status of this software. * * Author: Daniel Veillard */ #ifndef __XML_DICT_H__ #define __XML_DICT_H__ #include <stddef.h> #include <libxml/xmlversion.h> #ifdef __cplusplus extern "C" { #endif /* * The dictionary. */ typedef struct _xmlDict xmlDict; typedef xmlDict *xmlDictPtr; /* * Initializer */ XMLPUBFUN int XMLCALL xmlInitializeDict(void); /* * Constructor and destructor. */ XMLPUBFUN xmlDictPtr XMLCALL xmlDictCreate (void); XMLPUBFUN size_t XMLCALL xmlDictSetLimit (xmlDictPtr dict, size_t limit); XMLPUBFUN size_t XMLCALL xmlDictGetUsage (xmlDictPtr dict); XMLPUBFUN xmlDictPtr XMLCALL xmlDictCreateSub(xmlDictPtr sub); XMLPUBFUN int XMLCALL xmlDictReference(xmlDictPtr dict); XMLPUBFUN void XMLCALL xmlDictFree (xmlDictPtr dict); /* * Lookup of entry in the dictionary. */ XMLPUBFUN const xmlChar * XMLCALL xmlDictLookup (xmlDictPtr dict, const xmlChar *name, int len); XMLPUBFUN const xmlChar * XMLCALL xmlDictExists (xmlDictPtr dict, const xmlChar *name, int len); XMLPUBFUN const xmlChar * XMLCALL xmlDictQLookup (xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name); XMLPUBFUN int XMLCALL xmlDictOwns (xmlDictPtr dict, const xmlChar *str); XMLPUBFUN int XMLCALL xmlDictSize (xmlDictPtr dict); /* * Cleanup function */ XMLPUBFUN void XMLCALL xmlDictCleanup (void); #ifdef __cplusplus } #endif #endif /* ! __XML_DICT_H__ */ /* * Copyright (c) 2008-2018, Dave Benson and the protobuf-c authors. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /*! \file * \mainpage Introduction * * This is [protobuf-c], a C implementation of [Protocol Buffers]. * * This file defines the public API for the `libprotobuf-c` support library. * This API includes interfaces that can be used directly by client code as well * as the interfaces used by the code generated by the `protoc-c` compiler. * * The `libprotobuf-c` support library performs the actual serialization and * deserialization of Protocol Buffers messages. It interacts with structures, * definitions, and metadata generated by the `protoc-c` compiler from .proto * files. * * \authors Dave Benson and the `protobuf-c` authors. * * \copyright 2008-2014. Licensed under the terms of the [BSD-2-Clause] license. * * [protobuf-c]: https://github.com/protobuf-c/protobuf-c * [Protocol Buffers]: https://developers.google.com/protocol-buffers/ * [BSD-2-Clause]: http://opensource.org/licenses/BSD-2-Clause * * \page gencode Generated Code * * For each enum, we generate a C enum. For each message, we generate a C * structure which can be cast to a `ProtobufCMessage`. * * For each enum and message, we generate a descriptor object that allows us to * implement a kind of reflection on the structures. * * First, some naming conventions: * * - The name of the type for enums and messages and services is camel case * (meaning WordsAreCrammedTogether) except that double underscores are used * to delimit scopes. For example, the following `.proto` file: * ~~~{.proto} package foo.bar; message BazBah { optional int32 val = 1; } ~~~ * * would generate a C type `Foo__Bar__BazBah`. * * - Identifiers for functions and globals are all lowercase, with camel case * words separated by single underscores. For example, one of the function * prototypes generated by `protoc-c` for the above example: * ~~~{.c} Foo__Bar__BazBah * foo__bar__baz_bah__unpack (ProtobufCAllocator *allocator, size_t len, const uint8_t *data); ~~~ * * - Identifiers for enum values contain an uppercase prefix which embeds the * package name and the enum type name. * * - A double underscore is used to separate further components of identifier * names. * * For example, in the name of the unpack function above, the package name * `foo.bar` has become `foo__bar`, the message name BazBah has become * `baz_bah`, and the method name is `unpack`. These are all joined with double * underscores to form the C identifier `foo__bar__baz_bah__unpack`. * * We also generate descriptor objects for messages and enums. These are * declared in the `.pb-c.h` files: * ~~~{.c} extern const ProtobufCMessageDescriptor foo__bar__baz_bah__descriptor; ~~~ * * The message structures all begin with `ProtobufCMessageDescriptor *` which is * sufficient to allow them to be cast to `ProtobufCMessage`. * * For each message defined in a `.proto` file, we generate a number of * functions and macros. Each function name contains a prefix based on the * package name and message name in order to make it a unique C identifier. * * - `INIT`. Statically initializes a message object, initializing its * descriptor and setting its fields to default values. Uninitialized * messages cannot be processed by the protobuf-c library. * ~~~{.c} #define FOO__BAR__BAZ_BAH__INIT \ { PROTOBUF_C_MESSAGE_INIT (&foo__bar__baz_bah__descriptor), 0 } ~~~ * - `init()`. Initializes a message object, initializing its descriptor and * setting its fields to default values. Uninitialized messages cannot be * processed by the protobuf-c library. * ~~~{.c} void foo__bar__baz_bah__init (Foo__Bar__BazBah *message); ~~~ * - `unpack()`. Unpacks data for a particular message format. Note that the * `allocator` parameter is usually `NULL` to indicate that the system's * `malloc()` and `free()` functions should be used for dynamically allocating * memory. * ~~~{.c} Foo__Bar__BazBah * foo__bar__baz_bah__unpack (ProtobufCAllocator *allocator, size_t len, const uint8_t *data); ~~~ * * - `free_unpacked()`. Frees a message object obtained with the `unpack()` * method. Freeing `NULL` is allowed (the same as with `free()`). * ~~~{.c} void foo__bar__baz_bah__free_unpacked (Foo__Bar__BazBah *message, ProtobufCAllocator *allocator); ~~~ * * - `get_packed_size()`. Calculates the length in bytes of the serialized * representation of the message object. * ~~~{.c} size_t foo__bar__baz_bah__get_packed_size (const Foo__Bar__BazBah *message); ~~~ * * - `pack()`. Pack a message object into a preallocated buffer. Assumes that * the buffer is large enough. (Use `get_packed_size()` first.) * ~~~{.c} size_t foo__bar__baz_bah__pack (const Foo__Bar__BazBah *message, uint8_t *out); ~~~ * * - `pack_to_buffer()`. Packs a message into a "virtual buffer". This is an * object which defines an "append bytes" callback to consume data as it is * serialized. * ~~~{.c} size_t foo__bar__baz_bah__pack_to_buffer (const Foo__Bar__BazBah *message, ProtobufCBuffer *buffer); ~~~ * * \page pack Packing and unpacking messages * * To pack a message, first compute the packed size of the message with * protobuf_c_message_get_packed_size(), then allocate a buffer of at least * that size, then call protobuf_c_message_pack(). * * Alternatively, a message can be serialized without calculating the final size * first. Use the protobuf_c_message_pack_to_buffer() function and provide a * ProtobufCBuffer object which implements an "append" method that consumes * data. * * To unpack a message, call the protobuf_c_message_unpack() function. The * result can be cast to an object of the type that matches the descriptor for * the message. * * The result of unpacking a message should be freed with * protobuf_c_message_free_unpacked(). */ #ifndef PROTOBUF_C_H #define PROTOBUF_C_H #include <assert.h> #include <limits.h> #include <stddef.h> #include <stdint.h> #ifdef __cplusplus # define PROTOBUF_C__BEGIN_DECLS extern "C" { # define PROTOBUF_C__END_DECLS } #else # define PROTOBUF_C__BEGIN_DECLS # define PROTOBUF_C__END_DECLS #endif PROTOBUF_C__BEGIN_DECLS #if defined(_WIN32) && defined(PROTOBUF_C_USE_SHARED_LIB) # ifdef PROTOBUF_C_EXPORT # define PROTOBUF_C__API __declspec(dllexport) # else # define PROTOBUF_C__API __declspec(dllimport) # endif #else # define PROTOBUF_C__API #endif #if !defined(PROTOBUF_C__NO_DEPRECATED) && \ ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) # define PROTOBUF_C__DEPRECATED __attribute__((__deprecated__)) #else # define PROTOBUF_C__DEPRECATED #endif #ifndef PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE #define PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(enum_name) \ , _##enum_name##_IS_INT_SIZE = INT_MAX #endif #define PROTOBUF_C__SERVICE_DESCRIPTOR_MAGIC 0x14159bc3 #define PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC 0x28aaeef9 #define PROTOBUF_C__ENUM_DESCRIPTOR_MAGIC 0x114315af /* Empty string used for initializers */ extern const char protobuf_c_empty_string[]; /** * \defgroup api Public API * * This is the public API for `libprotobuf-c`. These interfaces are stable and * subject to Semantic Versioning guarantees. * * @{ */ /** * Values for the `flags` word in `ProtobufCFieldDescriptor`. */ typedef enum { /** Set if the field is repeated and marked with the `packed` option. */ PROTOBUF_C_FIELD_FLAG_PACKED = (1 << 0), /** Set if the field is marked with the `deprecated` option. */ PROTOBUF_C_FIELD_FLAG_DEPRECATED = (1 << 1), /** Set if the field is a member of a oneof (union). */ PROTOBUF_C_FIELD_FLAG_ONEOF = (1 << 2), } ProtobufCFieldFlag; /** * Message field rules. * * \see [Defining A Message Type] in the Protocol Buffers documentation. * * [Defining A Message Type]: * https://developers.google.com/protocol-buffers/docs/proto#simple */ typedef enum { /** A well-formed message must have exactly one of this field. */ PROTOBUF_C_LABEL_REQUIRED, /** * A well-formed message can have zero or one of this field (but not * more than one). */ PROTOBUF_C_LABEL_OPTIONAL, /** * This field can be repeated any number of times (including zero) in a * well-formed message. The order of the repeated values will be * preserved. */ PROTOBUF_C_LABEL_REPEATED, /** * This field has no label. This is valid only in proto3 and is * equivalent to OPTIONAL but no "has" quantifier will be consulted. */ PROTOBUF_C_LABEL_NONE, } ProtobufCLabel; /** * Field value types. * * \see [Scalar Value Types] in the Protocol Buffers documentation. * * [Scalar Value Types]: * https://developers.google.com/protocol-buffers/docs/proto#scalar */ typedef enum { PROTOBUF_C_TYPE_INT32, /**< int32 */ PROTOBUF_C_TYPE_SINT32, /**< signed int32 */ PROTOBUF_C_TYPE_SFIXED32, /**< signed int32 (4 bytes) */ PROTOBUF_C_TYPE_INT64, /**< int64 */ PROTOBUF_C_TYPE_SINT64, /**< signed int64 */ PROTOBUF_C_TYPE_SFIXED64, /**< signed int64 (8 bytes) */ PROTOBUF_C_TYPE_UINT32, /**< unsigned int32 */ PROTOBUF_C_TYPE_FIXED32, /**< unsigned int32 (4 bytes) */ PROTOBUF_C_TYPE_UINT64, /**< unsigned int64 */ PROTOBUF_C_TYPE_FIXED64, /**< unsigned int64 (8 bytes) */ PROTOBUF_C_TYPE_FLOAT, /**< float */ PROTOBUF_C_TYPE_DOUBLE, /**< double */ PROTOBUF_C_TYPE_BOOL, /**< boolean */ PROTOBUF_C_TYPE_ENUM, /**< enumerated type */ PROTOBUF_C_TYPE_STRING, /**< UTF-8 or ASCII string */ PROTOBUF_C_TYPE_BYTES, /**< arbitrary byte sequence */ PROTOBUF_C_TYPE_MESSAGE, /**< nested message */ } ProtobufCType; /** * Field wire types. * * \see [Message Structure] in the Protocol Buffers documentation. * * [Message Structure]: * https://developers.google.com/protocol-buffers/docs/encoding#structure */ typedef enum { PROTOBUF_C_WIRE_TYPE_VARINT = 0, PROTOBUF_C_WIRE_TYPE_64BIT = 1, PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED = 2, /* "Start group" and "end group" wire types are unsupported. */ PROTOBUF_C_WIRE_TYPE_32BIT = 5, } ProtobufCWireType; struct ProtobufCAllocator; struct ProtobufCBinaryData; struct ProtobufCBuffer; struct ProtobufCBufferSimple; struct ProtobufCEnumDescriptor; struct ProtobufCEnumValue; struct ProtobufCEnumValueIndex; struct ProtobufCFieldDescriptor; struct ProtobufCIntRange; struct ProtobufCMessage; struct ProtobufCMessageDescriptor; struct ProtobufCMessageUnknownField; struct ProtobufCMethodDescriptor; struct ProtobufCService; struct ProtobufCServiceDescriptor; typedef struct ProtobufCAllocator ProtobufCAllocator; typedef struct ProtobufCBinaryData ProtobufCBinaryData; typedef struct ProtobufCBuffer ProtobufCBuffer; typedef struct ProtobufCBufferSimple ProtobufCBufferSimple; typedef struct ProtobufCEnumDescriptor ProtobufCEnumDescriptor; typedef struct ProtobufCEnumValue ProtobufCEnumValue; typedef struct ProtobufCEnumValueIndex ProtobufCEnumValueIndex; typedef struct ProtobufCFieldDescriptor ProtobufCFieldDescriptor; typedef struct ProtobufCIntRange ProtobufCIntRange; typedef struct ProtobufCMessage ProtobufCMessage; typedef struct ProtobufCMessageDescriptor ProtobufCMessageDescriptor; typedef struct ProtobufCMessageUnknownField ProtobufCMessageUnknownField; typedef struct ProtobufCMethodDescriptor ProtobufCMethodDescriptor; typedef struct ProtobufCService ProtobufCService; typedef struct ProtobufCServiceDescriptor ProtobufCServiceDescriptor; /** Boolean type. */ typedef int protobuf_c_boolean; typedef void (*ProtobufCClosure)(const ProtobufCMessage *, void *closure_data); typedef void (*ProtobufCMessageInit)(ProtobufCMessage *); typedef void (*ProtobufCServiceDestroy)(ProtobufCService *); /** * Structure for defining a custom memory allocator. */ struct ProtobufCAllocator { /** Function to allocate memory. */ void *(*alloc)(void *allocator_data, size_t size); /** Function to free memory. */ void (*free)(void *allocator_data, void *pointer); /** Opaque pointer passed to `alloc` and `free` functions. */ void *allocator_data; }; /** * Structure for the protobuf `bytes` scalar type. * * The data contained in a `ProtobufCBinaryData` is an arbitrary sequence of * bytes. It may contain embedded `NUL` characters and is not required to be * `NUL`-terminated. */ struct ProtobufCBinaryData { size_t len; /**< Number of bytes in the `data` field. */ uint8_t *data; /**< Data bytes. */ }; /** * Structure for defining a virtual append-only buffer. Used by * protobuf_c_message_pack_to_buffer() to abstract the consumption of serialized * bytes. * * `ProtobufCBuffer` "subclasses" may be defined on the stack. For example, to * write to a `FILE` object: * ~~~{.c} typedef struct { ProtobufCBuffer base; FILE *fp; } BufferAppendToFile; static void my_buffer_file_append(ProtobufCBuffer *buffer, size_t len, const uint8_t *data) { BufferAppendToFile *file_buf = (BufferAppendToFile *) buffer; fwrite(data, len, 1, file_buf->fp); // XXX: No error handling! } ~~~ * * To use this new type of ProtobufCBuffer, it could be called as follows: * ~~~{.c} ... BufferAppendToFile tmp = {0}; tmp.base.append = my_buffer_file_append; tmp.fp = fp; protobuf_c_message_pack_to_buffer(&message, &tmp); ... ~~~ */ struct ProtobufCBuffer { /** Append function. Consumes the `len` bytes stored at `data`. */ void (*append)(ProtobufCBuffer *buffer, size_t len, const uint8_t *data); }; /** * Simple buffer "subclass" of `ProtobufCBuffer`. * * A `ProtobufCBufferSimple` object is declared on the stack and uses a * scratch buffer provided by the user for the initial allocation. It performs * exponential resizing, using dynamically allocated memory. A * `ProtobufCBufferSimple` object can be created and used as follows: * ~~~{.c} uint8_t pad[128]; ProtobufCBufferSimple simple = PROTOBUF_C_BUFFER_SIMPLE_INIT(pad); ProtobufCBuffer *buffer = (ProtobufCBuffer *) &simple; ~~~ * * `buffer` can now be used with `protobuf_c_message_pack_to_buffer()`. Once a * message has been serialized to a `ProtobufCBufferSimple` object, the * serialized data bytes can be accessed from the `.data` field. * * To free the memory allocated by a `ProtobufCBufferSimple` object, if any, * call PROTOBUF_C_BUFFER_SIMPLE_CLEAR() on the object, for example: * ~~~{.c} PROTOBUF_C_BUFFER_SIMPLE_CLEAR(&simple); ~~~ * * \see PROTOBUF_C_BUFFER_SIMPLE_INIT * \see PROTOBUF_C_BUFFER_SIMPLE_CLEAR */ struct ProtobufCBufferSimple { /** "Base class". */ ProtobufCBuffer base; /** Number of bytes allocated in `data`. */ size_t alloced; /** Number of bytes currently stored in `data`. */ size_t len; /** Data bytes. */ uint8_t *data; /** Whether `data` must be freed. */ protobuf_c_boolean must_free_data; /** Allocator to use. May be NULL to indicate the system allocator. */ ProtobufCAllocator *allocator; }; /** * Describes an enumeration as a whole, with all of its values. */ struct ProtobufCEnumDescriptor { /** Magic value checked to ensure that the API is used correctly. */ uint32_t magic; /** The qualified name (e.g., "namespace.Type"). */ const char *name; /** The unqualified name as given in the .proto file (e.g., "Type"). */ const char *short_name; /** Identifier used in generated C code. */ const char *c_name; /** The dot-separated namespace. */ const char *package_name; /** Number elements in `values`. */ unsigned n_values; /** Array of distinct values, sorted by numeric value. */ const ProtobufCEnumValue *values; /** Number of elements in `values_by_name`. */ unsigned n_value_names; /** Array of named values, including aliases, sorted by name. */ const ProtobufCEnumValueIndex *values_by_name; /** Number of elements in `value_ranges`. */ unsigned n_value_ranges; /** Value ranges, for faster lookups by numeric value. */ const ProtobufCIntRange *value_ranges; /** Reserved for future use. */ void *reserved1; /** Reserved for future use. */ void *reserved2; /** Reserved for future use. */ void *reserved3; /** Reserved for future use. */ void *reserved4; }; /** * Represents a single value of an enumeration. */ struct ProtobufCEnumValue { /** The string identifying this value in the .proto file. */ const char *name; /** The string identifying this value in generated C code. */ const char *c_name; /** The numeric value assigned in the .proto file. */ int value; }; /** * Used by `ProtobufCEnumDescriptor` to look up enum values. */ struct ProtobufCEnumValueIndex { /** Name of the enum value. */ const char *name; /** Index into values[] array. */ unsigned index; }; /** * Describes a single field in a message. */ struct ProtobufCFieldDescriptor { /** Name of the field as given in the .proto file. */ const char *name; /** Tag value of the field as given in the .proto file. */ uint32_t id; /** Whether the field is `REQUIRED`, `OPTIONAL`, or `REPEATED`. */ ProtobufCLabel label; /** The type of the field. */ ProtobufCType type; /** * The offset in bytes of the message's C structure's quantifier field * (the `has_MEMBER` field for optional members or the `n_MEMBER` field * for repeated members or the case enum for oneofs). */ unsigned quantifier_offset; /** * The offset in bytes into the message's C structure for the member * itself. */ unsigned offset; /** * A type-specific descriptor. * * If `type` is `PROTOBUF_C_TYPE_ENUM`, then `descriptor` points to the * corresponding `ProtobufCEnumDescriptor`. * * If `type` is `PROTOBUF_C_TYPE_MESSAGE`, then `descriptor` points to * the corresponding `ProtobufCMessageDescriptor`. * * Otherwise this field is NULL. */ const void *descriptor; /* for MESSAGE and ENUM types */ /** The default value for this field, if defined. May be NULL. */ const void *default_value; /** * A flag word. Zero or more of the bits defined in the * `ProtobufCFieldFlag` enum may be set. */ uint32_t flags; /** Reserved for future use. */ unsigned reserved_flags; /** Reserved for future use. */ void *reserved2; /** Reserved for future use. */ void *reserved3; }; /** * Helper structure for optimizing int => index lookups in the case * where the keys are mostly consecutive values, as they presumably are for * enums and fields. * * The data structures requires that the values in the original array are * sorted. */ struct ProtobufCIntRange { int start_value; unsigned orig_index; /* * NOTE: the number of values in the range can be inferred by looking * at the next element's orig_index. A dummy element is added to make * this simple. */ }; /** * An instance of a message. * * `ProtobufCMessage` is a light-weight "base class" for all messages. * * In particular, `ProtobufCMessage` doesn't have any allocation policy * associated with it. That's because it's common to create `ProtobufCMessage` * objects on the stack. In fact, that's what we recommend for sending messages. * If the object is allocated from the stack, you can't really have a memory * leak. * * This means that calls to functions like protobuf_c_message_unpack() which * return a `ProtobufCMessage` must be paired with a call to a free function, * like protobuf_c_message_free_unpacked(). */ struct ProtobufCMessage { /** The descriptor for this message type. */ const ProtobufCMessageDescriptor *descriptor; /** The number of elements in `unknown_fields`. */ unsigned n_unknown_fields; /** The fields that weren't recognized by the parser. */ ProtobufCMessageUnknownField *unknown_fields; }; /** * Describes a message. */ struct ProtobufCMessageDescriptor { /** Magic value checked to ensure that the API is used correctly. */ uint32_t magic; /** The qualified name (e.g., "namespace.Type"). */ const char *name; /** The unqualified name as given in the .proto file (e.g., "Type"). */ const char *short_name; /** Identifier used in generated C code. */ const char *c_name; /** The dot-separated namespace. */ const char *package_name; /** * Size in bytes of the C structure representing an instance of this * type of message. */ size_t sizeof_message; /** Number of elements in `fields`. */ unsigned n_fields; /** Field descriptors, sorted by tag number. */ const ProtobufCFieldDescriptor *fields; /** Used for looking up fields by name. */ const unsigned *fields_sorted_by_name; /** Number of elements in `field_ranges`. */ unsigned n_field_ranges; /** Used for looking up fields by id. */ const ProtobufCIntRange *field_ranges; /** Message initialisation function. */ ProtobufCMessageInit message_init; /** Reserved for future use. */ void *reserved1; /** Reserved for future use. */ void *reserved2; /** Reserved for future use. */ void *reserved3; }; /** * An unknown message field. */ struct ProtobufCMessageUnknownField { /** The tag number. */ uint32_t tag; /** The wire type of the field. */ ProtobufCWireType wire_type; /** Number of bytes in `data`. */ size_t len; /** Field data. */ uint8_t *data; }; /** * Method descriptor. */ struct ProtobufCMethodDescriptor { /** Method name. */ const char *name; /** Input message descriptor. */ const ProtobufCMessageDescriptor *input; /** Output message descriptor. */ const ProtobufCMessageDescriptor *output; }; /** * Service. */ struct ProtobufCService { /** Service descriptor. */ const ProtobufCServiceDescriptor *descriptor; /** Function to invoke the service. */ void (*invoke)(ProtobufCService *service, unsigned method_index, const ProtobufCMessage *input, ProtobufCClosure closure, void *closure_data); /** Function to destroy the service. */ void (*destroy)(ProtobufCService *service); }; /** * Service descriptor. */ struct ProtobufCServiceDescriptor { /** Magic value checked to ensure that the API is used correctly. */ uint32_t magic; /** Service name. */ const char *name; /** Short version of service name. */ const char *short_name; /** C identifier for the service name. */ const char *c_name; /** Package name. */ const char *package; /** Number of elements in `methods`. */ unsigned n_methods; /** Method descriptors, in the order defined in the .proto file. */ const ProtobufCMethodDescriptor *methods; /** Sort index of methods. */ const unsigned *method_indices_by_name; }; /** * Get the version of the protobuf-c library. Note that this is the version of * the library linked against, not the version of the headers compiled against. * * \return A string containing the version number of protobuf-c. */ PROTOBUF_C__API const char * protobuf_c_version(void); /** * Get the version of the protobuf-c library. Note that this is the version of * the library linked against, not the version of the headers compiled against. * * \return A 32 bit unsigned integer containing the version number of * protobuf-c, represented in base-10 as (MAJOR*1E6) + (MINOR*1E3) + PATCH. */ PROTOBUF_C__API uint32_t protobuf_c_version_number(void); /** * The version of the protobuf-c headers, represented as a string using the same * format as protobuf_c_version(). */ #define PROTOBUF_C_VERSION "1.3.3" /** * The version of the protobuf-c headers, represented as an integer using the * same format as protobuf_c_version_number(). */ #define PROTOBUF_C_VERSION_NUMBER 1003003 /** * The minimum protoc-c version which works with the current version of the * protobuf-c headers. */ #define PROTOBUF_C_MIN_COMPILER_VERSION 1000000 /** * Look up a `ProtobufCEnumValue` from a `ProtobufCEnumDescriptor` by name. * * \param desc * The `ProtobufCEnumDescriptor` object. * \param name * The `name` field from the corresponding `ProtobufCEnumValue` object to * match. * \return * A `ProtobufCEnumValue` object. * \retval NULL * If not found or if the optimize_for = CODE_SIZE option was set. */ PROTOBUF_C__API const ProtobufCEnumValue * protobuf_c_enum_descriptor_get_value_by_name( const ProtobufCEnumDescriptor *desc, const char *name); /** * Look up a `ProtobufCEnumValue` from a `ProtobufCEnumDescriptor` by numeric * value. * * \param desc * The `ProtobufCEnumDescriptor` object. * \param value * The `value` field from the corresponding `ProtobufCEnumValue` object to * match. * * \return * A `ProtobufCEnumValue` object. * \retval NULL * If not found. */ PROTOBUF_C__API const ProtobufCEnumValue * protobuf_c_enum_descriptor_get_value( const ProtobufCEnumDescriptor *desc, int value); /** * Look up a `ProtobufCFieldDescriptor` from a `ProtobufCMessageDescriptor` by * the name of the field. * * \param desc * The `ProtobufCMessageDescriptor` object. * \param name * The name of the field. * \return * A `ProtobufCFieldDescriptor` object. * \retval NULL * If not found or if the optimize_for = CODE_SIZE option was set. */ PROTOBUF_C__API const ProtobufCFieldDescriptor * protobuf_c_message_descriptor_get_field_by_name( const ProtobufCMessageDescriptor *desc, const char *name); /** * Look up a `ProtobufCFieldDescriptor` from a `ProtobufCMessageDescriptor` by * the tag value of the field. * * \param desc * The `ProtobufCMessageDescriptor` object. * \param value * The tag value of the field. * \return * A `ProtobufCFieldDescriptor` object. * \retval NULL * If not found. */ PROTOBUF_C__API const ProtobufCFieldDescriptor * protobuf_c_message_descriptor_get_field( const ProtobufCMessageDescriptor *desc, unsigned value); /** * Determine the number of bytes required to store the serialised message. * * \param message * The message object to serialise. * \return * Number of bytes. */ PROTOBUF_C__API size_t protobuf_c_message_get_packed_size(const ProtobufCMessage *message); /** * Serialise a message from its in-memory representation. * * This function stores the serialised bytes of the message in a pre-allocated * buffer. * * \param message * The message object to serialise. * \param[out] out * Buffer to store the bytes of the serialised message. This buffer must * have enough space to store the packed message. Use * protobuf_c_message_get_packed_size() to determine the number of bytes * required. * \return * Number of bytes stored in `out`. */ PROTOBUF_C__API size_t protobuf_c_message_pack(const ProtobufCMessage *message, uint8_t *out); /** * Serialise a message from its in-memory representation to a virtual buffer. * * This function calls the `append` method of a `ProtobufCBuffer` object to * consume the bytes generated by the serialiser. * * \param message * The message object to serialise. * \param buffer * The virtual buffer object. * \return * Number of bytes passed to the virtual buffer. */ PROTOBUF_C__API size_t protobuf_c_message_pack_to_buffer( const ProtobufCMessage *message, ProtobufCBuffer *buffer); /** * Unpack a serialised message into an in-memory representation. * * \param descriptor * The message descriptor. * \param allocator * `ProtobufCAllocator` to use for memory allocation. May be NULL to * specify the default allocator. * \param len * Length in bytes of the serialised message. * \param data * Pointer to the serialised message. * \return * An unpacked message object. * \retval NULL * If an error occurred during unpacking. */ PROTOBUF_C__API ProtobufCMessage * protobuf_c_message_unpack( const ProtobufCMessageDescriptor *descriptor, ProtobufCAllocator *allocator, size_t len, const uint8_t *data); /** * Free an unpacked message object. * * This function should be used to deallocate the memory used by a call to * protobuf_c_message_unpack(). * * \param message * The message object to free. May be NULL. * \param allocator * `ProtobufCAllocator` to use for memory deallocation. May be NULL to * specify the default allocator. */ PROTOBUF_C__API void protobuf_c_message_free_unpacked( ProtobufCMessage *message, ProtobufCAllocator *allocator); /** * Check the validity of a message object. * * Makes sure all required fields (`PROTOBUF_C_LABEL_REQUIRED`) are present. * Recursively checks nested messages. * * \retval TRUE * Message is valid. * \retval FALSE * Message is invalid. */ PROTOBUF_C__API protobuf_c_boolean protobuf_c_message_check(const ProtobufCMessage *); /** Message initialiser. */ #define PROTOBUF_C_MESSAGE_INIT(descriptor) { descriptor, 0, NULL } /** * Initialise a message object from a message descriptor. * * \param descriptor * Message descriptor. * \param message * Allocated block of memory of size `descriptor->sizeof_message`. */ PROTOBUF_C__API void protobuf_c_message_init( const ProtobufCMessageDescriptor *descriptor, void *message); /** * Free a service. * * \param service * The service object to free. */ PROTOBUF_C__API void protobuf_c_service_destroy(ProtobufCService *service); /** * Look up a `ProtobufCMethodDescriptor` by name. * * \param desc * Service descriptor. * \param name * Name of the method. * * \return * A `ProtobufCMethodDescriptor` object. * \retval NULL * If not found or if the optimize_for = CODE_SIZE option was set. */ PROTOBUF_C__API const ProtobufCMethodDescriptor * protobuf_c_service_descriptor_get_method_by_name( const ProtobufCServiceDescriptor *desc, const char *name); /** * Initialise a `ProtobufCBufferSimple` object. */ #define PROTOBUF_C_BUFFER_SIMPLE_INIT(array_of_bytes) \ { \ { protobuf_c_buffer_simple_append }, \ sizeof(array_of_bytes), \ 0, \ (array_of_bytes), \ 0, \ NULL \ } /** * Clear a `ProtobufCBufferSimple` object, freeing any allocated memory. */ #define PROTOBUF_C_BUFFER_SIMPLE_CLEAR(simp_buf) \ do { \ if ((simp_buf)->must_free_data) { \ if ((simp_buf)->allocator != NULL) \ (simp_buf)->allocator->free( \ (simp_buf)->allocator, \ (simp_buf)->data); \ else \ free((simp_buf)->data); \ } \ } while (0) /** * The `append` method for `ProtobufCBufferSimple`. * * \param buffer * The buffer object to append to. Must actually be a * `ProtobufCBufferSimple` object. * \param len * Number of bytes in `data`. * \param data * Data to append. */ PROTOBUF_C__API void protobuf_c_buffer_simple_append( ProtobufCBuffer *buffer, size_t len, const unsigned char *data); PROTOBUF_C__API void protobuf_c_service_generated_init( ProtobufCService *service, const ProtobufCServiceDescriptor *descriptor, ProtobufCServiceDestroy destroy); PROTOBUF_C__API void protobuf_c_service_invoke_internal( ProtobufCService *service, unsigned method_index, const ProtobufCMessage *input, ProtobufCClosure closure, void *closure_data); /**@}*/ PROTOBUF_C__END_DECLS #endif /* PROTOBUF_C_H */ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software <http://www.openldap.org/>. * * Copyright 1998-2026 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP * Public License. * * A copy of this license is available in file LICENSE in the * top-level directory of the distribution or, alternatively, at * <http://www.OpenLDAP.org/license.html>. */ /* Portions Copyright (c) 1990 Regents of the University of Michigan. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that this notice is preserved and that due credit is given * to the University of Michigan at Ann Arbor. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. */ #ifndef _LDAP_H #define _LDAP_H /* pull in lber */ #include <lber.h> /* include version and API feature defines */ #include <ldap_features.h> LDAP_BEGIN_DECL #define LDAP_VERSION1 1 #define LDAP_VERSION2 2 #define LDAP_VERSION3 3 #define LDAP_VERSION_MIN LDAP_VERSION2 #define LDAP_VERSION LDAP_VERSION2 #define LDAP_VERSION_MAX LDAP_VERSION3 /* * We use 3000+n here because it is above 1823 (for RFC 1823), * above 2000+rev of IETF LDAPEXT draft (now quite dated), * yet below allocations for new RFCs (just in case there is * someday an RFC produced). */ #define LDAP_API_VERSION 3001 #define LDAP_VENDOR_NAME "OpenLDAP" /* OpenLDAP API Features */ #define LDAP_API_FEATURE_X_OPENLDAP LDAP_VENDOR_VERSION #if defined( LDAP_API_FEATURE_X_OPENLDAP_REENTRANT ) # define LDAP_API_FEATURE_THREAD_SAFE 1 #endif #if defined( LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE ) # define LDAP_API_FEATURE_SESSION_THREAD_SAFE 1 # define LDAP_API_FEATURE_OPERATION_THREAD_SAFE 1 #endif #define LDAP_PORT 389 /* ldap:/// default LDAP port */ #define LDAPS_PORT 636 /* ldaps:/// default LDAP over TLS port */ #define LDAP_ROOT_DSE "" #define LDAP_NO_ATTRS "1.1" #define LDAP_ALL_USER_ATTRIBUTES "*" #define LDAP_ALL_OPERATIONAL_ATTRIBUTES "+" /* RFC 3673 */ /* RFC 4511: maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- */ #define LDAP_MAXINT (2147483647) /* * LDAP_OPTions * 0x0000 - 0x0fff reserved for api options * 0x1000 - 0x3fff reserved for api extended options * 0x4000 - 0x7fff reserved for private and experimental options */ #define LDAP_OPT_API_INFO 0x0000 #define LDAP_OPT_DESC 0x0001 /* historic */ #define LDAP_OPT_DEREF 0x0002 #define LDAP_OPT_SIZELIMIT 0x0003 #define LDAP_OPT_TIMELIMIT 0x0004 /* 0x05 - 0x07 not defined */ #define LDAP_OPT_REFERRALS 0x0008 #define LDAP_OPT_RESTART 0x0009 /* 0x0a - 0x10 not defined */ #define LDAP_OPT_PROTOCOL_VERSION 0x0011 #define LDAP_OPT_SERVER_CONTROLS 0x0012 #define LDAP_OPT_CLIENT_CONTROLS 0x0013 /* 0x14 not defined */ #define LDAP_OPT_API_FEATURE_INFO 0x0015 /* 0x16 - 0x2f not defined */ #define LDAP_OPT_HOST_NAME 0x0030 #define LDAP_OPT_RESULT_CODE 0x0031 #define LDAP_OPT_ERROR_NUMBER LDAP_OPT_RESULT_CODE #define LDAP_OPT_DIAGNOSTIC_MESSAGE 0x0032 #define LDAP_OPT_ERROR_STRING LDAP_OPT_DIAGNOSTIC_MESSAGE #define LDAP_OPT_MATCHED_DN 0x0033 /* 0x0034 - 0x3fff not defined */ /* 0x0091 used by Microsoft for LDAP_OPT_AUTO_RECONNECT */ #define LDAP_OPT_SSPI_FLAGS 0x0092 /* 0x0093 used by Microsoft for LDAP_OPT_SSL_INFO */ /* 0x0094 used by Microsoft for LDAP_OPT_REF_DEREF_CONN_PER_MSG */ #define LDAP_OPT_SIGN 0x0095 #define LDAP_OPT_ENCRYPT 0x0096 #define LDAP_OPT_SASL_METHOD 0x0097 /* 0x0098 used by Microsoft for LDAP_OPT_AREC_EXCLUSIVE */ #define LDAP_OPT_SECURITY_CONTEXT 0x0099 /* 0x009A used by Microsoft for LDAP_OPT_ROOTDSE_CACHE */ /* 0x009B - 0x3fff not defined */ /* API Extensions */ #define LDAP_OPT_API_EXTENSION_BASE 0x4000 /* API extensions */ /* private and experimental options */ /* OpenLDAP specific options */ #define LDAP_OPT_DEBUG_LEVEL 0x5001 /* debug level */ #define LDAP_OPT_TIMEOUT 0x5002 /* default timeout */ #define LDAP_OPT_REFHOPLIMIT 0x5003 /* ref hop limit */ #define LDAP_OPT_NETWORK_TIMEOUT 0x5005 /* socket level timeout */ #define LDAP_OPT_URI 0x5006 #define LDAP_OPT_REFERRAL_URLS 0x5007 /* Referral URLs */ #define LDAP_OPT_SOCKBUF 0x5008 /* sockbuf */ #define LDAP_OPT_DEFBASE 0x5009 /* searchbase */ #define LDAP_OPT_CONNECT_ASYNC 0x5010 /* create connections asynchronously */ #define LDAP_OPT_CONNECT_CB 0x5011 /* connection callbacks */ #define LDAP_OPT_SESSION_REFCNT 0x5012 /* session reference count */ #define LDAP_OPT_KEEPCONN 0x5013 /* keep the connection on read error or NoD */ #define LDAP_OPT_SOCKET_BIND_ADDRESSES 0x5014 /* user configured bind IPs */ #define LDAP_OPT_TCP_USER_TIMEOUT 0x5015 /* set TCP_USER_TIMEOUT if the OS supports it, ignored otherwise */ /* OpenLDAP TLS options */ #define LDAP_OPT_X_TLS 0x6000 #define LDAP_OPT_X_TLS_CTX 0x6001 /* OpenSSL CTX* */ #define LDAP_OPT_X_TLS_CACERTFILE 0x6002 #define LDAP_OPT_X_TLS_CACERTDIR 0x6003 #define LDAP_OPT_X_TLS_CERTFILE 0x6004 #define LDAP_OPT_X_TLS_KEYFILE 0x6005 #define LDAP_OPT_X_TLS_REQUIRE_CERT 0x6006 #define LDAP_OPT_X_TLS_PROTOCOL_MIN 0x6007 #define LDAP_OPT_X_TLS_CIPHER_SUITE 0x6008 #define LDAP_OPT_X_TLS_RANDOM_FILE 0x6009 #define LDAP_OPT_X_TLS_SSL_CTX 0x600a /* OpenSSL SSL* */ #define LDAP_OPT_X_TLS_CRLCHECK 0x600b #define LDAP_OPT_X_TLS_CONNECT_CB 0x600c #define LDAP_OPT_X_TLS_CONNECT_ARG 0x600d #define LDAP_OPT_X_TLS_DHFILE 0x600e #define LDAP_OPT_X_TLS_NEWCTX 0x600f #define LDAP_OPT_X_TLS_CRLFILE 0x6010 /* GNUtls only */ #define LDAP_OPT_X_TLS_PACKAGE 0x6011 #define LDAP_OPT_X_TLS_ECNAME 0x6012 #define LDAP_OPT_X_TLS_VERSION 0x6013 /* read-only */ #define LDAP_OPT_X_TLS_CIPHER 0x6014 /* read-only */ #define LDAP_OPT_X_TLS_PEERCERT 0x6015 /* read-only */ #define LDAP_OPT_X_TLS_CACERT 0x6016 #define LDAP_OPT_X_TLS_CERT 0x6017 #define LDAP_OPT_X_TLS_KEY 0x6018 #define LDAP_OPT_X_TLS_PEERKEY_HASH 0x6019 #define LDAP_OPT_X_TLS_REQUIRE_SAN 0x601a #define LDAP_OPT_X_TLS_PROTOCOL_MAX 0x601b #define LDAP_OPT_X_TLS_NEVER 0 #define LDAP_OPT_X_TLS_HARD 1 #define LDAP_OPT_X_TLS_DEMAND 2 #define LDAP_OPT_X_TLS_ALLOW 3 #define LDAP_OPT_X_TLS_TRY 4 #define LDAP_OPT_X_TLS_CRL_NONE 0 #define LDAP_OPT_X_TLS_CRL_PEER 1 #define LDAP_OPT_X_TLS_CRL_ALL 2 /* for LDAP_OPT_X_TLS_PROTOCOL_MIN/MAX */ #define LDAP_OPT_X_TLS_PROTOCOL(maj,min) (((maj) << 8) + (min)) #define LDAP_OPT_X_TLS_PROTOCOL_SSL2 (2 << 8) #define LDAP_OPT_X_TLS_PROTOCOL_SSL3 (3 << 8) #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_0 ((3 << 8) + 1) #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_1 ((3 << 8) + 2) #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_2 ((3 << 8) + 3) #define LDAP_OPT_X_TLS_PROTOCOL_TLS1_3 ((3 << 8) + 4) #define LDAP_OPT_X_SASL_CBINDING_NONE 0 #define LDAP_OPT_X_SASL_CBINDING_TLS_UNIQUE 1 #define LDAP_OPT_X_SASL_CBINDING_TLS_ENDPOINT 2 /* OpenLDAP SASL options */ #define LDAP_OPT_X_SASL_MECH 0x6100 #define LDAP_OPT_X_SASL_REALM 0x6101 #define LDAP_OPT_X_SASL_AUTHCID 0x6102 #define LDAP_OPT_X_SASL_AUTHZID 0x6103 #define LDAP_OPT_X_SASL_SSF 0x6104 /* read-only */ #define LDAP_OPT_X_SASL_SSF_EXTERNAL 0x6105 /* write-only */ #define LDAP_OPT_X_SASL_SECPROPS 0x6106 /* write-only */ #define LDAP_OPT_X_SASL_SSF_MIN 0x6107 #define LDAP_OPT_X_SASL_SSF_MAX 0x6108 #define LDAP_OPT_X_SASL_MAXBUFSIZE 0x6109 #define LDAP_OPT_X_SASL_MECHLIST 0x610a /* read-only */ #define LDAP_OPT_X_SASL_NOCANON 0x610b #define LDAP_OPT_X_SASL_USERNAME 0x610c /* read-only */ #define LDAP_OPT_X_SASL_GSS_CREDS 0x610d #define LDAP_OPT_X_SASL_CBINDING 0x610e /* * OpenLDAP per connection tcp-keepalive settings * (Linux only, ignored where unsupported) */ #define LDAP_OPT_X_KEEPALIVE_IDLE 0x6300 #define LDAP_OPT_X_KEEPALIVE_PROBES 0x6301 #define LDAP_OPT_X_KEEPALIVE_INTERVAL 0x6302 /* Private API Extensions -- reserved for application use */ #define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x7000 /* Private API inclusive */ /* * ldap_get_option() and ldap_set_option() return values. * As later versions may return other values indicating * failure, current applications should only compare returned * value against LDAP_OPT_SUCCESS. */ #define LDAP_OPT_SUCCESS 0 #define LDAP_OPT_ERROR (-1) /* option on/off values */ #define LDAP_OPT_ON ((void *) &ber_pvt_opt_on) #define LDAP_OPT_OFF ((void *) 0) typedef struct ldapapiinfo { int ldapai_info_version; /* version of LDAPAPIInfo */ #define LDAP_API_INFO_VERSION (1) int ldapai_api_version; /* revision of API supported */ int ldapai_protocol_version; /* highest LDAP version supported */ char **ldapai_extensions; /* names of API extensions */ char *ldapai_vendor_name; /* name of supplier */ int ldapai_vendor_version; /* supplier-specific version * 100 */ } LDAPAPIInfo; typedef struct ldap_apifeature_info { int ldapaif_info_version; /* version of LDAPAPIFeatureInfo */ #define LDAP_FEATURE_INFO_VERSION (1) /* apifeature_info struct version */ char* ldapaif_name; /* LDAP_API_FEATURE_* (less prefix) */ int ldapaif_version; /* value of LDAP_API_FEATURE_... */ } LDAPAPIFeatureInfo; /* * LDAP Control structure */ typedef struct ldapcontrol { char * ldctl_oid; /* numericoid of control */ struct berval ldctl_value; /* encoded value of control */ char ldctl_iscritical; /* criticality */ } LDAPControl; /* LDAP Controls */ /* standard track controls */ #define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2" /* RFC 3296 */ #define LDAP_CONTROL_PROXY_AUTHZ "2.16.840.1.113730.3.4.18" /* RFC 4370 */ #define LDAP_CONTROL_SUBENTRIES "1.3.6.1.4.1.4203.1.10.1" /* RFC 3672 */ #define LDAP_CONTROL_VALUESRETURNFILTER "1.2.826.0.1.3344810.2.3"/* RFC 3876 */ #define LDAP_CONTROL_ASSERT "1.3.6.1.1.12" /* RFC 4528 */ #define LDAP_CONTROL_PRE_READ "1.3.6.1.1.13.1" /* RFC 4527 */ #define LDAP_CONTROL_POST_READ "1.3.6.1.1.13.2" /* RFC 4527 */ #define LDAP_CONTROL_SORTREQUEST "1.2.840.113556.1.4.473" /* RFC 2891 */ #define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474" /* RFC 2891 */ /* non-standard track controls */ #define LDAP_CONTROL_PAGEDRESULTS "1.2.840.113556.1.4.319" /* RFC 2696 */ #define LDAP_CONTROL_AUTHZID_REQUEST "2.16.840.1.113730.3.4.16" /* RFC 3829 */ #define LDAP_CONTROL_AUTHZID_RESPONSE "2.16.840.1.113730.3.4.15" /* RFC 3829 */ /* LDAP Content Synchronization Operation -- RFC 4533 */ #define LDAP_SYNC_OID "1.3.6.1.4.1.4203.1.9.1" #define LDAP_CONTROL_SYNC LDAP_SYNC_OID ".1" #define LDAP_CONTROL_SYNC_STATE LDAP_SYNC_OID ".2" #define LDAP_CONTROL_SYNC_DONE LDAP_SYNC_OID ".3" #define LDAP_SYNC_INFO LDAP_SYNC_OID ".4" #define LDAP_SYNC_NONE 0x00 #define LDAP_SYNC_REFRESH_ONLY 0x01 #define LDAP_SYNC_RESERVED 0x02 #define LDAP_SYNC_REFRESH_AND_PERSIST 0x03 #define LDAP_SYNC_REFRESH_PRESENTS 0 #define LDAP_SYNC_REFRESH_DELETES 1 #define LDAP_TAG_SYNC_NEW_COOKIE ((ber_tag_t) 0x80U) #define LDAP_TAG_SYNC_REFRESH_DELETE ((ber_tag_t) 0xa1U) #define LDAP_TAG_SYNC_REFRESH_PRESENT ((ber_tag_t) 0xa2U) #define LDAP_TAG_SYNC_ID_SET ((ber_tag_t) 0xa3U) #define LDAP_TAG_SYNC_COOKIE ((ber_tag_t) 0x04U) #define LDAP_TAG_REFRESHDELETES ((ber_tag_t) 0x01U) #define LDAP_TAG_REFRESHDONE ((ber_tag_t) 0x01U) #define LDAP_TAG_RELOAD_HINT ((ber_tag_t) 0x01U) #define LDAP_SYNC_PRESENT 0 #define LDAP_SYNC_ADD 1 #define LDAP_SYNC_MODIFY 2 #define LDAP_SYNC_DELETE 3 #define LDAP_SYNC_NEW_COOKIE 4 /* LDAP Don't Use Copy Control (RFC 6171) */ #define LDAP_CONTROL_DONTUSECOPY "1.3.6.1.1.22" /* Password policy Controls *//* work in progress */ /* ITS#3458: released; disabled by default */ #define LDAP_CONTROL_PASSWORDPOLICYREQUEST "1.3.6.1.4.1.42.2.27.8.5.1" #define LDAP_CONTROL_PASSWORDPOLICYRESPONSE "1.3.6.1.4.1.42.2.27.8.5.1" /* various works in progress */ #define LDAP_CONTROL_NOOP "1.3.6.1.4.1.4203.666.5.2" #define LDAP_CONTROL_NO_SUBORDINATES "1.3.6.1.4.1.4203.666.5.11" #define LDAP_CONTROL_RELAX "1.3.6.1.4.1.4203.666.5.12" #define LDAP_CONTROL_MANAGEDIT LDAP_CONTROL_RELAX #define LDAP_CONTROL_SLURP "1.3.6.1.4.1.4203.666.5.13" #define LDAP_CONTROL_VALSORT "1.3.6.1.4.1.4203.666.5.14" #define LDAP_CONTROL_X_DEREF "1.3.6.1.4.1.4203.666.5.16" #define LDAP_CONTROL_X_WHATFAILED "1.3.6.1.4.1.4203.666.5.17" /* LDAP Chaining Behavior Control *//* work in progress */ /* <draft-sermersheim-ldap-chaining>; * see also LDAP_NO_REFERRALS_FOUND, LDAP_CANNOT_CHAIN */ #define LDAP_CONTROL_X_CHAINING_BEHAVIOR "1.3.6.1.4.1.4203.666.11.3" #define LDAP_CHAINING_PREFERRED 0 #define LDAP_CHAINING_REQUIRED 1 #define LDAP_REFERRALS_PREFERRED 2 #define LDAP_REFERRALS_REQUIRED 3 /* MS Active Directory controls (for compatibility) */ #define LDAP_CONTROL_X_LAZY_COMMIT "1.2.840.113556.1.4.619" #define LDAP_CONTROL_X_INCREMENTAL_VALUES "1.2.840.113556.1.4.802" #define LDAP_CONTROL_X_DOMAIN_SCOPE "1.2.840.113556.1.4.1339" #define LDAP_CONTROL_X_PERMISSIVE_MODIFY "1.2.840.113556.1.4.1413" #define LDAP_CONTROL_X_SEARCH_OPTIONS "1.2.840.113556.1.4.1340" #define LDAP_SEARCH_FLAG_DOMAIN_SCOPE 1 /* do not generate referrals */ #define LDAP_SEARCH_FLAG_PHANTOM_ROOT 2 /* search all subordinate NCs */ #define LDAP_CONTROL_X_TREE_DELETE "1.2.840.113556.1.4.805" /* MS Active Directory controls - not implemented in slapd(8) */ #define LDAP_CONTROL_X_SERVER_NOTIFICATION "1.2.840.113556.1.4.528" #define LDAP_CONTROL_X_EXTENDED_DN "1.2.840.113556.1.4.529" #define LDAP_CONTROL_X_SHOW_DELETED "1.2.840.113556.1.4.417" #define LDAP_CONTROL_X_DIRSYNC "1.2.840.113556.1.4.841" #define LDAP_CONTROL_X_DIRSYNC_OBJECT_SECURITY 0x00000001 #define LDAP_CONTROL_X_DIRSYNC_ANCESTORS_FIRST 0x00000800 #define LDAP_CONTROL_X_DIRSYNC_PUBLIC_DATA_ONLY 0x00002000 #define LDAP_CONTROL_X_DIRSYNC_INCREMENTAL_VALUES 0x80000000 /* <draft-wahl-ldap-session> */ #define LDAP_CONTROL_X_SESSION_TRACKING "1.3.6.1.4.1.21008.108.63.1" #define LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_SESSION_ID \ LDAP_CONTROL_X_SESSION_TRACKING ".1" #define LDAP_CONTROL_X_SESSION_TRACKING_RADIUS_ACCT_MULTI_SESSION_ID \ LDAP_CONTROL_X_SESSION_TRACKING ".2" #define LDAP_CONTROL_X_SESSION_TRACKING_USERNAME \ LDAP_CONTROL_X_SESSION_TRACKING ".3" /* various expired works */ /* LDAP Duplicated Entry Control Extension *//* not implemented in slapd(8) */ #define LDAP_CONTROL_DUPENT_REQUEST "2.16.840.1.113719.1.27.101.1" #define LDAP_CONTROL_DUPENT_RESPONSE "2.16.840.1.113719.1.27.101.2" #define LDAP_CONTROL_DUPENT_ENTRY "2.16.840.1.113719.1.27.101.3" #define LDAP_CONTROL_DUPENT LDAP_CONTROL_DUPENT_REQUEST /* LDAP Persistent Search Control *//* not implemented in slapd(8) */ #define LDAP_CONTROL_PERSIST_REQUEST "2.16.840.1.113730.3.4.3" #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_NOTICE "2.16.840.1.113730.3.4.7" #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_ADD 0x1 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_DELETE 0x2 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_MODIFY 0x4 #define LDAP_CONTROL_PERSIST_ENTRY_CHANGE_RENAME 0x8 /* LDAP VLV */ #define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9" #define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10" /* Sun's analogue to ppolicy */ #define LDAP_CONTROL_X_ACCOUNT_USABILITY "1.3.6.1.4.1.42.2.27.9.5.8" #define LDAP_TAG_X_ACCOUNT_USABILITY_AVAILABLE ((ber_tag_t) 0x80U) /* primitive + 0 */ #define LDAP_TAG_X_ACCOUNT_USABILITY_NOT_AVAILABLE ((ber_tag_t) 0xA1U) /* constructed + 1 */ #define LDAP_TAG_X_ACCOUNT_USABILITY_INACTIVE ((ber_tag_t) 0x80U) /* primitive + 0 */ #define LDAP_TAG_X_ACCOUNT_USABILITY_RESET ((ber_tag_t) 0x81U) /* primitive + 1 */ #define LDAP_TAG_X_ACCOUNT_USABILITY_EXPIRED ((ber_tag_t) 0x82U) /* primitive + 2 */ #define LDAP_TAG_X_ACCOUNT_USABILITY_REMAINING_GRACE ((ber_tag_t) 0x83U) /* primitive + 3 */ #define LDAP_TAG_X_ACCOUNT_USABILITY_UNTIL_UNLOCK ((ber_tag_t) 0x84U) /* primitive + 4 */ /* Netscape Password policy response controls */ /* <draft-vchu-ldap-pwd-policy> */ #define LDAP_CONTROL_X_PASSWORD_EXPIRED "2.16.840.1.113730.3.4.4" #define LDAP_CONTROL_X_PASSWORD_EXPIRING "2.16.840.1.113730.3.4.5" /* LDAP Unsolicited Notifications */ #define LDAP_NOTICE_OF_DISCONNECTION "1.3.6.1.4.1.1466.20036" /* RFC 4511 */ #define LDAP_NOTICE_DISCONNECT LDAP_NOTICE_OF_DISCONNECTION /* LDAP Extended Operations */ #define LDAP_EXOP_START_TLS "1.3.6.1.4.1.1466.20037" /* RFC 4511 */ #define LDAP_EXOP_MODIFY_PASSWD "1.3.6.1.4.1.4203.1.11.1" /* RFC 3062 */ #define LDAP_TAG_EXOP_MODIFY_PASSWD_ID ((ber_tag_t) 0x80U) #define LDAP_TAG_EXOP_MODIFY_PASSWD_OLD ((ber_tag_t) 0x81U) #define LDAP_TAG_EXOP_MODIFY_PASSWD_NEW ((ber_tag_t) 0x82U) #define LDAP_TAG_EXOP_MODIFY_PASSWD_GEN ((ber_tag_t) 0x80U) #define LDAP_EXOP_CANCEL "1.3.6.1.1.8" /* RFC 3909 */ #define LDAP_EXOP_X_CANCEL LDAP_EXOP_CANCEL #define LDAP_EXOP_REFRESH "1.3.6.1.4.1.1466.101.119.1" /* RFC 2589 */ #define LDAP_TAG_EXOP_REFRESH_REQ_DN ((ber_tag_t) 0x80U) #define LDAP_TAG_EXOP_REFRESH_REQ_TTL ((ber_tag_t) 0x81U) #define LDAP_TAG_EXOP_REFRESH_RES_TTL ((ber_tag_t) 0x81U) #define LDAP_EXOP_VERIFY_CREDENTIALS "1.3.6.1.4.1.4203.666.6.5" #define LDAP_EXOP_X_VERIFY_CREDENTIALS LDAP_EXOP_VERIFY_CREDENTIALS #define LDAP_TAG_EXOP_VERIFY_CREDENTIALS_COOKIE ((ber_tag_t) 0x80U) #define LDAP_TAG_EXOP_VERIFY_CREDENTIALS_SCREDS ((ber_tag_t) 0x81U) #define LDAP_TAG_EXOP_VERIFY_CREDENTIALS_CONTROLS ((ber_tag_t) 0xa2U) /* context specific + constructed + 2 */ #define LDAP_EXOP_WHO_AM_I "1.3.6.1.4.1.4203.1.11.3" /* RFC 4532 */ #define LDAP_EXOP_X_WHO_AM_I LDAP_EXOP_WHO_AM_I /* various works in progress */ #define LDAP_EXOP_TURN "1.3.6.1.1.19" /* RFC 4531 */ #define LDAP_EXOP_X_TURN LDAP_EXOP_TURN /* LDAP Distributed Procedures <draft-sermersheim-ldap-distproc> */ /* a work in progress */ #define LDAP_X_DISTPROC_BASE "1.3.6.1.4.1.4203.666.11.6" #define LDAP_EXOP_X_CHAINEDREQUEST LDAP_X_DISTPROC_BASE ".1" #define LDAP_FEATURE_X_CANCHAINOPS LDAP_X_DISTPROC_BASE ".2" #define LDAP_CONTROL_X_RETURNCONTREF LDAP_X_DISTPROC_BASE ".3" #define LDAP_URLEXT_X_LOCALREFOID LDAP_X_DISTPROC_BASE ".4" #define LDAP_URLEXT_X_REFTYPEOID LDAP_X_DISTPROC_BASE ".5" #define LDAP_URLEXT_X_SEARCHEDSUBTREEOID \ LDAP_X_DISTPROC_BASE ".6" #define LDAP_URLEXT_X_FAILEDNAMEOID LDAP_X_DISTPROC_BASE ".7" #define LDAP_URLEXT_X_LOCALREF "x-localReference" #define LDAP_URLEXT_X_REFTYPE "x-referenceType" #define LDAP_URLEXT_X_SEARCHEDSUBTREE "x-searchedSubtree" #define LDAP_URLEXT_X_FAILEDNAME "x-failedName" #define LDAP_TXN "1.3.6.1.1.21" /* RFC 5805 */ #define LDAP_EXOP_TXN_START LDAP_TXN ".1" #define LDAP_CONTROL_TXN_SPEC LDAP_TXN ".2" #define LDAP_EXOP_TXN_END LDAP_TXN ".3" #define LDAP_EXOP_TXN_ABORTED_NOTICE LDAP_TXN ".4" /* LDAP Features */ #define LDAP_FEATURE_ALL_OP_ATTRS "1.3.6.1.4.1.4203.1.5.1" /* RFC 3673 */ #define LDAP_FEATURE_OBJECTCLASS_ATTRS \ "1.3.6.1.4.1.4203.1.5.2" /* @objectClass - new number to be assigned */ #define LDAP_FEATURE_ABSOLUTE_FILTERS "1.3.6.1.4.1.4203.1.5.3" /* (&) (|) */ #define LDAP_FEATURE_LANGUAGE_TAG_OPTIONS "1.3.6.1.4.1.4203.1.5.4" #define LDAP_FEATURE_LANGUAGE_RANGE_OPTIONS "1.3.6.1.4.1.4203.1.5.5" #define LDAP_FEATURE_MODIFY_INCREMENT "1.3.6.1.1.14" /* LDAP Experimental (works in progress) Features */ #define LDAP_FEATURE_SUBORDINATE_SCOPE \ "1.3.6.1.4.1.4203.666.8.1" /* "children" */ #define LDAP_FEATURE_CHILDREN_SCOPE LDAP_FEATURE_SUBORDINATE_SCOPE /* * specific LDAP instantiations of BER types we know about */ /* Overview of LBER tag construction * * Bits * ______ * 8 7 | CLASS * 0 0 = UNIVERSAL * 0 1 = APPLICATION * 1 0 = CONTEXT-SPECIFIC * 1 1 = PRIVATE * _____ * | 6 | DATA-TYPE * 0 = PRIMITIVE * 1 = CONSTRUCTED * ___________ * | 5 ... 1 | TAG-NUMBER */ /* general stuff */ #define LDAP_TAG_MESSAGE ((ber_tag_t) 0x30U) /* constructed + 16 */ #define LDAP_TAG_MSGID ((ber_tag_t) 0x02U) /* integer */ #define LDAP_TAG_LDAPDN ((ber_tag_t) 0x04U) /* octet string */ #define LDAP_TAG_LDAPCRED ((ber_tag_t) 0x04U) /* octet string */ #define LDAP_TAG_CONTROLS ((ber_tag_t) 0xa0U) /* context specific + constructed + 0 */ #define LDAP_TAG_REFERRAL ((ber_tag_t) 0xa3U) /* context specific + constructed + 3 */ #define LDAP_TAG_NEWSUPERIOR ((ber_tag_t) 0x80U) /* context-specific + primitive + 0 */ #define LDAP_TAG_EXOP_REQ_OID ((ber_tag_t) 0x80U) /* context specific + primitive */ #define LDAP_TAG_EXOP_REQ_VALUE ((ber_tag_t) 0x81U) /* context specific + primitive */ #define LDAP_TAG_EXOP_RES_OID ((ber_tag_t) 0x8aU) /* context specific + primitive */ #define LDAP_TAG_EXOP_RES_VALUE ((ber_tag_t) 0x8bU) /* context specific + primitive */ #define LDAP_TAG_IM_RES_OID ((ber_tag_t) 0x80U) /* context specific + primitive */ #define LDAP_TAG_IM_RES_VALUE ((ber_tag_t) 0x81U) /* context specific + primitive */ #define LDAP_TAG_SASL_RES_CREDS ((ber_tag_t) 0x87U) /* context specific + primitive */ /* LDAP Request Messages */ #define LDAP_REQ_BIND ((ber_tag_t) 0x60U) /* application + constructed */ #define LDAP_REQ_UNBIND ((ber_tag_t) 0x42U) /* application + primitive */ #define LDAP_REQ_SEARCH ((ber_tag_t) 0x63U) /* application + constructed */ #define LDAP_REQ_MODIFY ((ber_tag_t) 0x66U) /* application + constructed */ #define LDAP_REQ_ADD ((ber_tag_t) 0x68U) /* application + constructed */ #define LDAP_REQ_DELETE ((ber_tag_t) 0x4aU) /* application + primitive */ #define LDAP_REQ_MODDN ((ber_tag_t) 0x6cU) /* application + constructed */ #define LDAP_REQ_MODRDN LDAP_REQ_MODDN #define LDAP_REQ_RENAME LDAP_REQ_MODDN #define LDAP_REQ_COMPARE ((ber_tag_t) 0x6eU) /* application + constructed */ #define LDAP_REQ_ABANDON ((ber_tag_t) 0x50U) /* application + primitive */ #define LDAP_REQ_EXTENDED ((ber_tag_t) 0x77U) /* application + constructed */ /* LDAP Response Messages */ #define LDAP_RES_BIND ((ber_tag_t) 0x61U) /* application + constructed */ #define LDAP_RES_SEARCH_ENTRY ((ber_tag_t) 0x64U) /* application + constructed */ #define LDAP_RES_SEARCH_REFERENCE ((ber_tag_t) 0x73U) /* V3: application + constructed */ #define LDAP_RES_SEARCH_RESULT ((ber_tag_t) 0x65U) /* application + constructed */ #define LDAP_RES_MODIFY ((ber_tag_t) 0x67U) /* application + constructed */ #define LDAP_RES_ADD ((ber_tag_t) 0x69U) /* application + constructed */ #define LDAP_RES_DELETE ((ber_tag_t) 0x6bU) /* application + constructed */ #define LDAP_RES_MODDN ((ber_tag_t) 0x6dU) /* application + constructed */ #define LDAP_RES_MODRDN LDAP_RES_MODDN /* application + constructed */ #define LDAP_RES_RENAME LDAP_RES_MODDN /* application + constructed */ #define LDAP_RES_COMPARE ((ber_tag_t) 0x6fU) /* application + constructed */ #define LDAP_RES_EXTENDED ((ber_tag_t) 0x78U) /* V3: application + constructed */ #define LDAP_RES_INTERMEDIATE ((ber_tag_t) 0x79U) /* V3+: application + constructed */ #define LDAP_RES_ANY (-1) #define LDAP_RES_UNSOLICITED (0) /* sasl methods */ #define LDAP_SASL_SIMPLE ((char*)0) #define LDAP_SASL_NULL ("") /* authentication methods available */ #define LDAP_AUTH_NONE ((ber_tag_t) 0x00U) /* no authentication */ #define LDAP_AUTH_SIMPLE ((ber_tag_t) 0x80U) /* context specific + primitive */ #define LDAP_AUTH_SASL ((ber_tag_t) 0xa3U) /* context specific + constructed */ #define LDAP_AUTH_KRBV4 ((ber_tag_t) 0xffU) /* means do both of the following */ #define LDAP_AUTH_KRBV41 ((ber_tag_t) 0x81U) /* context specific + primitive */ #define LDAP_AUTH_KRBV42 ((ber_tag_t) 0x82U) /* context specific + primitive */ /* used by the Windows API but not used on the wire */ #define LDAP_AUTH_NEGOTIATE ((ber_tag_t) 0x04FFU) /* filter types */ #define LDAP_FILTER_AND ((ber_tag_t) 0xa0U) /* context specific + constructed */ #define LDAP_FILTER_OR ((ber_tag_t) 0xa1U) /* context specific + constructed */ #define LDAP_FILTER_NOT ((ber_tag_t) 0xa2U) /* context specific + constructed */ #define LDAP_FILTER_EQUALITY ((ber_tag_t) 0xa3U) /* context specific + constructed */ #define LDAP_FILTER_SUBSTRINGS ((ber_tag_t) 0xa4U) /* context specific + constructed */ #define LDAP_FILTER_GE ((ber_tag_t) 0xa5U) /* context specific + constructed */ #define LDAP_FILTER_LE ((ber_tag_t) 0xa6U) /* context specific + constructed */ #define LDAP_FILTER_PRESENT ((ber_tag_t) 0x87U) /* context specific + primitive */ #define LDAP_FILTER_APPROX ((ber_tag_t) 0xa8U) /* context specific + constructed */ #define LDAP_FILTER_EXT ((ber_tag_t) 0xa9U) /* context specific + constructed */ /* extended filter component types */ #define LDAP_FILTER_EXT_OID ((ber_tag_t) 0x81U) /* context specific */ #define LDAP_FILTER_EXT_TYPE ((ber_tag_t) 0x82U) /* context specific */ #define LDAP_FILTER_EXT_VALUE ((ber_tag_t) 0x83U) /* context specific */ #define LDAP_FILTER_EXT_DNATTRS ((ber_tag_t) 0x84U) /* context specific */ /* substring filter component types */ #define LDAP_SUBSTRING_INITIAL ((ber_tag_t) 0x80U) /* context specific */ #define LDAP_SUBSTRING_ANY ((ber_tag_t) 0x81U) /* context specific */ #define LDAP_SUBSTRING_FINAL ((ber_tag_t) 0x82U) /* context specific */ /* search scopes */ #define LDAP_SCOPE_BASE ((ber_int_t) 0x0000) #define LDAP_SCOPE_BASEOBJECT LDAP_SCOPE_BASE #define LDAP_SCOPE_ONELEVEL ((ber_int_t) 0x0001) #define LDAP_SCOPE_ONE LDAP_SCOPE_ONELEVEL #define LDAP_SCOPE_SUBTREE ((ber_int_t) 0x0002) #define LDAP_SCOPE_SUB LDAP_SCOPE_SUBTREE #define LDAP_SCOPE_SUBORDINATE ((ber_int_t) 0x0003) /* OpenLDAP extension */ #define LDAP_SCOPE_CHILDREN LDAP_SCOPE_SUBORDINATE #define LDAP_SCOPE_DEFAULT ((ber_int_t) -1) /* OpenLDAP extension */ /* substring filter component types */ #define LDAP_SUBSTRING_INITIAL ((ber_tag_t) 0x80U) /* context specific */ #define LDAP_SUBSTRING_ANY ((ber_tag_t) 0x81U) /* context specific */ #define LDAP_SUBSTRING_FINAL ((ber_tag_t) 0x82U) /* context specific */ /* * LDAP Result Codes */ #define LDAP_SUCCESS 0x00 #define LDAP_RANGE(n,x,y) (((x) <= (n)) && ((n) <= (y))) #define LDAP_OPERATIONS_ERROR 0x01 #define LDAP_PROTOCOL_ERROR 0x02 #define LDAP_TIMELIMIT_EXCEEDED 0x03 #define LDAP_SIZELIMIT_EXCEEDED 0x04 #define LDAP_COMPARE_FALSE 0x05 #define LDAP_COMPARE_TRUE 0x06 #define LDAP_AUTH_METHOD_NOT_SUPPORTED 0x07 #define LDAP_STRONG_AUTH_NOT_SUPPORTED LDAP_AUTH_METHOD_NOT_SUPPORTED #define LDAP_STRONG_AUTH_REQUIRED 0x08 #define LDAP_STRONGER_AUTH_REQUIRED LDAP_STRONG_AUTH_REQUIRED #define LDAP_PARTIAL_RESULTS 0x09 /* LDAPv2+ (not LDAPv3) */ #define LDAP_REFERRAL 0x0a /* LDAPv3 */ #define LDAP_ADMINLIMIT_EXCEEDED 0x0b /* LDAPv3 */ #define LDAP_UNAVAILABLE_CRITICAL_EXTENSION 0x0c /* LDAPv3 */ #define LDAP_CONFIDENTIALITY_REQUIRED 0x0d /* LDAPv3 */ #define LDAP_SASL_BIND_IN_PROGRESS 0x0e /* LDAPv3 */ #define LDAP_ATTR_ERROR(n) LDAP_RANGE((n),0x10,0x15) /* 16-21 */ #define LDAP_NO_SUCH_ATTRIBUTE 0x10 #define LDAP_UNDEFINED_TYPE 0x11 #define LDAP_INAPPROPRIATE_MATCHING 0x12 #define LDAP_CONSTRAINT_VIOLATION 0x13 #define LDAP_TYPE_OR_VALUE_EXISTS 0x14 #define LDAP_INVALID_SYNTAX 0x15 #define LDAP_NAME_ERROR(n) LDAP_RANGE((n),0x20,0x24) /* 32-34,36 */ #define LDAP_NO_SUCH_OBJECT 0x20 #define LDAP_ALIAS_PROBLEM 0x21 #define LDAP_INVALID_DN_SYNTAX 0x22 #define LDAP_IS_LEAF 0x23 /* not LDAPv3 */ #define LDAP_ALIAS_DEREF_PROBLEM 0x24 #define LDAP_SECURITY_ERROR(n) LDAP_RANGE((n),0x2F,0x32) /* 47-50 */ #define LDAP_X_PROXY_AUTHZ_FAILURE 0x2F /* LDAPv3 proxy authorization */ #define LDAP_INAPPROPRIATE_AUTH 0x30 #define LDAP_INVALID_CREDENTIALS 0x31 #define LDAP_INSUFFICIENT_ACCESS 0x32 #define LDAP_SERVICE_ERROR(n) LDAP_RANGE((n),0x33,0x36) /* 51-54 */ #define LDAP_BUSY 0x33 #define LDAP_UNAVAILABLE 0x34 #define LDAP_UNWILLING_TO_PERFORM 0x35 #define LDAP_LOOP_DETECT 0x36 #define LDAP_UPDATE_ERROR(n) LDAP_RANGE((n),0x40,0x47) /* 64-69,71 */ #define LDAP_NAMING_VIOLATION 0x40 #define LDAP_OBJECT_CLASS_VIOLATION 0x41 #define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42 #define LDAP_NOT_ALLOWED_ON_RDN 0x43 #define LDAP_ALREADY_EXISTS 0x44 #define LDAP_NO_OBJECT_CLASS_MODS 0x45 #define LDAP_RESULTS_TOO_LARGE 0x46 /* CLDAP */ #define LDAP_AFFECTS_MULTIPLE_DSAS 0x47 #define LDAP_VLV_ERROR 0x4C #define LDAP_OTHER 0x50 /* LCUP operation codes (113-117) - not implemented */ #define LDAP_CUP_RESOURCES_EXHAUSTED 0x71 #define LDAP_CUP_SECURITY_VIOLATION 0x72 #define LDAP_CUP_INVALID_DATA 0x73 #define LDAP_CUP_UNSUPPORTED_SCHEME 0x74 #define LDAP_CUP_RELOAD_REQUIRED 0x75 /* Cancel operation codes (118-121) */ #define LDAP_CANCELLED 0x76 #define LDAP_NO_SUCH_OPERATION 0x77 #define LDAP_TOO_LATE 0x78 #define LDAP_CANNOT_CANCEL 0x79 /* Assertion control (122) */ #define LDAP_ASSERTION_FAILED 0x7A /* Proxied Authorization Denied (123) */ #define LDAP_PROXIED_AUTHORIZATION_DENIED 0x7B /* Experimental result codes */ #define LDAP_E_ERROR(n) LDAP_RANGE((n),0x1000,0x3FFF) /* LDAP Sync (4096) */ #define LDAP_SYNC_REFRESH_REQUIRED 0x1000 /* Private Use result codes */ #define LDAP_X_ERROR(n) LDAP_RANGE((n),0x4000,0xFFFF) #define LDAP_X_SYNC_REFRESH_REQUIRED 0x4100 /* defunct */ #define LDAP_X_ASSERTION_FAILED 0x410f /* defunct */ /* for the LDAP No-Op control */ #define LDAP_X_NO_OPERATION 0x410e /* for the Chaining Behavior control (consecutive result codes requested; * see <draft-sermersheim-ldap-chaining> ) */ #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR #define LDAP_X_NO_REFERRALS_FOUND 0x4110 #define LDAP_X_CANNOT_CHAIN 0x4111 #endif /* for Distributed Procedures (see <draft-sermersheim-ldap-distproc>) */ #ifdef LDAP_X_DISTPROC_BASE #define LDAP_X_INVALIDREFERENCE 0x4112 #endif #define LDAP_TXN_SPECIFY_OKAY 0x4120 #define LDAP_TXN_ID_INVALID 0x4121 /* API Error Codes * * Based on draft-ietf-ldap-c-api-xx * but with new negative code values */ #define LDAP_API_ERROR(n) ((n)<0) #define LDAP_API_RESULT(n) ((n)<=0) #define LDAP_SERVER_DOWN (-1) #define LDAP_LOCAL_ERROR (-2) #define LDAP_ENCODING_ERROR (-3) #define LDAP_DECODING_ERROR (-4) #define LDAP_TIMEOUT (-5) #define LDAP_AUTH_UNKNOWN (-6) #define LDAP_FILTER_ERROR (-7) #define LDAP_USER_CANCELLED (-8) #define LDAP_PARAM_ERROR (-9) #define LDAP_NO_MEMORY (-10) #define LDAP_CONNECT_ERROR (-11) #define LDAP_NOT_SUPPORTED (-12) #define LDAP_CONTROL_NOT_FOUND (-13) #define LDAP_NO_RESULTS_RETURNED (-14) #define LDAP_MORE_RESULTS_TO_RETURN (-15) /* Obsolete */ #define LDAP_CLIENT_LOOP (-16) #define LDAP_REFERRAL_LIMIT_EXCEEDED (-17) #define LDAP_X_CONNECTING (-18) /* * This structure represents both ldap messages and ldap responses. * These are really the same, except in the case of search responses, * where a response has multiple messages. */ typedef struct ldapmsg LDAPMessage; /* for modifications */ typedef struct ldapmod { int mod_op; #define LDAP_MOD_OP (0x0007) #define LDAP_MOD_ADD (0x0000) #define LDAP_MOD_DELETE (0x0001) #define LDAP_MOD_REPLACE (0x0002) #define LDAP_MOD_INCREMENT (0x0003) /* OpenLDAP extension */ #define LDAP_MOD_BVALUES (0x0080) /* IMPORTANT: do not use code 0x1000 (or above), * it is used internally by the backends! * (see ldap/servers/slapd/slap.h) */ char *mod_type; union mod_vals_u { char **modv_strvals; struct berval **modv_bvals; } mod_vals; #define mod_values mod_vals.modv_strvals #define mod_bvalues mod_vals.modv_bvals } LDAPMod; /* * structure representing an ldap session which can * encompass connections to multiple servers (in the * face of referrals). */ typedef struct ldap LDAP; #define LDAP_DEREF_NEVER 0x00 #define LDAP_DEREF_SEARCHING 0x01 #define LDAP_DEREF_FINDING 0x02 #define LDAP_DEREF_ALWAYS 0x03 #define LDAP_NO_LIMIT 0 /* how many messages to retrieve results for */ #define LDAP_MSG_ONE 0x00 #define LDAP_MSG_ALL 0x01 #define LDAP_MSG_RECEIVED 0x02 /* * types for ldap URL handling */ typedef struct ldap_url_desc { struct ldap_url_desc *lud_next; char *lud_scheme; char *lud_host; int lud_port; char *lud_dn; char **lud_attrs; int lud_scope; char *lud_filter; char **lud_exts; int lud_crit_exts; } LDAPURLDesc; #define LDAP_URL_SUCCESS 0x00 /* Success */ #define LDAP_URL_ERR_MEM 0x01 /* can't allocate memory space */ #define LDAP_URL_ERR_PARAM 0x02 /* parameter is bad */ #define LDAP_URL_ERR_BADSCHEME 0x03 /* URL doesn't begin with "ldap[si]://" */ #define LDAP_URL_ERR_BADENCLOSURE 0x04 /* URL is missing trailing ">" */ #define LDAP_URL_ERR_BADURL 0x05 /* URL is bad */ #define LDAP_URL_ERR_BADHOST 0x06 /* host port is bad */ #define LDAP_URL_ERR_BADATTRS 0x07 /* bad (or missing) attributes */ #define LDAP_URL_ERR_BADSCOPE 0x08 /* scope string is invalid (or missing) */ #define LDAP_URL_ERR_BADFILTER 0x09 /* bad or missing filter */ #define LDAP_URL_ERR_BADEXTS 0x0a /* bad or missing extensions */ /* * LDAP sync (RFC4533) API */ typedef struct ldap_sync_t ldap_sync_t; typedef enum { /* these are private - the client should never see them */ LDAP_SYNC_CAPI_NONE = -1, LDAP_SYNC_CAPI_PHASE_FLAG = 0x10U, LDAP_SYNC_CAPI_IDSET_FLAG = 0x20U, LDAP_SYNC_CAPI_DONE_FLAG = 0x40U, /* these are passed to ls_search_entry() */ LDAP_SYNC_CAPI_PRESENT = LDAP_SYNC_PRESENT, LDAP_SYNC_CAPI_ADD = LDAP_SYNC_ADD, LDAP_SYNC_CAPI_MODIFY = LDAP_SYNC_MODIFY, LDAP_SYNC_CAPI_DELETE = LDAP_SYNC_DELETE, /* these are passed to ls_intermediate() */ LDAP_SYNC_CAPI_PRESENTS = ( LDAP_SYNC_CAPI_PHASE_FLAG | LDAP_SYNC_CAPI_PRESENT ), LDAP_SYNC_CAPI_DELETES = ( LDAP_SYNC_CAPI_PHASE_FLAG | LDAP_SYNC_CAPI_DELETE ), LDAP_SYNC_CAPI_PRESENTS_IDSET = ( LDAP_SYNC_CAPI_PRESENTS | LDAP_SYNC_CAPI_IDSET_FLAG ), LDAP_SYNC_CAPI_DELETES_IDSET = ( LDAP_SYNC_CAPI_DELETES | LDAP_SYNC_CAPI_IDSET_FLAG ), LDAP_SYNC_CAPI_DONE = ( LDAP_SYNC_CAPI_DONE_FLAG | LDAP_SYNC_CAPI_PRESENTS ) } ldap_sync_refresh_t; /* * Called when an entry is returned by ldap_result(). * If phase is LDAP_SYNC_CAPI_ADD or LDAP_SYNC_CAPI_MODIFY, * the entry has been either added or modified, and thus * the complete view of the entry should be in the LDAPMessage. * If phase is LDAP_SYNC_CAPI_PRESENT or LDAP_SYNC_CAPI_DELETE, * only the DN should be in the LDAPMessage. */ typedef int (*ldap_sync_search_entry_f) LDAP_P(( ldap_sync_t *ls, LDAPMessage *msg, struct berval *entryUUID, ldap_sync_refresh_t phase )); /* * Called when a reference is returned; the client should know * what to do with it. */ typedef int (*ldap_sync_search_reference_f) LDAP_P(( ldap_sync_t *ls, LDAPMessage *msg )); /* * Called when specific intermediate/final messages are returned. * If phase is LDAP_SYNC_CAPI_PRESENTS or LDAP_SYNC_CAPI_DELETES, * a "presents" or "deletes" phase begins. * If phase is LDAP_SYNC_CAPI_DONE, a special "presents" phase * with refreshDone set to "TRUE" has been returned, to indicate * that the refresh phase of a refreshAndPersist is complete. * In the above cases, syncUUIDs is NULL. * * If phase is LDAP_SYNC_CAPI_PRESENTS_IDSET or * LDAP_SYNC_CAPI_DELETES_IDSET, syncUUIDs is an array of UUIDs * that are either present or have been deleted. */ typedef int (*ldap_sync_intermediate_f) LDAP_P(( ldap_sync_t *ls, LDAPMessage *msg, BerVarray syncUUIDs, ldap_sync_refresh_t phase )); /* * Called when a searchResultDone is returned. In refreshAndPersist, * this can only occur if the search for any reason is being terminated * by the server. */ typedef int (*ldap_sync_search_result_f) LDAP_P(( ldap_sync_t *ls, LDAPMessage *msg, int refreshDeletes )); /* * This structure contains all information about the persistent search; * the caller is responsible for connecting, setting version, binding, tls... */ struct ldap_sync_t { /* conf search params */ char *ls_base; int ls_scope; char *ls_filter; char **ls_attrs; int ls_timelimit; int ls_sizelimit; /* poll timeout */ int ls_timeout; /* helpers - add as appropriate */ ldap_sync_search_entry_f ls_search_entry; ldap_sync_search_reference_f ls_search_reference; ldap_sync_intermediate_f ls_intermediate; ldap_sync_search_result_f ls_search_result; /* set by the caller as appropriate */ void *ls_private; /* conn stuff */ LDAP *ls_ld; /* --- the parameters below are private - do not modify --- */ /* FIXME: make the structure opaque, and provide an interface * to modify the public values? */ /* result stuff */ int ls_msgid; /* sync stuff */ /* needed by refreshOnly */ int ls_reloadHint; /* opaque - need to pass between sessions, updated by the API */ struct berval ls_cookie; /* state variable - do not modify */ ldap_sync_refresh_t ls_refreshPhase; }; /* * End of LDAP sync (RFC4533) API */ /* * Connection callbacks... */ struct ldap_conncb; struct sockaddr; /* Called after a connection is established */ typedef int (ldap_conn_add_f) LDAP_P(( LDAP *ld, Sockbuf *sb, LDAPURLDesc *srv, struct sockaddr *addr, struct ldap_conncb *ctx )); /* Called before a connection is closed */ typedef void (ldap_conn_del_f) LDAP_P(( LDAP *ld, Sockbuf *sb, struct ldap_conncb *ctx )); /* Callbacks are pushed on a stack. Last one pushed is first one executed. The * delete callback is called with a NULL Sockbuf just before freeing the LDAP handle. */ typedef struct ldap_conncb { ldap_conn_add_f *lc_add; ldap_conn_del_f *lc_del; void *lc_arg; } ldap_conncb; /* * The API draft spec says we should declare (or cause to be declared) * 'struct timeval'. We don't. See IETF LDAPext discussions. */ struct timeval; /* * in options.c: */ LDAP_F( int ) ldap_get_option LDAP_P(( LDAP *ld, int option, void *outvalue)); LDAP_F( int ) ldap_set_option LDAP_P(( LDAP *ld, int option, LDAP_CONST void *invalue)); /* V3 REBIND Function Callback Prototype */ typedef int (LDAP_REBIND_PROC) LDAP_P(( LDAP *ld, LDAP_CONST char *url, ber_tag_t request, ber_int_t msgid, void *params )); LDAP_F( int ) ldap_set_rebind_proc LDAP_P(( LDAP *ld, LDAP_REBIND_PROC *rebind_proc, void *params )); /* V3 referral selection Function Callback Prototype */ typedef int (LDAP_NEXTREF_PROC) LDAP_P(( LDAP *ld, char ***refsp, int *cntp, void *params )); LDAP_F( int ) ldap_set_nextref_proc LDAP_P(( LDAP *ld, LDAP_NEXTREF_PROC *nextref_proc, void *params )); /* V3 URLLIST Function Callback Prototype */ typedef int (LDAP_URLLIST_PROC) LDAP_P(( LDAP *ld, LDAPURLDesc **urllist, LDAPURLDesc **url, void *params )); LDAP_F( int ) ldap_set_urllist_proc LDAP_P(( LDAP *ld, LDAP_URLLIST_PROC *urllist_proc, void *params )); /* * in controls.c: */ #if LDAP_DEPRECATED LDAP_F( int ) ldap_create_control LDAP_P(( /* deprecated, use ldap_control_create */ LDAP_CONST char *requestOID, BerElement *ber, int iscritical, LDAPControl **ctrlp )); LDAP_F( LDAPControl * ) ldap_find_control LDAP_P(( /* deprecated, use ldap_control_find */ LDAP_CONST char *oid, LDAPControl **ctrls )); #endif LDAP_F( int ) ldap_control_create LDAP_P(( LDAP_CONST char *requestOID, int iscritical, struct berval *value, int dupval, LDAPControl **ctrlp )); LDAP_F( LDAPControl * ) ldap_control_find LDAP_P(( LDAP_CONST char *oid, LDAPControl **ctrls, LDAPControl ***nextctrlp )); LDAP_F( void ) ldap_control_free LDAP_P(( LDAPControl *ctrl )); LDAP_F( void ) ldap_controls_free LDAP_P(( LDAPControl **ctrls )); LDAP_F( LDAPControl ** ) ldap_controls_dup LDAP_P(( LDAPControl *LDAP_CONST *controls )); LDAP_F( LDAPControl * ) ldap_control_dup LDAP_P(( LDAP_CONST LDAPControl *c )); /* * in dnssrv.c: */ LDAP_F( int ) ldap_domain2dn LDAP_P(( LDAP_CONST char* domain, char** dn )); LDAP_F( int ) ldap_dn2domain LDAP_P(( LDAP_CONST char* dn, char** domain )); LDAP_F( int ) ldap_domain2hostlist LDAP_P(( LDAP_CONST char *domain, char** hostlist )); /* * in extended.c: */ LDAP_F( int ) ldap_extended_operation LDAP_P(( LDAP *ld, LDAP_CONST char *reqoid, struct berval *reqdata, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp )); LDAP_F( int ) ldap_extended_operation_s LDAP_P(( LDAP *ld, LDAP_CONST char *reqoid, struct berval *reqdata, LDAPControl **serverctrls, LDAPControl **clientctrls, char **retoidp, struct berval **retdatap )); LDAP_F( int ) ldap_parse_extended_result LDAP_P(( LDAP *ld, LDAPMessage *res, char **retoidp, struct berval **retdatap, int freeit )); LDAP_F( int ) ldap_parse_intermediate LDAP_P(( LDAP *ld, LDAPMessage *res, char **retoidp, struct berval **retdatap, LDAPControl ***serverctrls, int freeit )); /* * in abandon.c: */ LDAP_F( int ) ldap_abandon_ext LDAP_P(( LDAP *ld, int msgid, LDAPControl **serverctrls, LDAPControl **clientctrls )); #if LDAP_DEPRECATED LDAP_F( int ) ldap_abandon LDAP_P(( /* deprecated, use ldap_abandon_ext */ LDAP *ld, int msgid )); #endif /* * in add.c: */ LDAP_F( int ) ldap_add_ext LDAP_P(( LDAP *ld, LDAP_CONST char *dn, LDAPMod **attrs, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp )); LDAP_F( int ) ldap_add_ext_s LDAP_P(( LDAP *ld, LDAP_CONST char *dn, LDAPMod **attrs, LDAPControl **serverctrls, LDAPControl **clientctrls )); #if LDAP_DEPRECATED LDAP_F( int ) ldap_add LDAP_P(( /* deprecated, use ldap_add_ext */ LDAP *ld, LDAP_CONST char *dn, LDAPMod **attrs )); LDAP_F( int ) ldap_add_s LDAP_P(( /* deprecated, use ldap_add_ext_s */ LDAP *ld, LDAP_CONST char *dn, LDAPMod **attrs )); #endif /* * in sasl.c: */ LDAP_F( int ) ldap_sasl_bind LDAP_P(( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *mechanism, struct berval *cred, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp )); /* Interaction flags (should be passed about in a control) * Automatic (default): use defaults, prompt otherwise * Interactive: prompt always * Quiet: never prompt */ #define LDAP_SASL_AUTOMATIC 0U #define LDAP_SASL_INTERACTIVE 1U #define LDAP_SASL_QUIET 2U /* * V3 SASL Interaction Function Callback Prototype * when using Cyrus SASL, interact is pointer to sasl_interact_t * should likely passed in a control (and provided controls) */ typedef int (LDAP_SASL_INTERACT_PROC) LDAP_P(( LDAP *ld, unsigned flags, void* defaults, void *interact )); LDAP_F( int ) ldap_sasl_interactive_bind LDAP_P(( LDAP *ld, LDAP_CONST char *dn, /* usually NULL */ LDAP_CONST char *saslMechanism, LDAPControl **serverControls, LDAPControl **clientControls, /* should be client controls */ unsigned flags, LDAP_SASL_INTERACT_PROC *proc, void *defaults, /* as obtained from ldap_result() */ LDAPMessage *result, /* returned during bind processing */ const char **rmech, int *msgid )); LDAP_F( int ) ldap_sasl_interactive_bind_s LDAP_P(( LDAP *ld, LDAP_CONST char *dn, /* usually NULL */ LDAP_CONST char *saslMechanism, LDAPControl **serverControls, LDAPControl **clientControls, /* should be client controls */ unsigned flags, LDAP_SASL_INTERACT_PROC *proc, void *defaults )); LDAP_F( int ) ldap_sasl_bind_s LDAP_P(( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *mechanism, struct berval *cred, LDAPControl **serverctrls, LDAPControl **clientctrls, struct berval **servercredp )); LDAP_F( int ) ldap_parse_sasl_bind_result LDAP_P(( LDAP *ld, LDAPMessage *res, struct berval **servercredp, int freeit )); #if LDAP_DEPRECATED /* * in bind.c: * (deprecated) */ LDAP_F( int ) ldap_bind LDAP_P(( /* deprecated, use ldap_sasl_bind */ LDAP *ld, LDAP_CONST char *who, LDAP_CONST char *passwd, int authmethod )); LDAP_F( int ) ldap_bind_s LDAP_P(( /* deprecated, use ldap_sasl_bind_s */ LDAP *ld, LDAP_CONST char *who, LDAP_CONST char *cred, int authmethod )); /* * in sbind.c: */ LDAP_F( int ) ldap_simple_bind LDAP_P(( /* deprecated, use ldap_sasl_bind */ LDAP *ld, LDAP_CONST char *who, LDAP_CONST char *passwd )); LDAP_F( int ) ldap_simple_bind_s LDAP_P(( /* deprecated, use ldap_sasl_bind_s */ LDAP *ld, LDAP_CONST char *who, LDAP_CONST char *passwd )); #endif /* * in compare.c: */ LDAP_F( int ) ldap_compare_ext LDAP_P(( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *attr, struct berval *bvalue, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp )); LDAP_F( int ) ldap_compare_ext_s LDAP_P(( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *attr, struct berval *bvalue, LDAPControl **serverctrls, LDAPControl **clientctrls )); #if LDAP_DEPRECATED LDAP_F( int ) ldap_compare LDAP_P(( /* deprecated, use ldap_compare_ext */ LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *attr, LDAP_CONST char *value )); LDAP_F( int ) ldap_compare_s LDAP_P(( /* deprecated, use ldap_compare_ext_s */ LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *attr, LDAP_CONST char *value )); #endif /* * in delete.c: */ LDAP_F( int ) ldap_delete_ext LDAP_P(( LDAP *ld, LDAP_CONST char *dn, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp )); LDAP_F( int ) ldap_delete_ext_s LDAP_P(( LDAP *ld, LDAP_CONST char *dn, LDAPControl **serverctrls, LDAPControl **clientctrls )); #if LDAP_DEPRECATED LDAP_F( int ) ldap_delete LDAP_P(( /* deprecated, use ldap_delete_ext */ LDAP *ld, LDAP_CONST char *dn )); LDAP_F( int ) ldap_delete_s LDAP_P(( /* deprecated, use ldap_delete_ext_s */ LDAP *ld, LDAP_CONST char *dn )); #endif /* * in error.c: */ LDAP_F( int ) ldap_parse_result LDAP_P(( LDAP *ld, LDAPMessage *res, int *errcodep, char **matcheddnp, char **diagmsgp, char ***referralsp, LDAPControl ***serverctrls, int freeit )); LDAP_F( char * ) ldap_err2string LDAP_P(( int err )); #if LDAP_DEPRECATED LDAP_F( int ) ldap_result2error LDAP_P(( /* deprecated, use ldap_parse_result */ LDAP *ld, LDAPMessage *r, int freeit )); LDAP_F( void ) ldap_perror LDAP_P(( /* deprecated, use ldap_err2string */ LDAP *ld, LDAP_CONST char *s )); #endif /* * in modify.c: */ LDAP_F( int ) ldap_modify_ext LDAP_P(( LDAP *ld, LDAP_CONST char *dn, LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp )); LDAP_F( int ) ldap_modify_ext_s LDAP_P(( LDAP *ld, LDAP_CONST char *dn, LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls )); #if LDAP_DEPRECATED LDAP_F( int ) ldap_modify LDAP_P(( /* deprecated, use ldap_modify_ext */ LDAP *ld, LDAP_CONST char *dn, LDAPMod **mods )); LDAP_F( int ) ldap_modify_s LDAP_P(( /* deprecated, use ldap_modify_ext_s */ LDAP *ld, LDAP_CONST char *dn, LDAPMod **mods )); #endif /* * in modrdn.c: */ LDAP_F( int ) ldap_rename LDAP_P(( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn, LDAP_CONST char *newSuperior, int deleteoldrdn, LDAPControl **sctrls, LDAPControl **cctrls, int *msgidp )); LDAP_F( int ) ldap_rename_s LDAP_P(( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn, LDAP_CONST char *newSuperior, int deleteoldrdn, LDAPControl **sctrls, LDAPControl **cctrls )); #if LDAP_DEPRECATED LDAP_F( int ) ldap_rename2 LDAP_P(( /* deprecated, use ldap_rename */ LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn, LDAP_CONST char *newSuperior, int deleteoldrdn )); LDAP_F( int ) ldap_rename2_s LDAP_P(( /* deprecated, use ldap_rename_s */ LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn, LDAP_CONST char *newSuperior, int deleteoldrdn )); LDAP_F( int ) ldap_modrdn LDAP_P(( /* deprecated, use ldap_rename */ LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn )); LDAP_F( int ) ldap_modrdn_s LDAP_P(( /* deprecated, use ldap_rename_s */ LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn )); LDAP_F( int ) ldap_modrdn2 LDAP_P(( /* deprecated, use ldap_rename */ LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn, int deleteoldrdn )); LDAP_F( int ) ldap_modrdn2_s LDAP_P(( /* deprecated, use ldap_rename_s */ LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *newrdn, int deleteoldrdn)); #endif /* * in open.c: */ #if LDAP_DEPRECATED LDAP_F( LDAP * ) ldap_init LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */ LDAP_CONST char *host, int port )); LDAP_F( LDAP * ) ldap_open LDAP_P(( /* deprecated, use ldap_create or ldap_initialize */ LDAP_CONST char *host, int port )); #endif LDAP_F( int ) ldap_create LDAP_P(( LDAP **ldp )); LDAP_F( int ) ldap_initialize LDAP_P(( LDAP **ldp, LDAP_CONST char *url )); LDAP_F( LDAP * ) ldap_dup LDAP_P(( LDAP *old )); LDAP_F( int ) ldap_connect( LDAP *ld ); /* * in tls.c */ LDAP_F( int ) ldap_tls_inplace LDAP_P(( LDAP *ld )); LDAP_F( int ) ldap_start_tls LDAP_P(( LDAP *ld, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp )); LDAP_F( int ) ldap_install_tls LDAP_P(( LDAP *ld )); LDAP_F( int ) ldap_start_tls_s LDAP_P(( LDAP *ld, LDAPControl **serverctrls, LDAPControl **clientctrls )); /* * in messages.c: */ LDAP_F( LDAPMessage * ) ldap_first_message LDAP_P(( LDAP *ld, LDAPMessage *chain )); LDAP_F( LDAPMessage * ) ldap_next_message LDAP_P(( LDAP *ld, LDAPMessage *msg )); LDAP_F( int ) ldap_count_messages LDAP_P(( LDAP *ld, LDAPMessage *chain )); /* * in references.c: */ LDAP_F( LDAPMessage * ) ldap_first_reference LDAP_P(( LDAP *ld, LDAPMessage *chain )); LDAP_F( LDAPMessage * ) ldap_next_reference LDAP_P(( LDAP *ld, LDAPMessage *ref )); LDAP_F( int ) ldap_count_references LDAP_P(( LDAP *ld, LDAPMessage *chain )); LDAP_F( int ) ldap_parse_reference LDAP_P(( LDAP *ld, LDAPMessage *ref, char ***referralsp, LDAPControl ***serverctrls, int freeit)); /* * in getentry.c: */ LDAP_F( LDAPMessage * ) ldap_first_entry LDAP_P(( LDAP *ld, LDAPMessage *chain )); LDAP_F( LDAPMessage * ) ldap_next_entry LDAP_P(( LDAP *ld, LDAPMessage *entry )); LDAP_F( int ) ldap_count_entries LDAP_P(( LDAP *ld, LDAPMessage *chain )); LDAP_F( int ) ldap_get_entry_controls LDAP_P(( LDAP *ld, LDAPMessage *entry, LDAPControl ***serverctrls)); /* * in addentry.c */ LDAP_F( LDAPMessage * ) ldap_delete_result_entry LDAP_P(( LDAPMessage **list, LDAPMessage *e )); LDAP_F( void ) ldap_add_result_entry LDAP_P(( LDAPMessage **list, LDAPMessage *e )); /* * in getdn.c */ LDAP_F( char * ) ldap_get_dn LDAP_P(( LDAP *ld, LDAPMessage *entry )); typedef struct ldap_ava { struct berval la_attr; struct berval la_value; unsigned la_flags; #define LDAP_AVA_NULL 0x0000U #define LDAP_AVA_STRING 0x0001U #define LDAP_AVA_BINARY 0x0002U #define LDAP_AVA_NONPRINTABLE 0x0004U #define LDAP_AVA_FREE_ATTR 0x0010U #define LDAP_AVA_FREE_VALUE 0x0020U void *la_private; } LDAPAVA; typedef LDAPAVA** LDAPRDN; typedef LDAPRDN* LDAPDN; /* DN formats */ #define LDAP_DN_FORMAT_LDAP 0x0000U #define LDAP_DN_FORMAT_LDAPV3 0x0010U #define LDAP_DN_FORMAT_LDAPV2 0x0020U #define LDAP_DN_FORMAT_DCE 0x0030U #define LDAP_DN_FORMAT_UFN 0x0040U /* dn2str only */ #define LDAP_DN_FORMAT_AD_CANONICAL 0x0050U /* dn2str only */ #define LDAP_DN_FORMAT_LBER 0x00F0U /* for testing only */ #define LDAP_DN_FORMAT_MASK 0x00F0U /* DN flags */ #define LDAP_DN_PRETTY 0x0100U #define LDAP_DN_SKIP 0x0200U #define LDAP_DN_P_NOLEADTRAILSPACES 0x1000U #define LDAP_DN_P_NOSPACEAFTERRDN 0x2000U #define LDAP_DN_PEDANTIC 0xF000U LDAP_F( void ) ldap_rdnfree LDAP_P(( LDAPRDN rdn )); LDAP_F( void ) ldap_dnfree LDAP_P(( LDAPDN dn )); LDAP_F( int ) ldap_bv2dn LDAP_P(( struct berval *bv, LDAPDN *dn, unsigned flags )); LDAP_F( int ) ldap_str2dn LDAP_P(( LDAP_CONST char *str, LDAPDN *dn, unsigned flags )); LDAP_F( int ) ldap_dn2bv LDAP_P(( LDAPDN dn, struct berval *bv, unsigned flags )); LDAP_F( int ) ldap_dn2str LDAP_P(( LDAPDN dn, char **str, unsigned flags )); LDAP_F( int ) ldap_bv2rdn LDAP_P(( struct berval *bv, LDAPRDN *rdn, char **next, unsigned flags )); LDAP_F( int ) ldap_str2rdn LDAP_P(( LDAP_CONST char *str, LDAPRDN *rdn, char **next, unsigned flags )); LDAP_F( int ) ldap_rdn2bv LDAP_P(( LDAPRDN rdn, struct berval *bv, unsigned flags )); LDAP_F( int ) ldap_rdn2str LDAP_P(( LDAPRDN rdn, char **str, unsigned flags )); LDAP_F( int ) ldap_dn_normalize LDAP_P(( LDAP_CONST char *in, unsigned iflags, char **out, unsigned oflags )); LDAP_F( char * ) ldap_dn2ufn LDAP_P(( /* deprecated, use ldap_str2dn/dn2str */ LDAP_CONST char *dn )); LDAP_F( char ** ) ldap_explode_dn LDAP_P(( /* deprecated, ldap_str2dn */ LDAP_CONST char *dn, int notypes )); LDAP_F( char ** ) ldap_explode_rdn LDAP_P(( /* deprecated, ldap_str2rdn */ LDAP_CONST char *rdn, int notypes )); typedef int LDAPDN_rewrite_func LDAP_P(( LDAPDN dn, unsigned flags, void *ctx )); LDAP_F( int ) ldap_X509dn2bv LDAP_P(( void *x509_name, struct berval *dn, LDAPDN_rewrite_func *func, unsigned flags )); LDAP_F( char * ) ldap_dn2dcedn LDAP_P(( /* deprecated, ldap_str2dn/dn2str */ LDAP_CONST char *dn )); LDAP_F( char * ) ldap_dcedn2dn LDAP_P(( /* deprecated, ldap_str2dn/dn2str */ LDAP_CONST char *dce )); LDAP_F( char * ) ldap_dn2ad_canonical LDAP_P(( /* deprecated, ldap_str2dn/dn2str */ LDAP_CONST char *dn )); LDAP_F( int ) ldap_get_dn_ber LDAP_P(( LDAP *ld, LDAPMessage *e, BerElement **berout, struct berval *dn )); LDAP_F( int ) ldap_get_attribute_ber LDAP_P(( LDAP *ld, LDAPMessage *e, BerElement *ber, struct berval *attr, struct berval **vals )); /* * in getattr.c */ LDAP_F( char * ) ldap_first_attribute LDAP_P(( LDAP *ld, LDAPMessage *entry, BerElement **ber )); LDAP_F( char * ) ldap_next_attribute LDAP_P(( LDAP *ld, LDAPMessage *entry, BerElement *ber )); /* * in getvalues.c */ LDAP_F( struct berval ** ) ldap_get_values_len LDAP_P(( LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )); LDAP_F( int ) ldap_count_values_len LDAP_P(( struct berval **vals )); LDAP_F( void ) ldap_value_free_len LDAP_P(( struct berval **vals )); #if LDAP_DEPRECATED LDAP_F( char ** ) ldap_get_values LDAP_P(( /* deprecated, use ldap_get_values_len */ LDAP *ld, LDAPMessage *entry, LDAP_CONST char *target )); LDAP_F( int ) ldap_count_values LDAP_P(( /* deprecated, use ldap_count_values_len */ char **vals )); LDAP_F( void ) ldap_value_free LDAP_P(( /* deprecated, use ldap_value_free_len */ char **vals )); #endif /* * in result.c: */ LDAP_F( int ) ldap_result LDAP_P(( LDAP *ld, int msgid, int all, struct timeval *timeout, LDAPMessage **result )); LDAP_F( int ) ldap_msgtype LDAP_P(( LDAPMessage *lm )); LDAP_F( int ) ldap_msgid LDAP_P(( LDAPMessage *lm )); LDAP_F( int ) ldap_msgfree LDAP_P(( LDAPMessage *lm )); LDAP_F( int ) ldap_msgdelete LDAP_P(( LDAP *ld, int msgid )); /* * in search.c: */ LDAP_F( int ) ldap_bv2escaped_filter_value LDAP_P(( struct berval *in, struct berval *out )); LDAP_F( int ) ldap_search_ext LDAP_P(( LDAP *ld, LDAP_CONST char *base, int scope, LDAP_CONST char *filter, char **attrs, int attrsonly, LDAPControl **serverctrls, LDAPControl **clientctrls, struct timeval *timeout, int sizelimit, int *msgidp )); LDAP_F( int ) ldap_search_ext_s LDAP_P(( LDAP *ld, LDAP_CONST char *base, int scope, LDAP_CONST char *filter, char **attrs, int attrsonly, LDAPControl **serverctrls, LDAPControl **clientctrls, struct timeval *timeout, int sizelimit, LDAPMessage **res )); #if LDAP_DEPRECATED LDAP_F( int ) ldap_search LDAP_P(( /* deprecated, use ldap_search_ext */ LDAP *ld, LDAP_CONST char *base, int scope, LDAP_CONST char *filter, char **attrs, int attrsonly )); LDAP_F( int ) ldap_search_s LDAP_P(( /* deprecated, use ldap_search_ext_s */ LDAP *ld, LDAP_CONST char *base, int scope, LDAP_CONST char *filter, char **attrs, int attrsonly, LDAPMessage **res )); LDAP_F( int ) ldap_search_st LDAP_P(( /* deprecated, use ldap_search_ext_s */ LDAP *ld, LDAP_CONST char *base, int scope, LDAP_CONST char *filter, char **attrs, int attrsonly, struct timeval *timeout, LDAPMessage **res )); #endif /* * in unbind.c */ LDAP_F( int ) ldap_unbind_ext LDAP_P(( LDAP *ld, LDAPControl **serverctrls, LDAPControl **clientctrls)); LDAP_F( int ) ldap_unbind_ext_s LDAP_P(( LDAP *ld, LDAPControl **serverctrls, LDAPControl **clientctrls)); LDAP_F( int ) ldap_destroy LDAP_P(( LDAP *ld)); #if LDAP_DEPRECATED LDAP_F( int ) ldap_unbind LDAP_P(( /* deprecated, use ldap_unbind_ext */ LDAP *ld )); LDAP_F( int ) ldap_unbind_s LDAP_P(( /* deprecated, use ldap_unbind_ext_s */ LDAP *ld )); #endif /* * in filter.c */ LDAP_F( int ) ldap_put_vrFilter LDAP_P(( BerElement *ber, const char *vrf )); /* * in free.c */ LDAP_F( void * ) ldap_memalloc LDAP_P(( ber_len_t s )); LDAP_F( void * ) ldap_memrealloc LDAP_P(( void* p, ber_len_t s )); LDAP_F( void * ) ldap_memcalloc LDAP_P(( ber_len_t n, ber_len_t s )); LDAP_F( void ) ldap_memfree LDAP_P(( void* p )); LDAP_F( void ) ldap_memvfree LDAP_P(( void** v )); LDAP_F( char * ) ldap_strdup LDAP_P(( LDAP_CONST char * )); LDAP_F( void ) ldap_mods_free LDAP_P(( LDAPMod **mods, int freemods )); #if LDAP_DEPRECATED /* * in sort.c (deprecated, use custom code instead) */ typedef int (LDAP_SORT_AD_CMP_PROC) LDAP_P(( /* deprecated */ LDAP_CONST char *left, LDAP_CONST char *right )); typedef int (LDAP_SORT_AV_CMP_PROC) LDAP_P(( /* deprecated */ LDAP_CONST void *left, LDAP_CONST void *right )); LDAP_F( int ) /* deprecated */ ldap_sort_entries LDAP_P(( LDAP *ld, LDAPMessage **chain, LDAP_CONST char *attr, LDAP_SORT_AD_CMP_PROC *cmp )); LDAP_F( int ) /* deprecated */ ldap_sort_values LDAP_P(( LDAP *ld, char **vals, LDAP_SORT_AV_CMP_PROC *cmp )); LDAP_F( int ) /* deprecated */ ldap_sort_strcasecmp LDAP_P(( LDAP_CONST void *a, LDAP_CONST void *b )); #endif /* * in url.c */ LDAP_F( int ) ldap_is_ldap_url LDAP_P(( LDAP_CONST char *url )); LDAP_F( int ) ldap_is_ldaps_url LDAP_P(( LDAP_CONST char *url )); LDAP_F( int ) ldap_is_ldapi_url LDAP_P(( LDAP_CONST char *url )); #ifdef LDAP_CONNECTIONLESS LDAP_F( int ) ldap_is_ldapc_url LDAP_P(( LDAP_CONST char *url )); #endif LDAP_F( int ) ldap_url_parse LDAP_P(( LDAP_CONST char *url, LDAPURLDesc **ludpp )); LDAP_F( char * ) ldap_url_desc2str LDAP_P(( LDAPURLDesc *ludp )); LDAP_F( void ) ldap_free_urldesc LDAP_P(( LDAPURLDesc *ludp )); /* * LDAP Cancel Extended Operation <draft-zeilenga-ldap-cancel-xx.txt> * in cancel.c */ #define LDAP_API_FEATURE_CANCEL 1000 LDAP_F( int ) ldap_cancel LDAP_P(( LDAP *ld, int cancelid, LDAPControl **sctrls, LDAPControl **cctrls, int *msgidp )); LDAP_F( int ) ldap_cancel_s LDAP_P(( LDAP *ld, int cancelid, LDAPControl **sctrl, LDAPControl **cctrl )); /* * LDAP Turn Extended Operation <draft-zeilenga-ldap-turn-xx.txt> * in turn.c */ #define LDAP_API_FEATURE_TURN 1000 LDAP_F( int ) ldap_turn LDAP_P(( LDAP *ld, int mutual, LDAP_CONST char* identifier, LDAPControl **sctrls, LDAPControl **cctrls, int *msgidp )); LDAP_F( int ) ldap_turn_s LDAP_P(( LDAP *ld, int mutual, LDAP_CONST char* identifier, LDAPControl **sctrl, LDAPControl **cctrl )); /* * LDAP Paged Results * in pagectrl.c */ #define LDAP_API_FEATURE_PAGED_RESULTS 2000 LDAP_F( int ) ldap_create_page_control_value LDAP_P(( LDAP *ld, ber_int_t pagesize, struct berval *cookie, struct berval *value )); LDAP_F( int ) ldap_create_page_control LDAP_P(( LDAP *ld, ber_int_t pagesize, struct berval *cookie, int iscritical, LDAPControl **ctrlp )); #if LDAP_DEPRECATED LDAP_F( int ) ldap_parse_page_control LDAP_P(( /* deprecated, use ldap_parse_pageresponse_control */ LDAP *ld, LDAPControl **ctrls, ber_int_t *count, struct berval **cookie )); #endif LDAP_F( int ) ldap_parse_pageresponse_control LDAP_P(( LDAP *ld, LDAPControl *ctrl, ber_int_t *count, struct berval *cookie )); /* * LDAP Server Side Sort * in sortctrl.c */ #define LDAP_API_FEATURE_SERVER_SIDE_SORT 2000 /* structure for a sort-key */ typedef struct ldapsortkey { char *attributeType; char *orderingRule; int reverseOrder; } LDAPSortKey; LDAP_F( int ) ldap_create_sort_keylist LDAP_P(( LDAPSortKey ***sortKeyList, char *keyString )); LDAP_F( void ) ldap_free_sort_keylist LDAP_P(( LDAPSortKey **sortkeylist )); LDAP_F( int ) ldap_create_sort_control_value LDAP_P(( LDAP *ld, LDAPSortKey **keyList, struct berval *value )); LDAP_F( int ) ldap_create_sort_control LDAP_P(( LDAP *ld, LDAPSortKey **keyList, int iscritical, LDAPControl **ctrlp )); LDAP_F( int ) ldap_parse_sortresponse_control LDAP_P(( LDAP *ld, LDAPControl *ctrl, ber_int_t *result, char **attribute )); /* * LDAP Virtual List View * in vlvctrl.c */ #define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 2000 /* structure for virtual list */ typedef struct ldapvlvinfo { ber_int_t ldvlv_version; ber_int_t ldvlv_before_count; ber_int_t ldvlv_after_count; ber_int_t ldvlv_offset; ber_int_t ldvlv_count; struct berval * ldvlv_attrvalue; struct berval * ldvlv_context; void * ldvlv_extradata; } LDAPVLVInfo; LDAP_F( int ) ldap_create_vlv_control_value LDAP_P(( LDAP *ld, LDAPVLVInfo *ldvlistp, struct berval *value)); LDAP_F( int ) ldap_create_vlv_control LDAP_P(( LDAP *ld, LDAPVLVInfo *ldvlistp, LDAPControl **ctrlp )); LDAP_F( int ) ldap_parse_vlvresponse_control LDAP_P(( LDAP *ld, LDAPControl *ctrls, ber_int_t *target_posp, ber_int_t *list_countp, struct berval **contextp, int *errcodep )); /* * LDAP Verify Credentials */ #define LDAP_API_FEATURE_VERIFY_CREDENTIALS 1000 LDAP_F( int ) ldap_verify_credentials LDAP_P(( LDAP *ld, struct berval *cookie, LDAP_CONST char *dn, LDAP_CONST char *mechanism, struct berval *cred, LDAPControl **ctrls, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp )); LDAP_F( int ) ldap_verify_credentials_s LDAP_P(( LDAP *ld, struct berval *cookie, LDAP_CONST char *dn, LDAP_CONST char *mechanism, struct berval *cred, LDAPControl **vcictrls, LDAPControl **serverctrls, LDAPControl **clientctrls, int *code, char **diagmsgp, struct berval **scookie, struct berval **servercredp, LDAPControl ***vcoctrls)); LDAP_F( int ) ldap_parse_verify_credentials LDAP_P(( LDAP *ld, LDAPMessage *res, int *code, char **diagmsgp, struct berval **cookie, struct berval **servercredp, LDAPControl ***vcctrls)); /* not yet implemented */ /* #define LDAP_API_FEATURE_VERIFY_CREDENTIALS_INTERACTIVE 1000 */ #ifdef LDAP_API_FEATURE_VERIFY_CREDENTIALS_INTERACTIVE LDAP_F( int ) ldap_verify_credentials_interactive LDAP_P(( LDAP *ld, LDAP_CONST char *dn, /* usually NULL */ LDAP_CONST char *saslMechanism, LDAPControl **vcControls, LDAPControl **serverControls, LDAPControl **clientControls, /* should be client controls */ unsigned flags, LDAP_SASL_INTERACT_PROC *proc, void *defaults, void *context, /* as obtained from ldap_result() */ LDAPMessage *result, /* returned during bind processing */ const char **rmech, int *msgid )); #endif /* * LDAP Who Am I? * in whoami.c */ #define LDAP_API_FEATURE_WHOAMI 1000 LDAP_F( int ) ldap_parse_whoami LDAP_P(( LDAP *ld, LDAPMessage *res, struct berval **authzid )); LDAP_F( int ) ldap_whoami LDAP_P(( LDAP *ld, LDAPControl **sctrls, LDAPControl **cctrls, int *msgidp )); LDAP_F( int ) ldap_whoami_s LDAP_P(( LDAP *ld, struct berval **authzid, LDAPControl **sctrls, LDAPControl **cctrls )); /* * LDAP Password Modify * in passwd.c */ #define LDAP_API_FEATURE_PASSWD_MODIFY 1000 LDAP_F( int ) ldap_parse_passwd LDAP_P(( LDAP *ld, LDAPMessage *res, struct berval *newpasswd )); LDAP_F( int ) ldap_passwd LDAP_P(( LDAP *ld, struct berval *user, struct berval *oldpw, struct berval *newpw, LDAPControl **sctrls, LDAPControl **cctrls, int *msgidp )); LDAP_F( int ) ldap_passwd_s LDAP_P(( LDAP *ld, struct berval *user, struct berval *oldpw, struct berval *newpw, struct berval *newpasswd, LDAPControl **sctrls, LDAPControl **cctrls )); #ifdef LDAP_CONTROL_PASSWORDPOLICYREQUEST /* * LDAP Password Policy controls * in ppolicy.c */ #define LDAP_API_FEATURE_PASSWORD_POLICY 1000 typedef enum passpolicyerror_enum { PP_passwordExpired = 0, PP_accountLocked = 1, PP_changeAfterReset = 2, PP_passwordModNotAllowed = 3, PP_mustSupplyOldPassword = 4, PP_insufficientPasswordQuality = 5, PP_passwordTooShort = 6, PP_passwordTooYoung = 7, PP_passwordInHistory = 8, PP_passwordTooLong = 9, PP_noError = 65535 } LDAPPasswordPolicyError; LDAP_F( int ) ldap_create_passwordpolicy_control LDAP_P(( LDAP *ld, LDAPControl **ctrlp )); LDAP_F( int ) ldap_parse_passwordpolicy_control LDAP_P(( LDAP *ld, LDAPControl *ctrl, ber_int_t *expirep, ber_int_t *gracep, LDAPPasswordPolicyError *errorp )); LDAP_F( const char * ) ldap_passwordpolicy_err2txt LDAP_P(( LDAPPasswordPolicyError )); #endif /* LDAP_CONTROL_PASSWORDPOLICYREQUEST */ LDAP_F( int ) ldap_parse_password_expiring_control LDAP_P(( LDAP *ld, LDAPControl *ctrl, long *secondsp )); /* * LDAP Dynamic Directory Services Refresh -- RFC 2589 * in dds.c */ #define LDAP_API_FEATURE_REFRESH 1000 LDAP_F( int ) ldap_parse_refresh LDAP_P(( LDAP *ld, LDAPMessage *res, ber_int_t *newttl )); LDAP_F( int ) ldap_refresh LDAP_P(( LDAP *ld, struct berval *dn, ber_int_t ttl, LDAPControl **sctrls, LDAPControl **cctrls, int *msgidp )); LDAP_F( int ) ldap_refresh_s LDAP_P(( LDAP *ld, struct berval *dn, ber_int_t ttl, ber_int_t *newttl, LDAPControl **sctrls, LDAPControl **cctrls )); /* * LDAP Transactions */ LDAP_F( int ) ldap_txn_start LDAP_P(( LDAP *ld, LDAPControl **sctrls, LDAPControl **cctrls, int *msgidp )); LDAP_F( int ) ldap_txn_start_s LDAP_P(( LDAP *ld, LDAPControl **sctrl, LDAPControl **cctrl, struct berval **rettxnid )); LDAP_F( int ) ldap_txn_end LDAP_P(( LDAP *ld, int commit, struct berval *txnid, LDAPControl **sctrls, LDAPControl **cctrls, int *msgidp )); LDAP_F( int ) ldap_txn_end_s LDAP_P(( LDAP *ld, int commit, struct berval *txnid, LDAPControl **sctrl, LDAPControl **cctrl, int *retidp )); /* * in ldap_sync.c */ /* * initialize the persistent search structure */ LDAP_F( ldap_sync_t * ) ldap_sync_initialize LDAP_P(( ldap_sync_t *ls )); /* * destroy the persistent search structure */ LDAP_F( void ) ldap_sync_destroy LDAP_P(( ldap_sync_t *ls, int freeit )); /* * initialize a refreshOnly sync */ LDAP_F( int ) ldap_sync_init LDAP_P(( ldap_sync_t *ls, int mode )); /* * initialize a refreshOnly sync */ LDAP_F( int ) ldap_sync_init_refresh_only LDAP_P(( ldap_sync_t *ls )); /* * initialize a refreshAndPersist sync */ LDAP_F( int ) ldap_sync_init_refresh_and_persist LDAP_P(( ldap_sync_t *ls )); /* * poll for new responses */ LDAP_F( int ) ldap_sync_poll LDAP_P(( ldap_sync_t *ls )); #ifdef LDAP_CONTROL_X_SESSION_TRACKING /* * in stctrl.c */ LDAP_F( int ) ldap_create_session_tracking_value LDAP_P(( LDAP *ld, char *sessionSourceIp, char *sessionSourceName, char *formatOID, struct berval *sessionTrackingIdentifier, struct berval *value )); LDAP_F( int ) ldap_create_session_tracking_control LDAP_P(( LDAP *ld, char *sessionSourceIp, char *sessionSourceName, char *formatOID, struct berval *sessionTrackingIdentifier, LDAPControl **ctrlp )); LDAP_F( int ) ldap_parse_session_tracking_control LDAP_P(( LDAP *ld, LDAPControl *ctrl, struct berval *ip, struct berval *name, struct berval *oid, struct berval *id )); #endif /* LDAP_CONTROL_X_SESSION_TRACKING */ /* * in msctrl.c */ #ifdef LDAP_CONTROL_X_DIRSYNC LDAP_F( int ) ldap_create_dirsync_value LDAP_P(( LDAP *ld, int flags, int maxAttrCount, struct berval *cookie, struct berval *value )); LDAP_F( int ) ldap_create_dirsync_control LDAP_P(( LDAP *ld, int flags, int maxAttrCount, struct berval *cookie, LDAPControl **ctrlp )); LDAP_F( int ) ldap_parse_dirsync_control LDAP_P(( LDAP *ld, LDAPControl *ctrl, int *continueFlag, struct berval *cookie )); #endif /* LDAP_CONTROL_X_DIRSYNC */ #ifdef LDAP_CONTROL_X_EXTENDED_DN LDAP_F( int ) ldap_create_extended_dn_value LDAP_P(( LDAP *ld, int flag, struct berval *value )); LDAP_F( int ) ldap_create_extended_dn_control LDAP_P(( LDAP *ld, int flag, LDAPControl **ctrlp )); #endif /* LDAP_CONTROL_X_EXTENDED_DN */ #ifdef LDAP_CONTROL_X_SHOW_DELETED LDAP_F( int ) ldap_create_show_deleted_control LDAP_P(( LDAP *ld, LDAPControl **ctrlp )); #endif /* LDAP_CONTROL_X_SHOW_DELETED */ #ifdef LDAP_CONTROL_X_SERVER_NOTIFICATION LDAP_F( int ) ldap_create_server_notification_control LDAP_P(( LDAP *ld, LDAPControl **ctrlp )); #endif /* LDAP_CONTROL_X_SERVER_NOTIFICATION */ /* * in assertion.c */ LDAP_F (int) ldap_create_assertion_control_value LDAP_P(( LDAP *ld, char *assertion, struct berval *value )); LDAP_F( int ) ldap_create_assertion_control LDAP_P(( LDAP *ld, char *filter, int iscritical, LDAPControl **ctrlp )); /* * in deref.c */ typedef struct LDAPDerefSpec { char *derefAttr; char **attributes; } LDAPDerefSpec; typedef struct LDAPDerefVal { char *type; BerVarray vals; struct LDAPDerefVal *next; } LDAPDerefVal; typedef struct LDAPDerefRes { char *derefAttr; struct berval derefVal; LDAPDerefVal *attrVals; struct LDAPDerefRes *next; } LDAPDerefRes; LDAP_F( int ) ldap_create_deref_control_value LDAP_P(( LDAP *ld, LDAPDerefSpec *ds, struct berval *value )); LDAP_F( int ) ldap_create_deref_control LDAP_P(( LDAP *ld, LDAPDerefSpec *ds, int iscritical, LDAPControl **ctrlp )); LDAP_F( void ) ldap_derefresponse_free LDAP_P(( LDAPDerefRes *dr )); LDAP_F( int ) ldap_parse_derefresponse_control LDAP_P(( LDAP *ld, LDAPControl *ctrl, LDAPDerefRes **drp )); LDAP_F( int ) ldap_parse_deref_control LDAP_P(( LDAP *ld, LDAPControl **ctrls, LDAPDerefRes **drp )); /* * in psearch.c */ LDAP_F( int ) ldap_create_persistentsearch_control_value LDAP_P(( LDAP *ld, int changetypes, int changesonly, int return_echg_ctls, struct berval *value )); LDAP_F( int ) ldap_create_persistentsearch_control LDAP_P(( LDAP *ld, int changetypes, int changesonly, int return_echg_ctls, int isCritical, LDAPControl **ctrlp )); LDAP_F( int ) ldap_parse_entrychange_control LDAP_P(( LDAP *ld, LDAPControl *ctrl, int *chgtypep, struct berval *prevdnp, int *chgnumpresentp, long *chgnump )); /* in account_usability.c */ LDAP_F( int ) ldap_create_accountusability_control LDAP_P(( LDAP *ld, LDAPControl **ctrlp )); typedef struct LDAPAccountUsabilityMoreInfo { ber_int_t inactive; ber_int_t reset; ber_int_t expired; ber_int_t remaining_grace; ber_int_t seconds_before_unlock; } LDAPAccountUsabilityMoreInfo; typedef union LDAPAccountUsability { ber_int_t seconds_remaining; LDAPAccountUsabilityMoreInfo more_info; } LDAPAccountUsability; LDAP_F( int ) ldap_parse_accountusability_control LDAP_P(( LDAP *ld, LDAPControl *ctrl, int *availablep, LDAPAccountUsability *usabilityp )); /* * high level LDIF to LDAP structure support */ #define LDIF_DEFAULT_ADD 0x01 /* if changetype missing, assume LDAP_ADD */ #define LDIF_ENTRIES_ONLY 0x02 /* ignore changetypes other than add */ #define LDIF_NO_CONTROLS 0x04 /* ignore control specifications */ #define LDIF_MODS_ONLY 0x08 /* no changetypes, assume LDAP_MODIFY */ #define LDIF_NO_DN 0x10 /* dn is not present */ typedef struct ldifrecord { ber_tag_t lr_op; /* type of operation - LDAP_REQ_MODIFY, LDAP_REQ_ADD, etc. */ struct berval lr_dn; /* DN of operation */ LDAPControl **lr_ctrls; /* controls specified for operation */ /* some ops such as LDAP_REQ_DELETE require only a DN */ /* other ops require different data - the ldif_ops union is used to specify the data for each type of operation */ union ldif_ops_u { LDAPMod **lr_mods; /* list of mods for LDAP_REQ_MODIFY, LDAP_REQ_ADD */ #define lrop_mods ldif_ops.lr_mods struct ldif_op_rename_s { struct berval lr_newrdn; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */ #define lrop_newrdn ldif_ops.ldif_op_rename.lr_newrdn struct berval lr_newsuperior; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */ #define lrop_newsup ldif_ops.ldif_op_rename.lr_newsuperior int lr_deleteoldrdn; /* LDAP_REQ_MODDN, LDAP_REQ_MODRDN, LDAP_REQ_RENAME */ #define lrop_delold ldif_ops.ldif_op_rename.lr_deleteoldrdn } ldif_op_rename; /* rename/moddn/modrdn */ /* the following are for future support */ struct ldif_op_ext_s { struct berval lr_extop_oid; /* LDAP_REQ_EXTENDED */ #define lrop_extop_oid ldif_ops.ldif_op_ext.lr_extop_oid struct berval lr_extop_data; /* LDAP_REQ_EXTENDED */ #define lrop_extop_data ldif_ops.ldif_op_ext.lr_extop_data } ldif_op_ext; /* extended operation */ struct ldif_op_cmp_s { struct berval lr_cmp_attr; /* LDAP_REQ_COMPARE */ #define lrop_cmp_attr ldif_ops.ldif_op_cmp.lr_cmp_attr struct berval lr_cmp_bvalue; /* LDAP_REQ_COMPARE */ #define lrop_cmp_bval ldif_ops.ldif_op_cmp.lr_cmp_bvalue } ldif_op_cmp; /* compare operation */ } ldif_ops; /* PRIVATE STUFF - DO NOT TOUCH */ /* for efficiency, the implementation allocates memory */ /* in large blobs, and makes the above fields point to */ /* locations inside those blobs - one consequence is that */ /* you cannot simply free the above allocated fields, nor */ /* assign them to be owned by another memory context which */ /* might free them (unless providing your own mem ctx) */ /* we use the fields below to keep track of those blobs */ /* so we that we can free them later */ void *lr_ctx; /* the memory context or NULL */ int lr_lines; LDAPMod *lr_lm; unsigned char *lr_mops; char *lr_freeval; struct berval *lr_vals; struct berval *lr_btype; } LDIFRecord; /* free internal fields - does not free the LDIFRecord */ LDAP_F( void ) ldap_ldif_record_done LDAP_P(( LDIFRecord *lr )); LDAP_F( int ) ldap_parse_ldif_record LDAP_P(( struct berval *rbuf, unsigned long linenum, LDIFRecord *lr, const char *errstr, unsigned int flags )); LDAP_END_DECL #endif /* _LDAP_H */ /* Copyright (C) 1992-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ /* * X/Open Portability Guide 4.2: ftw.h */ #ifndef _FTW_H #define _FTW_H 1 #include <features.h> #include <sys/types.h> #include <sys/stat.h> __BEGIN_DECLS /* Values for the FLAG argument to the user function passed to `ftw' and 'nftw'. */ enum { FTW_F, /* Regular file. */ #define FTW_F FTW_F FTW_D, /* Directory. */ #define FTW_D FTW_D FTW_DNR, /* Unreadable directory. */ #define FTW_DNR FTW_DNR FTW_NS, /* Unstatable file. */ #define FTW_NS FTW_NS #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED FTW_SL, /* Symbolic link. */ # define FTW_SL FTW_SL #endif #ifdef __USE_XOPEN_EXTENDED /* These flags are only passed from the `nftw' function. */ FTW_DP, /* Directory, all subdirs have been visited. */ # define FTW_DP FTW_DP FTW_SLN /* Symbolic link naming non-existing file. */ # define FTW_SLN FTW_SLN #endif /* extended X/Open */ }; #ifdef __USE_XOPEN_EXTENDED /* Flags for fourth argument of `nftw'. */ enum { FTW_PHYS = 1, /* Perform physical walk, ignore symlinks. */ # define FTW_PHYS FTW_PHYS FTW_MOUNT = 2, /* Report only files on same file system as the argument. */ # define FTW_MOUNT FTW_MOUNT FTW_CHDIR = 4, /* Change to current directory while processing it. */ # define FTW_CHDIR FTW_CHDIR FTW_DEPTH = 8 /* Report files in directory before directory itself.*/ # define FTW_DEPTH FTW_DEPTH # ifdef __USE_GNU , FTW_ACTIONRETVAL = 16 /* Assume callback to return FTW_* values instead of zero to continue and non-zero to terminate. */ # define FTW_ACTIONRETVAL FTW_ACTIONRETVAL # endif }; #ifdef __USE_GNU /* Return values from callback functions. */ enum { FTW_CONTINUE = 0, /* Continue with next sibling or for FTW_D with the first child. */ # define FTW_CONTINUE FTW_CONTINUE FTW_STOP = 1, /* Return from `ftw' or `nftw' with FTW_STOP as return value. */ # define FTW_STOP FTW_STOP FTW_SKIP_SUBTREE = 2, /* Only meaningful for FTW_D: Don't walk through the subtree, instead just continue with its next sibling. */ # define FTW_SKIP_SUBTREE FTW_SKIP_SUBTREE FTW_SKIP_SIBLINGS = 3,/* Continue with FTW_DP callback for current directory (if FTW_DEPTH) and then its siblings. */ # define FTW_SKIP_SIBLINGS FTW_SKIP_SIBLINGS }; #endif /* Structure used for fourth argument to callback function for `nftw'. */ struct FTW { int base; int level; }; #endif /* extended X/Open */ /* Convenient types for callback functions. */ typedef int (*__ftw_func_t) (const char *__filename, const struct stat *__status, int __flag); #ifdef __USE_LARGEFILE64 typedef int (*__ftw64_func_t) (const char *__filename, const struct stat64 *__status, int __flag); #endif #ifdef __USE_XOPEN_EXTENDED typedef int (*__nftw_func_t) (const char *__filename, const struct stat *__status, int __flag, struct FTW *__info); # ifdef __USE_LARGEFILE64 typedef int (*__nftw64_func_t) (const char *__filename, const struct stat64 *__status, int __flag, struct FTW *__info); # endif #endif /* Call a function on every element in a directory tree. This function is a possible cancellation point and therefore not marked with __THROW. */ #ifndef __USE_FILE_OFFSET64 extern int ftw (const char *__dir, __ftw_func_t __func, int __descriptors) __nonnull ((1, 2)); #else # ifdef __REDIRECT # ifndef __USE_TIME_BITS64 extern int __REDIRECT (ftw, (const char *__dir, __ftw_func_t __func, int __descriptors), ftw64) __nonnull ((1, 2)); # else extern int __REDIRECT (ftw, (const char *__dir, __ftw_func_t __func, int __descriptors), __ftw64_time64) __nonnull ((1, 2)); # endif # else # ifndef __USE_TIME_BITS64 # define ftw ftw64 # else # define ftw __ftw64_time64 # endif # endif #endif #ifdef __USE_LARGEFILE64 # ifndef __USE_TIME_BITS64 extern int ftw64 (const char *__dir, __ftw64_func_t __func, int __descriptors) __nonnull ((1, 2)); # else # ifdef __REDIRECT extern int __REDIRECT (ftw64, (const char *__dir, __ftw64_func_t __func, int __descriptors), __ftw64_time64) __nonnull ((1, 2)); # else # define nftw64 __nftw64_time64 # endif # endif #endif #ifdef __USE_XOPEN_EXTENDED /* Call a function on every element in a directory tree. FLAG allows to specify the behaviour more detailed. This function is a possible cancellation point and therefore not marked with __THROW. */ # ifndef __USE_FILE_OFFSET64 extern int nftw (const char *__dir, __nftw_func_t __func, int __descriptors, int __flag) __nonnull ((1, 2)); # else # ifdef __REDIRECT # ifndef __USE_TIME_BITS64 extern int __REDIRECT (nftw, (const char *__dir, __nftw_func_t __func, int __descriptors, int __flag), nftw64) __nonnull ((1, 2)); # else extern int __REDIRECT (nftw, (const char *__dir, __nftw_func_t __func, int __descriptors, int __flag), __nftw64_time64) __nonnull ((1, 2)); # endif # else # ifndef __USE_TIME_BITS64 # define nftw nftw64 # else # define nftw __nftw64_time64 # endif # endif # endif # ifdef __USE_LARGEFILE64 # ifndef __USE_TIME_BITS64 extern int nftw64 (const char *__dir, __nftw64_func_t __func, int __descriptors, int __flag) __nonnull ((1, 2)); # else # ifdef __REDIRECT extern int __REDIRECT (nftw64, (const char *__dir, __nftw64_func_t __func, int __descriptors, int __flag), __nftw64_time64) __nonnull ((1, 2)); # else # define nftw64 __nftw64_time64 # endif # endif # endif #endif __END_DECLS #endif /* ftw.h */ /* Copyright (C) 1998-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _EXECINFO_H #define _EXECINFO_H 1 #include <features.h> __BEGIN_DECLS /* Store up to SIZE return address of the current program state in ARRAY and return the exact number of values stored. */ extern int backtrace (void **__array, int __size) __nonnull ((1)); /* Return names of functions from the backtrace list in ARRAY in a newly malloc()ed memory block. */ extern char **backtrace_symbols (void *const *__array, int __size) __THROW __nonnull ((1)); /* This function is similar to backtrace_symbols() but it writes the result immediately to a file. */ extern void backtrace_symbols_fd (void *const *__array, int __size, int __fd) __THROW __nonnull ((1)); __END_DECLS #endif /* execinfo.h */ /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Thomas E. Dickey 1996-on * ****************************************************************************/ /* $Id: curses.h.in,v 1.271 2021/03/20 16:25:43 tom Exp $ */ #ifndef __NCURSES_H #define __NCURSES_H #define CURSES 1 #define CURSES_H 1 /* These are defined only in curses.h, and are used for conditional compiles */ #define NCURSES_VERSION_MAJOR 6 #define NCURSES_VERSION_MINOR 2 #define NCURSES_VERSION_PATCH 20210508 /* This is defined in more than one ncurses header, for identification */ #undef NCURSES_VERSION #define NCURSES_VERSION "6.2" /* * Identify the mouse encoding version. */ #define NCURSES_MOUSE_VERSION 2 /* * Definitions to facilitate DLL's. */ #include <ncurses_dll.h> /* * Extra headers. */ #if 1 #include <stdint.h> #endif #ifdef __cplusplus #else #if 0 #include <stdnoreturn.h> #undef GCC_NORETURN #define GCC_NORETURN _Noreturn #endif #endif /* * User-definable tweak to disable the include of <stdbool.h>. */ #ifndef NCURSES_ENABLE_STDBOOL_H #define NCURSES_ENABLE_STDBOOL_H 1 #endif /* * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses * configured using --disable-macros. */ #ifndef NCURSES_ATTR_T #define NCURSES_ATTR_T int #endif /* * Expands to 'const' if ncurses is configured using --enable-const. Note that * doing so makes it incompatible with other implementations of X/Open Curses. */ #undef NCURSES_CONST #define NCURSES_CONST const #undef NCURSES_INLINE #define NCURSES_INLINE inline /* * The standard type used for color values, and for color-pairs. The latter * allows the curses library to enumerate the combinations of foreground and * background colors used by an application, and is normally the product of the * total foreground and background colors. * * X/Open uses "short" for both of these types, ultimately because they are * numbers from the SVr4 terminal database, which uses 16-bit signed values. */ #undef NCURSES_COLOR_T #define NCURSES_COLOR_T short #undef NCURSES_PAIRS_T #define NCURSES_PAIRS_T short /* * Definitions used to make WINDOW and similar structs opaque. */ #ifndef NCURSES_INTERNALS #define NCURSES_OPAQUE 0 #define NCURSES_OPAQUE_FORM 0 #define NCURSES_OPAQUE_MENU 0 #define NCURSES_OPAQUE_PANEL 0 #endif /* * Definition used to optionally suppress wattr* macros to help with the * transition from ncurses5 to ncurses6 by allowing the header files to * be shared across development packages for ncursesw in both ABIs. */ #ifndef NCURSES_WATTR_MACROS #define NCURSES_WATTR_MACROS 0 #endif /* * The reentrant code relies on the opaque setting, but adds features. */ #ifndef NCURSES_REENTRANT #define NCURSES_REENTRANT 0 #endif /* * In certain environments, we must work around linker problems for data */ #undef NCURSES_BROKEN_LINKER #if 0 #define NCURSES_BROKEN_LINKER 1 #endif /* * Control whether bindings for interop support are added. */ #undef NCURSES_INTEROP_FUNCS #define NCURSES_INTEROP_FUNCS 1 /* * The internal type used for window dimensions. */ #undef NCURSES_SIZE_T #define NCURSES_SIZE_T short /* * Control whether tparm() supports varargs or fixed-parameter list. */ #undef NCURSES_TPARM_VARARGS #define NCURSES_TPARM_VARARGS 1 /* * Control type used for tparm's arguments. While X/Open equates long and * char* values, this is not always workable for 64-bit platforms. */ #undef NCURSES_TPARM_ARG #define NCURSES_TPARM_ARG intptr_t /* * Control whether ncurses uses wcwidth() for checking width of line-drawing * characters. */ #undef NCURSES_WCWIDTH_GRAPHICS #define NCURSES_WCWIDTH_GRAPHICS 1 /* * NCURSES_CH_T is used in building the library, but not used otherwise in * this header file, since that would make the normal/wide-character versions * of the header incompatible. */ #undef NCURSES_CH_T #define NCURSES_CH_T cchar_t #if 1 && defined(_LP64) typedef unsigned chtype; typedef unsigned mmask_t; #else typedef uint32_t chtype; typedef uint32_t mmask_t; #endif /* * We need FILE, etc. Include this before checking any feature symbols. */ #include <stdio.h> /* * With XPG4, you must define _XOPEN_SOURCE_EXTENDED, it is redundant (or * conflicting) when _XOPEN_SOURCE is 500 or greater. If NCURSES_WIDECHAR is * not already defined, e.g., if the platform relies upon nonstandard feature * test macros, define it at this point if the standard feature test macros * indicate that it should be defined. */ #ifndef NCURSES_WIDECHAR #if defined(_XOPEN_SOURCE_EXTENDED) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) #define NCURSES_WIDECHAR 1 #else #define NCURSES_WIDECHAR 0 #endif #endif /* NCURSES_WIDECHAR */ #include <stdarg.h> /* we need va_list */ #if NCURSES_WIDECHAR #include <stddef.h> /* we want wchar_t */ #endif /* X/Open and SVr4 specify that curses implements 'bool'. However, C++ may also * implement it. If so, we must use the C++ compiler's type to avoid conflict * with other interfaces. * * A further complication is that <stdbool.h> may declare 'bool' to be a * different type, such as an enum which is not necessarily compatible with * C++. If we have <stdbool.h>, make 'bool' a macro, so users may #undef it. * Otherwise, let it remain a typedef to avoid conflicts with other #define's. * In either case, make a typedef for NCURSES_BOOL which can be used if needed * from either C or C++. */ #undef TRUE #define TRUE 1 #undef FALSE #define FALSE 0 typedef unsigned char NCURSES_BOOL; #if defined(__cplusplus) /* __cplusplus, etc. */ /* use the C++ compiler's bool type */ #define NCURSES_BOOL bool #else /* c89, c99, etc. */ #if NCURSES_ENABLE_STDBOOL_H #include <stdbool.h> /* use whatever the C compiler decides bool really is */ #define NCURSES_BOOL bool #else /* there is no predefined bool - use our own */ #undef bool #define bool NCURSES_BOOL #endif #endif /* !__cplusplus, etc. */ #ifdef __cplusplus extern "C" { #define NCURSES_CAST(type,value) static_cast<type>(value) #else #define NCURSES_CAST(type,value) (type)(value) #endif #define NCURSES_OK_ADDR(p) (0 != NCURSES_CAST(const void *, (p))) /* * X/Open attributes. In the ncurses implementation, they are identical to the * A_ attributes. */ #define WA_ATTRIBUTES A_ATTRIBUTES #define WA_NORMAL A_NORMAL #define WA_STANDOUT A_STANDOUT #define WA_UNDERLINE A_UNDERLINE #define WA_REVERSE A_REVERSE #define WA_BLINK A_BLINK #define WA_DIM A_DIM #define WA_BOLD A_BOLD #define WA_ALTCHARSET A_ALTCHARSET #define WA_INVIS A_INVIS #define WA_PROTECT A_PROTECT #define WA_HORIZONTAL A_HORIZONTAL #define WA_LEFT A_LEFT #define WA_LOW A_LOW #define WA_RIGHT A_RIGHT #define WA_TOP A_TOP #define WA_VERTICAL A_VERTICAL #if 1 #define WA_ITALIC A_ITALIC /* ncurses extension */ #endif /* colors */ #define COLOR_BLACK 0 #define COLOR_RED 1 #define COLOR_GREEN 2 #define COLOR_YELLOW 3 #define COLOR_BLUE 4 #define COLOR_MAGENTA 5 #define COLOR_CYAN 6 #define COLOR_WHITE 7 /* line graphics */ #if 0 || NCURSES_REENTRANT NCURSES_WRAPPED_VAR(chtype*, acs_map); #define acs_map NCURSES_PUBLIC_VAR(acs_map()) #else extern NCURSES_EXPORT_VAR(chtype) acs_map[]; #endif #define NCURSES_ACS(c) (acs_map[NCURSES_CAST(unsigned char,(c))]) /* VT100 symbols begin here */ #define ACS_ULCORNER NCURSES_ACS('l') /* upper left corner */ #define ACS_LLCORNER NCURSES_ACS('m') /* lower left corner */ #define ACS_URCORNER NCURSES_ACS('k') /* upper right corner */ #define ACS_LRCORNER NCURSES_ACS('j') /* lower right corner */ #define ACS_LTEE NCURSES_ACS('t') /* tee pointing right */ #define ACS_RTEE NCURSES_ACS('u') /* tee pointing left */ #define ACS_BTEE NCURSES_ACS('v') /* tee pointing up */ #define ACS_TTEE NCURSES_ACS('w') /* tee pointing down */ #define ACS_HLINE NCURSES_ACS('q') /* horizontal line */ #define ACS_VLINE NCURSES_ACS('x') /* vertical line */ #define ACS_PLUS NCURSES_ACS('n') /* large plus or crossover */ #define ACS_S1 NCURSES_ACS('o') /* scan line 1 */ #define ACS_S9 NCURSES_ACS('s') /* scan line 9 */ #define ACS_DIAMOND NCURSES_ACS('`') /* diamond */ #define ACS_CKBOARD NCURSES_ACS('a') /* checker board (stipple) */ #define ACS_DEGREE NCURSES_ACS('f') /* degree symbol */ #define ACS_PLMINUS NCURSES_ACS('g') /* plus/minus */ #define ACS_BULLET NCURSES_ACS('~') /* bullet */ /* Teletype 5410v1 symbols begin here */ #define ACS_LARROW NCURSES_ACS(',') /* arrow pointing left */ #define ACS_RARROW NCURSES_ACS('+') /* arrow pointing right */ #define ACS_DARROW NCURSES_ACS('.') /* arrow pointing down */ #define ACS_UARROW NCURSES_ACS('-') /* arrow pointing up */ #define ACS_BOARD NCURSES_ACS('h') /* board of squares */ #define ACS_LANTERN NCURSES_ACS('i') /* lantern symbol */ #define ACS_BLOCK NCURSES_ACS('0') /* solid square block */ /* * These aren't documented, but a lot of System Vs have them anyway * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings). * The ACS_names may not match AT&T's, our source didn't know them. */ #define ACS_S3 NCURSES_ACS('p') /* scan line 3 */ #define ACS_S7 NCURSES_ACS('r') /* scan line 7 */ #define ACS_LEQUAL NCURSES_ACS('y') /* less/equal */ #define ACS_GEQUAL NCURSES_ACS('z') /* greater/equal */ #define ACS_PI NCURSES_ACS('{') /* Pi */ #define ACS_NEQUAL NCURSES_ACS('|') /* not equal */ #define ACS_STERLING NCURSES_ACS('}') /* UK pound sign */ /* * Line drawing ACS names are of the form ACS_trbl, where t is the top, r * is the right, b is the bottom, and l is the left. t, r, b, and l might * be B (blank), S (single), D (double), or T (thick). The subset defined * here only uses B and S. */ #define ACS_BSSB ACS_ULCORNER #define ACS_SSBB ACS_LLCORNER #define ACS_BBSS ACS_URCORNER #define ACS_SBBS ACS_LRCORNER #define ACS_SBSS ACS_RTEE #define ACS_SSSB ACS_LTEE #define ACS_SSBS ACS_BTEE #define ACS_BSSS ACS_TTEE #define ACS_BSBS ACS_HLINE #define ACS_SBSB ACS_VLINE #define ACS_SSSS ACS_PLUS #undef ERR #define ERR (-1) #undef OK #define OK (0) /* values for the _flags member */ #define _SUBWIN 0x01 /* is this a sub-window? */ #define _ENDLINE 0x02 /* is the window flush right? */ #define _FULLWIN 0x04 /* is the window full-screen? */ #define _SCROLLWIN 0x08 /* bottom edge is at screen bottom? */ #define _ISPAD 0x10 /* is this window a pad? */ #define _HASMOVED 0x20 /* has cursor moved since last refresh? */ #define _WRAPPED 0x40 /* cursor was just wrappped */ /* * this value is used in the firstchar and lastchar fields to mark * unchanged lines */ #define _NOCHANGE -1 /* * this value is used in the oldindex field to mark lines created by insertions * and scrolls. */ #define _NEWINDEX -1 typedef struct screen SCREEN; typedef struct _win_st WINDOW; typedef chtype attr_t; /* ...must be at least as wide as chtype */ #if NCURSES_WIDECHAR #if 0 #ifdef mblen /* libutf8.h defines it w/o undefining first */ #undef mblen #endif #include <libutf8.h> #endif #if 1 #include <wchar.h> /* ...to get mbstate_t, etc. */ #endif #if 0 typedef unsigned short wchar_t1; #endif #if 0 typedef unsigned int wint_t1; #endif /* * cchar_t stores an array of CCHARW_MAX wide characters. The first is * normally a spacing character. The others are non-spacing. If those * (spacing and nonspacing) do not fill the array, a null L'\0' follows. * Otherwise, a null is assumed to follow when extracting via getcchar(). */ #define CCHARW_MAX 5 typedef struct { attr_t attr; wchar_t chars[CCHARW_MAX]; #if 1 #undef NCURSES_EXT_COLORS #define NCURSES_EXT_COLORS 20210508 int ext_color; /* color pair, must be more than 16-bits */ #endif } cchar_t; #endif /* NCURSES_WIDECHAR */ #if !NCURSES_OPAQUE struct ldat; struct _win_st { NCURSES_SIZE_T _cury, _curx; /* current cursor position */ /* window location and size */ NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */ NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */ short _flags; /* window state flags */ /* attribute tracking */ attr_t _attrs; /* current attribute for non-space character */ chtype _bkgd; /* current background char/attribute pair */ /* option values set by user */ bool _notimeout; /* no time out on function-key entry? */ bool _clear; /* consider all data in the window invalid? */ bool _leaveok; /* OK to not reset cursor on exit? */ bool _scroll; /* OK to scroll this window? */ bool _idlok; /* OK to use insert/delete line? */ bool _idcok; /* OK to use insert/delete char? */ bool _immed; /* window in immed mode? (not yet used) */ bool _sync; /* window in sync mode? */ bool _use_keypad; /* process function keys into KEY_ symbols? */ int _delay; /* 0 = nodelay, <0 = blocking, >0 = delay */ struct ldat *_line; /* the actual line data */ /* global screen state */ NCURSES_SIZE_T _regtop; /* top line of scrolling region */ NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */ /* these are used only if this is a sub-window */ int _parx; /* x coordinate of this window in parent */ int _pary; /* y coordinate of this window in parent */ WINDOW *_parent; /* pointer to parent if a sub-window */ /* these are used only if this is a pad */ struct pdat { NCURSES_SIZE_T _pad_y, _pad_x; NCURSES_SIZE_T _pad_top, _pad_left; NCURSES_SIZE_T _pad_bottom, _pad_right; } _pad; NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */ #if NCURSES_WIDECHAR cchar_t _bkgrnd; /* current background char/attribute pair */ #if 1 int _color; /* current color-pair for non-space character */ #endif #endif }; #endif /* NCURSES_OPAQUE */ /* * GCC (and some other compilers) define '__attribute__'; we're using this * macro to alert the compiler to flag inconsistencies in printf/scanf-like * function calls. Just in case '__attribute__' isn't defined, make a dummy. * Old versions of G++ do not accept it anyway, at least not consistently with * GCC. */ #if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__)) #define __attribute__(p) /* nothing */ #endif /* * We cannot define these in ncurses_cfg.h, since they require parameters to be * passed (that is non-portable). If you happen to be using gcc with warnings * enabled, define * GCC_PRINTF * GCC_SCANF * to improve checking of calls to printw(), etc. */ #ifndef GCC_PRINTFLIKE #if defined(GCC_PRINTF) && !defined(printf) #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) #else #define GCC_PRINTFLIKE(fmt,var) /*nothing*/ #endif #endif #ifndef GCC_SCANFLIKE #if defined(GCC_SCANF) && !defined(scanf) #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) #else #define GCC_SCANFLIKE(fmt,var) /*nothing*/ #endif #endif #ifndef GCC_NORETURN #define GCC_NORETURN /* nothing */ #endif #ifndef GCC_UNUSED #define GCC_UNUSED /* nothing */ #endif #undef GCC_DEPRECATED #if (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)) && !defined(NCURSES_INTERNALS) #define GCC_DEPRECATED(msg) __attribute__((deprecated)) #else #define GCC_DEPRECATED(msg) /* nothing */ #endif /* * Curses uses a helper function. Define our type for this to simplify * extending it for the sp-funcs feature. */ typedef int (*NCURSES_OUTC)(int); /* * Function prototypes. This is the complete X/Open Curses list of required * functions. Those marked `generated' will have sources generated from the * macro definitions later in this file, in order to satisfy XPG4.2 * requirements. */ extern NCURSES_EXPORT(int) addch (const chtype); /* generated */ extern NCURSES_EXPORT(int) addchnstr (const chtype *, int); /* generated */ extern NCURSES_EXPORT(int) addchstr (const chtype *); /* generated */ extern NCURSES_EXPORT(int) addnstr (const char *, int); /* generated */ extern NCURSES_EXPORT(int) addstr (const char *); /* generated */ extern NCURSES_EXPORT(int) attroff (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attron (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attr_get (attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ extern NCURSES_EXPORT(int) attr_off (attr_t, void *); /* generated */ extern NCURSES_EXPORT(int) attr_on (attr_t, void *); /* generated */ extern NCURSES_EXPORT(int) attr_set (attr_t, NCURSES_PAIRS_T, void *); /* generated */ extern NCURSES_EXPORT(int) baudrate (void); /* implemented */ extern NCURSES_EXPORT(int) beep (void); /* implemented */ extern NCURSES_EXPORT(int) bkgd (chtype); /* generated */ extern NCURSES_EXPORT(void) bkgdset (chtype); /* generated */ extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* generated */ extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype); /* generated */ extern NCURSES_EXPORT(bool) can_change_color (void); /* implemented */ extern NCURSES_EXPORT(int) cbreak (void); /* implemented */ extern NCURSES_EXPORT(int) chgat (int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ extern NCURSES_EXPORT(int) clear (void); /* generated */ extern NCURSES_EXPORT(int) clearok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) clrtobot (void); /* generated */ extern NCURSES_EXPORT(int) clrtoeol (void); /* generated */ extern NCURSES_EXPORT(int) color_content (NCURSES_COLOR_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ extern NCURSES_EXPORT(int) color_set (NCURSES_PAIRS_T,void*); /* generated */ extern NCURSES_EXPORT(int) COLOR_PAIR (int); /* generated */ extern NCURSES_EXPORT(int) copywin (const WINDOW*,WINDOW*,int,int,int,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) curs_set (int); /* implemented */ extern NCURSES_EXPORT(int) def_prog_mode (void); /* implemented */ extern NCURSES_EXPORT(int) def_shell_mode (void); /* implemented */ extern NCURSES_EXPORT(int) delay_output (int); /* implemented */ extern NCURSES_EXPORT(int) delch (void); /* generated */ extern NCURSES_EXPORT(void) delscreen (SCREEN *); /* implemented */ extern NCURSES_EXPORT(int) delwin (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) deleteln (void); /* generated */ extern NCURSES_EXPORT(WINDOW *) derwin (WINDOW *,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) doupdate (void); /* implemented */ extern NCURSES_EXPORT(WINDOW *) dupwin (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) echo (void); /* implemented */ extern NCURSES_EXPORT(int) echochar (const chtype); /* generated */ extern NCURSES_EXPORT(int) erase (void); /* generated */ extern NCURSES_EXPORT(int) endwin (void); /* implemented */ extern NCURSES_EXPORT(char) erasechar (void); /* implemented */ extern NCURSES_EXPORT(void) filter (void); /* implemented */ extern NCURSES_EXPORT(int) flash (void); /* implemented */ extern NCURSES_EXPORT(int) flushinp (void); /* implemented */ extern NCURSES_EXPORT(chtype) getbkgd (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getch (void); /* generated */ extern NCURSES_EXPORT(int) getnstr (char *, int); /* generated */ extern NCURSES_EXPORT(int) getstr (char *); /* generated */ extern NCURSES_EXPORT(WINDOW *) getwin (FILE *); /* implemented */ extern NCURSES_EXPORT(int) halfdelay (int); /* implemented */ extern NCURSES_EXPORT(bool) has_colors (void); /* implemented */ extern NCURSES_EXPORT(bool) has_ic (void); /* implemented */ extern NCURSES_EXPORT(bool) has_il (void); /* implemented */ extern NCURSES_EXPORT(int) hline (chtype, int); /* generated */ extern NCURSES_EXPORT(void) idcok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(int) idlok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(void) immedok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(chtype) inch (void); /* generated */ extern NCURSES_EXPORT(int) inchnstr (chtype *, int); /* generated */ extern NCURSES_EXPORT(int) inchstr (chtype *); /* generated */ extern NCURSES_EXPORT(WINDOW *) initscr (void); /* implemented */ extern NCURSES_EXPORT(int) init_color (NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ extern NCURSES_EXPORT(int) init_pair (NCURSES_PAIRS_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ extern NCURSES_EXPORT(int) innstr (char *, int); /* generated */ extern NCURSES_EXPORT(int) insch (chtype); /* generated */ extern NCURSES_EXPORT(int) insdelln (int); /* generated */ extern NCURSES_EXPORT(int) insertln (void); /* generated */ extern NCURSES_EXPORT(int) insnstr (const char *, int); /* generated */ extern NCURSES_EXPORT(int) insstr (const char *); /* generated */ extern NCURSES_EXPORT(int) instr (char *); /* generated */ extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(bool) isendwin (void); /* implemented */ extern NCURSES_EXPORT(bool) is_linetouched (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(bool) is_wintouched (WINDOW *); /* implemented */ extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int); /* implemented */ extern NCURSES_EXPORT(int) keypad (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(char) killchar (void); /* implemented */ extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(char *) longname (void); /* implemented */ extern NCURSES_EXPORT(int) meta (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) move (int, int); /* generated */ extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype); /* generated */ extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvaddchstr (int, int, const chtype *); /* generated */ extern NCURSES_EXPORT(int) mvaddnstr (int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvaddstr (int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ extern NCURSES_EXPORT(int) mvcur (int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) mvdelch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvderwin (WINDOW *, int, int); /* implemented */ extern NCURSES_EXPORT(int) mvgetch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvgetnstr (int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvgetstr (int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(chtype) mvinch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvinchnstr (int, int, chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvinchstr (int, int, chtype *); /* generated */ extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvinsch (int, int, chtype); /* generated */ extern NCURSES_EXPORT(int) mvinsnstr (int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvinsstr (int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvinstr (int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...) /* implemented */ GCC_PRINTFLIKE(3,4); extern NCURSES_EXPORT(int) mvscanw (int,int, const char *,...) /* implemented */ GCC_SCANFLIKE(3,4); extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype); /* generated */ extern NCURSES_EXPORT(int) mvwaddchnstr (WINDOW *, int, int, const chtype *, int);/* generated */ extern NCURSES_EXPORT(int) mvwaddchstr (WINDOW *, int, int, const chtype *); /* generated */ extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwaddstr (WINDOW *, int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, NCURSES_PAIRS_T, const void *);/* generated */ extern NCURSES_EXPORT(int) mvwdelch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetnstr (WINDOW *, int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) mvwin (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(chtype) mvwinch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwinchnstr (WINDOW *, int, int, chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinchstr (WINDOW *, int, int, chtype *); /* generated */ extern NCURSES_EXPORT(int) mvwinnstr (WINDOW *, int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinsch (WINDOW *, int, int, chtype); /* generated */ extern NCURSES_EXPORT(int) mvwinsnstr (WINDOW *, int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinsstr (WINDOW *, int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...) /* implemented */ GCC_PRINTFLIKE(4,5); extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, const char *,...) /* implemented */ GCC_SCANFLIKE(4,5); extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) napms (int); /* implemented */ extern NCURSES_EXPORT(WINDOW *) newpad (int,int); /* implemented */ extern NCURSES_EXPORT(SCREEN *) newterm (const char *,FILE *,FILE *); /* implemented */ extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) nl (void); /* implemented */ extern NCURSES_EXPORT(int) nocbreak (void); /* implemented */ extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) noecho (void); /* implemented */ extern NCURSES_EXPORT(int) nonl (void); /* implemented */ extern NCURSES_EXPORT(void) noqiflush (void); /* implemented */ extern NCURSES_EXPORT(int) noraw (void); /* implemented */ extern NCURSES_EXPORT(int) notimeout (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) overlay (const WINDOW*,WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) pair_content (NCURSES_PAIRS_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ extern NCURSES_EXPORT(int) PAIR_NUMBER (int); /* generated */ extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) pnoutrefresh (WINDOW*,int,int,int,int,int,int);/* implemented */ extern NCURSES_EXPORT(int) prefresh (WINDOW *,int,int,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) printw (const char *,...) /* implemented */ GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *); /* implemented */ extern NCURSES_EXPORT(void) qiflush (void); /* implemented */ extern NCURSES_EXPORT(int) raw (void); /* implemented */ extern NCURSES_EXPORT(int) redrawwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) refresh (void); /* generated */ extern NCURSES_EXPORT(int) resetty (void); /* implemented */ extern NCURSES_EXPORT(int) reset_prog_mode (void); /* implemented */ extern NCURSES_EXPORT(int) reset_shell_mode (void); /* implemented */ extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int)); /* implemented */ extern NCURSES_EXPORT(int) savetty (void); /* implemented */ extern NCURSES_EXPORT(int) scanw (const char *,...) /* implemented */ GCC_SCANFLIKE(1,2); extern NCURSES_EXPORT(int) scr_dump (const char *); /* implemented */ extern NCURSES_EXPORT(int) scr_init (const char *); /* implemented */ extern NCURSES_EXPORT(int) scrl (int); /* generated */ extern NCURSES_EXPORT(int) scroll (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) scrollok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) scr_restore (const char *); /* implemented */ extern NCURSES_EXPORT(int) scr_set (const char *); /* implemented */ extern NCURSES_EXPORT(int) setscrreg (int,int); /* generated */ extern NCURSES_EXPORT(SCREEN *) set_term (SCREEN *); /* implemented */ extern NCURSES_EXPORT(int) slk_attroff (const chtype); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_off (const attr_t, void *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) slk_attron (const chtype); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_on (attr_t,void*); /* generated:WIDEC */ extern NCURSES_EXPORT(int) slk_attrset (const chtype); /* implemented */ extern NCURSES_EXPORT(attr_t) slk_attr (void); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_set (const attr_t,NCURSES_PAIRS_T,void*); /* implemented */ extern NCURSES_EXPORT(int) slk_clear (void); /* implemented */ extern NCURSES_EXPORT(int) slk_color (NCURSES_PAIRS_T); /* implemented */ extern NCURSES_EXPORT(int) slk_init (int); /* implemented */ extern NCURSES_EXPORT(char *) slk_label (int); /* implemented */ extern NCURSES_EXPORT(int) slk_noutrefresh (void); /* implemented */ extern NCURSES_EXPORT(int) slk_refresh (void); /* implemented */ extern NCURSES_EXPORT(int) slk_restore (void); /* implemented */ extern NCURSES_EXPORT(int) slk_set (int,const char *,int); /* implemented */ extern NCURSES_EXPORT(int) slk_touch (void); /* implemented */ extern NCURSES_EXPORT(int) standout (void); /* generated */ extern NCURSES_EXPORT(int) standend (void); /* generated */ extern NCURSES_EXPORT(int) start_color (void); /* implemented */ extern NCURSES_EXPORT(WINDOW *) subpad (WINDOW *, int, int, int, int); /* implemented */ extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *, int, int, int, int); /* implemented */ extern NCURSES_EXPORT(int) syncok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(chtype) termattrs (void); /* implemented */ extern NCURSES_EXPORT(char *) termname (void); /* implemented */ extern NCURSES_EXPORT(void) timeout (int); /* generated */ extern NCURSES_EXPORT(int) touchline (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) touchwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) typeahead (int); /* implemented */ extern NCURSES_EXPORT(int) ungetch (int); /* implemented */ extern NCURSES_EXPORT(int) untouchwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(void) use_env (bool); /* implemented */ extern NCURSES_EXPORT(void) use_tioctl (bool); /* implemented */ extern NCURSES_EXPORT(int) vidattr (chtype); /* implemented */ extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC); /* implemented */ extern NCURSES_EXPORT(int) vline (chtype, int); /* generated */ extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_printw); /* implemented */ extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list); /* implemented */ extern NCURSES_EXPORT(int) vwscanw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_scanw); /* implemented */ extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, const char *,va_list); /* implemented */ extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int); /* implemented */ extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *); /* generated */ extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int); /* implemented */ extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *); /* generated */ extern NCURSES_EXPORT(int) wattron (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattroff (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattrset (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattr_get (WINDOW *, attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ extern NCURSES_EXPORT(int) wattr_on (WINDOW *, attr_t, void *); /* implemented */ extern NCURSES_EXPORT(int) wattr_off (WINDOW *, attr_t, void *); /* implemented */ extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, NCURSES_PAIRS_T, void *); /* generated */ extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype); /* implemented */ extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype); /* implemented */ extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* implemented */ extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, NCURSES_PAIRS_T, const void *);/* implemented */ extern NCURSES_EXPORT(int) wclear (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wclrtobot (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wclrtoeol (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wcolor_set (WINDOW*,NCURSES_PAIRS_T,void*); /* implemented */ extern NCURSES_EXPORT(void) wcursyncup (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wdelch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wdeleteln (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wechochar (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) werase (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wgetch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int); /* implemented */ extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *); /* generated */ extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int); /* implemented */ extern NCURSES_EXPORT(chtype) winch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) winchnstr (WINDOW *, chtype *, int); /* implemented */ extern NCURSES_EXPORT(int) winchstr (WINDOW *, chtype *); /* generated */ extern NCURSES_EXPORT(int) winnstr (WINDOW *, char *, int); /* implemented */ extern NCURSES_EXPORT(int) winsch (WINDOW *, chtype); /* implemented */ extern NCURSES_EXPORT(int) winsdelln (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) winsertln (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) winsnstr (WINDOW *, const char *,int); /* implemented */ extern NCURSES_EXPORT(int) winsstr (WINDOW *, const char *); /* generated */ extern NCURSES_EXPORT(int) winstr (WINDOW *, char *); /* generated */ extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wprintw (WINDOW *, const char *,...) /* implemented */ GCC_PRINTFLIKE(2,3); extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wrefresh (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wscanw (WINDOW *, const char *,...) /* implemented */ GCC_SCANFLIKE(2,3); extern NCURSES_EXPORT(int) wscrl (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wstandout (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wstandend (WINDOW *); /* generated */ extern NCURSES_EXPORT(void) wsyncdown (WINDOW *); /* implemented */ extern NCURSES_EXPORT(void) wsyncup (WINDOW *); /* implemented */ extern NCURSES_EXPORT(void) wtimeout (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) wtouchln (WINDOW *,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int); /* implemented */ /* * These are also declared in <term.h>: */ extern NCURSES_EXPORT(int) tigetflag (const char *); /* implemented */ extern NCURSES_EXPORT(int) tigetnum (const char *); /* implemented */ extern NCURSES_EXPORT(char *) tigetstr (const char *); /* implemented */ extern NCURSES_EXPORT(int) putp (const char *); /* implemented */ #if NCURSES_TPARM_VARARGS extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */ #else extern NCURSES_EXPORT(char *) tparm (const char *, NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG); /* special */ #endif extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */ /* * These functions are not in X/Open, but we use them in macro definitions: */ extern NCURSES_EXPORT(int) getattrs (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getcurx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getcury (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getbegx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getbegy (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getmaxx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getmaxy (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getparx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getpary (const WINDOW *); /* generated */ /* * vid_attr() was implemented originally based on a draft of X/Open curses. */ #if !NCURSES_WIDECHAR #define vid_attr(a,pair,opts) vidattr(a) #endif /* * These functions are extensions - not in X/Open Curses. */ #if 1 #undef NCURSES_EXT_FUNCS #define NCURSES_EXT_FUNCS 20210508 typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *); typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *); extern NCURSES_EXPORT(bool) is_term_resized (int, int); extern NCURSES_EXPORT(char *) keybound (int, int); extern NCURSES_EXPORT(const char *) curses_version (void); extern NCURSES_EXPORT(int) alloc_pair (int, int); extern NCURSES_EXPORT(int) assume_default_colors (int, int); extern NCURSES_EXPORT(int) define_key (const char *, int); extern NCURSES_EXPORT(int) extended_color_content(int, int *, int *, int *); extern NCURSES_EXPORT(int) extended_pair_content(int, int *, int *); extern NCURSES_EXPORT(int) extended_slk_color(int); extern NCURSES_EXPORT(int) find_pair (int, int); extern NCURSES_EXPORT(int) free_pair (int); extern NCURSES_EXPORT(int) get_escdelay (void); extern NCURSES_EXPORT(int) init_extended_color(int, int, int, int); extern NCURSES_EXPORT(int) init_extended_pair(int, int, int); extern NCURSES_EXPORT(int) key_defined (const char *); extern NCURSES_EXPORT(int) keyok (int, bool); extern NCURSES_EXPORT(void) reset_color_pairs (void); extern NCURSES_EXPORT(int) resize_term (int, int); extern NCURSES_EXPORT(int) resizeterm (int, int); extern NCURSES_EXPORT(int) set_escdelay (int); extern NCURSES_EXPORT(int) set_tabsize (int); extern NCURSES_EXPORT(int) use_default_colors (void); extern NCURSES_EXPORT(int) use_extended_names (bool); extern NCURSES_EXPORT(int) use_legacy_coding (int); extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *); extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *); extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int); extern NCURSES_EXPORT(void) nofilter(void); /* * These extensions provide access to information stored in the WINDOW even * when NCURSES_OPAQUE is set: */ extern NCURSES_EXPORT(WINDOW *) wgetparent (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_cleared (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_idcok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_idlok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_immedok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_keypad (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_leaveok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_nodelay (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_notimeout (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_pad (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_scrollok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_subwin (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_syncok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wgetdelay (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wgetscrreg (const WINDOW *, int *, int *); /* generated */ #else #define curses_version() NCURSES_VERSION #endif /* * Extra extension-functions, which pass a SCREEN pointer rather than using * a global variable SP. */ #if 1 #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 20210508 #define NCURSES_SP_NAME(name) name##_sp /* Define the sp-funcs helper function */ #define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC) typedef int (*NCURSES_SP_OUTC)(SCREEN*, int); extern NCURSES_EXPORT(SCREEN *) new_prescr (void); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(baudrate) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(beep) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(can_change_color) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(cbreak) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(color_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(delay_output) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(doupdate) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(echo) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(endwin) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char) NCURSES_SP_NAME(erasechar) (SCREEN*);/* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(filter) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flash) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flushinp) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(getwin) (SCREEN*, FILE *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(halfdelay) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_colors) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_ic) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_il) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_color) (SCREEN*, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_pair) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(intrflush) (SCREEN*, WINDOW*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(isendwin) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(keyname) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char) NCURSES_SP_NAME(killchar) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mvcur) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newpad) (SCREEN*, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, const char *, FILE *, FILE *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newwin) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nl) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noecho) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nonl) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(noqiflush) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noraw) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(pair_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(qiflush) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(raw) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resetty) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ripoffline) (SCREEN*, int, int (*)(WINDOW *, int)); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(savetty) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_init) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_restore) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_set) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attroff) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attron) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attrset) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(slk_attr) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attr_set) (SCREEN*, const attr_t, NCURSES_PAIRS_T, void*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_clear) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_color) (SCREEN*, NCURSES_PAIRS_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_init) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(slk_label) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_noutrefresh) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_refresh) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_restore) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_set) (SCREEN*, int, const char *, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_touch) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(start_color) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(termattrs) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(termname) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetch) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_env) (SCREEN*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_tioctl) (SCREEN*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ #if 1 extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(alloc_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_color_content) (SCREEN*, int, int *, int *, int *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_pair_content) (SCREEN*, int, int *, int *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_slk_color) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(find_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(free_pair) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_color) (SCREEN*, int, int, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_pair) (SCREEN*, int, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(is_term_resized) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined) (SCREEN*, const char *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */ /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(reset_color_pairs) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resize_term) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resizeterm) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_escdelay) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_tabsize) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_default_colors) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ #endif #else #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 0 #define NCURSES_SP_NAME(name) name #define NCURSES_SP_OUTC NCURSES_OUTC #endif /* attributes */ #define NCURSES_ATTR_SHIFT 8 #define NCURSES_BITS(mask,shift) (NCURSES_CAST(chtype,(mask)) << ((shift) + NCURSES_ATTR_SHIFT)) #define A_NORMAL (1U - 1U) #define A_ATTRIBUTES NCURSES_BITS(~(1U - 1U),0) #define A_CHARTEXT (NCURSES_BITS(1U,0) - 1U) #define A_COLOR NCURSES_BITS(((1U) << 8) - 1U,0) #define A_STANDOUT NCURSES_BITS(1U,8) #define A_UNDERLINE NCURSES_BITS(1U,9) #define A_REVERSE NCURSES_BITS(1U,10) #define A_BLINK NCURSES_BITS(1U,11) #define A_DIM NCURSES_BITS(1U,12) #define A_BOLD NCURSES_BITS(1U,13) #define A_ALTCHARSET NCURSES_BITS(1U,14) #define A_INVIS NCURSES_BITS(1U,15) #define A_PROTECT NCURSES_BITS(1U,16) #define A_HORIZONTAL NCURSES_BITS(1U,17) #define A_LEFT NCURSES_BITS(1U,18) #define A_LOW NCURSES_BITS(1U,19) #define A_RIGHT NCURSES_BITS(1U,20) #define A_TOP NCURSES_BITS(1U,21) #define A_VERTICAL NCURSES_BITS(1U,22) #if 1 #define A_ITALIC NCURSES_BITS(1U,23) /* ncurses extension */ #endif /* * Most of the pseudo functions are macros that either provide compatibility * with older versions of curses, or provide inline functionality to improve * performance. */ /* * These pseudo functions are always implemented as macros: */ #define getyx(win,y,x) (y = getcury(win), x = getcurx(win)) #define getbegyx(win,y,x) (y = getbegy(win), x = getbegx(win)) #define getmaxyx(win,y,x) (y = getmaxy(win), x = getmaxx(win)) #define getparyx(win,y,x) (y = getpary(win), x = getparx(win)) #define getsyx(y,x) do { if (newscr) { \ if (is_leaveok(newscr)) \ (y) = (x) = -1; \ else \ getyx(newscr,(y), (x)); \ } \ } while(0) #define setsyx(y,x) do { if (newscr) { \ if ((y) == -1 && (x) == -1) \ leaveok(newscr, TRUE); \ else { \ leaveok(newscr, FALSE); \ wmove(newscr, (y), (x)); \ } \ } \ } while(0) #ifndef NCURSES_NOMACROS /* * These miscellaneous pseudo functions are provided for compatibility: */ #define wgetstr(w, s) wgetnstr(w, s, -1) #define getnstr(s, n) wgetnstr(stdscr, s, (n)) #define setterm(term) setupterm(term, 1, (int *)0) #define fixterm() reset_prog_mode() #define resetterm() reset_shell_mode() #define saveterm() def_prog_mode() #define crmode() cbreak() #define nocrmode() nocbreak() #define gettmode() /* It seems older SYSV curses versions define these */ #if !NCURSES_OPAQUE #define getattrs(win) NCURSES_CAST(int, NCURSES_OK_ADDR(win) ? (win)->_attrs : A_NORMAL) #define getcurx(win) (NCURSES_OK_ADDR(win) ? (win)->_curx : ERR) #define getcury(win) (NCURSES_OK_ADDR(win) ? (win)->_cury : ERR) #define getbegx(win) (NCURSES_OK_ADDR(win) ? (win)->_begx : ERR) #define getbegy(win) (NCURSES_OK_ADDR(win) ? (win)->_begy : ERR) #define getmaxx(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxx + 1) : ERR) #define getmaxy(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxy + 1) : ERR) #define getparx(win) (NCURSES_OK_ADDR(win) ? (win)->_parx : ERR) #define getpary(win) (NCURSES_OK_ADDR(win) ? (win)->_pary : ERR) #endif /* NCURSES_OPAQUE */ #define wstandout(win) (wattrset(win,A_STANDOUT)) #define wstandend(win) (wattrset(win,A_NORMAL)) #define wattron(win,at) wattr_on(win, NCURSES_CAST(attr_t, at), NULL) #define wattroff(win,at) wattr_off(win, NCURSES_CAST(attr_t, at), NULL) #if !NCURSES_OPAQUE #if NCURSES_WATTR_MACROS #if NCURSES_WIDECHAR && 1 #define wattrset(win,at) \ (NCURSES_OK_ADDR(win) \ ? ((win)->_color = NCURSES_CAST(int, PAIR_NUMBER(at)), \ (win)->_attrs = NCURSES_CAST(attr_t, at), \ OK) \ : ERR) #else #define wattrset(win,at) \ (NCURSES_OK_ADDR(win) \ ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \ OK) \ : ERR) #endif #endif /* NCURSES_WATTR_MACROS */ #endif /* NCURSES_OPAQUE */ #define scroll(win) wscrl(win,1) #define touchwin(win) wtouchln((win), 0, getmaxy(win), 1) #define touchline(win, s, c) wtouchln((win), s, c, 1) #define untouchwin(win) wtouchln((win), 0, getmaxy(win), 0) #define box(win, v, h) wborder(win, v, v, h, h, 0, 0, 0, 0) #define border(ls, rs, ts, bs, tl, tr, bl, br) wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br) #define hline(ch, n) whline(stdscr, ch, (n)) #define vline(ch, n) wvline(stdscr, ch, (n)) #define winstr(w, s) winnstr(w, s, -1) #define winchstr(w, s) winchnstr(w, s, -1) #define winsstr(w, s) winsnstr(w, s, -1) #if !NCURSES_OPAQUE #define redrawwin(win) wredrawln(win, 0, (NCURSES_OK_ADDR(win) ? (win)->_maxy+1 : -1)) #endif /* NCURSES_OPAQUE */ #define waddstr(win,str) waddnstr(win,str,-1) #define waddchstr(win,str) waddchnstr(win,str,-1) /* * These apply to the first 256 color pairs. */ #define COLOR_PAIR(n) (NCURSES_BITS((n), 0) & A_COLOR) #define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & A_COLOR) >> NCURSES_ATTR_SHIFT))) /* * pseudo functions for standard screen */ #define addch(ch) waddch(stdscr,(ch)) #define addchnstr(str,n) waddchnstr(stdscr,(str),(n)) #define addchstr(str) waddchstr(stdscr,(str)) #define addnstr(str,n) waddnstr(stdscr,(str),(n)) #define addstr(str) waddnstr(stdscr,(str),-1) #define attr_get(ap,cp,o) wattr_get(stdscr,(ap),(cp),(o)) #define attr_off(a,o) wattr_off(stdscr,(a),(o)) #define attr_on(a,o) wattr_on(stdscr,(a),(o)) #define attr_set(a,c,o) wattr_set(stdscr,(a),(c),(o)) #define attroff(at) wattroff(stdscr,(at)) #define attron(at) wattron(stdscr,(at)) #define attrset(at) wattrset(stdscr,(at)) #define bkgd(ch) wbkgd(stdscr,(ch)) #define bkgdset(ch) wbkgdset(stdscr,(ch)) #define chgat(n,a,c,o) wchgat(stdscr,(n),(a),(c),(o)) #define clear() wclear(stdscr) #define clrtobot() wclrtobot(stdscr) #define clrtoeol() wclrtoeol(stdscr) #define color_set(c,o) wcolor_set(stdscr,(c),(o)) #define delch() wdelch(stdscr) #define deleteln() winsdelln(stdscr,-1) #define echochar(c) wechochar(stdscr,(c)) #define erase() werase(stdscr) #define getch() wgetch(stdscr) #define getstr(str) wgetstr(stdscr,(str)) #define inch() winch(stdscr) #define inchnstr(s,n) winchnstr(stdscr,(s),(n)) #define inchstr(s) winchstr(stdscr,(s)) #define innstr(s,n) winnstr(stdscr,(s),(n)) #define insch(c) winsch(stdscr,(c)) #define insdelln(n) winsdelln(stdscr,(n)) #define insertln() winsdelln(stdscr,1) #define insnstr(s,n) winsnstr(stdscr,(s),(n)) #define insstr(s) winsstr(stdscr,(s)) #define instr(s) winstr(stdscr,(s)) #define move(y,x) wmove(stdscr,(y),(x)) #define refresh() wrefresh(stdscr) #define scrl(n) wscrl(stdscr,(n)) #define setscrreg(t,b) wsetscrreg(stdscr,(t),(b)) #define standend() wstandend(stdscr) #define standout() wstandout(stdscr) #define timeout(delay) wtimeout(stdscr,(delay)) #define wdeleteln(win) winsdelln(win,-1) #define winsertln(win) winsdelln(win,1) /* * mv functions */ #define mvwaddch(win,y,x,ch) (wmove((win),(y),(x)) == ERR ? ERR : waddch((win),(ch))) #define mvwaddchnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),(n))) #define mvwaddchstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),-1)) #define mvwaddnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),(n))) #define mvwaddstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),-1)) #define mvwchgat(win,y,x,n,a,c,o) (wmove((win),(y),(x)) == ERR ? ERR : wchgat((win),(n),(a),(c),(o))) #define mvwdelch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wdelch(win)) #define mvwgetch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wgetch(win)) #define mvwgetnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : wgetnstr((win),(str),(n))) #define mvwgetstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : wgetstr((win),(str))) #define mvwhline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : whline((win),(c),(n))) #define mvwinch(win,y,x) (wmove((win),(y),(x)) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win)) #define mvwinchnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winchnstr((win),(s),(n))) #define mvwinchstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winchstr((win),(s))) #define mvwinnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winnstr((win),(s),(n))) #define mvwinsch(win,y,x,c) (wmove((win),(y),(x)) == ERR ? ERR : winsch((win),(c))) #define mvwinsnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winsnstr((win),(s),(n))) #define mvwinsstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winsstr((win),(s))) #define mvwinstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winstr((win),(s))) #define mvwvline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : wvline((win),(c),(n))) #define mvaddch(y,x,ch) mvwaddch(stdscr,(y),(x),(ch)) #define mvaddchnstr(y,x,str,n) mvwaddchnstr(stdscr,(y),(x),(str),(n)) #define mvaddchstr(y,x,str) mvwaddchstr(stdscr,(y),(x),(str)) #define mvaddnstr(y,x,str,n) mvwaddnstr(stdscr,(y),(x),(str),(n)) #define mvaddstr(y,x,str) mvwaddstr(stdscr,(y),(x),(str)) #define mvchgat(y,x,n,a,c,o) mvwchgat(stdscr,(y),(x),(n),(a),(c),(o)) #define mvdelch(y,x) mvwdelch(stdscr,(y),(x)) #define mvgetch(y,x) mvwgetch(stdscr,(y),(x)) #define mvgetnstr(y,x,str,n) mvwgetnstr(stdscr,(y),(x),(str),(n)) #define mvgetstr(y,x,str) mvwgetstr(stdscr,(y),(x),(str)) #define mvhline(y,x,c,n) mvwhline(stdscr,(y),(x),(c),(n)) #define mvinch(y,x) mvwinch(stdscr,(y),(x)) #define mvinchnstr(y,x,s,n) mvwinchnstr(stdscr,(y),(x),(s),(n)) #define mvinchstr(y,x,s) mvwinchstr(stdscr,(y),(x),(s)) #define mvinnstr(y,x,s,n) mvwinnstr(stdscr,(y),(x),(s),(n)) #define mvinsch(y,x,c) mvwinsch(stdscr,(y),(x),(c)) #define mvinsnstr(y,x,s,n) mvwinsnstr(stdscr,(y),(x),(s),(n)) #define mvinsstr(y,x,s) mvwinsstr(stdscr,(y),(x),(s)) #define mvinstr(y,x,s) mvwinstr(stdscr,(y),(x),(s)) #define mvvline(y,x,c,n) mvwvline(stdscr,(y),(x),(c),(n)) /* * Some wide-character functions can be implemented without the extensions. */ #if !NCURSES_OPAQUE #define getbkgd(win) (NCURSES_OK_ADDR(win) ? ((win)->_bkgd) : 0) #endif /* NCURSES_OPAQUE */ #define slk_attr_off(a,v) ((v) ? ERR : slk_attroff(a)) #define slk_attr_on(a,v) ((v) ? ERR : slk_attron(a)) #if !NCURSES_OPAQUE #if NCURSES_WATTR_MACROS #if NCURSES_WIDECHAR && 1 #define wattr_set(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)((win)->_attrs = ((a) & ~A_COLOR), \ (win)->_color = (opts) ? *(int *)(opts) : (p)), \ OK) \ : ERR) #define wattr_get(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)(NCURSES_OK_ADDR(a) \ ? (*(a) = (win)->_attrs) \ : OK), \ (void)(NCURSES_OK_ADDR(p) \ ? (*(p) = (NCURSES_PAIRS_T) (win)->_color) \ : OK), \ (void)(NCURSES_OK_ADDR(opts) \ ? (*(int *)(opts) = (win)->_color) \ : OK), \ OK) \ : ERR) #else /* !(NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */ #define wattr_set(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)((win)->_attrs = (((a) & ~A_COLOR) | \ (attr_t)COLOR_PAIR(p))), \ OK) \ : ERR) #define wattr_get(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)(NCURSES_OK_ADDR(a) \ ? (*(a) = (win)->_attrs) \ : OK), \ (void)(NCURSES_OK_ADDR(p) \ ? (*(p) = (NCURSES_PAIRS_T) PAIR_NUMBER((win)->_attrs)) \ : OK), \ OK) \ : ERR) #endif /* (NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */ #endif /* NCURSES_WATTR_MACROS */ #endif /* NCURSES_OPAQUE */ /* * X/Open curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use * varargs.h. It adds new calls vw_printw/vw_scanw, which are supposed to * use POSIX stdarg.h. The ncurses versions of vwprintw/vwscanw already * use stdarg.h, so... */ /* define vw_printw vwprintw */ /* define vw_scanw vwscanw */ /* * Export fallback function for use in C++ binding. */ #if !1 #define vsscanf(a,b,c) _nc_vsscanf(a,b,c) NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list); #endif /* * These macros are extensions - not in X/Open Curses. */ #if 1 #if !NCURSES_OPAQUE #define is_cleared(win) (NCURSES_OK_ADDR(win) ? (win)->_clear : FALSE) #define is_idcok(win) (NCURSES_OK_ADDR(win) ? (win)->_idcok : FALSE) #define is_idlok(win) (NCURSES_OK_ADDR(win) ? (win)->_idlok : FALSE) #define is_immedok(win) (NCURSES_OK_ADDR(win) ? (win)->_immed : FALSE) #define is_keypad(win) (NCURSES_OK_ADDR(win) ? (win)->_use_keypad : FALSE) #define is_leaveok(win) (NCURSES_OK_ADDR(win) ? (win)->_leaveok : FALSE) #define is_nodelay(win) (NCURSES_OK_ADDR(win) ? ((win)->_delay == 0) : FALSE) #define is_notimeout(win) (NCURSES_OK_ADDR(win) ? (win)->_notimeout : FALSE) #define is_pad(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _ISPAD) != 0 : FALSE) #define is_scrollok(win) (NCURSES_OK_ADDR(win) ? (win)->_scroll : FALSE) #define is_subwin(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE) #define is_syncok(win) (NCURSES_OK_ADDR(win) ? (win)->_sync : FALSE) #define wgetdelay(win) (NCURSES_OK_ADDR(win) ? (win)->_delay : 0) #define wgetparent(win) (NCURSES_OK_ADDR(win) ? (win)->_parent : 0) #define wgetscrreg(win,t,b) (NCURSES_OK_ADDR(win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR) #endif #endif /* * X/Open says this returns a bool; SVr4 also checked for out-of-range line. * The macro provides compatibility: */ #define is_linetouched(w,l) ((!(w) || ((l) > getmaxy(w)) || ((l) < 0)) ? ERR : (is_linetouched)((w),(l))) #endif /* NCURSES_NOMACROS */ /* * Public variables. * * Notes: * a. ESCDELAY was an undocumented feature under AIX curses. * It gives the ESC expire time in milliseconds. * b. ttytype is needed for backward compatibility */ #if NCURSES_REENTRANT NCURSES_WRAPPED_VAR(WINDOW *, curscr); NCURSES_WRAPPED_VAR(WINDOW *, newscr); NCURSES_WRAPPED_VAR(WINDOW *, stdscr); NCURSES_WRAPPED_VAR(char *, ttytype); NCURSES_WRAPPED_VAR(int, COLORS); NCURSES_WRAPPED_VAR(int, COLOR_PAIRS); NCURSES_WRAPPED_VAR(int, COLS); NCURSES_WRAPPED_VAR(int, ESCDELAY); NCURSES_WRAPPED_VAR(int, LINES); NCURSES_WRAPPED_VAR(int, TABSIZE); #define curscr NCURSES_PUBLIC_VAR(curscr()) #define newscr NCURSES_PUBLIC_VAR(newscr()) #define stdscr NCURSES_PUBLIC_VAR(stdscr()) #define ttytype NCURSES_PUBLIC_VAR(ttytype()) #define COLORS NCURSES_PUBLIC_VAR(COLORS()) #define COLOR_PAIRS NCURSES_PUBLIC_VAR(COLOR_PAIRS()) #define COLS NCURSES_PUBLIC_VAR(COLS()) #define ESCDELAY NCURSES_PUBLIC_VAR(ESCDELAY()) #define LINES NCURSES_PUBLIC_VAR(LINES()) #define TABSIZE NCURSES_PUBLIC_VAR(TABSIZE()) #else extern NCURSES_EXPORT_VAR(WINDOW *) curscr; extern NCURSES_EXPORT_VAR(WINDOW *) newscr; extern NCURSES_EXPORT_VAR(WINDOW *) stdscr; extern NCURSES_EXPORT_VAR(char) ttytype[]; extern NCURSES_EXPORT_VAR(int) COLORS; extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS; extern NCURSES_EXPORT_VAR(int) COLS; extern NCURSES_EXPORT_VAR(int) ESCDELAY; extern NCURSES_EXPORT_VAR(int) LINES; extern NCURSES_EXPORT_VAR(int) TABSIZE; #endif /* * Pseudo-character tokens outside ASCII range. The curses wgetch() function * will return any given one of these only if the corresponding k- capability * is defined in your terminal's terminfo entry. * * Some keys (KEY_A1, etc) are arranged like this: * a1 up a3 * left b2 right * c1 down c3 * * A few key codes do not depend upon the terminfo entry. */ #define KEY_CODE_YES 0400 /* A wchar_t contains a key code */ #define KEY_MIN 0401 /* Minimum curses key */ #define KEY_BREAK 0401 /* Break key (unreliable) */ #define KEY_SRESET 0530 /* Soft (partial) reset (unreliable) */ #define KEY_RESET 0531 /* Reset or hard reset (unreliable) */ /* * These definitions were generated by ./MKkey_defs.sh ../../include/Caps ../../include/Caps-ncurses */ #define KEY_DOWN 0402 /* down-arrow key */ #define KEY_UP 0403 /* up-arrow key */ #define KEY_LEFT 0404 /* left-arrow key */ #define KEY_RIGHT 0405 /* right-arrow key */ #define KEY_HOME 0406 /* home key */ #define KEY_BACKSPACE 0407 /* backspace key */ #define KEY_F0 0410 /* Function keys. Space for 64 */ #define KEY_F(n) (KEY_F0+(n)) /* Value of function key n */ #define KEY_DL 0510 /* delete-line key */ #define KEY_IL 0511 /* insert-line key */ #define KEY_DC 0512 /* delete-character key */ #define KEY_IC 0513 /* insert-character key */ #define KEY_EIC 0514 /* sent by rmir or smir in insert mode */ #define KEY_CLEAR 0515 /* clear-screen or erase key */ #define KEY_EOS 0516 /* clear-to-end-of-screen key */ #define KEY_EOL 0517 /* clear-to-end-of-line key */ #define KEY_SF 0520 /* scroll-forward key */ #define KEY_SR 0521 /* scroll-backward key */ #define KEY_NPAGE 0522 /* next-page key */ #define KEY_PPAGE 0523 /* previous-page key */ #define KEY_STAB 0524 /* set-tab key */ #define KEY_CTAB 0525 /* clear-tab key */ #define KEY_CATAB 0526 /* clear-all-tabs key */ #define KEY_ENTER 0527 /* enter/send key */ #define KEY_PRINT 0532 /* print key */ #define KEY_LL 0533 /* lower-left key (home down) */ #define KEY_A1 0534 /* upper left of keypad */ #define KEY_A3 0535 /* upper right of keypad */ #define KEY_B2 0536 /* center of keypad */ #define KEY_C1 0537 /* lower left of keypad */ #define KEY_C3 0540 /* lower right of keypad */ #define KEY_BTAB 0541 /* back-tab key */ #define KEY_BEG 0542 /* begin key */ #define KEY_CANCEL 0543 /* cancel key */ #define KEY_CLOSE 0544 /* close key */ #define KEY_COMMAND 0545 /* command key */ #define KEY_COPY 0546 /* copy key */ #define KEY_CREATE 0547 /* create key */ #define KEY_END 0550 /* end key */ #define KEY_EXIT 0551 /* exit key */ #define KEY_FIND 0552 /* find key */ #define KEY_HELP 0553 /* help key */ #define KEY_MARK 0554 /* mark key */ #define KEY_MESSAGE 0555 /* message key */ #define KEY_MOVE 0556 /* move key */ #define KEY_NEXT 0557 /* next key */ #define KEY_OPEN 0560 /* open key */ #define KEY_OPTIONS 0561 /* options key */ #define KEY_PREVIOUS 0562 /* previous key */ #define KEY_REDO 0563 /* redo key */ #define KEY_REFERENCE 0564 /* reference key */ #define KEY_REFRESH 0565 /* refresh key */ #define KEY_REPLACE 0566 /* replace key */ #define KEY_RESTART 0567 /* restart key */ #define KEY_RESUME 0570 /* resume key */ #define KEY_SAVE 0571 /* save key */ #define KEY_SBEG 0572 /* shifted begin key */ #define KEY_SCANCEL 0573 /* shifted cancel key */ #define KEY_SCOMMAND 0574 /* shifted command key */ #define KEY_SCOPY 0575 /* shifted copy key */ #define KEY_SCREATE 0576 /* shifted create key */ #define KEY_SDC 0577 /* shifted delete-character key */ #define KEY_SDL 0600 /* shifted delete-line key */ #define KEY_SELECT 0601 /* select key */ #define KEY_SEND 0602 /* shifted end key */ #define KEY_SEOL 0603 /* shifted clear-to-end-of-line key */ #define KEY_SEXIT 0604 /* shifted exit key */ #define KEY_SFIND 0605 /* shifted find key */ #define KEY_SHELP 0606 /* shifted help key */ #define KEY_SHOME 0607 /* shifted home key */ #define KEY_SIC 0610 /* shifted insert-character key */ #define KEY_SLEFT 0611 /* shifted left-arrow key */ #define KEY_SMESSAGE 0612 /* shifted message key */ #define KEY_SMOVE 0613 /* shifted move key */ #define KEY_SNEXT 0614 /* shifted next key */ #define KEY_SOPTIONS 0615 /* shifted options key */ #define KEY_SPREVIOUS 0616 /* shifted previous key */ #define KEY_SPRINT 0617 /* shifted print key */ #define KEY_SREDO 0620 /* shifted redo key */ #define KEY_SREPLACE 0621 /* shifted replace key */ #define KEY_SRIGHT 0622 /* shifted right-arrow key */ #define KEY_SRSUME 0623 /* shifted resume key */ #define KEY_SSAVE 0624 /* shifted save key */ #define KEY_SSUSPEND 0625 /* shifted suspend key */ #define KEY_SUNDO 0626 /* shifted undo key */ #define KEY_SUSPEND 0627 /* suspend key */ #define KEY_UNDO 0630 /* undo key */ #define KEY_MOUSE 0631 /* Mouse event has occurred */ #ifdef NCURSES_EXT_FUNCS #define KEY_RESIZE 0632 /* Terminal resize event */ #endif #define KEY_MAX 0777 /* Maximum key value is 0632 */ /* $Id: curses.wide,v 1.50 2017/03/26 16:05:21 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in * (see that file for the relevant copyright). */ #define _XOPEN_CURSES 1 #if NCURSES_WIDECHAR extern NCURSES_EXPORT_VAR(cchar_t *) _nc_wacs; #define NCURSES_WACS(c) (&_nc_wacs[NCURSES_CAST(unsigned char,(c))]) #define WACS_BSSB NCURSES_WACS('l') #define WACS_SSBB NCURSES_WACS('m') #define WACS_BBSS NCURSES_WACS('k') #define WACS_SBBS NCURSES_WACS('j') #define WACS_SBSS NCURSES_WACS('u') #define WACS_SSSB NCURSES_WACS('t') #define WACS_SSBS NCURSES_WACS('v') #define WACS_BSSS NCURSES_WACS('w') #define WACS_BSBS NCURSES_WACS('q') #define WACS_SBSB NCURSES_WACS('x') #define WACS_SSSS NCURSES_WACS('n') #define WACS_ULCORNER WACS_BSSB #define WACS_LLCORNER WACS_SSBB #define WACS_URCORNER WACS_BBSS #define WACS_LRCORNER WACS_SBBS #define WACS_RTEE WACS_SBSS #define WACS_LTEE WACS_SSSB #define WACS_BTEE WACS_SSBS #define WACS_TTEE WACS_BSSS #define WACS_HLINE WACS_BSBS #define WACS_VLINE WACS_SBSB #define WACS_PLUS WACS_SSSS #define WACS_S1 NCURSES_WACS('o') /* scan line 1 */ #define WACS_S9 NCURSES_WACS('s') /* scan line 9 */ #define WACS_DIAMOND NCURSES_WACS('`') /* diamond */ #define WACS_CKBOARD NCURSES_WACS('a') /* checker board */ #define WACS_DEGREE NCURSES_WACS('f') /* degree symbol */ #define WACS_PLMINUS NCURSES_WACS('g') /* plus/minus */ #define WACS_BULLET NCURSES_WACS('~') /* bullet */ /* Teletype 5410v1 symbols */ #define WACS_LARROW NCURSES_WACS(',') /* arrow left */ #define WACS_RARROW NCURSES_WACS('+') /* arrow right */ #define WACS_DARROW NCURSES_WACS('.') /* arrow down */ #define WACS_UARROW NCURSES_WACS('-') /* arrow up */ #define WACS_BOARD NCURSES_WACS('h') /* board of squares */ #define WACS_LANTERN NCURSES_WACS('i') /* lantern symbol */ #define WACS_BLOCK NCURSES_WACS('0') /* solid square block */ /* ncurses extensions */ #define WACS_S3 NCURSES_WACS('p') /* scan line 3 */ #define WACS_S7 NCURSES_WACS('r') /* scan line 7 */ #define WACS_LEQUAL NCURSES_WACS('y') /* less/equal */ #define WACS_GEQUAL NCURSES_WACS('z') /* greater/equal */ #define WACS_PI NCURSES_WACS('{') /* Pi */ #define WACS_NEQUAL NCURSES_WACS('|') /* not equal */ #define WACS_STERLING NCURSES_WACS('}') /* UK pound sign */ /* double lines */ #define WACS_BDDB NCURSES_WACS('C') #define WACS_DDBB NCURSES_WACS('D') #define WACS_BBDD NCURSES_WACS('B') #define WACS_DBBD NCURSES_WACS('A') #define WACS_DBDD NCURSES_WACS('G') #define WACS_DDDB NCURSES_WACS('F') #define WACS_DDBD NCURSES_WACS('H') #define WACS_BDDD NCURSES_WACS('I') #define WACS_BDBD NCURSES_WACS('R') #define WACS_DBDB NCURSES_WACS('Y') #define WACS_DDDD NCURSES_WACS('E') #define WACS_D_ULCORNER WACS_BDDB #define WACS_D_LLCORNER WACS_DDBB #define WACS_D_URCORNER WACS_BBDD #define WACS_D_LRCORNER WACS_DBBD #define WACS_D_RTEE WACS_DBDD #define WACS_D_LTEE WACS_DDDB #define WACS_D_BTEE WACS_DDBD #define WACS_D_TTEE WACS_BDDD #define WACS_D_HLINE WACS_BDBD #define WACS_D_VLINE WACS_DBDB #define WACS_D_PLUS WACS_DDDD /* thick lines */ #define WACS_BTTB NCURSES_WACS('L') #define WACS_TTBB NCURSES_WACS('M') #define WACS_BBTT NCURSES_WACS('K') #define WACS_TBBT NCURSES_WACS('J') #define WACS_TBTT NCURSES_WACS('U') #define WACS_TTTB NCURSES_WACS('T') #define WACS_TTBT NCURSES_WACS('V') #define WACS_BTTT NCURSES_WACS('W') #define WACS_BTBT NCURSES_WACS('Q') #define WACS_TBTB NCURSES_WACS('X') #define WACS_TTTT NCURSES_WACS('N') #define WACS_T_ULCORNER WACS_BTTB #define WACS_T_LLCORNER WACS_TTBB #define WACS_T_URCORNER WACS_BBTT #define WACS_T_LRCORNER WACS_TBBT #define WACS_T_RTEE WACS_TBTT #define WACS_T_LTEE WACS_TTTB #define WACS_T_BTEE WACS_TTBT #define WACS_T_TTEE WACS_BTTT #define WACS_T_HLINE WACS_BTBT #define WACS_T_VLINE WACS_TBTB #define WACS_T_PLUS WACS_TTTT /* * Function prototypes for wide-character operations. * * "generated" comments should include ":WIDEC" to make the corresponding * functions ifdef'd in lib_gen.c * * "implemented" comments do not need this marker. */ extern NCURSES_EXPORT(int) add_wch (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) add_wchnstr (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) add_wchstr (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) addnwstr (const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) addwstr (const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) bkgrnd (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(void) bkgrndset (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) border_set (const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* generated:WIDEC */ extern NCURSES_EXPORT(int) box_set (WINDOW *, const cchar_t *, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) echo_wchar (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) erasewchar (wchar_t*); /* implemented */ extern NCURSES_EXPORT(int) get_wch (wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) get_wstr (wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) getbkgrnd (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) getcchar (const cchar_t *, wchar_t*, attr_t*, NCURSES_PAIRS_T*, void*); /* implemented */ extern NCURSES_EXPORT(int) getn_wstr (wint_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) hline_set (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wch (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wchnstr (cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wchstr (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) innwstr (wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_nwstr (const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_wch (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_wstr (const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) inwstr (wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(NCURSES_CONST char*) key_name (wchar_t); /* implemented */ extern NCURSES_EXPORT(int) killwchar (wchar_t *); /* implemented */ extern NCURSES_EXPORT(int) mvadd_wch (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvadd_wchnstr (int, int, const cchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvadd_wchstr (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvaddnwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvaddwstr (int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvget_wch (int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvget_wstr (int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvgetn_wstr (int, int, wint_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvhline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wch (int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wchnstr (int, int, cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wchstr (int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvinnwstr (int, int, wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_nwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_wch (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_wstr (int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvinwstr (int, int, wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvvline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wchnstr (WINDOW *, int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wchstr (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwaddnwstr (WINDOW *, int, int, const wchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwaddwstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwget_wch (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwget_wstr (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwgetn_wstr (WINDOW *, int, int, wint_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwhline_set (WINDOW *, int, int, const cchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wch (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wchnstr (WINDOW *, int,int, cchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wchstr (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwinnwstr (WINDOW *, int, int, wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_nwstr (WINDOW *, int,int, const wchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_wstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwinwstr (WINDOW *, int, int, wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwvline_set (WINDOW *, int,int, const cchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) pecho_wchar (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) setcchar (cchar_t *, const wchar_t *, const attr_t, NCURSES_PAIRS_T, const void *); /* implemented */ extern NCURSES_EXPORT(int) slk_wset (int, const wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(attr_t) term_attrs (void); /* implemented */ extern NCURSES_EXPORT(int) unget_wch (const wchar_t); /* implemented */ extern NCURSES_EXPORT(int) vid_attr (attr_t, NCURSES_PAIRS_T, void *); /* implemented */ extern NCURSES_EXPORT(int) vid_puts (attr_t, NCURSES_PAIRS_T, void *, NCURSES_OUTC); /* implemented */ extern NCURSES_EXPORT(int) vline_set (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wadd_wch (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wadd_wchnstr (WINDOW *,const cchar_t *,int); /* implemented */ extern NCURSES_EXPORT(int) wadd_wchstr (WINDOW *,const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) waddnwstr (WINDOW *,const wchar_t *,int); /* implemented */ extern NCURSES_EXPORT(int) waddwstr (WINDOW *,const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wbkgrnd (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(void) wbkgrndset (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wborder_set (WINDOW *,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* implemented */ extern NCURSES_EXPORT(int) wecho_wchar (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wget_wch (WINDOW *, wint_t *); /* implemented */ extern NCURSES_EXPORT(int) wget_wstr (WINDOW *, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wgetbkgrnd (WINDOW *, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wgetn_wstr (WINDOW *, wint_t *, int); /* implemented */ extern NCURSES_EXPORT(int) whline_set (WINDOW *, const cchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) win_wch (WINDOW *, cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) win_wchnstr (WINDOW *, cchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) win_wchstr (WINDOW *, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) winnwstr (WINDOW *, wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) wins_nwstr (WINDOW *, const wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) wins_wch (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wins_wstr (WINDOW *, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) winwstr (WINDOW *, wchar_t *); /* implemented */ extern NCURSES_EXPORT(wchar_t*) wunctrl (cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wvline_set (WINDOW *, const cchar_t *, int); /* implemented */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(term_attrs) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(unget_wch) (SCREEN*, const wchar_t); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_attr) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ #endif #ifndef NCURSES_NOMACROS /* * XSI curses macros for XPG4 conformance. */ #define add_wch(c) wadd_wch(stdscr,(c)) #define add_wchnstr(str,n) wadd_wchnstr(stdscr,(str),(n)) #define add_wchstr(str) wadd_wchstr(stdscr,(str)) #define addnwstr(wstr,n) waddnwstr(stdscr,(wstr),(n)) #define addwstr(wstr) waddwstr(stdscr,(wstr)) #define bkgrnd(c) wbkgrnd(stdscr,(c)) #define bkgrndset(c) wbkgrndset(stdscr,(c)) #define border_set(l,r,t,b,tl,tr,bl,br) wborder_set(stdscr,(l),(r),(t),(b),tl,tr,bl,br) #define box_set(w,v,h) wborder_set((w),(v),(v),(h),(h),0,0,0,0) #define echo_wchar(c) wecho_wchar(stdscr,(c)) #define get_wch(c) wget_wch(stdscr,(c)) #define get_wstr(t) wget_wstr(stdscr,(t)) #define getbkgrnd(wch) wgetbkgrnd(stdscr,(wch)) #define getn_wstr(t,n) wgetn_wstr(stdscr,(t),(n)) #define hline_set(c,n) whline_set(stdscr,(c),(n)) #define in_wch(c) win_wch(stdscr,(c)) #define in_wchnstr(c,n) win_wchnstr(stdscr,(c),(n)) #define in_wchstr(c) win_wchstr(stdscr,(c)) #define innwstr(c,n) winnwstr(stdscr,(c),(n)) #define ins_nwstr(t,n) wins_nwstr(stdscr,(t),(n)) #define ins_wch(c) wins_wch(stdscr,(c)) #define ins_wstr(t) wins_wstr(stdscr,(t)) #define inwstr(c) winwstr(stdscr,(c)) #define vline_set(c,n) wvline_set(stdscr,(c),(n)) #define wadd_wchstr(win,str) wadd_wchnstr((win),(str),-1) #define waddwstr(win,wstr) waddnwstr((win),(wstr),-1) #define wget_wstr(w,t) wgetn_wstr((w),(t),-1) #define win_wchstr(w,c) win_wchnstr((w),(c),-1) #define wins_wstr(w,t) wins_nwstr((w),(t),-1) #if !NCURSES_OPAQUE #define wgetbkgrnd(win,wch) (NCURSES_OK_ADDR(wch) ? ((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK) : ERR) #endif #define mvadd_wch(y,x,c) mvwadd_wch(stdscr,(y),(x),(c)) #define mvadd_wchnstr(y,x,s,n) mvwadd_wchnstr(stdscr,(y),(x),(s),(n)) #define mvadd_wchstr(y,x,s) mvwadd_wchstr(stdscr,(y),(x),(s)) #define mvaddnwstr(y,x,wstr,n) mvwaddnwstr(stdscr,(y),(x),(wstr),(n)) #define mvaddwstr(y,x,wstr) mvwaddwstr(stdscr,(y),(x),(wstr)) #define mvget_wch(y,x,c) mvwget_wch(stdscr,(y),(x),(c)) #define mvget_wstr(y,x,t) mvwget_wstr(stdscr,(y),(x),(t)) #define mvgetn_wstr(y,x,t,n) mvwgetn_wstr(stdscr,(y),(x),(t),(n)) #define mvhline_set(y,x,c,n) mvwhline_set(stdscr,(y),(x),(c),(n)) #define mvin_wch(y,x,c) mvwin_wch(stdscr,(y),(x),(c)) #define mvin_wchnstr(y,x,c,n) mvwin_wchnstr(stdscr,(y),(x),(c),(n)) #define mvin_wchstr(y,x,c) mvwin_wchstr(stdscr,(y),(x),(c)) #define mvinnwstr(y,x,c,n) mvwinnwstr(stdscr,(y),(x),(c),(n)) #define mvins_nwstr(y,x,t,n) mvwins_nwstr(stdscr,(y),(x),(t),(n)) #define mvins_wch(y,x,c) mvwins_wch(stdscr,(y),(x),(c)) #define mvins_wstr(y,x,t) mvwins_wstr(stdscr,(y),(x),(t)) #define mvinwstr(y,x,c) mvwinwstr(stdscr,(y),(x),(c)) #define mvvline_set(y,x,c,n) mvwvline_set(stdscr,(y),(x),(c),(n)) #define mvwadd_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wch((win),(c))) #define mvwadd_wchnstr(win,y,x,s,n) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchnstr((win),(s),(n))) #define mvwadd_wchstr(win,y,x,s) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchstr((win),(s))) #define mvwaddnwstr(win,y,x,wstr,n) (wmove(win,(y),(x)) == ERR ? ERR : waddnwstr((win),(wstr),(n))) #define mvwaddwstr(win,y,x,wstr) (wmove(win,(y),(x)) == ERR ? ERR : waddwstr((win),(wstr))) #define mvwget_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wget_wch((win),(c))) #define mvwget_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wget_wstr((win),(t))) #define mvwgetn_wstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wgetn_wstr((win),(t),(n))) #define mvwhline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : whline_set((win),(c),(n))) #define mvwin_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wch((win),(c))) #define mvwin_wchnstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : win_wchnstr((win),(c),(n))) #define mvwin_wchstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wchstr((win),(c))) #define mvwinnwstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : winnwstr((win),(c),(n))) #define mvwins_nwstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wins_nwstr((win),(t),(n))) #define mvwins_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wins_wch((win),(c))) #define mvwins_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wins_wstr((win),(t))) #define mvwinwstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : winwstr((win),(c))) #define mvwvline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : wvline_set((win),(c),(n))) #endif /* NCURSES_NOMACROS */ #if defined(TRACE) || defined(NCURSES_TEST) extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *); extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *); #endif #endif /* NCURSES_WIDECHAR */ /* $Id: curses.tail,v 1.26 2021/03/20 15:49:25 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in * (see that file for the relevant copyright). */ /* mouse interface */ #if NCURSES_MOUSE_VERSION > 1 #define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5)) #else #define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6)) #endif #define NCURSES_BUTTON_RELEASED 001L #define NCURSES_BUTTON_PRESSED 002L #define NCURSES_BUTTON_CLICKED 004L #define NCURSES_DOUBLE_CLICKED 010L #define NCURSES_TRIPLE_CLICKED 020L #define NCURSES_RESERVED_EVENT 040L /* event masks */ #define BUTTON1_RELEASED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED) #define BUTTON1_PRESSED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED) #define BUTTON1_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED) #define BUTTON1_DOUBLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED) #define BUTTON1_TRIPLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED) #define BUTTON2_RELEASED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED) #define BUTTON2_PRESSED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED) #define BUTTON2_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED) #define BUTTON2_DOUBLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED) #define BUTTON2_TRIPLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED) #define BUTTON3_RELEASED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED) #define BUTTON3_PRESSED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED) #define BUTTON3_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED) #define BUTTON3_DOUBLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED) #define BUTTON3_TRIPLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED) #define BUTTON4_RELEASED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED) #define BUTTON4_PRESSED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED) #define BUTTON4_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED) #define BUTTON4_DOUBLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED) #define BUTTON4_TRIPLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED) /* * In 32 bits the version-1 scheme does not provide enough space for a 5th * button, unless we choose to change the ABI by omitting the reserved-events. */ #if NCURSES_MOUSE_VERSION > 1 #define BUTTON5_RELEASED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED) #define BUTTON5_PRESSED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED) #define BUTTON5_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED) #define BUTTON5_DOUBLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED) #define BUTTON5_TRIPLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED) #define BUTTON_CTRL NCURSES_MOUSE_MASK(6, 0001L) #define BUTTON_SHIFT NCURSES_MOUSE_MASK(6, 0002L) #define BUTTON_ALT NCURSES_MOUSE_MASK(6, 0004L) #define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(6, 0010L) #else #define BUTTON1_RESERVED_EVENT NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT) #define BUTTON2_RESERVED_EVENT NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT) #define BUTTON3_RESERVED_EVENT NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT) #define BUTTON4_RESERVED_EVENT NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT) #define BUTTON_CTRL NCURSES_MOUSE_MASK(5, 0001L) #define BUTTON_SHIFT NCURSES_MOUSE_MASK(5, 0002L) #define BUTTON_ALT NCURSES_MOUSE_MASK(5, 0004L) #define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(5, 0010L) #endif #define ALL_MOUSE_EVENTS (REPORT_MOUSE_POSITION - 1) /* macros to extract single event-bits from masks */ #define BUTTON_RELEASE(e, x) ((e) & NCURSES_MOUSE_MASK(x, 001)) #define BUTTON_PRESS(e, x) ((e) & NCURSES_MOUSE_MASK(x, 002)) #define BUTTON_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 004)) #define BUTTON_DOUBLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 010)) #define BUTTON_TRIPLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 020)) #define BUTTON_RESERVED_EVENT(e, x) ((e) & NCURSES_MOUSE_MASK(x, 040)) typedef struct { short id; /* ID to distinguish multiple devices */ int x, y, z; /* event coordinates (character-cell) */ mmask_t bstate; /* button state bits */ } MEVENT; extern NCURSES_EXPORT(bool) has_mouse(void); extern NCURSES_EXPORT(int) getmouse (MEVENT *); extern NCURSES_EXPORT(int) ungetmouse (MEVENT *); extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *); extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int); extern NCURSES_EXPORT(int) mouseinterval (int); extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool); extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* generated */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_mouse) (SCREEN*); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *); extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, mmask_t *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mouseinterval) (SCREEN*, int); #endif #ifndef NCURSES_NOMACROS #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen) #endif /* other non-XSI functions */ extern NCURSES_EXPORT(int) mcprint (char *, int); /* direct data to printer */ extern NCURSES_EXPORT(int) has_key (int); /* do we have given key? */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (SCREEN*, int); /* do we have given key? */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mcprint) (SCREEN*, char *, int); /* direct data to printer */ #endif /* Debugging : use with libncurses_g.a */ extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(char *) _traceattr (attr_t); extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype); extern NCURSES_EXPORT(char *) _tracechar (int); extern NCURSES_EXPORT(char *) _tracechtype (chtype); extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype); #if NCURSES_WIDECHAR #define _tracech_t _tracecchar_t extern NCURSES_EXPORT(char *) _tracecchar_t (const cchar_t *); #define _tracech_t2 _tracecchar_t2 extern NCURSES_EXPORT(char *) _tracecchar_t2 (int, const cchar_t *); #else #define _tracech_t _tracechtype #define _tracech_t2 _tracechtype2 #endif extern NCURSES_EXPORT(void) trace (const unsigned) GCC_DEPRECATED("use curses_trace"); extern NCURSES_EXPORT(unsigned) curses_trace (const unsigned); /* trace masks */ #define TRACE_DISABLE 0x0000 /* turn off tracing */ #define TRACE_TIMES 0x0001 /* trace user and system times of updates */ #define TRACE_TPUTS 0x0002 /* trace tputs calls */ #define TRACE_UPDATE 0x0004 /* trace update actions, old & new screens */ #define TRACE_MOVE 0x0008 /* trace cursor moves and scrolls */ #define TRACE_CHARPUT 0x0010 /* trace all character outputs */ #define TRACE_ORDINARY 0x001F /* trace all update actions */ #define TRACE_CALLS 0x0020 /* trace all curses calls */ #define TRACE_VIRTPUT 0x0040 /* trace virtual character puts */ #define TRACE_IEVENT 0x0080 /* trace low-level input processing */ #define TRACE_BITS 0x0100 /* trace state of TTY control bits */ #define TRACE_ICALLS 0x0200 /* trace internal/nested calls */ #define TRACE_CCALLS 0x0400 /* trace per-character calls */ #define TRACE_DATABASE 0x0800 /* trace read/write of terminfo/termcap data */ #define TRACE_ATTRS 0x1000 /* trace attribute updates */ #define TRACE_SHIFT 13 /* number of bits in the trace masks */ #define TRACE_MAXIMUM ((1 << TRACE_SHIFT) - 1) /* maximum trace level */ #if defined(TRACE) || defined(NCURSES_TEST) extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable; /* enable optimizations */ extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *); #define OPTIMIZE_MVCUR 0x01 /* cursor movement optimization */ #define OPTIMIZE_HASHMAP 0x02 /* diff hashing to detect scrolls */ #define OPTIMIZE_SCROLL 0x04 /* scroll optimization */ #define OPTIMIZE_ALL 0xff /* enable all optimizations (dflt) */ #endif extern GCC_NORETURN NCURSES_EXPORT(void) exit_curses (int); #include <unctrl.h> #ifdef __cplusplus #ifndef NCURSES_NOMACROS /* these names conflict with STL */ #undef box #undef clear #undef erase #undef move #undef refresh #endif /* NCURSES_NOMACROS */ } #endif #endif /* __NCURSES_H */ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software <http://www.openldap.org/>. * * Copyright 1998-2026 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP * Public License. * * A copy of this license is available in file LICENSE in the * top-level directory of the distribution or, alternatively, at * <http://www.OpenLDAP.org/license.html>. */ /* LDAP C Defines */ #ifndef _LDAP_CDEFS_H #define _LDAP_CDEFS_H #if defined(__cplusplus) || defined(c_plusplus) # define LDAP_BEGIN_DECL extern "C" { # define LDAP_END_DECL } #else # define LDAP_BEGIN_DECL /* begin declarations */ # define LDAP_END_DECL /* end declarations */ #endif #if !defined(LDAP_NO_PROTOTYPES) && ( defined(LDAP_NEEDS_PROTOTYPES) || \ defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) ) /* ANSI C or C++ */ # define LDAP_P(protos) protos # define LDAP_CONCAT1(x,y) x ## y # define LDAP_CONCAT(x,y) LDAP_CONCAT1(x,y) # define LDAP_STRING(x) #x /* stringify without expanding x */ # define LDAP_XSTRING(x) LDAP_STRING(x) /* expand x, then stringify */ #ifndef LDAP_CONST # define LDAP_CONST const #endif #else /* no prototypes */ /* traditional C */ # define LDAP_P(protos) () # define LDAP_CONCAT(x,y) x/**/y # define LDAP_STRING(x) "x" #ifndef LDAP_CONST # define LDAP_CONST /* no const */ #endif #endif /* no prototypes */ #if (__GNUC__) * 1000 + (__GNUC_MINOR__) >= 2006 # define LDAP_GCCATTR(attrs) __attribute__(attrs) #else # define LDAP_GCCATTR(attrs) #endif /* * Support for Windows DLLs. * * When external source code includes header files for dynamic libraries, * the external source code is "importing" DLL symbols into its resulting * object code. On Windows, symbols imported from DLLs must be explicitly * indicated in header files with the __declspec(dllimport) directive. * This is not totally necessary for functions because the compiler * (gcc or MSVC) will generate stubs when this directive is absent. * However, this is required for imported variables. * * The LDAP libraries, i.e. liblber and libldap, can be built as * static or shared, based on configuration. Just about all other source * code in OpenLDAP use these libraries. If the LDAP libraries * are configured as shared, 'configure' defines the LDAP_LIBS_DYNAMIC * macro. When other source files include LDAP library headers, the * LDAP library symbols will automatically be marked as imported. When * the actual LDAP libraries are being built, the symbols will not * be marked as imported because the LBER_LIBRARY or LDAP_LIBRARY macros * will be respectively defined. * * Any project outside of OpenLDAP with source code wanting to use * LDAP dynamic libraries should explicitly define LDAP_LIBS_DYNAMIC. * This will ensure that external source code appropriately marks symbols * that will be imported. * * The slapd executable, itself, can be used as a dynamic library. * For example, if a backend module is compiled as shared, it will * import symbols from slapd. When this happens, the slapd symbols * must be marked as imported in header files that the backend module * includes. Remember that slapd links with various static libraries. * If the LDAP libraries were configured as static, their object * code is also part of the monolithic slapd executable. Thus, when * a backend module imports symbols from slapd, it imports symbols from * all of the static libraries in slapd as well. Thus, the SLAP_IMPORT * macro, when defined, will appropriately mark symbols as imported. * This macro should be used by shared backend modules as well as any * other external source code that imports symbols from the slapd * executable as if it were a DLL. * * Note that we don't actually have to worry about using the * __declspec(dllexport) directive anywhere. This is because both * MSVC and Mingw provide alternate (more effective) methods for exporting * symbols out of binaries, i.e. the use of a DEF file. * * NOTE ABOUT BACKENDS: Backends can be configured as static or dynamic. * When a backend is configured as dynamic, slapd will load the backend * explicitly and populate function pointer structures by calling * the backend's well-known initialization function. Because of this * procedure, slapd never implicitly imports symbols from dynamic backends. * This makes it unnecessary to tag various backend functions with the * __declspec(dllimport) directive. This is because neither slapd nor * any other external binary should ever be implicitly loading a backend * dynamic module. * * Backends are supposed to be self-contained. However, it appears that * back-meta DOES implicitly import symbols from back-ldap. This means * that the __declspec(dllimport) directive should be marked on back-ldap * functions (in its header files) if and only if we're compiling for * windows AND back-ldap has been configured as dynamic AND back-meta * is the client of back-ldap. When client is slapd, there is no effect * since slapd does not implicitly import symbols. * * TODO(?): Currently, back-meta nor back-ldap is supported for Mingw32. * Thus, there's no need to worry about this right now. This is something that * may or may not have to be addressed in the future. */ /* LBER library */ #if defined(_WIN32) && \ ((defined(LDAP_LIBS_DYNAMIC) && !defined(LBER_LIBRARY)) || \ (!defined(LDAP_LIBS_DYNAMIC) && defined(SLAPD_IMPORT))) # define LBER_F(type) extern __declspec(dllimport) type # define LBER_V(type) extern __declspec(dllimport) type #else # define LBER_F(type) extern type # define LBER_V(type) extern type #endif /* LDAP library */ #if defined(_WIN32) && \ ((defined(LDAP_LIBS_DYNAMIC) && !defined(LDAP_LIBRARY)) || \ (!defined(LDAP_LIBS_DYNAMIC) && defined(SLAPD_IMPORT))) # define LDAP_F(type) extern __declspec(dllimport) type # define LDAP_V(type) extern __declspec(dllimport) type #else # define LDAP_F(type) extern type # define LDAP_V(type) extern type #endif /* AVL library */ #if defined(_WIN32) && defined(SLAPD_IMPORT) # define LDAP_AVL_F(type) extern __declspec(dllimport) type # define LDAP_AVL_V(type) extern __declspec(dllimport) type #else # define LDAP_AVL_F(type) extern type # define LDAP_AVL_V(type) extern type #endif /* LDIF library */ #if defined(_WIN32) && defined(SLAPD_IMPORT) # define LDAP_LDIF_F(type) extern __declspec(dllimport) type # define LDAP_LDIF_V(type) extern __declspec(dllimport) type #else # define LDAP_LDIF_F(type) extern type # define LDAP_LDIF_V(type) extern type #endif /* LUNICODE library */ #if defined(_WIN32) && defined(SLAPD_IMPORT) # define LDAP_LUNICODE_F(type) extern __declspec(dllimport) type # define LDAP_LUNICODE_V(type) extern __declspec(dllimport) type #else # define LDAP_LUNICODE_F(type) extern type # define LDAP_LUNICODE_V(type) extern type #endif /* LUTIL library */ #if defined(_WIN32) && defined(SLAPD_IMPORT) # define LDAP_LUTIL_F(type) extern __declspec(dllimport) type # define LDAP_LUTIL_V(type) extern __declspec(dllimport) type #else # define LDAP_LUTIL_F(type) extern type # define LDAP_LUTIL_V(type) extern type #endif /* REWRITE library */ #if defined(_WIN32) && defined(SLAPD_IMPORT) # define LDAP_REWRITE_F(type) extern __declspec(dllimport) type # define LDAP_REWRITE_V(type) extern __declspec(dllimport) type #else # define LDAP_REWRITE_F(type) extern type # define LDAP_REWRITE_V(type) extern type #endif /* SLAPD (as a dynamic library exporting symbols) */ #if defined(_WIN32) && defined(SLAPD_IMPORT) # define LDAP_SLAPD_F(type) extern __declspec(dllimport) type # define LDAP_SLAPD_V(type) extern __declspec(dllimport) type #else # define LDAP_SLAPD_F(type) extern type # define LDAP_SLAPD_V(type) extern type #endif /* SLAPD (as a dynamic library exporting symbols) */ #if defined(_WIN32) && defined(SLAPD_IMPORT) # define LDAP_SLAPI_F(type) extern __declspec(dllimport) type # define LDAP_SLAPI_V(type) extern __declspec(dllimport) type #else # define LDAP_SLAPI_F(type) extern type # define LDAP_SLAPI_V(type) extern type #endif /* SLAPD (as a dynamic library exporting symbols) */ #if defined(_WIN32) && defined(SLAPD_IMPORT) # define SLAPI_F(type) extern __declspec(dllimport) type # define SLAPI_V(type) extern __declspec(dllimport) type #else # define SLAPI_F(type) extern type # define SLAPI_V(type) extern type #endif /* * C library. Mingw32 links with the dynamic C run-time library by default, * so the explicit definition of CSTATIC will keep dllimport from * being defined, if desired. * * MSVC defines the _DLL macro when the compiler is invoked with /MD or /MDd, * which means the resulting object code will be linked with the dynamic * C run-time library. * * Technically, it shouldn't be necessary to redefine any functions that * the headers for the C library should already contain. Nevertheless, this * is here as a safe-guard. * * TODO: Determine if these macros ever get expanded for Windows. If not, * the declspec expansion can probably be removed. */ #if (defined(__MINGW32__) && !defined(CSTATIC)) || \ (defined(_MSC_VER) && defined(_DLL)) # define LDAP_LIBC_F(type) extern __declspec(dllimport) type # define LDAP_LIBC_V(type) extern __declspec(dllimport) type #else # define LDAP_LIBC_F(type) extern type # define LDAP_LIBC_V(type) extern type #endif #endif /* _LDAP_CDEFS_H */ // * This makes emacs happy -*-Mode: C++;-*- /**************************************************************************** * Copyright 2019,2020 Thomas E. Dickey * * Copyright 1998-2012,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ // $Id: cursesm.h,v 1.34 2020/05/24 01:40:20 anonymous.maarten Exp $ #ifndef NCURSES_CURSESM_H_incl #define NCURSES_CURSESM_H_incl 1 #include <cursesp.h> extern "C" { # include <menu.h> } // // ------------------------------------------------------------------------- // This wraps the ITEM type of <menu.h> // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP NCursesMenuItem { friend class NCursesMenu; protected: ITEM *item; inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) { if (err != E_OK) THROW(new NCursesMenuException (err)); } public: NCursesMenuItem (const char* p_name = NULL, const char* p_descript = NULL) : item(0) { item = p_name ? ::new_item (p_name, p_descript) : STATIC_CAST(ITEM*)(0); if (p_name && !item) OnError (E_SYSTEM_ERROR); } // Create an item. If you pass both parameters as NULL, a delimiting // item is constructed which can be used to terminate a list of // NCursesMenu objects. NCursesMenuItem& operator=(const NCursesMenuItem& rhs) { if (this != &rhs) { *this = rhs; } return *this; } NCursesMenuItem(const NCursesMenuItem& rhs) : item(0) { (void) rhs; } virtual ~NCursesMenuItem () THROWS(NCursesException); // Release the items memory inline const char* name () const { return ::item_name (item); } // Name of the item inline const char* description () const { return ::item_description (item); } // Description of the item inline int (index) (void) const { return ::item_index (item); } // Index of the item in an item array (or -1) inline void options_on (Item_Options opts) { OnError (::item_opts_on (item, opts)); } // Switch on the items options inline void options_off (Item_Options opts) { OnError (::item_opts_off (item, opts)); } // Switch off the item's option inline Item_Options options () const { return ::item_opts (item); } // Retrieve the items options inline void set_options (Item_Options opts) { OnError (::set_item_opts (item, opts)); } // Set the items options inline void set_value (bool f) { OnError (::set_item_value (item,f)); } // Set/Reset the items selection state inline bool value () const { return ::item_value (item); } // Retrieve the items selection state inline bool visible () const { return ::item_visible (item); } // Retrieve visibility of the item virtual bool action(); // Perform an action associated with this item; you may use this in an // user supplied driver for a menu; you may derive from this class and // overload action() to supply items with different actions. // If an action returns true, the menu will be exited. The default action // is to do nothing. }; // Prototype for an items callback function. typedef bool ITEMCALLBACK(NCursesMenuItem&); // If you don't like to create a child class for individual items to // overload action(), you may use this class and provide a callback // function pointer for items. class NCURSES_CXX_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem { private: ITEMCALLBACK* p_fct; public: NCursesMenuCallbackItem(ITEMCALLBACK* fct = NULL, const char* p_name = NULL, const char* p_descript = NULL ) : NCursesMenuItem (p_name, p_descript), p_fct (fct) { } NCursesMenuCallbackItem& operator=(const NCursesMenuCallbackItem& rhs) { if (this != &rhs) { *this = rhs; } return *this; } NCursesMenuCallbackItem(const NCursesMenuCallbackItem& rhs) : NCursesMenuItem(rhs), p_fct(0) { } virtual ~NCursesMenuCallbackItem() THROWS(NCursesException); bool action(); }; // This are the built-in hook functions in this C++ binding. In C++ we use // virtual member functions (see below On_..._Init and On_..._Termination) // to provide this functionality in an object oriented manner. extern "C" { void _nc_xx_mnu_init(MENU *); void _nc_xx_mnu_term(MENU *); void _nc_xx_itm_init(MENU *); void _nc_xx_itm_term(MENU *); } // // ------------------------------------------------------------------------- // This wraps the MENU type of <menu.h> // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP NCursesMenu : public NCursesPanel { protected: MENU *menu; private: NCursesWindow* sub; // the subwindow object bool b_sub_owner; // is this our own subwindow? bool b_framed; // has the menu a border? bool b_autoDelete; // Delete items when deleting menu? NCursesMenuItem** my_items; // The array of items for this menu // This structure is used for the menu's user data field to link the // MENU* to the C++ object and to provide extra space for a user pointer. typedef struct { void* m_user; // the pointer for the user's data const NCursesMenu* m_back; // backward pointer to C++ object const MENU* m_owner; } UserHook; // Get the backward pointer to the C++ object from a MENU static inline NCursesMenu* getHook(const MENU *m) { UserHook* hook = STATIC_CAST(UserHook*)(::menu_userptr(m)); assert(hook != 0 && hook->m_owner==m); return const_cast<NCursesMenu*>(hook->m_back); } friend void _nc_xx_mnu_init(MENU *); friend void _nc_xx_mnu_term(MENU *); friend void _nc_xx_itm_init(MENU *); friend void _nc_xx_itm_term(MENU *); // Calculate ITEM* array for the menu ITEM** mapItems(NCursesMenuItem* nitems[]); protected: // internal routines inline void set_user(void *user) { UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu)); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu); uptr->m_user = user; } inline void *get_user() { UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu)); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu); return uptr->m_user; } void InitMenu (NCursesMenuItem* menu[], bool with_frame, bool autoDeleteItems); inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) { if (err != E_OK) THROW(new NCursesMenuException (this, err)); } // this wraps the menu_driver call. virtual int driver (int c) ; // 'Internal' constructor to create a menu without association to // an array of items. NCursesMenu( int nlines, int ncols, int begin_y = 0, int begin_x = 0) : NCursesPanel(nlines,ncols,begin_y,begin_x), menu (STATIC_CAST(MENU*)(0)), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_items(0) { } public: // Make a full window size menu NCursesMenu (NCursesMenuItem* Items[], bool with_frame=FALSE, // Reserve space for a frame? bool autoDelete_Items=FALSE) // Autocleanup of Items? : NCursesPanel(), menu(0), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_items(0) { InitMenu(Items, with_frame, autoDelete_Items); } // Make a menu with a window of this size. NCursesMenu (NCursesMenuItem* Items[], int nlines, int ncols, int begin_y = 0, int begin_x = 0, bool with_frame=FALSE, // Reserve space for a frame? bool autoDelete_Items=FALSE) // Autocleanup of Items? : NCursesPanel(nlines, ncols, begin_y, begin_x), menu(0), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_items(0) { InitMenu(Items, with_frame, autoDelete_Items); } NCursesMenu& operator=(const NCursesMenu& rhs) { if (this != &rhs) { *this = rhs; NCursesPanel::operator=(rhs); } return *this; } NCursesMenu(const NCursesMenu& rhs) : NCursesPanel(rhs), menu(rhs.menu), sub(rhs.sub), b_sub_owner(rhs.b_sub_owner), b_framed(rhs.b_framed), b_autoDelete(rhs.b_autoDelete), my_items(rhs.my_items) { } virtual ~NCursesMenu () THROWS(NCursesException); // Retrieve the menus subwindow inline NCursesWindow& subWindow() const { assert(sub!=NULL); return *sub; } // Set the menus subwindow void setSubWindow(NCursesWindow& sub); // Set these items for the menu inline void setItems(NCursesMenuItem* Items[]) { OnError(::set_menu_items(menu,mapItems(Items))); } // Remove the menu from the screen inline void unpost (void) { OnError (::unpost_menu (menu)); } // Post the menu to the screen if flag is true, unpost it otherwise inline void post(bool flag = TRUE) { flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu)); } // Get the number of rows and columns for this menu inline void scale (int& mrows, int& mcols) const { OnError (::scale_menu (menu, &mrows, &mcols)); } // Set the format of this menu inline void set_format(int mrows, int mcols) { OnError (::set_menu_format(menu, mrows, mcols)); } // Get the format of this menu inline void menu_format(int& rows,int& ncols) { ::menu_format(menu,&rows,&ncols); } // Items of the menu inline NCursesMenuItem* items() const { return *my_items; } // Get the number of items in this menu inline int count() const { return ::item_count(menu); } // Get the current item (i.e. the one the cursor is located) inline NCursesMenuItem* current_item() const { return my_items[::item_index(::current_item(menu))]; } // Get the marker string inline const char* mark() const { return ::menu_mark(menu); } // Set the marker string inline void set_mark(const char *marker) { OnError (::set_menu_mark (menu, marker)); } // Get the name of the request code c inline static const char* request_name(int c) { return ::menu_request_name(c); } // Get the current pattern inline char* pattern() const { return ::menu_pattern(menu); } // true if there is a pattern match, false otherwise. bool set_pattern (const char *pat); // set the default attributes for the menu // i.e. set fore, back and grey attribute virtual void setDefaultAttributes(); // Get the menus background attributes inline chtype back() const { return ::menu_back(menu); } // Get the menus foreground attributes inline chtype fore() const { return ::menu_fore(menu); } // Get the menus grey attributes (used for unselectable items) inline chtype grey() const { return ::menu_grey(menu); } // Set the menus background attributes inline chtype set_background(chtype a) { return ::set_menu_back(menu,a); } // Set the menus foreground attributes inline chtype set_foreground(chtype a) { return ::set_menu_fore(menu,a); } // Set the menus grey attributes (used for unselectable items) inline chtype set_grey(chtype a) { return ::set_menu_grey(menu,a); } inline void options_on (Menu_Options opts) { OnError (::menu_opts_on (menu,opts)); } inline void options_off(Menu_Options opts) { OnError (::menu_opts_off(menu,opts)); } inline Menu_Options options() const { return ::menu_opts(menu); } inline void set_options (Menu_Options opts) { OnError (::set_menu_opts (menu,opts)); } inline int pad() const { return ::menu_pad(menu); } inline void set_pad (int padch) { OnError (::set_menu_pad (menu, padch)); } // Position the cursor to the current item inline void position_cursor () const { OnError (::pos_menu_cursor (menu)); } // Set the current item inline void set_current(NCursesMenuItem& I) { OnError (::set_current_item(menu, I.item)); } // Get the current top row of the menu inline int top_row (void) const { return ::top_row (menu); } // Set the current top row of the menu inline void set_top_row (int row) { OnError (::set_top_row (menu, row)); } // spacing control // Set the spacing for the menu inline void setSpacing(int spc_description, int spc_rows, int spc_columns) { OnError(::set_menu_spacing(menu, spc_description, spc_rows, spc_columns)); } // Get the spacing info for the menu inline void Spacing(int& spc_description, int& spc_rows, int& spc_columns) const { OnError(::menu_spacing(menu, &spc_description, &spc_rows, &spc_columns)); } // Decorations inline void frame(const char *title=NULL, const char* btitle=NULL) { if (b_framed) NCursesPanel::frame(title,btitle); else OnError(E_SYSTEM_ERROR); } inline void boldframe(const char *title=NULL, const char* btitle=NULL) { if (b_framed) NCursesPanel::boldframe(title,btitle); else OnError(E_SYSTEM_ERROR); } inline void label(const char *topLabel, const char *bottomLabel) { if (b_framed) NCursesPanel::label(topLabel,bottomLabel); else OnError(E_SYSTEM_ERROR); } // ----- // Hooks // ----- // Called after the menu gets repositioned in its window. // This is especially true if the menu is posted. virtual void On_Menu_Init(); // Called before the menu gets repositioned in its window. // This is especially true if the menu is unposted. virtual void On_Menu_Termination(); // Called after the item became the current item virtual void On_Item_Init(NCursesMenuItem& item); // Called before this item is left as current item. virtual void On_Item_Termination(NCursesMenuItem& item); // Provide a default key virtualization. Translate the keyboard // code c into a menu request code. // The default implementation provides a hopefully straightforward // mapping for the most common keystrokes and menu requests. virtual int virtualize(int c); // Operators inline NCursesMenuItem* operator[](int i) const { if ( (i < 0) || (i >= ::item_count (menu)) ) OnError (E_BAD_ARGUMENT); return (my_items[i]); } // Perform the menu's operation // Return the item where you left the selection mark for a single // selection menu, or NULL for a multivalued menu. virtual NCursesMenuItem* operator()(void); // -------------------- // Exception handlers // Called by operator() // -------------------- // Called if the request is denied virtual void On_Request_Denied(int c) const; // Called if the item is not selectable virtual void On_Not_Selectable(int c) const; // Called if pattern doesn't match virtual void On_No_Match(int c) const; // Called if the command is unknown virtual void On_Unknown_Command(int c) const; }; // // ------------------------------------------------------------------------- // This is the typical C++ typesafe way to allow to attach // user data to an item of a menu. Its assumed that the user // data belongs to some class T. Use T as template argument // to create a UserItem. // ------------------------------------------------------------------------- // template<class T> class NCURSES_CXX_IMPEXP NCursesUserItem : public NCursesMenuItem { public: NCursesUserItem (const char* p_name, const char* p_descript = NULL, const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesMenuItem (p_name, p_descript) { if (item) OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void*>(p_UserData)))); } virtual ~NCursesUserItem() THROWS(NCursesException) {} inline const T* UserData (void) const { return reinterpret_cast<const T*>(::item_userptr (item)); }; inline virtual void setUserData(const T* p_UserData) { if (item) OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void *>(p_UserData)))); } }; // // ------------------------------------------------------------------------- // The same mechanism is used to attach user data to a menu // ------------------------------------------------------------------------- // template<class T> class NCURSES_CXX_IMPEXP NCursesUserMenu : public NCursesMenu { protected: NCursesUserMenu( int nlines, int ncols, int begin_y = 0, int begin_x = 0, const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesMenu(nlines,ncols,begin_y,begin_x) { if (menu) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); } public: NCursesUserMenu (NCursesMenuItem* Items[], const T* p_UserData = STATIC_CAST(T*)(0), bool with_frame=FALSE, bool autoDelete_Items=FALSE) : NCursesMenu (Items, with_frame, autoDelete_Items) { if (menu) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); }; NCursesUserMenu (NCursesMenuItem* Items[], int nlines, int ncols, int begin_y = 0, int begin_x = 0, const T* p_UserData = STATIC_CAST(T*)(0), bool with_frame=FALSE) : NCursesMenu (Items, nlines, ncols, begin_y, begin_x, with_frame) { if (menu) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); }; virtual ~NCursesUserMenu() THROWS(NCursesException) { }; inline T* UserData (void) { return reinterpret_cast<T*>(get_user ()); }; inline virtual void setUserData (const T* p_UserData) { if (menu) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); } }; #endif /* NCURSES_CURSESM_H_incl */ /**************************************************************************** * Copyright 2018,2020 Thomas E. Dickey * * Copyright 2006-2012,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Thomas E. Dickey 2006 * ****************************************************************************/ /* $Id: nc_tparm.h,v 1.11 2020/05/27 23:33:31 tom Exp $ */ #ifndef NC_TPARM_included #define NC_TPARM_included 1 #include <ncurses_cfg.h> #include <curses.h> /* * Cast parameters past the formatting-string for tparm() to match the * assumption of the varargs code. */ #ifndef TPARM_ARG #ifdef NCURSES_TPARM_ARG #define TPARM_ARG NCURSES_TPARM_ARG #else #define TPARM_ARG long #endif #endif /* TPARAM_ARG */ #define TPARM_N(n) (TPARM_ARG)(n) #define TPARM_9(a,b,c,d,e,f,g,h,i,j) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i),TPARM_N(j)) #if NCURSES_TPARM_VARARGS #define TPARM_8(a,b,c,d,e,f,g,h,i) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i)) #define TPARM_7(a,b,c,d,e,f,g,h) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h)) #define TPARM_6(a,b,c,d,e,f,g) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g)) #define TPARM_5(a,b,c,d,e,f) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f)) #define TPARM_4(a,b,c,d,e) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e)) #define TPARM_3(a,b,c,d) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d)) #define TPARM_2(a,b,c) tparm(a,TPARM_N(b),TPARM_N(c)) #define TPARM_1(a,b) tparm(a,TPARM_N(b)) #define TPARM_0(a) tparm(a) #else #define TPARM_8(a,b,c,d,e,f,g,h,i) TPARM_9(a,b,c,d,e,f,g,h,i,0) #define TPARM_7(a,b,c,d,e,f,g,h) TPARM_8(a,b,c,d,e,f,g,h,0) #define TPARM_6(a,b,c,d,e,f,g) TPARM_7(a,b,c,d,e,f,g,0) #define TPARM_5(a,b,c,d,e,f) TPARM_6(a,b,c,d,e,f,0) #define TPARM_4(a,b,c,d,e) TPARM_5(a,b,c,d,e,0) #define TPARM_3(a,b,c,d) TPARM_4(a,b,c,d,0) #define TPARM_2(a,b,c) TPARM_3(a,b,c,0) #define TPARM_1(a,b) TPARM_2(a,b,0) #define TPARM_0(a) TPARM_1(a,0) #endif #ifdef NCURSES_INTERNALS #define TIPARM_1(s,a) _nc_tiparm(1,s,a) #define TIPARM_2(s,a,b) _nc_tiparm(2,s,a,b) #define TIPARM_3(s,a,b,c) _nc_tiparm(3,s,a,b,c) #define TIPARM_4(s,a,b,c,d) _nc_tiparm(4,s,a,b,c,d) #define TIPARM_5(s,a,b,c,d,e) _nc_tiparm(5,s,a,b,c,d,e) #define TIPARM_6(s,a,b,c,d,e,f) _nc_tiparm(6,s,a,b,c,d,e,f) #define TIPARM_7(s,a,b,c,d,e,f,g) _nc_tiparm(7,s,a,b,c,d,e,f,g) #define TIPARM_8(s,a,b,c,d,e,f,g,h) _nc_tiparm(8,s,a,b,c,d,e,f,g,h) #define TIPARM_9(s,a,b,c,d,e,f,g,h,i) _nc_tiparm(9,s,a,b,c,d,e,f,g,h,i) #endif #endif /* NC_TPARM_included */ /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Thomas E. Dickey 1996 on * ****************************************************************************/ /* * $Id: tic.h,v 1.82 2021/03/20 16:06:15 tom Exp $ * tic.h - Global variables and structures for the terminfo compiler. */ #ifndef __TIC_H #define __TIC_H /* *INDENT-OFF* */ #ifdef __cplusplus extern "C" { #endif #include <ncurses_cfg.h> #include <curses.h> /* for the _tracef() prototype, ERR/OK, bool defs */ /* ** The format of SVr2 compiled terminfo files is as follows: ** ** Header (12 bytes), containing information given below ** Names Section, containing the names of the terminal ** Boolean Section, containing the values of all of the ** boolean capabilities ** A null byte may be inserted here to make ** sure that the Number Section begins on an ** even word boundary. ** Number Section, containing the values of all of the numeric ** capabilities, each as a short integer ** String Section, containing short integer offsets into the ** String Table, one per string capability ** String Table, containing the actual characters of the string ** capabilities. ** ** In the SVr2 format, "short" means signed 16-bit numbers, which is sometimes ** inconvenient. The numbers are signed, to provide for absent and canceled ** values. ncurses6.1 introduced an extension to this compiled format, by ** making the Number Section a list of signed 32-bit integers. ** ** NOTE that all short integers in the file are stored using VAX/PDP-style ** byte-order, i.e., least-significant byte first. ** ** There is no structure definition here because it would only confuse ** matters. Terminfo format is a raw byte layout, not a structure ** dump. If you happen to be on a little-endian machine with 16-bit ** shorts that requires no padding between short members in a struct, ** then there is a natural C structure that captures the header, but ** not very helpfully. */ #define MAGIC 0432 /* first two bytes of a compiled entry */ #define MAGIC2 01036 /* first two bytes of a compiled 32-bit entry */ #undef BYTE #define BYTE(p,n) (unsigned char)((p)[n]) #define IS_NEG1(p) ((BYTE(p,0) == 0377) && (BYTE(p,1) == 0377)) #define IS_NEG2(p) ((BYTE(p,0) == 0376) && (BYTE(p,1) == 0377)) #define LOW_MSB(p) (BYTE(p,0) + 256*BYTE(p,1)) #define IS_TIC_MAGIC(p) (LOW_MSB(p) == MAGIC || LOW_MSB(p) == MAGIC2) #define quick_prefix(s) (!strncmp((s), "b64:", (size_t)4) || !strncmp((s), "hex:", (size_t)4)) /* * The "maximum" here is misleading; XSI guarantees minimum values, which a * given implementation may exceed. */ #define MAX_NAME_SIZE 512 /* maximum legal name field size (XSI:127) */ #define MAX_ENTRY_SIZE1 4096 /* maximum legal entry size (SVr2) */ #define MAX_ENTRY_SIZE2 32768 /* maximum legal entry size (ncurses6.1) */ #if NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR #define MAX_ENTRY_SIZE MAX_ENTRY_SIZE2 #else #define MAX_ENTRY_SIZE MAX_ENTRY_SIZE1 #endif /* * The maximum size of individual name or alias is guaranteed in XSI to be at * least 14, since that corresponds to the older filename lengths. Newer * systems allow longer aliases, though not many terminal descriptions are * written to use them. The MAX_ALIAS symbol is used for warnings. */ #if HAVE_LONG_FILE_NAMES #define MAX_ALIAS 32 /* smaller than POSIX minimum for PATH_MAX */ #else #define MAX_ALIAS 14 /* SVr3 filename length */ #endif /* location of user's personal info directory */ #define PRIVATE_INFO "%s/.terminfo" /* plug getenv("HOME") into %s */ /* * Some traces are designed to be used via tic's verbose option (and similar in * infocmp and toe) rather than the 'trace()' function. So we use the bits * above the normal trace() parameter as a debug-level. */ #define MAX_DEBUG_LEVEL 15 #define DEBUG_LEVEL(n) ((n) << TRACE_SHIFT) #define set_trace_level(n) \ _nc_tracing &= DEBUG_LEVEL(MAX_DEBUG_LEVEL) \ + DEBUG_LEVEL(MAX_DEBUG_LEVEL) - 1, \ _nc_tracing |= DEBUG_LEVEL(n) #ifdef TRACE #define DEBUG(n, a) if (_nc_tracing >= DEBUG_LEVEL(n)) _tracef a #else #define DEBUG(n, a) /*nothing*/ #endif /* * These are the types of tokens returned by the scanner. The first * three are also used in the hash table of capability names. The scanner * returns one of these values after loading the specifics into the global * structure curr_token. */ #define BOOLEAN 0 /* Boolean capability */ #define NUMBER 1 /* Numeric capability */ #define STRING 2 /* String-valued capability */ #define CANCEL 3 /* Capability to be cancelled in following tc's */ #define NAMES 4 /* The names for a terminal type */ #define UNDEF 5 /* Undefined */ #define NO_PUSHBACK -1 /* used in pushtype to indicate no pushback */ /* * The global structure in which the specific parts of a * scanned token are returned. */ struct token { char *tk_name; /* name of capability */ int tk_valnumber; /* value of capability (if a number) */ char *tk_valstring; /* value of capability (if a string) */ }; /* * Offsets to string capabilities, with the corresponding functionkey codes. */ struct tinfo_fkeys { unsigned offset; chtype code; }; typedef short HashValue; /* * The file comp_captab.c contains an array of these structures, one per * possible capability. These are indexed by a hash table array of pointers to * the same structures for use by the parser. */ struct name_table_entry { const char *nte_name; /* name to hash on */ int nte_type; /* BOOLEAN, NUMBER or STRING */ HashValue nte_index; /* index of associated variable in its array */ HashValue nte_link; /* index in table of next hash, or -1 */ }; /* * Use this structure to hide differences between terminfo and termcap tables. */ typedef struct { unsigned table_size; const HashValue *table_data; HashValue (*hash_of)(const char *); int (*compare_names)(const char *, const char *); } HashData; struct alias { const char *from; const char *to; const char *source; }; #define NOTFOUND ((struct name_table_entry *) 0) /* * The file comp_userdefs.c contains an array of these structures, one per * possible capability. These are indexed by a hash table array of pointers to * the same structures for use by the parser. */ struct user_table_entry { const char *ute_name; /* name to hash on */ int ute_type; /* mask (BOOLEAN, NUMBER, STRING) */ unsigned ute_argc; /* number of parameters */ unsigned ute_args; /* bit-mask for string parameters */ HashValue ute_index; /* index of associated variable in its array */ HashValue ute_link; /* index in table of next hash, or -1 */ }; /* * The casts are required for correct sign-propagation with systems such as * AIX, IRIX64, Solaris which default to unsigned characters. The C standard * leaves this detail unspecified. */ /* out-of-band values for representing absent capabilities */ #define ABSENT_BOOLEAN ((signed char)-1) /* 255 */ #define ABSENT_NUMERIC (-1) #define ABSENT_STRING (char *)0 /* out-of-band values for representing cancels */ #define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */ #define CANCELLED_NUMERIC (-2) #define CANCELLED_STRING (char *)(-1) #define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */ #define VALID_NUMERIC(s) ((s) >= 0) #define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING) /* termcap entries longer than this may break old binaries */ #define MAX_TERMCAP_LENGTH 1023 /* this is a documented limitation of terminfo */ #define MAX_TERMINFO_LENGTH 4096 #ifndef TERMINFO #define TERMINFO "/usr/share/terminfo" #endif #ifdef NCURSES_TERM_ENTRY_H_incl /* * These entrypoints are used only by the ncurses utilities such as tic. */ #ifdef NCURSES_INTERNALS /* access.c */ extern NCURSES_EXPORT(unsigned) _nc_pathlast (const char *); extern NCURSES_EXPORT(bool) _nc_is_abs_path (const char *); extern NCURSES_EXPORT(bool) _nc_is_dir_path (const char *); extern NCURSES_EXPORT(bool) _nc_is_file_path (const char *); extern NCURSES_EXPORT(char *) _nc_basename (char *); extern NCURSES_EXPORT(char *) _nc_rootname (char *); /* comp_captab.c */ extern NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool); extern NCURSES_EXPORT(const HashData *) _nc_get_hash_info (bool); extern NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool); /* comp_hash.c: name lookup */ extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_type_entry (const char *, int, bool); extern NCURSES_EXPORT(struct user_table_entry const *) _nc_find_user_entry (const char *); /* comp_scan.c: lexical analysis */ extern NCURSES_EXPORT(int) _nc_get_token (bool); extern NCURSES_EXPORT(void) _nc_panic_mode (char); extern NCURSES_EXPORT(void) _nc_push_token (int); extern NCURSES_EXPORT_VAR(int) _nc_curr_col; extern NCURSES_EXPORT_VAR(int) _nc_curr_line; extern NCURSES_EXPORT_VAR(int) _nc_syntax; extern NCURSES_EXPORT_VAR(int) _nc_strict_bsd; extern NCURSES_EXPORT_VAR(long) _nc_comment_end; extern NCURSES_EXPORT_VAR(long) _nc_comment_start; extern NCURSES_EXPORT_VAR(long) _nc_curr_file_pos; extern NCURSES_EXPORT_VAR(long) _nc_start_line; #define SYN_TERMINFO 0 #define SYN_TERMCAP 1 /* comp_error.c: warning & abort messages */ extern NCURSES_EXPORT(const char *) _nc_get_source (void); extern GCC_NORETURN NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(void) _nc_get_type (char *name); extern NCURSES_EXPORT(void) _nc_set_source (const char *const); extern NCURSES_EXPORT(void) _nc_set_type (const char *const); extern GCC_NORETURN NCURSES_EXPORT(void) _nc_syserr_abort (const char *const,...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(void) _nc_warning (const char *const,...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings; /* comp_scan.c */ extern NCURSES_EXPORT_VAR(struct token) _nc_curr_token; /* comp_userdefs.c */ NCURSES_EXPORT(const struct user_table_entry *) _nc_get_userdefs_table (void); NCURSES_EXPORT(const HashData *) _nc_get_hash_user (void); /* captoinfo.c: capability conversion */ extern NCURSES_EXPORT(char *) _nc_captoinfo (const char *, const char *, int const); extern NCURSES_EXPORT(char *) _nc_infotocap (const char *, const char *, int const); /* home_terminfo.c */ extern NCURSES_EXPORT(char *) _nc_home_terminfo (void); /* init_keytry.c */ #if BROKEN_LINKER #define _nc_tinfo_fkeys _nc_tinfo_fkeysf() extern NCURSES_EXPORT(const struct tinfo_fkeys *) _nc_tinfo_fkeysf (void); #else extern NCURSES_EXPORT_VAR(const struct tinfo_fkeys) _nc_tinfo_fkeys[]; #endif /* lib_tparm.c */ #define NUM_PARM 9 extern NCURSES_EXPORT_VAR(int) _nc_tparm_err; extern NCURSES_EXPORT(int) _nc_tparm_analyze(const char *, char **, int *); /* lib_trace.c */ extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing; extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *); extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *); /* lib_tputs.c */ extern NCURSES_EXPORT_VAR(int) _nc_nulls_sent; /* Add one for every null sent */ /* comp_main.c: compiler main */ extern const char * _nc_progname; /* db_iterator.c */ extern NCURSES_EXPORT(const char *) _nc_next_db(DBDIRS *, int *); extern NCURSES_EXPORT(const char *) _nc_tic_dir (const char *); extern NCURSES_EXPORT(void) _nc_first_db(DBDIRS *, int *); extern NCURSES_EXPORT(void) _nc_last_db(void); /* write_entry.c */ extern NCURSES_EXPORT(int) _nc_tic_written (void); #endif /* NCURSES_INTERNALS */ /* * These entrypoints were used by tack before 1.08. */ #undef NCURSES_TACK_1_08 #ifdef NCURSES_INTERNALS #define NCURSES_TACK_1_08 /* nothing */ #else #define NCURSES_TACK_1_08 GCC_DEPRECATED("upgrade to tack 1.08") #endif /* comp_hash.c: name lookup */ extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry (const char *, const HashValue *) NCURSES_TACK_1_08; extern NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool) NCURSES_TACK_1_08; /* comp_scan.c: lexical analysis */ extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *) NCURSES_TACK_1_08; /* comp_expand.c: expand string into readable form */ extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int) NCURSES_TACK_1_08; /* comp_scan.c: decode string from readable form */ extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *) NCURSES_TACK_1_08; #endif /* NCURSES_TERM_ENTRY_H_incl */ #ifdef __cplusplus } #endif /* *INDENT-ON* */ #endif /* __TIC_H */ /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Thomas E. Dickey 1996-on * ****************************************************************************/ /* $Id: curses.h.in,v 1.271 2021/03/20 16:25:43 tom Exp $ */ #ifndef __NCURSES_H #define __NCURSES_H #define CURSES 1 #define CURSES_H 1 /* These are defined only in curses.h, and are used for conditional compiles */ #define NCURSES_VERSION_MAJOR 6 #define NCURSES_VERSION_MINOR 2 #define NCURSES_VERSION_PATCH 20210508 /* This is defined in more than one ncurses header, for identification */ #undef NCURSES_VERSION #define NCURSES_VERSION "6.2" /* * Identify the mouse encoding version. */ #define NCURSES_MOUSE_VERSION 2 /* * Definitions to facilitate DLL's. */ #include <ncurses_dll.h> /* * Extra headers. */ #if 1 #include <stdint.h> #endif #ifdef __cplusplus #else #if 0 #include <stdnoreturn.h> #undef GCC_NORETURN #define GCC_NORETURN _Noreturn #endif #endif /* * User-definable tweak to disable the include of <stdbool.h>. */ #ifndef NCURSES_ENABLE_STDBOOL_H #define NCURSES_ENABLE_STDBOOL_H 1 #endif /* * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses * configured using --disable-macros. */ #ifndef NCURSES_ATTR_T #define NCURSES_ATTR_T int #endif /* * Expands to 'const' if ncurses is configured using --enable-const. Note that * doing so makes it incompatible with other implementations of X/Open Curses. */ #undef NCURSES_CONST #define NCURSES_CONST const #undef NCURSES_INLINE #define NCURSES_INLINE inline /* * The standard type used for color values, and for color-pairs. The latter * allows the curses library to enumerate the combinations of foreground and * background colors used by an application, and is normally the product of the * total foreground and background colors. * * X/Open uses "short" for both of these types, ultimately because they are * numbers from the SVr4 terminal database, which uses 16-bit signed values. */ #undef NCURSES_COLOR_T #define NCURSES_COLOR_T short #undef NCURSES_PAIRS_T #define NCURSES_PAIRS_T short /* * Definitions used to make WINDOW and similar structs opaque. */ #ifndef NCURSES_INTERNALS #define NCURSES_OPAQUE 0 #define NCURSES_OPAQUE_FORM 0 #define NCURSES_OPAQUE_MENU 0 #define NCURSES_OPAQUE_PANEL 0 #endif /* * Definition used to optionally suppress wattr* macros to help with the * transition from ncurses5 to ncurses6 by allowing the header files to * be shared across development packages for ncursesw in both ABIs. */ #ifndef NCURSES_WATTR_MACROS #define NCURSES_WATTR_MACROS 0 #endif /* * The reentrant code relies on the opaque setting, but adds features. */ #ifndef NCURSES_REENTRANT #define NCURSES_REENTRANT 0 #endif /* * In certain environments, we must work around linker problems for data */ #undef NCURSES_BROKEN_LINKER #if 0 #define NCURSES_BROKEN_LINKER 1 #endif /* * Control whether bindings for interop support are added. */ #undef NCURSES_INTEROP_FUNCS #define NCURSES_INTEROP_FUNCS 1 /* * The internal type used for window dimensions. */ #undef NCURSES_SIZE_T #define NCURSES_SIZE_T short /* * Control whether tparm() supports varargs or fixed-parameter list. */ #undef NCURSES_TPARM_VARARGS #define NCURSES_TPARM_VARARGS 1 /* * Control type used for tparm's arguments. While X/Open equates long and * char* values, this is not always workable for 64-bit platforms. */ #undef NCURSES_TPARM_ARG #define NCURSES_TPARM_ARG intptr_t /* * Control whether ncurses uses wcwidth() for checking width of line-drawing * characters. */ #undef NCURSES_WCWIDTH_GRAPHICS #define NCURSES_WCWIDTH_GRAPHICS 1 /* * NCURSES_CH_T is used in building the library, but not used otherwise in * this header file, since that would make the normal/wide-character versions * of the header incompatible. */ #undef NCURSES_CH_T #define NCURSES_CH_T cchar_t #if 1 && defined(_LP64) typedef unsigned chtype; typedef unsigned mmask_t; #else typedef uint32_t chtype; typedef uint32_t mmask_t; #endif /* * We need FILE, etc. Include this before checking any feature symbols. */ #include <stdio.h> /* * With XPG4, you must define _XOPEN_SOURCE_EXTENDED, it is redundant (or * conflicting) when _XOPEN_SOURCE is 500 or greater. If NCURSES_WIDECHAR is * not already defined, e.g., if the platform relies upon nonstandard feature * test macros, define it at this point if the standard feature test macros * indicate that it should be defined. */ #ifndef NCURSES_WIDECHAR #if defined(_XOPEN_SOURCE_EXTENDED) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) #define NCURSES_WIDECHAR 1 #else #define NCURSES_WIDECHAR 0 #endif #endif /* NCURSES_WIDECHAR */ #include <stdarg.h> /* we need va_list */ #if NCURSES_WIDECHAR #include <stddef.h> /* we want wchar_t */ #endif /* X/Open and SVr4 specify that curses implements 'bool'. However, C++ may also * implement it. If so, we must use the C++ compiler's type to avoid conflict * with other interfaces. * * A further complication is that <stdbool.h> may declare 'bool' to be a * different type, such as an enum which is not necessarily compatible with * C++. If we have <stdbool.h>, make 'bool' a macro, so users may #undef it. * Otherwise, let it remain a typedef to avoid conflicts with other #define's. * In either case, make a typedef for NCURSES_BOOL which can be used if needed * from either C or C++. */ #undef TRUE #define TRUE 1 #undef FALSE #define FALSE 0 typedef unsigned char NCURSES_BOOL; #if defined(__cplusplus) /* __cplusplus, etc. */ /* use the C++ compiler's bool type */ #define NCURSES_BOOL bool #else /* c89, c99, etc. */ #if NCURSES_ENABLE_STDBOOL_H #include <stdbool.h> /* use whatever the C compiler decides bool really is */ #define NCURSES_BOOL bool #else /* there is no predefined bool - use our own */ #undef bool #define bool NCURSES_BOOL #endif #endif /* !__cplusplus, etc. */ #ifdef __cplusplus extern "C" { #define NCURSES_CAST(type,value) static_cast<type>(value) #else #define NCURSES_CAST(type,value) (type)(value) #endif #define NCURSES_OK_ADDR(p) (0 != NCURSES_CAST(const void *, (p))) /* * X/Open attributes. In the ncurses implementation, they are identical to the * A_ attributes. */ #define WA_ATTRIBUTES A_ATTRIBUTES #define WA_NORMAL A_NORMAL #define WA_STANDOUT A_STANDOUT #define WA_UNDERLINE A_UNDERLINE #define WA_REVERSE A_REVERSE #define WA_BLINK A_BLINK #define WA_DIM A_DIM #define WA_BOLD A_BOLD #define WA_ALTCHARSET A_ALTCHARSET #define WA_INVIS A_INVIS #define WA_PROTECT A_PROTECT #define WA_HORIZONTAL A_HORIZONTAL #define WA_LEFT A_LEFT #define WA_LOW A_LOW #define WA_RIGHT A_RIGHT #define WA_TOP A_TOP #define WA_VERTICAL A_VERTICAL #if 1 #define WA_ITALIC A_ITALIC /* ncurses extension */ #endif /* colors */ #define COLOR_BLACK 0 #define COLOR_RED 1 #define COLOR_GREEN 2 #define COLOR_YELLOW 3 #define COLOR_BLUE 4 #define COLOR_MAGENTA 5 #define COLOR_CYAN 6 #define COLOR_WHITE 7 /* line graphics */ #if 0 || NCURSES_REENTRANT NCURSES_WRAPPED_VAR(chtype*, acs_map); #define acs_map NCURSES_PUBLIC_VAR(acs_map()) #else extern NCURSES_EXPORT_VAR(chtype) acs_map[]; #endif #define NCURSES_ACS(c) (acs_map[NCURSES_CAST(unsigned char,(c))]) /* VT100 symbols begin here */ #define ACS_ULCORNER NCURSES_ACS('l') /* upper left corner */ #define ACS_LLCORNER NCURSES_ACS('m') /* lower left corner */ #define ACS_URCORNER NCURSES_ACS('k') /* upper right corner */ #define ACS_LRCORNER NCURSES_ACS('j') /* lower right corner */ #define ACS_LTEE NCURSES_ACS('t') /* tee pointing right */ #define ACS_RTEE NCURSES_ACS('u') /* tee pointing left */ #define ACS_BTEE NCURSES_ACS('v') /* tee pointing up */ #define ACS_TTEE NCURSES_ACS('w') /* tee pointing down */ #define ACS_HLINE NCURSES_ACS('q') /* horizontal line */ #define ACS_VLINE NCURSES_ACS('x') /* vertical line */ #define ACS_PLUS NCURSES_ACS('n') /* large plus or crossover */ #define ACS_S1 NCURSES_ACS('o') /* scan line 1 */ #define ACS_S9 NCURSES_ACS('s') /* scan line 9 */ #define ACS_DIAMOND NCURSES_ACS('`') /* diamond */ #define ACS_CKBOARD NCURSES_ACS('a') /* checker board (stipple) */ #define ACS_DEGREE NCURSES_ACS('f') /* degree symbol */ #define ACS_PLMINUS NCURSES_ACS('g') /* plus/minus */ #define ACS_BULLET NCURSES_ACS('~') /* bullet */ /* Teletype 5410v1 symbols begin here */ #define ACS_LARROW NCURSES_ACS(',') /* arrow pointing left */ #define ACS_RARROW NCURSES_ACS('+') /* arrow pointing right */ #define ACS_DARROW NCURSES_ACS('.') /* arrow pointing down */ #define ACS_UARROW NCURSES_ACS('-') /* arrow pointing up */ #define ACS_BOARD NCURSES_ACS('h') /* board of squares */ #define ACS_LANTERN NCURSES_ACS('i') /* lantern symbol */ #define ACS_BLOCK NCURSES_ACS('0') /* solid square block */ /* * These aren't documented, but a lot of System Vs have them anyway * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings). * The ACS_names may not match AT&T's, our source didn't know them. */ #define ACS_S3 NCURSES_ACS('p') /* scan line 3 */ #define ACS_S7 NCURSES_ACS('r') /* scan line 7 */ #define ACS_LEQUAL NCURSES_ACS('y') /* less/equal */ #define ACS_GEQUAL NCURSES_ACS('z') /* greater/equal */ #define ACS_PI NCURSES_ACS('{') /* Pi */ #define ACS_NEQUAL NCURSES_ACS('|') /* not equal */ #define ACS_STERLING NCURSES_ACS('}') /* UK pound sign */ /* * Line drawing ACS names are of the form ACS_trbl, where t is the top, r * is the right, b is the bottom, and l is the left. t, r, b, and l might * be B (blank), S (single), D (double), or T (thick). The subset defined * here only uses B and S. */ #define ACS_BSSB ACS_ULCORNER #define ACS_SSBB ACS_LLCORNER #define ACS_BBSS ACS_URCORNER #define ACS_SBBS ACS_LRCORNER #define ACS_SBSS ACS_RTEE #define ACS_SSSB ACS_LTEE #define ACS_SSBS ACS_BTEE #define ACS_BSSS ACS_TTEE #define ACS_BSBS ACS_HLINE #define ACS_SBSB ACS_VLINE #define ACS_SSSS ACS_PLUS #undef ERR #define ERR (-1) #undef OK #define OK (0) /* values for the _flags member */ #define _SUBWIN 0x01 /* is this a sub-window? */ #define _ENDLINE 0x02 /* is the window flush right? */ #define _FULLWIN 0x04 /* is the window full-screen? */ #define _SCROLLWIN 0x08 /* bottom edge is at screen bottom? */ #define _ISPAD 0x10 /* is this window a pad? */ #define _HASMOVED 0x20 /* has cursor moved since last refresh? */ #define _WRAPPED 0x40 /* cursor was just wrappped */ /* * this value is used in the firstchar and lastchar fields to mark * unchanged lines */ #define _NOCHANGE -1 /* * this value is used in the oldindex field to mark lines created by insertions * and scrolls. */ #define _NEWINDEX -1 typedef struct screen SCREEN; typedef struct _win_st WINDOW; typedef chtype attr_t; /* ...must be at least as wide as chtype */ #if NCURSES_WIDECHAR #if 0 #ifdef mblen /* libutf8.h defines it w/o undefining first */ #undef mblen #endif #include <libutf8.h> #endif #if 1 #include <wchar.h> /* ...to get mbstate_t, etc. */ #endif #if 0 typedef unsigned short wchar_t1; #endif #if 0 typedef unsigned int wint_t1; #endif /* * cchar_t stores an array of CCHARW_MAX wide characters. The first is * normally a spacing character. The others are non-spacing. If those * (spacing and nonspacing) do not fill the array, a null L'\0' follows. * Otherwise, a null is assumed to follow when extracting via getcchar(). */ #define CCHARW_MAX 5 typedef struct { attr_t attr; wchar_t chars[CCHARW_MAX]; #if 1 #undef NCURSES_EXT_COLORS #define NCURSES_EXT_COLORS 20210508 int ext_color; /* color pair, must be more than 16-bits */ #endif } cchar_t; #endif /* NCURSES_WIDECHAR */ #if !NCURSES_OPAQUE struct ldat; struct _win_st { NCURSES_SIZE_T _cury, _curx; /* current cursor position */ /* window location and size */ NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */ NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */ short _flags; /* window state flags */ /* attribute tracking */ attr_t _attrs; /* current attribute for non-space character */ chtype _bkgd; /* current background char/attribute pair */ /* option values set by user */ bool _notimeout; /* no time out on function-key entry? */ bool _clear; /* consider all data in the window invalid? */ bool _leaveok; /* OK to not reset cursor on exit? */ bool _scroll; /* OK to scroll this window? */ bool _idlok; /* OK to use insert/delete line? */ bool _idcok; /* OK to use insert/delete char? */ bool _immed; /* window in immed mode? (not yet used) */ bool _sync; /* window in sync mode? */ bool _use_keypad; /* process function keys into KEY_ symbols? */ int _delay; /* 0 = nodelay, <0 = blocking, >0 = delay */ struct ldat *_line; /* the actual line data */ /* global screen state */ NCURSES_SIZE_T _regtop; /* top line of scrolling region */ NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */ /* these are used only if this is a sub-window */ int _parx; /* x coordinate of this window in parent */ int _pary; /* y coordinate of this window in parent */ WINDOW *_parent; /* pointer to parent if a sub-window */ /* these are used only if this is a pad */ struct pdat { NCURSES_SIZE_T _pad_y, _pad_x; NCURSES_SIZE_T _pad_top, _pad_left; NCURSES_SIZE_T _pad_bottom, _pad_right; } _pad; NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */ #if NCURSES_WIDECHAR cchar_t _bkgrnd; /* current background char/attribute pair */ #if 1 int _color; /* current color-pair for non-space character */ #endif #endif }; #endif /* NCURSES_OPAQUE */ /* * GCC (and some other compilers) define '__attribute__'; we're using this * macro to alert the compiler to flag inconsistencies in printf/scanf-like * function calls. Just in case '__attribute__' isn't defined, make a dummy. * Old versions of G++ do not accept it anyway, at least not consistently with * GCC. */ #if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__)) #define __attribute__(p) /* nothing */ #endif /* * We cannot define these in ncurses_cfg.h, since they require parameters to be * passed (that is non-portable). If you happen to be using gcc with warnings * enabled, define * GCC_PRINTF * GCC_SCANF * to improve checking of calls to printw(), etc. */ #ifndef GCC_PRINTFLIKE #if defined(GCC_PRINTF) && !defined(printf) #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) #else #define GCC_PRINTFLIKE(fmt,var) /*nothing*/ #endif #endif #ifndef GCC_SCANFLIKE #if defined(GCC_SCANF) && !defined(scanf) #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) #else #define GCC_SCANFLIKE(fmt,var) /*nothing*/ #endif #endif #ifndef GCC_NORETURN #define GCC_NORETURN /* nothing */ #endif #ifndef GCC_UNUSED #define GCC_UNUSED /* nothing */ #endif #undef GCC_DEPRECATED #if (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)) && !defined(NCURSES_INTERNALS) #define GCC_DEPRECATED(msg) __attribute__((deprecated)) #else #define GCC_DEPRECATED(msg) /* nothing */ #endif /* * Curses uses a helper function. Define our type for this to simplify * extending it for the sp-funcs feature. */ typedef int (*NCURSES_OUTC)(int); /* * Function prototypes. This is the complete X/Open Curses list of required * functions. Those marked `generated' will have sources generated from the * macro definitions later in this file, in order to satisfy XPG4.2 * requirements. */ extern NCURSES_EXPORT(int) addch (const chtype); /* generated */ extern NCURSES_EXPORT(int) addchnstr (const chtype *, int); /* generated */ extern NCURSES_EXPORT(int) addchstr (const chtype *); /* generated */ extern NCURSES_EXPORT(int) addnstr (const char *, int); /* generated */ extern NCURSES_EXPORT(int) addstr (const char *); /* generated */ extern NCURSES_EXPORT(int) attroff (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attron (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attr_get (attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ extern NCURSES_EXPORT(int) attr_off (attr_t, void *); /* generated */ extern NCURSES_EXPORT(int) attr_on (attr_t, void *); /* generated */ extern NCURSES_EXPORT(int) attr_set (attr_t, NCURSES_PAIRS_T, void *); /* generated */ extern NCURSES_EXPORT(int) baudrate (void); /* implemented */ extern NCURSES_EXPORT(int) beep (void); /* implemented */ extern NCURSES_EXPORT(int) bkgd (chtype); /* generated */ extern NCURSES_EXPORT(void) bkgdset (chtype); /* generated */ extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* generated */ extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype); /* generated */ extern NCURSES_EXPORT(bool) can_change_color (void); /* implemented */ extern NCURSES_EXPORT(int) cbreak (void); /* implemented */ extern NCURSES_EXPORT(int) chgat (int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ extern NCURSES_EXPORT(int) clear (void); /* generated */ extern NCURSES_EXPORT(int) clearok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) clrtobot (void); /* generated */ extern NCURSES_EXPORT(int) clrtoeol (void); /* generated */ extern NCURSES_EXPORT(int) color_content (NCURSES_COLOR_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ extern NCURSES_EXPORT(int) color_set (NCURSES_PAIRS_T,void*); /* generated */ extern NCURSES_EXPORT(int) COLOR_PAIR (int); /* generated */ extern NCURSES_EXPORT(int) copywin (const WINDOW*,WINDOW*,int,int,int,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) curs_set (int); /* implemented */ extern NCURSES_EXPORT(int) def_prog_mode (void); /* implemented */ extern NCURSES_EXPORT(int) def_shell_mode (void); /* implemented */ extern NCURSES_EXPORT(int) delay_output (int); /* implemented */ extern NCURSES_EXPORT(int) delch (void); /* generated */ extern NCURSES_EXPORT(void) delscreen (SCREEN *); /* implemented */ extern NCURSES_EXPORT(int) delwin (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) deleteln (void); /* generated */ extern NCURSES_EXPORT(WINDOW *) derwin (WINDOW *,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) doupdate (void); /* implemented */ extern NCURSES_EXPORT(WINDOW *) dupwin (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) echo (void); /* implemented */ extern NCURSES_EXPORT(int) echochar (const chtype); /* generated */ extern NCURSES_EXPORT(int) erase (void); /* generated */ extern NCURSES_EXPORT(int) endwin (void); /* implemented */ extern NCURSES_EXPORT(char) erasechar (void); /* implemented */ extern NCURSES_EXPORT(void) filter (void); /* implemented */ extern NCURSES_EXPORT(int) flash (void); /* implemented */ extern NCURSES_EXPORT(int) flushinp (void); /* implemented */ extern NCURSES_EXPORT(chtype) getbkgd (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getch (void); /* generated */ extern NCURSES_EXPORT(int) getnstr (char *, int); /* generated */ extern NCURSES_EXPORT(int) getstr (char *); /* generated */ extern NCURSES_EXPORT(WINDOW *) getwin (FILE *); /* implemented */ extern NCURSES_EXPORT(int) halfdelay (int); /* implemented */ extern NCURSES_EXPORT(bool) has_colors (void); /* implemented */ extern NCURSES_EXPORT(bool) has_ic (void); /* implemented */ extern NCURSES_EXPORT(bool) has_il (void); /* implemented */ extern NCURSES_EXPORT(int) hline (chtype, int); /* generated */ extern NCURSES_EXPORT(void) idcok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(int) idlok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(void) immedok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(chtype) inch (void); /* generated */ extern NCURSES_EXPORT(int) inchnstr (chtype *, int); /* generated */ extern NCURSES_EXPORT(int) inchstr (chtype *); /* generated */ extern NCURSES_EXPORT(WINDOW *) initscr (void); /* implemented */ extern NCURSES_EXPORT(int) init_color (NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ extern NCURSES_EXPORT(int) init_pair (NCURSES_PAIRS_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ extern NCURSES_EXPORT(int) innstr (char *, int); /* generated */ extern NCURSES_EXPORT(int) insch (chtype); /* generated */ extern NCURSES_EXPORT(int) insdelln (int); /* generated */ extern NCURSES_EXPORT(int) insertln (void); /* generated */ extern NCURSES_EXPORT(int) insnstr (const char *, int); /* generated */ extern NCURSES_EXPORT(int) insstr (const char *); /* generated */ extern NCURSES_EXPORT(int) instr (char *); /* generated */ extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(bool) isendwin (void); /* implemented */ extern NCURSES_EXPORT(bool) is_linetouched (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(bool) is_wintouched (WINDOW *); /* implemented */ extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int); /* implemented */ extern NCURSES_EXPORT(int) keypad (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(char) killchar (void); /* implemented */ extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(char *) longname (void); /* implemented */ extern NCURSES_EXPORT(int) meta (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) move (int, int); /* generated */ extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype); /* generated */ extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvaddchstr (int, int, const chtype *); /* generated */ extern NCURSES_EXPORT(int) mvaddnstr (int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvaddstr (int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ extern NCURSES_EXPORT(int) mvcur (int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) mvdelch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvderwin (WINDOW *, int, int); /* implemented */ extern NCURSES_EXPORT(int) mvgetch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvgetnstr (int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvgetstr (int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(chtype) mvinch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvinchnstr (int, int, chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvinchstr (int, int, chtype *); /* generated */ extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvinsch (int, int, chtype); /* generated */ extern NCURSES_EXPORT(int) mvinsnstr (int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvinsstr (int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvinstr (int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...) /* implemented */ GCC_PRINTFLIKE(3,4); extern NCURSES_EXPORT(int) mvscanw (int,int, const char *,...) /* implemented */ GCC_SCANFLIKE(3,4); extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype); /* generated */ extern NCURSES_EXPORT(int) mvwaddchnstr (WINDOW *, int, int, const chtype *, int);/* generated */ extern NCURSES_EXPORT(int) mvwaddchstr (WINDOW *, int, int, const chtype *); /* generated */ extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwaddstr (WINDOW *, int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, NCURSES_PAIRS_T, const void *);/* generated */ extern NCURSES_EXPORT(int) mvwdelch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetnstr (WINDOW *, int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) mvwin (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(chtype) mvwinch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwinchnstr (WINDOW *, int, int, chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinchstr (WINDOW *, int, int, chtype *); /* generated */ extern NCURSES_EXPORT(int) mvwinnstr (WINDOW *, int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinsch (WINDOW *, int, int, chtype); /* generated */ extern NCURSES_EXPORT(int) mvwinsnstr (WINDOW *, int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinsstr (WINDOW *, int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...) /* implemented */ GCC_PRINTFLIKE(4,5); extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, const char *,...) /* implemented */ GCC_SCANFLIKE(4,5); extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) napms (int); /* implemented */ extern NCURSES_EXPORT(WINDOW *) newpad (int,int); /* implemented */ extern NCURSES_EXPORT(SCREEN *) newterm (const char *,FILE *,FILE *); /* implemented */ extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) nl (void); /* implemented */ extern NCURSES_EXPORT(int) nocbreak (void); /* implemented */ extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) noecho (void); /* implemented */ extern NCURSES_EXPORT(int) nonl (void); /* implemented */ extern NCURSES_EXPORT(void) noqiflush (void); /* implemented */ extern NCURSES_EXPORT(int) noraw (void); /* implemented */ extern NCURSES_EXPORT(int) notimeout (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) overlay (const WINDOW*,WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) pair_content (NCURSES_PAIRS_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ extern NCURSES_EXPORT(int) PAIR_NUMBER (int); /* generated */ extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) pnoutrefresh (WINDOW*,int,int,int,int,int,int);/* implemented */ extern NCURSES_EXPORT(int) prefresh (WINDOW *,int,int,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) printw (const char *,...) /* implemented */ GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *); /* implemented */ extern NCURSES_EXPORT(void) qiflush (void); /* implemented */ extern NCURSES_EXPORT(int) raw (void); /* implemented */ extern NCURSES_EXPORT(int) redrawwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) refresh (void); /* generated */ extern NCURSES_EXPORT(int) resetty (void); /* implemented */ extern NCURSES_EXPORT(int) reset_prog_mode (void); /* implemented */ extern NCURSES_EXPORT(int) reset_shell_mode (void); /* implemented */ extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int)); /* implemented */ extern NCURSES_EXPORT(int) savetty (void); /* implemented */ extern NCURSES_EXPORT(int) scanw (const char *,...) /* implemented */ GCC_SCANFLIKE(1,2); extern NCURSES_EXPORT(int) scr_dump (const char *); /* implemented */ extern NCURSES_EXPORT(int) scr_init (const char *); /* implemented */ extern NCURSES_EXPORT(int) scrl (int); /* generated */ extern NCURSES_EXPORT(int) scroll (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) scrollok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) scr_restore (const char *); /* implemented */ extern NCURSES_EXPORT(int) scr_set (const char *); /* implemented */ extern NCURSES_EXPORT(int) setscrreg (int,int); /* generated */ extern NCURSES_EXPORT(SCREEN *) set_term (SCREEN *); /* implemented */ extern NCURSES_EXPORT(int) slk_attroff (const chtype); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_off (const attr_t, void *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) slk_attron (const chtype); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_on (attr_t,void*); /* generated:WIDEC */ extern NCURSES_EXPORT(int) slk_attrset (const chtype); /* implemented */ extern NCURSES_EXPORT(attr_t) slk_attr (void); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_set (const attr_t,NCURSES_PAIRS_T,void*); /* implemented */ extern NCURSES_EXPORT(int) slk_clear (void); /* implemented */ extern NCURSES_EXPORT(int) slk_color (NCURSES_PAIRS_T); /* implemented */ extern NCURSES_EXPORT(int) slk_init (int); /* implemented */ extern NCURSES_EXPORT(char *) slk_label (int); /* implemented */ extern NCURSES_EXPORT(int) slk_noutrefresh (void); /* implemented */ extern NCURSES_EXPORT(int) slk_refresh (void); /* implemented */ extern NCURSES_EXPORT(int) slk_restore (void); /* implemented */ extern NCURSES_EXPORT(int) slk_set (int,const char *,int); /* implemented */ extern NCURSES_EXPORT(int) slk_touch (void); /* implemented */ extern NCURSES_EXPORT(int) standout (void); /* generated */ extern NCURSES_EXPORT(int) standend (void); /* generated */ extern NCURSES_EXPORT(int) start_color (void); /* implemented */ extern NCURSES_EXPORT(WINDOW *) subpad (WINDOW *, int, int, int, int); /* implemented */ extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *, int, int, int, int); /* implemented */ extern NCURSES_EXPORT(int) syncok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(chtype) termattrs (void); /* implemented */ extern NCURSES_EXPORT(char *) termname (void); /* implemented */ extern NCURSES_EXPORT(void) timeout (int); /* generated */ extern NCURSES_EXPORT(int) touchline (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) touchwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) typeahead (int); /* implemented */ extern NCURSES_EXPORT(int) ungetch (int); /* implemented */ extern NCURSES_EXPORT(int) untouchwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(void) use_env (bool); /* implemented */ extern NCURSES_EXPORT(void) use_tioctl (bool); /* implemented */ extern NCURSES_EXPORT(int) vidattr (chtype); /* implemented */ extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC); /* implemented */ extern NCURSES_EXPORT(int) vline (chtype, int); /* generated */ extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_printw); /* implemented */ extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list); /* implemented */ extern NCURSES_EXPORT(int) vwscanw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_scanw); /* implemented */ extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, const char *,va_list); /* implemented */ extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int); /* implemented */ extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *); /* generated */ extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int); /* implemented */ extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *); /* generated */ extern NCURSES_EXPORT(int) wattron (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattroff (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattrset (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattr_get (WINDOW *, attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ extern NCURSES_EXPORT(int) wattr_on (WINDOW *, attr_t, void *); /* implemented */ extern NCURSES_EXPORT(int) wattr_off (WINDOW *, attr_t, void *); /* implemented */ extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, NCURSES_PAIRS_T, void *); /* generated */ extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype); /* implemented */ extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype); /* implemented */ extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* implemented */ extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, NCURSES_PAIRS_T, const void *);/* implemented */ extern NCURSES_EXPORT(int) wclear (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wclrtobot (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wclrtoeol (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wcolor_set (WINDOW*,NCURSES_PAIRS_T,void*); /* implemented */ extern NCURSES_EXPORT(void) wcursyncup (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wdelch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wdeleteln (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wechochar (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) werase (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wgetch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int); /* implemented */ extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *); /* generated */ extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int); /* implemented */ extern NCURSES_EXPORT(chtype) winch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) winchnstr (WINDOW *, chtype *, int); /* implemented */ extern NCURSES_EXPORT(int) winchstr (WINDOW *, chtype *); /* generated */ extern NCURSES_EXPORT(int) winnstr (WINDOW *, char *, int); /* implemented */ extern NCURSES_EXPORT(int) winsch (WINDOW *, chtype); /* implemented */ extern NCURSES_EXPORT(int) winsdelln (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) winsertln (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) winsnstr (WINDOW *, const char *,int); /* implemented */ extern NCURSES_EXPORT(int) winsstr (WINDOW *, const char *); /* generated */ extern NCURSES_EXPORT(int) winstr (WINDOW *, char *); /* generated */ extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wprintw (WINDOW *, const char *,...) /* implemented */ GCC_PRINTFLIKE(2,3); extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wrefresh (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wscanw (WINDOW *, const char *,...) /* implemented */ GCC_SCANFLIKE(2,3); extern NCURSES_EXPORT(int) wscrl (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wstandout (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wstandend (WINDOW *); /* generated */ extern NCURSES_EXPORT(void) wsyncdown (WINDOW *); /* implemented */ extern NCURSES_EXPORT(void) wsyncup (WINDOW *); /* implemented */ extern NCURSES_EXPORT(void) wtimeout (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) wtouchln (WINDOW *,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int); /* implemented */ /* * These are also declared in <term.h>: */ extern NCURSES_EXPORT(int) tigetflag (const char *); /* implemented */ extern NCURSES_EXPORT(int) tigetnum (const char *); /* implemented */ extern NCURSES_EXPORT(char *) tigetstr (const char *); /* implemented */ extern NCURSES_EXPORT(int) putp (const char *); /* implemented */ #if NCURSES_TPARM_VARARGS extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */ #else extern NCURSES_EXPORT(char *) tparm (const char *, NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG); /* special */ #endif extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */ /* * These functions are not in X/Open, but we use them in macro definitions: */ extern NCURSES_EXPORT(int) getattrs (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getcurx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getcury (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getbegx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getbegy (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getmaxx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getmaxy (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getparx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getpary (const WINDOW *); /* generated */ /* * vid_attr() was implemented originally based on a draft of X/Open curses. */ #if !NCURSES_WIDECHAR #define vid_attr(a,pair,opts) vidattr(a) #endif /* * These functions are extensions - not in X/Open Curses. */ #if 1 #undef NCURSES_EXT_FUNCS #define NCURSES_EXT_FUNCS 20210508 typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *); typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *); extern NCURSES_EXPORT(bool) is_term_resized (int, int); extern NCURSES_EXPORT(char *) keybound (int, int); extern NCURSES_EXPORT(const char *) curses_version (void); extern NCURSES_EXPORT(int) alloc_pair (int, int); extern NCURSES_EXPORT(int) assume_default_colors (int, int); extern NCURSES_EXPORT(int) define_key (const char *, int); extern NCURSES_EXPORT(int) extended_color_content(int, int *, int *, int *); extern NCURSES_EXPORT(int) extended_pair_content(int, int *, int *); extern NCURSES_EXPORT(int) extended_slk_color(int); extern NCURSES_EXPORT(int) find_pair (int, int); extern NCURSES_EXPORT(int) free_pair (int); extern NCURSES_EXPORT(int) get_escdelay (void); extern NCURSES_EXPORT(int) init_extended_color(int, int, int, int); extern NCURSES_EXPORT(int) init_extended_pair(int, int, int); extern NCURSES_EXPORT(int) key_defined (const char *); extern NCURSES_EXPORT(int) keyok (int, bool); extern NCURSES_EXPORT(void) reset_color_pairs (void); extern NCURSES_EXPORT(int) resize_term (int, int); extern NCURSES_EXPORT(int) resizeterm (int, int); extern NCURSES_EXPORT(int) set_escdelay (int); extern NCURSES_EXPORT(int) set_tabsize (int); extern NCURSES_EXPORT(int) use_default_colors (void); extern NCURSES_EXPORT(int) use_extended_names (bool); extern NCURSES_EXPORT(int) use_legacy_coding (int); extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *); extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *); extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int); extern NCURSES_EXPORT(void) nofilter(void); /* * These extensions provide access to information stored in the WINDOW even * when NCURSES_OPAQUE is set: */ extern NCURSES_EXPORT(WINDOW *) wgetparent (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_cleared (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_idcok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_idlok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_immedok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_keypad (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_leaveok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_nodelay (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_notimeout (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_pad (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_scrollok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_subwin (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_syncok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wgetdelay (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wgetscrreg (const WINDOW *, int *, int *); /* generated */ #else #define curses_version() NCURSES_VERSION #endif /* * Extra extension-functions, which pass a SCREEN pointer rather than using * a global variable SP. */ #if 1 #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 20210508 #define NCURSES_SP_NAME(name) name##_sp /* Define the sp-funcs helper function */ #define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC) typedef int (*NCURSES_SP_OUTC)(SCREEN*, int); extern NCURSES_EXPORT(SCREEN *) new_prescr (void); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(baudrate) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(beep) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(can_change_color) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(cbreak) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(color_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(delay_output) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(doupdate) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(echo) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(endwin) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char) NCURSES_SP_NAME(erasechar) (SCREEN*);/* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(filter) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flash) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flushinp) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(getwin) (SCREEN*, FILE *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(halfdelay) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_colors) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_ic) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_il) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_color) (SCREEN*, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_pair) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(intrflush) (SCREEN*, WINDOW*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(isendwin) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(keyname) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char) NCURSES_SP_NAME(killchar) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mvcur) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newpad) (SCREEN*, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, const char *, FILE *, FILE *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newwin) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nl) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noecho) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nonl) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(noqiflush) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noraw) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(pair_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(qiflush) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(raw) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resetty) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ripoffline) (SCREEN*, int, int (*)(WINDOW *, int)); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(savetty) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_init) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_restore) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_set) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attroff) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attron) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attrset) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(slk_attr) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attr_set) (SCREEN*, const attr_t, NCURSES_PAIRS_T, void*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_clear) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_color) (SCREEN*, NCURSES_PAIRS_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_init) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(slk_label) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_noutrefresh) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_refresh) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_restore) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_set) (SCREEN*, int, const char *, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_touch) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(start_color) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(termattrs) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(termname) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetch) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_env) (SCREEN*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_tioctl) (SCREEN*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ #if 1 extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(alloc_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_color_content) (SCREEN*, int, int *, int *, int *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_pair_content) (SCREEN*, int, int *, int *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_slk_color) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(find_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(free_pair) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_color) (SCREEN*, int, int, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_pair) (SCREEN*, int, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(is_term_resized) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined) (SCREEN*, const char *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */ /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(reset_color_pairs) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resize_term) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resizeterm) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_escdelay) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_tabsize) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_default_colors) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ #endif #else #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 0 #define NCURSES_SP_NAME(name) name #define NCURSES_SP_OUTC NCURSES_OUTC #endif /* attributes */ #define NCURSES_ATTR_SHIFT 8 #define NCURSES_BITS(mask,shift) (NCURSES_CAST(chtype,(mask)) << ((shift) + NCURSES_ATTR_SHIFT)) #define A_NORMAL (1U - 1U) #define A_ATTRIBUTES NCURSES_BITS(~(1U - 1U),0) #define A_CHARTEXT (NCURSES_BITS(1U,0) - 1U) #define A_COLOR NCURSES_BITS(((1U) << 8) - 1U,0) #define A_STANDOUT NCURSES_BITS(1U,8) #define A_UNDERLINE NCURSES_BITS(1U,9) #define A_REVERSE NCURSES_BITS(1U,10) #define A_BLINK NCURSES_BITS(1U,11) #define A_DIM NCURSES_BITS(1U,12) #define A_BOLD NCURSES_BITS(1U,13) #define A_ALTCHARSET NCURSES_BITS(1U,14) #define A_INVIS NCURSES_BITS(1U,15) #define A_PROTECT NCURSES_BITS(1U,16) #define A_HORIZONTAL NCURSES_BITS(1U,17) #define A_LEFT NCURSES_BITS(1U,18) #define A_LOW NCURSES_BITS(1U,19) #define A_RIGHT NCURSES_BITS(1U,20) #define A_TOP NCURSES_BITS(1U,21) #define A_VERTICAL NCURSES_BITS(1U,22) #if 1 #define A_ITALIC NCURSES_BITS(1U,23) /* ncurses extension */ #endif /* * Most of the pseudo functions are macros that either provide compatibility * with older versions of curses, or provide inline functionality to improve * performance. */ /* * These pseudo functions are always implemented as macros: */ #define getyx(win,y,x) (y = getcury(win), x = getcurx(win)) #define getbegyx(win,y,x) (y = getbegy(win), x = getbegx(win)) #define getmaxyx(win,y,x) (y = getmaxy(win), x = getmaxx(win)) #define getparyx(win,y,x) (y = getpary(win), x = getparx(win)) #define getsyx(y,x) do { if (newscr) { \ if (is_leaveok(newscr)) \ (y) = (x) = -1; \ else \ getyx(newscr,(y), (x)); \ } \ } while(0) #define setsyx(y,x) do { if (newscr) { \ if ((y) == -1 && (x) == -1) \ leaveok(newscr, TRUE); \ else { \ leaveok(newscr, FALSE); \ wmove(newscr, (y), (x)); \ } \ } \ } while(0) #ifndef NCURSES_NOMACROS /* * These miscellaneous pseudo functions are provided for compatibility: */ #define wgetstr(w, s) wgetnstr(w, s, -1) #define getnstr(s, n) wgetnstr(stdscr, s, (n)) #define setterm(term) setupterm(term, 1, (int *)0) #define fixterm() reset_prog_mode() #define resetterm() reset_shell_mode() #define saveterm() def_prog_mode() #define crmode() cbreak() #define nocrmode() nocbreak() #define gettmode() /* It seems older SYSV curses versions define these */ #if !NCURSES_OPAQUE #define getattrs(win) NCURSES_CAST(int, NCURSES_OK_ADDR(win) ? (win)->_attrs : A_NORMAL) #define getcurx(win) (NCURSES_OK_ADDR(win) ? (win)->_curx : ERR) #define getcury(win) (NCURSES_OK_ADDR(win) ? (win)->_cury : ERR) #define getbegx(win) (NCURSES_OK_ADDR(win) ? (win)->_begx : ERR) #define getbegy(win) (NCURSES_OK_ADDR(win) ? (win)->_begy : ERR) #define getmaxx(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxx + 1) : ERR) #define getmaxy(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxy + 1) : ERR) #define getparx(win) (NCURSES_OK_ADDR(win) ? (win)->_parx : ERR) #define getpary(win) (NCURSES_OK_ADDR(win) ? (win)->_pary : ERR) #endif /* NCURSES_OPAQUE */ #define wstandout(win) (wattrset(win,A_STANDOUT)) #define wstandend(win) (wattrset(win,A_NORMAL)) #define wattron(win,at) wattr_on(win, NCURSES_CAST(attr_t, at), NULL) #define wattroff(win,at) wattr_off(win, NCURSES_CAST(attr_t, at), NULL) #if !NCURSES_OPAQUE #if NCURSES_WATTR_MACROS #if NCURSES_WIDECHAR && 1 #define wattrset(win,at) \ (NCURSES_OK_ADDR(win) \ ? ((win)->_color = NCURSES_CAST(int, PAIR_NUMBER(at)), \ (win)->_attrs = NCURSES_CAST(attr_t, at), \ OK) \ : ERR) #else #define wattrset(win,at) \ (NCURSES_OK_ADDR(win) \ ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \ OK) \ : ERR) #endif #endif /* NCURSES_WATTR_MACROS */ #endif /* NCURSES_OPAQUE */ #define scroll(win) wscrl(win,1) #define touchwin(win) wtouchln((win), 0, getmaxy(win), 1) #define touchline(win, s, c) wtouchln((win), s, c, 1) #define untouchwin(win) wtouchln((win), 0, getmaxy(win), 0) #define box(win, v, h) wborder(win, v, v, h, h, 0, 0, 0, 0) #define border(ls, rs, ts, bs, tl, tr, bl, br) wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br) #define hline(ch, n) whline(stdscr, ch, (n)) #define vline(ch, n) wvline(stdscr, ch, (n)) #define winstr(w, s) winnstr(w, s, -1) #define winchstr(w, s) winchnstr(w, s, -1) #define winsstr(w, s) winsnstr(w, s, -1) #if !NCURSES_OPAQUE #define redrawwin(win) wredrawln(win, 0, (NCURSES_OK_ADDR(win) ? (win)->_maxy+1 : -1)) #endif /* NCURSES_OPAQUE */ #define waddstr(win,str) waddnstr(win,str,-1) #define waddchstr(win,str) waddchnstr(win,str,-1) /* * These apply to the first 256 color pairs. */ #define COLOR_PAIR(n) (NCURSES_BITS((n), 0) & A_COLOR) #define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & A_COLOR) >> NCURSES_ATTR_SHIFT))) /* * pseudo functions for standard screen */ #define addch(ch) waddch(stdscr,(ch)) #define addchnstr(str,n) waddchnstr(stdscr,(str),(n)) #define addchstr(str) waddchstr(stdscr,(str)) #define addnstr(str,n) waddnstr(stdscr,(str),(n)) #define addstr(str) waddnstr(stdscr,(str),-1) #define attr_get(ap,cp,o) wattr_get(stdscr,(ap),(cp),(o)) #define attr_off(a,o) wattr_off(stdscr,(a),(o)) #define attr_on(a,o) wattr_on(stdscr,(a),(o)) #define attr_set(a,c,o) wattr_set(stdscr,(a),(c),(o)) #define attroff(at) wattroff(stdscr,(at)) #define attron(at) wattron(stdscr,(at)) #define attrset(at) wattrset(stdscr,(at)) #define bkgd(ch) wbkgd(stdscr,(ch)) #define bkgdset(ch) wbkgdset(stdscr,(ch)) #define chgat(n,a,c,o) wchgat(stdscr,(n),(a),(c),(o)) #define clear() wclear(stdscr) #define clrtobot() wclrtobot(stdscr) #define clrtoeol() wclrtoeol(stdscr) #define color_set(c,o) wcolor_set(stdscr,(c),(o)) #define delch() wdelch(stdscr) #define deleteln() winsdelln(stdscr,-1) #define echochar(c) wechochar(stdscr,(c)) #define erase() werase(stdscr) #define getch() wgetch(stdscr) #define getstr(str) wgetstr(stdscr,(str)) #define inch() winch(stdscr) #define inchnstr(s,n) winchnstr(stdscr,(s),(n)) #define inchstr(s) winchstr(stdscr,(s)) #define innstr(s,n) winnstr(stdscr,(s),(n)) #define insch(c) winsch(stdscr,(c)) #define insdelln(n) winsdelln(stdscr,(n)) #define insertln() winsdelln(stdscr,1) #define insnstr(s,n) winsnstr(stdscr,(s),(n)) #define insstr(s) winsstr(stdscr,(s)) #define instr(s) winstr(stdscr,(s)) #define move(y,x) wmove(stdscr,(y),(x)) #define refresh() wrefresh(stdscr) #define scrl(n) wscrl(stdscr,(n)) #define setscrreg(t,b) wsetscrreg(stdscr,(t),(b)) #define standend() wstandend(stdscr) #define standout() wstandout(stdscr) #define timeout(delay) wtimeout(stdscr,(delay)) #define wdeleteln(win) winsdelln(win,-1) #define winsertln(win) winsdelln(win,1) /* * mv functions */ #define mvwaddch(win,y,x,ch) (wmove((win),(y),(x)) == ERR ? ERR : waddch((win),(ch))) #define mvwaddchnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),(n))) #define mvwaddchstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),-1)) #define mvwaddnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),(n))) #define mvwaddstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),-1)) #define mvwchgat(win,y,x,n,a,c,o) (wmove((win),(y),(x)) == ERR ? ERR : wchgat((win),(n),(a),(c),(o))) #define mvwdelch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wdelch(win)) #define mvwgetch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wgetch(win)) #define mvwgetnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : wgetnstr((win),(str),(n))) #define mvwgetstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : wgetstr((win),(str))) #define mvwhline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : whline((win),(c),(n))) #define mvwinch(win,y,x) (wmove((win),(y),(x)) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win)) #define mvwinchnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winchnstr((win),(s),(n))) #define mvwinchstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winchstr((win),(s))) #define mvwinnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winnstr((win),(s),(n))) #define mvwinsch(win,y,x,c) (wmove((win),(y),(x)) == ERR ? ERR : winsch((win),(c))) #define mvwinsnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winsnstr((win),(s),(n))) #define mvwinsstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winsstr((win),(s))) #define mvwinstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winstr((win),(s))) #define mvwvline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : wvline((win),(c),(n))) #define mvaddch(y,x,ch) mvwaddch(stdscr,(y),(x),(ch)) #define mvaddchnstr(y,x,str,n) mvwaddchnstr(stdscr,(y),(x),(str),(n)) #define mvaddchstr(y,x,str) mvwaddchstr(stdscr,(y),(x),(str)) #define mvaddnstr(y,x,str,n) mvwaddnstr(stdscr,(y),(x),(str),(n)) #define mvaddstr(y,x,str) mvwaddstr(stdscr,(y),(x),(str)) #define mvchgat(y,x,n,a,c,o) mvwchgat(stdscr,(y),(x),(n),(a),(c),(o)) #define mvdelch(y,x) mvwdelch(stdscr,(y),(x)) #define mvgetch(y,x) mvwgetch(stdscr,(y),(x)) #define mvgetnstr(y,x,str,n) mvwgetnstr(stdscr,(y),(x),(str),(n)) #define mvgetstr(y,x,str) mvwgetstr(stdscr,(y),(x),(str)) #define mvhline(y,x,c,n) mvwhline(stdscr,(y),(x),(c),(n)) #define mvinch(y,x) mvwinch(stdscr,(y),(x)) #define mvinchnstr(y,x,s,n) mvwinchnstr(stdscr,(y),(x),(s),(n)) #define mvinchstr(y,x,s) mvwinchstr(stdscr,(y),(x),(s)) #define mvinnstr(y,x,s,n) mvwinnstr(stdscr,(y),(x),(s),(n)) #define mvinsch(y,x,c) mvwinsch(stdscr,(y),(x),(c)) #define mvinsnstr(y,x,s,n) mvwinsnstr(stdscr,(y),(x),(s),(n)) #define mvinsstr(y,x,s) mvwinsstr(stdscr,(y),(x),(s)) #define mvinstr(y,x,s) mvwinstr(stdscr,(y),(x),(s)) #define mvvline(y,x,c,n) mvwvline(stdscr,(y),(x),(c),(n)) /* * Some wide-character functions can be implemented without the extensions. */ #if !NCURSES_OPAQUE #define getbkgd(win) (NCURSES_OK_ADDR(win) ? ((win)->_bkgd) : 0) #endif /* NCURSES_OPAQUE */ #define slk_attr_off(a,v) ((v) ? ERR : slk_attroff(a)) #define slk_attr_on(a,v) ((v) ? ERR : slk_attron(a)) #if !NCURSES_OPAQUE #if NCURSES_WATTR_MACROS #if NCURSES_WIDECHAR && 1 #define wattr_set(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)((win)->_attrs = ((a) & ~A_COLOR), \ (win)->_color = (opts) ? *(int *)(opts) : (p)), \ OK) \ : ERR) #define wattr_get(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)(NCURSES_OK_ADDR(a) \ ? (*(a) = (win)->_attrs) \ : OK), \ (void)(NCURSES_OK_ADDR(p) \ ? (*(p) = (NCURSES_PAIRS_T) (win)->_color) \ : OK), \ (void)(NCURSES_OK_ADDR(opts) \ ? (*(int *)(opts) = (win)->_color) \ : OK), \ OK) \ : ERR) #else /* !(NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */ #define wattr_set(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)((win)->_attrs = (((a) & ~A_COLOR) | \ (attr_t)COLOR_PAIR(p))), \ OK) \ : ERR) #define wattr_get(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)(NCURSES_OK_ADDR(a) \ ? (*(a) = (win)->_attrs) \ : OK), \ (void)(NCURSES_OK_ADDR(p) \ ? (*(p) = (NCURSES_PAIRS_T) PAIR_NUMBER((win)->_attrs)) \ : OK), \ OK) \ : ERR) #endif /* (NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */ #endif /* NCURSES_WATTR_MACROS */ #endif /* NCURSES_OPAQUE */ /* * X/Open curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use * varargs.h. It adds new calls vw_printw/vw_scanw, which are supposed to * use POSIX stdarg.h. The ncurses versions of vwprintw/vwscanw already * use stdarg.h, so... */ /* define vw_printw vwprintw */ /* define vw_scanw vwscanw */ /* * Export fallback function for use in C++ binding. */ #if !1 #define vsscanf(a,b,c) _nc_vsscanf(a,b,c) NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list); #endif /* * These macros are extensions - not in X/Open Curses. */ #if 1 #if !NCURSES_OPAQUE #define is_cleared(win) (NCURSES_OK_ADDR(win) ? (win)->_clear : FALSE) #define is_idcok(win) (NCURSES_OK_ADDR(win) ? (win)->_idcok : FALSE) #define is_idlok(win) (NCURSES_OK_ADDR(win) ? (win)->_idlok : FALSE) #define is_immedok(win) (NCURSES_OK_ADDR(win) ? (win)->_immed : FALSE) #define is_keypad(win) (NCURSES_OK_ADDR(win) ? (win)->_use_keypad : FALSE) #define is_leaveok(win) (NCURSES_OK_ADDR(win) ? (win)->_leaveok : FALSE) #define is_nodelay(win) (NCURSES_OK_ADDR(win) ? ((win)->_delay == 0) : FALSE) #define is_notimeout(win) (NCURSES_OK_ADDR(win) ? (win)->_notimeout : FALSE) #define is_pad(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _ISPAD) != 0 : FALSE) #define is_scrollok(win) (NCURSES_OK_ADDR(win) ? (win)->_scroll : FALSE) #define is_subwin(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE) #define is_syncok(win) (NCURSES_OK_ADDR(win) ? (win)->_sync : FALSE) #define wgetdelay(win) (NCURSES_OK_ADDR(win) ? (win)->_delay : 0) #define wgetparent(win) (NCURSES_OK_ADDR(win) ? (win)->_parent : 0) #define wgetscrreg(win,t,b) (NCURSES_OK_ADDR(win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR) #endif #endif /* * X/Open says this returns a bool; SVr4 also checked for out-of-range line. * The macro provides compatibility: */ #define is_linetouched(w,l) ((!(w) || ((l) > getmaxy(w)) || ((l) < 0)) ? ERR : (is_linetouched)((w),(l))) #endif /* NCURSES_NOMACROS */ /* * Public variables. * * Notes: * a. ESCDELAY was an undocumented feature under AIX curses. * It gives the ESC expire time in milliseconds. * b. ttytype is needed for backward compatibility */ #if NCURSES_REENTRANT NCURSES_WRAPPED_VAR(WINDOW *, curscr); NCURSES_WRAPPED_VAR(WINDOW *, newscr); NCURSES_WRAPPED_VAR(WINDOW *, stdscr); NCURSES_WRAPPED_VAR(char *, ttytype); NCURSES_WRAPPED_VAR(int, COLORS); NCURSES_WRAPPED_VAR(int, COLOR_PAIRS); NCURSES_WRAPPED_VAR(int, COLS); NCURSES_WRAPPED_VAR(int, ESCDELAY); NCURSES_WRAPPED_VAR(int, LINES); NCURSES_WRAPPED_VAR(int, TABSIZE); #define curscr NCURSES_PUBLIC_VAR(curscr()) #define newscr NCURSES_PUBLIC_VAR(newscr()) #define stdscr NCURSES_PUBLIC_VAR(stdscr()) #define ttytype NCURSES_PUBLIC_VAR(ttytype()) #define COLORS NCURSES_PUBLIC_VAR(COLORS()) #define COLOR_PAIRS NCURSES_PUBLIC_VAR(COLOR_PAIRS()) #define COLS NCURSES_PUBLIC_VAR(COLS()) #define ESCDELAY NCURSES_PUBLIC_VAR(ESCDELAY()) #define LINES NCURSES_PUBLIC_VAR(LINES()) #define TABSIZE NCURSES_PUBLIC_VAR(TABSIZE()) #else extern NCURSES_EXPORT_VAR(WINDOW *) curscr; extern NCURSES_EXPORT_VAR(WINDOW *) newscr; extern NCURSES_EXPORT_VAR(WINDOW *) stdscr; extern NCURSES_EXPORT_VAR(char) ttytype[]; extern NCURSES_EXPORT_VAR(int) COLORS; extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS; extern NCURSES_EXPORT_VAR(int) COLS; extern NCURSES_EXPORT_VAR(int) ESCDELAY; extern NCURSES_EXPORT_VAR(int) LINES; extern NCURSES_EXPORT_VAR(int) TABSIZE; #endif /* * Pseudo-character tokens outside ASCII range. The curses wgetch() function * will return any given one of these only if the corresponding k- capability * is defined in your terminal's terminfo entry. * * Some keys (KEY_A1, etc) are arranged like this: * a1 up a3 * left b2 right * c1 down c3 * * A few key codes do not depend upon the terminfo entry. */ #define KEY_CODE_YES 0400 /* A wchar_t contains a key code */ #define KEY_MIN 0401 /* Minimum curses key */ #define KEY_BREAK 0401 /* Break key (unreliable) */ #define KEY_SRESET 0530 /* Soft (partial) reset (unreliable) */ #define KEY_RESET 0531 /* Reset or hard reset (unreliable) */ /* * These definitions were generated by ./MKkey_defs.sh ../../include/Caps ../../include/Caps-ncurses */ #define KEY_DOWN 0402 /* down-arrow key */ #define KEY_UP 0403 /* up-arrow key */ #define KEY_LEFT 0404 /* left-arrow key */ #define KEY_RIGHT 0405 /* right-arrow key */ #define KEY_HOME 0406 /* home key */ #define KEY_BACKSPACE 0407 /* backspace key */ #define KEY_F0 0410 /* Function keys. Space for 64 */ #define KEY_F(n) (KEY_F0+(n)) /* Value of function key n */ #define KEY_DL 0510 /* delete-line key */ #define KEY_IL 0511 /* insert-line key */ #define KEY_DC 0512 /* delete-character key */ #define KEY_IC 0513 /* insert-character key */ #define KEY_EIC 0514 /* sent by rmir or smir in insert mode */ #define KEY_CLEAR 0515 /* clear-screen or erase key */ #define KEY_EOS 0516 /* clear-to-end-of-screen key */ #define KEY_EOL 0517 /* clear-to-end-of-line key */ #define KEY_SF 0520 /* scroll-forward key */ #define KEY_SR 0521 /* scroll-backward key */ #define KEY_NPAGE 0522 /* next-page key */ #define KEY_PPAGE 0523 /* previous-page key */ #define KEY_STAB 0524 /* set-tab key */ #define KEY_CTAB 0525 /* clear-tab key */ #define KEY_CATAB 0526 /* clear-all-tabs key */ #define KEY_ENTER 0527 /* enter/send key */ #define KEY_PRINT 0532 /* print key */ #define KEY_LL 0533 /* lower-left key (home down) */ #define KEY_A1 0534 /* upper left of keypad */ #define KEY_A3 0535 /* upper right of keypad */ #define KEY_B2 0536 /* center of keypad */ #define KEY_C1 0537 /* lower left of keypad */ #define KEY_C3 0540 /* lower right of keypad */ #define KEY_BTAB 0541 /* back-tab key */ #define KEY_BEG 0542 /* begin key */ #define KEY_CANCEL 0543 /* cancel key */ #define KEY_CLOSE 0544 /* close key */ #define KEY_COMMAND 0545 /* command key */ #define KEY_COPY 0546 /* copy key */ #define KEY_CREATE 0547 /* create key */ #define KEY_END 0550 /* end key */ #define KEY_EXIT 0551 /* exit key */ #define KEY_FIND 0552 /* find key */ #define KEY_HELP 0553 /* help key */ #define KEY_MARK 0554 /* mark key */ #define KEY_MESSAGE 0555 /* message key */ #define KEY_MOVE 0556 /* move key */ #define KEY_NEXT 0557 /* next key */ #define KEY_OPEN 0560 /* open key */ #define KEY_OPTIONS 0561 /* options key */ #define KEY_PREVIOUS 0562 /* previous key */ #define KEY_REDO 0563 /* redo key */ #define KEY_REFERENCE 0564 /* reference key */ #define KEY_REFRESH 0565 /* refresh key */ #define KEY_REPLACE 0566 /* replace key */ #define KEY_RESTART 0567 /* restart key */ #define KEY_RESUME 0570 /* resume key */ #define KEY_SAVE 0571 /* save key */ #define KEY_SBEG 0572 /* shifted begin key */ #define KEY_SCANCEL 0573 /* shifted cancel key */ #define KEY_SCOMMAND 0574 /* shifted command key */ #define KEY_SCOPY 0575 /* shifted copy key */ #define KEY_SCREATE 0576 /* shifted create key */ #define KEY_SDC 0577 /* shifted delete-character key */ #define KEY_SDL 0600 /* shifted delete-line key */ #define KEY_SELECT 0601 /* select key */ #define KEY_SEND 0602 /* shifted end key */ #define KEY_SEOL 0603 /* shifted clear-to-end-of-line key */ #define KEY_SEXIT 0604 /* shifted exit key */ #define KEY_SFIND 0605 /* shifted find key */ #define KEY_SHELP 0606 /* shifted help key */ #define KEY_SHOME 0607 /* shifted home key */ #define KEY_SIC 0610 /* shifted insert-character key */ #define KEY_SLEFT 0611 /* shifted left-arrow key */ #define KEY_SMESSAGE 0612 /* shifted message key */ #define KEY_SMOVE 0613 /* shifted move key */ #define KEY_SNEXT 0614 /* shifted next key */ #define KEY_SOPTIONS 0615 /* shifted options key */ #define KEY_SPREVIOUS 0616 /* shifted previous key */ #define KEY_SPRINT 0617 /* shifted print key */ #define KEY_SREDO 0620 /* shifted redo key */ #define KEY_SREPLACE 0621 /* shifted replace key */ #define KEY_SRIGHT 0622 /* shifted right-arrow key */ #define KEY_SRSUME 0623 /* shifted resume key */ #define KEY_SSAVE 0624 /* shifted save key */ #define KEY_SSUSPEND 0625 /* shifted suspend key */ #define KEY_SUNDO 0626 /* shifted undo key */ #define KEY_SUSPEND 0627 /* suspend key */ #define KEY_UNDO 0630 /* undo key */ #define KEY_MOUSE 0631 /* Mouse event has occurred */ #ifdef NCURSES_EXT_FUNCS #define KEY_RESIZE 0632 /* Terminal resize event */ #endif #define KEY_MAX 0777 /* Maximum key value is 0632 */ /* $Id: curses.wide,v 1.50 2017/03/26 16:05:21 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in * (see that file for the relevant copyright). */ #define _XOPEN_CURSES 1 #if NCURSES_WIDECHAR extern NCURSES_EXPORT_VAR(cchar_t *) _nc_wacs; #define NCURSES_WACS(c) (&_nc_wacs[NCURSES_CAST(unsigned char,(c))]) #define WACS_BSSB NCURSES_WACS('l') #define WACS_SSBB NCURSES_WACS('m') #define WACS_BBSS NCURSES_WACS('k') #define WACS_SBBS NCURSES_WACS('j') #define WACS_SBSS NCURSES_WACS('u') #define WACS_SSSB NCURSES_WACS('t') #define WACS_SSBS NCURSES_WACS('v') #define WACS_BSSS NCURSES_WACS('w') #define WACS_BSBS NCURSES_WACS('q') #define WACS_SBSB NCURSES_WACS('x') #define WACS_SSSS NCURSES_WACS('n') #define WACS_ULCORNER WACS_BSSB #define WACS_LLCORNER WACS_SSBB #define WACS_URCORNER WACS_BBSS #define WACS_LRCORNER WACS_SBBS #define WACS_RTEE WACS_SBSS #define WACS_LTEE WACS_SSSB #define WACS_BTEE WACS_SSBS #define WACS_TTEE WACS_BSSS #define WACS_HLINE WACS_BSBS #define WACS_VLINE WACS_SBSB #define WACS_PLUS WACS_SSSS #define WACS_S1 NCURSES_WACS('o') /* scan line 1 */ #define WACS_S9 NCURSES_WACS('s') /* scan line 9 */ #define WACS_DIAMOND NCURSES_WACS('`') /* diamond */ #define WACS_CKBOARD NCURSES_WACS('a') /* checker board */ #define WACS_DEGREE NCURSES_WACS('f') /* degree symbol */ #define WACS_PLMINUS NCURSES_WACS('g') /* plus/minus */ #define WACS_BULLET NCURSES_WACS('~') /* bullet */ /* Teletype 5410v1 symbols */ #define WACS_LARROW NCURSES_WACS(',') /* arrow left */ #define WACS_RARROW NCURSES_WACS('+') /* arrow right */ #define WACS_DARROW NCURSES_WACS('.') /* arrow down */ #define WACS_UARROW NCURSES_WACS('-') /* arrow up */ #define WACS_BOARD NCURSES_WACS('h') /* board of squares */ #define WACS_LANTERN NCURSES_WACS('i') /* lantern symbol */ #define WACS_BLOCK NCURSES_WACS('0') /* solid square block */ /* ncurses extensions */ #define WACS_S3 NCURSES_WACS('p') /* scan line 3 */ #define WACS_S7 NCURSES_WACS('r') /* scan line 7 */ #define WACS_LEQUAL NCURSES_WACS('y') /* less/equal */ #define WACS_GEQUAL NCURSES_WACS('z') /* greater/equal */ #define WACS_PI NCURSES_WACS('{') /* Pi */ #define WACS_NEQUAL NCURSES_WACS('|') /* not equal */ #define WACS_STERLING NCURSES_WACS('}') /* UK pound sign */ /* double lines */ #define WACS_BDDB NCURSES_WACS('C') #define WACS_DDBB NCURSES_WACS('D') #define WACS_BBDD NCURSES_WACS('B') #define WACS_DBBD NCURSES_WACS('A') #define WACS_DBDD NCURSES_WACS('G') #define WACS_DDDB NCURSES_WACS('F') #define WACS_DDBD NCURSES_WACS('H') #define WACS_BDDD NCURSES_WACS('I') #define WACS_BDBD NCURSES_WACS('R') #define WACS_DBDB NCURSES_WACS('Y') #define WACS_DDDD NCURSES_WACS('E') #define WACS_D_ULCORNER WACS_BDDB #define WACS_D_LLCORNER WACS_DDBB #define WACS_D_URCORNER WACS_BBDD #define WACS_D_LRCORNER WACS_DBBD #define WACS_D_RTEE WACS_DBDD #define WACS_D_LTEE WACS_DDDB #define WACS_D_BTEE WACS_DDBD #define WACS_D_TTEE WACS_BDDD #define WACS_D_HLINE WACS_BDBD #define WACS_D_VLINE WACS_DBDB #define WACS_D_PLUS WACS_DDDD /* thick lines */ #define WACS_BTTB NCURSES_WACS('L') #define WACS_TTBB NCURSES_WACS('M') #define WACS_BBTT NCURSES_WACS('K') #define WACS_TBBT NCURSES_WACS('J') #define WACS_TBTT NCURSES_WACS('U') #define WACS_TTTB NCURSES_WACS('T') #define WACS_TTBT NCURSES_WACS('V') #define WACS_BTTT NCURSES_WACS('W') #define WACS_BTBT NCURSES_WACS('Q') #define WACS_TBTB NCURSES_WACS('X') #define WACS_TTTT NCURSES_WACS('N') #define WACS_T_ULCORNER WACS_BTTB #define WACS_T_LLCORNER WACS_TTBB #define WACS_T_URCORNER WACS_BBTT #define WACS_T_LRCORNER WACS_TBBT #define WACS_T_RTEE WACS_TBTT #define WACS_T_LTEE WACS_TTTB #define WACS_T_BTEE WACS_TTBT #define WACS_T_TTEE WACS_BTTT #define WACS_T_HLINE WACS_BTBT #define WACS_T_VLINE WACS_TBTB #define WACS_T_PLUS WACS_TTTT /* * Function prototypes for wide-character operations. * * "generated" comments should include ":WIDEC" to make the corresponding * functions ifdef'd in lib_gen.c * * "implemented" comments do not need this marker. */ extern NCURSES_EXPORT(int) add_wch (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) add_wchnstr (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) add_wchstr (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) addnwstr (const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) addwstr (const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) bkgrnd (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(void) bkgrndset (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) border_set (const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* generated:WIDEC */ extern NCURSES_EXPORT(int) box_set (WINDOW *, const cchar_t *, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) echo_wchar (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) erasewchar (wchar_t*); /* implemented */ extern NCURSES_EXPORT(int) get_wch (wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) get_wstr (wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) getbkgrnd (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) getcchar (const cchar_t *, wchar_t*, attr_t*, NCURSES_PAIRS_T*, void*); /* implemented */ extern NCURSES_EXPORT(int) getn_wstr (wint_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) hline_set (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wch (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wchnstr (cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wchstr (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) innwstr (wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_nwstr (const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_wch (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_wstr (const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) inwstr (wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(NCURSES_CONST char*) key_name (wchar_t); /* implemented */ extern NCURSES_EXPORT(int) killwchar (wchar_t *); /* implemented */ extern NCURSES_EXPORT(int) mvadd_wch (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvadd_wchnstr (int, int, const cchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvadd_wchstr (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvaddnwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvaddwstr (int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvget_wch (int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvget_wstr (int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvgetn_wstr (int, int, wint_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvhline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wch (int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wchnstr (int, int, cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wchstr (int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvinnwstr (int, int, wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_nwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_wch (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_wstr (int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvinwstr (int, int, wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvvline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wchnstr (WINDOW *, int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wchstr (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwaddnwstr (WINDOW *, int, int, const wchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwaddwstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwget_wch (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwget_wstr (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwgetn_wstr (WINDOW *, int, int, wint_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwhline_set (WINDOW *, int, int, const cchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wch (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wchnstr (WINDOW *, int,int, cchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wchstr (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwinnwstr (WINDOW *, int, int, wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_nwstr (WINDOW *, int,int, const wchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_wstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwinwstr (WINDOW *, int, int, wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwvline_set (WINDOW *, int,int, const cchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) pecho_wchar (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) setcchar (cchar_t *, const wchar_t *, const attr_t, NCURSES_PAIRS_T, const void *); /* implemented */ extern NCURSES_EXPORT(int) slk_wset (int, const wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(attr_t) term_attrs (void); /* implemented */ extern NCURSES_EXPORT(int) unget_wch (const wchar_t); /* implemented */ extern NCURSES_EXPORT(int) vid_attr (attr_t, NCURSES_PAIRS_T, void *); /* implemented */ extern NCURSES_EXPORT(int) vid_puts (attr_t, NCURSES_PAIRS_T, void *, NCURSES_OUTC); /* implemented */ extern NCURSES_EXPORT(int) vline_set (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wadd_wch (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wadd_wchnstr (WINDOW *,const cchar_t *,int); /* implemented */ extern NCURSES_EXPORT(int) wadd_wchstr (WINDOW *,const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) waddnwstr (WINDOW *,const wchar_t *,int); /* implemented */ extern NCURSES_EXPORT(int) waddwstr (WINDOW *,const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wbkgrnd (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(void) wbkgrndset (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wborder_set (WINDOW *,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* implemented */ extern NCURSES_EXPORT(int) wecho_wchar (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wget_wch (WINDOW *, wint_t *); /* implemented */ extern NCURSES_EXPORT(int) wget_wstr (WINDOW *, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wgetbkgrnd (WINDOW *, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wgetn_wstr (WINDOW *, wint_t *, int); /* implemented */ extern NCURSES_EXPORT(int) whline_set (WINDOW *, const cchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) win_wch (WINDOW *, cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) win_wchnstr (WINDOW *, cchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) win_wchstr (WINDOW *, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) winnwstr (WINDOW *, wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) wins_nwstr (WINDOW *, const wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) wins_wch (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wins_wstr (WINDOW *, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) winwstr (WINDOW *, wchar_t *); /* implemented */ extern NCURSES_EXPORT(wchar_t*) wunctrl (cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wvline_set (WINDOW *, const cchar_t *, int); /* implemented */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(term_attrs) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(unget_wch) (SCREEN*, const wchar_t); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_attr) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ #endif #ifndef NCURSES_NOMACROS /* * XSI curses macros for XPG4 conformance. */ #define add_wch(c) wadd_wch(stdscr,(c)) #define add_wchnstr(str,n) wadd_wchnstr(stdscr,(str),(n)) #define add_wchstr(str) wadd_wchstr(stdscr,(str)) #define addnwstr(wstr,n) waddnwstr(stdscr,(wstr),(n)) #define addwstr(wstr) waddwstr(stdscr,(wstr)) #define bkgrnd(c) wbkgrnd(stdscr,(c)) #define bkgrndset(c) wbkgrndset(stdscr,(c)) #define border_set(l,r,t,b,tl,tr,bl,br) wborder_set(stdscr,(l),(r),(t),(b),tl,tr,bl,br) #define box_set(w,v,h) wborder_set((w),(v),(v),(h),(h),0,0,0,0) #define echo_wchar(c) wecho_wchar(stdscr,(c)) #define get_wch(c) wget_wch(stdscr,(c)) #define get_wstr(t) wget_wstr(stdscr,(t)) #define getbkgrnd(wch) wgetbkgrnd(stdscr,(wch)) #define getn_wstr(t,n) wgetn_wstr(stdscr,(t),(n)) #define hline_set(c,n) whline_set(stdscr,(c),(n)) #define in_wch(c) win_wch(stdscr,(c)) #define in_wchnstr(c,n) win_wchnstr(stdscr,(c),(n)) #define in_wchstr(c) win_wchstr(stdscr,(c)) #define innwstr(c,n) winnwstr(stdscr,(c),(n)) #define ins_nwstr(t,n) wins_nwstr(stdscr,(t),(n)) #define ins_wch(c) wins_wch(stdscr,(c)) #define ins_wstr(t) wins_wstr(stdscr,(t)) #define inwstr(c) winwstr(stdscr,(c)) #define vline_set(c,n) wvline_set(stdscr,(c),(n)) #define wadd_wchstr(win,str) wadd_wchnstr((win),(str),-1) #define waddwstr(win,wstr) waddnwstr((win),(wstr),-1) #define wget_wstr(w,t) wgetn_wstr((w),(t),-1) #define win_wchstr(w,c) win_wchnstr((w),(c),-1) #define wins_wstr(w,t) wins_nwstr((w),(t),-1) #if !NCURSES_OPAQUE #define wgetbkgrnd(win,wch) (NCURSES_OK_ADDR(wch) ? ((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK) : ERR) #endif #define mvadd_wch(y,x,c) mvwadd_wch(stdscr,(y),(x),(c)) #define mvadd_wchnstr(y,x,s,n) mvwadd_wchnstr(stdscr,(y),(x),(s),(n)) #define mvadd_wchstr(y,x,s) mvwadd_wchstr(stdscr,(y),(x),(s)) #define mvaddnwstr(y,x,wstr,n) mvwaddnwstr(stdscr,(y),(x),(wstr),(n)) #define mvaddwstr(y,x,wstr) mvwaddwstr(stdscr,(y),(x),(wstr)) #define mvget_wch(y,x,c) mvwget_wch(stdscr,(y),(x),(c)) #define mvget_wstr(y,x,t) mvwget_wstr(stdscr,(y),(x),(t)) #define mvgetn_wstr(y,x,t,n) mvwgetn_wstr(stdscr,(y),(x),(t),(n)) #define mvhline_set(y,x,c,n) mvwhline_set(stdscr,(y),(x),(c),(n)) #define mvin_wch(y,x,c) mvwin_wch(stdscr,(y),(x),(c)) #define mvin_wchnstr(y,x,c,n) mvwin_wchnstr(stdscr,(y),(x),(c),(n)) #define mvin_wchstr(y,x,c) mvwin_wchstr(stdscr,(y),(x),(c)) #define mvinnwstr(y,x,c,n) mvwinnwstr(stdscr,(y),(x),(c),(n)) #define mvins_nwstr(y,x,t,n) mvwins_nwstr(stdscr,(y),(x),(t),(n)) #define mvins_wch(y,x,c) mvwins_wch(stdscr,(y),(x),(c)) #define mvins_wstr(y,x,t) mvwins_wstr(stdscr,(y),(x),(t)) #define mvinwstr(y,x,c) mvwinwstr(stdscr,(y),(x),(c)) #define mvvline_set(y,x,c,n) mvwvline_set(stdscr,(y),(x),(c),(n)) #define mvwadd_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wch((win),(c))) #define mvwadd_wchnstr(win,y,x,s,n) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchnstr((win),(s),(n))) #define mvwadd_wchstr(win,y,x,s) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchstr((win),(s))) #define mvwaddnwstr(win,y,x,wstr,n) (wmove(win,(y),(x)) == ERR ? ERR : waddnwstr((win),(wstr),(n))) #define mvwaddwstr(win,y,x,wstr) (wmove(win,(y),(x)) == ERR ? ERR : waddwstr((win),(wstr))) #define mvwget_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wget_wch((win),(c))) #define mvwget_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wget_wstr((win),(t))) #define mvwgetn_wstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wgetn_wstr((win),(t),(n))) #define mvwhline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : whline_set((win),(c),(n))) #define mvwin_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wch((win),(c))) #define mvwin_wchnstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : win_wchnstr((win),(c),(n))) #define mvwin_wchstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wchstr((win),(c))) #define mvwinnwstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : winnwstr((win),(c),(n))) #define mvwins_nwstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wins_nwstr((win),(t),(n))) #define mvwins_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wins_wch((win),(c))) #define mvwins_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wins_wstr((win),(t))) #define mvwinwstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : winwstr((win),(c))) #define mvwvline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : wvline_set((win),(c),(n))) #endif /* NCURSES_NOMACROS */ #if defined(TRACE) || defined(NCURSES_TEST) extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *); extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *); #endif #endif /* NCURSES_WIDECHAR */ /* $Id: curses.tail,v 1.26 2021/03/20 15:49:25 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in * (see that file for the relevant copyright). */ /* mouse interface */ #if NCURSES_MOUSE_VERSION > 1 #define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5)) #else #define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6)) #endif #define NCURSES_BUTTON_RELEASED 001L #define NCURSES_BUTTON_PRESSED 002L #define NCURSES_BUTTON_CLICKED 004L #define NCURSES_DOUBLE_CLICKED 010L #define NCURSES_TRIPLE_CLICKED 020L #define NCURSES_RESERVED_EVENT 040L /* event masks */ #define BUTTON1_RELEASED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED) #define BUTTON1_PRESSED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED) #define BUTTON1_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED) #define BUTTON1_DOUBLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED) #define BUTTON1_TRIPLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED) #define BUTTON2_RELEASED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED) #define BUTTON2_PRESSED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED) #define BUTTON2_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED) #define BUTTON2_DOUBLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED) #define BUTTON2_TRIPLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED) #define BUTTON3_RELEASED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED) #define BUTTON3_PRESSED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED) #define BUTTON3_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED) #define BUTTON3_DOUBLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED) #define BUTTON3_TRIPLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED) #define BUTTON4_RELEASED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED) #define BUTTON4_PRESSED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED) #define BUTTON4_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED) #define BUTTON4_DOUBLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED) #define BUTTON4_TRIPLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED) /* * In 32 bits the version-1 scheme does not provide enough space for a 5th * button, unless we choose to change the ABI by omitting the reserved-events. */ #if NCURSES_MOUSE_VERSION > 1 #define BUTTON5_RELEASED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED) #define BUTTON5_PRESSED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED) #define BUTTON5_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED) #define BUTTON5_DOUBLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED) #define BUTTON5_TRIPLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED) #define BUTTON_CTRL NCURSES_MOUSE_MASK(6, 0001L) #define BUTTON_SHIFT NCURSES_MOUSE_MASK(6, 0002L) #define BUTTON_ALT NCURSES_MOUSE_MASK(6, 0004L) #define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(6, 0010L) #else #define BUTTON1_RESERVED_EVENT NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT) #define BUTTON2_RESERVED_EVENT NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT) #define BUTTON3_RESERVED_EVENT NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT) #define BUTTON4_RESERVED_EVENT NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT) #define BUTTON_CTRL NCURSES_MOUSE_MASK(5, 0001L) #define BUTTON_SHIFT NCURSES_MOUSE_MASK(5, 0002L) #define BUTTON_ALT NCURSES_MOUSE_MASK(5, 0004L) #define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(5, 0010L) #endif #define ALL_MOUSE_EVENTS (REPORT_MOUSE_POSITION - 1) /* macros to extract single event-bits from masks */ #define BUTTON_RELEASE(e, x) ((e) & NCURSES_MOUSE_MASK(x, 001)) #define BUTTON_PRESS(e, x) ((e) & NCURSES_MOUSE_MASK(x, 002)) #define BUTTON_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 004)) #define BUTTON_DOUBLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 010)) #define BUTTON_TRIPLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 020)) #define BUTTON_RESERVED_EVENT(e, x) ((e) & NCURSES_MOUSE_MASK(x, 040)) typedef struct { short id; /* ID to distinguish multiple devices */ int x, y, z; /* event coordinates (character-cell) */ mmask_t bstate; /* button state bits */ } MEVENT; extern NCURSES_EXPORT(bool) has_mouse(void); extern NCURSES_EXPORT(int) getmouse (MEVENT *); extern NCURSES_EXPORT(int) ungetmouse (MEVENT *); extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *); extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int); extern NCURSES_EXPORT(int) mouseinterval (int); extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool); extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* generated */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_mouse) (SCREEN*); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *); extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, mmask_t *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mouseinterval) (SCREEN*, int); #endif #ifndef NCURSES_NOMACROS #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen) #endif /* other non-XSI functions */ extern NCURSES_EXPORT(int) mcprint (char *, int); /* direct data to printer */ extern NCURSES_EXPORT(int) has_key (int); /* do we have given key? */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (SCREEN*, int); /* do we have given key? */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mcprint) (SCREEN*, char *, int); /* direct data to printer */ #endif /* Debugging : use with libncurses_g.a */ extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(char *) _traceattr (attr_t); extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype); extern NCURSES_EXPORT(char *) _tracechar (int); extern NCURSES_EXPORT(char *) _tracechtype (chtype); extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype); #if NCURSES_WIDECHAR #define _tracech_t _tracecchar_t extern NCURSES_EXPORT(char *) _tracecchar_t (const cchar_t *); #define _tracech_t2 _tracecchar_t2 extern NCURSES_EXPORT(char *) _tracecchar_t2 (int, const cchar_t *); #else #define _tracech_t _tracechtype #define _tracech_t2 _tracechtype2 #endif extern NCURSES_EXPORT(void) trace (const unsigned) GCC_DEPRECATED("use curses_trace"); extern NCURSES_EXPORT(unsigned) curses_trace (const unsigned); /* trace masks */ #define TRACE_DISABLE 0x0000 /* turn off tracing */ #define TRACE_TIMES 0x0001 /* trace user and system times of updates */ #define TRACE_TPUTS 0x0002 /* trace tputs calls */ #define TRACE_UPDATE 0x0004 /* trace update actions, old & new screens */ #define TRACE_MOVE 0x0008 /* trace cursor moves and scrolls */ #define TRACE_CHARPUT 0x0010 /* trace all character outputs */ #define TRACE_ORDINARY 0x001F /* trace all update actions */ #define TRACE_CALLS 0x0020 /* trace all curses calls */ #define TRACE_VIRTPUT 0x0040 /* trace virtual character puts */ #define TRACE_IEVENT 0x0080 /* trace low-level input processing */ #define TRACE_BITS 0x0100 /* trace state of TTY control bits */ #define TRACE_ICALLS 0x0200 /* trace internal/nested calls */ #define TRACE_CCALLS 0x0400 /* trace per-character calls */ #define TRACE_DATABASE 0x0800 /* trace read/write of terminfo/termcap data */ #define TRACE_ATTRS 0x1000 /* trace attribute updates */ #define TRACE_SHIFT 13 /* number of bits in the trace masks */ #define TRACE_MAXIMUM ((1 << TRACE_SHIFT) - 1) /* maximum trace level */ #if defined(TRACE) || defined(NCURSES_TEST) extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable; /* enable optimizations */ extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *); #define OPTIMIZE_MVCUR 0x01 /* cursor movement optimization */ #define OPTIMIZE_HASHMAP 0x02 /* diff hashing to detect scrolls */ #define OPTIMIZE_SCROLL 0x04 /* scroll optimization */ #define OPTIMIZE_ALL 0xff /* enable all optimizations (dflt) */ #endif extern GCC_NORETURN NCURSES_EXPORT(void) exit_curses (int); #include <unctrl.h> #ifdef __cplusplus #ifndef NCURSES_NOMACROS /* these names conflict with STL */ #undef box #undef clear #undef erase #undef move #undef refresh #endif /* NCURSES_NOMACROS */ } #endif #endif /* __NCURSES_H */ // * This makes emacs happy -*-Mode: C++;-*- /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ // $Id: etip.h.in,v 1.46 2021/04/17 17:59:57 tom Exp $ #ifndef NCURSES_ETIP_H_incl #define NCURSES_ETIP_H_incl 1 // These are substituted at configure/build time #ifndef HAVE_BUILTIN_H #define HAVE_BUILTIN_H 0 #endif #ifndef HAVE_GXX_BUILTIN_H #define HAVE_GXX_BUILTIN_H 0 #endif #ifndef HAVE_GPP_BUILTIN_H #define HAVE_GPP_BUILTIN_H 0 #endif #ifndef HAVE_IOSTREAM #define HAVE_IOSTREAM 1 #endif #ifndef HAVE_TYPEINFO #define HAVE_TYPEINFO 1 #endif #ifndef HAVE_VALUES_H #define HAVE_VALUES_H 0 #endif #ifndef ETIP_NEEDS_MATH_H #define ETIP_NEEDS_MATH_H 0 #endif #ifndef ETIP_NEEDS_MATH_EXCEPTION #define ETIP_NEEDS_MATH_EXCEPTION 0 #endif #ifndef CPP_HAS_PARAM_INIT #define CPP_HAS_PARAM_INIT 0 #endif #ifndef CPP_HAS_STATIC_CAST #define CPP_HAS_STATIC_CAST 1 #endif #ifndef IOSTREAM_NAMESPACE #define IOSTREAM_NAMESPACE 1 #endif #ifdef __GNUG__ # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8)) # if HAVE_TYPEINFO # include <typeinfo> # endif # endif #endif #if defined(__GNUG__) # if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H # if ETIP_NEEDS_MATH_H # if ETIP_NEEDS_MATH_EXCEPTION # undef exception # define exception math_exception # endif # include <math.h> # endif # undef exception # define exception builtin_exception # if HAVE_GPP_BUILTIN_H # include <gpp/builtin.h> # elif HAVE_GXX_BUILTIN_H # include <g++/builtin.h> # else # include <builtin.h> # endif # undef exception # endif #elif defined (__SUNPRO_CC) # include <generic.h> #endif #include <curses.h> extern "C" { #if HAVE_VALUES_H # include <values.h> #endif #include <assert.h> #include <eti.h> #include <errno.h> } // Language features #if CPP_HAS_PARAM_INIT #define NCURSES_PARAM_INIT(value) = value #else #define NCURSES_PARAM_INIT(value) /*nothing*/ #endif #if CPP_HAS_STATIC_CAST #define STATIC_CAST(s) static_cast<s> #else #define STATIC_CAST(s) (s) #endif // Forward Declarations class NCURSES_CXX_IMPEXP NCursesPanel; class NCURSES_CXX_IMPEXP NCursesMenu; class NCURSES_CXX_IMPEXP NCursesForm; class NCURSES_CXX_IMPEXP NCursesException { public: const char *message; int errorno; NCursesException (const char* msg, int err) : message(msg), errorno (err) {}; explicit NCursesException (const char* msg) : message(msg), errorno (E_SYSTEM_ERROR) {}; NCursesException& operator=(const NCursesException& rhs) { message = rhs.message; errorno = rhs.errorno; return *this; } NCursesException(const NCursesException& rhs) : message(rhs.message), errorno(rhs.errorno) { } virtual const char *classname() const { return "NCursesWindow"; } virtual ~NCursesException() { } }; class NCURSES_CXX_IMPEXP NCursesPanelException : public NCursesException { public: const NCursesPanel* p; NCursesPanelException (const char *msg, int err) : NCursesException (msg, err), p (0) {}; NCursesPanelException (const NCursesPanel* panel, const char *msg, int err) : NCursesException (msg, err), p (panel) {}; explicit NCursesPanelException (int err) : NCursesException ("panel library error", err), p (0) {}; NCursesPanelException (const NCursesPanel* panel, int err) : NCursesException ("panel library error", err), p (panel) {}; NCursesPanelException& operator=(const NCursesPanelException& rhs) { if (this != &rhs) { NCursesException::operator=(rhs); p = rhs.p; } return *this; } NCursesPanelException(const NCursesPanelException& rhs) : NCursesException(rhs), p(rhs.p) { } virtual const char *classname() const { return "NCursesPanel"; } virtual ~NCursesPanelException() { } }; class NCURSES_CXX_IMPEXP NCursesMenuException : public NCursesException { public: const NCursesMenu* m; NCursesMenuException (const char *msg, int err) : NCursesException (msg, err), m (0) {}; NCursesMenuException (const NCursesMenu* menu, const char *msg, int err) : NCursesException (msg, err), m (menu) {}; explicit NCursesMenuException (int err) : NCursesException ("menu library error", err), m (0) {}; NCursesMenuException (const NCursesMenu* menu, int err) : NCursesException ("menu library error", err), m (menu) {}; NCursesMenuException& operator=(const NCursesMenuException& rhs) { if (this != &rhs) { NCursesException::operator=(rhs); m = rhs.m; } return *this; } NCursesMenuException(const NCursesMenuException& rhs) : NCursesException(rhs), m(rhs.m) { } virtual const char *classname() const { return "NCursesMenu"; } virtual ~NCursesMenuException() { } }; class NCURSES_CXX_IMPEXP NCursesFormException : public NCursesException { public: const NCursesForm* f; NCursesFormException (const char *msg, int err) : NCursesException (msg, err), f (0) {}; NCursesFormException (const NCursesForm* form, const char *msg, int err) : NCursesException (msg, err), f (form) {}; explicit NCursesFormException (int err) : NCursesException ("form library error", err), f (0) {}; NCursesFormException (const NCursesForm* form, int err) : NCursesException ("form library error", err), f (form) {}; NCursesFormException& operator=(const NCursesFormException& rhs) { if (this != &rhs) { NCursesException::operator=(rhs); f = rhs.f; } return *this; } NCursesFormException(const NCursesFormException& rhs) : NCursesException(rhs), f(rhs.f) { } virtual const char *classname() const { return "NCursesForm"; } virtual ~NCursesFormException() { } }; #if !((defined(__GNUG__) && defined(__EXCEPTIONS) && (__GNUG__ < 7)) || defined(__SUNPRO_CC)) # if HAVE_IOSTREAM # include <iostream> # if IOSTREAM_NAMESPACE using std::cerr; using std::endl; # endif # else # include <iostream.h> # endif #endif inline void THROW(const NCursesException *e) { #if defined(__GNUG__) && defined(__EXCEPTIONS) # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8)) (*lib_error_handler)(e ? e->classname() : "", e ? e->message : ""); # elif (__GNUG__ >= 7) // g++ 7.0 warns about deprecation, but lacks the predefined symbols ::endwin(); std::cerr << "Found a problem - goodbye" << std::endl; exit(EXIT_FAILURE); # else # define CPP_HAS_TRY_CATCH 1 # endif #elif defined(__SUNPRO_CC) # if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5) genericerror(1, ((e != 0) ? (char *)(e->message) : "")); # else # define CPP_HAS_TRY_CATCH 1 # endif #else if (e) cerr << e->message << endl; exit(0); #endif #ifndef CPP_HAS_TRY_CATCH #define CPP_HAS_TRY_CATCH 0 #define NCURSES_CPP_TRY /* nothing */ #define NCURSES_CPP_CATCH(e) if (false) #define THROWS(s) /* nothing */ #define THROW2(s,t) /* nothing */ #elif CPP_HAS_TRY_CATCH throw *e; #define NCURSES_CPP_TRY try #define NCURSES_CPP_CATCH(e) catch(e) #if defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510) // C++17 deprecates the usage of throw(). #define THROWS(s) /* nothing */ #define THROW2(s,t) /* nothing */ #else #define THROWS(s) throw(s) #define THROW2(s,t) throw(s,t) #endif #endif } #endif /* NCURSES_ETIP_H_incl */ /**************************************************************************** * Copyright 2020 Thomas E. Dickey * * Copyright 1998-2002,2003 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1995,1997 * ****************************************************************************/ /* $Id: eti.h,v 1.9 2020/02/02 23:34:34 tom Exp $ */ #ifndef NCURSES_ETI_H_incl #define NCURSES_ETI_H_incl 1 #define E_OK (0) #define E_SYSTEM_ERROR (-1) #define E_BAD_ARGUMENT (-2) #define E_POSTED (-3) #define E_CONNECTED (-4) #define E_BAD_STATE (-5) #define E_NO_ROOM (-6) #define E_NOT_POSTED (-7) #define E_UNKNOWN_COMMAND (-8) #define E_NO_MATCH (-9) #define E_NOT_SELECTABLE (-10) #define E_NOT_CONNECTED (-11) #define E_REQUEST_DENIED (-12) #define E_INVALID_FIELD (-13) #define E_CURRENT (-14) #endif // * this is for making emacs happy: -*-Mode: C++;-*- // vile:cppmode /**************************************************************************** * Copyright 2019-2020,2021 Thomas E. Dickey * * Copyright 1998-2003,2005 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ // $Id: cursslk.h,v 1.19 2021/04/17 18:11:08 tom Exp $ #ifndef NCURSES_CURSSLK_H_incl #define NCURSES_CURSSLK_H_incl #include <cursesw.h> class NCURSES_CXX_IMPEXP Soft_Label_Key_Set { public: // This inner class represents the attributes of a Soft Label Key (SLK) class NCURSES_CXX_IMPEXP Soft_Label_Key { friend class Soft_Label_Key_Set; public: typedef enum { Left=0, Center=1, Right=2 } Justification; private: char *label; // The Text of the Label Justification format; // The Justification int num; // The number of the Label Soft_Label_Key() : label(NULL), format(Left), num(-1) { } virtual ~Soft_Label_Key() { delete[] label; }; public: // Set the text of the Label Soft_Label_Key& operator=(char *text); // Set the Justification of the Label Soft_Label_Key& operator=(Justification just) { format = just; return *this; } // Retrieve the text of the label inline char* operator()(void) const { return label; } Soft_Label_Key& operator=(const Soft_Label_Key& rhs) { if (this != &rhs) { *this = rhs; } return *this; } Soft_Label_Key(const Soft_Label_Key& rhs) : label(NULL), format(rhs.format), num(rhs.num) { *this = rhs.label; } }; public: typedef enum { None = -1, Three_Two_Three = 0, Four_Four = 1, PC_Style = 2, PC_Style_With_Index = 3 } Label_Layout; private: static long count; // Number of Key Sets static Label_Layout format; // Layout of the Key Sets static int num_labels; // Number Of Labels in Key Sets bool b_attrInit; // Are attributes initialized Soft_Label_Key *slk_array; // The array of SLK's // Init the Key Set void init(); // Activate or Deactivate Label# i, Label counting starts with 1! void activate_label(int i, bool bf=TRUE); // Activate of Deactivate all Labels void activate_labels(bool bf); protected: inline void Error (const char* msg) const THROWS(NCursesException) { THROW(new NCursesException (msg)); } // Remove SLK's from screen void clear() { if (ERR==::slk_clear()) Error("slk_clear"); } // Restore them void restore() { if (ERR==::slk_restore()) Error("slk_restore"); } public: // Construct a Key Set, use the most comfortable layout as default. // You must create a Soft_Label_Key_Set before you create any object of // the NCursesWindow, NCursesPanel or derived classes. (Actually before // ::initscr() is called). explicit Soft_Label_Key_Set(Label_Layout fmt); // This constructor assumes, that you already constructed a Key Set // with a layout by the constructor above. This layout will be reused. Soft_Label_Key_Set(); Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs) { if (this != &rhs) { *this = rhs; init(); // allocate a new slk_array[] } return *this; } Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs) : b_attrInit(rhs.b_attrInit), slk_array(NULL) { init(); // allocate a new slk_array[] } virtual ~Soft_Label_Key_Set() THROWS(NCursesException); // Get Label# i. Label counting starts with 1! Soft_Label_Key& operator[](int i); // Retrieve number of Labels int labels() const; // Refresh the SLK portion of the screen inline void refresh() { if (ERR==::slk_refresh()) Error("slk_refresh"); } // Mark the SLK portion of the screen for refresh, defer actual refresh // until next update call. inline void noutrefresh() { if (ERR==::slk_noutrefresh()) Error("slk_noutrefresh"); } // Mark the whole SLK portion of the screen as modified inline void touch() { if (ERR==::slk_touch()) Error("slk_touch"); } // Activate Label# i inline void show(int i) { activate_label(i,FALSE); activate_label(i,TRUE); } // Hide Label# i inline void hide(int i) { activate_label(i,FALSE); } // Show all Labels inline void show() { activate_labels(FALSE); activate_labels(TRUE); } // Hide all Labels inline void hide() { activate_labels(FALSE); } inline void attron(attr_t attrs) { if (ERR==::slk_attron(attrs)) Error("slk_attron"); } inline void attroff(attr_t attrs) { if (ERR==::slk_attroff(attrs)) Error("slk_attroff"); } inline void attrset(attr_t attrs) { if (ERR==::slk_attrset(attrs)) Error("slk_attrset"); } inline void color(short color_pair_number) { if (ERR==::slk_color(color_pair_number)) Error("slk_color"); } inline attr_t attr() const { return ::slk_attr(); } }; #endif /* NCURSES_CURSSLK_H_incl */ /**************************************************************************** * Copyright 2020 Thomas E. Dickey * * Copyright 1998-2009,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Juergen Pfeifer 1996-1999,2008 * ****************************************************************************/ /* $Id: panel.h,v 1.14 2020/07/04 20:38:43 tom Exp $ */ /* panel.h -- interface file for panels library */ #ifndef NCURSES_PANEL_H_incl #define NCURSES_PANEL_H_incl 1 #include <curses.h> typedef struct panel #if !NCURSES_OPAQUE_PANEL { WINDOW *win; struct panel *below; struct panel *above; NCURSES_CONST void *user; } #endif /* !NCURSES_OPAQUE_PANEL */ PANEL; #if defined(__cplusplus) extern "C" { #endif #if defined(BUILDING_PANEL) # define PANEL_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT #else # define PANEL_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT #endif #define PANEL_WRAPPED_VAR(type,name) extern PANEL_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) #define PANEL_EXPORT(type) PANEL_IMPEXP type NCURSES_API #define PANEL_EXPORT_VAR(type) PANEL_IMPEXP type extern PANEL_EXPORT(WINDOW*) panel_window (const PANEL *); extern PANEL_EXPORT(void) update_panels (void); extern PANEL_EXPORT(int) hide_panel (PANEL *); extern PANEL_EXPORT(int) show_panel (PANEL *); extern PANEL_EXPORT(int) del_panel (PANEL *); extern PANEL_EXPORT(int) top_panel (PANEL *); extern PANEL_EXPORT(int) bottom_panel (PANEL *); extern PANEL_EXPORT(PANEL*) new_panel (WINDOW *); extern PANEL_EXPORT(PANEL*) panel_above (const PANEL *); extern PANEL_EXPORT(PANEL*) panel_below (const PANEL *); extern PANEL_EXPORT(int) set_panel_userptr (PANEL *, NCURSES_CONST void *); extern PANEL_EXPORT(NCURSES_CONST void*) panel_userptr (const PANEL *); extern PANEL_EXPORT(int) move_panel (PANEL *, int, int); extern PANEL_EXPORT(int) replace_panel (PANEL *,WINDOW *); extern PANEL_EXPORT(int) panel_hidden (const PANEL *); #if NCURSES_SP_FUNCS extern PANEL_EXPORT(PANEL *) ground_panel(SCREEN *); extern PANEL_EXPORT(PANEL *) ceiling_panel(SCREEN *); extern PANEL_EXPORT(void) NCURSES_SP_NAME(update_panels) (SCREEN*); #endif #if defined(__cplusplus) } #endif #endif /* NCURSES_PANEL_H_incl */ /* end of panel.h */ /**************************************************************************** * Copyright 2020 Thomas E. Dickey * * Copyright 1998-2001,2009 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ /* * unctrl.h * * Display a printable version of a control character. * Control characters are displayed in caret notation (^x), DELETE is displayed * as ^?. Printable characters are displayed as is. */ /* $Id: unctrl.h.in,v 1.12 2020/02/02 23:34:34 tom Exp $ */ #ifndef NCURSES_UNCTRL_H_incl #define NCURSES_UNCTRL_H_incl 1 #undef NCURSES_VERSION #define NCURSES_VERSION "6.2" #ifdef __cplusplus extern "C" { #endif #include <curses.h> #undef unctrl NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype); #if 1 NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype); #endif #ifdef __cplusplus } #endif #endif /* NCURSES_UNCTRL_H_incl */ /**************************************************************************** * Copyright 2018,2020 Thomas E. Dickey * * Copyright 1998-2000,2001 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * ****************************************************************************/ /* $Id: termcap.h.in,v 1.19 2020/02/02 23:34:34 tom Exp $ */ #ifndef NCURSES_TERMCAP_H_incl #define NCURSES_TERMCAP_H_incl 1 #undef NCURSES_VERSION #define NCURSES_VERSION "6.2" #include <ncurses_dll.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include <sys/types.h> #undef NCURSES_OSPEED #define NCURSES_OSPEED unsigned extern NCURSES_EXPORT_VAR(char) PC; extern NCURSES_EXPORT_VAR(char *) UP; extern NCURSES_EXPORT_VAR(char *) BC; extern NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed; #if !defined(NCURSES_TERM_H_incl) extern NCURSES_EXPORT(char *) tgetstr (const char *, char **); extern NCURSES_EXPORT(char *) tgoto (const char *, int, int); extern NCURSES_EXPORT(int) tgetent (char *, const char *); extern NCURSES_EXPORT(int) tgetflag (const char *); extern NCURSES_EXPORT(int) tgetnum (const char *); extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int)); #endif #ifdef __cplusplus } #endif #endif /* NCURSES_TERMCAP_H_incl */ /**************************************************************************** * Copyright 2018,2020 Thomas E. Dickey * * Copyright 2009,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /* $Id: ncurses_dll.h.in,v 1.17 2020/09/05 17:58:47 juergen Exp $ */ #ifndef NCURSES_DLL_H_incl #define NCURSES_DLL_H_incl 1 /* * MinGW gcc (unlike MSYS2 and Cygwin) should define _WIN32 and possibly _WIN64. */ #if defined(__MINGW64__) #ifndef _WIN64 #define _WIN64 1 #endif #elif defined(__MINGW32__) #ifndef _WIN32 #define _WIN32 1 #endif /* 2014-08-02 workaround for broken MinGW compiler. * Oddly, only TRACE is mapped to trace - the other -D's are okay. * suggest TDM as an alternative. */ #if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) #ifdef trace #undef trace #define TRACE #endif #endif /* broken compiler */ #endif /* MingW */ /* * For reentrant code, we map the various global variables into SCREEN by * using functions to access them. */ #define NCURSES_PUBLIC_VAR(name) _nc_##name #if defined(BUILDING_NCURSES) # define NCURSES_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT #else # define NCURSES_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT #endif #define NCURSES_WRAPPED_VAR(type,name) extern NCURSES_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) #define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API #define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type /* * These symbols hide dllimport/dllexport, for compilers which care about it. */ #if defined(__CYGWIN__) || (defined(_WIN32) || defined(_WIN64)) # if defined(NCURSES_STATIC) /* "static" here only implies "not-a-DLL" */ # define NCURSES_EXPORT_GENERAL_IMPORT # define NCURSES_EXPORT_GENERAL_EXPORT # else # define NCURSES_EXPORT_GENERAL_IMPORT __declspec(dllimport) # define NCURSES_EXPORT_GENERAL_EXPORT __declspec(dllexport) # endif # define NCURSES_API __cdecl #else # define NCURSES_EXPORT_GENERAL_IMPORT # define NCURSES_EXPORT_GENERAL_EXPORT # define NCURSES_API /* FIXME: __attribute__ ((cdecl)) is only available on x86 */ #endif #endif /* NCURSES_DLL_H_incl */ // * This makes emacs happy -*-Mode: C++;-*- // vile:cppmode /**************************************************************************** * Copyright 2019-2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ // $Id: cursesf.h,v 1.38 2021/04/17 18:11:08 tom Exp $ #ifndef NCURSES_CURSESF_H_incl #define NCURSES_CURSESF_H_incl 1 #include <cursesp.h> #ifndef __EXT_QNX #include <string.h> #endif extern "C" { # include <form.h> } // // ------------------------------------------------------------------------- // The abstract base class for builtin and user defined Fieldtypes. // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP NCursesFormField; // forward declaration // Class to represent builtin field types as well as C++ written new // fieldtypes (see classes UserDefineFieldType... class NCURSES_CXX_IMPEXP NCursesFieldType { friend class NCursesFormField; protected: FIELDTYPE* fieldtype; inline void OnError(int err) const THROW2(NCursesException const, NCursesFormException) { if (err!=E_OK) THROW(new NCursesFormException (err)); } NCursesFieldType(FIELDTYPE *f) : fieldtype(f) { } virtual ~NCursesFieldType() {} // Set the fields f fieldtype to this one. virtual void set(NCursesFormField& f) = 0; public: NCursesFieldType() : fieldtype(STATIC_CAST(FIELDTYPE*)(0)) { } NCursesFieldType& operator=(const NCursesFieldType& rhs) { if (this != &rhs) { *this = rhs; } return *this; } NCursesFieldType(const NCursesFieldType& rhs) : fieldtype(rhs.fieldtype) { } }; // // ------------------------------------------------------------------------- // The class representing a forms field, wrapping the lowlevel FIELD struct // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP NCursesFormField { friend class NCursesForm; protected: FIELD *field; // lowlevel structure NCursesFieldType* ftype; // Associated field type // Error handler inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) { if (err != E_OK) THROW(new NCursesFormException (err)); } public: // Create a 'Null' field. Can be used to delimit a field list NCursesFormField() : field(STATIC_CAST(FIELD*)(0)), ftype(STATIC_CAST(NCursesFieldType*)(0)) { } // Create a new field NCursesFormField (int rows, int ncols, int first_row = 0, int first_col = 0, int offscreen_rows = 0, int additional_buffers = 0) : field(0), ftype(STATIC_CAST(NCursesFieldType*)(0)) { field = ::new_field(rows, ncols, first_row, first_col, offscreen_rows, additional_buffers); if (!field) OnError(errno); } NCursesFormField& operator=(const NCursesFormField& rhs) { if (this != &rhs) { *this = rhs; } return *this; } NCursesFormField(const NCursesFormField& rhs) : field(rhs.field), ftype(rhs.ftype) { } virtual ~NCursesFormField () THROWS(NCursesException); // Duplicate the field at a new position inline NCursesFormField* dup(int first_row, int first_col) { NCursesFormField* f = new NCursesFormField(); if (!f) OnError(E_SYSTEM_ERROR); else { f->ftype = ftype; f->field = ::dup_field(field,first_row,first_col); if (!f->field) OnError(errno); } return f; } // Link the field to a new location inline NCursesFormField* link(int first_row, int first_col) { NCursesFormField* f = new NCursesFormField(); if (!f) OnError(E_SYSTEM_ERROR); else { f->ftype = ftype; f->field = ::link_field(field,first_row,first_col); if (!f->field) OnError(errno); } return f; } // Get the lowlevel field representation inline FIELD* get_field() const { return field; } // Retrieve info about the field inline void info(int& rows, int& ncols, int& first_row, int& first_col, int& offscreen_rows, int& additional_buffers) const { OnError(::field_info(field, &rows, &ncols, &first_row, &first_col, &offscreen_rows, &additional_buffers)); } // Retrieve info about the fields dynamic properties. inline void dynamic_info(int& dynamic_rows, int& dynamic_cols, int& max_growth) const { OnError(::dynamic_field_info(field, &dynamic_rows, &dynamic_cols, &max_growth)); } // For a dynamic field you may set the maximum growth limit. // A zero means unlimited growth. inline void set_maximum_growth(int growth = 0) { OnError(::set_max_field(field,growth)); } // Move the field to a new position inline void move(int row, int col) { OnError(::move_field(field,row,col)); } // Mark the field to start a new page inline void new_page(bool pageFlag = FALSE) { OnError(::set_new_page(field,pageFlag)); } // Retrieve whether or not the field starts a new page. inline bool is_new_page() const { return ::new_page(field); } // Set the justification for the field inline void set_justification(int just) { OnError(::set_field_just(field,just)); } // Retrieve the fields justification inline int justification() const { return ::field_just(field); } // Set the foreground attribute for the field inline void set_foreground(chtype foreground) { OnError(::set_field_fore(field,foreground)); } // Retrieve the fields foreground attribute inline chtype fore() const { return ::field_fore(field); } // Set the background attribute for the field inline void set_background(chtype background) { OnError(::set_field_back(field,background)); } // Retrieve the fields background attribute inline chtype back() const { return ::field_back(field); } // Set the padding character for the field inline void set_pad_character(int padding) { OnError(::set_field_pad(field, padding)); } // Retrieve the fields padding character inline int pad() const { return ::field_pad(field); } // Switch on the fields options inline void options_on (Field_Options opts) { OnError (::field_opts_on (field, opts)); } // Switch off the fields options inline void options_off (Field_Options opts) { OnError (::field_opts_off (field, opts)); } // Retrieve the fields options inline Field_Options options () const { return ::field_opts (field); } // Set the fields options inline void set_options (Field_Options opts) { OnError (::set_field_opts (field, opts)); } // Mark the field as changed inline void set_changed(bool changeFlag = TRUE) { OnError(::set_field_status(field,changeFlag)); } // Test whether or not the field is marked as changed inline bool changed() const { return ::field_status(field); } // Return the index of the field in the field array of a form // or -1 if the field is not associated to a form inline int (index)() const { return ::field_index(field); } // Store a value in a fields buffer. The default buffer is nr. 0 inline void set_value(const char *val, int buffer = 0) { OnError(::set_field_buffer(field,buffer,val)); } // Retrieve the value of a fields buffer. The default buffer is nr. 0 inline char* value(int buffer = 0) const { return ::field_buffer(field,buffer); } // Set the validation type of the field. inline void set_fieldtype(NCursesFieldType& f) { ftype = &f; f.set(*this); // A good friend may do that... } // Retrieve the validation type of the field. inline NCursesFieldType* fieldtype() const { return ftype; } }; // This are the built-in hook functions in this C++ binding. In C++ we use // virtual member functions (see below On_..._Init and On_..._Termination) // to provide this functionality in an object oriented manner. extern "C" { void _nc_xx_frm_init(FORM *); void _nc_xx_frm_term(FORM *); void _nc_xx_fld_init(FORM *); void _nc_xx_fld_term(FORM *); } // // ------------------------------------------------------------------------- // The class representing a form, wrapping the lowlevel FORM struct // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP NCursesForm : public NCursesPanel { protected: FORM* form; // the lowlevel structure private: NCursesWindow* sub; // the subwindow object bool b_sub_owner; // is this our own subwindow? bool b_framed; // has the form a border? bool b_autoDelete; // Delete fields when deleting form? NCursesFormField** my_fields; // The array of fields for this form // This structure is used for the form's user data field to link the // FORM* to the C++ object and to provide extra space for a user pointer. typedef struct { void* m_user; // the pointer for the user's data const NCursesForm* m_back; // backward pointer to C++ object const FORM* m_owner; } UserHook; // Get the backward pointer to the C++ object from a FORM static inline NCursesForm* getHook(const FORM *f) { UserHook* hook = reinterpret_cast<UserHook*>(::form_userptr(f)); assert(hook != 0 && hook->m_owner==f); return const_cast<NCursesForm*>(hook->m_back); } friend void _nc_xx_frm_init(FORM *); friend void _nc_xx_frm_term(FORM *); friend void _nc_xx_fld_init(FORM *); friend void _nc_xx_fld_term(FORM *); // Calculate FIELD* array for the menu FIELD** mapFields(NCursesFormField* nfields[]); protected: // internal routines inline void set_user(void *user) { UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form)); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form); uptr->m_user = user; } inline void *get_user() { UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form)); assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form); return uptr->m_user; } void InitForm (NCursesFormField* Fields[], bool with_frame, bool autoDeleteFields); inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) { if (err != E_OK) THROW(new NCursesFormException (err)); } // this wraps the form_driver call. virtual int driver (int c) ; // 'Internal' constructor, builds an object without association to a // field array. NCursesForm( int nlines, int ncols, int begin_y = 0, int begin_x = 0) : NCursesPanel(nlines, ncols, begin_y, begin_x), form (STATIC_CAST(FORM*)(0)), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_fields(0) { } public: // Create form for the default panel. NCursesForm (NCursesFormField* Fields[], bool with_frame=FALSE, // reserve space for a frame? bool autoDelete_Fields=FALSE) // do automatic cleanup? : NCursesPanel(), form(0), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_fields(0) { InitForm(Fields, with_frame, autoDelete_Fields); } // Create a form in a panel with the given position and size. NCursesForm (NCursesFormField* Fields[], int nlines, int ncols, int begin_y, int begin_x, bool with_frame=FALSE, // reserve space for a frame? bool autoDelete_Fields=FALSE) // do automatic cleanup? : NCursesPanel(nlines, ncols, begin_y, begin_x), form(0), sub(0), b_sub_owner(0), b_framed(0), b_autoDelete(0), my_fields(0) { InitForm(Fields, with_frame, autoDelete_Fields); } NCursesForm& operator=(const NCursesForm& rhs) { if (this != &rhs) { *this = rhs; NCursesPanel::operator=(rhs); } return *this; } NCursesForm(const NCursesForm& rhs) : NCursesPanel(rhs), form(rhs.form), sub(rhs.sub), b_sub_owner(rhs.b_sub_owner), b_framed(rhs.b_framed), b_autoDelete(rhs.b_autoDelete), my_fields(rhs.my_fields) { } virtual ~NCursesForm() THROWS(NCursesException); // Set the default attributes for the form virtual void setDefaultAttributes(); // Retrieve current field of the form. inline NCursesFormField* current_field() const { return my_fields[::field_index(::current_field(form))]; } // Set the forms subwindow void setSubWindow(NCursesWindow& sub); // Set these fields for the form inline void setFields(NCursesFormField* Fields[]) { OnError(::set_form_fields(form,mapFields(Fields))); } // Remove the form from the screen inline void unpost (void) { OnError (::unpost_form (form)); } // Post the form to the screen if flag is true, unpost it otherwise inline void post(bool flag = TRUE) { OnError (flag ? ::post_form(form) : ::unpost_form (form)); } // Decorations inline void frame(const char *title=NULL, const char* btitle=NULL) { if (b_framed) NCursesPanel::frame(title,btitle); else OnError(E_SYSTEM_ERROR); } inline void boldframe(const char *title=NULL, const char* btitle=NULL) { if (b_framed) NCursesPanel::boldframe(title,btitle); else OnError(E_SYSTEM_ERROR); } inline void label(const char *topLabel, const char *bottomLabel) { if (b_framed) NCursesPanel::label(topLabel,bottomLabel); else OnError(E_SYSTEM_ERROR); } // ----- // Hooks // ----- // Called after the form gets repositioned in its window. // This is especially true if the form is posted. virtual void On_Form_Init(); // Called before the form gets repositioned in its window. // This is especially true if the form is unposted. virtual void On_Form_Termination(); // Called after the field became the current field virtual void On_Field_Init(NCursesFormField& field); // Called before this field is left as current field. virtual void On_Field_Termination(NCursesFormField& field); // Calculate required window size for the form. void scale(int& rows, int& ncols) const { OnError(::scale_form(form,&rows,&ncols)); } // Retrieve number of fields in the form. int count() const { return ::field_count(form); } // Make the page the current page of the form. void set_page(int pageNum) { OnError(::set_form_page(form, pageNum)); } // Retrieve current page number int page() const { return ::form_page(form); } // Switch on the forms options inline void options_on (Form_Options opts) { OnError (::form_opts_on (form, opts)); } // Switch off the forms options inline void options_off (Form_Options opts) { OnError (::form_opts_off (form, opts)); } // Retrieve the forms options inline Form_Options options () const { return ::form_opts (form); } // Set the forms options inline void set_options (Form_Options opts) { OnError (::set_form_opts (form, opts)); } // Are there more data in the current field after the data shown inline bool data_ahead() const { return ::data_ahead(form); } // Are there more data in the current field before the data shown inline bool data_behind() const { return ::data_behind(form); } // Position the cursor to the current field inline void position_cursor () { OnError (::pos_form_cursor (form)); } // Set the current field inline void set_current(NCursesFormField& F) { OnError (::set_current_field(form, F.field)); } // Provide a default key virtualization. Translate the keyboard // code c into a form request code. // The default implementation provides a hopefully straightforward // mapping for the most common keystrokes and form requests. virtual int virtualize(int c); // Operators inline NCursesFormField* operator[](int i) const { if ( (i < 0) || (i >= ::field_count (form)) ) OnError (E_BAD_ARGUMENT); return my_fields[i]; } // Perform the menu's operation // Return the field where you left the form. virtual NCursesFormField* operator()(void); // Exception handlers. The default is a Beep. virtual void On_Request_Denied(int c) const; virtual void On_Invalid_Field(int c) const; virtual void On_Unknown_Command(int c) const; }; // // ------------------------------------------------------------------------- // This is the typical C++ typesafe way to allow to attach // user data to a field of a form. Its assumed that the user // data belongs to some class T. Use T as template argument // to create a UserField. // ------------------------------------------------------------------------- template<class T> class NCURSES_CXX_IMPEXP NCursesUserField : public NCursesFormField { public: NCursesUserField (int rows, int ncols, int first_row = 0, int first_col = 0, const T* p_UserData = STATIC_CAST(T*)(0), int offscreen_rows = 0, int additional_buffers = 0) : NCursesFormField (rows, ncols, first_row, first_col, offscreen_rows, additional_buffers) { if (field) OnError(::set_field_userptr(field, STATIC_CAST(void *)(p_UserData))); } virtual ~NCursesUserField() THROWS(NCursesException) {}; inline const T* UserData (void) const { return reinterpret_cast<const T*>(::field_userptr (field)); } inline virtual void setUserData(const T* p_UserData) { if (field) OnError (::set_field_userptr (field, STATIC_CAST(void *)(p_UserData))); } }; // // ------------------------------------------------------------------------- // The same mechanism is used to attach user data to a form // ------------------------------------------------------------------------- // template<class T> class NCURSES_CXX_IMPEXP NCursesUserForm : public NCursesForm { protected: // 'Internal' constructor, builds an object without association to a // field array. NCursesUserForm( int nlines, int ncols, int begin_y = 0, int begin_x = 0, const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesForm(nlines,ncols,begin_y,begin_x) { if (form) set_user (const_cast<void *>(reinterpret_cast<const void*> (p_UserData))); } public: NCursesUserForm (NCursesFormField* Fields[], const T* p_UserData = STATIC_CAST(T*)(0), bool with_frame=FALSE, bool autoDelete_Fields=FALSE) : NCursesForm (Fields, with_frame, autoDelete_Fields) { if (form) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); }; NCursesUserForm (NCursesFormField* Fields[], int nlines, int ncols, int begin_y = 0, int begin_x = 0, const T* p_UserData = STATIC_CAST(T*)(0), bool with_frame=FALSE, bool autoDelete_Fields=FALSE) : NCursesForm (Fields, nlines, ncols, begin_y, begin_x, with_frame, autoDelete_Fields) { if (form) set_user (const_cast<void *>(reinterpret_cast<const void*> (p_UserData))); }; virtual ~NCursesUserForm() THROWS(NCursesException) { }; inline T* UserData (void) { return reinterpret_cast<T*>(get_user ()); }; inline virtual void setUserData (const T* p_UserData) { if (form) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); } }; // // ------------------------------------------------------------------------- // Builtin Fieldtypes // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP Alpha_Field : public NCursesFieldType { private: int min_field_width; void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype,min_field_width)); } public: explicit Alpha_Field(int width) : NCursesFieldType(TYPE_ALPHA), min_field_width(width) { } }; class NCURSES_CXX_IMPEXP Alphanumeric_Field : public NCursesFieldType { private: int min_field_width; void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype,min_field_width)); } public: explicit Alphanumeric_Field(int width) : NCursesFieldType(TYPE_ALNUM), min_field_width(width) { } }; class NCURSES_CXX_IMPEXP Integer_Field : public NCursesFieldType { private: int precision; long lower_limit, upper_limit; void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype, precision,lower_limit,upper_limit)); } public: Integer_Field(int prec, long low=0L, long high=0L) : NCursesFieldType(TYPE_INTEGER), precision(prec), lower_limit(low), upper_limit(high) { } }; class NCURSES_CXX_IMPEXP Numeric_Field : public NCursesFieldType { private: int precision; double lower_limit, upper_limit; void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype, precision,lower_limit,upper_limit)); } public: Numeric_Field(int prec, double low=0.0, double high=0.0) : NCursesFieldType(TYPE_NUMERIC), precision(prec), lower_limit(low), upper_limit(high) { } }; class NCURSES_CXX_IMPEXP Regular_Expression_Field : public NCursesFieldType { private: char* regex; void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype,regex)); } void copy_regex(const char *source) { regex = new char[1 + ::strlen(source)]; (::strcpy)(regex, source); } public: explicit Regular_Expression_Field(const char *expr) : NCursesFieldType(TYPE_REGEXP), regex(NULL) { copy_regex(expr); } Regular_Expression_Field& operator=(const Regular_Expression_Field& rhs) { if (this != &rhs) { *this = rhs; copy_regex(rhs.regex); NCursesFieldType::operator=(rhs); } return *this; } Regular_Expression_Field(const Regular_Expression_Field& rhs) : NCursesFieldType(rhs), regex(NULL) { copy_regex(rhs.regex); } ~Regular_Expression_Field() { delete[] regex; } }; class NCURSES_CXX_IMPEXP Enumeration_Field : public NCursesFieldType { private: const char** list; int case_sensitive; int non_unique_matches; void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype, list,case_sensitive,non_unique_matches)); } public: Enumeration_Field(const char* enums[], bool case_sens=FALSE, bool non_unique=FALSE) : NCursesFieldType(TYPE_ENUM), list(enums), case_sensitive(case_sens ? -1 : 0), non_unique_matches(non_unique ? -1 : 0) { } Enumeration_Field& operator=(const Enumeration_Field& rhs) { if (this != &rhs) { *this = rhs; NCursesFieldType::operator=(rhs); } return *this; } Enumeration_Field(const Enumeration_Field& rhs) : NCursesFieldType(rhs), list(rhs.list), case_sensitive(rhs.case_sensitive), non_unique_matches(rhs.non_unique_matches) { } }; class NCURSES_CXX_IMPEXP IPV4_Address_Field : public NCursesFieldType { private: void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype)); } public: IPV4_Address_Field() : NCursesFieldType(TYPE_IPV4) { } }; extern "C" { bool _nc_xx_fld_fcheck(FIELD *, const void*); bool _nc_xx_fld_ccheck(int c, const void *); void* _nc_xx_fld_makearg(va_list*); } // // ------------------------------------------------------------------------- // Abstract base class for User-Defined Fieldtypes // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP UserDefinedFieldType : public NCursesFieldType { friend class UDF_Init; // Internal helper to set up statics private: // For all C++ defined fieldtypes we need only one generic lowlevel // FIELDTYPE* element. static FIELDTYPE* generic_fieldtype; protected: // This are the functions required by the low level libforms functions // to construct a fieldtype. friend bool _nc_xx_fld_fcheck(FIELD *, const void*); friend bool _nc_xx_fld_ccheck(int c, const void *); friend void* _nc_xx_fld_makearg(va_list*); void set(NCursesFormField& f) { OnError(::set_field_type(f.get_field(),fieldtype,&f)); } protected: // Redefine this function to do a field validation. The argument // is a reference to the field you should validate. virtual bool field_check(NCursesFormField& f) = 0; // Redefine this function to do a character validation. The argument // is the character to be validated. virtual bool char_check (int c) = 0; public: UserDefinedFieldType(); }; extern "C" { bool _nc_xx_next_choice(FIELD*, const void *); bool _nc_xx_prev_choice(FIELD*, const void *); } // // ------------------------------------------------------------------------- // Abstract base class for User-Defined Fieldtypes with Choice functions // ------------------------------------------------------------------------- // class NCURSES_CXX_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType { friend class UDF_Init; // Internal helper to set up statics private: // For all C++ defined fieldtypes with choice functions we need only one // generic lowlevel FIELDTYPE* element. static FIELDTYPE* generic_fieldtype_with_choice; // This are the functions required by the low level libforms functions // to construct a fieldtype with choice functions. friend bool _nc_xx_next_choice(FIELD*, const void *); friend bool _nc_xx_prev_choice(FIELD*, const void *); protected: // Redefine this function to do the retrieval of the next choice value. // The argument is a reference to the field tobe examined. virtual bool next (NCursesFormField& f) = 0; // Redefine this function to do the retrieval of the previous choice value. // The argument is a reference to the field tobe examined. virtual bool previous(NCursesFormField& f) = 0; public: UserDefinedFieldType_With_Choice(); }; #endif /* NCURSES_CURSESF_H_incl */ /**************************************************************************** * Copyright 2018-2019,2020 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1995,1997 * ****************************************************************************/ /* $Id: form.h,v 0.31 2020/07/04 20:38:43 tom Exp $ */ #ifndef FORM_H #define FORM_H /* *INDENT-OFF*/ #include <curses.h> #include <eti.h> #ifdef __cplusplus extern "C" { #endif #if defined(BUILDING_FORM) # define FORM_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT #else # define FORM_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT #endif #define FORM_WRAPPED_VAR(type,name) extern FORM_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) #define FORM_EXPORT(type) FORM_IMPEXP type NCURSES_API #define FORM_EXPORT_VAR(type) FORM_IMPEXP type #ifndef FORM_PRIV_H typedef void *FIELD_CELL; #endif #ifndef NCURSES_FIELD_INTERNALS #define NCURSES_FIELD_INTERNALS /* nothing */ #endif typedef int Form_Options; typedef int Field_Options; /********** * _PAGE * **********/ typedef struct pagenode #if !NCURSES_OPAQUE_FORM { short pmin; /* index of first field on page */ short pmax; /* index of last field on page */ short smin; /* index of top leftmost field on page */ short smax; /* index of bottom rightmost field on page */ } #endif /* !NCURSES_OPAQUE_FORM */ _PAGE; /********** * FIELD * **********/ typedef struct fieldnode #if 1 /* not yet: !NCURSES_OPAQUE_FORM */ { unsigned short status; /* flags */ short rows; /* size in rows */ short cols; /* size in cols */ short frow; /* first row */ short fcol; /* first col */ int drows; /* dynamic rows */ int dcols; /* dynamic cols */ int maxgrow; /* maximum field growth */ int nrow; /* off-screen rows */ short nbuf; /* additional buffers */ short just; /* justification */ short page; /* page on form */ short index; /* into form -> field */ int pad; /* pad character */ chtype fore; /* foreground attribute */ chtype back; /* background attribute */ Field_Options opts; /* options */ struct fieldnode * snext; /* sorted order pointer */ struct fieldnode * sprev; /* sorted order pointer */ struct fieldnode * link; /* linked field chain */ struct formnode * form; /* containing form */ struct typenode * type; /* field type */ void * arg; /* argument for type */ FIELD_CELL * buf; /* field buffers */ void * usrptr; /* user pointer */ /* * The wide-character configuration requires extra information. Because * there are existing applications that manipulate the members of FIELD * directly, we cannot make the struct opaque, except by changing the ABI. * Offsets of members up to this point are the same in the narrow- and * wide-character configuration. But note that the type of buf depends on * the configuration, and is made opaque for that reason. */ NCURSES_FIELD_INTERNALS } #endif /* NCURSES_OPAQUE_FORM */ FIELD; /********* * FORM * *********/ typedef struct formnode #if 1 /* not yet: !NCURSES_OPAQUE_FORM */ { unsigned short status; /* flags */ short rows; /* size in rows */ short cols; /* size in cols */ int currow; /* current row in field window */ int curcol; /* current col in field window */ int toprow; /* in scrollable field window */ int begincol; /* in horiz. scrollable field */ short maxfield; /* number of fields */ short maxpage; /* number of pages */ short curpage; /* index into page */ Form_Options opts; /* options */ WINDOW * win; /* window */ WINDOW * sub; /* subwindow */ WINDOW * w; /* window for current field */ FIELD ** field; /* field [maxfield] */ FIELD * current; /* current field */ _PAGE * page; /* page [maxpage] */ void * usrptr; /* user pointer */ void (*forminit)(struct formnode *); void (*formterm)(struct formnode *); void (*fieldinit)(struct formnode *); void (*fieldterm)(struct formnode *); } #endif /* !NCURSES_OPAQUE_FORM */ FORM; /************** * FIELDTYPE * **************/ typedef struct typenode #if !NCURSES_OPAQUE_FORM { unsigned short status; /* flags */ long ref; /* reference count */ struct typenode * left; /* ptr to operand for | */ struct typenode * right; /* ptr to operand for | */ void* (*makearg)(va_list *); /* make fieldtype arg */ void* (*copyarg)(const void *); /* copy fieldtype arg */ void (*freearg)(void *); /* free fieldtype arg */ #if NCURSES_INTEROP_FUNCS union { bool (*ofcheck)(FIELD *,const void *); /* field validation */ bool (*gfcheck)(FORM*,FIELD *,const void*); /* generic field validation */ } fieldcheck; union { bool (*occheck)(int,const void *); /* character validation */ bool (*gccheck)(int,FORM*, FIELD*,const void*); /* generic char validation */ } charcheck; union { bool (*onext)(FIELD *,const void *); /* enumerate next value */ bool (*gnext)(FORM*,FIELD*,const void*); /* generic enumerate next */ } enum_next; union { bool (*oprev)(FIELD *,const void *); /* enumerate prev value */ bool (*gprev)(FORM*,FIELD*,const void*); /* generic enumerate prev */ } enum_prev; void* (*genericarg)(void*); /* Alternate Arg method */ #else bool (*fcheck)(FIELD *,const void *); /* field validation */ bool (*ccheck)(int,const void *); /* character validation */ bool (*next)(FIELD *,const void *); /* enumerate next value */ bool (*prev)(FIELD *,const void *); /* enumerate prev value */ #endif } #endif /* !NCURSES_OPAQUE_FORM */ FIELDTYPE; typedef void (*Form_Hook)(FORM *); /*************************** * miscellaneous #defines * ***************************/ /* field justification */ #define NO_JUSTIFICATION (0) #define JUSTIFY_LEFT (1) #define JUSTIFY_CENTER (2) #define JUSTIFY_RIGHT (3) /* field options */ #define O_VISIBLE (0x0001U) #define O_ACTIVE (0x0002U) #define O_PUBLIC (0x0004U) #define O_EDIT (0x0008U) #define O_WRAP (0x0010U) #define O_BLANK (0x0020U) #define O_AUTOSKIP (0x0040U) #define O_NULLOK (0x0080U) #define O_PASSOK (0x0100U) #define O_STATIC (0x0200U) #define O_DYNAMIC_JUSTIFY (0x0400U) /* ncurses extension */ #define O_NO_LEFT_STRIP (0x0800U) /* ncurses extension */ #define O_EDGE_INSERT_STAY (0x1000U) /* ncurses extension */ #define O_INPUT_LIMIT (0x2000U) /* ncurses extension */ /* form options */ #define O_NL_OVERLOAD (0x0001U) #define O_BS_OVERLOAD (0x0002U) /* form driver commands */ #define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */ #define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */ #define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */ #define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */ #define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */ #define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */ #define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */ #define REQ_LAST_FIELD (KEY_MAX + 8) /* move to last field */ #define REQ_SNEXT_FIELD (KEY_MAX + 9) /* move to sorted next field */ #define REQ_SPREV_FIELD (KEY_MAX + 10) /* move to sorted prev field */ #define REQ_SFIRST_FIELD (KEY_MAX + 11) /* move to sorted first field */ #define REQ_SLAST_FIELD (KEY_MAX + 12) /* move to sorted last field */ #define REQ_LEFT_FIELD (KEY_MAX + 13) /* move to left to field */ #define REQ_RIGHT_FIELD (KEY_MAX + 14) /* move to right to field */ #define REQ_UP_FIELD (KEY_MAX + 15) /* move to up to field */ #define REQ_DOWN_FIELD (KEY_MAX + 16) /* move to down to field */ #define REQ_NEXT_CHAR (KEY_MAX + 17) /* move to next char in field */ #define REQ_PREV_CHAR (KEY_MAX + 18) /* move to prev char in field */ #define REQ_NEXT_LINE (KEY_MAX + 19) /* move to next line in field */ #define REQ_PREV_LINE (KEY_MAX + 20) /* move to prev line in field */ #define REQ_NEXT_WORD (KEY_MAX + 21) /* move to next word in field */ #define REQ_PREV_WORD (KEY_MAX + 22) /* move to prev word in field */ #define REQ_BEG_FIELD (KEY_MAX + 23) /* move to first char in field */ #define REQ_END_FIELD (KEY_MAX + 24) /* move after last char in fld */ #define REQ_BEG_LINE (KEY_MAX + 25) /* move to beginning of line */ #define REQ_END_LINE (KEY_MAX + 26) /* move after last char in line */ #define REQ_LEFT_CHAR (KEY_MAX + 27) /* move left in field */ #define REQ_RIGHT_CHAR (KEY_MAX + 28) /* move right in field */ #define REQ_UP_CHAR (KEY_MAX + 29) /* move up in field */ #define REQ_DOWN_CHAR (KEY_MAX + 30) /* move down in field */ #define REQ_NEW_LINE (KEY_MAX + 31) /* insert/overlay new line */ #define REQ_INS_CHAR (KEY_MAX + 32) /* insert blank char at cursor */ #define REQ_INS_LINE (KEY_MAX + 33) /* insert blank line at cursor */ #define REQ_DEL_CHAR (KEY_MAX + 34) /* delete char at cursor */ #define REQ_DEL_PREV (KEY_MAX + 35) /* delete char before cursor */ #define REQ_DEL_LINE (KEY_MAX + 36) /* delete line at cursor */ #define REQ_DEL_WORD (KEY_MAX + 37) /* delete word at cursor */ #define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */ #define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */ #define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */ #define REQ_OVL_MODE (KEY_MAX + 41) /* begin overlay mode */ #define REQ_INS_MODE (KEY_MAX + 42) /* begin insert mode */ #define REQ_SCR_FLINE (KEY_MAX + 43) /* scroll field forward a line */ #define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */ #define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */ #define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */ #define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page */ #define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page */ #define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */ #define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */ #define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */ #define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */ #define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */ #define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */ #define REQ_VALIDATION (KEY_MAX + 55) /* validate field */ #define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */ #define REQ_PREV_CHOICE (KEY_MAX + 57) /* display prev field choice */ #define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */ #define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */ #if defined(MAX_COMMAND) # if (MAX_FORM_COMMAND > MAX_COMMAND) # error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND # elif (MAX_COMMAND != (KEY_MAX + 128)) # error Something is wrong -- MAX_COMMAND is already inconsistently defined. # endif #else # define MAX_COMMAND (KEY_MAX + 128) #endif /************************* * standard field types * *************************/ extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA; extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM; extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM; extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER; extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC; extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP; /************************************ * built-in additional field types * * They are not defined in SVr4 * ************************************/ extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Version 4 address */ /*********************** * FIELDTYPE routines * ***********************/ extern FORM_EXPORT(FIELDTYPE *) new_fieldtype ( bool (* const field_check)(FIELD *,const void *), bool (* const char_check)(int,const void *)); extern FORM_EXPORT(FIELDTYPE *) link_fieldtype( FIELDTYPE *, FIELDTYPE *); extern FORM_EXPORT(int) free_fieldtype (FIELDTYPE *); extern FORM_EXPORT(int) set_fieldtype_arg (FIELDTYPE *, void * (* const make_arg)(va_list *), void * (* const copy_arg)(const void *), void (* const free_arg)(void *)); extern FORM_EXPORT(int) set_fieldtype_choice (FIELDTYPE *, bool (* const next_choice)(FIELD *,const void *), bool (* const prev_choice)(FIELD *,const void *)); /******************* * FIELD routines * *******************/ extern FORM_EXPORT(FIELD *) new_field (int,int,int,int,int,int); extern FORM_EXPORT(FIELD *) dup_field (FIELD *,int,int); extern FORM_EXPORT(FIELD *) link_field (FIELD *,int,int); extern FORM_EXPORT(int) free_field (FIELD *); extern FORM_EXPORT(int) field_info (const FIELD *,int *,int *,int *,int *,int *,int *); extern FORM_EXPORT(int) dynamic_field_info (const FIELD *,int *,int *,int *); extern FORM_EXPORT(int) set_max_field ( FIELD *,int); extern FORM_EXPORT(int) move_field (FIELD *,int,int); extern FORM_EXPORT(int) set_field_type (FIELD *,FIELDTYPE *,...); extern FORM_EXPORT(int) set_new_page (FIELD *,bool); extern FORM_EXPORT(int) set_field_just (FIELD *,int); extern FORM_EXPORT(int) field_just (const FIELD *); extern FORM_EXPORT(int) set_field_fore (FIELD *,chtype); extern FORM_EXPORT(int) set_field_back (FIELD *,chtype); extern FORM_EXPORT(int) set_field_pad (FIELD *,int); extern FORM_EXPORT(int) field_pad (const FIELD *); extern FORM_EXPORT(int) set_field_buffer (FIELD *,int,const char *); extern FORM_EXPORT(int) set_field_status (FIELD *,bool); extern FORM_EXPORT(int) set_field_userptr (FIELD *, void *); extern FORM_EXPORT(int) set_field_opts (FIELD *,Field_Options); extern FORM_EXPORT(int) field_opts_on (FIELD *,Field_Options); extern FORM_EXPORT(int) field_opts_off (FIELD *,Field_Options); extern FORM_EXPORT(chtype) field_fore (const FIELD *); extern FORM_EXPORT(chtype) field_back (const FIELD *); extern FORM_EXPORT(bool) new_page (const FIELD *); extern FORM_EXPORT(bool) field_status (const FIELD *); extern FORM_EXPORT(void *) field_arg (const FIELD *); extern FORM_EXPORT(void *) field_userptr (const FIELD *); extern FORM_EXPORT(FIELDTYPE *) field_type (const FIELD *); extern FORM_EXPORT(char *) field_buffer (const FIELD *,int); extern FORM_EXPORT(Field_Options) field_opts (const FIELD *); /****************** * FORM routines * ******************/ extern FORM_EXPORT(FORM *) new_form (FIELD **); extern FORM_EXPORT(FIELD **) form_fields (const FORM *); extern FORM_EXPORT(FIELD *) current_field (const FORM *); extern FORM_EXPORT(WINDOW *) form_win (const FORM *); extern FORM_EXPORT(WINDOW *) form_sub (const FORM *); extern FORM_EXPORT(Form_Hook) form_init (const FORM *); extern FORM_EXPORT(Form_Hook) form_term (const FORM *); extern FORM_EXPORT(Form_Hook) field_init (const FORM *); extern FORM_EXPORT(Form_Hook) field_term (const FORM *); extern FORM_EXPORT(int) free_form (FORM *); extern FORM_EXPORT(int) set_form_fields (FORM *,FIELD **); extern FORM_EXPORT(int) field_count (const FORM *); extern FORM_EXPORT(int) set_form_win (FORM *,WINDOW *); extern FORM_EXPORT(int) set_form_sub (FORM *,WINDOW *); extern FORM_EXPORT(int) set_current_field (FORM *,FIELD *); extern FORM_EXPORT(int) unfocus_current_field (FORM *); extern FORM_EXPORT(int) field_index (const FIELD *); extern FORM_EXPORT(int) set_form_page (FORM *,int); extern FORM_EXPORT(int) form_page (const FORM *); extern FORM_EXPORT(int) scale_form (const FORM *,int *,int *); extern FORM_EXPORT(int) set_form_init (FORM *,Form_Hook); extern FORM_EXPORT(int) set_form_term (FORM *,Form_Hook); extern FORM_EXPORT(int) set_field_init (FORM *,Form_Hook); extern FORM_EXPORT(int) set_field_term (FORM *,Form_Hook); extern FORM_EXPORT(int) post_form (FORM *); extern FORM_EXPORT(int) unpost_form (FORM *); extern FORM_EXPORT(int) pos_form_cursor (FORM *); extern FORM_EXPORT(int) form_driver (FORM *,int); # if NCURSES_WIDECHAR extern FORM_EXPORT(int) form_driver_w (FORM *,int,wchar_t); # endif extern FORM_EXPORT(int) set_form_userptr (FORM *,void *); extern FORM_EXPORT(int) set_form_opts (FORM *,Form_Options); extern FORM_EXPORT(int) form_opts_on (FORM *,Form_Options); extern FORM_EXPORT(int) form_opts_off (FORM *,Form_Options); extern FORM_EXPORT(int) form_request_by_name (const char *); extern FORM_EXPORT(const char *) form_request_name (int); extern FORM_EXPORT(void *) form_userptr (const FORM *); extern FORM_EXPORT(Form_Options) form_opts (const FORM *); extern FORM_EXPORT(bool) data_ahead (const FORM *); extern FORM_EXPORT(bool) data_behind (const FORM *); #if NCURSES_SP_FUNCS extern FORM_EXPORT(FORM *) NCURSES_SP_NAME(new_form) (SCREEN*, FIELD **); #endif #ifdef __cplusplus } #endif /* *INDENT-ON*/ #endif /* FORM_H */ /**************************************************************************** * Copyright 2018-2019,2020 Thomas E. Dickey * * Copyright 1998-2015,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Thomas E. Dickey 1998-on * ****************************************************************************/ /* $Id: term_entry.h,v 1.60 2020/02/29 15:46:00 anonymous.maarten Exp $ */ /* * term_entry.h -- interface to entry-manipulation code */ #ifndef NCURSES_TERM_ENTRY_H_incl #define NCURSES_TERM_ENTRY_H_incl 1 /* *INDENT-OFF* */ #ifdef __cplusplus extern "C" { #endif #include <curses.h> #include <term.h> /* * These macros may be used by programs that know about TERMTYPE: */ #if NCURSES_XNAMES #define NUM_BOOLEANS(tp) (tp)->num_Booleans #define NUM_NUMBERS(tp) (tp)->num_Numbers #define NUM_STRINGS(tp) (tp)->num_Strings #define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i] #else #define NUM_BOOLEANS(tp) BOOLCOUNT #define NUM_NUMBERS(tp) NUMCOUNT #define NUM_STRINGS(tp) STRCOUNT #define EXT_NAMES(tp,i,limit,index,table) table[i] #endif #define NUM_EXT_NAMES(tp) (unsigned) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings) #define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++) #define for_each_number(n,tp) for(n = 0; n < NUM_NUMBERS(tp); n++) #define for_each_string(n,tp) for(n = 0; n < NUM_STRINGS(tp); n++) #if NCURSES_XNAMES #define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; (int) n < (int) NUM_BOOLEANS(tp); n++) #define for_each_ext_number(n,tp) for(n = NUMCOUNT; (int) n < (int) NUM_NUMBERS(tp); n++) #define for_each_ext_string(n,tp) for(n = STRCOUNT; (int) n < (int) NUM_STRINGS(tp); n++) #endif #define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names) #define ExtNumname(tp,i,names) EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names) #define ExtStrname(tp,i,names) EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names) /* * The remaining type-definitions and macros are used only internally by the * ncurses utilities. */ #ifdef NCURSES_INTERNALS /* * see db_iterator.c - this enumeration lists the places searched for a * terminal description and defines the order in which they are searched. */ typedef enum { dbdTIC = 0, /* special, used by tic when writing entry */ #if NCURSES_USE_DATABASE dbdEnvOnce, /* the $TERMINFO environment variable */ dbdHome, /* $HOME/.terminfo */ dbdEnvList, /* the $TERMINFO_DIRS environment variable */ dbdCfgList, /* the compiled-in TERMINFO_DIRS value */ dbdCfgOnce, /* the compiled-in TERMINFO value */ #endif #if NCURSES_USE_TERMCAP dbdEnvOnce2, /* the $TERMCAP environment variable */ dbdEnvList2, /* the $TERMPATH environment variable */ dbdCfgList2, /* the compiled-in TERMPATH */ #endif dbdLAST } DBDIRS; #define MAX_USES 32 #define MAX_CROSSLINKS 16 typedef struct entry ENTRY; typedef struct { char *name; ENTRY *link; long line; } ENTRY_USES; struct entry { TERMTYPE2 tterm; unsigned nuses; ENTRY_USES uses[MAX_USES]; int ncrosslinks; ENTRY *crosslinks[MAX_CROSSLINKS]; long cstart; long cend; long startline; ENTRY *next; ENTRY *last; }; extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head; extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail; #define for_entry_list(qp) for (qp = _nc_head; qp; qp = qp->next) #define MAX_LINE 132 #define NULLHOOK (bool(*)(ENTRY *))0 /* * Note that WANTED and PRESENT are not simple inverses! If a capability * has been explicitly cancelled, it's not considered WANTED. */ #define WANTED(s) ((s) == ABSENT_STRING) #define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING)) #define ANDMISSING(p,q) \ { \ if (PRESENT(p) && !PRESENT(q)) \ _nc_warning(#p " but no " #q); \ } #define PAIRED(p,q) \ { \ if (PRESENT(q) && !PRESENT(p)) \ _nc_warning(#q " but no " #p); \ if (PRESENT(p) && !PRESENT(q)) \ _nc_warning(#p " but no " #q); \ } /* * These entrypoints are used only by the ncurses utilities such as tic. */ /* alloc_entry.c: elementary allocation code */ extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp); extern NCURSES_EXPORT(char *) _nc_save_str (const char *const); extern NCURSES_EXPORT(void) _nc_init_entry (ENTRY *const); extern NCURSES_EXPORT(void) _nc_merge_entry (ENTRY *const, ENTRY *const); extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool); /* alloc_ttype.c: elementary allocation code */ extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE2 *, TERMTYPE2 *); /* free_ttype.c: elementary allocation code */ extern NCURSES_EXPORT(void) _nc_free_termtype2 (TERMTYPE2 *); /* lib_termcap.c: trim sgr0 string for termcap users */ extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE2 *); /* parse_entry.c: entry-parsing code */ #if NCURSES_XNAMES extern NCURSES_EXPORT_VAR(bool) _nc_user_definable; extern NCURSES_EXPORT_VAR(bool) _nc_disable_period; #endif extern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool); extern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *); /* write_entry.c: writing an entry to the file system */ extern NCURSES_EXPORT(void) _nc_set_writedir (const char *); extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE2 *const); extern NCURSES_EXPORT(int) _nc_write_object (TERMTYPE2 *, char *, unsigned *, unsigned); /* comp_parse.c: entry list handling */ extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*)); extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *); extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */ extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool); extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *); extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */ extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2)(TERMTYPE2 *, bool); /* trace_xnames.c */ extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *); #endif /* NCURSES_INTERNALS */ /* * These entrypoints were used by tack before 1.08. */ #undef NCURSES_TACK_1_08 #ifdef NCURSES_INTERNALS #define NCURSES_TACK_1_08 /* nothing */ #else #define NCURSES_TACK_1_08 GCC_DEPRECATED("upgrade to tack 1.08") #endif /* alloc_ttype.c: elementary allocation code */ extern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, const TERMTYPE *) NCURSES_TACK_1_08; /* lib_acs.c */ extern NCURSES_EXPORT(void) _nc_init_acs (void) NCURSES_TACK_1_08; /* corresponds to traditional 'init_acs()' */ /* free_ttype.c: elementary allocation code */ extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *) NCURSES_TACK_1_08; #ifdef __cplusplus } #endif /* *INDENT-ON* */ #endif /* NCURSES_TERM_ENTRY_H_incl */ /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2013,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /****************************************************************************/ /* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 */ /* and: Eric S. Raymond <esr@snark.thyrsus.com> */ /* and: Thomas E. Dickey 1995-on */ /****************************************************************************/ /* $Id: MKterm.h.awk.in,v 1.79 2021/03/20 16:08:03 tom Exp $ */ /* ** term.h -- Definition of struct term */ #ifndef NCURSES_TERM_H_incl #define NCURSES_TERM_H_incl 1 #undef NCURSES_VERSION #define NCURSES_VERSION "6.2" #include <ncurses_dll.h> #ifdef __cplusplus extern "C" { #endif /* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H * definition (based on the system for which this was configured). */ #ifndef __NCURSES_H typedef struct screen SCREEN; #if 1 #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 20210508 #undef NCURSES_SP_NAME #define NCURSES_SP_NAME(name) name##_sp /* Define the sp-funcs helper function */ #undef NCURSES_SP_OUTC #define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC) typedef int (*NCURSES_SP_OUTC)(SCREEN*, int); #endif #endif /* __NCURSES_H */ #undef NCURSES_CONST #define NCURSES_CONST const #undef NCURSES_SBOOL #define NCURSES_SBOOL char #undef NCURSES_USE_DATABASE #define NCURSES_USE_DATABASE 1 #undef NCURSES_USE_TERMCAP #define NCURSES_USE_TERMCAP 0 #undef NCURSES_XNAMES #define NCURSES_XNAMES 1 /* We will use these symbols to hide differences between * termios/termio/sgttyb interfaces. */ #undef TTY #undef SET_TTY #undef GET_TTY /* Assume POSIX termio if we have the header and function */ /* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */ #if 1 && 1 #undef TERMIOS #define TERMIOS 1 #include <termios.h> #define TTY struct termios #else /* !HAVE_TERMIOS_H */ /* #if HAVE_TERMIO_H */ #if 1 #undef TERMIOS #define TERMIOS 1 #include <termio.h> #define TTY struct termio #else /* !HAVE_TERMIO_H */ #if (defined(_WIN32) || defined(_WIN64)) #if 0 #include <win32_curses.h> #define TTY struct winconmode #else #include <ncurses_mingw.h> #define TTY struct termios #endif #else #undef TERMIOS #include <sgtty.h> #include <sys/ioctl.h> #define TTY struct sgttyb #endif /* MINGW32 */ #endif /* HAVE_TERMIO_H */ #endif /* HAVE_TERMIOS_H */ #ifdef TERMIOS #define GET_TTY(fd, buf) tcgetattr(fd, buf) #define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf) #elif 0 && (defined(_WIN32) || defined(_WIN64)) #define GET_TTY(fd, buf) _nc_console_getmode(_nc_console_fd2handle(fd),buf) #define SET_TTY(fd, buf) _nc_console_setmode(_nc_console_fd2handle(fd),buf) #else #define GET_TTY(fd, buf) gtty(fd, buf) #define SET_TTY(fd, buf) stty(fd, buf) #endif #ifndef GCC_NORETURN #define GCC_NORETURN /* nothing */ #endif #define NAMESIZE 256 /* The cast works because TERMTYPE is the first data in TERMINAL */ #define CUR ((TERMTYPE *)(cur_term))-> #define auto_left_margin CUR Booleans[0] #define auto_right_margin CUR Booleans[1] #define no_esc_ctlc CUR Booleans[2] #define ceol_standout_glitch CUR Booleans[3] #define eat_newline_glitch CUR Booleans[4] #define erase_overstrike CUR Booleans[5] #define generic_type CUR Booleans[6] #define hard_copy CUR Booleans[7] #define has_meta_key CUR Booleans[8] #define has_status_line CUR Booleans[9] #define insert_null_glitch CUR Booleans[10] #define memory_above CUR Booleans[11] #define memory_below CUR Booleans[12] #define move_insert_mode CUR Booleans[13] #define move_standout_mode CUR Booleans[14] #define over_strike CUR Booleans[15] #define status_line_esc_ok CUR Booleans[16] #define dest_tabs_magic_smso CUR Booleans[17] #define tilde_glitch CUR Booleans[18] #define transparent_underline CUR Booleans[19] #define xon_xoff CUR Booleans[20] #define needs_xon_xoff CUR Booleans[21] #define prtr_silent CUR Booleans[22] #define hard_cursor CUR Booleans[23] #define non_rev_rmcup CUR Booleans[24] #define no_pad_char CUR Booleans[25] #define non_dest_scroll_region CUR Booleans[26] #define can_change CUR Booleans[27] #define back_color_erase CUR Booleans[28] #define hue_lightness_saturation CUR Booleans[29] #define col_addr_glitch CUR Booleans[30] #define cr_cancels_micro_mode CUR Booleans[31] #define has_print_wheel CUR Booleans[32] #define row_addr_glitch CUR Booleans[33] #define semi_auto_right_margin CUR Booleans[34] #define cpi_changes_res CUR Booleans[35] #define lpi_changes_res CUR Booleans[36] #define columns CUR Numbers[0] #define init_tabs CUR Numbers[1] #define lines CUR Numbers[2] #define lines_of_memory CUR Numbers[3] #define magic_cookie_glitch CUR Numbers[4] #define padding_baud_rate CUR Numbers[5] #define virtual_terminal CUR Numbers[6] #define width_status_line CUR Numbers[7] #define num_labels CUR Numbers[8] #define label_height CUR Numbers[9] #define label_width CUR Numbers[10] #define max_attributes CUR Numbers[11] #define maximum_windows CUR Numbers[12] #define max_colors CUR Numbers[13] #define max_pairs CUR Numbers[14] #define no_color_video CUR Numbers[15] #define buffer_capacity CUR Numbers[16] #define dot_vert_spacing CUR Numbers[17] #define dot_horz_spacing CUR Numbers[18] #define max_micro_address CUR Numbers[19] #define max_micro_jump CUR Numbers[20] #define micro_col_size CUR Numbers[21] #define micro_line_size CUR Numbers[22] #define number_of_pins CUR Numbers[23] #define output_res_char CUR Numbers[24] #define output_res_line CUR Numbers[25] #define output_res_horz_inch CUR Numbers[26] #define output_res_vert_inch CUR Numbers[27] #define print_rate CUR Numbers[28] #define wide_char_size CUR Numbers[29] #define buttons CUR Numbers[30] #define bit_image_entwining CUR Numbers[31] #define bit_image_type CUR Numbers[32] #define back_tab CUR Strings[0] #define bell CUR Strings[1] #define carriage_return CUR Strings[2] #define change_scroll_region CUR Strings[3] #define clear_all_tabs CUR Strings[4] #define clear_screen CUR Strings[5] #define clr_eol CUR Strings[6] #define clr_eos CUR Strings[7] #define column_address CUR Strings[8] #define command_character CUR Strings[9] #define cursor_address CUR Strings[10] #define cursor_down CUR Strings[11] #define cursor_home CUR Strings[12] #define cursor_invisible CUR Strings[13] #define cursor_left CUR Strings[14] #define cursor_mem_address CUR Strings[15] #define cursor_normal CUR Strings[16] #define cursor_right CUR Strings[17] #define cursor_to_ll CUR Strings[18] #define cursor_up CUR Strings[19] #define cursor_visible CUR Strings[20] #define delete_character CUR Strings[21] #define delete_line CUR Strings[22] #define dis_status_line CUR Strings[23] #define down_half_line CUR Strings[24] #define enter_alt_charset_mode CUR Strings[25] #define enter_blink_mode CUR Strings[26] #define enter_bold_mode CUR Strings[27] #define enter_ca_mode CUR Strings[28] #define enter_delete_mode CUR Strings[29] #define enter_dim_mode CUR Strings[30] #define enter_insert_mode CUR Strings[31] #define enter_secure_mode CUR Strings[32] #define enter_protected_mode CUR Strings[33] #define enter_reverse_mode CUR Strings[34] #define enter_standout_mode CUR Strings[35] #define enter_underline_mode CUR Strings[36] #define erase_chars CUR Strings[37] #define exit_alt_charset_mode CUR Strings[38] #define exit_attribute_mode CUR Strings[39] #define exit_ca_mode CUR Strings[40] #define exit_delete_mode CUR Strings[41] #define exit_insert_mode CUR Strings[42] #define exit_standout_mode CUR Strings[43] #define exit_underline_mode CUR Strings[44] #define flash_screen CUR Strings[45] #define form_feed CUR Strings[46] #define from_status_line CUR Strings[47] #define init_1string CUR Strings[48] #define init_2string CUR Strings[49] #define init_3string CUR Strings[50] #define init_file CUR Strings[51] #define insert_character CUR Strings[52] #define insert_line CUR Strings[53] #define insert_padding CUR Strings[54] #define key_backspace CUR Strings[55] #define key_catab CUR Strings[56] #define key_clear CUR Strings[57] #define key_ctab CUR Strings[58] #define key_dc CUR Strings[59] #define key_dl CUR Strings[60] #define key_down CUR Strings[61] #define key_eic CUR Strings[62] #define key_eol CUR Strings[63] #define key_eos CUR Strings[64] #define key_f0 CUR Strings[65] #define key_f1 CUR Strings[66] #define key_f10 CUR Strings[67] #define key_f2 CUR Strings[68] #define key_f3 CUR Strings[69] #define key_f4 CUR Strings[70] #define key_f5 CUR Strings[71] #define key_f6 CUR Strings[72] #define key_f7 CUR Strings[73] #define key_f8 CUR Strings[74] #define key_f9 CUR Strings[75] #define key_home CUR Strings[76] #define key_ic CUR Strings[77] #define key_il CUR Strings[78] #define key_left CUR Strings[79] #define key_ll CUR Strings[80] #define key_npage CUR Strings[81] #define key_ppage CUR Strings[82] #define key_right CUR Strings[83] #define key_sf CUR Strings[84] #define key_sr CUR Strings[85] #define key_stab CUR Strings[86] #define key_up CUR Strings[87] #define keypad_local CUR Strings[88] #define keypad_xmit CUR Strings[89] #define lab_f0 CUR Strings[90] #define lab_f1 CUR Strings[91] #define lab_f10 CUR Strings[92] #define lab_f2 CUR Strings[93] #define lab_f3 CUR Strings[94] #define lab_f4 CUR Strings[95] #define lab_f5 CUR Strings[96] #define lab_f6 CUR Strings[97] #define lab_f7 CUR Strings[98] #define lab_f8 CUR Strings[99] #define lab_f9 CUR Strings[100] #define meta_off CUR Strings[101] #define meta_on CUR Strings[102] #define newline CUR Strings[103] #define pad_char CUR Strings[104] #define parm_dch CUR Strings[105] #define parm_delete_line CUR Strings[106] #define parm_down_cursor CUR Strings[107] #define parm_ich CUR Strings[108] #define parm_index CUR Strings[109] #define parm_insert_line CUR Strings[110] #define parm_left_cursor CUR Strings[111] #define parm_right_cursor CUR Strings[112] #define parm_rindex CUR Strings[113] #define parm_up_cursor CUR Strings[114] #define pkey_key CUR Strings[115] #define pkey_local CUR Strings[116] #define pkey_xmit CUR Strings[117] #define print_screen CUR Strings[118] #define prtr_off CUR Strings[119] #define prtr_on CUR Strings[120] #define repeat_char CUR Strings[121] #define reset_1string CUR Strings[122] #define reset_2string CUR Strings[123] #define reset_3string CUR Strings[124] #define reset_file CUR Strings[125] #define restore_cursor CUR Strings[126] #define row_address CUR Strings[127] #define save_cursor CUR Strings[128] #define scroll_forward CUR Strings[129] #define scroll_reverse CUR Strings[130] #define set_attributes CUR Strings[131] #define set_tab CUR Strings[132] #define set_window CUR Strings[133] #define tab CUR Strings[134] #define to_status_line CUR Strings[135] #define underline_char CUR Strings[136] #define up_half_line CUR Strings[137] #define init_prog CUR Strings[138] #define key_a1 CUR Strings[139] #define key_a3 CUR Strings[140] #define key_b2 CUR Strings[141] #define key_c1 CUR Strings[142] #define key_c3 CUR Strings[143] #define prtr_non CUR Strings[144] #define char_padding CUR Strings[145] #define acs_chars CUR Strings[146] #define plab_norm CUR Strings[147] #define key_btab CUR Strings[148] #define enter_xon_mode CUR Strings[149] #define exit_xon_mode CUR Strings[150] #define enter_am_mode CUR Strings[151] #define exit_am_mode CUR Strings[152] #define xon_character CUR Strings[153] #define xoff_character CUR Strings[154] #define ena_acs CUR Strings[155] #define label_on CUR Strings[156] #define label_off CUR Strings[157] #define key_beg CUR Strings[158] #define key_cancel CUR Strings[159] #define key_close CUR Strings[160] #define key_command CUR Strings[161] #define key_copy CUR Strings[162] #define key_create CUR Strings[163] #define key_end CUR Strings[164] #define key_enter CUR Strings[165] #define key_exit CUR Strings[166] #define key_find CUR Strings[167] #define key_help CUR Strings[168] #define key_mark CUR Strings[169] #define key_message CUR Strings[170] #define key_move CUR Strings[171] #define key_next CUR Strings[172] #define key_open CUR Strings[173] #define key_options CUR Strings[174] #define key_previous CUR Strings[175] #define key_print CUR Strings[176] #define key_redo CUR Strings[177] #define key_reference CUR Strings[178] #define key_refresh CUR Strings[179] #define key_replace CUR Strings[180] #define key_restart CUR Strings[181] #define key_resume CUR Strings[182] #define key_save CUR Strings[183] #define key_suspend CUR Strings[184] #define key_undo CUR Strings[185] #define key_sbeg CUR Strings[186] #define key_scancel CUR Strings[187] #define key_scommand CUR Strings[188] #define key_scopy CUR Strings[189] #define key_screate CUR Strings[190] #define key_sdc CUR Strings[191] #define key_sdl CUR Strings[192] #define key_select CUR Strings[193] #define key_send CUR Strings[194] #define key_seol CUR Strings[195] #define key_sexit CUR Strings[196] #define key_sfind CUR Strings[197] #define key_shelp CUR Strings[198] #define key_shome CUR Strings[199] #define key_sic CUR Strings[200] #define key_sleft CUR Strings[201] #define key_smessage CUR Strings[202] #define key_smove CUR Strings[203] #define key_snext CUR Strings[204] #define key_soptions CUR Strings[205] #define key_sprevious CUR Strings[206] #define key_sprint CUR Strings[207] #define key_sredo CUR Strings[208] #define key_sreplace CUR Strings[209] #define key_sright CUR Strings[210] #define key_srsume CUR Strings[211] #define key_ssave CUR Strings[212] #define key_ssuspend CUR Strings[213] #define key_sundo CUR Strings[214] #define req_for_input CUR Strings[215] #define key_f11 CUR Strings[216] #define key_f12 CUR Strings[217] #define key_f13 CUR Strings[218] #define key_f14 CUR Strings[219] #define key_f15 CUR Strings[220] #define key_f16 CUR Strings[221] #define key_f17 CUR Strings[222] #define key_f18 CUR Strings[223] #define key_f19 CUR Strings[224] #define key_f20 CUR Strings[225] #define key_f21 CUR Strings[226] #define key_f22 CUR Strings[227] #define key_f23 CUR Strings[228] #define key_f24 CUR Strings[229] #define key_f25 CUR Strings[230] #define key_f26 CUR Strings[231] #define key_f27 CUR Strings[232] #define key_f28 CUR Strings[233] #define key_f29 CUR Strings[234] #define key_f30 CUR Strings[235] #define key_f31 CUR Strings[236] #define key_f32 CUR Strings[237] #define key_f33 CUR Strings[238] #define key_f34 CUR Strings[239] #define key_f35 CUR Strings[240] #define key_f36 CUR Strings[241] #define key_f37 CUR Strings[242] #define key_f38 CUR Strings[243] #define key_f39 CUR Strings[244] #define key_f40 CUR Strings[245] #define key_f41 CUR Strings[246] #define key_f42 CUR Strings[247] #define key_f43 CUR Strings[248] #define key_f44 CUR Strings[249] #define key_f45 CUR Strings[250] #define key_f46 CUR Strings[251] #define key_f47 CUR Strings[252] #define key_f48 CUR Strings[253] #define key_f49 CUR Strings[254] #define key_f50 CUR Strings[255] #define key_f51 CUR Strings[256] #define key_f52 CUR Strings[257] #define key_f53 CUR Strings[258] #define key_f54 CUR Strings[259] #define key_f55 CUR Strings[260] #define key_f56 CUR Strings[261] #define key_f57 CUR Strings[262] #define key_f58 CUR Strings[263] #define key_f59 CUR Strings[264] #define key_f60 CUR Strings[265] #define key_f61 CUR Strings[266] #define key_f62 CUR Strings[267] #define key_f63 CUR Strings[268] #define clr_bol CUR Strings[269] #define clear_margins CUR Strings[270] #define set_left_margin CUR Strings[271] #define set_right_margin CUR Strings[272] #define label_format CUR Strings[273] #define set_clock CUR Strings[274] #define display_clock CUR Strings[275] #define remove_clock CUR Strings[276] #define create_window CUR Strings[277] #define goto_window CUR Strings[278] #define hangup CUR Strings[279] #define dial_phone CUR Strings[280] #define quick_dial CUR Strings[281] #define tone CUR Strings[282] #define pulse CUR Strings[283] #define flash_hook CUR Strings[284] #define fixed_pause CUR Strings[285] #define wait_tone CUR Strings[286] #define user0 CUR Strings[287] #define user1 CUR Strings[288] #define user2 CUR Strings[289] #define user3 CUR Strings[290] #define user4 CUR Strings[291] #define user5 CUR Strings[292] #define user6 CUR Strings[293] #define user7 CUR Strings[294] #define user8 CUR Strings[295] #define user9 CUR Strings[296] #define orig_pair CUR Strings[297] #define orig_colors CUR Strings[298] #define initialize_color CUR Strings[299] #define initialize_pair CUR Strings[300] #define set_color_pair CUR Strings[301] #define set_foreground CUR Strings[302] #define set_background CUR Strings[303] #define change_char_pitch CUR Strings[304] #define change_line_pitch CUR Strings[305] #define change_res_horz CUR Strings[306] #define change_res_vert CUR Strings[307] #define define_char CUR Strings[308] #define enter_doublewide_mode CUR Strings[309] #define enter_draft_quality CUR Strings[310] #define enter_italics_mode CUR Strings[311] #define enter_leftward_mode CUR Strings[312] #define enter_micro_mode CUR Strings[313] #define enter_near_letter_quality CUR Strings[314] #define enter_normal_quality CUR Strings[315] #define enter_shadow_mode CUR Strings[316] #define enter_subscript_mode CUR Strings[317] #define enter_superscript_mode CUR Strings[318] #define enter_upward_mode CUR Strings[319] #define exit_doublewide_mode CUR Strings[320] #define exit_italics_mode CUR Strings[321] #define exit_leftward_mode CUR Strings[322] #define exit_micro_mode CUR Strings[323] #define exit_shadow_mode CUR Strings[324] #define exit_subscript_mode CUR Strings[325] #define exit_superscript_mode CUR Strings[326] #define exit_upward_mode CUR Strings[327] #define micro_column_address CUR Strings[328] #define micro_down CUR Strings[329] #define micro_left CUR Strings[330] #define micro_right CUR Strings[331] #define micro_row_address CUR Strings[332] #define micro_up CUR Strings[333] #define order_of_pins CUR Strings[334] #define parm_down_micro CUR Strings[335] #define parm_left_micro CUR Strings[336] #define parm_right_micro CUR Strings[337] #define parm_up_micro CUR Strings[338] #define select_char_set CUR Strings[339] #define set_bottom_margin CUR Strings[340] #define set_bottom_margin_parm CUR Strings[341] #define set_left_margin_parm CUR Strings[342] #define set_right_margin_parm CUR Strings[343] #define set_top_margin CUR Strings[344] #define set_top_margin_parm CUR Strings[345] #define start_bit_image CUR Strings[346] #define start_char_set_def CUR Strings[347] #define stop_bit_image CUR Strings[348] #define stop_char_set_def CUR Strings[349] #define subscript_characters CUR Strings[350] #define superscript_characters CUR Strings[351] #define these_cause_cr CUR Strings[352] #define zero_motion CUR Strings[353] #define char_set_names CUR Strings[354] #define key_mouse CUR Strings[355] #define mouse_info CUR Strings[356] #define req_mouse_pos CUR Strings[357] #define get_mouse CUR Strings[358] #define set_a_foreground CUR Strings[359] #define set_a_background CUR Strings[360] #define pkey_plab CUR Strings[361] #define device_type CUR Strings[362] #define code_set_init CUR Strings[363] #define set0_des_seq CUR Strings[364] #define set1_des_seq CUR Strings[365] #define set2_des_seq CUR Strings[366] #define set3_des_seq CUR Strings[367] #define set_lr_margin CUR Strings[368] #define set_tb_margin CUR Strings[369] #define bit_image_repeat CUR Strings[370] #define bit_image_newline CUR Strings[371] #define bit_image_carriage_return CUR Strings[372] #define color_names CUR Strings[373] #define define_bit_image_region CUR Strings[374] #define end_bit_image_region CUR Strings[375] #define set_color_band CUR Strings[376] #define set_page_length CUR Strings[377] #define display_pc_char CUR Strings[378] #define enter_pc_charset_mode CUR Strings[379] #define exit_pc_charset_mode CUR Strings[380] #define enter_scancode_mode CUR Strings[381] #define exit_scancode_mode CUR Strings[382] #define pc_term_options CUR Strings[383] #define scancode_escape CUR Strings[384] #define alt_scancode_esc CUR Strings[385] #define enter_horizontal_hl_mode CUR Strings[386] #define enter_left_hl_mode CUR Strings[387] #define enter_low_hl_mode CUR Strings[388] #define enter_right_hl_mode CUR Strings[389] #define enter_top_hl_mode CUR Strings[390] #define enter_vertical_hl_mode CUR Strings[391] #define set_a_attributes CUR Strings[392] #define set_pglen_inch CUR Strings[393] #define BOOLWRITE 37 #define NUMWRITE 33 #define STRWRITE 394 /* older synonyms for some capabilities */ #define beehive_glitch no_esc_ctlc #define teleray_glitch dest_tabs_magic_smso /* HPUX-11 uses this name rather than the standard one */ #ifndef micro_char_size #define micro_char_size micro_col_size #endif #ifdef __INTERNAL_CAPS_VISIBLE #define termcap_init2 CUR Strings[394] #define termcap_reset CUR Strings[395] #define magic_cookie_glitch_ul CUR Numbers[33] #define backspaces_with_bs CUR Booleans[37] #define crt_no_scrolling CUR Booleans[38] #define no_correctly_working_cr CUR Booleans[39] #define carriage_return_delay CUR Numbers[34] #define new_line_delay CUR Numbers[35] #define linefeed_if_not_lf CUR Strings[396] #define backspace_if_not_bs CUR Strings[397] #define gnu_has_meta_key CUR Booleans[40] #define linefeed_is_newline CUR Booleans[41] #define backspace_delay CUR Numbers[36] #define horizontal_tab_delay CUR Numbers[37] #define number_of_function_keys CUR Numbers[38] #define other_non_function_keys CUR Strings[398] #define arrow_key_map CUR Strings[399] #define has_hardware_tabs CUR Booleans[42] #define return_does_clr_eol CUR Booleans[43] #define acs_ulcorner CUR Strings[400] #define acs_llcorner CUR Strings[401] #define acs_urcorner CUR Strings[402] #define acs_lrcorner CUR Strings[403] #define acs_ltee CUR Strings[404] #define acs_rtee CUR Strings[405] #define acs_btee CUR Strings[406] #define acs_ttee CUR Strings[407] #define acs_hline CUR Strings[408] #define acs_vline CUR Strings[409] #define acs_plus CUR Strings[410] #define memory_lock CUR Strings[411] #define memory_unlock CUR Strings[412] #define box_chars_1 CUR Strings[413] #endif /* __INTERNAL_CAPS_VISIBLE */ /* * Predefined terminfo array sizes */ #define BOOLCOUNT 44 #define NUMCOUNT 39 #define STRCOUNT 414 /* used by code for comparing entries */ #define acs_chars_index 146 typedef struct termtype { /* in-core form of terminfo data */ char *term_names; /* str_table offset of term names */ char *str_table; /* pointer to string table */ NCURSES_SBOOL *Booleans; /* array of boolean values */ short *Numbers; /* array of integer values */ char **Strings; /* array of string offsets */ #if NCURSES_XNAMES char *ext_str_table; /* pointer to extended string table */ char **ext_Names; /* corresponding names */ unsigned short num_Booleans;/* count total Booleans */ unsigned short num_Numbers; /* count total Numbers */ unsigned short num_Strings; /* count total Strings */ unsigned short ext_Booleans;/* count extensions to Booleans */ unsigned short ext_Numbers; /* count extensions to Numbers */ unsigned short ext_Strings; /* count extensions to Strings */ #endif /* NCURSES_XNAMES */ } TERMTYPE; /* * The only reason these structures are visible is for read-only use. * Programs which modify the data are not, never were, portable across * curses implementations. */ #ifdef NCURSES_INTERNALS typedef struct termtype2 { /* in-core form of terminfo data */ char *term_names; /* str_table offset of term names */ char *str_table; /* pointer to string table */ NCURSES_SBOOL *Booleans; /* array of boolean values */ int *Numbers; /* array of integer values */ char **Strings; /* array of string offsets */ #if NCURSES_XNAMES char *ext_str_table; /* pointer to extended string table */ char **ext_Names; /* corresponding names */ unsigned short num_Booleans;/* count total Booleans */ unsigned short num_Numbers; /* count total Numbers */ unsigned short num_Strings; /* count total Strings */ unsigned short ext_Booleans;/* count extensions to Booleans */ unsigned short ext_Numbers; /* count extensions to Numbers */ unsigned short ext_Strings; /* count extensions to Strings */ #endif /* NCURSES_XNAMES */ } TERMTYPE2; typedef struct term { /* describe an actual terminal */ TERMTYPE type; /* terminal type description */ short Filedes; /* file description being written to */ TTY Ottyb; /* original state of the terminal */ TTY Nttyb; /* current state of the terminal */ int _baudrate; /* used to compute padding */ char * _termname; /* used for termname() */ TERMTYPE2 type2; /* extended terminal type description */ } TERMINAL; #else typedef struct term TERMINAL; #endif /* NCURSES_INTERNALS */ #if 0 && !0 extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term; #elif 0 NCURSES_WRAPPED_VAR(TERMINAL *, cur_term); #define cur_term NCURSES_PUBLIC_VAR(cur_term()) #else extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term; #endif #if 0 || 0 NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes); NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames); #define boolnames NCURSES_PUBLIC_VAR(boolnames()) #define boolcodes NCURSES_PUBLIC_VAR(boolcodes()) #define boolfnames NCURSES_PUBLIC_VAR(boolfnames()) #define numnames NCURSES_PUBLIC_VAR(numnames()) #define numcodes NCURSES_PUBLIC_VAR(numcodes()) #define numfnames NCURSES_PUBLIC_VAR(numfnames()) #define strnames NCURSES_PUBLIC_VAR(strnames()) #define strcodes NCURSES_PUBLIC_VAR(strcodes()) #define strfnames NCURSES_PUBLIC_VAR(strfnames()) #else extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[]; extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[]; #endif /* * These entrypoints are used only by the ncurses utilities such as tic. */ #ifdef NCURSES_INTERNALS extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf); extern NCURSES_EXPORT(int) _nc_read_entry2 (const char * const, char * const, TERMTYPE2 *const); extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE2 *); extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE2 *, char *, int); extern NCURSES_EXPORT(char *) _nc_first_name (const char *const); extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const); extern NCURSES_EXPORT(char *) _nc_tiparm(int, const char *, ...); #endif /* NCURSES_INTERNALS */ /* * These entrypoints are used by tack 1.07. */ extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *); extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const); /* * Normal entry points */ extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *); extern NCURSES_EXPORT(int) del_curterm (TERMINAL *); /* miscellaneous entry points */ extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *); extern NCURSES_EXPORT(int) setupterm (const char *,int,int *); /* terminfo entry points, also declared in curses.h */ #if !defined(__NCURSES_H) extern NCURSES_EXPORT(char *) tigetstr (const char *); extern NCURSES_EXPORT_VAR(char) ttytype[]; extern NCURSES_EXPORT(int) putp (const char *); extern NCURSES_EXPORT(int) tigetflag (const char *); extern NCURSES_EXPORT(int) tigetnum (const char *); #if 1 /* NCURSES_TPARM_VARARGS */ extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */ #else extern NCURSES_EXPORT(char *) tparm (const char *, long,long,long,long,long,long,long,long,long); /* special */ #endif extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */ #endif /* __NCURSES_H */ /* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */ #if !defined(NCURSES_TERMCAP_H_incl) extern NCURSES_EXPORT(char *) tgetstr (const char *, char **); extern NCURSES_EXPORT(char *) tgoto (const char *, int, int); extern NCURSES_EXPORT(int) tgetent (char *, const char *); extern NCURSES_EXPORT(int) tgetflag (const char *); extern NCURSES_EXPORT(int) tgetnum (const char *); extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int)); #endif /* NCURSES_TERMCAP_H_incl */ /* * Include curses.h before term.h to enable these extensions. */ #if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0) extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tigetstr) (SCREEN*, const char *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(putp) (SCREEN*, const char *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetflag) (SCREEN*, const char *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetnum) (SCREEN*, const char *); #if 1 /* NCURSES_TPARM_VARARGS */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, ...); /* special */ #else extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, long,long,long,long,long,long,long,long,long); /* special */ #endif /* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgetstr) (SCREEN*, const char *, char **); extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetflag) (SCREEN*, const char *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetnum) (SCREEN*, const char *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC); extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *); #endif /* NCURSES_SP_FUNCS */ /* * Debugging features. */ extern GCC_NORETURN NCURSES_EXPORT(void) exit_terminfo(int); #ifdef __cplusplus } #endif #endif /* NCURSES_TERM_H_incl */ /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 * * and: Eric S. Raymond <esr@snark.thyrsus.com> * * and: Thomas E. Dickey 1996-on * ****************************************************************************/ /* $Id: curses.h.in,v 1.271 2021/03/20 16:25:43 tom Exp $ */ #ifndef __NCURSES_H #define __NCURSES_H #define CURSES 1 #define CURSES_H 1 /* These are defined only in curses.h, and are used for conditional compiles */ #define NCURSES_VERSION_MAJOR 6 #define NCURSES_VERSION_MINOR 2 #define NCURSES_VERSION_PATCH 20210508 /* This is defined in more than one ncurses header, for identification */ #undef NCURSES_VERSION #define NCURSES_VERSION "6.2" /* * Identify the mouse encoding version. */ #define NCURSES_MOUSE_VERSION 2 /* * Definitions to facilitate DLL's. */ #include <ncurses_dll.h> /* * Extra headers. */ #if 1 #include <stdint.h> #endif #ifdef __cplusplus #else #if 0 #include <stdnoreturn.h> #undef GCC_NORETURN #define GCC_NORETURN _Noreturn #endif #endif /* * User-definable tweak to disable the include of <stdbool.h>. */ #ifndef NCURSES_ENABLE_STDBOOL_H #define NCURSES_ENABLE_STDBOOL_H 1 #endif /* * NCURSES_ATTR_T is used to quiet compiler warnings when building ncurses * configured using --disable-macros. */ #ifndef NCURSES_ATTR_T #define NCURSES_ATTR_T int #endif /* * Expands to 'const' if ncurses is configured using --enable-const. Note that * doing so makes it incompatible with other implementations of X/Open Curses. */ #undef NCURSES_CONST #define NCURSES_CONST const #undef NCURSES_INLINE #define NCURSES_INLINE inline /* * The standard type used for color values, and for color-pairs. The latter * allows the curses library to enumerate the combinations of foreground and * background colors used by an application, and is normally the product of the * total foreground and background colors. * * X/Open uses "short" for both of these types, ultimately because they are * numbers from the SVr4 terminal database, which uses 16-bit signed values. */ #undef NCURSES_COLOR_T #define NCURSES_COLOR_T short #undef NCURSES_PAIRS_T #define NCURSES_PAIRS_T short /* * Definitions used to make WINDOW and similar structs opaque. */ #ifndef NCURSES_INTERNALS #define NCURSES_OPAQUE 0 #define NCURSES_OPAQUE_FORM 0 #define NCURSES_OPAQUE_MENU 0 #define NCURSES_OPAQUE_PANEL 0 #endif /* * Definition used to optionally suppress wattr* macros to help with the * transition from ncurses5 to ncurses6 by allowing the header files to * be shared across development packages for ncursesw in both ABIs. */ #ifndef NCURSES_WATTR_MACROS #define NCURSES_WATTR_MACROS 0 #endif /* * The reentrant code relies on the opaque setting, but adds features. */ #ifndef NCURSES_REENTRANT #define NCURSES_REENTRANT 0 #endif /* * In certain environments, we must work around linker problems for data */ #undef NCURSES_BROKEN_LINKER #if 0 #define NCURSES_BROKEN_LINKER 1 #endif /* * Control whether bindings for interop support are added. */ #undef NCURSES_INTEROP_FUNCS #define NCURSES_INTEROP_FUNCS 1 /* * The internal type used for window dimensions. */ #undef NCURSES_SIZE_T #define NCURSES_SIZE_T short /* * Control whether tparm() supports varargs or fixed-parameter list. */ #undef NCURSES_TPARM_VARARGS #define NCURSES_TPARM_VARARGS 1 /* * Control type used for tparm's arguments. While X/Open equates long and * char* values, this is not always workable for 64-bit platforms. */ #undef NCURSES_TPARM_ARG #define NCURSES_TPARM_ARG intptr_t /* * Control whether ncurses uses wcwidth() for checking width of line-drawing * characters. */ #undef NCURSES_WCWIDTH_GRAPHICS #define NCURSES_WCWIDTH_GRAPHICS 1 /* * NCURSES_CH_T is used in building the library, but not used otherwise in * this header file, since that would make the normal/wide-character versions * of the header incompatible. */ #undef NCURSES_CH_T #define NCURSES_CH_T cchar_t #if 1 && defined(_LP64) typedef unsigned chtype; typedef unsigned mmask_t; #else typedef uint32_t chtype; typedef uint32_t mmask_t; #endif /* * We need FILE, etc. Include this before checking any feature symbols. */ #include <stdio.h> /* * With XPG4, you must define _XOPEN_SOURCE_EXTENDED, it is redundant (or * conflicting) when _XOPEN_SOURCE is 500 or greater. If NCURSES_WIDECHAR is * not already defined, e.g., if the platform relies upon nonstandard feature * test macros, define it at this point if the standard feature test macros * indicate that it should be defined. */ #ifndef NCURSES_WIDECHAR #if defined(_XOPEN_SOURCE_EXTENDED) || (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500)) #define NCURSES_WIDECHAR 1 #else #define NCURSES_WIDECHAR 0 #endif #endif /* NCURSES_WIDECHAR */ #include <stdarg.h> /* we need va_list */ #if NCURSES_WIDECHAR #include <stddef.h> /* we want wchar_t */ #endif /* X/Open and SVr4 specify that curses implements 'bool'. However, C++ may also * implement it. If so, we must use the C++ compiler's type to avoid conflict * with other interfaces. * * A further complication is that <stdbool.h> may declare 'bool' to be a * different type, such as an enum which is not necessarily compatible with * C++. If we have <stdbool.h>, make 'bool' a macro, so users may #undef it. * Otherwise, let it remain a typedef to avoid conflicts with other #define's. * In either case, make a typedef for NCURSES_BOOL which can be used if needed * from either C or C++. */ #undef TRUE #define TRUE 1 #undef FALSE #define FALSE 0 typedef unsigned char NCURSES_BOOL; #if defined(__cplusplus) /* __cplusplus, etc. */ /* use the C++ compiler's bool type */ #define NCURSES_BOOL bool #else /* c89, c99, etc. */ #if NCURSES_ENABLE_STDBOOL_H #include <stdbool.h> /* use whatever the C compiler decides bool really is */ #define NCURSES_BOOL bool #else /* there is no predefined bool - use our own */ #undef bool #define bool NCURSES_BOOL #endif #endif /* !__cplusplus, etc. */ #ifdef __cplusplus extern "C" { #define NCURSES_CAST(type,value) static_cast<type>(value) #else #define NCURSES_CAST(type,value) (type)(value) #endif #define NCURSES_OK_ADDR(p) (0 != NCURSES_CAST(const void *, (p))) /* * X/Open attributes. In the ncurses implementation, they are identical to the * A_ attributes. */ #define WA_ATTRIBUTES A_ATTRIBUTES #define WA_NORMAL A_NORMAL #define WA_STANDOUT A_STANDOUT #define WA_UNDERLINE A_UNDERLINE #define WA_REVERSE A_REVERSE #define WA_BLINK A_BLINK #define WA_DIM A_DIM #define WA_BOLD A_BOLD #define WA_ALTCHARSET A_ALTCHARSET #define WA_INVIS A_INVIS #define WA_PROTECT A_PROTECT #define WA_HORIZONTAL A_HORIZONTAL #define WA_LEFT A_LEFT #define WA_LOW A_LOW #define WA_RIGHT A_RIGHT #define WA_TOP A_TOP #define WA_VERTICAL A_VERTICAL #if 1 #define WA_ITALIC A_ITALIC /* ncurses extension */ #endif /* colors */ #define COLOR_BLACK 0 #define COLOR_RED 1 #define COLOR_GREEN 2 #define COLOR_YELLOW 3 #define COLOR_BLUE 4 #define COLOR_MAGENTA 5 #define COLOR_CYAN 6 #define COLOR_WHITE 7 /* line graphics */ #if 0 || NCURSES_REENTRANT NCURSES_WRAPPED_VAR(chtype*, acs_map); #define acs_map NCURSES_PUBLIC_VAR(acs_map()) #else extern NCURSES_EXPORT_VAR(chtype) acs_map[]; #endif #define NCURSES_ACS(c) (acs_map[NCURSES_CAST(unsigned char,(c))]) /* VT100 symbols begin here */ #define ACS_ULCORNER NCURSES_ACS('l') /* upper left corner */ #define ACS_LLCORNER NCURSES_ACS('m') /* lower left corner */ #define ACS_URCORNER NCURSES_ACS('k') /* upper right corner */ #define ACS_LRCORNER NCURSES_ACS('j') /* lower right corner */ #define ACS_LTEE NCURSES_ACS('t') /* tee pointing right */ #define ACS_RTEE NCURSES_ACS('u') /* tee pointing left */ #define ACS_BTEE NCURSES_ACS('v') /* tee pointing up */ #define ACS_TTEE NCURSES_ACS('w') /* tee pointing down */ #define ACS_HLINE NCURSES_ACS('q') /* horizontal line */ #define ACS_VLINE NCURSES_ACS('x') /* vertical line */ #define ACS_PLUS NCURSES_ACS('n') /* large plus or crossover */ #define ACS_S1 NCURSES_ACS('o') /* scan line 1 */ #define ACS_S9 NCURSES_ACS('s') /* scan line 9 */ #define ACS_DIAMOND NCURSES_ACS('`') /* diamond */ #define ACS_CKBOARD NCURSES_ACS('a') /* checker board (stipple) */ #define ACS_DEGREE NCURSES_ACS('f') /* degree symbol */ #define ACS_PLMINUS NCURSES_ACS('g') /* plus/minus */ #define ACS_BULLET NCURSES_ACS('~') /* bullet */ /* Teletype 5410v1 symbols begin here */ #define ACS_LARROW NCURSES_ACS(',') /* arrow pointing left */ #define ACS_RARROW NCURSES_ACS('+') /* arrow pointing right */ #define ACS_DARROW NCURSES_ACS('.') /* arrow pointing down */ #define ACS_UARROW NCURSES_ACS('-') /* arrow pointing up */ #define ACS_BOARD NCURSES_ACS('h') /* board of squares */ #define ACS_LANTERN NCURSES_ACS('i') /* lantern symbol */ #define ACS_BLOCK NCURSES_ACS('0') /* solid square block */ /* * These aren't documented, but a lot of System Vs have them anyway * (you can spot pprryyzz{{||}} in a lot of AT&T terminfo strings). * The ACS_names may not match AT&T's, our source didn't know them. */ #define ACS_S3 NCURSES_ACS('p') /* scan line 3 */ #define ACS_S7 NCURSES_ACS('r') /* scan line 7 */ #define ACS_LEQUAL NCURSES_ACS('y') /* less/equal */ #define ACS_GEQUAL NCURSES_ACS('z') /* greater/equal */ #define ACS_PI NCURSES_ACS('{') /* Pi */ #define ACS_NEQUAL NCURSES_ACS('|') /* not equal */ #define ACS_STERLING NCURSES_ACS('}') /* UK pound sign */ /* * Line drawing ACS names are of the form ACS_trbl, where t is the top, r * is the right, b is the bottom, and l is the left. t, r, b, and l might * be B (blank), S (single), D (double), or T (thick). The subset defined * here only uses B and S. */ #define ACS_BSSB ACS_ULCORNER #define ACS_SSBB ACS_LLCORNER #define ACS_BBSS ACS_URCORNER #define ACS_SBBS ACS_LRCORNER #define ACS_SBSS ACS_RTEE #define ACS_SSSB ACS_LTEE #define ACS_SSBS ACS_BTEE #define ACS_BSSS ACS_TTEE #define ACS_BSBS ACS_HLINE #define ACS_SBSB ACS_VLINE #define ACS_SSSS ACS_PLUS #undef ERR #define ERR (-1) #undef OK #define OK (0) /* values for the _flags member */ #define _SUBWIN 0x01 /* is this a sub-window? */ #define _ENDLINE 0x02 /* is the window flush right? */ #define _FULLWIN 0x04 /* is the window full-screen? */ #define _SCROLLWIN 0x08 /* bottom edge is at screen bottom? */ #define _ISPAD 0x10 /* is this window a pad? */ #define _HASMOVED 0x20 /* has cursor moved since last refresh? */ #define _WRAPPED 0x40 /* cursor was just wrappped */ /* * this value is used in the firstchar and lastchar fields to mark * unchanged lines */ #define _NOCHANGE -1 /* * this value is used in the oldindex field to mark lines created by insertions * and scrolls. */ #define _NEWINDEX -1 typedef struct screen SCREEN; typedef struct _win_st WINDOW; typedef chtype attr_t; /* ...must be at least as wide as chtype */ #if NCURSES_WIDECHAR #if 0 #ifdef mblen /* libutf8.h defines it w/o undefining first */ #undef mblen #endif #include <libutf8.h> #endif #if 1 #include <wchar.h> /* ...to get mbstate_t, etc. */ #endif #if 0 typedef unsigned short wchar_t1; #endif #if 0 typedef unsigned int wint_t1; #endif /* * cchar_t stores an array of CCHARW_MAX wide characters. The first is * normally a spacing character. The others are non-spacing. If those * (spacing and nonspacing) do not fill the array, a null L'\0' follows. * Otherwise, a null is assumed to follow when extracting via getcchar(). */ #define CCHARW_MAX 5 typedef struct { attr_t attr; wchar_t chars[CCHARW_MAX]; #if 1 #undef NCURSES_EXT_COLORS #define NCURSES_EXT_COLORS 20210508 int ext_color; /* color pair, must be more than 16-bits */ #endif } cchar_t; #endif /* NCURSES_WIDECHAR */ #if !NCURSES_OPAQUE struct ldat; struct _win_st { NCURSES_SIZE_T _cury, _curx; /* current cursor position */ /* window location and size */ NCURSES_SIZE_T _maxy, _maxx; /* maximums of x and y, NOT window size */ NCURSES_SIZE_T _begy, _begx; /* screen coords of upper-left-hand corner */ short _flags; /* window state flags */ /* attribute tracking */ attr_t _attrs; /* current attribute for non-space character */ chtype _bkgd; /* current background char/attribute pair */ /* option values set by user */ bool _notimeout; /* no time out on function-key entry? */ bool _clear; /* consider all data in the window invalid? */ bool _leaveok; /* OK to not reset cursor on exit? */ bool _scroll; /* OK to scroll this window? */ bool _idlok; /* OK to use insert/delete line? */ bool _idcok; /* OK to use insert/delete char? */ bool _immed; /* window in immed mode? (not yet used) */ bool _sync; /* window in sync mode? */ bool _use_keypad; /* process function keys into KEY_ symbols? */ int _delay; /* 0 = nodelay, <0 = blocking, >0 = delay */ struct ldat *_line; /* the actual line data */ /* global screen state */ NCURSES_SIZE_T _regtop; /* top line of scrolling region */ NCURSES_SIZE_T _regbottom; /* bottom line of scrolling region */ /* these are used only if this is a sub-window */ int _parx; /* x coordinate of this window in parent */ int _pary; /* y coordinate of this window in parent */ WINDOW *_parent; /* pointer to parent if a sub-window */ /* these are used only if this is a pad */ struct pdat { NCURSES_SIZE_T _pad_y, _pad_x; NCURSES_SIZE_T _pad_top, _pad_left; NCURSES_SIZE_T _pad_bottom, _pad_right; } _pad; NCURSES_SIZE_T _yoffset; /* real begy is _begy + _yoffset */ #if NCURSES_WIDECHAR cchar_t _bkgrnd; /* current background char/attribute pair */ #if 1 int _color; /* current color-pair for non-space character */ #endif #endif }; #endif /* NCURSES_OPAQUE */ /* * GCC (and some other compilers) define '__attribute__'; we're using this * macro to alert the compiler to flag inconsistencies in printf/scanf-like * function calls. Just in case '__attribute__' isn't defined, make a dummy. * Old versions of G++ do not accept it anyway, at least not consistently with * GCC. */ #if !(defined(__GNUC__) || defined(__GNUG__) || defined(__attribute__)) #define __attribute__(p) /* nothing */ #endif /* * We cannot define these in ncurses_cfg.h, since they require parameters to be * passed (that is non-portable). If you happen to be using gcc with warnings * enabled, define * GCC_PRINTF * GCC_SCANF * to improve checking of calls to printw(), etc. */ #ifndef GCC_PRINTFLIKE #if defined(GCC_PRINTF) && !defined(printf) #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var))) #else #define GCC_PRINTFLIKE(fmt,var) /*nothing*/ #endif #endif #ifndef GCC_SCANFLIKE #if defined(GCC_SCANF) && !defined(scanf) #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var))) #else #define GCC_SCANFLIKE(fmt,var) /*nothing*/ #endif #endif #ifndef GCC_NORETURN #define GCC_NORETURN /* nothing */ #endif #ifndef GCC_UNUSED #define GCC_UNUSED /* nothing */ #endif #undef GCC_DEPRECATED #if (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2)) && !defined(NCURSES_INTERNALS) #define GCC_DEPRECATED(msg) __attribute__((deprecated)) #else #define GCC_DEPRECATED(msg) /* nothing */ #endif /* * Curses uses a helper function. Define our type for this to simplify * extending it for the sp-funcs feature. */ typedef int (*NCURSES_OUTC)(int); /* * Function prototypes. This is the complete X/Open Curses list of required * functions. Those marked `generated' will have sources generated from the * macro definitions later in this file, in order to satisfy XPG4.2 * requirements. */ extern NCURSES_EXPORT(int) addch (const chtype); /* generated */ extern NCURSES_EXPORT(int) addchnstr (const chtype *, int); /* generated */ extern NCURSES_EXPORT(int) addchstr (const chtype *); /* generated */ extern NCURSES_EXPORT(int) addnstr (const char *, int); /* generated */ extern NCURSES_EXPORT(int) addstr (const char *); /* generated */ extern NCURSES_EXPORT(int) attroff (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attron (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attrset (NCURSES_ATTR_T); /* generated */ extern NCURSES_EXPORT(int) attr_get (attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ extern NCURSES_EXPORT(int) attr_off (attr_t, void *); /* generated */ extern NCURSES_EXPORT(int) attr_on (attr_t, void *); /* generated */ extern NCURSES_EXPORT(int) attr_set (attr_t, NCURSES_PAIRS_T, void *); /* generated */ extern NCURSES_EXPORT(int) baudrate (void); /* implemented */ extern NCURSES_EXPORT(int) beep (void); /* implemented */ extern NCURSES_EXPORT(int) bkgd (chtype); /* generated */ extern NCURSES_EXPORT(void) bkgdset (chtype); /* generated */ extern NCURSES_EXPORT(int) border (chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* generated */ extern NCURSES_EXPORT(int) box (WINDOW *, chtype, chtype); /* generated */ extern NCURSES_EXPORT(bool) can_change_color (void); /* implemented */ extern NCURSES_EXPORT(int) cbreak (void); /* implemented */ extern NCURSES_EXPORT(int) chgat (int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ extern NCURSES_EXPORT(int) clear (void); /* generated */ extern NCURSES_EXPORT(int) clearok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) clrtobot (void); /* generated */ extern NCURSES_EXPORT(int) clrtoeol (void); /* generated */ extern NCURSES_EXPORT(int) color_content (NCURSES_COLOR_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ extern NCURSES_EXPORT(int) color_set (NCURSES_PAIRS_T,void*); /* generated */ extern NCURSES_EXPORT(int) COLOR_PAIR (int); /* generated */ extern NCURSES_EXPORT(int) copywin (const WINDOW*,WINDOW*,int,int,int,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) curs_set (int); /* implemented */ extern NCURSES_EXPORT(int) def_prog_mode (void); /* implemented */ extern NCURSES_EXPORT(int) def_shell_mode (void); /* implemented */ extern NCURSES_EXPORT(int) delay_output (int); /* implemented */ extern NCURSES_EXPORT(int) delch (void); /* generated */ extern NCURSES_EXPORT(void) delscreen (SCREEN *); /* implemented */ extern NCURSES_EXPORT(int) delwin (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) deleteln (void); /* generated */ extern NCURSES_EXPORT(WINDOW *) derwin (WINDOW *,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) doupdate (void); /* implemented */ extern NCURSES_EXPORT(WINDOW *) dupwin (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) echo (void); /* implemented */ extern NCURSES_EXPORT(int) echochar (const chtype); /* generated */ extern NCURSES_EXPORT(int) erase (void); /* generated */ extern NCURSES_EXPORT(int) endwin (void); /* implemented */ extern NCURSES_EXPORT(char) erasechar (void); /* implemented */ extern NCURSES_EXPORT(void) filter (void); /* implemented */ extern NCURSES_EXPORT(int) flash (void); /* implemented */ extern NCURSES_EXPORT(int) flushinp (void); /* implemented */ extern NCURSES_EXPORT(chtype) getbkgd (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getch (void); /* generated */ extern NCURSES_EXPORT(int) getnstr (char *, int); /* generated */ extern NCURSES_EXPORT(int) getstr (char *); /* generated */ extern NCURSES_EXPORT(WINDOW *) getwin (FILE *); /* implemented */ extern NCURSES_EXPORT(int) halfdelay (int); /* implemented */ extern NCURSES_EXPORT(bool) has_colors (void); /* implemented */ extern NCURSES_EXPORT(bool) has_ic (void); /* implemented */ extern NCURSES_EXPORT(bool) has_il (void); /* implemented */ extern NCURSES_EXPORT(int) hline (chtype, int); /* generated */ extern NCURSES_EXPORT(void) idcok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(int) idlok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(void) immedok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(chtype) inch (void); /* generated */ extern NCURSES_EXPORT(int) inchnstr (chtype *, int); /* generated */ extern NCURSES_EXPORT(int) inchstr (chtype *); /* generated */ extern NCURSES_EXPORT(WINDOW *) initscr (void); /* implemented */ extern NCURSES_EXPORT(int) init_color (NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ extern NCURSES_EXPORT(int) init_pair (NCURSES_PAIRS_T,NCURSES_COLOR_T,NCURSES_COLOR_T); /* implemented */ extern NCURSES_EXPORT(int) innstr (char *, int); /* generated */ extern NCURSES_EXPORT(int) insch (chtype); /* generated */ extern NCURSES_EXPORT(int) insdelln (int); /* generated */ extern NCURSES_EXPORT(int) insertln (void); /* generated */ extern NCURSES_EXPORT(int) insnstr (const char *, int); /* generated */ extern NCURSES_EXPORT(int) insstr (const char *); /* generated */ extern NCURSES_EXPORT(int) instr (char *); /* generated */ extern NCURSES_EXPORT(int) intrflush (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(bool) isendwin (void); /* implemented */ extern NCURSES_EXPORT(bool) is_linetouched (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(bool) is_wintouched (WINDOW *); /* implemented */ extern NCURSES_EXPORT(NCURSES_CONST char *) keyname (int); /* implemented */ extern NCURSES_EXPORT(int) keypad (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(char) killchar (void); /* implemented */ extern NCURSES_EXPORT(int) leaveok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(char *) longname (void); /* implemented */ extern NCURSES_EXPORT(int) meta (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) move (int, int); /* generated */ extern NCURSES_EXPORT(int) mvaddch (int, int, const chtype); /* generated */ extern NCURSES_EXPORT(int) mvaddchnstr (int, int, const chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvaddchstr (int, int, const chtype *); /* generated */ extern NCURSES_EXPORT(int) mvaddnstr (int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvaddstr (int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvchgat (int, int, int, attr_t, NCURSES_PAIRS_T, const void *); /* generated */ extern NCURSES_EXPORT(int) mvcur (int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) mvdelch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvderwin (WINDOW *, int, int); /* implemented */ extern NCURSES_EXPORT(int) mvgetch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvgetnstr (int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvgetstr (int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvhline (int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(chtype) mvinch (int, int); /* generated */ extern NCURSES_EXPORT(int) mvinchnstr (int, int, chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvinchstr (int, int, chtype *); /* generated */ extern NCURSES_EXPORT(int) mvinnstr (int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvinsch (int, int, chtype); /* generated */ extern NCURSES_EXPORT(int) mvinsnstr (int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvinsstr (int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvinstr (int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvprintw (int,int, const char *,...) /* implemented */ GCC_PRINTFLIKE(3,4); extern NCURSES_EXPORT(int) mvscanw (int,int, const char *,...) /* implemented */ GCC_SCANFLIKE(3,4); extern NCURSES_EXPORT(int) mvvline (int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) mvwaddch (WINDOW *, int, int, const chtype); /* generated */ extern NCURSES_EXPORT(int) mvwaddchnstr (WINDOW *, int, int, const chtype *, int);/* generated */ extern NCURSES_EXPORT(int) mvwaddchstr (WINDOW *, int, int, const chtype *); /* generated */ extern NCURSES_EXPORT(int) mvwaddnstr (WINDOW *, int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwaddstr (WINDOW *, int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvwchgat (WINDOW *, int, int, int, attr_t, NCURSES_PAIRS_T, const void *);/* generated */ extern NCURSES_EXPORT(int) mvwdelch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetnstr (WINDOW *, int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwgetstr (WINDOW *, int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvwhline (WINDOW *, int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) mvwin (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(chtype) mvwinch (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) mvwinchnstr (WINDOW *, int, int, chtype *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinchstr (WINDOW *, int, int, chtype *); /* generated */ extern NCURSES_EXPORT(int) mvwinnstr (WINDOW *, int, int, char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinsch (WINDOW *, int, int, chtype); /* generated */ extern NCURSES_EXPORT(int) mvwinsnstr (WINDOW *, int, int, const char *, int); /* generated */ extern NCURSES_EXPORT(int) mvwinsstr (WINDOW *, int, int, const char *); /* generated */ extern NCURSES_EXPORT(int) mvwinstr (WINDOW *, int, int, char *); /* generated */ extern NCURSES_EXPORT(int) mvwprintw (WINDOW*,int,int, const char *,...) /* implemented */ GCC_PRINTFLIKE(4,5); extern NCURSES_EXPORT(int) mvwscanw (WINDOW *,int,int, const char *,...) /* implemented */ GCC_SCANFLIKE(4,5); extern NCURSES_EXPORT(int) mvwvline (WINDOW *,int, int, chtype, int); /* generated */ extern NCURSES_EXPORT(int) napms (int); /* implemented */ extern NCURSES_EXPORT(WINDOW *) newpad (int,int); /* implemented */ extern NCURSES_EXPORT(SCREEN *) newterm (const char *,FILE *,FILE *); /* implemented */ extern NCURSES_EXPORT(WINDOW *) newwin (int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) nl (void); /* implemented */ extern NCURSES_EXPORT(int) nocbreak (void); /* implemented */ extern NCURSES_EXPORT(int) nodelay (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) noecho (void); /* implemented */ extern NCURSES_EXPORT(int) nonl (void); /* implemented */ extern NCURSES_EXPORT(void) noqiflush (void); /* implemented */ extern NCURSES_EXPORT(int) noraw (void); /* implemented */ extern NCURSES_EXPORT(int) notimeout (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) overlay (const WINDOW*,WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) overwrite (const WINDOW*,WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) pair_content (NCURSES_PAIRS_T,NCURSES_COLOR_T*,NCURSES_COLOR_T*); /* implemented */ extern NCURSES_EXPORT(int) PAIR_NUMBER (int); /* generated */ extern NCURSES_EXPORT(int) pechochar (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) pnoutrefresh (WINDOW*,int,int,int,int,int,int);/* implemented */ extern NCURSES_EXPORT(int) prefresh (WINDOW *,int,int,int,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) printw (const char *,...) /* implemented */ GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(int) putwin (WINDOW *, FILE *); /* implemented */ extern NCURSES_EXPORT(void) qiflush (void); /* implemented */ extern NCURSES_EXPORT(int) raw (void); /* implemented */ extern NCURSES_EXPORT(int) redrawwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) refresh (void); /* generated */ extern NCURSES_EXPORT(int) resetty (void); /* implemented */ extern NCURSES_EXPORT(int) reset_prog_mode (void); /* implemented */ extern NCURSES_EXPORT(int) reset_shell_mode (void); /* implemented */ extern NCURSES_EXPORT(int) ripoffline (int, int (*)(WINDOW *, int)); /* implemented */ extern NCURSES_EXPORT(int) savetty (void); /* implemented */ extern NCURSES_EXPORT(int) scanw (const char *,...) /* implemented */ GCC_SCANFLIKE(1,2); extern NCURSES_EXPORT(int) scr_dump (const char *); /* implemented */ extern NCURSES_EXPORT(int) scr_init (const char *); /* implemented */ extern NCURSES_EXPORT(int) scrl (int); /* generated */ extern NCURSES_EXPORT(int) scroll (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) scrollok (WINDOW *,bool); /* implemented */ extern NCURSES_EXPORT(int) scr_restore (const char *); /* implemented */ extern NCURSES_EXPORT(int) scr_set (const char *); /* implemented */ extern NCURSES_EXPORT(int) setscrreg (int,int); /* generated */ extern NCURSES_EXPORT(SCREEN *) set_term (SCREEN *); /* implemented */ extern NCURSES_EXPORT(int) slk_attroff (const chtype); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_off (const attr_t, void *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) slk_attron (const chtype); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_on (attr_t,void*); /* generated:WIDEC */ extern NCURSES_EXPORT(int) slk_attrset (const chtype); /* implemented */ extern NCURSES_EXPORT(attr_t) slk_attr (void); /* implemented */ extern NCURSES_EXPORT(int) slk_attr_set (const attr_t,NCURSES_PAIRS_T,void*); /* implemented */ extern NCURSES_EXPORT(int) slk_clear (void); /* implemented */ extern NCURSES_EXPORT(int) slk_color (NCURSES_PAIRS_T); /* implemented */ extern NCURSES_EXPORT(int) slk_init (int); /* implemented */ extern NCURSES_EXPORT(char *) slk_label (int); /* implemented */ extern NCURSES_EXPORT(int) slk_noutrefresh (void); /* implemented */ extern NCURSES_EXPORT(int) slk_refresh (void); /* implemented */ extern NCURSES_EXPORT(int) slk_restore (void); /* implemented */ extern NCURSES_EXPORT(int) slk_set (int,const char *,int); /* implemented */ extern NCURSES_EXPORT(int) slk_touch (void); /* implemented */ extern NCURSES_EXPORT(int) standout (void); /* generated */ extern NCURSES_EXPORT(int) standend (void); /* generated */ extern NCURSES_EXPORT(int) start_color (void); /* implemented */ extern NCURSES_EXPORT(WINDOW *) subpad (WINDOW *, int, int, int, int); /* implemented */ extern NCURSES_EXPORT(WINDOW *) subwin (WINDOW *, int, int, int, int); /* implemented */ extern NCURSES_EXPORT(int) syncok (WINDOW *, bool); /* implemented */ extern NCURSES_EXPORT(chtype) termattrs (void); /* implemented */ extern NCURSES_EXPORT(char *) termname (void); /* implemented */ extern NCURSES_EXPORT(void) timeout (int); /* generated */ extern NCURSES_EXPORT(int) touchline (WINDOW *, int, int); /* generated */ extern NCURSES_EXPORT(int) touchwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) typeahead (int); /* implemented */ extern NCURSES_EXPORT(int) ungetch (int); /* implemented */ extern NCURSES_EXPORT(int) untouchwin (WINDOW *); /* generated */ extern NCURSES_EXPORT(void) use_env (bool); /* implemented */ extern NCURSES_EXPORT(void) use_tioctl (bool); /* implemented */ extern NCURSES_EXPORT(int) vidattr (chtype); /* implemented */ extern NCURSES_EXPORT(int) vidputs (chtype, NCURSES_OUTC); /* implemented */ extern NCURSES_EXPORT(int) vline (chtype, int); /* generated */ extern NCURSES_EXPORT(int) vwprintw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_printw); /* implemented */ extern NCURSES_EXPORT(int) vw_printw (WINDOW *, const char *,va_list); /* implemented */ extern NCURSES_EXPORT(int) vwscanw (WINDOW *, const char *,va_list) GCC_DEPRECATED(use vw_scanw); /* implemented */ extern NCURSES_EXPORT(int) vw_scanw (WINDOW *, const char *,va_list); /* implemented */ extern NCURSES_EXPORT(int) waddch (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) waddchnstr (WINDOW *,const chtype *,int); /* implemented */ extern NCURSES_EXPORT(int) waddchstr (WINDOW *,const chtype *); /* generated */ extern NCURSES_EXPORT(int) waddnstr (WINDOW *,const char *,int); /* implemented */ extern NCURSES_EXPORT(int) waddstr (WINDOW *,const char *); /* generated */ extern NCURSES_EXPORT(int) wattron (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattroff (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattrset (WINDOW *, int); /* generated */ extern NCURSES_EXPORT(int) wattr_get (WINDOW *, attr_t *, NCURSES_PAIRS_T *, void *); /* generated */ extern NCURSES_EXPORT(int) wattr_on (WINDOW *, attr_t, void *); /* implemented */ extern NCURSES_EXPORT(int) wattr_off (WINDOW *, attr_t, void *); /* implemented */ extern NCURSES_EXPORT(int) wattr_set (WINDOW *, attr_t, NCURSES_PAIRS_T, void *); /* generated */ extern NCURSES_EXPORT(int) wbkgd (WINDOW *, chtype); /* implemented */ extern NCURSES_EXPORT(void) wbkgdset (WINDOW *,chtype); /* implemented */ extern NCURSES_EXPORT(int) wborder (WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype); /* implemented */ extern NCURSES_EXPORT(int) wchgat (WINDOW *, int, attr_t, NCURSES_PAIRS_T, const void *);/* implemented */ extern NCURSES_EXPORT(int) wclear (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wclrtobot (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wclrtoeol (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wcolor_set (WINDOW*,NCURSES_PAIRS_T,void*); /* implemented */ extern NCURSES_EXPORT(void) wcursyncup (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wdelch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wdeleteln (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wechochar (WINDOW *, const chtype); /* implemented */ extern NCURSES_EXPORT(int) werase (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wgetch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wgetnstr (WINDOW *,char *,int); /* implemented */ extern NCURSES_EXPORT(int) wgetstr (WINDOW *, char *); /* generated */ extern NCURSES_EXPORT(int) whline (WINDOW *, chtype, int); /* implemented */ extern NCURSES_EXPORT(chtype) winch (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) winchnstr (WINDOW *, chtype *, int); /* implemented */ extern NCURSES_EXPORT(int) winchstr (WINDOW *, chtype *); /* generated */ extern NCURSES_EXPORT(int) winnstr (WINDOW *, char *, int); /* implemented */ extern NCURSES_EXPORT(int) winsch (WINDOW *, chtype); /* implemented */ extern NCURSES_EXPORT(int) winsdelln (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) winsertln (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) winsnstr (WINDOW *, const char *,int); /* implemented */ extern NCURSES_EXPORT(int) winsstr (WINDOW *, const char *); /* generated */ extern NCURSES_EXPORT(int) winstr (WINDOW *, char *); /* generated */ extern NCURSES_EXPORT(int) wmove (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wnoutrefresh (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wprintw (WINDOW *, const char *,...) /* implemented */ GCC_PRINTFLIKE(2,3); extern NCURSES_EXPORT(int) wredrawln (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wrefresh (WINDOW *); /* implemented */ extern NCURSES_EXPORT(int) wscanw (WINDOW *, const char *,...) /* implemented */ GCC_SCANFLIKE(2,3); extern NCURSES_EXPORT(int) wscrl (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) wsetscrreg (WINDOW *,int,int); /* implemented */ extern NCURSES_EXPORT(int) wstandout (WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wstandend (WINDOW *); /* generated */ extern NCURSES_EXPORT(void) wsyncdown (WINDOW *); /* implemented */ extern NCURSES_EXPORT(void) wsyncup (WINDOW *); /* implemented */ extern NCURSES_EXPORT(void) wtimeout (WINDOW *,int); /* implemented */ extern NCURSES_EXPORT(int) wtouchln (WINDOW *,int,int,int); /* implemented */ extern NCURSES_EXPORT(int) wvline (WINDOW *,chtype,int); /* implemented */ /* * These are also declared in <term.h>: */ extern NCURSES_EXPORT(int) tigetflag (const char *); /* implemented */ extern NCURSES_EXPORT(int) tigetnum (const char *); /* implemented */ extern NCURSES_EXPORT(char *) tigetstr (const char *); /* implemented */ extern NCURSES_EXPORT(int) putp (const char *); /* implemented */ #if NCURSES_TPARM_VARARGS extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */ #else extern NCURSES_EXPORT(char *) tparm (const char *, NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG,NCURSES_TPARM_ARG); /* special */ #endif extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */ /* * These functions are not in X/Open, but we use them in macro definitions: */ extern NCURSES_EXPORT(int) getattrs (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getcurx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getcury (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getbegx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getbegy (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getmaxx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getmaxy (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getparx (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) getpary (const WINDOW *); /* generated */ /* * vid_attr() was implemented originally based on a draft of X/Open curses. */ #if !NCURSES_WIDECHAR #define vid_attr(a,pair,opts) vidattr(a) #endif /* * These functions are extensions - not in X/Open Curses. */ #if 1 #undef NCURSES_EXT_FUNCS #define NCURSES_EXT_FUNCS 20210508 typedef int (*NCURSES_WINDOW_CB)(WINDOW *, void *); typedef int (*NCURSES_SCREEN_CB)(SCREEN *, void *); extern NCURSES_EXPORT(bool) is_term_resized (int, int); extern NCURSES_EXPORT(char *) keybound (int, int); extern NCURSES_EXPORT(const char *) curses_version (void); extern NCURSES_EXPORT(int) alloc_pair (int, int); extern NCURSES_EXPORT(int) assume_default_colors (int, int); extern NCURSES_EXPORT(int) define_key (const char *, int); extern NCURSES_EXPORT(int) extended_color_content(int, int *, int *, int *); extern NCURSES_EXPORT(int) extended_pair_content(int, int *, int *); extern NCURSES_EXPORT(int) extended_slk_color(int); extern NCURSES_EXPORT(int) find_pair (int, int); extern NCURSES_EXPORT(int) free_pair (int); extern NCURSES_EXPORT(int) get_escdelay (void); extern NCURSES_EXPORT(int) init_extended_color(int, int, int, int); extern NCURSES_EXPORT(int) init_extended_pair(int, int, int); extern NCURSES_EXPORT(int) key_defined (const char *); extern NCURSES_EXPORT(int) keyok (int, bool); extern NCURSES_EXPORT(void) reset_color_pairs (void); extern NCURSES_EXPORT(int) resize_term (int, int); extern NCURSES_EXPORT(int) resizeterm (int, int); extern NCURSES_EXPORT(int) set_escdelay (int); extern NCURSES_EXPORT(int) set_tabsize (int); extern NCURSES_EXPORT(int) use_default_colors (void); extern NCURSES_EXPORT(int) use_extended_names (bool); extern NCURSES_EXPORT(int) use_legacy_coding (int); extern NCURSES_EXPORT(int) use_screen (SCREEN *, NCURSES_SCREEN_CB, void *); extern NCURSES_EXPORT(int) use_window (WINDOW *, NCURSES_WINDOW_CB, void *); extern NCURSES_EXPORT(int) wresize (WINDOW *, int, int); extern NCURSES_EXPORT(void) nofilter(void); /* * These extensions provide access to information stored in the WINDOW even * when NCURSES_OPAQUE is set: */ extern NCURSES_EXPORT(WINDOW *) wgetparent (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_cleared (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_idcok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_idlok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_immedok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_keypad (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_leaveok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_nodelay (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_notimeout (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_pad (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_scrollok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_subwin (const WINDOW *); /* generated */ extern NCURSES_EXPORT(bool) is_syncok (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wgetdelay (const WINDOW *); /* generated */ extern NCURSES_EXPORT(int) wgetscrreg (const WINDOW *, int *, int *); /* generated */ #else #define curses_version() NCURSES_VERSION #endif /* * Extra extension-functions, which pass a SCREEN pointer rather than using * a global variable SP. */ #if 1 #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 20210508 #define NCURSES_SP_NAME(name) name##_sp /* Define the sp-funcs helper function */ #define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC) typedef int (*NCURSES_SP_OUTC)(SCREEN*, int); extern NCURSES_EXPORT(SCREEN *) new_prescr (void); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(baudrate) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(beep) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(can_change_color) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(cbreak) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(curs_set) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(color_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(def_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(delay_output) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(doupdate) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(echo) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(endwin) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char) NCURSES_SP_NAME(erasechar) (SCREEN*);/* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(filter) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flash) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(flushinp) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(getwin) (SCREEN*, FILE *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(halfdelay) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_colors) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_ic) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_il) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_color) (SCREEN*, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_pair) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T, NCURSES_COLOR_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(intrflush) (SCREEN*, WINDOW*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(isendwin) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(keyname) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char) NCURSES_SP_NAME(killchar) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(longname) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mvcur) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(napms) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newpad) (SCREEN*, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(SCREEN *) NCURSES_SP_NAME(newterm) (SCREEN*, const char *, FILE *, FILE *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(WINDOW *) NCURSES_SP_NAME(newwin) (SCREEN*, int, int, int, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nl) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nocbreak) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noecho) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(nonl) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(noqiflush) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(noraw) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(pair_content) (SCREEN*, NCURSES_PAIRS_T, NCURSES_COLOR_T*, NCURSES_COLOR_T*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(qiflush) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(raw) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_prog_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(reset_shell_mode) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resetty) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ripoffline) (SCREEN*, int, int (*)(WINDOW *, int)); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(savetty) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_init) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_restore) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(scr_set) (SCREEN*, const char *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attroff) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attron) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attrset) (SCREEN*, const chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(slk_attr) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_attr_set) (SCREEN*, const attr_t, NCURSES_PAIRS_T, void*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_clear) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_color) (SCREEN*, NCURSES_PAIRS_T); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_init) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(slk_label) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_noutrefresh) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_refresh) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_restore) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_set) (SCREEN*, int, const char *, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(slk_touch) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(start_color) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(chtype) NCURSES_SP_NAME(termattrs) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(termname) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(typeahead) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetch) (SCREEN*, int); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_env) (SCREEN*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(use_tioctl) (SCREEN*, bool); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidattr) (SCREEN*, chtype); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vidputs) (SCREEN*, chtype, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ #if 1 extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(keybound) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(alloc_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(assume_default_colors) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(define_key) (SCREEN*, const char *, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_color_content) (SCREEN*, int, int *, int *, int *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_pair_content) (SCREEN*, int, int *, int *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(extended_slk_color) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(get_escdelay) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(find_pair) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(free_pair) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_color) (SCREEN*, int, int, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(init_extended_pair) (SCREEN*, int, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(is_term_resized) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(key_defined) (SCREEN*, const char *); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(keyok) (SCREEN*, int, bool); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(nofilter) (SCREEN*); /* implemented */ /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(void) NCURSES_SP_NAME(reset_color_pairs) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resize_term) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(resizeterm) (SCREEN*, int, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_escdelay) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(set_tabsize) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_default_colors) (SCREEN*); /* implemented:EXT_SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(use_legacy_coding) (SCREEN*, int); /* implemented:EXT_SP_FUNC */ #endif #else #undef NCURSES_SP_FUNCS #define NCURSES_SP_FUNCS 0 #define NCURSES_SP_NAME(name) name #define NCURSES_SP_OUTC NCURSES_OUTC #endif /* attributes */ #define NCURSES_ATTR_SHIFT 8 #define NCURSES_BITS(mask,shift) (NCURSES_CAST(chtype,(mask)) << ((shift) + NCURSES_ATTR_SHIFT)) #define A_NORMAL (1U - 1U) #define A_ATTRIBUTES NCURSES_BITS(~(1U - 1U),0) #define A_CHARTEXT (NCURSES_BITS(1U,0) - 1U) #define A_COLOR NCURSES_BITS(((1U) << 8) - 1U,0) #define A_STANDOUT NCURSES_BITS(1U,8) #define A_UNDERLINE NCURSES_BITS(1U,9) #define A_REVERSE NCURSES_BITS(1U,10) #define A_BLINK NCURSES_BITS(1U,11) #define A_DIM NCURSES_BITS(1U,12) #define A_BOLD NCURSES_BITS(1U,13) #define A_ALTCHARSET NCURSES_BITS(1U,14) #define A_INVIS NCURSES_BITS(1U,15) #define A_PROTECT NCURSES_BITS(1U,16) #define A_HORIZONTAL NCURSES_BITS(1U,17) #define A_LEFT NCURSES_BITS(1U,18) #define A_LOW NCURSES_BITS(1U,19) #define A_RIGHT NCURSES_BITS(1U,20) #define A_TOP NCURSES_BITS(1U,21) #define A_VERTICAL NCURSES_BITS(1U,22) #if 1 #define A_ITALIC NCURSES_BITS(1U,23) /* ncurses extension */ #endif /* * Most of the pseudo functions are macros that either provide compatibility * with older versions of curses, or provide inline functionality to improve * performance. */ /* * These pseudo functions are always implemented as macros: */ #define getyx(win,y,x) (y = getcury(win), x = getcurx(win)) #define getbegyx(win,y,x) (y = getbegy(win), x = getbegx(win)) #define getmaxyx(win,y,x) (y = getmaxy(win), x = getmaxx(win)) #define getparyx(win,y,x) (y = getpary(win), x = getparx(win)) #define getsyx(y,x) do { if (newscr) { \ if (is_leaveok(newscr)) \ (y) = (x) = -1; \ else \ getyx(newscr,(y), (x)); \ } \ } while(0) #define setsyx(y,x) do { if (newscr) { \ if ((y) == -1 && (x) == -1) \ leaveok(newscr, TRUE); \ else { \ leaveok(newscr, FALSE); \ wmove(newscr, (y), (x)); \ } \ } \ } while(0) #ifndef NCURSES_NOMACROS /* * These miscellaneous pseudo functions are provided for compatibility: */ #define wgetstr(w, s) wgetnstr(w, s, -1) #define getnstr(s, n) wgetnstr(stdscr, s, (n)) #define setterm(term) setupterm(term, 1, (int *)0) #define fixterm() reset_prog_mode() #define resetterm() reset_shell_mode() #define saveterm() def_prog_mode() #define crmode() cbreak() #define nocrmode() nocbreak() #define gettmode() /* It seems older SYSV curses versions define these */ #if !NCURSES_OPAQUE #define getattrs(win) NCURSES_CAST(int, NCURSES_OK_ADDR(win) ? (win)->_attrs : A_NORMAL) #define getcurx(win) (NCURSES_OK_ADDR(win) ? (win)->_curx : ERR) #define getcury(win) (NCURSES_OK_ADDR(win) ? (win)->_cury : ERR) #define getbegx(win) (NCURSES_OK_ADDR(win) ? (win)->_begx : ERR) #define getbegy(win) (NCURSES_OK_ADDR(win) ? (win)->_begy : ERR) #define getmaxx(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxx + 1) : ERR) #define getmaxy(win) (NCURSES_OK_ADDR(win) ? ((win)->_maxy + 1) : ERR) #define getparx(win) (NCURSES_OK_ADDR(win) ? (win)->_parx : ERR) #define getpary(win) (NCURSES_OK_ADDR(win) ? (win)->_pary : ERR) #endif /* NCURSES_OPAQUE */ #define wstandout(win) (wattrset(win,A_STANDOUT)) #define wstandend(win) (wattrset(win,A_NORMAL)) #define wattron(win,at) wattr_on(win, NCURSES_CAST(attr_t, at), NULL) #define wattroff(win,at) wattr_off(win, NCURSES_CAST(attr_t, at), NULL) #if !NCURSES_OPAQUE #if NCURSES_WATTR_MACROS #if NCURSES_WIDECHAR && 1 #define wattrset(win,at) \ (NCURSES_OK_ADDR(win) \ ? ((win)->_color = NCURSES_CAST(int, PAIR_NUMBER(at)), \ (win)->_attrs = NCURSES_CAST(attr_t, at), \ OK) \ : ERR) #else #define wattrset(win,at) \ (NCURSES_OK_ADDR(win) \ ? ((win)->_attrs = NCURSES_CAST(attr_t, at), \ OK) \ : ERR) #endif #endif /* NCURSES_WATTR_MACROS */ #endif /* NCURSES_OPAQUE */ #define scroll(win) wscrl(win,1) #define touchwin(win) wtouchln((win), 0, getmaxy(win), 1) #define touchline(win, s, c) wtouchln((win), s, c, 1) #define untouchwin(win) wtouchln((win), 0, getmaxy(win), 0) #define box(win, v, h) wborder(win, v, v, h, h, 0, 0, 0, 0) #define border(ls, rs, ts, bs, tl, tr, bl, br) wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br) #define hline(ch, n) whline(stdscr, ch, (n)) #define vline(ch, n) wvline(stdscr, ch, (n)) #define winstr(w, s) winnstr(w, s, -1) #define winchstr(w, s) winchnstr(w, s, -1) #define winsstr(w, s) winsnstr(w, s, -1) #if !NCURSES_OPAQUE #define redrawwin(win) wredrawln(win, 0, (NCURSES_OK_ADDR(win) ? (win)->_maxy+1 : -1)) #endif /* NCURSES_OPAQUE */ #define waddstr(win,str) waddnstr(win,str,-1) #define waddchstr(win,str) waddchnstr(win,str,-1) /* * These apply to the first 256 color pairs. */ #define COLOR_PAIR(n) (NCURSES_BITS((n), 0) & A_COLOR) #define PAIR_NUMBER(a) (NCURSES_CAST(int,((NCURSES_CAST(unsigned long,(a)) & A_COLOR) >> NCURSES_ATTR_SHIFT))) /* * pseudo functions for standard screen */ #define addch(ch) waddch(stdscr,(ch)) #define addchnstr(str,n) waddchnstr(stdscr,(str),(n)) #define addchstr(str) waddchstr(stdscr,(str)) #define addnstr(str,n) waddnstr(stdscr,(str),(n)) #define addstr(str) waddnstr(stdscr,(str),-1) #define attr_get(ap,cp,o) wattr_get(stdscr,(ap),(cp),(o)) #define attr_off(a,o) wattr_off(stdscr,(a),(o)) #define attr_on(a,o) wattr_on(stdscr,(a),(o)) #define attr_set(a,c,o) wattr_set(stdscr,(a),(c),(o)) #define attroff(at) wattroff(stdscr,(at)) #define attron(at) wattron(stdscr,(at)) #define attrset(at) wattrset(stdscr,(at)) #define bkgd(ch) wbkgd(stdscr,(ch)) #define bkgdset(ch) wbkgdset(stdscr,(ch)) #define chgat(n,a,c,o) wchgat(stdscr,(n),(a),(c),(o)) #define clear() wclear(stdscr) #define clrtobot() wclrtobot(stdscr) #define clrtoeol() wclrtoeol(stdscr) #define color_set(c,o) wcolor_set(stdscr,(c),(o)) #define delch() wdelch(stdscr) #define deleteln() winsdelln(stdscr,-1) #define echochar(c) wechochar(stdscr,(c)) #define erase() werase(stdscr) #define getch() wgetch(stdscr) #define getstr(str) wgetstr(stdscr,(str)) #define inch() winch(stdscr) #define inchnstr(s,n) winchnstr(stdscr,(s),(n)) #define inchstr(s) winchstr(stdscr,(s)) #define innstr(s,n) winnstr(stdscr,(s),(n)) #define insch(c) winsch(stdscr,(c)) #define insdelln(n) winsdelln(stdscr,(n)) #define insertln() winsdelln(stdscr,1) #define insnstr(s,n) winsnstr(stdscr,(s),(n)) #define insstr(s) winsstr(stdscr,(s)) #define instr(s) winstr(stdscr,(s)) #define move(y,x) wmove(stdscr,(y),(x)) #define refresh() wrefresh(stdscr) #define scrl(n) wscrl(stdscr,(n)) #define setscrreg(t,b) wsetscrreg(stdscr,(t),(b)) #define standend() wstandend(stdscr) #define standout() wstandout(stdscr) #define timeout(delay) wtimeout(stdscr,(delay)) #define wdeleteln(win) winsdelln(win,-1) #define winsertln(win) winsdelln(win,1) /* * mv functions */ #define mvwaddch(win,y,x,ch) (wmove((win),(y),(x)) == ERR ? ERR : waddch((win),(ch))) #define mvwaddchnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),(n))) #define mvwaddchstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddchnstr((win),(str),-1)) #define mvwaddnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),(n))) #define mvwaddstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : waddnstr((win),(str),-1)) #define mvwchgat(win,y,x,n,a,c,o) (wmove((win),(y),(x)) == ERR ? ERR : wchgat((win),(n),(a),(c),(o))) #define mvwdelch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wdelch(win)) #define mvwgetch(win,y,x) (wmove((win),(y),(x)) == ERR ? ERR : wgetch(win)) #define mvwgetnstr(win,y,x,str,n) (wmove((win),(y),(x)) == ERR ? ERR : wgetnstr((win),(str),(n))) #define mvwgetstr(win,y,x,str) (wmove((win),(y),(x)) == ERR ? ERR : wgetstr((win),(str))) #define mvwhline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : whline((win),(c),(n))) #define mvwinch(win,y,x) (wmove((win),(y),(x)) == ERR ? NCURSES_CAST(chtype, ERR) : winch(win)) #define mvwinchnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winchnstr((win),(s),(n))) #define mvwinchstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winchstr((win),(s))) #define mvwinnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winnstr((win),(s),(n))) #define mvwinsch(win,y,x,c) (wmove((win),(y),(x)) == ERR ? ERR : winsch((win),(c))) #define mvwinsnstr(win,y,x,s,n) (wmove((win),(y),(x)) == ERR ? ERR : winsnstr((win),(s),(n))) #define mvwinsstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winsstr((win),(s))) #define mvwinstr(win,y,x,s) (wmove((win),(y),(x)) == ERR ? ERR : winstr((win),(s))) #define mvwvline(win,y,x,c,n) (wmove((win),(y),(x)) == ERR ? ERR : wvline((win),(c),(n))) #define mvaddch(y,x,ch) mvwaddch(stdscr,(y),(x),(ch)) #define mvaddchnstr(y,x,str,n) mvwaddchnstr(stdscr,(y),(x),(str),(n)) #define mvaddchstr(y,x,str) mvwaddchstr(stdscr,(y),(x),(str)) #define mvaddnstr(y,x,str,n) mvwaddnstr(stdscr,(y),(x),(str),(n)) #define mvaddstr(y,x,str) mvwaddstr(stdscr,(y),(x),(str)) #define mvchgat(y,x,n,a,c,o) mvwchgat(stdscr,(y),(x),(n),(a),(c),(o)) #define mvdelch(y,x) mvwdelch(stdscr,(y),(x)) #define mvgetch(y,x) mvwgetch(stdscr,(y),(x)) #define mvgetnstr(y,x,str,n) mvwgetnstr(stdscr,(y),(x),(str),(n)) #define mvgetstr(y,x,str) mvwgetstr(stdscr,(y),(x),(str)) #define mvhline(y,x,c,n) mvwhline(stdscr,(y),(x),(c),(n)) #define mvinch(y,x) mvwinch(stdscr,(y),(x)) #define mvinchnstr(y,x,s,n) mvwinchnstr(stdscr,(y),(x),(s),(n)) #define mvinchstr(y,x,s) mvwinchstr(stdscr,(y),(x),(s)) #define mvinnstr(y,x,s,n) mvwinnstr(stdscr,(y),(x),(s),(n)) #define mvinsch(y,x,c) mvwinsch(stdscr,(y),(x),(c)) #define mvinsnstr(y,x,s,n) mvwinsnstr(stdscr,(y),(x),(s),(n)) #define mvinsstr(y,x,s) mvwinsstr(stdscr,(y),(x),(s)) #define mvinstr(y,x,s) mvwinstr(stdscr,(y),(x),(s)) #define mvvline(y,x,c,n) mvwvline(stdscr,(y),(x),(c),(n)) /* * Some wide-character functions can be implemented without the extensions. */ #if !NCURSES_OPAQUE #define getbkgd(win) (NCURSES_OK_ADDR(win) ? ((win)->_bkgd) : 0) #endif /* NCURSES_OPAQUE */ #define slk_attr_off(a,v) ((v) ? ERR : slk_attroff(a)) #define slk_attr_on(a,v) ((v) ? ERR : slk_attron(a)) #if !NCURSES_OPAQUE #if NCURSES_WATTR_MACROS #if NCURSES_WIDECHAR && 1 #define wattr_set(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)((win)->_attrs = ((a) & ~A_COLOR), \ (win)->_color = (opts) ? *(int *)(opts) : (p)), \ OK) \ : ERR) #define wattr_get(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)(NCURSES_OK_ADDR(a) \ ? (*(a) = (win)->_attrs) \ : OK), \ (void)(NCURSES_OK_ADDR(p) \ ? (*(p) = (NCURSES_PAIRS_T) (win)->_color) \ : OK), \ (void)(NCURSES_OK_ADDR(opts) \ ? (*(int *)(opts) = (win)->_color) \ : OK), \ OK) \ : ERR) #else /* !(NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */ #define wattr_set(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)((win)->_attrs = (((a) & ~A_COLOR) | \ (attr_t)COLOR_PAIR(p))), \ OK) \ : ERR) #define wattr_get(win,a,p,opts) \ (NCURSES_OK_ADDR(win) \ ? ((void)(NCURSES_OK_ADDR(a) \ ? (*(a) = (win)->_attrs) \ : OK), \ (void)(NCURSES_OK_ADDR(p) \ ? (*(p) = (NCURSES_PAIRS_T) PAIR_NUMBER((win)->_attrs)) \ : OK), \ OK) \ : ERR) #endif /* (NCURSES_WIDECHAR && NCURSES_EXE_COLORS) */ #endif /* NCURSES_WATTR_MACROS */ #endif /* NCURSES_OPAQUE */ /* * X/Open curses deprecates SVr4 vwprintw/vwscanw, which are supposed to use * varargs.h. It adds new calls vw_printw/vw_scanw, which are supposed to * use POSIX stdarg.h. The ncurses versions of vwprintw/vwscanw already * use stdarg.h, so... */ /* define vw_printw vwprintw */ /* define vw_scanw vwscanw */ /* * Export fallback function for use in C++ binding. */ #if !1 #define vsscanf(a,b,c) _nc_vsscanf(a,b,c) NCURSES_EXPORT(int) vsscanf(const char *, const char *, va_list); #endif /* * These macros are extensions - not in X/Open Curses. */ #if 1 #if !NCURSES_OPAQUE #define is_cleared(win) (NCURSES_OK_ADDR(win) ? (win)->_clear : FALSE) #define is_idcok(win) (NCURSES_OK_ADDR(win) ? (win)->_idcok : FALSE) #define is_idlok(win) (NCURSES_OK_ADDR(win) ? (win)->_idlok : FALSE) #define is_immedok(win) (NCURSES_OK_ADDR(win) ? (win)->_immed : FALSE) #define is_keypad(win) (NCURSES_OK_ADDR(win) ? (win)->_use_keypad : FALSE) #define is_leaveok(win) (NCURSES_OK_ADDR(win) ? (win)->_leaveok : FALSE) #define is_nodelay(win) (NCURSES_OK_ADDR(win) ? ((win)->_delay == 0) : FALSE) #define is_notimeout(win) (NCURSES_OK_ADDR(win) ? (win)->_notimeout : FALSE) #define is_pad(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _ISPAD) != 0 : FALSE) #define is_scrollok(win) (NCURSES_OK_ADDR(win) ? (win)->_scroll : FALSE) #define is_subwin(win) (NCURSES_OK_ADDR(win) ? ((win)->_flags & _SUBWIN) != 0 : FALSE) #define is_syncok(win) (NCURSES_OK_ADDR(win) ? (win)->_sync : FALSE) #define wgetdelay(win) (NCURSES_OK_ADDR(win) ? (win)->_delay : 0) #define wgetparent(win) (NCURSES_OK_ADDR(win) ? (win)->_parent : 0) #define wgetscrreg(win,t,b) (NCURSES_OK_ADDR(win) ? (*(t) = (win)->_regtop, *(b) = (win)->_regbottom, OK) : ERR) #endif #endif /* * X/Open says this returns a bool; SVr4 also checked for out-of-range line. * The macro provides compatibility: */ #define is_linetouched(w,l) ((!(w) || ((l) > getmaxy(w)) || ((l) < 0)) ? ERR : (is_linetouched)((w),(l))) #endif /* NCURSES_NOMACROS */ /* * Public variables. * * Notes: * a. ESCDELAY was an undocumented feature under AIX curses. * It gives the ESC expire time in milliseconds. * b. ttytype is needed for backward compatibility */ #if NCURSES_REENTRANT NCURSES_WRAPPED_VAR(WINDOW *, curscr); NCURSES_WRAPPED_VAR(WINDOW *, newscr); NCURSES_WRAPPED_VAR(WINDOW *, stdscr); NCURSES_WRAPPED_VAR(char *, ttytype); NCURSES_WRAPPED_VAR(int, COLORS); NCURSES_WRAPPED_VAR(int, COLOR_PAIRS); NCURSES_WRAPPED_VAR(int, COLS); NCURSES_WRAPPED_VAR(int, ESCDELAY); NCURSES_WRAPPED_VAR(int, LINES); NCURSES_WRAPPED_VAR(int, TABSIZE); #define curscr NCURSES_PUBLIC_VAR(curscr()) #define newscr NCURSES_PUBLIC_VAR(newscr()) #define stdscr NCURSES_PUBLIC_VAR(stdscr()) #define ttytype NCURSES_PUBLIC_VAR(ttytype()) #define COLORS NCURSES_PUBLIC_VAR(COLORS()) #define COLOR_PAIRS NCURSES_PUBLIC_VAR(COLOR_PAIRS()) #define COLS NCURSES_PUBLIC_VAR(COLS()) #define ESCDELAY NCURSES_PUBLIC_VAR(ESCDELAY()) #define LINES NCURSES_PUBLIC_VAR(LINES()) #define TABSIZE NCURSES_PUBLIC_VAR(TABSIZE()) #else extern NCURSES_EXPORT_VAR(WINDOW *) curscr; extern NCURSES_EXPORT_VAR(WINDOW *) newscr; extern NCURSES_EXPORT_VAR(WINDOW *) stdscr; extern NCURSES_EXPORT_VAR(char) ttytype[]; extern NCURSES_EXPORT_VAR(int) COLORS; extern NCURSES_EXPORT_VAR(int) COLOR_PAIRS; extern NCURSES_EXPORT_VAR(int) COLS; extern NCURSES_EXPORT_VAR(int) ESCDELAY; extern NCURSES_EXPORT_VAR(int) LINES; extern NCURSES_EXPORT_VAR(int) TABSIZE; #endif /* * Pseudo-character tokens outside ASCII range. The curses wgetch() function * will return any given one of these only if the corresponding k- capability * is defined in your terminal's terminfo entry. * * Some keys (KEY_A1, etc) are arranged like this: * a1 up a3 * left b2 right * c1 down c3 * * A few key codes do not depend upon the terminfo entry. */ #define KEY_CODE_YES 0400 /* A wchar_t contains a key code */ #define KEY_MIN 0401 /* Minimum curses key */ #define KEY_BREAK 0401 /* Break key (unreliable) */ #define KEY_SRESET 0530 /* Soft (partial) reset (unreliable) */ #define KEY_RESET 0531 /* Reset or hard reset (unreliable) */ /* * These definitions were generated by ./MKkey_defs.sh ../../include/Caps ../../include/Caps-ncurses */ #define KEY_DOWN 0402 /* down-arrow key */ #define KEY_UP 0403 /* up-arrow key */ #define KEY_LEFT 0404 /* left-arrow key */ #define KEY_RIGHT 0405 /* right-arrow key */ #define KEY_HOME 0406 /* home key */ #define KEY_BACKSPACE 0407 /* backspace key */ #define KEY_F0 0410 /* Function keys. Space for 64 */ #define KEY_F(n) (KEY_F0+(n)) /* Value of function key n */ #define KEY_DL 0510 /* delete-line key */ #define KEY_IL 0511 /* insert-line key */ #define KEY_DC 0512 /* delete-character key */ #define KEY_IC 0513 /* insert-character key */ #define KEY_EIC 0514 /* sent by rmir or smir in insert mode */ #define KEY_CLEAR 0515 /* clear-screen or erase key */ #define KEY_EOS 0516 /* clear-to-end-of-screen key */ #define KEY_EOL 0517 /* clear-to-end-of-line key */ #define KEY_SF 0520 /* scroll-forward key */ #define KEY_SR 0521 /* scroll-backward key */ #define KEY_NPAGE 0522 /* next-page key */ #define KEY_PPAGE 0523 /* previous-page key */ #define KEY_STAB 0524 /* set-tab key */ #define KEY_CTAB 0525 /* clear-tab key */ #define KEY_CATAB 0526 /* clear-all-tabs key */ #define KEY_ENTER 0527 /* enter/send key */ #define KEY_PRINT 0532 /* print key */ #define KEY_LL 0533 /* lower-left key (home down) */ #define KEY_A1 0534 /* upper left of keypad */ #define KEY_A3 0535 /* upper right of keypad */ #define KEY_B2 0536 /* center of keypad */ #define KEY_C1 0537 /* lower left of keypad */ #define KEY_C3 0540 /* lower right of keypad */ #define KEY_BTAB 0541 /* back-tab key */ #define KEY_BEG 0542 /* begin key */ #define KEY_CANCEL 0543 /* cancel key */ #define KEY_CLOSE 0544 /* close key */ #define KEY_COMMAND 0545 /* command key */ #define KEY_COPY 0546 /* copy key */ #define KEY_CREATE 0547 /* create key */ #define KEY_END 0550 /* end key */ #define KEY_EXIT 0551 /* exit key */ #define KEY_FIND 0552 /* find key */ #define KEY_HELP 0553 /* help key */ #define KEY_MARK 0554 /* mark key */ #define KEY_MESSAGE 0555 /* message key */ #define KEY_MOVE 0556 /* move key */ #define KEY_NEXT 0557 /* next key */ #define KEY_OPEN 0560 /* open key */ #define KEY_OPTIONS 0561 /* options key */ #define KEY_PREVIOUS 0562 /* previous key */ #define KEY_REDO 0563 /* redo key */ #define KEY_REFERENCE 0564 /* reference key */ #define KEY_REFRESH 0565 /* refresh key */ #define KEY_REPLACE 0566 /* replace key */ #define KEY_RESTART 0567 /* restart key */ #define KEY_RESUME 0570 /* resume key */ #define KEY_SAVE 0571 /* save key */ #define KEY_SBEG 0572 /* shifted begin key */ #define KEY_SCANCEL 0573 /* shifted cancel key */ #define KEY_SCOMMAND 0574 /* shifted command key */ #define KEY_SCOPY 0575 /* shifted copy key */ #define KEY_SCREATE 0576 /* shifted create key */ #define KEY_SDC 0577 /* shifted delete-character key */ #define KEY_SDL 0600 /* shifted delete-line key */ #define KEY_SELECT 0601 /* select key */ #define KEY_SEND 0602 /* shifted end key */ #define KEY_SEOL 0603 /* shifted clear-to-end-of-line key */ #define KEY_SEXIT 0604 /* shifted exit key */ #define KEY_SFIND 0605 /* shifted find key */ #define KEY_SHELP 0606 /* shifted help key */ #define KEY_SHOME 0607 /* shifted home key */ #define KEY_SIC 0610 /* shifted insert-character key */ #define KEY_SLEFT 0611 /* shifted left-arrow key */ #define KEY_SMESSAGE 0612 /* shifted message key */ #define KEY_SMOVE 0613 /* shifted move key */ #define KEY_SNEXT 0614 /* shifted next key */ #define KEY_SOPTIONS 0615 /* shifted options key */ #define KEY_SPREVIOUS 0616 /* shifted previous key */ #define KEY_SPRINT 0617 /* shifted print key */ #define KEY_SREDO 0620 /* shifted redo key */ #define KEY_SREPLACE 0621 /* shifted replace key */ #define KEY_SRIGHT 0622 /* shifted right-arrow key */ #define KEY_SRSUME 0623 /* shifted resume key */ #define KEY_SSAVE 0624 /* shifted save key */ #define KEY_SSUSPEND 0625 /* shifted suspend key */ #define KEY_SUNDO 0626 /* shifted undo key */ #define KEY_SUSPEND 0627 /* suspend key */ #define KEY_UNDO 0630 /* undo key */ #define KEY_MOUSE 0631 /* Mouse event has occurred */ #ifdef NCURSES_EXT_FUNCS #define KEY_RESIZE 0632 /* Terminal resize event */ #endif #define KEY_MAX 0777 /* Maximum key value is 0632 */ /* $Id: curses.wide,v 1.50 2017/03/26 16:05:21 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in * (see that file for the relevant copyright). */ #define _XOPEN_CURSES 1 #if NCURSES_WIDECHAR extern NCURSES_EXPORT_VAR(cchar_t *) _nc_wacs; #define NCURSES_WACS(c) (&_nc_wacs[NCURSES_CAST(unsigned char,(c))]) #define WACS_BSSB NCURSES_WACS('l') #define WACS_SSBB NCURSES_WACS('m') #define WACS_BBSS NCURSES_WACS('k') #define WACS_SBBS NCURSES_WACS('j') #define WACS_SBSS NCURSES_WACS('u') #define WACS_SSSB NCURSES_WACS('t') #define WACS_SSBS NCURSES_WACS('v') #define WACS_BSSS NCURSES_WACS('w') #define WACS_BSBS NCURSES_WACS('q') #define WACS_SBSB NCURSES_WACS('x') #define WACS_SSSS NCURSES_WACS('n') #define WACS_ULCORNER WACS_BSSB #define WACS_LLCORNER WACS_SSBB #define WACS_URCORNER WACS_BBSS #define WACS_LRCORNER WACS_SBBS #define WACS_RTEE WACS_SBSS #define WACS_LTEE WACS_SSSB #define WACS_BTEE WACS_SSBS #define WACS_TTEE WACS_BSSS #define WACS_HLINE WACS_BSBS #define WACS_VLINE WACS_SBSB #define WACS_PLUS WACS_SSSS #define WACS_S1 NCURSES_WACS('o') /* scan line 1 */ #define WACS_S9 NCURSES_WACS('s') /* scan line 9 */ #define WACS_DIAMOND NCURSES_WACS('`') /* diamond */ #define WACS_CKBOARD NCURSES_WACS('a') /* checker board */ #define WACS_DEGREE NCURSES_WACS('f') /* degree symbol */ #define WACS_PLMINUS NCURSES_WACS('g') /* plus/minus */ #define WACS_BULLET NCURSES_WACS('~') /* bullet */ /* Teletype 5410v1 symbols */ #define WACS_LARROW NCURSES_WACS(',') /* arrow left */ #define WACS_RARROW NCURSES_WACS('+') /* arrow right */ #define WACS_DARROW NCURSES_WACS('.') /* arrow down */ #define WACS_UARROW NCURSES_WACS('-') /* arrow up */ #define WACS_BOARD NCURSES_WACS('h') /* board of squares */ #define WACS_LANTERN NCURSES_WACS('i') /* lantern symbol */ #define WACS_BLOCK NCURSES_WACS('0') /* solid square block */ /* ncurses extensions */ #define WACS_S3 NCURSES_WACS('p') /* scan line 3 */ #define WACS_S7 NCURSES_WACS('r') /* scan line 7 */ #define WACS_LEQUAL NCURSES_WACS('y') /* less/equal */ #define WACS_GEQUAL NCURSES_WACS('z') /* greater/equal */ #define WACS_PI NCURSES_WACS('{') /* Pi */ #define WACS_NEQUAL NCURSES_WACS('|') /* not equal */ #define WACS_STERLING NCURSES_WACS('}') /* UK pound sign */ /* double lines */ #define WACS_BDDB NCURSES_WACS('C') #define WACS_DDBB NCURSES_WACS('D') #define WACS_BBDD NCURSES_WACS('B') #define WACS_DBBD NCURSES_WACS('A') #define WACS_DBDD NCURSES_WACS('G') #define WACS_DDDB NCURSES_WACS('F') #define WACS_DDBD NCURSES_WACS('H') #define WACS_BDDD NCURSES_WACS('I') #define WACS_BDBD NCURSES_WACS('R') #define WACS_DBDB NCURSES_WACS('Y') #define WACS_DDDD NCURSES_WACS('E') #define WACS_D_ULCORNER WACS_BDDB #define WACS_D_LLCORNER WACS_DDBB #define WACS_D_URCORNER WACS_BBDD #define WACS_D_LRCORNER WACS_DBBD #define WACS_D_RTEE WACS_DBDD #define WACS_D_LTEE WACS_DDDB #define WACS_D_BTEE WACS_DDBD #define WACS_D_TTEE WACS_BDDD #define WACS_D_HLINE WACS_BDBD #define WACS_D_VLINE WACS_DBDB #define WACS_D_PLUS WACS_DDDD /* thick lines */ #define WACS_BTTB NCURSES_WACS('L') #define WACS_TTBB NCURSES_WACS('M') #define WACS_BBTT NCURSES_WACS('K') #define WACS_TBBT NCURSES_WACS('J') #define WACS_TBTT NCURSES_WACS('U') #define WACS_TTTB NCURSES_WACS('T') #define WACS_TTBT NCURSES_WACS('V') #define WACS_BTTT NCURSES_WACS('W') #define WACS_BTBT NCURSES_WACS('Q') #define WACS_TBTB NCURSES_WACS('X') #define WACS_TTTT NCURSES_WACS('N') #define WACS_T_ULCORNER WACS_BTTB #define WACS_T_LLCORNER WACS_TTBB #define WACS_T_URCORNER WACS_BBTT #define WACS_T_LRCORNER WACS_TBBT #define WACS_T_RTEE WACS_TBTT #define WACS_T_LTEE WACS_TTTB #define WACS_T_BTEE WACS_TTBT #define WACS_T_TTEE WACS_BTTT #define WACS_T_HLINE WACS_BTBT #define WACS_T_VLINE WACS_TBTB #define WACS_T_PLUS WACS_TTTT /* * Function prototypes for wide-character operations. * * "generated" comments should include ":WIDEC" to make the corresponding * functions ifdef'd in lib_gen.c * * "implemented" comments do not need this marker. */ extern NCURSES_EXPORT(int) add_wch (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) add_wchnstr (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) add_wchstr (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) addnwstr (const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) addwstr (const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) bkgrnd (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(void) bkgrndset (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) border_set (const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* generated:WIDEC */ extern NCURSES_EXPORT(int) box_set (WINDOW *, const cchar_t *, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) echo_wchar (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) erasewchar (wchar_t*); /* implemented */ extern NCURSES_EXPORT(int) get_wch (wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) get_wstr (wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) getbkgrnd (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) getcchar (const cchar_t *, wchar_t*, attr_t*, NCURSES_PAIRS_T*, void*); /* implemented */ extern NCURSES_EXPORT(int) getn_wstr (wint_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) hline_set (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wch (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wchnstr (cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) in_wchstr (cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) innwstr (wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_nwstr (const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_wch (const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) ins_wstr (const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) inwstr (wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(NCURSES_CONST char*) key_name (wchar_t); /* implemented */ extern NCURSES_EXPORT(int) killwchar (wchar_t *); /* implemented */ extern NCURSES_EXPORT(int) mvadd_wch (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvadd_wchnstr (int, int, const cchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvadd_wchstr (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvaddnwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvaddwstr (int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvget_wch (int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvget_wstr (int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvgetn_wstr (int, int, wint_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvhline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wch (int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wchnstr (int, int, cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvin_wchstr (int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvinnwstr (int, int, wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_nwstr (int, int, const wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_wch (int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvins_wstr (int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvinwstr (int, int, wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvvline_set (int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wchnstr (WINDOW *, int, int, const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwadd_wchstr (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwaddnwstr (WINDOW *, int, int, const wchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwaddwstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwget_wch (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwget_wstr (WINDOW *, int, int, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwgetn_wstr (WINDOW *, int, int, wint_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwhline_set (WINDOW *, int, int, const cchar_t *, int);/* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wch (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wchnstr (WINDOW *, int,int, cchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwin_wchstr (WINDOW *, int, int, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwinnwstr (WINDOW *, int, int, wchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_nwstr (WINDOW *, int,int, const wchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_wch (WINDOW *, int, int, const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwins_wstr (WINDOW *, int, int, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwinwstr (WINDOW *, int, int, wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) mvwvline_set (WINDOW *, int,int, const cchar_t *,int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) pecho_wchar (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) setcchar (cchar_t *, const wchar_t *, const attr_t, NCURSES_PAIRS_T, const void *); /* implemented */ extern NCURSES_EXPORT(int) slk_wset (int, const wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(attr_t) term_attrs (void); /* implemented */ extern NCURSES_EXPORT(int) unget_wch (const wchar_t); /* implemented */ extern NCURSES_EXPORT(int) vid_attr (attr_t, NCURSES_PAIRS_T, void *); /* implemented */ extern NCURSES_EXPORT(int) vid_puts (attr_t, NCURSES_PAIRS_T, void *, NCURSES_OUTC); /* implemented */ extern NCURSES_EXPORT(int) vline_set (const cchar_t *, int); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wadd_wch (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wadd_wchnstr (WINDOW *,const cchar_t *,int); /* implemented */ extern NCURSES_EXPORT(int) wadd_wchstr (WINDOW *,const cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) waddnwstr (WINDOW *,const wchar_t *,int); /* implemented */ extern NCURSES_EXPORT(int) waddwstr (WINDOW *,const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wbkgrnd (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(void) wbkgrndset (WINDOW *,const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wborder_set (WINDOW *,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*,const cchar_t*); /* implemented */ extern NCURSES_EXPORT(int) wecho_wchar (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wget_wch (WINDOW *, wint_t *); /* implemented */ extern NCURSES_EXPORT(int) wget_wstr (WINDOW *, wint_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wgetbkgrnd (WINDOW *, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) wgetn_wstr (WINDOW *, wint_t *, int); /* implemented */ extern NCURSES_EXPORT(int) whline_set (WINDOW *, const cchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) win_wch (WINDOW *, cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) win_wchnstr (WINDOW *, cchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) win_wchstr (WINDOW *, cchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) winnwstr (WINDOW *, wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) wins_nwstr (WINDOW *, const wchar_t *, int); /* implemented */ extern NCURSES_EXPORT(int) wins_wch (WINDOW *, const cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wins_wstr (WINDOW *, const wchar_t *); /* generated:WIDEC */ extern NCURSES_EXPORT(int) winwstr (WINDOW *, wchar_t *); /* implemented */ extern NCURSES_EXPORT(wchar_t*) wunctrl (cchar_t *); /* implemented */ extern NCURSES_EXPORT(int) wvline_set (WINDOW *, const cchar_t *, int); /* implemented */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(attr_t) NCURSES_SP_NAME(term_attrs) (SCREEN*); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(unget_wch) (SCREEN*, const wchar_t); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(wchar_t*) NCURSES_SP_NAME(wunctrl) (SCREEN*, cchar_t *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_attr) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *); /* implemented:SP_FUNC */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(vid_puts) (SCREEN*, attr_t, NCURSES_PAIRS_T, void *, NCURSES_SP_OUTC); /* implemented:SP_FUNC */ #endif #ifndef NCURSES_NOMACROS /* * XSI curses macros for XPG4 conformance. */ #define add_wch(c) wadd_wch(stdscr,(c)) #define add_wchnstr(str,n) wadd_wchnstr(stdscr,(str),(n)) #define add_wchstr(str) wadd_wchstr(stdscr,(str)) #define addnwstr(wstr,n) waddnwstr(stdscr,(wstr),(n)) #define addwstr(wstr) waddwstr(stdscr,(wstr)) #define bkgrnd(c) wbkgrnd(stdscr,(c)) #define bkgrndset(c) wbkgrndset(stdscr,(c)) #define border_set(l,r,t,b,tl,tr,bl,br) wborder_set(stdscr,(l),(r),(t),(b),tl,tr,bl,br) #define box_set(w,v,h) wborder_set((w),(v),(v),(h),(h),0,0,0,0) #define echo_wchar(c) wecho_wchar(stdscr,(c)) #define get_wch(c) wget_wch(stdscr,(c)) #define get_wstr(t) wget_wstr(stdscr,(t)) #define getbkgrnd(wch) wgetbkgrnd(stdscr,(wch)) #define getn_wstr(t,n) wgetn_wstr(stdscr,(t),(n)) #define hline_set(c,n) whline_set(stdscr,(c),(n)) #define in_wch(c) win_wch(stdscr,(c)) #define in_wchnstr(c,n) win_wchnstr(stdscr,(c),(n)) #define in_wchstr(c) win_wchstr(stdscr,(c)) #define innwstr(c,n) winnwstr(stdscr,(c),(n)) #define ins_nwstr(t,n) wins_nwstr(stdscr,(t),(n)) #define ins_wch(c) wins_wch(stdscr,(c)) #define ins_wstr(t) wins_wstr(stdscr,(t)) #define inwstr(c) winwstr(stdscr,(c)) #define vline_set(c,n) wvline_set(stdscr,(c),(n)) #define wadd_wchstr(win,str) wadd_wchnstr((win),(str),-1) #define waddwstr(win,wstr) waddnwstr((win),(wstr),-1) #define wget_wstr(w,t) wgetn_wstr((w),(t),-1) #define win_wchstr(w,c) win_wchnstr((w),(c),-1) #define wins_wstr(w,t) wins_nwstr((w),(t),-1) #if !NCURSES_OPAQUE #define wgetbkgrnd(win,wch) (NCURSES_OK_ADDR(wch) ? ((win) ? (*(wch) = (win)->_bkgrnd) : *(wch), OK) : ERR) #endif #define mvadd_wch(y,x,c) mvwadd_wch(stdscr,(y),(x),(c)) #define mvadd_wchnstr(y,x,s,n) mvwadd_wchnstr(stdscr,(y),(x),(s),(n)) #define mvadd_wchstr(y,x,s) mvwadd_wchstr(stdscr,(y),(x),(s)) #define mvaddnwstr(y,x,wstr,n) mvwaddnwstr(stdscr,(y),(x),(wstr),(n)) #define mvaddwstr(y,x,wstr) mvwaddwstr(stdscr,(y),(x),(wstr)) #define mvget_wch(y,x,c) mvwget_wch(stdscr,(y),(x),(c)) #define mvget_wstr(y,x,t) mvwget_wstr(stdscr,(y),(x),(t)) #define mvgetn_wstr(y,x,t,n) mvwgetn_wstr(stdscr,(y),(x),(t),(n)) #define mvhline_set(y,x,c,n) mvwhline_set(stdscr,(y),(x),(c),(n)) #define mvin_wch(y,x,c) mvwin_wch(stdscr,(y),(x),(c)) #define mvin_wchnstr(y,x,c,n) mvwin_wchnstr(stdscr,(y),(x),(c),(n)) #define mvin_wchstr(y,x,c) mvwin_wchstr(stdscr,(y),(x),(c)) #define mvinnwstr(y,x,c,n) mvwinnwstr(stdscr,(y),(x),(c),(n)) #define mvins_nwstr(y,x,t,n) mvwins_nwstr(stdscr,(y),(x),(t),(n)) #define mvins_wch(y,x,c) mvwins_wch(stdscr,(y),(x),(c)) #define mvins_wstr(y,x,t) mvwins_wstr(stdscr,(y),(x),(t)) #define mvinwstr(y,x,c) mvwinwstr(stdscr,(y),(x),(c)) #define mvvline_set(y,x,c,n) mvwvline_set(stdscr,(y),(x),(c),(n)) #define mvwadd_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wch((win),(c))) #define mvwadd_wchnstr(win,y,x,s,n) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchnstr((win),(s),(n))) #define mvwadd_wchstr(win,y,x,s) (wmove(win,(y),(x)) == ERR ? ERR : wadd_wchstr((win),(s))) #define mvwaddnwstr(win,y,x,wstr,n) (wmove(win,(y),(x)) == ERR ? ERR : waddnwstr((win),(wstr),(n))) #define mvwaddwstr(win,y,x,wstr) (wmove(win,(y),(x)) == ERR ? ERR : waddwstr((win),(wstr))) #define mvwget_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wget_wch((win),(c))) #define mvwget_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wget_wstr((win),(t))) #define mvwgetn_wstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wgetn_wstr((win),(t),(n))) #define mvwhline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : whline_set((win),(c),(n))) #define mvwin_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wch((win),(c))) #define mvwin_wchnstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : win_wchnstr((win),(c),(n))) #define mvwin_wchstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : win_wchstr((win),(c))) #define mvwinnwstr(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : winnwstr((win),(c),(n))) #define mvwins_nwstr(win,y,x,t,n) (wmove(win,(y),(x)) == ERR ? ERR : wins_nwstr((win),(t),(n))) #define mvwins_wch(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : wins_wch((win),(c))) #define mvwins_wstr(win,y,x,t) (wmove(win,(y),(x)) == ERR ? ERR : wins_wstr((win),(t))) #define mvwinwstr(win,y,x,c) (wmove(win,(y),(x)) == ERR ? ERR : winwstr((win),(c))) #define mvwvline_set(win,y,x,c,n) (wmove(win,(y),(x)) == ERR ? ERR : wvline_set((win),(c),(n))) #endif /* NCURSES_NOMACROS */ #if defined(TRACE) || defined(NCURSES_TEST) extern NCURSES_EXPORT(const char *) _nc_viswbuf(const wchar_t *); extern NCURSES_EXPORT(const char *) _nc_viswibuf(const wint_t *); #endif #endif /* NCURSES_WIDECHAR */ /* $Id: curses.tail,v 1.26 2021/03/20 15:49:25 tom Exp $ */ /* * vile:cmode: * This file is part of ncurses, designed to be appended after curses.h.in * (see that file for the relevant copyright). */ /* mouse interface */ #if NCURSES_MOUSE_VERSION > 1 #define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 5)) #else #define NCURSES_MOUSE_MASK(b,m) ((m) << (((b) - 1) * 6)) #endif #define NCURSES_BUTTON_RELEASED 001L #define NCURSES_BUTTON_PRESSED 002L #define NCURSES_BUTTON_CLICKED 004L #define NCURSES_DOUBLE_CLICKED 010L #define NCURSES_TRIPLE_CLICKED 020L #define NCURSES_RESERVED_EVENT 040L /* event masks */ #define BUTTON1_RELEASED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_RELEASED) #define BUTTON1_PRESSED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_PRESSED) #define BUTTON1_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_BUTTON_CLICKED) #define BUTTON1_DOUBLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_DOUBLE_CLICKED) #define BUTTON1_TRIPLE_CLICKED NCURSES_MOUSE_MASK(1, NCURSES_TRIPLE_CLICKED) #define BUTTON2_RELEASED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_RELEASED) #define BUTTON2_PRESSED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_PRESSED) #define BUTTON2_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_BUTTON_CLICKED) #define BUTTON2_DOUBLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_DOUBLE_CLICKED) #define BUTTON2_TRIPLE_CLICKED NCURSES_MOUSE_MASK(2, NCURSES_TRIPLE_CLICKED) #define BUTTON3_RELEASED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_RELEASED) #define BUTTON3_PRESSED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_PRESSED) #define BUTTON3_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_BUTTON_CLICKED) #define BUTTON3_DOUBLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_DOUBLE_CLICKED) #define BUTTON3_TRIPLE_CLICKED NCURSES_MOUSE_MASK(3, NCURSES_TRIPLE_CLICKED) #define BUTTON4_RELEASED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_RELEASED) #define BUTTON4_PRESSED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_PRESSED) #define BUTTON4_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_BUTTON_CLICKED) #define BUTTON4_DOUBLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_DOUBLE_CLICKED) #define BUTTON4_TRIPLE_CLICKED NCURSES_MOUSE_MASK(4, NCURSES_TRIPLE_CLICKED) /* * In 32 bits the version-1 scheme does not provide enough space for a 5th * button, unless we choose to change the ABI by omitting the reserved-events. */ #if NCURSES_MOUSE_VERSION > 1 #define BUTTON5_RELEASED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_RELEASED) #define BUTTON5_PRESSED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_PRESSED) #define BUTTON5_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_BUTTON_CLICKED) #define BUTTON5_DOUBLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_DOUBLE_CLICKED) #define BUTTON5_TRIPLE_CLICKED NCURSES_MOUSE_MASK(5, NCURSES_TRIPLE_CLICKED) #define BUTTON_CTRL NCURSES_MOUSE_MASK(6, 0001L) #define BUTTON_SHIFT NCURSES_MOUSE_MASK(6, 0002L) #define BUTTON_ALT NCURSES_MOUSE_MASK(6, 0004L) #define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(6, 0010L) #else #define BUTTON1_RESERVED_EVENT NCURSES_MOUSE_MASK(1, NCURSES_RESERVED_EVENT) #define BUTTON2_RESERVED_EVENT NCURSES_MOUSE_MASK(2, NCURSES_RESERVED_EVENT) #define BUTTON3_RESERVED_EVENT NCURSES_MOUSE_MASK(3, NCURSES_RESERVED_EVENT) #define BUTTON4_RESERVED_EVENT NCURSES_MOUSE_MASK(4, NCURSES_RESERVED_EVENT) #define BUTTON_CTRL NCURSES_MOUSE_MASK(5, 0001L) #define BUTTON_SHIFT NCURSES_MOUSE_MASK(5, 0002L) #define BUTTON_ALT NCURSES_MOUSE_MASK(5, 0004L) #define REPORT_MOUSE_POSITION NCURSES_MOUSE_MASK(5, 0010L) #endif #define ALL_MOUSE_EVENTS (REPORT_MOUSE_POSITION - 1) /* macros to extract single event-bits from masks */ #define BUTTON_RELEASE(e, x) ((e) & NCURSES_MOUSE_MASK(x, 001)) #define BUTTON_PRESS(e, x) ((e) & NCURSES_MOUSE_MASK(x, 002)) #define BUTTON_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 004)) #define BUTTON_DOUBLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 010)) #define BUTTON_TRIPLE_CLICK(e, x) ((e) & NCURSES_MOUSE_MASK(x, 020)) #define BUTTON_RESERVED_EVENT(e, x) ((e) & NCURSES_MOUSE_MASK(x, 040)) typedef struct { short id; /* ID to distinguish multiple devices */ int x, y, z; /* event coordinates (character-cell) */ mmask_t bstate; /* button state bits */ } MEVENT; extern NCURSES_EXPORT(bool) has_mouse(void); extern NCURSES_EXPORT(int) getmouse (MEVENT *); extern NCURSES_EXPORT(int) ungetmouse (MEVENT *); extern NCURSES_EXPORT(mmask_t) mousemask (mmask_t, mmask_t *); extern NCURSES_EXPORT(bool) wenclose (const WINDOW *, int, int); extern NCURSES_EXPORT(int) mouseinterval (int); extern NCURSES_EXPORT(bool) wmouse_trafo (const WINDOW*, int*, int*, bool); extern NCURSES_EXPORT(bool) mouse_trafo (int*, int*, bool); /* generated */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(bool) NCURSES_SP_NAME(has_mouse) (SCREEN*); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(getmouse) (SCREEN*, MEVENT *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(ungetmouse) (SCREEN*,MEVENT *); extern NCURSES_EXPORT(mmask_t) NCURSES_SP_NAME(mousemask) (SCREEN*, mmask_t, mmask_t *); extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mouseinterval) (SCREEN*, int); #endif #ifndef NCURSES_NOMACROS #define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen) #endif /* other non-XSI functions */ extern NCURSES_EXPORT(int) mcprint (char *, int); /* direct data to printer */ extern NCURSES_EXPORT(int) has_key (int); /* do we have given key? */ #if NCURSES_SP_FUNCS extern NCURSES_EXPORT(int) NCURSES_SP_NAME(has_key) (SCREEN*, int); /* do we have given key? */ extern NCURSES_EXPORT(int) NCURSES_SP_NAME(mcprint) (SCREEN*, char *, int); /* direct data to printer */ #endif /* Debugging : use with libncurses_g.a */ extern NCURSES_EXPORT(void) _tracef (const char *, ...) GCC_PRINTFLIKE(1,2); extern NCURSES_EXPORT(char *) _traceattr (attr_t); extern NCURSES_EXPORT(char *) _traceattr2 (int, chtype); extern NCURSES_EXPORT(char *) _tracechar (int); extern NCURSES_EXPORT(char *) _tracechtype (chtype); extern NCURSES_EXPORT(char *) _tracechtype2 (int, chtype); #if NCURSES_WIDECHAR #define _tracech_t _tracecchar_t extern NCURSES_EXPORT(char *) _tracecchar_t (const cchar_t *); #define _tracech_t2 _tracecchar_t2 extern NCURSES_EXPORT(char *) _tracecchar_t2 (int, const cchar_t *); #else #define _tracech_t _tracechtype #define _tracech_t2 _tracechtype2 #endif extern NCURSES_EXPORT(void) trace (const unsigned) GCC_DEPRECATED("use curses_trace"); extern NCURSES_EXPORT(unsigned) curses_trace (const unsigned); /* trace masks */ #define TRACE_DISABLE 0x0000 /* turn off tracing */ #define TRACE_TIMES 0x0001 /* trace user and system times of updates */ #define TRACE_TPUTS 0x0002 /* trace tputs calls */ #define TRACE_UPDATE 0x0004 /* trace update actions, old & new screens */ #define TRACE_MOVE 0x0008 /* trace cursor moves and scrolls */ #define TRACE_CHARPUT 0x0010 /* trace all character outputs */ #define TRACE_ORDINARY 0x001F /* trace all update actions */ #define TRACE_CALLS 0x0020 /* trace all curses calls */ #define TRACE_VIRTPUT 0x0040 /* trace virtual character puts */ #define TRACE_IEVENT 0x0080 /* trace low-level input processing */ #define TRACE_BITS 0x0100 /* trace state of TTY control bits */ #define TRACE_ICALLS 0x0200 /* trace internal/nested calls */ #define TRACE_CCALLS 0x0400 /* trace per-character calls */ #define TRACE_DATABASE 0x0800 /* trace read/write of terminfo/termcap data */ #define TRACE_ATTRS 0x1000 /* trace attribute updates */ #define TRACE_SHIFT 13 /* number of bits in the trace masks */ #define TRACE_MAXIMUM ((1 << TRACE_SHIFT) - 1) /* maximum trace level */ #if defined(TRACE) || defined(NCURSES_TEST) extern NCURSES_EXPORT_VAR(int) _nc_optimize_enable; /* enable optimizations */ extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *); #define OPTIMIZE_MVCUR 0x01 /* cursor movement optimization */ #define OPTIMIZE_HASHMAP 0x02 /* diff hashing to detect scrolls */ #define OPTIMIZE_SCROLL 0x04 /* scroll optimization */ #define OPTIMIZE_ALL 0xff /* enable all optimizations (dflt) */ #endif extern GCC_NORETURN NCURSES_EXPORT(void) exit_curses (int); #include <unctrl.h> #ifdef __cplusplus #ifndef NCURSES_NOMACROS /* these names conflict with STL */ #undef box #undef clear #undef erase #undef move #undef refresh #endif /* NCURSES_NOMACROS */ } #endif #endif /* __NCURSES_H */ /**************************************************************************** * Copyright 2020 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1995,1997 * ****************************************************************************/ /* $Id: menu.h,v 1.26 2020/12/12 00:38:02 tom Exp $ */ #ifndef ETI_MENU #define ETI_MENU #ifdef AMIGA #define TEXT TEXT_ncurses #endif #include <curses.h> #include <eti.h> #ifdef __cplusplus extern "C" { #endif #if defined(BUILDING_MENU) # define MENU_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT #else # define MENU_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT #endif #define MENU_WRAPPED_VAR(type,name) extern MENU_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) #define MENU_EXPORT(type) MENU_IMPEXP type NCURSES_API #define MENU_EXPORT_VAR(type) MENU_IMPEXP type typedef int Menu_Options; typedef int Item_Options; /* Menu options: */ #define O_ONEVALUE (0x01) #define O_SHOWDESC (0x02) #define O_ROWMAJOR (0x04) #define O_IGNORECASE (0x08) #define O_SHOWMATCH (0x10) #define O_NONCYCLIC (0x20) #define O_MOUSE_MENU (0x40) /* Item options: */ #define O_SELECTABLE (0x01) #if !NCURSES_OPAQUE_MENU typedef struct { const char *str; unsigned short length; } TEXT; #endif /* !NCURSES_OPAQUE_MENU */ struct tagMENU; typedef struct tagITEM #if !NCURSES_OPAQUE_MENU { TEXT name; /* name of menu item */ TEXT description; /* description of item, optional in display */ struct tagMENU *imenu; /* Pointer to parent menu */ void *userptr; /* Pointer to user defined per item data */ Item_Options opt; /* Item options */ short index; /* Item number if connected to a menu */ short y; /* y and x location of item in menu */ short x; bool value; /* Selection value */ struct tagITEM *left; /* neighbor items */ struct tagITEM *right; struct tagITEM *up; struct tagITEM *down; } #endif /* !NCURSES_OPAQUE_MENU */ ITEM; typedef void (*Menu_Hook) (struct tagMENU *); typedef struct tagMENU #if 1 /* not yet: !NCURSES_OPAQUE_MENU */ { short height; /* Nr. of chars high */ short width; /* Nr. of chars wide */ short rows; /* Nr. of items high */ short cols; /* Nr. of items wide */ short frows; /* Nr. of formatted items high */ short fcols; /* Nr. of formatted items wide */ short arows; /* Nr. of items high (actual) */ short namelen; /* Max. name length */ short desclen; /* Max. description length */ short marklen; /* Length of mark, if any */ short itemlen; /* Length of one item */ short spc_desc; /* Spacing for descriptor */ short spc_cols; /* Spacing for columns */ short spc_rows; /* Spacing for rows */ char *pattern; /* Buffer to store match chars */ short pindex; /* Index into pattern buffer */ WINDOW *win; /* Window containing menu */ WINDOW *sub; /* Subwindow for menu display */ WINDOW *userwin; /* User's window */ WINDOW *usersub; /* User's subwindow */ ITEM **items; /* array of items */ short nitems; /* Nr. of items in menu */ ITEM *curitem; /* Current item */ short toprow; /* Top row of menu */ chtype fore; /* Selection attribute */ chtype back; /* Nonselection attribute */ chtype grey; /* Inactive attribute */ unsigned char pad; /* Pad character */ Menu_Hook menuinit; /* User hooks */ Menu_Hook menuterm; Menu_Hook iteminit; Menu_Hook itemterm; void *userptr; /* Pointer to menus user data */ char *mark; /* Pointer to marker string */ Menu_Options opt; /* Menu options */ unsigned short status; /* Internal state of menu */ } #endif /* !NCURSES_OPAQUE_MENU */ MENU; /* Define keys */ #define REQ_LEFT_ITEM (KEY_MAX + 1) #define REQ_RIGHT_ITEM (KEY_MAX + 2) #define REQ_UP_ITEM (KEY_MAX + 3) #define REQ_DOWN_ITEM (KEY_MAX + 4) #define REQ_SCR_ULINE (KEY_MAX + 5) #define REQ_SCR_DLINE (KEY_MAX + 6) #define REQ_SCR_DPAGE (KEY_MAX + 7) #define REQ_SCR_UPAGE (KEY_MAX + 8) #define REQ_FIRST_ITEM (KEY_MAX + 9) #define REQ_LAST_ITEM (KEY_MAX + 10) #define REQ_NEXT_ITEM (KEY_MAX + 11) #define REQ_PREV_ITEM (KEY_MAX + 12) #define REQ_TOGGLE_ITEM (KEY_MAX + 13) #define REQ_CLEAR_PATTERN (KEY_MAX + 14) #define REQ_BACK_PATTERN (KEY_MAX + 15) #define REQ_NEXT_MATCH (KEY_MAX + 16) #define REQ_PREV_MATCH (KEY_MAX + 17) #define MIN_MENU_COMMAND (KEY_MAX + 1) #define MAX_MENU_COMMAND (KEY_MAX + 17) /* * Some AT&T code expects MAX_COMMAND to be out-of-band not * just for menu commands but for forms ones as well. */ #if defined(MAX_COMMAND) # if (MAX_MENU_COMMAND > MAX_COMMAND) # error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND # elif (MAX_COMMAND != (KEY_MAX + 128)) # error Something is wrong -- MAX_COMMAND is already inconsistently defined. # endif #else # define MAX_COMMAND (KEY_MAX + 128) #endif /* --------- prototypes for libmenu functions ----------------------------- */ extern MENU_EXPORT(ITEM **) menu_items(const MENU *); extern MENU_EXPORT(ITEM *) current_item(const MENU *); extern MENU_EXPORT(ITEM *) new_item(const char *, const char *); extern MENU_EXPORT(MENU *) new_menu(ITEM **); extern MENU_EXPORT(Item_Options) item_opts(const ITEM *); extern MENU_EXPORT(Menu_Options) menu_opts(const MENU *); extern MENU_EXPORT(Menu_Hook) item_init(const MENU *); extern MENU_EXPORT(Menu_Hook) item_term(const MENU *); extern MENU_EXPORT(Menu_Hook) menu_init(const MENU *); extern MENU_EXPORT(Menu_Hook) menu_term(const MENU *); extern MENU_EXPORT(WINDOW *) menu_sub(const MENU *); extern MENU_EXPORT(WINDOW *) menu_win(const MENU *); extern MENU_EXPORT(const char *) item_description(const ITEM *); extern MENU_EXPORT(const char *) item_name(const ITEM *); extern MENU_EXPORT(const char *) menu_mark(const MENU *); extern MENU_EXPORT(const char *) menu_request_name(int); extern MENU_EXPORT(char *) menu_pattern(const MENU *); extern MENU_EXPORT(void *) menu_userptr(const MENU *); extern MENU_EXPORT(void *) item_userptr(const ITEM *); extern MENU_EXPORT(chtype) menu_back(const MENU *); extern MENU_EXPORT(chtype) menu_fore(const MENU *); extern MENU_EXPORT(chtype) menu_grey(const MENU *); extern MENU_EXPORT(int) free_item(ITEM *); extern MENU_EXPORT(int) free_menu(MENU *); extern MENU_EXPORT(int) item_count(const MENU *); extern MENU_EXPORT(int) item_index(const ITEM *); extern MENU_EXPORT(int) item_opts_off(ITEM *, Item_Options); extern MENU_EXPORT(int) item_opts_on(ITEM *, Item_Options); extern MENU_EXPORT(int) menu_driver(MENU *, int); extern MENU_EXPORT(int) menu_opts_off(MENU *, Menu_Options); extern MENU_EXPORT(int) menu_opts_on(MENU *, Menu_Options); extern MENU_EXPORT(int) menu_pad(const MENU *); extern MENU_EXPORT(int) pos_menu_cursor(const MENU *); extern MENU_EXPORT(int) post_menu(MENU *); extern MENU_EXPORT(int) scale_menu(const MENU *, int *, int *); extern MENU_EXPORT(int) set_current_item(MENU *menu, ITEM *item); extern MENU_EXPORT(int) set_item_init(MENU *, Menu_Hook); extern MENU_EXPORT(int) set_item_opts(ITEM *, Item_Options); extern MENU_EXPORT(int) set_item_term(MENU *, Menu_Hook); extern MENU_EXPORT(int) set_item_userptr(ITEM *, void *); extern MENU_EXPORT(int) set_item_value(ITEM *, bool); extern MENU_EXPORT(int) set_menu_back(MENU *, chtype); extern MENU_EXPORT(int) set_menu_fore(MENU *, chtype); extern MENU_EXPORT(int) set_menu_format(MENU *, int, int); extern MENU_EXPORT(int) set_menu_grey(MENU *, chtype); extern MENU_EXPORT(int) set_menu_init(MENU *, Menu_Hook); extern MENU_EXPORT(int) set_menu_items(MENU *, ITEM **); extern MENU_EXPORT(int) set_menu_mark(MENU *, const char *); extern MENU_EXPORT(int) set_menu_opts(MENU *, Menu_Options); extern MENU_EXPORT(int) set_menu_pad(MENU *, int); extern MENU_EXPORT(int) set_menu_pattern(MENU *, const char *); extern MENU_EXPORT(int) set_menu_sub(MENU *, WINDOW *); extern MENU_EXPORT(int) set_menu_term(MENU *, Menu_Hook); extern MENU_EXPORT(int) set_menu_userptr(MENU *, void *); extern MENU_EXPORT(int) set_menu_win(MENU *, WINDOW *); extern MENU_EXPORT(int) set_top_row(MENU *, int); extern MENU_EXPORT(int) top_row(const MENU *); extern MENU_EXPORT(int) unpost_menu(MENU *); extern MENU_EXPORT(int) menu_request_by_name(const char *); extern MENU_EXPORT(int) set_menu_spacing(MENU *, int, int, int); extern MENU_EXPORT(int) menu_spacing(const MENU *, int *, int *, int *); extern MENU_EXPORT(bool) item_value(const ITEM *); extern MENU_EXPORT(bool) item_visible(const ITEM *); extern MENU_EXPORT(void) menu_format(const MENU *, int *, int *); #if NCURSES_SP_FUNCS extern MENU_EXPORT(MENU *) NCURSES_SP_NAME(new_menu) (SCREEN *, ITEM **); #endif #ifdef __cplusplus } #endif #endif /* ETI_MENU */ // * This makes emacs happy -*-Mode: C++;-*- // vile:cppmode /**************************************************************************** * Copyright 2019-2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ #ifndef NCURSES_CURSESP_H_incl #define NCURSES_CURSESP_H_incl 1 // $Id: cursesp.h,v 1.35 2021/04/17 18:11:08 tom Exp $ #include <cursesw.h> extern "C" { # include <panel.h> } class NCURSES_CXX_IMPEXP NCursesPanel : public NCursesWindow { protected: PANEL *p; static NCursesPanel *dummy; private: // This structure is used for the panel's user data field to link the // PANEL* to the C++ object and to provide extra space for a user pointer. typedef struct { void* m_user; // the pointer for the user's data const NCursesPanel* m_back; // backward pointer to C++ object const PANEL* m_owner; // the panel itself } UserHook; inline UserHook *UserPointer() { UserHook* uptr = reinterpret_cast<UserHook*>( const_cast<void *>(::panel_userptr (p))); return uptr; } void init(); // Initialize the panel object protected: void set_user(void *user) { UserHook* uptr = UserPointer(); if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) { uptr->m_user = user; } } // Set the user pointer of the panel. void *get_user() { UserHook* uptr = UserPointer(); void *result = 0; if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) result = uptr->m_user; return result; } void OnError (int err) const THROW2(NCursesException const, NCursesPanelException) { if (err==ERR) THROW(new NCursesPanelException (this, err)); } // If err is equal to the curses error indicator ERR, an error handler // is called. // Get a keystroke. Default implementation calls getch() virtual int getKey(void); public: NCursesPanel(int nlines, int ncols, int begin_y = 0, int begin_x = 0) : NCursesWindow(nlines,ncols,begin_y,begin_x), p(0) { init(); } // Create a panel with this size starting at the requested position. NCursesPanel() : NCursesWindow(::stdscr), p(0) { init(); } // This constructor creates the default Panel associated with the // ::stdscr window NCursesPanel& operator=(const NCursesPanel& rhs) { if (this != &rhs) { *this = rhs; NCursesWindow::operator=(rhs); } return *this; } NCursesPanel(const NCursesPanel& rhs) : NCursesWindow(rhs), p(rhs.p) { } virtual ~NCursesPanel() THROWS(NCursesException); // basic manipulation inline void hide() { OnError (::hide_panel(p)); } // Hide the panel. It stays in the stack but becomes invisible. inline void show() { OnError (::show_panel(p)); } // Show the panel, i.e. make it visible. inline void top() { OnError (::top_panel(p)); } // Make this panel the top panel in the stack. inline void bottom() { OnError (::bottom_panel(p)); } // Make this panel the bottom panel in the stack. // N.B.: The panel associated with ::stdscr is always on the bottom. So // actually bottom() makes the panel the first above ::stdscr. virtual int mvwin(int y, int x) { OnError(::move_panel(p, y, x)); return OK; } inline bool hidden() const { return (::panel_hidden (p) ? TRUE : FALSE); } // Return TRUE if the panel is hidden, FALSE otherwise. /* The functions panel_above() and panel_below() are not reflected in the NCursesPanel class. The reason for this is, that we cannot assume that a panel retrieved by those operations is one wrapped by a C++ class. Although this situation might be handled, we also need a reverse mapping from PANEL to NCursesPanel which needs some redesign of the low level stuff. At the moment, we define them in the interface but they will always produce an error. */ inline NCursesPanel& above() const { OnError(ERR); return *dummy; } inline NCursesPanel& below() const { OnError(ERR); return *dummy; } // Those two are rewrites of the corresponding virtual members of // NCursesWindow virtual int refresh(); // Propagate all panel changes to the virtual screen and update the // physical screen. virtual int noutrefresh(); // Propagate all panel changes to the virtual screen. static void redraw(); // Redraw all panels. // decorations virtual void frame(const char* title=NULL, const char* btitle=NULL); // Put a frame around the panel and put the title centered in the top line // and btitle in the bottom line. virtual void boldframe(const char* title=NULL, const char* btitle=NULL); // Same as frame(), but use highlighted attributes. virtual void label(const char* topLabel, const char* bottomLabel); // Put the title centered in the top line and btitle in the bottom line. virtual void centertext(int row,const char* label); // Put the label text centered in the specified row. }; /* We use templates to provide a typesafe mechanism to associate * user data with a panel. A NCursesUserPanel<T> is a panel * associated with some user data of type T. */ template<class T> class NCursesUserPanel : public NCursesPanel { public: NCursesUserPanel (int nlines, int ncols, int begin_y = 0, int begin_x = 0, const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel (nlines, ncols, begin_y, begin_x) { if (p) set_user (const_cast<void *>(reinterpret_cast<const void*> (p_UserData))); }; // This creates an user panel of the requested size with associated // user data pointed to by p_UserData. explicit NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel() { if (p) set_user(const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); }; // This creates an user panel associated with the ::stdscr and user data // pointed to by p_UserData. virtual ~NCursesUserPanel() THROWS(NCursesException) {}; T* UserData (void) { return reinterpret_cast<T*>(get_user ()); }; // Retrieve the user data associated with the panel. virtual void setUserData (const T* p_UserData) { if (p) set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData))); } // Associate the user panel with the user data pointed to by p_UserData. }; #endif /* NCURSES_CURSESP_H_incl */ // * This makes emacs happy -*-Mode: C++;-*- /**************************************************************************** * Copyright 2019,2020 Thomas E. Dickey * * Copyright 1998-2005,2011 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ // $Id: cursesapp.h,v 1.17 2020/08/29 16:22:03 juergen Exp $ #ifndef NCURSES_CURSESAPP_H_incl #define NCURSES_CURSESAPP_H_incl #include <cursslk.h> #if (defined(_WIN32) || defined(_WIN64)) # define NCURSES_CXX_MAIN_NAME cursespp_main # define NCURSES_CXX_MAIN \ int main(int argc, char *argv[]) { \ return NCURSES_CXX_MAIN_NAME(argc, argv); \ } #else # define NCURSES_CXX_MAIN_NAME main #endif NCURSES_CXX_IMPEXP int NCURSES_CXX_MAIN_NAME(int argc, char *argv[]); class NCURSES_CXX_IMPEXP NCursesApplication { public: typedef struct _slk_link { // This structure is used to maintain struct _slk_link* prev; // a stack of SLKs Soft_Label_Key_Set* SLKs; } SLK_Link; private: static int rinit(NCursesWindow& w); // Internal Init function for title static NCursesApplication* theApp; // Global ref. to the application static SLK_Link* slk_stack; protected: static NCursesWindow* titleWindow; // The Title Window (if any) bool b_Colors; // Is this a color application? NCursesWindow* Root_Window; // This is the stdscr equiv. // Initialization of attributes; // Rewrite this in your derived class if you prefer other settings virtual void init(bool bColors); // The number of lines for the title window. Default is no title window // You may rewrite this in your derived class virtual int titlesize() const { return 0; } // This method is called to put something into the title window initially // You may rewrite this in your derived class virtual void title() { } // The layout used for the Soft Label Keys. Default is to have no SLKs. // You may rewrite this in your derived class virtual Soft_Label_Key_Set::Label_Layout useSLKs() const { return Soft_Label_Key_Set::None; } // This method is called to initialize the SLKs. Default is nothing. // You may rewrite this in your derived class virtual void init_labels(Soft_Label_Key_Set& S) const { (void) S; } // Your derived class must implement this method. The return value must // be the exit value of your application. virtual int run() = 0; // The constructor is protected, so you may use it in your derived // class constructor. The argument tells whether or not you want colors. NCursesApplication(bool wantColors = FALSE); NCursesApplication& operator=(const NCursesApplication& rhs) { if (this != &rhs) { *this = rhs; } return *this; } NCursesApplication(const NCursesApplication& rhs) : b_Colors(rhs.b_Colors), Root_Window(rhs.Root_Window) { } static NCursesWindow *&getTitleWindow(); public: virtual ~NCursesApplication() THROWS(NCursesException); // Get a pointer to the current application object static NCursesApplication* getApplication(); // This method runs the application and returns its exit value int operator()(void); // Process the commandline arguments. The default implementation simply // ignores them. Your derived class may rewrite this. virtual void handleArgs(int argc, char* argv[]) { (void) argc; (void) argv; } // Does this application use colors? inline bool useColors() const { return b_Colors; } // Push the Key Set S onto the SLK Stack. S then becomes the current set // of Soft Labelled Keys. void push(Soft_Label_Key_Set& S); // Throw away the current set of SLKs and make the previous one the // new current set. bool pop(); // Retrieve the current set of Soft Labelled Keys. Soft_Label_Key_Set* top() const; // Attributes to use for menu and forms foregrounds virtual chtype foregrounds() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(1)) : A_BOLD; } // Attributes to use for menu and forms backgrounds virtual chtype backgrounds() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(2)) : A_NORMAL; } // Attributes to use for inactive (menu) elements virtual chtype inactives() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(3)|A_DIM) : A_DIM; } // Attributes to use for (form) labels and SLKs virtual chtype labels() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(4)) : A_NORMAL; } // Attributes to use for form backgrounds virtual chtype dialog_backgrounds() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(4)) : A_NORMAL; } // Attributes to use as default for (form) window backgrounds virtual chtype window_backgrounds() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(5)) : A_NORMAL; } // Attributes to use for the title window virtual chtype screen_titles() const { return b_Colors ? static_cast<chtype>(COLOR_PAIR(6)) : A_BOLD; } }; #endif /* NCURSES_CURSESAPP_H_incl */ // * This makes emacs happy -*-Mode: C++;-*- // vile:cppmode /**************************************************************************** * Copyright 2019-2020,2021 Thomas E. Dickey * * Copyright 1998-2014,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ #ifndef NCURSES_CURSESW_H_incl #define NCURSES_CURSESW_H_incl 1 // $Id: cursesw.h,v 1.58 2021/04/17 18:11:08 tom Exp $ extern "C" { # include <curses.h> } #if defined(BUILDING_NCURSES_CXX) # define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT #else # define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT #endif #define NCURSES_CXX_WRAPPED_VAR(type,name) extern NCURSES_CXX_IMPEXP type NCURSES_PUBLIC_VAR(name)(void) #define NCURSES_CXX_EXPORT(type) NCURSES_CXX_IMPEXP type NCURSES_API #define NCURSES_CXX_EXPORT_VAR(type) NCURSES_CXX_IMPEXP type #include <etip.h> /* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro. Undefine it here, because NCursesWindow uses lines as a method. */ #undef lines /* "Convert" macros to inlines. We'll define it as another symbol to avoid * conflict with library symbols. */ #undef UNDEF #define UNDEF(name) CUR_ ##name #ifdef addch inline int UNDEF(addch)(chtype ch) { return addch(ch); } #undef addch #define addch UNDEF(addch) #endif #ifdef addchstr inline int UNDEF(addchstr)(chtype *at) { return addchstr(at); } #undef addchstr #define addchstr UNDEF(addchstr) #endif #ifdef addnstr inline int UNDEF(addnstr)(const char *str, int n) { return addnstr(str, n); } #undef addnstr #define addnstr UNDEF(addnstr) #endif #ifdef addstr inline int UNDEF(addstr)(const char * str) { return addstr(str); } #undef addstr #define addstr UNDEF(addstr) #endif #ifdef attroff inline int UNDEF(attroff)(chtype at) { return attroff(at); } #undef attroff #define attroff UNDEF(attroff) #endif #ifdef attron inline int UNDEF(attron)(chtype at) { return attron(at); } #undef attron #define attron UNDEF(attron) #endif #ifdef attrset inline chtype UNDEF(attrset)(chtype at) { return attrset(at); } #undef attrset #define attrset UNDEF(attrset) #endif #ifdef bkgd inline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); } #undef bkgd #define bkgd UNDEF(bkgd) #endif #ifdef bkgdset inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); } #undef bkgdset #define bkgdset UNDEF(bkgdset) #endif #ifdef border inline int UNDEF(border)(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br) { return border(ls, rs, ts, bs, tl, tr, bl, br); } #undef border #define border UNDEF(border) #endif #ifdef box inline int UNDEF(box)(WINDOW *win, int v, int h) { return box(win, v, h); } #undef box #define box UNDEF(box) #endif #ifdef chgat inline int UNDEF(chgat)(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) { return chgat(n, attr, color, opts); } #undef chgat #define chgat UNDEF(chgat) #endif #ifdef clear inline int UNDEF(clear)() { return clear(); } #undef clear #define clear UNDEF(clear) #endif #ifdef clearok inline int UNDEF(clearok)(WINDOW* win, bool bf) { return clearok(win, bf); } #undef clearok #define clearok UNDEF(clearok) #else extern "C" NCURSES_IMPEXP int NCURSES_API clearok(WINDOW*, bool); #endif #ifdef clrtobot inline int UNDEF(clrtobot)() { return clrtobot(); } #undef clrtobot #define clrtobot UNDEF(clrtobot) #endif #ifdef clrtoeol inline int UNDEF(clrtoeol)() { return clrtoeol(); } #undef clrtoeol #define clrtoeol UNDEF(clrtoeol) #endif #ifdef color_set inline chtype UNDEF(color_set)(NCURSES_PAIRS_T p, void* opts) { return color_set(p, opts); } #undef color_set #define color_set UNDEF(color_set) #endif #ifdef crmode inline int UNDEF(crmode)(void) { return crmode(); } #undef crmode #define crmode UNDEF(crmode) #endif #ifdef delch inline int UNDEF(delch)() { return delch(); } #undef delch #define delch UNDEF(delch) #endif #ifdef deleteln inline int UNDEF(deleteln)() { return deleteln(); } #undef deleteln #define deleteln UNDEF(deleteln) #endif #ifdef echochar inline int UNDEF(echochar)(chtype ch) { return echochar(ch); } #undef echochar #define echochar UNDEF(echochar) #endif #ifdef erase inline int UNDEF(erase)() { return erase(); } #undef erase #define erase UNDEF(erase) #endif #ifdef fixterm inline int UNDEF(fixterm)(void) { return fixterm(); } #undef fixterm #define fixterm UNDEF(fixterm) #endif #ifdef flushok inline int UNDEF(flushok)(WINDOW* _win, bool _bf) { return flushok(_win, _bf); } #undef flushok #define flushok UNDEF(flushok) #else #define _no_flushok #endif #ifdef getattrs inline int UNDEF(getattrs)(WINDOW *win) { return getattrs(win); } #undef getattrs #define getattrs UNDEF(getattrs) #endif #ifdef getbegyx inline void UNDEF(getbegyx)(WINDOW* win, int& y, int& x) { getbegyx(win, y, x); } #undef getbegyx #define getbegyx UNDEF(getbegyx) #endif #ifdef getbkgd inline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); } #undef getbkgd #define getbkgd UNDEF(getbkgd) #endif #ifdef getch inline int UNDEF(getch)() { return getch(); } #undef getch #define getch UNDEF(getch) #endif #ifdef getmaxyx inline void UNDEF(getmaxyx)(WINDOW* win, int& y, int& x) { getmaxyx(win, y, x); } #undef getmaxyx #define getmaxyx UNDEF(getmaxyx) #endif #ifdef getnstr inline int UNDEF(getnstr)(char *_str, int n) { return getnstr(_str, n); } #undef getnstr #define getnstr UNDEF(getnstr) #endif #ifdef getparyx inline void UNDEF(getparyx)(WINDOW* win, int& y, int& x) { getparyx(win, y, x); } #undef getparyx #define getparyx UNDEF(getparyx) #endif #ifdef getstr inline int UNDEF(getstr)(char *_str) { return getstr(_str); } #undef getstr #define getstr UNDEF(getstr) #endif #ifdef getyx inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) { getyx(win, y, x); } #undef getyx #define getyx UNDEF(getyx) #endif #ifdef hline inline int UNDEF(hline)(chtype ch, int n) { return hline(ch, n); } #undef hline #define hline UNDEF(hline) #endif #ifdef inch inline chtype UNDEF(inch)() { return inch(); } #undef inch #define inch UNDEF(inch) #endif #ifdef inchstr inline int UNDEF(inchstr)(chtype *str) { return inchstr(str); } #undef inchstr #define inchstr UNDEF(inchstr) #endif #ifdef innstr inline int UNDEF(innstr)(char *_str, int n) { return innstr(_str, n); } #undef innstr #define innstr UNDEF(innstr) #endif #ifdef insch inline int UNDEF(insch)(chtype c) { return insch(c); } #undef insch #define insch UNDEF(insch) #endif #ifdef insdelln inline int UNDEF(insdelln)(int n) { return insdelln(n); } #undef insdelln #define insdelln UNDEF(insdelln) #endif #ifdef insertln inline int UNDEF(insertln)() { return insertln(); } #undef insertln #define insertln UNDEF(insertln) #endif #ifdef insnstr inline int UNDEF(insnstr)(const char *_str, int n) { return insnstr(_str, n); } #undef insnstr #define insnstr UNDEF(insnstr) #endif #ifdef insstr inline int UNDEF(insstr)(const char *_str) { return insstr(_str); } #undef insstr #define insstr UNDEF(insstr) #endif #ifdef instr inline int UNDEF(instr)(char *_str) { return instr(_str); } #undef instr #define instr UNDEF(instr) #endif #ifdef intrflush inline void UNDEF(intrflush)(WINDOW *win, bool bf) { intrflush(); } #undef intrflush #define intrflush UNDEF(intrflush) #endif #ifdef is_linetouched inline int UNDEF(is_linetouched)(WINDOW *w, int l) { return is_linetouched(w,l); } #undef is_linetouched #define is_linetouched UNDEF(is_linetouched) #endif #ifdef leaveok inline int UNDEF(leaveok)(WINDOW* win, bool bf) { return leaveok(win, bf); } #undef leaveok #define leaveok UNDEF(leaveok) #else extern "C" NCURSES_IMPEXP int NCURSES_API leaveok(WINDOW* win, bool bf); #endif #ifdef move inline int UNDEF(move)(int x, int y) { return move(x, y); } #undef move #define move UNDEF(move) #endif #ifdef mvaddch inline int UNDEF(mvaddch)(int y, int x, chtype ch) { return mvaddch(y, x, ch); } #undef mvaddch #define mvaddch UNDEF(mvaddch) #endif #ifdef mvaddnstr inline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n) { return mvaddnstr(y, x, str, n); } #undef mvaddnstr #define mvaddnstr UNDEF(mvaddnstr) #endif #ifdef mvaddstr inline int UNDEF(mvaddstr)(int y, int x, const char * str) { return mvaddstr(y, x, str); } #undef mvaddstr #define mvaddstr UNDEF(mvaddstr) #endif #ifdef mvchgat inline int UNDEF(mvchgat)(int y, int x, int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) { return mvchgat(y, x, n, attr, color, opts); } #undef mvchgat #define mvchgat UNDEF(mvchgat) #endif #ifdef mvdelch inline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);} #undef mvdelch #define mvdelch UNDEF(mvdelch) #endif #ifdef mvgetch inline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);} #undef mvgetch #define mvgetch UNDEF(mvgetch) #endif #ifdef mvgetnstr inline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) { return mvgetnstr(y, x, str, n);} #undef mvgetnstr #define mvgetnstr UNDEF(mvgetnstr) #endif #ifdef mvgetstr inline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);} #undef mvgetstr #define mvgetstr UNDEF(mvgetstr) #endif #ifdef mvinch inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);} #undef mvinch #define mvinch UNDEF(mvinch) #endif #ifdef mvinnstr inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) { return mvinnstr(y, x, _str, n); } #undef mvinnstr #define mvinnstr UNDEF(mvinnstr) #endif #ifdef mvinsch inline int UNDEF(mvinsch)(int y, int x, chtype c) { return mvinsch(y, x, c); } #undef mvinsch #define mvinsch UNDEF(mvinsch) #endif #ifdef mvinsnstr inline int UNDEF(mvinsnstr)(int y, int x, const char *_str, int n) { return mvinsnstr(y, x, _str, n); } #undef mvinsnstr #define mvinsnstr UNDEF(mvinsnstr) #endif #ifdef mvinsstr inline int UNDEF(mvinsstr)(int y, int x, const char *_str) { return mvinsstr(y, x, _str); } #undef mvinsstr #define mvinsstr UNDEF(mvinsstr) #endif #ifdef mvwaddch inline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch) { return mvwaddch(win, y, x, ch); } #undef mvwaddch #define mvwaddch UNDEF(mvwaddch) #endif #ifdef mvwaddchnstr inline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, const chtype *str, int n) { return mvwaddchnstr(win, y, x, str, n); } #undef mvwaddchnstr #define mvwaddchnstr UNDEF(mvwaddchnstr) #endif #ifdef mvwaddchstr inline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, const chtype *str) { return mvwaddchstr(win, y, x, str); } #undef mvwaddchstr #define mvwaddchstr UNDEF(mvwaddchstr) #endif #ifdef mvwaddnstr inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n) { return mvwaddnstr(win, y, x, str, n); } #undef mvwaddnstr #define mvwaddnstr UNDEF(mvwaddnstr) #endif #ifdef mvwaddstr inline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str) { return mvwaddstr(win, y, x, str); } #undef mvwaddstr #define mvwaddstr UNDEF(mvwaddstr) #endif #ifdef mvwchgat inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) { return mvwchgat(win, y, x, n, attr, color, opts); } #undef mvwchgat #define mvwchgat UNDEF(mvwchgat) #endif #ifdef mvwdelch inline int UNDEF(mvwdelch)(WINDOW *win, int y, int x) { return mvwdelch(win, y, x); } #undef mvwdelch #define mvwdelch UNDEF(mvwdelch) #endif #ifdef mvwgetch inline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);} #undef mvwgetch #define mvwgetch UNDEF(mvwgetch) #endif #ifdef mvwgetnstr inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n) {return mvwgetnstr(win, y, x, str, n);} #undef mvwgetnstr #define mvwgetnstr UNDEF(mvwgetnstr) #endif #ifdef mvwgetstr inline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str) {return mvwgetstr(win, y, x, str);} #undef mvwgetstr #define mvwgetstr UNDEF(mvwgetstr) #endif #ifdef mvwhline inline int UNDEF(mvwhline)(WINDOW *win, int y, int x, chtype c, int n) { return mvwhline(win, y, x, c, n); } #undef mvwhline #define mvwhline UNDEF(mvwhline) #endif #ifdef mvwinch inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) { return mvwinch(win, y, x);} #undef mvwinch #define mvwinch UNDEF(mvwinch) #endif #ifdef mvwinchnstr inline int UNDEF(mvwinchnstr)(WINDOW *win, int y, int x, chtype *str, int n) { return mvwinchnstr(win, y, x, str, n); } #undef mvwinchnstr #define mvwinchnstr UNDEF(mvwinchnstr) #endif #ifdef mvwinchstr inline int UNDEF(mvwinchstr)(WINDOW *win, int y, int x, chtype *str) { return mvwinchstr(win, y, x, str); } #undef mvwinchstr #define mvwinchstr UNDEF(mvwinchstr) #endif #ifdef mvwinnstr inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) { return mvwinnstr(win, y, x, _str, n); } #undef mvwinnstr #define mvwinnstr UNDEF(mvwinnstr) #endif #ifdef mvwinsch inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c) { return mvwinsch(win, y, x, c); } #undef mvwinsch #define mvwinsch UNDEF(mvwinsch) #endif #ifdef mvwinsnstr inline int UNDEF(mvwinsnstr)(WINDOW *w, int y, int x, const char *_str, int n) { return mvwinsnstr(w, y, x, _str, n); } #undef mvwinsnstr #define mvwinsnstr UNDEF(mvwinsnstr) #endif #ifdef mvwinsstr inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x, const char *_str) { return mvwinsstr(w, y, x, _str); } #undef mvwinsstr #define mvwinsstr UNDEF(mvwinsstr) #endif #ifdef mvwvline inline int UNDEF(mvwvline)(WINDOW *win, int y, int x, chtype c, int n) { return mvwvline(win, y, x, c, n); } #undef mvwvline #define mvwvline UNDEF(mvwvline) #endif #ifdef napms inline void UNDEF(napms)(unsigned long x) { napms(x); } #undef napms #define napms UNDEF(napms) #endif #ifdef nocrmode inline int UNDEF(nocrmode)(void) { return nocrmode(); } #undef nocrmode #define nocrmode UNDEF(nocrmode) #endif #ifdef nodelay inline void UNDEF(nodelay)() { nodelay(); } #undef nodelay #define nodelay UNDEF(nodelay) #endif #ifdef redrawwin inline int UNDEF(redrawwin)(WINDOW *win) { return redrawwin(win); } #undef redrawwin #define redrawwin UNDEF(redrawwin) #endif #ifdef refresh inline int UNDEF(refresh)() { return refresh(); } #undef refresh #define refresh UNDEF(refresh) #endif #ifdef resetterm inline int UNDEF(resetterm)(void) { return resetterm(); } #undef resetterm #define resetterm UNDEF(resetterm) #endif #ifdef saveterm inline int UNDEF(saveterm)(void) { return saveterm(); } #undef saveterm #define saveterm UNDEF(saveterm) #endif #ifdef scrl inline int UNDEF(scrl)(int l) { return scrl(l); } #undef scrl #define scrl UNDEF(scrl) #endif #ifdef scroll inline int UNDEF(scroll)(WINDOW *win) { return scroll(win); } #undef scroll #define scroll UNDEF(scroll) #endif #ifdef scrollok inline int UNDEF(scrollok)(WINDOW* win, bool bf) { return scrollok(win, bf); } #undef scrollok #define scrollok UNDEF(scrollok) #else #if defined(__NCURSES_H) extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, bool); #else extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, char); #endif #endif #ifdef setscrreg inline int UNDEF(setscrreg)(int t, int b) { return setscrreg(t, b); } #undef setscrreg #define setscrreg UNDEF(setscrreg) #endif #ifdef standend inline int UNDEF(standend)() { return standend(); } #undef standend #define standend UNDEF(standend) #endif #ifdef standout inline int UNDEF(standout)() { return standout(); } #undef standout #define standout UNDEF(standout) #endif #ifdef subpad inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x) { return derwin(p, l, c, y, x); } #undef subpad #define subpad UNDEF(subpad) #endif #ifdef timeout inline void UNDEF(timeout)(int delay) { timeout(delay); } #undef timeout #define timeout UNDEF(timeout) #endif #ifdef touchline inline int UNDEF(touchline)(WINDOW *win, int s, int c) { return touchline(win, s, c); } #undef touchline #define touchline UNDEF(touchline) #endif #ifdef touchwin inline int UNDEF(touchwin)(WINDOW *win) { return touchwin(win); } #undef touchwin #define touchwin UNDEF(touchwin) #endif #ifdef untouchwin inline int UNDEF(untouchwin)(WINDOW *win) { return untouchwin(win); } #undef untouchwin #define untouchwin UNDEF(untouchwin) #endif #ifdef vline inline int UNDEF(vline)(chtype ch, int n) { return vline(ch, n); } #undef vline #define vline UNDEF(vline) #endif #ifdef waddchstr inline int UNDEF(waddchstr)(WINDOW *win, chtype *at) { return waddchstr(win, at); } #undef waddchstr #define waddchstr UNDEF(waddchstr) #endif #ifdef waddstr inline int UNDEF(waddstr)(WINDOW *win, char *str) { return waddstr(win, str); } #undef waddstr #define waddstr UNDEF(waddstr) #endif #ifdef wattroff inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); } #undef wattroff #define wattroff UNDEF(wattroff) #endif #ifdef wattrset inline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); } #undef wattrset #define wattrset UNDEF(wattrset) #endif #ifdef winch inline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); } #undef winch #define winch UNDEF(winch) #endif #ifdef winchnstr inline int UNDEF(winchnstr)(WINDOW *win, chtype *str, int n) { return winchnstr(win, str, n); } #undef winchnstr #define winchnstr UNDEF(winchnstr) #endif #ifdef winchstr inline int UNDEF(winchstr)(WINDOW *win, chtype *str) { return winchstr(win, str); } #undef winchstr #define winchstr UNDEF(winchstr) #endif #ifdef winsstr inline int UNDEF(winsstr)(WINDOW *w, const char *_str) { return winsstr(w, _str); } #undef winsstr #define winsstr UNDEF(winsstr) #endif #ifdef wstandend inline int UNDEF(wstandend)(WINDOW *win) { return wstandend(win); } #undef wstandend #define wstandend UNDEF(wstandend) #endif #ifdef wstandout inline int UNDEF(wstandout)(WINDOW *win) { return wstandout(win); } #undef wstandout #define wstandout UNDEF(wstandout) #endif /* * * C++ class for windows. * */ extern "C" int _nc_ripoffline(int, int (*init)(WINDOW*, int)); extern "C" int _nc_xx_ripoff_init(WINDOW *, int); extern "C" int _nc_has_mouse(void); class NCURSES_CXX_IMPEXP NCursesWindow { friend class NCursesMenu; friend class NCursesForm; private: static bool b_initialized; static void initialize(); void constructing(); friend int _nc_xx_ripoff_init(WINDOW *, int); void set_keyboard(); NCURSES_COLOR_T getcolor(int getback) const; NCURSES_PAIRS_T getPair() const; static int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back, NCURSES_PAIRS_T pair); static int colorInitialized; // This private constructor is only used during the initialization // of windows generated by ripoffline() calls. NCursesWindow(WINDOW* win, int ncols); protected: virtual void err_handler(const char *) const THROWS(NCursesException); // Signal an error with the given message text. static long count; // count of all active windows: // We rely on the c++ promise that // all otherwise uninitialized // static class vars are set to 0 WINDOW* w; // the curses WINDOW bool alloced; // TRUE if we own the WINDOW NCursesWindow* par; // parent, if subwindow NCursesWindow* subwins; // head of subwindows list NCursesWindow* sib; // next subwindow of parent void kill_subwindows(); // disable all subwindows // Destroy all subwindows. /* Only for use by derived classes. They are then in charge to fill the member variables correctly. */ NCursesWindow(); public: explicit NCursesWindow(WINDOW* window); // useful only for stdscr NCursesWindow(int nlines, // number of lines int ncols, // number of columns int begin_y, // line origin int begin_x); // col origin NCursesWindow(NCursesWindow& par,// parent window int nlines, // number of lines int ncols, // number of columns int begin_y, // absolute or relative int begin_x, // origins: char absrel = 'a');// if `a', begin_y & begin_x are // absolute screen pos, else if `r', they are relative to par origin NCursesWindow(NCursesWindow& par,// parent window bool do_box = TRUE); // this is the very common case that we want to create the subwindow that // is two lines and two columns smaller and begins at (1,1). // We may automatically request the box around it. NCursesWindow& operator=(const NCursesWindow& rhs) { if (this != &rhs) *this = rhs; return *this; } NCursesWindow(const NCursesWindow& rhs) : w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib) { } virtual ~NCursesWindow() THROWS(NCursesException); NCursesWindow Clone(); // Make an exact copy of the window. // Initialization. static void useColors(void); // Call this routine very early if you want to have colors. static int ripoffline(int ripoff_lines, int (*init)(NCursesWindow& win)); // This function is used to generate a window of ripped-of lines. // If the argument is positive, lines are removed from the top, if it // is negative lines are removed from the bottom. This enhances the // lowlevel ripoffline() function because it uses the internal // implementation that allows to remove more than just a single line. // This function must be called before any other ncurses function. The // creation of the window is deferred until ncurses gets initialized. // The initialization function is then called. // ------------------------------------------------------------------------- // terminal status // ------------------------------------------------------------------------- int lines() const { initialize(); return LINES; } // Number of lines on terminal, *not* window int cols() const { initialize(); return COLS; } // Number of cols on terminal, *not* window int tabsize() const { initialize(); return TABSIZE; } // Size of a tab on terminal, *not* window static int NumberOfColors(); // Number of available colors int colors() const { return NumberOfColors(); } // Number of available colors // ------------------------------------------------------------------------- // window status // ------------------------------------------------------------------------- int height() const { return maxy() + 1; } // Number of lines in this window int width() const { return maxx() + 1; } // Number of columns in this window int begx() const { return getbegx(w); } // Column of top left corner relative to stdscr int begy() const { return getbegy(w); } // Line of top left corner relative to stdscr int curx() const { return getcurx(w); } // Column of top left corner relative to stdscr int cury() const { return getcury(w); } // Line of top left corner relative to stdscr int maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; } // Largest x coord in window int maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; } // Largest y coord in window NCURSES_PAIRS_T getcolor() const; // Actual color pair NCURSES_COLOR_T foreground() const { return getcolor(0); } // Actual foreground color NCURSES_COLOR_T background() const { return getcolor(1); } // Actual background color int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back); // Set color palette entry int setcolor(NCURSES_PAIRS_T pair); // Set actually used palette entry // ------------------------------------------------------------------------- // window positioning // ------------------------------------------------------------------------- virtual int mvwin(int begin_y, int begin_x) { return ::mvwin(w, begin_y, begin_x); } // Move window to new position with the new position as top left corner. // This is virtual because it is redefined in NCursesPanel. // ------------------------------------------------------------------------- // coordinate positioning // ------------------------------------------------------------------------- int move(int y, int x) { return ::wmove(w, y, x); } // Move cursor the this position void getyx(int& y, int& x) const { ::getyx(w, y, x); } // Get current position of the cursor void getbegyx(int& y, int& x) const { ::getbegyx(w, y, x); } // Get beginning of the window void getmaxyx(int& y, int& x) const { ::getmaxyx(w, y, x); } // Get size of the window void getparyx(int& y, int& x) const { ::getparyx(w, y, x); } // Get parent's beginning of the window int mvcur(int oldrow, int oldcol, int newrow, int newcol) const { return ::mvcur(oldrow, oldcol, newrow, newcol); } // Perform lowlevel cursor motion that takes effect immediately. // ------------------------------------------------------------------------- // input // ------------------------------------------------------------------------- int getch() { return ::wgetch(w); } // Get a keystroke from the window. int getch(int y, int x) { return ::mvwgetch(w, y, x); } // Move cursor to position and get a keystroke from the window int getstr(char* str, int n=-1) { return ::wgetnstr(w, str, n); } // Read a series of characters into str until a newline or carriage return // is received. Read at most n characters. If n is negative, the limit is // ignored. int getstr(int y, int x, char* str, int n=-1) { return ::mvwgetnstr(w, y, x, str, n); } // Move the cursor to the requested position and then perform the getstr() // as described above. int instr(char *s, int n=-1) { return ::winnstr(w, s, n); } // Get a string of characters from the window into the buffer s. Retrieve // at most n characters, if n is negative retrieve all characters up to the // end of the current line. Attributes are stripped from the characters. int instr(int y, int x, char *s, int n=-1) { return ::mvwinnstr(w, y, x, s, n); } // Move the cursor to the requested position and then perform the instr() // as described above. int scanw(const char* fmt, ...) // Perform a scanw function from the window. #if __GNUG__ >= 2 __attribute__ ((format (scanf, 2, 3))); #else ; #endif int scanw(const char*, va_list); // Perform a scanw function from the window. int scanw(int y, int x, const char* fmt, ...) // Move the cursor to the requested position and then perform a scanw // from the window. #if __GNUG__ >= 2 __attribute__ ((format (scanf, 4, 5))); #else ; #endif int scanw(int y, int x, const char* fmt, va_list); // Move the cursor to the requested position and then perform a scanw // from the window. // ------------------------------------------------------------------------- // output // ------------------------------------------------------------------------- int addch(const chtype ch) { return ::waddch(w, ch); } // Put attributed character to the window. int addch(int y, int x, const chtype ch) { return ::mvwaddch(w, y, x, ch); } // Move cursor to the requested position and then put attributed character // to the window. int echochar(const chtype ch) { return ::wechochar(w, ch); } // Put attributed character to the window and refresh it immediately. int addstr(const char* str, int n=-1) { return ::waddnstr(w, str, n); } // Write the string str to the window, stop writing if the terminating // NUL or the limit n is reached. If n is negative, it is ignored. int addstr(int y, int x, const char * str, int n=-1) { return ::mvwaddnstr(w, y, x, str, n); } // Move the cursor to the requested position and then perform the addchstr // as described above. int addchstr(const chtype* str, int n=-1) { return ::waddchnstr(w, str, n); } // Write the string str to the window, stop writing if the terminating // NUL or the limit n is reached. If n is negative, it is ignored. int addchstr(int y, int x, const chtype * str, int n=-1) { return ::mvwaddchnstr(w, y, x, str, n); } // Move the cursor to the requested position and then perform the addchstr // as described above. int printw(const char* fmt, ...) // Do a formatted print to the window. #if (__GNUG__ >= 2) && !defined(printf) __attribute__ ((format (printf, 2, 3))); #else ; #endif int printw(int y, int x, const char * fmt, ...) // Move the cursor and then do a formatted print to the window. #if (__GNUG__ >= 2) && !defined(printf) __attribute__ ((format (printf, 4, 5))); #else ; #endif int printw(const char* fmt, va_list args); // Do a formatted print to the window. int printw(int y, int x, const char * fmt, va_list args); // Move the cursor and then do a formatted print to the window. chtype inch() const { return ::winch(w); } // Retrieve attributed character under the current cursor position. chtype inch(int y, int x) { return ::mvwinch(w, y, x); } // Move cursor to requested position and then retrieve attributed character // at this position. int inchstr(chtype* str, int n=-1) { return ::winchnstr(w, str, n); } // Read the string str from the window, stop reading if the terminating // NUL or the limit n is reached. If n is negative, it is ignored. int inchstr(int y, int x, chtype * str, int n=-1) { return ::mvwinchnstr(w, y, x, str, n); } // Move the cursor to the requested position and then perform the inchstr // as described above. int insch(chtype ch) { return ::winsch(w, ch); } // Insert attributed character into the window before current cursor // position. int insch(int y, int x, chtype ch) { return ::mvwinsch(w, y, x, ch); } // Move cursor to requested position and then insert the attributed // character before that position. int insertln() { return ::winsdelln(w, 1); } // Insert an empty line above the current line. int insdelln(int n=1) { return ::winsdelln(w, n); } // If n>0 insert that many lines above the current line. If n<0 delete // that many lines beginning with the current line. int insstr(const char *s, int n=-1) { return ::winsnstr(w, s, n); } // Insert the string into the window before the current cursor position. // Insert stops at end of string or when the limit n is reached. If n is // negative, it is ignored. int insstr(int y, int x, const char *s, int n=-1) { return ::mvwinsnstr(w, y, x, s, n); } // Move the cursor to the requested position and then perform the insstr() // as described above. int attron (chtype at) { return ::wattron (w, at); } // Switch on the window attributes; int attroff(chtype at) { return ::wattroff(w, static_cast<int>(at)); } // Switch off the window attributes; int attrset(chtype at) { return ::wattrset(w, static_cast<int>(at)); } // Set the window attributes; chtype attrget() { return ::getattrs(w); } // Get the window attributes; int color_set(NCURSES_PAIRS_T color_pair_number, void* opts=NULL) { return ::wcolor_set(w, color_pair_number, opts); } // Set the window color attribute; int chgat(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) { return ::wchgat(w, n, attr, color, opts); } // Change the attributes of the next n characters in the current line. If // n is negative or greater than the number of remaining characters in the // line, the attributes will be changed up to the end of the line. int chgat(int y, int x, int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) { return ::mvwchgat(w, y, x, n, attr, color, opts); } // Move the cursor to the requested position and then perform chgat() as // described above. // ------------------------------------------------------------------------- // background // ------------------------------------------------------------------------- chtype getbkgd() const { return ::getbkgd(w); } // Get current background setting. int bkgd(const chtype ch) { return ::wbkgd(w, ch); } // Set the background property and apply it to the window. void bkgdset(chtype ch) { ::wbkgdset(w, ch); } // Set the background property. // ------------------------------------------------------------------------- // borders // ------------------------------------------------------------------------- int box(chtype vert=0, chtype hor=0) { return ::wborder(w, vert, vert, hor, hor, 0, 0, 0, 0); } // Draw a box around the window with the given vertical and horizontal // drawing characters. If you specify a zero as character, curses will try // to find a "nice" character. int border(chtype left=0, chtype right=0, chtype top =0, chtype bottom=0, chtype top_left =0, chtype top_right=0, chtype bottom_left =0, chtype bottom_right=0) { return ::wborder(w, left, right, top, bottom, top_left, top_right, bottom_left, bottom_right); } // Draw a border around the window with the given characters for the // various parts of the border. If you pass zero for a character, curses // will try to find "nice" characters. // ------------------------------------------------------------------------- // lines and boxes // ------------------------------------------------------------------------- int hline(int len, chtype ch=0) { return ::whline(w, ch, len); } // Draw a horizontal line of len characters with the given character. If // you pass zero for the character, curses will try to find a "nice" one. int hline(int y, int x, int len, chtype ch=0) { return ::mvwhline(w, y, x, ch, len); } // Move the cursor to the requested position and then draw a horizontal line. int vline(int len, chtype ch=0) { return ::wvline(w, ch, len); } // Draw a vertical line of len characters with the given character. If // you pass zero for the character, curses will try to find a "nice" one. int vline(int y, int x, int len, chtype ch=0) { return ::mvwvline(w, y, x, ch, len); } // Move the cursor to the requested position and then draw a vertical line. // ------------------------------------------------------------------------- // erasure // ------------------------------------------------------------------------- int erase() { return ::werase(w); } // Erase the window. int clear() { return ::wclear(w); } // Clear the window. int clearok(bool bf) { return ::clearok(w, bf); } // Set/Reset the clear flag. If set, the next refresh() will clear the // screen. int clrtobot() { return ::wclrtobot(w); } // Clear to the end of the window. int clrtoeol() { return ::wclrtoeol(w); } // Clear to the end of the line. int delch() { return ::wdelch(w); } // Delete character under the cursor. int delch(int y, int x) { return ::mvwdelch(w, y, x); } // Move cursor to requested position and delete the character under the // cursor. int deleteln() { return ::winsdelln(w, -1); } // Delete the current line. // ------------------------------------------------------------------------- // screen control // ------------------------------------------------------------------------- int scroll(int amount=1) { return ::wscrl(w, amount); } // Scroll amount lines. If amount is positive, scroll up, otherwise // scroll down. int scrollok(bool bf) { return ::scrollok(w, bf); } // If bf is TRUE, window scrolls if cursor is moved off the bottom // edge of the window or a scrolling region, otherwise the cursor is left // at the bottom line. int setscrreg(int from, int to) { return ::wsetscrreg(w, from, to); } // Define a soft scrolling region. int idlok(bool bf) { return ::idlok(w, bf); } // If bf is TRUE, use insert/delete line hardware support if possible. // Otherwise do it in software. void idcok(bool bf) { ::idcok(w, bf); } // If bf is TRUE, use insert/delete character hardware support if possible. // Otherwise do it in software. int touchline(int s, int c) { return ::touchline(w, s, c); } // Mark the given lines as modified. int touchwin() { return ::wtouchln(w, 0, height(), 1); } // Mark the whole window as modified. int untouchwin() { return ::wtouchln(w, 0, height(), 0); } // Mark the whole window as unmodified. int touchln(int s, int cnt, bool changed=TRUE) { return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); } // Mark cnt lines beginning from line s as changed or unchanged, depending // on the value of the changed flag. bool is_linetouched(int line) const { return (::is_linetouched(w, line) == TRUE ? TRUE:FALSE); } // Return TRUE if line is marked as changed, FALSE otherwise bool is_wintouched() const { return (::is_wintouched(w) ? TRUE:FALSE); } // Return TRUE if window is marked as changed, FALSE otherwise int leaveok(bool bf) { return ::leaveok(w, bf); } // If bf is TRUE, curses will leave the cursor after an update wherever // it is after the update. int redrawln(int from, int n) { return ::wredrawln(w, from, n); } // Redraw n lines starting from the requested line int redrawwin() { return ::wredrawln(w, 0, height()); } // Redraw the whole window int doupdate() { return ::doupdate(); } // Do all outputs to make the physical screen looking like the virtual one void syncdown() { ::wsyncdown(w); } // Propagate the changes down to all descendant windows void syncup() { ::wsyncup(w); } // Propagate the changes up in the hierarchy void cursyncup() { ::wcursyncup(w); } // Position the cursor in all ancestor windows corresponding to our setting int syncok(bool bf) { return ::syncok(w, bf); } // If called with bf=TRUE, syncup() is called whenever the window is changed #ifndef _no_flushok int flushok(bool bf) { return ::flushok(w, bf); } #endif void immedok(bool bf) { ::immedok(w, bf); } // If called with bf=TRUE, any change in the window will cause an // automatic immediate refresh() int intrflush(bool bf) { return ::intrflush(w, bf); } int keypad(bool bf) { return ::keypad(w, bf); } // If called with bf=TRUE, the application will interpret function keys. int nodelay(bool bf) { return ::nodelay(w, bf); } int meta(bool bf) { return ::meta(w, bf); } // If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise // 7-Bit characters are generated. int standout() { return ::wstandout(w); } // Enable "standout" attributes int standend() { return ::wstandend(w); } // Disable "standout" attributes // ------------------------------------------------------------------------- // The next two are virtual, because we redefine them in the // NCursesPanel class. // ------------------------------------------------------------------------- virtual int refresh() { return ::wrefresh(w); } // Propagate the changes in this window to the virtual screen and call // doupdate(). This is redefined in NCursesPanel. virtual int noutrefresh() { return ::wnoutrefresh(w); } // Propagate the changes in this window to the virtual screen. This is // redefined in NCursesPanel. // ------------------------------------------------------------------------- // multiple window control // ------------------------------------------------------------------------- int overlay(NCursesWindow& win) { return ::overlay(w, win.w); } // Overlay this window over win. int overwrite(NCursesWindow& win) { return ::overwrite(w, win.w); } // Overwrite win with this window. int copywin(NCursesWindow& win, int sminrow, int smincol, int dminrow, int dmincol, int dmaxrow, int dmaxcol, bool overlaywin=TRUE) { return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)); } // Overlay or overwrite the rectangle in win given by dminrow,dmincol, // dmaxrow,dmaxcol with the rectangle in this window beginning at // sminrow,smincol. // ------------------------------------------------------------------------- // Extended functions // ------------------------------------------------------------------------- #if defined(NCURSES_EXT_FUNCS) && (NCURSES_EXT_FUNCS != 0) int wresize(int newLines, int newColumns) { return ::wresize(w, newLines, newColumns); } #endif // ------------------------------------------------------------------------- // Mouse related // ------------------------------------------------------------------------- bool has_mouse() const; // Return TRUE if terminal supports a mouse, FALSE otherwise // ------------------------------------------------------------------------- // traversal support // ------------------------------------------------------------------------- NCursesWindow* child() { return subwins; } // Get the first child window. NCursesWindow* sibling() { return sib; } // Get the next child of my parent. NCursesWindow* parent() { return par; } // Get my parent. bool isDescendant(NCursesWindow& win); // Return TRUE if win is a descendant of this. }; // ------------------------------------------------------------------------- // We leave this here for compatibility reasons. // ------------------------------------------------------------------------- class NCURSES_CXX_IMPEXP NCursesColorWindow : public NCursesWindow { public: explicit NCursesColorWindow(WINDOW* &window) // useful only for stdscr : NCursesWindow(window) { useColors(); } NCursesColorWindow(int nlines, // number of lines int ncols, // number of columns int begin_y, // line origin int begin_x) // col origin : NCursesWindow(nlines, ncols, begin_y, begin_x) { useColors(); } NCursesColorWindow(NCursesWindow& parentWin,// parent window int nlines, // number of lines int ncols, // number of columns int begin_y, // absolute or relative int begin_x, // origins: char absrel = 'a') // if `a', by & bx are : NCursesWindow(parentWin, nlines, ncols, // absolute screen pos, begin_y, begin_x, // else if `r', they are absrel ) { // relative to par origin useColors(); } }; // These enum definitions really belong inside the NCursesPad class, but only // recent compilers support that feature. typedef enum { REQ_PAD_REFRESH = KEY_MAX + 1, REQ_PAD_UP, REQ_PAD_DOWN, REQ_PAD_LEFT, REQ_PAD_RIGHT, REQ_PAD_EXIT } Pad_Request; const Pad_Request PAD_LOW = REQ_PAD_REFRESH; // lowest op-code const Pad_Request PAD_HIGH = REQ_PAD_EXIT; // highest op-code // ------------------------------------------------------------------------- // Pad Support. We allow an association of a pad with a "real" window // through which the pad may be viewed. // ------------------------------------------------------------------------- class NCURSES_CXX_IMPEXP NCursesPad : public NCursesWindow { private: NCursesWindow* viewWin; // the "viewport" window NCursesWindow* viewSub; // the "viewport" subwindow int h_gridsize, v_gridsize; protected: int min_row, min_col; // top left row/col of the pads display area NCursesWindow* Win(void) const { // Get the window into which the pad should be copied (if any) return (viewSub?viewSub:(viewWin?viewWin:0)); } NCursesWindow* getWindow(void) const { return viewWin; } NCursesWindow* getSubWindow(void) const { return viewSub; } virtual int driver (int key); // Virtualize keystroke key // The driver translates the keystroke c into an Pad_Request virtual void OnUnknownOperation(int pad_req) { (void) pad_req; ::beep(); } // This is called if the driver returns an unknown op-code virtual void OnNavigationError(int pad_req) { (void) pad_req; ::beep(); } // This is called if a navigation request couldn't be satisfied virtual void OnOperation(int pad_req) { (void) pad_req; }; // OnOperation is called if a Pad_Operation was executed and just before // the refresh() operation is done. public: NCursesPad(int nlines, int ncols); // create a pad with the given size NCursesPad& operator=(const NCursesPad& rhs) { if (this != &rhs) { *this = rhs; NCursesWindow::operator=(rhs); } return *this; } NCursesPad(const NCursesPad& rhs) : NCursesWindow(rhs), viewWin(rhs.viewWin), viewSub(rhs.viewSub), h_gridsize(rhs.h_gridsize), v_gridsize(rhs.v_gridsize), min_row(rhs.min_row), min_col(rhs.min_col) { } virtual ~NCursesPad() THROWS(NCursesException) {} int echochar(const chtype ch) { return ::pechochar(w, ch); } // Put the attributed character onto the pad and immediately do a // prefresh(). int refresh(); // If a viewport is defined the pad is displayed in this window, otherwise // this is a noop. int refresh(int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol) { return ::prefresh(w, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol); } // The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle // on the screen. <b>refresh</b> copies a rectangle of this size beginning // with top left corner pminrow,pmincol onto the screen and calls doupdate(). int noutrefresh(); // If a viewport is defined the pad is displayed in this window, otherwise // this is a noop. int noutrefresh(int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol) { return ::pnoutrefresh(w, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol); } // Does the same as refresh() but without calling doupdate(). virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1); // Add the window "view" as viewing window to the pad. virtual void setSubWindow(NCursesWindow& sub); // Use the subwindow "sub" of the viewport window for the actual viewing. // The full viewport window is usually used to provide some decorations // like frames, titles etc. virtual void operator() (void); // Perform Pad's operation }; // A FramedPad is constructed always with a viewport window. This viewport // will be framed (by a box() command) and the interior of the box is the // viewport subwindow. On the frame we display scrollbar sliders. class NCURSES_CXX_IMPEXP NCursesFramedPad : public NCursesPad { protected: virtual void OnOperation(int pad_req); public: NCursesFramedPad(NCursesWindow& win, int nlines, int ncols, int v_grid = 1, int h_grid = 1) : NCursesPad(nlines, ncols) { NCursesPad::setWindow(win, v_grid, h_grid); NCursesPad::setSubWindow(*(new NCursesWindow(win))); } // Construct the FramedPad with the given Window win as viewport. virtual ~NCursesFramedPad() THROWS(NCursesException) { delete getSubWindow(); } void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) { (void) view; (void) v_grid; (void) h_grid; err_handler("Operation not allowed"); } // Disable this call; the viewport is already defined void setSubWindow(NCursesWindow& sub) { (void) sub; err_handler("Operation not allowed"); } // Disable this call; the viewport subwindow is already defined }; #endif /* NCURSES_CURSESW_H_incl */ /* Copyright (C) 1996-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _NL_TYPES_H #define _NL_TYPES_H 1 #include <features.h> /* The default message set used by the gencat program. */ #define NL_SETD 1 /* Value for FLAG parameter of `catgets' to say we want XPG4 compliance. */ #define NL_CAT_LOCALE 1 __BEGIN_DECLS /* Message catalog descriptor type. */ typedef void *nl_catd; /* Type used by `nl_langinfo'. */ typedef int nl_item; /* Open message catalog for later use, returning descriptor. This function is a possible cancellation point and therefore not marked with __THROW. */ extern nl_catd catopen (const char *__cat_name, int __flag) __nonnull ((1)); /* Return translation with NUMBER in SET of CATALOG; if not found return STRING. */ extern char *catgets (nl_catd __catalog, int __set, int __number, const char *__string) __THROW __nonnull ((1)); /* Close message CATALOG. */ extern int catclose (nl_catd __catalog) __THROW __nonnull ((1)); __END_DECLS #endif /* nl_types.h */ /* This file is here to prevent a file conflict on multiarch systems. */ #ifdef ffi_wrapper_h #error "Do not define ffi_wrapper_h!" #endif #define ffi_wrapper_h #if defined(__i386__) #include "ffi-i386.h" #elif defined(__powerpc64__) #include "ffi-ppc64.h" #elif defined(__powerpc__) #include "ffi-ppc.h" #elif defined(__s390x__) #include "ffi-s390x.h" #elif defined(__s390__) #include "ffi-s390.h" #elif defined(__x86_64__) #include "ffi-x86_64.h" #else #error "The libffi-devel package is not usable with the architecture." #endif #undef ffi_wrapper_h /* Copyright (C) 1996-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _REGEXP_H #define _REGEXP_H 1 /* The contents of this header file were originally standardized in the Single Unix Specification, Issue 3 (1992). In Issue 4 (1994) the header was marked as TO BE WITHDRAWN, and new applications were encouraged to use <regex.h> instead. It was officially withdrawn from the standard in Issue 6 (aka POSIX.1-2001). The GNU C Library provided this header through version 2.22. */ #error "The GNU C Library no longer implements <regexp.h>." #error "Please update your code to use <regex.h> instead (no trailing 'p')." #endif /* regexp.h */ // * This makes emacs happy -*-Mode: C++;-*- /**************************************************************************** * Copyright 2018-2020,2021 Thomas E. Dickey * * Copyright 1998-2012,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * * "Software"), to deal in the Software without restriction, including * * without limitation the rights to use, copy, modify, merge, publish, * * distribute, distribute with modifications, sublicense, and/or sell * * copies of the Software, and to permit persons to whom the Software is * * furnished to do so, subject to the following conditions: * * * * The above copyright notice and this permission notice shall be included * * in all copies or substantial portions of the Software. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * * * Except as contained in this notice, the name(s) of the above copyright * * holders shall not be used in advertising or otherwise to promote the * * sale, use or other dealings in this Software without prior written * * authorization. * ****************************************************************************/ /**************************************************************************** * Author: Juergen Pfeifer, 1997 * ****************************************************************************/ // $Id: etip.h.in,v 1.46 2021/04/17 17:59:57 tom Exp $ #ifndef NCURSES_ETIP_H_incl #define NCURSES_ETIP_H_incl 1 // These are substituted at configure/build time #ifndef HAVE_BUILTIN_H #define HAVE_BUILTIN_H 0 #endif #ifndef HAVE_GXX_BUILTIN_H #define HAVE_GXX_BUILTIN_H 0 #endif #ifndef HAVE_GPP_BUILTIN_H #define HAVE_GPP_BUILTIN_H 0 #endif #ifndef HAVE_IOSTREAM #define HAVE_IOSTREAM 1 #endif #ifndef HAVE_TYPEINFO #define HAVE_TYPEINFO 1 #endif #ifndef HAVE_VALUES_H #define HAVE_VALUES_H 0 #endif #ifndef ETIP_NEEDS_MATH_H #define ETIP_NEEDS_MATH_H 0 #endif #ifndef ETIP_NEEDS_MATH_EXCEPTION #define ETIP_NEEDS_MATH_EXCEPTION 0 #endif #ifndef CPP_HAS_PARAM_INIT #define CPP_HAS_PARAM_INIT 0 #endif #ifndef CPP_HAS_STATIC_CAST #define CPP_HAS_STATIC_CAST 1 #endif #ifndef IOSTREAM_NAMESPACE #define IOSTREAM_NAMESPACE 1 #endif #ifdef __GNUG__ # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8)) # if HAVE_TYPEINFO # include <typeinfo> # endif # endif #endif #if defined(__GNUG__) # if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H # if ETIP_NEEDS_MATH_H # if ETIP_NEEDS_MATH_EXCEPTION # undef exception # define exception math_exception # endif # include <math.h> # endif # undef exception # define exception builtin_exception # if HAVE_GPP_BUILTIN_H # include <gpp/builtin.h> # elif HAVE_GXX_BUILTIN_H # include <g++/builtin.h> # else # include <builtin.h> # endif # undef exception # endif #elif defined (__SUNPRO_CC) # include <generic.h> #endif #include <curses.h> extern "C" { #if HAVE_VALUES_H # include <values.h> #endif #include <assert.h> #include <eti.h> #include <errno.h> } // Language features #if CPP_HAS_PARAM_INIT #define NCURSES_PARAM_INIT(value) = value #else #define NCURSES_PARAM_INIT(value) /*nothing*/ #endif #if CPP_HAS_STATIC_CAST #define STATIC_CAST(s) static_cast<s> #else #define STATIC_CAST(s) (s) #endif // Forward Declarations class NCURSES_CXX_IMPEXP NCursesPanel; class NCURSES_CXX_IMPEXP NCursesMenu; class NCURSES_CXX_IMPEXP NCursesForm; class NCURSES_CXX_IMPEXP NCursesException { public: const char *message; int errorno; NCursesException (const char* msg, int err) : message(msg), errorno (err) {}; explicit NCursesException (const char* msg) : message(msg), errorno (E_SYSTEM_ERROR) {}; NCursesException& operator=(const NCursesException& rhs) { message = rhs.message; errorno = rhs.errorno; return *this; } NCursesException(const NCursesException& rhs) : message(rhs.message), errorno(rhs.errorno) { } virtual const char *classname() const { return "NCursesWindow"; } virtual ~NCursesException() { } }; class NCURSES_CXX_IMPEXP NCursesPanelException : public NCursesException { public: const NCursesPanel* p; NCursesPanelException (const char *msg, int err) : NCursesException (msg, err), p (0) {}; NCursesPanelException (const NCursesPanel* panel, const char *msg, int err) : NCursesException (msg, err), p (panel) {}; explicit NCursesPanelException (int err) : NCursesException ("panel library error", err), p (0) {}; NCursesPanelException (const NCursesPanel* panel, int err) : NCursesException ("panel library error", err), p (panel) {}; NCursesPanelException& operator=(const NCursesPanelException& rhs) { if (this != &rhs) { NCursesException::operator=(rhs); p = rhs.p; } return *this; } NCursesPanelException(const NCursesPanelException& rhs) : NCursesException(rhs), p(rhs.p) { } virtual const char *classname() const { return "NCursesPanel"; } virtual ~NCursesPanelException() { } }; class NCURSES_CXX_IMPEXP NCursesMenuException : public NCursesException { public: const NCursesMenu* m; NCursesMenuException (const char *msg, int err) : NCursesException (msg, err), m (0) {}; NCursesMenuException (const NCursesMenu* menu, const char *msg, int err) : NCursesException (msg, err), m (menu) {}; explicit NCursesMenuException (int err) : NCursesException ("menu library error", err), m (0) {}; NCursesMenuException (const NCursesMenu* menu, int err) : NCursesException ("menu library error", err), m (menu) {}; NCursesMenuException& operator=(const NCursesMenuException& rhs) { if (this != &rhs) { NCursesException::operator=(rhs); m = rhs.m; } return *this; } NCursesMenuException(const NCursesMenuException& rhs) : NCursesException(rhs), m(rhs.m) { } virtual const char *classname() const { return "NCursesMenu"; } virtual ~NCursesMenuException() { } }; class NCURSES_CXX_IMPEXP NCursesFormException : public NCursesException { public: const NCursesForm* f; NCursesFormException (const char *msg, int err) : NCursesException (msg, err), f (0) {}; NCursesFormException (const NCursesForm* form, const char *msg, int err) : NCursesException (msg, err), f (form) {}; explicit NCursesFormException (int err) : NCursesException ("form library error", err), f (0) {}; NCursesFormException (const NCursesForm* form, int err) : NCursesException ("form library error", err), f (form) {}; NCursesFormException& operator=(const NCursesFormException& rhs) { if (this != &rhs) { NCursesException::operator=(rhs); f = rhs.f; } return *this; } NCursesFormException(const NCursesFormException& rhs) : NCursesException(rhs), f(rhs.f) { } virtual const char *classname() const { return "NCursesForm"; } virtual ~NCursesFormException() { } }; #if !((defined(__GNUG__) && defined(__EXCEPTIONS) && (__GNUG__ < 7)) || defined(__SUNPRO_CC)) # if HAVE_IOSTREAM # include <iostream> # if IOSTREAM_NAMESPACE using std::cerr; using std::endl; # endif # else # include <iostream.h> # endif #endif inline void THROW(const NCursesException *e) { #if defined(__GNUG__) && defined(__EXCEPTIONS) # if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8)) (*lib_error_handler)(e ? e->classname() : "", e ? e->message : ""); # elif (__GNUG__ >= 7) // g++ 7.0 warns about deprecation, but lacks the predefined symbols ::endwin(); std::cerr << "Found a problem - goodbye" << std::endl; exit(EXIT_FAILURE); # else # define CPP_HAS_TRY_CATCH 1 # endif #elif defined(__SUNPRO_CC) # if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5) genericerror(1, ((e != 0) ? (char *)(e->message) : "")); # else # define CPP_HAS_TRY_CATCH 1 # endif #else if (e) cerr << e->message << endl; exit(0); #endif #ifndef CPP_HAS_TRY_CATCH #define CPP_HAS_TRY_CATCH 0 #define NCURSES_CPP_TRY /* nothing */ #define NCURSES_CPP_CATCH(e) if (false) #define THROWS(s) /* nothing */ #define THROW2(s,t) /* nothing */ #elif CPP_HAS_TRY_CATCH throw *e; #define NCURSES_CPP_TRY try #define NCURSES_CPP_CATCH(e) catch(e) #if defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510) // C++17 deprecates the usage of throw(). #define THROWS(s) /* nothing */ #define THROW2(s,t) /* nothing */ #else #define THROWS(s) throw(s) #define THROW2(s,t) throw(s,t) #endif #endif } #endif /* NCURSES_ETIP_H_incl */ /* Functions for pseudo TTY handling. Copyright (C) 1996-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _PTY_H #define _PTY_H 1 #include <features.h> struct termios; struct winsize; #include <termios.h> #include <sys/ioctl.h> __BEGIN_DECLS /* Create pseudo tty master slave pair with NAME and set terminal attributes according to TERMP and WINP and return handles for both ends in AMASTER and ASLAVE. */ extern int openpty (int *__amaster, int *__aslave, char *__name, const struct termios *__termp, const struct winsize *__winp) __THROW; /* Create child process and establish the slave pseudo terminal as the child's controlling terminal. */ extern int forkpty (int *__amaster, char *__name, const struct termios *__termp, const struct winsize *__winp) __THROW; __END_DECLS #endif /* pty.h */ /* Data structure for communication from the run-time dynamic linker for loaded ELF shared objects. Copyright (C) 1995-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _LINK_H #define _LINK_H 1 #include <features.h> #include <elf.h> #include <dlfcn.h> #include <sys/types.h> /* We use this macro to refer to ELF types independent of the native wordsize. `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */ #define ElfW(type) _ElfW (Elf, __ELF_NATIVE_CLASS, type) #define _ElfW(e,w,t) _ElfW_1 (e, w, _##t) #define _ElfW_1(e,w,t) e##w##t #include <bits/elfclass.h> /* Defines __ELF_NATIVE_CLASS. */ #include <bits/link.h> /* The legacy rendezvous structure used by the run-time dynamic linker to communicate details of shared object loading to the debugger. */ struct r_debug { /* Version number for this protocol. It should be greater than 0. */ int r_version; struct link_map *r_map; /* Head of the chain of loaded objects. */ /* This is the address of a function internal to the run-time linker, that will always be called when the linker begins to map in a library or unmap it, and again when the mapping change is complete. The debugger can set a breakpoint at this address if it wants to notice shared object mapping changes. */ ElfW(Addr) r_brk; enum { /* This state value describes the mapping change taking place when the `r_brk' address is called. */ RT_CONSISTENT, /* Mapping change is complete. */ RT_ADD, /* Beginning to add a new object. */ RT_DELETE /* Beginning to remove an object mapping. */ } r_state; ElfW(Addr) r_ldbase; /* Base address the linker is loaded at. */ }; /* This is the symbol of that structure provided by the dynamic linker. */ extern struct r_debug _r_debug; /* The extended rendezvous structure used by the run-time dynamic linker to communicate details of shared object loading to the debugger. If the executable's dynamic section has a DT_DEBUG element, the run-time linker sets that element's value to the address where this structure can be found. */ struct r_debug_extended { struct r_debug base; /* The following field is added by r_version == 2. */ /* Link to the next r_debug_extended structure. Each r_debug_extended structure represents a different namespace. The first r_debug_extended structure is for the default namespace. */ struct r_debug_extended *r_next; }; /* This symbol refers to the "dynamic structure" in the `.dynamic' section of whatever module refers to `_DYNAMIC'. So, to find its own `struct r_debug_extended', a program could do: for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) if (dyn->d_tag == DT_DEBUG) r_debug_extended = (struct r_debug_extended *) dyn->d_un.d_ptr; */ extern ElfW(Dyn) _DYNAMIC[]; /* Structure describing a loaded shared object. The `l_next' and `l_prev' members form a chain of all the shared objects loaded at startup. These data structures exist in space used by the run-time dynamic linker; modifying them may have disastrous results. */ struct link_map { /* These first few members are part of the protocol with the debugger. This is the same format used in SVR4. */ ElfW(Addr) l_addr; /* Difference between the address in the ELF file and the addresses in memory. */ char *l_name; /* Absolute file name object was found in. */ ElfW(Dyn) *l_ld; /* Dynamic section of the shared object. */ struct link_map *l_next, *l_prev; /* Chain of loaded objects. */ }; #ifdef __USE_GNU /* Version numbers for la_version handshake interface. */ #include <bits/link_lavcurrent.h> /* Activity types signaled through la_activity. */ enum { LA_ACT_CONSISTENT, /* Link map consistent again. */ LA_ACT_ADD, /* New object will be added. */ LA_ACT_DELETE /* Objects will be removed. */ }; /* Values representing origin of name for dynamic loading. */ enum { LA_SER_ORIG = 0x01, /* Original name. */ LA_SER_LIBPATH = 0x02, /* Directory from LD_LIBRARY_PATH. */ LA_SER_RUNPATH = 0x04, /* Directory from RPATH/RUNPATH. */ LA_SER_CONFIG = 0x08, /* Found through ldconfig. */ LA_SER_DEFAULT = 0x40, /* Default directory. */ LA_SER_SECURE = 0x80 /* Unused. */ }; /* Values for la_objopen return value. */ enum { LA_FLG_BINDTO = 0x01, /* Audit symbols bound to this object. */ LA_FLG_BINDFROM = 0x02 /* Audit symbols bound from this object. */ }; /* Values for la_symbind flags parameter. */ enum { LA_SYMB_NOPLTENTER = 0x01, /* la_pltenter will not be called. */ LA_SYMB_NOPLTEXIT = 0x02, /* la_pltexit will not be called. */ LA_SYMB_STRUCTCALL = 0x04, /* Return value is a structure. */ LA_SYMB_DLSYM = 0x08, /* Binding due to dlsym call. */ LA_SYMB_ALTVALUE = 0x10 /* Value has been changed by a previous la_symbind call. */ }; struct dl_phdr_info { ElfW(Addr) dlpi_addr; const char *dlpi_name; const ElfW(Phdr) *dlpi_phdr; ElfW(Half) dlpi_phnum; /* Note: Following members were introduced after the first version of this structure was available. Check the SIZE argument passed to the dl_iterate_phdr callback to determine whether or not each later member is available. */ /* Incremented when a new object may have been added. */ __extension__ unsigned long long int dlpi_adds; /* Incremented when an object may have been removed. */ __extension__ unsigned long long int dlpi_subs; /* If there is a PT_TLS segment, its module ID as used in TLS relocations, else zero. */ size_t dlpi_tls_modid; /* The address of the calling thread's instance of this module's PT_TLS segment, if it has one and it has been allocated in the calling thread, otherwise a null pointer. */ void *dlpi_tls_data; }; __BEGIN_DECLS extern int dl_iterate_phdr (int (*__callback) (struct dl_phdr_info *, size_t, void *), void *__data); /* Prototypes for the ld.so auditing interfaces. These are not defined anywhere in ld.so but instead have to be provided by the auditing DSO. */ extern unsigned int la_version (unsigned int __version); extern void la_activity (uintptr_t *__cookie, unsigned int __flag); extern char *la_objsearch (const char *__name, uintptr_t *__cookie, unsigned int __flag); extern unsigned int la_objopen (struct link_map *__map, Lmid_t __lmid, uintptr_t *__cookie); extern void la_preinit (uintptr_t *__cookie); extern uintptr_t la_symbind32 (Elf32_Sym *__sym, unsigned int __ndx, uintptr_t *__refcook, uintptr_t *__defcook, unsigned int *__flags, const char *__symname); extern uintptr_t la_symbind64 (Elf64_Sym *__sym, unsigned int __ndx, uintptr_t *__refcook, uintptr_t *__defcook, unsigned int *__flags, const char *__symname); extern unsigned int la_objclose (uintptr_t *__cookie); __END_DECLS #endif #endif /* link.h */ /* Copyright (C) 1993-2021 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C 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. The GNU C 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 the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ #ifndef _UTMP_H #define _UTMP_H 1 #include <features.h> #include <sys/types.h> __BEGIN_DECLS /* Get system dependent values and data structures. */ #include <bits/utmp.h> /* Compatibility names for the strings of the canonical file names. */ #define UTMP_FILE _PATH_UTMP #define UTMP_FILENAME _PATH_UTMP #define WTMP_FILE _PATH_WTMP #define WTMP_FILENAME _PATH_WTMP /* Make FD be the controlling terminal, stdin, stdout, and stderr; then close FD. Returns 0 on success, nonzero on error. */ extern int login_tty (int __fd) __THROW; /* Write the given entry into utmp and wtmp. */ extern void login (const struct utmp *__entry) __THROW; /* Write the utmp entry to say the user on UT_LINE has logged out. */ extern int logout (const char *__ut_line) __THROW; /* Append to wtmp an entry for the current time and the given info. */ extern void logwtmp (const char *__ut_line, const char *__ut_name, const char *__ut_host) __THROW; /* Append entry UTMP to the wtmp-like file WTMP_FILE. */ extern void updwtmp (const char *__wtmp_file, const struct utmp *__utmp) __THROW; /* Change name of the utmp file to be examined. */ extern int utmpname (const char *__file) __THROW; /* Read next entry from a utmp-like file. */ extern struct utmp *getutent (void) __THROW; /* Reset the input stream to the beginning of the file. */ extern void setutent (void) __THROW; /* Close the current open file. */ extern void endutent (void) __THROW; /* Search forward from the current point in the utmp file until the next entry with a ut_type matching ID->ut_type. */ extern struct utmp *getutid (const struct utmp *__id) __THROW; /* Search forward from the current point in the utmp file until the next entry with a ut_line matching LINE->ut_line. */ extern struct utmp *getutline (const struct utmp *__line) __THROW; /* Write out entry pointed to by UTMP_PTR into the utmp file. */ extern struct utmp *pututline (const struct utmp *__utmp_ptr) __THROW; #ifdef __USE_MISC /* Reentrant versions of the file for handling utmp files. */ extern int getutent_r (struct utmp *__buffer, struct utmp **__result) __THROW; extern int getutid_r (const struct utmp *__id, struct utmp *__buffer, struct utmp **__result) __THROW; extern int getutline_r (const struct utmp *__line, struct utmp *__buffer, struct utmp **__result) __THROW; #endif /* Use misc. */ __END_DECLS #endif /* utmp.h */ /* * fontconfig/fontconfig/fcprivate.h * * Copyright © 2001 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of the author(s) not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The authors make no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #ifndef _FCPRIVATE_H_ #define _FCPRIVATE_H_ /* * I tried this with functions that took va_list* arguments * but portability concerns made me change these functions * into macros (sigh). */ #define FcPatternVapBuild(result, orig, va) \ { \ FcPattern *__p__ = (orig); \ const char *__o__; \ FcValue __v__; \ \ if (!__p__) \ { \ __p__ = FcPatternCreate (); \ if (!__p__) \ goto _FcPatternVapBuild_bail0; \ } \ for (;;) \ { \ __o__ = va_arg (va, const char *); \ if (!__o__) \ break; \ __v__.type = va_arg (va, int); \ switch (__v__.type) { \ case FcTypeUnknown: \ case FcTypeVoid: \ goto _FcPatternVapBuild_bail1; \ case FcTypeInteger: \ __v__.u.i = va_arg (va, int); \ break; \ case FcTypeDouble: \ __v__.u.d = va_arg (va, double); \ break; \ case FcTypeString: \ __v__.u.s = va_arg (va, const FcChar8 *); \ break; \ case FcTypeBool: \ __v__.u.b = va_arg (va, FcBool); \ break; \ case FcTypeMatrix: \ __v__.u.m = va_arg (va, const FcMatrix *); \ break; \ case FcTypeCharSet: \ __v__.u.c = va_arg (va, const FcCharSet *); \ break; \ case FcTypeFTFace: \ __v__.u.f = va_arg (va, FT_Face); \ break; \ case FcTypeLangSet: \ __v__.u.l = va_arg (va, const FcLangSet *); \ break; \ case FcTypeRange: \ __v__.u.r = va_arg (va, const FcRange *); \ break; \ } \ if (!FcPatternAdd (__p__, __o__, __v__, FcTrue)) \ goto _FcPatternVapBuild_bail1; \ } \ result = __p__; \ goto _FcPatternVapBuild_return; \ \ _FcPatternVapBuild_bail1: \ if (!orig) \ FcPatternDestroy (__p__); \ _FcPatternVapBuild_bail0: \ result = (void*)0; \ \ _FcPatternVapBuild_return: \ ; \ } #define FcObjectSetVapBuild(__ret__, __first__, __va__) \ { \ FcObjectSet *__os__; \ const char *__ob__; \ \ __ret__ = 0; \ __os__ = FcObjectSetCreate (); \ if (!__os__) \ goto _FcObjectSetVapBuild_bail0; \ __ob__ = __first__; \ while (__ob__) \ { \ if (!FcObjectSetAdd (__os__, __ob__)) \ goto _FcObjectSetVapBuild_bail1; \ __ob__ = va_arg (__va__, const char *); \ } \ __ret__ = __os__; \ \ _FcObjectSetVapBuild_bail1: \ if (!__ret__ && __os__) \ FcObjectSetDestroy (__os__); \ _FcObjectSetVapBuild_bail0: \ ; \ } #ifndef FC_ATTRIBUTE_VISIBILITY_HIDDEN #define FC_ATTRIBUTE_VISIBILITY_HIDDEN __attribute((visibility("hidden"))) #endif #ifndef FC_ATTRIBUTE_VISIBILITY_EXPORT #define FC_ATTRIBUTE_VISIBILITY_EXPORT __attribute((visibility("default"))) #endif #endif /* _FCPRIVATE_H_ */ /* * fontconfig/fontconfig/fcfreetype.h * * Copyright © 2001 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of the author(s) not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The authors make no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #ifndef _FCFREETYPE_H_ #define _FCFREETYPE_H_ #include <ft2build.h> #include FT_FREETYPE_H #ifndef FcPublic #define FcPublic #endif _FCFUNCPROTOBEGIN FcPublic FT_UInt FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4); FcPublic FcCharSet * FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing); FcPublic FcCharSet * FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks); FcPublic FcResult FcPatternGetFTFace (const FcPattern *p, const char *object, int n, FT_Face *f); FcPublic FcBool FcPatternAddFTFace (FcPattern *p, const char *object, const FT_Face f); FcPublic FcPattern * FcFreeTypeQueryFace (const FT_Face face, const FcChar8 *file, unsigned int id, FcBlanks *blanks); _FCFUNCPROTOEND #endif /* * fontconfig/fontconfig/fontconfig.h * * Copyright © 2001 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of the author(s) not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. The authors make no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #ifndef _FONTCONFIG_H_ #define _FONTCONFIG_H_ #include <sys/types.h> #include <sys/stat.h> #include <stdarg.h> #include <limits.h> #if defined(__GNUC__) && (__GNUC__ >= 4) #define FC_ATTRIBUTE_SENTINEL(x) __attribute__((__sentinel__(0))) #else #define FC_ATTRIBUTE_SENTINEL(x) #endif #ifndef FcPublic #define FcPublic #endif typedef unsigned char FcChar8; typedef unsigned short FcChar16; typedef unsigned int FcChar32; typedef int FcBool; /* * Current Fontconfig version number. This same number * must appear in the fontconfig configure.in file. Yes, * it'a a pain to synchronize version numbers like this. */ #define FC_MAJOR 2 #define FC_MINOR 14 #define FC_REVISION 0 #define FC_VERSION ((FC_MAJOR * 10000) + (FC_MINOR * 100) + (FC_REVISION)) /* * Current font cache file format version * This is appended to the cache files so that multiple * versions of the library will peacefully coexist * * Change this value whenever the disk format for the cache file * changes in any non-compatible way. Try to avoid such changes as * it means multiple copies of the font information. */ #define FC_CACHE_VERSION_NUMBER 8 #define _FC_STRINGIFY_(s) #s #define _FC_STRINGIFY(s) _FC_STRINGIFY_(s) #define FC_CACHE_VERSION _FC_STRINGIFY(FC_CACHE_VERSION_NUMBER) #define FcFalse 0 #define FcTrue 1 #define FcDontCare 2 #define FC_FAMILY "family" /* String */ #define FC_STYLE "style" /* String */ #define FC_SLANT "slant" /* Int */ #define FC_WEIGHT "weight" /* Int */ #define FC_SIZE "size" /* Range (double) */ #define FC_ASPECT "aspect" /* Double */ #define FC_PIXEL_SIZE "pixelsize" /* Double */ #define FC_SPACING "spacing" /* Int */ #define FC_FOUNDRY "foundry" /* String */ #define FC_ANTIALIAS "antialias" /* Bool (depends) */ #define FC_HINTING "hinting" /* Bool (true) */ #define FC_HINT_STYLE "hintstyle" /* Int */ #define FC_VERTICAL_LAYOUT "verticallayout" /* Bool (false) */ #define FC_AUTOHINT "autohint" /* Bool (false) */ /* FC_GLOBAL_ADVANCE is deprecated. this is simply ignored on freetype 2.4.5 or later */ #define FC_GLOBAL_ADVANCE "globaladvance" /* Bool (true) */ #define FC_WIDTH "width" /* Int */ #define FC_FILE "file" /* String */ #define FC_INDEX "index" /* Int */ #define FC_FT_FACE "ftface" /* FT_Face */ #define FC_RASTERIZER "rasterizer" /* String (deprecated) */ #define FC_OUTLINE "outline" /* Bool */ #define FC_SCALABLE "scalable" /* Bool */ #define FC_COLOR "color" /* Bool */ #define FC_VARIABLE "variable" /* Bool */ #define FC_SCALE "scale" /* double (deprecated) */ #define FC_SYMBOL "symbol" /* Bool */ #define FC_DPI "dpi" /* double */ #define FC_RGBA "rgba" /* Int */ #define FC_MINSPACE "minspace" /* Bool use minimum line spacing */ #define FC_SOURCE "source" /* String (deprecated) */ #define FC_CHARSET "charset" /* CharSet */ #define FC_LANG "lang" /* LangSet Set of RFC 3066 langs */ #define FC_FONTVERSION "fontversion" /* Int from 'head' table */ #define FC_FULLNAME "fullname" /* String */ #define FC_FAMILYLANG "familylang" /* String RFC 3066 langs */ #define FC_STYLELANG "stylelang" /* String RFC 3066 langs */ #define FC_FULLNAMELANG "fullnamelang" /* String RFC 3066 langs */ #define FC_CAPABILITY "capability" /* String */ #define FC_FONTFORMAT "fontformat" /* String */ #define FC_EMBOLDEN "embolden" /* Bool - true if emboldening needed*/ #define FC_EMBEDDED_BITMAP "embeddedbitmap" /* Bool - true to enable embedded bitmaps */ #define FC_DECORATIVE "decorative" /* Bool - true if style is a decorative variant */ #define FC_LCD_FILTER "lcdfilter" /* Int */ #define FC_FONT_FEATURES "fontfeatures" /* String */ #define FC_FONT_VARIATIONS "fontvariations" /* String */ #define FC_NAMELANG "namelang" /* String RFC 3866 langs */ #define FC_PRGNAME "prgname" /* String */ #define FC_HASH "hash" /* String (deprecated) */ #define FC_POSTSCRIPT_NAME "postscriptname" /* String */ #define FC_FONT_HAS_HINT "fonthashint" /* Bool - true if font has hinting */ #define FC_ORDER "order" /* Integer */ #define FC_CACHE_SUFFIX ".cache-" FC_CACHE_VERSION #define FC_DIR_CACHE_FILE "fonts.cache-" FC_CACHE_VERSION #define FC_USER_CACHE_FILE ".fonts.cache-" FC_CACHE_VERSION /* Adjust outline rasterizer */ #define FC_CHARWIDTH "charwidth" /* Int */ #define FC_CHAR_WIDTH FC_CHARWIDTH #define FC_CHAR_HEIGHT "charheight"/* Int */ #define FC_MATRIX "matrix" /* FcMatrix */ #define FC_WEIGHT_THIN 0 #define FC_WEIGHT_EXTRALIGHT 40 #define FC_WEIGHT_ULTRALIGHT FC_WEIGHT_EXTRALIGHT #define FC_WEIGHT_LIGHT 50 #define FC_WEIGHT_DEMILIGHT 55 #define FC_WEIGHT_SEMILIGHT FC_WEIGHT_DEMILIGHT #define FC_WEIGHT_BOOK 75 #define FC_WEIGHT_REGULAR 80 #define FC_WEIGHT_NORMAL FC_WEIGHT_REGULAR #define FC_WEIGHT_MEDIUM 100 #define FC_WEIGHT_DEMIBOLD 180 #define FC_WEIGHT_SEMIBOLD FC_WEIGHT_DEMIBOLD #define FC_WEIGHT_BOLD 200 #define FC_WEIGHT_EXTRABOLD 205 #define FC_WEIGHT_ULTRABOLD FC_WEIGHT_EXTRABOLD #define FC_WEIGHT_BLACK 210 #define FC_WEIGHT_HEAVY FC_WEIGHT_BLACK #define FC_WEIGHT_EXTRABLACK 215 #define FC_WEIGHT_ULTRABLACK FC_WEIGHT_EXTRABLACK #define FC_SLANT_ROMAN 0 #define FC_SLANT_ITALIC 100 #define FC_SLANT_OBLIQUE 110 #define FC_WIDTH_ULTRACONDENSED 50 #define FC_WIDTH_EXTRACONDENSED 63 #define FC_WIDTH_CONDENSED 75 #define FC_WIDTH_SEMICONDENSED 87 #define FC_WIDTH_NORMAL 100 #define FC_WIDTH_SEMIEXPANDED 113 #define FC_WIDTH_EXPANDED 125 #define FC_WIDTH_EXTRAEXPANDED 150 #define FC_WIDTH_ULTRAEXPANDED 200 #define FC_PROPORTIONAL 0 #define FC_DUAL 90 #define FC_MONO 100 #define FC_CHARCELL 110 /* sub-pixel order */ #define FC_RGBA_UNKNOWN 0 #define FC_RGBA_RGB 1 #define FC_RGBA_BGR 2 #define FC_RGBA_VRGB 3 #define FC_RGBA_VBGR 4 #define FC_RGBA_NONE 5 /* hinting style */ #define FC_HINT_NONE 0 #define FC_HINT_SLIGHT 1 #define FC_HINT_MEDIUM 2 #define FC_HINT_FULL 3 /* LCD filter */ #define FC_LCD_NONE 0 #define FC_LCD_DEFAULT 1 #define FC_LCD_LIGHT 2 #define FC_LCD_LEGACY 3 typedef enum _FcType { FcTypeUnknown = -1, FcTypeVoid, FcTypeInteger, FcTypeDouble, FcTypeString, FcTypeBool, FcTypeMatrix, FcTypeCharSet, FcTypeFTFace, FcTypeLangSet, FcTypeRange } FcType; typedef struct _FcMatrix { double xx, xy, yx, yy; } FcMatrix; #define FcMatrixInit(m) ((m)->xx = (m)->yy = 1, \ (m)->xy = (m)->yx = 0) /* * A data structure to represent the available glyphs in a font. * This is represented as a sparse boolean btree. */ typedef struct _FcCharSet FcCharSet; typedef struct _FcObjectType { char *object; FcType type; } FcObjectType; typedef struct _FcConstant { const FcChar8 *name; const char *object; int value; } FcConstant; typedef enum _FcResult { FcResultMatch, FcResultNoMatch, FcResultTypeMismatch, FcResultNoId, FcResultOutOfMemory } FcResult; typedef enum _FcValueBinding { FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame, /* to make sure sizeof (FcValueBinding) == 4 even with -fshort-enums */ FcValueBindingEnd = INT_MAX } FcValueBinding; typedef struct _FcPattern FcPattern; typedef struct _FcPatternIter { void *dummy1; void *dummy2; } FcPatternIter; typedef struct _FcLangSet FcLangSet; typedef struct _FcRange FcRange; typedef struct _FcValue { FcType type; union { const FcChar8 *s; int i; FcBool b; double d; const FcMatrix *m; const FcCharSet *c; void *f; const FcLangSet *l; const FcRange *r; } u; } FcValue; typedef struct _FcFontSet { int nfont; int sfont; FcPattern **fonts; } FcFontSet; typedef struct _FcObjectSet { int nobject; int sobject; const char **objects; } FcObjectSet; typedef enum _FcMatchKind { FcMatchPattern, FcMatchFont, FcMatchScan, FcMatchKindEnd, FcMatchKindBegin = FcMatchPattern } FcMatchKind; typedef enum _FcLangResult { FcLangEqual = 0, FcLangDifferentCountry = 1, FcLangDifferentTerritory = 1, FcLangDifferentLang = 2 } FcLangResult; typedef enum _FcSetName { FcSetSystem = 0, FcSetApplication = 1 } FcSetName; typedef struct _FcConfigFileInfoIter { void *dummy1; void *dummy2; void *dummy3; } FcConfigFileInfoIter; typedef struct _FcAtomic FcAtomic; #if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */ #define _FCFUNCPROTOBEGIN extern "C" { /* do not leave open across includes */ #define _FCFUNCPROTOEND } #else #define _FCFUNCPROTOBEGIN #define _FCFUNCPROTOEND #endif typedef enum { FcEndianBig, FcEndianLittle } FcEndian; typedef struct _FcConfig FcConfig; typedef struct _FcGlobalCache FcFileCache; typedef struct _FcBlanks FcBlanks; typedef struct _FcStrList FcStrList; typedef struct _FcStrSet FcStrSet; typedef struct _FcCache FcCache; _FCFUNCPROTOBEGIN /* fcblanks.c */ FcPublic FcBlanks * FcBlanksCreate (void); FcPublic void FcBlanksDestroy (FcBlanks *b); FcPublic FcBool FcBlanksAdd (FcBlanks *b, FcChar32 ucs4); FcPublic FcBool FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4); /* fccache.c */ FcPublic const FcChar8 * FcCacheDir(const FcCache *c); FcPublic FcFontSet * FcCacheCopySet(const FcCache *c); FcPublic const FcChar8 * FcCacheSubdir (const FcCache *c, int i); FcPublic int FcCacheNumSubdir (const FcCache *c); FcPublic int FcCacheNumFont (const FcCache *c); FcPublic FcBool FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config); FcPublic FcBool FcDirCacheValid (const FcChar8 *cache_file); FcPublic FcBool FcDirCacheClean (const FcChar8 *cache_dir, FcBool verbose); FcPublic void FcCacheCreateTagFile (FcConfig *config); FcPublic FcBool FcDirCacheCreateUUID (FcChar8 *dir, FcBool force, FcConfig *config); FcPublic FcBool FcDirCacheDeleteUUID (const FcChar8 *dir, FcConfig *config); /* fccfg.c */ FcPublic FcChar8 * FcConfigHome (void); FcPublic FcBool FcConfigEnableHome (FcBool enable); FcPublic FcChar8 * FcConfigGetFilename (FcConfig *config, const FcChar8 *url); FcPublic FcChar8 * FcConfigFilename (const FcChar8 *url); FcPublic FcConfig * FcConfigCreate (void); FcPublic FcConfig * FcConfigReference (FcConfig *config); FcPublic void FcConfigDestroy (FcConfig *config); FcPublic FcBool FcConfigSetCurrent (FcConfig *config); FcPublic FcConfig * FcConfigGetCurrent (void); FcPublic FcBool FcConfigUptoDate (FcConfig *config); FcPublic FcBool FcConfigBuildFonts (FcConfig *config); FcPublic FcStrList * FcConfigGetFontDirs (FcConfig *config); FcPublic FcStrList * FcConfigGetConfigDirs (FcConfig *config); FcPublic FcStrList * FcConfigGetConfigFiles (FcConfig *config); FcPublic FcChar8 * FcConfigGetCache (FcConfig *config); FcPublic FcBlanks * FcConfigGetBlanks (FcConfig *config); FcPublic FcStrList * FcConfigGetCacheDirs (FcConfig *config); FcPublic int FcConfigGetRescanInterval (FcConfig *config); FcPublic FcBool FcConfigSetRescanInterval (FcConfig *config, int rescanInterval); FcPublic FcFontSet * FcConfigGetFonts (FcConfig *config, FcSetName set); FcPublic FcBool FcConfigAppFontAddFile (FcConfig *config, const FcChar8 *file); FcPublic FcBool FcConfigAppFontAddDir (FcConfig *config, const FcChar8 *dir); FcPublic void FcConfigAppFontClear (FcConfig *config); FcPublic FcBool FcConfigSubstituteWithPat (FcConfig *config, FcPattern *p, FcPattern *p_pat, FcMatchKind kind); FcPublic FcBool FcConfigSubstitute (FcConfig *config, FcPattern *p, FcMatchKind kind); FcPublic const FcChar8 * FcConfigGetSysRoot (const FcConfig *config); FcPublic void FcConfigSetSysRoot (FcConfig *config, const FcChar8 *sysroot); FcPublic void FcConfigFileInfoIterInit (FcConfig *config, FcConfigFileInfoIter *iter); FcPublic FcBool FcConfigFileInfoIterNext (FcConfig *config, FcConfigFileInfoIter *iter); FcPublic FcBool FcConfigFileInfoIterGet (FcConfig *config, FcConfigFileInfoIter *iter, FcChar8 **name, FcChar8 **description, FcBool *enabled); /* fccharset.c */ FcPublic FcCharSet* FcCharSetCreate (void); /* deprecated alias for FcCharSetCreate */ FcPublic FcCharSet * FcCharSetNew (void); FcPublic void FcCharSetDestroy (FcCharSet *fcs); FcPublic FcBool FcCharSetAddChar (FcCharSet *fcs, FcChar32 ucs4); FcPublic FcBool FcCharSetDelChar (FcCharSet *fcs, FcChar32 ucs4); FcPublic FcCharSet* FcCharSetCopy (FcCharSet *src); FcPublic FcBool FcCharSetEqual (const FcCharSet *a, const FcCharSet *b); FcPublic FcCharSet* FcCharSetIntersect (const FcCharSet *a, const FcCharSet *b); FcPublic FcCharSet* FcCharSetUnion (const FcCharSet *a, const FcCharSet *b); FcPublic FcCharSet* FcCharSetSubtract (const FcCharSet *a, const FcCharSet *b); FcPublic FcBool FcCharSetMerge (FcCharSet *a, const FcCharSet *b, FcBool *changed); FcPublic FcBool FcCharSetHasChar (const FcCharSet *fcs, FcChar32 ucs4); FcPublic FcChar32 FcCharSetCount (const FcCharSet *a); FcPublic FcChar32 FcCharSetIntersectCount (const FcCharSet *a, const FcCharSet *b); FcPublic FcChar32 FcCharSetSubtractCount (const FcCharSet *a, const FcCharSet *b); FcPublic FcBool FcCharSetIsSubset (const FcCharSet *a, const FcCharSet *b); #define FC_CHARSET_MAP_SIZE (256/32) #define FC_CHARSET_DONE ((FcChar32) -1) FcPublic FcChar32 FcCharSetFirstPage (const FcCharSet *a, FcChar32 map[FC_CHARSET_MAP_SIZE], FcChar32 *next); FcPublic FcChar32 FcCharSetNextPage (const FcCharSet *a, FcChar32 map[FC_CHARSET_MAP_SIZE], FcChar32 *next); /* * old coverage API, rather hard to use correctly */ FcPublic FcChar32 FcCharSetCoverage (const FcCharSet *a, FcChar32 page, FcChar32 *result); /* fcdbg.c */ FcPublic void FcValuePrint (const FcValue v); FcPublic void FcPatternPrint (const FcPattern *p); FcPublic void FcFontSetPrint (const FcFontSet *s); /* fcdefault.c */ FcPublic FcStrSet * FcGetDefaultLangs (void); FcPublic void FcDefaultSubstitute (FcPattern *pattern); /* fcdir.c */ FcPublic FcBool FcFileIsDir (const FcChar8 *file); FcPublic FcBool FcFileScan (FcFontSet *set, FcStrSet *dirs, FcFileCache *cache, FcBlanks *blanks, const FcChar8 *file, FcBool force); FcPublic FcBool FcDirScan (FcFontSet *set, FcStrSet *dirs, FcFileCache *cache, FcBlanks *blanks, const FcChar8 *dir, FcBool force); FcPublic FcBool FcDirSave (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir); FcPublic FcCache * FcDirCacheLoad (const FcChar8 *dir, FcConfig *config, FcChar8 **cache_file); FcPublic FcCache * FcDirCacheRescan (const FcChar8 *dir, FcConfig *config); FcPublic FcCache * FcDirCacheRead (const FcChar8 *dir, FcBool force, FcConfig *config); FcPublic FcCache * FcDirCacheLoadFile (const FcChar8 *cache_file, struct stat *file_stat); FcPublic void FcDirCacheUnload (FcCache *cache); /* fcfreetype.c */ FcPublic FcPattern * FcFreeTypeQuery (const FcChar8 *file, unsigned int id, FcBlanks *blanks, int *count); FcPublic unsigned int FcFreeTypeQueryAll(const FcChar8 *file, unsigned int id, FcBlanks *blanks, int *count, FcFontSet *set); /* fcfs.c */ FcPublic FcFontSet * FcFontSetCreate (void); FcPublic void FcFontSetDestroy (FcFontSet *s); FcPublic FcBool FcFontSetAdd (FcFontSet *s, FcPattern *font); /* fcinit.c */ FcPublic FcConfig * FcInitLoadConfig (void); FcPublic FcConfig * FcInitLoadConfigAndFonts (void); FcPublic FcBool FcInit (void); FcPublic void FcFini (void); FcPublic int FcGetVersion (void); FcPublic FcBool FcInitReinitialize (void); FcPublic FcBool FcInitBringUptoDate (void); /* fclang.c */ FcPublic FcStrSet * FcGetLangs (void); FcPublic FcChar8 * FcLangNormalize (const FcChar8 *lang); FcPublic const FcCharSet * FcLangGetCharSet (const FcChar8 *lang); FcPublic FcLangSet* FcLangSetCreate (void); FcPublic void FcLangSetDestroy (FcLangSet *ls); FcPublic FcLangSet* FcLangSetCopy (const FcLangSet *ls); FcPublic FcBool FcLangSetAdd (FcLangSet *ls, const FcChar8 *lang); FcPublic FcBool FcLangSetDel (FcLangSet *ls, const FcChar8 *lang); FcPublic FcLangResult FcLangSetHasLang (const FcLangSet *ls, const FcChar8 *lang); FcPublic FcLangResult FcLangSetCompare (const FcLangSet *lsa, const FcLangSet *lsb); FcPublic FcBool FcLangSetContains (const FcLangSet *lsa, const FcLangSet *lsb); FcPublic FcBool FcLangSetEqual (const FcLangSet *lsa, const FcLangSet *lsb); FcPublic FcChar32 FcLangSetHash (const FcLangSet *ls); FcPublic FcStrSet * FcLangSetGetLangs (const FcLangSet *ls); FcPublic FcLangSet * FcLangSetUnion (const FcLangSet *a, const FcLangSet *b); FcPublic FcLangSet * FcLangSetSubtract (const FcLangSet *a, const FcLangSet *b); /* fclist.c */ FcPublic FcObjectSet * FcObjectSetCreate (void); FcPublic FcBool FcObjectSetAdd (FcObjectSet *os, const char *object); FcPublic void FcObjectSetDestroy (FcObjectSet *os); FcPublic FcObjectSet * FcObjectSetVaBuild (const char *first, va_list va); FcPublic FcObjectSet * FcObjectSetBuild (const char *first, ...) FC_ATTRIBUTE_SENTINEL(0); FcPublic FcFontSet * FcFontSetList (FcConfig *config, FcFontSet **sets, int nsets, FcPattern *p, FcObjectSet *os); FcPublic FcFontSet * FcFontList (FcConfig *config, FcPattern *p, FcObjectSet *os); /* fcatomic.c */ FcPublic FcAtomic * FcAtomicCreate (const FcChar8 *file); FcPublic FcBool FcAtomicLock (FcAtomic *atomic); FcPublic FcChar8 * FcAtomicNewFile (FcAtomic *atomic); FcPublic FcChar8 * FcAtomicOrigFile (FcAtomic *atomic); FcPublic FcBool FcAtomicReplaceOrig (FcAtomic *atomic); FcPublic void FcAtomicDeleteNew (FcAtomic *atomic); FcPublic void FcAtomicUnlock (FcAtomic *atomic); FcPublic void FcAtomicDestroy (FcAtomic *atomic); /* fcmatch.c */ FcPublic FcPattern * FcFontSetMatch (FcConfig *config, FcFontSet **sets, int nsets, FcPattern *p, FcResult *result); FcPublic FcPattern * FcFontMatch (FcConfig *config, FcPattern *p, FcResult *result); FcPublic FcPattern * FcFontRenderPrepare (FcConfig *config, FcPattern *pat, FcPattern *font); FcPublic FcFontSet * FcFontSetSort (FcConfig *config, FcFontSet **sets, int nsets, FcPattern *p, FcBool trim, FcCharSet **csp, FcResult *result); FcPublic FcFontSet * FcFontSort (FcConfig *config, FcPattern *p, FcBool trim, FcCharSet **csp, FcResult *result); FcPublic void FcFontSetSortDestroy (FcFontSet *fs); /* fcmatrix.c */ FcPublic FcMatrix * FcMatrixCopy (const FcMatrix *mat); FcPublic FcBool FcMatrixEqual (const FcMatrix *mat1, const FcMatrix *mat2); FcPublic void FcMatrixMultiply (FcMatrix *result, const FcMatrix *a, const FcMatrix *b); FcPublic void FcMatrixRotate (FcMatrix *m, double c, double s); FcPublic void FcMatrixScale (FcMatrix *m, double sx, double sy); FcPublic void FcMatrixShear (FcMatrix *m, double sh, double sv); /* fcname.c */ /* Deprecated. Does nothing. Returns FcFalse. */ FcPublic FcBool FcNameRegisterObjectTypes (const FcObjectType *types, int ntype); /* Deprecated. Does nothing. Returns FcFalse. */ FcPublic FcBool FcNameUnregisterObjectTypes (const FcObjectType *types, int ntype); FcPublic const FcObjectType * FcNameGetObjectType (const char *object); /* Deprecated. Does nothing. Returns FcFalse. */ FcPublic FcBool FcNameRegisterConstants (const FcConstant *consts, int nconsts); /* Deprecated. Does nothing. Returns FcFalse. */ FcPublic FcBool FcNameUnregisterConstants (const FcConstant *consts, int nconsts); FcPublic const FcConstant * FcNameGetConstant (const FcChar8 *string); FcPublic FcBool FcNameConstant (const FcChar8 *string, int *result); FcPublic FcPattern * FcNameParse (const FcChar8 *name); FcPublic FcChar8 * FcNameUnparse (FcPattern *pat); /* fcpat.c */ FcPublic FcPattern * FcPatternCreate (void); FcPublic FcPattern * FcPatternDuplicate (const FcPattern *p); FcPublic void FcPatternReference (FcPattern *p); FcPublic FcPattern * FcPatternFilter (FcPattern *p, const FcObjectSet *os); FcPublic void FcValueDestroy (FcValue v); FcPublic FcBool FcValueEqual (FcValue va, FcValue vb); FcPublic FcValue FcValueSave (FcValue v); FcPublic void FcPatternDestroy (FcPattern *p); int FcPatternObjectCount (const FcPattern *pat); FcPublic FcBool FcPatternEqual (const FcPattern *pa, const FcPattern *pb); FcPublic FcBool FcPatternEqualSubset (const FcPattern *pa, const FcPattern *pb, const FcObjectSet *os); FcPublic FcChar32 FcPatternHash (const FcPattern *p); FcPublic FcBool FcPatternAdd (FcPattern *p, const char *object, FcValue value, FcBool append); FcPublic FcBool FcPatternAddWeak (FcPattern *p, const char *object, FcValue value, FcBool append); FcPublic FcResult FcPatternGet (const FcPattern *p, const char *object, int id, FcValue *v); FcPublic FcResult FcPatternGetWithBinding (const FcPattern *p, const char *object, int id, FcValue *v, FcValueBinding *b); FcPublic FcBool FcPatternDel (FcPattern *p, const char *object); FcPublic FcBool FcPatternRemove (FcPattern *p, const char *object, int id); FcPublic FcBool FcPatternAddInteger (FcPattern *p, const char *object, int i); FcPublic FcBool FcPatternAddDouble (FcPattern *p, const char *object, double d); FcPublic FcBool FcPatternAddString (FcPattern *p, const char *object, const FcChar8 *s); FcPublic FcBool FcPatternAddMatrix (FcPattern *p, const char *object, const FcMatrix *s); FcPublic FcBool FcPatternAddCharSet (FcPattern *p, const char *object, const FcCharSet *c); FcPublic FcBool FcPatternAddBool (FcPattern *p, const char *object, FcBool b); FcPublic FcBool FcPatternAddLangSet (FcPattern *p, const char *object, const FcLangSet *ls); FcPublic FcBool FcPatternAddRange (FcPattern *p, const char *object, const FcRange *r); FcPublic FcResult FcPatternGetInteger (const FcPattern *p, const char *object, int n, int *i); FcPublic FcResult FcPatternGetDouble (const FcPattern *p, const char *object, int n, double *d); FcPublic FcResult FcPatternGetString (const FcPattern *p, const char *object, int n, FcChar8 ** s); FcPublic FcResult FcPatternGetMatrix (const FcPattern *p, const char *object, int n, FcMatrix **s); FcPublic FcResult FcPatternGetCharSet (const FcPattern *p, const char *object, int n, FcCharSet **c); FcPublic FcResult FcPatternGetBool (const FcPattern *p, const char *object, int n, FcBool *b); FcPublic FcResult FcPatternGetLangSet (const FcPattern *p, const char *object, int n, FcLangSet **ls); FcPublic FcResult FcPatternGetRange (const FcPattern *p, const char *object, int id, FcRange **r); FcPublic FcPattern * FcPatternVaBuild (FcPattern *p, va_list va); FcPublic FcPattern * FcPatternBuild (FcPattern *p, ...) FC_ATTRIBUTE_SENTINEL(0); FcPublic FcChar8 * FcPatternFormat (FcPattern *pat, const FcChar8 *format); /* fcrange.c */ FcPublic FcRange * FcRangeCreateDouble (double begin, double end); FcPublic FcRange * FcRangeCreateInteger (FcChar32 begin, FcChar32 end); FcPublic void FcRangeDestroy (FcRange *range); FcPublic FcRange * FcRangeCopy (const FcRange *r); FcPublic FcBool FcRangeGetDouble(const FcRange *range, double *begin, double *end); FcPublic void FcPatternIterStart (const FcPattern *pat, FcPatternIter *iter); FcPublic FcBool FcPatternIterNext (const FcPattern *pat, FcPatternIter *iter); FcPublic FcBool FcPatternIterEqual (const FcPattern *p1, FcPatternIter *i1, const FcPattern *p2, FcPatternIter *i2); FcPublic FcBool FcPatternFindIter (const FcPattern *pat, FcPatternIter *iter, const char *object); FcPublic FcBool FcPatternIterIsValid (const FcPattern *pat, FcPatternIter *iter); FcPublic const char * FcPatternIterGetObject (const FcPattern *pat, FcPatternIter *iter); FcPublic int FcPatternIterValueCount (const FcPattern *pat, FcPatternIter *iter); FcPublic FcResult FcPatternIterGetValue (const FcPattern *pat, FcPatternIter *iter, int id, FcValue *v, FcValueBinding *b); /* fcweight.c */ FcPublic int FcWeightFromOpenType (int ot_weight); FcPublic double FcWeightFromOpenTypeDouble (double ot_weight); FcPublic int FcWeightToOpenType (int fc_weight); FcPublic double FcWeightToOpenTypeDouble (double fc_weight); /* fcstr.c */ FcPublic FcChar8 * FcStrCopy (const FcChar8 *s); FcPublic FcChar8 * FcStrCopyFilename (const FcChar8 *s); FcPublic FcChar8 * FcStrPlus (const FcChar8 *s1, const FcChar8 *s2); FcPublic void FcStrFree (FcChar8 *s); /* These are ASCII only, suitable only for pattern element names */ #define FcIsUpper(c) ((0101 <= (c) && (c) <= 0132)) #define FcIsLower(c) ((0141 <= (c) && (c) <= 0172)) #define FcToLower(c) (FcIsUpper(c) ? (c) - 0101 + 0141 : (c)) FcPublic FcChar8 * FcStrDowncase (const FcChar8 *s); FcPublic int FcStrCmpIgnoreCase (const FcChar8 *s1, const FcChar8 *s2); FcPublic int FcStrCmp (const FcChar8 *s1, const FcChar8 *s2); FcPublic const FcChar8 * FcStrStrIgnoreCase (const FcChar8 *s1, const FcChar8 *s2); FcPublic const FcChar8 * FcStrStr (const FcChar8 *s1, const FcChar8 *s2); FcPublic int FcUtf8ToUcs4 (const FcChar8 *src_orig, FcChar32 *dst, int len); FcPublic FcBool FcUtf8Len (const FcChar8 *string, int len, int *nchar, int *wchar); #define FC_UTF8_MAX_LEN 6 FcPublic int FcUcs4ToUtf8 (FcChar32 ucs4, FcChar8 dest[FC_UTF8_MAX_LEN]); FcPublic int FcUtf16ToUcs4 (const FcChar8 *src_orig, FcEndian endian, FcChar32 *dst, int len); /* in bytes */ FcPublic FcBool FcUtf16Len (const FcChar8 *string, FcEndian endian, int len, /* in bytes */ int *nchar, int *wchar); FcPublic FcChar8 * FcStrBuildFilename (const FcChar8 *path, ...); FcPublic FcChar8 * FcStrDirname (const FcChar8 *file); FcPublic FcChar8 * FcStrBasename (const FcChar8 *file); FcPublic FcStrSet * FcStrSetCreate (void); FcPublic FcBool FcStrSetMember (FcStrSet *set, const FcChar8 *s); FcPublic FcBool FcStrSetEqual (FcStrSet *sa, FcStrSet *sb); FcPublic FcBool FcStrSetAdd (FcStrSet *set, const FcChar8 *s); FcPublic FcBool FcStrSetAddFilename (FcStrSet *set, const FcChar8 *s); FcPublic FcBool FcStrSetDel (FcStrSet *set, const FcChar8 *s); FcPublic void FcStrSetDestroy (FcStrSet *set); FcPublic FcStrList * FcStrListCreate (FcStrSet *set); FcPublic void FcStrListFirst (FcStrList *list); FcPublic FcChar8 * FcStrListNext (FcStrList *list); FcPublic void FcStrListDone (FcStrList *list); /* fcxml.c */ FcPublic FcBool FcConfigParseAndLoad (FcConfig *config, const FcChar8 *file, FcBool complain); FcPublic FcBool FcConfigParseAndLoadFromMemory (FcConfig *config, const FcChar8 *buffer, FcBool complain); _FCFUNCPROTOEND #undef FC_ATTRIBUTE_SENTINEL #ifndef _FCINT_H_ /* * Deprecated functions are placed here to help users fix their code without * digging through documentation */ #define FcConfigGetRescanInverval FcConfigGetRescanInverval_REPLACE_BY_FcConfigGetRescanInterval #define FcConfigSetRescanInverval FcConfigSetRescanInverval_REPLACE_BY_FcConfigSetRescanInterval #endif #endif /* _FONTCONFIG_H_ */ // Stream buffer classes -*- C++ -*- // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/streambuf * This is a Standard C++ Library header. */ // // ISO C++ 14882: 27.5 Stream buffers // #ifndef _GLIBXX_STREAMBUF #define _GLIBXX_STREAMBUF 1 #pragma GCC system_header #include <bits/c++config.h> #include <iosfwd> #include <bits/localefwd.h> #include <bits/ios_base.h> #include <bits/cpp_type_traits.h> #include <ext/type_traits.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION #define _IsUnused __attribute__ ((__unused__)) template<typename _CharT, typename _Traits> streamsize __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*, basic_streambuf<_CharT, _Traits>*, bool&); /** * @brief The actual work of input and output (interface). * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * * This is a base class. Derived stream buffers each control a * pair of character sequences: one for input, and one for output. * * Section [27.5.1] of the standard describes the requirements and * behavior of stream buffer classes. That section (three paragraphs) * is reproduced here, for simplicity and accuracy. * * -# Stream buffers can impose various constraints on the sequences * they control. Some constraints are: * - The controlled input sequence can be not readable. * - The controlled output sequence can be not writable. * - The controlled sequences can be associated with the contents of * other representations for character sequences, such as external * files. * - The controlled sequences can support operations @e directly to or * from associated sequences. * - The controlled sequences can impose limitations on how the * program can read characters from a sequence, write characters to * a sequence, put characters back into an input sequence, or alter * the stream position. * . * -# Each sequence is characterized by three pointers which, if non-null, * all point into the same @c charT array object. The array object * represents, at any moment, a (sub)sequence of characters from the * sequence. Operations performed on a sequence alter the values * stored in these pointers, perform reads and writes directly to or * from associated sequences, and alter <em>the stream position</em> and * conversion state as needed to maintain this subsequence relationship. * The three pointers are: * - the <em>beginning pointer</em>, or lowest element address in the * array (called @e xbeg here); * - the <em>next pointer</em>, or next element address that is a * current candidate for reading or writing (called @e xnext here); * - the <em>end pointer</em>, or first element address beyond the * end of the array (called @e xend here). * . * -# The following semantic constraints shall always apply for any set * of three pointers for a sequence, using the pointer names given * immediately above: * - If @e xnext is not a null pointer, then @e xbeg and @e xend shall * also be non-null pointers into the same @c charT array, as * described above; otherwise, @e xbeg and @e xend shall also be null. * - If @e xnext is not a null pointer and @e xnext < @e xend for an * output sequence, then a <em>write position</em> is available. * In this case, @e *xnext shall be assignable as the next element * to write (to put, or to store a character value, into the sequence). * - If @e xnext is not a null pointer and @e xbeg < @e xnext for an * input sequence, then a <em>putback position</em> is available. * In this case, @e xnext[-1] shall have a defined value and is the * next (preceding) element to store a character that is put back * into the input sequence. * - If @e xnext is not a null pointer and @e xnext< @e xend for an * input sequence, then a <em>read position</em> is available. * In this case, @e *xnext shall have a defined value and is the * next element to read (to get, or to obtain a character value, * from the sequence). */ template<typename _CharT, typename _Traits> class basic_streambuf { public: ///@{ /** * These are standard types. They permit a standardized way of * referring to names of (or names dependent on) the template * parameters, which are specific to the implementation. */ typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; ///@} ///@{ /// This is a non-standard type. typedef basic_streambuf<char_type, traits_type> __streambuf_type; ///@} friend class basic_ios<char_type, traits_type>; friend class basic_istream<char_type, traits_type>; friend class basic_ostream<char_type, traits_type>; friend class istreambuf_iterator<char_type, traits_type>; friend class ostreambuf_iterator<char_type, traits_type>; friend streamsize __copy_streambufs_eof<>(basic_streambuf*, basic_streambuf*, bool&); template<bool _IsMove, typename _CharT2> friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, _CharT2*>::__type __copy_move_a2(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, _CharT2*); template<typename _CharT2> friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, istreambuf_iterator<_CharT2> >::__type find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, const _CharT2&); template<typename _CharT2, typename _Distance> friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value, void>::__type advance(istreambuf_iterator<_CharT2>&, _Distance); friend void __istream_extract(istream&, char*, streamsize); template<typename _CharT2, typename _Traits2, typename _Alloc> friend basic_istream<_CharT2, _Traits2>& operator>>(basic_istream<_CharT2, _Traits2>&, basic_string<_CharT2, _Traits2, _Alloc>&); template<typename _CharT2, typename _Traits2, typename _Alloc> friend basic_istream<_CharT2, _Traits2>& getline(basic_istream<_CharT2, _Traits2>&, basic_string<_CharT2, _Traits2, _Alloc>&, _CharT2); protected: /* * This is based on _IO_FILE, just reordered to be more consistent, * and is intended to be the most minimal abstraction for an * internal buffer. * - get == input == read * - put == output == write */ char_type* _M_in_beg; ///< Start of get area. char_type* _M_in_cur; ///< Current read area. char_type* _M_in_end; ///< End of get area. char_type* _M_out_beg; ///< Start of put area. char_type* _M_out_cur; ///< Current put area. char_type* _M_out_end; ///< End of put area. /// Current locale setting. locale _M_buf_locale; public: /// Destructor deallocates no buffer space. virtual ~basic_streambuf() { } // [27.5.2.2.1] locales /** * @brief Entry point for imbue(). * @param __loc The new locale. * @return The previous locale. * * Calls the derived imbue(__loc). */ locale pubimbue(const locale& __loc) { locale __tmp(this->getloc()); this->imbue(__loc); _M_buf_locale = __loc; return __tmp; } /** * @brief Locale access. * @return The current locale in effect. * * If pubimbue(loc) has been called, then the most recent @c loc * is returned. Otherwise the global locale in effect at the time * of construction is returned. */ locale getloc() const { return _M_buf_locale; } // [27.5.2.2.2] buffer management and positioning ///@{ /** * @brief Entry points for derived buffer functions. * * The public versions of @c pubfoo dispatch to the protected * derived @c foo member functions, passing the arguments (if any) * and returning the result unchanged. */ basic_streambuf* pubsetbuf(char_type* __s, streamsize __n) { return this->setbuf(__s, __n); } /** * @brief Alters the stream position. * @param __off Offset. * @param __way Value for ios_base::seekdir. * @param __mode Value for ios_base::openmode. * * Calls virtual seekoff function. */ pos_type pubseekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode = ios_base::in | ios_base::out) { return this->seekoff(__off, __way, __mode); } /** * @brief Alters the stream position. * @param __sp Position * @param __mode Value for ios_base::openmode. * * Calls virtual seekpos function. */ pos_type pubseekpos(pos_type __sp, ios_base::openmode __mode = ios_base::in | ios_base::out) { return this->seekpos(__sp, __mode); } /** * @brief Calls virtual sync function. */ int pubsync() { return this->sync(); } ///@} // [27.5.2.2.3] get area /** * @brief Looking ahead into the stream. * @return The number of characters available. * * If a read position is available, returns the number of characters * available for reading before the buffer must be refilled. * Otherwise returns the derived @c showmanyc(). */ streamsize in_avail() { const streamsize __ret = this->egptr() - this->gptr(); return __ret ? __ret : this->showmanyc(); } /** * @brief Getting the next character. * @return The next character, or eof. * * Calls @c sbumpc(), and if that function returns * @c traits::eof(), so does this function. Otherwise, @c sgetc(). */ int_type snextc() { int_type __ret = traits_type::eof(); if (__builtin_expect(!traits_type::eq_int_type(this->sbumpc(), __ret), true)) __ret = this->sgetc(); return __ret; } /** * @brief Getting the next character. * @return The next character, or eof. * * If the input read position is available, returns that character * and increments the read pointer, otherwise calls and returns * @c uflow(). */ int_type sbumpc() { int_type __ret; if (__builtin_expect(this->gptr() < this->egptr(), true)) { __ret = traits_type::to_int_type(*this->gptr()); this->gbump(1); } else __ret = this->uflow(); return __ret; } /** * @brief Getting the next character. * @return The next character, or eof. * * If the input read position is available, returns that character, * otherwise calls and returns @c underflow(). Does not move the * read position after fetching the character. */ int_type sgetc() { int_type __ret; if (__builtin_expect(this->gptr() < this->egptr(), true)) __ret = traits_type::to_int_type(*this->gptr()); else __ret = this->underflow(); return __ret; } /** * @brief Entry point for xsgetn. * @param __s A buffer area. * @param __n A count. * * Returns xsgetn(__s,__n). The effect is to fill @a __s[0] through * @a __s[__n-1] with characters from the input sequence, if possible. */ streamsize sgetn(char_type* __s, streamsize __n) { return this->xsgetn(__s, __n); } // [27.5.2.2.4] putback /** * @brief Pushing characters back into the input stream. * @param __c The character to push back. * @return The previous character, if possible. * * Similar to sungetc(), but @a __c is pushed onto the stream * instead of <em>the previous character.</em> If successful, * the next character fetched from the input stream will be @a * __c. */ int_type sputbackc(char_type __c) { int_type __ret; const bool __testpos = this->eback() < this->gptr(); if (__builtin_expect(!__testpos || !traits_type::eq(__c, this->gptr()[-1]), false)) __ret = this->pbackfail(traits_type::to_int_type(__c)); else { this->gbump(-1); __ret = traits_type::to_int_type(*this->gptr()); } return __ret; } /** * @brief Moving backwards in the input stream. * @return The previous character, if possible. * * If a putback position is available, this function decrements * the input pointer and returns that character. Otherwise, * calls and returns pbackfail(). The effect is to @a unget * the last character @a gotten. */ int_type sungetc() { int_type __ret; if (__builtin_expect(this->eback() < this->gptr(), true)) { this->gbump(-1); __ret = traits_type::to_int_type(*this->gptr()); } else __ret = this->pbackfail(); return __ret; } // [27.5.2.2.5] put area /** * @brief Entry point for all single-character output functions. * @param __c A character to output. * @return @a __c, if possible. * * One of two public output functions. * * If a write position is available for the output sequence (i.e., * the buffer is not full), stores @a __c in that position, increments * the position, and returns @c traits::to_int_type(__c). If a write * position is not available, returns @c overflow(__c). */ int_type sputc(char_type __c) { int_type __ret; if (__builtin_expect(this->pptr() < this->epptr(), true)) { *this->pptr() = __c; this->pbump(1); __ret = traits_type::to_int_type(__c); } else __ret = this->overflow(traits_type::to_int_type(__c)); return __ret; } /** * @brief Entry point for all single-character output functions. * @param __s A buffer read area. * @param __n A count. * * One of two public output functions. * * * Returns xsputn(__s,__n). The effect is to write @a __s[0] through * @a __s[__n-1] to the output sequence, if possible. */ streamsize sputn(const char_type* __s, streamsize __n) { return this->xsputn(__s, __n); } protected: /** * @brief Base constructor. * * Only called from derived constructors, and sets up all the * buffer data to zero, including the pointers described in the * basic_streambuf class description. Note that, as a result, * - the class starts with no read nor write positions available, * - this is not an error */ basic_streambuf() : _M_in_beg(0), _M_in_cur(0), _M_in_end(0), _M_out_beg(0), _M_out_cur(0), _M_out_end(0), _M_buf_locale(locale()) { } // [27.5.2.3.1] get area access ///@{ /** * @brief Access to the get area. * * These functions are only available to other protected functions, * including derived classes. * * - eback() returns the beginning pointer for the input sequence * - gptr() returns the next pointer for the input sequence * - egptr() returns the end pointer for the input sequence */ char_type* eback() const { return _M_in_beg; } char_type* gptr() const { return _M_in_cur; } char_type* egptr() const { return _M_in_end; } ///@} /** * @brief Moving the read position. * @param __n The delta by which to move. * * This just advances the read position without returning any data. */ void gbump(int __n) { _M_in_cur += __n; } /** * @brief Setting the three read area pointers. * @param __gbeg A pointer. * @param __gnext A pointer. * @param __gend A pointer. * @post @a __gbeg == @c eback(), @a __gnext == @c gptr(), and * @a __gend == @c egptr() */ void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) { _M_in_beg = __gbeg; _M_in_cur = __gnext; _M_in_end = __gend; } // [27.5.2.3.2] put area access ///@{ /** * @brief Access to the put area. * * These functions are only available to other protected functions, * including derived classes. * * - pbase() returns the beginning pointer for the output sequence * - pptr() returns the next pointer for the output sequence * - epptr() returns the end pointer for the output sequence */ char_type* pbase() const { return _M_out_beg; } char_type* pptr() const { return _M_out_cur; } char_type* epptr() const { return _M_out_end; } ///@} /** * @brief Moving the write position. * @param __n The delta by which to move. * * This just advances the write position without returning any data. */ void pbump(int __n) { _M_out_cur += __n; } /** * @brief Setting the three write area pointers. * @param __pbeg A pointer. * @param __pend A pointer. * @post @a __pbeg == @c pbase(), @a __pbeg == @c pptr(), and * @a __pend == @c epptr() */ void setp(char_type* __pbeg, char_type* __pend) { _M_out_beg = _M_out_cur = __pbeg; _M_out_end = __pend; } // [27.5.2.4] virtual functions // [27.5.2.4.1] locales /** * @brief Changes translations. * @param __loc A new locale. * * Translations done during I/O which depend on the current * locale are changed by this call. The standard adds, * <em>Between invocations of this function a class derived * from streambuf can safely cache results of calls to locale * functions and to members of facets so obtained.</em> * * @note Base class version does nothing. */ virtual void imbue(const locale& __loc _IsUnused) { } // [27.5.2.4.2] buffer management and positioning /** * @brief Manipulates the buffer. * * Each derived class provides its own appropriate behavior. See * the next-to-last paragraph of * https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering * for more on this function. * * @note Base class version does nothing, returns @c this. */ virtual basic_streambuf<char_type,_Traits>* setbuf(char_type*, streamsize) { return this; } /** * @brief Alters the stream positions. * * Each derived class provides its own appropriate behavior. * @note Base class version does nothing, returns a @c pos_type * that represents an invalid stream position. */ virtual pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out) { return pos_type(off_type(-1)); } /** * @brief Alters the stream positions. * * Each derived class provides its own appropriate behavior. * @note Base class version does nothing, returns a @c pos_type * that represents an invalid stream position. */ virtual pos_type seekpos(pos_type, ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out) { return pos_type(off_type(-1)); } /** * @brief Synchronizes the buffer arrays with the controlled sequences. * @return -1 on failure. * * Each derived class provides its own appropriate behavior, * including the definition of @a failure. * @note Base class version does nothing, returns zero. */ virtual int sync() { return 0; } // [27.5.2.4.3] get area /** * @brief Investigating the data available. * @return An estimate of the number of characters available in the * input sequence, or -1. * * <em>If it returns a positive value, then successive calls to * @c underflow() will not return @c traits::eof() until at * least that number of characters have been supplied. If @c * showmanyc() returns -1, then calls to @c underflow() or @c * uflow() will fail.</em> [27.5.2.4.3]/1 * * @note Base class version does nothing, returns zero. * @note The standard adds that <em>the intention is not only that the * calls [to underflow or uflow] will not return @c eof() but * that they will return immediately.</em> * @note The standard adds that <em>the morphemes of @c showmanyc are * @b es-how-many-see, not @b show-manic.</em> */ virtual streamsize showmanyc() { return 0; } /** * @brief Multiple character extraction. * @param __s A buffer area. * @param __n Maximum number of characters to assign. * @return The number of characters assigned. * * Fills @a __s[0] through @a __s[__n-1] with characters from the input * sequence, as if by @c sbumpc(). Stops when either @a __n characters * have been copied, or when @c traits::eof() would be copied. * * It is expected that derived classes provide a more efficient * implementation by overriding this definition. */ virtual streamsize xsgetn(char_type* __s, streamsize __n); /** * @brief Fetches more data from the controlled sequence. * @return The first character from the <em>pending sequence</em>. * * Informally, this function is called when the input buffer is * exhausted (or does not exist, as buffering need not actually be * done). If a buffer exists, it is @a refilled. In either case, the * next available character is returned, or @c traits::eof() to * indicate a null pending sequence. * * For a formal definition of the pending sequence, see a good text * such as Langer & Kreft, or [27.5.2.4.3]/7-14. * * A functioning input streambuf can be created by overriding only * this function (no buffer area will be used). For an example, see * https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html * * @note Base class version does nothing, returns eof(). */ virtual int_type underflow() { return traits_type::eof(); } /** * @brief Fetches more data from the controlled sequence. * @return The first character from the <em>pending sequence</em>. * * Informally, this function does the same thing as @c underflow(), * and in fact is required to call that function. It also returns * the new character, like @c underflow() does. However, this * function also moves the read position forward by one. */ virtual int_type uflow() { int_type __ret = traits_type::eof(); const bool __testeof = traits_type::eq_int_type(this->underflow(), __ret); if (!__testeof) { __ret = traits_type::to_int_type(*this->gptr()); this->gbump(1); } return __ret; } // [27.5.2.4.4] putback /** * @brief Tries to back up the input sequence. * @param __c The character to be inserted back into the sequence. * @return eof() on failure, <em>some other value</em> on success * @post The constraints of @c gptr(), @c eback(), and @c pptr() * are the same as for @c underflow(). * * @note Base class version does nothing, returns eof(). */ virtual int_type pbackfail(int_type __c _IsUnused = traits_type::eof()) { return traits_type::eof(); } // Put area: /** * @brief Multiple character insertion. * @param __s A buffer area. * @param __n Maximum number of characters to write. * @return The number of characters written. * * Writes @a __s[0] through @a __s[__n-1] to the output sequence, as if * by @c sputc(). Stops when either @a n characters have been * copied, or when @c sputc() would return @c traits::eof(). * * It is expected that derived classes provide a more efficient * implementation by overriding this definition. */ virtual streamsize xsputn(const char_type* __s, streamsize __n); /** * @brief Consumes data from the buffer; writes to the * controlled sequence. * @param __c An additional character to consume. * @return eof() to indicate failure, something else (usually * @a __c, or not_eof()) * * Informally, this function is called when the output buffer * is full (or does not exist, as buffering need not actually * be done). If a buffer exists, it is @a consumed, with * <em>some effect</em> on the controlled sequence. * (Typically, the buffer is written out to the sequence * verbatim.) In either case, the character @a c is also * written out, if @a __c is not @c eof(). * * For a formal definition of this function, see a good text * such as Langer & Kreft, or [27.5.2.4.5]/3-7. * * A functioning output streambuf can be created by overriding only * this function (no buffer area will be used). * * @note Base class version does nothing, returns eof(). */ virtual int_type overflow(int_type __c _IsUnused = traits_type::eof()) { return traits_type::eof(); } #if _GLIBCXX_USE_DEPRECATED && __cplusplus <= 201402L // Annex D.6 (removed in C++17) public: /** * @brief Tosses a character. * * Advances the read pointer, ignoring the character that would have * been read. * * See http://gcc.gnu.org/ml/libstdc++/2002-05/msg00168.html */ _GLIBCXX_DEPRECATED_SUGGEST("std::basic_streambuf::sbumpc") void stossc() { if (this->gptr() < this->egptr()) this->gbump(1); else this->uflow(); } #endif // Also used by specializations for char and wchar_t in src. void __safe_gbump(streamsize __n) { _M_in_cur += __n; } void __safe_pbump(streamsize __n) { _M_out_cur += __n; } #if __cplusplus < 201103L private: #else protected: #endif basic_streambuf(const basic_streambuf&); basic_streambuf& operator=(const basic_streambuf&); #if __cplusplus >= 201103L void swap(basic_streambuf& __sb) { std::swap(_M_in_beg, __sb._M_in_beg); std::swap(_M_in_cur, __sb._M_in_cur); std::swap(_M_in_end, __sb._M_in_end); std::swap(_M_out_beg, __sb._M_out_beg); std::swap(_M_out_cur, __sb._M_out_cur); std::swap(_M_out_end, __sb._M_out_end); std::swap(_M_buf_locale, __sb._M_buf_locale); } #endif }; #if __cplusplus >= 201103L template<typename _CharT, typename _Traits> std::basic_streambuf<_CharT, _Traits>:: basic_streambuf(const basic_streambuf&) = default; template<typename _CharT, typename _Traits> std::basic_streambuf<_CharT, _Traits>& std::basic_streambuf<_CharT, _Traits>:: operator=(const basic_streambuf&) = default; #endif // Explicit specialization declarations, defined in src/streambuf.cc. template<> streamsize __copy_streambufs_eof(basic_streambuf<char>* __sbin, basic_streambuf<char>* __sbout, bool& __ineof); #ifdef _GLIBCXX_USE_WCHAR_T template<> streamsize __copy_streambufs_eof(basic_streambuf<wchar_t>* __sbin, basic_streambuf<wchar_t>* __sbout, bool& __ineof); #endif #undef _IsUnused _GLIBCXX_END_NAMESPACE_VERSION } // namespace #include <bits/streambuf.tcc> #endif /* _GLIBCXX_STREAMBUF */ // C++11 <type_traits> -*- C++ -*- // Copyright (C) 2007-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/type_traits * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_TYPE_TRAITS #define _GLIBCXX_TYPE_TRAITS 1 #pragma GCC system_header #if __cplusplus < 201103L # include <bits/c++0x_warning.h> #else #include <bits/c++config.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename... _Elements> class tuple; template<typename _Tp> class reference_wrapper; /** * @defgroup metaprogramming Metaprogramming * @ingroup utilities * * Template utilities for compile-time introspection and modification, * including type classification traits, type property inspection traits * and type transformation traits. * * @since C++11 * * @{ */ /// integral_constant template<typename _Tp, _Tp __v> struct integral_constant { static constexpr _Tp value = __v; typedef _Tp value_type; typedef integral_constant<_Tp, __v> type; constexpr operator value_type() const noexcept { return value; } #if __cplusplus > 201103L #define __cpp_lib_integral_constant_callable 201304 constexpr value_type operator()() const noexcept { return value; } #endif }; template<typename _Tp, _Tp __v> constexpr _Tp integral_constant<_Tp, __v>::value; /// The type used as a compile-time boolean with true value. using true_type = integral_constant<bool, true>; /// The type used as a compile-time boolean with false value. using false_type = integral_constant<bool, false>; /// @cond undocumented /// bool_constant for C++11 template<bool __v> using __bool_constant = integral_constant<bool, __v>; /// @endcond #if __cplusplus >= 201703L # define __cpp_lib_bool_constant 201505 /// Alias template for compile-time boolean constant types. /// @since C++17 template<bool __v> using bool_constant = integral_constant<bool, __v>; #endif // Metaprogramming helper types. template<bool, typename, typename> struct conditional; /// @cond undocumented template <typename _Type> struct __type_identity { using type = _Type; }; template<typename _Tp> using __type_identity_t = typename __type_identity<_Tp>::type; template<typename...> struct __or_; template<> struct __or_<> : public false_type { }; template<typename _B1> struct __or_<_B1> : public _B1 { }; template<typename _B1, typename _B2> struct __or_<_B1, _B2> : public conditional<_B1::value, _B1, _B2>::type { }; template<typename _B1, typename _B2, typename _B3, typename... _Bn> struct __or_<_B1, _B2, _B3, _Bn...> : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type { }; template<typename...> struct __and_; template<> struct __and_<> : public true_type { }; template<typename _B1> struct __and_<_B1> : public _B1 { }; template<typename _B1, typename _B2> struct __and_<_B1, _B2> : public conditional<_B1::value, _B2, _B1>::type { }; template<typename _B1, typename _B2, typename _B3, typename... _Bn> struct __and_<_B1, _B2, _B3, _Bn...> : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type { }; template<typename _Pp> struct __not_ : public __bool_constant<!bool(_Pp::value)> { }; /// @endcond #if __cplusplus >= 201703L /// @cond undocumented template<typename... _Bn> inline constexpr bool __or_v = __or_<_Bn...>::value; template<typename... _Bn> inline constexpr bool __and_v = __and_<_Bn...>::value; /// @endcond #define __cpp_lib_logical_traits 201510 template<typename... _Bn> struct conjunction : __and_<_Bn...> { }; template<typename... _Bn> struct disjunction : __or_<_Bn...> { }; template<typename _Pp> struct negation : __not_<_Pp> { }; /** @ingroup variable_templates * @{ */ template<typename... _Bn> inline constexpr bool conjunction_v = conjunction<_Bn...>::value; template<typename... _Bn> inline constexpr bool disjunction_v = disjunction<_Bn...>::value; template<typename _Pp> inline constexpr bool negation_v = negation<_Pp>::value; /// @} #endif // C++17 // Forward declarations template<typename> struct is_reference; template<typename> struct is_function; template<typename> struct is_void; template<typename> struct remove_cv; template<typename> struct is_const; /// @cond undocumented template<typename> struct __is_array_unknown_bounds; // Helper functions that return false_type for incomplete classes, // incomplete unions and arrays of known bound from those. template <typename _Tp, size_t = sizeof(_Tp)> constexpr true_type __is_complete_or_unbounded(__type_identity<_Tp>) { return {}; } template <typename _TypeIdentity, typename _NestedType = typename _TypeIdentity::type> constexpr typename __or_< is_reference<_NestedType>, is_function<_NestedType>, is_void<_NestedType>, __is_array_unknown_bounds<_NestedType> >::type __is_complete_or_unbounded(_TypeIdentity) { return {}; } // For several sfinae-friendly trait implementations we transport both the // result information (as the member type) and the failure information (no // member type). This is very similar to std::enable_if, but we cannot use // them, because we need to derive from them as an implementation detail. template<typename _Tp> struct __success_type { typedef _Tp type; }; struct __failure_type { }; // __remove_cv_t (std::remove_cv_t for C++11). template<typename _Tp> using __remove_cv_t = typename remove_cv<_Tp>::type; // Primary type categories. template<typename> struct __is_void_helper : public false_type { }; template<> struct __is_void_helper<void> : public true_type { }; /// @endcond /// is_void template<typename _Tp> struct is_void : public __is_void_helper<__remove_cv_t<_Tp>>::type { }; /// @cond undocumented template<typename> struct __is_integral_helper : public false_type { }; template<> struct __is_integral_helper<bool> : public true_type { }; template<> struct __is_integral_helper<char> : public true_type { }; template<> struct __is_integral_helper<signed char> : public true_type { }; template<> struct __is_integral_helper<unsigned char> : public true_type { }; // We want is_integral<wchar_t> to be true (and make_signed/unsigned to work) // even when libc doesn't provide working <wchar.h> and related functions, // so check __WCHAR_TYPE__ instead of _GLIBCXX_USE_WCHAR_T. #ifdef __WCHAR_TYPE__ template<> struct __is_integral_helper<wchar_t> : public true_type { }; #endif #ifdef _GLIBCXX_USE_CHAR8_T template<> struct __is_integral_helper<char8_t> : public true_type { }; #endif template<> struct __is_integral_helper<char16_t> : public true_type { }; template<> struct __is_integral_helper<char32_t> : public true_type { }; template<> struct __is_integral_helper<short> : public true_type { }; template<> struct __is_integral_helper<unsigned short> : public true_type { }; template<> struct __is_integral_helper<int> : public true_type { }; template<> struct __is_integral_helper<unsigned int> : public true_type { }; template<> struct __is_integral_helper<long> : public true_type { }; template<> struct __is_integral_helper<unsigned long> : public true_type { }; template<> struct __is_integral_helper<long long> : public true_type { }; template<> struct __is_integral_helper<unsigned long long> : public true_type { }; // Conditionalizing on __STRICT_ANSI__ here will break any port that // uses one of these types for size_t. #if defined(__GLIBCXX_TYPE_INT_N_0) template<> struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_0> : public true_type { }; template<> struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_0> : public true_type { }; #endif #if defined(__GLIBCXX_TYPE_INT_N_1) template<> struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_1> : public true_type { }; template<> struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_1> : public true_type { }; #endif #if defined(__GLIBCXX_TYPE_INT_N_2) template<> struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_2> : public true_type { }; template<> struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_2> : public true_type { }; #endif #if defined(__GLIBCXX_TYPE_INT_N_3) template<> struct __is_integral_helper<__GLIBCXX_TYPE_INT_N_3> : public true_type { }; template<> struct __is_integral_helper<unsigned __GLIBCXX_TYPE_INT_N_3> : public true_type { }; #endif /// @endcond /// is_integral template<typename _Tp> struct is_integral : public __is_integral_helper<__remove_cv_t<_Tp>>::type { }; /// @cond undocumented template<typename> struct __is_floating_point_helper : public false_type { }; template<> struct __is_floating_point_helper<float> : public true_type { }; template<> struct __is_floating_point_helper<double> : public true_type { }; template<> struct __is_floating_point_helper<long double> : public true_type { }; #if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) template<> struct __is_floating_point_helper<__float128> : public true_type { }; #endif /// @endcond /// is_floating_point template<typename _Tp> struct is_floating_point : public __is_floating_point_helper<__remove_cv_t<_Tp>>::type { }; /// is_array template<typename> struct is_array : public false_type { }; template<typename _Tp, std::size_t _Size> struct is_array<_Tp[_Size]> : public true_type { }; template<typename _Tp> struct is_array<_Tp[]> : public true_type { }; template<typename> struct __is_pointer_helper : public false_type { }; template<typename _Tp> struct __is_pointer_helper<_Tp*> : public true_type { }; /// is_pointer template<typename _Tp> struct is_pointer : public __is_pointer_helper<__remove_cv_t<_Tp>>::type { }; /// is_lvalue_reference template<typename> struct is_lvalue_reference : public false_type { }; template<typename _Tp> struct is_lvalue_reference<_Tp&> : public true_type { }; /// is_rvalue_reference template<typename> struct is_rvalue_reference : public false_type { }; template<typename _Tp> struct is_rvalue_reference<_Tp&&> : public true_type { }; template<typename> struct __is_member_object_pointer_helper : public false_type { }; template<typename _Tp, typename _Cp> struct __is_member_object_pointer_helper<_Tp _Cp::*> : public __not_<is_function<_Tp>>::type { }; /// is_member_object_pointer template<typename _Tp> struct is_member_object_pointer : public __is_member_object_pointer_helper<__remove_cv_t<_Tp>>::type { }; template<typename> struct __is_member_function_pointer_helper : public false_type { }; template<typename _Tp, typename _Cp> struct __is_member_function_pointer_helper<_Tp _Cp::*> : public is_function<_Tp>::type { }; /// is_member_function_pointer template<typename _Tp> struct is_member_function_pointer : public __is_member_function_pointer_helper<__remove_cv_t<_Tp>>::type { }; /// is_enum template<typename _Tp> struct is_enum : public integral_constant<bool, __is_enum(_Tp)> { }; /// is_union template<typename _Tp> struct is_union : public integral_constant<bool, __is_union(_Tp)> { }; /// is_class template<typename _Tp> struct is_class : public integral_constant<bool, __is_class(_Tp)> { }; /// is_function template<typename _Tp> struct is_function : public __bool_constant<!is_const<const _Tp>::value> { }; template<typename _Tp> struct is_function<_Tp&> : public false_type { }; template<typename _Tp> struct is_function<_Tp&&> : public false_type { }; #define __cpp_lib_is_null_pointer 201309 template<typename> struct __is_null_pointer_helper : public false_type { }; template<> struct __is_null_pointer_helper<std::nullptr_t> : public true_type { }; /// is_null_pointer (LWG 2247). template<typename _Tp> struct is_null_pointer : public __is_null_pointer_helper<__remove_cv_t<_Tp>>::type { }; /// __is_nullptr_t (deprecated extension). /// @deprecated Use `is_null_pointer` instead. template<typename _Tp> struct __is_nullptr_t : public is_null_pointer<_Tp> { } _GLIBCXX_DEPRECATED_SUGGEST("std::is_null_pointer"); // Composite type categories. /// is_reference template<typename _Tp> struct is_reference : public __or_<is_lvalue_reference<_Tp>, is_rvalue_reference<_Tp>>::type { }; /// is_arithmetic template<typename _Tp> struct is_arithmetic : public __or_<is_integral<_Tp>, is_floating_point<_Tp>>::type { }; /// is_fundamental template<typename _Tp> struct is_fundamental : public __or_<is_arithmetic<_Tp>, is_void<_Tp>, is_null_pointer<_Tp>>::type { }; /// is_object template<typename _Tp> struct is_object : public __not_<__or_<is_function<_Tp>, is_reference<_Tp>, is_void<_Tp>>>::type { }; template<typename> struct is_member_pointer; /// is_scalar template<typename _Tp> struct is_scalar : public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>, is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type { }; /// is_compound template<typename _Tp> struct is_compound : public __not_<is_fundamental<_Tp>>::type { }; /// @cond undocumented template<typename _Tp> struct __is_member_pointer_helper : public false_type { }; template<typename _Tp, typename _Cp> struct __is_member_pointer_helper<_Tp _Cp::*> : public true_type { }; /// @endcond /// is_member_pointer template<typename _Tp> struct is_member_pointer : public __is_member_pointer_helper<__remove_cv_t<_Tp>>::type { }; template<typename, typename> struct is_same; /// @cond undocumented template<typename _Tp, typename... _Types> using __is_one_of = __or_<is_same<_Tp, _Types>...>; // Check if a type is one of the signed integer types. template<typename _Tp> using __is_signed_integer = __is_one_of<__remove_cv_t<_Tp>, signed char, signed short, signed int, signed long, signed long long #if defined(__GLIBCXX_TYPE_INT_N_0) , signed __GLIBCXX_TYPE_INT_N_0 #endif #if defined(__GLIBCXX_TYPE_INT_N_1) , signed __GLIBCXX_TYPE_INT_N_1 #endif #if defined(__GLIBCXX_TYPE_INT_N_2) , signed __GLIBCXX_TYPE_INT_N_2 #endif #if defined(__GLIBCXX_TYPE_INT_N_3) , signed __GLIBCXX_TYPE_INT_N_3 #endif >; // Check if a type is one of the unsigned integer types. template<typename _Tp> using __is_unsigned_integer = __is_one_of<__remove_cv_t<_Tp>, unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long #if defined(__GLIBCXX_TYPE_INT_N_0) , unsigned __GLIBCXX_TYPE_INT_N_0 #endif #if defined(__GLIBCXX_TYPE_INT_N_1) , unsigned __GLIBCXX_TYPE_INT_N_1 #endif #if defined(__GLIBCXX_TYPE_INT_N_2) , unsigned __GLIBCXX_TYPE_INT_N_2 #endif #if defined(__GLIBCXX_TYPE_INT_N_3) , unsigned __GLIBCXX_TYPE_INT_N_3 #endif >; // Check if a type is one of the signed or unsigned integer types. template<typename _Tp> using __is_standard_integer = __or_<__is_signed_integer<_Tp>, __is_unsigned_integer<_Tp>>; // __void_t (std::void_t for C++11) template<typename...> using __void_t = void; // Utility to detect referenceable types ([defns.referenceable]). template<typename _Tp, typename = void> struct __is_referenceable : public false_type { }; template<typename _Tp> struct __is_referenceable<_Tp, __void_t<_Tp&>> : public true_type { }; /// @endcond // Type properties. /// is_const template<typename> struct is_const : public false_type { }; template<typename _Tp> struct is_const<_Tp const> : public true_type { }; /// is_volatile template<typename> struct is_volatile : public false_type { }; template<typename _Tp> struct is_volatile<_Tp volatile> : public true_type { }; /// is_trivial template<typename _Tp> struct is_trivial : public integral_constant<bool, __is_trivial(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// is_trivially_copyable template<typename _Tp> struct is_trivially_copyable : public integral_constant<bool, __is_trivially_copyable(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// is_standard_layout template<typename _Tp> struct is_standard_layout : public integral_constant<bool, __is_standard_layout(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /** is_pod (deprecated in C++20) * @deprecated Use `is_standard_layout && is_trivial` instead. */ // Could use is_standard_layout && is_trivial instead of the builtin. template<typename _Tp> struct _GLIBCXX20_DEPRECATED("use is_standard_layout && is_trivial instead") is_pod : public integral_constant<bool, __is_pod(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /** is_literal_type * @deprecated Deprecated in C++20. The idea of a literal type isn't useful. */ template<typename _Tp> struct _GLIBCXX17_DEPRECATED is_literal_type : public integral_constant<bool, __is_literal_type(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// is_empty template<typename _Tp> struct is_empty : public integral_constant<bool, __is_empty(_Tp)> { }; /// is_polymorphic template<typename _Tp> struct is_polymorphic : public integral_constant<bool, __is_polymorphic(_Tp)> { }; #if __cplusplus >= 201402L #define __cpp_lib_is_final 201402L /// is_final /// @since C++14 template<typename _Tp> struct is_final : public integral_constant<bool, __is_final(_Tp)> { }; #endif /// is_abstract template<typename _Tp> struct is_abstract : public integral_constant<bool, __is_abstract(_Tp)> { }; /// @cond undocumented template<typename _Tp, bool = is_arithmetic<_Tp>::value> struct __is_signed_helper : public false_type { }; template<typename _Tp> struct __is_signed_helper<_Tp, true> : public integral_constant<bool, _Tp(-1) < _Tp(0)> { }; /// @endcond /// is_signed template<typename _Tp> struct is_signed : public __is_signed_helper<_Tp>::type { }; /// is_unsigned template<typename _Tp> struct is_unsigned : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>> { }; /// @cond undocumented template<typename _Tp, typename _Up = _Tp&&> _Up __declval(int); template<typename _Tp> _Tp __declval(long); /// @endcond template<typename _Tp> auto declval() noexcept -> decltype(__declval<_Tp>(0)); template<typename, unsigned = 0> struct extent; template<typename> struct remove_all_extents; /// @cond undocumented template<typename _Tp> struct __is_array_known_bounds : public integral_constant<bool, (extent<_Tp>::value > 0)> { }; template<typename _Tp> struct __is_array_unknown_bounds : public __and_<is_array<_Tp>, __not_<extent<_Tp>>> { }; // Destructible and constructible type properties. // In N3290 is_destructible does not say anything about function // types and abstract types, see LWG 2049. This implementation // describes function types as non-destructible and all complete // object types as destructible, iff the explicit destructor // call expression is wellformed. struct __do_is_destructible_impl { template<typename _Tp, typename = decltype(declval<_Tp&>().~_Tp())> static true_type __test(int); template<typename> static false_type __test(...); }; template<typename _Tp> struct __is_destructible_impl : public __do_is_destructible_impl { typedef decltype(__test<_Tp>(0)) type; }; template<typename _Tp, bool = __or_<is_void<_Tp>, __is_array_unknown_bounds<_Tp>, is_function<_Tp>>::value, bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> struct __is_destructible_safe; template<typename _Tp> struct __is_destructible_safe<_Tp, false, false> : public __is_destructible_impl<typename remove_all_extents<_Tp>::type>::type { }; template<typename _Tp> struct __is_destructible_safe<_Tp, true, false> : public false_type { }; template<typename _Tp> struct __is_destructible_safe<_Tp, false, true> : public true_type { }; /// @endcond /// is_destructible template<typename _Tp> struct is_destructible : public __is_destructible_safe<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// @cond undocumented // is_nothrow_destructible requires that is_destructible is // satisfied as well. We realize that by mimicing the // implementation of is_destructible but refer to noexcept(expr) // instead of decltype(expr). struct __do_is_nt_destructible_impl { template<typename _Tp> static __bool_constant<noexcept(declval<_Tp&>().~_Tp())> __test(int); template<typename> static false_type __test(...); }; template<typename _Tp> struct __is_nt_destructible_impl : public __do_is_nt_destructible_impl { typedef decltype(__test<_Tp>(0)) type; }; template<typename _Tp, bool = __or_<is_void<_Tp>, __is_array_unknown_bounds<_Tp>, is_function<_Tp>>::value, bool = __or_<is_reference<_Tp>, is_scalar<_Tp>>::value> struct __is_nt_destructible_safe; template<typename _Tp> struct __is_nt_destructible_safe<_Tp, false, false> : public __is_nt_destructible_impl<typename remove_all_extents<_Tp>::type>::type { }; template<typename _Tp> struct __is_nt_destructible_safe<_Tp, true, false> : public false_type { }; template<typename _Tp> struct __is_nt_destructible_safe<_Tp, false, true> : public true_type { }; /// @endcond /// is_nothrow_destructible template<typename _Tp> struct is_nothrow_destructible : public __is_nt_destructible_safe<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// @cond undocumented template<typename _Tp, typename... _Args> struct __is_constructible_impl : public __bool_constant<__is_constructible(_Tp, _Args...)> { }; /// @endcond /// is_constructible template<typename _Tp, typename... _Args> struct is_constructible : public __is_constructible_impl<_Tp, _Args...> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// is_default_constructible template<typename _Tp> struct is_default_constructible : public __is_constructible_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// @cond undocumented template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_copy_constructible_impl; template<typename _Tp> struct __is_copy_constructible_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_copy_constructible_impl<_Tp, true> : public __is_constructible_impl<_Tp, const _Tp&> { }; /// @endcond /// is_copy_constructible template<typename _Tp> struct is_copy_constructible : public __is_copy_constructible_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// @cond undocumented template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_move_constructible_impl; template<typename _Tp> struct __is_move_constructible_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_move_constructible_impl<_Tp, true> : public __is_constructible_impl<_Tp, _Tp&&> { }; /// @endcond /// is_move_constructible template<typename _Tp> struct is_move_constructible : public __is_move_constructible_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// @cond undocumented template<typename _Tp, typename... _Args> using __is_nothrow_constructible_impl = __bool_constant<__is_nothrow_constructible(_Tp, _Args...)>; /// @endcond /// is_nothrow_constructible template<typename _Tp, typename... _Args> struct is_nothrow_constructible : public __is_nothrow_constructible_impl<_Tp, _Args...>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// is_nothrow_default_constructible template<typename _Tp> struct is_nothrow_default_constructible : public __bool_constant<__is_nothrow_constructible(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// @cond undocumented template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_nothrow_copy_constructible_impl; template<typename _Tp> struct __is_nothrow_copy_constructible_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_nothrow_copy_constructible_impl<_Tp, true> : public __is_nothrow_constructible_impl<_Tp, const _Tp&> { }; /// @endcond /// is_nothrow_copy_constructible template<typename _Tp> struct is_nothrow_copy_constructible : public __is_nothrow_copy_constructible_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// @cond undocumented template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_nothrow_move_constructible_impl; template<typename _Tp> struct __is_nothrow_move_constructible_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_nothrow_move_constructible_impl<_Tp, true> : public __is_nothrow_constructible_impl<_Tp, _Tp&&> { }; /// @endcond /// is_nothrow_move_constructible template<typename _Tp> struct is_nothrow_move_constructible : public __is_nothrow_move_constructible_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// is_assignable template<typename _Tp, typename _Up> struct is_assignable : public __bool_constant<__is_assignable(_Tp, _Up)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_copy_assignable_impl; template<typename _Tp> struct __is_copy_assignable_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_copy_assignable_impl<_Tp, true> : public __bool_constant<__is_assignable(_Tp&, const _Tp&)> { }; /// is_copy_assignable template<typename _Tp> struct is_copy_assignable : public __is_copy_assignable_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_move_assignable_impl; template<typename _Tp> struct __is_move_assignable_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_move_assignable_impl<_Tp, true> : public __bool_constant<__is_assignable(_Tp&, _Tp&&)> { }; /// is_move_assignable template<typename _Tp> struct is_move_assignable : public __is_move_assignable_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, typename _Up> using __is_nothrow_assignable_impl = __bool_constant<__is_nothrow_assignable(_Tp, _Up)>; /// is_nothrow_assignable template<typename _Tp, typename _Up> struct is_nothrow_assignable : public __is_nothrow_assignable_impl<_Tp, _Up> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_nt_copy_assignable_impl; template<typename _Tp> struct __is_nt_copy_assignable_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_nt_copy_assignable_impl<_Tp, true> : public __is_nothrow_assignable_impl<_Tp&, const _Tp&> { }; /// is_nothrow_copy_assignable template<typename _Tp> struct is_nothrow_copy_assignable : public __is_nt_copy_assignable_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_nt_move_assignable_impl; template<typename _Tp> struct __is_nt_move_assignable_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_nt_move_assignable_impl<_Tp, true> : public __is_nothrow_assignable_impl<_Tp&, _Tp&&> { }; /// is_nothrow_move_assignable template<typename _Tp> struct is_nothrow_move_assignable : public __is_nt_move_assignable_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// is_trivially_constructible template<typename _Tp, typename... _Args> struct is_trivially_constructible : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// is_trivially_default_constructible template<typename _Tp> struct is_trivially_default_constructible : public __bool_constant<__is_trivially_constructible(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; struct __do_is_implicitly_default_constructible_impl { template <typename _Tp> static void __helper(const _Tp&); template <typename _Tp> static true_type __test(const _Tp&, decltype(__helper<const _Tp&>({}))* = 0); static false_type __test(...); }; template<typename _Tp> struct __is_implicitly_default_constructible_impl : public __do_is_implicitly_default_constructible_impl { typedef decltype(__test(declval<_Tp>())) type; }; template<typename _Tp> struct __is_implicitly_default_constructible_safe : public __is_implicitly_default_constructible_impl<_Tp>::type { }; template <typename _Tp> struct __is_implicitly_default_constructible : public __and_<__is_constructible_impl<_Tp>, __is_implicitly_default_constructible_safe<_Tp>> { }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_trivially_copy_constructible_impl; template<typename _Tp> struct __is_trivially_copy_constructible_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_trivially_copy_constructible_impl<_Tp, true> : public __and_<__is_copy_constructible_impl<_Tp>, integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)>> { }; /// is_trivially_copy_constructible template<typename _Tp> struct is_trivially_copy_constructible : public __is_trivially_copy_constructible_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_trivially_move_constructible_impl; template<typename _Tp> struct __is_trivially_move_constructible_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_trivially_move_constructible_impl<_Tp, true> : public __and_<__is_move_constructible_impl<_Tp>, integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&&)>> { }; /// is_trivially_move_constructible template<typename _Tp> struct is_trivially_move_constructible : public __is_trivially_move_constructible_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// is_trivially_assignable template<typename _Tp, typename _Up> struct is_trivially_assignable : public __bool_constant<__is_trivially_assignable(_Tp, _Up)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_trivially_copy_assignable_impl; template<typename _Tp> struct __is_trivially_copy_assignable_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_trivially_copy_assignable_impl<_Tp, true> : public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)> { }; /// is_trivially_copy_assignable template<typename _Tp> struct is_trivially_copy_assignable : public __is_trivially_copy_assignable_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __is_trivially_move_assignable_impl; template<typename _Tp> struct __is_trivially_move_assignable_impl<_Tp, false> : public false_type { }; template<typename _Tp> struct __is_trivially_move_assignable_impl<_Tp, true> : public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)> { }; /// is_trivially_move_assignable template<typename _Tp> struct is_trivially_move_assignable : public __is_trivially_move_assignable_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// is_trivially_destructible template<typename _Tp> struct is_trivially_destructible : public __and_<__is_destructible_safe<_Tp>, __bool_constant<__has_trivial_destructor(_Tp)>> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// has_virtual_destructor template<typename _Tp> struct has_virtual_destructor : public integral_constant<bool, __has_virtual_destructor(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; // type property queries. /// alignment_of template<typename _Tp> struct alignment_of : public integral_constant<std::size_t, alignof(_Tp)> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// rank template<typename> struct rank : public integral_constant<std::size_t, 0> { }; template<typename _Tp, std::size_t _Size> struct rank<_Tp[_Size]> : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; template<typename _Tp> struct rank<_Tp[]> : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; /// extent template<typename, unsigned _Uint> struct extent : public integral_constant<std::size_t, 0> { }; template<typename _Tp, unsigned _Uint, std::size_t _Size> struct extent<_Tp[_Size], _Uint> : public integral_constant<std::size_t, _Uint == 0 ? _Size : extent<_Tp, _Uint - 1>::value> { }; template<typename _Tp, unsigned _Uint> struct extent<_Tp[], _Uint> : public integral_constant<std::size_t, _Uint == 0 ? 0 : extent<_Tp, _Uint - 1>::value> { }; // Type relations. /// is_same template<typename _Tp, typename _Up> struct is_same #ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME : public integral_constant<bool, __is_same(_Tp, _Up)> #else : public false_type #endif { }; #ifndef _GLIBCXX_HAVE_BUILTIN_IS_SAME template<typename _Tp> struct is_same<_Tp, _Tp> : public true_type { }; #endif /// is_base_of template<typename _Base, typename _Derived> struct is_base_of : public integral_constant<bool, __is_base_of(_Base, _Derived)> { }; template<typename _From, typename _To, bool = __or_<is_void<_From>, is_function<_To>, is_array<_To>>::value> struct __is_convertible_helper { typedef typename is_void<_To>::type type; }; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" template<typename _From, typename _To> class __is_convertible_helper<_From, _To, false> { template<typename _To1> static void __test_aux(_To1) noexcept; template<typename _From1, typename _To1, typename = decltype(__test_aux<_To1>(std::declval<_From1>()))> static true_type __test(int); template<typename, typename> static false_type __test(...); public: typedef decltype(__test<_From, _To>(0)) type; }; #pragma GCC diagnostic pop /// is_convertible template<typename _From, typename _To> struct is_convertible : public __is_convertible_helper<_From, _To>::type { }; // helper trait for unique_ptr<T[]>, shared_ptr<T[]>, and span<T, N> template<typename _ToElementType, typename _FromElementType> using __is_array_convertible = is_convertible<_FromElementType(*)[], _ToElementType(*)[]>; template<typename _From, typename _To, bool = __or_<is_void<_From>, is_function<_To>, is_array<_To>>::value> struct __is_nt_convertible_helper : is_void<_To> { }; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" template<typename _From, typename _To> class __is_nt_convertible_helper<_From, _To, false> { template<typename _To1> static void __test_aux(_To1) noexcept; template<typename _From1, typename _To1> static __bool_constant<noexcept(__test_aux<_To1>(std::declval<_From1>()))> __test(int); template<typename, typename> static false_type __test(...); public: using type = decltype(__test<_From, _To>(0)); }; #pragma GCC diagnostic pop #if __cplusplus > 201703L #define __cpp_lib_is_nothrow_convertible 201806L /// is_nothrow_convertible template<typename _From, typename _To> struct is_nothrow_convertible : public __is_nt_convertible_helper<_From, _To>::type { }; /// is_nothrow_convertible_v template<typename _From, typename _To> inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_From, _To>::value; #endif // C++2a // Const-volatile modifications. /// remove_const template<typename _Tp> struct remove_const { typedef _Tp type; }; template<typename _Tp> struct remove_const<_Tp const> { typedef _Tp type; }; /// remove_volatile template<typename _Tp> struct remove_volatile { typedef _Tp type; }; template<typename _Tp> struct remove_volatile<_Tp volatile> { typedef _Tp type; }; /// remove_cv template<typename _Tp> struct remove_cv { using type = _Tp; }; template<typename _Tp> struct remove_cv<const _Tp> { using type = _Tp; }; template<typename _Tp> struct remove_cv<volatile _Tp> { using type = _Tp; }; template<typename _Tp> struct remove_cv<const volatile _Tp> { using type = _Tp; }; /// add_const template<typename _Tp> struct add_const { typedef _Tp const type; }; /// add_volatile template<typename _Tp> struct add_volatile { typedef _Tp volatile type; }; /// add_cv template<typename _Tp> struct add_cv { typedef typename add_const<typename add_volatile<_Tp>::type>::type type; }; #if __cplusplus > 201103L #define __cpp_lib_transformation_trait_aliases 201304 /// Alias template for remove_const template<typename _Tp> using remove_const_t = typename remove_const<_Tp>::type; /// Alias template for remove_volatile template<typename _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; /// Alias template for remove_cv template<typename _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; /// Alias template for add_const template<typename _Tp> using add_const_t = typename add_const<_Tp>::type; /// Alias template for add_volatile template<typename _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; /// Alias template for add_cv template<typename _Tp> using add_cv_t = typename add_cv<_Tp>::type; #endif // Reference transformations. /// remove_reference template<typename _Tp> struct remove_reference { typedef _Tp type; }; template<typename _Tp> struct remove_reference<_Tp&> { typedef _Tp type; }; template<typename _Tp> struct remove_reference<_Tp&&> { typedef _Tp type; }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_helper { typedef _Tp type; }; template<typename _Tp> struct __add_lvalue_reference_helper<_Tp, true> { typedef _Tp& type; }; /// add_lvalue_reference template<typename _Tp> struct add_lvalue_reference : public __add_lvalue_reference_helper<_Tp> { }; template<typename _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_helper { typedef _Tp type; }; template<typename _Tp> struct __add_rvalue_reference_helper<_Tp, true> { typedef _Tp&& type; }; /// add_rvalue_reference template<typename _Tp> struct add_rvalue_reference : public __add_rvalue_reference_helper<_Tp> { }; #if __cplusplus > 201103L /// Alias template for remove_reference template<typename _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; /// Alias template for add_lvalue_reference template<typename _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; /// Alias template for add_rvalue_reference template<typename _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; #endif // Sign modifications. /// @cond undocumented // Utility for constructing identically cv-qualified types. template<typename _Unqualified, bool _IsConst, bool _IsVol> struct __cv_selector; template<typename _Unqualified> struct __cv_selector<_Unqualified, false, false> { typedef _Unqualified __type; }; template<typename _Unqualified> struct __cv_selector<_Unqualified, false, true> { typedef volatile _Unqualified __type; }; template<typename _Unqualified> struct __cv_selector<_Unqualified, true, false> { typedef const _Unqualified __type; }; template<typename _Unqualified> struct __cv_selector<_Unqualified, true, true> { typedef const volatile _Unqualified __type; }; template<typename _Qualified, typename _Unqualified, bool _IsConst = is_const<_Qualified>::value, bool _IsVol = is_volatile<_Qualified>::value> class __match_cv_qualifiers { typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; public: typedef typename __match::__type __type; }; // Utility for finding the unsigned versions of signed integral types. template<typename _Tp> struct __make_unsigned { typedef _Tp __type; }; template<> struct __make_unsigned<char> { typedef unsigned char __type; }; template<> struct __make_unsigned<signed char> { typedef unsigned char __type; }; template<> struct __make_unsigned<short> { typedef unsigned short __type; }; template<> struct __make_unsigned<int> { typedef unsigned int __type; }; template<> struct __make_unsigned<long> { typedef unsigned long __type; }; template<> struct __make_unsigned<long long> { typedef unsigned long long __type; }; #if defined(__GLIBCXX_TYPE_INT_N_0) template<> struct __make_unsigned<__GLIBCXX_TYPE_INT_N_0> { typedef unsigned __GLIBCXX_TYPE_INT_N_0 __type; }; #endif #if defined(__GLIBCXX_TYPE_INT_N_1) template<> struct __make_unsigned<__GLIBCXX_TYPE_INT_N_1> { typedef unsigned __GLIBCXX_TYPE_INT_N_1 __type; }; #endif #if defined(__GLIBCXX_TYPE_INT_N_2) template<> struct __make_unsigned<__GLIBCXX_TYPE_INT_N_2> { typedef unsigned __GLIBCXX_TYPE_INT_N_2 __type; }; #endif #if defined(__GLIBCXX_TYPE_INT_N_3) template<> struct __make_unsigned<__GLIBCXX_TYPE_INT_N_3> { typedef unsigned __GLIBCXX_TYPE_INT_N_3 __type; }; #endif // Select between integral and enum: not possible to be both. template<typename _Tp, bool _IsInt = is_integral<_Tp>::value, bool _IsEnum = is_enum<_Tp>::value> class __make_unsigned_selector; template<typename _Tp> class __make_unsigned_selector<_Tp, true, false> { using __unsigned_type = typename __make_unsigned<__remove_cv_t<_Tp>>::__type; public: using __type = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; }; class __make_unsigned_selector_base { protected: template<typename...> struct _List { }; template<typename _Tp, typename... _Up> struct _List<_Tp, _Up...> : _List<_Up...> { static constexpr size_t __size = sizeof(_Tp); }; template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> struct __select; template<size_t _Sz, typename _Uint, typename... _UInts> struct __select<_Sz, _List<_Uint, _UInts...>, true> { using __type = _Uint; }; template<size_t _Sz, typename _Uint, typename... _UInts> struct __select<_Sz, _List<_Uint, _UInts...>, false> : __select<_Sz, _List<_UInts...>> { }; }; // Choose unsigned integer type with the smallest rank and same size as _Tp template<typename _Tp> class __make_unsigned_selector<_Tp, false, true> : __make_unsigned_selector_base { // With -fshort-enums, an enum may be as small as a char. using _UInts = _List<unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long>; using __unsigned_type = typename __select<sizeof(_Tp), _UInts>::__type; public: using __type = typename __match_cv_qualifiers<_Tp, __unsigned_type>::__type; }; // wchar_t, char8_t, char16_t and char32_t are integral types but are // neither signed integer types nor unsigned integer types, so must be // transformed to the unsigned integer type with the smallest rank. // Use the partial specialization for enumeration types to do that. #ifdef __WCHAR_TYPE__ template<> struct __make_unsigned<wchar_t> { using __type = typename __make_unsigned_selector<wchar_t, false, true>::__type; }; #endif #ifdef _GLIBCXX_USE_CHAR8_T template<> struct __make_unsigned<char8_t> { using __type = typename __make_unsigned_selector<char8_t, false, true>::__type; }; #endif template<> struct __make_unsigned<char16_t> { using __type = typename __make_unsigned_selector<char16_t, false, true>::__type; }; template<> struct __make_unsigned<char32_t> { using __type = typename __make_unsigned_selector<char32_t, false, true>::__type; }; /// @endcond // Given an integral/enum type, return the corresponding unsigned // integer type. // Primary template. /// make_unsigned template<typename _Tp> struct make_unsigned { typedef typename __make_unsigned_selector<_Tp>::__type type; }; // Integral, but don't define. template<> struct make_unsigned<bool>; /// @cond undocumented // Utility for finding the signed versions of unsigned integral types. template<typename _Tp> struct __make_signed { typedef _Tp __type; }; template<> struct __make_signed<char> { typedef signed char __type; }; template<> struct __make_signed<unsigned char> { typedef signed char __type; }; template<> struct __make_signed<unsigned short> { typedef signed short __type; }; template<> struct __make_signed<unsigned int> { typedef signed int __type; }; template<> struct __make_signed<unsigned long> { typedef signed long __type; }; template<> struct __make_signed<unsigned long long> { typedef signed long long __type; }; #if defined(__GLIBCXX_TYPE_INT_N_0) template<> struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_0> { typedef __GLIBCXX_TYPE_INT_N_0 __type; }; #endif #if defined(__GLIBCXX_TYPE_INT_N_1) template<> struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_1> { typedef __GLIBCXX_TYPE_INT_N_1 __type; }; #endif #if defined(__GLIBCXX_TYPE_INT_N_2) template<> struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_2> { typedef __GLIBCXX_TYPE_INT_N_2 __type; }; #endif #if defined(__GLIBCXX_TYPE_INT_N_3) template<> struct __make_signed<unsigned __GLIBCXX_TYPE_INT_N_3> { typedef __GLIBCXX_TYPE_INT_N_3 __type; }; #endif // Select between integral and enum: not possible to be both. template<typename _Tp, bool _IsInt = is_integral<_Tp>::value, bool _IsEnum = is_enum<_Tp>::value> class __make_signed_selector; template<typename _Tp> class __make_signed_selector<_Tp, true, false> { using __signed_type = typename __make_signed<__remove_cv_t<_Tp>>::__type; public: using __type = typename __match_cv_qualifiers<_Tp, __signed_type>::__type; }; // Choose signed integer type with the smallest rank and same size as _Tp template<typename _Tp> class __make_signed_selector<_Tp, false, true> { typedef typename __make_unsigned_selector<_Tp>::__type __unsigned_type; public: typedef typename __make_signed_selector<__unsigned_type>::__type __type; }; // wchar_t, char16_t and char32_t are integral types but are neither // signed integer types nor unsigned integer types, so must be // transformed to the signed integer type with the smallest rank. // Use the partial specialization for enumeration types to do that. #if defined(__WCHAR_TYPE__) template<> struct __make_signed<wchar_t> { using __type = typename __make_signed_selector<wchar_t, false, true>::__type; }; #endif #if defined(_GLIBCXX_USE_CHAR8_T) template<> struct __make_signed<char8_t> { using __type = typename __make_signed_selector<char8_t, false, true>::__type; }; #endif template<> struct __make_signed<char16_t> { using __type = typename __make_signed_selector<char16_t, false, true>::__type; }; template<> struct __make_signed<char32_t> { using __type = typename __make_signed_selector<char32_t, false, true>::__type; }; /// @endcond // Given an integral/enum type, return the corresponding signed // integer type. // Primary template. /// make_signed template<typename _Tp> struct make_signed { typedef typename __make_signed_selector<_Tp>::__type type; }; // Integral, but don't define. template<> struct make_signed<bool>; #if __cplusplus > 201103L /// Alias template for make_signed template<typename _Tp> using make_signed_t = typename make_signed<_Tp>::type; /// Alias template for make_unsigned template<typename _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; #endif // Array modifications. /// remove_extent template<typename _Tp> struct remove_extent { typedef _Tp type; }; template<typename _Tp, std::size_t _Size> struct remove_extent<_Tp[_Size]> { typedef _Tp type; }; template<typename _Tp> struct remove_extent<_Tp[]> { typedef _Tp type; }; /// remove_all_extents template<typename _Tp> struct remove_all_extents { typedef _Tp type; }; template<typename _Tp, std::size_t _Size> struct remove_all_extents<_Tp[_Size]> { typedef typename remove_all_extents<_Tp>::type type; }; template<typename _Tp> struct remove_all_extents<_Tp[]> { typedef typename remove_all_extents<_Tp>::type type; }; #if __cplusplus > 201103L /// Alias template for remove_extent template<typename _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; /// Alias template for remove_all_extents template<typename _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; #endif // Pointer modifications. template<typename _Tp, typename> struct __remove_pointer_helper { typedef _Tp type; }; template<typename _Tp, typename _Up> struct __remove_pointer_helper<_Tp, _Up*> { typedef _Up type; }; /// remove_pointer template<typename _Tp> struct remove_pointer : public __remove_pointer_helper<_Tp, __remove_cv_t<_Tp>> { }; template<typename _Tp, bool = __or_<__is_referenceable<_Tp>, is_void<_Tp>>::value> struct __add_pointer_helper { typedef _Tp type; }; template<typename _Tp> struct __add_pointer_helper<_Tp, true> { typedef typename remove_reference<_Tp>::type* type; }; /// add_pointer template<typename _Tp> struct add_pointer : public __add_pointer_helper<_Tp> { }; #if __cplusplus > 201103L /// Alias template for remove_pointer template<typename _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; /// Alias template for add_pointer template<typename _Tp> using add_pointer_t = typename add_pointer<_Tp>::type; #endif template<std::size_t _Len> struct __aligned_storage_msa { union __type { unsigned char __data[_Len]; struct __attribute__((__aligned__)) { } __align; }; }; /** * @brief Alignment type. * * The value of _Align is a default-alignment which shall be the * most stringent alignment requirement for any C++ object type * whose size is no greater than _Len (3.9). The member typedef * type shall be a POD type suitable for use as uninitialized * storage for any object whose size is at most _Len and whose * alignment is a divisor of _Align. */ template<std::size_t _Len, std::size_t _Align = __alignof__(typename __aligned_storage_msa<_Len>::__type)> struct aligned_storage { union type { unsigned char __data[_Len]; struct __attribute__((__aligned__((_Align)))) { } __align; }; }; template <typename... _Types> struct __strictest_alignment { static const size_t _S_alignment = 0; static const size_t _S_size = 0; }; template <typename _Tp, typename... _Types> struct __strictest_alignment<_Tp, _Types...> { static const size_t _S_alignment = alignof(_Tp) > __strictest_alignment<_Types...>::_S_alignment ? alignof(_Tp) : __strictest_alignment<_Types...>::_S_alignment; static const size_t _S_size = sizeof(_Tp) > __strictest_alignment<_Types...>::_S_size ? sizeof(_Tp) : __strictest_alignment<_Types...>::_S_size; }; /** * @brief Provide aligned storage for types. * * [meta.trans.other] * * Provides aligned storage for any of the provided types of at * least size _Len. * * @see aligned_storage */ template <size_t _Len, typename... _Types> struct aligned_union { private: static_assert(sizeof...(_Types) != 0, "At least one type is required"); using __strictest = __strictest_alignment<_Types...>; static const size_t _S_len = _Len > __strictest::_S_size ? _Len : __strictest::_S_size; public: /// The value of the strictest alignment of _Types. static const size_t alignment_value = __strictest::_S_alignment; /// The storage. typedef typename aligned_storage<_S_len, alignment_value>::type type; }; template <size_t _Len, typename... _Types> const size_t aligned_union<_Len, _Types...>::alignment_value; /// @cond undocumented // Decay trait for arrays and functions, used for perfect forwarding // in make_pair, make_tuple, etc. template<typename _Up, bool _IsArray = is_array<_Up>::value, bool _IsFunction = is_function<_Up>::value> struct __decay_selector; // NB: DR 705. template<typename _Up> struct __decay_selector<_Up, false, false> { typedef __remove_cv_t<_Up> __type; }; template<typename _Up> struct __decay_selector<_Up, true, false> { typedef typename remove_extent<_Up>::type* __type; }; template<typename _Up> struct __decay_selector<_Up, false, true> { typedef typename add_pointer<_Up>::type __type; }; /// @endcond /// decay template<typename _Tp> class decay { typedef typename remove_reference<_Tp>::type __remove_type; public: typedef typename __decay_selector<__remove_type>::__type type; }; /// @cond undocumented // Helper which adds a reference to a type when given a reference_wrapper template<typename _Tp> struct __strip_reference_wrapper { typedef _Tp __type; }; template<typename _Tp> struct __strip_reference_wrapper<reference_wrapper<_Tp> > { typedef _Tp& __type; }; // __decay_t (std::decay_t for C++11). template<typename _Tp> using __decay_t = typename decay<_Tp>::type; template<typename _Tp> using __decay_and_strip = __strip_reference_wrapper<__decay_t<_Tp>>; /// @endcond // Primary template. /// Define a member typedef `type` only if a boolean constant is true. template<bool, typename _Tp = void> struct enable_if { }; // Partial specialization for true. template<typename _Tp> struct enable_if<true, _Tp> { typedef _Tp type; }; /// @cond undocumented // __enable_if_t (std::enable_if_t for C++11) template<bool _Cond, typename _Tp = void> using __enable_if_t = typename enable_if<_Cond, _Tp>::type; // Helper for SFINAE constraints template<typename... _Cond> using _Require = __enable_if_t<__and_<_Cond...>::value>; // __remove_cvref_t (std::remove_cvref_t for C++11). template<typename _Tp> using __remove_cvref_t = typename remove_cv<typename remove_reference<_Tp>::type>::type; /// @endcond // Primary template. /// Define a member typedef @c type to one of two argument types. template<bool _Cond, typename _Iftrue, typename _Iffalse> struct conditional { typedef _Iftrue type; }; // Partial specialization for false. template<typename _Iftrue, typename _Iffalse> struct conditional<false, _Iftrue, _Iffalse> { typedef _Iffalse type; }; /// common_type template<typename... _Tp> struct common_type; // Sfinae-friendly common_type implementation: /// @cond undocumented struct __do_common_type_impl { template<typename _Tp, typename _Up> using __cond_t = decltype(true ? std::declval<_Tp>() : std::declval<_Up>()); // if decay_t<decltype(false ? declval<D1>() : declval<D2>())> // denotes a valid type, let C denote that type. template<typename _Tp, typename _Up> static __success_type<__decay_t<__cond_t<_Tp, _Up>>> _S_test(int); #if __cplusplus > 201703L // Otherwise, if COND-RES(CREF(D1), CREF(D2)) denotes a type, // let C denote the type decay_t<COND-RES(CREF(D1), CREF(D2))>. template<typename _Tp, typename _Up> static __success_type<__remove_cvref_t<__cond_t<const _Tp&, const _Up&>>> _S_test_2(int); #endif template<typename, typename> static __failure_type _S_test_2(...); template<typename _Tp, typename _Up> static decltype(_S_test_2<_Tp, _Up>(0)) _S_test(...); }; // If sizeof...(T) is zero, there shall be no member type. template<> struct common_type<> { }; // If sizeof...(T) is one, the same type, if any, as common_type_t<T0, T0>. template<typename _Tp0> struct common_type<_Tp0> : public common_type<_Tp0, _Tp0> { }; // If sizeof...(T) is two, ... template<typename _Tp1, typename _Tp2, typename _Dp1 = __decay_t<_Tp1>, typename _Dp2 = __decay_t<_Tp2>> struct __common_type_impl { // If is_same_v<T1, D1> is false or is_same_v<T2, D2> is false, // let C denote the same type, if any, as common_type_t<D1, D2>. using type = common_type<_Dp1, _Dp2>; }; template<typename _Tp1, typename _Tp2> struct __common_type_impl<_Tp1, _Tp2, _Tp1, _Tp2> : private __do_common_type_impl { // Otherwise, if decay_t<decltype(false ? declval<D1>() : declval<D2>())> // denotes a valid type, let C denote that type. using type = decltype(_S_test<_Tp1, _Tp2>(0)); }; // If sizeof...(T) is two, ... template<typename _Tp1, typename _Tp2> struct common_type<_Tp1, _Tp2> : public __common_type_impl<_Tp1, _Tp2>::type { }; template<typename...> struct __common_type_pack { }; template<typename, typename, typename = void> struct __common_type_fold; // If sizeof...(T) is greater than two, ... template<typename _Tp1, typename _Tp2, typename... _Rp> struct common_type<_Tp1, _Tp2, _Rp...> : public __common_type_fold<common_type<_Tp1, _Tp2>, __common_type_pack<_Rp...>> { }; // Let C denote the same type, if any, as common_type_t<T1, T2>. // If there is such a type C, type shall denote the same type, if any, // as common_type_t<C, R...>. template<typename _CTp, typename... _Rp> struct __common_type_fold<_CTp, __common_type_pack<_Rp...>, __void_t<typename _CTp::type>> : public common_type<typename _CTp::type, _Rp...> { }; // Otherwise, there shall be no member type. template<typename _CTp, typename _Rp> struct __common_type_fold<_CTp, _Rp, void> { }; template<typename _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl { using type = __underlying_type(_Tp); }; template<typename _Tp> struct __underlying_type_impl<_Tp, false> { }; /// @endcond /// The underlying type of an enum. template<typename _Tp> struct underlying_type : public __underlying_type_impl<_Tp> { }; /// @cond undocumented template<typename _Tp> struct __declval_protector { static const bool __stop = false; }; /// @endcond /** Utility to simplify expressions used in unevaluated operands * @since C++11 * @ingroup utilities */ template<typename _Tp> auto declval() noexcept -> decltype(__declval<_Tp>(0)) { static_assert(__declval_protector<_Tp>::__stop, "declval() must not be used!"); return __declval<_Tp>(0); } /// result_of template<typename _Signature> struct result_of; // Sfinae-friendly result_of implementation: #define __cpp_lib_result_of_sfinae 201210 /// @cond undocumented struct __invoke_memfun_ref { }; struct __invoke_memfun_deref { }; struct __invoke_memobj_ref { }; struct __invoke_memobj_deref { }; struct __invoke_other { }; // Associate a tag type with a specialization of __success_type. template<typename _Tp, typename _Tag> struct __result_of_success : __success_type<_Tp> { using __invoke_type = _Tag; }; // [func.require] paragraph 1 bullet 1: struct __result_of_memfun_ref_impl { template<typename _Fp, typename _Tp1, typename... _Args> static __result_of_success<decltype( (std::declval<_Tp1>().*std::declval<_Fp>())(std::declval<_Args>()...) ), __invoke_memfun_ref> _S_test(int); template<typename...> static __failure_type _S_test(...); }; template<typename _MemPtr, typename _Arg, typename... _Args> struct __result_of_memfun_ref : private __result_of_memfun_ref_impl { typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; }; // [func.require] paragraph 1 bullet 2: struct __result_of_memfun_deref_impl { template<typename _Fp, typename _Tp1, typename... _Args> static __result_of_success<decltype( ((*std::declval<_Tp1>()).*std::declval<_Fp>())(std::declval<_Args>()...) ), __invoke_memfun_deref> _S_test(int); template<typename...> static __failure_type _S_test(...); }; template<typename _MemPtr, typename _Arg, typename... _Args> struct __result_of_memfun_deref : private __result_of_memfun_deref_impl { typedef decltype(_S_test<_MemPtr, _Arg, _Args...>(0)) type; }; // [func.require] paragraph 1 bullet 3: struct __result_of_memobj_ref_impl { template<typename _Fp, typename _Tp1> static __result_of_success<decltype( std::declval<_Tp1>().*std::declval<_Fp>() ), __invoke_memobj_ref> _S_test(int); template<typename, typename> static __failure_type _S_test(...); }; template<typename _MemPtr, typename _Arg> struct __result_of_memobj_ref : private __result_of_memobj_ref_impl { typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; }; // [func.require] paragraph 1 bullet 4: struct __result_of_memobj_deref_impl { template<typename _Fp, typename _Tp1> static __result_of_success<decltype( (*std::declval<_Tp1>()).*std::declval<_Fp>() ), __invoke_memobj_deref> _S_test(int); template<typename, typename> static __failure_type _S_test(...); }; template<typename _MemPtr, typename _Arg> struct __result_of_memobj_deref : private __result_of_memobj_deref_impl { typedef decltype(_S_test<_MemPtr, _Arg>(0)) type; }; template<typename _MemPtr, typename _Arg> struct __result_of_memobj; template<typename _Res, typename _Class, typename _Arg> struct __result_of_memobj<_Res _Class::*, _Arg> { typedef __remove_cvref_t<_Arg> _Argval; typedef _Res _Class::* _MemPtr; typedef typename conditional<__or_<is_same<_Argval, _Class>, is_base_of<_Class, _Argval>>::value, __result_of_memobj_ref<_MemPtr, _Arg>, __result_of_memobj_deref<_MemPtr, _Arg> >::type::type type; }; template<typename _MemPtr, typename _Arg, typename... _Args> struct __result_of_memfun; template<typename _Res, typename _Class, typename _Arg, typename... _Args> struct __result_of_memfun<_Res _Class::*, _Arg, _Args...> { typedef typename remove_reference<_Arg>::type _Argval; typedef _Res _Class::* _MemPtr; typedef typename conditional<is_base_of<_Class, _Argval>::value, __result_of_memfun_ref<_MemPtr, _Arg, _Args...>, __result_of_memfun_deref<_MemPtr, _Arg, _Args...> >::type::type type; }; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2219. INVOKE-ing a pointer to member with a reference_wrapper // as the object expression // Used by result_of, invoke etc. to unwrap a reference_wrapper. template<typename _Tp, typename _Up = __remove_cvref_t<_Tp>> struct __inv_unwrap { using type = _Tp; }; template<typename _Tp, typename _Up> struct __inv_unwrap<_Tp, reference_wrapper<_Up>> { using type = _Up&; }; template<bool, bool, typename _Functor, typename... _ArgTypes> struct __result_of_impl { typedef __failure_type type; }; template<typename _MemPtr, typename _Arg> struct __result_of_impl<true, false, _MemPtr, _Arg> : public __result_of_memobj<__decay_t<_MemPtr>, typename __inv_unwrap<_Arg>::type> { }; template<typename _MemPtr, typename _Arg, typename... _Args> struct __result_of_impl<false, true, _MemPtr, _Arg, _Args...> : public __result_of_memfun<__decay_t<_MemPtr>, typename __inv_unwrap<_Arg>::type, _Args...> { }; // [func.require] paragraph 1 bullet 5: struct __result_of_other_impl { template<typename _Fn, typename... _Args> static __result_of_success<decltype( std::declval<_Fn>()(std::declval<_Args>()...) ), __invoke_other> _S_test(int); template<typename...> static __failure_type _S_test(...); }; template<typename _Functor, typename... _ArgTypes> struct __result_of_impl<false, false, _Functor, _ArgTypes...> : private __result_of_other_impl { typedef decltype(_S_test<_Functor, _ArgTypes...>(0)) type; }; // __invoke_result (std::invoke_result for C++11) template<typename _Functor, typename... _ArgTypes> struct __invoke_result : public __result_of_impl< is_member_object_pointer< typename remove_reference<_Functor>::type >::value, is_member_function_pointer< typename remove_reference<_Functor>::type >::value, _Functor, _ArgTypes... >::type { }; /// @endcond template<typename _Functor, typename... _ArgTypes> struct result_of<_Functor(_ArgTypes...)> : public __invoke_result<_Functor, _ArgTypes...> { }; #if __cplusplus >= 201402L /// Alias template for aligned_storage template<size_t _Len, size_t _Align = __alignof__(typename __aligned_storage_msa<_Len>::__type)> using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; template <size_t _Len, typename... _Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; /// Alias template for decay template<typename _Tp> using decay_t = typename decay<_Tp>::type; /// Alias template for enable_if template<bool _Cond, typename _Tp = void> using enable_if_t = typename enable_if<_Cond, _Tp>::type; /// Alias template for conditional template<bool _Cond, typename _Iftrue, typename _Iffalse> using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type; /// Alias template for common_type template<typename... _Tp> using common_type_t = typename common_type<_Tp...>::type; /// Alias template for underlying_type template<typename _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; /// Alias template for result_of template<typename _Tp> using result_of_t = typename result_of<_Tp>::type; #endif // C++14 #if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++11 #define __cpp_lib_void_t 201411 /// A metafunction that always yields void, used for detecting valid types. template<typename...> using void_t = void; #endif /// @cond undocumented /// Implementation of the detection idiom (negative case). template<typename _Default, typename _AlwaysVoid, template<typename...> class _Op, typename... _Args> struct __detector { using value_t = false_type; using type = _Default; }; /// Implementation of the detection idiom (positive case). template<typename _Default, template<typename...> class _Op, typename... _Args> struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...> { using value_t = true_type; using type = _Op<_Args...>; }; // Detect whether _Op<_Args...> is a valid type, use _Default if not. template<typename _Default, template<typename...> class _Op, typename... _Args> using __detected_or = __detector<_Default, void, _Op, _Args...>; // _Op<_Args...> if that is a valid type, otherwise _Default. template<typename _Default, template<typename...> class _Op, typename... _Args> using __detected_or_t = typename __detected_or<_Default, _Op, _Args...>::type; /** * Use SFINAE to determine if the type _Tp has a publicly-accessible * member type _NTYPE. */ #define _GLIBCXX_HAS_NESTED_TYPE(_NTYPE) \ template<typename _Tp, typename = __void_t<>> \ struct __has_##_NTYPE \ : false_type \ { }; \ template<typename _Tp> \ struct __has_##_NTYPE<_Tp, __void_t<typename _Tp::_NTYPE>> \ : true_type \ { }; template <typename _Tp> struct __is_swappable; template <typename _Tp> struct __is_nothrow_swappable; template<typename> struct __is_tuple_like_impl : false_type { }; template<typename... _Tps> struct __is_tuple_like_impl<tuple<_Tps...>> : true_type { }; // Internal type trait that allows us to sfinae-protect tuple_cat. template<typename _Tp> struct __is_tuple_like : public __is_tuple_like_impl<__remove_cvref_t<_Tp>>::type { }; /// @endcond template<typename _Tp> _GLIBCXX20_CONSTEXPR inline _Require<__not_<__is_tuple_like<_Tp>>, is_move_constructible<_Tp>, is_move_assignable<_Tp>> swap(_Tp&, _Tp&) noexcept(__and_<is_nothrow_move_constructible<_Tp>, is_nothrow_move_assignable<_Tp>>::value); template<typename _Tp, size_t _Nm> _GLIBCXX20_CONSTEXPR inline __enable_if_t<__is_swappable<_Tp>::value> swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) noexcept(__is_nothrow_swappable<_Tp>::value); /// @cond undocumented namespace __swappable_details { using std::swap; struct __do_is_swappable_impl { template<typename _Tp, typename = decltype(swap(std::declval<_Tp&>(), std::declval<_Tp&>()))> static true_type __test(int); template<typename> static false_type __test(...); }; struct __do_is_nothrow_swappable_impl { template<typename _Tp> static __bool_constant< noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())) > __test(int); template<typename> static false_type __test(...); }; } // namespace __swappable_details template<typename _Tp> struct __is_swappable_impl : public __swappable_details::__do_is_swappable_impl { typedef decltype(__test<_Tp>(0)) type; }; template<typename _Tp> struct __is_nothrow_swappable_impl : public __swappable_details::__do_is_nothrow_swappable_impl { typedef decltype(__test<_Tp>(0)) type; }; template<typename _Tp> struct __is_swappable : public __is_swappable_impl<_Tp>::type { }; template<typename _Tp> struct __is_nothrow_swappable : public __is_nothrow_swappable_impl<_Tp>::type { }; /// @endcond #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 #define __cpp_lib_is_swappable 201603 /// Metafunctions used for detecting swappable types: p0185r1 /// is_swappable template<typename _Tp> struct is_swappable : public __is_swappable_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// is_nothrow_swappable template<typename _Tp> struct is_nothrow_swappable : public __is_nothrow_swappable_impl<_Tp>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; #if __cplusplus >= 201402L /// is_swappable_v template<typename _Tp> _GLIBCXX17_INLINE constexpr bool is_swappable_v = is_swappable<_Tp>::value; /// is_nothrow_swappable_v template<typename _Tp> _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value; #endif // __cplusplus >= 201402L /// @cond undocumented namespace __swappable_with_details { using std::swap; struct __do_is_swappable_with_impl { template<typename _Tp, typename _Up, typename = decltype(swap(std::declval<_Tp>(), std::declval<_Up>())), typename = decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> static true_type __test(int); template<typename, typename> static false_type __test(...); }; struct __do_is_nothrow_swappable_with_impl { template<typename _Tp, typename _Up> static __bool_constant< noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) && noexcept(swap(std::declval<_Up>(), std::declval<_Tp>())) > __test(int); template<typename, typename> static false_type __test(...); }; } // namespace __swappable_with_details template<typename _Tp, typename _Up> struct __is_swappable_with_impl : public __swappable_with_details::__do_is_swappable_with_impl { typedef decltype(__test<_Tp, _Up>(0)) type; }; // Optimization for the homogenous lvalue case, not required: template<typename _Tp> struct __is_swappable_with_impl<_Tp&, _Tp&> : public __swappable_details::__do_is_swappable_impl { typedef decltype(__test<_Tp&>(0)) type; }; template<typename _Tp, typename _Up> struct __is_nothrow_swappable_with_impl : public __swappable_with_details::__do_is_nothrow_swappable_with_impl { typedef decltype(__test<_Tp, _Up>(0)) type; }; // Optimization for the homogenous lvalue case, not required: template<typename _Tp> struct __is_nothrow_swappable_with_impl<_Tp&, _Tp&> : public __swappable_details::__do_is_nothrow_swappable_impl { typedef decltype(__test<_Tp&>(0)) type; }; /// @endcond /// is_swappable_with template<typename _Tp, typename _Up> struct is_swappable_with : public __is_swappable_with_impl<_Tp, _Up>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "first template argument must be a complete class or an unbounded array"); static_assert(std::__is_complete_or_unbounded(__type_identity<_Up>{}), "second template argument must be a complete class or an unbounded array"); }; /// is_nothrow_swappable_with template<typename _Tp, typename _Up> struct is_nothrow_swappable_with : public __is_nothrow_swappable_with_impl<_Tp, _Up>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "first template argument must be a complete class or an unbounded array"); static_assert(std::__is_complete_or_unbounded(__type_identity<_Up>{}), "second template argument must be a complete class or an unbounded array"); }; #if __cplusplus >= 201402L /// is_swappable_with_v template<typename _Tp, typename _Up> _GLIBCXX17_INLINE constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value; /// is_nothrow_swappable_with_v template<typename _Tp, typename _Up> _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value; #endif // __cplusplus >= 201402L #endif// c++1z or gnu++11 /// @cond undocumented // __is_invocable (std::is_invocable for C++11) // The primary template is used for invalid INVOKE expressions. template<typename _Result, typename _Ret, bool = is_void<_Ret>::value, typename = void> struct __is_invocable_impl : false_type { using __nothrow_type = false_type; // For is_nothrow_invocable_r }; // Used for valid INVOKE and INVOKE<void> expressions. template<typename _Result, typename _Ret> struct __is_invocable_impl<_Result, _Ret, /* is_void<_Ret> = */ true, __void_t<typename _Result::type>> : true_type { using __nothrow_type = true_type; // For is_nothrow_invocable_r }; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" // Used for INVOKE<R> expressions to check the implicit conversion to R. template<typename _Result, typename _Ret> struct __is_invocable_impl<_Result, _Ret, /* is_void<_Ret> = */ false, __void_t<typename _Result::type>> { private: // The type of the INVOKE expression. // Unlike declval, this doesn't add_rvalue_reference, so it respects // guaranteed copy elision. static typename _Result::type _S_get() noexcept; template<typename _Tp> static void _S_conv(_Tp) noexcept; // This overload is viable if INVOKE(f, args...) can convert to _Tp. template<typename _Tp, bool _Check_Noex = false, typename = decltype(_S_conv<_Tp>(_S_get())), bool _Noex = noexcept(_S_conv<_Tp>(_S_get()))> static __bool_constant<_Check_Noex ? _Noex : true> _S_test(int); template<typename _Tp, bool = false> static false_type _S_test(...); public: // For is_invocable_r using type = decltype(_S_test<_Ret>(1)); // For is_nothrow_invocable_r using __nothrow_type = decltype(_S_test<_Ret, true>(1)); }; #pragma GCC diagnostic pop template<typename _Fn, typename... _ArgTypes> struct __is_invocable : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type { }; template<typename _Fn, typename _Tp, typename... _Args> constexpr bool __call_is_nt(__invoke_memfun_ref) { using _Up = typename __inv_unwrap<_Tp>::type; return noexcept((std::declval<_Up>().*std::declval<_Fn>())( std::declval<_Args>()...)); } template<typename _Fn, typename _Tp, typename... _Args> constexpr bool __call_is_nt(__invoke_memfun_deref) { return noexcept(((*std::declval<_Tp>()).*std::declval<_Fn>())( std::declval<_Args>()...)); } template<typename _Fn, typename _Tp> constexpr bool __call_is_nt(__invoke_memobj_ref) { using _Up = typename __inv_unwrap<_Tp>::type; return noexcept(std::declval<_Up>().*std::declval<_Fn>()); } template<typename _Fn, typename _Tp> constexpr bool __call_is_nt(__invoke_memobj_deref) { return noexcept((*std::declval<_Tp>()).*std::declval<_Fn>()); } template<typename _Fn, typename... _Args> constexpr bool __call_is_nt(__invoke_other) { return noexcept(std::declval<_Fn>()(std::declval<_Args>()...)); } template<typename _Result, typename _Fn, typename... _Args> struct __call_is_nothrow : __bool_constant< std::__call_is_nt<_Fn, _Args...>(typename _Result::__invoke_type{}) > { }; template<typename _Fn, typename... _Args> using __call_is_nothrow_ = __call_is_nothrow<__invoke_result<_Fn, _Args...>, _Fn, _Args...>; // __is_nothrow_invocable (std::is_nothrow_invocable for C++11) template<typename _Fn, typename... _Args> struct __is_nothrow_invocable : __and_<__is_invocable<_Fn, _Args...>, __call_is_nothrow_<_Fn, _Args...>>::type { }; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" struct __nonesuchbase {}; struct __nonesuch : private __nonesuchbase { ~__nonesuch() = delete; __nonesuch(__nonesuch const&) = delete; void operator=(__nonesuch const&) = delete; }; #pragma GCC diagnostic pop /// @endcond #if __cplusplus >= 201703L # define __cpp_lib_is_invocable 201703 /// std::invoke_result template<typename _Functor, typename... _ArgTypes> struct invoke_result : public __invoke_result<_Functor, _ArgTypes...> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Functor>{}), "_Functor must be a complete class or an unbounded array"); static_assert((std::__is_complete_or_unbounded( __type_identity<_ArgTypes>{}) && ...), "each argument type must be a complete class or an unbounded array"); }; /// std::invoke_result_t template<typename _Fn, typename... _Args> using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; /// std::is_invocable template<typename _Fn, typename... _ArgTypes> struct is_invocable : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), "_Fn must be a complete class or an unbounded array"); static_assert((std::__is_complete_or_unbounded( __type_identity<_ArgTypes>{}) && ...), "each argument type must be a complete class or an unbounded array"); }; /// std::is_invocable_r template<typename _Ret, typename _Fn, typename... _ArgTypes> struct is_invocable_r : __is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), "_Fn must be a complete class or an unbounded array"); static_assert((std::__is_complete_or_unbounded( __type_identity<_ArgTypes>{}) && ...), "each argument type must be a complete class or an unbounded array"); static_assert(std::__is_complete_or_unbounded(__type_identity<_Ret>{}), "_Ret must be a complete class or an unbounded array"); }; /// std::is_nothrow_invocable template<typename _Fn, typename... _ArgTypes> struct is_nothrow_invocable : __and_<__is_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, void>, __call_is_nothrow_<_Fn, _ArgTypes...>>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), "_Fn must be a complete class or an unbounded array"); static_assert((std::__is_complete_or_unbounded( __type_identity<_ArgTypes>{}) && ...), "each argument type must be a complete class or an unbounded array"); }; /// @cond undocumented template<typename _Result, typename _Ret> using __is_nt_invocable_impl = typename __is_invocable_impl<_Result, _Ret>::__nothrow_type; /// @endcond /// std::is_nothrow_invocable_r template<typename _Ret, typename _Fn, typename... _ArgTypes> struct is_nothrow_invocable_r : __and_<__is_nt_invocable_impl<__invoke_result<_Fn, _ArgTypes...>, _Ret>, __call_is_nothrow_<_Fn, _ArgTypes...>>::type { static_assert(std::__is_complete_or_unbounded(__type_identity<_Fn>{}), "_Fn must be a complete class or an unbounded array"); static_assert((std::__is_complete_or_unbounded( __type_identity<_ArgTypes>{}) && ...), "each argument type must be a complete class or an unbounded array"); static_assert(std::__is_complete_or_unbounded(__type_identity<_Ret>{}), "_Ret must be a complete class or an unbounded array"); }; #endif // C++17 #if __cplusplus >= 201703L # define __cpp_lib_type_trait_variable_templates 201510L /** * @defgroup variable_templates Variable templates for type traits. * @ingroup metaprogramming * * The variable `is_foo_v<T>` is a boolean constant with the same value * as the type trait `is_foo<T>::value`. * * @since C++17 */ /** @ingroup variable_templates * @{ */ template <typename _Tp> inline constexpr bool is_void_v = is_void<_Tp>::value; template <typename _Tp> inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; template <typename _Tp> inline constexpr bool is_integral_v = is_integral<_Tp>::value; template <typename _Tp> inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; template <typename _Tp> inline constexpr bool is_array_v = is_array<_Tp>::value; template <typename _Tp> inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; template <typename _Tp> inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; template <typename _Tp> inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; template <typename _Tp> inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value; template <typename _Tp> inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value; template <typename _Tp> inline constexpr bool is_enum_v = is_enum<_Tp>::value; template <typename _Tp> inline constexpr bool is_union_v = is_union<_Tp>::value; template <typename _Tp> inline constexpr bool is_class_v = is_class<_Tp>::value; template <typename _Tp> inline constexpr bool is_function_v = is_function<_Tp>::value; template <typename _Tp> inline constexpr bool is_reference_v = is_reference<_Tp>::value; template <typename _Tp> inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; template <typename _Tp> inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; template <typename _Tp> inline constexpr bool is_object_v = is_object<_Tp>::value; template <typename _Tp> inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; template <typename _Tp> inline constexpr bool is_compound_v = is_compound<_Tp>::value; template <typename _Tp> inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; template <typename _Tp> inline constexpr bool is_const_v = is_const<_Tp>::value; template <typename _Tp> inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; template <typename _Tp> inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; template <typename _Tp> inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value; template <typename _Tp> inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" template <typename _Tp> _GLIBCXX20_DEPRECATED("use is_standard_layout_v && is_trivial_v instead") inline constexpr bool is_pod_v = is_pod<_Tp>::value; template <typename _Tp> _GLIBCXX17_DEPRECATED inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; #pragma GCC diagnostic pop template <typename _Tp> inline constexpr bool is_empty_v = is_empty<_Tp>::value; template <typename _Tp> inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; template <typename _Tp> inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; template <typename _Tp> inline constexpr bool is_final_v = is_final<_Tp>::value; template <typename _Tp> inline constexpr bool is_signed_v = is_signed<_Tp>::value; template <typename _Tp> inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; template <typename _Tp, typename... _Args> inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value; template <typename _Tp> inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value; template <typename _Tp> inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value; template <typename _Tp> inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value; template <typename _Tp, typename _Up> inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; template <typename _Tp> inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; template <typename _Tp> inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; template <typename _Tp> inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; template <typename _Tp, typename... _Args> inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value; template <typename _Tp> inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value; template <typename _Tp> inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value; template <typename _Tp> inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value; template <typename _Tp, typename _Up> inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Up>::value; template <typename _Tp> inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value; template <typename _Tp> inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value; template <typename _Tp> inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value; template <typename _Tp, typename... _Args> inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value; template <typename _Tp> inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value; template <typename _Tp> inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value; template <typename _Tp> inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value; template <typename _Tp, typename _Up> inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Up>::value; template <typename _Tp> inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value; template <typename _Tp> inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value; template <typename _Tp> inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value; template <typename _Tp> inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value; template <typename _Tp> inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; template <typename _Tp> inline constexpr size_t rank_v = rank<_Tp>::value; template <typename _Tp, unsigned _Idx = 0> inline constexpr size_t extent_v = extent<_Tp, _Idx>::value; #ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME template <typename _Tp, typename _Up> inline constexpr bool is_same_v = __is_same(_Tp, _Up); #else template <typename _Tp, typename _Up> inline constexpr bool is_same_v = std::is_same<_Tp, _Up>::value; #endif template <typename _Base, typename _Derived> inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; template <typename _From, typename _To> inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; template<typename _Fn, typename... _Args> inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; template<typename _Fn, typename... _Args> inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value; template<typename _Ret, typename _Fn, typename... _Args> inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value; template<typename _Ret, typename _Fn, typename... _Args> inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; /// @} #ifdef _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP # define __cpp_lib_has_unique_object_representations 201606 /// has_unique_object_representations template<typename _Tp> struct has_unique_object_representations : bool_constant<__has_unique_object_representations( remove_cv_t<remove_all_extents_t<_Tp>> )> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// @ingroup variable_templates template<typename _Tp> inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value; #endif #ifdef _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE # define __cpp_lib_is_aggregate 201703 /// is_aggregate template<typename _Tp> struct is_aggregate : bool_constant<__is_aggregate(remove_cv_t<_Tp>)> { }; /// @ingroup variable_templates template<typename _Tp> inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; #endif #endif // C++17 #if __cplusplus > 201703L #define __cpp_lib_remove_cvref 201711L /// Remove references and cv-qualifiers. template<typename _Tp> struct remove_cvref : remove_cv<_Tp> { }; template<typename _Tp> struct remove_cvref<_Tp&> : remove_cv<_Tp> { }; template<typename _Tp> struct remove_cvref<_Tp&&> : remove_cv<_Tp> { }; template<typename _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type; #define __cpp_lib_type_identity 201806L /// Identity metafunction. template<typename _Tp> struct type_identity { using type = _Tp; }; template<typename _Tp> using type_identity_t = typename type_identity<_Tp>::type; #define __cpp_lib_unwrap_ref 201811L /// Unwrap a reference_wrapper template<typename _Tp> struct unwrap_reference { using type = _Tp; }; template<typename _Tp> struct unwrap_reference<reference_wrapper<_Tp>> { using type = _Tp&; }; template<typename _Tp> using unwrap_reference_t = typename unwrap_reference<_Tp>::type; /// Decay type and if it's a reference_wrapper, unwrap it template<typename _Tp> struct unwrap_ref_decay { using type = unwrap_reference_t<decay_t<_Tp>>; }; template<typename _Tp> using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; #define __cpp_lib_bounded_array_traits 201902L /// True for a type that is an array of known bound. template<typename _Tp> struct is_bounded_array : public __is_array_known_bounds<_Tp> { }; /// True for a type that is an array of unknown bound. template<typename _Tp> struct is_unbounded_array : public __is_array_unknown_bounds<_Tp> { }; /// @ingroup variable_templates template<typename _Tp> inline constexpr bool is_bounded_array_v = is_bounded_array<_Tp>::value; /// @ingroup variable_templates template<typename _Tp> inline constexpr bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; #if __cplusplus > 202002L #define __cpp_lib_is_scoped_enum 202011L /// @since C++23 //@{ template<typename _Tp> struct is_scoped_enum : false_type { }; template<typename _Tp> requires __is_enum(_Tp) && requires(_Tp __t) { __t = __t; } // fails if incomplete struct is_scoped_enum<_Tp> : bool_constant<!requires(_Tp __t, void(*__f)(int)) { __f(__t); }> { }; // FIXME remove this partial specialization and use remove_cv_t<_Tp> above // when PR c++/99968 is fixed. template<typename _Tp> requires __is_enum(_Tp) && requires(_Tp __t) { __t = __t; } // fails if incomplete struct is_scoped_enum<const _Tp> : bool_constant<!requires(_Tp __t, void(*__f)(int)) { __f(__t); }> { }; /** * @ingroup variable_templates */ template<typename _Tp> inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value; #endif // C++23 #ifdef _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED #define __cpp_lib_is_constant_evaluated 201811L /// Returns true only when called during constant evaluation. constexpr inline bool is_constant_evaluated() noexcept { return __builtin_is_constant_evaluated(); } /// @} #endif /// @cond undocumented template<typename _From, typename _To> using __copy_cv = typename __match_cv_qualifiers<_From, _To>::__type; template<typename _Xp, typename _Yp> using __cond_res = decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()()); template<typename _Ap, typename _Bp, typename = void> struct __common_ref_impl { }; // [meta.trans.other], COMMON-REF(A, B) template<typename _Ap, typename _Bp> using __common_ref = typename __common_ref_impl<_Ap, _Bp>::type; // COND-RES(COPYCV(X, Y) &, COPYCV(Y, X) &) template<typename _Xp, typename _Yp> using __condres_cvref = __cond_res<__copy_cv<_Xp, _Yp>&, __copy_cv<_Yp, _Xp>&>; // If A and B are both lvalue reference types, ... template<typename _Xp, typename _Yp> struct __common_ref_impl<_Xp&, _Yp&, __void_t<__condres_cvref<_Xp, _Yp>>> : enable_if<is_reference_v<__condres_cvref<_Xp, _Yp>>, __condres_cvref<_Xp, _Yp>> { }; // let C be remove_reference_t<COMMON-REF(X&, Y&)>&& template<typename _Xp, typename _Yp> using __common_ref_C = remove_reference_t<__common_ref<_Xp&, _Yp&>>&&; // If A and B are both rvalue reference types, ... template<typename _Xp, typename _Yp> struct __common_ref_impl<_Xp&&, _Yp&&, _Require<is_convertible<_Xp&&, __common_ref_C<_Xp, _Yp>>, is_convertible<_Yp&&, __common_ref_C<_Xp, _Yp>>>> { using type = __common_ref_C<_Xp, _Yp>; }; // let D be COMMON-REF(const X&, Y&) template<typename _Xp, typename _Yp> using __common_ref_D = __common_ref<const _Xp&, _Yp&>; // If A is an rvalue reference and B is an lvalue reference, ... template<typename _Xp, typename _Yp> struct __common_ref_impl<_Xp&&, _Yp&, _Require<is_convertible<_Xp&&, __common_ref_D<_Xp, _Yp>>>> { using type = __common_ref_D<_Xp, _Yp>; }; // If A is an lvalue reference and B is an rvalue reference, ... template<typename _Xp, typename _Yp> struct __common_ref_impl<_Xp&, _Yp&&> : __common_ref_impl<_Yp&&, _Xp&> { }; /// @endcond template<typename _Tp, typename _Up, template<typename> class _TQual, template<typename> class _UQual> struct basic_common_reference { }; /// @cond undocumented template<typename _Tp> struct __xref { template<typename _Up> using __type = __copy_cv<_Tp, _Up>; }; template<typename _Tp> struct __xref<_Tp&> { template<typename _Up> using __type = __copy_cv<_Tp, _Up>&; }; template<typename _Tp> struct __xref<_Tp&&> { template<typename _Up> using __type = __copy_cv<_Tp, _Up>&&; }; template<typename _Tp1, typename _Tp2> using __basic_common_ref = typename basic_common_reference<remove_cvref_t<_Tp1>, remove_cvref_t<_Tp2>, __xref<_Tp1>::template __type, __xref<_Tp2>::template __type>::type; /// @endcond template<typename... _Tp> struct common_reference; template<typename... _Tp> using common_reference_t = typename common_reference<_Tp...>::type; // If sizeof...(T) is zero, there shall be no member type. template<> struct common_reference<> { }; // If sizeof...(T) is one ... template<typename _Tp0> struct common_reference<_Tp0> { using type = _Tp0; }; /// @cond undocumented template<typename _Tp1, typename _Tp2, int _Bullet = 1, typename = void> struct __common_reference_impl : __common_reference_impl<_Tp1, _Tp2, _Bullet + 1> { }; // If sizeof...(T) is two ... template<typename _Tp1, typename _Tp2> struct common_reference<_Tp1, _Tp2> : __common_reference_impl<_Tp1, _Tp2> { }; // If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, ... template<typename _Tp1, typename _Tp2> struct __common_reference_impl<_Tp1&, _Tp2&, 1, void_t<__common_ref<_Tp1&, _Tp2&>>> { using type = __common_ref<_Tp1&, _Tp2&>; }; template<typename _Tp1, typename _Tp2> struct __common_reference_impl<_Tp1&&, _Tp2&&, 1, void_t<__common_ref<_Tp1&&, _Tp2&&>>> { using type = __common_ref<_Tp1&&, _Tp2&&>; }; template<typename _Tp1, typename _Tp2> struct __common_reference_impl<_Tp1&, _Tp2&&, 1, void_t<__common_ref<_Tp1&, _Tp2&&>>> { using type = __common_ref<_Tp1&, _Tp2&&>; }; template<typename _Tp1, typename _Tp2> struct __common_reference_impl<_Tp1&&, _Tp2&, 1, void_t<__common_ref<_Tp1&&, _Tp2&>>> { using type = __common_ref<_Tp1&&, _Tp2&>; }; // Otherwise, if basic_common_reference<...>::type is well-formed, ... template<typename _Tp1, typename _Tp2> struct __common_reference_impl<_Tp1, _Tp2, 2, void_t<__basic_common_ref<_Tp1, _Tp2>>> { using type = __basic_common_ref<_Tp1, _Tp2>; }; // Otherwise, if COND-RES(T1, T2) is well-formed, ... template<typename _Tp1, typename _Tp2> struct __common_reference_impl<_Tp1, _Tp2, 3, void_t<__cond_res<_Tp1, _Tp2>>> { using type = __cond_res<_Tp1, _Tp2>; }; // Otherwise, if common_type_t<T1, T2> is well-formed, ... template<typename _Tp1, typename _Tp2> struct __common_reference_impl<_Tp1, _Tp2, 4, void_t<common_type_t<_Tp1, _Tp2>>> { using type = common_type_t<_Tp1, _Tp2>; }; // Otherwise, there shall be no member type. template<typename _Tp1, typename _Tp2> struct __common_reference_impl<_Tp1, _Tp2, 5, void> { }; // Otherwise, if sizeof...(T) is greater than two, ... template<typename _Tp1, typename _Tp2, typename... _Rest> struct common_reference<_Tp1, _Tp2, _Rest...> : __common_type_fold<common_reference<_Tp1, _Tp2>, __common_type_pack<_Rest...>> { }; // Reuse __common_type_fold for common_reference<T1, T2, Rest...> template<typename _Tp1, typename _Tp2, typename... _Rest> struct __common_type_fold<common_reference<_Tp1, _Tp2>, __common_type_pack<_Rest...>, void_t<common_reference_t<_Tp1, _Tp2>>> : public common_reference<common_reference_t<_Tp1, _Tp2>, _Rest...> { }; /// @endcond #endif // C++2a /// @} group metaprogramming _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++11 #endif // _GLIBCXX_TYPE_TRAITS // <stack> -*- C++ -*- // Copyright (C) 2001-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /* * * Copyright (c) 1994 * Hewlett-Packard Company * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Hewlett-Packard Company makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * * Copyright (c) 1996,1997 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ /** @file include/stack * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_STACK #define _GLIBCXX_STACK 1 #pragma GCC system_header #include <deque> #include <bits/stl_stack.h> #endif /* _GLIBCXX_STACK */ // Exception Handling support header for -*- C++ -*- // Copyright (C) 1995-2021 Free Software Foundation, Inc. // // This file is part of GCC. // // GCC is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3, or (at your option) // any later version. // // GCC is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file exception * This is a Standard C++ Library header. */ #ifndef __EXCEPTION__ #define __EXCEPTION__ #pragma GCC system_header #pragma GCC visibility push(default) #include <bits/c++config.h> #include <bits/exception.h> extern "C++" { namespace std { /** @addtogroup exceptions * @{ */ /** If an %exception is thrown which is not listed in a function's * %exception specification, one of these may be thrown. * * @ingroup exceptions */ class bad_exception : public exception { public: bad_exception() _GLIBCXX_USE_NOEXCEPT { } // This declaration is not useless: // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 virtual ~bad_exception() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT; // See comment in eh_exception.cc. virtual const char* what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT; }; /// If you write a replacement %terminate handler, it must be of this type. typedef void (*terminate_handler) (); /// If you write a replacement %unexpected handler, it must be of this type. typedef void (*unexpected_handler) (); /// Takes a new handler function as an argument, returns the old function. terminate_handler set_terminate(terminate_handler) _GLIBCXX_USE_NOEXCEPT; #if __cplusplus >= 201103L /// Return the current terminate handler. terminate_handler get_terminate() noexcept; #endif /** The runtime will call this function if %exception handling must be * abandoned for any reason. It can also be called by the user. */ void terminate() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__noreturn__)); /// Takes a new handler function as an argument, returns the old function. unexpected_handler set_unexpected(unexpected_handler) _GLIBCXX_USE_NOEXCEPT; #if __cplusplus >= 201103L /// Return the current unexpected handler. unexpected_handler get_unexpected() noexcept; #endif /** The runtime will call this function if an %exception is thrown which * violates the function's %exception specification. */ void unexpected() __attribute__ ((__noreturn__)); /** [18.6.4]/1: 'Returns true after completing evaluation of a * throw-expression until either completing initialization of the * exception-declaration in the matching handler or entering `unexpected()` * due to the throw; or after entering `terminate()` for any reason * other than an explicit call to `terminate()`. [Note: This includes * stack unwinding [15.2]. end note]' * * 2: 'When `uncaught_exception()` is true, throwing an * %exception can result in a call of 1terminate()` * (15.5.1).' */ _GLIBCXX17_DEPRECATED_SUGGEST("std::uncaught_exceptions()") bool uncaught_exception() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); #if __cplusplus >= 201703L || !defined(__STRICT_ANSI__) // c++17 or gnu++98 #define __cpp_lib_uncaught_exceptions 201411L /** The number of uncaught exceptions. * @since C++17, or any non-strict mode, e.g. `-std=gnu++98` * @see uncaught_exception() */ int uncaught_exceptions() _GLIBCXX_USE_NOEXCEPT __attribute__ ((__pure__)); #endif /// @} group exceptions } // namespace std namespace __gnu_cxx { _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @brief A replacement for the standard terminate_handler which * prints more information about the terminating exception (if any) * on stderr. * * @ingroup exceptions * * Call * @code * std::set_terminate(__gnu_cxx::__verbose_terminate_handler) * @endcode * to use. For more info, see * http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt02ch06s02.html * * In 3.4 and later, this is on by default. */ void __verbose_terminate_handler(); _GLIBCXX_END_NAMESPACE_VERSION } // namespace } // extern "C++" #pragma GCC visibility pop #if (__cplusplus >= 201103L) #include <bits/exception_ptr.h> #include <bits/nested_exception.h> #endif #endif // -*- C++ -*- forwarding header. // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/cstdio * This is a Standard C++ Library file. You should @c \#include this file * in your programs, rather than any of the @a *.h implementation files. * * This is the C++ version of the Standard C Library header @c stdio.h, * and its contents are (mostly) the same as that header, but are all * contained in the namespace @c std (except for names which are defined * as macros in C). */ // // ISO C++ 14882: 27.8.2 C Library files // #pragma GCC system_header #include <bits/c++config.h> #include <stdio.h> #ifndef _GLIBCXX_CSTDIO #define _GLIBCXX_CSTDIO 1 #if __cplusplus <= 201103L && !defined(_GLIBCXX_HAVE_GETS) extern "C" char* gets (char* __s) __attribute__((__deprecated__)); #endif // Get rid of those macros defined in <stdio.h> in lieu of real functions. #undef clearerr #undef fclose #undef feof #undef ferror #undef fflush #undef fgetc #undef fgetpos #undef fgets #undef fopen #undef fprintf #undef fputc #undef fputs #undef fread #undef freopen #undef fscanf #undef fseek #undef fsetpos #undef ftell #undef fwrite #undef getc #undef getchar #if __cplusplus <= 201103L # undef gets #endif #undef perror #undef printf #undef putc #undef putchar #undef puts #undef remove #undef rename #undef rewind #undef scanf #undef setbuf #undef setvbuf #undef sprintf #undef sscanf #undef tmpfile #undef tmpnam #undef ungetc #undef vfprintf #undef vprintf #undef vsprintf namespace std { using ::FILE; using ::fpos_t; using ::clearerr; using ::fclose; using ::feof; using ::ferror; using ::fflush; using ::fgetc; using ::fgetpos; using ::fgets; using ::fopen; using ::fprintf; using ::fputc; using ::fputs; using ::fread; using ::freopen; using ::fscanf; using ::fseek; using ::fsetpos; using ::ftell; using ::fwrite; using ::getc; using ::getchar; #if __cplusplus <= 201103L // LWG 2249 using ::gets; #endif using ::perror; using ::printf; using ::putc; using ::putchar; using ::puts; using ::remove; using ::rename; using ::rewind; using ::scanf; using ::setbuf; using ::setvbuf; using ::sprintf; using ::sscanf; using ::tmpfile; #if _GLIBCXX_USE_TMPNAM using ::tmpnam; #endif using ::ungetc; using ::vfprintf; using ::vprintf; using ::vsprintf; } // namespace #if _GLIBCXX_USE_C99_STDIO #undef snprintf #undef vfscanf #undef vscanf #undef vsnprintf #undef vsscanf namespace __gnu_cxx { #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC extern "C" int (snprintf)(char * __restrict, std::size_t, const char * __restrict, ...) throw (); extern "C" int (vfscanf)(FILE * __restrict, const char * __restrict, __gnuc_va_list); extern "C" int (vscanf)(const char * __restrict, __gnuc_va_list); extern "C" int (vsnprintf)(char * __restrict, std::size_t, const char * __restrict, __gnuc_va_list) throw (); extern "C" int (vsscanf)(const char * __restrict, const char * __restrict, __gnuc_va_list) throw (); #endif #if !_GLIBCXX_USE_C99_DYNAMIC using ::snprintf; using ::vfscanf; using ::vscanf; using ::vsnprintf; using ::vsscanf; #endif } // namespace __gnu_cxx namespace std { using ::__gnu_cxx::snprintf; using ::__gnu_cxx::vfscanf; using ::__gnu_cxx::vscanf; using ::__gnu_cxx::vsnprintf; using ::__gnu_cxx::vsscanf; } // namespace std #endif // _GLIBCXX_USE_C99_STDIO #endif // <ctgmath> -*- C++ -*- // Copyright (C) 2007-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/ctgmath * This is a Standard C++ Library header. */ #pragma GCC system_header #ifndef _GLIBCXX_CTGMATH #define _GLIBCXX_CTGMATH 1 #if __cplusplus < 201103L # include <bits/c++0x_warning.h> #else # include <cmath> extern "C++" { # include <complex> } #endif #endif // String based streams -*- C++ -*- // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/sstream * This is a Standard C++ Library header. */ // // ISO C++ 14882: 27.7 String-based streams // #ifndef _GLIBCXX_SSTREAM #define _GLIBCXX_SSTREAM 1 #pragma GCC system_header #include <istream> #include <ostream> #include <bits/alloc_traits.h> // allocator_traits, __allocator_like #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI # define _GLIBCXX_LVAL_REF_QUAL & #else # define _GLIBCXX_LVAL_REF_QUAL #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_CXX11 // [27.7.1] template class basic_stringbuf /** * @brief The actual work of input and output (for std::string). * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. * * This class associates either or both of its input and output sequences * with a sequence of characters, which can be initialized from, or made * available as, a @c std::basic_string. (Paraphrased from [27.7.1]/1.) * * For this class, open modes (of type @c ios_base::openmode) have * @c in set if the input sequence can be read, and @c out set if the * output sequence can be written. */ template<typename _CharT, typename _Traits, typename _Alloc> class basic_stringbuf : public basic_streambuf<_CharT, _Traits> { struct __xfer_bufptrs; #if __cplusplus >= 201103L using allocator_traits = std::allocator_traits<_Alloc>; using _Noexcept_swap = __or_<typename allocator_traits::propagate_on_container_swap, typename allocator_traits::is_always_equal>; #endif public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef basic_streambuf<char_type, traits_type> __streambuf_type; typedef basic_string<char_type, _Traits, _Alloc> __string_type; typedef typename __string_type::size_type __size_type; protected: /// Place to stash in || out || in | out settings for current stringbuf. ios_base::openmode _M_mode; // Data Members: __string_type _M_string; public: // Constructors: /** * @brief Starts with an empty string buffer. * * The default constructor initializes the parent class using its * own default ctor. */ basic_stringbuf() : __streambuf_type(), _M_mode(ios_base::in | ios_base::out), _M_string() { } /** * @brief Starts with an empty string buffer. * @param __mode Whether the buffer can read, or write, or both. * * The default constructor initializes the parent class using its * own default ctor. */ explicit basic_stringbuf(ios_base::openmode __mode) : __streambuf_type(), _M_mode(__mode), _M_string() { } /** * @brief Starts with an existing string buffer. * @param __str A string to copy as a starting buffer. * @param __mode Whether the buffer can read, or write, or both. * * This constructor initializes the parent class using its * own default ctor. */ explicit basic_stringbuf(const __string_type& __str, ios_base::openmode __mode = ios_base::in | ios_base::out) : __streambuf_type(), _M_mode(), _M_string(__str.data(), __str.size(), __str.get_allocator()) { _M_stringbuf_init(__mode); } #if __cplusplus >= 201103L basic_stringbuf(const basic_stringbuf&) = delete; basic_stringbuf(basic_stringbuf&& __rhs) : basic_stringbuf(std::move(__rhs), __xfer_bufptrs(__rhs, this)) { __rhs._M_sync(const_cast<char_type*>(__rhs._M_string.data()), 0, 0); } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI explicit basic_stringbuf(const allocator_type& __a) : basic_stringbuf(ios_base::in | std::ios_base::out, __a) { } basic_stringbuf(ios_base::openmode __mode, const allocator_type& __a) : __streambuf_type(), _M_mode(__mode), _M_string(__a) { } explicit basic_stringbuf(__string_type&& __s, ios_base::openmode __mode = ios_base::in | ios_base::out) : __streambuf_type(), _M_mode(__mode), _M_string(std::move(__s)) { _M_stringbuf_init(__mode); } template<typename _SAlloc> basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s, const allocator_type& __a) : basic_stringbuf(__s, ios_base::in | std::ios_base::out, __a) { } template<typename _SAlloc> basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s, ios_base::openmode __mode, const allocator_type& __a) : __streambuf_type(), _M_mode(__mode), _M_string(__s.data(), __s.size(), __a) { _M_stringbuf_init(__mode); } template<typename _SAlloc> explicit basic_stringbuf(const basic_string<_CharT, _Traits, _SAlloc>& __s, ios_base::openmode __mode = ios_base::in | ios_base::out) : basic_stringbuf(__s, __mode, allocator_type{}) { } basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a) : basic_stringbuf(std::move(__rhs), __a, __xfer_bufptrs(__rhs, this)) { __rhs._M_sync(const_cast<char_type*>(__rhs._M_string.data()), 0, 0); } allocator_type get_allocator() const noexcept { return _M_string.get_allocator(); } #endif // C++20 // 27.8.2.2 Assign and swap: basic_stringbuf& operator=(const basic_stringbuf&) = delete; basic_stringbuf& operator=(basic_stringbuf&& __rhs) { __xfer_bufptrs __st{__rhs, this}; const __streambuf_type& __base = __rhs; __streambuf_type::operator=(__base); this->pubimbue(__rhs.getloc()); _M_mode = __rhs._M_mode; _M_string = std::move(__rhs._M_string); __rhs._M_sync(const_cast<char_type*>(__rhs._M_string.data()), 0, 0); return *this; } void swap(basic_stringbuf& __rhs) noexcept(_Noexcept_swap::value) { __xfer_bufptrs __l_st{*this, std::__addressof(__rhs)}; __xfer_bufptrs __r_st{__rhs, this}; __streambuf_type& __base = __rhs; __streambuf_type::swap(__base); __rhs.pubimbue(this->pubimbue(__rhs.getloc())); std::swap(_M_mode, __rhs._M_mode); std::swap(_M_string, __rhs._M_string); // XXX not exception safe } #endif // C++11 // Getters and setters: /** * @brief Copying out the string buffer. * @return A copy of one of the underlying sequences. * * <em>If the buffer is only created in input mode, the underlying * character sequence is equal to the input sequence; otherwise, it * is equal to the output sequence.</em> [27.7.1.2]/1 */ __string_type str() const _GLIBCXX_LVAL_REF_QUAL { __string_type __ret(_M_string.get_allocator()); if (char_type* __hi = _M_high_mark()) __ret.assign(this->pbase(), __hi); else __ret = _M_string; return __ret; } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI #if __cpp_concepts template<__allocator_like _SAlloc> basic_string<_CharT, _Traits, _SAlloc> str(const _SAlloc& __sa) const { auto __sv = view(); return { __sv.data(), __sv.size(), __sa }; } #endif __string_type str() && { if (char_type* __hi = _M_high_mark()) { // Set length to end of character sequence and add null terminator. _M_string._M_set_length(_M_high_mark() - this->pbase()); } auto __str = std::move(_M_string); _M_string.clear(); _M_sync(_M_string.data(), 0, 0); return __str; } basic_string_view<char_type, traits_type> view() const noexcept { if (char_type* __hi = _M_high_mark()) return { this->pbase(), __hi }; else return _M_string; } #endif // C++20 /** * @brief Setting a new buffer. * @param __s The string to use as a new sequence. * * Deallocates any previous stored sequence, then copies @a s to * use as a new one. */ void str(const __string_type& __s) { // Cannot use _M_string = __s, since v3 strings are COW // (not always true now but assign() always works). _M_string.assign(__s.data(), __s.size()); _M_stringbuf_init(_M_mode); } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI #if __cpp_concepts template<__allocator_like _SAlloc> requires (!is_same_v<_SAlloc, _Alloc>) void str(const basic_string<_CharT, _Traits, _SAlloc>& __s) { _M_string.assign(__s.data(), __s.size()); _M_stringbuf_init(_M_mode); } #endif void str(__string_type&& __s) { _M_string = std::move(__s); _M_stringbuf_init(_M_mode); } #endif protected: // Common initialization code goes here. void _M_stringbuf_init(ios_base::openmode __mode) { _M_mode = __mode; __size_type __len = 0; if (_M_mode & (ios_base::ate | ios_base::app)) __len = _M_string.size(); _M_sync(const_cast<char_type*>(_M_string.data()), 0, __len); } virtual streamsize showmanyc() { streamsize __ret = -1; if (_M_mode & ios_base::in) { _M_update_egptr(); __ret = this->egptr() - this->gptr(); } return __ret; } virtual int_type underflow(); virtual int_type pbackfail(int_type __c = traits_type::eof()); virtual int_type overflow(int_type __c = traits_type::eof()); /** * @brief Manipulates the buffer. * @param __s Pointer to a buffer area. * @param __n Size of @a __s. * @return @c this * * If no buffer has already been created, and both @a __s and @a __n are * non-zero, then @c __s is used as a buffer; see * https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering * for more. */ virtual __streambuf_type* setbuf(char_type* __s, streamsize __n) { if (__s && __n >= 0) { // This is implementation-defined behavior, and assumes // that an external char_type array of length __n exists // and has been pre-allocated. If this is not the case, // things will quickly blow up. // Step 1: Destroy the current internal array. _M_string.clear(); // Step 2: Use the external array. _M_sync(__s, __n, 0); } return this; } virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode = ios_base::in | ios_base::out); virtual pos_type seekpos(pos_type __sp, ios_base::openmode __mode = ios_base::in | ios_base::out); // Internal function for correctly updating the internal buffer // for a particular _M_string, due to initialization or re-sizing // of an existing _M_string. void _M_sync(char_type* __base, __size_type __i, __size_type __o); // Internal function for correctly updating egptr() to the actual // string end. void _M_update_egptr() { if (char_type* __pptr = this->pptr()) { char_type* __egptr = this->egptr(); if (!__egptr || __pptr > __egptr) { if (_M_mode & ios_base::in) this->setg(this->eback(), this->gptr(), __pptr); else this->setg(__pptr, __pptr, __pptr); } } } // Works around the issue with pbump, part of the protected // interface of basic_streambuf, taking just an int. void _M_pbump(char_type* __pbeg, char_type* __pend, off_type __off); private: // Return a pointer to the end of the underlying character sequence. // This might not be the same character as _M_string.end() because // basic_stringbuf::overflow might have written to unused capacity // in _M_string without updating its length. __attribute__((__always_inline__)) char_type* _M_high_mark() const _GLIBCXX_NOEXCEPT { if (char_type* __pptr = this->pptr()) { char_type* __egptr = this->egptr(); if (!__egptr || __pptr > __egptr) return __pptr; // Underlying sequence is [pbase, pptr). else return __egptr; // Underlying sequence is [pbase, egptr). } return 0; // Underlying character sequence is just _M_string. } #if __cplusplus >= 201103L #if _GLIBCXX_USE_CXX11_ABI // This type captures the state of the gptr / pptr pointers as offsets // so they can be restored in another object after moving the string. struct __xfer_bufptrs { __xfer_bufptrs(const basic_stringbuf& __from, basic_stringbuf* __to) : _M_to{__to}, _M_goff{-1, -1, -1}, _M_poff{-1, -1, -1} { const _CharT* const __str = __from._M_string.data(); const _CharT* __end = nullptr; if (__from.eback()) { _M_goff[0] = __from.eback() - __str; _M_goff[1] = __from.gptr() - __str; _M_goff[2] = __from.egptr() - __str; __end = __from.egptr(); } if (__from.pbase()) { _M_poff[0] = __from.pbase() - __str; _M_poff[1] = __from.pptr() - __from.pbase(); _M_poff[2] = __from.epptr() - __str; if (!__end || __from.pptr() > __end) __end = __from.pptr(); } // Set _M_string length to the greater of the get and put areas. if (__end) { // The const_cast avoids changing this constructor's signature, // because it is exported from the dynamic library. auto& __mut_from = const_cast<basic_stringbuf&>(__from); __mut_from._M_string._M_length(__end - __str); } } ~__xfer_bufptrs() { char_type* __str = const_cast<char_type*>(_M_to->_M_string.data()); if (_M_goff[0] != -1) _M_to->setg(__str+_M_goff[0], __str+_M_goff[1], __str+_M_goff[2]); if (_M_poff[0] != -1) _M_to->_M_pbump(__str+_M_poff[0], __str+_M_poff[2], _M_poff[1]); } basic_stringbuf* _M_to; off_type _M_goff[3]; off_type _M_poff[3]; }; #else // This type does nothing when using Copy-On-Write strings. struct __xfer_bufptrs { __xfer_bufptrs(const basic_stringbuf&, basic_stringbuf*) { } }; #endif // The move constructor initializes an __xfer_bufptrs temporary then // delegates to this constructor to performs moves during its lifetime. basic_stringbuf(basic_stringbuf&& __rhs, __xfer_bufptrs&&) : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)), _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string)) { } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI // The move constructor initializes an __xfer_bufptrs temporary then // delegates to this constructor to performs moves during its lifetime. basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a, __xfer_bufptrs&&) : __streambuf_type(static_cast<const __streambuf_type&>(__rhs)), _M_mode(__rhs._M_mode), _M_string(std::move(__rhs._M_string), __a) { } #endif #endif // C++11 }; // [27.7.2] Template class basic_istringstream /** * @brief Controlling input for std::string. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. * * This class supports reading from objects of type std::basic_string, * using the inherited functions from std::basic_istream. To control * the associated sequence, an instance of std::basic_stringbuf is used, * which this page refers to as @c sb. */ template<typename _CharT, typename _Traits, typename _Alloc> class basic_istringstream : public basic_istream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard types: typedef basic_string<_CharT, _Traits, _Alloc> __string_type; typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; typedef basic_istream<char_type, traits_type> __istream_type; private: __stringbuf_type _M_stringbuf; public: // Constructors: /** * @brief Default constructor starts with an empty string buffer. * * Initializes @c sb using @c in, and passes @c &sb to the base * class initializer. Does not allocate any buffer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ basic_istringstream() : __istream_type(), _M_stringbuf(ios_base::in) { this->init(&_M_stringbuf); } /** * @brief Starts with an empty string buffer. * @param __mode Whether the buffer can read, or write, or both. * * @c ios_base::in is automatically included in @a __mode. * * Initializes @c sb using @c __mode|in, and passes @c &sb to the base * class initializer. Does not allocate any buffer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ explicit basic_istringstream(ios_base::openmode __mode) : __istream_type(), _M_stringbuf(__mode | ios_base::in) { this->init(&_M_stringbuf); } /** * @brief Starts with an existing string buffer. * @param __str A string to copy as a starting buffer. * @param __mode Whether the buffer can read, or write, or both. * * @c ios_base::in is automatically included in @a mode. * * Initializes @c sb using @a str and @c mode|in, and passes @c &sb * to the base class initializer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ explicit basic_istringstream(const __string_type& __str, ios_base::openmode __mode = ios_base::in) : __istream_type(), _M_stringbuf(__str, __mode | ios_base::in) { this->init(&_M_stringbuf); } /** * @brief The destructor does nothing. * * The buffer is deallocated by the stringbuf object, not the * formatting stream. */ ~basic_istringstream() { } #if __cplusplus >= 201103L basic_istringstream(const basic_istringstream&) = delete; basic_istringstream(basic_istringstream&& __rhs) : __istream_type(std::move(__rhs)), _M_stringbuf(std::move(__rhs._M_stringbuf)) { __istream_type::set_rdbuf(&_M_stringbuf); } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI basic_istringstream(ios_base::openmode __mode, const allocator_type& __a) : __istream_type(), _M_stringbuf(__mode | ios_base::in, __a) { this->init(std::__addressof(_M_stringbuf)); } explicit basic_istringstream(__string_type&& __str, ios_base::openmode __mode = ios_base::in) : __istream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::in) { this->init(std::__addressof(_M_stringbuf)); } template<typename _SAlloc> basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, const allocator_type& __a) : basic_istringstream(__str, ios_base::in, __a) { } template<typename _SAlloc> basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, ios_base::openmode __mode, const allocator_type& __a) : __istream_type(), _M_stringbuf(__str, __mode | ios_base::in, __a) { this->init(std::__addressof(_M_stringbuf)); } template<typename _SAlloc> explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, ios_base::openmode __mode = ios_base::in) : basic_istringstream(__str, __mode, allocator_type()) { } #endif // C++20 // 27.8.3.2 Assign and swap: basic_istringstream& operator=(const basic_istringstream&) = delete; basic_istringstream& operator=(basic_istringstream&& __rhs) { __istream_type::operator=(std::move(__rhs)); _M_stringbuf = std::move(__rhs._M_stringbuf); return *this; } void swap(basic_istringstream& __rhs) { __istream_type::swap(__rhs); _M_stringbuf.swap(__rhs._M_stringbuf); } #endif // C++11 // Members: /** * @brief Accessing the underlying buffer. * @return The current basic_stringbuf buffer. * * This hides both signatures of std::basic_ios::rdbuf(). */ __stringbuf_type* rdbuf() const { return const_cast<__stringbuf_type*>(&_M_stringbuf); } /** * @brief Copying out the string buffer. * @return @c rdbuf()->str() */ __string_type str() const _GLIBCXX_LVAL_REF_QUAL { return _M_stringbuf.str(); } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI #if __cpp_concepts template<__allocator_like _SAlloc> basic_string<_CharT, _Traits, _SAlloc> str(const _SAlloc& __sa) const { return _M_stringbuf.str(__sa); } #endif __string_type str() && { return std::move(_M_stringbuf).str(); } basic_string_view<char_type, traits_type> view() const noexcept { return _M_stringbuf.view(); } #endif /** * @brief Setting a new buffer. * @param __s The string to use as a new sequence. * * Calls @c rdbuf()->str(s). */ void str(const __string_type& __s) { _M_stringbuf.str(__s); } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI #if __cpp_concepts template<__allocator_like _SAlloc> requires (!is_same_v<_SAlloc, _Alloc>) void str(const basic_string<_CharT, _Traits, _SAlloc>& __s) { _M_stringbuf.str(__s); } #endif void str(__string_type&& __s) { _M_stringbuf.str(std::move(__s)); } #endif }; // [27.7.3] Template class basic_ostringstream /** * @brief Controlling output for std::string. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. * * This class supports writing to objects of type std::basic_string, * using the inherited functions from std::basic_ostream. To control * the associated sequence, an instance of std::basic_stringbuf is used, * which this page refers to as @c sb. */ template <typename _CharT, typename _Traits, typename _Alloc> class basic_ostringstream : public basic_ostream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard types: typedef basic_string<_CharT, _Traits, _Alloc> __string_type; typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; typedef basic_ostream<char_type, traits_type> __ostream_type; private: __stringbuf_type _M_stringbuf; public: // Constructors/destructor: /** * @brief Default constructor starts with an empty string buffer. * * Initializes @c sb using @c mode|out, and passes @c &sb to the base * class initializer. Does not allocate any buffer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ basic_ostringstream() : __ostream_type(), _M_stringbuf(ios_base::out) { this->init(&_M_stringbuf); } /** * @brief Starts with an empty string buffer. * @param __mode Whether the buffer can read, or write, or both. * * @c ios_base::out is automatically included in @a mode. * * Initializes @c sb using @c mode|out, and passes @c &sb to the base * class initializer. Does not allocate any buffer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ explicit basic_ostringstream(ios_base::openmode __mode) : __ostream_type(), _M_stringbuf(__mode | ios_base::out) { this->init(&_M_stringbuf); } /** * @brief Starts with an existing string buffer. * @param __str A string to copy as a starting buffer. * @param __mode Whether the buffer can read, or write, or both. * * @c ios_base::out is automatically included in @a mode. * * Initializes @c sb using @a str and @c mode|out, and passes @c &sb * to the base class initializer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ explicit basic_ostringstream(const __string_type& __str, ios_base::openmode __mode = ios_base::out) : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::out) { this->init(&_M_stringbuf); } /** * @brief The destructor does nothing. * * The buffer is deallocated by the stringbuf object, not the * formatting stream. */ ~basic_ostringstream() { } #if __cplusplus >= 201103L basic_ostringstream(const basic_ostringstream&) = delete; basic_ostringstream(basic_ostringstream&& __rhs) : __ostream_type(std::move(__rhs)), _M_stringbuf(std::move(__rhs._M_stringbuf)) { __ostream_type::set_rdbuf(&_M_stringbuf); } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI basic_ostringstream(ios_base::openmode __mode, const allocator_type& __a) : __ostream_type(), _M_stringbuf(__mode | ios_base::out, __a) { this->init(std::__addressof(_M_stringbuf)); } explicit basic_ostringstream(__string_type&& __str, ios_base::openmode __mode = ios_base::out) : __ostream_type(), _M_stringbuf(std::move(__str), __mode | ios_base::out) { this->init(std::__addressof(_M_stringbuf)); } template<typename _SAlloc> basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, const allocator_type& __a) : basic_ostringstream(__str, ios_base::out, __a) { } template<typename _SAlloc> basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, ios_base::openmode __mode, const allocator_type& __a) : __ostream_type(), _M_stringbuf(__str, __mode | ios_base::out, __a) { this->init(std::__addressof(_M_stringbuf)); } template<typename _SAlloc> explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, ios_base::openmode __mode = ios_base::out) : basic_ostringstream(__str, __mode, allocator_type()) { } #endif // C++20 // 27.8.3.2 Assign and swap: basic_ostringstream& operator=(const basic_ostringstream&) = delete; basic_ostringstream& operator=(basic_ostringstream&& __rhs) { __ostream_type::operator=(std::move(__rhs)); _M_stringbuf = std::move(__rhs._M_stringbuf); return *this; } void swap(basic_ostringstream& __rhs) { __ostream_type::swap(__rhs); _M_stringbuf.swap(__rhs._M_stringbuf); } #endif // C++11 // Members: /** * @brief Accessing the underlying buffer. * @return The current basic_stringbuf buffer. * * This hides both signatures of std::basic_ios::rdbuf(). */ __stringbuf_type* rdbuf() const { return const_cast<__stringbuf_type*>(&_M_stringbuf); } /** * @brief Copying out the string buffer. * @return @c rdbuf()->str() */ __string_type str() const _GLIBCXX_LVAL_REF_QUAL { return _M_stringbuf.str(); } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI #if __cpp_concepts template<__allocator_like _SAlloc> basic_string<_CharT, _Traits, _SAlloc> str(const _SAlloc& __sa) const { return _M_stringbuf.str(__sa); } #endif __string_type str() && { return std::move(_M_stringbuf).str(); } basic_string_view<char_type, traits_type> view() const noexcept { return _M_stringbuf.view(); } #endif /** * @brief Setting a new buffer. * @param __s The string to use as a new sequence. * * Calls @c rdbuf()->str(s). */ void str(const __string_type& __s) { _M_stringbuf.str(__s); } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI #if __cpp_concepts template<__allocator_like _SAlloc> requires (!is_same_v<_SAlloc, _Alloc>) void str(const basic_string<_CharT, _Traits, _SAlloc>& __s) { _M_stringbuf.str(__s); } #endif void str(__string_type&& __s) { _M_stringbuf.str(std::move(__s)); } #endif }; // [27.7.4] Template class basic_stringstream /** * @brief Controlling input and output for std::string. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * @tparam _Alloc Allocator type, defaults to allocator<_CharT>. * * This class supports reading from and writing to objects of type * std::basic_string, using the inherited functions from * std::basic_iostream. To control the associated sequence, an instance * of std::basic_stringbuf is used, which this page refers to as @c sb. */ template <typename _CharT, typename _Traits, typename _Alloc> class basic_stringstream : public basic_iostream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 251. basic_stringbuf missing allocator_type typedef _Alloc allocator_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard Types: typedef basic_string<_CharT, _Traits, _Alloc> __string_type; typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; typedef basic_iostream<char_type, traits_type> __iostream_type; private: __stringbuf_type _M_stringbuf; public: // Constructors/destructors /** * @brief Default constructor starts with an empty string buffer. * * Initializes @c sb using the mode @c in|out, and passes @c &sb * to the base class initializer. Does not allocate any buffer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ basic_stringstream() : __iostream_type(), _M_stringbuf(ios_base::out | ios_base::in) { this->init(&_M_stringbuf); } /** * @brief Starts with an empty string buffer. * @param __m Whether the buffer can read, or write, or both. * * Initializes @c sb using the mode from @c __m, and passes @c &sb * to the base class initializer. Does not allocate any buffer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ explicit basic_stringstream(ios_base::openmode __m) : __iostream_type(), _M_stringbuf(__m) { this->init(&_M_stringbuf); } /** * @brief Starts with an existing string buffer. * @param __str A string to copy as a starting buffer. * @param __m Whether the buffer can read, or write, or both. * * Initializes @c sb using @a __str and @c __m, and passes @c &sb * to the base class initializer. * * That's a lie. We initialize the base class with NULL, because the * string class does its own memory management. */ explicit basic_stringstream(const __string_type& __str, ios_base::openmode __m = ios_base::out | ios_base::in) : __iostream_type(), _M_stringbuf(__str, __m) { this->init(&_M_stringbuf); } /** * @brief The destructor does nothing. * * The buffer is deallocated by the stringbuf object, not the * formatting stream. */ ~basic_stringstream() { } #if __cplusplus >= 201103L basic_stringstream(const basic_stringstream&) = delete; basic_stringstream(basic_stringstream&& __rhs) : __iostream_type(std::move(__rhs)), _M_stringbuf(std::move(__rhs._M_stringbuf)) { __iostream_type::set_rdbuf(&_M_stringbuf); } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI basic_stringstream(ios_base::openmode __mode, const allocator_type& __a) : __iostream_type(), _M_stringbuf(__mode, __a) { this->init(&_M_stringbuf); } explicit basic_stringstream(__string_type&& __str, ios_base::openmode __mode = ios_base::in | ios_base::out) : __iostream_type(), _M_stringbuf(std::move(__str), __mode) { this->init(std::__addressof(_M_stringbuf)); } template<typename _SAlloc> basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, const allocator_type& __a) : basic_stringstream(__str, ios_base::in | ios_base::out, __a) { } template<typename _SAlloc> basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, ios_base::openmode __mode, const allocator_type& __a) : __iostream_type(), _M_stringbuf(__str, __mode, __a) { this->init(std::__addressof(_M_stringbuf)); } template<typename _SAlloc> explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __str, ios_base::openmode __mode = ios_base::in | ios_base::out) : basic_stringstream(__str, __mode, allocator_type()) { } #endif // C++20 // 27.8.3.2 Assign and swap: basic_stringstream& operator=(const basic_stringstream&) = delete; basic_stringstream& operator=(basic_stringstream&& __rhs) { __iostream_type::operator=(std::move(__rhs)); _M_stringbuf = std::move(__rhs._M_stringbuf); return *this; } void swap(basic_stringstream& __rhs) { __iostream_type::swap(__rhs); _M_stringbuf.swap(__rhs._M_stringbuf); } #endif // C++11 // Members: /** * @brief Accessing the underlying buffer. * @return The current basic_stringbuf buffer. * * This hides both signatures of std::basic_ios::rdbuf(). */ __stringbuf_type* rdbuf() const { return const_cast<__stringbuf_type*>(&_M_stringbuf); } /** * @brief Copying out the string buffer. * @return @c rdbuf()->str() */ __string_type str() const _GLIBCXX_LVAL_REF_QUAL { return _M_stringbuf.str(); } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI #if __cpp_concepts template<__allocator_like _SAlloc> basic_string<_CharT, _Traits, _SAlloc> str(const _SAlloc& __sa) const { return _M_stringbuf.str(__sa); } #endif __string_type str() && { return std::move(_M_stringbuf).str(); } basic_string_view<char_type, traits_type> view() const noexcept { return _M_stringbuf.view(); } #endif /** * @brief Setting a new buffer. * @param __s The string to use as a new sequence. * * Calls @c rdbuf()->str(s). */ void str(const __string_type& __s) { _M_stringbuf.str(__s); } #if __cplusplus > 201703L && _GLIBCXX_USE_CXX11_ABI #if __cpp_concepts template<__allocator_like _SAlloc> requires (!is_same_v<_SAlloc, _Alloc>) void str(const basic_string<_CharT, _Traits, _SAlloc>& __s) { _M_stringbuf.str(__s); } #endif void str(__string_type&& __s) { _M_stringbuf.str(std::move(__s)); } #endif }; #if __cplusplus >= 201103L /// Swap specialization for stringbufs. template <class _CharT, class _Traits, class _Allocator> inline void swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, basic_stringbuf<_CharT, _Traits, _Allocator>& __y) noexcept(noexcept(__x.swap(__y))) { __x.swap(__y); } /// Swap specialization for istringstreams. template <class _CharT, class _Traits, class _Allocator> inline void swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, basic_istringstream<_CharT, _Traits, _Allocator>& __y) { __x.swap(__y); } /// Swap specialization for ostringstreams. template <class _CharT, class _Traits, class _Allocator> inline void swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, basic_ostringstream<_CharT, _Traits, _Allocator>& __y) { __x.swap(__y); } /// Swap specialization for stringstreams. template <class _CharT, class _Traits, class _Allocator> inline void swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, basic_stringstream<_CharT, _Traits, _Allocator>& __y) { __x.swap(__y); } #endif // C++11 _GLIBCXX_END_NAMESPACE_CXX11 _GLIBCXX_END_NAMESPACE_VERSION } // namespace #undef _GLIBCXX_LVAL_REF_QUAL #include <bits/sstream.tcc> #endif /* _GLIBCXX_SSTREAM */ // <stop_token> -*- C++ -*- // Copyright (C) 2019-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/stop_token * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_STOP_TOKEN #define _GLIBCXX_STOP_TOKEN #if __cplusplus > 201703L #include <atomic> #include <bits/std_thread.h> #include <semaphore> #define __cpp_lib_jthread 201911L namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /// Tag type indicating a stop_source should have no shared-stop-state. struct nostopstate_t { explicit nostopstate_t() = default; }; inline constexpr nostopstate_t nostopstate{}; class stop_source; /// Allow testing whether a stop request has been made on a `stop_source`. class stop_token { public: stop_token() noexcept = default; stop_token(const stop_token&) noexcept = default; stop_token(stop_token&&) noexcept = default; ~stop_token() = default; stop_token& operator=(const stop_token&) noexcept = default; stop_token& operator=(stop_token&&) noexcept = default; [[nodiscard]] bool stop_possible() const noexcept { return static_cast<bool>(_M_state) && _M_state->_M_stop_possible(); } [[nodiscard]] bool stop_requested() const noexcept { return static_cast<bool>(_M_state) && _M_state->_M_stop_requested(); } void swap(stop_token& __rhs) noexcept { _M_state.swap(__rhs._M_state); } [[nodiscard]] friend bool operator==(const stop_token& __a, const stop_token& __b) { return __a._M_state == __b._M_state; } friend void swap(stop_token& __lhs, stop_token& __rhs) noexcept { __lhs.swap(__rhs); } private: friend class stop_source; template<typename _Callback> friend class stop_callback; static void _S_yield() noexcept { #if defined __i386__ || defined __x86_64__ __builtin_ia32_pause(); #endif this_thread::yield(); } #ifndef __cpp_lib_semaphore struct binary_semaphore { explicit binary_semaphore(int __d) : _M_counter(__d > 0) { } void release() { _M_counter.fetch_add(1, memory_order::release); } void acquire() { int __old = 1; while (!_M_counter.compare_exchange_weak(__old, 0, memory_order::acquire, memory_order::relaxed)) { __old = 1; _S_yield(); } } atomic<int> _M_counter; }; #endif struct _Stop_cb { using __cb_type = void(_Stop_cb*) noexcept; __cb_type* _M_callback; _Stop_cb* _M_prev = nullptr; _Stop_cb* _M_next = nullptr; bool* _M_destroyed = nullptr; binary_semaphore _M_done{0}; [[__gnu__::__nonnull__]] explicit _Stop_cb(__cb_type* __cb) : _M_callback(__cb) { } void _M_run() noexcept { _M_callback(this); } }; struct _Stop_state_t { using value_type = uint32_t; static constexpr value_type _S_stop_requested_bit = 1; static constexpr value_type _S_locked_bit = 2; static constexpr value_type _S_ssrc_counter_inc = 4; std::atomic<value_type> _M_owners{1}; std::atomic<value_type> _M_value{_S_ssrc_counter_inc}; _Stop_cb* _M_head = nullptr; std::thread::id _M_requester; _Stop_state_t() = default; bool _M_stop_possible() noexcept { // true if a stop request has already been made or there are still // stop_source objects that would allow one to be made. return _M_value.load(memory_order::acquire) & ~_S_locked_bit; } bool _M_stop_requested() noexcept { return _M_value.load(memory_order::acquire) & _S_stop_requested_bit; } void _M_add_owner() noexcept { _M_owners.fetch_add(1, memory_order::relaxed); } void _M_release_ownership() noexcept { if (_M_owners.fetch_sub(1, memory_order::acq_rel) == 1) delete this; } void _M_add_ssrc() noexcept { _M_value.fetch_add(_S_ssrc_counter_inc, memory_order::relaxed); } void _M_sub_ssrc() noexcept { _M_value.fetch_sub(_S_ssrc_counter_inc, memory_order::release); } // Obtain lock. void _M_lock() noexcept { // Can use relaxed loads to get the current value. // The successful call to _M_try_lock is an acquire operation. auto __old = _M_value.load(memory_order::relaxed); while (!_M_try_lock(__old, memory_order::relaxed)) { } } // Precondition: calling thread holds the lock. void _M_unlock() noexcept { _M_value.fetch_sub(_S_locked_bit, memory_order::release); } bool _M_request_stop() noexcept { // obtain lock and set stop_requested bit auto __old = _M_value.load(memory_order::acquire); do { if (__old & _S_stop_requested_bit) // stop request already made return false; } while (!_M_try_lock_and_stop(__old)); _M_requester = this_thread::get_id(); while (_M_head) { bool __last_cb; _Stop_cb* __cb = _M_head; _M_head = _M_head->_M_next; if (_M_head) { _M_head->_M_prev = nullptr; __last_cb = false; } else __last_cb = true; // Allow other callbacks to be unregistered while __cb runs. _M_unlock(); bool __destroyed = false; __cb->_M_destroyed = &__destroyed; // run callback __cb->_M_run(); if (!__destroyed) { __cb->_M_destroyed = nullptr; // synchronize with destructor of stop_callback that owns *__cb if (!__gnu_cxx::__is_single_threaded()) __cb->_M_done.release(); } // Avoid relocking if we already know there are no more callbacks. if (__last_cb) return true; _M_lock(); } _M_unlock(); return true; } [[__gnu__::__nonnull__]] bool _M_register_callback(_Stop_cb* __cb) noexcept { auto __old = _M_value.load(memory_order::acquire); do { if (__old & _S_stop_requested_bit) // stop request already made { __cb->_M_run(); // run synchronously return false; } if (__old < _S_ssrc_counter_inc) // no stop_source owns *this // No need to register callback if no stop request can be made. // Returning false also means the stop_callback does not share // ownership of this state, but that's not observable. return false; } while (!_M_try_lock(__old)); __cb->_M_next = _M_head; if (_M_head) { _M_head->_M_prev = __cb; } _M_head = __cb; _M_unlock(); return true; } // Called by ~stop_callback just before destroying *__cb. [[__gnu__::__nonnull__]] void _M_remove_callback(_Stop_cb* __cb) { _M_lock(); if (__cb == _M_head) { _M_head = _M_head->_M_next; if (_M_head) _M_head->_M_prev = nullptr; _M_unlock(); return; } else if (__cb->_M_prev) { __cb->_M_prev->_M_next = __cb->_M_next; if (__cb->_M_next) __cb->_M_next->_M_prev = __cb->_M_prev; _M_unlock(); return; } _M_unlock(); // Callback is not in the list, so must have been removed by a call to // _M_request_stop. // Despite appearances there is no data race on _M_requester. The only // write to it happens before the callback is removed from the list, // and removing it from the list happens before this read. if (!(_M_requester == this_thread::get_id())) { // Synchronize with completion of callback. __cb->_M_done.acquire(); // Safe for ~stop_callback to destroy *__cb now. return; } if (__cb->_M_destroyed) *__cb->_M_destroyed = true; } // Try to obtain the lock. // Returns true if the lock is acquired (with memory order acquire). // Otherwise, sets __curval = _M_value.load(__failure) and returns false. // Might fail spuriously, so must be called in a loop. bool _M_try_lock(value_type& __curval, memory_order __failure = memory_order::acquire) noexcept { return _M_do_try_lock(__curval, 0, memory_order::acquire, __failure); } // Try to obtain the lock to make a stop request. // Returns true if the lock is acquired and the _S_stop_requested_bit is // set (with memory order acq_rel so that other threads see the request). // Otherwise, sets __curval = _M_value.load(memory_order::acquire) and // returns false. // Might fail spuriously, so must be called in a loop. bool _M_try_lock_and_stop(value_type& __curval) noexcept { return _M_do_try_lock(__curval, _S_stop_requested_bit, memory_order::acq_rel, memory_order::acquire); } bool _M_do_try_lock(value_type& __curval, value_type __newbits, memory_order __success, memory_order __failure) noexcept { if (__curval & _S_locked_bit) { _S_yield(); __curval = _M_value.load(__failure); return false; } __newbits |= _S_locked_bit; return _M_value.compare_exchange_weak(__curval, __curval | __newbits, __success, __failure); } }; struct _Stop_state_ref { _Stop_state_ref() = default; explicit _Stop_state_ref(const stop_source&) : _M_ptr(new _Stop_state_t()) { } _Stop_state_ref(const _Stop_state_ref& __other) noexcept : _M_ptr(__other._M_ptr) { if (_M_ptr) _M_ptr->_M_add_owner(); } _Stop_state_ref(_Stop_state_ref&& __other) noexcept : _M_ptr(__other._M_ptr) { __other._M_ptr = nullptr; } _Stop_state_ref& operator=(const _Stop_state_ref& __other) noexcept { if (auto __ptr = __other._M_ptr; __ptr != _M_ptr) { if (__ptr) __ptr->_M_add_owner(); if (_M_ptr) _M_ptr->_M_release_ownership(); _M_ptr = __ptr; } return *this; } _Stop_state_ref& operator=(_Stop_state_ref&& __other) noexcept { _Stop_state_ref(std::move(__other)).swap(*this); return *this; } ~_Stop_state_ref() { if (_M_ptr) _M_ptr->_M_release_ownership(); } void swap(_Stop_state_ref& __other) noexcept { std::swap(_M_ptr, __other._M_ptr); } explicit operator bool() const noexcept { return _M_ptr != nullptr; } _Stop_state_t* operator->() const noexcept { return _M_ptr; } #if __cpp_impl_three_way_comparison >= 201907L friend bool operator==(const _Stop_state_ref&, const _Stop_state_ref&) = default; #else friend bool operator==(const _Stop_state_ref& __lhs, const _Stop_state_ref& __rhs) noexcept { return __lhs._M_ptr == __rhs._M_ptr; } friend bool operator!=(const _Stop_state_ref& __lhs, const _Stop_state_ref& __rhs) noexcept { return __lhs._M_ptr != __rhs._M_ptr; } #endif private: _Stop_state_t* _M_ptr = nullptr; }; _Stop_state_ref _M_state; explicit stop_token(const _Stop_state_ref& __state) noexcept : _M_state{__state} { } }; /// A type that allows a stop request to be made. class stop_source { public: stop_source() : _M_state(*this) { } explicit stop_source(std::nostopstate_t) noexcept { } stop_source(const stop_source& __other) noexcept : _M_state(__other._M_state) { if (_M_state) _M_state->_M_add_ssrc(); } stop_source(stop_source&&) noexcept = default; stop_source& operator=(const stop_source& __other) noexcept { if (_M_state != __other._M_state) { stop_source __sink(std::move(*this)); _M_state = __other._M_state; if (_M_state) _M_state->_M_add_ssrc(); } return *this; } stop_source& operator=(stop_source&&) noexcept = default; ~stop_source() { if (_M_state) _M_state->_M_sub_ssrc(); } [[nodiscard]] bool stop_possible() const noexcept { return static_cast<bool>(_M_state); } [[nodiscard]] bool stop_requested() const noexcept { return static_cast<bool>(_M_state) && _M_state->_M_stop_requested(); } bool request_stop() const noexcept { if (stop_possible()) return _M_state->_M_request_stop(); return false; } [[nodiscard]] stop_token get_token() const noexcept { return stop_token{_M_state}; } void swap(stop_source& __other) noexcept { _M_state.swap(__other._M_state); } [[nodiscard]] friend bool operator==(const stop_source& __a, const stop_source& __b) noexcept { return __a._M_state == __b._M_state; } friend void swap(stop_source& __lhs, stop_source& __rhs) noexcept { __lhs.swap(__rhs); } private: stop_token::_Stop_state_ref _M_state; }; /// A wrapper for callbacks to be run when a stop request is made. template<typename _Callback> class [[nodiscard]] stop_callback { static_assert(is_nothrow_destructible_v<_Callback>); static_assert(is_invocable_v<_Callback>); public: using callback_type = _Callback; template<typename _Cb, enable_if_t<is_constructible_v<_Callback, _Cb>, int> = 0> explicit stop_callback(const stop_token& __token, _Cb&& __cb) noexcept(is_nothrow_constructible_v<_Callback, _Cb>) : _M_cb(std::forward<_Cb>(__cb)) { if (auto __state = __token._M_state) { if (__state->_M_register_callback(&_M_cb)) _M_state.swap(__state); } } template<typename _Cb, enable_if_t<is_constructible_v<_Callback, _Cb>, int> = 0> explicit stop_callback(stop_token&& __token, _Cb&& __cb) noexcept(is_nothrow_constructible_v<_Callback, _Cb>) : _M_cb(std::forward<_Cb>(__cb)) { if (auto& __state = __token._M_state) { if (__state->_M_register_callback(&_M_cb)) _M_state.swap(__state); } } ~stop_callback() { if (_M_state) { _M_state->_M_remove_callback(&_M_cb); } } stop_callback(const stop_callback&) = delete; stop_callback& operator=(const stop_callback&) = delete; stop_callback(stop_callback&&) = delete; stop_callback& operator=(stop_callback&&) = delete; private: struct _Cb_impl : stop_token::_Stop_cb { template<typename _Cb> explicit _Cb_impl(_Cb&& __cb) : _Stop_cb(&_S_execute), _M_cb(std::forward<_Cb>(__cb)) { } _Callback _M_cb; [[__gnu__::__nonnull__]] static void _S_execute(_Stop_cb* __that) noexcept { _Callback& __cb = static_cast<_Cb_impl*>(__that)->_M_cb; std::forward<_Callback>(__cb)(); } }; _Cb_impl _M_cb; stop_token::_Stop_state_ref _M_state; }; template<typename _Callback> stop_callback(stop_token, _Callback) -> stop_callback<_Callback>; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // __cplusplus > 201703L #endif // _GLIBCXX_STOP_TOKEN // -*- C++ -*- compatibility header. // Copyright (C) 2002-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file math.h * This is a Standard C++ Library header. */ #if !defined __cplusplus || defined _GLIBCXX_INCLUDE_NEXT_C_HEADERS # include_next <math.h> #else #ifndef _GLIBCXX_MATH_H #define _GLIBCXX_MATH_H 1 # include <cmath> using std::abs; using std::acos; using std::asin; using std::atan; using std::atan2; using std::cos; using std::sin; using std::tan; using std::cosh; using std::sinh; using std::tanh; using std::exp; using std::frexp; using std::ldexp; using std::log; using std::log10; using std::modf; using std::pow; using std::sqrt; using std::ceil; using std::fabs; using std::floor; using std::fmod; #if _GLIBCXX_USE_C99_MATH using std::fpclassify; using std::isfinite; using std::isinf; using std::isnan; using std::isnormal; using std::signbit; using std::isgreater; using std::isgreaterequal; using std::isless; using std::islessequal; using std::islessgreater; using std::isunordered; #endif #if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_MATH_TR1) using std::acosh; using std::asinh; using std::atanh; using std::cbrt; using std::copysign; using std::erf; using std::erfc; using std::exp2; using std::expm1; using std::fdim; using std::fma; using std::fmax; using std::fmin; using std::hypot; using std::ilogb; using std::lgamma; using std::llrint; using std::llround; using std::log1p; using std::log2; using std::logb; using std::lrint; using std::lround; using std::nearbyint; using std::nextafter; using std::nexttoward; using std::remainder; using std::remquo; using std::rint; using std::round; using std::scalbln; using std::scalbn; using std::tgamma; using std::trunc; #endif // C++11 && _GLIBCXX_USE_C99_MATH_TR1 // The mathematical special functions are only added to the global namespace // by IS 29124, but not by C++17. #if __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0 using std::assoc_laguerref; using std::assoc_laguerrel; using std::assoc_laguerre; using std::assoc_legendref; using std::assoc_legendrel; using std::assoc_legendre; using std::betaf; using std::betal; using std::beta; using std::comp_ellint_1f; using std::comp_ellint_1l; using std::comp_ellint_1; using std::comp_ellint_2f; using std::comp_ellint_2l; using std::comp_ellint_2; using std::comp_ellint_3f; using std::comp_ellint_3l; using std::comp_ellint_3; using std::cyl_bessel_if; using std::cyl_bessel_il; using std::cyl_bessel_i; using std::cyl_bessel_jf; using std::cyl_bessel_jl; using std::cyl_bessel_j; using std::cyl_bessel_kf; using std::cyl_bessel_kl; using std::cyl_bessel_k; using std::cyl_neumannf; using std::cyl_neumannl; using std::cyl_neumann; using std::ellint_1f; using std::ellint_1l; using std::ellint_1; using std::ellint_2f; using std::ellint_2l; using std::ellint_2; using std::ellint_3f; using std::ellint_3l; using std::ellint_3; using std::expintf; using std::expintl; using std::expint; using std::hermitef; using std::hermitel; using std::hermite; using std::laguerref; using std::laguerrel; using std::laguerre; using std::legendref; using std::legendrel; using std::legendre; using std::riemann_zetaf; using std::riemann_zetal; using std::riemann_zeta; using std::sph_besself; using std::sph_bessell; using std::sph_bessel; using std::sph_legendref; using std::sph_legendrel; using std::sph_legendre; using std::sph_neumannf; using std::sph_neumannl; using std::sph_neumann; #endif // _GLIBCXX_USE_STD_SPEC_FUNCS #if __cplusplus > 201703L using std::lerp; #endif // C++20 #endif // _GLIBCXX_MATH_H #endif // __cplusplus // -*- C++ -*- forwarding header. // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/climits * This is a Standard C++ Library file. You should @c \#include this file * in your programs, rather than any of the @a *.h implementation files. * * This is the C++ version of the Standard C Library header @c limits.h, * and its contents are (mostly) the same as that header, but are all * contained in the namespace @c std (except for names which are defined * as macros in C). */ // // ISO C++ 14882: 18.2.2 Implementation properties: C library // #pragma GCC system_header #include <bits/c++config.h> #include <limits.h> #ifndef _GLIBCXX_CLIMITS #define _GLIBCXX_CLIMITS 1 #ifndef LLONG_MIN #define LLONG_MIN (-__LONG_LONG_MAX__ - 1) #endif #ifndef LLONG_MAX #define LLONG_MAX __LONG_LONG_MAX__ #endif #ifndef ULLONG_MAX #define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1) #endif #endif // <iterator> -*- C++ -*- // Copyright (C) 2001-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /* * * Copyright (c) 1994 * Hewlett-Packard Company * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Hewlett-Packard Company makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * * Copyright (c) 1996,1997 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ /** @file include/iterator * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_ITERATOR #define _GLIBCXX_ITERATOR 1 #pragma GCC system_header #include <bits/c++config.h> #include <bits/stl_iterator_base_types.h> #include <bits/stl_iterator_base_funcs.h> #include <bits/stl_iterator.h> #include <iosfwd> #include <bits/stream_iterator.h> #include <bits/streambuf_iterator.h> #include <bits/range_access.h> #if __cplusplus >= 201402L && ! defined _GLIBCXX_DEBUG // PR libstdc++/70303 # define __cpp_lib_null_iterators 201304L #endif #endif /* _GLIBCXX_ITERATOR */ // -*- C++ -*- compatibility header. // Copyright (C) 2007-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file tgmath.h * This is a Standard C++ Library header. */ #include <bits/c++config.h> #if __cplusplus >= 201103L # include <ctgmath> #else # if _GLIBCXX_HAVE_TGMATH_H # include_next <tgmath.h> # endif #endif #ifndef _GLIBCXX_TGMATH_H #define _GLIBCXX_TGMATH_H 1 #endif // <ranges> -*- C++ -*- // Copyright (C) 2019-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/ranges * This is a Standard C++ Library header. * @ingroup concepts */ #ifndef _GLIBCXX_RANGES #define _GLIBCXX_RANGES 1 #if __cplusplus > 201703L #pragma GCC system_header #include <concepts> #if __cpp_lib_concepts #include <compare> #include <initializer_list> #include <iterator> #include <optional> #include <tuple> #include <bits/ranges_util.h> #include <bits/refwrap.h> /** * @defgroup ranges Ranges * * Components for dealing with ranges of elements. */ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace ranges { // [range.access] customization point objects // [range.req] range and view concepts // [range.dangling] dangling iterator handling // Defined in <bits/ranges_base.h> // [view.interface] View interface // [range.subrange] Sub-ranges // Defined in <bits/ranges_util.h> // C++20 24.6 [range.factories] Range factories /// A view that contains no elements. template<typename _Tp> requires is_object_v<_Tp> class empty_view : public view_interface<empty_view<_Tp>> { public: static constexpr _Tp* begin() noexcept { return nullptr; } static constexpr _Tp* end() noexcept { return nullptr; } static constexpr _Tp* data() noexcept { return nullptr; } static constexpr size_t size() noexcept { return 0; } static constexpr bool empty() noexcept { return true; } }; template<typename _Tp> inline constexpr bool enable_borrowed_range<empty_view<_Tp>> = true; namespace __detail { template<typename _Tp> concept __boxable = copy_constructible<_Tp> && is_object_v<_Tp>; template<__boxable _Tp> struct __box : std::optional<_Tp> { using std::optional<_Tp>::optional; constexpr __box() noexcept(is_nothrow_default_constructible_v<_Tp>) requires default_initializable<_Tp> : std::optional<_Tp>{std::in_place} { } __box(const __box&) = default; __box(__box&&) = default; using std::optional<_Tp>::operator=; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3477. Simplify constraints for semiregular-box __box& operator=(const __box& __that) noexcept(is_nothrow_copy_constructible_v<_Tp>) requires (!copyable<_Tp>) { if (this != std::__addressof(__that)) { if ((bool)__that) this->emplace(*__that); else this->reset(); } return *this; } __box& operator=(__box&& __that) noexcept(is_nothrow_move_constructible_v<_Tp>) requires (!movable<_Tp>) { if (this != std::__addressof(__that)) { if ((bool)__that) this->emplace(std::move(*__that)); else this->reset(); } return *this; } }; // For types which are already copyable, this specialization of the // copyable wrapper stores the object directly without going through // std::optional. It provides just the subset of the primary template's // API that we currently use. template<__boxable _Tp> requires copyable<_Tp> struct __box<_Tp> { private: [[no_unique_address]] _Tp _M_value = _Tp(); public: __box() requires default_initializable<_Tp> = default; constexpr explicit __box(const _Tp& __t) noexcept(is_nothrow_copy_constructible_v<_Tp>) : _M_value(__t) { } constexpr explicit __box(_Tp&& __t) noexcept(is_nothrow_move_constructible_v<_Tp>) : _M_value(std::move(__t)) { } template<typename... _Args> requires constructible_from<_Tp, _Args...> constexpr explicit __box(in_place_t, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>) : _M_value(std::forward<_Args>(__args)...) { } constexpr bool has_value() const noexcept { return true; }; constexpr _Tp& operator*() noexcept { return _M_value; } constexpr const _Tp& operator*() const noexcept { return _M_value; } constexpr _Tp* operator->() noexcept { return std::__addressof(_M_value); } constexpr const _Tp* operator->() const noexcept { return std::__addressof(_M_value); } }; } // namespace __detail /// A view that contains exactly one element. template<copy_constructible _Tp> requires is_object_v<_Tp> class single_view : public view_interface<single_view<_Tp>> { public: single_view() = default; constexpr explicit single_view(const _Tp& __t) : _M_value(__t) { } constexpr explicit single_view(_Tp&& __t) : _M_value(std::move(__t)) { } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3428. single_view's in place constructor should be explicit template<typename... _Args> requires constructible_from<_Tp, _Args...> constexpr explicit single_view(in_place_t, _Args&&... __args) : _M_value{in_place, std::forward<_Args>(__args)...} { } constexpr _Tp* begin() noexcept { return data(); } constexpr const _Tp* begin() const noexcept { return data(); } constexpr _Tp* end() noexcept { return data() + 1; } constexpr const _Tp* end() const noexcept { return data() + 1; } static constexpr size_t size() noexcept { return 1; } constexpr _Tp* data() noexcept { return _M_value.operator->(); } constexpr const _Tp* data() const noexcept { return _M_value.operator->(); } private: [[no_unique_address]] __detail::__box<_Tp> _M_value; }; template<typename _Tp> single_view(_Tp) -> single_view<_Tp>; namespace __detail { template<typename _Wp> constexpr auto __to_signed_like(_Wp __w) noexcept { if constexpr (!integral<_Wp>) return iter_difference_t<_Wp>(); else if constexpr (sizeof(iter_difference_t<_Wp>) > sizeof(_Wp)) return iter_difference_t<_Wp>(__w); else if constexpr (sizeof(ptrdiff_t) > sizeof(_Wp)) return ptrdiff_t(__w); else if constexpr (sizeof(long long) > sizeof(_Wp)) return (long long)(__w); #ifdef __SIZEOF_INT128__ else if constexpr (__SIZEOF_INT128__ > sizeof(_Wp)) return __int128(__w); #endif else return __max_diff_type(__w); } template<typename _Wp> using __iota_diff_t = decltype(__to_signed_like(std::declval<_Wp>())); template<typename _It> concept __decrementable = incrementable<_It> && requires(_It __i) { { --__i } -> same_as<_It&>; { __i-- } -> same_as<_It>; }; template<typename _It> concept __advanceable = __decrementable<_It> && totally_ordered<_It> && requires( _It __i, const _It __j, const __iota_diff_t<_It> __n) { { __i += __n } -> same_as<_It&>; { __i -= __n } -> same_as<_It&>; _It(__j + __n); _It(__n + __j); _It(__j - __n); { __j - __j } -> convertible_to<__iota_diff_t<_It>>; }; template<typename _Winc> struct __iota_view_iter_cat { }; template<incrementable _Winc> struct __iota_view_iter_cat<_Winc> { using iterator_category = input_iterator_tag; }; } // namespace __detail template<weakly_incrementable _Winc, semiregular _Bound = unreachable_sentinel_t> requires std::__detail::__weakly_eq_cmp_with<_Winc, _Bound> && copyable<_Winc> class iota_view : public view_interface<iota_view<_Winc, _Bound>> { private: struct _Sentinel; struct _Iterator : __detail::__iota_view_iter_cat<_Winc> { private: static auto _S_iter_concept() { using namespace __detail; if constexpr (__advanceable<_Winc>) return random_access_iterator_tag{}; else if constexpr (__decrementable<_Winc>) return bidirectional_iterator_tag{}; else if constexpr (incrementable<_Winc>) return forward_iterator_tag{}; else return input_iterator_tag{}; } public: using iterator_concept = decltype(_S_iter_concept()); // iterator_category defined in __iota_view_iter_cat using value_type = _Winc; using difference_type = __detail::__iota_diff_t<_Winc>; _Iterator() requires default_initializable<_Winc> = default; constexpr explicit _Iterator(_Winc __value) : _M_value(__value) { } constexpr _Winc operator*() const noexcept(is_nothrow_copy_constructible_v<_Winc>) { return _M_value; } constexpr _Iterator& operator++() { ++_M_value; return *this; } constexpr void operator++(int) { ++*this; } constexpr _Iterator operator++(int) requires incrementable<_Winc> { auto __tmp = *this; ++*this; return __tmp; } constexpr _Iterator& operator--() requires __detail::__decrementable<_Winc> { --_M_value; return *this; } constexpr _Iterator operator--(int) requires __detail::__decrementable<_Winc> { auto __tmp = *this; --*this; return __tmp; } constexpr _Iterator& operator+=(difference_type __n) requires __detail::__advanceable<_Winc> { using __detail::__is_integer_like; using __detail::__is_signed_integer_like; if constexpr (__is_integer_like<_Winc> && !__is_signed_integer_like<_Winc>) { if (__n >= difference_type(0)) _M_value += static_cast<_Winc>(__n); else _M_value -= static_cast<_Winc>(-__n); } else _M_value += __n; return *this; } constexpr _Iterator& operator-=(difference_type __n) requires __detail::__advanceable<_Winc> { using __detail::__is_integer_like; using __detail::__is_signed_integer_like; if constexpr (__is_integer_like<_Winc> && !__is_signed_integer_like<_Winc>) { if (__n >= difference_type(0)) _M_value -= static_cast<_Winc>(__n); else _M_value += static_cast<_Winc>(-__n); } else _M_value -= __n; return *this; } constexpr _Winc operator[](difference_type __n) const requires __detail::__advanceable<_Winc> { return _Winc(_M_value + __n); } friend constexpr bool operator==(const _Iterator& __x, const _Iterator& __y) requires equality_comparable<_Winc> { return __x._M_value == __y._M_value; } friend constexpr bool operator<(const _Iterator& __x, const _Iterator& __y) requires totally_ordered<_Winc> { return __x._M_value < __y._M_value; } friend constexpr bool operator>(const _Iterator& __x, const _Iterator& __y) requires totally_ordered<_Winc> { return __y < __x; } friend constexpr bool operator<=(const _Iterator& __x, const _Iterator& __y) requires totally_ordered<_Winc> { return !(__y < __x); } friend constexpr bool operator>=(const _Iterator& __x, const _Iterator& __y) requires totally_ordered<_Winc> { return !(__x < __y); } #ifdef __cpp_lib_three_way_comparison friend constexpr auto operator<=>(const _Iterator& __x, const _Iterator& __y) requires totally_ordered<_Winc> && three_way_comparable<_Winc> { return __x._M_value <=> __y._M_value; } #endif friend constexpr _Iterator operator+(_Iterator __i, difference_type __n) requires __detail::__advanceable<_Winc> { __i += __n; return __i; } friend constexpr _Iterator operator+(difference_type __n, _Iterator __i) requires __detail::__advanceable<_Winc> { return __i += __n; } friend constexpr _Iterator operator-(_Iterator __i, difference_type __n) requires __detail::__advanceable<_Winc> { __i -= __n; return __i; } friend constexpr difference_type operator-(const _Iterator& __x, const _Iterator& __y) requires __detail::__advanceable<_Winc> { using __detail::__is_integer_like; using __detail::__is_signed_integer_like; using _Dt = difference_type; if constexpr (__is_integer_like<_Winc>) { if constexpr (__is_signed_integer_like<_Winc>) return _Dt(_Dt(__x._M_value) - _Dt(__y._M_value)); else return (__y._M_value > __x._M_value) ? _Dt(-_Dt(__y._M_value - __x._M_value)) : _Dt(__x._M_value - __y._M_value); } else return __x._M_value - __y._M_value; } private: _Winc _M_value = _Winc(); friend iota_view; friend _Sentinel; }; struct _Sentinel { private: constexpr bool _M_equal(const _Iterator& __x) const { return __x._M_value == _M_bound; } constexpr auto _M_distance_from(const _Iterator& __x) const { return _M_bound - __x._M_value; } _Bound _M_bound = _Bound(); public: _Sentinel() = default; constexpr explicit _Sentinel(_Bound __bound) : _M_bound(__bound) { } friend constexpr bool operator==(const _Iterator& __x, const _Sentinel& __y) { return __y._M_equal(__x); } friend constexpr iter_difference_t<_Winc> operator-(const _Iterator& __x, const _Sentinel& __y) requires sized_sentinel_for<_Bound, _Winc> { return -__y._M_distance_from(__x); } friend constexpr iter_difference_t<_Winc> operator-(const _Sentinel& __x, const _Iterator& __y) requires sized_sentinel_for<_Bound, _Winc> { return __x._M_distance_from(__y); } friend iota_view; }; _Winc _M_value = _Winc(); [[no_unique_address]] _Bound _M_bound = _Bound(); public: iota_view() requires default_initializable<_Winc> = default; constexpr explicit iota_view(_Winc __value) : _M_value(__value) { } constexpr iota_view(type_identity_t<_Winc> __value, type_identity_t<_Bound> __bound) : _M_value(__value), _M_bound(__bound) { if constexpr (totally_ordered_with<_Winc, _Bound>) __glibcxx_assert( bool(__value <= __bound) ); } constexpr iota_view(_Iterator __first, _Iterator __last) requires same_as<_Winc, _Bound> : iota_view(__first._M_value, __last._M_value) { } constexpr iota_view(_Iterator __first, unreachable_sentinel_t __last) requires same_as<_Bound, unreachable_sentinel_t> : iota_view(__first._M_value, __last) { } constexpr iota_view(_Iterator __first, _Sentinel __last) requires (!same_as<_Winc, _Bound>) && (!same_as<_Bound, unreachable_sentinel_t>) : iota_view(__first._M_value, __last._M_bound) { } constexpr _Iterator begin() const { return _Iterator{_M_value}; } constexpr auto end() const { if constexpr (same_as<_Bound, unreachable_sentinel_t>) return unreachable_sentinel; else return _Sentinel{_M_bound}; } constexpr _Iterator end() const requires same_as<_Winc, _Bound> { return _Iterator{_M_bound}; } constexpr auto size() const requires (same_as<_Winc, _Bound> && __detail::__advanceable<_Winc>) || (integral<_Winc> && integral<_Bound>) || sized_sentinel_for<_Bound, _Winc> { using __detail::__is_integer_like; using __detail::__to_unsigned_like; if constexpr (integral<_Winc> && integral<_Bound>) { using _Up = make_unsigned_t<decltype(_M_bound - _M_value)>; return _Up(_M_bound) - _Up(_M_value); } else if constexpr (__is_integer_like<_Winc>) return __to_unsigned_like(_M_bound) - __to_unsigned_like(_M_value); else return __to_unsigned_like(_M_bound - _M_value); } }; template<typename _Winc, typename _Bound> requires (!__detail::__is_integer_like<_Winc> || !__detail::__is_integer_like<_Bound> || (__detail::__is_signed_integer_like<_Winc> == __detail::__is_signed_integer_like<_Bound>)) iota_view(_Winc, _Bound) -> iota_view<_Winc, _Bound>; template<weakly_incrementable _Winc, semiregular _Bound> inline constexpr bool enable_borrowed_range<iota_view<_Winc, _Bound>> = true; namespace views { template<typename _Tp> inline constexpr empty_view<_Tp> empty{}; struct _Single { template<typename _Tp> constexpr auto operator()(_Tp&& __e) const { return single_view<decay_t<_Tp>>(std::forward<_Tp>(__e)); } }; inline constexpr _Single single{}; struct _Iota { template<typename _Tp> constexpr auto operator()(_Tp&& __e) const { return iota_view(std::forward<_Tp>(__e)); } template<typename _Tp, typename _Up> constexpr auto operator()(_Tp&& __e, _Up&& __f) const { return iota_view(std::forward<_Tp>(__e), std::forward<_Up>(__f)); } }; inline constexpr _Iota iota{}; } // namespace views namespace __detail { template<typename _Val, typename _CharT, typename _Traits> concept __stream_extractable = requires(basic_istream<_CharT, _Traits>& is, _Val& t) { is >> t; }; } // namespace __detail template<movable _Val, typename _CharT, typename _Traits = char_traits<_CharT>> requires default_initializable<_Val> && __detail::__stream_extractable<_Val, _CharT, _Traits> class basic_istream_view : public view_interface<basic_istream_view<_Val, _CharT, _Traits>> { public: basic_istream_view() = default; constexpr explicit basic_istream_view(basic_istream<_CharT, _Traits>& __stream) : _M_stream(std::__addressof(__stream)) { } constexpr auto begin() { if (_M_stream != nullptr) *_M_stream >> _M_object; return _Iterator{this}; } constexpr default_sentinel_t end() const noexcept { return default_sentinel; } private: basic_istream<_CharT, _Traits>* _M_stream = nullptr; _Val _M_object = _Val(); struct _Iterator { public: using iterator_concept = input_iterator_tag; using difference_type = ptrdiff_t; using value_type = _Val; _Iterator() = default; constexpr explicit _Iterator(basic_istream_view* __parent) noexcept : _M_parent(__parent) { } _Iterator(const _Iterator&) = delete; _Iterator(_Iterator&&) = default; _Iterator& operator=(const _Iterator&) = delete; _Iterator& operator=(_Iterator&&) = default; _Iterator& operator++() { __glibcxx_assert(_M_parent->_M_stream != nullptr); *_M_parent->_M_stream >> _M_parent->_M_object; return *this; } void operator++(int) { ++*this; } _Val& operator*() const { __glibcxx_assert(_M_parent->_M_stream != nullptr); return _M_parent->_M_object; } friend bool operator==(const _Iterator& __x, default_sentinel_t) { return __x._M_at_end(); } private: basic_istream_view* _M_parent = nullptr; bool _M_at_end() const { return _M_parent == nullptr || !*_M_parent->_M_stream; } }; friend _Iterator; }; template<typename _Val, typename _CharT, typename _Traits> basic_istream_view<_Val, _CharT, _Traits> istream_view(basic_istream<_CharT, _Traits>& __s) { return basic_istream_view<_Val, _CharT, _Traits>{__s}; } // C++20 24.7 [range.adaptors] Range adaptors namespace __detail { struct _Empty { }; // Alias for a type that is conditionally present // (and is an empty type otherwise). // Data members using this alias should use [[no_unique_address]] so that // they take no space when not needed. template<bool _Present, typename _Tp> using __maybe_present_t = conditional_t<_Present, _Tp, _Empty>; // Alias for a type that is conditionally const. template<bool _Const, typename _Tp> using __maybe_const_t = conditional_t<_Const, const _Tp, _Tp>; } // namespace __detail namespace views::__adaptor { // True if the range adaptor _Adaptor can be applied with _Args. template<typename _Adaptor, typename... _Args> concept __adaptor_invocable = requires { std::declval<_Adaptor>()(declval<_Args>()...); }; // True if the range adaptor non-closure _Adaptor can be partially applied // with _Args. template<typename _Adaptor, typename... _Args> concept __adaptor_partial_app_viable = (_Adaptor::_S_arity > 1) && (sizeof...(_Args) == _Adaptor::_S_arity - 1) && (constructible_from<decay_t<_Args>, _Args> && ...); template<typename _Adaptor, typename... _Args> struct _Partial; template<typename _Lhs, typename _Rhs> struct _Pipe; // The base class of every range adaptor closure. // // The derived class should define the optional static data member // _S_has_simple_call_op to true if the behavior of this adaptor is // independent of the constness/value category of the adaptor object. struct _RangeAdaptorClosure { // range | adaptor is equivalent to adaptor(range). template<typename _Self, typename _Range> requires derived_from<remove_cvref_t<_Self>, _RangeAdaptorClosure> && __adaptor_invocable<_Self, _Range> friend constexpr auto operator|(_Range&& __r, _Self&& __self) { return std::forward<_Self>(__self)(std::forward<_Range>(__r)); } // Compose the adaptors __lhs and __rhs into a pipeline, returning // another range adaptor closure object. template<typename _Lhs, typename _Rhs> requires derived_from<_Lhs, _RangeAdaptorClosure> && derived_from<_Rhs, _RangeAdaptorClosure> friend constexpr auto operator|(_Lhs __lhs, _Rhs __rhs) { return _Pipe<_Lhs, _Rhs>{std::move(__lhs), std::move(__rhs)}; } }; // The base class of every range adaptor non-closure. // // The static data member _Derived::_S_arity must contain the total number of // arguments that the adaptor takes, and the class _Derived must introduce // _RangeAdaptor::operator() into the class scope via a using-declaration. // // The optional static data member _Derived::_S_has_simple_extra_args should // be defined to true if the behavior of this adaptor is independent of the // constness/value category of the extra arguments. This data member could // also be defined as a variable template parameterized by the types of the // extra arguments. template<typename _Derived> struct _RangeAdaptor { // Partially apply the arguments __args to the range adaptor _Derived, // returning a range adaptor closure object. template<typename... _Args> requires __adaptor_partial_app_viable<_Derived, _Args...> constexpr auto operator()(_Args&&... __args) const { return _Partial<_Derived, decay_t<_Args>...>{std::forward<_Args>(__args)...}; } }; // True if the range adaptor closure _Adaptor has a simple operator(), i.e. // one that's not overloaded according to constness or value category of the // _Adaptor object. template<typename _Adaptor> concept __closure_has_simple_call_op = _Adaptor::_S_has_simple_call_op; // True if the behavior of the range adaptor non-closure _Adaptor is // independent of the value category of its extra arguments _Args. template<typename _Adaptor, typename... _Args> concept __adaptor_has_simple_extra_args = _Adaptor::_S_has_simple_extra_args || _Adaptor::template _S_has_simple_extra_args<_Args...>; // A range adaptor closure that represents partial application of // the range adaptor _Adaptor with arguments _Args. template<typename _Adaptor, typename... _Args> struct _Partial : _RangeAdaptorClosure { tuple<_Args...> _M_args; constexpr _Partial(_Args... __args) : _M_args(std::move(__args)...) { } // Invoke _Adaptor with arguments __r, _M_args... according to the // value category of this _Partial object. template<typename _Range> requires __adaptor_invocable<_Adaptor, _Range, const _Args&...> constexpr auto operator()(_Range&& __r) const & { auto __forwarder = [&__r] (const auto&... __args) { return _Adaptor{}(std::forward<_Range>(__r), __args...); }; return std::apply(__forwarder, _M_args); } template<typename _Range> requires __adaptor_invocable<_Adaptor, _Range, _Args...> constexpr auto operator()(_Range&& __r) && { auto __forwarder = [&__r] (auto&... __args) { return _Adaptor{}(std::forward<_Range>(__r), std::move(__args)...); }; return std::apply(__forwarder, _M_args); } template<typename _Range> constexpr auto operator()(_Range&& __r) const && = delete; }; // A lightweight specialization of the above primary template for // the common case where _Adaptor accepts a single extra argument. template<typename _Adaptor, typename _Arg> struct _Partial<_Adaptor, _Arg> : _RangeAdaptorClosure { _Arg _M_arg; constexpr _Partial(_Arg __arg) : _M_arg(std::move(__arg)) { } template<typename _Range> requires __adaptor_invocable<_Adaptor, _Range, const _Arg&> constexpr auto operator()(_Range&& __r) const & { return _Adaptor{}(std::forward<_Range>(__r), _M_arg); } template<typename _Range> requires __adaptor_invocable<_Adaptor, _Range, _Arg> constexpr auto operator()(_Range&& __r) && { return _Adaptor{}(std::forward<_Range>(__r), std::move(_M_arg)); } template<typename _Range> constexpr auto operator()(_Range&& __r) const && = delete; }; // Partial specialization of the primary template for the case where the extra // arguments of the adaptor can always be safely and efficiently forwarded by // const reference. This lets us get away with a single operator() overload, // which makes overload resolution failure diagnostics more concise. template<typename _Adaptor, typename... _Args> requires __adaptor_has_simple_extra_args<_Adaptor, _Args...> && (is_trivially_copyable_v<_Args> && ...) struct _Partial<_Adaptor, _Args...> : _RangeAdaptorClosure { tuple<_Args...> _M_args; constexpr _Partial(_Args... __args) : _M_args(std::move(__args)...) { } // Invoke _Adaptor with arguments __r, const _M_args&... regardless // of the value category of this _Partial object. template<typename _Range> requires __adaptor_invocable<_Adaptor, _Range, const _Args&...> constexpr auto operator()(_Range&& __r) const { auto __forwarder = [&__r] (const auto&... __args) { return _Adaptor{}(std::forward<_Range>(__r), __args...); }; return std::apply(__forwarder, _M_args); } static constexpr bool _S_has_simple_call_op = true; }; // A lightweight specialization of the above template for the common case // where _Adaptor accepts a single extra argument. template<typename _Adaptor, typename _Arg> requires __adaptor_has_simple_extra_args<_Adaptor, _Arg> && is_trivially_copyable_v<_Arg> struct _Partial<_Adaptor, _Arg> : _RangeAdaptorClosure { _Arg _M_arg; constexpr _Partial(_Arg __arg) : _M_arg(std::move(__arg)) { } template<typename _Range> requires __adaptor_invocable<_Adaptor, _Range, const _Arg&> constexpr auto operator()(_Range&& __r) const { return _Adaptor{}(std::forward<_Range>(__r), _M_arg); } static constexpr bool _S_has_simple_call_op = true; }; template<typename _Lhs, typename _Rhs, typename _Range> concept __pipe_invocable = requires { std::declval<_Rhs>()(std::declval<_Lhs>()(std::declval<_Range>())); }; // A range adaptor closure that represents composition of the range // adaptor closures _Lhs and _Rhs. template<typename _Lhs, typename _Rhs> struct _Pipe : _RangeAdaptorClosure { [[no_unique_address]] _Lhs _M_lhs; [[no_unique_address]] _Rhs _M_rhs; constexpr _Pipe(_Lhs __lhs, _Rhs __rhs) : _M_lhs(std::move(__lhs)), _M_rhs(std::move(__rhs)) { } // Invoke _M_rhs(_M_lhs(__r)) according to the value category of this // range adaptor closure object. template<typename _Range> requires __pipe_invocable<const _Lhs&, const _Rhs&, _Range> constexpr auto operator()(_Range&& __r) const & { return _M_rhs(_M_lhs(std::forward<_Range>(__r))); } template<typename _Range> requires __pipe_invocable<_Lhs, _Rhs, _Range> constexpr auto operator()(_Range&& __r) && { return std::move(_M_rhs)(std::move(_M_lhs)(std::forward<_Range>(__r))); } template<typename _Range> constexpr auto operator()(_Range&& __r) const && = delete; }; // A partial specialization of the above primary template for the case where // both adaptor operands have a simple operator(). This in turn lets us // implement composition using a single simple operator(), which makes // overload resolution failure diagnostics more concise. template<typename _Lhs, typename _Rhs> requires __closure_has_simple_call_op<_Lhs> && __closure_has_simple_call_op<_Rhs> struct _Pipe<_Lhs, _Rhs> : _RangeAdaptorClosure { [[no_unique_address]] _Lhs _M_lhs; [[no_unique_address]] _Rhs _M_rhs; constexpr _Pipe(_Lhs __lhs, _Rhs __rhs) : _M_lhs(std::move(__lhs)), _M_rhs(std::move(__rhs)) { } template<typename _Range> requires __pipe_invocable<const _Lhs&, const _Rhs&, _Range> constexpr auto operator()(_Range&& __r) const { return _M_rhs(_M_lhs(std::forward<_Range>(__r))); } static constexpr bool _S_has_simple_call_op = true; }; } // namespace views::__adaptor template<range _Range> requires is_object_v<_Range> class ref_view : public view_interface<ref_view<_Range>> { private: _Range* _M_r = nullptr; static void _S_fun(_Range&); // not defined static void _S_fun(_Range&&) = delete; public: constexpr ref_view() noexcept = default; template<__detail::__not_same_as<ref_view> _Tp> requires convertible_to<_Tp, _Range&> && requires { _S_fun(declval<_Tp>()); } constexpr ref_view(_Tp&& __t) : _M_r(std::__addressof(static_cast<_Range&>(std::forward<_Tp>(__t)))) { } constexpr _Range& base() const { return *_M_r; } constexpr iterator_t<_Range> begin() const { return ranges::begin(*_M_r); } constexpr sentinel_t<_Range> end() const { return ranges::end(*_M_r); } constexpr bool empty() const requires requires { ranges::empty(*_M_r); } { return ranges::empty(*_M_r); } constexpr auto size() const requires sized_range<_Range> { return ranges::size(*_M_r); } constexpr auto data() const requires contiguous_range<_Range> { return ranges::data(*_M_r); } }; template<typename _Range> ref_view(_Range&) -> ref_view<_Range>; template<typename _Tp> inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true; namespace views { namespace __detail { template<typename _Range> concept __can_ref_view = requires { ref_view{std::declval<_Range>()}; }; template<typename _Range> concept __can_subrange = requires { subrange{std::declval<_Range>()}; }; } // namespace __detail struct _All : __adaptor::_RangeAdaptorClosure { template<viewable_range _Range> requires view<decay_t<_Range>> || __detail::__can_ref_view<_Range> || __detail::__can_subrange<_Range> constexpr auto operator()(_Range&& __r) const { if constexpr (view<decay_t<_Range>>) return std::forward<_Range>(__r); else if constexpr (__detail::__can_ref_view<_Range>) return ref_view{std::forward<_Range>(__r)}; else return subrange{std::forward<_Range>(__r)}; } static constexpr bool _S_has_simple_call_op = true; }; inline constexpr _All all; template<viewable_range _Range> using all_t = decltype(all(std::declval<_Range>())); } // namespace views namespace __detail { template<typename _Tp> struct __non_propagating_cache { // When _Tp is not an object type (e.g. is a reference type), we make // __non_propagating_cache<_Tp> empty rather than ill-formed so that // users can easily conditionally declare data members with this type // (such as join_view::_M_inner). }; template<typename _Tp> requires is_object_v<_Tp> struct __non_propagating_cache<_Tp> : protected _Optional_base<_Tp> { __non_propagating_cache() = default; constexpr __non_propagating_cache(const __non_propagating_cache&) noexcept { } constexpr __non_propagating_cache(__non_propagating_cache&& __other) noexcept { __other._M_reset(); } constexpr __non_propagating_cache& operator=(const __non_propagating_cache& __other) noexcept { if (std::__addressof(__other) != this) this->_M_reset(); return *this; } constexpr __non_propagating_cache& operator=(__non_propagating_cache&& __other) noexcept { this->_M_reset(); __other._M_reset(); return *this; } constexpr _Tp& operator*() noexcept { return this->_M_get(); } constexpr const _Tp& operator*() const noexcept { return this->_M_get(); } template<typename _Iter> _Tp& _M_emplace_deref(const _Iter& __i) { this->_M_reset(); // Using _Optional_base::_M_construct to initialize from '*__i' // would incur an extra move due to the indirection, so we instead // use placement new directly. ::new ((void *) std::__addressof(this->_M_payload._M_payload)) _Tp(*__i); this->_M_payload._M_engaged = true; return this->_M_get(); } }; template<range _Range> struct _CachedPosition { constexpr bool _M_has_value() const { return false; } constexpr iterator_t<_Range> _M_get(const _Range&) const { __glibcxx_assert(false); __builtin_unreachable(); } constexpr void _M_set(const _Range&, const iterator_t<_Range>&) const { } }; template<forward_range _Range> struct _CachedPosition<_Range> : protected __non_propagating_cache<iterator_t<_Range>> { constexpr bool _M_has_value() const { return this->_M_is_engaged(); } constexpr iterator_t<_Range> _M_get(const _Range&) const { __glibcxx_assert(_M_has_value()); return **this; } constexpr void _M_set(const _Range&, const iterator_t<_Range>& __it) { __glibcxx_assert(!_M_has_value()); std::construct_at(std::__addressof(this->_M_payload._M_payload), in_place, __it); this->_M_payload._M_engaged = true; } }; template<random_access_range _Range> requires (sizeof(range_difference_t<_Range>) <= sizeof(iterator_t<_Range>)) struct _CachedPosition<_Range> { private: range_difference_t<_Range> _M_offset = -1; public: _CachedPosition() = default; constexpr _CachedPosition(const _CachedPosition&) = default; constexpr _CachedPosition(_CachedPosition&& __other) noexcept { *this = std::move(__other); } constexpr _CachedPosition& operator=(const _CachedPosition&) = default; constexpr _CachedPosition& operator=(_CachedPosition&& __other) noexcept { // Propagate the cached offset, but invalidate the source. _M_offset = __other._M_offset; __other._M_offset = -1; return *this; } constexpr bool _M_has_value() const { return _M_offset >= 0; } constexpr iterator_t<_Range> _M_get(_Range& __r) const { __glibcxx_assert(_M_has_value()); return ranges::begin(__r) + _M_offset; } constexpr void _M_set(_Range& __r, const iterator_t<_Range>& __it) { __glibcxx_assert(!_M_has_value()); _M_offset = __it - ranges::begin(__r); } }; } // namespace __detail namespace __detail { template<typename _Base> struct __filter_view_iter_cat { }; template<forward_range _Base> struct __filter_view_iter_cat<_Base> { private: static auto _S_iter_cat() { using _Cat = typename iterator_traits<iterator_t<_Base>>::iterator_category; if constexpr (derived_from<_Cat, bidirectional_iterator_tag>) return bidirectional_iterator_tag{}; else if constexpr (derived_from<_Cat, forward_iterator_tag>) return forward_iterator_tag{}; else return _Cat{}; } public: using iterator_category = decltype(_S_iter_cat()); }; } // namespace __detail template<input_range _Vp, indirect_unary_predicate<iterator_t<_Vp>> _Pred> requires view<_Vp> && is_object_v<_Pred> class filter_view : public view_interface<filter_view<_Vp, _Pred>> { private: struct _Sentinel; struct _Iterator : __detail::__filter_view_iter_cat<_Vp> { private: static constexpr auto _S_iter_concept() { if constexpr (bidirectional_range<_Vp>) return bidirectional_iterator_tag{}; else if constexpr (forward_range<_Vp>) return forward_iterator_tag{}; else return input_iterator_tag{}; } friend filter_view; using _Vp_iter = iterator_t<_Vp>; _Vp_iter _M_current = _Vp_iter(); filter_view* _M_parent = nullptr; public: using iterator_concept = decltype(_S_iter_concept()); // iterator_category defined in __filter_view_iter_cat using value_type = range_value_t<_Vp>; using difference_type = range_difference_t<_Vp>; _Iterator() requires default_initializable<_Vp_iter> = default; constexpr _Iterator(filter_view* __parent, _Vp_iter __current) : _M_current(std::move(__current)), _M_parent(__parent) { } constexpr const _Vp_iter& base() const & noexcept { return _M_current; } constexpr _Vp_iter base() && { return std::move(_M_current); } constexpr range_reference_t<_Vp> operator*() const { return *_M_current; } constexpr _Vp_iter operator->() const requires __detail::__has_arrow<_Vp_iter> && copyable<_Vp_iter> { return _M_current; } constexpr _Iterator& operator++() { _M_current = ranges::find_if(std::move(++_M_current), ranges::end(_M_parent->_M_base), std::ref(*_M_parent->_M_pred)); return *this; } constexpr void operator++(int) { ++*this; } constexpr _Iterator operator++(int) requires forward_range<_Vp> { auto __tmp = *this; ++*this; return __tmp; } constexpr _Iterator& operator--() requires bidirectional_range<_Vp> { do --_M_current; while (!std::__invoke(*_M_parent->_M_pred, *_M_current)); return *this; } constexpr _Iterator operator--(int) requires bidirectional_range<_Vp> { auto __tmp = *this; --*this; return __tmp; } friend constexpr bool operator==(const _Iterator& __x, const _Iterator& __y) requires equality_comparable<_Vp_iter> { return __x._M_current == __y._M_current; } friend constexpr range_rvalue_reference_t<_Vp> iter_move(const _Iterator& __i) noexcept(noexcept(ranges::iter_move(__i._M_current))) { return ranges::iter_move(__i._M_current); } friend constexpr void iter_swap(const _Iterator& __x, const _Iterator& __y) noexcept(noexcept(ranges::iter_swap(__x._M_current, __y._M_current))) requires indirectly_swappable<_Vp_iter> { ranges::iter_swap(__x._M_current, __y._M_current); } }; struct _Sentinel { private: sentinel_t<_Vp> _M_end = sentinel_t<_Vp>(); constexpr bool __equal(const _Iterator& __i) const { return __i._M_current == _M_end; } public: _Sentinel() = default; constexpr explicit _Sentinel(filter_view* __parent) : _M_end(ranges::end(__parent->_M_base)) { } constexpr sentinel_t<_Vp> base() const { return _M_end; } friend constexpr bool operator==(const _Iterator& __x, const _Sentinel& __y) { return __y.__equal(__x); } }; [[no_unique_address]] __detail::__box<_Pred> _M_pred; [[no_unique_address]] __detail::_CachedPosition<_Vp> _M_cached_begin; _Vp _M_base = _Vp(); public: filter_view() requires default_initializable<_Vp> = default; constexpr filter_view(_Vp __base, _Pred __pred) : _M_pred(std::move(__pred)), _M_base(std::move(__base)) { } constexpr _Vp base() const& requires copy_constructible<_Vp> { return _M_base; } constexpr _Vp base() && { return std::move(_M_base); } constexpr const _Pred& pred() const { return *_M_pred; } constexpr _Iterator begin() { if (_M_cached_begin._M_has_value()) return {this, _M_cached_begin._M_get(_M_base)}; __glibcxx_assert(_M_pred.has_value()); auto __it = ranges::find_if(ranges::begin(_M_base), ranges::end(_M_base), std::ref(*_M_pred)); _M_cached_begin._M_set(_M_base, __it); return {this, std::move(__it)}; } constexpr auto end() { if constexpr (common_range<_Vp>) return _Iterator{this, ranges::end(_M_base)}; else return _Sentinel{this}; } }; template<typename _Range, typename _Pred> filter_view(_Range&&, _Pred) -> filter_view<views::all_t<_Range>, _Pred>; namespace views { namespace __detail { template<typename _Range, typename _Pred> concept __can_filter_view = requires { filter_view(std::declval<_Range>(), std::declval<_Pred>()); }; } // namespace __detail struct _Filter : __adaptor::_RangeAdaptor<_Filter> { template<viewable_range _Range, typename _Pred> requires __detail::__can_filter_view<_Range, _Pred> constexpr auto operator()(_Range&& __r, _Pred&& __p) const { return filter_view(std::forward<_Range>(__r), std::forward<_Pred>(__p)); } using _RangeAdaptor<_Filter>::operator(); static constexpr int _S_arity = 2; static constexpr bool _S_has_simple_extra_args = true; }; inline constexpr _Filter filter; } // namespace views template<input_range _Vp, copy_constructible _Fp> requires view<_Vp> && is_object_v<_Fp> && regular_invocable<_Fp&, range_reference_t<_Vp>> && std::__detail::__can_reference<invoke_result_t<_Fp&, range_reference_t<_Vp>>> class transform_view : public view_interface<transform_view<_Vp, _Fp>> { private: template<bool _Const> using _Base = __detail::__maybe_const_t<_Const, _Vp>; template<bool _Const> struct __iter_cat { }; template<bool _Const> requires forward_range<_Base<_Const>> struct __iter_cat<_Const> { private: static auto _S_iter_cat() { using _Base = transform_view::_Base<_Const>; using _Res = invoke_result_t<_Fp&, range_reference_t<_Base>>; if constexpr (is_lvalue_reference_v<_Res>) { using _Cat = typename iterator_traits<iterator_t<_Base>>::iterator_category; if constexpr (derived_from<_Cat, contiguous_iterator_tag>) return random_access_iterator_tag{}; else return _Cat{}; } else return input_iterator_tag{}; } public: using iterator_category = decltype(_S_iter_cat()); }; template<bool _Const> struct _Sentinel; template<bool _Const> struct _Iterator : __iter_cat<_Const> { private: using _Parent = __detail::__maybe_const_t<_Const, transform_view>; using _Base = transform_view::_Base<_Const>; static auto _S_iter_concept() { if constexpr (random_access_range<_Base>) return random_access_iterator_tag{}; else if constexpr (bidirectional_range<_Base>) return bidirectional_iterator_tag{}; else if constexpr (forward_range<_Base>) return forward_iterator_tag{}; else return input_iterator_tag{}; } using _Base_iter = iterator_t<_Base>; _Base_iter _M_current = _Base_iter(); _Parent* _M_parent = nullptr; public: using iterator_concept = decltype(_S_iter_concept()); // iterator_category defined in __transform_view_iter_cat using value_type = remove_cvref_t<invoke_result_t<_Fp&, range_reference_t<_Base>>>; using difference_type = range_difference_t<_Base>; _Iterator() requires default_initializable<_Base_iter> = default; constexpr _Iterator(_Parent* __parent, _Base_iter __current) : _M_current(std::move(__current)), _M_parent(__parent) { } constexpr _Iterator(_Iterator<!_Const> __i) requires _Const && convertible_to<iterator_t<_Vp>, _Base_iter> : _M_current(std::move(__i._M_current)), _M_parent(__i._M_parent) { } constexpr const _Base_iter& base() const & noexcept { return _M_current; } constexpr _Base_iter base() && { return std::move(_M_current); } constexpr decltype(auto) operator*() const noexcept(noexcept(std::__invoke(*_M_parent->_M_fun, *_M_current))) { return std::__invoke(*_M_parent->_M_fun, *_M_current); } constexpr _Iterator& operator++() { ++_M_current; return *this; } constexpr void operator++(int) { ++_M_current; } constexpr _Iterator operator++(int) requires forward_range<_Base> { auto __tmp = *this; ++*this; return __tmp; } constexpr _Iterator& operator--() requires bidirectional_range<_Base> { --_M_current; return *this; } constexpr _Iterator operator--(int) requires bidirectional_range<_Base> { auto __tmp = *this; --*this; return __tmp; } constexpr _Iterator& operator+=(difference_type __n) requires random_access_range<_Base> { _M_current += __n; return *this; } constexpr _Iterator& operator-=(difference_type __n) requires random_access_range<_Base> { _M_current -= __n; return *this; } constexpr decltype(auto) operator[](difference_type __n) const requires random_access_range<_Base> { return std::__invoke(*_M_parent->_M_fun, _M_current[__n]); } friend constexpr bool operator==(const _Iterator& __x, const _Iterator& __y) requires equality_comparable<_Base_iter> { return __x._M_current == __y._M_current; } friend constexpr bool operator<(const _Iterator& __x, const _Iterator& __y) requires random_access_range<_Base> { return __x._M_current < __y._M_current; } friend constexpr bool operator>(const _Iterator& __x, const _Iterator& __y) requires random_access_range<_Base> { return __y < __x; } friend constexpr bool operator<=(const _Iterator& __x, const _Iterator& __y) requires random_access_range<_Base> { return !(__y < __x); } friend constexpr bool operator>=(const _Iterator& __x, const _Iterator& __y) requires random_access_range<_Base> { return !(__x < __y); } #ifdef __cpp_lib_three_way_comparison friend constexpr auto operator<=>(const _Iterator& __x, const _Iterator& __y) requires random_access_range<_Base> && three_way_comparable<_Base_iter> { return __x._M_current <=> __y._M_current; } #endif friend constexpr _Iterator operator+(_Iterator __i, difference_type __n) requires random_access_range<_Base> { return {__i._M_parent, __i._M_current + __n}; } friend constexpr _Iterator operator+(difference_type __n, _Iterator __i) requires random_access_range<_Base> { return {__i._M_parent, __i._M_current + __n}; } friend constexpr _Iterator operator-(_Iterator __i, difference_type __n) requires random_access_range<_Base> { return {__i._M_parent, __i._M_current - __n}; } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3483. transform_view::iterator's difference is overconstrained friend constexpr difference_type operator-(const _Iterator& __x, const _Iterator& __y) requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>> { return __x._M_current - __y._M_current; } friend constexpr decltype(auto) iter_move(const _Iterator& __i) noexcept(noexcept(*__i)) { if constexpr (is_lvalue_reference_v<decltype(*__i)>) return std::move(*__i); else return *__i; } friend _Iterator<!_Const>; template<bool> friend struct _Sentinel; }; template<bool _Const> struct _Sentinel { private: using _Parent = __detail::__maybe_const_t<_Const, transform_view>; using _Base = transform_view::_Base<_Const>; template<bool _Const2> constexpr auto __distance_from(const _Iterator<_Const2>& __i) const { return _M_end - __i._M_current; } template<bool _Const2> constexpr bool __equal(const _Iterator<_Const2>& __i) const { return __i._M_current == _M_end; } sentinel_t<_Base> _M_end = sentinel_t<_Base>(); public: _Sentinel() = default; constexpr explicit _Sentinel(sentinel_t<_Base> __end) : _M_end(__end) { } constexpr _Sentinel(_Sentinel<!_Const> __i) requires _Const && convertible_to<sentinel_t<_Vp>, sentinel_t<_Base>> : _M_end(std::move(__i._M_end)) { } constexpr sentinel_t<_Base> base() const { return _M_end; } template<bool _Const2> requires sentinel_for<sentinel_t<_Base>, iterator_t<__detail::__maybe_const_t<_Const2, _Vp>>> friend constexpr bool operator==(const _Iterator<_Const2>& __x, const _Sentinel& __y) { return __y.__equal(__x); } template<bool _Const2, typename _Base2 = __detail::__maybe_const_t<_Const2, _Vp>> requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base2>> friend constexpr range_difference_t<_Base2> operator-(const _Iterator<_Const2>& __x, const _Sentinel& __y) { return -__y.__distance_from(__x); } template<bool _Const2, typename _Base2 = __detail::__maybe_const_t<_Const2, _Vp>> requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base2>> friend constexpr range_difference_t<_Base2> operator-(const _Sentinel& __y, const _Iterator<_Const2>& __x) { return __y.__distance_from(__x); } friend _Sentinel<!_Const>; }; [[no_unique_address]] __detail::__box<_Fp> _M_fun; _Vp _M_base = _Vp(); public: transform_view() requires default_initializable<_Vp> = default; constexpr transform_view(_Vp __base, _Fp __fun) : _M_fun(std::move(__fun)), _M_base(std::move(__base)) { } constexpr _Vp base() const& requires copy_constructible<_Vp> { return _M_base ; } constexpr _Vp base() && { return std::move(_M_base); } constexpr _Iterator<false> begin() { return _Iterator<false>{this, ranges::begin(_M_base)}; } constexpr _Iterator<true> begin() const requires range<const _Vp> && regular_invocable<const _Fp&, range_reference_t<const _Vp>> { return _Iterator<true>{this, ranges::begin(_M_base)}; } constexpr _Sentinel<false> end() { return _Sentinel<false>{ranges::end(_M_base)}; } constexpr _Iterator<false> end() requires common_range<_Vp> { return _Iterator<false>{this, ranges::end(_M_base)}; } constexpr _Sentinel<true> end() const requires range<const _Vp> && regular_invocable<const _Fp&, range_reference_t<const _Vp>> { return _Sentinel<true>{ranges::end(_M_base)}; } constexpr _Iterator<true> end() const requires common_range<const _Vp> && regular_invocable<const _Fp&, range_reference_t<const _Vp>> { return _Iterator<true>{this, ranges::end(_M_base)}; } constexpr auto size() requires sized_range<_Vp> { return ranges::size(_M_base); } constexpr auto size() const requires sized_range<const _Vp> { return ranges::size(_M_base); } }; template<typename _Range, typename _Fp> transform_view(_Range&&, _Fp) -> transform_view<views::all_t<_Range>, _Fp>; namespace views { namespace __detail { template<typename _Range, typename _Fp> concept __can_transform_view = requires { transform_view(std::declval<_Range>(), std::declval<_Fp>()); }; } // namespace __detail struct _Transform : __adaptor::_RangeAdaptor<_Transform> { template<viewable_range _Range, typename _Fp> requires __detail::__can_transform_view<_Range, _Fp> constexpr auto operator()(_Range&& __r, _Fp&& __f) const { return transform_view(std::forward<_Range>(__r), std::forward<_Fp>(__f)); } using _RangeAdaptor<_Transform>::operator(); static constexpr int _S_arity = 2; static constexpr bool _S_has_simple_extra_args = true; }; inline constexpr _Transform transform; } // namespace views template<view _Vp> class take_view : public view_interface<take_view<_Vp>> { private: template<bool _Const> using _CI = counted_iterator< iterator_t<__detail::__maybe_const_t<_Const, _Vp>>>; template<bool _Const> struct _Sentinel { private: using _Base = __detail::__maybe_const_t<_Const, _Vp>; sentinel_t<_Base> _M_end = sentinel_t<_Base>(); public: _Sentinel() = default; constexpr explicit _Sentinel(sentinel_t<_Base> __end) : _M_end(__end) { } constexpr _Sentinel(_Sentinel<!_Const> __s) requires _Const && convertible_to<sentinel_t<_Vp>, sentinel_t<_Base>> : _M_end(std::move(__s._M_end)) { } constexpr sentinel_t<_Base> base() const { return _M_end; } friend constexpr bool operator==(const _CI<_Const>& __y, const _Sentinel& __x) { return __y.count() == 0 || __y.base() == __x._M_end; } template<bool _OtherConst = !_Const, typename _Base2 = __detail::__maybe_const_t<_OtherConst, _Vp>> requires sentinel_for<sentinel_t<_Base>, iterator_t<_Base2>> friend constexpr bool operator==(const _CI<_OtherConst>& __y, const _Sentinel& __x) { return __y.count() == 0 || __y.base() == __x._M_end; } friend _Sentinel<!_Const>; }; range_difference_t<_Vp> _M_count = 0; _Vp _M_base = _Vp(); public: take_view() requires default_initializable<_Vp> = default; constexpr take_view(_Vp base, range_difference_t<_Vp> __count) : _M_count(std::move(__count)), _M_base(std::move(base)) { } constexpr _Vp base() const& requires copy_constructible<_Vp> { return _M_base; } constexpr _Vp base() && { return std::move(_M_base); } constexpr auto begin() requires (!__detail::__simple_view<_Vp>) { if constexpr (sized_range<_Vp>) { if constexpr (random_access_range<_Vp>) return ranges::begin(_M_base); else { auto __sz = size(); return counted_iterator(ranges::begin(_M_base), __sz); } } else return counted_iterator(ranges::begin(_M_base), _M_count); } constexpr auto begin() const requires range<const _Vp> { if constexpr (sized_range<const _Vp>) { if constexpr (random_access_range<const _Vp>) return ranges::begin(_M_base); else { auto __sz = size(); return counted_iterator(ranges::begin(_M_base), __sz); } } else return counted_iterator(ranges::begin(_M_base), _M_count); } constexpr auto end() requires (!__detail::__simple_view<_Vp>) { if constexpr (sized_range<_Vp>) { if constexpr (random_access_range<_Vp>) return ranges::begin(_M_base) + size(); else return default_sentinel; } else return _Sentinel<false>{ranges::end(_M_base)}; } constexpr auto end() const requires range<const _Vp> { if constexpr (sized_range<const _Vp>) { if constexpr (random_access_range<const _Vp>) return ranges::begin(_M_base) + size(); else return default_sentinel; } else return _Sentinel<true>{ranges::end(_M_base)}; } constexpr auto size() requires sized_range<_Vp> { auto __n = ranges::size(_M_base); return std::min(__n, static_cast<decltype(__n)>(_M_count)); } constexpr auto size() const requires sized_range<const _Vp> { auto __n = ranges::size(_M_base); return std::min(__n, static_cast<decltype(__n)>(_M_count)); } }; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3447. Deduction guides for take_view and drop_view have different // constraints template<typename _Range> take_view(_Range&&, range_difference_t<_Range>) -> take_view<views::all_t<_Range>>; template<typename _Tp> inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>; namespace views { namespace __detail { template<typename _Range, typename _Tp> concept __can_take_view = requires { take_view(std::declval<_Range>(), std::declval<_Tp>()); }; } // namespace __detail struct _Take : __adaptor::_RangeAdaptor<_Take> { template<viewable_range _Range, typename _Tp> requires __detail::__can_take_view<_Range, _Tp> constexpr auto operator()(_Range&& __r, _Tp&& __n) const { return take_view(std::forward<_Range>(__r), std::forward<_Tp>(__n)); } using _RangeAdaptor<_Take>::operator(); static constexpr int _S_arity = 2; // The count argument of views::take is not always simple -- it can be // e.g. a move-only class that's implicitly convertible to the difference // type. But an integer-like count argument is surely simple. template<typename _Tp> static constexpr bool _S_has_simple_extra_args = ranges::__detail::__is_integer_like<_Tp>; }; inline constexpr _Take take; } // namespace views template<view _Vp, typename _Pred> requires input_range<_Vp> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_Vp>> class take_while_view : public view_interface<take_while_view<_Vp, _Pred>> { template<bool _Const> struct _Sentinel { private: using _Base = __detail::__maybe_const_t<_Const, _Vp>; sentinel_t<_Base> _M_end = sentinel_t<_Base>(); const _Pred* _M_pred = nullptr; public: _Sentinel() = default; constexpr explicit _Sentinel(sentinel_t<_Base> __end, const _Pred* __pred) : _M_end(__end), _M_pred(__pred) { } constexpr _Sentinel(_Sentinel<!_Const> __s) requires _Const && convertible_to<sentinel_t<_Vp>, sentinel_t<_Base>> : _M_end(__s._M_end), _M_pred(__s._M_pred) { } constexpr sentinel_t<_Base> base() const { return _M_end; } friend constexpr bool operator==(const iterator_t<_Base>& __x, const _Sentinel& __y) { return __y._M_end == __x || !std::__invoke(*__y._M_pred, *__x); } template<bool _OtherConst = !_Const, typename _Base2 = __detail::__maybe_const_t<_OtherConst, _Vp>> requires sentinel_for<sentinel_t<_Base>, iterator_t<_Base2>> friend constexpr bool operator==(const iterator_t<_Base2>& __x, const _Sentinel& __y) { return __y._M_end == __x || !std::__invoke(*__y._M_pred, *__x); } friend _Sentinel<!_Const>; }; [[no_unique_address]] __detail::__box<_Pred> _M_pred; _Vp _M_base = _Vp(); public: take_while_view() requires default_initializable<_Vp> = default; constexpr take_while_view(_Vp base, _Pred __pred) : _M_pred(std::move(__pred)), _M_base(std::move(base)) { } constexpr _Vp base() const& requires copy_constructible<_Vp> { return _M_base; } constexpr _Vp base() && { return std::move(_M_base); } constexpr const _Pred& pred() const { return *_M_pred; } constexpr auto begin() requires (!__detail::__simple_view<_Vp>) { return ranges::begin(_M_base); } constexpr auto begin() const requires range<const _Vp> && indirect_unary_predicate<const _Pred, iterator_t<const _Vp>> { return ranges::begin(_M_base); } constexpr auto end() requires (!__detail::__simple_view<_Vp>) { return _Sentinel<false>(ranges::end(_M_base), std::__addressof(*_M_pred)); } constexpr auto end() const requires range<const _Vp> && indirect_unary_predicate<const _Pred, iterator_t<const _Vp>> { return _Sentinel<true>(ranges::end(_M_base), std::__addressof(*_M_pred)); } }; template<typename _Range, typename _Pred> take_while_view(_Range&&, _Pred) -> take_while_view<views::all_t<_Range>, _Pred>; namespace views { namespace __detail { template<typename _Range, typename _Pred> concept __can_take_while_view = requires { take_while_view(std::declval<_Range>(), std::declval<_Pred>()); }; } // namespace __detail struct _TakeWhile : __adaptor::_RangeAdaptor<_TakeWhile> { template<viewable_range _Range, typename _Pred> requires __detail::__can_take_while_view<_Range, _Pred> constexpr auto operator()(_Range&& __r, _Pred&& __p) const { return take_while_view(std::forward<_Range>(__r), std::forward<_Pred>(__p)); } using _RangeAdaptor<_TakeWhile>::operator(); static constexpr int _S_arity = 2; static constexpr bool _S_has_simple_extra_args = true; }; inline constexpr _TakeWhile take_while; } // namespace views template<view _Vp> class drop_view : public view_interface<drop_view<_Vp>> { private: range_difference_t<_Vp> _M_count = 0; _Vp _M_base = _Vp(); // ranges::next(begin(base), count, end(base)) is O(1) if _Vp satisfies // both random_access_range and sized_range. Otherwise, cache its result. static constexpr bool _S_needs_cached_begin = !(random_access_range<const _Vp> && sized_range<const _Vp>); [[no_unique_address]] __detail::__maybe_present_t<_S_needs_cached_begin, __detail::_CachedPosition<_Vp>> _M_cached_begin; public: drop_view() requires default_initializable<_Vp> = default; constexpr drop_view(_Vp __base, range_difference_t<_Vp> __count) : _M_count(__count), _M_base(std::move(__base)) { __glibcxx_assert(__count >= 0); } constexpr _Vp base() const& requires copy_constructible<_Vp> { return _M_base; } constexpr _Vp base() && { return std::move(_M_base); } // This overload is disabled for simple views with constant-time begin(). constexpr auto begin() requires (!(__detail::__simple_view<_Vp> && random_access_range<const _Vp> && sized_range<const _Vp>)) { if constexpr (_S_needs_cached_begin) if (_M_cached_begin._M_has_value()) return _M_cached_begin._M_get(_M_base); auto __it = ranges::next(ranges::begin(_M_base), _M_count, ranges::end(_M_base)); if constexpr (_S_needs_cached_begin) _M_cached_begin._M_set(_M_base, __it); return __it; } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3482. drop_view's const begin should additionally require sized_range constexpr auto begin() const requires random_access_range<const _Vp> && sized_range<const _Vp> { return ranges::next(ranges::begin(_M_base), _M_count, ranges::end(_M_base)); } constexpr auto end() requires (!__detail::__simple_view<_Vp>) { return ranges::end(_M_base); } constexpr auto end() const requires range<const _Vp> { return ranges::end(_M_base); } constexpr auto size() requires sized_range<_Vp> { const auto __s = ranges::size(_M_base); const auto __c = static_cast<decltype(__s)>(_M_count); return __s < __c ? 0 : __s - __c; } constexpr auto size() const requires sized_range<const _Vp> { const auto __s = ranges::size(_M_base); const auto __c = static_cast<decltype(__s)>(_M_count); return __s < __c ? 0 : __s - __c; } }; template<typename _Range> drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>; template<typename _Tp> inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>; namespace views { namespace __detail { template<typename _Range, typename _Tp> concept __can_drop_view = requires { drop_view(std::declval<_Range>(), std::declval<_Tp>()); }; } // namespace __detail struct _Drop : __adaptor::_RangeAdaptor<_Drop> { template<viewable_range _Range, typename _Tp> requires __detail::__can_drop_view<_Range, _Tp> constexpr auto operator()(_Range&& __r, _Tp&& __n) const { return drop_view(std::forward<_Range>(__r), std::forward<_Tp>(__n)); } using _RangeAdaptor<_Drop>::operator(); static constexpr int _S_arity = 2; template<typename _Tp> static constexpr bool _S_has_simple_extra_args = _Take::_S_has_simple_extra_args<_Tp>; }; inline constexpr _Drop drop; } // namespace views template<view _Vp, typename _Pred> requires input_range<_Vp> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_Vp>> class drop_while_view : public view_interface<drop_while_view<_Vp, _Pred>> { private: [[no_unique_address]] __detail::__box<_Pred> _M_pred; [[no_unique_address]] __detail::_CachedPosition<_Vp> _M_cached_begin; _Vp _M_base = _Vp(); public: drop_while_view() requires default_initializable<_Vp> = default; constexpr drop_while_view(_Vp __base, _Pred __pred) : _M_pred(std::move(__pred)), _M_base(std::move(__base)) { } constexpr _Vp base() const& requires copy_constructible<_Vp> { return _M_base; } constexpr _Vp base() && { return std::move(_M_base); } constexpr const _Pred& pred() const { return *_M_pred; } constexpr auto begin() { if (_M_cached_begin._M_has_value()) return _M_cached_begin._M_get(_M_base); __glibcxx_assert(_M_pred.has_value()); auto __it = ranges::find_if_not(ranges::begin(_M_base), ranges::end(_M_base), std::cref(*_M_pred)); _M_cached_begin._M_set(_M_base, __it); return __it; } constexpr auto end() { return ranges::end(_M_base); } }; template<typename _Range, typename _Pred> drop_while_view(_Range&&, _Pred) -> drop_while_view<views::all_t<_Range>, _Pred>; template<typename _Tp, typename _Pred> inline constexpr bool enable_borrowed_range<drop_while_view<_Tp, _Pred>> = enable_borrowed_range<_Tp>; namespace views { namespace __detail { template<typename _Range, typename _Pred> concept __can_drop_while_view = requires { drop_while_view(std::declval<_Range>(), std::declval<_Pred>()); }; } // namespace __detail struct _DropWhile : __adaptor::_RangeAdaptor<_DropWhile> { template<viewable_range _Range, typename _Pred> requires __detail::__can_drop_while_view<_Range, _Pred> constexpr auto operator()(_Range&& __r, _Pred&& __p) const { return drop_while_view(std::forward<_Range>(__r), std::forward<_Pred>(__p)); } using _RangeAdaptor<_DropWhile>::operator(); static constexpr int _S_arity = 2; static constexpr bool _S_has_simple_extra_args = true; }; inline constexpr _DropWhile drop_while; } // namespace views template<input_range _Vp> requires view<_Vp> && input_range<range_reference_t<_Vp>> class join_view : public view_interface<join_view<_Vp>> { private: using _InnerRange = range_reference_t<_Vp>; template<bool _Const> using _Base = __detail::__maybe_const_t<_Const, _Vp>; template<bool _Const> using _Outer_iter = iterator_t<_Base<_Const>>; template<bool _Const> using _Inner_iter = iterator_t<range_reference_t<_Base<_Const>>>; template<bool _Const> static constexpr bool _S_ref_is_glvalue = is_reference_v<range_reference_t<_Base<_Const>>>; template<bool _Const> struct __iter_cat { }; template<bool _Const> requires _S_ref_is_glvalue<_Const> && forward_range<_Base<_Const>> && forward_range<range_reference_t<_Base<_Const>>> struct __iter_cat<_Const> { private: static constexpr auto _S_iter_cat() { using _Outer_iter = join_view::_Outer_iter<_Const>; using _Inner_iter = join_view::_Inner_iter<_Const>; using _OuterCat = typename iterator_traits<_Outer_iter>::iterator_category; using _InnerCat = typename iterator_traits<_Inner_iter>::iterator_category; if constexpr (derived_from<_OuterCat, bidirectional_iterator_tag> && derived_from<_InnerCat, bidirectional_iterator_tag> && common_range<range_reference_t<_Base<_Const>>>) return bidirectional_iterator_tag{}; else if constexpr (derived_from<_OuterCat, forward_iterator_tag> && derived_from<_InnerCat, forward_iterator_tag>) return forward_iterator_tag{}; else return input_iterator_tag{}; } public: using iterator_category = decltype(_S_iter_cat()); }; template<bool _Const> struct _Sentinel; template<bool _Const> struct _Iterator : __iter_cat<_Const> { private: using _Parent = __detail::__maybe_const_t<_Const, join_view>; using _Base = join_view::_Base<_Const>; static constexpr bool _S_ref_is_glvalue = join_view::_S_ref_is_glvalue<_Const>; constexpr void _M_satisfy() { auto __update_inner = [this] (const iterator_t<_Base>& __x) -> auto&& { if constexpr (_S_ref_is_glvalue) return *__x; else return _M_parent->_M_inner._M_emplace_deref(__x); }; for (; _M_outer != ranges::end(_M_parent->_M_base); ++_M_outer) { auto&& __inner = __update_inner(_M_outer); _M_inner = ranges::begin(__inner); if (_M_inner != ranges::end(__inner)) return; } if constexpr (_S_ref_is_glvalue) _M_inner = _Inner_iter(); } static constexpr auto _S_iter_concept() { if constexpr (_S_ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>> && common_range<range_reference_t<_Base>>) return bidirectional_iterator_tag{}; else if constexpr (_S_ref_is_glvalue && forward_range<_Base> && forward_range<range_reference_t<_Base>>) return forward_iterator_tag{}; else return input_iterator_tag{}; } using _Outer_iter = join_view::_Outer_iter<_Const>; using _Inner_iter = join_view::_Inner_iter<_Const>; _Outer_iter _M_outer = _Outer_iter(); _Inner_iter _M_inner = _Inner_iter(); _Parent* _M_parent = nullptr; public: using iterator_concept = decltype(_S_iter_concept()); // iterator_category defined in __join_view_iter_cat using value_type = range_value_t<range_reference_t<_Base>>; using difference_type = common_type_t<range_difference_t<_Base>, range_difference_t<range_reference_t<_Base>>>; _Iterator() requires (default_initializable<_Outer_iter> && default_initializable<_Inner_iter>) = default; constexpr _Iterator(_Parent* __parent, _Outer_iter __outer) : _M_outer(std::move(__outer)), _M_parent(__parent) { _M_satisfy(); } constexpr _Iterator(_Iterator<!_Const> __i) requires _Const && convertible_to<iterator_t<_Vp>, _Outer_iter> && convertible_to<iterator_t<_InnerRange>, _Inner_iter> : _M_outer(std::move(__i._M_outer)), _M_inner(std::move(__i._M_inner)), _M_parent(__i._M_parent) { } constexpr decltype(auto) operator*() const { return *_M_inner; } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3500. join_view::iterator::operator->() is bogus constexpr _Inner_iter operator->() const requires __detail::__has_arrow<_Inner_iter> && copyable<_Inner_iter> { return _M_inner; } constexpr _Iterator& operator++() { auto&& __inner_range = [this] () -> auto&& { if constexpr (_S_ref_is_glvalue) return *_M_outer; else return *_M_parent->_M_inner; }(); if (++_M_inner == ranges::end(__inner_range)) { ++_M_outer; _M_satisfy(); } return *this; } constexpr void operator++(int) { ++*this; } constexpr _Iterator operator++(int) requires _S_ref_is_glvalue && forward_range<_Base> && forward_range<range_reference_t<_Base>> { auto __tmp = *this; ++*this; return __tmp; } constexpr _Iterator& operator--() requires _S_ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>> && common_range<range_reference_t<_Base>> { if (_M_outer == ranges::end(_M_parent->_M_base)) _M_inner = ranges::end(*--_M_outer); while (_M_inner == ranges::begin(*_M_outer)) _M_inner = ranges::end(*--_M_outer); --_M_inner; return *this; } constexpr _Iterator operator--(int) requires _S_ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>> && common_range<range_reference_t<_Base>> { auto __tmp = *this; --*this; return __tmp; } friend constexpr bool operator==(const _Iterator& __x, const _Iterator& __y) requires _S_ref_is_glvalue && equality_comparable<_Outer_iter> && equality_comparable<_Inner_iter> { return (__x._M_outer == __y._M_outer && __x._M_inner == __y._M_inner); } friend constexpr decltype(auto) iter_move(const _Iterator& __i) noexcept(noexcept(ranges::iter_move(__i._M_inner))) { return ranges::iter_move(__i._M_inner); } friend constexpr void iter_swap(const _Iterator& __x, const _Iterator& __y) noexcept(noexcept(ranges::iter_swap(__x._M_inner, __y._M_inner))) requires indirectly_swappable<_Inner_iter> { return ranges::iter_swap(__x._M_inner, __y._M_inner); } friend _Iterator<!_Const>; template<bool> friend struct _Sentinel; }; template<bool _Const> struct _Sentinel { private: using _Parent = __detail::__maybe_const_t<_Const, join_view>; using _Base = join_view::_Base<_Const>; template<bool _Const2> constexpr bool __equal(const _Iterator<_Const2>& __i) const { return __i._M_outer == _M_end; } sentinel_t<_Base> _M_end = sentinel_t<_Base>(); public: _Sentinel() = default; constexpr explicit _Sentinel(_Parent* __parent) : _M_end(ranges::end(__parent->_M_base)) { } constexpr _Sentinel(_Sentinel<!_Const> __s) requires _Const && convertible_to<sentinel_t<_Vp>, sentinel_t<_Base>> : _M_end(std::move(__s._M_end)) { } template<bool _Const2> requires sentinel_for<sentinel_t<_Base>, iterator_t<__detail::__maybe_const_t<_Const2, _Vp>>> friend constexpr bool operator==(const _Iterator<_Const2>& __x, const _Sentinel& __y) { return __y.__equal(__x); } friend _Sentinel<!_Const>; }; [[no_unique_address]] __detail::__non_propagating_cache<remove_cv_t<_InnerRange>> _M_inner; _Vp _M_base = _Vp(); public: join_view() requires default_initializable<_Vp> = default; constexpr explicit join_view(_Vp __base) : _M_base(std::move(__base)) { } constexpr _Vp base() const& requires copy_constructible<_Vp> { return _M_base; } constexpr _Vp base() && { return std::move(_M_base); } constexpr auto begin() { constexpr bool __use_const = (__detail::__simple_view<_Vp> && is_reference_v<range_reference_t<_Vp>>); return _Iterator<__use_const>{this, ranges::begin(_M_base)}; } constexpr auto begin() const requires input_range<const _Vp> && is_reference_v<range_reference_t<const _Vp>> { return _Iterator<true>{this, ranges::begin(_M_base)}; } constexpr auto end() { if constexpr (forward_range<_Vp> && is_reference_v<_InnerRange> && forward_range<_InnerRange> && common_range<_Vp> && common_range<_InnerRange>) return _Iterator<__detail::__simple_view<_Vp>>{this, ranges::end(_M_base)}; else return _Sentinel<__detail::__simple_view<_Vp>>{this}; } constexpr auto end() const requires input_range<const _Vp> && is_reference_v<range_reference_t<const _Vp>> { if constexpr (forward_range<const _Vp> && is_reference_v<range_reference_t<const _Vp>> && forward_range<range_reference_t<const _Vp>> && common_range<const _Vp> && common_range<range_reference_t<const _Vp>>) return _Iterator<true>{this, ranges::end(_M_base)}; else return _Sentinel<true>{this}; } }; template<typename _Range> explicit join_view(_Range&&) -> join_view<views::all_t<_Range>>; namespace views { namespace __detail { template<typename _Range> concept __can_join_view = requires { join_view<all_t<_Range>>{std::declval<_Range>()}; }; } // namespace __detail struct _Join : __adaptor::_RangeAdaptorClosure { template<viewable_range _Range> requires __detail::__can_join_view<_Range> constexpr auto operator()(_Range&& __r) const { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3474. Nesting join_views is broken because of CTAD return join_view<all_t<_Range>>{std::forward<_Range>(__r)}; } static constexpr bool _S_has_simple_call_op = true; }; inline constexpr _Join join; } // namespace views namespace __detail { template<auto> struct __require_constant; template<typename _Range> concept __tiny_range = sized_range<_Range> && requires { typename __require_constant<remove_reference_t<_Range>::size()>; } && (remove_reference_t<_Range>::size() <= 1); template<typename _Base> struct __split_view_outer_iter_cat { }; template<forward_range _Base> struct __split_view_outer_iter_cat<_Base> { using iterator_category = input_iterator_tag; }; template<typename _Base> struct __split_view_inner_iter_cat { }; template<forward_range _Base> struct __split_view_inner_iter_cat<_Base> { private: static constexpr auto _S_iter_cat() { using _Cat = typename iterator_traits<iterator_t<_Base>>::iterator_category; if constexpr (derived_from<_Cat, forward_iterator_tag>) return forward_iterator_tag{}; else return _Cat{}; } public: using iterator_category = decltype(_S_iter_cat()); }; } template<input_range _Vp, forward_range _Pattern> requires view<_Vp> && view<_Pattern> && indirectly_comparable<iterator_t<_Vp>, iterator_t<_Pattern>, ranges::equal_to> && (forward_range<_Vp> || __detail::__tiny_range<_Pattern>) class split_view : public view_interface<split_view<_Vp, _Pattern>> { private: template<bool _Const> using _Base = __detail::__maybe_const_t<_Const, _Vp>; template<bool _Const> struct _InnerIter; template<bool _Const> struct _OuterIter : __detail::__split_view_outer_iter_cat<_Base<_Const>> { private: using _Parent = __detail::__maybe_const_t<_Const, split_view>; using _Base = split_view::_Base<_Const>; constexpr bool __at_end() const { return __current() == ranges::end(_M_parent->_M_base); } // [range.split.outer] p1 // Many of the following specifications refer to the notional member // current of outer-iterator. current is equivalent to current_ if // V models forward_range, and parent_->current_ otherwise. constexpr auto& __current() noexcept { if constexpr (forward_range<_Vp>) return _M_current; else return _M_parent->_M_current; } constexpr auto& __current() const noexcept { if constexpr (forward_range<_Vp>) return _M_current; else return _M_parent->_M_current; } _Parent* _M_parent = nullptr; // XXX: _M_current is present only if "V models forward_range" [[no_unique_address]] __detail::__maybe_present_t<forward_range<_Vp>, iterator_t<_Base>> _M_current; public: using iterator_concept = conditional_t<forward_range<_Base>, forward_iterator_tag, input_iterator_tag>; // iterator_category defined in __split_view_outer_iter_cat using difference_type = range_difference_t<_Base>; struct value_type : view_interface<value_type> { private: _OuterIter _M_i = _OuterIter(); public: value_type() = default; constexpr explicit value_type(_OuterIter __i) : _M_i(std::move(__i)) { } constexpr _InnerIter<_Const> begin() const { return _InnerIter<_Const>{_M_i}; } constexpr default_sentinel_t end() const noexcept { return default_sentinel; } }; _OuterIter() = default; constexpr explicit _OuterIter(_Parent* __parent) requires (!forward_range<_Base>) : _M_parent(__parent) { } constexpr _OuterIter(_Parent* __parent, iterator_t<_Base> __current) requires forward_range<_Base> : _M_parent(__parent), _M_current(std::move(__current)) { } constexpr _OuterIter(_OuterIter<!_Const> __i) requires _Const && convertible_to<iterator_t<_Vp>, iterator_t<_Base>> : _M_parent(__i._M_parent), _M_current(std::move(__i._M_current)) { } constexpr value_type operator*() const { return value_type{*this}; } constexpr _OuterIter& operator++() { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3505. split_view::outer-iterator::operator++ misspecified const auto __end = ranges::end(_M_parent->_M_base); if (__current() == __end) return *this; const auto [__pbegin, __pend] = subrange{_M_parent->_M_pattern}; if (__pbegin == __pend) ++__current(); else if constexpr (__detail::__tiny_range<_Pattern>) { __current() = ranges::find(std::move(__current()), __end, *__pbegin); if (__current() != __end) ++__current(); } else do { auto [__b, __p] = ranges::mismatch(__current(), __end, __pbegin, __pend); if (__p == __pend) { __current() = __b; break; } } while (++__current() != __end); return *this; } constexpr decltype(auto) operator++(int) { if constexpr (forward_range<_Base>) { auto __tmp = *this; ++*this; return __tmp; } else ++*this; } friend constexpr bool operator==(const _OuterIter& __x, const _OuterIter& __y) requires forward_range<_Base> { return __x._M_current == __y._M_current; } friend constexpr bool operator==(const _OuterIter& __x, default_sentinel_t) { return __x.__at_end(); }; friend _OuterIter<!_Const>; friend _InnerIter<_Const>; }; template<bool _Const> struct _InnerIter : __detail::__split_view_inner_iter_cat<_Base<_Const>> { private: using _Base = split_view::_Base<_Const>; constexpr bool __at_end() const { auto [__pcur, __pend] = subrange{_M_i._M_parent->_M_pattern}; auto __end = ranges::end(_M_i._M_parent->_M_base); if constexpr (__detail::__tiny_range<_Pattern>) { const auto& __cur = _M_i_current(); if (__cur == __end) return true; if (__pcur == __pend) return _M_incremented; return *__cur == *__pcur; } else { auto __cur = _M_i_current(); if (__cur == __end) return true; if (__pcur == __pend) return _M_incremented; do { if (*__cur != *__pcur) return false; if (++__pcur == __pend) return true; } while (++__cur != __end); return false; } } constexpr auto& _M_i_current() noexcept { return _M_i.__current(); } constexpr auto& _M_i_current() const noexcept { return _M_i.__current(); } _OuterIter<_Const> _M_i = _OuterIter<_Const>(); bool _M_incremented = false; public: using iterator_concept = typename _OuterIter<_Const>::iterator_concept; // iterator_category defined in __split_view_inner_iter_cat using value_type = range_value_t<_Base>; using difference_type = range_difference_t<_Base>; _InnerIter() = default; constexpr explicit _InnerIter(_OuterIter<_Const> __i) : _M_i(std::move(__i)) { } constexpr const iterator_t<_Base>& base() const& noexcept { return _M_i_current(); } constexpr iterator_t<_Base> base() && requires forward_range<_Vp> { return std::move(_M_i_current()); } constexpr decltype(auto) operator*() const { return *_M_i_current(); } constexpr _InnerIter& operator++() { _M_incremented = true; if constexpr (!forward_range<_Base>) if constexpr (_Pattern::size() == 0) return *this; ++_M_i_current(); return *this; } constexpr decltype(auto) operator++(int) { if constexpr (forward_range<_Base>) { auto __tmp = *this; ++*this; return __tmp; } else ++*this; } friend constexpr bool operator==(const _InnerIter& __x, const _InnerIter& __y) requires forward_range<_Base> { return __x._M_i == __y._M_i; } friend constexpr bool operator==(const _InnerIter& __x, default_sentinel_t) { return __x.__at_end(); } friend constexpr decltype(auto) iter_move(const _InnerIter& __i) noexcept(noexcept(ranges::iter_move(__i._M_i_current()))) { return ranges::iter_move(__i._M_i_current()); } friend constexpr void iter_swap(const _InnerIter& __x, const _InnerIter& __y) noexcept(noexcept(ranges::iter_swap(__x._M_i_current(), __y._M_i_current()))) requires indirectly_swappable<iterator_t<_Base>> { ranges::iter_swap(__x._M_i_current(), __y._M_i_current()); } }; _Pattern _M_pattern = _Pattern(); // XXX: _M_current is "present only if !forward_range<V>" [[no_unique_address]] __detail::__maybe_present_t<!forward_range<_Vp>, iterator_t<_Vp>> _M_current; _Vp _M_base = _Vp(); public: split_view() requires (default_initializable<_Vp> && default_initializable<_Pattern> && (forward_range<_Vp> || default_initializable<iterator_t<_Vp>>)) = default; constexpr split_view(_Vp __base, _Pattern __pattern) : _M_pattern(std::move(__pattern)), _M_base(std::move(__base)) { } template<input_range _Range> requires constructible_from<_Vp, views::all_t<_Range>> && constructible_from<_Pattern, single_view<range_value_t<_Range>>> constexpr split_view(_Range&& __r, range_value_t<_Range> __e) : _M_pattern(views::single(std::move(__e))), _M_base(views::all(std::forward<_Range>(__r))) { } constexpr _Vp base() const& requires copy_constructible<_Vp> { return _M_base; } constexpr _Vp base() && { return std::move(_M_base); } constexpr auto begin() { if constexpr (forward_range<_Vp>) { constexpr bool __simple = __detail::__simple_view<_Vp> && __detail::__simple_view<_Pattern>; return _OuterIter<__simple>{this, ranges::begin(_M_base)}; } else { _M_current = ranges::begin(_M_base); return _OuterIter<false>{this}; } } constexpr auto begin() const requires forward_range<_Vp> && forward_range<const _Vp> { return _OuterIter<true>{this, ranges::begin(_M_base)}; } constexpr auto end() requires forward_range<_Vp> && common_range<_Vp> { constexpr bool __simple = __detail::__simple_view<_Vp> && __detail::__simple_view<_Pattern>; return _OuterIter<__simple>{this, ranges::end(_M_base)}; } constexpr auto end() const { if constexpr (forward_range<_Vp> && forward_range<const _Vp> && common_range<const _Vp>) return _OuterIter<true>{this, ranges::end(_M_base)}; else return default_sentinel; } }; template<typename _Range, typename _Pattern> split_view(_Range&&, _Pattern&&) -> split_view<views::all_t<_Range>, views::all_t<_Pattern>>; template<input_range _Range> split_view(_Range&&, range_value_t<_Range>) -> split_view<views::all_t<_Range>, single_view<range_value_t<_Range>>>; namespace views { namespace __detail { template<typename _Range, typename _Pattern> concept __can_split_view = requires { split_view(std::declval<_Range>(), std::declval<_Pattern>()); }; } // namespace __detail struct _Split : __adaptor::_RangeAdaptor<_Split> { template<viewable_range _Range, typename _Pattern> requires __detail::__can_split_view<_Range, _Pattern> constexpr auto operator()(_Range&& __r, _Pattern&& __f) const { return split_view(std::forward<_Range>(__r), std::forward<_Pattern>(__f)); } using _RangeAdaptor<_Split>::operator(); static constexpr int _S_arity = 2; // The pattern argument of views::split is not always simple -- it can be // a non-view range, the value category of which affects whether the call // is well-formed. But a scalar or a view pattern argument is surely // simple. template<typename _Pattern> static constexpr bool _S_has_simple_extra_args = is_scalar_v<_Pattern> || (view<_Pattern> && copy_constructible<_Pattern>); }; inline constexpr _Split split; } // namespace views namespace views { struct _Counted { template<input_or_output_iterator _Iter> constexpr auto operator()(_Iter __i, iter_difference_t<_Iter> __n) const { if constexpr (random_access_iterator<_Iter>) return subrange(__i, __i + __n); else return subrange(counted_iterator(std::move(__i), __n), default_sentinel); } }; inline constexpr _Counted counted{}; } // namespace views template<view _Vp> requires (!common_range<_Vp>) && copyable<iterator_t<_Vp>> class common_view : public view_interface<common_view<_Vp>> { private: _Vp _M_base = _Vp(); public: common_view() requires default_initializable<_Vp> = default; constexpr explicit common_view(_Vp __r) : _M_base(std::move(__r)) { } /* XXX: LWG 3280 didn't remove this constructor, but I think it should? template<viewable_range _Range> requires (!common_range<_Range>) && constructible_from<_Vp, views::all_t<_Range>> constexpr explicit common_view(_Range&& __r) : _M_base(views::all(std::forward<_Range>(__r))) { } */ constexpr _Vp base() const& requires copy_constructible<_Vp> { return _M_base; } constexpr _Vp base() && { return std::move(_M_base); } constexpr auto begin() { if constexpr (random_access_range<_Vp> && sized_range<_Vp>) return ranges::begin(_M_base); else return common_iterator<iterator_t<_Vp>, sentinel_t<_Vp>> (ranges::begin(_M_base)); } constexpr auto begin() const requires range<const _Vp> { if constexpr (random_access_range<const _Vp> && sized_range<const _Vp>) return ranges::begin(_M_base); else return common_iterator<iterator_t<const _Vp>, sentinel_t<const _Vp>> (ranges::begin(_M_base)); } constexpr auto end() { if constexpr (random_access_range<_Vp> && sized_range<_Vp>) return ranges::begin(_M_base) + ranges::size(_M_base); else return common_iterator<iterator_t<_Vp>, sentinel_t<_Vp>> (ranges::end(_M_base)); } constexpr auto end() const requires range<const _Vp> { if constexpr (random_access_range<const _Vp> && sized_range<const _Vp>) return ranges::begin(_M_base) + ranges::size(_M_base); else return common_iterator<iterator_t<const _Vp>, sentinel_t<const _Vp>> (ranges::end(_M_base)); } constexpr auto size() requires sized_range<_Vp> { return ranges::size(_M_base); } constexpr auto size() const requires sized_range<const _Vp> { return ranges::size(_M_base); } }; template<typename _Range> common_view(_Range&&) -> common_view<views::all_t<_Range>>; template<typename _Tp> inline constexpr bool enable_borrowed_range<common_view<_Tp>> = enable_borrowed_range<_Tp>; namespace views { namespace __detail { template<typename _Range> concept __already_common = common_range<_Range> && requires { views::all(std::declval<_Range>()); }; template<typename _Range> concept __can_common_view = requires { common_view{std::declval<_Range>()}; }; } // namespace __detail struct _Common : __adaptor::_RangeAdaptorClosure { template<viewable_range _Range> requires __detail::__already_common<_Range> || __detail::__can_common_view<_Range> constexpr auto operator()(_Range&& __r) const { if constexpr (__detail::__already_common<_Range>) return views::all(std::forward<_Range>(__r)); else return common_view{std::forward<_Range>(__r)}; } static constexpr bool _S_has_simple_call_op = true; }; inline constexpr _Common common; } // namespace views template<view _Vp> requires bidirectional_range<_Vp> class reverse_view : public view_interface<reverse_view<_Vp>> { private: static constexpr bool _S_needs_cached_begin = !common_range<_Vp> && !random_access_range<_Vp>; [[no_unique_address]] __detail::__maybe_present_t<_S_needs_cached_begin, __detail::_CachedPosition<_Vp>> _M_cached_begin; _Vp _M_base = _Vp(); public: reverse_view() requires default_initializable<_Vp> = default; constexpr explicit reverse_view(_Vp __r) : _M_base(std::move(__r)) { } constexpr _Vp base() const& requires copy_constructible<_Vp> { return _M_base; } constexpr _Vp base() && { return std::move(_M_base); } constexpr reverse_iterator<iterator_t<_Vp>> begin() { if constexpr (_S_needs_cached_begin) if (_M_cached_begin._M_has_value()) return std::make_reverse_iterator(_M_cached_begin._M_get(_M_base)); auto __it = ranges::next(ranges::begin(_M_base), ranges::end(_M_base)); if constexpr (_S_needs_cached_begin) _M_cached_begin._M_set(_M_base, __it); return std::make_reverse_iterator(std::move(__it)); } constexpr auto begin() requires common_range<_Vp> { return std::make_reverse_iterator(ranges::end(_M_base)); } constexpr auto begin() const requires common_range<const _Vp> { return std::make_reverse_iterator(ranges::end(_M_base)); } constexpr reverse_iterator<iterator_t<_Vp>> end() { return std::make_reverse_iterator(ranges::begin(_M_base)); } constexpr auto end() const requires common_range<const _Vp> { return std::make_reverse_iterator(ranges::begin(_M_base)); } constexpr auto size() requires sized_range<_Vp> { return ranges::size(_M_base); } constexpr auto size() const requires sized_range<const _Vp> { return ranges::size(_M_base); } }; template<typename _Range> reverse_view(_Range&&) -> reverse_view<views::all_t<_Range>>; template<typename _Tp> inline constexpr bool enable_borrowed_range<reverse_view<_Tp>> = enable_borrowed_range<_Tp>; namespace views { namespace __detail { template<typename> inline constexpr bool __is_reversible_subrange = false; template<typename _Iter, subrange_kind _Kind> inline constexpr bool __is_reversible_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> = true; template<typename> inline constexpr bool __is_reverse_view = false; template<typename _Vp> inline constexpr bool __is_reverse_view<reverse_view<_Vp>> = true; template<typename _Range> concept __can_reverse_view = requires { reverse_view{std::declval<_Range>()}; }; } // namespace __detail struct _Reverse : __adaptor::_RangeAdaptorClosure { template<viewable_range _Range> requires __detail::__is_reverse_view<remove_cvref_t<_Range>> || __detail::__is_reversible_subrange<remove_cvref_t<_Range>> || __detail::__can_reverse_view<_Range> constexpr auto operator()(_Range&& __r) const { using _Tp = remove_cvref_t<_Range>; if constexpr (__detail::__is_reverse_view<_Tp>) return std::forward<_Range>(__r).base(); else if constexpr (__detail::__is_reversible_subrange<_Tp>) { using _Iter = decltype(ranges::begin(__r).base()); if constexpr (sized_range<_Tp>) return subrange<_Iter, _Iter, subrange_kind::sized> {__r.end().base(), __r.begin().base(), __r.size()}; else return subrange<_Iter, _Iter, subrange_kind::unsized> {__r.end().base(), __r.begin().base()}; } else return reverse_view{std::forward<_Range>(__r)}; } static constexpr bool _S_has_simple_call_op = true; }; inline constexpr _Reverse reverse; } // namespace views namespace __detail { template<typename _Tp, size_t _Nm> concept __has_tuple_element = requires(_Tp __t) { typename tuple_size<_Tp>::type; requires _Nm < tuple_size_v<_Tp>; typename tuple_element_t<_Nm, _Tp>; { std::get<_Nm>(__t) } -> convertible_to<const tuple_element_t<_Nm, _Tp>&>; }; template<typename _Tp, size_t _Nm> concept __returnable_element = is_reference_v<_Tp> || move_constructible<tuple_element_t<_Nm, _Tp>>; } template<input_range _Vp, size_t _Nm> requires view<_Vp> && __detail::__has_tuple_element<range_value_t<_Vp>, _Nm> && __detail::__has_tuple_element<remove_reference_t<range_reference_t<_Vp>>, _Nm> && __detail::__returnable_element<range_reference_t<_Vp>, _Nm> class elements_view : public view_interface<elements_view<_Vp, _Nm>> { public: elements_view() requires default_initializable<_Vp> = default; constexpr explicit elements_view(_Vp base) : _M_base(std::move(base)) { } constexpr _Vp base() const& requires copy_constructible<_Vp> { return _M_base; } constexpr _Vp base() && { return std::move(_M_base); } constexpr auto begin() requires (!__detail::__simple_view<_Vp>) { return _Iterator<false>(ranges::begin(_M_base)); } constexpr auto begin() const requires range<const _Vp> { return _Iterator<true>(ranges::begin(_M_base)); } constexpr auto end() requires (!__detail::__simple_view<_Vp> && !common_range<_Vp>) { return _Sentinel<false>{ranges::end(_M_base)}; } constexpr auto end() requires (!__detail::__simple_view<_Vp> && common_range<_Vp>) { return _Iterator<false>{ranges::end(_M_base)}; } constexpr auto end() const requires range<const _Vp> { return _Sentinel<true>{ranges::end(_M_base)}; } constexpr auto end() const requires common_range<const _Vp> { return _Iterator<true>{ranges::end(_M_base)}; } constexpr auto size() requires sized_range<_Vp> { return ranges::size(_M_base); } constexpr auto size() const requires sized_range<const _Vp> { return ranges::size(_M_base); } private: template<bool _Const> using _Base = __detail::__maybe_const_t<_Const, _Vp>; template<bool _Const> struct __iter_cat { }; template<bool _Const> requires forward_range<_Base<_Const>> struct __iter_cat<_Const> { private: static auto _S_iter_cat() { using _Base = elements_view::_Base<_Const>; using _Cat = typename iterator_traits<iterator_t<_Base>>::iterator_category; using _Res = decltype((std::get<_Nm>(*std::declval<iterator_t<_Base>>()))); if constexpr (!is_lvalue_reference_v<_Res>) return input_iterator_tag{}; else if constexpr (derived_from<_Cat, random_access_iterator_tag>) return random_access_iterator_tag{}; else return _Cat{}; } public: using iterator_category = decltype(_S_iter_cat()); }; template<bool _Const> struct _Sentinel; template<bool _Const> struct _Iterator : __iter_cat<_Const> { private: using _Base = elements_view::_Base<_Const>; iterator_t<_Base> _M_current = iterator_t<_Base>(); static constexpr decltype(auto) _S_get_element(const iterator_t<_Base>& __i) { if constexpr (is_reference_v<range_reference_t<_Base>>) return std::get<_Nm>(*__i); else { using _Et = remove_cv_t<tuple_element_t<_Nm, range_reference_t<_Base>>>; return static_cast<_Et>(std::get<_Nm>(*__i)); } } static auto _S_iter_concept() { if constexpr (random_access_range<_Base>) return random_access_iterator_tag{}; else if constexpr (bidirectional_range<_Base>) return bidirectional_iterator_tag{}; else if constexpr (forward_range<_Base>) return forward_iterator_tag{}; else return input_iterator_tag{}; } friend _Iterator<!_Const>; public: using iterator_concept = decltype(_S_iter_concept()); // iterator_category defined in elements_view::__iter_cat using value_type = remove_cvref_t<tuple_element_t<_Nm, range_value_t<_Base>>>; using difference_type = range_difference_t<_Base>; _Iterator() requires default_initializable<iterator_t<_Base>> = default; constexpr explicit _Iterator(iterator_t<_Base> current) : _M_current(std::move(current)) { } constexpr _Iterator(_Iterator<!_Const> i) requires _Const && convertible_to<iterator_t<_Vp>, iterator_t<_Base>> : _M_current(std::move(i._M_current)) { } constexpr const iterator_t<_Base>& base() const& noexcept { return _M_current; } constexpr iterator_t<_Base> base() && { return std::move(_M_current); } constexpr decltype(auto) operator*() const { return _S_get_element(_M_current); } constexpr _Iterator& operator++() { ++_M_current; return *this; } constexpr void operator++(int) { ++_M_current; } constexpr _Iterator operator++(int) requires forward_range<_Base> { auto __tmp = *this; ++_M_current; return __tmp; } constexpr _Iterator& operator--() requires bidirectional_range<_Base> { --_M_current; return *this; } constexpr _Iterator operator--(int) requires bidirectional_range<_Base> { auto __tmp = *this; --_M_current; return __tmp; } constexpr _Iterator& operator+=(difference_type __n) requires random_access_range<_Base> { _M_current += __n; return *this; } constexpr _Iterator& operator-=(difference_type __n) requires random_access_range<_Base> { _M_current -= __n; return *this; } constexpr decltype(auto) operator[](difference_type __n) const requires random_access_range<_Base> { return _S_get_element(_M_current + __n); } friend constexpr bool operator==(const _Iterator& __x, const _Iterator& __y) requires equality_comparable<iterator_t<_Base>> { return __x._M_current == __y._M_current; } friend constexpr bool operator<(const _Iterator& __x, const _Iterator& __y) requires random_access_range<_Base> { return __x._M_current < __y._M_current; } friend constexpr bool operator>(const _Iterator& __x, const _Iterator& __y) requires random_access_range<_Base> { return __y._M_current < __x._M_current; } friend constexpr bool operator<=(const _Iterator& __x, const _Iterator& __y) requires random_access_range<_Base> { return !(__y._M_current > __x._M_current); } friend constexpr bool operator>=(const _Iterator& __x, const _Iterator& __y) requires random_access_range<_Base> { return !(__x._M_current > __y._M_current); } #ifdef __cpp_lib_three_way_comparison friend constexpr auto operator<=>(const _Iterator& __x, const _Iterator& __y) requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>> { return __x._M_current <=> __y._M_current; } #endif friend constexpr _Iterator operator+(const _Iterator& __x, difference_type __y) requires random_access_range<_Base> { return _Iterator{__x} += __y; } friend constexpr _Iterator operator+(difference_type __x, const _Iterator& __y) requires random_access_range<_Base> { return __y + __x; } friend constexpr _Iterator operator-(const _Iterator& __x, difference_type __y) requires random_access_range<_Base> { return _Iterator{__x} -= __y; } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3483. transform_view::iterator's difference is overconstrained friend constexpr difference_type operator-(const _Iterator& __x, const _Iterator& __y) requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>> { return __x._M_current - __y._M_current; } template <bool> friend struct _Sentinel; }; template<bool _Const> struct _Sentinel { private: template<bool _Const2> constexpr bool _M_equal(const _Iterator<_Const2>& __x) const { return __x._M_current == _M_end; } template<bool _Const2> constexpr auto _M_distance_from(const _Iterator<_Const2>& __i) const { return _M_end - __i._M_current; } using _Base = elements_view::_Base<_Const>; sentinel_t<_Base> _M_end = sentinel_t<_Base>(); public: _Sentinel() = default; constexpr explicit _Sentinel(sentinel_t<_Base> __end) : _M_end(std::move(__end)) { } constexpr _Sentinel(_Sentinel<!_Const> __other) requires _Const && convertible_to<sentinel_t<_Vp>, sentinel_t<_Base>> : _M_end(std::move(__other._M_end)) { } constexpr sentinel_t<_Base> base() const { return _M_end; } template<bool _Const2> requires sentinel_for<sentinel_t<_Base>, iterator_t<__detail::__maybe_const_t<_Const2, _Vp>>> friend constexpr bool operator==(const _Iterator<_Const2>& __x, const _Sentinel& __y) { return __y._M_equal(__x); } template<bool _Const2, typename _Base2 = __detail::__maybe_const_t<_Const2, _Vp>> requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base2>> friend constexpr range_difference_t<_Base2> operator-(const _Iterator<_Const2>& __x, const _Sentinel& __y) { return -__y._M_distance_from(__x); } template<bool _Const2, typename _Base2 = __detail::__maybe_const_t<_Const2, _Vp>> requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base2>> friend constexpr range_difference_t<_Base2> operator-(const _Sentinel& __x, const _Iterator<_Const2>& __y) { return __x._M_distance_from(__y); } friend _Sentinel<!_Const>; }; _Vp _M_base = _Vp(); }; template<typename _Tp, size_t _Nm> inline constexpr bool enable_borrowed_range<elements_view<_Tp, _Nm>> = enable_borrowed_range<_Tp>; template<typename _Range> using keys_view = elements_view<views::all_t<_Range>, 0>; template<typename _Range> using values_view = elements_view<views::all_t<_Range>, 1>; namespace views { namespace __detail { template<size_t _Nm, typename _Range> concept __can_elements_view = requires { elements_view<all_t<_Range>, _Nm>{std::declval<_Range>()}; }; } // namespace __detail template<size_t _Nm> struct _Elements : __adaptor::_RangeAdaptorClosure { template<viewable_range _Range> requires __detail::__can_elements_view<_Nm, _Range> constexpr auto operator()(_Range&& __r) const { return elements_view<all_t<_Range>, _Nm>{std::forward<_Range>(__r)}; } static constexpr bool _S_has_simple_call_op = true; }; template<size_t _Nm> inline constexpr _Elements<_Nm> elements; inline constexpr auto keys = elements<0>; inline constexpr auto values = elements<1>; } // namespace views } // namespace ranges namespace views = ranges::views; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // library concepts #endif // C++2a #endif /* _GLIBCXX_RANGES */ // <set> -*- C++ -*- // Copyright (C) 2001-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /* * * Copyright (c) 1994 * Hewlett-Packard Company * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Hewlett-Packard Company makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. * * * Copyright (c) 1996,1997 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ /** @file include/set * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_SET #define _GLIBCXX_SET 1 #pragma GCC system_header #include <bits/stl_tree.h> #include <bits/stl_set.h> #include <bits/stl_multiset.h> #include <bits/range_access.h> #include <bits/erase_if.h> #ifdef _GLIBCXX_DEBUG # include <debug/set> #endif #if __cplusplus >= 201703L namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace pmr { template<typename _Tp> class polymorphic_allocator; template<typename _Key, typename _Cmp = std::less<_Key>> using set = std::set<_Key, _Cmp, polymorphic_allocator<_Key>>; template<typename _Key, typename _Cmp = std::less<_Key>> using multiset = std::multiset<_Key, _Cmp, polymorphic_allocator<_Key>>; } // namespace pmr _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++17 #if __cplusplus > 201703L namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Key, typename _Compare, typename _Alloc, typename _Predicate> inline typename set<_Key, _Compare, _Alloc>::size_type erase_if(set<_Key, _Compare, _Alloc>& __cont, _Predicate __pred) { return __detail::__erase_nodes_if(__cont, __pred); } template<typename _Key, typename _Compare, typename _Alloc, typename _Predicate> inline typename multiset<_Key, _Compare, _Alloc>::size_type erase_if(multiset<_Key, _Compare, _Alloc>& __cont, _Predicate __pred) { return __detail::__erase_nodes_if(__cont, __pred); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++20 #endif /* _GLIBCXX_SET */ // -*- C++ -*- forwarding header. // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/cwctype * This is a Standard C++ Library file. You should @c \#include this file * in your programs, rather than any of the @a *.h implementation files. * * This is the C++ version of the Standard C Library header @c wctype.h, * and its contents are (mostly) the same as that header, but are all * contained in the namespace @c std (except for names which are defined * as macros in C). */ // // ISO C++ 14882: <cwctype> // #pragma GCC system_header #include <bits/c++config.h> #if _GLIBCXX_HAVE_WCTYPE_H #if __GLIBC__ == 2 && __GLIBC_MINOR__ < 10 // Work around glibc BZ 9694 #include <stddef.h> #endif #include <wctype.h> #endif // _GLIBCXX_HAVE_WCTYPE_H #ifndef _GLIBCXX_CWCTYPE #define _GLIBCXX_CWCTYPE 1 // Get rid of those macros defined in <wctype.h> in lieu of real functions. #undef iswalnum #undef iswalpha #if _GLIBCXX_HAVE_ISWBLANK # undef iswblank #endif #undef iswcntrl #undef iswctype #undef iswdigit #undef iswgraph #undef iswlower #undef iswprint #undef iswpunct #undef iswspace #undef iswupper #undef iswxdigit #undef towctrans #undef towlower #undef towupper #undef wctrans #undef wctype #if _GLIBCXX_USE_WCHAR_T namespace std { using ::wctrans_t; using ::wctype_t; using ::wint_t; using ::iswalnum; using ::iswalpha; #if _GLIBCXX_HAVE_ISWBLANK using ::iswblank; #endif using ::iswcntrl; using ::iswctype; using ::iswdigit; using ::iswgraph; using ::iswlower; using ::iswprint; using ::iswpunct; using ::iswspace; using ::iswupper; using ::iswxdigit; using ::towctrans; using ::towlower; using ::towupper; using ::wctrans; using ::wctype; } // namespace #endif //_GLIBCXX_USE_WCHAR_T #endif // _GLIBCXX_CWCTYPE // <future> -*- C++ -*- // Copyright (C) 2009-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/future * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_FUTURE #define _GLIBCXX_FUTURE 1 #pragma GCC system_header #if __cplusplus < 201103L # include <bits/c++0x_warning.h> #else #include <mutex> // call_once #include <condition_variable> // __at_thread_exit_elt #include <system_error> #include <atomic> #include <bits/allocated_ptr.h> #include <bits/atomic_futex.h> #include <bits/invoke.h> #include <bits/unique_ptr.h> #include <bits/shared_ptr.h> #include <bits/std_function.h> #include <bits/std_thread.h> #include <bits/uses_allocator.h> #include <ext/aligned_buffer.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @defgroup futures Futures * @ingroup concurrency * * Classes for futures support. * @{ */ /// Error code for futures enum class future_errc { future_already_retrieved = 1, promise_already_satisfied, no_state, broken_promise }; /// Specialization. template<> struct is_error_code_enum<future_errc> : public true_type { }; /// Points to a statically-allocated object derived from error_category. const error_category& future_category() noexcept; /// Overload for make_error_code. inline error_code make_error_code(future_errc __errc) noexcept { return error_code(static_cast<int>(__errc), future_category()); } /// Overload for make_error_condition. inline error_condition make_error_condition(future_errc __errc) noexcept { return error_condition(static_cast<int>(__errc), future_category()); } /** * @brief Exception type thrown by futures. * @ingroup exceptions */ class future_error : public logic_error { public: explicit future_error(future_errc __errc) : future_error(std::make_error_code(__errc)) { } virtual ~future_error() noexcept; virtual const char* what() const noexcept; const error_code& code() const noexcept { return _M_code; } private: explicit future_error(error_code __ec) : logic_error("std::future_error: " + __ec.message()), _M_code(__ec) { } friend void __throw_future_error(int); error_code _M_code; }; // Forward declarations. template<typename _Res> class future; template<typename _Res> class shared_future; template<typename _Signature> class packaged_task; template<typename _Res> class promise; /// Launch code for futures enum class launch { async = 1, deferred = 2 }; constexpr launch operator&(launch __x, launch __y) noexcept { return static_cast<launch>( static_cast<int>(__x) & static_cast<int>(__y)); } constexpr launch operator|(launch __x, launch __y) noexcept { return static_cast<launch>( static_cast<int>(__x) | static_cast<int>(__y)); } constexpr launch operator^(launch __x, launch __y) noexcept { return static_cast<launch>( static_cast<int>(__x) ^ static_cast<int>(__y)); } constexpr launch operator~(launch __x) noexcept { return static_cast<launch>(~static_cast<int>(__x)); } inline launch& operator&=(launch& __x, launch __y) noexcept { return __x = __x & __y; } inline launch& operator|=(launch& __x, launch __y) noexcept { return __x = __x | __y; } inline launch& operator^=(launch& __x, launch __y) noexcept { return __x = __x ^ __y; } /// Status code for futures enum class future_status { ready, timeout, deferred }; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2021. Further incorrect usages of result_of template<typename _Fn, typename... _Args> using __async_result_of = typename __invoke_result< typename decay<_Fn>::type, typename decay<_Args>::type...>::type; template<typename _Fn, typename... _Args> future<__async_result_of<_Fn, _Args...>> async(launch __policy, _Fn&& __fn, _Args&&... __args); template<typename _Fn, typename... _Args> future<__async_result_of<_Fn, _Args...>> async(_Fn&& __fn, _Args&&... __args); #if defined(_GLIBCXX_HAS_GTHREADS) /// Base class and enclosing scope. struct __future_base { /// Base class for results. struct _Result_base { exception_ptr _M_error; _Result_base(const _Result_base&) = delete; _Result_base& operator=(const _Result_base&) = delete; // _M_destroy() allows derived classes to control deallocation virtual void _M_destroy() = 0; struct _Deleter { void operator()(_Result_base* __fr) const { __fr->_M_destroy(); } }; protected: _Result_base(); virtual ~_Result_base(); }; /// A unique_ptr for result objects. template<typename _Res> using _Ptr = unique_ptr<_Res, _Result_base::_Deleter>; /// A result object that has storage for an object of type _Res. template<typename _Res> struct _Result : _Result_base { private: __gnu_cxx::__aligned_buffer<_Res> _M_storage; bool _M_initialized; public: typedef _Res result_type; _Result() noexcept : _M_initialized() { } ~_Result() { if (_M_initialized) _M_value().~_Res(); } // Return lvalue, future will add const or rvalue-reference _Res& _M_value() noexcept { return *_M_storage._M_ptr(); } void _M_set(const _Res& __res) { ::new (_M_storage._M_addr()) _Res(__res); _M_initialized = true; } void _M_set(_Res&& __res) { ::new (_M_storage._M_addr()) _Res(std::move(__res)); _M_initialized = true; } private: void _M_destroy() { delete this; } }; /// A result object that uses an allocator. template<typename _Res, typename _Alloc> struct _Result_alloc final : _Result<_Res>, _Alloc { using __allocator_type = __alloc_rebind<_Alloc, _Result_alloc>; explicit _Result_alloc(const _Alloc& __a) : _Result<_Res>(), _Alloc(__a) { } private: void _M_destroy() { __allocator_type __a(*this); __allocated_ptr<__allocator_type> __guard_ptr{ __a, this }; this->~_Result_alloc(); } }; // Create a result object that uses an allocator. template<typename _Res, typename _Allocator> static _Ptr<_Result_alloc<_Res, _Allocator>> _S_allocate_result(const _Allocator& __a) { using __result_type = _Result_alloc<_Res, _Allocator>; typename __result_type::__allocator_type __a2(__a); auto __guard = std::__allocate_guarded(__a2); __result_type* __p = ::new((void*)__guard.get()) __result_type{__a}; __guard = nullptr; return _Ptr<__result_type>(__p); } // Keep it simple for std::allocator. template<typename _Res, typename _Tp> static _Ptr<_Result<_Res>> _S_allocate_result(const std::allocator<_Tp>& __a) { return _Ptr<_Result<_Res>>(new _Result<_Res>); } // Base class for various types of shared state created by an // asynchronous provider (such as a std::promise) and shared with one // or more associated futures. class _State_baseV2 { typedef _Ptr<_Result_base> _Ptr_type; enum _Status : unsigned { __not_ready, __ready }; _Ptr_type _M_result; __atomic_futex_unsigned<> _M_status; atomic_flag _M_retrieved = ATOMIC_FLAG_INIT; once_flag _M_once; public: _State_baseV2() noexcept : _M_result(), _M_status(_Status::__not_ready) { } _State_baseV2(const _State_baseV2&) = delete; _State_baseV2& operator=(const _State_baseV2&) = delete; virtual ~_State_baseV2() = default; _Result_base& wait() { // Run any deferred function or join any asynchronous thread: _M_complete_async(); // Acquire MO makes sure this synchronizes with the thread that made // the future ready. _M_status._M_load_when_equal(_Status::__ready, memory_order_acquire); return *_M_result; } template<typename _Rep, typename _Period> future_status wait_for(const chrono::duration<_Rep, _Period>& __rel) { // First, check if the future has been made ready. Use acquire MO // to synchronize with the thread that made it ready. if (_M_status._M_load(memory_order_acquire) == _Status::__ready) return future_status::ready; if (_M_is_deferred_future()) return future_status::deferred; // Don't wait unless the relative time is greater than zero. if (__rel > __rel.zero() && _M_status._M_load_when_equal_for(_Status::__ready, memory_order_acquire, __rel)) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2100. timed waiting functions must also join // This call is a no-op by default except on an async future, // in which case the async thread is joined. It's also not a // no-op for a deferred future, but such a future will never // reach this point because it returns future_status::deferred // instead of waiting for the future to become ready (see // above). Async futures synchronize in this call, so we need // no further synchronization here. _M_complete_async(); return future_status::ready; } return future_status::timeout; } template<typename _Clock, typename _Duration> future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs) { #if __cplusplus > 201703L static_assert(chrono::is_clock_v<_Clock>); #endif // First, check if the future has been made ready. Use acquire MO // to synchronize with the thread that made it ready. if (_M_status._M_load(memory_order_acquire) == _Status::__ready) return future_status::ready; if (_M_is_deferred_future()) return future_status::deferred; if (_M_status._M_load_when_equal_until(_Status::__ready, memory_order_acquire, __abs)) { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2100. timed waiting functions must also join // See wait_for(...) above. _M_complete_async(); return future_status::ready; } return future_status::timeout; } // Provide a result to the shared state and make it ready. // Calls at most once: _M_result = __res(); void _M_set_result(function<_Ptr_type()> __res, bool __ignore_failure = false) { bool __did_set = false; // all calls to this function are serialized, // side-effects of invoking __res only happen once call_once(_M_once, &_State_baseV2::_M_do_set, this, std::__addressof(__res), std::__addressof(__did_set)); if (__did_set) // Use release MO to synchronize with observers of the ready state. _M_status._M_store_notify_all(_Status::__ready, memory_order_release); else if (!__ignore_failure) __throw_future_error(int(future_errc::promise_already_satisfied)); } // Provide a result to the shared state but delay making it ready // until the calling thread exits. // Calls at most once: _M_result = __res(); void _M_set_delayed_result(function<_Ptr_type()> __res, weak_ptr<_State_baseV2> __self) { bool __did_set = false; unique_ptr<_Make_ready> __mr{new _Make_ready}; // all calls to this function are serialized, // side-effects of invoking __res only happen once call_once(_M_once, &_State_baseV2::_M_do_set, this, std::__addressof(__res), std::__addressof(__did_set)); if (!__did_set) __throw_future_error(int(future_errc::promise_already_satisfied)); __mr->_M_shared_state = std::move(__self); __mr->_M_set(); __mr.release(); } // Abandon this shared state. void _M_break_promise(_Ptr_type __res) { if (static_cast<bool>(__res)) { __res->_M_error = make_exception_ptr(future_error(future_errc::broken_promise)); // This function is only called when the last asynchronous result // provider is abandoning this shared state, so noone can be // trying to make the shared state ready at the same time, and // we can access _M_result directly instead of through call_once. _M_result.swap(__res); // Use release MO to synchronize with observers of the ready state. _M_status._M_store_notify_all(_Status::__ready, memory_order_release); } } // Called when this object is first passed to a future. void _M_set_retrieved_flag() { if (_M_retrieved.test_and_set()) __throw_future_error(int(future_errc::future_already_retrieved)); } template<typename _Res, typename _Arg> struct _Setter; // set lvalues template<typename _Res, typename _Arg> struct _Setter<_Res, _Arg&> { // check this is only used by promise<R>::set_value(const R&) // or promise<R&>::set_value(R&) static_assert(is_same<_Res, _Arg&>::value // promise<R&> || is_same<const _Res, _Arg>::value, // promise<R> "Invalid specialisation"); // Used by std::promise to copy construct the result. typename promise<_Res>::_Ptr_type operator()() const { _M_promise->_M_storage->_M_set(*_M_arg); return std::move(_M_promise->_M_storage); } promise<_Res>* _M_promise; _Arg* _M_arg; }; // set rvalues template<typename _Res> struct _Setter<_Res, _Res&&> { // Used by std::promise to move construct the result. typename promise<_Res>::_Ptr_type operator()() const { _M_promise->_M_storage->_M_set(std::move(*_M_arg)); return std::move(_M_promise->_M_storage); } promise<_Res>* _M_promise; _Res* _M_arg; }; // set void template<typename _Res> struct _Setter<_Res, void> { static_assert(is_void<_Res>::value, "Only used for promise<void>"); typename promise<_Res>::_Ptr_type operator()() const { return std::move(_M_promise->_M_storage); } promise<_Res>* _M_promise; }; struct __exception_ptr_tag { }; // set exceptions template<typename _Res> struct _Setter<_Res, __exception_ptr_tag> { // Used by std::promise to store an exception as the result. typename promise<_Res>::_Ptr_type operator()() const { _M_promise->_M_storage->_M_error = *_M_ex; return std::move(_M_promise->_M_storage); } promise<_Res>* _M_promise; exception_ptr* _M_ex; }; template<typename _Res, typename _Arg> __attribute__((__always_inline__)) static _Setter<_Res, _Arg&&> __setter(promise<_Res>* __prom, _Arg&& __arg) noexcept { return _Setter<_Res, _Arg&&>{ __prom, std::__addressof(__arg) }; } template<typename _Res> __attribute__((__always_inline__)) static _Setter<_Res, __exception_ptr_tag> __setter(exception_ptr& __ex, promise<_Res>* __prom) noexcept { return _Setter<_Res, __exception_ptr_tag>{ __prom, &__ex }; } template<typename _Res> __attribute__((__always_inline__)) static _Setter<_Res, void> __setter(promise<_Res>* __prom) noexcept { return _Setter<_Res, void>{ __prom }; } template<typename _Tp> static void _S_check(const shared_ptr<_Tp>& __p) { if (!static_cast<bool>(__p)) __throw_future_error((int)future_errc::no_state); } private: // The function invoked with std::call_once(_M_once, ...). void _M_do_set(function<_Ptr_type()>* __f, bool* __did_set) { _Ptr_type __res = (*__f)(); // Notify the caller that we did try to set; if we do not throw an // exception, the caller will be aware that it did set (e.g., see // _M_set_result). *__did_set = true; _M_result.swap(__res); // nothrow } // Wait for completion of async function. virtual void _M_complete_async() { } // Return true if state corresponds to a deferred function. virtual bool _M_is_deferred_future() const { return false; } struct _Make_ready final : __at_thread_exit_elt { weak_ptr<_State_baseV2> _M_shared_state; static void _S_run(void*); void _M_set(); }; }; #ifdef _GLIBCXX_ASYNC_ABI_COMPAT class _State_base; class _Async_state_common; #else using _State_base = _State_baseV2; class _Async_state_commonV2; #endif template<typename _BoundFn, typename _Res = decltype(std::declval<_BoundFn&>()())> class _Deferred_state; template<typename _BoundFn, typename _Res = decltype(std::declval<_BoundFn&>()())> class _Async_state_impl; template<typename _Signature> class _Task_state_base; template<typename _Fn, typename _Alloc, typename _Signature> class _Task_state; template<typename _Res_ptr, typename _Fn, typename _Res = typename _Res_ptr::element_type::result_type> struct _Task_setter; template<typename _Res_ptr, typename _BoundFn> static _Task_setter<_Res_ptr, _BoundFn> _S_task_setter(_Res_ptr& __ptr, _BoundFn& __call) { return { std::__addressof(__ptr), std::__addressof(__call) }; } }; /// Partial specialization for reference types. template<typename _Res> struct __future_base::_Result<_Res&> : __future_base::_Result_base { typedef _Res& result_type; _Result() noexcept : _M_value_ptr() { } void _M_set(_Res& __res) noexcept { _M_value_ptr = std::addressof(__res); } _Res& _M_get() noexcept { return *_M_value_ptr; } private: _Res* _M_value_ptr; void _M_destroy() { delete this; } }; /// Explicit specialization for void. template<> struct __future_base::_Result<void> : __future_base::_Result_base { typedef void result_type; private: void _M_destroy() { delete this; } }; #ifndef _GLIBCXX_ASYNC_ABI_COMPAT // Allow _Setter objects to be stored locally in std::function template<typename _Res, typename _Arg> struct __is_location_invariant <__future_base::_State_base::_Setter<_Res, _Arg>> : true_type { }; // Allow _Task_setter objects to be stored locally in std::function template<typename _Res_ptr, typename _Fn, typename _Res> struct __is_location_invariant <__future_base::_Task_setter<_Res_ptr, _Fn, _Res>> : true_type { }; /// Common implementation for future and shared_future. template<typename _Res> class __basic_future : public __future_base { protected: typedef shared_ptr<_State_base> __state_type; typedef __future_base::_Result<_Res>& __result_type; private: __state_type _M_state; public: // Disable copying. __basic_future(const __basic_future&) = delete; __basic_future& operator=(const __basic_future&) = delete; bool valid() const noexcept { return static_cast<bool>(_M_state); } void wait() const { _State_base::_S_check(_M_state); _M_state->wait(); } template<typename _Rep, typename _Period> future_status wait_for(const chrono::duration<_Rep, _Period>& __rel) const { _State_base::_S_check(_M_state); return _M_state->wait_for(__rel); } template<typename _Clock, typename _Duration> future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs) const { _State_base::_S_check(_M_state); return _M_state->wait_until(__abs); } protected: /// Wait for the state to be ready and rethrow any stored exception __result_type _M_get_result() const { _State_base::_S_check(_M_state); _Result_base& __res = _M_state->wait(); if (!(__res._M_error == nullptr)) rethrow_exception(__res._M_error); return static_cast<__result_type>(__res); } void _M_swap(__basic_future& __that) noexcept { _M_state.swap(__that._M_state); } // Construction of a future by promise::get_future() explicit __basic_future(const __state_type& __state) : _M_state(__state) { _State_base::_S_check(_M_state); _M_state->_M_set_retrieved_flag(); } // Copy construction from a shared_future explicit __basic_future(const shared_future<_Res>&) noexcept; // Move construction from a shared_future explicit __basic_future(shared_future<_Res>&&) noexcept; // Move construction from a future explicit __basic_future(future<_Res>&&) noexcept; constexpr __basic_future() noexcept : _M_state() { } struct _Reset { explicit _Reset(__basic_future& __fut) noexcept : _M_fut(__fut) { } ~_Reset() { _M_fut._M_state.reset(); } __basic_future& _M_fut; }; }; /// Primary template for future. template<typename _Res> class future : public __basic_future<_Res> { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3458. Is shared_future intended to work with arrays or function types? static_assert(!is_array<_Res>{}, "result type must not be an array"); static_assert(!is_function<_Res>{}, "result type must not be a function"); static_assert(is_destructible<_Res>{}, "result type must be destructible"); friend class promise<_Res>; template<typename> friend class packaged_task; template<typename _Fn, typename... _Args> friend future<__async_result_of<_Fn, _Args...>> async(launch, _Fn&&, _Args&&...); typedef __basic_future<_Res> _Base_type; typedef typename _Base_type::__state_type __state_type; explicit future(const __state_type& __state) : _Base_type(__state) { } public: constexpr future() noexcept : _Base_type() { } /// Move constructor future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { } // Disable copying future(const future&) = delete; future& operator=(const future&) = delete; future& operator=(future&& __fut) noexcept { future(std::move(__fut))._M_swap(*this); return *this; } /// Retrieving the value _Res get() { typename _Base_type::_Reset __reset(*this); return std::move(this->_M_get_result()._M_value()); } shared_future<_Res> share() noexcept; }; /// Partial specialization for future<R&> template<typename _Res> class future<_Res&> : public __basic_future<_Res&> { friend class promise<_Res&>; template<typename> friend class packaged_task; template<typename _Fn, typename... _Args> friend future<__async_result_of<_Fn, _Args...>> async(launch, _Fn&&, _Args&&...); typedef __basic_future<_Res&> _Base_type; typedef typename _Base_type::__state_type __state_type; explicit future(const __state_type& __state) : _Base_type(__state) { } public: constexpr future() noexcept : _Base_type() { } /// Move constructor future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { } // Disable copying future(const future&) = delete; future& operator=(const future&) = delete; future& operator=(future&& __fut) noexcept { future(std::move(__fut))._M_swap(*this); return *this; } /// Retrieving the value _Res& get() { typename _Base_type::_Reset __reset(*this); return this->_M_get_result()._M_get(); } shared_future<_Res&> share() noexcept; }; /// Explicit specialization for future<void> template<> class future<void> : public __basic_future<void> { friend class promise<void>; template<typename> friend class packaged_task; template<typename _Fn, typename... _Args> friend future<__async_result_of<_Fn, _Args...>> async(launch, _Fn&&, _Args&&...); typedef __basic_future<void> _Base_type; typedef typename _Base_type::__state_type __state_type; explicit future(const __state_type& __state) : _Base_type(__state) { } public: constexpr future() noexcept : _Base_type() { } /// Move constructor future(future&& __uf) noexcept : _Base_type(std::move(__uf)) { } // Disable copying future(const future&) = delete; future& operator=(const future&) = delete; future& operator=(future&& __fut) noexcept { future(std::move(__fut))._M_swap(*this); return *this; } /// Retrieving the value void get() { typename _Base_type::_Reset __reset(*this); this->_M_get_result(); } shared_future<void> share() noexcept; }; /// Primary template for shared_future. template<typename _Res> class shared_future : public __basic_future<_Res> { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3458. Is shared_future intended to work with arrays or function types? static_assert(!is_array<_Res>{}, "result type must not be an array"); static_assert(!is_function<_Res>{}, "result type must not be a function"); static_assert(is_destructible<_Res>{}, "result type must be destructible"); typedef __basic_future<_Res> _Base_type; public: constexpr shared_future() noexcept : _Base_type() { } /// Copy constructor shared_future(const shared_future& __sf) noexcept : _Base_type(__sf) { } /// Construct from a future rvalue shared_future(future<_Res>&& __uf) noexcept : _Base_type(std::move(__uf)) { } /// Construct from a shared_future rvalue shared_future(shared_future&& __sf) noexcept : _Base_type(std::move(__sf)) { } shared_future& operator=(const shared_future& __sf) noexcept { shared_future(__sf)._M_swap(*this); return *this; } shared_future& operator=(shared_future&& __sf) noexcept { shared_future(std::move(__sf))._M_swap(*this); return *this; } /// Retrieving the value const _Res& get() const { return this->_M_get_result()._M_value(); } }; /// Partial specialization for shared_future<R&> template<typename _Res> class shared_future<_Res&> : public __basic_future<_Res&> { typedef __basic_future<_Res&> _Base_type; public: constexpr shared_future() noexcept : _Base_type() { } /// Copy constructor shared_future(const shared_future& __sf) : _Base_type(__sf) { } /// Construct from a future rvalue shared_future(future<_Res&>&& __uf) noexcept : _Base_type(std::move(__uf)) { } /// Construct from a shared_future rvalue shared_future(shared_future&& __sf) noexcept : _Base_type(std::move(__sf)) { } shared_future& operator=(const shared_future& __sf) { shared_future(__sf)._M_swap(*this); return *this; } shared_future& operator=(shared_future&& __sf) noexcept { shared_future(std::move(__sf))._M_swap(*this); return *this; } /// Retrieving the value _Res& get() const { return this->_M_get_result()._M_get(); } }; /// Explicit specialization for shared_future<void> template<> class shared_future<void> : public __basic_future<void> { typedef __basic_future<void> _Base_type; public: constexpr shared_future() noexcept : _Base_type() { } /// Copy constructor shared_future(const shared_future& __sf) : _Base_type(__sf) { } /// Construct from a future rvalue shared_future(future<void>&& __uf) noexcept : _Base_type(std::move(__uf)) { } /// Construct from a shared_future rvalue shared_future(shared_future&& __sf) noexcept : _Base_type(std::move(__sf)) { } shared_future& operator=(const shared_future& __sf) { shared_future(__sf)._M_swap(*this); return *this; } shared_future& operator=(shared_future&& __sf) noexcept { shared_future(std::move(__sf))._M_swap(*this); return *this; } // Retrieving the value void get() const { this->_M_get_result(); } }; // Now we can define the protected __basic_future constructors. template<typename _Res> inline __basic_future<_Res>:: __basic_future(const shared_future<_Res>& __sf) noexcept : _M_state(__sf._M_state) { } template<typename _Res> inline __basic_future<_Res>:: __basic_future(shared_future<_Res>&& __sf) noexcept : _M_state(std::move(__sf._M_state)) { } template<typename _Res> inline __basic_future<_Res>:: __basic_future(future<_Res>&& __uf) noexcept : _M_state(std::move(__uf._M_state)) { } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2556. Wide contract for future::share() template<typename _Res> inline shared_future<_Res> future<_Res>::share() noexcept { return shared_future<_Res>(std::move(*this)); } template<typename _Res> inline shared_future<_Res&> future<_Res&>::share() noexcept { return shared_future<_Res&>(std::move(*this)); } inline shared_future<void> future<void>::share() noexcept { return shared_future<void>(std::move(*this)); } /// Primary template for promise template<typename _Res> class promise { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3466: Specify the requirements for promise/future/[...] consistently static_assert(!is_array<_Res>{}, "result type must not be an array"); static_assert(!is_function<_Res>{}, "result type must not be a function"); static_assert(is_destructible<_Res>{}, "result type must be destructible"); typedef __future_base::_State_base _State; typedef __future_base::_Result<_Res> _Res_type; typedef __future_base::_Ptr<_Res_type> _Ptr_type; template<typename, typename> friend struct _State::_Setter; friend _State; shared_ptr<_State> _M_future; _Ptr_type _M_storage; public: promise() : _M_future(std::make_shared<_State>()), _M_storage(new _Res_type()) { } promise(promise&& __rhs) noexcept : _M_future(std::move(__rhs._M_future)), _M_storage(std::move(__rhs._M_storage)) { } template<typename _Allocator> promise(allocator_arg_t, const _Allocator& __a) : _M_future(std::allocate_shared<_State>(__a)), _M_storage(__future_base::_S_allocate_result<_Res>(__a)) { } template<typename _Allocator> promise(allocator_arg_t, const _Allocator&, promise&& __rhs) : _M_future(std::move(__rhs._M_future)), _M_storage(std::move(__rhs._M_storage)) { } promise(const promise&) = delete; ~promise() { if (static_cast<bool>(_M_future) && !_M_future.unique()) _M_future->_M_break_promise(std::move(_M_storage)); } // Assignment promise& operator=(promise&& __rhs) noexcept { promise(std::move(__rhs)).swap(*this); return *this; } promise& operator=(const promise&) = delete; void swap(promise& __rhs) noexcept { _M_future.swap(__rhs._M_future); _M_storage.swap(__rhs._M_storage); } // Retrieving the result future<_Res> get_future() { return future<_Res>(_M_future); } // Setting the result void set_value(const _Res& __r) { _M_state()._M_set_result(_State::__setter(this, __r)); } void set_value(_Res&& __r) { _M_state()._M_set_result(_State::__setter(this, std::move(__r))); } void set_exception(exception_ptr __p) { _M_state()._M_set_result(_State::__setter(__p, this)); } void set_value_at_thread_exit(const _Res& __r) { _M_state()._M_set_delayed_result(_State::__setter(this, __r), _M_future); } void set_value_at_thread_exit(_Res&& __r) { _M_state()._M_set_delayed_result( _State::__setter(this, std::move(__r)), _M_future); } void set_exception_at_thread_exit(exception_ptr __p) { _M_state()._M_set_delayed_result(_State::__setter(__p, this), _M_future); } private: _State& _M_state() { __future_base::_State_base::_S_check(_M_future); return *_M_future; } }; template<typename _Res> inline void swap(promise<_Res>& __x, promise<_Res>& __y) noexcept { __x.swap(__y); } template<typename _Res, typename _Alloc> struct uses_allocator<promise<_Res>, _Alloc> : public true_type { }; /// Partial specialization for promise<R&> template<typename _Res> class promise<_Res&> { typedef __future_base::_State_base _State; typedef __future_base::_Result<_Res&> _Res_type; typedef __future_base::_Ptr<_Res_type> _Ptr_type; template<typename, typename> friend struct _State::_Setter; friend _State; shared_ptr<_State> _M_future; _Ptr_type _M_storage; public: promise() : _M_future(std::make_shared<_State>()), _M_storage(new _Res_type()) { } promise(promise&& __rhs) noexcept : _M_future(std::move(__rhs._M_future)), _M_storage(std::move(__rhs._M_storage)) { } template<typename _Allocator> promise(allocator_arg_t, const _Allocator& __a) : _M_future(std::allocate_shared<_State>(__a)), _M_storage(__future_base::_S_allocate_result<_Res&>(__a)) { } template<typename _Allocator> promise(allocator_arg_t, const _Allocator&, promise&& __rhs) : _M_future(std::move(__rhs._M_future)), _M_storage(std::move(__rhs._M_storage)) { } promise(const promise&) = delete; ~promise() { if (static_cast<bool>(_M_future) && !_M_future.unique()) _M_future->_M_break_promise(std::move(_M_storage)); } // Assignment promise& operator=(promise&& __rhs) noexcept { promise(std::move(__rhs)).swap(*this); return *this; } promise& operator=(const promise&) = delete; void swap(promise& __rhs) noexcept { _M_future.swap(__rhs._M_future); _M_storage.swap(__rhs._M_storage); } // Retrieving the result future<_Res&> get_future() { return future<_Res&>(_M_future); } // Setting the result void set_value(_Res& __r) { _M_state()._M_set_result(_State::__setter(this, __r)); } void set_exception(exception_ptr __p) { _M_state()._M_set_result(_State::__setter(__p, this)); } void set_value_at_thread_exit(_Res& __r) { _M_state()._M_set_delayed_result(_State::__setter(this, __r), _M_future); } void set_exception_at_thread_exit(exception_ptr __p) { _M_state()._M_set_delayed_result(_State::__setter(__p, this), _M_future); } private: _State& _M_state() { __future_base::_State_base::_S_check(_M_future); return *_M_future; } }; /// Explicit specialization for promise<void> template<> class promise<void> { typedef __future_base::_State_base _State; typedef __future_base::_Result<void> _Res_type; typedef __future_base::_Ptr<_Res_type> _Ptr_type; template<typename, typename> friend struct _State::_Setter; friend _State; shared_ptr<_State> _M_future; _Ptr_type _M_storage; public: promise() : _M_future(std::make_shared<_State>()), _M_storage(new _Res_type()) { } promise(promise&& __rhs) noexcept : _M_future(std::move(__rhs._M_future)), _M_storage(std::move(__rhs._M_storage)) { } template<typename _Allocator> promise(allocator_arg_t, const _Allocator& __a) : _M_future(std::allocate_shared<_State>(__a)), _M_storage(__future_base::_S_allocate_result<void>(__a)) { } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2095. missing constructors needed for uses-allocator construction template<typename _Allocator> promise(allocator_arg_t, const _Allocator&, promise&& __rhs) : _M_future(std::move(__rhs._M_future)), _M_storage(std::move(__rhs._M_storage)) { } promise(const promise&) = delete; ~promise() { if (static_cast<bool>(_M_future) && !_M_future.unique()) _M_future->_M_break_promise(std::move(_M_storage)); } // Assignment promise& operator=(promise&& __rhs) noexcept { promise(std::move(__rhs)).swap(*this); return *this; } promise& operator=(const promise&) = delete; void swap(promise& __rhs) noexcept { _M_future.swap(__rhs._M_future); _M_storage.swap(__rhs._M_storage); } // Retrieving the result future<void> get_future() { return future<void>(_M_future); } // Setting the result void set_value() { _M_state()._M_set_result(_State::__setter(this)); } void set_exception(exception_ptr __p) { _M_state()._M_set_result(_State::__setter(__p, this)); } void set_value_at_thread_exit() { _M_state()._M_set_delayed_result(_State::__setter(this), _M_future); } void set_exception_at_thread_exit(exception_ptr __p) { _M_state()._M_set_delayed_result(_State::__setter(__p, this), _M_future); } private: _State& _M_state() { __future_base::_State_base::_S_check(_M_future); return *_M_future; } }; template<typename _Ptr_type, typename _Fn, typename _Res> struct __future_base::_Task_setter { // Invoke the function and provide the result to the caller. _Ptr_type operator()() const { __try { (*_M_result)->_M_set((*_M_fn)()); } __catch(const __cxxabiv1::__forced_unwind&) { __throw_exception_again; // will cause broken_promise } __catch(...) { (*_M_result)->_M_error = current_exception(); } return std::move(*_M_result); } _Ptr_type* _M_result; _Fn* _M_fn; }; template<typename _Ptr_type, typename _Fn> struct __future_base::_Task_setter<_Ptr_type, _Fn, void> { _Ptr_type operator()() const { __try { (*_M_fn)(); } __catch(const __cxxabiv1::__forced_unwind&) { __throw_exception_again; // will cause broken_promise } __catch(...) { (*_M_result)->_M_error = current_exception(); } return std::move(*_M_result); } _Ptr_type* _M_result; _Fn* _M_fn; }; // Holds storage for a packaged_task's result. template<typename _Res, typename... _Args> struct __future_base::_Task_state_base<_Res(_Args...)> : __future_base::_State_base { typedef _Res _Res_type; template<typename _Alloc> _Task_state_base(const _Alloc& __a) : _M_result(_S_allocate_result<_Res>(__a)) { } // Invoke the stored task and make the state ready. virtual void _M_run(_Args&&... __args) = 0; // Invoke the stored task and make the state ready at thread exit. virtual void _M_run_delayed(_Args&&... __args, weak_ptr<_State_base>) = 0; virtual shared_ptr<_Task_state_base> _M_reset() = 0; typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type; _Ptr_type _M_result; }; // Holds a packaged_task's stored task. template<typename _Fn, typename _Alloc, typename _Res, typename... _Args> struct __future_base::_Task_state<_Fn, _Alloc, _Res(_Args...)> final : __future_base::_Task_state_base<_Res(_Args...)> { template<typename _Fn2> _Task_state(_Fn2&& __fn, const _Alloc& __a) : _Task_state_base<_Res(_Args...)>(__a), _M_impl(std::forward<_Fn2>(__fn), __a) { } private: virtual void _M_run(_Args&&... __args) { auto __boundfn = [&] () -> _Res { return std::__invoke_r<_Res>(_M_impl._M_fn, std::forward<_Args>(__args)...); }; this->_M_set_result(_S_task_setter(this->_M_result, __boundfn)); } virtual void _M_run_delayed(_Args&&... __args, weak_ptr<_State_base> __self) { auto __boundfn = [&] () -> _Res { return std::__invoke_r<_Res>(_M_impl._M_fn, std::forward<_Args>(__args)...); }; this->_M_set_delayed_result(_S_task_setter(this->_M_result, __boundfn), std::move(__self)); } virtual shared_ptr<_Task_state_base<_Res(_Args...)>> _M_reset(); struct _Impl : _Alloc { template<typename _Fn2> _Impl(_Fn2&& __fn, const _Alloc& __a) : _Alloc(__a), _M_fn(std::forward<_Fn2>(__fn)) { } _Fn _M_fn; } _M_impl; }; template<typename _Signature, typename _Fn, typename _Alloc = std::allocator<int>> static shared_ptr<__future_base::_Task_state_base<_Signature>> __create_task_state(_Fn&& __fn, const _Alloc& __a = _Alloc()) { typedef typename decay<_Fn>::type _Fn2; typedef __future_base::_Task_state<_Fn2, _Alloc, _Signature> _State; return std::allocate_shared<_State>(__a, std::forward<_Fn>(__fn), __a); } template<typename _Fn, typename _Alloc, typename _Res, typename... _Args> shared_ptr<__future_base::_Task_state_base<_Res(_Args...)>> __future_base::_Task_state<_Fn, _Alloc, _Res(_Args...)>::_M_reset() { return __create_task_state<_Res(_Args...)>(std::move(_M_impl._M_fn), static_cast<_Alloc&>(_M_impl)); } /// packaged_task template<typename _Res, typename... _ArgTypes> class packaged_task<_Res(_ArgTypes...)> { typedef __future_base::_Task_state_base<_Res(_ArgTypes...)> _State_type; shared_ptr<_State_type> _M_state; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3039. Unnecessary decay in thread and packaged_task template<typename _Fn, typename _Fn2 = __remove_cvref_t<_Fn>> using __not_same = typename enable_if<!is_same<packaged_task, _Fn2>::value>::type; public: // Construction and destruction packaged_task() noexcept { } template<typename _Fn, typename = __not_same<_Fn>> explicit packaged_task(_Fn&& __fn) : _M_state( __create_task_state<_Res(_ArgTypes...)>(std::forward<_Fn>(__fn))) { } #if __cplusplus < 201703L // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2097. packaged_task constructors should be constrained // 2407. [this constructor should not be] explicit // 2921. packaged_task and type-erased allocators template<typename _Fn, typename _Alloc, typename = __not_same<_Fn>> packaged_task(allocator_arg_t, const _Alloc& __a, _Fn&& __fn) : _M_state(__create_task_state<_Res(_ArgTypes...)>( std::forward<_Fn>(__fn), __a)) { } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2095. missing constructors needed for uses-allocator construction template<typename _Allocator> packaged_task(allocator_arg_t, const _Allocator& __a) noexcept { } template<typename _Allocator> packaged_task(allocator_arg_t, const _Allocator&, const packaged_task&) = delete; template<typename _Allocator> packaged_task(allocator_arg_t, const _Allocator&, packaged_task&& __other) noexcept { this->swap(__other); } #endif ~packaged_task() { if (static_cast<bool>(_M_state) && !_M_state.unique()) _M_state->_M_break_promise(std::move(_M_state->_M_result)); } // No copy packaged_task(const packaged_task&) = delete; packaged_task& operator=(const packaged_task&) = delete; // Move support packaged_task(packaged_task&& __other) noexcept { this->swap(__other); } packaged_task& operator=(packaged_task&& __other) noexcept { packaged_task(std::move(__other)).swap(*this); return *this; } void swap(packaged_task& __other) noexcept { _M_state.swap(__other._M_state); } bool valid() const noexcept { return static_cast<bool>(_M_state); } // Result retrieval future<_Res> get_future() { return future<_Res>(_M_state); } // Execution void operator()(_ArgTypes... __args) { __future_base::_State_base::_S_check(_M_state); _M_state->_M_run(std::forward<_ArgTypes>(__args)...); } void make_ready_at_thread_exit(_ArgTypes... __args) { __future_base::_State_base::_S_check(_M_state); _M_state->_M_run_delayed(std::forward<_ArgTypes>(__args)..., _M_state); } void reset() { __future_base::_State_base::_S_check(_M_state); packaged_task __tmp; __tmp._M_state = _M_state; _M_state = _M_state->_M_reset(); } }; // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3117. Missing packaged_task deduction guides #if __cpp_deduction_guides >= 201606 template<typename _Res, typename... _ArgTypes> packaged_task(_Res(*)(_ArgTypes...)) -> packaged_task<_Res(_ArgTypes...)>; template<typename _Fun, typename _Signature = typename __function_guide_helper<decltype(&_Fun::operator())>::type> packaged_task(_Fun) -> packaged_task<_Signature>; #endif /// swap template<typename _Res, typename... _ArgTypes> inline void swap(packaged_task<_Res(_ArgTypes...)>& __x, packaged_task<_Res(_ArgTypes...)>& __y) noexcept { __x.swap(__y); } #if __cplusplus < 201703L // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2976. Dangling uses_allocator specialization for packaged_task template<typename _Res, typename _Alloc> struct uses_allocator<packaged_task<_Res>, _Alloc> : public true_type { }; #endif // Shared state created by std::async(). // Holds a deferred function and storage for its result. template<typename _BoundFn, typename _Res> class __future_base::_Deferred_state final : public __future_base::_State_base { public: template<typename... _Args> explicit _Deferred_state(_Args&&... __args) : _M_result(new _Result<_Res>()), _M_fn(std::forward<_Args>(__args)...) { } private: typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type; _Ptr_type _M_result; _BoundFn _M_fn; // Run the deferred function. virtual void _M_complete_async() { // Multiple threads can call a waiting function on the future and // reach this point at the same time. The call_once in _M_set_result // ensures only the first one run the deferred function, stores the // result in _M_result, swaps that with the base _M_result and makes // the state ready. Tell _M_set_result to ignore failure so all later // calls do nothing. _M_set_result(_S_task_setter(_M_result, _M_fn), true); } // Caller should check whether the state is ready first, because this // function will return true even after the deferred function has run. virtual bool _M_is_deferred_future() const { return true; } }; // Common functionality hoisted out of the _Async_state_impl template. class __future_base::_Async_state_commonV2 : public __future_base::_State_base { protected: ~_Async_state_commonV2() = default; // Make waiting functions block until the thread completes, as if joined. // // This function is used by wait() to satisfy the first requirement below // and by wait_for() / wait_until() to satisfy the second. // // [futures.async]: // // - a call to a waiting function on an asynchronous return object that // shares the shared state created by this async call shall block until // the associated thread has completed, as if joined, or else time out. // // - the associated thread completion synchronizes with the return from // the first function that successfully detects the ready status of the // shared state or with the return from the last function that releases // the shared state, whichever happens first. virtual void _M_complete_async() { _M_join(); } void _M_join() { std::call_once(_M_once, &thread::join, &_M_thread); } thread _M_thread; once_flag _M_once; }; // Shared state created by std::async(). // Starts a new thread that runs a function and makes the shared state ready. template<typename _BoundFn, typename _Res> class __future_base::_Async_state_impl final : public __future_base::_Async_state_commonV2 { public: template<typename... _Args> explicit _Async_state_impl(_Args&&... __args) : _M_result(new _Result<_Res>()), _M_fn(std::forward<_Args>(__args)...) { _M_thread = std::thread{&_Async_state_impl::_M_run, this}; } // Must not destroy _M_result and _M_fn until the thread finishes. // Call join() directly rather than through _M_join() because no other // thread can be referring to this state if it is being destroyed. ~_Async_state_impl() { if (_M_thread.joinable()) _M_thread.join(); } private: void _M_run() { __try { _M_set_result(_S_task_setter(_M_result, _M_fn)); } __catch (const __cxxabiv1::__forced_unwind&) { // make the shared state ready on thread cancellation if (static_cast<bool>(_M_result)) this->_M_break_promise(std::move(_M_result)); __throw_exception_again; } } typedef __future_base::_Ptr<_Result<_Res>> _Ptr_type; _Ptr_type _M_result; _BoundFn _M_fn; }; /// async template<typename _Fn, typename... _Args> _GLIBCXX_NODISCARD future<__async_result_of<_Fn, _Args...>> async(launch __policy, _Fn&& __fn, _Args&&... __args) { using _Wr = std::thread::_Call_wrapper<_Fn, _Args...>; using _As = __future_base::_Async_state_impl<_Wr>; using _Ds = __future_base::_Deferred_state<_Wr>; std::shared_ptr<__future_base::_State_base> __state; if ((__policy & launch::async) == launch::async) { __try { __state = std::make_shared<_As>(std::forward<_Fn>(__fn), std::forward<_Args>(__args)...); } #if __cpp_exceptions catch(const system_error& __e) { if (__e.code() != errc::resource_unavailable_try_again || (__policy & launch::deferred) != launch::deferred) throw; } #endif } if (!__state) { __state = std::make_shared<_Ds>(std::forward<_Fn>(__fn), std::forward<_Args>(__args)...); } return future<__async_result_of<_Fn, _Args...>>(std::move(__state)); } /// async, potential overload template<typename _Fn, typename... _Args> _GLIBCXX_NODISCARD inline future<__async_result_of<_Fn, _Args...>> async(_Fn&& __fn, _Args&&... __args) { return std::async(launch::async|launch::deferred, std::forward<_Fn>(__fn), std::forward<_Args>(__args)...); } #endif // _GLIBCXX_ASYNC_ABI_COMPAT #endif // _GLIBCXX_HAS_GTHREADS /// @} group futures _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // C++11 #endif // _GLIBCXX_FUTURE // <array> -*- C++ -*- // Copyright (C) 2007-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/array * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_ARRAY #define _GLIBCXX_ARRAY 1 #pragma GCC system_header #if __cplusplus < 201103L # include <bits/c++0x_warning.h> #else #include <utility> #include <bits/functexcept.h> #include <bits/stl_algobase.h> #include <bits/range_access.h> #include <debug/assertions.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp, std::size_t _Nm> struct __array_traits { typedef _Tp _Type[_Nm]; typedef __is_swappable<_Tp> _Is_swappable; typedef __is_nothrow_swappable<_Tp> _Is_nothrow_swappable; static constexpr _Tp& _S_ref(const _Type& __t, std::size_t __n) noexcept { return const_cast<_Tp&>(__t[__n]); } static constexpr _Tp* _S_ptr(const _Type& __t) noexcept { return const_cast<_Tp*>(__t); } }; template<typename _Tp> struct __array_traits<_Tp, 0> { struct _Type { }; typedef true_type _Is_swappable; typedef true_type _Is_nothrow_swappable; static constexpr _Tp& _S_ref(const _Type&, std::size_t) noexcept { return *static_cast<_Tp*>(nullptr); } static constexpr _Tp* _S_ptr(const _Type&) noexcept { return nullptr; } }; /** * @brief A standard container for storing a fixed size sequence of elements. * * @ingroup sequences * * Meets the requirements of a <a href="tables.html#65">container</a>, a * <a href="tables.html#66">reversible container</a>, and a * <a href="tables.html#67">sequence</a>. * * Sets support random access iterators. * * @tparam Tp Type of element. Required to be a complete type. * @tparam Nm Number of elements. */ template<typename _Tp, std::size_t _Nm> struct array { typedef _Tp value_type; typedef value_type* pointer; typedef const value_type* const_pointer; typedef value_type& reference; typedef const value_type& const_reference; typedef value_type* iterator; typedef const value_type* const_iterator; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; // Support for zero-sized arrays mandatory. typedef __array_traits<_Tp, _Nm> _AT_Type; typename _AT_Type::_Type _M_elems; // No explicit construct/copy/destroy for aggregate type. // DR 776. _GLIBCXX20_CONSTEXPR void fill(const value_type& __u) { std::fill_n(begin(), size(), __u); } _GLIBCXX20_CONSTEXPR void swap(array& __other) noexcept(_AT_Type::_Is_nothrow_swappable::value) { std::swap_ranges(begin(), end(), __other.begin()); } // Iterators. _GLIBCXX17_CONSTEXPR iterator begin() noexcept { return iterator(data()); } _GLIBCXX17_CONSTEXPR const_iterator begin() const noexcept { return const_iterator(data()); } _GLIBCXX17_CONSTEXPR iterator end() noexcept { return iterator(data() + _Nm); } _GLIBCXX17_CONSTEXPR const_iterator end() const noexcept { return const_iterator(data() + _Nm); } _GLIBCXX17_CONSTEXPR reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } _GLIBCXX17_CONSTEXPR const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } _GLIBCXX17_CONSTEXPR reverse_iterator rend() noexcept { return reverse_iterator(begin()); } _GLIBCXX17_CONSTEXPR const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } _GLIBCXX17_CONSTEXPR const_iterator cbegin() const noexcept { return const_iterator(data()); } _GLIBCXX17_CONSTEXPR const_iterator cend() const noexcept { return const_iterator(data() + _Nm); } _GLIBCXX17_CONSTEXPR const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } _GLIBCXX17_CONSTEXPR const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } // Capacity. constexpr size_type size() const noexcept { return _Nm; } constexpr size_type max_size() const noexcept { return _Nm; } _GLIBCXX_NODISCARD constexpr bool empty() const noexcept { return size() == 0; } // Element access. _GLIBCXX17_CONSTEXPR reference operator[](size_type __n) noexcept { __glibcxx_requires_subscript(__n); return _AT_Type::_S_ref(_M_elems, __n); } constexpr const_reference operator[](size_type __n) const noexcept { #if __cplusplus >= 201402L __glibcxx_requires_subscript(__n); #endif return _AT_Type::_S_ref(_M_elems, __n); } _GLIBCXX17_CONSTEXPR reference at(size_type __n) { if (__n >= _Nm) std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) " ">= _Nm (which is %zu)"), __n, _Nm); return _AT_Type::_S_ref(_M_elems, __n); } constexpr const_reference at(size_type __n) const { // Result of conditional expression must be an lvalue so use // boolean ? lvalue : (throw-expr, lvalue) return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n) : (std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) " ">= _Nm (which is %zu)"), __n, _Nm), _AT_Type::_S_ref(_M_elems, 0)); } _GLIBCXX17_CONSTEXPR reference front() noexcept { __glibcxx_requires_nonempty(); return *begin(); } constexpr const_reference front() const noexcept { #if __cplusplus >= 201402L __glibcxx_requires_nonempty(); #endif return _AT_Type::_S_ref(_M_elems, 0); } _GLIBCXX17_CONSTEXPR reference back() noexcept { __glibcxx_requires_nonempty(); return _Nm ? *(end() - 1) : *end(); } constexpr const_reference back() const noexcept { #if __cplusplus >= 201402L __glibcxx_requires_nonempty(); #endif return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1) : _AT_Type::_S_ref(_M_elems, 0); } _GLIBCXX17_CONSTEXPR pointer data() noexcept { return _AT_Type::_S_ptr(_M_elems); } _GLIBCXX17_CONSTEXPR const_pointer data() const noexcept { return _AT_Type::_S_ptr(_M_elems); } }; #if __cpp_deduction_guides >= 201606 template<typename _Tp, typename... _Up> array(_Tp, _Up...) -> array<enable_if_t<(is_same_v<_Tp, _Up> && ...), _Tp>, 1 + sizeof...(_Up)>; #endif // Array comparisons. template<typename _Tp, std::size_t _Nm> _GLIBCXX20_CONSTEXPR inline bool operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return std::equal(__one.begin(), __one.end(), __two.begin()); } #if __cpp_lib_three_way_comparison && __cpp_lib_concepts template<typename _Tp, size_t _Nm> constexpr __detail::__synth3way_t<_Tp> operator<=>(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) { #ifdef __cpp_lib_is_constant_evaluated if constexpr (_Nm && __is_memcmp_ordered<_Tp>::__value) if (!std::is_constant_evaluated()) { constexpr size_t __n = _Nm * sizeof(_Tp); return __builtin_memcmp(__a.data(), __b.data(), __n) <=> 0; } #endif for (size_t __i = 0; __i < _Nm; ++__i) { auto __c = __detail::__synth3way(__a[__i], __b[__i]); if (__c != 0) return __c; } return strong_ordering::equal; } #else template<typename _Tp, std::size_t _Nm> _GLIBCXX20_CONSTEXPR inline bool operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one == __two); } template<typename _Tp, std::size_t _Nm> _GLIBCXX20_CONSTEXPR inline bool operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) { return std::lexicographical_compare(__a.begin(), __a.end(), __b.begin(), __b.end()); } template<typename _Tp, std::size_t _Nm> _GLIBCXX20_CONSTEXPR inline bool operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return __two < __one; } template<typename _Tp, std::size_t _Nm> _GLIBCXX20_CONSTEXPR inline bool operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one > __two); } template<typename _Tp, std::size_t _Nm> _GLIBCXX20_CONSTEXPR inline bool operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two) { return !(__one < __two); } #endif // three_way_comparison && concepts // Specialized algorithms. template<typename _Tp, std::size_t _Nm> _GLIBCXX20_CONSTEXPR inline #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 // Constrained free swap overload, see p0185r1 typename enable_if< __array_traits<_Tp, _Nm>::_Is_swappable::value >::type #else void #endif swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two) noexcept(noexcept(__one.swap(__two))) { __one.swap(__two); } #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11 template<typename _Tp, std::size_t _Nm> typename enable_if< !__array_traits<_Tp, _Nm>::_Is_swappable::value>::type swap(array<_Tp, _Nm>&, array<_Tp, _Nm>&) = delete; #endif template<std::size_t _Int, typename _Tp, std::size_t _Nm> constexpr _Tp& get(array<_Tp, _Nm>& __arr) noexcept { static_assert(_Int < _Nm, "array index is within bounds"); return __array_traits<_Tp, _Nm>::_S_ref(__arr._M_elems, _Int); } template<std::size_t _Int, typename _Tp, std::size_t _Nm> constexpr _Tp&& get(array<_Tp, _Nm>&& __arr) noexcept { static_assert(_Int < _Nm, "array index is within bounds"); return std::move(std::get<_Int>(__arr)); } template<std::size_t _Int, typename _Tp, std::size_t _Nm> constexpr const _Tp& get(const array<_Tp, _Nm>& __arr) noexcept { static_assert(_Int < _Nm, "array index is within bounds"); return __array_traits<_Tp, _Nm>::_S_ref(__arr._M_elems, _Int); } template<std::size_t _Int, typename _Tp, std::size_t _Nm> constexpr const _Tp&& get(const array<_Tp, _Nm>&& __arr) noexcept { static_assert(_Int < _Nm, "array index is within bounds"); return std::move(std::get<_Int>(__arr)); } #if __cplusplus > 201703L #define __cpp_lib_to_array 201907L template<bool _Move = false, typename _Tp, size_t... _Idx> constexpr array<remove_cv_t<_Tp>, sizeof...(_Idx)> __to_array(_Tp (&__a)[sizeof...(_Idx)], index_sequence<_Idx...>) { if constexpr (_Move) return {{std::move(__a[_Idx])...}}; else return {{__a[_Idx]...}}; } template<typename _Tp, size_t _Nm> constexpr array<remove_cv_t<_Tp>, _Nm> to_array(_Tp (&__a)[_Nm]) noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) { static_assert(!is_array_v<_Tp>); static_assert(is_constructible_v<_Tp, _Tp&>); if constexpr (is_constructible_v<_Tp, _Tp&>) return std::__to_array(__a, make_index_sequence<_Nm>{}); __builtin_unreachable(); // FIXME: see PR c++/91388 } template<typename _Tp, size_t _Nm> constexpr array<remove_cv_t<_Tp>, _Nm> to_array(_Tp (&&__a)[_Nm]) noexcept(is_nothrow_move_constructible_v<_Tp>) { static_assert(!is_array_v<_Tp>); static_assert(is_move_constructible_v<_Tp>); if constexpr (is_move_constructible_v<_Tp>) return std::__to_array<1>(__a, make_index_sequence<_Nm>{}); __builtin_unreachable(); // FIXME: see PR c++/91388 } #endif // C++20 // Tuple interface to class template array. /// tuple_size template<typename _Tp> struct tuple_size; /// Partial specialization for std::array template<typename _Tp, std::size_t _Nm> struct tuple_size<array<_Tp, _Nm>> : public integral_constant<std::size_t, _Nm> { }; /// tuple_element template<std::size_t _Int, typename _Tp> struct tuple_element; /// Partial specialization for std::array template<std::size_t _Int, typename _Tp, std::size_t _Nm> struct tuple_element<_Int, array<_Tp, _Nm>> { static_assert(_Int < _Nm, "index is out of bounds"); typedef _Tp type; }; template<typename _Tp, std::size_t _Nm> struct __is_tuple_like_impl<array<_Tp, _Nm>> : true_type { }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++11 #endif // _GLIBCXX_ARRAY // File based streams -*- C++ -*- // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/fstream * This is a Standard C++ Library header. */ // // ISO C++ 14882: 27.8 File-based streams // #ifndef _GLIBCXX_FSTREAM #define _GLIBCXX_FSTREAM 1 #pragma GCC system_header #include <istream> #include <ostream> #include <bits/codecvt.h> #include <cstdio> // For BUFSIZ #include <bits/basic_file.h> // For __basic_file, __c_lock #if __cplusplus >= 201103L #include <string> // For std::string overloads. #endif // This can be overridden by the target's os_defines.h #ifndef _GLIBCXX_BUFSIZ # define _GLIBCXX_BUFSIZ BUFSIZ #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201703L // Enable if _Path is a filesystem::path or experimental::filesystem::path template<typename _Path, typename _Result = _Path, typename _Path2 = decltype(std::declval<_Path&>().make_preferred().filename())> using _If_fs_path = enable_if_t<is_same_v<_Path, _Path2>, _Result>; #endif // C++17 // [27.8.1.1] template class basic_filebuf /** * @brief The actual work of input and output (for files). * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * * This class associates both its input and output sequence with an * external disk file, and maintains a joint file position for both * sequences. Many of its semantics are described in terms of similar * behavior in the Standard C Library's @c FILE streams. * * Requirements on traits_type, specific to this class: * - traits_type::pos_type must be fpos<traits_type::state_type> * - traits_type::off_type must be streamoff * - traits_type::state_type must be Assignable and DefaultConstructible, * - traits_type::state_type() must be the initial state for codecvt. */ template<typename _CharT, typename _Traits> class basic_filebuf : public basic_streambuf<_CharT, _Traits> { #if __cplusplus >= 201103L template<typename _Tp> using __chk_state = __and_<is_copy_assignable<_Tp>, is_copy_constructible<_Tp>, is_default_constructible<_Tp>>; static_assert(__chk_state<typename _Traits::state_type>::value, "state_type must be CopyAssignable, CopyConstructible" " and DefaultConstructible"); static_assert(is_same<typename _Traits::pos_type, fpos<typename _Traits::state_type>>::value, "pos_type must be fpos<state_type>"); #endif public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; typedef basic_streambuf<char_type, traits_type> __streambuf_type; typedef basic_filebuf<char_type, traits_type> __filebuf_type; typedef __basic_file<char> __file_type; typedef typename traits_type::state_type __state_type; typedef codecvt<char_type, char, __state_type> __codecvt_type; friend class ios_base; // For sync_with_stdio. protected: // Data Members: // MT lock inherited from libio or other low-level io library. __c_lock _M_lock; // External buffer. __file_type _M_file; /// Place to stash in || out || in | out settings for current filebuf. ios_base::openmode _M_mode; // Beginning state type for codecvt. __state_type _M_state_beg; // During output, the state that corresponds to pptr(), // during input, the state that corresponds to egptr() and // _M_ext_next. __state_type _M_state_cur; // Not used for output. During input, the state that corresponds // to eback() and _M_ext_buf. __state_type _M_state_last; /// Pointer to the beginning of internal buffer. char_type* _M_buf; /** * Actual size of internal buffer. This number is equal to the size * of the put area + 1 position, reserved for the overflow char of * a full area. */ size_t _M_buf_size; // Set iff _M_buf is allocated memory from _M_allocate_internal_buffer. bool _M_buf_allocated; /** * _M_reading == false && _M_writing == false for @b uncommitted mode; * _M_reading == true for @b read mode; * _M_writing == true for @b write mode; * * NB: _M_reading == true && _M_writing == true is unused. */ bool _M_reading; bool _M_writing; ///@{ /** * Necessary bits for putback buffer management. * * @note pbacks of over one character are not currently supported. */ char_type _M_pback; char_type* _M_pback_cur_save; char_type* _M_pback_end_save; bool _M_pback_init; ///@} // Cached codecvt facet. const __codecvt_type* _M_codecvt; /** * Buffer for external characters. Used for input when * codecvt::always_noconv() == false. When valid, this corresponds * to eback(). */ char* _M_ext_buf; /** * Size of buffer held by _M_ext_buf. */ streamsize _M_ext_buf_size; /** * Pointers into the buffer held by _M_ext_buf that delimit a * subsequence of bytes that have been read but not yet converted. * When valid, _M_ext_next corresponds to egptr(). */ const char* _M_ext_next; char* _M_ext_end; /** * Initializes pback buffers, and moves normal buffers to safety. * Assumptions: * _M_in_cur has already been moved back */ void _M_create_pback() { if (!_M_pback_init) { _M_pback_cur_save = this->gptr(); _M_pback_end_save = this->egptr(); this->setg(&_M_pback, &_M_pback, &_M_pback + 1); _M_pback_init = true; } } /** * Deactivates pback buffer contents, and restores normal buffer. * Assumptions: * The pback buffer has only moved forward. */ void _M_destroy_pback() throw() { if (_M_pback_init) { // Length _M_in_cur moved in the pback buffer. _M_pback_cur_save += this->gptr() != this->eback(); this->setg(_M_buf, _M_pback_cur_save, _M_pback_end_save); _M_pback_init = false; } } public: // Constructors/destructor: /** * @brief Does not open any files. * * The default constructor initializes the parent class using its * own default ctor. */ basic_filebuf(); #if __cplusplus >= 201103L basic_filebuf(const basic_filebuf&) = delete; basic_filebuf(basic_filebuf&&); #endif /** * @brief The destructor closes the file first. */ virtual ~basic_filebuf() { __try { this->close(); } __catch(...) { } } #if __cplusplus >= 201103L basic_filebuf& operator=(const basic_filebuf&) = delete; basic_filebuf& operator=(basic_filebuf&&); void swap(basic_filebuf&); #endif // Members: /** * @brief Returns true if the external file is open. */ bool is_open() const throw() { return _M_file.is_open(); } /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * @return @c this on success, NULL on failure * * If a file is already open, this function immediately fails. * Otherwise it tries to open the file named @a __s using the flags * given in @a __mode. * * Table 92, adapted here, gives the relation between openmode * combinations and the equivalent @c fopen() flags. * (NB: lines app, in|out|app, in|app, binary|app, binary|in|out|app, * and binary|in|app per DR 596) * <pre> * +---------------------------------------------------------+ * | ios_base Flag combination stdio equivalent | * |binary in out trunc app | * +---------------------------------------------------------+ * | + w | * | + + a | * | + a | * | + + w | * | + r | * | + + r+ | * | + + + w+ | * | + + + a+ | * | + + a+ | * +---------------------------------------------------------+ * | + + wb | * | + + + ab | * | + + ab | * | + + + wb | * | + + rb | * | + + + r+b | * | + + + + w+b | * | + + + + a+b | * | + + + a+b | * +---------------------------------------------------------+ * </pre> */ __filebuf_type* open(const char* __s, ios_base::openmode __mode); #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T /** * @brief Opens an external file. * @param __s The name of the file, as a wide character string. * @param __mode The open mode flags. * @return @c this on success, NULL on failure */ __filebuf_type* open(const wchar_t* __s, ios_base::openmode __mode); #endif #if __cplusplus >= 201103L /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * @return @c this on success, NULL on failure */ __filebuf_type* open(const std::string& __s, ios_base::openmode __mode) { return open(__s.c_str(), __mode); } #if __cplusplus >= 201703L /** * @brief Opens an external file. * @param __s The name of the file, as a filesystem::path. * @param __mode The open mode flags. * @return @c this on success, NULL on failure */ template<typename _Path> _If_fs_path<_Path, __filebuf_type*> open(const _Path& __s, ios_base::openmode __mode) { return open(__s.c_str(), __mode); } #endif // C++17 #endif // C++11 /** * @brief Closes the currently associated file. * @return @c this on success, NULL on failure * * If no file is currently open, this function immediately fails. * * If a <em>put buffer area</em> exists, @c overflow(eof) is * called to flush all the characters. The file is then * closed. * * If any operations fail, this function also fails. */ __filebuf_type* close(); protected: void _M_allocate_internal_buffer(); void _M_destroy_internal_buffer() throw(); // [27.8.1.4] overridden virtual functions virtual streamsize showmanyc(); // Stroustrup, 1998, p. 628 // underflow() and uflow() functions are called to get the next // character from the real input source when the buffer is empty. // Buffered input uses underflow() virtual int_type underflow(); virtual int_type pbackfail(int_type __c = _Traits::eof()); // Stroustrup, 1998, p 648 // The overflow() function is called to transfer characters to the // real output destination when the buffer is full. A call to // overflow(c) outputs the contents of the buffer plus the // character c. // 27.5.2.4.5 // Consume some sequence of the characters in the pending sequence. virtual int_type overflow(int_type __c = _Traits::eof()); // Convert internal byte sequence to external, char-based // sequence via codecvt. bool _M_convert_to_external(char_type*, streamsize); /** * @brief Manipulates the buffer. * @param __s Pointer to a buffer area. * @param __n Size of @a __s. * @return @c this * * If no file has been opened, and both @a __s and @a __n are zero, then * the stream becomes unbuffered. Otherwise, @c __s is used as a * buffer; see * https://gcc.gnu.org/onlinedocs/libstdc++/manual/streambufs.html#io.streambuf.buffering * for more. */ virtual __streambuf_type* setbuf(char_type* __s, streamsize __n); virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode = ios_base::in | ios_base::out); virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode = ios_base::in | ios_base::out); // Common code for seekoff, seekpos, and overflow pos_type _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state); int _M_get_ext_pos(__state_type &__state); virtual int sync(); virtual void imbue(const locale& __loc); virtual streamsize xsgetn(char_type* __s, streamsize __n); virtual streamsize xsputn(const char_type* __s, streamsize __n); // Flushes output buffer, then writes unshift sequence. bool _M_terminate_output(); /** * This function sets the pointers of the internal buffer, both get * and put areas. Typically: * * __off == egptr() - eback() upon underflow/uflow (@b read mode); * __off == 0 upon overflow (@b write mode); * __off == -1 upon open, setbuf, seekoff/pos (@b uncommitted mode). * * NB: epptr() - pbase() == _M_buf_size - 1, since _M_buf_size * reflects the actual allocated memory and the last cell is reserved * for the overflow char of a full put area. */ void _M_set_buffer(streamsize __off) { const bool __testin = _M_mode & ios_base::in; const bool __testout = (_M_mode & ios_base::out || _M_mode & ios_base::app); if (__testin && __off > 0) this->setg(_M_buf, _M_buf, _M_buf + __off); else this->setg(_M_buf, _M_buf, _M_buf); if (__testout && __off == 0 && _M_buf_size > 1 ) this->setp(_M_buf, _M_buf + _M_buf_size - 1); else this->setp(0, 0); } }; // [27.8.1.5] Template class basic_ifstream /** * @brief Controlling input for files. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * * This class supports reading from named files, using the inherited * functions from std::basic_istream. To control the associated * sequence, an instance of std::basic_filebuf is used, which this page * refers to as @c sb. */ template<typename _CharT, typename _Traits> class basic_ifstream : public basic_istream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard types: typedef basic_filebuf<char_type, traits_type> __filebuf_type; typedef basic_istream<char_type, traits_type> __istream_type; private: __filebuf_type _M_filebuf; public: // Constructors/Destructors: /** * @brief Default constructor. * * Initializes @c sb using its default constructor, and passes * @c &sb to the base class initializer. Does not open any files * (you haven't given it a filename to open). */ basic_ifstream() : __istream_type(), _M_filebuf() { this->init(&_M_filebuf); } /** * @brief Create an input file stream. * @param __s Null terminated string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * @c ios_base::in is automatically included in @a __mode. */ explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in) : __istream_type(), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T /** * @param Create an input file stream. * @param __s Wide string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * @c ios_base::in is automatically included in @a __mode. */ basic_ifstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in) : __istream_type(), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #endif #if __cplusplus >= 201103L /** * @brief Create an input file stream. * @param __s std::string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * @c ios_base::in is automatically included in @a __mode. */ explicit basic_ifstream(const std::string& __s, ios_base::openmode __mode = ios_base::in) : __istream_type(), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #if __cplusplus >= 201703L /** * @brief Create an input file stream. * @param __s filesystem::path specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * @c ios_base::in is automatically included in @a __mode. */ template<typename _Path, typename _Require = _If_fs_path<_Path>> basic_ifstream(const _Path& __s, ios_base::openmode __mode = ios_base::in) : basic_ifstream(__s.c_str(), __mode) { } #endif // C++17 basic_ifstream(const basic_ifstream&) = delete; basic_ifstream(basic_ifstream&& __rhs) : __istream_type(std::move(__rhs)), _M_filebuf(std::move(__rhs._M_filebuf)) { __istream_type::set_rdbuf(&_M_filebuf); } #endif // C++11 /** * @brief The destructor does nothing. * * The file is closed by the filebuf object, not the formatting * stream. */ ~basic_ifstream() { } #if __cplusplus >= 201103L // 27.8.3.2 Assign and swap: basic_ifstream& operator=(const basic_ifstream&) = delete; basic_ifstream& operator=(basic_ifstream&& __rhs) { __istream_type::operator=(std::move(__rhs)); _M_filebuf = std::move(__rhs._M_filebuf); return *this; } void swap(basic_ifstream& __rhs) { __istream_type::swap(__rhs); _M_filebuf.swap(__rhs._M_filebuf); } #endif // Members: /** * @brief Accessing the underlying buffer. * @return The current basic_filebuf buffer. * * This hides both signatures of std::basic_ios::rdbuf(). */ __filebuf_type* rdbuf() const { return const_cast<__filebuf_type*>(&_M_filebuf); } /** * @brief Wrapper to test for an open file. * @return @c rdbuf()->is_open() */ bool is_open() { return _M_filebuf.is_open(); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 365. Lack of const-qualification in clause 27 bool is_open() const { return _M_filebuf.is_open(); } /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(s,__mode|in). If that function * fails, @c failbit is set in the stream's error state. */ void open(const char* __s, ios_base::openmode __mode = ios_base::in) { if (!_M_filebuf.open(__s, __mode | ios_base::in)) this->setstate(ios_base::failbit); else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 409. Closing an fstream should clear error state this->clear(); } #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T /** * @brief Opens an external file. * @param __s The name of the file, as a wide character string. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode|in). If that function * fails, @c failbit is set in the stream's error state. */ void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in) { if (!_M_filebuf.open(__s, __mode | ios_base::in)) this->setstate(ios_base::failbit); else this->clear(); } #endif #if __cplusplus >= 201103L /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode|in). If that function * fails, @c failbit is set in the stream's error state. */ void open(const std::string& __s, ios_base::openmode __mode = ios_base::in) { if (!_M_filebuf.open(__s, __mode | ios_base::in)) this->setstate(ios_base::failbit); else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 409. Closing an fstream should clear error state this->clear(); } #if __cplusplus >= 201703L /** * @brief Opens an external file. * @param __s The name of the file, as a filesystem::path. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode|in). If that function * fails, @c failbit is set in the stream's error state. */ template<typename _Path> _If_fs_path<_Path, void> open(const _Path& __s, ios_base::openmode __mode = ios_base::in) { open(__s.c_str(), __mode); } #endif // C++17 #endif // C++11 /** * @brief Close the file. * * Calls @c std::basic_filebuf::close(). If that function * fails, @c failbit is set in the stream's error state. */ void close() { if (!_M_filebuf.close()) this->setstate(ios_base::failbit); } }; // [27.8.1.8] Template class basic_ofstream /** * @brief Controlling output for files. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * * This class supports reading from named files, using the inherited * functions from std::basic_ostream. To control the associated * sequence, an instance of std::basic_filebuf is used, which this page * refers to as @c sb. */ template<typename _CharT, typename _Traits> class basic_ofstream : public basic_ostream<_CharT,_Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard types: typedef basic_filebuf<char_type, traits_type> __filebuf_type; typedef basic_ostream<char_type, traits_type> __ostream_type; private: __filebuf_type _M_filebuf; public: // Constructors: /** * @brief Default constructor. * * Initializes @c sb using its default constructor, and passes * @c &sb to the base class initializer. Does not open any files * (you haven't given it a filename to open). */ basic_ofstream(): __ostream_type(), _M_filebuf() { this->init(&_M_filebuf); } /** * @brief Create an output file stream. * @param __s Null terminated string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * @c ios_base::out is automatically included in @a __mode. */ explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out) : __ostream_type(), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T /** * @param Create an output file stream. * @param __s Wide string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * @c ios_base::out | @c ios_base::trunc is automatically included in * @a __mode. */ basic_ofstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::out|ios_base::trunc) : __ostream_type(), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #endif #if __cplusplus >= 201103L /** * @brief Create an output file stream. * @param __s std::string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * @c ios_base::out is automatically included in @a __mode. */ explicit basic_ofstream(const std::string& __s, ios_base::openmode __mode = ios_base::out) : __ostream_type(), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #if __cplusplus >= 201703L /** * @brief Create an output file stream. * @param __s filesystem::path specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). * * @c ios_base::out is automatically included in @a __mode. */ template<typename _Path, typename _Require = _If_fs_path<_Path>> basic_ofstream(const _Path& __s, ios_base::openmode __mode = ios_base::out) : basic_ofstream(__s.c_str(), __mode) { } #endif // C++17 basic_ofstream(const basic_ofstream&) = delete; basic_ofstream(basic_ofstream&& __rhs) : __ostream_type(std::move(__rhs)), _M_filebuf(std::move(__rhs._M_filebuf)) { __ostream_type::set_rdbuf(&_M_filebuf); } #endif /** * @brief The destructor does nothing. * * The file is closed by the filebuf object, not the formatting * stream. */ ~basic_ofstream() { } #if __cplusplus >= 201103L // 27.8.3.2 Assign and swap: basic_ofstream& operator=(const basic_ofstream&) = delete; basic_ofstream& operator=(basic_ofstream&& __rhs) { __ostream_type::operator=(std::move(__rhs)); _M_filebuf = std::move(__rhs._M_filebuf); return *this; } void swap(basic_ofstream& __rhs) { __ostream_type::swap(__rhs); _M_filebuf.swap(__rhs._M_filebuf); } #endif // Members: /** * @brief Accessing the underlying buffer. * @return The current basic_filebuf buffer. * * This hides both signatures of std::basic_ios::rdbuf(). */ __filebuf_type* rdbuf() const { return const_cast<__filebuf_type*>(&_M_filebuf); } /** * @brief Wrapper to test for an open file. * @return @c rdbuf()->is_open() */ bool is_open() { return _M_filebuf.is_open(); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 365. Lack of const-qualification in clause 27 bool is_open() const { return _M_filebuf.is_open(); } /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode|out). If that * function fails, @c failbit is set in the stream's error state. */ void open(const char* __s, ios_base::openmode __mode = ios_base::out) { if (!_M_filebuf.open(__s, __mode | ios_base::out)) this->setstate(ios_base::failbit); else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 409. Closing an fstream should clear error state this->clear(); } #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode|out). If that * function fails, @c failbit is set in the stream's error state. */ void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out) { if (!_M_filebuf.open(__s, __mode | ios_base::out)) this->setstate(ios_base::failbit); else this->clear(); } #endif #if __cplusplus >= 201103L /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(s,mode|out). If that * function fails, @c failbit is set in the stream's error state. */ void open(const std::string& __s, ios_base::openmode __mode = ios_base::out) { if (!_M_filebuf.open(__s, __mode | ios_base::out)) this->setstate(ios_base::failbit); else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 409. Closing an fstream should clear error state this->clear(); } #if __cplusplus >= 201703L /** * @brief Opens an external file. * @param __s The name of the file, as a filesystem::path. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode|out). If that * function fails, @c failbit is set in the stream's error state. */ template<typename _Path> _If_fs_path<_Path, void> open(const _Path& __s, ios_base::openmode __mode = ios_base::out) { open(__s.c_str(), __mode); } #endif // C++17 #endif // C++11 /** * @brief Close the file. * * Calls @c std::basic_filebuf::close(). If that function * fails, @c failbit is set in the stream's error state. */ void close() { if (!_M_filebuf.close()) this->setstate(ios_base::failbit); } }; // [27.8.1.11] Template class basic_fstream /** * @brief Controlling input and output for files. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * * This class supports reading from and writing to named files, using * the inherited functions from std::basic_iostream. To control the * associated sequence, an instance of std::basic_filebuf is used, which * this page refers to as @c sb. */ template<typename _CharT, typename _Traits> class basic_fstream : public basic_iostream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; // Non-standard types: typedef basic_filebuf<char_type, traits_type> __filebuf_type; typedef basic_ios<char_type, traits_type> __ios_type; typedef basic_iostream<char_type, traits_type> __iostream_type; private: __filebuf_type _M_filebuf; public: // Constructors/destructor: /** * @brief Default constructor. * * Initializes @c sb using its default constructor, and passes * @c &sb to the base class initializer. Does not open any files * (you haven't given it a filename to open). */ basic_fstream() : __iostream_type(), _M_filebuf() { this->init(&_M_filebuf); } /** * @brief Create an input/output file stream. * @param __s Null terminated string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). */ explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out) : __iostream_type(0), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T /** * @param Create an input/output file stream. * @param __s Wide string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). */ basic_fstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out) : __iostream_type(0), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #endif #if __cplusplus >= 201103L /** * @brief Create an input/output file stream. * @param __s Null terminated string specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). */ explicit basic_fstream(const std::string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out) : __iostream_type(0), _M_filebuf() { this->init(&_M_filebuf); this->open(__s, __mode); } #if __cplusplus >= 201703L /** * @brief Create an input/output file stream. * @param __s filesystem::path specifying the filename. * @param __mode Open file in specified mode (see std::ios_base). */ template<typename _Path, typename _Require = _If_fs_path<_Path>> basic_fstream(const _Path& __s, ios_base::openmode __mode = ios_base::in | ios_base::out) : basic_fstream(__s.c_str(), __mode) { } #endif // C++17 basic_fstream(const basic_fstream&) = delete; basic_fstream(basic_fstream&& __rhs) : __iostream_type(std::move(__rhs)), _M_filebuf(std::move(__rhs._M_filebuf)) { __iostream_type::set_rdbuf(&_M_filebuf); } #endif /** * @brief The destructor does nothing. * * The file is closed by the filebuf object, not the formatting * stream. */ ~basic_fstream() { } #if __cplusplus >= 201103L // 27.8.3.2 Assign and swap: basic_fstream& operator=(const basic_fstream&) = delete; basic_fstream& operator=(basic_fstream&& __rhs) { __iostream_type::operator=(std::move(__rhs)); _M_filebuf = std::move(__rhs._M_filebuf); return *this; } void swap(basic_fstream& __rhs) { __iostream_type::swap(__rhs); _M_filebuf.swap(__rhs._M_filebuf); } #endif // Members: /** * @brief Accessing the underlying buffer. * @return The current basic_filebuf buffer. * * This hides both signatures of std::basic_ios::rdbuf(). */ __filebuf_type* rdbuf() const { return const_cast<__filebuf_type*>(&_M_filebuf); } /** * @brief Wrapper to test for an open file. * @return @c rdbuf()->is_open() */ bool is_open() { return _M_filebuf.is_open(); } // _GLIBCXX_RESOLVE_LIB_DEFECTS // 365. Lack of const-qualification in clause 27 bool is_open() const { return _M_filebuf.is_open(); } /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode). If that * function fails, @c failbit is set in the stream's error state. */ void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out) { if (!_M_filebuf.open(__s, __mode)) this->setstate(ios_base::failbit); else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 409. Closing an fstream should clear error state this->clear(); } #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode). If that * function fails, @c failbit is set in the stream's error state. */ void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out) { if (!_M_filebuf.open(__s, __mode)) this->setstate(ios_base::failbit); else this->clear(); } #endif #if __cplusplus >= 201103L /** * @brief Opens an external file. * @param __s The name of the file. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode). If that * function fails, @c failbit is set in the stream's error state. */ void open(const std::string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out) { if (!_M_filebuf.open(__s, __mode)) this->setstate(ios_base::failbit); else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 409. Closing an fstream should clear error state this->clear(); } #if __cplusplus >= 201703L /** * @brief Opens an external file. * @param __s The name of the file, as a filesystem::path. * @param __mode The open mode flags. * * Calls @c std::basic_filebuf::open(__s,__mode). If that * function fails, @c failbit is set in the stream's error state. */ template<typename _Path> _If_fs_path<_Path, void> open(const _Path& __s, ios_base::openmode __mode = ios_base::in | ios_base::out) { open(__s.c_str(), __mode); } #endif // C++17 #endif // C++11 /** * @brief Close the file. * * Calls @c std::basic_filebuf::close(). If that function * fails, @c failbit is set in the stream's error state. */ void close() { if (!_M_filebuf.close()) this->setstate(ios_base::failbit); } }; #if __cplusplus >= 201103L /// Swap specialization for filebufs. template <class _CharT, class _Traits> inline void swap(basic_filebuf<_CharT, _Traits>& __x, basic_filebuf<_CharT, _Traits>& __y) { __x.swap(__y); } /// Swap specialization for ifstreams. template <class _CharT, class _Traits> inline void swap(basic_ifstream<_CharT, _Traits>& __x, basic_ifstream<_CharT, _Traits>& __y) { __x.swap(__y); } /// Swap specialization for ofstreams. template <class _CharT, class _Traits> inline void swap(basic_ofstream<_CharT, _Traits>& __x, basic_ofstream<_CharT, _Traits>& __y) { __x.swap(__y); } /// Swap specialization for fstreams. template <class _CharT, class _Traits> inline void swap(basic_fstream<_CharT, _Traits>& __x, basic_fstream<_CharT, _Traits>& __y) { __x.swap(__y); } #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace #include <bits/fstream.tcc> #endif /* _GLIBCXX_FSTREAM */ // C++ includes used for precompiling TR1 -*- C++ -*- // Copyright (C) 2006-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file stdtr1c++.h * This is an implementation file for a precompiled header. */ #include <bits/stdc++.h> #include <tr1/array> #include <tr1/cctype> #include <tr1/cfenv> #include <tr1/cfloat> #include <tr1/cinttypes> #include <tr1/climits> #include <tr1/cmath> #include <tr1/complex> #include <tr1/cstdarg> #include <tr1/cstdbool> #include <tr1/cstdint> #include <tr1/cstdio> #include <tr1/cstdlib> #include <tr1/ctgmath> #include <tr1/ctime> #include <tr1/cwchar> #include <tr1/cwctype> #include <tr1/functional> #include <tr1/random> #include <tr1/tuple> #include <tr1/unordered_map> #include <tr1/unordered_set> #include <tr1/utility> // Control various target specific ABI tweaks. Generic version. // Copyright (C) 2004-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/cxxabi_tweaks.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{cxxabi.h} */ #ifndef _CXXABI_TWEAKS_H #define _CXXABI_TWEAKS_H 1 #ifdef __cplusplus namespace __cxxabiv1 { extern "C" { #endif // The generic ABI uses the first byte of a 64-bit guard variable. #define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0) #define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1 #define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1) #define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1) #define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1) __extension__ typedef int __guard __attribute__((mode (__DI__))); // __cxa_vec_ctor has void return type. typedef void __cxa_vec_ctor_return_type; #define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return // Constructors and destructors do not return a value. typedef void __cxa_cdtor_return_type; #ifdef __cplusplus } } // namespace __cxxabiv1 #endif #endif // std::messages implementation details, GNU version -*- C++ -*- // Copyright (C) 2001-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/messages_members.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.2.7.1.2 messages functions // // Written by Benjamin Kosnik <bkoz@redhat.com> #include <libintl.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Non-virtual member functions. template<typename _CharT> messages<_CharT>::messages(size_t __refs) : facet(__refs), _M_c_locale_messages(_S_get_c_locale()), _M_name_messages(_S_get_c_name()) { } template<typename _CharT> messages<_CharT>::messages(__c_locale __cloc, const char* __s, size_t __refs) : facet(__refs), _M_c_locale_messages(0), _M_name_messages(0) { if (__builtin_strcmp(__s, _S_get_c_name()) != 0) { const size_t __len = __builtin_strlen(__s) + 1; char* __tmp = new char[__len]; __builtin_memcpy(__tmp, __s, __len); _M_name_messages = __tmp; } else _M_name_messages = _S_get_c_name(); // Last to avoid leaking memory if new throws. _M_c_locale_messages = _S_clone_c_locale(__cloc); } template<typename _CharT> typename messages<_CharT>::catalog messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc, const char* __dir) const { bindtextdomain(__s.c_str(), __dir); return this->do_open(__s, __loc); } // Virtual member functions. template<typename _CharT> messages<_CharT>::~messages() { if (_M_name_messages != _S_get_c_name()) delete [] _M_name_messages; _S_destroy_c_locale(_M_c_locale_messages); } template<typename _CharT> typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __s, const locale&) const { // No error checking is done, assume the catalog exists and can // be used. textdomain(__s.c_str()); return 0; } template<typename _CharT> void messages<_CharT>::do_close(catalog) const { } // messages_byname template<typename _CharT> messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs) : messages<_CharT>(__refs) { if (this->_M_name_messages != locale::facet::_S_get_c_name()) { delete [] this->_M_name_messages; if (__builtin_strcmp(__s, locale::facet::_S_get_c_name()) != 0) { const size_t __len = __builtin_strlen(__s) + 1; char* __tmp = new char[__len]; __builtin_memcpy(__tmp, __s, __len); this->_M_name_messages = __tmp; } else this->_M_name_messages = locale::facet::_S_get_c_name(); } if (__builtin_strcmp(__s, "C") != 0 && __builtin_strcmp(__s, "POSIX") != 0) { this->_S_destroy_c_locale(this->_M_c_locale_messages); this->_S_create_c_locale(this->_M_c_locale_messages, __s); } } //Specializations. template<> typename messages<char>::catalog messages<char>::do_open(const basic_string<char>&, const locale&) const; template<> void messages<char>::do_close(catalog) const; #ifdef _GLIBCXX_USE_WCHAR_T template<> typename messages<wchar_t>::catalog messages<wchar_t>::do_open(const basic_string<char>&, const locale&) const; template<> void messages<wchar_t>::do_close(catalog) const; #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace /* Threads compatibility routines for libgcc2 and libobjc. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _GLIBCXX_GCC_GTHR_POSIX_H #define _GLIBCXX_GCC_GTHR_POSIX_H /* POSIX threads specific definitions. Easy, since the interface is just one-to-one mapping. */ #define __GTHREADS 1 #define __GTHREADS_CXX0X 1 #include <pthread.h> #if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) # include <unistd.h> # if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 # define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 # else # define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 # endif #endif typedef pthread_t __gthread_t; typedef pthread_key_t __gthread_key_t; typedef pthread_once_t __gthread_once_t; typedef pthread_mutex_t __gthread_mutex_t; typedef pthread_mutex_t __gthread_recursive_mutex_t; typedef pthread_cond_t __gthread_cond_t; typedef struct timespec __gthread_time_t; /* POSIX like conditional variables are supported. Please look at comments in gthr.h for details. */ #define __GTHREAD_HAS_COND 1 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER #define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP #else #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER #define __GTHREAD_TIME_INIT {0,0} #ifdef _GTHREAD_USE_MUTEX_INIT_FUNC # undef __GTHREAD_MUTEX_INIT #endif #ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC # undef __GTHREAD_RECURSIVE_MUTEX_INIT # undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION # define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #ifdef _GTHREAD_USE_COND_INIT_FUNC # undef __GTHREAD_COND_INIT # define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function #endif #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK # ifndef __gthrw_pragma # define __gthrw_pragma(pragma) # endif # define __gthrw2(name,name2,type) \ static __typeof(type) name \ __attribute__ ((__weakref__(#name2), __copy__ (type))); \ __gthrw_pragma(weak type) # define __gthrw_(name) __gthrw_ ## name #else # define __gthrw2(name,name2,type) # define __gthrw_(name) name #endif /* Typically, __gthrw_foo is a weak reference to symbol foo. */ #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) __gthrw(pthread_once) __gthrw(pthread_getspecific) __gthrw(pthread_setspecific) __gthrw(pthread_create) __gthrw(pthread_join) __gthrw(pthread_equal) __gthrw(pthread_self) __gthrw(pthread_detach) #ifndef __BIONIC__ __gthrw(pthread_cancel) #endif __gthrw(sched_yield) __gthrw(pthread_mutex_lock) __gthrw(pthread_mutex_trylock) #if _GTHREAD_USE_MUTEX_TIMEDLOCK __gthrw(pthread_mutex_timedlock) #endif __gthrw(pthread_mutex_unlock) __gthrw(pthread_mutex_init) __gthrw(pthread_mutex_destroy) __gthrw(pthread_cond_init) __gthrw(pthread_cond_broadcast) __gthrw(pthread_cond_signal) __gthrw(pthread_cond_wait) __gthrw(pthread_cond_timedwait) __gthrw(pthread_cond_destroy) __gthrw(pthread_key_create) __gthrw(pthread_key_delete) __gthrw(pthread_mutexattr_init) __gthrw(pthread_mutexattr_settype) __gthrw(pthread_mutexattr_destroy) #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) /* Objective-C. */ __gthrw(pthread_exit) #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(sched_get_priority_max) __gthrw(sched_get_priority_min) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ __gthrw(pthread_attr_destroy) __gthrw(pthread_attr_init) __gthrw(pthread_attr_setdetachstate) #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(pthread_getschedparam) __gthrw(pthread_setschedparam) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _LIBOBJC || _LIBOBJC_WEAK */ #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if -pthreads is not specified. The functions are dummies and most return an error value. However pthread_once returns 0 without invoking the routine it is passed so we cannot pretend that the interface is active if -pthreads is not specified. On Solaris 2.5.1, the interface is not exposed at all so we need to play the usual game with weak symbols. On Solaris 10 and up, a working interface is always exposed. On FreeBSD 6 and later, libc also exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, which means the alternate __gthread_active_p below cannot be used there. */ #if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) static volatile int __gthread_active = -1; static void __gthread_trigger (void) { __gthread_active = 1; } static inline int __gthread_active_p (void) { static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; /* This test is not protected to avoid taking a lock on the main code path so every update of __gthread_active in a threaded program must be atomic with regard to the result of the test. */ if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { if (__gthrw_(pthread_once)) { /* If this really is a threaded program, then we must ensure that __gthread_active has been set to 1 before exiting this block. */ __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); } /* Make sure we'll never enter this block again. */ if (__gthread_active < 0) __gthread_active = 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* neither FreeBSD nor Solaris */ /* For a program to be multi-threaded the only thing that it certainly must be using is pthread_create. However, there may be other libraries that intercept pthread_create with their own definitions to wrap pthreads functionality for some purpose. In those cases, pthread_create being defined might not necessarily mean that libpthread is actually linked in. For the GNU C library, we can use a known internal name. This is always available in the ABI, but no other library would define it. That is ideal, since any public pthread function might be intercepted just as pthread_create might be. __pthread_key_create is an "internal" implementation symbol, but it is part of the public exported ABI. Also, it's among the symbols that the static libpthread.a always links in whenever pthread_create is used, so there is no danger of a false negative result in any statically-linked, multi-threaded program. For others, we choose pthread_cancel as a function that seems unlikely to be redefined by an interceptor library. The bionic (Android) C library does not provide pthread_cancel, so we do use pthread_create there (and interceptor libraries lose). */ #ifdef __GLIBC__ __gthrw2(__gthrw_(__pthread_key_create), __pthread_key_create, pthread_key_create) # define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create) #elif defined (__BIONIC__) # define GTHR_ACTIVE_PROXY __gthrw_(pthread_create) #else # define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel) #endif static inline int __gthread_active_p (void) { static void *const __gthread_active_ptr = __extension__ (void *) >HR_ACTIVE_PROXY; return __gthread_active_ptr != 0; } #endif /* FreeBSD or Solaris */ #else /* not __GXX_WEAK__ */ /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread calls in shared flavors of the HP-UX C library. Most of the stubs have no functionality. The details are described in the "libc cumulative patch" for each subversion of HP-UX 11. There are two special interfaces provided for checking whether an application is linked to a shared pthread library or not. However, these interfaces aren't available in early libpthread libraries. We also need a test that works for archive libraries. We can't use pthread_once as some libc versions call the init function. We also can't use pthread_create or pthread_attr_init as these create a thread and thereby prevent changing the default stack size. The function pthread_default_stacksize_np is available in both the archive and shared versions of libpthread. It can be used to determine the default pthread stack size. There is a stub in some shared libc versions which returns a zero size if pthreads are not active. We provide an equivalent stub to handle cases where libc doesn't provide one. */ #if defined(__hppa__) && defined(__hpux__) static volatile int __gthread_active = -1; static inline int __gthread_active_p (void) { /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; size_t __s; if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { pthread_default_stacksize_np (0, &__s); __gthread_active = __s ? 1 : 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* not hppa-hpux */ static inline int __gthread_active_p (void) { return 1; } #endif /* hppa-hpux */ #endif /* __GXX_WEAK__ */ #ifdef _LIBOBJC /* This is the config.h file in libobjc/ */ #include <config.h> #ifdef HAVE_SCHED_H # include <sched.h> #endif /* Key structure for maintaining thread specific storage */ static pthread_key_t _objc_thread_storage; static pthread_attr_t _objc_thread_attribs; /* Thread local storage for a single thread */ static void *thread_local_storage = NULL; /* Backend initialization functions */ /* Initialize the threads subsystem. */ static inline int __gthread_objc_init_thread_system (void) { if (__gthread_active_p ()) { /* Initialize the thread storage key. */ if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) { /* The normal default detach state for threads is * PTHREAD_CREATE_JOINABLE which causes threads to not die * when you think they should. */ if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, PTHREAD_CREATE_DETACHED) == 0) return 0; } } return -1; } /* Close the threads subsystem. */ static inline int __gthread_objc_close_thread_system (void) { if (__gthread_active_p () && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) return 0; return -1; } /* Backend thread functions */ /* Create a new thread of execution. */ static inline objc_thread_t __gthread_objc_thread_detach (void (*func)(void *), void *arg) { objc_thread_t thread_id; pthread_t new_thread_handle; if (!__gthread_active_p ()) return NULL; if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, (void *) func, arg))) thread_id = (objc_thread_t) new_thread_handle; else thread_id = NULL; return thread_id; } /* Set the current thread's priority. */ static inline int __gthread_objc_thread_set_priority (int priority) { if (!__gthread_active_p ()) return -1; else { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING pthread_t thread_id = __gthrw_(pthread_self) (); int policy; struct sched_param params; int priority_min, priority_max; if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) { if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) return -1; if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) return -1; if (priority > priority_max) priority = priority_max; else if (priority < priority_min) priority = priority_min; params.sched_priority = priority; /* * The solaris 7 and several other man pages incorrectly state that * this should be a pointer to policy but pthread.h is universally * at odds with this. */ if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) return 0; } #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return -1; } } /* Return the current thread's priority. */ static inline int __gthread_objc_thread_get_priority (void) { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING if (__gthread_active_p ()) { int policy; struct sched_param params; if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) return params.sched_priority; else return -1; } else #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return OBJC_THREAD_INTERACTIVE_PRIORITY; } /* Yield our process time to another thread. */ static inline void __gthread_objc_thread_yield (void) { if (__gthread_active_p ()) __gthrw_(sched_yield) (); } /* Terminate the current thread. */ static inline int __gthread_objc_thread_exit (void) { if (__gthread_active_p ()) /* exit the thread */ __gthrw_(pthread_exit) (&__objc_thread_exit_status); /* Failed if we reached here */ return -1; } /* Returns an integer value which uniquely describes a thread. */ static inline objc_thread_t __gthread_objc_thread_id (void) { if (__gthread_active_p ()) return (objc_thread_t) __gthrw_(pthread_self) (); else return (objc_thread_t) 1; } /* Sets the thread's local storage pointer. */ static inline int __gthread_objc_thread_set_data (void *value) { if (__gthread_active_p ()) return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); else { thread_local_storage = value; return 0; } } /* Returns the thread's local storage pointer. */ static inline void * __gthread_objc_thread_get_data (void) { if (__gthread_active_p ()) return __gthrw_(pthread_getspecific) (_objc_thread_storage); else return thread_local_storage; } /* Backend mutex functions */ /* Allocate a mutex. */ static inline int __gthread_objc_mutex_allocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) { objc_free (mutex->backend); mutex->backend = NULL; return -1; } } return 0; } /* Deallocate a mutex. */ static inline int __gthread_objc_mutex_deallocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { int count; /* * Posix Threads specifically require that the thread be unlocked * for __gthrw_(pthread_mutex_destroy) to work. */ do { count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); if (count < 0) return -1; } while (count); if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) return -1; objc_free (mutex->backend); mutex->backend = NULL; } return 0; } /* Grab a lock on a mutex. */ static inline int __gthread_objc_mutex_lock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Try to grab a lock on a mutex. */ static inline int __gthread_objc_mutex_trylock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Unlock the mutex */ static inline int __gthread_objc_mutex_unlock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Backend condition mutex functions */ /* Allocate a condition. */ static inline int __gthread_objc_condition_allocate (objc_condition_t condition) { if (__gthread_active_p ()) { condition->backend = objc_malloc (sizeof (pthread_cond_t)); if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) { objc_free (condition->backend); condition->backend = NULL; return -1; } } return 0; } /* Deallocate a condition. */ static inline int __gthread_objc_condition_deallocate (objc_condition_t condition) { if (__gthread_active_p ()) { if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) return -1; objc_free (condition->backend); condition->backend = NULL; } return 0; } /* Wait on the condition */ static inline int __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, (pthread_mutex_t *) mutex->backend); else return 0; } /* Wake up all threads waiting on this condition. */ static inline int __gthread_objc_condition_broadcast (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); else return 0; } /* Wake up one thread waiting on this condition. */ static inline int __gthread_objc_condition_signal (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); else return 0; } #else /* _LIBOBJC */ static inline int __gthread_create (__gthread_t *__threadid, void *(*__func) (void*), void *__args) { return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); } static inline int __gthread_join (__gthread_t __threadid, void **__value_ptr) { return __gthrw_(pthread_join) (__threadid, __value_ptr); } static inline int __gthread_detach (__gthread_t __threadid) { return __gthrw_(pthread_detach) (__threadid); } static inline int __gthread_equal (__gthread_t __t1, __gthread_t __t2) { return __gthrw_(pthread_equal) (__t1, __t2); } static inline __gthread_t __gthread_self (void) { return __gthrw_(pthread_self) (); } static inline int __gthread_yield (void) { return __gthrw_(sched_yield) (); } static inline int __gthread_once (__gthread_once_t *__once, void (*__func) (void)) { if (__gthread_active_p ()) return __gthrw_(pthread_once) (__once, __func); else return -1; } static inline int __gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) { return __gthrw_(pthread_key_create) (__key, __dtor); } static inline int __gthread_key_delete (__gthread_key_t __key) { return __gthrw_(pthread_key_delete) (__key); } static inline void * __gthread_getspecific (__gthread_key_t __key) { return __gthrw_(pthread_getspecific) (__key); } static inline int __gthread_setspecific (__gthread_key_t __key, const void *__ptr) { return __gthrw_(pthread_setspecific) (__key, __ptr); } static inline void __gthread_mutex_init_function (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) __gthrw_(pthread_mutex_init) (__mutex, NULL); } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_destroy) (__mutex); else return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_lock) (__mutex); else return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_trylock) (__mutex); else return 0; } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_mutex_timedlock (__gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); else return 0; } #endif static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_unlock) (__mutex); else return 0; } #if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \ || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC) static inline int __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) { if (__gthread_active_p ()) { pthread_mutexattr_t __attr; int __r; __r = __gthrw_(pthread_mutexattr_init) (&__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_settype) (&__attr, PTHREAD_MUTEX_RECURSIVE); if (!__r) __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); return __r; } return 0; } #endif static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthread_mutex_timedlock (__mutex, __abs_timeout); } #endif static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } #ifdef _GTHREAD_USE_COND_INIT_FUNC static inline void __gthread_cond_init_function (__gthread_cond_t *__cond) { if (__gthread_active_p ()) __gthrw_(pthread_cond_init) (__cond, NULL); } #endif static inline int __gthread_cond_broadcast (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_broadcast) (__cond); } static inline int __gthread_cond_signal (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_signal) (__cond); } static inline int __gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) { return __gthrw_(pthread_cond_wait) (__cond, __mutex); } static inline int __gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); } static inline int __gthread_cond_wait_recursive (__gthread_cond_t *__cond, __gthread_recursive_mutex_t *__mutex) { return __gthread_cond_wait (__cond, __mutex); } static inline int __gthread_cond_destroy (__gthread_cond_t* __cond) { return __gthrw_(pthread_cond_destroy) (__cond); } #endif /* _LIBOBJC */ #endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */ // Specific definitions for generic platforms -*- C++ -*- // Copyright (C) 2007-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/error_constants.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{system_error} */ #ifndef _GLIBCXX_ERROR_CONSTANTS #define _GLIBCXX_ERROR_CONSTANTS 1 #include <bits/c++config.h> #include <cerrno> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION enum class errc { address_family_not_supported = EAFNOSUPPORT, address_in_use = EADDRINUSE, address_not_available = EADDRNOTAVAIL, already_connected = EISCONN, argument_list_too_long = E2BIG, argument_out_of_domain = EDOM, bad_address = EFAULT, bad_file_descriptor = EBADF, #ifdef EBADMSG bad_message = EBADMSG, #endif broken_pipe = EPIPE, connection_aborted = ECONNABORTED, connection_already_in_progress = EALREADY, connection_refused = ECONNREFUSED, connection_reset = ECONNRESET, cross_device_link = EXDEV, destination_address_required = EDESTADDRREQ, device_or_resource_busy = EBUSY, directory_not_empty = ENOTEMPTY, executable_format_error = ENOEXEC, file_exists = EEXIST, file_too_large = EFBIG, filename_too_long = ENAMETOOLONG, function_not_supported = ENOSYS, host_unreachable = EHOSTUNREACH, #ifdef EIDRM identifier_removed = EIDRM, #endif illegal_byte_sequence = EILSEQ, inappropriate_io_control_operation = ENOTTY, interrupted = EINTR, invalid_argument = EINVAL, invalid_seek = ESPIPE, io_error = EIO, is_a_directory = EISDIR, message_size = EMSGSIZE, network_down = ENETDOWN, network_reset = ENETRESET, network_unreachable = ENETUNREACH, no_buffer_space = ENOBUFS, no_child_process = ECHILD, #ifdef ENOLINK no_link = ENOLINK, #endif no_lock_available = ENOLCK, #ifdef ENODATA no_message_available = ENODATA, #endif no_message = ENOMSG, no_protocol_option = ENOPROTOOPT, no_space_on_device = ENOSPC, #ifdef ENOSR no_stream_resources = ENOSR, #endif no_such_device_or_address = ENXIO, no_such_device = ENODEV, no_such_file_or_directory = ENOENT, no_such_process = ESRCH, not_a_directory = ENOTDIR, not_a_socket = ENOTSOCK, #ifdef ENOSTR not_a_stream = ENOSTR, #endif not_connected = ENOTCONN, not_enough_memory = ENOMEM, #ifdef ENOTSUP not_supported = ENOTSUP, #endif #ifdef ECANCELED operation_canceled = ECANCELED, #endif operation_in_progress = EINPROGRESS, operation_not_permitted = EPERM, operation_not_supported = EOPNOTSUPP, operation_would_block = EWOULDBLOCK, #ifdef EOWNERDEAD owner_dead = EOWNERDEAD, #endif permission_denied = EACCES, #ifdef EPROTO protocol_error = EPROTO, #endif protocol_not_supported = EPROTONOSUPPORT, read_only_file_system = EROFS, resource_deadlock_would_occur = EDEADLK, resource_unavailable_try_again = EAGAIN, result_out_of_range = ERANGE, #ifdef ENOTRECOVERABLE state_not_recoverable = ENOTRECOVERABLE, #endif #ifdef ETIME stream_timeout = ETIME, #endif #ifdef ETXTBSY text_file_busy = ETXTBSY, #endif timed_out = ETIMEDOUT, too_many_files_open_in_system = ENFILE, too_many_files_open = EMFILE, too_many_links = EMLINK, too_many_symbolic_link_levels = ELOOP, #ifdef EOVERFLOW value_too_large = EOVERFLOW, #elif defined __AVR__ value_too_large = 999, #endif wrong_protocol_type = EPROTOTYPE }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // Locale support -*- C++ -*- // Copyright (C) 2000-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/ctype_inline.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.1 Locales // // ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) // functions go in ctype.cc namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION bool ctype<char>:: is(mask __m, char __c) const { return _M_table[static_cast<unsigned char>(__c)] & __m; } const char* ctype<char>:: is(const char* __low, const char* __high, mask* __vec) const { while (__low < __high) *__vec++ = _M_table[static_cast<unsigned char>(*__low++)]; return __high; } const char* ctype<char>:: scan_is(mask __m, const char* __low, const char* __high) const { while (__low < __high && !(_M_table[static_cast<unsigned char>(*__low)] & __m)) ++__low; return __low; } const char* ctype<char>:: scan_not(mask __m, const char* __low, const char* __high) const { while (__low < __high && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0) ++__low; return __low; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace // Specific definitions for GNU/Linux -*- C++ -*- // Copyright (C) 2000-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/os_defines.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{iosfwd} */ #ifndef _GLIBCXX_OS_DEFINES #define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. // This keeps isanum, et al from being propagated as macros. #define __NO_CTYPE 1 #include <features.h> // Provide a declaration for the possibly deprecated gets function, as // glibc 2.15 and later does not declare gets for ISO C11 when // __GNU_SOURCE is defined. #if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE) # undef _GLIBCXX_HAVE_GETS #endif // Glibc 2.23 removed the obsolete isinf and isnan declarations. Check the // version dynamically in case it has changed since libstdc++ was configured. #define _GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC __GLIBC_PREREQ(2,23) #if __GLIBC_PREREQ(2, 27) // Since glibc 2.27 pthread_self() is usable without linking to libpthread. # define _GLIBCXX_NATIVE_THREAD_ID pthread_self() #else // Before then it was in libc.so.6 but not libc.a, and always returns 0, // which breaks the invariant this_thread::get_id() != thread::id{}. // So only use it if we know the libpthread version is available. // Otherwise use (__gthread_t)1 as the ID of the main (and only) thread. # define _GLIBCXX_NATIVE_THREAD_ID \ (__gthread_active_p() ? __gthread_self() : (__gthread_t)1) #endif #if __GLIBC_PREREQ(2, 34) // Since glibc 2.34 all pthreads functions are usable without linking to // libpthread. # define _GLIBCXX_GTHREAD_USE_WEAK 0 #endif #endif // std::time_get, std::time_put implementation, GNU version -*- C++ -*- // Copyright (C) 2001-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/time_members.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.2.5.1.2 - time_get functions // ISO C++ 14882: 22.2.5.3.2 - time_put functions // // Written by Benjamin Kosnik <bkoz@redhat.com> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _CharT> __timepunct<_CharT>::__timepunct(size_t __refs) : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), _M_name_timepunct(_S_get_c_name()) { _M_initialize_timepunct(); } template<typename _CharT> __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(0), _M_name_timepunct(_S_get_c_name()) { _M_initialize_timepunct(); } template<typename _CharT> __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, size_t __refs) : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), _M_name_timepunct(0) { if (__builtin_strcmp(__s, _S_get_c_name()) != 0) { const size_t __len = __builtin_strlen(__s) + 1; char* __tmp = new char[__len]; __builtin_memcpy(__tmp, __s, __len); _M_name_timepunct = __tmp; } else _M_name_timepunct = _S_get_c_name(); __try { _M_initialize_timepunct(__cloc); } __catch(...) { if (_M_name_timepunct != _S_get_c_name()) delete [] _M_name_timepunct; __throw_exception_again; } } template<typename _CharT> __timepunct<_CharT>::~__timepunct() { if (_M_name_timepunct != _S_get_c_name()) delete [] _M_name_timepunct; delete _M_data; _S_destroy_c_locale(_M_c_locale_timepunct); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace // C++ includes used for precompiling -*- C++ -*- // Copyright (C) 2003-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file stdc++.h * This is an implementation file for a precompiled header. */ // 17.4.1.2 Headers // C #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <cwchar> #include <cwctype> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdalign> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cuchar> #endif // C++ #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <codecvt> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #endif #if __cplusplus >= 201402L #include <shared_mutex> #endif #if __cplusplus >= 201703L #include <any> #include <charconv> // #include <execution> #include <filesystem> #include <optional> #include <memory_resource> #include <string_view> #include <variant> #endif #if __cplusplus > 201703L #include <barrier> #include <bit> #include <compare> #include <concepts> #if __cpp_impl_coroutine # include <coroutine> #endif #include <latch> #include <numbers> #include <ranges> #include <span> #include <stop_token> #include <semaphore> #include <source_location> #include <syncstream> #include <version> #endif // Specific definitions for generic platforms -*- C++ -*- // Copyright (C) 2005-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/cpu_defines.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{iosfwd} */ #ifndef _GLIBCXX_CPU_DEFINES #define _GLIBCXX_CPU_DEFINES 1 #endif // Optimizations for random number functions, x86 version -*- C++ -*- // Copyright (C) 2012-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/opt_random.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{random} */ #ifndef _BITS_OPT_RANDOM_H #define _BITS_OPT_RANDOM_H 1 #ifdef __SSE3__ #include <pmmintrin.h> #endif #pragma GCC system_header namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef __SSE3__ template<> template<typename _UniformRandomNumberGenerator> void normal_distribution<double>:: __generate(typename normal_distribution<double>::result_type* __f, typename normal_distribution<double>::result_type* __t, _UniformRandomNumberGenerator& __urng, const param_type& __param) { typedef uint64_t __uctype; if (__f == __t) return; if (_M_saved_available) { _M_saved_available = false; *__f++ = _M_saved * __param.stddev() + __param.mean(); if (__f == __t) return; } constexpr uint64_t __maskval = 0xfffffffffffffull; static const __m128i __mask = _mm_set1_epi64x(__maskval); static const __m128i __two = _mm_set1_epi64x(0x4000000000000000ull); static const __m128d __three = _mm_set1_pd(3.0); const __m128d __av = _mm_set1_pd(__param.mean()); const __uctype __urngmin = __urng.min(); const __uctype __urngmax = __urng.max(); const __uctype __urngrange = __urngmax - __urngmin; const __uctype __uerngrange = __urngrange + 1; while (__f + 1 < __t) { double __le; __m128d __x; do { union { __m128i __i; __m128d __d; } __v; if (__urngrange > __maskval) { if (__detail::_Power_of_2(__uerngrange)) __v.__i = _mm_and_si128(_mm_set_epi64x(__urng(), __urng()), __mask); else { const __uctype __uerange = __maskval + 1; const __uctype __scaling = __urngrange / __uerange; const __uctype __past = __uerange * __scaling; uint64_t __v1; do __v1 = __uctype(__urng()) - __urngmin; while (__v1 >= __past); __v1 /= __scaling; uint64_t __v2; do __v2 = __uctype(__urng()) - __urngmin; while (__v2 >= __past); __v2 /= __scaling; __v.__i = _mm_set_epi64x(__v1, __v2); } } else if (__urngrange == __maskval) __v.__i = _mm_set_epi64x(__urng(), __urng()); else if ((__urngrange + 2) * __urngrange >= __maskval && __detail::_Power_of_2(__uerngrange)) { uint64_t __v1 = __urng() * __uerngrange + __urng(); uint64_t __v2 = __urng() * __uerngrange + __urng(); __v.__i = _mm_and_si128(_mm_set_epi64x(__v1, __v2), __mask); } else { size_t __nrng = 2; __uctype __high = __maskval / __uerngrange / __uerngrange; while (__high > __uerngrange) { ++__nrng; __high /= __uerngrange; } const __uctype __highrange = __high + 1; const __uctype __scaling = __urngrange / __highrange; const __uctype __past = __highrange * __scaling; __uctype __tmp; uint64_t __v1; do { do __tmp = __uctype(__urng()) - __urngmin; while (__tmp >= __past); __v1 = __tmp / __scaling; for (size_t __cnt = 0; __cnt < __nrng; ++__cnt) { __tmp = __v1; __v1 *= __uerngrange; __v1 += __uctype(__urng()) - __urngmin; } } while (__v1 > __maskval || __v1 < __tmp); uint64_t __v2; do { do __tmp = __uctype(__urng()) - __urngmin; while (__tmp >= __past); __v2 = __tmp / __scaling; for (size_t __cnt = 0; __cnt < __nrng; ++__cnt) { __tmp = __v2; __v2 *= __uerngrange; __v2 += __uctype(__urng()) - __urngmin; } } while (__v2 > __maskval || __v2 < __tmp); __v.__i = _mm_set_epi64x(__v1, __v2); } __v.__i = _mm_or_si128(__v.__i, __two); __x = _mm_sub_pd(__v.__d, __three); __m128d __m = _mm_mul_pd(__x, __x); __le = _mm_cvtsd_f64(_mm_hadd_pd (__m, __m)); } while (__le == 0.0 || __le >= 1.0); double __mult = (std::sqrt(-2.0 * std::log(__le) / __le) * __param.stddev()); __x = _mm_add_pd(_mm_mul_pd(__x, _mm_set1_pd(__mult)), __av); _mm_storeu_pd(__f, __x); __f += 2; } if (__f != __t) { result_type __x, __y, __r2; __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> __aurng(__urng); do { __x = result_type(2.0) * __aurng() - 1.0; __y = result_type(2.0) * __aurng() - 1.0; __r2 = __x * __x + __y * __y; } while (__r2 > 1.0 || __r2 == 0.0); const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); _M_saved = __x * __mult; _M_saved_available = true; *__f = __y * __mult * __param.stddev() + __param.mean(); } } #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // _BITS_OPT_RANDOM_H // Wrapper for underlying C-language localization -*- C++ -*- // Copyright (C) 2001-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/c++locale.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.8 Standard locale categories. // // Written by Benjamin Kosnik <bkoz@redhat.com> #ifndef _GLIBCXX_CXX_LOCALE_H #define _GLIBCXX_CXX_LOCALE_H 1 #pragma GCC system_header #include <clocale> #define _GLIBCXX_C_LOCALE_GNU 1 #define _GLIBCXX_NUM_CATEGORIES 6 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION extern "C" __typeof(uselocale) __uselocale; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __locale_t __c_locale; // Convert numeric value of type double and long double to string and // return length of string. If vsnprintf is available use it, otherwise // fall back to the unsafe vsprintf which, in general, can be dangerous // and should be avoided. inline int __convert_from_v(const __c_locale& __cloc __attribute__ ((__unused__)), char* __out, const int __size __attribute__ ((__unused__)), const char* __fmt, ...) { #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __c_locale __old = __gnu_cxx::__uselocale(__cloc); #else char* __old = std::setlocale(LC_NUMERIC, 0); char* __sav = 0; if (__builtin_strcmp(__old, "C")) { const size_t __len = __builtin_strlen(__old) + 1; __sav = new char[__len]; __builtin_memcpy(__sav, __old, __len); std::setlocale(LC_NUMERIC, "C"); } #endif __builtin_va_list __args; __builtin_va_start(__args, __fmt); #if _GLIBCXX_USE_C99_STDIO const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args); #else const int __ret = __builtin_vsprintf(__out, __fmt, __args); #endif __builtin_va_end(__args); #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __gnu_cxx::__uselocale(__old); #else if (__sav) { std::setlocale(LC_NUMERIC, __sav); delete [] __sav; } #endif return __ret; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // Locale support -*- C++ -*- // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/ctype_base.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.1 Locales // // Information as gleaned from /usr/include/ctype.h namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @brief Base class for ctype. struct ctype_base { // Non-standard typedefs. typedef const int* __to_type; // NB: Offsets into ctype<char>::_M_table force a particular size // on the mask type. Because of this, we don't use an enum. typedef unsigned short mask; static const mask upper = _ISupper; static const mask lower = _ISlower; static const mask alpha = _ISalpha; static const mask digit = _ISdigit; static const mask xdigit = _ISxdigit; static const mask space = _ISspace; static const mask print = _ISprint; static const mask graph = _ISalpha | _ISdigit | _ISpunct; static const mask cntrl = _IScntrl; static const mask punct = _ISpunct; static const mask alnum = _ISalpha | _ISdigit; #if __cplusplus >= 201103L static const mask blank = _ISblank; #endif }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace /* Threads compatibility routines for libgcc2 and libobjc. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _GLIBCXX_GCC_GTHR_SINGLE_H #define _GLIBCXX_GCC_GTHR_SINGLE_H /* Just provide compatibility for mutex handling. */ typedef int __gthread_key_t; typedef int __gthread_once_t; typedef int __gthread_mutex_t; typedef int __gthread_recursive_mutex_t; #define __GTHREAD_ONCE_INIT 0 #define __GTHREAD_MUTEX_INIT 0 #define __GTHREAD_MUTEX_INIT_FUNCTION(mx) do {} while (0) #define __GTHREAD_RECURSIVE_MUTEX_INIT 0 #define _GLIBCXX_UNUSED __attribute__((__unused__)) #ifdef _LIBOBJC /* Thread local storage for a single thread */ static void *thread_local_storage = NULL; /* Backend initialization functions */ /* Initialize the threads subsystem. */ static inline int __gthread_objc_init_thread_system (void) { /* No thread support available */ return -1; } /* Close the threads subsystem. */ static inline int __gthread_objc_close_thread_system (void) { /* No thread support available */ return -1; } /* Backend thread functions */ /* Create a new thread of execution. */ static inline objc_thread_t __gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED) { /* No thread support available */ return NULL; } /* Set the current thread's priority. */ static inline int __gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED) { /* No thread support available */ return -1; } /* Return the current thread's priority. */ static inline int __gthread_objc_thread_get_priority (void) { return OBJC_THREAD_INTERACTIVE_PRIORITY; } /* Yield our process time to another thread. */ static inline void __gthread_objc_thread_yield (void) { return; } /* Terminate the current thread. */ static inline int __gthread_objc_thread_exit (void) { /* No thread support available */ /* Should we really exit the program */ /* exit (&__objc_thread_exit_status); */ return -1; } /* Returns an integer value which uniquely describes a thread. */ static inline objc_thread_t __gthread_objc_thread_id (void) { /* No thread support, use 1. */ return (objc_thread_t) 1; } /* Sets the thread's local storage pointer. */ static inline int __gthread_objc_thread_set_data (void *value) { thread_local_storage = value; return 0; } /* Returns the thread's local storage pointer. */ static inline void * __gthread_objc_thread_get_data (void) { return thread_local_storage; } /* Backend mutex functions */ /* Allocate a mutex. */ static inline int __gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Deallocate a mutex. */ static inline int __gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Grab a lock on a mutex. */ static inline int __gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED) { /* There can only be one thread, so we always get the lock */ return 0; } /* Try to grab a lock on a mutex. */ static inline int __gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED) { /* There can only be one thread, so we always get the lock */ return 0; } /* Unlock the mutex */ static inline int __gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Backend condition mutex functions */ /* Allocate a condition. */ static inline int __gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } /* Deallocate a condition. */ static inline int __gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } /* Wait on the condition */ static inline int __gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED, objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Wake up all threads waiting on this condition. */ static inline int __gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } /* Wake up one thread waiting on this condition. */ static inline int __gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } #else /* _LIBOBJC */ static inline int __gthread_active_p (void) { return 0; } static inline int __gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED) { return 0; } static inline int _GLIBCXX_UNUSED __gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED) { return 0; } static int _GLIBCXX_UNUSED __gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED) { return 0; } static inline void * __gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } #endif /* _LIBOBJC */ #undef _GLIBCXX_UNUSED #endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */ /* Threads compatibility routines for libgcc2. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _GLIBCXX_GCC_GTHR_H #define _GLIBCXX_GCC_GTHR_H #ifndef _GLIBCXX_HIDE_EXPORTS #pragma GCC visibility push(default) #endif /* If this file is compiled with threads support, it must #define __GTHREADS 1 to indicate that threads support is present. Also it has define function int __gthread_active_p () that returns 1 if thread system is active, 0 if not. The threads interface must define the following types: __gthread_key_t __gthread_once_t __gthread_mutex_t __gthread_recursive_mutex_t The threads interface must define the following macros: __GTHREAD_ONCE_INIT to initialize __gthread_once_t __GTHREAD_MUTEX_INIT to initialize __gthread_mutex_t to get a fast non-recursive mutex. __GTHREAD_MUTEX_INIT_FUNCTION to initialize __gthread_mutex_t to get a fast non-recursive mutex. Define this to a function which looks like this: void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *) Some systems can't initialize a mutex without a function call. Don't define __GTHREAD_MUTEX_INIT in this case. __GTHREAD_RECURSIVE_MUTEX_INIT __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION as above, but for a recursive mutex. The threads interface must define the following static functions: int __gthread_once (__gthread_once_t *once, void (*func) ()) int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *)) int __gthread_key_delete (__gthread_key_t key) void *__gthread_getspecific (__gthread_key_t key) int __gthread_setspecific (__gthread_key_t key, const void *ptr) int __gthread_mutex_destroy (__gthread_mutex_t *mutex); int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex); int __gthread_mutex_lock (__gthread_mutex_t *mutex); int __gthread_mutex_trylock (__gthread_mutex_t *mutex); int __gthread_mutex_unlock (__gthread_mutex_t *mutex); int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex); int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex); int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex); The following are supported in POSIX threads only. They are required to fix a deadlock in static initialization inside libsupc++. The header file gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra features are supported. Types: __gthread_cond_t Macros: __GTHREAD_COND_INIT __GTHREAD_COND_INIT_FUNCTION Interface: int __gthread_cond_broadcast (__gthread_cond_t *cond); int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex); int __gthread_cond_wait_recursive (__gthread_cond_t *cond, __gthread_recursive_mutex_t *mutex); All functions returning int should return zero on success or the error number. If the operation is not supported, -1 is returned. If the following are also defined, you should #define __GTHREADS_CXX0X 1 to enable the c++0x thread library. Types: __gthread_t __gthread_time_t Interface: int __gthread_create (__gthread_t *thread, void *(*func) (void*), void *args); int __gthread_join (__gthread_t thread, void **value_ptr); int __gthread_detach (__gthread_t thread); int __gthread_equal (__gthread_t t1, __gthread_t t2); __gthread_t __gthread_self (void); int __gthread_yield (void); int __gthread_mutex_timedlock (__gthread_mutex_t *m, const __gthread_time_t *abs_timeout); int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m, const __gthread_time_t *abs_time); int __gthread_cond_signal (__gthread_cond_t *cond); int __gthread_cond_timedwait (__gthread_cond_t *cond, __gthread_mutex_t *mutex, const __gthread_time_t *abs_timeout); */ #if __GXX_WEAK__ /* The pe-coff weak support isn't fully compatible to ELF's weak. For static libraries it might would work, but as we need to deal with shared versions too, we disable it for mingw-targets. */ #ifdef __MINGW32__ #undef _GLIBCXX_GTHREAD_USE_WEAK #define _GLIBCXX_GTHREAD_USE_WEAK 0 #endif #ifndef _GLIBCXX_GTHREAD_USE_WEAK #define _GLIBCXX_GTHREAD_USE_WEAK 1 #endif #endif #include <bits/gthr-default.h> #ifndef _GLIBCXX_HIDE_EXPORTS #pragma GCC visibility pop #endif #endif /* ! _GLIBCXX_GCC_GTHR_H */ // Base to std::allocator -*- C++ -*- // Copyright (C) 2004-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/c++allocator.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{memory} */ #ifndef _GLIBCXX_CXX_ALLOCATOR_H #define _GLIBCXX_CXX_ALLOCATOR_H 1 #include <ext/new_allocator.h> #if __cplusplus >= 201103L namespace std { /** * @brief An alias to the base class for std::allocator. * * Used to set the std::allocator base class to * __gnu_cxx::new_allocator. * * @ingroup allocators * @tparam _Tp Type of allocated object. */ template<typename _Tp> using __allocator_base = __gnu_cxx::new_allocator<_Tp>; } #else // Define new_allocator as the base class to std::allocator. # define __allocator_base __gnu_cxx::new_allocator #endif #ifndef _GLIBCXX_SANITIZE_STD_ALLOCATOR # if defined(__SANITIZE_ADDRESS__) # define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1 # elif defined __has_feature # if __has_feature(address_sanitizer) # define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1 # endif # endif #endif #endif // Underlying io library details -*- C++ -*- // Copyright (C) 2000-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/c++io.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ios} */ // c_io_stdio.h - Defines for using "C" stdio.h #ifndef _GLIBCXX_CXX_IO_H #define _GLIBCXX_CXX_IO_H 1 #include <cstdio> #include <bits/gthr.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __gthread_mutex_t __c_lock; // for basic_file.h typedef FILE __c_file; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // C++ includes used for precompiling extensions -*- C++ -*- // Copyright (C) 2006-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file extc++.h * This is an implementation file for a precompiled header. */ #if __cplusplus < 201103L #include <bits/stdtr1c++.h> #else #include <bits/stdc++.h> #endif #include <ext/algorithm> #if __cplusplus >= 201103L # include <ext/aligned_buffer.h> #endif #include <ext/alloc_traits.h> #include <ext/atomicity.h> #include <ext/bitmap_allocator.h> #include <ext/cast.h> #if __cplusplus >= 201103L # include <ext/cmath> #endif #include <ext/concurrence.h> #include <ext/debug_allocator.h> #include <ext/extptr_allocator.h> #include <ext/functional> #include <ext/iterator> #include <ext/malloc_allocator.h> #include <ext/memory> #include <ext/mt_allocator.h> #include <ext/new_allocator.h> #include <ext/numeric> #include <ext/numeric_traits.h> #include <ext/pod_char_traits.h> #include <ext/pointer.h> #include <ext/pool_allocator.h> #if __cplusplus >= 201103L # include <ext/random> #endif #include <ext/rb_tree> #include <ext/rope> #include <ext/slist> #include <ext/stdio_filebuf.h> #include <ext/stdio_sync_filebuf.h> #include <ext/throw_allocator.h> #include <ext/typelist.h> #include <ext/type_traits.h> #include <ext/vstring.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/priority_queue.hpp> #include <ext/pb_ds/exception.hpp> #include <ext/pb_ds/hash_policy.hpp> #include <ext/pb_ds/list_update_policy.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/trie_policy.hpp> #ifdef _GLIBCXX_HAVE_ICONV #include <ext/codecvt_specializations.h> #include <ext/enc_filebuf.h> #endif // Low-level type for atomic operations -*- C++ -*- // Copyright (C) 2004-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file atomic_word.h * This file is a GNU extension to the Standard C++ Library. */ #ifndef _GLIBCXX_ATOMIC_WORD_H #define _GLIBCXX_ATOMIC_WORD_H 1 typedef int _Atomic_word; // This is a memory order acquire fence. #define _GLIBCXX_READ_MEM_BARRIER __atomic_thread_fence (__ATOMIC_ACQUIRE) // This is a memory order release fence. #define _GLIBCXX_WRITE_MEM_BARRIER __atomic_thread_fence (__ATOMIC_RELEASE) #endif #ifndef _CPP_CPPCONFIG_WRAPPER #define _CPP_CPPCONFIG_WRAPPER 1 #include <bits/wordsize.h> #if __WORDSIZE == 32 // Predefined symbols and macros -*- C++ -*- // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/c++config.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{version} */ #ifndef _GLIBCXX_CXX_CONFIG_H #define _GLIBCXX_CXX_CONFIG_H 1 // The major release number for the GCC release the C++ library belongs to. #define _GLIBCXX_RELEASE 11 // The datestamp of the C++ library in compressed ISO date format. #define __GLIBCXX__ 20240719 // Macros for various attributes. // _GLIBCXX_PURE // _GLIBCXX_CONST // _GLIBCXX_NORETURN // _GLIBCXX_NOTHROW // _GLIBCXX_VISIBILITY #ifndef _GLIBCXX_PURE # define _GLIBCXX_PURE __attribute__ ((__pure__)) #endif #ifndef _GLIBCXX_CONST # define _GLIBCXX_CONST __attribute__ ((__const__)) #endif #ifndef _GLIBCXX_NORETURN # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__)) #endif // See below for C++ #ifndef _GLIBCXX_NOTHROW # ifndef __cplusplus # define _GLIBCXX_NOTHROW __attribute__((__nothrow__)) # endif #endif // Macros for visibility attributes. // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY // _GLIBCXX_VISIBILITY # define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 1 #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) #else // If this is not supplied by the OS-specific or CPU-specific // headers included below, it will be defined to an empty default. # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V) #endif // Macros for deprecated attributes. // _GLIBCXX_USE_DEPRECATED // _GLIBCXX_DEPRECATED // _GLIBCXX_DEPRECATED_SUGGEST( string-literal ) // _GLIBCXX11_DEPRECATED // _GLIBCXX11_DEPRECATED_SUGGEST( string-literal ) // _GLIBCXX17_DEPRECATED // _GLIBCXX17_DEPRECATED_SUGGEST( string-literal ) // _GLIBCXX20_DEPRECATED( string-literal ) // _GLIBCXX20_DEPRECATED_SUGGEST( string-literal ) #ifndef _GLIBCXX_USE_DEPRECATED # define _GLIBCXX_USE_DEPRECATED 1 #endif #if defined(__DEPRECATED) # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__)) # define _GLIBCXX_DEPRECATED_SUGGEST(ALT) \ __attribute__ ((__deprecated__ ("use '" ALT "' instead"))) #else # define _GLIBCXX_DEPRECATED # define _GLIBCXX_DEPRECATED_SUGGEST(ALT) #endif #if defined(__DEPRECATED) && (__cplusplus >= 201103L) # define _GLIBCXX11_DEPRECATED _GLIBCXX_DEPRECATED # define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) #else # define _GLIBCXX11_DEPRECATED # define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) #endif #if defined(__DEPRECATED) && (__cplusplus >= 201703L) # define _GLIBCXX17_DEPRECATED [[__deprecated__]] # define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) #else # define _GLIBCXX17_DEPRECATED # define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) #endif #if defined(__DEPRECATED) && (__cplusplus > 201703L) # define _GLIBCXX20_DEPRECATED(MSG) [[deprecated(MSG)]] # define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) #else # define _GLIBCXX20_DEPRECATED(MSG) # define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) #endif // Macros for ABI tag attributes. #ifndef _GLIBCXX_ABI_TAG_CXX11 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11"))) #endif // Macro to warn about unused results. #if __cplusplus >= 201703L # define _GLIBCXX_NODISCARD [[__nodiscard__]] #else # define _GLIBCXX_NODISCARD #endif #if __cplusplus // Macro for constexpr, to support in mixed 03/0x mode. #ifndef _GLIBCXX_CONSTEXPR # if __cplusplus >= 201103L # define _GLIBCXX_CONSTEXPR constexpr # define _GLIBCXX_USE_CONSTEXPR constexpr # else # define _GLIBCXX_CONSTEXPR # define _GLIBCXX_USE_CONSTEXPR const # endif #endif #ifndef _GLIBCXX14_CONSTEXPR # if __cplusplus >= 201402L # define _GLIBCXX14_CONSTEXPR constexpr # else # define _GLIBCXX14_CONSTEXPR # endif #endif #ifndef _GLIBCXX17_CONSTEXPR # if __cplusplus >= 201703L # define _GLIBCXX17_CONSTEXPR constexpr # else # define _GLIBCXX17_CONSTEXPR # endif #endif #ifndef _GLIBCXX20_CONSTEXPR # if __cplusplus > 201703L # define _GLIBCXX20_CONSTEXPR constexpr # else # define _GLIBCXX20_CONSTEXPR # endif #endif #ifndef _GLIBCXX17_INLINE # if __cplusplus >= 201703L # define _GLIBCXX17_INLINE inline # else # define _GLIBCXX17_INLINE # endif #endif // Macro for noexcept, to support in mixed 03/0x mode. #ifndef _GLIBCXX_NOEXCEPT # if __cplusplus >= 201103L # define _GLIBCXX_NOEXCEPT noexcept # define _GLIBCXX_NOEXCEPT_IF(...) noexcept(__VA_ARGS__) # define _GLIBCXX_USE_NOEXCEPT noexcept # define _GLIBCXX_THROW(_EXC) # else # define _GLIBCXX_NOEXCEPT # define _GLIBCXX_NOEXCEPT_IF(...) # define _GLIBCXX_USE_NOEXCEPT throw() # define _GLIBCXX_THROW(_EXC) throw(_EXC) # endif #endif #ifndef _GLIBCXX_NOTHROW # define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT #endif #ifndef _GLIBCXX_THROW_OR_ABORT # if __cpp_exceptions # define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC)) # else # define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort()) # endif #endif #if __cpp_noexcept_function_type #define _GLIBCXX_NOEXCEPT_PARM , bool _NE #define _GLIBCXX_NOEXCEPT_QUAL noexcept (_NE) #else #define _GLIBCXX_NOEXCEPT_PARM #define _GLIBCXX_NOEXCEPT_QUAL #endif // Macro for extern template, ie controlling template linkage via use // of extern keyword on template declaration. As documented in the g++ // manual, it inhibits all implicit instantiations and is used // throughout the library to avoid multiple weak definitions for // required types that are already explicitly instantiated in the // library binary. This substantially reduces the binary size of // resulting executables. // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern // templates only in basic_string, thus activating its debug-mode // checks even at -O0. # define _GLIBCXX_EXTERN_TEMPLATE 1 /* Outline of libstdc++ namespaces. namespace std { namespace __debug { } namespace __parallel { } namespace __cxx1998 { } namespace __detail { namespace __variant { } // C++17 } namespace rel_ops { } namespace tr1 { namespace placeholders { } namespace regex_constants { } namespace __detail { } } namespace tr2 { } namespace decimal { } namespace chrono { } // C++11 namespace placeholders { } // C++11 namespace regex_constants { } // C++11 namespace this_thread { } // C++11 inline namespace literals { // C++14 inline namespace chrono_literals { } // C++14 inline namespace complex_literals { } // C++14 inline namespace string_literals { } // C++14 inline namespace string_view_literals { } // C++17 } } namespace abi { } namespace __gnu_cxx { namespace __detail { } } For full details see: http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html */ namespace std { typedef __SIZE_TYPE__ size_t; typedef __PTRDIFF_TYPE__ ptrdiff_t; #if __cplusplus >= 201103L typedef decltype(nullptr) nullptr_t; #endif } # define _GLIBCXX_USE_DUAL_ABI 1 #if ! _GLIBCXX_USE_DUAL_ABI // Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI # undef _GLIBCXX_USE_CXX11_ABI #endif #ifndef _GLIBCXX_USE_CXX11_ABI # define _GLIBCXX_USE_CXX11_ABI 1 #endif #if _GLIBCXX_USE_CXX11_ABI namespace std { inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } } namespace __gnu_cxx { inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } } # define _GLIBCXX_NAMESPACE_CXX11 __cxx11:: # define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 { # define _GLIBCXX_END_NAMESPACE_CXX11 } # define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11 #else # define _GLIBCXX_NAMESPACE_CXX11 # define _GLIBCXX_BEGIN_NAMESPACE_CXX11 # define _GLIBCXX_END_NAMESPACE_CXX11 # define _GLIBCXX_DEFAULT_ABI_TAG #endif // Defined if inline namespaces are used for versioning. # define _GLIBCXX_INLINE_VERSION 0 // Inline namespace for symbol versioning. #if _GLIBCXX_INLINE_VERSION # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 { # define _GLIBCXX_END_NAMESPACE_VERSION } namespace std { inline _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201402L inline namespace literals { inline namespace chrono_literals { } inline namespace complex_literals { } inline namespace string_literals { } #if __cplusplus > 201402L inline namespace string_view_literals { } #endif // C++17 } #endif // C++14 _GLIBCXX_END_NAMESPACE_VERSION } namespace __gnu_cxx { inline _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } #else # define _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_VERSION #endif // Inline namespaces for special modes: debug, parallel. #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) namespace std { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Non-inline namespace for components replaced by alternates in active mode. namespace __cxx1998 { # if _GLIBCXX_USE_CXX11_ABI inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } # endif } _GLIBCXX_END_NAMESPACE_VERSION // Inline namespace for debug mode. # ifdef _GLIBCXX_DEBUG inline namespace __debug { } # endif // Inline namespaces for parallel mode. # ifdef _GLIBCXX_PARALLEL inline namespace __parallel { } # endif } // Check for invalid usage and unsupported mixed-mode use. # if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL) # error illegal use of multiple inlined namespaces # endif // Check for invalid use due to lack for weak symbols. # if __NO_INLINE__ && !__GXX_WEAK__ # warning currently using inlined namespace mode which may fail \ without inlining due to lack of weak symbols # endif #endif // Macros for namespace scope. Either namespace std:: or the name // of some nested namespace within it corresponding to the active mode. // _GLIBCXX_STD_A // _GLIBCXX_STD_C // // Macros for opening/closing conditional namespaces. // _GLIBCXX_BEGIN_NAMESPACE_ALGO // _GLIBCXX_END_NAMESPACE_ALGO // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_END_NAMESPACE_CONTAINER #if defined(_GLIBCXX_DEBUG) # define _GLIBCXX_STD_C __cxx1998 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \ namespace _GLIBCXX_STD_C { # define _GLIBCXX_END_NAMESPACE_CONTAINER } #else # define _GLIBCXX_STD_C std # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER # define _GLIBCXX_END_NAMESPACE_CONTAINER #endif #ifdef _GLIBCXX_PARALLEL # define _GLIBCXX_STD_A __cxx1998 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO \ namespace _GLIBCXX_STD_A { # define _GLIBCXX_END_NAMESPACE_ALGO } #else # define _GLIBCXX_STD_A std # define _GLIBCXX_BEGIN_NAMESPACE_ALGO # define _GLIBCXX_END_NAMESPACE_ALGO #endif // GLIBCXX_ABI Deprecated // Define if compatibility should be provided for -mlong-double-64. #undef _GLIBCXX_LONG_DOUBLE_COMPAT // Define if compatibility should be provided for alternative 128-bit long // double formats. Not possible for Clang until __ibm128 is supported. #ifndef __clang__ #undef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT #endif // Inline namespaces for long double 128 modes. #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ && defined __LONG_DOUBLE_IEEE128__ namespace std { // Namespaces for 128-bit IEEE long double format on 64-bit POWER LE. inline namespace __gnu_cxx_ieee128 { } inline namespace __gnu_cxx11_ieee128 { } } # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ieee128:: # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ieee128 { # define _GLIBCXX_END_NAMESPACE_LDBL } # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 __gnu_cxx11_ieee128:: # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 namespace __gnu_cxx11_ieee128 { # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 } #else // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ namespace std { inline namespace __gnu_cxx_ldbl128 { } } # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128:: # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 { # define _GLIBCXX_END_NAMESPACE_LDBL } #else # define _GLIBCXX_NAMESPACE_LDBL # define _GLIBCXX_BEGIN_NAMESPACE_LDBL # define _GLIBCXX_END_NAMESPACE_LDBL #endif #if _GLIBCXX_USE_CXX11_ABI # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_CXX11 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_CXX11 # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_CXX11 #else # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_LDBL # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_LDBL # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_LDBL #endif #endif // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 // Debug Mode implies checking assertions. #if defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_ASSERTIONS) # define _GLIBCXX_ASSERTIONS 1 #endif // Disable std::string explicit instantiation declarations in order to assert. #ifdef _GLIBCXX_ASSERTIONS # undef _GLIBCXX_EXTERN_TEMPLATE # define _GLIBCXX_EXTERN_TEMPLATE -1 #endif #if __has_builtin(__builtin_is_constant_evaluated) # define __glibcxx_constexpr_assert(cond) \ if (__builtin_is_constant_evaluated() && !bool(cond)) \ __builtin_unreachable() /* precondition violation detected! */ #else # define __glibcxx_constexpr_assert(unevaluated) #endif // Assert. #if defined(_GLIBCXX_ASSERTIONS) \ || defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PARALLEL_ASSERTIONS) namespace std { // Avoid the use of assert, because we're trying to keep the <cassert> // include out of the mix. extern "C++" _GLIBCXX_NORETURN inline void __replacement_assert(const char* __file, int __line, const char* __function, const char* __condition) { __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line, __function, __condition); __builtin_abort(); } } #define __glibcxx_assert_impl(_Condition) \ if (__builtin_expect(!bool(_Condition), false)) \ { \ __glibcxx_constexpr_assert(_Condition); \ std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ #_Condition); \ } #endif #if defined(_GLIBCXX_ASSERTIONS) # define __glibcxx_assert(cond) \ do { __glibcxx_assert_impl(cond); } while (false) #else # define __glibcxx_assert(cond) \ do { __glibcxx_constexpr_assert(cond); } while (false) #endif // Macros for race detectors. // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain // atomic (lock-free) synchronization to race detectors: // the race detector will infer a happens-before arc from the former to the // latter when they share the same argument pointer. // // The most frequent use case for these macros (and the only case in the // current implementation of the library) is atomic reference counting: // void _M_remove_reference() // { // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0) // { // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); // _M_destroy(__a); // } // } // The annotations in this example tell the race detector that all memory // accesses occurred when the refcount was positive do not race with // memory accesses which occurred after the refcount became zero. #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) #endif #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) #endif // Macros for C linkage: define extern "C" linkage only when using C++. # define _GLIBCXX_BEGIN_EXTERN_C extern "C" { # define _GLIBCXX_END_EXTERN_C } # define _GLIBCXX_USE_ALLOCATOR_NEW 1 #ifdef __SIZEOF_INT128__ #if ! defined __GLIBCXX_TYPE_INT_N_0 && ! defined __STRICT_ANSI__ // If __int128 is supported, we expect __GLIBCXX_TYPE_INT_N_0 to be defined // unless the compiler is in strict mode. If it's not defined and the strict // macro is not defined, something is wrong. #warning "__STRICT_ANSI__ seems to have been undefined; this is not supported" #endif #endif #else // !__cplusplus # define _GLIBCXX_BEGIN_EXTERN_C # define _GLIBCXX_END_EXTERN_C #endif // First includes. // Pick up any OS-specific definitions. #include <bits/os_defines.h> // Pick up any CPU-specific definitions. #include <bits/cpu_defines.h> // If platform uses neither visibility nor psuedo-visibility, // specify empty default for namespace annotation macros. #ifndef _GLIBCXX_PSEUDO_VISIBILITY # define _GLIBCXX_PSEUDO_VISIBILITY(V) #endif // Certain function definitions that are meant to be overridable from // user code are decorated with this macro. For some targets, this // macro causes these definitions to be weak. #ifndef _GLIBCXX_WEAK_DEFINITION # define _GLIBCXX_WEAK_DEFINITION #endif // By default, we assume that __GXX_WEAK__ also means that there is support // for declaring functions as weak while not defining such functions. This // allows for referring to functions provided by other libraries (e.g., // libitm) without depending on them if the respective features are not used. #ifndef _GLIBCXX_USE_WEAK_REF # define _GLIBCXX_USE_WEAK_REF __GXX_WEAK__ #endif // Conditionally enable annotations for the Transactional Memory TS on C++11. // Most of the following conditions are due to limitations in the current // implementation. #if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI \ && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201500L \ && !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF \ && _GLIBCXX_USE_ALLOCATOR_NEW #define _GLIBCXX_TXN_SAFE transaction_safe #define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic #else #define _GLIBCXX_TXN_SAFE #define _GLIBCXX_TXN_SAFE_DYN #endif #if __cplusplus > 201402L // In C++17 mathematical special functions are in namespace std. # define _GLIBCXX_USE_STD_SPEC_FUNCS 1 #elif __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0 // For C++11 and C++14 they are in namespace std when requested. # define _GLIBCXX_USE_STD_SPEC_FUNCS 1 #endif // The remainder of the prewritten config is automatic; all the // user hooks are listed above. // Create a boolean flag to be used to determine if --fast-math is set. #ifdef __FAST_MATH__ # define _GLIBCXX_FAST_MATH 1 #else # define _GLIBCXX_FAST_MATH 0 #endif // This marks string literals in header files to be extracted for eventual // translation. It is primarily used for messages in thrown exceptions; see // src/functexcept.cc. We use __N because the more traditional _N is used // for something else under certain OSes (see BADNAMES). #define __N(msgid) (msgid) // For example, <windows.h> is known to #define min and max as macros... #undef min #undef max // N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally // so they should be tested with #if not with #ifdef. #if __cplusplus >= 201103L # ifndef _GLIBCXX_USE_C99_MATH # define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH # endif # ifndef _GLIBCXX_USE_C99_COMPLEX # define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX # endif # ifndef _GLIBCXX_USE_C99_STDIO # define _GLIBCXX_USE_C99_STDIO _GLIBCXX11_USE_C99_STDIO # endif # ifndef _GLIBCXX_USE_C99_STDLIB # define _GLIBCXX_USE_C99_STDLIB _GLIBCXX11_USE_C99_STDLIB # endif # ifndef _GLIBCXX_USE_C99_WCHAR # define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR # endif #else # ifndef _GLIBCXX_USE_C99_MATH # define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH # endif # ifndef _GLIBCXX_USE_C99_COMPLEX # define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX # endif # ifndef _GLIBCXX_USE_C99_STDIO # define _GLIBCXX_USE_C99_STDIO _GLIBCXX98_USE_C99_STDIO # endif # ifndef _GLIBCXX_USE_C99_STDLIB # define _GLIBCXX_USE_C99_STDLIB _GLIBCXX98_USE_C99_STDLIB # endif # ifndef _GLIBCXX_USE_C99_WCHAR # define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR # endif #endif // Unless explicitly specified, enable char8_t extensions only if the core // language char8_t feature macro is defined. #ifndef _GLIBCXX_USE_CHAR8_T # ifdef __cpp_char8_t # define _GLIBCXX_USE_CHAR8_T 1 # endif #endif #ifdef _GLIBCXX_USE_CHAR8_T # define __cpp_lib_char8_t 201907L #endif /* Define if __float128 is supported on this host. */ #if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) /* For powerpc64 don't use __float128 when it's the same type as long double. */ # if !(defined(_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT) && defined(__LONG_DOUBLE_IEEE128__)) # define _GLIBCXX_USE_FLOAT128 1 # endif #endif // Define if float has the IEEE binary32 format. #if __FLT_MANT_DIG__ == 24 \ && __FLT_MIN_EXP__ == -125 \ && __FLT_MAX_EXP__ == 128 # define _GLIBCXX_FLOAT_IS_IEEE_BINARY32 1 #endif // Define if double has the IEEE binary64 format. #if __DBL_MANT_DIG__ == 53 \ && __DBL_MIN_EXP__ == -1021 \ && __DBL_MAX_EXP__ == 1024 # define _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 1 #endif #ifdef __has_builtin # ifdef __is_identifier // Intel and older Clang require !__is_identifier for some built-ins: # define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) || ! __is_identifier(B) # else # define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) # endif #endif #if _GLIBCXX_HAS_BUILTIN(__has_unique_object_representations) # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 #endif #if _GLIBCXX_HAS_BUILTIN(__is_aggregate) # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 #endif #if _GLIBCXX_HAS_BUILTIN(__builtin_is_constant_evaluated) # define _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 1 #endif #if _GLIBCXX_HAS_BUILTIN(__is_same) # define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1 #endif #if _GLIBCXX_HAS_BUILTIN(__builtin_launder) # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 #endif #undef _GLIBCXX_HAS_BUILTIN // PSTL configuration #if __cplusplus >= 201703L // This header is not installed for freestanding: #if __has_include(<pstl/pstl_config.h>) // Preserved here so we have some idea which version of upstream we've pulled in // #define PSTL_VERSION 9000 // For now this defaults to being based on the presence of Thread Building Blocks # ifndef _GLIBCXX_USE_TBB_PAR_BACKEND # define _GLIBCXX_USE_TBB_PAR_BACKEND __has_include(<tbb/tbb.h>) # endif // This section will need some rework when a new (default) backend type is added # if _GLIBCXX_USE_TBB_PAR_BACKEND # define _PSTL_PAR_BACKEND_TBB # else # define _PSTL_PAR_BACKEND_SERIAL # endif # define _PSTL_ASSERT(_Condition) __glibcxx_assert(_Condition) # define _PSTL_ASSERT_MSG(_Condition, _Message) __glibcxx_assert(_Condition) #include <pstl/pstl_config.h> #endif // __has_include #endif // C++17 // End of prewritten config; the settings discovered at configure time follow. /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `acosf' function. */ #define _GLIBCXX_HAVE_ACOSF 1 /* Define to 1 if you have the `acosl' function. */ #define _GLIBCXX_HAVE_ACOSL 1 /* Define to 1 if you have the `aligned_alloc' function. */ #define _GLIBCXX_HAVE_ALIGNED_ALLOC 1 /* Define to 1 if you have the <arpa/inet.h> header file. */ #define _GLIBCXX_HAVE_ARPA_INET_H 1 /* Define to 1 if you have the `asinf' function. */ #define _GLIBCXX_HAVE_ASINF 1 /* Define to 1 if you have the `asinl' function. */ #define _GLIBCXX_HAVE_ASINL 1 /* Define to 1 if the target assembler supports .symver directive. */ #define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1 /* Define to 1 if you have the `atan2f' function. */ #define _GLIBCXX_HAVE_ATAN2F 1 /* Define to 1 if you have the `atan2l' function. */ #define _GLIBCXX_HAVE_ATAN2L 1 /* Define to 1 if you have the `atanf' function. */ #define _GLIBCXX_HAVE_ATANF 1 /* Define to 1 if you have the `atanl' function. */ #define _GLIBCXX_HAVE_ATANL 1 /* Defined if shared_ptr reference counting should use atomic operations. */ #define _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY 1 /* Define to 1 if you have the `at_quick_exit' function. */ #define _GLIBCXX_HAVE_AT_QUICK_EXIT 1 /* Define to 1 if the target assembler supports thread-local storage. */ /* #undef _GLIBCXX_HAVE_CC_TLS */ /* Define to 1 if you have the `ceilf' function. */ #define _GLIBCXX_HAVE_CEILF 1 /* Define to 1 if you have the `ceill' function. */ #define _GLIBCXX_HAVE_CEILL 1 /* Define to 1 if you have the <complex.h> header file. */ #define _GLIBCXX_HAVE_COMPLEX_H 1 /* Define to 1 if you have the `cosf' function. */ #define _GLIBCXX_HAVE_COSF 1 /* Define to 1 if you have the `coshf' function. */ #define _GLIBCXX_HAVE_COSHF 1 /* Define to 1 if you have the `coshl' function. */ #define _GLIBCXX_HAVE_COSHL 1 /* Define to 1 if you have the `cosl' function. */ #define _GLIBCXX_HAVE_COSL 1 /* Define to 1 if you have the <dirent.h> header file. */ #define _GLIBCXX_HAVE_DIRENT_H 1 /* Define if dirfd is available in <dirent.h>. */ #define _GLIBCXX_HAVE_DIRFD 1 /* Define to 1 if you have the <dlfcn.h> header file. */ #define _GLIBCXX_HAVE_DLFCN_H 1 /* Define to 1 if you have the <endian.h> header file. */ #define _GLIBCXX_HAVE_ENDIAN_H 1 /* Define to 1 if GCC 4.6 supported std::exception_ptr for the target */ #define _GLIBCXX_HAVE_EXCEPTION_PTR_SINCE_GCC46 1 /* Define to 1 if you have the <execinfo.h> header file. */ #define _GLIBCXX_HAVE_EXECINFO_H 1 /* Define to 1 if you have the `expf' function. */ #define _GLIBCXX_HAVE_EXPF 1 /* Define to 1 if you have the `expl' function. */ #define _GLIBCXX_HAVE_EXPL 1 /* Define to 1 if you have the `fabsf' function. */ #define _GLIBCXX_HAVE_FABSF 1 /* Define to 1 if you have the `fabsl' function. */ #define _GLIBCXX_HAVE_FABSL 1 /* Define to 1 if you have the <fcntl.h> header file. */ #define _GLIBCXX_HAVE_FCNTL_H 1 /* Define if fdopendir is available in <dirent.h>. */ #define _GLIBCXX_HAVE_FDOPENDIR 1 /* Define to 1 if you have the <fenv.h> header file. */ #define _GLIBCXX_HAVE_FENV_H 1 /* Define to 1 if you have the `finite' function. */ #define _GLIBCXX_HAVE_FINITE 1 /* Define to 1 if you have the `finitef' function. */ #define _GLIBCXX_HAVE_FINITEF 1 /* Define to 1 if you have the `finitel' function. */ #define _GLIBCXX_HAVE_FINITEL 1 /* Define to 1 if you have the <float.h> header file. */ #define _GLIBCXX_HAVE_FLOAT_H 1 /* Define to 1 if you have the `floorf' function. */ #define _GLIBCXX_HAVE_FLOORF 1 /* Define to 1 if you have the `floorl' function. */ #define _GLIBCXX_HAVE_FLOORL 1 /* Define to 1 if you have the `fmodf' function. */ #define _GLIBCXX_HAVE_FMODF 1 /* Define to 1 if you have the `fmodl' function. */ #define _GLIBCXX_HAVE_FMODL 1 /* Define to 1 if you have the `fpclass' function. */ /* #undef _GLIBCXX_HAVE_FPCLASS */ /* Define to 1 if you have the <fp.h> header file. */ /* #undef _GLIBCXX_HAVE_FP_H */ /* Define to 1 if you have the `frexpf' function. */ #define _GLIBCXX_HAVE_FREXPF 1 /* Define to 1 if you have the `frexpl' function. */ #define _GLIBCXX_HAVE_FREXPL 1 /* Define if _Unwind_GetIPInfo is available. */ #define _GLIBCXX_HAVE_GETIPINFO 1 /* Define if gets is available in <stdio.h> before C++14. */ #define _GLIBCXX_HAVE_GETS 1 /* Define to 1 if you have the `hypot' function. */ #define _GLIBCXX_HAVE_HYPOT 1 /* Define to 1 if you have the `hypotf' function. */ #define _GLIBCXX_HAVE_HYPOTF 1 /* Define to 1 if you have the `hypotl' function. */ #define _GLIBCXX_HAVE_HYPOTL 1 /* Define if you have the iconv() function. */ #define _GLIBCXX_HAVE_ICONV 1 /* Define to 1 if you have the <ieeefp.h> header file. */ /* #undef _GLIBCXX_HAVE_IEEEFP_H */ /* Define if int64_t is available in <stdint.h>. */ #define _GLIBCXX_HAVE_INT64_T 1 /* Define if int64_t is a long. */ /* #undef _GLIBCXX_HAVE_INT64_T_LONG */ /* Define if int64_t is a long long. */ #define _GLIBCXX_HAVE_INT64_T_LONG_LONG 1 /* Define to 1 if you have the <inttypes.h> header file. */ #define _GLIBCXX_HAVE_INTTYPES_H 1 /* Define to 1 if you have the `isinf' function. */ /* #undef _GLIBCXX_HAVE_ISINF */ /* Define to 1 if you have the `isinff' function. */ #define _GLIBCXX_HAVE_ISINFF 1 /* Define to 1 if you have the `isinfl' function. */ #define _GLIBCXX_HAVE_ISINFL 1 /* Define to 1 if you have the `isnan' function. */ /* #undef _GLIBCXX_HAVE_ISNAN */ /* Define to 1 if you have the `isnanf' function. */ #define _GLIBCXX_HAVE_ISNANF 1 /* Define to 1 if you have the `isnanl' function. */ #define _GLIBCXX_HAVE_ISNANL 1 /* Defined if iswblank exists. */ #define _GLIBCXX_HAVE_ISWBLANK 1 /* Define if LC_MESSAGES is available in <locale.h>. */ #define _GLIBCXX_HAVE_LC_MESSAGES 1 /* Define to 1 if you have the `ldexpf' function. */ #define _GLIBCXX_HAVE_LDEXPF 1 /* Define to 1 if you have the `ldexpl' function. */ #define _GLIBCXX_HAVE_LDEXPL 1 /* Define to 1 if you have the <libintl.h> header file. */ #define _GLIBCXX_HAVE_LIBINTL_H 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_AS 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_DATA 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_FSIZE 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_RSS 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_VMEM 0 /* Define if link is available in <unistd.h>. */ #define _GLIBCXX_HAVE_LINK 1 /* Define if futex syscall is available. */ #define _GLIBCXX_HAVE_LINUX_FUTEX 1 /* Define to 1 if you have the <linux/random.h> header file. */ #define _GLIBCXX_HAVE_LINUX_RANDOM_H 1 /* Define to 1 if you have the <linux/types.h> header file. */ #define _GLIBCXX_HAVE_LINUX_TYPES_H 1 /* Define to 1 if you have the <locale.h> header file. */ #define _GLIBCXX_HAVE_LOCALE_H 1 /* Define to 1 if you have the `log10f' function. */ #define _GLIBCXX_HAVE_LOG10F 1 /* Define to 1 if you have the `log10l' function. */ #define _GLIBCXX_HAVE_LOG10L 1 /* Define to 1 if you have the `logf' function. */ #define _GLIBCXX_HAVE_LOGF 1 /* Define to 1 if you have the `logl' function. */ #define _GLIBCXX_HAVE_LOGL 1 /* Define to 1 if you have the <machine/endian.h> header file. */ /* #undef _GLIBCXX_HAVE_MACHINE_ENDIAN_H */ /* Define to 1 if you have the <machine/param.h> header file. */ /* #undef _GLIBCXX_HAVE_MACHINE_PARAM_H */ /* Define if mbstate_t exists in wchar.h. */ #define _GLIBCXX_HAVE_MBSTATE_T 1 /* Define to 1 if you have the `memalign' function. */ #define _GLIBCXX_HAVE_MEMALIGN 1 /* Define to 1 if you have the <memory.h> header file. */ #define _GLIBCXX_HAVE_MEMORY_H 1 /* Define to 1 if you have the `modf' function. */ #define _GLIBCXX_HAVE_MODF 1 /* Define to 1 if you have the `modff' function. */ #define _GLIBCXX_HAVE_MODFF 1 /* Define to 1 if you have the `modfl' function. */ #define _GLIBCXX_HAVE_MODFL 1 /* Define to 1 if you have the <nan.h> header file. */ /* #undef _GLIBCXX_HAVE_NAN_H */ /* Define to 1 if you have the <netdb.h> header file. */ #define _GLIBCXX_HAVE_NETDB_H 1 /* Define to 1 if you have the <netinet/in.h> header file. */ #define _GLIBCXX_HAVE_NETINET_IN_H 1 /* Define to 1 if you have the <netinet/tcp.h> header file. */ #define _GLIBCXX_HAVE_NETINET_TCP_H 1 /* Define if <math.h> defines obsolete isinf function. */ /* #undef _GLIBCXX_HAVE_OBSOLETE_ISINF */ /* Define if <math.h> defines obsolete isnan function. */ /* #undef _GLIBCXX_HAVE_OBSOLETE_ISNAN */ /* Define if openat is available in <fcntl.h>. */ #define _GLIBCXX_HAVE_OPENAT 1 /* Define if poll is available in <poll.h>. */ #define _GLIBCXX_HAVE_POLL 1 /* Define to 1 if you have the <poll.h> header file. */ #define _GLIBCXX_HAVE_POLL_H 1 /* Define to 1 if you have the `posix_memalign' function. */ #define _GLIBCXX_HAVE_POSIX_MEMALIGN 1 /* Define to 1 if POSIX Semaphores with sem_timedwait are available in <semaphore.h>. */ #define _GLIBCXX_HAVE_POSIX_SEMAPHORE 1 /* Define to 1 if you have the `powf' function. */ #define _GLIBCXX_HAVE_POWF 1 /* Define to 1 if you have the `powl' function. */ #define _GLIBCXX_HAVE_POWL 1 /* Define to 1 if you have the `qfpclass' function. */ /* #undef _GLIBCXX_HAVE_QFPCLASS */ /* Define to 1 if you have the `quick_exit' function. */ #define _GLIBCXX_HAVE_QUICK_EXIT 1 /* Define if readlink is available in <unistd.h>. */ #define _GLIBCXX_HAVE_READLINK 1 /* Define to 1 if you have the `secure_getenv' function. */ #define _GLIBCXX_HAVE_SECURE_GETENV 1 /* Define to 1 if you have the `setenv' function. */ #define _GLIBCXX_HAVE_SETENV 1 /* Define to 1 if you have the `sincos' function. */ #define _GLIBCXX_HAVE_SINCOS 1 /* Define to 1 if you have the `sincosf' function. */ #define _GLIBCXX_HAVE_SINCOSF 1 /* Define to 1 if you have the `sincosl' function. */ #define _GLIBCXX_HAVE_SINCOSL 1 /* Define to 1 if you have the `sinf' function. */ #define _GLIBCXX_HAVE_SINF 1 /* Define to 1 if you have the `sinhf' function. */ #define _GLIBCXX_HAVE_SINHF 1 /* Define to 1 if you have the `sinhl' function. */ #define _GLIBCXX_HAVE_SINHL 1 /* Define to 1 if you have the `sinl' function. */ #define _GLIBCXX_HAVE_SINL 1 /* Defined if sleep exists. */ /* #undef _GLIBCXX_HAVE_SLEEP */ /* Define to 1 if you have the `sockatmark' function. */ #define _GLIBCXX_HAVE_SOCKATMARK 1 /* Define to 1 if you have the `sqrtf' function. */ #define _GLIBCXX_HAVE_SQRTF 1 /* Define to 1 if you have the `sqrtl' function. */ #define _GLIBCXX_HAVE_SQRTL 1 /* Define to 1 if you have the <stdalign.h> header file. */ #define _GLIBCXX_HAVE_STDALIGN_H 1 /* Define to 1 if you have the <stdbool.h> header file. */ #define _GLIBCXX_HAVE_STDBOOL_H 1 /* Define to 1 if you have the <stdint.h> header file. */ #define _GLIBCXX_HAVE_STDINT_H 1 /* Define to 1 if you have the <stdlib.h> header file. */ #define _GLIBCXX_HAVE_STDLIB_H 1 /* Define if strerror_l is available in <string.h>. */ #define _GLIBCXX_HAVE_STRERROR_L 1 /* Define if strerror_r is available in <string.h>. */ #define _GLIBCXX_HAVE_STRERROR_R 1 /* Define to 1 if you have the <strings.h> header file. */ #define _GLIBCXX_HAVE_STRINGS_H 1 /* Define to 1 if you have the <string.h> header file. */ #define _GLIBCXX_HAVE_STRING_H 1 /* Define to 1 if you have the `strtof' function. */ #define _GLIBCXX_HAVE_STRTOF 1 /* Define to 1 if you have the `strtold' function. */ #define _GLIBCXX_HAVE_STRTOLD 1 /* Define to 1 if `d_type' is a member of `struct dirent'. */ #define _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE 1 /* Define if strxfrm_l is available in <string.h>. */ #define _GLIBCXX_HAVE_STRXFRM_L 1 /* Define if symlink is available in <unistd.h>. */ #define _GLIBCXX_HAVE_SYMLINK 1 /* Define to 1 if the target runtime linker supports binding the same symbol to different versions. */ #define _GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1 /* Define to 1 if you have the <sys/filio.h> header file. */ /* #undef _GLIBCXX_HAVE_SYS_FILIO_H */ /* Define to 1 if you have the <sys/ioctl.h> header file. */ #define _GLIBCXX_HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the <sys/ipc.h> header file. */ #define _GLIBCXX_HAVE_SYS_IPC_H 1 /* Define to 1 if you have the <sys/isa_defs.h> header file. */ /* #undef _GLIBCXX_HAVE_SYS_ISA_DEFS_H */ /* Define to 1 if you have the <sys/machine.h> header file. */ /* #undef _GLIBCXX_HAVE_SYS_MACHINE_H */ /* Define to 1 if you have the <sys/param.h> header file. */ #define _GLIBCXX_HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the <sys/resource.h> header file. */ #define _GLIBCXX_HAVE_SYS_RESOURCE_H 1 /* Define to 1 if you have a suitable <sys/sdt.h> header file */ #define _GLIBCXX_HAVE_SYS_SDT_H 1 /* Define to 1 if you have the <sys/sem.h> header file. */ #define _GLIBCXX_HAVE_SYS_SEM_H 1 /* Define to 1 if you have the <sys/socket.h> header file. */ #define _GLIBCXX_HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the <sys/statvfs.h> header file. */ #define _GLIBCXX_HAVE_SYS_STATVFS_H 1 /* Define to 1 if you have the <sys/stat.h> header file. */ #define _GLIBCXX_HAVE_SYS_STAT_H 1 /* Define to 1 if you have the <sys/sysinfo.h> header file. */ #define _GLIBCXX_HAVE_SYS_SYSINFO_H 1 /* Define to 1 if you have the <sys/time.h> header file. */ #define _GLIBCXX_HAVE_SYS_TIME_H 1 /* Define to 1 if you have the <sys/types.h> header file. */ #define _GLIBCXX_HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the <sys/uio.h> header file. */ #define _GLIBCXX_HAVE_SYS_UIO_H 1 /* Define if S_IFREG is available in <sys/stat.h>. */ /* #undef _GLIBCXX_HAVE_S_IFREG */ /* Define if S_ISREG is available in <sys/stat.h>. */ #define _GLIBCXX_HAVE_S_ISREG 1 /* Define to 1 if you have the `tanf' function. */ #define _GLIBCXX_HAVE_TANF 1 /* Define to 1 if you have the `tanhf' function. */ #define _GLIBCXX_HAVE_TANHF 1 /* Define to 1 if you have the `tanhl' function. */ #define _GLIBCXX_HAVE_TANHL 1 /* Define to 1 if you have the `tanl' function. */ #define _GLIBCXX_HAVE_TANL 1 /* Define to 1 if you have the <tgmath.h> header file. */ #define _GLIBCXX_HAVE_TGMATH_H 1 /* Define to 1 if you have the `timespec_get' function. */ #define _GLIBCXX_HAVE_TIMESPEC_GET 1 /* Define to 1 if the target supports thread-local storage. */ #define _GLIBCXX_HAVE_TLS 1 /* Define if truncate is available in <unistd.h>. */ #define _GLIBCXX_HAVE_TRUNCATE 1 /* Define to 1 if you have the <uchar.h> header file. */ #define _GLIBCXX_HAVE_UCHAR_H 1 /* Define to 1 if you have the <unistd.h> header file. */ #define _GLIBCXX_HAVE_UNISTD_H 1 /* Define if unlinkat is available in <fcntl.h>. */ #define _GLIBCXX_HAVE_UNLINKAT 1 /* Define to 1 if you have the `uselocale' function. */ #define _GLIBCXX_HAVE_USELOCALE 1 /* Defined if usleep exists. */ /* #undef _GLIBCXX_HAVE_USLEEP */ /* Define to 1 if you have the <utime.h> header file. */ #define _GLIBCXX_HAVE_UTIME_H 1 /* Defined if vfwscanf exists. */ #define _GLIBCXX_HAVE_VFWSCANF 1 /* Defined if vswscanf exists. */ #define _GLIBCXX_HAVE_VSWSCANF 1 /* Defined if vwscanf exists. */ #define _GLIBCXX_HAVE_VWSCANF 1 /* Define to 1 if you have the <wchar.h> header file. */ #define _GLIBCXX_HAVE_WCHAR_H 1 /* Defined if wcstof exists. */ #define _GLIBCXX_HAVE_WCSTOF 1 /* Define to 1 if you have the <wctype.h> header file. */ #define _GLIBCXX_HAVE_WCTYPE_H 1 /* Defined if Sleep exists. */ /* #undef _GLIBCXX_HAVE_WIN32_SLEEP */ /* Define if writev is available in <sys/uio.h>. */ #define _GLIBCXX_HAVE_WRITEV 1 /* Define to 1 if you have the <xlocale.h> header file. */ /* #undef _GLIBCXX_HAVE_XLOCALE_H */ /* Define to 1 if you have the `_acosf' function. */ /* #undef _GLIBCXX_HAVE__ACOSF */ /* Define to 1 if you have the `_acosl' function. */ /* #undef _GLIBCXX_HAVE__ACOSL */ /* Define to 1 if you have the `_aligned_malloc' function. */ /* #undef _GLIBCXX_HAVE__ALIGNED_MALLOC */ /* Define to 1 if you have the `_asinf' function. */ /* #undef _GLIBCXX_HAVE__ASINF */ /* Define to 1 if you have the `_asinl' function. */ /* #undef _GLIBCXX_HAVE__ASINL */ /* Define to 1 if you have the `_atan2f' function. */ /* #undef _GLIBCXX_HAVE__ATAN2F */ /* Define to 1 if you have the `_atan2l' function. */ /* #undef _GLIBCXX_HAVE__ATAN2L */ /* Define to 1 if you have the `_atanf' function. */ /* #undef _GLIBCXX_HAVE__ATANF */ /* Define to 1 if you have the `_atanl' function. */ /* #undef _GLIBCXX_HAVE__ATANL */ /* Define to 1 if you have the `_ceilf' function. */ /* #undef _GLIBCXX_HAVE__CEILF */ /* Define to 1 if you have the `_ceill' function. */ /* #undef _GLIBCXX_HAVE__CEILL */ /* Define to 1 if you have the `_cosf' function. */ /* #undef _GLIBCXX_HAVE__COSF */ /* Define to 1 if you have the `_coshf' function. */ /* #undef _GLIBCXX_HAVE__COSHF */ /* Define to 1 if you have the `_coshl' function. */ /* #undef _GLIBCXX_HAVE__COSHL */ /* Define to 1 if you have the `_cosl' function. */ /* #undef _GLIBCXX_HAVE__COSL */ /* Define to 1 if you have the `_expf' function. */ /* #undef _GLIBCXX_HAVE__EXPF */ /* Define to 1 if you have the `_expl' function. */ /* #undef _GLIBCXX_HAVE__EXPL */ /* Define to 1 if you have the `_fabsf' function. */ /* #undef _GLIBCXX_HAVE__FABSF */ /* Define to 1 if you have the `_fabsl' function. */ /* #undef _GLIBCXX_HAVE__FABSL */ /* Define to 1 if you have the `_finite' function. */ /* #undef _GLIBCXX_HAVE__FINITE */ /* Define to 1 if you have the `_finitef' function. */ /* #undef _GLIBCXX_HAVE__FINITEF */ /* Define to 1 if you have the `_finitel' function. */ /* #undef _GLIBCXX_HAVE__FINITEL */ /* Define to 1 if you have the `_floorf' function. */ /* #undef _GLIBCXX_HAVE__FLOORF */ /* Define to 1 if you have the `_floorl' function. */ /* #undef _GLIBCXX_HAVE__FLOORL */ /* Define to 1 if you have the `_fmodf' function. */ /* #undef _GLIBCXX_HAVE__FMODF */ /* Define to 1 if you have the `_fmodl' function. */ /* #undef _GLIBCXX_HAVE__FMODL */ /* Define to 1 if you have the `_fpclass' function. */ /* #undef _GLIBCXX_HAVE__FPCLASS */ /* Define to 1 if you have the `_frexpf' function. */ /* #undef _GLIBCXX_HAVE__FREXPF */ /* Define to 1 if you have the `_frexpl' function. */ /* #undef _GLIBCXX_HAVE__FREXPL */ /* Define to 1 if you have the `_hypot' function. */ /* #undef _GLIBCXX_HAVE__HYPOT */ /* Define to 1 if you have the `_hypotf' function. */ /* #undef _GLIBCXX_HAVE__HYPOTF */ /* Define to 1 if you have the `_hypotl' function. */ /* #undef _GLIBCXX_HAVE__HYPOTL */ /* Define to 1 if you have the `_isinf' function. */ /* #undef _GLIBCXX_HAVE__ISINF */ /* Define to 1 if you have the `_isinff' function. */ /* #undef _GLIBCXX_HAVE__ISINFF */ /* Define to 1 if you have the `_isinfl' function. */ /* #undef _GLIBCXX_HAVE__ISINFL */ /* Define to 1 if you have the `_isnan' function. */ /* #undef _GLIBCXX_HAVE__ISNAN */ /* Define to 1 if you have the `_isnanf' function. */ /* #undef _GLIBCXX_HAVE__ISNANF */ /* Define to 1 if you have the `_isnanl' function. */ /* #undef _GLIBCXX_HAVE__ISNANL */ /* Define to 1 if you have the `_ldexpf' function. */ /* #undef _GLIBCXX_HAVE__LDEXPF */ /* Define to 1 if you have the `_ldexpl' function. */ /* #undef _GLIBCXX_HAVE__LDEXPL */ /* Define to 1 if you have the `_log10f' function. */ /* #undef _GLIBCXX_HAVE__LOG10F */ /* Define to 1 if you have the `_log10l' function. */ /* #undef _GLIBCXX_HAVE__LOG10L */ /* Define to 1 if you have the `_logf' function. */ /* #undef _GLIBCXX_HAVE__LOGF */ /* Define to 1 if you have the `_logl' function. */ /* #undef _GLIBCXX_HAVE__LOGL */ /* Define to 1 if you have the `_modf' function. */ /* #undef _GLIBCXX_HAVE__MODF */ /* Define to 1 if you have the `_modff' function. */ /* #undef _GLIBCXX_HAVE__MODFF */ /* Define to 1 if you have the `_modfl' function. */ /* #undef _GLIBCXX_HAVE__MODFL */ /* Define to 1 if you have the `_powf' function. */ /* #undef _GLIBCXX_HAVE__POWF */ /* Define to 1 if you have the `_powl' function. */ /* #undef _GLIBCXX_HAVE__POWL */ /* Define to 1 if you have the `_qfpclass' function. */ /* #undef _GLIBCXX_HAVE__QFPCLASS */ /* Define to 1 if you have the `_sincos' function. */ /* #undef _GLIBCXX_HAVE__SINCOS */ /* Define to 1 if you have the `_sincosf' function. */ /* #undef _GLIBCXX_HAVE__SINCOSF */ /* Define to 1 if you have the `_sincosl' function. */ /* #undef _GLIBCXX_HAVE__SINCOSL */ /* Define to 1 if you have the `_sinf' function. */ /* #undef _GLIBCXX_HAVE__SINF */ /* Define to 1 if you have the `_sinhf' function. */ /* #undef _GLIBCXX_HAVE__SINHF */ /* Define to 1 if you have the `_sinhl' function. */ /* #undef _GLIBCXX_HAVE__SINHL */ /* Define to 1 if you have the `_sinl' function. */ /* #undef _GLIBCXX_HAVE__SINL */ /* Define to 1 if you have the `_sqrtf' function. */ /* #undef _GLIBCXX_HAVE__SQRTF */ /* Define to 1 if you have the `_sqrtl' function. */ /* #undef _GLIBCXX_HAVE__SQRTL */ /* Define to 1 if you have the `_tanf' function. */ /* #undef _GLIBCXX_HAVE__TANF */ /* Define to 1 if you have the `_tanhf' function. */ /* #undef _GLIBCXX_HAVE__TANHF */ /* Define to 1 if you have the `_tanhl' function. */ /* #undef _GLIBCXX_HAVE__TANHL */ /* Define to 1 if you have the `_tanl' function. */ /* #undef _GLIBCXX_HAVE__TANL */ /* Define to 1 if you have the `_wfopen' function. */ /* #undef _GLIBCXX_HAVE__WFOPEN */ /* Define to 1 if you have the `__cxa_thread_atexit' function. */ /* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT */ /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */ #define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1 /* Define as const if the declaration of iconv() needs const. */ #define _GLIBCXX_ICONV_CONST /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define _GLIBCXX_LT_OBJDIR ".libs/" /* Name of package */ /* #undef _GLIBCXX_PACKAGE */ /* Define to the address where bug reports for this package should be sent. */ #define _GLIBCXX_PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define _GLIBCXX_PACKAGE_NAME "package-unused" /* Define to the full name and version of this package. */ #define _GLIBCXX_PACKAGE_STRING "package-unused version-unused" /* Define to the one symbol short name of this package. */ #define _GLIBCXX_PACKAGE_TARNAME "libstdc++" /* Define to the home page for this package. */ #define _GLIBCXX_PACKAGE_URL "" /* Define to the version of this package. */ #define _GLIBCXX_PACKAGE__GLIBCXX_VERSION "version-unused" /* The size of `char', as computed by sizeof. */ /* #undef SIZEOF_CHAR */ /* The size of `int', as computed by sizeof. */ /* #undef SIZEOF_INT */ /* The size of `long', as computed by sizeof. */ /* #undef SIZEOF_LONG */ /* The size of `short', as computed by sizeof. */ /* #undef SIZEOF_SHORT */ /* The size of `void *', as computed by sizeof. */ /* #undef SIZEOF_VOID_P */ /* Define to 1 if you have the ANSI C header files. */ #define _GLIBCXX_STDC_HEADERS 1 /* Version number of package */ /* #undef _GLIBCXX_VERSION */ /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _GLIBCXX_DARWIN_USE_64_BIT_INODE # define _GLIBCXX_DARWIN_USE_64_BIT_INODE 1 #endif /* Number of bits in a file offset, on hosts where this is settable. */ #define _GLIBCXX_FILE_OFFSET_BITS 64 /* Define if C99 functions in <complex.h> should be used in <complex> for C++11. Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX11_USE_C99_COMPLEX 1 /* Define if C99 functions or macros in <math.h> should be imported in <cmath> in namespace std for C++11. */ #define _GLIBCXX11_USE_C99_MATH 1 /* Define if C99 functions or macros in <stdio.h> should be imported in <cstdio> in namespace std for C++11. */ #define _GLIBCXX11_USE_C99_STDIO 1 /* Define if C99 functions or macros in <stdlib.h> should be imported in <cstdlib> in namespace std for C++11. */ #define _GLIBCXX11_USE_C99_STDLIB 1 /* Define if C99 functions or macros in <wchar.h> should be imported in <cwchar> in namespace std for C++11. */ #define _GLIBCXX11_USE_C99_WCHAR 1 /* Define if C99 functions in <complex.h> should be used in <complex> for C++98. Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX98_USE_C99_COMPLEX 1 /* Define if C99 functions or macros in <math.h> should be imported in <cmath> in namespace std for C++98. */ #define _GLIBCXX98_USE_C99_MATH 1 /* Define if C99 functions or macros in <stdio.h> should be imported in <cstdio> in namespace std for C++98. */ #define _GLIBCXX98_USE_C99_STDIO 1 /* Define if C99 functions or macros in <stdlib.h> should be imported in <cstdlib> in namespace std for C++98. */ #define _GLIBCXX98_USE_C99_STDLIB 1 /* Define if C99 functions or macros in <wchar.h> should be imported in <cwchar> in namespace std for C++98. */ #define _GLIBCXX98_USE_C99_WCHAR 1 /* Define if the compiler supports C++11 atomics. */ #define _GLIBCXX_ATOMIC_BUILTINS 1 /* Define to use concept checking code from the boost libraries. */ /* #undef _GLIBCXX_CONCEPT_CHECKS */ /* Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, undefined for platform defaults */ #define _GLIBCXX_FULLY_DYNAMIC_STRING 0 /* Define if gthreads library is available. */ #define _GLIBCXX_HAS_GTHREADS 1 /* Define to 1 if a full hosted library is built, or 0 if freestanding. */ #define _GLIBCXX_HOSTED 1 /* Define if compatibility should be provided for alternative 128-bit long double formats. */ /* Define if compatibility should be provided for -mlong-double-64. */ /* Define to the letter to which size_t is mangled. */ #define _GLIBCXX_MANGLE_SIZE_T j /* Define if C99 llrint and llround functions are missing from <math.h>. */ /* #undef _GLIBCXX_NO_C99_ROUNDING_FUNCS */ /* Defined if no way to sleep is available. */ /* #undef _GLIBCXX_NO_SLEEP */ /* Define if ptrdiff_t is int. */ #define _GLIBCXX_PTRDIFF_T_IS_INT 1 /* Define if using setrlimit to set resource limits during "make check" */ #define _GLIBCXX_RES_LIMITS 1 /* Define if size_t is unsigned int. */ #define _GLIBCXX_SIZE_T_IS_UINT 1 /* Define to the value of the EOF integer constant. */ #define _GLIBCXX_STDIO_EOF -1 /* Define to the value of the SEEK_CUR integer constant. */ #define _GLIBCXX_STDIO_SEEK_CUR 1 /* Define to the value of the SEEK_END integer constant. */ #define _GLIBCXX_STDIO_SEEK_END 2 /* Define to use symbol versioning in the shared library. */ #define _GLIBCXX_SYMVER 1 /* Define to use darwin versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_DARWIN */ /* Define to use GNU versioning in the shared library. */ #define _GLIBCXX_SYMVER_GNU 1 /* Define to use GNU namespace versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */ /* Define to use Sun versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_SUN */ /* Define if C11 functions in <uchar.h> should be imported into namespace std in <cuchar>. */ #define _GLIBCXX_USE_C11_UCHAR_CXX11 1 /* Define if C99 functions or macros from <wchar.h>, <math.h>, <complex.h>, <stdio.h>, and <stdlib.h> can be used or exposed. */ #define _GLIBCXX_USE_C99 1 /* Define if C99 functions in <complex.h> should be used in <tr1/complex>. Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX_USE_C99_COMPLEX_TR1 1 /* Define if C99 functions in <ctype.h> should be imported in <tr1/cctype> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_CTYPE_TR1 1 /* Define if C99 functions in <fenv.h> should be imported in <tr1/cfenv> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_FENV_TR1 1 /* Define if C99 functions in <inttypes.h> should be imported in <tr1/cinttypes> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_INTTYPES_TR1 1 /* Define if wchar_t C99 functions in <inttypes.h> should be imported in <tr1/cinttypes> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 1 /* Define if C99 functions or macros in <math.h> should be imported in <tr1/cmath> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_MATH_TR1 1 /* Define if C99 types in <stdint.h> should be imported in <tr1/cstdint> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_STDINT_TR1 1 /* Defined if clock_gettime syscall has monotonic and realtime clock support. */ /* #undef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL */ /* Defined if clock_gettime has monotonic clock support. */ #define _GLIBCXX_USE_CLOCK_MONOTONIC 1 /* Defined if clock_gettime has realtime clock support. */ #define _GLIBCXX_USE_CLOCK_REALTIME 1 /* Define if ISO/IEC TR 24733 decimal floating point types are supported on this host. */ #define _GLIBCXX_USE_DECIMAL_FLOAT 1 /* Define if /dev/random and /dev/urandom are available for std::random_device. */ #define _GLIBCXX_USE_DEV_RANDOM 1 /* Define if fchmod is available in <sys/stat.h>. */ #define _GLIBCXX_USE_FCHMOD 1 /* Define if fchmodat is available in <sys/stat.h>. */ #define _GLIBCXX_USE_FCHMODAT 1 /* Defined if gettimeofday is available. */ #define _GLIBCXX_USE_GETTIMEOFDAY 1 /* Define if get_nprocs is available in <sys/sysinfo.h>. */ #define _GLIBCXX_USE_GET_NPROCS 1 /* Define if __int128 is supported on this host. */ /* #undef _GLIBCXX_USE_INT128 */ /* Define if LFS support is available. */ #define _GLIBCXX_USE_LFS 1 /* Define if code specialized for long long should be used. */ #define _GLIBCXX_USE_LONG_LONG 1 /* Define if lstat is available in <sys/stat.h>. */ #define _GLIBCXX_USE_LSTAT 1 /* Defined if nanosleep is available. */ #define _GLIBCXX_USE_NANOSLEEP 1 /* Define if NLS translations are to be used. */ #define _GLIBCXX_USE_NLS 1 /* Define if pthreads_num_processors_np is available in <pthread.h>. */ /* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */ /* Define if pthread_cond_clockwait is available in <pthread.h>. */ #define _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT 1 /* Define if pthread_mutex_clocklock is available in <pthread.h>. */ #define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK 1 /* Define if pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock are available in <pthread.h>. */ #define _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK 1 /* Define if POSIX read/write locks are available in <gthr.h>. */ #define _GLIBCXX_USE_PTHREAD_RWLOCK_T 1 /* Define if /dev/random and /dev/urandom are available for the random_device of TR1 (Chapter 5.1). */ #define _GLIBCXX_USE_RANDOM_TR1 1 /* Define if usable realpath is available in <stdlib.h>. */ #define _GLIBCXX_USE_REALPATH 1 /* Defined if sched_yield is available. */ #define _GLIBCXX_USE_SCHED_YIELD 1 /* Define if _SC_NPROCESSORS_ONLN is available in <unistd.h>. */ #define _GLIBCXX_USE_SC_NPROCESSORS_ONLN 1 /* Define if _SC_NPROC_ONLN is available in <unistd.h>. */ /* #undef _GLIBCXX_USE_SC_NPROC_ONLN */ /* Define if sendfile is available in <sys/sendfile.h>. */ #define _GLIBCXX_USE_SENDFILE 1 /* Define to restrict std::__basic_file<> to stdio APIs. */ /* #undef _GLIBCXX_USE_STDIO_PURE */ /* Define if struct stat has timespec members. */ #define _GLIBCXX_USE_ST_MTIM 1 /* Define if sysctl(), CTL_HW and HW_NCPU are available in <sys/sysctl.h>. */ /* #undef _GLIBCXX_USE_SYSCTL_HW_NCPU */ /* Define if obsolescent tmpnam is available in <stdio.h>. */ #define _GLIBCXX_USE_TMPNAM 1 /* Define if utime is available in <utime.h>. */ #define _GLIBCXX_USE_UTIME 1 /* Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and AT_FDCWD in <fcntl.h>. */ #define _GLIBCXX_USE_UTIMENSAT 1 /* Define if code specialized for wchar_t should be used. */ #define _GLIBCXX_USE_WCHAR_T 1 /* Define to 1 if a verbose library is built, or 0 otherwise. */ #define _GLIBCXX_VERBOSE 1 /* Defined if as can handle rdrand. */ #define _GLIBCXX_X86_RDRAND 1 /* Defined if as can handle rdseed. */ #define _GLIBCXX_X86_RDSEED 1 /* Define to 1 if mutex_timedlock is available. */ #define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 /* Define for large files, on AIX-style hosts. */ /* #undef _GLIBCXX_LARGE_FILES */ /* Define if all C++11 floating point overloads are available in <math.h>. */ #if __cplusplus >= 201103L /* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP */ #endif /* Define if all C++11 integral type overloads are available in <math.h>. */ #if __cplusplus >= 201103L /* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT */ #endif #if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF) # define _GLIBCXX_HAVE_ACOSF 1 # define acosf _acosf #endif #if defined (_GLIBCXX_HAVE__ACOSL) && ! defined (_GLIBCXX_HAVE_ACOSL) # define _GLIBCXX_HAVE_ACOSL 1 # define acosl _acosl #endif #if defined (_GLIBCXX_HAVE__ASINF) && ! defined (_GLIBCXX_HAVE_ASINF) # define _GLIBCXX_HAVE_ASINF 1 # define asinf _asinf #endif #if defined (_GLIBCXX_HAVE__ASINL) && ! defined (_GLIBCXX_HAVE_ASINL) # define _GLIBCXX_HAVE_ASINL 1 # define asinl _asinl #endif #if defined (_GLIBCXX_HAVE__ATAN2F) && ! defined (_GLIBCXX_HAVE_ATAN2F) # define _GLIBCXX_HAVE_ATAN2F 1 # define atan2f _atan2f #endif #if defined (_GLIBCXX_HAVE__ATAN2L) && ! defined (_GLIBCXX_HAVE_ATAN2L) # define _GLIBCXX_HAVE_ATAN2L 1 # define atan2l _atan2l #endif #if defined (_GLIBCXX_HAVE__ATANF) && ! defined (_GLIBCXX_HAVE_ATANF) # define _GLIBCXX_HAVE_ATANF 1 # define atanf _atanf #endif #if defined (_GLIBCXX_HAVE__ATANL) && ! defined (_GLIBCXX_HAVE_ATANL) # define _GLIBCXX_HAVE_ATANL 1 # define atanl _atanl #endif #if defined (_GLIBCXX_HAVE__CEILF) && ! defined (_GLIBCXX_HAVE_CEILF) # define _GLIBCXX_HAVE_CEILF 1 # define ceilf _ceilf #endif #if defined (_GLIBCXX_HAVE__CEILL) && ! defined (_GLIBCXX_HAVE_CEILL) # define _GLIBCXX_HAVE_CEILL 1 # define ceill _ceill #endif #if defined (_GLIBCXX_HAVE__COSF) && ! defined (_GLIBCXX_HAVE_COSF) # define _GLIBCXX_HAVE_COSF 1 # define cosf _cosf #endif #if defined (_GLIBCXX_HAVE__COSHF) && ! defined (_GLIBCXX_HAVE_COSHF) # define _GLIBCXX_HAVE_COSHF 1 # define coshf _coshf #endif #if defined (_GLIBCXX_HAVE__COSHL) && ! defined (_GLIBCXX_HAVE_COSHL) # define _GLIBCXX_HAVE_COSHL 1 # define coshl _coshl #endif #if defined (_GLIBCXX_HAVE__COSL) && ! defined (_GLIBCXX_HAVE_COSL) # define _GLIBCXX_HAVE_COSL 1 # define cosl _cosl #endif #if defined (_GLIBCXX_HAVE__EXPF) && ! defined (_GLIBCXX_HAVE_EXPF) # define _GLIBCXX_HAVE_EXPF 1 # define expf _expf #endif #if defined (_GLIBCXX_HAVE__EXPL) && ! defined (_GLIBCXX_HAVE_EXPL) # define _GLIBCXX_HAVE_EXPL 1 # define expl _expl #endif #if defined (_GLIBCXX_HAVE__FABSF) && ! defined (_GLIBCXX_HAVE_FABSF) # define _GLIBCXX_HAVE_FABSF 1 # define fabsf _fabsf #endif #if defined (_GLIBCXX_HAVE__FABSL) && ! defined (_GLIBCXX_HAVE_FABSL) # define _GLIBCXX_HAVE_FABSL 1 # define fabsl _fabsl #endif #if defined (_GLIBCXX_HAVE__FINITE) && ! defined (_GLIBCXX_HAVE_FINITE) # define _GLIBCXX_HAVE_FINITE 1 # define finite _finite #endif #if defined (_GLIBCXX_HAVE__FINITEF) && ! defined (_GLIBCXX_HAVE_FINITEF) # define _GLIBCXX_HAVE_FINITEF 1 # define finitef _finitef #endif #if defined (_GLIBCXX_HAVE__FINITEL) && ! defined (_GLIBCXX_HAVE_FINITEL) # define _GLIBCXX_HAVE_FINITEL 1 # define finitel _finitel #endif #if defined (_GLIBCXX_HAVE__FLOORF) && ! defined (_GLIBCXX_HAVE_FLOORF) # define _GLIBCXX_HAVE_FLOORF 1 # define floorf _floorf #endif #if defined (_GLIBCXX_HAVE__FLOORL) && ! defined (_GLIBCXX_HAVE_FLOORL) # define _GLIBCXX_HAVE_FLOORL 1 # define floorl _floorl #endif #if defined (_GLIBCXX_HAVE__FMODF) && ! defined (_GLIBCXX_HAVE_FMODF) # define _GLIBCXX_HAVE_FMODF 1 # define fmodf _fmodf #endif #if defined (_GLIBCXX_HAVE__FMODL) && ! defined (_GLIBCXX_HAVE_FMODL) # define _GLIBCXX_HAVE_FMODL 1 # define fmodl _fmodl #endif #if defined (_GLIBCXX_HAVE__FPCLASS) && ! defined (_GLIBCXX_HAVE_FPCLASS) # define _GLIBCXX_HAVE_FPCLASS 1 # define fpclass _fpclass #endif #if defined (_GLIBCXX_HAVE__FREXPF) && ! defined (_GLIBCXX_HAVE_FREXPF) # define _GLIBCXX_HAVE_FREXPF 1 # define frexpf _frexpf #endif #if defined (_GLIBCXX_HAVE__FREXPL) && ! defined (_GLIBCXX_HAVE_FREXPL) # define _GLIBCXX_HAVE_FREXPL 1 # define frexpl _frexpl #endif #if defined (_GLIBCXX_HAVE__HYPOT) && ! defined (_GLIBCXX_HAVE_HYPOT) # define _GLIBCXX_HAVE_HYPOT 1 # define hypot _hypot #endif #if defined (_GLIBCXX_HAVE__HYPOTF) && ! defined (_GLIBCXX_HAVE_HYPOTF) # define _GLIBCXX_HAVE_HYPOTF 1 # define hypotf _hypotf #endif #if defined (_GLIBCXX_HAVE__HYPOTL) && ! defined (_GLIBCXX_HAVE_HYPOTL) # define _GLIBCXX_HAVE_HYPOTL 1 # define hypotl _hypotl #endif #if defined (_GLIBCXX_HAVE__ISINF) && ! defined (_GLIBCXX_HAVE_ISINF) # define _GLIBCXX_HAVE_ISINF 1 # define isinf _isinf #endif #if defined (_GLIBCXX_HAVE__ISINFF) && ! defined (_GLIBCXX_HAVE_ISINFF) # define _GLIBCXX_HAVE_ISINFF 1 # define isinff _isinff #endif #if defined (_GLIBCXX_HAVE__ISINFL) && ! defined (_GLIBCXX_HAVE_ISINFL) # define _GLIBCXX_HAVE_ISINFL 1 # define isinfl _isinfl #endif #if defined (_GLIBCXX_HAVE__ISNAN) && ! defined (_GLIBCXX_HAVE_ISNAN) # define _GLIBCXX_HAVE_ISNAN 1 # define isnan _isnan #endif #if defined (_GLIBCXX_HAVE__ISNANF) && ! defined (_GLIBCXX_HAVE_ISNANF) # define _GLIBCXX_HAVE_ISNANF 1 # define isnanf _isnanf #endif #if defined (_GLIBCXX_HAVE__ISNANL) && ! defined (_GLIBCXX_HAVE_ISNANL) # define _GLIBCXX_HAVE_ISNANL 1 # define isnanl _isnanl #endif #if defined (_GLIBCXX_HAVE__LDEXPF) && ! defined (_GLIBCXX_HAVE_LDEXPF) # define _GLIBCXX_HAVE_LDEXPF 1 # define ldexpf _ldexpf #endif #if defined (_GLIBCXX_HAVE__LDEXPL) && ! defined (_GLIBCXX_HAVE_LDEXPL) # define _GLIBCXX_HAVE_LDEXPL 1 # define ldexpl _ldexpl #endif #if defined (_GLIBCXX_HAVE__LOG10F) && ! defined (_GLIBCXX_HAVE_LOG10F) # define _GLIBCXX_HAVE_LOG10F 1 # define log10f _log10f #endif #if defined (_GLIBCXX_HAVE__LOG10L) && ! defined (_GLIBCXX_HAVE_LOG10L) # define _GLIBCXX_HAVE_LOG10L 1 # define log10l _log10l #endif #if defined (_GLIBCXX_HAVE__LOGF) && ! defined (_GLIBCXX_HAVE_LOGF) # define _GLIBCXX_HAVE_LOGF 1 # define logf _logf #endif #if defined (_GLIBCXX_HAVE__LOGL) && ! defined (_GLIBCXX_HAVE_LOGL) # define _GLIBCXX_HAVE_LOGL 1 # define logl _logl #endif #if defined (_GLIBCXX_HAVE__MODF) && ! defined (_GLIBCXX_HAVE_MODF) # define _GLIBCXX_HAVE_MODF 1 # define modf _modf #endif #if defined (_GLIBCXX_HAVE__MODFF) && ! defined (_GLIBCXX_HAVE_MODFF) # define _GLIBCXX_HAVE_MODFF 1 # define modff _modff #endif #if defined (_GLIBCXX_HAVE__MODFL) && ! defined (_GLIBCXX_HAVE_MODFL) # define _GLIBCXX_HAVE_MODFL 1 # define modfl _modfl #endif #if defined (_GLIBCXX_HAVE__POWF) && ! defined (_GLIBCXX_HAVE_POWF) # define _GLIBCXX_HAVE_POWF 1 # define powf _powf #endif #if defined (_GLIBCXX_HAVE__POWL) && ! defined (_GLIBCXX_HAVE_POWL) # define _GLIBCXX_HAVE_POWL 1 # define powl _powl #endif #if defined (_GLIBCXX_HAVE__QFPCLASS) && ! defined (_GLIBCXX_HAVE_QFPCLASS) # define _GLIBCXX_HAVE_QFPCLASS 1 # define qfpclass _qfpclass #endif #if defined (_GLIBCXX_HAVE__SINCOS) && ! defined (_GLIBCXX_HAVE_SINCOS) # define _GLIBCXX_HAVE_SINCOS 1 # define sincos _sincos #endif #if defined (_GLIBCXX_HAVE__SINCOSF) && ! defined (_GLIBCXX_HAVE_SINCOSF) # define _GLIBCXX_HAVE_SINCOSF 1 # define sincosf _sincosf #endif #if defined (_GLIBCXX_HAVE__SINCOSL) && ! defined (_GLIBCXX_HAVE_SINCOSL) # define _GLIBCXX_HAVE_SINCOSL 1 # define sincosl _sincosl #endif #if defined (_GLIBCXX_HAVE__SINF) && ! defined (_GLIBCXX_HAVE_SINF) # define _GLIBCXX_HAVE_SINF 1 # define sinf _sinf #endif #if defined (_GLIBCXX_HAVE__SINHF) && ! defined (_GLIBCXX_HAVE_SINHF) # define _GLIBCXX_HAVE_SINHF 1 # define sinhf _sinhf #endif #if defined (_GLIBCXX_HAVE__SINHL) && ! defined (_GLIBCXX_HAVE_SINHL) # define _GLIBCXX_HAVE_SINHL 1 # define sinhl _sinhl #endif #if defined (_GLIBCXX_HAVE__SINL) && ! defined (_GLIBCXX_HAVE_SINL) # define _GLIBCXX_HAVE_SINL 1 # define sinl _sinl #endif #if defined (_GLIBCXX_HAVE__SQRTF) && ! defined (_GLIBCXX_HAVE_SQRTF) # define _GLIBCXX_HAVE_SQRTF 1 # define sqrtf _sqrtf #endif #if defined (_GLIBCXX_HAVE__SQRTL) && ! defined (_GLIBCXX_HAVE_SQRTL) # define _GLIBCXX_HAVE_SQRTL 1 # define sqrtl _sqrtl #endif #if defined (_GLIBCXX_HAVE__STRTOF) && ! defined (_GLIBCXX_HAVE_STRTOF) # define _GLIBCXX_HAVE_STRTOF 1 # define strtof _strtof #endif #if defined (_GLIBCXX_HAVE__STRTOLD) && ! defined (_GLIBCXX_HAVE_STRTOLD) # define _GLIBCXX_HAVE_STRTOLD 1 # define strtold _strtold #endif #if defined (_GLIBCXX_HAVE__TANF) && ! defined (_GLIBCXX_HAVE_TANF) # define _GLIBCXX_HAVE_TANF 1 # define tanf _tanf #endif #if defined (_GLIBCXX_HAVE__TANHF) && ! defined (_GLIBCXX_HAVE_TANHF) # define _GLIBCXX_HAVE_TANHF 1 # define tanhf _tanhf #endif #if defined (_GLIBCXX_HAVE__TANHL) && ! defined (_GLIBCXX_HAVE_TANHL) # define _GLIBCXX_HAVE_TANHL 1 # define tanhl _tanhl #endif #if defined (_GLIBCXX_HAVE__TANL) && ! defined (_GLIBCXX_HAVE_TANL) # define _GLIBCXX_HAVE_TANL 1 # define tanl _tanl #endif #endif // _GLIBCXX_CXX_CONFIG_H #else // Predefined symbols and macros -*- C++ -*- // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/c++config.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{version} */ #ifndef _GLIBCXX_CXX_CONFIG_H #define _GLIBCXX_CXX_CONFIG_H 1 // The major release number for the GCC release the C++ library belongs to. #define _GLIBCXX_RELEASE 11 // The datestamp of the C++ library in compressed ISO date format. #define __GLIBCXX__ 20240719 // Macros for various attributes. // _GLIBCXX_PURE // _GLIBCXX_CONST // _GLIBCXX_NORETURN // _GLIBCXX_NOTHROW // _GLIBCXX_VISIBILITY #ifndef _GLIBCXX_PURE # define _GLIBCXX_PURE __attribute__ ((__pure__)) #endif #ifndef _GLIBCXX_CONST # define _GLIBCXX_CONST __attribute__ ((__const__)) #endif #ifndef _GLIBCXX_NORETURN # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__)) #endif // See below for C++ #ifndef _GLIBCXX_NOTHROW # ifndef __cplusplus # define _GLIBCXX_NOTHROW __attribute__((__nothrow__)) # endif #endif // Macros for visibility attributes. // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY // _GLIBCXX_VISIBILITY # define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 1 #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) #else // If this is not supplied by the OS-specific or CPU-specific // headers included below, it will be defined to an empty default. # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V) #endif // Macros for deprecated attributes. // _GLIBCXX_USE_DEPRECATED // _GLIBCXX_DEPRECATED // _GLIBCXX_DEPRECATED_SUGGEST( string-literal ) // _GLIBCXX11_DEPRECATED // _GLIBCXX11_DEPRECATED_SUGGEST( string-literal ) // _GLIBCXX17_DEPRECATED // _GLIBCXX17_DEPRECATED_SUGGEST( string-literal ) // _GLIBCXX20_DEPRECATED( string-literal ) // _GLIBCXX20_DEPRECATED_SUGGEST( string-literal ) #ifndef _GLIBCXX_USE_DEPRECATED # define _GLIBCXX_USE_DEPRECATED 1 #endif #if defined(__DEPRECATED) # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__)) # define _GLIBCXX_DEPRECATED_SUGGEST(ALT) \ __attribute__ ((__deprecated__ ("use '" ALT "' instead"))) #else # define _GLIBCXX_DEPRECATED # define _GLIBCXX_DEPRECATED_SUGGEST(ALT) #endif #if defined(__DEPRECATED) && (__cplusplus >= 201103L) # define _GLIBCXX11_DEPRECATED _GLIBCXX_DEPRECATED # define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) #else # define _GLIBCXX11_DEPRECATED # define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) #endif #if defined(__DEPRECATED) && (__cplusplus >= 201703L) # define _GLIBCXX17_DEPRECATED [[__deprecated__]] # define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) #else # define _GLIBCXX17_DEPRECATED # define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) #endif #if defined(__DEPRECATED) && (__cplusplus > 201703L) # define _GLIBCXX20_DEPRECATED(MSG) [[deprecated(MSG)]] # define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) #else # define _GLIBCXX20_DEPRECATED(MSG) # define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) #endif // Macros for ABI tag attributes. #ifndef _GLIBCXX_ABI_TAG_CXX11 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11"))) #endif // Macro to warn about unused results. #if __cplusplus >= 201703L # define _GLIBCXX_NODISCARD [[__nodiscard__]] #else # define _GLIBCXX_NODISCARD #endif #if __cplusplus // Macro for constexpr, to support in mixed 03/0x mode. #ifndef _GLIBCXX_CONSTEXPR # if __cplusplus >= 201103L # define _GLIBCXX_CONSTEXPR constexpr # define _GLIBCXX_USE_CONSTEXPR constexpr # else # define _GLIBCXX_CONSTEXPR # define _GLIBCXX_USE_CONSTEXPR const # endif #endif #ifndef _GLIBCXX14_CONSTEXPR # if __cplusplus >= 201402L # define _GLIBCXX14_CONSTEXPR constexpr # else # define _GLIBCXX14_CONSTEXPR # endif #endif #ifndef _GLIBCXX17_CONSTEXPR # if __cplusplus >= 201703L # define _GLIBCXX17_CONSTEXPR constexpr # else # define _GLIBCXX17_CONSTEXPR # endif #endif #ifndef _GLIBCXX20_CONSTEXPR # if __cplusplus > 201703L # define _GLIBCXX20_CONSTEXPR constexpr # else # define _GLIBCXX20_CONSTEXPR # endif #endif #ifndef _GLIBCXX17_INLINE # if __cplusplus >= 201703L # define _GLIBCXX17_INLINE inline # else # define _GLIBCXX17_INLINE # endif #endif // Macro for noexcept, to support in mixed 03/0x mode. #ifndef _GLIBCXX_NOEXCEPT # if __cplusplus >= 201103L # define _GLIBCXX_NOEXCEPT noexcept # define _GLIBCXX_NOEXCEPT_IF(...) noexcept(__VA_ARGS__) # define _GLIBCXX_USE_NOEXCEPT noexcept # define _GLIBCXX_THROW(_EXC) # else # define _GLIBCXX_NOEXCEPT # define _GLIBCXX_NOEXCEPT_IF(...) # define _GLIBCXX_USE_NOEXCEPT throw() # define _GLIBCXX_THROW(_EXC) throw(_EXC) # endif #endif #ifndef _GLIBCXX_NOTHROW # define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT #endif #ifndef _GLIBCXX_THROW_OR_ABORT # if __cpp_exceptions # define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC)) # else # define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort()) # endif #endif #if __cpp_noexcept_function_type #define _GLIBCXX_NOEXCEPT_PARM , bool _NE #define _GLIBCXX_NOEXCEPT_QUAL noexcept (_NE) #else #define _GLIBCXX_NOEXCEPT_PARM #define _GLIBCXX_NOEXCEPT_QUAL #endif // Macro for extern template, ie controlling template linkage via use // of extern keyword on template declaration. As documented in the g++ // manual, it inhibits all implicit instantiations and is used // throughout the library to avoid multiple weak definitions for // required types that are already explicitly instantiated in the // library binary. This substantially reduces the binary size of // resulting executables. // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern // templates only in basic_string, thus activating its debug-mode // checks even at -O0. # define _GLIBCXX_EXTERN_TEMPLATE 1 /* Outline of libstdc++ namespaces. namespace std { namespace __debug { } namespace __parallel { } namespace __cxx1998 { } namespace __detail { namespace __variant { } // C++17 } namespace rel_ops { } namespace tr1 { namespace placeholders { } namespace regex_constants { } namespace __detail { } } namespace tr2 { } namespace decimal { } namespace chrono { } // C++11 namespace placeholders { } // C++11 namespace regex_constants { } // C++11 namespace this_thread { } // C++11 inline namespace literals { // C++14 inline namespace chrono_literals { } // C++14 inline namespace complex_literals { } // C++14 inline namespace string_literals { } // C++14 inline namespace string_view_literals { } // C++17 } } namespace abi { } namespace __gnu_cxx { namespace __detail { } } For full details see: http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html */ namespace std { typedef __SIZE_TYPE__ size_t; typedef __PTRDIFF_TYPE__ ptrdiff_t; #if __cplusplus >= 201103L typedef decltype(nullptr) nullptr_t; #endif } # define _GLIBCXX_USE_DUAL_ABI 1 #if ! _GLIBCXX_USE_DUAL_ABI // Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI # undef _GLIBCXX_USE_CXX11_ABI #endif #ifndef _GLIBCXX_USE_CXX11_ABI # define _GLIBCXX_USE_CXX11_ABI 1 #endif #if _GLIBCXX_USE_CXX11_ABI namespace std { inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } } namespace __gnu_cxx { inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } } # define _GLIBCXX_NAMESPACE_CXX11 __cxx11:: # define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 { # define _GLIBCXX_END_NAMESPACE_CXX11 } # define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11 #else # define _GLIBCXX_NAMESPACE_CXX11 # define _GLIBCXX_BEGIN_NAMESPACE_CXX11 # define _GLIBCXX_END_NAMESPACE_CXX11 # define _GLIBCXX_DEFAULT_ABI_TAG #endif // Defined if inline namespaces are used for versioning. # define _GLIBCXX_INLINE_VERSION 0 // Inline namespace for symbol versioning. #if _GLIBCXX_INLINE_VERSION # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 { # define _GLIBCXX_END_NAMESPACE_VERSION } namespace std { inline _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201402L inline namespace literals { inline namespace chrono_literals { } inline namespace complex_literals { } inline namespace string_literals { } #if __cplusplus > 201402L inline namespace string_view_literals { } #endif // C++17 } #endif // C++14 _GLIBCXX_END_NAMESPACE_VERSION } namespace __gnu_cxx { inline _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } #else # define _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_VERSION #endif // Inline namespaces for special modes: debug, parallel. #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) namespace std { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Non-inline namespace for components replaced by alternates in active mode. namespace __cxx1998 { # if _GLIBCXX_USE_CXX11_ABI inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } # endif } _GLIBCXX_END_NAMESPACE_VERSION // Inline namespace for debug mode. # ifdef _GLIBCXX_DEBUG inline namespace __debug { } # endif // Inline namespaces for parallel mode. # ifdef _GLIBCXX_PARALLEL inline namespace __parallel { } # endif } // Check for invalid usage and unsupported mixed-mode use. # if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL) # error illegal use of multiple inlined namespaces # endif // Check for invalid use due to lack for weak symbols. # if __NO_INLINE__ && !__GXX_WEAK__ # warning currently using inlined namespace mode which may fail \ without inlining due to lack of weak symbols # endif #endif // Macros for namespace scope. Either namespace std:: or the name // of some nested namespace within it corresponding to the active mode. // _GLIBCXX_STD_A // _GLIBCXX_STD_C // // Macros for opening/closing conditional namespaces. // _GLIBCXX_BEGIN_NAMESPACE_ALGO // _GLIBCXX_END_NAMESPACE_ALGO // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_END_NAMESPACE_CONTAINER #if defined(_GLIBCXX_DEBUG) # define _GLIBCXX_STD_C __cxx1998 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \ namespace _GLIBCXX_STD_C { # define _GLIBCXX_END_NAMESPACE_CONTAINER } #else # define _GLIBCXX_STD_C std # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER # define _GLIBCXX_END_NAMESPACE_CONTAINER #endif #ifdef _GLIBCXX_PARALLEL # define _GLIBCXX_STD_A __cxx1998 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO \ namespace _GLIBCXX_STD_A { # define _GLIBCXX_END_NAMESPACE_ALGO } #else # define _GLIBCXX_STD_A std # define _GLIBCXX_BEGIN_NAMESPACE_ALGO # define _GLIBCXX_END_NAMESPACE_ALGO #endif // GLIBCXX_ABI Deprecated // Define if compatibility should be provided for -mlong-double-64. #undef _GLIBCXX_LONG_DOUBLE_COMPAT // Define if compatibility should be provided for alternative 128-bit long // double formats. Not possible for Clang until __ibm128 is supported. #ifndef __clang__ #undef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT #endif // Inline namespaces for long double 128 modes. #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ && defined __LONG_DOUBLE_IEEE128__ namespace std { // Namespaces for 128-bit IEEE long double format on 64-bit POWER LE. inline namespace __gnu_cxx_ieee128 { } inline namespace __gnu_cxx11_ieee128 { } } # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ieee128:: # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ieee128 { # define _GLIBCXX_END_NAMESPACE_LDBL } # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 __gnu_cxx11_ieee128:: # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 namespace __gnu_cxx11_ieee128 { # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 } #else // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ namespace std { inline namespace __gnu_cxx_ldbl128 { } } # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128:: # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 { # define _GLIBCXX_END_NAMESPACE_LDBL } #else # define _GLIBCXX_NAMESPACE_LDBL # define _GLIBCXX_BEGIN_NAMESPACE_LDBL # define _GLIBCXX_END_NAMESPACE_LDBL #endif #if _GLIBCXX_USE_CXX11_ABI # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_CXX11 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_CXX11 # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_CXX11 #else # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_LDBL # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_LDBL # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_LDBL #endif #endif // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 // Debug Mode implies checking assertions. #if defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_ASSERTIONS) # define _GLIBCXX_ASSERTIONS 1 #endif // Disable std::string explicit instantiation declarations in order to assert. #ifdef _GLIBCXX_ASSERTIONS # undef _GLIBCXX_EXTERN_TEMPLATE # define _GLIBCXX_EXTERN_TEMPLATE -1 #endif #if __has_builtin(__builtin_is_constant_evaluated) # define __glibcxx_constexpr_assert(cond) \ if (__builtin_is_constant_evaluated() && !bool(cond)) \ __builtin_unreachable() /* precondition violation detected! */ #else # define __glibcxx_constexpr_assert(unevaluated) #endif // Assert. #if defined(_GLIBCXX_ASSERTIONS) \ || defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PARALLEL_ASSERTIONS) namespace std { // Avoid the use of assert, because we're trying to keep the <cassert> // include out of the mix. extern "C++" _GLIBCXX_NORETURN inline void __replacement_assert(const char* __file, int __line, const char* __function, const char* __condition) { __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line, __function, __condition); __builtin_abort(); } } #define __glibcxx_assert_impl(_Condition) \ if (__builtin_expect(!bool(_Condition), false)) \ { \ __glibcxx_constexpr_assert(_Condition); \ std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ #_Condition); \ } #endif #if defined(_GLIBCXX_ASSERTIONS) # define __glibcxx_assert(cond) \ do { __glibcxx_assert_impl(cond); } while (false) #else # define __glibcxx_assert(cond) \ do { __glibcxx_constexpr_assert(cond); } while (false) #endif // Macros for race detectors. // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain // atomic (lock-free) synchronization to race detectors: // the race detector will infer a happens-before arc from the former to the // latter when they share the same argument pointer. // // The most frequent use case for these macros (and the only case in the // current implementation of the library) is atomic reference counting: // void _M_remove_reference() // { // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0) // { // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); // _M_destroy(__a); // } // } // The annotations in this example tell the race detector that all memory // accesses occurred when the refcount was positive do not race with // memory accesses which occurred after the refcount became zero. #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) #endif #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) #endif // Macros for C linkage: define extern "C" linkage only when using C++. # define _GLIBCXX_BEGIN_EXTERN_C extern "C" { # define _GLIBCXX_END_EXTERN_C } # define _GLIBCXX_USE_ALLOCATOR_NEW 1 #ifdef __SIZEOF_INT128__ #if ! defined __GLIBCXX_TYPE_INT_N_0 && ! defined __STRICT_ANSI__ // If __int128 is supported, we expect __GLIBCXX_TYPE_INT_N_0 to be defined // unless the compiler is in strict mode. If it's not defined and the strict // macro is not defined, something is wrong. #warning "__STRICT_ANSI__ seems to have been undefined; this is not supported" #endif #endif #else // !__cplusplus # define _GLIBCXX_BEGIN_EXTERN_C # define _GLIBCXX_END_EXTERN_C #endif // First includes. // Pick up any OS-specific definitions. #include <bits/os_defines.h> // Pick up any CPU-specific definitions. #include <bits/cpu_defines.h> // If platform uses neither visibility nor psuedo-visibility, // specify empty default for namespace annotation macros. #ifndef _GLIBCXX_PSEUDO_VISIBILITY # define _GLIBCXX_PSEUDO_VISIBILITY(V) #endif // Certain function definitions that are meant to be overridable from // user code are decorated with this macro. For some targets, this // macro causes these definitions to be weak. #ifndef _GLIBCXX_WEAK_DEFINITION # define _GLIBCXX_WEAK_DEFINITION #endif // By default, we assume that __GXX_WEAK__ also means that there is support // for declaring functions as weak while not defining such functions. This // allows for referring to functions provided by other libraries (e.g., // libitm) without depending on them if the respective features are not used. #ifndef _GLIBCXX_USE_WEAK_REF # define _GLIBCXX_USE_WEAK_REF __GXX_WEAK__ #endif // Conditionally enable annotations for the Transactional Memory TS on C++11. // Most of the following conditions are due to limitations in the current // implementation. #if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI \ && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201500L \ && !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF \ && _GLIBCXX_USE_ALLOCATOR_NEW #define _GLIBCXX_TXN_SAFE transaction_safe #define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic #else #define _GLIBCXX_TXN_SAFE #define _GLIBCXX_TXN_SAFE_DYN #endif #if __cplusplus > 201402L // In C++17 mathematical special functions are in namespace std. # define _GLIBCXX_USE_STD_SPEC_FUNCS 1 #elif __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0 // For C++11 and C++14 they are in namespace std when requested. # define _GLIBCXX_USE_STD_SPEC_FUNCS 1 #endif // The remainder of the prewritten config is automatic; all the // user hooks are listed above. // Create a boolean flag to be used to determine if --fast-math is set. #ifdef __FAST_MATH__ # define _GLIBCXX_FAST_MATH 1 #else # define _GLIBCXX_FAST_MATH 0 #endif // This marks string literals in header files to be extracted for eventual // translation. It is primarily used for messages in thrown exceptions; see // src/functexcept.cc. We use __N because the more traditional _N is used // for something else under certain OSes (see BADNAMES). #define __N(msgid) (msgid) // For example, <windows.h> is known to #define min and max as macros... #undef min #undef max // N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally // so they should be tested with #if not with #ifdef. #if __cplusplus >= 201103L # ifndef _GLIBCXX_USE_C99_MATH # define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH # endif # ifndef _GLIBCXX_USE_C99_COMPLEX # define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX # endif # ifndef _GLIBCXX_USE_C99_STDIO # define _GLIBCXX_USE_C99_STDIO _GLIBCXX11_USE_C99_STDIO # endif # ifndef _GLIBCXX_USE_C99_STDLIB # define _GLIBCXX_USE_C99_STDLIB _GLIBCXX11_USE_C99_STDLIB # endif # ifndef _GLIBCXX_USE_C99_WCHAR # define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR # endif #else # ifndef _GLIBCXX_USE_C99_MATH # define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH # endif # ifndef _GLIBCXX_USE_C99_COMPLEX # define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX # endif # ifndef _GLIBCXX_USE_C99_STDIO # define _GLIBCXX_USE_C99_STDIO _GLIBCXX98_USE_C99_STDIO # endif # ifndef _GLIBCXX_USE_C99_STDLIB # define _GLIBCXX_USE_C99_STDLIB _GLIBCXX98_USE_C99_STDLIB # endif # ifndef _GLIBCXX_USE_C99_WCHAR # define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR # endif #endif // Unless explicitly specified, enable char8_t extensions only if the core // language char8_t feature macro is defined. #ifndef _GLIBCXX_USE_CHAR8_T # ifdef __cpp_char8_t # define _GLIBCXX_USE_CHAR8_T 1 # endif #endif #ifdef _GLIBCXX_USE_CHAR8_T # define __cpp_lib_char8_t 201907L #endif /* Define if __float128 is supported on this host. */ #if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) /* For powerpc64 don't use __float128 when it's the same type as long double. */ # if !(defined(_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT) && defined(__LONG_DOUBLE_IEEE128__)) # define _GLIBCXX_USE_FLOAT128 1 # endif #endif // Define if float has the IEEE binary32 format. #if __FLT_MANT_DIG__ == 24 \ && __FLT_MIN_EXP__ == -125 \ && __FLT_MAX_EXP__ == 128 # define _GLIBCXX_FLOAT_IS_IEEE_BINARY32 1 #endif // Define if double has the IEEE binary64 format. #if __DBL_MANT_DIG__ == 53 \ && __DBL_MIN_EXP__ == -1021 \ && __DBL_MAX_EXP__ == 1024 # define _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 1 #endif #ifdef __has_builtin # ifdef __is_identifier // Intel and older Clang require !__is_identifier for some built-ins: # define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) || ! __is_identifier(B) # else # define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) # endif #endif #if _GLIBCXX_HAS_BUILTIN(__has_unique_object_representations) # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 #endif #if _GLIBCXX_HAS_BUILTIN(__is_aggregate) # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 #endif #if _GLIBCXX_HAS_BUILTIN(__builtin_is_constant_evaluated) # define _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 1 #endif #if _GLIBCXX_HAS_BUILTIN(__is_same) # define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1 #endif #if _GLIBCXX_HAS_BUILTIN(__builtin_launder) # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 #endif #undef _GLIBCXX_HAS_BUILTIN // PSTL configuration #if __cplusplus >= 201703L // This header is not installed for freestanding: #if __has_include(<pstl/pstl_config.h>) // Preserved here so we have some idea which version of upstream we've pulled in // #define PSTL_VERSION 9000 // For now this defaults to being based on the presence of Thread Building Blocks # ifndef _GLIBCXX_USE_TBB_PAR_BACKEND # define _GLIBCXX_USE_TBB_PAR_BACKEND __has_include(<tbb/tbb.h>) # endif // This section will need some rework when a new (default) backend type is added # if _GLIBCXX_USE_TBB_PAR_BACKEND # define _PSTL_PAR_BACKEND_TBB # else # define _PSTL_PAR_BACKEND_SERIAL # endif # define _PSTL_ASSERT(_Condition) __glibcxx_assert(_Condition) # define _PSTL_ASSERT_MSG(_Condition, _Message) __glibcxx_assert(_Condition) #include <pstl/pstl_config.h> #endif // __has_include #endif // C++17 // End of prewritten config; the settings discovered at configure time follow. /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `acosf' function. */ #define _GLIBCXX_HAVE_ACOSF 1 /* Define to 1 if you have the `acosl' function. */ #define _GLIBCXX_HAVE_ACOSL 1 /* Define to 1 if you have the `aligned_alloc' function. */ #define _GLIBCXX_HAVE_ALIGNED_ALLOC 1 /* Define to 1 if you have the <arpa/inet.h> header file. */ #define _GLIBCXX_HAVE_ARPA_INET_H 1 /* Define to 1 if you have the `asinf' function. */ #define _GLIBCXX_HAVE_ASINF 1 /* Define to 1 if you have the `asinl' function. */ #define _GLIBCXX_HAVE_ASINL 1 /* Define to 1 if the target assembler supports .symver directive. */ #define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1 /* Define to 1 if you have the `atan2f' function. */ #define _GLIBCXX_HAVE_ATAN2F 1 /* Define to 1 if you have the `atan2l' function. */ #define _GLIBCXX_HAVE_ATAN2L 1 /* Define to 1 if you have the `atanf' function. */ #define _GLIBCXX_HAVE_ATANF 1 /* Define to 1 if you have the `atanl' function. */ #define _GLIBCXX_HAVE_ATANL 1 /* Defined if shared_ptr reference counting should use atomic operations. */ #define _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY 1 /* Define to 1 if you have the `at_quick_exit' function. */ #define _GLIBCXX_HAVE_AT_QUICK_EXIT 1 /* Define to 1 if the target assembler supports thread-local storage. */ /* #undef _GLIBCXX_HAVE_CC_TLS */ /* Define to 1 if you have the `ceilf' function. */ #define _GLIBCXX_HAVE_CEILF 1 /* Define to 1 if you have the `ceill' function. */ #define _GLIBCXX_HAVE_CEILL 1 /* Define to 1 if you have the <complex.h> header file. */ #define _GLIBCXX_HAVE_COMPLEX_H 1 /* Define to 1 if you have the `cosf' function. */ #define _GLIBCXX_HAVE_COSF 1 /* Define to 1 if you have the `coshf' function. */ #define _GLIBCXX_HAVE_COSHF 1 /* Define to 1 if you have the `coshl' function. */ #define _GLIBCXX_HAVE_COSHL 1 /* Define to 1 if you have the `cosl' function. */ #define _GLIBCXX_HAVE_COSL 1 /* Define to 1 if you have the <dirent.h> header file. */ #define _GLIBCXX_HAVE_DIRENT_H 1 /* Define if dirfd is available in <dirent.h>. */ #define _GLIBCXX_HAVE_DIRFD 1 /* Define to 1 if you have the <dlfcn.h> header file. */ #define _GLIBCXX_HAVE_DLFCN_H 1 /* Define to 1 if you have the <endian.h> header file. */ #define _GLIBCXX_HAVE_ENDIAN_H 1 /* Define to 1 if GCC 4.6 supported std::exception_ptr for the target */ #define _GLIBCXX_HAVE_EXCEPTION_PTR_SINCE_GCC46 1 /* Define to 1 if you have the <execinfo.h> header file. */ #define _GLIBCXX_HAVE_EXECINFO_H 1 /* Define to 1 if you have the `expf' function. */ #define _GLIBCXX_HAVE_EXPF 1 /* Define to 1 if you have the `expl' function. */ #define _GLIBCXX_HAVE_EXPL 1 /* Define to 1 if you have the `fabsf' function. */ #define _GLIBCXX_HAVE_FABSF 1 /* Define to 1 if you have the `fabsl' function. */ #define _GLIBCXX_HAVE_FABSL 1 /* Define to 1 if you have the <fcntl.h> header file. */ #define _GLIBCXX_HAVE_FCNTL_H 1 /* Define if fdopendir is available in <dirent.h>. */ #define _GLIBCXX_HAVE_FDOPENDIR 1 /* Define to 1 if you have the <fenv.h> header file. */ #define _GLIBCXX_HAVE_FENV_H 1 /* Define to 1 if you have the `finite' function. */ #define _GLIBCXX_HAVE_FINITE 1 /* Define to 1 if you have the `finitef' function. */ #define _GLIBCXX_HAVE_FINITEF 1 /* Define to 1 if you have the `finitel' function. */ #define _GLIBCXX_HAVE_FINITEL 1 /* Define to 1 if you have the <float.h> header file. */ #define _GLIBCXX_HAVE_FLOAT_H 1 /* Define to 1 if you have the `floorf' function. */ #define _GLIBCXX_HAVE_FLOORF 1 /* Define to 1 if you have the `floorl' function. */ #define _GLIBCXX_HAVE_FLOORL 1 /* Define to 1 if you have the `fmodf' function. */ #define _GLIBCXX_HAVE_FMODF 1 /* Define to 1 if you have the `fmodl' function. */ #define _GLIBCXX_HAVE_FMODL 1 /* Define to 1 if you have the `fpclass' function. */ /* #undef _GLIBCXX_HAVE_FPCLASS */ /* Define to 1 if you have the <fp.h> header file. */ /* #undef _GLIBCXX_HAVE_FP_H */ /* Define to 1 if you have the `frexpf' function. */ #define _GLIBCXX_HAVE_FREXPF 1 /* Define to 1 if you have the `frexpl' function. */ #define _GLIBCXX_HAVE_FREXPL 1 /* Define if _Unwind_GetIPInfo is available. */ #define _GLIBCXX_HAVE_GETIPINFO 1 /* Define if gets is available in <stdio.h> before C++14. */ #define _GLIBCXX_HAVE_GETS 1 /* Define to 1 if you have the `hypot' function. */ #define _GLIBCXX_HAVE_HYPOT 1 /* Define to 1 if you have the `hypotf' function. */ #define _GLIBCXX_HAVE_HYPOTF 1 /* Define to 1 if you have the `hypotl' function. */ #define _GLIBCXX_HAVE_HYPOTL 1 /* Define if you have the iconv() function. */ #define _GLIBCXX_HAVE_ICONV 1 /* Define to 1 if you have the <ieeefp.h> header file. */ /* #undef _GLIBCXX_HAVE_IEEEFP_H */ /* Define if int64_t is available in <stdint.h>. */ #define _GLIBCXX_HAVE_INT64_T 1 /* Define if int64_t is a long. */ #define _GLIBCXX_HAVE_INT64_T_LONG 1 /* Define if int64_t is a long long. */ /* #undef _GLIBCXX_HAVE_INT64_T_LONG_LONG */ /* Define to 1 if you have the <inttypes.h> header file. */ #define _GLIBCXX_HAVE_INTTYPES_H 1 /* Define to 1 if you have the `isinf' function. */ /* #undef _GLIBCXX_HAVE_ISINF */ /* Define to 1 if you have the `isinff' function. */ #define _GLIBCXX_HAVE_ISINFF 1 /* Define to 1 if you have the `isinfl' function. */ #define _GLIBCXX_HAVE_ISINFL 1 /* Define to 1 if you have the `isnan' function. */ /* #undef _GLIBCXX_HAVE_ISNAN */ /* Define to 1 if you have the `isnanf' function. */ #define _GLIBCXX_HAVE_ISNANF 1 /* Define to 1 if you have the `isnanl' function. */ #define _GLIBCXX_HAVE_ISNANL 1 /* Defined if iswblank exists. */ #define _GLIBCXX_HAVE_ISWBLANK 1 /* Define if LC_MESSAGES is available in <locale.h>. */ #define _GLIBCXX_HAVE_LC_MESSAGES 1 /* Define to 1 if you have the `ldexpf' function. */ #define _GLIBCXX_HAVE_LDEXPF 1 /* Define to 1 if you have the `ldexpl' function. */ #define _GLIBCXX_HAVE_LDEXPL 1 /* Define to 1 if you have the <libintl.h> header file. */ #define _GLIBCXX_HAVE_LIBINTL_H 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_AS 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_DATA 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_FSIZE 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_RSS 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_VMEM 0 /* Define if link is available in <unistd.h>. */ #define _GLIBCXX_HAVE_LINK 1 /* Define if futex syscall is available. */ #define _GLIBCXX_HAVE_LINUX_FUTEX 1 /* Define to 1 if you have the <linux/random.h> header file. */ #define _GLIBCXX_HAVE_LINUX_RANDOM_H 1 /* Define to 1 if you have the <linux/types.h> header file. */ #define _GLIBCXX_HAVE_LINUX_TYPES_H 1 /* Define to 1 if you have the <locale.h> header file. */ #define _GLIBCXX_HAVE_LOCALE_H 1 /* Define to 1 if you have the `log10f' function. */ #define _GLIBCXX_HAVE_LOG10F 1 /* Define to 1 if you have the `log10l' function. */ #define _GLIBCXX_HAVE_LOG10L 1 /* Define to 1 if you have the `logf' function. */ #define _GLIBCXX_HAVE_LOGF 1 /* Define to 1 if you have the `logl' function. */ #define _GLIBCXX_HAVE_LOGL 1 /* Define to 1 if you have the <machine/endian.h> header file. */ /* #undef _GLIBCXX_HAVE_MACHINE_ENDIAN_H */ /* Define to 1 if you have the <machine/param.h> header file. */ /* #undef _GLIBCXX_HAVE_MACHINE_PARAM_H */ /* Define if mbstate_t exists in wchar.h. */ #define _GLIBCXX_HAVE_MBSTATE_T 1 /* Define to 1 if you have the `memalign' function. */ #define _GLIBCXX_HAVE_MEMALIGN 1 /* Define to 1 if you have the <memory.h> header file. */ #define _GLIBCXX_HAVE_MEMORY_H 1 /* Define to 1 if you have the `modf' function. */ #define _GLIBCXX_HAVE_MODF 1 /* Define to 1 if you have the `modff' function. */ #define _GLIBCXX_HAVE_MODFF 1 /* Define to 1 if you have the `modfl' function. */ #define _GLIBCXX_HAVE_MODFL 1 /* Define to 1 if you have the <nan.h> header file. */ /* #undef _GLIBCXX_HAVE_NAN_H */ /* Define to 1 if you have the <netdb.h> header file. */ #define _GLIBCXX_HAVE_NETDB_H 1 /* Define to 1 if you have the <netinet/in.h> header file. */ #define _GLIBCXX_HAVE_NETINET_IN_H 1 /* Define to 1 if you have the <netinet/tcp.h> header file. */ #define _GLIBCXX_HAVE_NETINET_TCP_H 1 /* Define if <math.h> defines obsolete isinf function. */ /* #undef _GLIBCXX_HAVE_OBSOLETE_ISINF */ /* Define if <math.h> defines obsolete isnan function. */ /* #undef _GLIBCXX_HAVE_OBSOLETE_ISNAN */ /* Define if openat is available in <fcntl.h>. */ #define _GLIBCXX_HAVE_OPENAT 1 /* Define if poll is available in <poll.h>. */ #define _GLIBCXX_HAVE_POLL 1 /* Define to 1 if you have the <poll.h> header file. */ #define _GLIBCXX_HAVE_POLL_H 1 /* Define to 1 if you have the `posix_memalign' function. */ #define _GLIBCXX_HAVE_POSIX_MEMALIGN 1 /* Define to 1 if POSIX Semaphores with sem_timedwait are available in <semaphore.h>. */ #define _GLIBCXX_HAVE_POSIX_SEMAPHORE 1 /* Define to 1 if you have the `powf' function. */ #define _GLIBCXX_HAVE_POWF 1 /* Define to 1 if you have the `powl' function. */ #define _GLIBCXX_HAVE_POWL 1 /* Define to 1 if you have the `qfpclass' function. */ /* #undef _GLIBCXX_HAVE_QFPCLASS */ /* Define to 1 if you have the `quick_exit' function. */ #define _GLIBCXX_HAVE_QUICK_EXIT 1 /* Define if readlink is available in <unistd.h>. */ #define _GLIBCXX_HAVE_READLINK 1 /* Define to 1 if you have the `secure_getenv' function. */ #define _GLIBCXX_HAVE_SECURE_GETENV 1 /* Define to 1 if you have the `setenv' function. */ #define _GLIBCXX_HAVE_SETENV 1 /* Define to 1 if you have the `sincos' function. */ #define _GLIBCXX_HAVE_SINCOS 1 /* Define to 1 if you have the `sincosf' function. */ #define _GLIBCXX_HAVE_SINCOSF 1 /* Define to 1 if you have the `sincosl' function. */ #define _GLIBCXX_HAVE_SINCOSL 1 /* Define to 1 if you have the `sinf' function. */ #define _GLIBCXX_HAVE_SINF 1 /* Define to 1 if you have the `sinhf' function. */ #define _GLIBCXX_HAVE_SINHF 1 /* Define to 1 if you have the `sinhl' function. */ #define _GLIBCXX_HAVE_SINHL 1 /* Define to 1 if you have the `sinl' function. */ #define _GLIBCXX_HAVE_SINL 1 /* Defined if sleep exists. */ /* #undef _GLIBCXX_HAVE_SLEEP */ /* Define to 1 if you have the `sockatmark' function. */ #define _GLIBCXX_HAVE_SOCKATMARK 1 /* Define to 1 if you have the `sqrtf' function. */ #define _GLIBCXX_HAVE_SQRTF 1 /* Define to 1 if you have the `sqrtl' function. */ #define _GLIBCXX_HAVE_SQRTL 1 /* Define to 1 if you have the <stdalign.h> header file. */ #define _GLIBCXX_HAVE_STDALIGN_H 1 /* Define to 1 if you have the <stdbool.h> header file. */ #define _GLIBCXX_HAVE_STDBOOL_H 1 /* Define to 1 if you have the <stdint.h> header file. */ #define _GLIBCXX_HAVE_STDINT_H 1 /* Define to 1 if you have the <stdlib.h> header file. */ #define _GLIBCXX_HAVE_STDLIB_H 1 /* Define if strerror_l is available in <string.h>. */ #define _GLIBCXX_HAVE_STRERROR_L 1 /* Define if strerror_r is available in <string.h>. */ #define _GLIBCXX_HAVE_STRERROR_R 1 /* Define to 1 if you have the <strings.h> header file. */ #define _GLIBCXX_HAVE_STRINGS_H 1 /* Define to 1 if you have the <string.h> header file. */ #define _GLIBCXX_HAVE_STRING_H 1 /* Define to 1 if you have the `strtof' function. */ #define _GLIBCXX_HAVE_STRTOF 1 /* Define to 1 if you have the `strtold' function. */ #define _GLIBCXX_HAVE_STRTOLD 1 /* Define to 1 if `d_type' is a member of `struct dirent'. */ #define _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE 1 /* Define if strxfrm_l is available in <string.h>. */ #define _GLIBCXX_HAVE_STRXFRM_L 1 /* Define if symlink is available in <unistd.h>. */ #define _GLIBCXX_HAVE_SYMLINK 1 /* Define to 1 if the target runtime linker supports binding the same symbol to different versions. */ #define _GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1 /* Define to 1 if you have the <sys/filio.h> header file. */ /* #undef _GLIBCXX_HAVE_SYS_FILIO_H */ /* Define to 1 if you have the <sys/ioctl.h> header file. */ #define _GLIBCXX_HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the <sys/ipc.h> header file. */ #define _GLIBCXX_HAVE_SYS_IPC_H 1 /* Define to 1 if you have the <sys/isa_defs.h> header file. */ /* #undef _GLIBCXX_HAVE_SYS_ISA_DEFS_H */ /* Define to 1 if you have the <sys/machine.h> header file. */ /* #undef _GLIBCXX_HAVE_SYS_MACHINE_H */ /* Define to 1 if you have the <sys/param.h> header file. */ #define _GLIBCXX_HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the <sys/resource.h> header file. */ #define _GLIBCXX_HAVE_SYS_RESOURCE_H 1 /* Define to 1 if you have a suitable <sys/sdt.h> header file */ #define _GLIBCXX_HAVE_SYS_SDT_H 1 /* Define to 1 if you have the <sys/sem.h> header file. */ #define _GLIBCXX_HAVE_SYS_SEM_H 1 /* Define to 1 if you have the <sys/socket.h> header file. */ #define _GLIBCXX_HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the <sys/statvfs.h> header file. */ #define _GLIBCXX_HAVE_SYS_STATVFS_H 1 /* Define to 1 if you have the <sys/stat.h> header file. */ #define _GLIBCXX_HAVE_SYS_STAT_H 1 /* Define to 1 if you have the <sys/sysinfo.h> header file. */ #define _GLIBCXX_HAVE_SYS_SYSINFO_H 1 /* Define to 1 if you have the <sys/time.h> header file. */ #define _GLIBCXX_HAVE_SYS_TIME_H 1 /* Define to 1 if you have the <sys/types.h> header file. */ #define _GLIBCXX_HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the <sys/uio.h> header file. */ #define _GLIBCXX_HAVE_SYS_UIO_H 1 /* Define if S_IFREG is available in <sys/stat.h>. */ /* #undef _GLIBCXX_HAVE_S_IFREG */ /* Define if S_ISREG is available in <sys/stat.h>. */ #define _GLIBCXX_HAVE_S_ISREG 1 /* Define to 1 if you have the `tanf' function. */ #define _GLIBCXX_HAVE_TANF 1 /* Define to 1 if you have the `tanhf' function. */ #define _GLIBCXX_HAVE_TANHF 1 /* Define to 1 if you have the `tanhl' function. */ #define _GLIBCXX_HAVE_TANHL 1 /* Define to 1 if you have the `tanl' function. */ #define _GLIBCXX_HAVE_TANL 1 /* Define to 1 if you have the <tgmath.h> header file. */ #define _GLIBCXX_HAVE_TGMATH_H 1 /* Define to 1 if you have the `timespec_get' function. */ #define _GLIBCXX_HAVE_TIMESPEC_GET 1 /* Define to 1 if the target supports thread-local storage. */ #define _GLIBCXX_HAVE_TLS 1 /* Define if truncate is available in <unistd.h>. */ #define _GLIBCXX_HAVE_TRUNCATE 1 /* Define to 1 if you have the <uchar.h> header file. */ #define _GLIBCXX_HAVE_UCHAR_H 1 /* Define to 1 if you have the <unistd.h> header file. */ #define _GLIBCXX_HAVE_UNISTD_H 1 /* Define if unlinkat is available in <fcntl.h>. */ #define _GLIBCXX_HAVE_UNLINKAT 1 /* Define to 1 if you have the `uselocale' function. */ #define _GLIBCXX_HAVE_USELOCALE 1 /* Defined if usleep exists. */ /* #undef _GLIBCXX_HAVE_USLEEP */ /* Define to 1 if you have the <utime.h> header file. */ #define _GLIBCXX_HAVE_UTIME_H 1 /* Defined if vfwscanf exists. */ #define _GLIBCXX_HAVE_VFWSCANF 1 /* Defined if vswscanf exists. */ #define _GLIBCXX_HAVE_VSWSCANF 1 /* Defined if vwscanf exists. */ #define _GLIBCXX_HAVE_VWSCANF 1 /* Define to 1 if you have the <wchar.h> header file. */ #define _GLIBCXX_HAVE_WCHAR_H 1 /* Defined if wcstof exists. */ #define _GLIBCXX_HAVE_WCSTOF 1 /* Define to 1 if you have the <wctype.h> header file. */ #define _GLIBCXX_HAVE_WCTYPE_H 1 /* Defined if Sleep exists. */ /* #undef _GLIBCXX_HAVE_WIN32_SLEEP */ /* Define if writev is available in <sys/uio.h>. */ #define _GLIBCXX_HAVE_WRITEV 1 /* Define to 1 if you have the <xlocale.h> header file. */ /* #undef _GLIBCXX_HAVE_XLOCALE_H */ /* Define to 1 if you have the `_acosf' function. */ /* #undef _GLIBCXX_HAVE__ACOSF */ /* Define to 1 if you have the `_acosl' function. */ /* #undef _GLIBCXX_HAVE__ACOSL */ /* Define to 1 if you have the `_aligned_malloc' function. */ /* #undef _GLIBCXX_HAVE__ALIGNED_MALLOC */ /* Define to 1 if you have the `_asinf' function. */ /* #undef _GLIBCXX_HAVE__ASINF */ /* Define to 1 if you have the `_asinl' function. */ /* #undef _GLIBCXX_HAVE__ASINL */ /* Define to 1 if you have the `_atan2f' function. */ /* #undef _GLIBCXX_HAVE__ATAN2F */ /* Define to 1 if you have the `_atan2l' function. */ /* #undef _GLIBCXX_HAVE__ATAN2L */ /* Define to 1 if you have the `_atanf' function. */ /* #undef _GLIBCXX_HAVE__ATANF */ /* Define to 1 if you have the `_atanl' function. */ /* #undef _GLIBCXX_HAVE__ATANL */ /* Define to 1 if you have the `_ceilf' function. */ /* #undef _GLIBCXX_HAVE__CEILF */ /* Define to 1 if you have the `_ceill' function. */ /* #undef _GLIBCXX_HAVE__CEILL */ /* Define to 1 if you have the `_cosf' function. */ /* #undef _GLIBCXX_HAVE__COSF */ /* Define to 1 if you have the `_coshf' function. */ /* #undef _GLIBCXX_HAVE__COSHF */ /* Define to 1 if you have the `_coshl' function. */ /* #undef _GLIBCXX_HAVE__COSHL */ /* Define to 1 if you have the `_cosl' function. */ /* #undef _GLIBCXX_HAVE__COSL */ /* Define to 1 if you have the `_expf' function. */ /* #undef _GLIBCXX_HAVE__EXPF */ /* Define to 1 if you have the `_expl' function. */ /* #undef _GLIBCXX_HAVE__EXPL */ /* Define to 1 if you have the `_fabsf' function. */ /* #undef _GLIBCXX_HAVE__FABSF */ /* Define to 1 if you have the `_fabsl' function. */ /* #undef _GLIBCXX_HAVE__FABSL */ /* Define to 1 if you have the `_finite' function. */ /* #undef _GLIBCXX_HAVE__FINITE */ /* Define to 1 if you have the `_finitef' function. */ /* #undef _GLIBCXX_HAVE__FINITEF */ /* Define to 1 if you have the `_finitel' function. */ /* #undef _GLIBCXX_HAVE__FINITEL */ /* Define to 1 if you have the `_floorf' function. */ /* #undef _GLIBCXX_HAVE__FLOORF */ /* Define to 1 if you have the `_floorl' function. */ /* #undef _GLIBCXX_HAVE__FLOORL */ /* Define to 1 if you have the `_fmodf' function. */ /* #undef _GLIBCXX_HAVE__FMODF */ /* Define to 1 if you have the `_fmodl' function. */ /* #undef _GLIBCXX_HAVE__FMODL */ /* Define to 1 if you have the `_fpclass' function. */ /* #undef _GLIBCXX_HAVE__FPCLASS */ /* Define to 1 if you have the `_frexpf' function. */ /* #undef _GLIBCXX_HAVE__FREXPF */ /* Define to 1 if you have the `_frexpl' function. */ /* #undef _GLIBCXX_HAVE__FREXPL */ /* Define to 1 if you have the `_hypot' function. */ /* #undef _GLIBCXX_HAVE__HYPOT */ /* Define to 1 if you have the `_hypotf' function. */ /* #undef _GLIBCXX_HAVE__HYPOTF */ /* Define to 1 if you have the `_hypotl' function. */ /* #undef _GLIBCXX_HAVE__HYPOTL */ /* Define to 1 if you have the `_isinf' function. */ /* #undef _GLIBCXX_HAVE__ISINF */ /* Define to 1 if you have the `_isinff' function. */ /* #undef _GLIBCXX_HAVE__ISINFF */ /* Define to 1 if you have the `_isinfl' function. */ /* #undef _GLIBCXX_HAVE__ISINFL */ /* Define to 1 if you have the `_isnan' function. */ /* #undef _GLIBCXX_HAVE__ISNAN */ /* Define to 1 if you have the `_isnanf' function. */ /* #undef _GLIBCXX_HAVE__ISNANF */ /* Define to 1 if you have the `_isnanl' function. */ /* #undef _GLIBCXX_HAVE__ISNANL */ /* Define to 1 if you have the `_ldexpf' function. */ /* #undef _GLIBCXX_HAVE__LDEXPF */ /* Define to 1 if you have the `_ldexpl' function. */ /* #undef _GLIBCXX_HAVE__LDEXPL */ /* Define to 1 if you have the `_log10f' function. */ /* #undef _GLIBCXX_HAVE__LOG10F */ /* Define to 1 if you have the `_log10l' function. */ /* #undef _GLIBCXX_HAVE__LOG10L */ /* Define to 1 if you have the `_logf' function. */ /* #undef _GLIBCXX_HAVE__LOGF */ /* Define to 1 if you have the `_logl' function. */ /* #undef _GLIBCXX_HAVE__LOGL */ /* Define to 1 if you have the `_modf' function. */ /* #undef _GLIBCXX_HAVE__MODF */ /* Define to 1 if you have the `_modff' function. */ /* #undef _GLIBCXX_HAVE__MODFF */ /* Define to 1 if you have the `_modfl' function. */ /* #undef _GLIBCXX_HAVE__MODFL */ /* Define to 1 if you have the `_powf' function. */ /* #undef _GLIBCXX_HAVE__POWF */ /* Define to 1 if you have the `_powl' function. */ /* #undef _GLIBCXX_HAVE__POWL */ /* Define to 1 if you have the `_qfpclass' function. */ /* #undef _GLIBCXX_HAVE__QFPCLASS */ /* Define to 1 if you have the `_sincos' function. */ /* #undef _GLIBCXX_HAVE__SINCOS */ /* Define to 1 if you have the `_sincosf' function. */ /* #undef _GLIBCXX_HAVE__SINCOSF */ /* Define to 1 if you have the `_sincosl' function. */ /* #undef _GLIBCXX_HAVE__SINCOSL */ /* Define to 1 if you have the `_sinf' function. */ /* #undef _GLIBCXX_HAVE__SINF */ /* Define to 1 if you have the `_sinhf' function. */ /* #undef _GLIBCXX_HAVE__SINHF */ /* Define to 1 if you have the `_sinhl' function. */ /* #undef _GLIBCXX_HAVE__SINHL */ /* Define to 1 if you have the `_sinl' function. */ /* #undef _GLIBCXX_HAVE__SINL */ /* Define to 1 if you have the `_sqrtf' function. */ /* #undef _GLIBCXX_HAVE__SQRTF */ /* Define to 1 if you have the `_sqrtl' function. */ /* #undef _GLIBCXX_HAVE__SQRTL */ /* Define to 1 if you have the `_tanf' function. */ /* #undef _GLIBCXX_HAVE__TANF */ /* Define to 1 if you have the `_tanhf' function. */ /* #undef _GLIBCXX_HAVE__TANHF */ /* Define to 1 if you have the `_tanhl' function. */ /* #undef _GLIBCXX_HAVE__TANHL */ /* Define to 1 if you have the `_tanl' function. */ /* #undef _GLIBCXX_HAVE__TANL */ /* Define to 1 if you have the `_wfopen' function. */ /* #undef _GLIBCXX_HAVE__WFOPEN */ /* Define to 1 if you have the `__cxa_thread_atexit' function. */ /* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT */ /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */ #define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1 /* Define as const if the declaration of iconv() needs const. */ #define _GLIBCXX_ICONV_CONST /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define _GLIBCXX_LT_OBJDIR ".libs/" /* Name of package */ /* #undef _GLIBCXX_PACKAGE */ /* Define to the address where bug reports for this package should be sent. */ #define _GLIBCXX_PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define _GLIBCXX_PACKAGE_NAME "package-unused" /* Define to the full name and version of this package. */ #define _GLIBCXX_PACKAGE_STRING "package-unused version-unused" /* Define to the one symbol short name of this package. */ #define _GLIBCXX_PACKAGE_TARNAME "libstdc++" /* Define to the home page for this package. */ #define _GLIBCXX_PACKAGE_URL "" /* Define to the version of this package. */ #define _GLIBCXX_PACKAGE__GLIBCXX_VERSION "version-unused" /* The size of `char', as computed by sizeof. */ /* #undef SIZEOF_CHAR */ /* The size of `int', as computed by sizeof. */ /* #undef SIZEOF_INT */ /* The size of `long', as computed by sizeof. */ /* #undef SIZEOF_LONG */ /* The size of `short', as computed by sizeof. */ /* #undef SIZEOF_SHORT */ /* The size of `void *', as computed by sizeof. */ /* #undef SIZEOF_VOID_P */ /* Define to 1 if you have the ANSI C header files. */ #define _GLIBCXX_STDC_HEADERS 1 /* Version number of package */ /* #undef _GLIBCXX_VERSION */ /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _GLIBCXX_DARWIN_USE_64_BIT_INODE # define _GLIBCXX_DARWIN_USE_64_BIT_INODE 1 #endif /* Number of bits in a file offset, on hosts where this is settable. */ /* #undef _GLIBCXX_FILE_OFFSET_BITS */ /* Define if C99 functions in <complex.h> should be used in <complex> for C++11. Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX11_USE_C99_COMPLEX 1 /* Define if C99 functions or macros in <math.h> should be imported in <cmath> in namespace std for C++11. */ #define _GLIBCXX11_USE_C99_MATH 1 /* Define if C99 functions or macros in <stdio.h> should be imported in <cstdio> in namespace std for C++11. */ #define _GLIBCXX11_USE_C99_STDIO 1 /* Define if C99 functions or macros in <stdlib.h> should be imported in <cstdlib> in namespace std for C++11. */ #define _GLIBCXX11_USE_C99_STDLIB 1 /* Define if C99 functions or macros in <wchar.h> should be imported in <cwchar> in namespace std for C++11. */ #define _GLIBCXX11_USE_C99_WCHAR 1 /* Define if C99 functions in <complex.h> should be used in <complex> for C++98. Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX98_USE_C99_COMPLEX 1 /* Define if C99 functions or macros in <math.h> should be imported in <cmath> in namespace std for C++98. */ #define _GLIBCXX98_USE_C99_MATH 1 /* Define if C99 functions or macros in <stdio.h> should be imported in <cstdio> in namespace std for C++98. */ #define _GLIBCXX98_USE_C99_STDIO 1 /* Define if C99 functions or macros in <stdlib.h> should be imported in <cstdlib> in namespace std for C++98. */ #define _GLIBCXX98_USE_C99_STDLIB 1 /* Define if C99 functions or macros in <wchar.h> should be imported in <cwchar> in namespace std for C++98. */ #define _GLIBCXX98_USE_C99_WCHAR 1 /* Define if the compiler supports C++11 atomics. */ #define _GLIBCXX_ATOMIC_BUILTINS 1 /* Define to use concept checking code from the boost libraries. */ /* #undef _GLIBCXX_CONCEPT_CHECKS */ /* Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, undefined for platform defaults */ #define _GLIBCXX_FULLY_DYNAMIC_STRING 0 /* Define if gthreads library is available. */ #define _GLIBCXX_HAS_GTHREADS 1 /* Define to 1 if a full hosted library is built, or 0 if freestanding. */ #define _GLIBCXX_HOSTED 1 /* Define if compatibility should be provided for alternative 128-bit long double formats. */ /* Define if compatibility should be provided for -mlong-double-64. */ /* Define to the letter to which size_t is mangled. */ #define _GLIBCXX_MANGLE_SIZE_T m /* Define if C99 llrint and llround functions are missing from <math.h>. */ /* #undef _GLIBCXX_NO_C99_ROUNDING_FUNCS */ /* Defined if no way to sleep is available. */ /* #undef _GLIBCXX_NO_SLEEP */ /* Define if ptrdiff_t is int. */ /* #undef _GLIBCXX_PTRDIFF_T_IS_INT */ /* Define if using setrlimit to set resource limits during "make check" */ #define _GLIBCXX_RES_LIMITS 1 /* Define if size_t is unsigned int. */ /* #undef _GLIBCXX_SIZE_T_IS_UINT */ /* Define to the value of the EOF integer constant. */ #define _GLIBCXX_STDIO_EOF -1 /* Define to the value of the SEEK_CUR integer constant. */ #define _GLIBCXX_STDIO_SEEK_CUR 1 /* Define to the value of the SEEK_END integer constant. */ #define _GLIBCXX_STDIO_SEEK_END 2 /* Define to use symbol versioning in the shared library. */ #define _GLIBCXX_SYMVER 1 /* Define to use darwin versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_DARWIN */ /* Define to use GNU versioning in the shared library. */ #define _GLIBCXX_SYMVER_GNU 1 /* Define to use GNU namespace versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */ /* Define to use Sun versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_SUN */ /* Define if C11 functions in <uchar.h> should be imported into namespace std in <cuchar>. */ #define _GLIBCXX_USE_C11_UCHAR_CXX11 1 /* Define if C99 functions or macros from <wchar.h>, <math.h>, <complex.h>, <stdio.h>, and <stdlib.h> can be used or exposed. */ #define _GLIBCXX_USE_C99 1 /* Define if C99 functions in <complex.h> should be used in <tr1/complex>. Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX_USE_C99_COMPLEX_TR1 1 /* Define if C99 functions in <ctype.h> should be imported in <tr1/cctype> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_CTYPE_TR1 1 /* Define if C99 functions in <fenv.h> should be imported in <tr1/cfenv> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_FENV_TR1 1 /* Define if C99 functions in <inttypes.h> should be imported in <tr1/cinttypes> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_INTTYPES_TR1 1 /* Define if wchar_t C99 functions in <inttypes.h> should be imported in <tr1/cinttypes> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 1 /* Define if C99 functions or macros in <math.h> should be imported in <tr1/cmath> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_MATH_TR1 1 /* Define if C99 types in <stdint.h> should be imported in <tr1/cstdint> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_STDINT_TR1 1 /* Defined if clock_gettime syscall has monotonic and realtime clock support. */ /* #undef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL */ /* Defined if clock_gettime has monotonic clock support. */ #define _GLIBCXX_USE_CLOCK_MONOTONIC 1 /* Defined if clock_gettime has realtime clock support. */ #define _GLIBCXX_USE_CLOCK_REALTIME 1 /* Define if ISO/IEC TR 24733 decimal floating point types are supported on this host. */ #define _GLIBCXX_USE_DECIMAL_FLOAT 1 /* Define if /dev/random and /dev/urandom are available for std::random_device. */ #define _GLIBCXX_USE_DEV_RANDOM 1 /* Define if fchmod is available in <sys/stat.h>. */ #define _GLIBCXX_USE_FCHMOD 1 /* Define if fchmodat is available in <sys/stat.h>. */ #define _GLIBCXX_USE_FCHMODAT 1 /* Defined if gettimeofday is available. */ #define _GLIBCXX_USE_GETTIMEOFDAY 1 /* Define if get_nprocs is available in <sys/sysinfo.h>. */ #define _GLIBCXX_USE_GET_NPROCS 1 /* Define if __int128 is supported on this host. */ #define _GLIBCXX_USE_INT128 1 /* Define if LFS support is available. */ #define _GLIBCXX_USE_LFS 1 /* Define if code specialized for long long should be used. */ #define _GLIBCXX_USE_LONG_LONG 1 /* Define if lstat is available in <sys/stat.h>. */ #define _GLIBCXX_USE_LSTAT 1 /* Defined if nanosleep is available. */ #define _GLIBCXX_USE_NANOSLEEP 1 /* Define if NLS translations are to be used. */ #define _GLIBCXX_USE_NLS 1 /* Define if pthreads_num_processors_np is available in <pthread.h>. */ /* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */ /* Define if pthread_cond_clockwait is available in <pthread.h>. */ #define _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT 1 /* Define if pthread_mutex_clocklock is available in <pthread.h>. */ #define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK 1 /* Define if pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock are available in <pthread.h>. */ #define _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK 1 /* Define if POSIX read/write locks are available in <gthr.h>. */ #define _GLIBCXX_USE_PTHREAD_RWLOCK_T 1 /* Define if /dev/random and /dev/urandom are available for the random_device of TR1 (Chapter 5.1). */ #define _GLIBCXX_USE_RANDOM_TR1 1 /* Define if usable realpath is available in <stdlib.h>. */ #define _GLIBCXX_USE_REALPATH 1 /* Defined if sched_yield is available. */ #define _GLIBCXX_USE_SCHED_YIELD 1 /* Define if _SC_NPROCESSORS_ONLN is available in <unistd.h>. */ #define _GLIBCXX_USE_SC_NPROCESSORS_ONLN 1 /* Define if _SC_NPROC_ONLN is available in <unistd.h>. */ /* #undef _GLIBCXX_USE_SC_NPROC_ONLN */ /* Define if sendfile is available in <sys/sendfile.h>. */ #define _GLIBCXX_USE_SENDFILE 1 /* Define to restrict std::__basic_file<> to stdio APIs. */ /* #undef _GLIBCXX_USE_STDIO_PURE */ /* Define if struct stat has timespec members. */ #define _GLIBCXX_USE_ST_MTIM 1 /* Define if sysctl(), CTL_HW and HW_NCPU are available in <sys/sysctl.h>. */ /* #undef _GLIBCXX_USE_SYSCTL_HW_NCPU */ /* Define if obsolescent tmpnam is available in <stdio.h>. */ #define _GLIBCXX_USE_TMPNAM 1 /* Define if utime is available in <utime.h>. */ #define _GLIBCXX_USE_UTIME 1 /* Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and AT_FDCWD in <fcntl.h>. */ #define _GLIBCXX_USE_UTIMENSAT 1 /* Define if code specialized for wchar_t should be used. */ #define _GLIBCXX_USE_WCHAR_T 1 /* Define to 1 if a verbose library is built, or 0 otherwise. */ #define _GLIBCXX_VERBOSE 1 /* Defined if as can handle rdrand. */ #define _GLIBCXX_X86_RDRAND 1 /* Defined if as can handle rdseed. */ #define _GLIBCXX_X86_RDSEED 1 /* Define to 1 if mutex_timedlock is available. */ #define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 /* Define for large files, on AIX-style hosts. */ /* #undef _GLIBCXX_LARGE_FILES */ /* Define if all C++11 floating point overloads are available in <math.h>. */ #if __cplusplus >= 201103L /* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP */ #endif /* Define if all C++11 integral type overloads are available in <math.h>. */ #if __cplusplus >= 201103L /* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT */ #endif #if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF) # define _GLIBCXX_HAVE_ACOSF 1 # define acosf _acosf #endif #if defined (_GLIBCXX_HAVE__ACOSL) && ! defined (_GLIBCXX_HAVE_ACOSL) # define _GLIBCXX_HAVE_ACOSL 1 # define acosl _acosl #endif #if defined (_GLIBCXX_HAVE__ASINF) && ! defined (_GLIBCXX_HAVE_ASINF) # define _GLIBCXX_HAVE_ASINF 1 # define asinf _asinf #endif #if defined (_GLIBCXX_HAVE__ASINL) && ! defined (_GLIBCXX_HAVE_ASINL) # define _GLIBCXX_HAVE_ASINL 1 # define asinl _asinl #endif #if defined (_GLIBCXX_HAVE__ATAN2F) && ! defined (_GLIBCXX_HAVE_ATAN2F) # define _GLIBCXX_HAVE_ATAN2F 1 # define atan2f _atan2f #endif #if defined (_GLIBCXX_HAVE__ATAN2L) && ! defined (_GLIBCXX_HAVE_ATAN2L) # define _GLIBCXX_HAVE_ATAN2L 1 # define atan2l _atan2l #endif #if defined (_GLIBCXX_HAVE__ATANF) && ! defined (_GLIBCXX_HAVE_ATANF) # define _GLIBCXX_HAVE_ATANF 1 # define atanf _atanf #endif #if defined (_GLIBCXX_HAVE__ATANL) && ! defined (_GLIBCXX_HAVE_ATANL) # define _GLIBCXX_HAVE_ATANL 1 # define atanl _atanl #endif #if defined (_GLIBCXX_HAVE__CEILF) && ! defined (_GLIBCXX_HAVE_CEILF) # define _GLIBCXX_HAVE_CEILF 1 # define ceilf _ceilf #endif #if defined (_GLIBCXX_HAVE__CEILL) && ! defined (_GLIBCXX_HAVE_CEILL) # define _GLIBCXX_HAVE_CEILL 1 # define ceill _ceill #endif #if defined (_GLIBCXX_HAVE__COSF) && ! defined (_GLIBCXX_HAVE_COSF) # define _GLIBCXX_HAVE_COSF 1 # define cosf _cosf #endif #if defined (_GLIBCXX_HAVE__COSHF) && ! defined (_GLIBCXX_HAVE_COSHF) # define _GLIBCXX_HAVE_COSHF 1 # define coshf _coshf #endif #if defined (_GLIBCXX_HAVE__COSHL) && ! defined (_GLIBCXX_HAVE_COSHL) # define _GLIBCXX_HAVE_COSHL 1 # define coshl _coshl #endif #if defined (_GLIBCXX_HAVE__COSL) && ! defined (_GLIBCXX_HAVE_COSL) # define _GLIBCXX_HAVE_COSL 1 # define cosl _cosl #endif #if defined (_GLIBCXX_HAVE__EXPF) && ! defined (_GLIBCXX_HAVE_EXPF) # define _GLIBCXX_HAVE_EXPF 1 # define expf _expf #endif #if defined (_GLIBCXX_HAVE__EXPL) && ! defined (_GLIBCXX_HAVE_EXPL) # define _GLIBCXX_HAVE_EXPL 1 # define expl _expl #endif #if defined (_GLIBCXX_HAVE__FABSF) && ! defined (_GLIBCXX_HAVE_FABSF) # define _GLIBCXX_HAVE_FABSF 1 # define fabsf _fabsf #endif #if defined (_GLIBCXX_HAVE__FABSL) && ! defined (_GLIBCXX_HAVE_FABSL) # define _GLIBCXX_HAVE_FABSL 1 # define fabsl _fabsl #endif #if defined (_GLIBCXX_HAVE__FINITE) && ! defined (_GLIBCXX_HAVE_FINITE) # define _GLIBCXX_HAVE_FINITE 1 # define finite _finite #endif #if defined (_GLIBCXX_HAVE__FINITEF) && ! defined (_GLIBCXX_HAVE_FINITEF) # define _GLIBCXX_HAVE_FINITEF 1 # define finitef _finitef #endif #if defined (_GLIBCXX_HAVE__FINITEL) && ! defined (_GLIBCXX_HAVE_FINITEL) # define _GLIBCXX_HAVE_FINITEL 1 # define finitel _finitel #endif #if defined (_GLIBCXX_HAVE__FLOORF) && ! defined (_GLIBCXX_HAVE_FLOORF) # define _GLIBCXX_HAVE_FLOORF 1 # define floorf _floorf #endif #if defined (_GLIBCXX_HAVE__FLOORL) && ! defined (_GLIBCXX_HAVE_FLOORL) # define _GLIBCXX_HAVE_FLOORL 1 # define floorl _floorl #endif #if defined (_GLIBCXX_HAVE__FMODF) && ! defined (_GLIBCXX_HAVE_FMODF) # define _GLIBCXX_HAVE_FMODF 1 # define fmodf _fmodf #endif #if defined (_GLIBCXX_HAVE__FMODL) && ! defined (_GLIBCXX_HAVE_FMODL) # define _GLIBCXX_HAVE_FMODL 1 # define fmodl _fmodl #endif #if defined (_GLIBCXX_HAVE__FPCLASS) && ! defined (_GLIBCXX_HAVE_FPCLASS) # define _GLIBCXX_HAVE_FPCLASS 1 # define fpclass _fpclass #endif #if defined (_GLIBCXX_HAVE__FREXPF) && ! defined (_GLIBCXX_HAVE_FREXPF) # define _GLIBCXX_HAVE_FREXPF 1 # define frexpf _frexpf #endif #if defined (_GLIBCXX_HAVE__FREXPL) && ! defined (_GLIBCXX_HAVE_FREXPL) # define _GLIBCXX_HAVE_FREXPL 1 # define frexpl _frexpl #endif #if defined (_GLIBCXX_HAVE__HYPOT) && ! defined (_GLIBCXX_HAVE_HYPOT) # define _GLIBCXX_HAVE_HYPOT 1 # define hypot _hypot #endif #if defined (_GLIBCXX_HAVE__HYPOTF) && ! defined (_GLIBCXX_HAVE_HYPOTF) # define _GLIBCXX_HAVE_HYPOTF 1 # define hypotf _hypotf #endif #if defined (_GLIBCXX_HAVE__HYPOTL) && ! defined (_GLIBCXX_HAVE_HYPOTL) # define _GLIBCXX_HAVE_HYPOTL 1 # define hypotl _hypotl #endif #if defined (_GLIBCXX_HAVE__ISINF) && ! defined (_GLIBCXX_HAVE_ISINF) # define _GLIBCXX_HAVE_ISINF 1 # define isinf _isinf #endif #if defined (_GLIBCXX_HAVE__ISINFF) && ! defined (_GLIBCXX_HAVE_ISINFF) # define _GLIBCXX_HAVE_ISINFF 1 # define isinff _isinff #endif #if defined (_GLIBCXX_HAVE__ISINFL) && ! defined (_GLIBCXX_HAVE_ISINFL) # define _GLIBCXX_HAVE_ISINFL 1 # define isinfl _isinfl #endif #if defined (_GLIBCXX_HAVE__ISNAN) && ! defined (_GLIBCXX_HAVE_ISNAN) # define _GLIBCXX_HAVE_ISNAN 1 # define isnan _isnan #endif #if defined (_GLIBCXX_HAVE__ISNANF) && ! defined (_GLIBCXX_HAVE_ISNANF) # define _GLIBCXX_HAVE_ISNANF 1 # define isnanf _isnanf #endif #if defined (_GLIBCXX_HAVE__ISNANL) && ! defined (_GLIBCXX_HAVE_ISNANL) # define _GLIBCXX_HAVE_ISNANL 1 # define isnanl _isnanl #endif #if defined (_GLIBCXX_HAVE__LDEXPF) && ! defined (_GLIBCXX_HAVE_LDEXPF) # define _GLIBCXX_HAVE_LDEXPF 1 # define ldexpf _ldexpf #endif #if defined (_GLIBCXX_HAVE__LDEXPL) && ! defined (_GLIBCXX_HAVE_LDEXPL) # define _GLIBCXX_HAVE_LDEXPL 1 # define ldexpl _ldexpl #endif #if defined (_GLIBCXX_HAVE__LOG10F) && ! defined (_GLIBCXX_HAVE_LOG10F) # define _GLIBCXX_HAVE_LOG10F 1 # define log10f _log10f #endif #if defined (_GLIBCXX_HAVE__LOG10L) && ! defined (_GLIBCXX_HAVE_LOG10L) # define _GLIBCXX_HAVE_LOG10L 1 # define log10l _log10l #endif #if defined (_GLIBCXX_HAVE__LOGF) && ! defined (_GLIBCXX_HAVE_LOGF) # define _GLIBCXX_HAVE_LOGF 1 # define logf _logf #endif #if defined (_GLIBCXX_HAVE__LOGL) && ! defined (_GLIBCXX_HAVE_LOGL) # define _GLIBCXX_HAVE_LOGL 1 # define logl _logl #endif #if defined (_GLIBCXX_HAVE__MODF) && ! defined (_GLIBCXX_HAVE_MODF) # define _GLIBCXX_HAVE_MODF 1 # define modf _modf #endif #if defined (_GLIBCXX_HAVE__MODFF) && ! defined (_GLIBCXX_HAVE_MODFF) # define _GLIBCXX_HAVE_MODFF 1 # define modff _modff #endif #if defined (_GLIBCXX_HAVE__MODFL) && ! defined (_GLIBCXX_HAVE_MODFL) # define _GLIBCXX_HAVE_MODFL 1 # define modfl _modfl #endif #if defined (_GLIBCXX_HAVE__POWF) && ! defined (_GLIBCXX_HAVE_POWF) # define _GLIBCXX_HAVE_POWF 1 # define powf _powf #endif #if defined (_GLIBCXX_HAVE__POWL) && ! defined (_GLIBCXX_HAVE_POWL) # define _GLIBCXX_HAVE_POWL 1 # define powl _powl #endif #if defined (_GLIBCXX_HAVE__QFPCLASS) && ! defined (_GLIBCXX_HAVE_QFPCLASS) # define _GLIBCXX_HAVE_QFPCLASS 1 # define qfpclass _qfpclass #endif #if defined (_GLIBCXX_HAVE__SINCOS) && ! defined (_GLIBCXX_HAVE_SINCOS) # define _GLIBCXX_HAVE_SINCOS 1 # define sincos _sincos #endif #if defined (_GLIBCXX_HAVE__SINCOSF) && ! defined (_GLIBCXX_HAVE_SINCOSF) # define _GLIBCXX_HAVE_SINCOSF 1 # define sincosf _sincosf #endif #if defined (_GLIBCXX_HAVE__SINCOSL) && ! defined (_GLIBCXX_HAVE_SINCOSL) # define _GLIBCXX_HAVE_SINCOSL 1 # define sincosl _sincosl #endif #if defined (_GLIBCXX_HAVE__SINF) && ! defined (_GLIBCXX_HAVE_SINF) # define _GLIBCXX_HAVE_SINF 1 # define sinf _sinf #endif #if defined (_GLIBCXX_HAVE__SINHF) && ! defined (_GLIBCXX_HAVE_SINHF) # define _GLIBCXX_HAVE_SINHF 1 # define sinhf _sinhf #endif #if defined (_GLIBCXX_HAVE__SINHL) && ! defined (_GLIBCXX_HAVE_SINHL) # define _GLIBCXX_HAVE_SINHL 1 # define sinhl _sinhl #endif #if defined (_GLIBCXX_HAVE__SINL) && ! defined (_GLIBCXX_HAVE_SINL) # define _GLIBCXX_HAVE_SINL 1 # define sinl _sinl #endif #if defined (_GLIBCXX_HAVE__SQRTF) && ! defined (_GLIBCXX_HAVE_SQRTF) # define _GLIBCXX_HAVE_SQRTF 1 # define sqrtf _sqrtf #endif #if defined (_GLIBCXX_HAVE__SQRTL) && ! defined (_GLIBCXX_HAVE_SQRTL) # define _GLIBCXX_HAVE_SQRTL 1 # define sqrtl _sqrtl #endif #if defined (_GLIBCXX_HAVE__STRTOF) && ! defined (_GLIBCXX_HAVE_STRTOF) # define _GLIBCXX_HAVE_STRTOF 1 # define strtof _strtof #endif #if defined (_GLIBCXX_HAVE__STRTOLD) && ! defined (_GLIBCXX_HAVE_STRTOLD) # define _GLIBCXX_HAVE_STRTOLD 1 # define strtold _strtold #endif #if defined (_GLIBCXX_HAVE__TANF) && ! defined (_GLIBCXX_HAVE_TANF) # define _GLIBCXX_HAVE_TANF 1 # define tanf _tanf #endif #if defined (_GLIBCXX_HAVE__TANHF) && ! defined (_GLIBCXX_HAVE_TANHF) # define _GLIBCXX_HAVE_TANHF 1 # define tanhf _tanhf #endif #if defined (_GLIBCXX_HAVE__TANHL) && ! defined (_GLIBCXX_HAVE_TANHL) # define _GLIBCXX_HAVE_TANHL 1 # define tanhl _tanhl #endif #if defined (_GLIBCXX_HAVE__TANL) && ! defined (_GLIBCXX_HAVE_TANL) # define _GLIBCXX_HAVE_TANL 1 # define tanl _tanl #endif #endif // _GLIBCXX_CXX_CONFIG_H #endif #endif /* Threads compatibility routines for libgcc2 and libobjc. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _GLIBCXX_GCC_GTHR_POSIX_H #define _GLIBCXX_GCC_GTHR_POSIX_H /* POSIX threads specific definitions. Easy, since the interface is just one-to-one mapping. */ #define __GTHREADS 1 #define __GTHREADS_CXX0X 1 #include <pthread.h> #if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) # include <unistd.h> # if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 # define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 # else # define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 # endif #endif typedef pthread_t __gthread_t; typedef pthread_key_t __gthread_key_t; typedef pthread_once_t __gthread_once_t; typedef pthread_mutex_t __gthread_mutex_t; typedef pthread_mutex_t __gthread_recursive_mutex_t; typedef pthread_cond_t __gthread_cond_t; typedef struct timespec __gthread_time_t; /* POSIX like conditional variables are supported. Please look at comments in gthr.h for details. */ #define __GTHREAD_HAS_COND 1 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER #define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP #else #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER #define __GTHREAD_TIME_INIT {0,0} #ifdef _GTHREAD_USE_MUTEX_INIT_FUNC # undef __GTHREAD_MUTEX_INIT #endif #ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC # undef __GTHREAD_RECURSIVE_MUTEX_INIT # undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION # define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #ifdef _GTHREAD_USE_COND_INIT_FUNC # undef __GTHREAD_COND_INIT # define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function #endif #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK # ifndef __gthrw_pragma # define __gthrw_pragma(pragma) # endif # define __gthrw2(name,name2,type) \ static __typeof(type) name \ __attribute__ ((__weakref__(#name2), __copy__ (type))); \ __gthrw_pragma(weak type) # define __gthrw_(name) __gthrw_ ## name #else # define __gthrw2(name,name2,type) # define __gthrw_(name) name #endif /* Typically, __gthrw_foo is a weak reference to symbol foo. */ #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) __gthrw(pthread_once) __gthrw(pthread_getspecific) __gthrw(pthread_setspecific) __gthrw(pthread_create) __gthrw(pthread_join) __gthrw(pthread_equal) __gthrw(pthread_self) __gthrw(pthread_detach) #ifndef __BIONIC__ __gthrw(pthread_cancel) #endif __gthrw(sched_yield) __gthrw(pthread_mutex_lock) __gthrw(pthread_mutex_trylock) #if _GTHREAD_USE_MUTEX_TIMEDLOCK __gthrw(pthread_mutex_timedlock) #endif __gthrw(pthread_mutex_unlock) __gthrw(pthread_mutex_init) __gthrw(pthread_mutex_destroy) __gthrw(pthread_cond_init) __gthrw(pthread_cond_broadcast) __gthrw(pthread_cond_signal) __gthrw(pthread_cond_wait) __gthrw(pthread_cond_timedwait) __gthrw(pthread_cond_destroy) __gthrw(pthread_key_create) __gthrw(pthread_key_delete) __gthrw(pthread_mutexattr_init) __gthrw(pthread_mutexattr_settype) __gthrw(pthread_mutexattr_destroy) #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) /* Objective-C. */ __gthrw(pthread_exit) #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(sched_get_priority_max) __gthrw(sched_get_priority_min) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ __gthrw(pthread_attr_destroy) __gthrw(pthread_attr_init) __gthrw(pthread_attr_setdetachstate) #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(pthread_getschedparam) __gthrw(pthread_setschedparam) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _LIBOBJC || _LIBOBJC_WEAK */ #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if -pthreads is not specified. The functions are dummies and most return an error value. However pthread_once returns 0 without invoking the routine it is passed so we cannot pretend that the interface is active if -pthreads is not specified. On Solaris 2.5.1, the interface is not exposed at all so we need to play the usual game with weak symbols. On Solaris 10 and up, a working interface is always exposed. On FreeBSD 6 and later, libc also exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, which means the alternate __gthread_active_p below cannot be used there. */ #if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) static volatile int __gthread_active = -1; static void __gthread_trigger (void) { __gthread_active = 1; } static inline int __gthread_active_p (void) { static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; /* This test is not protected to avoid taking a lock on the main code path so every update of __gthread_active in a threaded program must be atomic with regard to the result of the test. */ if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { if (__gthrw_(pthread_once)) { /* If this really is a threaded program, then we must ensure that __gthread_active has been set to 1 before exiting this block. */ __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); } /* Make sure we'll never enter this block again. */ if (__gthread_active < 0) __gthread_active = 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* neither FreeBSD nor Solaris */ /* For a program to be multi-threaded the only thing that it certainly must be using is pthread_create. However, there may be other libraries that intercept pthread_create with their own definitions to wrap pthreads functionality for some purpose. In those cases, pthread_create being defined might not necessarily mean that libpthread is actually linked in. For the GNU C library, we can use a known internal name. This is always available in the ABI, but no other library would define it. That is ideal, since any public pthread function might be intercepted just as pthread_create might be. __pthread_key_create is an "internal" implementation symbol, but it is part of the public exported ABI. Also, it's among the symbols that the static libpthread.a always links in whenever pthread_create is used, so there is no danger of a false negative result in any statically-linked, multi-threaded program. For others, we choose pthread_cancel as a function that seems unlikely to be redefined by an interceptor library. The bionic (Android) C library does not provide pthread_cancel, so we do use pthread_create there (and interceptor libraries lose). */ #ifdef __GLIBC__ __gthrw2(__gthrw_(__pthread_key_create), __pthread_key_create, pthread_key_create) # define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create) #elif defined (__BIONIC__) # define GTHR_ACTIVE_PROXY __gthrw_(pthread_create) #else # define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel) #endif static inline int __gthread_active_p (void) { static void *const __gthread_active_ptr = __extension__ (void *) >HR_ACTIVE_PROXY; return __gthread_active_ptr != 0; } #endif /* FreeBSD or Solaris */ #else /* not __GXX_WEAK__ */ /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread calls in shared flavors of the HP-UX C library. Most of the stubs have no functionality. The details are described in the "libc cumulative patch" for each subversion of HP-UX 11. There are two special interfaces provided for checking whether an application is linked to a shared pthread library or not. However, these interfaces aren't available in early libpthread libraries. We also need a test that works for archive libraries. We can't use pthread_once as some libc versions call the init function. We also can't use pthread_create or pthread_attr_init as these create a thread and thereby prevent changing the default stack size. The function pthread_default_stacksize_np is available in both the archive and shared versions of libpthread. It can be used to determine the default pthread stack size. There is a stub in some shared libc versions which returns a zero size if pthreads are not active. We provide an equivalent stub to handle cases where libc doesn't provide one. */ #if defined(__hppa__) && defined(__hpux__) static volatile int __gthread_active = -1; static inline int __gthread_active_p (void) { /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; size_t __s; if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { pthread_default_stacksize_np (0, &__s); __gthread_active = __s ? 1 : 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* not hppa-hpux */ static inline int __gthread_active_p (void) { return 1; } #endif /* hppa-hpux */ #endif /* __GXX_WEAK__ */ #ifdef _LIBOBJC /* This is the config.h file in libobjc/ */ #include <config.h> #ifdef HAVE_SCHED_H # include <sched.h> #endif /* Key structure for maintaining thread specific storage */ static pthread_key_t _objc_thread_storage; static pthread_attr_t _objc_thread_attribs; /* Thread local storage for a single thread */ static void *thread_local_storage = NULL; /* Backend initialization functions */ /* Initialize the threads subsystem. */ static inline int __gthread_objc_init_thread_system (void) { if (__gthread_active_p ()) { /* Initialize the thread storage key. */ if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) { /* The normal default detach state for threads is * PTHREAD_CREATE_JOINABLE which causes threads to not die * when you think they should. */ if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, PTHREAD_CREATE_DETACHED) == 0) return 0; } } return -1; } /* Close the threads subsystem. */ static inline int __gthread_objc_close_thread_system (void) { if (__gthread_active_p () && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) return 0; return -1; } /* Backend thread functions */ /* Create a new thread of execution. */ static inline objc_thread_t __gthread_objc_thread_detach (void (*func)(void *), void *arg) { objc_thread_t thread_id; pthread_t new_thread_handle; if (!__gthread_active_p ()) return NULL; if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, (void *) func, arg))) thread_id = (objc_thread_t) new_thread_handle; else thread_id = NULL; return thread_id; } /* Set the current thread's priority. */ static inline int __gthread_objc_thread_set_priority (int priority) { if (!__gthread_active_p ()) return -1; else { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING pthread_t thread_id = __gthrw_(pthread_self) (); int policy; struct sched_param params; int priority_min, priority_max; if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) { if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) return -1; if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) return -1; if (priority > priority_max) priority = priority_max; else if (priority < priority_min) priority = priority_min; params.sched_priority = priority; /* * The solaris 7 and several other man pages incorrectly state that * this should be a pointer to policy but pthread.h is universally * at odds with this. */ if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) return 0; } #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return -1; } } /* Return the current thread's priority. */ static inline int __gthread_objc_thread_get_priority (void) { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING if (__gthread_active_p ()) { int policy; struct sched_param params; if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) return params.sched_priority; else return -1; } else #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return OBJC_THREAD_INTERACTIVE_PRIORITY; } /* Yield our process time to another thread. */ static inline void __gthread_objc_thread_yield (void) { if (__gthread_active_p ()) __gthrw_(sched_yield) (); } /* Terminate the current thread. */ static inline int __gthread_objc_thread_exit (void) { if (__gthread_active_p ()) /* exit the thread */ __gthrw_(pthread_exit) (&__objc_thread_exit_status); /* Failed if we reached here */ return -1; } /* Returns an integer value which uniquely describes a thread. */ static inline objc_thread_t __gthread_objc_thread_id (void) { if (__gthread_active_p ()) return (objc_thread_t) __gthrw_(pthread_self) (); else return (objc_thread_t) 1; } /* Sets the thread's local storage pointer. */ static inline int __gthread_objc_thread_set_data (void *value) { if (__gthread_active_p ()) return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); else { thread_local_storage = value; return 0; } } /* Returns the thread's local storage pointer. */ static inline void * __gthread_objc_thread_get_data (void) { if (__gthread_active_p ()) return __gthrw_(pthread_getspecific) (_objc_thread_storage); else return thread_local_storage; } /* Backend mutex functions */ /* Allocate a mutex. */ static inline int __gthread_objc_mutex_allocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) { objc_free (mutex->backend); mutex->backend = NULL; return -1; } } return 0; } /* Deallocate a mutex. */ static inline int __gthread_objc_mutex_deallocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { int count; /* * Posix Threads specifically require that the thread be unlocked * for __gthrw_(pthread_mutex_destroy) to work. */ do { count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); if (count < 0) return -1; } while (count); if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) return -1; objc_free (mutex->backend); mutex->backend = NULL; } return 0; } /* Grab a lock on a mutex. */ static inline int __gthread_objc_mutex_lock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Try to grab a lock on a mutex. */ static inline int __gthread_objc_mutex_trylock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Unlock the mutex */ static inline int __gthread_objc_mutex_unlock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Backend condition mutex functions */ /* Allocate a condition. */ static inline int __gthread_objc_condition_allocate (objc_condition_t condition) { if (__gthread_active_p ()) { condition->backend = objc_malloc (sizeof (pthread_cond_t)); if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) { objc_free (condition->backend); condition->backend = NULL; return -1; } } return 0; } /* Deallocate a condition. */ static inline int __gthread_objc_condition_deallocate (objc_condition_t condition) { if (__gthread_active_p ()) { if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) return -1; objc_free (condition->backend); condition->backend = NULL; } return 0; } /* Wait on the condition */ static inline int __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, (pthread_mutex_t *) mutex->backend); else return 0; } /* Wake up all threads waiting on this condition. */ static inline int __gthread_objc_condition_broadcast (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); else return 0; } /* Wake up one thread waiting on this condition. */ static inline int __gthread_objc_condition_signal (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); else return 0; } #else /* _LIBOBJC */ static inline int __gthread_create (__gthread_t *__threadid, void *(*__func) (void*), void *__args) { return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); } static inline int __gthread_join (__gthread_t __threadid, void **__value_ptr) { return __gthrw_(pthread_join) (__threadid, __value_ptr); } static inline int __gthread_detach (__gthread_t __threadid) { return __gthrw_(pthread_detach) (__threadid); } static inline int __gthread_equal (__gthread_t __t1, __gthread_t __t2) { return __gthrw_(pthread_equal) (__t1, __t2); } static inline __gthread_t __gthread_self (void) { return __gthrw_(pthread_self) (); } static inline int __gthread_yield (void) { return __gthrw_(sched_yield) (); } static inline int __gthread_once (__gthread_once_t *__once, void (*__func) (void)) { if (__gthread_active_p ()) return __gthrw_(pthread_once) (__once, __func); else return -1; } static inline int __gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) { return __gthrw_(pthread_key_create) (__key, __dtor); } static inline int __gthread_key_delete (__gthread_key_t __key) { return __gthrw_(pthread_key_delete) (__key); } static inline void * __gthread_getspecific (__gthread_key_t __key) { return __gthrw_(pthread_getspecific) (__key); } static inline int __gthread_setspecific (__gthread_key_t __key, const void *__ptr) { return __gthrw_(pthread_setspecific) (__key, __ptr); } static inline void __gthread_mutex_init_function (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) __gthrw_(pthread_mutex_init) (__mutex, NULL); } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_destroy) (__mutex); else return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_lock) (__mutex); else return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_trylock) (__mutex); else return 0; } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_mutex_timedlock (__gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); else return 0; } #endif static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_unlock) (__mutex); else return 0; } #if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \ || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC) static inline int __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) { if (__gthread_active_p ()) { pthread_mutexattr_t __attr; int __r; __r = __gthrw_(pthread_mutexattr_init) (&__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_settype) (&__attr, PTHREAD_MUTEX_RECURSIVE); if (!__r) __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); return __r; } return 0; } #endif static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthread_mutex_timedlock (__mutex, __abs_timeout); } #endif static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } #ifdef _GTHREAD_USE_COND_INIT_FUNC static inline void __gthread_cond_init_function (__gthread_cond_t *__cond) { if (__gthread_active_p ()) __gthrw_(pthread_cond_init) (__cond, NULL); } #endif static inline int __gthread_cond_broadcast (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_broadcast) (__cond); } static inline int __gthread_cond_signal (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_signal) (__cond); } static inline int __gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) { return __gthrw_(pthread_cond_wait) (__cond, __mutex); } static inline int __gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); } static inline int __gthread_cond_wait_recursive (__gthread_cond_t *__cond, __gthread_recursive_mutex_t *__mutex) { return __gthread_cond_wait (__cond, __mutex); } static inline int __gthread_cond_destroy (__gthread_cond_t* __cond) { return __gthrw_(pthread_cond_destroy) (__cond); } #endif /* _LIBOBJC */ #endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */ // Wrapper of C-language FILE struct -*- C++ -*- // Copyright (C) 2000-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. // // ISO C++ 14882: 27.8 File-based streams // /** @file bits/basic_file.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ios} */ #ifndef _GLIBCXX_BASIC_FILE_STDIO_H #define _GLIBCXX_BASIC_FILE_STDIO_H 1 #pragma GCC system_header #include <bits/c++config.h> #include <bits/c++io.h> // for __c_lock and __c_file #include <bits/move.h> // for swap #include <ios> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Generic declaration. template<typename _CharT> class __basic_file; // Specialization. template<> class __basic_file<char> { // Underlying data source/sink. __c_file* _M_cfile; // True iff we opened _M_cfile, and thus must close it ourselves. bool _M_cfile_created; public: __basic_file(__c_lock* __lock = 0) throw (); #if __cplusplus >= 201103L __basic_file(__basic_file&& __rv, __c_lock* = 0) noexcept : _M_cfile(__rv._M_cfile), _M_cfile_created(__rv._M_cfile_created) { __rv._M_cfile = nullptr; __rv._M_cfile_created = false; } __basic_file& operator=(const __basic_file&) = delete; __basic_file& operator=(__basic_file&&) = delete; void swap(__basic_file& __f) noexcept { std::swap(_M_cfile, __f._M_cfile); std::swap(_M_cfile_created, __f._M_cfile_created); } #endif __basic_file* open(const char* __name, ios_base::openmode __mode, int __prot = 0664); #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T __basic_file* open(const wchar_t* __name, ios_base::openmode __mode); #endif __basic_file* sys_open(__c_file* __file, ios_base::openmode); __basic_file* sys_open(int __fd, ios_base::openmode __mode) throw (); __basic_file* close(); _GLIBCXX_PURE bool is_open() const throw (); _GLIBCXX_PURE int fd() throw (); _GLIBCXX_PURE __c_file* file() throw (); ~__basic_file(); streamsize xsputn(const char* __s, streamsize __n); streamsize xsputn_2(const char* __s1, streamsize __n1, const char* __s2, streamsize __n2); streamsize xsgetn(char* __s, streamsize __n); streamoff seekoff(streamoff __off, ios_base::seekdir __way) throw (); int sync(); streamsize showmanyc(); }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // Optimizations for random number extensions, x86 version -*- C++ -*- // Copyright (C) 2012-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file ext/random.tcc * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ext/random} */ #ifndef _EXT_OPT_RANDOM_H #define _EXT_OPT_RANDOM_H 1 #pragma GCC system_header #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #ifdef __SSE2__ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace { template<size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2, uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4> inline __m128i __sse2_recursion(__m128i __a, __m128i __b, __m128i __c, __m128i __d) { __m128i __y = _mm_srli_epi32(__b, __sr1); __m128i __z = _mm_srli_si128(__c, __sr2); __m128i __v = _mm_slli_epi32(__d, __sl1); __z = _mm_xor_si128(__z, __a); __z = _mm_xor_si128(__z, __v); __m128i __x = _mm_slli_si128(__a, __sl2); __y = _mm_and_si128(__y, _mm_set_epi32(__msk4, __msk3, __msk2, __msk1)); __z = _mm_xor_si128(__z, __x); return _mm_xor_si128(__z, __y); } } #define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_GEN_READ 1 template<typename _UIntType, size_t __m, size_t __pos1, size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2, uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4, uint32_t __parity1, uint32_t __parity2, uint32_t __parity3, uint32_t __parity4> void simd_fast_mersenne_twister_engine<_UIntType, __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4, __parity1, __parity2, __parity3, __parity4>:: _M_gen_rand(void) { __m128i __r1 = _mm_load_si128(&_M_state[_M_nstate - 2]); __m128i __r2 = _mm_load_si128(&_M_state[_M_nstate - 1]); size_t __i; for (__i = 0; __i < _M_nstate - __pos1; ++__i) { __m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4> (_M_state[__i], _M_state[__i + __pos1], __r1, __r2); _mm_store_si128(&_M_state[__i], __r); __r1 = __r2; __r2 = __r; } for (; __i < _M_nstate; ++__i) { __m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4> (_M_state[__i], _M_state[__i + __pos1 - _M_nstate], __r1, __r2); _mm_store_si128(&_M_state[__i], __r); __r1 = __r2; __r2 = __r; } _M_pos = 0; } #define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_OPERATOREQUAL 1 template<typename _UIntType, size_t __m, size_t __pos1, size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2, uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4, uint32_t __parity1, uint32_t __parity2, uint32_t __parity3, uint32_t __parity4> bool operator==(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType, __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4, __parity1, __parity2, __parity3, __parity4>& __lhs, const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType, __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4, __parity1, __parity2, __parity3, __parity4>& __rhs) { __m128i __res = _mm_cmpeq_epi8(__lhs._M_state[0], __rhs._M_state[0]); for (size_t __i = 1; __i < __lhs._M_nstate; ++__i) __res = _mm_and_si128(__res, _mm_cmpeq_epi8(__lhs._M_state[__i], __rhs._M_state[__i])); return (_mm_movemask_epi8(__res) == 0xffff && __lhs._M_pos == __rhs._M_pos); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // __SSE2__ #endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #endif // _EXT_OPT_RANDOM_H // C++ includes used for precompiling TR1 -*- C++ -*- // Copyright (C) 2006-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file stdtr1c++.h * This is an implementation file for a precompiled header. */ #include <bits/stdc++.h> #include <tr1/array> #include <tr1/cctype> #include <tr1/cfenv> #include <tr1/cfloat> #include <tr1/cinttypes> #include <tr1/climits> #include <tr1/cmath> #include <tr1/complex> #include <tr1/cstdarg> #include <tr1/cstdbool> #include <tr1/cstdint> #include <tr1/cstdio> #include <tr1/cstdlib> #include <tr1/ctgmath> #include <tr1/ctime> #include <tr1/cwchar> #include <tr1/cwctype> #include <tr1/functional> #include <tr1/random> #include <tr1/tuple> #include <tr1/unordered_map> #include <tr1/unordered_set> #include <tr1/utility> // Control various target specific ABI tweaks. Generic version. // Copyright (C) 2004-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/cxxabi_tweaks.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{cxxabi.h} */ #ifndef _CXXABI_TWEAKS_H #define _CXXABI_TWEAKS_H 1 #ifdef __cplusplus namespace __cxxabiv1 { extern "C" { #endif // The generic ABI uses the first byte of a 64-bit guard variable. #define _GLIBCXX_GUARD_TEST(x) (*(char *) (x) != 0) #define _GLIBCXX_GUARD_SET(x) *(char *) (x) = 1 #define _GLIBCXX_GUARD_BIT __guard_test_bit (0, 1) #define _GLIBCXX_GUARD_PENDING_BIT __guard_test_bit (1, 1) #define _GLIBCXX_GUARD_WAITING_BIT __guard_test_bit (2, 1) __extension__ typedef int __guard __attribute__((mode (__DI__))); // __cxa_vec_ctor has void return type. typedef void __cxa_vec_ctor_return_type; #define _GLIBCXX_CXA_VEC_CTOR_RETURN(x) return // Constructors and destructors do not return a value. typedef void __cxa_cdtor_return_type; #ifdef __cplusplus } } // namespace __cxxabiv1 #endif #endif // std::messages implementation details, GNU version -*- C++ -*- // Copyright (C) 2001-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/messages_members.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.2.7.1.2 messages functions // // Written by Benjamin Kosnik <bkoz@redhat.com> #include <libintl.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Non-virtual member functions. template<typename _CharT> messages<_CharT>::messages(size_t __refs) : facet(__refs), _M_c_locale_messages(_S_get_c_locale()), _M_name_messages(_S_get_c_name()) { } template<typename _CharT> messages<_CharT>::messages(__c_locale __cloc, const char* __s, size_t __refs) : facet(__refs), _M_c_locale_messages(0), _M_name_messages(0) { if (__builtin_strcmp(__s, _S_get_c_name()) != 0) { const size_t __len = __builtin_strlen(__s) + 1; char* __tmp = new char[__len]; __builtin_memcpy(__tmp, __s, __len); _M_name_messages = __tmp; } else _M_name_messages = _S_get_c_name(); // Last to avoid leaking memory if new throws. _M_c_locale_messages = _S_clone_c_locale(__cloc); } template<typename _CharT> typename messages<_CharT>::catalog messages<_CharT>::open(const basic_string<char>& __s, const locale& __loc, const char* __dir) const { bindtextdomain(__s.c_str(), __dir); return this->do_open(__s, __loc); } // Virtual member functions. template<typename _CharT> messages<_CharT>::~messages() { if (_M_name_messages != _S_get_c_name()) delete [] _M_name_messages; _S_destroy_c_locale(_M_c_locale_messages); } template<typename _CharT> typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __s, const locale&) const { // No error checking is done, assume the catalog exists and can // be used. textdomain(__s.c_str()); return 0; } template<typename _CharT> void messages<_CharT>::do_close(catalog) const { } // messages_byname template<typename _CharT> messages_byname<_CharT>::messages_byname(const char* __s, size_t __refs) : messages<_CharT>(__refs) { if (this->_M_name_messages != locale::facet::_S_get_c_name()) { delete [] this->_M_name_messages; if (__builtin_strcmp(__s, locale::facet::_S_get_c_name()) != 0) { const size_t __len = __builtin_strlen(__s) + 1; char* __tmp = new char[__len]; __builtin_memcpy(__tmp, __s, __len); this->_M_name_messages = __tmp; } else this->_M_name_messages = locale::facet::_S_get_c_name(); } if (__builtin_strcmp(__s, "C") != 0 && __builtin_strcmp(__s, "POSIX") != 0) { this->_S_destroy_c_locale(this->_M_c_locale_messages); this->_S_create_c_locale(this->_M_c_locale_messages, __s); } } //Specializations. template<> typename messages<char>::catalog messages<char>::do_open(const basic_string<char>&, const locale&) const; template<> void messages<char>::do_close(catalog) const; #ifdef _GLIBCXX_USE_WCHAR_T template<> typename messages<wchar_t>::catalog messages<wchar_t>::do_open(const basic_string<char>&, const locale&) const; template<> void messages<wchar_t>::do_close(catalog) const; #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace /* Threads compatibility routines for libgcc2 and libobjc. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _GLIBCXX_GCC_GTHR_POSIX_H #define _GLIBCXX_GCC_GTHR_POSIX_H /* POSIX threads specific definitions. Easy, since the interface is just one-to-one mapping. */ #define __GTHREADS 1 #define __GTHREADS_CXX0X 1 #include <pthread.h> #if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) # include <unistd.h> # if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 # define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 # else # define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 # endif #endif typedef pthread_t __gthread_t; typedef pthread_key_t __gthread_key_t; typedef pthread_once_t __gthread_once_t; typedef pthread_mutex_t __gthread_mutex_t; typedef pthread_mutex_t __gthread_recursive_mutex_t; typedef pthread_cond_t __gthread_cond_t; typedef struct timespec __gthread_time_t; /* POSIX like conditional variables are supported. Please look at comments in gthr.h for details. */ #define __GTHREAD_HAS_COND 1 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER #define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP #else #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER #define __GTHREAD_TIME_INIT {0,0} #ifdef _GTHREAD_USE_MUTEX_INIT_FUNC # undef __GTHREAD_MUTEX_INIT #endif #ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC # undef __GTHREAD_RECURSIVE_MUTEX_INIT # undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION # define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #ifdef _GTHREAD_USE_COND_INIT_FUNC # undef __GTHREAD_COND_INIT # define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function #endif #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK # ifndef __gthrw_pragma # define __gthrw_pragma(pragma) # endif # define __gthrw2(name,name2,type) \ static __typeof(type) name \ __attribute__ ((__weakref__(#name2), __copy__ (type))); \ __gthrw_pragma(weak type) # define __gthrw_(name) __gthrw_ ## name #else # define __gthrw2(name,name2,type) # define __gthrw_(name) name #endif /* Typically, __gthrw_foo is a weak reference to symbol foo. */ #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) __gthrw(pthread_once) __gthrw(pthread_getspecific) __gthrw(pthread_setspecific) __gthrw(pthread_create) __gthrw(pthread_join) __gthrw(pthread_equal) __gthrw(pthread_self) __gthrw(pthread_detach) #ifndef __BIONIC__ __gthrw(pthread_cancel) #endif __gthrw(sched_yield) __gthrw(pthread_mutex_lock) __gthrw(pthread_mutex_trylock) #if _GTHREAD_USE_MUTEX_TIMEDLOCK __gthrw(pthread_mutex_timedlock) #endif __gthrw(pthread_mutex_unlock) __gthrw(pthread_mutex_init) __gthrw(pthread_mutex_destroy) __gthrw(pthread_cond_init) __gthrw(pthread_cond_broadcast) __gthrw(pthread_cond_signal) __gthrw(pthread_cond_wait) __gthrw(pthread_cond_timedwait) __gthrw(pthread_cond_destroy) __gthrw(pthread_key_create) __gthrw(pthread_key_delete) __gthrw(pthread_mutexattr_init) __gthrw(pthread_mutexattr_settype) __gthrw(pthread_mutexattr_destroy) #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) /* Objective-C. */ __gthrw(pthread_exit) #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(sched_get_priority_max) __gthrw(sched_get_priority_min) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ __gthrw(pthread_attr_destroy) __gthrw(pthread_attr_init) __gthrw(pthread_attr_setdetachstate) #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(pthread_getschedparam) __gthrw(pthread_setschedparam) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _LIBOBJC || _LIBOBJC_WEAK */ #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if -pthreads is not specified. The functions are dummies and most return an error value. However pthread_once returns 0 without invoking the routine it is passed so we cannot pretend that the interface is active if -pthreads is not specified. On Solaris 2.5.1, the interface is not exposed at all so we need to play the usual game with weak symbols. On Solaris 10 and up, a working interface is always exposed. On FreeBSD 6 and later, libc also exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, which means the alternate __gthread_active_p below cannot be used there. */ #if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) static volatile int __gthread_active = -1; static void __gthread_trigger (void) { __gthread_active = 1; } static inline int __gthread_active_p (void) { static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; /* This test is not protected to avoid taking a lock on the main code path so every update of __gthread_active in a threaded program must be atomic with regard to the result of the test. */ if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { if (__gthrw_(pthread_once)) { /* If this really is a threaded program, then we must ensure that __gthread_active has been set to 1 before exiting this block. */ __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); } /* Make sure we'll never enter this block again. */ if (__gthread_active < 0) __gthread_active = 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* neither FreeBSD nor Solaris */ /* For a program to be multi-threaded the only thing that it certainly must be using is pthread_create. However, there may be other libraries that intercept pthread_create with their own definitions to wrap pthreads functionality for some purpose. In those cases, pthread_create being defined might not necessarily mean that libpthread is actually linked in. For the GNU C library, we can use a known internal name. This is always available in the ABI, but no other library would define it. That is ideal, since any public pthread function might be intercepted just as pthread_create might be. __pthread_key_create is an "internal" implementation symbol, but it is part of the public exported ABI. Also, it's among the symbols that the static libpthread.a always links in whenever pthread_create is used, so there is no danger of a false negative result in any statically-linked, multi-threaded program. For others, we choose pthread_cancel as a function that seems unlikely to be redefined by an interceptor library. The bionic (Android) C library does not provide pthread_cancel, so we do use pthread_create there (and interceptor libraries lose). */ #ifdef __GLIBC__ __gthrw2(__gthrw_(__pthread_key_create), __pthread_key_create, pthread_key_create) # define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create) #elif defined (__BIONIC__) # define GTHR_ACTIVE_PROXY __gthrw_(pthread_create) #else # define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel) #endif static inline int __gthread_active_p (void) { static void *const __gthread_active_ptr = __extension__ (void *) >HR_ACTIVE_PROXY; return __gthread_active_ptr != 0; } #endif /* FreeBSD or Solaris */ #else /* not __GXX_WEAK__ */ /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread calls in shared flavors of the HP-UX C library. Most of the stubs have no functionality. The details are described in the "libc cumulative patch" for each subversion of HP-UX 11. There are two special interfaces provided for checking whether an application is linked to a shared pthread library or not. However, these interfaces aren't available in early libpthread libraries. We also need a test that works for archive libraries. We can't use pthread_once as some libc versions call the init function. We also can't use pthread_create or pthread_attr_init as these create a thread and thereby prevent changing the default stack size. The function pthread_default_stacksize_np is available in both the archive and shared versions of libpthread. It can be used to determine the default pthread stack size. There is a stub in some shared libc versions which returns a zero size if pthreads are not active. We provide an equivalent stub to handle cases where libc doesn't provide one. */ #if defined(__hppa__) && defined(__hpux__) static volatile int __gthread_active = -1; static inline int __gthread_active_p (void) { /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; size_t __s; if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { pthread_default_stacksize_np (0, &__s); __gthread_active = __s ? 1 : 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* not hppa-hpux */ static inline int __gthread_active_p (void) { return 1; } #endif /* hppa-hpux */ #endif /* __GXX_WEAK__ */ #ifdef _LIBOBJC /* This is the config.h file in libobjc/ */ #include <config.h> #ifdef HAVE_SCHED_H # include <sched.h> #endif /* Key structure for maintaining thread specific storage */ static pthread_key_t _objc_thread_storage; static pthread_attr_t _objc_thread_attribs; /* Thread local storage for a single thread */ static void *thread_local_storage = NULL; /* Backend initialization functions */ /* Initialize the threads subsystem. */ static inline int __gthread_objc_init_thread_system (void) { if (__gthread_active_p ()) { /* Initialize the thread storage key. */ if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) { /* The normal default detach state for threads is * PTHREAD_CREATE_JOINABLE which causes threads to not die * when you think they should. */ if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, PTHREAD_CREATE_DETACHED) == 0) return 0; } } return -1; } /* Close the threads subsystem. */ static inline int __gthread_objc_close_thread_system (void) { if (__gthread_active_p () && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) return 0; return -1; } /* Backend thread functions */ /* Create a new thread of execution. */ static inline objc_thread_t __gthread_objc_thread_detach (void (*func)(void *), void *arg) { objc_thread_t thread_id; pthread_t new_thread_handle; if (!__gthread_active_p ()) return NULL; if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, (void *) func, arg))) thread_id = (objc_thread_t) new_thread_handle; else thread_id = NULL; return thread_id; } /* Set the current thread's priority. */ static inline int __gthread_objc_thread_set_priority (int priority) { if (!__gthread_active_p ()) return -1; else { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING pthread_t thread_id = __gthrw_(pthread_self) (); int policy; struct sched_param params; int priority_min, priority_max; if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) { if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) return -1; if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) return -1; if (priority > priority_max) priority = priority_max; else if (priority < priority_min) priority = priority_min; params.sched_priority = priority; /* * The solaris 7 and several other man pages incorrectly state that * this should be a pointer to policy but pthread.h is universally * at odds with this. */ if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) return 0; } #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return -1; } } /* Return the current thread's priority. */ static inline int __gthread_objc_thread_get_priority (void) { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING if (__gthread_active_p ()) { int policy; struct sched_param params; if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) return params.sched_priority; else return -1; } else #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return OBJC_THREAD_INTERACTIVE_PRIORITY; } /* Yield our process time to another thread. */ static inline void __gthread_objc_thread_yield (void) { if (__gthread_active_p ()) __gthrw_(sched_yield) (); } /* Terminate the current thread. */ static inline int __gthread_objc_thread_exit (void) { if (__gthread_active_p ()) /* exit the thread */ __gthrw_(pthread_exit) (&__objc_thread_exit_status); /* Failed if we reached here */ return -1; } /* Returns an integer value which uniquely describes a thread. */ static inline objc_thread_t __gthread_objc_thread_id (void) { if (__gthread_active_p ()) return (objc_thread_t) __gthrw_(pthread_self) (); else return (objc_thread_t) 1; } /* Sets the thread's local storage pointer. */ static inline int __gthread_objc_thread_set_data (void *value) { if (__gthread_active_p ()) return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); else { thread_local_storage = value; return 0; } } /* Returns the thread's local storage pointer. */ static inline void * __gthread_objc_thread_get_data (void) { if (__gthread_active_p ()) return __gthrw_(pthread_getspecific) (_objc_thread_storage); else return thread_local_storage; } /* Backend mutex functions */ /* Allocate a mutex. */ static inline int __gthread_objc_mutex_allocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) { objc_free (mutex->backend); mutex->backend = NULL; return -1; } } return 0; } /* Deallocate a mutex. */ static inline int __gthread_objc_mutex_deallocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { int count; /* * Posix Threads specifically require that the thread be unlocked * for __gthrw_(pthread_mutex_destroy) to work. */ do { count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); if (count < 0) return -1; } while (count); if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) return -1; objc_free (mutex->backend); mutex->backend = NULL; } return 0; } /* Grab a lock on a mutex. */ static inline int __gthread_objc_mutex_lock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Try to grab a lock on a mutex. */ static inline int __gthread_objc_mutex_trylock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Unlock the mutex */ static inline int __gthread_objc_mutex_unlock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Backend condition mutex functions */ /* Allocate a condition. */ static inline int __gthread_objc_condition_allocate (objc_condition_t condition) { if (__gthread_active_p ()) { condition->backend = objc_malloc (sizeof (pthread_cond_t)); if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) { objc_free (condition->backend); condition->backend = NULL; return -1; } } return 0; } /* Deallocate a condition. */ static inline int __gthread_objc_condition_deallocate (objc_condition_t condition) { if (__gthread_active_p ()) { if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) return -1; objc_free (condition->backend); condition->backend = NULL; } return 0; } /* Wait on the condition */ static inline int __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, (pthread_mutex_t *) mutex->backend); else return 0; } /* Wake up all threads waiting on this condition. */ static inline int __gthread_objc_condition_broadcast (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); else return 0; } /* Wake up one thread waiting on this condition. */ static inline int __gthread_objc_condition_signal (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); else return 0; } #else /* _LIBOBJC */ static inline int __gthread_create (__gthread_t *__threadid, void *(*__func) (void*), void *__args) { return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); } static inline int __gthread_join (__gthread_t __threadid, void **__value_ptr) { return __gthrw_(pthread_join) (__threadid, __value_ptr); } static inline int __gthread_detach (__gthread_t __threadid) { return __gthrw_(pthread_detach) (__threadid); } static inline int __gthread_equal (__gthread_t __t1, __gthread_t __t2) { return __gthrw_(pthread_equal) (__t1, __t2); } static inline __gthread_t __gthread_self (void) { return __gthrw_(pthread_self) (); } static inline int __gthread_yield (void) { return __gthrw_(sched_yield) (); } static inline int __gthread_once (__gthread_once_t *__once, void (*__func) (void)) { if (__gthread_active_p ()) return __gthrw_(pthread_once) (__once, __func); else return -1; } static inline int __gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) { return __gthrw_(pthread_key_create) (__key, __dtor); } static inline int __gthread_key_delete (__gthread_key_t __key) { return __gthrw_(pthread_key_delete) (__key); } static inline void * __gthread_getspecific (__gthread_key_t __key) { return __gthrw_(pthread_getspecific) (__key); } static inline int __gthread_setspecific (__gthread_key_t __key, const void *__ptr) { return __gthrw_(pthread_setspecific) (__key, __ptr); } static inline void __gthread_mutex_init_function (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) __gthrw_(pthread_mutex_init) (__mutex, NULL); } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_destroy) (__mutex); else return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_lock) (__mutex); else return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_trylock) (__mutex); else return 0; } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_mutex_timedlock (__gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); else return 0; } #endif static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_unlock) (__mutex); else return 0; } #if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \ || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC) static inline int __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) { if (__gthread_active_p ()) { pthread_mutexattr_t __attr; int __r; __r = __gthrw_(pthread_mutexattr_init) (&__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_settype) (&__attr, PTHREAD_MUTEX_RECURSIVE); if (!__r) __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); return __r; } return 0; } #endif static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthread_mutex_timedlock (__mutex, __abs_timeout); } #endif static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } #ifdef _GTHREAD_USE_COND_INIT_FUNC static inline void __gthread_cond_init_function (__gthread_cond_t *__cond) { if (__gthread_active_p ()) __gthrw_(pthread_cond_init) (__cond, NULL); } #endif static inline int __gthread_cond_broadcast (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_broadcast) (__cond); } static inline int __gthread_cond_signal (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_signal) (__cond); } static inline int __gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) { return __gthrw_(pthread_cond_wait) (__cond, __mutex); } static inline int __gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); } static inline int __gthread_cond_wait_recursive (__gthread_cond_t *__cond, __gthread_recursive_mutex_t *__mutex) { return __gthread_cond_wait (__cond, __mutex); } static inline int __gthread_cond_destroy (__gthread_cond_t* __cond) { return __gthrw_(pthread_cond_destroy) (__cond); } #endif /* _LIBOBJC */ #endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */ // Specific definitions for generic platforms -*- C++ -*- // Copyright (C) 2007-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/error_constants.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{system_error} */ #ifndef _GLIBCXX_ERROR_CONSTANTS #define _GLIBCXX_ERROR_CONSTANTS 1 #include <bits/c++config.h> #include <cerrno> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION enum class errc { address_family_not_supported = EAFNOSUPPORT, address_in_use = EADDRINUSE, address_not_available = EADDRNOTAVAIL, already_connected = EISCONN, argument_list_too_long = E2BIG, argument_out_of_domain = EDOM, bad_address = EFAULT, bad_file_descriptor = EBADF, #ifdef EBADMSG bad_message = EBADMSG, #endif broken_pipe = EPIPE, connection_aborted = ECONNABORTED, connection_already_in_progress = EALREADY, connection_refused = ECONNREFUSED, connection_reset = ECONNRESET, cross_device_link = EXDEV, destination_address_required = EDESTADDRREQ, device_or_resource_busy = EBUSY, directory_not_empty = ENOTEMPTY, executable_format_error = ENOEXEC, file_exists = EEXIST, file_too_large = EFBIG, filename_too_long = ENAMETOOLONG, function_not_supported = ENOSYS, host_unreachable = EHOSTUNREACH, #ifdef EIDRM identifier_removed = EIDRM, #endif illegal_byte_sequence = EILSEQ, inappropriate_io_control_operation = ENOTTY, interrupted = EINTR, invalid_argument = EINVAL, invalid_seek = ESPIPE, io_error = EIO, is_a_directory = EISDIR, message_size = EMSGSIZE, network_down = ENETDOWN, network_reset = ENETRESET, network_unreachable = ENETUNREACH, no_buffer_space = ENOBUFS, no_child_process = ECHILD, #ifdef ENOLINK no_link = ENOLINK, #endif no_lock_available = ENOLCK, #ifdef ENODATA no_message_available = ENODATA, #endif no_message = ENOMSG, no_protocol_option = ENOPROTOOPT, no_space_on_device = ENOSPC, #ifdef ENOSR no_stream_resources = ENOSR, #endif no_such_device_or_address = ENXIO, no_such_device = ENODEV, no_such_file_or_directory = ENOENT, no_such_process = ESRCH, not_a_directory = ENOTDIR, not_a_socket = ENOTSOCK, #ifdef ENOSTR not_a_stream = ENOSTR, #endif not_connected = ENOTCONN, not_enough_memory = ENOMEM, #ifdef ENOTSUP not_supported = ENOTSUP, #endif #ifdef ECANCELED operation_canceled = ECANCELED, #endif operation_in_progress = EINPROGRESS, operation_not_permitted = EPERM, operation_not_supported = EOPNOTSUPP, operation_would_block = EWOULDBLOCK, #ifdef EOWNERDEAD owner_dead = EOWNERDEAD, #endif permission_denied = EACCES, #ifdef EPROTO protocol_error = EPROTO, #endif protocol_not_supported = EPROTONOSUPPORT, read_only_file_system = EROFS, resource_deadlock_would_occur = EDEADLK, resource_unavailable_try_again = EAGAIN, result_out_of_range = ERANGE, #ifdef ENOTRECOVERABLE state_not_recoverable = ENOTRECOVERABLE, #endif #ifdef ETIME stream_timeout = ETIME, #endif #ifdef ETXTBSY text_file_busy = ETXTBSY, #endif timed_out = ETIMEDOUT, too_many_files_open_in_system = ENFILE, too_many_files_open = EMFILE, too_many_links = EMLINK, too_many_symbolic_link_levels = ELOOP, #ifdef EOVERFLOW value_too_large = EOVERFLOW, #elif defined __AVR__ value_too_large = 999, #endif wrong_protocol_type = EPROTOTYPE }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // Locale support -*- C++ -*- // Copyright (C) 2000-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/ctype_inline.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.1 Locales // // ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) // functions go in ctype.cc namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION bool ctype<char>:: is(mask __m, char __c) const { return _M_table[static_cast<unsigned char>(__c)] & __m; } const char* ctype<char>:: is(const char* __low, const char* __high, mask* __vec) const { while (__low < __high) *__vec++ = _M_table[static_cast<unsigned char>(*__low++)]; return __high; } const char* ctype<char>:: scan_is(mask __m, const char* __low, const char* __high) const { while (__low < __high && !(_M_table[static_cast<unsigned char>(*__low)] & __m)) ++__low; return __low; } const char* ctype<char>:: scan_not(mask __m, const char* __low, const char* __high) const { while (__low < __high && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0) ++__low; return __low; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace // Specific definitions for GNU/Linux -*- C++ -*- // Copyright (C) 2000-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/os_defines.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{iosfwd} */ #ifndef _GLIBCXX_OS_DEFINES #define _GLIBCXX_OS_DEFINES 1 // System-specific #define, typedefs, corrections, etc, go here. This // file will come before all others. // This keeps isanum, et al from being propagated as macros. #define __NO_CTYPE 1 #include <features.h> // Provide a declaration for the possibly deprecated gets function, as // glibc 2.15 and later does not declare gets for ISO C11 when // __GNU_SOURCE is defined. #if __GLIBC_PREREQ(2,15) && defined(_GNU_SOURCE) # undef _GLIBCXX_HAVE_GETS #endif // Glibc 2.23 removed the obsolete isinf and isnan declarations. Check the // version dynamically in case it has changed since libstdc++ was configured. #define _GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC __GLIBC_PREREQ(2,23) #if __GLIBC_PREREQ(2, 27) // Since glibc 2.27 pthread_self() is usable without linking to libpthread. # define _GLIBCXX_NATIVE_THREAD_ID pthread_self() #else // Before then it was in libc.so.6 but not libc.a, and always returns 0, // which breaks the invariant this_thread::get_id() != thread::id{}. // So only use it if we know the libpthread version is available. // Otherwise use (__gthread_t)1 as the ID of the main (and only) thread. # define _GLIBCXX_NATIVE_THREAD_ID \ (__gthread_active_p() ? __gthread_self() : (__gthread_t)1) #endif #if __GLIBC_PREREQ(2, 34) // Since glibc 2.34 all pthreads functions are usable without linking to // libpthread. # define _GLIBCXX_GTHREAD_USE_WEAK 0 #endif #endif // std::time_get, std::time_put implementation, GNU version -*- C++ -*- // Copyright (C) 2001-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/time_members.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.2.5.1.2 - time_get functions // ISO C++ 14882: 22.2.5.3.2 - time_put functions // // Written by Benjamin Kosnik <bkoz@redhat.com> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _CharT> __timepunct<_CharT>::__timepunct(size_t __refs) : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), _M_name_timepunct(_S_get_c_name()) { _M_initialize_timepunct(); } template<typename _CharT> __timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs) : facet(__refs), _M_data(__cache), _M_c_locale_timepunct(0), _M_name_timepunct(_S_get_c_name()) { _M_initialize_timepunct(); } template<typename _CharT> __timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s, size_t __refs) : facet(__refs), _M_data(0), _M_c_locale_timepunct(0), _M_name_timepunct(0) { if (__builtin_strcmp(__s, _S_get_c_name()) != 0) { const size_t __len = __builtin_strlen(__s) + 1; char* __tmp = new char[__len]; __builtin_memcpy(__tmp, __s, __len); _M_name_timepunct = __tmp; } else _M_name_timepunct = _S_get_c_name(); __try { _M_initialize_timepunct(__cloc); } __catch(...) { if (_M_name_timepunct != _S_get_c_name()) delete [] _M_name_timepunct; __throw_exception_again; } } template<typename _CharT> __timepunct<_CharT>::~__timepunct() { if (_M_name_timepunct != _S_get_c_name()) delete [] _M_name_timepunct; delete _M_data; _S_destroy_c_locale(_M_c_locale_timepunct); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace // C++ includes used for precompiling -*- C++ -*- // Copyright (C) 2003-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file stdc++.h * This is an implementation file for a precompiled header. */ // 17.4.1.2 Headers // C #ifndef _GLIBCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <cwchar> #include <cwctype> #if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdalign> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cuchar> #endif // C++ #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #if __cplusplus >= 201103L #include <array> #include <atomic> #include <chrono> #include <codecvt> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> #endif #if __cplusplus >= 201402L #include <shared_mutex> #endif #if __cplusplus >= 201703L #include <any> #include <charconv> // #include <execution> #include <filesystem> #include <optional> #include <memory_resource> #include <string_view> #include <variant> #endif #if __cplusplus > 201703L #include <barrier> #include <bit> #include <compare> #include <concepts> #if __cpp_impl_coroutine # include <coroutine> #endif #include <latch> #include <numbers> #include <ranges> #include <span> #include <stop_token> #include <semaphore> #include <source_location> #include <syncstream> #include <version> #endif // Specific definitions for generic platforms -*- C++ -*- // Copyright (C) 2005-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/cpu_defines.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{iosfwd} */ #ifndef _GLIBCXX_CPU_DEFINES #define _GLIBCXX_CPU_DEFINES 1 #endif // Optimizations for random number functions, x86 version -*- C++ -*- // Copyright (C) 2012-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/opt_random.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{random} */ #ifndef _BITS_OPT_RANDOM_H #define _BITS_OPT_RANDOM_H 1 #ifdef __SSE3__ #include <pmmintrin.h> #endif #pragma GCC system_header namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef __SSE3__ template<> template<typename _UniformRandomNumberGenerator> void normal_distribution<double>:: __generate(typename normal_distribution<double>::result_type* __f, typename normal_distribution<double>::result_type* __t, _UniformRandomNumberGenerator& __urng, const param_type& __param) { typedef uint64_t __uctype; if (__f == __t) return; if (_M_saved_available) { _M_saved_available = false; *__f++ = _M_saved * __param.stddev() + __param.mean(); if (__f == __t) return; } constexpr uint64_t __maskval = 0xfffffffffffffull; static const __m128i __mask = _mm_set1_epi64x(__maskval); static const __m128i __two = _mm_set1_epi64x(0x4000000000000000ull); static const __m128d __three = _mm_set1_pd(3.0); const __m128d __av = _mm_set1_pd(__param.mean()); const __uctype __urngmin = __urng.min(); const __uctype __urngmax = __urng.max(); const __uctype __urngrange = __urngmax - __urngmin; const __uctype __uerngrange = __urngrange + 1; while (__f + 1 < __t) { double __le; __m128d __x; do { union { __m128i __i; __m128d __d; } __v; if (__urngrange > __maskval) { if (__detail::_Power_of_2(__uerngrange)) __v.__i = _mm_and_si128(_mm_set_epi64x(__urng(), __urng()), __mask); else { const __uctype __uerange = __maskval + 1; const __uctype __scaling = __urngrange / __uerange; const __uctype __past = __uerange * __scaling; uint64_t __v1; do __v1 = __uctype(__urng()) - __urngmin; while (__v1 >= __past); __v1 /= __scaling; uint64_t __v2; do __v2 = __uctype(__urng()) - __urngmin; while (__v2 >= __past); __v2 /= __scaling; __v.__i = _mm_set_epi64x(__v1, __v2); } } else if (__urngrange == __maskval) __v.__i = _mm_set_epi64x(__urng(), __urng()); else if ((__urngrange + 2) * __urngrange >= __maskval && __detail::_Power_of_2(__uerngrange)) { uint64_t __v1 = __urng() * __uerngrange + __urng(); uint64_t __v2 = __urng() * __uerngrange + __urng(); __v.__i = _mm_and_si128(_mm_set_epi64x(__v1, __v2), __mask); } else { size_t __nrng = 2; __uctype __high = __maskval / __uerngrange / __uerngrange; while (__high > __uerngrange) { ++__nrng; __high /= __uerngrange; } const __uctype __highrange = __high + 1; const __uctype __scaling = __urngrange / __highrange; const __uctype __past = __highrange * __scaling; __uctype __tmp; uint64_t __v1; do { do __tmp = __uctype(__urng()) - __urngmin; while (__tmp >= __past); __v1 = __tmp / __scaling; for (size_t __cnt = 0; __cnt < __nrng; ++__cnt) { __tmp = __v1; __v1 *= __uerngrange; __v1 += __uctype(__urng()) - __urngmin; } } while (__v1 > __maskval || __v1 < __tmp); uint64_t __v2; do { do __tmp = __uctype(__urng()) - __urngmin; while (__tmp >= __past); __v2 = __tmp / __scaling; for (size_t __cnt = 0; __cnt < __nrng; ++__cnt) { __tmp = __v2; __v2 *= __uerngrange; __v2 += __uctype(__urng()) - __urngmin; } } while (__v2 > __maskval || __v2 < __tmp); __v.__i = _mm_set_epi64x(__v1, __v2); } __v.__i = _mm_or_si128(__v.__i, __two); __x = _mm_sub_pd(__v.__d, __three); __m128d __m = _mm_mul_pd(__x, __x); __le = _mm_cvtsd_f64(_mm_hadd_pd (__m, __m)); } while (__le == 0.0 || __le >= 1.0); double __mult = (std::sqrt(-2.0 * std::log(__le) / __le) * __param.stddev()); __x = _mm_add_pd(_mm_mul_pd(__x, _mm_set1_pd(__mult)), __av); _mm_storeu_pd(__f, __x); __f += 2; } if (__f != __t) { result_type __x, __y, __r2; __detail::_Adaptor<_UniformRandomNumberGenerator, result_type> __aurng(__urng); do { __x = result_type(2.0) * __aurng() - 1.0; __y = result_type(2.0) * __aurng() - 1.0; __r2 = __x * __x + __y * __y; } while (__r2 > 1.0 || __r2 == 0.0); const result_type __mult = std::sqrt(-2 * std::log(__r2) / __r2); _M_saved = __x * __mult; _M_saved_available = true; *__f = __y * __mult * __param.stddev() + __param.mean(); } } #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // _BITS_OPT_RANDOM_H // Wrapper for underlying C-language localization -*- C++ -*- // Copyright (C) 2001-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/c++locale.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.8 Standard locale categories. // // Written by Benjamin Kosnik <bkoz@redhat.com> #ifndef _GLIBCXX_CXX_LOCALE_H #define _GLIBCXX_CXX_LOCALE_H 1 #pragma GCC system_header #include <clocale> #define _GLIBCXX_C_LOCALE_GNU 1 #define _GLIBCXX_NUM_CATEGORIES 6 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION extern "C" __typeof(uselocale) __uselocale; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __locale_t __c_locale; // Convert numeric value of type double and long double to string and // return length of string. If vsnprintf is available use it, otherwise // fall back to the unsafe vsprintf which, in general, can be dangerous // and should be avoided. inline int __convert_from_v(const __c_locale& __cloc __attribute__ ((__unused__)), char* __out, const int __size __attribute__ ((__unused__)), const char* __fmt, ...) { #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __c_locale __old = __gnu_cxx::__uselocale(__cloc); #else char* __old = std::setlocale(LC_NUMERIC, 0); char* __sav = 0; if (__builtin_strcmp(__old, "C")) { const size_t __len = __builtin_strlen(__old) + 1; __sav = new char[__len]; __builtin_memcpy(__sav, __old, __len); std::setlocale(LC_NUMERIC, "C"); } #endif __builtin_va_list __args; __builtin_va_start(__args, __fmt); #if _GLIBCXX_USE_C99_STDIO const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args); #else const int __ret = __builtin_vsprintf(__out, __fmt, __args); #endif __builtin_va_end(__args); #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) __gnu_cxx::__uselocale(__old); #else if (__sav) { std::setlocale(LC_NUMERIC, __sav); delete [] __sav; } #endif return __ret; } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // Locale support -*- C++ -*- // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/ctype_base.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{locale} */ // // ISO C++ 14882: 22.1 Locales // // Information as gleaned from /usr/include/ctype.h namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @brief Base class for ctype. struct ctype_base { // Non-standard typedefs. typedef const int* __to_type; // NB: Offsets into ctype<char>::_M_table force a particular size // on the mask type. Because of this, we don't use an enum. typedef unsigned short mask; static const mask upper = _ISupper; static const mask lower = _ISlower; static const mask alpha = _ISalpha; static const mask digit = _ISdigit; static const mask xdigit = _ISxdigit; static const mask space = _ISspace; static const mask print = _ISprint; static const mask graph = _ISalpha | _ISdigit | _ISpunct; static const mask cntrl = _IScntrl; static const mask punct = _ISpunct; static const mask alnum = _ISalpha | _ISdigit; #if __cplusplus >= 201103L static const mask blank = _ISblank; #endif }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace /* Threads compatibility routines for libgcc2 and libobjc. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _GLIBCXX_GCC_GTHR_SINGLE_H #define _GLIBCXX_GCC_GTHR_SINGLE_H /* Just provide compatibility for mutex handling. */ typedef int __gthread_key_t; typedef int __gthread_once_t; typedef int __gthread_mutex_t; typedef int __gthread_recursive_mutex_t; #define __GTHREAD_ONCE_INIT 0 #define __GTHREAD_MUTEX_INIT 0 #define __GTHREAD_MUTEX_INIT_FUNCTION(mx) do {} while (0) #define __GTHREAD_RECURSIVE_MUTEX_INIT 0 #define _GLIBCXX_UNUSED __attribute__((__unused__)) #ifdef _LIBOBJC /* Thread local storage for a single thread */ static void *thread_local_storage = NULL; /* Backend initialization functions */ /* Initialize the threads subsystem. */ static inline int __gthread_objc_init_thread_system (void) { /* No thread support available */ return -1; } /* Close the threads subsystem. */ static inline int __gthread_objc_close_thread_system (void) { /* No thread support available */ return -1; } /* Backend thread functions */ /* Create a new thread of execution. */ static inline objc_thread_t __gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED) { /* No thread support available */ return NULL; } /* Set the current thread's priority. */ static inline int __gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED) { /* No thread support available */ return -1; } /* Return the current thread's priority. */ static inline int __gthread_objc_thread_get_priority (void) { return OBJC_THREAD_INTERACTIVE_PRIORITY; } /* Yield our process time to another thread. */ static inline void __gthread_objc_thread_yield (void) { return; } /* Terminate the current thread. */ static inline int __gthread_objc_thread_exit (void) { /* No thread support available */ /* Should we really exit the program */ /* exit (&__objc_thread_exit_status); */ return -1; } /* Returns an integer value which uniquely describes a thread. */ static inline objc_thread_t __gthread_objc_thread_id (void) { /* No thread support, use 1. */ return (objc_thread_t) 1; } /* Sets the thread's local storage pointer. */ static inline int __gthread_objc_thread_set_data (void *value) { thread_local_storage = value; return 0; } /* Returns the thread's local storage pointer. */ static inline void * __gthread_objc_thread_get_data (void) { return thread_local_storage; } /* Backend mutex functions */ /* Allocate a mutex. */ static inline int __gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Deallocate a mutex. */ static inline int __gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Grab a lock on a mutex. */ static inline int __gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED) { /* There can only be one thread, so we always get the lock */ return 0; } /* Try to grab a lock on a mutex. */ static inline int __gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED) { /* There can only be one thread, so we always get the lock */ return 0; } /* Unlock the mutex */ static inline int __gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Backend condition mutex functions */ /* Allocate a condition. */ static inline int __gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } /* Deallocate a condition. */ static inline int __gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } /* Wait on the condition */ static inline int __gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED, objc_mutex_t mutex _GLIBCXX_UNUSED) { return 0; } /* Wake up all threads waiting on this condition. */ static inline int __gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } /* Wake up one thread waiting on this condition. */ static inline int __gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED) { return 0; } #else /* _LIBOBJC */ static inline int __gthread_active_p (void) { return 0; } static inline int __gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED) { return 0; } static inline int _GLIBCXX_UNUSED __gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED) { return 0; } static int _GLIBCXX_UNUSED __gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED) { return 0; } static inline void * __gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED) { return 0; } static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } #endif /* _LIBOBJC */ #undef _GLIBCXX_UNUSED #endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */ /* Threads compatibility routines for libgcc2. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _GLIBCXX_GCC_GTHR_H #define _GLIBCXX_GCC_GTHR_H #ifndef _GLIBCXX_HIDE_EXPORTS #pragma GCC visibility push(default) #endif /* If this file is compiled with threads support, it must #define __GTHREADS 1 to indicate that threads support is present. Also it has define function int __gthread_active_p () that returns 1 if thread system is active, 0 if not. The threads interface must define the following types: __gthread_key_t __gthread_once_t __gthread_mutex_t __gthread_recursive_mutex_t The threads interface must define the following macros: __GTHREAD_ONCE_INIT to initialize __gthread_once_t __GTHREAD_MUTEX_INIT to initialize __gthread_mutex_t to get a fast non-recursive mutex. __GTHREAD_MUTEX_INIT_FUNCTION to initialize __gthread_mutex_t to get a fast non-recursive mutex. Define this to a function which looks like this: void __GTHREAD_MUTEX_INIT_FUNCTION (__gthread_mutex_t *) Some systems can't initialize a mutex without a function call. Don't define __GTHREAD_MUTEX_INIT in this case. __GTHREAD_RECURSIVE_MUTEX_INIT __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION as above, but for a recursive mutex. The threads interface must define the following static functions: int __gthread_once (__gthread_once_t *once, void (*func) ()) int __gthread_key_create (__gthread_key_t *keyp, void (*dtor) (void *)) int __gthread_key_delete (__gthread_key_t key) void *__gthread_getspecific (__gthread_key_t key) int __gthread_setspecific (__gthread_key_t key, const void *ptr) int __gthread_mutex_destroy (__gthread_mutex_t *mutex); int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *mutex); int __gthread_mutex_lock (__gthread_mutex_t *mutex); int __gthread_mutex_trylock (__gthread_mutex_t *mutex); int __gthread_mutex_unlock (__gthread_mutex_t *mutex); int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex); int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex); int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex); The following are supported in POSIX threads only. They are required to fix a deadlock in static initialization inside libsupc++. The header file gthr-posix.h defines a symbol __GTHREAD_HAS_COND to signify that these extra features are supported. Types: __gthread_cond_t Macros: __GTHREAD_COND_INIT __GTHREAD_COND_INIT_FUNCTION Interface: int __gthread_cond_broadcast (__gthread_cond_t *cond); int __gthread_cond_wait (__gthread_cond_t *cond, __gthread_mutex_t *mutex); int __gthread_cond_wait_recursive (__gthread_cond_t *cond, __gthread_recursive_mutex_t *mutex); All functions returning int should return zero on success or the error number. If the operation is not supported, -1 is returned. If the following are also defined, you should #define __GTHREADS_CXX0X 1 to enable the c++0x thread library. Types: __gthread_t __gthread_time_t Interface: int __gthread_create (__gthread_t *thread, void *(*func) (void*), void *args); int __gthread_join (__gthread_t thread, void **value_ptr); int __gthread_detach (__gthread_t thread); int __gthread_equal (__gthread_t t1, __gthread_t t2); __gthread_t __gthread_self (void); int __gthread_yield (void); int __gthread_mutex_timedlock (__gthread_mutex_t *m, const __gthread_time_t *abs_timeout); int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *m, const __gthread_time_t *abs_time); int __gthread_cond_signal (__gthread_cond_t *cond); int __gthread_cond_timedwait (__gthread_cond_t *cond, __gthread_mutex_t *mutex, const __gthread_time_t *abs_timeout); */ #if __GXX_WEAK__ /* The pe-coff weak support isn't fully compatible to ELF's weak. For static libraries it might would work, but as we need to deal with shared versions too, we disable it for mingw-targets. */ #ifdef __MINGW32__ #undef _GLIBCXX_GTHREAD_USE_WEAK #define _GLIBCXX_GTHREAD_USE_WEAK 0 #endif #ifndef _GLIBCXX_GTHREAD_USE_WEAK #define _GLIBCXX_GTHREAD_USE_WEAK 1 #endif #endif #include <bits/gthr-default.h> #ifndef _GLIBCXX_HIDE_EXPORTS #pragma GCC visibility pop #endif #endif /* ! _GLIBCXX_GCC_GTHR_H */ // Base to std::allocator -*- C++ -*- // Copyright (C) 2004-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/c++allocator.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{memory} */ #ifndef _GLIBCXX_CXX_ALLOCATOR_H #define _GLIBCXX_CXX_ALLOCATOR_H 1 #include <ext/new_allocator.h> #if __cplusplus >= 201103L namespace std { /** * @brief An alias to the base class for std::allocator. * * Used to set the std::allocator base class to * __gnu_cxx::new_allocator. * * @ingroup allocators * @tparam _Tp Type of allocated object. */ template<typename _Tp> using __allocator_base = __gnu_cxx::new_allocator<_Tp>; } #else // Define new_allocator as the base class to std::allocator. # define __allocator_base __gnu_cxx::new_allocator #endif #ifndef _GLIBCXX_SANITIZE_STD_ALLOCATOR # if defined(__SANITIZE_ADDRESS__) # define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1 # elif defined __has_feature # if __has_feature(address_sanitizer) # define _GLIBCXX_SANITIZE_STD_ALLOCATOR 1 # endif # endif #endif #endif // Underlying io library details -*- C++ -*- // Copyright (C) 2000-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/c++io.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ios} */ // c_io_stdio.h - Defines for using "C" stdio.h #ifndef _GLIBCXX_CXX_IO_H #define _GLIBCXX_CXX_IO_H 1 #include <cstdio> #include <bits/gthr.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef __gthread_mutex_t __c_lock; // for basic_file.h typedef FILE __c_file; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // C++ includes used for precompiling extensions -*- C++ -*- // Copyright (C) 2006-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file extc++.h * This is an implementation file for a precompiled header. */ #if __cplusplus < 201103L #include <bits/stdtr1c++.h> #else #include <bits/stdc++.h> #endif #include <ext/algorithm> #if __cplusplus >= 201103L # include <ext/aligned_buffer.h> #endif #include <ext/alloc_traits.h> #include <ext/atomicity.h> #include <ext/bitmap_allocator.h> #include <ext/cast.h> #if __cplusplus >= 201103L # include <ext/cmath> #endif #include <ext/concurrence.h> #include <ext/debug_allocator.h> #include <ext/extptr_allocator.h> #include <ext/functional> #include <ext/iterator> #include <ext/malloc_allocator.h> #include <ext/memory> #include <ext/mt_allocator.h> #include <ext/new_allocator.h> #include <ext/numeric> #include <ext/numeric_traits.h> #include <ext/pod_char_traits.h> #include <ext/pointer.h> #include <ext/pool_allocator.h> #if __cplusplus >= 201103L # include <ext/random> #endif #include <ext/rb_tree> #include <ext/rope> #include <ext/slist> #include <ext/stdio_filebuf.h> #include <ext/stdio_sync_filebuf.h> #include <ext/throw_allocator.h> #include <ext/typelist.h> #include <ext/type_traits.h> #include <ext/vstring.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/priority_queue.hpp> #include <ext/pb_ds/exception.hpp> #include <ext/pb_ds/hash_policy.hpp> #include <ext/pb_ds/list_update_policy.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/trie_policy.hpp> #ifdef _GLIBCXX_HAVE_ICONV #include <ext/codecvt_specializations.h> #include <ext/enc_filebuf.h> #endif // Low-level type for atomic operations -*- C++ -*- // Copyright (C) 2004-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file atomic_word.h * This file is a GNU extension to the Standard C++ Library. */ #ifndef _GLIBCXX_ATOMIC_WORD_H #define _GLIBCXX_ATOMIC_WORD_H 1 typedef int _Atomic_word; // This is a memory order acquire fence. #define _GLIBCXX_READ_MEM_BARRIER __atomic_thread_fence (__ATOMIC_ACQUIRE) // This is a memory order release fence. #define _GLIBCXX_WRITE_MEM_BARRIER __atomic_thread_fence (__ATOMIC_RELEASE) #endif // Predefined symbols and macros -*- C++ -*- // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file bits/c++config.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{version} */ #ifndef _GLIBCXX_CXX_CONFIG_H #define _GLIBCXX_CXX_CONFIG_H 1 // The major release number for the GCC release the C++ library belongs to. #define _GLIBCXX_RELEASE 11 // The datestamp of the C++ library in compressed ISO date format. #define __GLIBCXX__ 20240719 // Macros for various attributes. // _GLIBCXX_PURE // _GLIBCXX_CONST // _GLIBCXX_NORETURN // _GLIBCXX_NOTHROW // _GLIBCXX_VISIBILITY #ifndef _GLIBCXX_PURE # define _GLIBCXX_PURE __attribute__ ((__pure__)) #endif #ifndef _GLIBCXX_CONST # define _GLIBCXX_CONST __attribute__ ((__const__)) #endif #ifndef _GLIBCXX_NORETURN # define _GLIBCXX_NORETURN __attribute__ ((__noreturn__)) #endif // See below for C++ #ifndef _GLIBCXX_NOTHROW # ifndef __cplusplus # define _GLIBCXX_NOTHROW __attribute__((__nothrow__)) # endif #endif // Macros for visibility attributes. // _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY // _GLIBCXX_VISIBILITY # define _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY 1 #if _GLIBCXX_HAVE_ATTRIBUTE_VISIBILITY # define _GLIBCXX_VISIBILITY(V) __attribute__ ((__visibility__ (#V))) #else // If this is not supplied by the OS-specific or CPU-specific // headers included below, it will be defined to an empty default. # define _GLIBCXX_VISIBILITY(V) _GLIBCXX_PSEUDO_VISIBILITY(V) #endif // Macros for deprecated attributes. // _GLIBCXX_USE_DEPRECATED // _GLIBCXX_DEPRECATED // _GLIBCXX_DEPRECATED_SUGGEST( string-literal ) // _GLIBCXX11_DEPRECATED // _GLIBCXX11_DEPRECATED_SUGGEST( string-literal ) // _GLIBCXX17_DEPRECATED // _GLIBCXX17_DEPRECATED_SUGGEST( string-literal ) // _GLIBCXX20_DEPRECATED( string-literal ) // _GLIBCXX20_DEPRECATED_SUGGEST( string-literal ) #ifndef _GLIBCXX_USE_DEPRECATED # define _GLIBCXX_USE_DEPRECATED 1 #endif #if defined(__DEPRECATED) # define _GLIBCXX_DEPRECATED __attribute__ ((__deprecated__)) # define _GLIBCXX_DEPRECATED_SUGGEST(ALT) \ __attribute__ ((__deprecated__ ("use '" ALT "' instead"))) #else # define _GLIBCXX_DEPRECATED # define _GLIBCXX_DEPRECATED_SUGGEST(ALT) #endif #if defined(__DEPRECATED) && (__cplusplus >= 201103L) # define _GLIBCXX11_DEPRECATED _GLIBCXX_DEPRECATED # define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) #else # define _GLIBCXX11_DEPRECATED # define _GLIBCXX11_DEPRECATED_SUGGEST(ALT) #endif #if defined(__DEPRECATED) && (__cplusplus >= 201703L) # define _GLIBCXX17_DEPRECATED [[__deprecated__]] # define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) #else # define _GLIBCXX17_DEPRECATED # define _GLIBCXX17_DEPRECATED_SUGGEST(ALT) #endif #if defined(__DEPRECATED) && (__cplusplus > 201703L) # define _GLIBCXX20_DEPRECATED(MSG) [[deprecated(MSG)]] # define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) _GLIBCXX_DEPRECATED_SUGGEST(ALT) #else # define _GLIBCXX20_DEPRECATED(MSG) # define _GLIBCXX20_DEPRECATED_SUGGEST(ALT) #endif // Macros for ABI tag attributes. #ifndef _GLIBCXX_ABI_TAG_CXX11 # define _GLIBCXX_ABI_TAG_CXX11 __attribute ((__abi_tag__ ("cxx11"))) #endif // Macro to warn about unused results. #if __cplusplus >= 201703L # define _GLIBCXX_NODISCARD [[__nodiscard__]] #else # define _GLIBCXX_NODISCARD #endif #if __cplusplus // Macro for constexpr, to support in mixed 03/0x mode. #ifndef _GLIBCXX_CONSTEXPR # if __cplusplus >= 201103L # define _GLIBCXX_CONSTEXPR constexpr # define _GLIBCXX_USE_CONSTEXPR constexpr # else # define _GLIBCXX_CONSTEXPR # define _GLIBCXX_USE_CONSTEXPR const # endif #endif #ifndef _GLIBCXX14_CONSTEXPR # if __cplusplus >= 201402L # define _GLIBCXX14_CONSTEXPR constexpr # else # define _GLIBCXX14_CONSTEXPR # endif #endif #ifndef _GLIBCXX17_CONSTEXPR # if __cplusplus >= 201703L # define _GLIBCXX17_CONSTEXPR constexpr # else # define _GLIBCXX17_CONSTEXPR # endif #endif #ifndef _GLIBCXX20_CONSTEXPR # if __cplusplus > 201703L # define _GLIBCXX20_CONSTEXPR constexpr # else # define _GLIBCXX20_CONSTEXPR # endif #endif #ifndef _GLIBCXX17_INLINE # if __cplusplus >= 201703L # define _GLIBCXX17_INLINE inline # else # define _GLIBCXX17_INLINE # endif #endif // Macro for noexcept, to support in mixed 03/0x mode. #ifndef _GLIBCXX_NOEXCEPT # if __cplusplus >= 201103L # define _GLIBCXX_NOEXCEPT noexcept # define _GLIBCXX_NOEXCEPT_IF(...) noexcept(__VA_ARGS__) # define _GLIBCXX_USE_NOEXCEPT noexcept # define _GLIBCXX_THROW(_EXC) # else # define _GLIBCXX_NOEXCEPT # define _GLIBCXX_NOEXCEPT_IF(...) # define _GLIBCXX_USE_NOEXCEPT throw() # define _GLIBCXX_THROW(_EXC) throw(_EXC) # endif #endif #ifndef _GLIBCXX_NOTHROW # define _GLIBCXX_NOTHROW _GLIBCXX_USE_NOEXCEPT #endif #ifndef _GLIBCXX_THROW_OR_ABORT # if __cpp_exceptions # define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC)) # else # define _GLIBCXX_THROW_OR_ABORT(_EXC) (__builtin_abort()) # endif #endif #if __cpp_noexcept_function_type #define _GLIBCXX_NOEXCEPT_PARM , bool _NE #define _GLIBCXX_NOEXCEPT_QUAL noexcept (_NE) #else #define _GLIBCXX_NOEXCEPT_PARM #define _GLIBCXX_NOEXCEPT_QUAL #endif // Macro for extern template, ie controlling template linkage via use // of extern keyword on template declaration. As documented in the g++ // manual, it inhibits all implicit instantiations and is used // throughout the library to avoid multiple weak definitions for // required types that are already explicitly instantiated in the // library binary. This substantially reduces the binary size of // resulting executables. // Special case: _GLIBCXX_EXTERN_TEMPLATE == -1 disallows extern // templates only in basic_string, thus activating its debug-mode // checks even at -O0. # define _GLIBCXX_EXTERN_TEMPLATE 1 /* Outline of libstdc++ namespaces. namespace std { namespace __debug { } namespace __parallel { } namespace __cxx1998 { } namespace __detail { namespace __variant { } // C++17 } namespace rel_ops { } namespace tr1 { namespace placeholders { } namespace regex_constants { } namespace __detail { } } namespace tr2 { } namespace decimal { } namespace chrono { } // C++11 namespace placeholders { } // C++11 namespace regex_constants { } // C++11 namespace this_thread { } // C++11 inline namespace literals { // C++14 inline namespace chrono_literals { } // C++14 inline namespace complex_literals { } // C++14 inline namespace string_literals { } // C++14 inline namespace string_view_literals { } // C++17 } } namespace abi { } namespace __gnu_cxx { namespace __detail { } } For full details see: http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html */ namespace std { typedef __SIZE_TYPE__ size_t; typedef __PTRDIFF_TYPE__ ptrdiff_t; #if __cplusplus >= 201103L typedef decltype(nullptr) nullptr_t; #endif } # define _GLIBCXX_USE_DUAL_ABI 1 #if ! _GLIBCXX_USE_DUAL_ABI // Ignore any pre-defined value of _GLIBCXX_USE_CXX11_ABI # undef _GLIBCXX_USE_CXX11_ABI #endif #ifndef _GLIBCXX_USE_CXX11_ABI # define _GLIBCXX_USE_CXX11_ABI 1 #endif #if _GLIBCXX_USE_CXX11_ABI namespace std { inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } } namespace __gnu_cxx { inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } } # define _GLIBCXX_NAMESPACE_CXX11 __cxx11:: # define _GLIBCXX_BEGIN_NAMESPACE_CXX11 namespace __cxx11 { # define _GLIBCXX_END_NAMESPACE_CXX11 } # define _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_ABI_TAG_CXX11 #else # define _GLIBCXX_NAMESPACE_CXX11 # define _GLIBCXX_BEGIN_NAMESPACE_CXX11 # define _GLIBCXX_END_NAMESPACE_CXX11 # define _GLIBCXX_DEFAULT_ABI_TAG #endif // Defined if inline namespaces are used for versioning. # define _GLIBCXX_INLINE_VERSION 0 // Inline namespace for symbol versioning. #if _GLIBCXX_INLINE_VERSION # define _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __8 { # define _GLIBCXX_END_NAMESPACE_VERSION } namespace std { inline _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201402L inline namespace literals { inline namespace chrono_literals { } inline namespace complex_literals { } inline namespace string_literals { } #if __cplusplus > 201402L inline namespace string_view_literals { } #endif // C++17 } #endif // C++14 _GLIBCXX_END_NAMESPACE_VERSION } namespace __gnu_cxx { inline _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } #else # define _GLIBCXX_BEGIN_NAMESPACE_VERSION # define _GLIBCXX_END_NAMESPACE_VERSION #endif // Inline namespaces for special modes: debug, parallel. #if defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL) namespace std { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Non-inline namespace for components replaced by alternates in active mode. namespace __cxx1998 { # if _GLIBCXX_USE_CXX11_ABI inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } # endif } _GLIBCXX_END_NAMESPACE_VERSION // Inline namespace for debug mode. # ifdef _GLIBCXX_DEBUG inline namespace __debug { } # endif // Inline namespaces for parallel mode. # ifdef _GLIBCXX_PARALLEL inline namespace __parallel { } # endif } // Check for invalid usage and unsupported mixed-mode use. # if defined(_GLIBCXX_DEBUG) && defined(_GLIBCXX_PARALLEL) # error illegal use of multiple inlined namespaces # endif // Check for invalid use due to lack for weak symbols. # if __NO_INLINE__ && !__GXX_WEAK__ # warning currently using inlined namespace mode which may fail \ without inlining due to lack of weak symbols # endif #endif // Macros for namespace scope. Either namespace std:: or the name // of some nested namespace within it corresponding to the active mode. // _GLIBCXX_STD_A // _GLIBCXX_STD_C // // Macros for opening/closing conditional namespaces. // _GLIBCXX_BEGIN_NAMESPACE_ALGO // _GLIBCXX_END_NAMESPACE_ALGO // _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_END_NAMESPACE_CONTAINER #if defined(_GLIBCXX_DEBUG) # define _GLIBCXX_STD_C __cxx1998 # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER \ namespace _GLIBCXX_STD_C { # define _GLIBCXX_END_NAMESPACE_CONTAINER } #else # define _GLIBCXX_STD_C std # define _GLIBCXX_BEGIN_NAMESPACE_CONTAINER # define _GLIBCXX_END_NAMESPACE_CONTAINER #endif #ifdef _GLIBCXX_PARALLEL # define _GLIBCXX_STD_A __cxx1998 # define _GLIBCXX_BEGIN_NAMESPACE_ALGO \ namespace _GLIBCXX_STD_A { # define _GLIBCXX_END_NAMESPACE_ALGO } #else # define _GLIBCXX_STD_A std # define _GLIBCXX_BEGIN_NAMESPACE_ALGO # define _GLIBCXX_END_NAMESPACE_ALGO #endif // GLIBCXX_ABI Deprecated // Define if compatibility should be provided for -mlong-double-64. #undef _GLIBCXX_LONG_DOUBLE_COMPAT // Define if compatibility should be provided for alternative 128-bit long // double formats. Not possible for Clang until __ibm128 is supported. #ifndef __clang__ #undef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT #endif // Inline namespaces for long double 128 modes. #if defined _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT \ && defined __LONG_DOUBLE_IEEE128__ namespace std { // Namespaces for 128-bit IEEE long double format on 64-bit POWER LE. inline namespace __gnu_cxx_ieee128 { } inline namespace __gnu_cxx11_ieee128 { } } # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ieee128:: # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ieee128 { # define _GLIBCXX_END_NAMESPACE_LDBL } # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 __gnu_cxx11_ieee128:: # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 namespace __gnu_cxx11_ieee128 { # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 } #else // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 #if defined _GLIBCXX_LONG_DOUBLE_COMPAT && defined __LONG_DOUBLE_128__ namespace std { inline namespace __gnu_cxx_ldbl128 { } } # define _GLIBCXX_NAMESPACE_LDBL __gnu_cxx_ldbl128:: # define _GLIBCXX_BEGIN_NAMESPACE_LDBL namespace __gnu_cxx_ldbl128 { # define _GLIBCXX_END_NAMESPACE_LDBL } #else # define _GLIBCXX_NAMESPACE_LDBL # define _GLIBCXX_BEGIN_NAMESPACE_LDBL # define _GLIBCXX_END_NAMESPACE_LDBL #endif #if _GLIBCXX_USE_CXX11_ABI # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_CXX11 # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_CXX11 # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_CXX11 #else # define _GLIBCXX_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_NAMESPACE_LDBL # define _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_BEGIN_NAMESPACE_LDBL # define _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 _GLIBCXX_END_NAMESPACE_LDBL #endif #endif // _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT && IEEE128 // Debug Mode implies checking assertions. #if defined(_GLIBCXX_DEBUG) && !defined(_GLIBCXX_ASSERTIONS) # define _GLIBCXX_ASSERTIONS 1 #endif // Disable std::string explicit instantiation declarations in order to assert. #ifdef _GLIBCXX_ASSERTIONS # undef _GLIBCXX_EXTERN_TEMPLATE # define _GLIBCXX_EXTERN_TEMPLATE -1 #endif #if __has_builtin(__builtin_is_constant_evaluated) # define __glibcxx_constexpr_assert(cond) \ if (__builtin_is_constant_evaluated() && !bool(cond)) \ __builtin_unreachable() /* precondition violation detected! */ #else # define __glibcxx_constexpr_assert(unevaluated) #endif // Assert. #if defined(_GLIBCXX_ASSERTIONS) \ || defined(_GLIBCXX_PARALLEL) || defined(_GLIBCXX_PARALLEL_ASSERTIONS) namespace std { // Avoid the use of assert, because we're trying to keep the <cassert> // include out of the mix. extern "C++" _GLIBCXX_NORETURN inline void __replacement_assert(const char* __file, int __line, const char* __function, const char* __condition) { __builtin_printf("%s:%d: %s: Assertion '%s' failed.\n", __file, __line, __function, __condition); __builtin_abort(); } } #define __glibcxx_assert_impl(_Condition) \ if (__builtin_expect(!bool(_Condition), false)) \ { \ __glibcxx_constexpr_assert(_Condition); \ std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \ #_Condition); \ } #endif #if defined(_GLIBCXX_ASSERTIONS) # define __glibcxx_assert(cond) \ do { __glibcxx_assert_impl(cond); } while (false) #else # define __glibcxx_assert(cond) \ do { __glibcxx_constexpr_assert(cond); } while (false) #endif // Macros for race detectors. // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) and // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) should be used to explain // atomic (lock-free) synchronization to race detectors: // the race detector will infer a happens-before arc from the former to the // latter when they share the same argument pointer. // // The most frequent use case for these macros (and the only case in the // current implementation of the library) is atomic reference counting: // void _M_remove_reference() // { // _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount); // if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount, -1) <= 0) // { // _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount); // _M_destroy(__a); // } // } // The annotations in this example tell the race detector that all memory // accesses occurred when the refcount was positive do not race with // memory accesses which occurred after the refcount became zero. #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(A) #endif #ifndef _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER # define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(A) #endif // Macros for C linkage: define extern "C" linkage only when using C++. # define _GLIBCXX_BEGIN_EXTERN_C extern "C" { # define _GLIBCXX_END_EXTERN_C } # define _GLIBCXX_USE_ALLOCATOR_NEW 1 #ifdef __SIZEOF_INT128__ #if ! defined __GLIBCXX_TYPE_INT_N_0 && ! defined __STRICT_ANSI__ // If __int128 is supported, we expect __GLIBCXX_TYPE_INT_N_0 to be defined // unless the compiler is in strict mode. If it's not defined and the strict // macro is not defined, something is wrong. #warning "__STRICT_ANSI__ seems to have been undefined; this is not supported" #endif #endif #else // !__cplusplus # define _GLIBCXX_BEGIN_EXTERN_C # define _GLIBCXX_END_EXTERN_C #endif // First includes. // Pick up any OS-specific definitions. #include <bits/os_defines.h> // Pick up any CPU-specific definitions. #include <bits/cpu_defines.h> // If platform uses neither visibility nor psuedo-visibility, // specify empty default for namespace annotation macros. #ifndef _GLIBCXX_PSEUDO_VISIBILITY # define _GLIBCXX_PSEUDO_VISIBILITY(V) #endif // Certain function definitions that are meant to be overridable from // user code are decorated with this macro. For some targets, this // macro causes these definitions to be weak. #ifndef _GLIBCXX_WEAK_DEFINITION # define _GLIBCXX_WEAK_DEFINITION #endif // By default, we assume that __GXX_WEAK__ also means that there is support // for declaring functions as weak while not defining such functions. This // allows for referring to functions provided by other libraries (e.g., // libitm) without depending on them if the respective features are not used. #ifndef _GLIBCXX_USE_WEAK_REF # define _GLIBCXX_USE_WEAK_REF __GXX_WEAK__ #endif // Conditionally enable annotations for the Transactional Memory TS on C++11. // Most of the following conditions are due to limitations in the current // implementation. #if __cplusplus >= 201103L && _GLIBCXX_USE_CXX11_ABI \ && _GLIBCXX_USE_DUAL_ABI && __cpp_transactional_memory >= 201500L \ && !_GLIBCXX_FULLY_DYNAMIC_STRING && _GLIBCXX_USE_WEAK_REF \ && _GLIBCXX_USE_ALLOCATOR_NEW #define _GLIBCXX_TXN_SAFE transaction_safe #define _GLIBCXX_TXN_SAFE_DYN transaction_safe_dynamic #else #define _GLIBCXX_TXN_SAFE #define _GLIBCXX_TXN_SAFE_DYN #endif #if __cplusplus > 201402L // In C++17 mathematical special functions are in namespace std. # define _GLIBCXX_USE_STD_SPEC_FUNCS 1 #elif __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0 // For C++11 and C++14 they are in namespace std when requested. # define _GLIBCXX_USE_STD_SPEC_FUNCS 1 #endif // The remainder of the prewritten config is automatic; all the // user hooks are listed above. // Create a boolean flag to be used to determine if --fast-math is set. #ifdef __FAST_MATH__ # define _GLIBCXX_FAST_MATH 1 #else # define _GLIBCXX_FAST_MATH 0 #endif // This marks string literals in header files to be extracted for eventual // translation. It is primarily used for messages in thrown exceptions; see // src/functexcept.cc. We use __N because the more traditional _N is used // for something else under certain OSes (see BADNAMES). #define __N(msgid) (msgid) // For example, <windows.h> is known to #define min and max as macros... #undef min #undef max // N.B. these _GLIBCXX_USE_C99_XXX macros are defined unconditionally // so they should be tested with #if not with #ifdef. #if __cplusplus >= 201103L # ifndef _GLIBCXX_USE_C99_MATH # define _GLIBCXX_USE_C99_MATH _GLIBCXX11_USE_C99_MATH # endif # ifndef _GLIBCXX_USE_C99_COMPLEX # define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX11_USE_C99_COMPLEX # endif # ifndef _GLIBCXX_USE_C99_STDIO # define _GLIBCXX_USE_C99_STDIO _GLIBCXX11_USE_C99_STDIO # endif # ifndef _GLIBCXX_USE_C99_STDLIB # define _GLIBCXX_USE_C99_STDLIB _GLIBCXX11_USE_C99_STDLIB # endif # ifndef _GLIBCXX_USE_C99_WCHAR # define _GLIBCXX_USE_C99_WCHAR _GLIBCXX11_USE_C99_WCHAR # endif #else # ifndef _GLIBCXX_USE_C99_MATH # define _GLIBCXX_USE_C99_MATH _GLIBCXX98_USE_C99_MATH # endif # ifndef _GLIBCXX_USE_C99_COMPLEX # define _GLIBCXX_USE_C99_COMPLEX _GLIBCXX98_USE_C99_COMPLEX # endif # ifndef _GLIBCXX_USE_C99_STDIO # define _GLIBCXX_USE_C99_STDIO _GLIBCXX98_USE_C99_STDIO # endif # ifndef _GLIBCXX_USE_C99_STDLIB # define _GLIBCXX_USE_C99_STDLIB _GLIBCXX98_USE_C99_STDLIB # endif # ifndef _GLIBCXX_USE_C99_WCHAR # define _GLIBCXX_USE_C99_WCHAR _GLIBCXX98_USE_C99_WCHAR # endif #endif // Unless explicitly specified, enable char8_t extensions only if the core // language char8_t feature macro is defined. #ifndef _GLIBCXX_USE_CHAR8_T # ifdef __cpp_char8_t # define _GLIBCXX_USE_CHAR8_T 1 # endif #endif #ifdef _GLIBCXX_USE_CHAR8_T # define __cpp_lib_char8_t 201907L #endif /* Define if __float128 is supported on this host. */ #if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) /* For powerpc64 don't use __float128 when it's the same type as long double. */ # if !(defined(_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT) && defined(__LONG_DOUBLE_IEEE128__)) # define _GLIBCXX_USE_FLOAT128 1 # endif #endif // Define if float has the IEEE binary32 format. #if __FLT_MANT_DIG__ == 24 \ && __FLT_MIN_EXP__ == -125 \ && __FLT_MAX_EXP__ == 128 # define _GLIBCXX_FLOAT_IS_IEEE_BINARY32 1 #endif // Define if double has the IEEE binary64 format. #if __DBL_MANT_DIG__ == 53 \ && __DBL_MIN_EXP__ == -1021 \ && __DBL_MAX_EXP__ == 1024 # define _GLIBCXX_DOUBLE_IS_IEEE_BINARY64 1 #endif #ifdef __has_builtin # ifdef __is_identifier // Intel and older Clang require !__is_identifier for some built-ins: # define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) || ! __is_identifier(B) # else # define _GLIBCXX_HAS_BUILTIN(B) __has_builtin(B) # endif #endif #if _GLIBCXX_HAS_BUILTIN(__has_unique_object_representations) # define _GLIBCXX_HAVE_BUILTIN_HAS_UNIQ_OBJ_REP 1 #endif #if _GLIBCXX_HAS_BUILTIN(__is_aggregate) # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 #endif #if _GLIBCXX_HAS_BUILTIN(__builtin_is_constant_evaluated) # define _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED 1 #endif #if _GLIBCXX_HAS_BUILTIN(__is_same) # define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1 #endif #if _GLIBCXX_HAS_BUILTIN(__builtin_launder) # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 #endif #undef _GLIBCXX_HAS_BUILTIN // PSTL configuration #if __cplusplus >= 201703L // This header is not installed for freestanding: #if __has_include(<pstl/pstl_config.h>) // Preserved here so we have some idea which version of upstream we've pulled in // #define PSTL_VERSION 9000 // For now this defaults to being based on the presence of Thread Building Blocks # ifndef _GLIBCXX_USE_TBB_PAR_BACKEND # define _GLIBCXX_USE_TBB_PAR_BACKEND __has_include(<tbb/tbb.h>) # endif // This section will need some rework when a new (default) backend type is added # if _GLIBCXX_USE_TBB_PAR_BACKEND # define _PSTL_PAR_BACKEND_TBB # else # define _PSTL_PAR_BACKEND_SERIAL # endif # define _PSTL_ASSERT(_Condition) __glibcxx_assert(_Condition) # define _PSTL_ASSERT_MSG(_Condition, _Message) __glibcxx_assert(_Condition) #include <pstl/pstl_config.h> #endif // __has_include #endif // C++17 // End of prewritten config; the settings discovered at configure time follow. /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `acosf' function. */ #define _GLIBCXX_HAVE_ACOSF 1 /* Define to 1 if you have the `acosl' function. */ #define _GLIBCXX_HAVE_ACOSL 1 /* Define to 1 if you have the `aligned_alloc' function. */ #define _GLIBCXX_HAVE_ALIGNED_ALLOC 1 /* Define to 1 if you have the <arpa/inet.h> header file. */ #define _GLIBCXX_HAVE_ARPA_INET_H 1 /* Define to 1 if you have the `asinf' function. */ #define _GLIBCXX_HAVE_ASINF 1 /* Define to 1 if you have the `asinl' function. */ #define _GLIBCXX_HAVE_ASINL 1 /* Define to 1 if the target assembler supports .symver directive. */ #define _GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE 1 /* Define to 1 if you have the `atan2f' function. */ #define _GLIBCXX_HAVE_ATAN2F 1 /* Define to 1 if you have the `atan2l' function. */ #define _GLIBCXX_HAVE_ATAN2L 1 /* Define to 1 if you have the `atanf' function. */ #define _GLIBCXX_HAVE_ATANF 1 /* Define to 1 if you have the `atanl' function. */ #define _GLIBCXX_HAVE_ATANL 1 /* Defined if shared_ptr reference counting should use atomic operations. */ #define _GLIBCXX_HAVE_ATOMIC_LOCK_POLICY 1 /* Define to 1 if you have the `at_quick_exit' function. */ #define _GLIBCXX_HAVE_AT_QUICK_EXIT 1 /* Define to 1 if the target assembler supports thread-local storage. */ /* #undef _GLIBCXX_HAVE_CC_TLS */ /* Define to 1 if you have the `ceilf' function. */ #define _GLIBCXX_HAVE_CEILF 1 /* Define to 1 if you have the `ceill' function. */ #define _GLIBCXX_HAVE_CEILL 1 /* Define to 1 if you have the <complex.h> header file. */ #define _GLIBCXX_HAVE_COMPLEX_H 1 /* Define to 1 if you have the `cosf' function. */ #define _GLIBCXX_HAVE_COSF 1 /* Define to 1 if you have the `coshf' function. */ #define _GLIBCXX_HAVE_COSHF 1 /* Define to 1 if you have the `coshl' function. */ #define _GLIBCXX_HAVE_COSHL 1 /* Define to 1 if you have the `cosl' function. */ #define _GLIBCXX_HAVE_COSL 1 /* Define to 1 if you have the <dirent.h> header file. */ #define _GLIBCXX_HAVE_DIRENT_H 1 /* Define if dirfd is available in <dirent.h>. */ #define _GLIBCXX_HAVE_DIRFD 1 /* Define to 1 if you have the <dlfcn.h> header file. */ #define _GLIBCXX_HAVE_DLFCN_H 1 /* Define to 1 if you have the <endian.h> header file. */ #define _GLIBCXX_HAVE_ENDIAN_H 1 /* Define to 1 if GCC 4.6 supported std::exception_ptr for the target */ #define _GLIBCXX_HAVE_EXCEPTION_PTR_SINCE_GCC46 1 /* Define to 1 if you have the <execinfo.h> header file. */ #define _GLIBCXX_HAVE_EXECINFO_H 1 /* Define to 1 if you have the `expf' function. */ #define _GLIBCXX_HAVE_EXPF 1 /* Define to 1 if you have the `expl' function. */ #define _GLIBCXX_HAVE_EXPL 1 /* Define to 1 if you have the `fabsf' function. */ #define _GLIBCXX_HAVE_FABSF 1 /* Define to 1 if you have the `fabsl' function. */ #define _GLIBCXX_HAVE_FABSL 1 /* Define to 1 if you have the <fcntl.h> header file. */ #define _GLIBCXX_HAVE_FCNTL_H 1 /* Define if fdopendir is available in <dirent.h>. */ #define _GLIBCXX_HAVE_FDOPENDIR 1 /* Define to 1 if you have the <fenv.h> header file. */ #define _GLIBCXX_HAVE_FENV_H 1 /* Define to 1 if you have the `finite' function. */ #define _GLIBCXX_HAVE_FINITE 1 /* Define to 1 if you have the `finitef' function. */ #define _GLIBCXX_HAVE_FINITEF 1 /* Define to 1 if you have the `finitel' function. */ #define _GLIBCXX_HAVE_FINITEL 1 /* Define to 1 if you have the <float.h> header file. */ #define _GLIBCXX_HAVE_FLOAT_H 1 /* Define to 1 if you have the `floorf' function. */ #define _GLIBCXX_HAVE_FLOORF 1 /* Define to 1 if you have the `floorl' function. */ #define _GLIBCXX_HAVE_FLOORL 1 /* Define to 1 if you have the `fmodf' function. */ #define _GLIBCXX_HAVE_FMODF 1 /* Define to 1 if you have the `fmodl' function. */ #define _GLIBCXX_HAVE_FMODL 1 /* Define to 1 if you have the `fpclass' function. */ /* #undef _GLIBCXX_HAVE_FPCLASS */ /* Define to 1 if you have the <fp.h> header file. */ /* #undef _GLIBCXX_HAVE_FP_H */ /* Define to 1 if you have the `frexpf' function. */ #define _GLIBCXX_HAVE_FREXPF 1 /* Define to 1 if you have the `frexpl' function. */ #define _GLIBCXX_HAVE_FREXPL 1 /* Define if _Unwind_GetIPInfo is available. */ #define _GLIBCXX_HAVE_GETIPINFO 1 /* Define if gets is available in <stdio.h> before C++14. */ #define _GLIBCXX_HAVE_GETS 1 /* Define to 1 if you have the `hypot' function. */ #define _GLIBCXX_HAVE_HYPOT 1 /* Define to 1 if you have the `hypotf' function. */ #define _GLIBCXX_HAVE_HYPOTF 1 /* Define to 1 if you have the `hypotl' function. */ #define _GLIBCXX_HAVE_HYPOTL 1 /* Define if you have the iconv() function. */ #define _GLIBCXX_HAVE_ICONV 1 /* Define to 1 if you have the <ieeefp.h> header file. */ /* #undef _GLIBCXX_HAVE_IEEEFP_H */ /* Define if int64_t is available in <stdint.h>. */ #define _GLIBCXX_HAVE_INT64_T 1 /* Define if int64_t is a long. */ /* #undef _GLIBCXX_HAVE_INT64_T_LONG */ /* Define if int64_t is a long long. */ #define _GLIBCXX_HAVE_INT64_T_LONG_LONG 1 /* Define to 1 if you have the <inttypes.h> header file. */ #define _GLIBCXX_HAVE_INTTYPES_H 1 /* Define to 1 if you have the `isinf' function. */ /* #undef _GLIBCXX_HAVE_ISINF */ /* Define to 1 if you have the `isinff' function. */ #define _GLIBCXX_HAVE_ISINFF 1 /* Define to 1 if you have the `isinfl' function. */ #define _GLIBCXX_HAVE_ISINFL 1 /* Define to 1 if you have the `isnan' function. */ /* #undef _GLIBCXX_HAVE_ISNAN */ /* Define to 1 if you have the `isnanf' function. */ #define _GLIBCXX_HAVE_ISNANF 1 /* Define to 1 if you have the `isnanl' function. */ #define _GLIBCXX_HAVE_ISNANL 1 /* Defined if iswblank exists. */ #define _GLIBCXX_HAVE_ISWBLANK 1 /* Define if LC_MESSAGES is available in <locale.h>. */ #define _GLIBCXX_HAVE_LC_MESSAGES 1 /* Define to 1 if you have the `ldexpf' function. */ #define _GLIBCXX_HAVE_LDEXPF 1 /* Define to 1 if you have the `ldexpl' function. */ #define _GLIBCXX_HAVE_LDEXPL 1 /* Define to 1 if you have the <libintl.h> header file. */ #define _GLIBCXX_HAVE_LIBINTL_H 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_AS 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_DATA 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_FSIZE 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_RSS 1 /* Only used in build directory testsuite_hooks.h. */ #define _GLIBCXX_HAVE_LIMIT_VMEM 0 /* Define if link is available in <unistd.h>. */ #define _GLIBCXX_HAVE_LINK 1 /* Define if futex syscall is available. */ #define _GLIBCXX_HAVE_LINUX_FUTEX 1 /* Define to 1 if you have the <linux/random.h> header file. */ #define _GLIBCXX_HAVE_LINUX_RANDOM_H 1 /* Define to 1 if you have the <linux/types.h> header file. */ #define _GLIBCXX_HAVE_LINUX_TYPES_H 1 /* Define to 1 if you have the <locale.h> header file. */ #define _GLIBCXX_HAVE_LOCALE_H 1 /* Define to 1 if you have the `log10f' function. */ #define _GLIBCXX_HAVE_LOG10F 1 /* Define to 1 if you have the `log10l' function. */ #define _GLIBCXX_HAVE_LOG10L 1 /* Define to 1 if you have the `logf' function. */ #define _GLIBCXX_HAVE_LOGF 1 /* Define to 1 if you have the `logl' function. */ #define _GLIBCXX_HAVE_LOGL 1 /* Define to 1 if you have the <machine/endian.h> header file. */ /* #undef _GLIBCXX_HAVE_MACHINE_ENDIAN_H */ /* Define to 1 if you have the <machine/param.h> header file. */ /* #undef _GLIBCXX_HAVE_MACHINE_PARAM_H */ /* Define if mbstate_t exists in wchar.h. */ #define _GLIBCXX_HAVE_MBSTATE_T 1 /* Define to 1 if you have the `memalign' function. */ #define _GLIBCXX_HAVE_MEMALIGN 1 /* Define to 1 if you have the <memory.h> header file. */ #define _GLIBCXX_HAVE_MEMORY_H 1 /* Define to 1 if you have the `modf' function. */ #define _GLIBCXX_HAVE_MODF 1 /* Define to 1 if you have the `modff' function. */ #define _GLIBCXX_HAVE_MODFF 1 /* Define to 1 if you have the `modfl' function. */ #define _GLIBCXX_HAVE_MODFL 1 /* Define to 1 if you have the <nan.h> header file. */ /* #undef _GLIBCXX_HAVE_NAN_H */ /* Define to 1 if you have the <netdb.h> header file. */ #define _GLIBCXX_HAVE_NETDB_H 1 /* Define to 1 if you have the <netinet/in.h> header file. */ #define _GLIBCXX_HAVE_NETINET_IN_H 1 /* Define to 1 if you have the <netinet/tcp.h> header file. */ #define _GLIBCXX_HAVE_NETINET_TCP_H 1 /* Define if <math.h> defines obsolete isinf function. */ /* #undef _GLIBCXX_HAVE_OBSOLETE_ISINF */ /* Define if <math.h> defines obsolete isnan function. */ /* #undef _GLIBCXX_HAVE_OBSOLETE_ISNAN */ /* Define if openat is available in <fcntl.h>. */ #define _GLIBCXX_HAVE_OPENAT 1 /* Define if poll is available in <poll.h>. */ #define _GLIBCXX_HAVE_POLL 1 /* Define to 1 if you have the <poll.h> header file. */ #define _GLIBCXX_HAVE_POLL_H 1 /* Define to 1 if you have the `posix_memalign' function. */ #define _GLIBCXX_HAVE_POSIX_MEMALIGN 1 /* Define to 1 if POSIX Semaphores with sem_timedwait are available in <semaphore.h>. */ #define _GLIBCXX_HAVE_POSIX_SEMAPHORE 1 /* Define to 1 if you have the `powf' function. */ #define _GLIBCXX_HAVE_POWF 1 /* Define to 1 if you have the `powl' function. */ #define _GLIBCXX_HAVE_POWL 1 /* Define to 1 if you have the `qfpclass' function. */ /* #undef _GLIBCXX_HAVE_QFPCLASS */ /* Define to 1 if you have the `quick_exit' function. */ #define _GLIBCXX_HAVE_QUICK_EXIT 1 /* Define if readlink is available in <unistd.h>. */ #define _GLIBCXX_HAVE_READLINK 1 /* Define to 1 if you have the `secure_getenv' function. */ #define _GLIBCXX_HAVE_SECURE_GETENV 1 /* Define to 1 if you have the `setenv' function. */ #define _GLIBCXX_HAVE_SETENV 1 /* Define to 1 if you have the `sincos' function. */ #define _GLIBCXX_HAVE_SINCOS 1 /* Define to 1 if you have the `sincosf' function. */ #define _GLIBCXX_HAVE_SINCOSF 1 /* Define to 1 if you have the `sincosl' function. */ #define _GLIBCXX_HAVE_SINCOSL 1 /* Define to 1 if you have the `sinf' function. */ #define _GLIBCXX_HAVE_SINF 1 /* Define to 1 if you have the `sinhf' function. */ #define _GLIBCXX_HAVE_SINHF 1 /* Define to 1 if you have the `sinhl' function. */ #define _GLIBCXX_HAVE_SINHL 1 /* Define to 1 if you have the `sinl' function. */ #define _GLIBCXX_HAVE_SINL 1 /* Defined if sleep exists. */ /* #undef _GLIBCXX_HAVE_SLEEP */ /* Define to 1 if you have the `sockatmark' function. */ #define _GLIBCXX_HAVE_SOCKATMARK 1 /* Define to 1 if you have the `sqrtf' function. */ #define _GLIBCXX_HAVE_SQRTF 1 /* Define to 1 if you have the `sqrtl' function. */ #define _GLIBCXX_HAVE_SQRTL 1 /* Define to 1 if you have the <stdalign.h> header file. */ #define _GLIBCXX_HAVE_STDALIGN_H 1 /* Define to 1 if you have the <stdbool.h> header file. */ #define _GLIBCXX_HAVE_STDBOOL_H 1 /* Define to 1 if you have the <stdint.h> header file. */ #define _GLIBCXX_HAVE_STDINT_H 1 /* Define to 1 if you have the <stdlib.h> header file. */ #define _GLIBCXX_HAVE_STDLIB_H 1 /* Define if strerror_l is available in <string.h>. */ #define _GLIBCXX_HAVE_STRERROR_L 1 /* Define if strerror_r is available in <string.h>. */ #define _GLIBCXX_HAVE_STRERROR_R 1 /* Define to 1 if you have the <strings.h> header file. */ #define _GLIBCXX_HAVE_STRINGS_H 1 /* Define to 1 if you have the <string.h> header file. */ #define _GLIBCXX_HAVE_STRING_H 1 /* Define to 1 if you have the `strtof' function. */ #define _GLIBCXX_HAVE_STRTOF 1 /* Define to 1 if you have the `strtold' function. */ #define _GLIBCXX_HAVE_STRTOLD 1 /* Define to 1 if `d_type' is a member of `struct dirent'. */ #define _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE 1 /* Define if strxfrm_l is available in <string.h>. */ #define _GLIBCXX_HAVE_STRXFRM_L 1 /* Define if symlink is available in <unistd.h>. */ #define _GLIBCXX_HAVE_SYMLINK 1 /* Define to 1 if the target runtime linker supports binding the same symbol to different versions. */ #define _GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT 1 /* Define to 1 if you have the <sys/filio.h> header file. */ /* #undef _GLIBCXX_HAVE_SYS_FILIO_H */ /* Define to 1 if you have the <sys/ioctl.h> header file. */ #define _GLIBCXX_HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the <sys/ipc.h> header file. */ #define _GLIBCXX_HAVE_SYS_IPC_H 1 /* Define to 1 if you have the <sys/isa_defs.h> header file. */ /* #undef _GLIBCXX_HAVE_SYS_ISA_DEFS_H */ /* Define to 1 if you have the <sys/machine.h> header file. */ /* #undef _GLIBCXX_HAVE_SYS_MACHINE_H */ /* Define to 1 if you have the <sys/param.h> header file. */ #define _GLIBCXX_HAVE_SYS_PARAM_H 1 /* Define to 1 if you have the <sys/resource.h> header file. */ #define _GLIBCXX_HAVE_SYS_RESOURCE_H 1 /* Define to 1 if you have a suitable <sys/sdt.h> header file */ #define _GLIBCXX_HAVE_SYS_SDT_H 1 /* Define to 1 if you have the <sys/sem.h> header file. */ #define _GLIBCXX_HAVE_SYS_SEM_H 1 /* Define to 1 if you have the <sys/socket.h> header file. */ #define _GLIBCXX_HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the <sys/statvfs.h> header file. */ #define _GLIBCXX_HAVE_SYS_STATVFS_H 1 /* Define to 1 if you have the <sys/stat.h> header file. */ #define _GLIBCXX_HAVE_SYS_STAT_H 1 /* Define to 1 if you have the <sys/sysinfo.h> header file. */ #define _GLIBCXX_HAVE_SYS_SYSINFO_H 1 /* Define to 1 if you have the <sys/time.h> header file. */ #define _GLIBCXX_HAVE_SYS_TIME_H 1 /* Define to 1 if you have the <sys/types.h> header file. */ #define _GLIBCXX_HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the <sys/uio.h> header file. */ #define _GLIBCXX_HAVE_SYS_UIO_H 1 /* Define if S_IFREG is available in <sys/stat.h>. */ /* #undef _GLIBCXX_HAVE_S_IFREG */ /* Define if S_ISREG is available in <sys/stat.h>. */ #define _GLIBCXX_HAVE_S_ISREG 1 /* Define to 1 if you have the `tanf' function. */ #define _GLIBCXX_HAVE_TANF 1 /* Define to 1 if you have the `tanhf' function. */ #define _GLIBCXX_HAVE_TANHF 1 /* Define to 1 if you have the `tanhl' function. */ #define _GLIBCXX_HAVE_TANHL 1 /* Define to 1 if you have the `tanl' function. */ #define _GLIBCXX_HAVE_TANL 1 /* Define to 1 if you have the <tgmath.h> header file. */ #define _GLIBCXX_HAVE_TGMATH_H 1 /* Define to 1 if you have the `timespec_get' function. */ #define _GLIBCXX_HAVE_TIMESPEC_GET 1 /* Define to 1 if the target supports thread-local storage. */ #define _GLIBCXX_HAVE_TLS 1 /* Define if truncate is available in <unistd.h>. */ #define _GLIBCXX_HAVE_TRUNCATE 1 /* Define to 1 if you have the <uchar.h> header file. */ #define _GLIBCXX_HAVE_UCHAR_H 1 /* Define to 1 if you have the <unistd.h> header file. */ #define _GLIBCXX_HAVE_UNISTD_H 1 /* Define if unlinkat is available in <fcntl.h>. */ #define _GLIBCXX_HAVE_UNLINKAT 1 /* Define to 1 if you have the `uselocale' function. */ #define _GLIBCXX_HAVE_USELOCALE 1 /* Defined if usleep exists. */ /* #undef _GLIBCXX_HAVE_USLEEP */ /* Define to 1 if you have the <utime.h> header file. */ #define _GLIBCXX_HAVE_UTIME_H 1 /* Defined if vfwscanf exists. */ #define _GLIBCXX_HAVE_VFWSCANF 1 /* Defined if vswscanf exists. */ #define _GLIBCXX_HAVE_VSWSCANF 1 /* Defined if vwscanf exists. */ #define _GLIBCXX_HAVE_VWSCANF 1 /* Define to 1 if you have the <wchar.h> header file. */ #define _GLIBCXX_HAVE_WCHAR_H 1 /* Defined if wcstof exists. */ #define _GLIBCXX_HAVE_WCSTOF 1 /* Define to 1 if you have the <wctype.h> header file. */ #define _GLIBCXX_HAVE_WCTYPE_H 1 /* Defined if Sleep exists. */ /* #undef _GLIBCXX_HAVE_WIN32_SLEEP */ /* Define if writev is available in <sys/uio.h>. */ #define _GLIBCXX_HAVE_WRITEV 1 /* Define to 1 if you have the <xlocale.h> header file. */ /* #undef _GLIBCXX_HAVE_XLOCALE_H */ /* Define to 1 if you have the `_acosf' function. */ /* #undef _GLIBCXX_HAVE__ACOSF */ /* Define to 1 if you have the `_acosl' function. */ /* #undef _GLIBCXX_HAVE__ACOSL */ /* Define to 1 if you have the `_aligned_malloc' function. */ /* #undef _GLIBCXX_HAVE__ALIGNED_MALLOC */ /* Define to 1 if you have the `_asinf' function. */ /* #undef _GLIBCXX_HAVE__ASINF */ /* Define to 1 if you have the `_asinl' function. */ /* #undef _GLIBCXX_HAVE__ASINL */ /* Define to 1 if you have the `_atan2f' function. */ /* #undef _GLIBCXX_HAVE__ATAN2F */ /* Define to 1 if you have the `_atan2l' function. */ /* #undef _GLIBCXX_HAVE__ATAN2L */ /* Define to 1 if you have the `_atanf' function. */ /* #undef _GLIBCXX_HAVE__ATANF */ /* Define to 1 if you have the `_atanl' function. */ /* #undef _GLIBCXX_HAVE__ATANL */ /* Define to 1 if you have the `_ceilf' function. */ /* #undef _GLIBCXX_HAVE__CEILF */ /* Define to 1 if you have the `_ceill' function. */ /* #undef _GLIBCXX_HAVE__CEILL */ /* Define to 1 if you have the `_cosf' function. */ /* #undef _GLIBCXX_HAVE__COSF */ /* Define to 1 if you have the `_coshf' function. */ /* #undef _GLIBCXX_HAVE__COSHF */ /* Define to 1 if you have the `_coshl' function. */ /* #undef _GLIBCXX_HAVE__COSHL */ /* Define to 1 if you have the `_cosl' function. */ /* #undef _GLIBCXX_HAVE__COSL */ /* Define to 1 if you have the `_expf' function. */ /* #undef _GLIBCXX_HAVE__EXPF */ /* Define to 1 if you have the `_expl' function. */ /* #undef _GLIBCXX_HAVE__EXPL */ /* Define to 1 if you have the `_fabsf' function. */ /* #undef _GLIBCXX_HAVE__FABSF */ /* Define to 1 if you have the `_fabsl' function. */ /* #undef _GLIBCXX_HAVE__FABSL */ /* Define to 1 if you have the `_finite' function. */ /* #undef _GLIBCXX_HAVE__FINITE */ /* Define to 1 if you have the `_finitef' function. */ /* #undef _GLIBCXX_HAVE__FINITEF */ /* Define to 1 if you have the `_finitel' function. */ /* #undef _GLIBCXX_HAVE__FINITEL */ /* Define to 1 if you have the `_floorf' function. */ /* #undef _GLIBCXX_HAVE__FLOORF */ /* Define to 1 if you have the `_floorl' function. */ /* #undef _GLIBCXX_HAVE__FLOORL */ /* Define to 1 if you have the `_fmodf' function. */ /* #undef _GLIBCXX_HAVE__FMODF */ /* Define to 1 if you have the `_fmodl' function. */ /* #undef _GLIBCXX_HAVE__FMODL */ /* Define to 1 if you have the `_fpclass' function. */ /* #undef _GLIBCXX_HAVE__FPCLASS */ /* Define to 1 if you have the `_frexpf' function. */ /* #undef _GLIBCXX_HAVE__FREXPF */ /* Define to 1 if you have the `_frexpl' function. */ /* #undef _GLIBCXX_HAVE__FREXPL */ /* Define to 1 if you have the `_hypot' function. */ /* #undef _GLIBCXX_HAVE__HYPOT */ /* Define to 1 if you have the `_hypotf' function. */ /* #undef _GLIBCXX_HAVE__HYPOTF */ /* Define to 1 if you have the `_hypotl' function. */ /* #undef _GLIBCXX_HAVE__HYPOTL */ /* Define to 1 if you have the `_isinf' function. */ /* #undef _GLIBCXX_HAVE__ISINF */ /* Define to 1 if you have the `_isinff' function. */ /* #undef _GLIBCXX_HAVE__ISINFF */ /* Define to 1 if you have the `_isinfl' function. */ /* #undef _GLIBCXX_HAVE__ISINFL */ /* Define to 1 if you have the `_isnan' function. */ /* #undef _GLIBCXX_HAVE__ISNAN */ /* Define to 1 if you have the `_isnanf' function. */ /* #undef _GLIBCXX_HAVE__ISNANF */ /* Define to 1 if you have the `_isnanl' function. */ /* #undef _GLIBCXX_HAVE__ISNANL */ /* Define to 1 if you have the `_ldexpf' function. */ /* #undef _GLIBCXX_HAVE__LDEXPF */ /* Define to 1 if you have the `_ldexpl' function. */ /* #undef _GLIBCXX_HAVE__LDEXPL */ /* Define to 1 if you have the `_log10f' function. */ /* #undef _GLIBCXX_HAVE__LOG10F */ /* Define to 1 if you have the `_log10l' function. */ /* #undef _GLIBCXX_HAVE__LOG10L */ /* Define to 1 if you have the `_logf' function. */ /* #undef _GLIBCXX_HAVE__LOGF */ /* Define to 1 if you have the `_logl' function. */ /* #undef _GLIBCXX_HAVE__LOGL */ /* Define to 1 if you have the `_modf' function. */ /* #undef _GLIBCXX_HAVE__MODF */ /* Define to 1 if you have the `_modff' function. */ /* #undef _GLIBCXX_HAVE__MODFF */ /* Define to 1 if you have the `_modfl' function. */ /* #undef _GLIBCXX_HAVE__MODFL */ /* Define to 1 if you have the `_powf' function. */ /* #undef _GLIBCXX_HAVE__POWF */ /* Define to 1 if you have the `_powl' function. */ /* #undef _GLIBCXX_HAVE__POWL */ /* Define to 1 if you have the `_qfpclass' function. */ /* #undef _GLIBCXX_HAVE__QFPCLASS */ /* Define to 1 if you have the `_sincos' function. */ /* #undef _GLIBCXX_HAVE__SINCOS */ /* Define to 1 if you have the `_sincosf' function. */ /* #undef _GLIBCXX_HAVE__SINCOSF */ /* Define to 1 if you have the `_sincosl' function. */ /* #undef _GLIBCXX_HAVE__SINCOSL */ /* Define to 1 if you have the `_sinf' function. */ /* #undef _GLIBCXX_HAVE__SINF */ /* Define to 1 if you have the `_sinhf' function. */ /* #undef _GLIBCXX_HAVE__SINHF */ /* Define to 1 if you have the `_sinhl' function. */ /* #undef _GLIBCXX_HAVE__SINHL */ /* Define to 1 if you have the `_sinl' function. */ /* #undef _GLIBCXX_HAVE__SINL */ /* Define to 1 if you have the `_sqrtf' function. */ /* #undef _GLIBCXX_HAVE__SQRTF */ /* Define to 1 if you have the `_sqrtl' function. */ /* #undef _GLIBCXX_HAVE__SQRTL */ /* Define to 1 if you have the `_tanf' function. */ /* #undef _GLIBCXX_HAVE__TANF */ /* Define to 1 if you have the `_tanhf' function. */ /* #undef _GLIBCXX_HAVE__TANHF */ /* Define to 1 if you have the `_tanhl' function. */ /* #undef _GLIBCXX_HAVE__TANHL */ /* Define to 1 if you have the `_tanl' function. */ /* #undef _GLIBCXX_HAVE__TANL */ /* Define to 1 if you have the `_wfopen' function. */ /* #undef _GLIBCXX_HAVE__WFOPEN */ /* Define to 1 if you have the `__cxa_thread_atexit' function. */ /* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT */ /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */ #define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1 /* Define as const if the declaration of iconv() needs const. */ #define _GLIBCXX_ICONV_CONST /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define _GLIBCXX_LT_OBJDIR ".libs/" /* Name of package */ /* #undef _GLIBCXX_PACKAGE */ /* Define to the address where bug reports for this package should be sent. */ #define _GLIBCXX_PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define _GLIBCXX_PACKAGE_NAME "package-unused" /* Define to the full name and version of this package. */ #define _GLIBCXX_PACKAGE_STRING "package-unused version-unused" /* Define to the one symbol short name of this package. */ #define _GLIBCXX_PACKAGE_TARNAME "libstdc++" /* Define to the home page for this package. */ #define _GLIBCXX_PACKAGE_URL "" /* Define to the version of this package. */ #define _GLIBCXX_PACKAGE__GLIBCXX_VERSION "version-unused" /* The size of `char', as computed by sizeof. */ /* #undef SIZEOF_CHAR */ /* The size of `int', as computed by sizeof. */ /* #undef SIZEOF_INT */ /* The size of `long', as computed by sizeof. */ /* #undef SIZEOF_LONG */ /* The size of `short', as computed by sizeof. */ /* #undef SIZEOF_SHORT */ /* The size of `void *', as computed by sizeof. */ /* #undef SIZEOF_VOID_P */ /* Define to 1 if you have the ANSI C header files. */ #define _GLIBCXX_STDC_HEADERS 1 /* Version number of package */ /* #undef _GLIBCXX_VERSION */ /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _GLIBCXX_DARWIN_USE_64_BIT_INODE # define _GLIBCXX_DARWIN_USE_64_BIT_INODE 1 #endif /* Number of bits in a file offset, on hosts where this is settable. */ #define _GLIBCXX_FILE_OFFSET_BITS 64 /* Define if C99 functions in <complex.h> should be used in <complex> for C++11. Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX11_USE_C99_COMPLEX 1 /* Define if C99 functions or macros in <math.h> should be imported in <cmath> in namespace std for C++11. */ #define _GLIBCXX11_USE_C99_MATH 1 /* Define if C99 functions or macros in <stdio.h> should be imported in <cstdio> in namespace std for C++11. */ #define _GLIBCXX11_USE_C99_STDIO 1 /* Define if C99 functions or macros in <stdlib.h> should be imported in <cstdlib> in namespace std for C++11. */ #define _GLIBCXX11_USE_C99_STDLIB 1 /* Define if C99 functions or macros in <wchar.h> should be imported in <cwchar> in namespace std for C++11. */ #define _GLIBCXX11_USE_C99_WCHAR 1 /* Define if C99 functions in <complex.h> should be used in <complex> for C++98. Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX98_USE_C99_COMPLEX 1 /* Define if C99 functions or macros in <math.h> should be imported in <cmath> in namespace std for C++98. */ #define _GLIBCXX98_USE_C99_MATH 1 /* Define if C99 functions or macros in <stdio.h> should be imported in <cstdio> in namespace std for C++98. */ #define _GLIBCXX98_USE_C99_STDIO 1 /* Define if C99 functions or macros in <stdlib.h> should be imported in <cstdlib> in namespace std for C++98. */ #define _GLIBCXX98_USE_C99_STDLIB 1 /* Define if C99 functions or macros in <wchar.h> should be imported in <cwchar> in namespace std for C++98. */ #define _GLIBCXX98_USE_C99_WCHAR 1 /* Define if the compiler supports C++11 atomics. */ #define _GLIBCXX_ATOMIC_BUILTINS 1 /* Define to use concept checking code from the boost libraries. */ /* #undef _GLIBCXX_CONCEPT_CHECKS */ /* Define to 1 if a fully dynamic basic_string is wanted, 0 to disable, undefined for platform defaults */ #define _GLIBCXX_FULLY_DYNAMIC_STRING 0 /* Define if gthreads library is available. */ #define _GLIBCXX_HAS_GTHREADS 1 /* Define to 1 if a full hosted library is built, or 0 if freestanding. */ #define _GLIBCXX_HOSTED 1 /* Define if compatibility should be provided for alternative 128-bit long double formats. */ /* Define if compatibility should be provided for -mlong-double-64. */ /* Define to the letter to which size_t is mangled. */ #define _GLIBCXX_MANGLE_SIZE_T j /* Define if C99 llrint and llround functions are missing from <math.h>. */ /* #undef _GLIBCXX_NO_C99_ROUNDING_FUNCS */ /* Defined if no way to sleep is available. */ /* #undef _GLIBCXX_NO_SLEEP */ /* Define if ptrdiff_t is int. */ #define _GLIBCXX_PTRDIFF_T_IS_INT 1 /* Define if using setrlimit to set resource limits during "make check" */ #define _GLIBCXX_RES_LIMITS 1 /* Define if size_t is unsigned int. */ #define _GLIBCXX_SIZE_T_IS_UINT 1 /* Define to the value of the EOF integer constant. */ #define _GLIBCXX_STDIO_EOF -1 /* Define to the value of the SEEK_CUR integer constant. */ #define _GLIBCXX_STDIO_SEEK_CUR 1 /* Define to the value of the SEEK_END integer constant. */ #define _GLIBCXX_STDIO_SEEK_END 2 /* Define to use symbol versioning in the shared library. */ #define _GLIBCXX_SYMVER 1 /* Define to use darwin versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_DARWIN */ /* Define to use GNU versioning in the shared library. */ #define _GLIBCXX_SYMVER_GNU 1 /* Define to use GNU namespace versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_GNU_NAMESPACE */ /* Define to use Sun versioning in the shared library. */ /* #undef _GLIBCXX_SYMVER_SUN */ /* Define if C11 functions in <uchar.h> should be imported into namespace std in <cuchar>. */ #define _GLIBCXX_USE_C11_UCHAR_CXX11 1 /* Define if C99 functions or macros from <wchar.h>, <math.h>, <complex.h>, <stdio.h>, and <stdlib.h> can be used or exposed. */ #define _GLIBCXX_USE_C99 1 /* Define if C99 functions in <complex.h> should be used in <tr1/complex>. Using compiler builtins for these functions requires corresponding C99 library functions to be present. */ #define _GLIBCXX_USE_C99_COMPLEX_TR1 1 /* Define if C99 functions in <ctype.h> should be imported in <tr1/cctype> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_CTYPE_TR1 1 /* Define if C99 functions in <fenv.h> should be imported in <tr1/cfenv> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_FENV_TR1 1 /* Define if C99 functions in <inttypes.h> should be imported in <tr1/cinttypes> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_INTTYPES_TR1 1 /* Define if wchar_t C99 functions in <inttypes.h> should be imported in <tr1/cinttypes> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_INTTYPES_WCHAR_T_TR1 1 /* Define if C99 functions or macros in <math.h> should be imported in <tr1/cmath> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_MATH_TR1 1 /* Define if C99 types in <stdint.h> should be imported in <tr1/cstdint> in namespace std::tr1. */ #define _GLIBCXX_USE_C99_STDINT_TR1 1 /* Defined if clock_gettime syscall has monotonic and realtime clock support. */ /* #undef _GLIBCXX_USE_CLOCK_GETTIME_SYSCALL */ /* Defined if clock_gettime has monotonic clock support. */ #define _GLIBCXX_USE_CLOCK_MONOTONIC 1 /* Defined if clock_gettime has realtime clock support. */ #define _GLIBCXX_USE_CLOCK_REALTIME 1 /* Define if ISO/IEC TR 24733 decimal floating point types are supported on this host. */ #define _GLIBCXX_USE_DECIMAL_FLOAT 1 /* Define if /dev/random and /dev/urandom are available for std::random_device. */ #define _GLIBCXX_USE_DEV_RANDOM 1 /* Define if fchmod is available in <sys/stat.h>. */ #define _GLIBCXX_USE_FCHMOD 1 /* Define if fchmodat is available in <sys/stat.h>. */ #define _GLIBCXX_USE_FCHMODAT 1 /* Defined if gettimeofday is available. */ #define _GLIBCXX_USE_GETTIMEOFDAY 1 /* Define if get_nprocs is available in <sys/sysinfo.h>. */ #define _GLIBCXX_USE_GET_NPROCS 1 /* Define if __int128 is supported on this host. */ /* #undef _GLIBCXX_USE_INT128 */ /* Define if LFS support is available. */ #define _GLIBCXX_USE_LFS 1 /* Define if code specialized for long long should be used. */ #define _GLIBCXX_USE_LONG_LONG 1 /* Define if lstat is available in <sys/stat.h>. */ #define _GLIBCXX_USE_LSTAT 1 /* Defined if nanosleep is available. */ #define _GLIBCXX_USE_NANOSLEEP 1 /* Define if NLS translations are to be used. */ #define _GLIBCXX_USE_NLS 1 /* Define if pthreads_num_processors_np is available in <pthread.h>. */ /* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */ /* Define if pthread_cond_clockwait is available in <pthread.h>. */ #define _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT 1 /* Define if pthread_mutex_clocklock is available in <pthread.h>. */ #define _GLIBCXX_USE_PTHREAD_MUTEX_CLOCKLOCK 1 /* Define if pthread_rwlock_clockrdlock and pthread_rwlock_clockwrlock are available in <pthread.h>. */ #define _GLIBCXX_USE_PTHREAD_RWLOCK_CLOCKLOCK 1 /* Define if POSIX read/write locks are available in <gthr.h>. */ #define _GLIBCXX_USE_PTHREAD_RWLOCK_T 1 /* Define if /dev/random and /dev/urandom are available for the random_device of TR1 (Chapter 5.1). */ #define _GLIBCXX_USE_RANDOM_TR1 1 /* Define if usable realpath is available in <stdlib.h>. */ #define _GLIBCXX_USE_REALPATH 1 /* Defined if sched_yield is available. */ #define _GLIBCXX_USE_SCHED_YIELD 1 /* Define if _SC_NPROCESSORS_ONLN is available in <unistd.h>. */ #define _GLIBCXX_USE_SC_NPROCESSORS_ONLN 1 /* Define if _SC_NPROC_ONLN is available in <unistd.h>. */ /* #undef _GLIBCXX_USE_SC_NPROC_ONLN */ /* Define if sendfile is available in <sys/sendfile.h>. */ #define _GLIBCXX_USE_SENDFILE 1 /* Define to restrict std::__basic_file<> to stdio APIs. */ /* #undef _GLIBCXX_USE_STDIO_PURE */ /* Define if struct stat has timespec members. */ #define _GLIBCXX_USE_ST_MTIM 1 /* Define if sysctl(), CTL_HW and HW_NCPU are available in <sys/sysctl.h>. */ /* #undef _GLIBCXX_USE_SYSCTL_HW_NCPU */ /* Define if obsolescent tmpnam is available in <stdio.h>. */ #define _GLIBCXX_USE_TMPNAM 1 /* Define if utime is available in <utime.h>. */ #define _GLIBCXX_USE_UTIME 1 /* Define if utimensat and UTIME_OMIT are available in <sys/stat.h> and AT_FDCWD in <fcntl.h>. */ #define _GLIBCXX_USE_UTIMENSAT 1 /* Define if code specialized for wchar_t should be used. */ #define _GLIBCXX_USE_WCHAR_T 1 /* Define to 1 if a verbose library is built, or 0 otherwise. */ #define _GLIBCXX_VERBOSE 1 /* Defined if as can handle rdrand. */ #define _GLIBCXX_X86_RDRAND 1 /* Defined if as can handle rdseed. */ #define _GLIBCXX_X86_RDSEED 1 /* Define to 1 if mutex_timedlock is available. */ #define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 /* Define for large files, on AIX-style hosts. */ /* #undef _GLIBCXX_LARGE_FILES */ /* Define if all C++11 floating point overloads are available in <math.h>. */ #if __cplusplus >= 201103L /* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP */ #endif /* Define if all C++11 integral type overloads are available in <math.h>. */ #if __cplusplus >= 201103L /* #undef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT */ #endif #if defined (_GLIBCXX_HAVE__ACOSF) && ! defined (_GLIBCXX_HAVE_ACOSF) # define _GLIBCXX_HAVE_ACOSF 1 # define acosf _acosf #endif #if defined (_GLIBCXX_HAVE__ACOSL) && ! defined (_GLIBCXX_HAVE_ACOSL) # define _GLIBCXX_HAVE_ACOSL 1 # define acosl _acosl #endif #if defined (_GLIBCXX_HAVE__ASINF) && ! defined (_GLIBCXX_HAVE_ASINF) # define _GLIBCXX_HAVE_ASINF 1 # define asinf _asinf #endif #if defined (_GLIBCXX_HAVE__ASINL) && ! defined (_GLIBCXX_HAVE_ASINL) # define _GLIBCXX_HAVE_ASINL 1 # define asinl _asinl #endif #if defined (_GLIBCXX_HAVE__ATAN2F) && ! defined (_GLIBCXX_HAVE_ATAN2F) # define _GLIBCXX_HAVE_ATAN2F 1 # define atan2f _atan2f #endif #if defined (_GLIBCXX_HAVE__ATAN2L) && ! defined (_GLIBCXX_HAVE_ATAN2L) # define _GLIBCXX_HAVE_ATAN2L 1 # define atan2l _atan2l #endif #if defined (_GLIBCXX_HAVE__ATANF) && ! defined (_GLIBCXX_HAVE_ATANF) # define _GLIBCXX_HAVE_ATANF 1 # define atanf _atanf #endif #if defined (_GLIBCXX_HAVE__ATANL) && ! defined (_GLIBCXX_HAVE_ATANL) # define _GLIBCXX_HAVE_ATANL 1 # define atanl _atanl #endif #if defined (_GLIBCXX_HAVE__CEILF) && ! defined (_GLIBCXX_HAVE_CEILF) # define _GLIBCXX_HAVE_CEILF 1 # define ceilf _ceilf #endif #if defined (_GLIBCXX_HAVE__CEILL) && ! defined (_GLIBCXX_HAVE_CEILL) # define _GLIBCXX_HAVE_CEILL 1 # define ceill _ceill #endif #if defined (_GLIBCXX_HAVE__COSF) && ! defined (_GLIBCXX_HAVE_COSF) # define _GLIBCXX_HAVE_COSF 1 # define cosf _cosf #endif #if defined (_GLIBCXX_HAVE__COSHF) && ! defined (_GLIBCXX_HAVE_COSHF) # define _GLIBCXX_HAVE_COSHF 1 # define coshf _coshf #endif #if defined (_GLIBCXX_HAVE__COSHL) && ! defined (_GLIBCXX_HAVE_COSHL) # define _GLIBCXX_HAVE_COSHL 1 # define coshl _coshl #endif #if defined (_GLIBCXX_HAVE__COSL) && ! defined (_GLIBCXX_HAVE_COSL) # define _GLIBCXX_HAVE_COSL 1 # define cosl _cosl #endif #if defined (_GLIBCXX_HAVE__EXPF) && ! defined (_GLIBCXX_HAVE_EXPF) # define _GLIBCXX_HAVE_EXPF 1 # define expf _expf #endif #if defined (_GLIBCXX_HAVE__EXPL) && ! defined (_GLIBCXX_HAVE_EXPL) # define _GLIBCXX_HAVE_EXPL 1 # define expl _expl #endif #if defined (_GLIBCXX_HAVE__FABSF) && ! defined (_GLIBCXX_HAVE_FABSF) # define _GLIBCXX_HAVE_FABSF 1 # define fabsf _fabsf #endif #if defined (_GLIBCXX_HAVE__FABSL) && ! defined (_GLIBCXX_HAVE_FABSL) # define _GLIBCXX_HAVE_FABSL 1 # define fabsl _fabsl #endif #if defined (_GLIBCXX_HAVE__FINITE) && ! defined (_GLIBCXX_HAVE_FINITE) # define _GLIBCXX_HAVE_FINITE 1 # define finite _finite #endif #if defined (_GLIBCXX_HAVE__FINITEF) && ! defined (_GLIBCXX_HAVE_FINITEF) # define _GLIBCXX_HAVE_FINITEF 1 # define finitef _finitef #endif #if defined (_GLIBCXX_HAVE__FINITEL) && ! defined (_GLIBCXX_HAVE_FINITEL) # define _GLIBCXX_HAVE_FINITEL 1 # define finitel _finitel #endif #if defined (_GLIBCXX_HAVE__FLOORF) && ! defined (_GLIBCXX_HAVE_FLOORF) # define _GLIBCXX_HAVE_FLOORF 1 # define floorf _floorf #endif #if defined (_GLIBCXX_HAVE__FLOORL) && ! defined (_GLIBCXX_HAVE_FLOORL) # define _GLIBCXX_HAVE_FLOORL 1 # define floorl _floorl #endif #if defined (_GLIBCXX_HAVE__FMODF) && ! defined (_GLIBCXX_HAVE_FMODF) # define _GLIBCXX_HAVE_FMODF 1 # define fmodf _fmodf #endif #if defined (_GLIBCXX_HAVE__FMODL) && ! defined (_GLIBCXX_HAVE_FMODL) # define _GLIBCXX_HAVE_FMODL 1 # define fmodl _fmodl #endif #if defined (_GLIBCXX_HAVE__FPCLASS) && ! defined (_GLIBCXX_HAVE_FPCLASS) # define _GLIBCXX_HAVE_FPCLASS 1 # define fpclass _fpclass #endif #if defined (_GLIBCXX_HAVE__FREXPF) && ! defined (_GLIBCXX_HAVE_FREXPF) # define _GLIBCXX_HAVE_FREXPF 1 # define frexpf _frexpf #endif #if defined (_GLIBCXX_HAVE__FREXPL) && ! defined (_GLIBCXX_HAVE_FREXPL) # define _GLIBCXX_HAVE_FREXPL 1 # define frexpl _frexpl #endif #if defined (_GLIBCXX_HAVE__HYPOT) && ! defined (_GLIBCXX_HAVE_HYPOT) # define _GLIBCXX_HAVE_HYPOT 1 # define hypot _hypot #endif #if defined (_GLIBCXX_HAVE__HYPOTF) && ! defined (_GLIBCXX_HAVE_HYPOTF) # define _GLIBCXX_HAVE_HYPOTF 1 # define hypotf _hypotf #endif #if defined (_GLIBCXX_HAVE__HYPOTL) && ! defined (_GLIBCXX_HAVE_HYPOTL) # define _GLIBCXX_HAVE_HYPOTL 1 # define hypotl _hypotl #endif #if defined (_GLIBCXX_HAVE__ISINF) && ! defined (_GLIBCXX_HAVE_ISINF) # define _GLIBCXX_HAVE_ISINF 1 # define isinf _isinf #endif #if defined (_GLIBCXX_HAVE__ISINFF) && ! defined (_GLIBCXX_HAVE_ISINFF) # define _GLIBCXX_HAVE_ISINFF 1 # define isinff _isinff #endif #if defined (_GLIBCXX_HAVE__ISINFL) && ! defined (_GLIBCXX_HAVE_ISINFL) # define _GLIBCXX_HAVE_ISINFL 1 # define isinfl _isinfl #endif #if defined (_GLIBCXX_HAVE__ISNAN) && ! defined (_GLIBCXX_HAVE_ISNAN) # define _GLIBCXX_HAVE_ISNAN 1 # define isnan _isnan #endif #if defined (_GLIBCXX_HAVE__ISNANF) && ! defined (_GLIBCXX_HAVE_ISNANF) # define _GLIBCXX_HAVE_ISNANF 1 # define isnanf _isnanf #endif #if defined (_GLIBCXX_HAVE__ISNANL) && ! defined (_GLIBCXX_HAVE_ISNANL) # define _GLIBCXX_HAVE_ISNANL 1 # define isnanl _isnanl #endif #if defined (_GLIBCXX_HAVE__LDEXPF) && ! defined (_GLIBCXX_HAVE_LDEXPF) # define _GLIBCXX_HAVE_LDEXPF 1 # define ldexpf _ldexpf #endif #if defined (_GLIBCXX_HAVE__LDEXPL) && ! defined (_GLIBCXX_HAVE_LDEXPL) # define _GLIBCXX_HAVE_LDEXPL 1 # define ldexpl _ldexpl #endif #if defined (_GLIBCXX_HAVE__LOG10F) && ! defined (_GLIBCXX_HAVE_LOG10F) # define _GLIBCXX_HAVE_LOG10F 1 # define log10f _log10f #endif #if defined (_GLIBCXX_HAVE__LOG10L) && ! defined (_GLIBCXX_HAVE_LOG10L) # define _GLIBCXX_HAVE_LOG10L 1 # define log10l _log10l #endif #if defined (_GLIBCXX_HAVE__LOGF) && ! defined (_GLIBCXX_HAVE_LOGF) # define _GLIBCXX_HAVE_LOGF 1 # define logf _logf #endif #if defined (_GLIBCXX_HAVE__LOGL) && ! defined (_GLIBCXX_HAVE_LOGL) # define _GLIBCXX_HAVE_LOGL 1 # define logl _logl #endif #if defined (_GLIBCXX_HAVE__MODF) && ! defined (_GLIBCXX_HAVE_MODF) # define _GLIBCXX_HAVE_MODF 1 # define modf _modf #endif #if defined (_GLIBCXX_HAVE__MODFF) && ! defined (_GLIBCXX_HAVE_MODFF) # define _GLIBCXX_HAVE_MODFF 1 # define modff _modff #endif #if defined (_GLIBCXX_HAVE__MODFL) && ! defined (_GLIBCXX_HAVE_MODFL) # define _GLIBCXX_HAVE_MODFL 1 # define modfl _modfl #endif #if defined (_GLIBCXX_HAVE__POWF) && ! defined (_GLIBCXX_HAVE_POWF) # define _GLIBCXX_HAVE_POWF 1 # define powf _powf #endif #if defined (_GLIBCXX_HAVE__POWL) && ! defined (_GLIBCXX_HAVE_POWL) # define _GLIBCXX_HAVE_POWL 1 # define powl _powl #endif #if defined (_GLIBCXX_HAVE__QFPCLASS) && ! defined (_GLIBCXX_HAVE_QFPCLASS) # define _GLIBCXX_HAVE_QFPCLASS 1 # define qfpclass _qfpclass #endif #if defined (_GLIBCXX_HAVE__SINCOS) && ! defined (_GLIBCXX_HAVE_SINCOS) # define _GLIBCXX_HAVE_SINCOS 1 # define sincos _sincos #endif #if defined (_GLIBCXX_HAVE__SINCOSF) && ! defined (_GLIBCXX_HAVE_SINCOSF) # define _GLIBCXX_HAVE_SINCOSF 1 # define sincosf _sincosf #endif #if defined (_GLIBCXX_HAVE__SINCOSL) && ! defined (_GLIBCXX_HAVE_SINCOSL) # define _GLIBCXX_HAVE_SINCOSL 1 # define sincosl _sincosl #endif #if defined (_GLIBCXX_HAVE__SINF) && ! defined (_GLIBCXX_HAVE_SINF) # define _GLIBCXX_HAVE_SINF 1 # define sinf _sinf #endif #if defined (_GLIBCXX_HAVE__SINHF) && ! defined (_GLIBCXX_HAVE_SINHF) # define _GLIBCXX_HAVE_SINHF 1 # define sinhf _sinhf #endif #if defined (_GLIBCXX_HAVE__SINHL) && ! defined (_GLIBCXX_HAVE_SINHL) # define _GLIBCXX_HAVE_SINHL 1 # define sinhl _sinhl #endif #if defined (_GLIBCXX_HAVE__SINL) && ! defined (_GLIBCXX_HAVE_SINL) # define _GLIBCXX_HAVE_SINL 1 # define sinl _sinl #endif #if defined (_GLIBCXX_HAVE__SQRTF) && ! defined (_GLIBCXX_HAVE_SQRTF) # define _GLIBCXX_HAVE_SQRTF 1 # define sqrtf _sqrtf #endif #if defined (_GLIBCXX_HAVE__SQRTL) && ! defined (_GLIBCXX_HAVE_SQRTL) # define _GLIBCXX_HAVE_SQRTL 1 # define sqrtl _sqrtl #endif #if defined (_GLIBCXX_HAVE__STRTOF) && ! defined (_GLIBCXX_HAVE_STRTOF) # define _GLIBCXX_HAVE_STRTOF 1 # define strtof _strtof #endif #if defined (_GLIBCXX_HAVE__STRTOLD) && ! defined (_GLIBCXX_HAVE_STRTOLD) # define _GLIBCXX_HAVE_STRTOLD 1 # define strtold _strtold #endif #if defined (_GLIBCXX_HAVE__TANF) && ! defined (_GLIBCXX_HAVE_TANF) # define _GLIBCXX_HAVE_TANF 1 # define tanf _tanf #endif #if defined (_GLIBCXX_HAVE__TANHF) && ! defined (_GLIBCXX_HAVE_TANHF) # define _GLIBCXX_HAVE_TANHF 1 # define tanhf _tanhf #endif #if defined (_GLIBCXX_HAVE__TANHL) && ! defined (_GLIBCXX_HAVE_TANHL) # define _GLIBCXX_HAVE_TANHL 1 # define tanhl _tanhl #endif #if defined (_GLIBCXX_HAVE__TANL) && ! defined (_GLIBCXX_HAVE_TANL) # define _GLIBCXX_HAVE_TANL 1 # define tanl _tanl #endif #endif // _GLIBCXX_CXX_CONFIG_H /* Threads compatibility routines for libgcc2 and libobjc. */ /* Compile this one with gcc. */ /* Copyright (C) 1997-2021 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _GLIBCXX_GCC_GTHR_POSIX_H #define _GLIBCXX_GCC_GTHR_POSIX_H /* POSIX threads specific definitions. Easy, since the interface is just one-to-one mapping. */ #define __GTHREADS 1 #define __GTHREADS_CXX0X 1 #include <pthread.h> #if ((defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)) \ || !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK)) # include <unistd.h> # if defined(_POSIX_TIMEOUTS) && _POSIX_TIMEOUTS >= 0 # define _GTHREAD_USE_MUTEX_TIMEDLOCK 1 # else # define _GTHREAD_USE_MUTEX_TIMEDLOCK 0 # endif #endif typedef pthread_t __gthread_t; typedef pthread_key_t __gthread_key_t; typedef pthread_once_t __gthread_once_t; typedef pthread_mutex_t __gthread_mutex_t; typedef pthread_mutex_t __gthread_recursive_mutex_t; typedef pthread_cond_t __gthread_cond_t; typedef struct timespec __gthread_time_t; /* POSIX like conditional variables are supported. Please look at comments in gthr.h for details. */ #define __GTHREAD_HAS_COND 1 #define __GTHREAD_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER #define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function #define __GTHREAD_ONCE_INIT PTHREAD_ONCE_INIT #if defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER #elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) #define __GTHREAD_RECURSIVE_MUTEX_INIT PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP #else #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER #define __GTHREAD_TIME_INIT {0,0} #ifdef _GTHREAD_USE_MUTEX_INIT_FUNC # undef __GTHREAD_MUTEX_INIT #endif #ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC # undef __GTHREAD_RECURSIVE_MUTEX_INIT # undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION # define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function #endif #ifdef _GTHREAD_USE_COND_INIT_FUNC # undef __GTHREAD_COND_INIT # define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function #endif #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK # ifndef __gthrw_pragma # define __gthrw_pragma(pragma) # endif # define __gthrw2(name,name2,type) \ static __typeof(type) name \ __attribute__ ((__weakref__(#name2), __copy__ (type))); \ __gthrw_pragma(weak type) # define __gthrw_(name) __gthrw_ ## name #else # define __gthrw2(name,name2,type) # define __gthrw_(name) name #endif /* Typically, __gthrw_foo is a weak reference to symbol foo. */ #define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name) __gthrw(pthread_once) __gthrw(pthread_getspecific) __gthrw(pthread_setspecific) __gthrw(pthread_create) __gthrw(pthread_join) __gthrw(pthread_equal) __gthrw(pthread_self) __gthrw(pthread_detach) #ifndef __BIONIC__ __gthrw(pthread_cancel) #endif __gthrw(sched_yield) __gthrw(pthread_mutex_lock) __gthrw(pthread_mutex_trylock) #if _GTHREAD_USE_MUTEX_TIMEDLOCK __gthrw(pthread_mutex_timedlock) #endif __gthrw(pthread_mutex_unlock) __gthrw(pthread_mutex_init) __gthrw(pthread_mutex_destroy) __gthrw(pthread_cond_init) __gthrw(pthread_cond_broadcast) __gthrw(pthread_cond_signal) __gthrw(pthread_cond_wait) __gthrw(pthread_cond_timedwait) __gthrw(pthread_cond_destroy) __gthrw(pthread_key_create) __gthrw(pthread_key_delete) __gthrw(pthread_mutexattr_init) __gthrw(pthread_mutexattr_settype) __gthrw(pthread_mutexattr_destroy) #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK) /* Objective-C. */ __gthrw(pthread_exit) #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(sched_get_priority_max) __gthrw(sched_get_priority_min) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ __gthrw(pthread_attr_destroy) __gthrw(pthread_attr_init) __gthrw(pthread_attr_setdetachstate) #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING __gthrw(pthread_getschedparam) __gthrw(pthread_setschedparam) #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _LIBOBJC || _LIBOBJC_WEAK */ #if __GXX_WEAK__ && _GLIBCXX_GTHREAD_USE_WEAK /* On Solaris 2.6 up to 9, the libc exposes a POSIX threads interface even if -pthreads is not specified. The functions are dummies and most return an error value. However pthread_once returns 0 without invoking the routine it is passed so we cannot pretend that the interface is active if -pthreads is not specified. On Solaris 2.5.1, the interface is not exposed at all so we need to play the usual game with weak symbols. On Solaris 10 and up, a working interface is always exposed. On FreeBSD 6 and later, libc also exposes a dummy POSIX threads interface, similar to what Solaris 2.6 up to 9 does. FreeBSD >= 700014 even provides a pthread_cancel stub in libc, which means the alternate __gthread_active_p below cannot be used there. */ #if defined(__FreeBSD__) || (defined(__sun) && defined(__svr4__)) static volatile int __gthread_active = -1; static void __gthread_trigger (void) { __gthread_active = 1; } static inline int __gthread_active_p (void) { static pthread_mutex_t __gthread_active_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_once_t __gthread_active_once = PTHREAD_ONCE_INIT; /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; /* This test is not protected to avoid taking a lock on the main code path so every update of __gthread_active in a threaded program must be atomic with regard to the result of the test. */ if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { if (__gthrw_(pthread_once)) { /* If this really is a threaded program, then we must ensure that __gthread_active has been set to 1 before exiting this block. */ __gthrw_(pthread_mutex_lock) (&__gthread_active_mutex); __gthrw_(pthread_once) (&__gthread_active_once, __gthread_trigger); __gthrw_(pthread_mutex_unlock) (&__gthread_active_mutex); } /* Make sure we'll never enter this block again. */ if (__gthread_active < 0) __gthread_active = 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* neither FreeBSD nor Solaris */ /* For a program to be multi-threaded the only thing that it certainly must be using is pthread_create. However, there may be other libraries that intercept pthread_create with their own definitions to wrap pthreads functionality for some purpose. In those cases, pthread_create being defined might not necessarily mean that libpthread is actually linked in. For the GNU C library, we can use a known internal name. This is always available in the ABI, but no other library would define it. That is ideal, since any public pthread function might be intercepted just as pthread_create might be. __pthread_key_create is an "internal" implementation symbol, but it is part of the public exported ABI. Also, it's among the symbols that the static libpthread.a always links in whenever pthread_create is used, so there is no danger of a false negative result in any statically-linked, multi-threaded program. For others, we choose pthread_cancel as a function that seems unlikely to be redefined by an interceptor library. The bionic (Android) C library does not provide pthread_cancel, so we do use pthread_create there (and interceptor libraries lose). */ #ifdef __GLIBC__ __gthrw2(__gthrw_(__pthread_key_create), __pthread_key_create, pthread_key_create) # define GTHR_ACTIVE_PROXY __gthrw_(__pthread_key_create) #elif defined (__BIONIC__) # define GTHR_ACTIVE_PROXY __gthrw_(pthread_create) #else # define GTHR_ACTIVE_PROXY __gthrw_(pthread_cancel) #endif static inline int __gthread_active_p (void) { static void *const __gthread_active_ptr = __extension__ (void *) >HR_ACTIVE_PROXY; return __gthread_active_ptr != 0; } #endif /* FreeBSD or Solaris */ #else /* not __GXX_WEAK__ */ /* Similar to Solaris, HP-UX 11 for PA-RISC provides stubs for pthread calls in shared flavors of the HP-UX C library. Most of the stubs have no functionality. The details are described in the "libc cumulative patch" for each subversion of HP-UX 11. There are two special interfaces provided for checking whether an application is linked to a shared pthread library or not. However, these interfaces aren't available in early libpthread libraries. We also need a test that works for archive libraries. We can't use pthread_once as some libc versions call the init function. We also can't use pthread_create or pthread_attr_init as these create a thread and thereby prevent changing the default stack size. The function pthread_default_stacksize_np is available in both the archive and shared versions of libpthread. It can be used to determine the default pthread stack size. There is a stub in some shared libc versions which returns a zero size if pthreads are not active. We provide an equivalent stub to handle cases where libc doesn't provide one. */ #if defined(__hppa__) && defined(__hpux__) static volatile int __gthread_active = -1; static inline int __gthread_active_p (void) { /* Avoid reading __gthread_active twice on the main code path. */ int __gthread_active_latest_value = __gthread_active; size_t __s; if (__builtin_expect (__gthread_active_latest_value < 0, 0)) { pthread_default_stacksize_np (0, &__s); __gthread_active = __s ? 1 : 0; __gthread_active_latest_value = __gthread_active; } return __gthread_active_latest_value != 0; } #else /* not hppa-hpux */ static inline int __gthread_active_p (void) { return 1; } #endif /* hppa-hpux */ #endif /* __GXX_WEAK__ */ #ifdef _LIBOBJC /* This is the config.h file in libobjc/ */ #include <config.h> #ifdef HAVE_SCHED_H # include <sched.h> #endif /* Key structure for maintaining thread specific storage */ static pthread_key_t _objc_thread_storage; static pthread_attr_t _objc_thread_attribs; /* Thread local storage for a single thread */ static void *thread_local_storage = NULL; /* Backend initialization functions */ /* Initialize the threads subsystem. */ static inline int __gthread_objc_init_thread_system (void) { if (__gthread_active_p ()) { /* Initialize the thread storage key. */ if (__gthrw_(pthread_key_create) (&_objc_thread_storage, NULL) == 0) { /* The normal default detach state for threads is * PTHREAD_CREATE_JOINABLE which causes threads to not die * when you think they should. */ if (__gthrw_(pthread_attr_init) (&_objc_thread_attribs) == 0 && __gthrw_(pthread_attr_setdetachstate) (&_objc_thread_attribs, PTHREAD_CREATE_DETACHED) == 0) return 0; } } return -1; } /* Close the threads subsystem. */ static inline int __gthread_objc_close_thread_system (void) { if (__gthread_active_p () && __gthrw_(pthread_key_delete) (_objc_thread_storage) == 0 && __gthrw_(pthread_attr_destroy) (&_objc_thread_attribs) == 0) return 0; return -1; } /* Backend thread functions */ /* Create a new thread of execution. */ static inline objc_thread_t __gthread_objc_thread_detach (void (*func)(void *), void *arg) { objc_thread_t thread_id; pthread_t new_thread_handle; if (!__gthread_active_p ()) return NULL; if (!(__gthrw_(pthread_create) (&new_thread_handle, &_objc_thread_attribs, (void *) func, arg))) thread_id = (objc_thread_t) new_thread_handle; else thread_id = NULL; return thread_id; } /* Set the current thread's priority. */ static inline int __gthread_objc_thread_set_priority (int priority) { if (!__gthread_active_p ()) return -1; else { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING pthread_t thread_id = __gthrw_(pthread_self) (); int policy; struct sched_param params; int priority_min, priority_max; if (__gthrw_(pthread_getschedparam) (thread_id, &policy, ¶ms) == 0) { if ((priority_max = __gthrw_(sched_get_priority_max) (policy)) == -1) return -1; if ((priority_min = __gthrw_(sched_get_priority_min) (policy)) == -1) return -1; if (priority > priority_max) priority = priority_max; else if (priority < priority_min) priority = priority_min; params.sched_priority = priority; /* * The solaris 7 and several other man pages incorrectly state that * this should be a pointer to policy but pthread.h is universally * at odds with this. */ if (__gthrw_(pthread_setschedparam) (thread_id, policy, ¶ms) == 0) return 0; } #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return -1; } } /* Return the current thread's priority. */ static inline int __gthread_objc_thread_get_priority (void) { #ifdef _POSIX_PRIORITY_SCHEDULING #ifdef _POSIX_THREAD_PRIORITY_SCHEDULING if (__gthread_active_p ()) { int policy; struct sched_param params; if (__gthrw_(pthread_getschedparam) (__gthrw_(pthread_self) (), &policy, ¶ms) == 0) return params.sched_priority; else return -1; } else #endif /* _POSIX_THREAD_PRIORITY_SCHEDULING */ #endif /* _POSIX_PRIORITY_SCHEDULING */ return OBJC_THREAD_INTERACTIVE_PRIORITY; } /* Yield our process time to another thread. */ static inline void __gthread_objc_thread_yield (void) { if (__gthread_active_p ()) __gthrw_(sched_yield) (); } /* Terminate the current thread. */ static inline int __gthread_objc_thread_exit (void) { if (__gthread_active_p ()) /* exit the thread */ __gthrw_(pthread_exit) (&__objc_thread_exit_status); /* Failed if we reached here */ return -1; } /* Returns an integer value which uniquely describes a thread. */ static inline objc_thread_t __gthread_objc_thread_id (void) { if (__gthread_active_p ()) return (objc_thread_t) __gthrw_(pthread_self) (); else return (objc_thread_t) 1; } /* Sets the thread's local storage pointer. */ static inline int __gthread_objc_thread_set_data (void *value) { if (__gthread_active_p ()) return __gthrw_(pthread_setspecific) (_objc_thread_storage, value); else { thread_local_storage = value; return 0; } } /* Returns the thread's local storage pointer. */ static inline void * __gthread_objc_thread_get_data (void) { if (__gthread_active_p ()) return __gthrw_(pthread_getspecific) (_objc_thread_storage); else return thread_local_storage; } /* Backend mutex functions */ /* Allocate a mutex. */ static inline int __gthread_objc_mutex_allocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { mutex->backend = objc_malloc (sizeof (pthread_mutex_t)); if (__gthrw_(pthread_mutex_init) ((pthread_mutex_t *) mutex->backend, NULL)) { objc_free (mutex->backend); mutex->backend = NULL; return -1; } } return 0; } /* Deallocate a mutex. */ static inline int __gthread_objc_mutex_deallocate (objc_mutex_t mutex) { if (__gthread_active_p ()) { int count; /* * Posix Threads specifically require that the thread be unlocked * for __gthrw_(pthread_mutex_destroy) to work. */ do { count = __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend); if (count < 0) return -1; } while (count); if (__gthrw_(pthread_mutex_destroy) ((pthread_mutex_t *) mutex->backend)) return -1; objc_free (mutex->backend); mutex->backend = NULL; } return 0; } /* Grab a lock on a mutex. */ static inline int __gthread_objc_mutex_lock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_lock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Try to grab a lock on a mutex. */ static inline int __gthread_objc_mutex_trylock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_trylock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Unlock the mutex */ static inline int __gthread_objc_mutex_unlock (objc_mutex_t mutex) { if (__gthread_active_p () && __gthrw_(pthread_mutex_unlock) ((pthread_mutex_t *) mutex->backend) != 0) { return -1; } return 0; } /* Backend condition mutex functions */ /* Allocate a condition. */ static inline int __gthread_objc_condition_allocate (objc_condition_t condition) { if (__gthread_active_p ()) { condition->backend = objc_malloc (sizeof (pthread_cond_t)); if (__gthrw_(pthread_cond_init) ((pthread_cond_t *) condition->backend, NULL)) { objc_free (condition->backend); condition->backend = NULL; return -1; } } return 0; } /* Deallocate a condition. */ static inline int __gthread_objc_condition_deallocate (objc_condition_t condition) { if (__gthread_active_p ()) { if (__gthrw_(pthread_cond_destroy) ((pthread_cond_t *) condition->backend)) return -1; objc_free (condition->backend); condition->backend = NULL; } return 0; } /* Wait on the condition */ static inline int __gthread_objc_condition_wait (objc_condition_t condition, objc_mutex_t mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_wait) ((pthread_cond_t *) condition->backend, (pthread_mutex_t *) mutex->backend); else return 0; } /* Wake up all threads waiting on this condition. */ static inline int __gthread_objc_condition_broadcast (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_broadcast) ((pthread_cond_t *) condition->backend); else return 0; } /* Wake up one thread waiting on this condition. */ static inline int __gthread_objc_condition_signal (objc_condition_t condition) { if (__gthread_active_p ()) return __gthrw_(pthread_cond_signal) ((pthread_cond_t *) condition->backend); else return 0; } #else /* _LIBOBJC */ static inline int __gthread_create (__gthread_t *__threadid, void *(*__func) (void*), void *__args) { return __gthrw_(pthread_create) (__threadid, NULL, __func, __args); } static inline int __gthread_join (__gthread_t __threadid, void **__value_ptr) { return __gthrw_(pthread_join) (__threadid, __value_ptr); } static inline int __gthread_detach (__gthread_t __threadid) { return __gthrw_(pthread_detach) (__threadid); } static inline int __gthread_equal (__gthread_t __t1, __gthread_t __t2) { return __gthrw_(pthread_equal) (__t1, __t2); } static inline __gthread_t __gthread_self (void) { return __gthrw_(pthread_self) (); } static inline int __gthread_yield (void) { return __gthrw_(sched_yield) (); } static inline int __gthread_once (__gthread_once_t *__once, void (*__func) (void)) { if (__gthread_active_p ()) return __gthrw_(pthread_once) (__once, __func); else return -1; } static inline int __gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *)) { return __gthrw_(pthread_key_create) (__key, __dtor); } static inline int __gthread_key_delete (__gthread_key_t __key) { return __gthrw_(pthread_key_delete) (__key); } static inline void * __gthread_getspecific (__gthread_key_t __key) { return __gthrw_(pthread_getspecific) (__key); } static inline int __gthread_setspecific (__gthread_key_t __key, const void *__ptr) { return __gthrw_(pthread_setspecific) (__key, __ptr); } static inline void __gthread_mutex_init_function (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) __gthrw_(pthread_mutex_init) (__mutex, NULL); } static inline int __gthread_mutex_destroy (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_destroy) (__mutex); else return 0; } static inline int __gthread_mutex_lock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_lock) (__mutex); else return 0; } static inline int __gthread_mutex_trylock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_trylock) (__mutex); else return 0; } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_mutex_timedlock (__gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_timedlock) (__mutex, __abs_timeout); else return 0; } #endif static inline int __gthread_mutex_unlock (__gthread_mutex_t *__mutex) { if (__gthread_active_p ()) return __gthrw_(pthread_mutex_unlock) (__mutex); else return 0; } #if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \ || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC) static inline int __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex) { if (__gthread_active_p ()) { pthread_mutexattr_t __attr; int __r; __r = __gthrw_(pthread_mutexattr_init) (&__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_settype) (&__attr, PTHREAD_MUTEX_RECURSIVE); if (!__r) __r = __gthrw_(pthread_mutex_init) (__mutex, &__attr); if (!__r) __r = __gthrw_(pthread_mutexattr_destroy) (&__attr); return __r; } return 0; } #endif static inline int __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_lock (__mutex); } static inline int __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_trylock (__mutex); } #if _GTHREAD_USE_MUTEX_TIMEDLOCK static inline int __gthread_recursive_mutex_timedlock (__gthread_recursive_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthread_mutex_timedlock (__mutex, __abs_timeout); } #endif static inline int __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_unlock (__mutex); } static inline int __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex) { return __gthread_mutex_destroy (__mutex); } #ifdef _GTHREAD_USE_COND_INIT_FUNC static inline void __gthread_cond_init_function (__gthread_cond_t *__cond) { if (__gthread_active_p ()) __gthrw_(pthread_cond_init) (__cond, NULL); } #endif static inline int __gthread_cond_broadcast (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_broadcast) (__cond); } static inline int __gthread_cond_signal (__gthread_cond_t *__cond) { return __gthrw_(pthread_cond_signal) (__cond); } static inline int __gthread_cond_wait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex) { return __gthrw_(pthread_cond_wait) (__cond, __mutex); } static inline int __gthread_cond_timedwait (__gthread_cond_t *__cond, __gthread_mutex_t *__mutex, const __gthread_time_t *__abs_timeout) { return __gthrw_(pthread_cond_timedwait) (__cond, __mutex, __abs_timeout); } static inline int __gthread_cond_wait_recursive (__gthread_cond_t *__cond, __gthread_recursive_mutex_t *__mutex) { return __gthread_cond_wait (__cond, __mutex); } static inline int __gthread_cond_destroy (__gthread_cond_t* __cond) { return __gthrw_(pthread_cond_destroy) (__cond); } #endif /* _LIBOBJC */ #endif /* ! _GLIBCXX_GCC_GTHR_POSIX_H */ // Wrapper of C-language FILE struct -*- C++ -*- // Copyright (C) 2000-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. // // ISO C++ 14882: 27.8 File-based streams // /** @file bits/basic_file.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ios} */ #ifndef _GLIBCXX_BASIC_FILE_STDIO_H #define _GLIBCXX_BASIC_FILE_STDIO_H 1 #pragma GCC system_header #include <bits/c++config.h> #include <bits/c++io.h> // for __c_lock and __c_file #include <bits/move.h> // for swap #include <ios> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION // Generic declaration. template<typename _CharT> class __basic_file; // Specialization. template<> class __basic_file<char> { // Underlying data source/sink. __c_file* _M_cfile; // True iff we opened _M_cfile, and thus must close it ourselves. bool _M_cfile_created; public: __basic_file(__c_lock* __lock = 0) throw (); #if __cplusplus >= 201103L __basic_file(__basic_file&& __rv, __c_lock* = 0) noexcept : _M_cfile(__rv._M_cfile), _M_cfile_created(__rv._M_cfile_created) { __rv._M_cfile = nullptr; __rv._M_cfile_created = false; } __basic_file& operator=(const __basic_file&) = delete; __basic_file& operator=(__basic_file&&) = delete; void swap(__basic_file& __f) noexcept { std::swap(_M_cfile, __f._M_cfile); std::swap(_M_cfile_created, __f._M_cfile_created); } #endif __basic_file* open(const char* __name, ios_base::openmode __mode, int __prot = 0664); #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T __basic_file* open(const wchar_t* __name, ios_base::openmode __mode); #endif __basic_file* sys_open(__c_file* __file, ios_base::openmode); __basic_file* sys_open(int __fd, ios_base::openmode __mode) throw (); __basic_file* close(); _GLIBCXX_PURE bool is_open() const throw (); _GLIBCXX_PURE int fd() throw (); _GLIBCXX_PURE __c_file* file() throw (); ~__basic_file(); streamsize xsputn(const char* __s, streamsize __n); streamsize xsputn_2(const char* __s1, streamsize __n1, const char* __s2, streamsize __n2); streamsize xsgetn(char* __s, streamsize __n); streamoff seekoff(streamoff __off, ios_base::seekdir __way) throw (); int sync(); streamsize showmanyc(); }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // Optimizations for random number extensions, x86 version -*- C++ -*- // Copyright (C) 2012-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file ext/random.tcc * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{ext/random} */ #ifndef _EXT_OPT_RANDOM_H #define _EXT_OPT_RANDOM_H 1 #pragma GCC system_header #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #ifdef __SSE2__ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace { template<size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2, uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4> inline __m128i __sse2_recursion(__m128i __a, __m128i __b, __m128i __c, __m128i __d) { __m128i __y = _mm_srli_epi32(__b, __sr1); __m128i __z = _mm_srli_si128(__c, __sr2); __m128i __v = _mm_slli_epi32(__d, __sl1); __z = _mm_xor_si128(__z, __a); __z = _mm_xor_si128(__z, __v); __m128i __x = _mm_slli_si128(__a, __sl2); __y = _mm_and_si128(__y, _mm_set_epi32(__msk4, __msk3, __msk2, __msk1)); __z = _mm_xor_si128(__z, __x); return _mm_xor_si128(__z, __y); } } #define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_GEN_READ 1 template<typename _UIntType, size_t __m, size_t __pos1, size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2, uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4, uint32_t __parity1, uint32_t __parity2, uint32_t __parity3, uint32_t __parity4> void simd_fast_mersenne_twister_engine<_UIntType, __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4, __parity1, __parity2, __parity3, __parity4>:: _M_gen_rand(void) { __m128i __r1 = _mm_load_si128(&_M_state[_M_nstate - 2]); __m128i __r2 = _mm_load_si128(&_M_state[_M_nstate - 1]); size_t __i; for (__i = 0; __i < _M_nstate - __pos1; ++__i) { __m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4> (_M_state[__i], _M_state[__i + __pos1], __r1, __r2); _mm_store_si128(&_M_state[__i], __r); __r1 = __r2; __r2 = __r; } for (; __i < _M_nstate; ++__i) { __m128i __r = __sse2_recursion<__sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4> (_M_state[__i], _M_state[__i + __pos1 - _M_nstate], __r1, __r2); _mm_store_si128(&_M_state[__i], __r); __r1 = __r2; __r2 = __r; } _M_pos = 0; } #define _GLIBCXX_OPT_HAVE_RANDOM_SFMT_OPERATOREQUAL 1 template<typename _UIntType, size_t __m, size_t __pos1, size_t __sl1, size_t __sl2, size_t __sr1, size_t __sr2, uint32_t __msk1, uint32_t __msk2, uint32_t __msk3, uint32_t __msk4, uint32_t __parity1, uint32_t __parity2, uint32_t __parity3, uint32_t __parity4> bool operator==(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType, __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4, __parity1, __parity2, __parity3, __parity4>& __lhs, const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType, __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3, __msk4, __parity1, __parity2, __parity3, __parity4>& __rhs) { __m128i __res = _mm_cmpeq_epi8(__lhs._M_state[0], __rhs._M_state[0]); for (size_t __i = 1; __i < __lhs._M_nstate; ++__i) __res = _mm_and_si128(__res, _mm_cmpeq_epi8(__lhs._M_state[__i], __rhs._M_state[__i])); return (_mm_movemask_epi8(__res) == 0xffff && __lhs._M_pos == __rhs._M_pos); } _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // __SSE2__ #endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #endif // _EXT_OPT_RANDOM_H // C++11 <typeindex> -*- C++ -*- // Copyright (C) 2010-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/typeindex * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_TYPEINDEX #define _GLIBCXX_TYPEINDEX 1 #pragma GCC system_header #if __cplusplus < 201103L # include <bits/c++0x_warning.h> #else #include <typeinfo> #if __cplusplus > 201703L # include <compare> #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @brief Class type_index * @ingroup utilities * * The class type_index provides a simple wrapper for type_info * which can be used as an index type in associative containers * (23.6) and in unordered associative containers (23.7). */ struct type_index { type_index(const type_info& __rhs) noexcept : _M_target(&__rhs) { } bool operator==(const type_index& __rhs) const noexcept { return *_M_target == *__rhs._M_target; } #if ! __cpp_lib_three_way_comparison bool operator!=(const type_index& __rhs) const noexcept { return *_M_target != *__rhs._M_target; } #endif bool operator<(const type_index& __rhs) const noexcept { return _M_target->before(*__rhs._M_target); } bool operator<=(const type_index& __rhs) const noexcept { return !__rhs._M_target->before(*_M_target); } bool operator>(const type_index& __rhs) const noexcept { return __rhs._M_target->before(*_M_target); } bool operator>=(const type_index& __rhs) const noexcept { return !_M_target->before(*__rhs._M_target); } #if __cpp_lib_three_way_comparison strong_ordering operator<=>(const type_index& __rhs) const noexcept { if (*_M_target == *__rhs._M_target) return strong_ordering::equal; if (_M_target->before(*__rhs._M_target)) return strong_ordering::less; return strong_ordering::greater; } #endif size_t hash_code() const noexcept { return _M_target->hash_code(); } const char* name() const noexcept { return _M_target->name(); } private: const type_info* _M_target; }; template<typename _Tp> struct hash; /// std::hash specialization for type_index. template<> struct hash<type_index> { typedef size_t result_type; typedef type_index argument_type; size_t operator()(const type_index& __ti) const noexcept { return __ti.hash_code(); } }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++11 #endif // _GLIBCXX_TYPEINDEX // <coroutine> -*- C++ -*- // Copyright (C) 2019-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/coroutine * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_COROUTINE #define _GLIBCXX_COROUTINE 1 #pragma GCC system_header // It is very likely that earlier versions would work, but they are untested. #if __cplusplus >= 201402L #include <bits/c++config.h> /** * @defgroup coroutines Coroutines * * Components for supporting coroutine implementations. */ #if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L # include <compare> # define _COROUTINES_USE_SPACESHIP 1 #else # include <bits/stl_function.h> // for std::less # define _COROUTINES_USE_SPACESHIP 0 #endif namespace std _GLIBCXX_VISIBILITY (default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cpp_impl_coroutine #define __cpp_lib_coroutine 201902L inline namespace __n4861 { // 17.12.2 coroutine traits /// [coroutine.traits] /// [coroutine.traits.primary] /// If _Result::promise_type is valid and denotes a type then the traits /// have a single publicly accessible member, otherwise they are empty. template <typename _Result, typename = void> struct __coroutine_traits_impl {}; template <typename _Result> struct __coroutine_traits_impl<_Result, __void_t<typename _Result::promise_type>> { using promise_type = typename _Result::promise_type; }; template <typename _Result, typename...> struct coroutine_traits : __coroutine_traits_impl<_Result> {}; // 17.12.3 Class template coroutine_handle /// [coroutine.handle] template <typename _Promise = void> struct coroutine_handle; template <> struct coroutine_handle<void> { public: // [coroutine.handle.con], construct/reset constexpr coroutine_handle() noexcept : _M_fr_ptr(0) {} constexpr coroutine_handle(std::nullptr_t __h) noexcept : _M_fr_ptr(__h) {} coroutine_handle& operator=(std::nullptr_t) noexcept { _M_fr_ptr = nullptr; return *this; } public: // [coroutine.handle.export.import], export/import constexpr void* address() const noexcept { return _M_fr_ptr; } constexpr static coroutine_handle from_address(void* __a) noexcept { coroutine_handle __self; __self._M_fr_ptr = __a; return __self; } public: // [coroutine.handle.observers], observers constexpr explicit operator bool() const noexcept { return bool(_M_fr_ptr); } bool done() const noexcept { return __builtin_coro_done(_M_fr_ptr); } // [coroutine.handle.resumption], resumption void operator()() const { resume(); } void resume() const { __builtin_coro_resume(_M_fr_ptr); } void destroy() const { __builtin_coro_destroy(_M_fr_ptr); } protected: void* _M_fr_ptr; }; // [coroutine.handle.compare], comparison operators constexpr bool operator==(coroutine_handle<> __a, coroutine_handle<> __b) noexcept { return __a.address() == __b.address(); } #if _COROUTINES_USE_SPACESHIP constexpr strong_ordering operator<=>(coroutine_handle<> __a, coroutine_handle<> __b) noexcept { return std::compare_three_way()(__a.address(), __b.address()); } #else // These are to enable operation with std=c++14,17. constexpr bool operator!=(coroutine_handle<> __a, coroutine_handle<> __b) noexcept { return !(__a == __b); } constexpr bool operator<(coroutine_handle<> __a, coroutine_handle<> __b) noexcept { return less<void*>()(__a.address(), __b.address()); } constexpr bool operator>(coroutine_handle<> __a, coroutine_handle<> __b) noexcept { return __b < __a; } constexpr bool operator<=(coroutine_handle<> __a, coroutine_handle<> __b) noexcept { return !(__a > __b); } constexpr bool operator>=(coroutine_handle<> __a, coroutine_handle<> __b) noexcept { return !(__a < __b); } #endif template <typename _Promise> struct coroutine_handle { // [coroutine.handle.con], construct/reset constexpr coroutine_handle() noexcept { } constexpr coroutine_handle(nullptr_t) noexcept { } static coroutine_handle from_promise(_Promise& __p) { coroutine_handle __self; __self._M_fr_ptr = __builtin_coro_promise((char*) &__p, __alignof(_Promise), true); return __self; } coroutine_handle& operator=(nullptr_t) noexcept { _M_fr_ptr = nullptr; return *this; } // [coroutine.handle.export.import], export/import constexpr void* address() const noexcept { return _M_fr_ptr; } constexpr static coroutine_handle from_address(void* __a) noexcept { coroutine_handle __self; __self._M_fr_ptr = __a; return __self; } // [coroutine.handle.conv], conversion constexpr operator coroutine_handle<>() const noexcept { return coroutine_handle<>::from_address(address()); } // [coroutine.handle.observers], observers constexpr explicit operator bool() const noexcept { return bool(_M_fr_ptr); } bool done() const noexcept { return __builtin_coro_done(_M_fr_ptr); } // [coroutine.handle.resumption], resumption void operator()() const { resume(); } void resume() const { __builtin_coro_resume(_M_fr_ptr); } void destroy() const { __builtin_coro_destroy(_M_fr_ptr); } // [coroutine.handle.promise], promise access _Promise& promise() const { void* __t = __builtin_coro_promise (_M_fr_ptr, __alignof(_Promise), false); return *static_cast<_Promise*>(__t); } private: void* _M_fr_ptr = nullptr; }; /// [coroutine.noop] struct noop_coroutine_promise { }; // 17.12.4.1 Class noop_coroutine_promise /// [coroutine.promise.noop] template <> struct coroutine_handle<noop_coroutine_promise> { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3460. Unimplementable noop_coroutine_handle guarantees // [coroutine.handle.noop.conv], conversion constexpr operator coroutine_handle<>() const noexcept { return coroutine_handle<>::from_address(address()); } // [coroutine.handle.noop.observers], observers constexpr explicit operator bool() const noexcept { return true; } constexpr bool done() const noexcept { return false; } // [coroutine.handle.noop.resumption], resumption void operator()() const noexcept {} void resume() const noexcept {} void destroy() const noexcept {} // [coroutine.handle.noop.promise], promise access noop_coroutine_promise& promise() const noexcept { return _S_fr.__p; } // [coroutine.handle.noop.address], address constexpr void* address() const noexcept { return _M_fr_ptr; } private: friend coroutine_handle noop_coroutine() noexcept; struct __frame { static void __dummy_resume_destroy() { } void (*__r)() = __dummy_resume_destroy; void (*__d)() = __dummy_resume_destroy; struct noop_coroutine_promise __p; }; static __frame _S_fr; explicit coroutine_handle() noexcept = default; void* _M_fr_ptr = &_S_fr; }; using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>; inline noop_coroutine_handle::__frame noop_coroutine_handle::_S_fr{}; inline noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle(); } // 17.12.5 Trivial awaitables /// [coroutine.trivial.awaitables] struct suspend_always { constexpr bool await_ready() const noexcept { return false; } constexpr void await_suspend(coroutine_handle<>) const noexcept {} constexpr void await_resume() const noexcept {} }; struct suspend_never { constexpr bool await_ready() const noexcept { return true; } constexpr void await_suspend(coroutine_handle<>) const noexcept {} constexpr void await_resume() const noexcept {} }; } // namespace __n4861 #else #error "the coroutine header requires -fcoroutines" #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++14 (we are allowing use from at least this) #endif // _GLIBCXX_COROUTINE // -*- C++ -*- forwarding header. // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file cstring * This is a Standard C++ Library file. You should @c \#include this file * in your programs, rather than any of the @a *.h implementation files. * * This is the C++ version of the Standard C Library header @c string.h, * and its contents are (mostly) the same as that header, but are all * contained in the namespace @c std (except for names which are defined * as macros in C). */ // // ISO C++ 14882: 20.4.6 C library // #pragma GCC system_header #include <bits/c++config.h> #include <string.h> #ifndef _GLIBCXX_CSTRING #define _GLIBCXX_CSTRING 1 // Get rid of those macros defined in <string.h> in lieu of real functions. #undef memchr #undef memcmp #undef memcpy #undef memmove #undef memset #undef strcat #undef strchr #undef strcmp #undef strcoll #undef strcpy #undef strcspn #undef strerror #undef strlen #undef strncat #undef strncmp #undef strncpy #undef strpbrk #undef strrchr #undef strspn #undef strstr #undef strtok #undef strxfrm extern "C++" { namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION using ::memchr; using ::memcmp; using ::memcpy; using ::memmove; using ::memset; using ::strcat; using ::strcmp; using ::strcoll; using ::strcpy; using ::strcspn; using ::strerror; using ::strlen; using ::strncat; using ::strncmp; using ::strncpy; using ::strspn; using ::strtok; using ::strxfrm; using ::strchr; using ::strpbrk; using ::strrchr; using ::strstr; #ifndef __CORRECT_ISO_CPP_STRING_H_PROTO inline void* memchr(void* __s, int __c, size_t __n) { return __builtin_memchr(__s, __c, __n); } inline char* strchr(char* __s, int __n) { return __builtin_strchr(__s, __n); } inline char* strpbrk(char* __s1, const char* __s2) { return __builtin_strpbrk(__s1, __s2); } inline char* strrchr(char* __s, int __n) { return __builtin_strrchr(__s, __n); } inline char* strstr(char* __s1, const char* __s2) { return __builtin_strstr(__s1, __s2); } #endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace } // extern "C++" #endif // Input streams -*- C++ -*- // Copyright (C) 1997-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. // // ISO C++ 14882: 27.6.1 Input streams // /** @file include/istream * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_ISTREAM #define _GLIBCXX_ISTREAM 1 #pragma GCC system_header #include <ios> #include <ostream> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * @brief Template class basic_istream. * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * * This is the base class for all input streams. It provides text * formatting of all builtin types, and communicates with any class * derived from basic_streambuf to do the actual input. */ template<typename _CharT, typename _Traits> class basic_istream : virtual public basic_ios<_CharT, _Traits> { public: // Types (inherited from basic_ios (27.4.4)): typedef _CharT char_type; typedef typename _Traits::int_type int_type; typedef typename _Traits::pos_type pos_type; typedef typename _Traits::off_type off_type; typedef _Traits traits_type; // Non-standard Types: typedef basic_streambuf<_CharT, _Traits> __streambuf_type; typedef basic_ios<_CharT, _Traits> __ios_type; typedef basic_istream<_CharT, _Traits> __istream_type; typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> > __num_get_type; typedef ctype<_CharT> __ctype_type; protected: // Data Members: /** * The number of characters extracted in the previous unformatted * function; see gcount(). */ streamsize _M_gcount; public: /** * @brief Base constructor. * * This ctor is almost never called by the user directly, rather from * derived classes' initialization lists, which pass a pointer to * their own stream buffer. */ explicit basic_istream(__streambuf_type* __sb) : _M_gcount(streamsize(0)) { this->init(__sb); } /** * @brief Base destructor. * * This does very little apart from providing a virtual base dtor. */ virtual ~basic_istream() { _M_gcount = streamsize(0); } /// Safe prefix/suffix operations. class sentry; friend class sentry; ///@{ /** * @brief Interface for manipulators. * * Manipulators such as @c std::ws and @c std::dec use these * functions in constructs like * <code>std::cin >> std::ws</code>. * For more information, see the iomanip header. */ __istream_type& operator>>(__istream_type& (*__pf)(__istream_type&)) { return __pf(*this); } __istream_type& operator>>(__ios_type& (*__pf)(__ios_type&)) { __pf(*this); return *this; } __istream_type& operator>>(ios_base& (*__pf)(ios_base&)) { __pf(*this); return *this; } ///@} ///@{ /** * @name Extractors * * All the @c operator>> functions (aka <em>formatted input * functions</em>) have some common behavior. Each starts by * constructing a temporary object of type std::basic_istream::sentry * with the second argument (noskipws) set to false. This has several * effects, concluding with the setting of a status flag; see the * sentry documentation for more. * * If the sentry status is good, the function tries to extract * whatever data is appropriate for the type of the argument. * * If an exception is thrown during extraction, ios_base::badbit * will be turned on in the stream's error state (without causing an * ios_base::failure to be thrown) and the original exception will * be rethrown if badbit is set in the exceptions mask. */ ///@{ /** * @brief Integer arithmetic extractors * @param __n A variable of builtin integral type. * @return @c *this if successful * * These functions use the stream's current locale (specifically, the * @c num_get facet) to parse the input data. */ __istream_type& operator>>(bool& __n) { return _M_extract(__n); } __istream_type& operator>>(short& __n); __istream_type& operator>>(unsigned short& __n) { return _M_extract(__n); } __istream_type& operator>>(int& __n); __istream_type& operator>>(unsigned int& __n) { return _M_extract(__n); } __istream_type& operator>>(long& __n) { return _M_extract(__n); } __istream_type& operator>>(unsigned long& __n) { return _M_extract(__n); } #ifdef _GLIBCXX_USE_LONG_LONG __istream_type& operator>>(long long& __n) { return _M_extract(__n); } __istream_type& operator>>(unsigned long long& __n) { return _M_extract(__n); } #endif ///@} ///@{ /** * @brief Floating point arithmetic extractors * @param __f A variable of builtin floating point type. * @return @c *this if successful * * These functions use the stream's current locale (specifically, the * @c num_get facet) to parse the input data. */ __istream_type& operator>>(float& __f) { return _M_extract(__f); } __istream_type& operator>>(double& __f) { return _M_extract(__f); } __istream_type& operator>>(long double& __f) { return _M_extract(__f); } ///@} /** * @brief Basic arithmetic extractors * @param __p A variable of pointer type. * @return @c *this if successful * * These functions use the stream's current locale (specifically, the * @c num_get facet) to parse the input data. */ __istream_type& operator>>(void*& __p) { return _M_extract(__p); } /** * @brief Extracting into another streambuf. * @param __sb A pointer to a streambuf * * This function behaves like one of the basic arithmetic extractors, * in that it also constructs a sentry object and has the same error * handling behavior. * * If @p __sb is NULL, the stream will set failbit in its error state. * * Characters are extracted from this stream and inserted into the * @p __sb streambuf until one of the following occurs: * * - the input stream reaches end-of-file, * - insertion into the output buffer fails (in this case, the * character that would have been inserted is not extracted), or * - an exception occurs (and in this case is caught) * * If the function inserts no characters, failbit is set. */ __istream_type& operator>>(__streambuf_type* __sb); ///@} // [27.6.1.3] unformatted input /** * @brief Character counting * @return The number of characters extracted by the previous * unformatted input function dispatched for this stream. */ streamsize gcount() const { return _M_gcount; } ///@{ /** * @name Unformatted Input Functions * * All the unformatted input functions have some common behavior. * Each starts by constructing a temporary object of type * std::basic_istream::sentry with the second argument (noskipws) * set to true. This has several effects, concluding with the * setting of a status flag; see the sentry documentation for more. * * If the sentry status is good, the function tries to extract * whatever data is appropriate for the type of the argument. * * The number of characters extracted is stored for later retrieval * by gcount(). * * If an exception is thrown during extraction, ios_base::badbit * will be turned on in the stream's error state (without causing an * ios_base::failure to be thrown) and the original exception will * be rethrown if badbit is set in the exceptions mask. */ /** * @brief Simple extraction. * @return A character, or eof(). * * Tries to extract a character. If none are available, sets failbit * and returns traits::eof(). */ int_type get(); /** * @brief Simple extraction. * @param __c The character in which to store data. * @return *this * * Tries to extract a character and store it in @a __c. If none are * available, sets failbit and returns traits::eof(). * * @note This function is not overloaded on signed char and * unsigned char. */ __istream_type& get(char_type& __c); /** * @brief Simple multiple-character extraction. * @param __s Pointer to an array. * @param __n Maximum number of characters to store in @a __s. * @param __delim A "stop" character. * @return *this * * Characters are extracted and stored into @a __s until one of the * following happens: * * - @c __n-1 characters are stored * - the input sequence reaches EOF * - the next character equals @a __delim, in which case the character * is not extracted * * If no characters are stored, failbit is set in the stream's error * state. * * In any case, a null character is stored into the next location in * the array. * * @note This function is not overloaded on signed char and * unsigned char. */ __istream_type& get(char_type* __s, streamsize __n, char_type __delim); /** * @brief Simple multiple-character extraction. * @param __s Pointer to an array. * @param __n Maximum number of characters to store in @a s. * @return *this * * Returns @c get(__s,__n,widen('\\n')). */ __istream_type& get(char_type* __s, streamsize __n) { return this->get(__s, __n, this->widen('\n')); } /** * @brief Extraction into another streambuf. * @param __sb A streambuf in which to store data. * @param __delim A "stop" character. * @return *this * * Characters are extracted and inserted into @a __sb until one of the * following happens: * * - the input sequence reaches EOF * - insertion into the output buffer fails (in this case, the * character that would have been inserted is not extracted) * - the next character equals @a __delim (in this case, the character * is not extracted) * - an exception occurs (and in this case is caught) * * If no characters are stored, failbit is set in the stream's error * state. */ __istream_type& get(__streambuf_type& __sb, char_type __delim); /** * @brief Extraction into another streambuf. * @param __sb A streambuf in which to store data. * @return *this * * Returns @c get(__sb,widen('\\n')). */ __istream_type& get(__streambuf_type& __sb) { return this->get(__sb, this->widen('\n')); } /** * @brief String extraction. * @param __s A character array in which to store the data. * @param __n Maximum number of characters to extract. * @param __delim A "stop" character. * @return *this * * Extracts and stores characters into @a __s until one of the * following happens. Note that these criteria are required to be * tested in the order listed here, to allow an input line to exactly * fill the @a __s array without setting failbit. * * -# the input sequence reaches end-of-file, in which case eofbit * is set in the stream error state * -# the next character equals @c __delim, in which case the character * is extracted (and therefore counted in @c gcount()) but not stored * -# @c __n-1 characters are stored, in which case failbit is set * in the stream error state * * If no characters are extracted, failbit is set. (An empty line of * input should therefore not cause failbit to be set.) * * In any case, a null character is stored in the next location in * the array. */ __istream_type& getline(char_type* __s, streamsize __n, char_type __delim); /** * @brief String extraction. * @param __s A character array in which to store the data. * @param __n Maximum number of characters to extract. * @return *this * * Returns @c getline(__s,__n,widen('\\n')). */ __istream_type& getline(char_type* __s, streamsize __n) { return this->getline(__s, __n, this->widen('\n')); } /** * @brief Discarding characters * @param __n Number of characters to discard. * @param __delim A "stop" character. * @return *this * * Extracts characters and throws them away until one of the * following happens: * - if @a __n @c != @c std::numeric_limits<int>::max(), @a __n * characters are extracted * - the input sequence reaches end-of-file * - the next character equals @a __delim (in this case, the character * is extracted); note that this condition will never occur if * @a __delim equals @c traits::eof(). * * NB: Provide three overloads, instead of the single function * (with defaults) mandated by the Standard: this leads to a * better performing implementation, while still conforming to * the Standard. */ __istream_type& ignore(streamsize __n, int_type __delim); __istream_type& ignore(streamsize __n); __istream_type& ignore(); /** * @brief Looking ahead in the stream * @return The next character, or eof(). * * If, after constructing the sentry object, @c good() is false, * returns @c traits::eof(). Otherwise reads but does not extract * the next input character. */ int_type peek(); /** * @brief Extraction without delimiters. * @param __s A character array. * @param __n Maximum number of characters to store. * @return *this * * If the stream state is @c good(), extracts characters and stores * them into @a __s until one of the following happens: * - @a __n characters are stored * - the input sequence reaches end-of-file, in which case the error * state is set to @c failbit|eofbit. * * @note This function is not overloaded on signed char and * unsigned char. */ __istream_type& read(char_type* __s, streamsize __n); /** * @brief Extraction until the buffer is exhausted, but no more. * @param __s A character array. * @param __n Maximum number of characters to store. * @return The number of characters extracted. * * Extracts characters and stores them into @a __s depending on the * number of characters remaining in the streambuf's buffer, * @c rdbuf()->in_avail(), called @c A here: * - if @c A @c == @c -1, sets eofbit and extracts no characters * - if @c A @c == @c 0, extracts no characters * - if @c A @c > @c 0, extracts @c min(A,n) * * The goal is to empty the current buffer, and to not request any * more from the external input sequence controlled by the streambuf. */ streamsize readsome(char_type* __s, streamsize __n); /** * @brief Unextracting a single character. * @param __c The character to push back into the input stream. * @return *this * * If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c). * * If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in * the error state. * * @note This function first clears eofbit. Since no characters * are extracted, the next call to @c gcount() will return 0, * as required by DR 60. */ __istream_type& putback(char_type __c); /** * @brief Unextracting the previous character. * @return *this * * If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c). * * If @c rdbuf() is null or if @c sungetc() fails, sets badbit in * the error state. * * @note This function first clears eofbit. Since no characters * are extracted, the next call to @c gcount() will return 0, * as required by DR 60. */ __istream_type& unget(); /** * @brief Synchronizing the stream buffer. * @return 0 on success, -1 on failure * * If @c rdbuf() is a null pointer, returns -1. * * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1, * sets badbit and returns -1. * * Otherwise, returns 0. * * @note This function does not count the number of characters * extracted, if any, and therefore does not affect the next * call to @c gcount(). */ int sync(); /** * @brief Getting the current read position. * @return A file position object. * * If @c fail() is not false, returns @c pos_type(-1) to indicate * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,in). * * @note This function does not count the number of characters * extracted, if any, and therefore does not affect the next * call to @c gcount(). At variance with putback, unget and * seekg, eofbit is not cleared first. */ pos_type tellg(); /** * @brief Changing the current read position. * @param __pos A file position object. * @return *this * * If @c fail() is not true, calls @c rdbuf()->pubseekpos(__pos). If * that function fails, sets failbit. * * @note This function first clears eofbit. It does not count the * number of characters extracted, if any, and therefore does * not affect the next call to @c gcount(). */ __istream_type& seekg(pos_type); /** * @brief Changing the current read position. * @param __off A file offset object. * @param __dir The direction in which to seek. * @return *this * * If @c fail() is not true, calls @c rdbuf()->pubseekoff(__off,__dir). * If that function fails, sets failbit. * * @note This function first clears eofbit. It does not count the * number of characters extracted, if any, and therefore does * not affect the next call to @c gcount(). */ __istream_type& seekg(off_type, ios_base::seekdir); ///@} protected: basic_istream() : _M_gcount(streamsize(0)) { this->init(0); } #if __cplusplus >= 201103L basic_istream(const basic_istream&) = delete; basic_istream(basic_istream&& __rhs) : __ios_type(), _M_gcount(__rhs._M_gcount) { __ios_type::move(__rhs); __rhs._M_gcount = 0; } // 27.7.3.3 Assign/swap basic_istream& operator=(const basic_istream&) = delete; basic_istream& operator=(basic_istream&& __rhs) { swap(__rhs); return *this; } void swap(basic_istream& __rhs) { __ios_type::swap(__rhs); std::swap(_M_gcount, __rhs._M_gcount); } #endif template<typename _ValueT> __istream_type& _M_extract(_ValueT& __v); }; /// Explicit specialization declarations, defined in src/istream.cc. template<> basic_istream<char>& basic_istream<char>:: getline(char_type* __s, streamsize __n, char_type __delim); template<> basic_istream<char>& basic_istream<char>:: ignore(streamsize __n); template<> basic_istream<char>& basic_istream<char>:: ignore(streamsize __n, int_type __delim); #ifdef _GLIBCXX_USE_WCHAR_T template<> basic_istream<wchar_t>& basic_istream<wchar_t>:: getline(char_type* __s, streamsize __n, char_type __delim); template<> basic_istream<wchar_t>& basic_istream<wchar_t>:: ignore(streamsize __n); template<> basic_istream<wchar_t>& basic_istream<wchar_t>:: ignore(streamsize __n, int_type __delim); #endif /** * @brief Performs setup work for input streams. * * Objects of this class are created before all of the standard * extractors are run. It is responsible for <em>exception-safe * prefix and suffix operations,</em> although only prefix actions * are currently required by the standard. */ template<typename _CharT, typename _Traits> class basic_istream<_CharT, _Traits>::sentry { // Data Members. bool _M_ok; public: /// Easy access to dependent types. typedef _Traits traits_type; typedef basic_streambuf<_CharT, _Traits> __streambuf_type; typedef basic_istream<_CharT, _Traits> __istream_type; typedef typename __istream_type::__ctype_type __ctype_type; typedef typename _Traits::int_type __int_type; /** * @brief The constructor performs all the work. * @param __is The input stream to guard. * @param __noskipws Whether to consume whitespace or not. * * If the stream state is good (@a __is.good() is true), then the * following actions are performed, otherwise the sentry state * is false (<em>not okay</em>) and failbit is set in the * stream state. * * The sentry's preparatory actions are: * * -# if the stream is tied to an output stream, @c is.tie()->flush() * is called to synchronize the output sequence * -# if @a __noskipws is false, and @c ios_base::skipws is set in * @c is.flags(), the sentry extracts and discards whitespace * characters from the stream. The currently imbued locale is * used to determine whether each character is whitespace. * * If the stream state is still good, then the sentry state becomes * true (@a okay). */ explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false); /** * @brief Quick status checking. * @return The sentry state. * * For ease of use, sentries may be converted to booleans. The * return value is that of the sentry state (true == okay). */ #if __cplusplus >= 201103L explicit #endif operator bool() const { return _M_ok; } }; ///@{ /** * @brief Character extractors * @param __in An input stream. * @param __c A character reference. * @return in * * Behaves like one of the formatted arithmetic extractors described in * std::basic_istream. After constructing a sentry object with good * status, this function extracts a character (if one is available) and * stores it in @a __c. Otherwise, sets failbit in the input stream. */ template<typename _CharT, typename _Traits> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c); template<class _Traits> inline basic_istream<char, _Traits>& operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c) { return (__in >> reinterpret_cast<char&>(__c)); } template<class _Traits> inline basic_istream<char, _Traits>& operator>>(basic_istream<char, _Traits>& __in, signed char& __c) { return (__in >> reinterpret_cast<char&>(__c)); } ///@} template<typename _CharT, typename _Traits> void __istream_extract(basic_istream<_CharT, _Traits>&, _CharT*, streamsize); void __istream_extract(istream&, char*, streamsize); ///@{ /** * @brief Character string extractors * @param __in An input stream. * @param __s A character array (or a pointer to an array before C++20). * @return __in * * Behaves like one of the formatted arithmetic extractors described in * `std::basic_istream`. After constructing a sentry object with good * status, this function extracts up to `n` characters and stores them * into the array `__s`. `n` is defined as: * * - if `width()` is greater than zero, `n` is `min(width(), n)` * - otherwise `n` is the number of elements of the array * - (before C++20 the pointer is assumed to point to an array of * the largest possible size for an array of `char_type`). * * Characters are extracted and stored until one of the following happens: * - `n - 1` characters are stored * - EOF is reached * - the next character is whitespace according to the current locale * * `width(0)` is then called for the input stream. * * If no characters are extracted, sets failbit. */ #if __cplusplus <= 201703L template<typename _CharT, typename _Traits> __attribute__((__nonnull__(2), __access__(__write_only__, 2))) inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s) { #ifdef __OPTIMIZE__ // Function inlining might make the buffer size known, allowing us to // prevent overflow. size_t __n = __builtin_object_size(__s, 0); if (__n < sizeof(_CharT)) { // There is not even space for the required null terminator. __glibcxx_assert(__n >= sizeof(_CharT)); // No point calling __istream_extract, but still need to reset width. __in.width(0); __in.setstate(ios_base::failbit); } else if (__n != (size_t)-1) { __n /= sizeof(_CharT); streamsize __w = __in.width(); std::__istream_extract(__in, __s, __n); if (__in.good() && (__w <= 0 || __n < __w)) { // Stopped extracting early to avoid overflowing the buffer, // but might have stopped anyway (and set eofbit) if at EOF. const typename _Traits::int_type __c = __in.rdbuf()->sgetc(); const bool __eof = _Traits::eq_int_type(__c, _Traits::eof()); if (__builtin_expect(__eof, true)) // Assume EOF, not overflow. __in.setstate(ios_base::eofbit); } } else #endif // __OPTIMIZE { // Buffer size is unknown, have to assume it's huge. streamsize __n = __gnu_cxx::__numeric_traits<streamsize>::__max; __n /= sizeof(_CharT); std::__istream_extract(__in, __s, __n); } return __in; } template<class _Traits> __attribute__((__nonnull__(2), __access__(__write_only__, 2))) inline basic_istream<char, _Traits>& operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s) { return __in >> reinterpret_cast<char*>(__s); } template<class _Traits> __attribute__((__nonnull__(2), __access__(__write_only__, 2))) inline basic_istream<char, _Traits>& operator>>(basic_istream<char, _Traits>& __in, signed char* __s) { return __in >> reinterpret_cast<char*>(__s); } #else // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2499. operator>>(istream&, char*) makes it hard to avoid buffer overflows template<typename _CharT, typename _Traits, size_t _Num> inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __in, _CharT (&__s)[_Num]) { static_assert(_Num <= __gnu_cxx::__numeric_traits<streamsize>::__max); std::__istream_extract(__in, __s, _Num); return __in; } template<class _Traits, size_t _Num> inline basic_istream<char, _Traits>& operator>>(basic_istream<char, _Traits>& __in, unsigned char (&__s)[_Num]) { return __in >> reinterpret_cast<char(&)[_Num]>(__s); } template<class _Traits, size_t _Num> inline basic_istream<char, _Traits>& operator>>(basic_istream<char, _Traits>& __in, signed char (&__s)[_Num]) { return __in >> reinterpret_cast<char(&)[_Num]>(__s); } #endif ///@} /** * @brief Template class basic_iostream * @ingroup io * * @tparam _CharT Type of character stream. * @tparam _Traits Traits for character type, defaults to * char_traits<_CharT>. * * This class multiply inherits from the input and output stream classes * simply to provide a single interface. */ template<typename _CharT, typename _Traits> class basic_iostream : public basic_istream<_CharT, _Traits>, public basic_ostream<_CharT, _Traits> { public: // _GLIBCXX_RESOLVE_LIB_DEFECTS // 271. basic_iostream missing typedefs // Types (inherited): typedef _CharT char_type; typedef typename _Traits::int_type int_type; typedef typename _Traits::pos_type pos_type; typedef typename _Traits::off_type off_type; typedef _Traits traits_type; // Non-standard Types: typedef basic_istream<_CharT, _Traits> __istream_type; typedef basic_ostream<_CharT, _Traits> __ostream_type; /** * @brief Constructor does nothing. * * Both of the parent classes are initialized with the same * streambuf pointer passed to this constructor. */ explicit basic_iostream(basic_streambuf<_CharT, _Traits>* __sb) : __istream_type(__sb), __ostream_type(__sb) { } /** * @brief Destructor does nothing. */ virtual ~basic_iostream() { } protected: basic_iostream() : __istream_type(), __ostream_type() { } #if __cplusplus >= 201103L basic_iostream(const basic_iostream&) = delete; basic_iostream(basic_iostream&& __rhs) : __istream_type(std::move(__rhs)), __ostream_type(*this) { } // 27.7.3.3 Assign/swap basic_iostream& operator=(const basic_iostream&) = delete; basic_iostream& operator=(basic_iostream&& __rhs) { swap(__rhs); return *this; } void swap(basic_iostream& __rhs) { __istream_type::swap(__rhs); } #endif }; /** * @brief Quick and easy way to eat whitespace * * This manipulator extracts whitespace characters, stopping when the * next character is non-whitespace, or when the input sequence is empty. * If the sequence is empty, @c eofbit is set in the stream, but not * @c failbit. * * The current locale is used to distinguish whitespace characters. * * Example: * @code * MyClass mc; * * std::cin >> std::ws >> mc; * @endcode * will skip leading whitespace before calling operator>> on cin and your * object. Note that the same effect can be achieved by creating a * std::basic_istream::sentry inside your definition of operator>>. */ template<typename _CharT, typename _Traits> basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _Traits>& __is); #if __cplusplus >= 201103L // C++11 27.7.2.6 Rvalue stream extraction [istream.rvalue] // _GLIBCXX_RESOLVE_LIB_DEFECTS // 2328. Rvalue stream extraction should use perfect forwarding // 1203. More useful rvalue stream insertion #if __cpp_lib_concepts template<typename _Is, typename _Tp> requires __derived_from_ios_base<_Is> && requires (_Is& __is, _Tp&& __t) { __is >> std::forward<_Tp>(__t); } using __rvalue_stream_extraction_t = _Is&&; #else template<typename _Is, typename _Tp, typename = _Require_derived_from_ios_base<_Is>, typename = decltype(std::declval<_Is&>() >> std::declval<_Tp>())> using __rvalue_stream_extraction_t = _Is&&; #endif /** * @brief Generic extractor for rvalue stream * @param __is An input stream. * @param __x A reference to the extraction target. * @return __is * * This is just a forwarding function to allow extraction from * rvalue streams since they won't bind to the extractor functions * that take an lvalue reference. */ template<typename _Istream, typename _Tp> inline __rvalue_stream_extraction_t<_Istream, _Tp> operator>>(_Istream&& __is, _Tp&& __x) { __is >> std::forward<_Tp>(__x); return std::move(__is); } #endif // C++11 _GLIBCXX_END_NAMESPACE_VERSION } // namespace #include <bits/istream.tcc> #endif /* _GLIBCXX_ISTREAM */ // Variable Templates For Type Traits -*- C++ -*- // Copyright (C) 2014-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/type_traits * This is a TS C++ Library header. * * This header defines variable templates for the C++14 type traits. * * Equivalent variable templates are defined in namespace `std` since C++17. * @see variable_templates * * @ingroup libfund-ts * @since C++14 */ // // N3932 Variable Templates For Type Traits (Revision 1) // #ifndef _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS #define _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS 1 #pragma GCC system_header #if __cplusplus >= 201402L #include <type_traits> #include <experimental/bits/lfts_config.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { inline namespace fundamentals_v1 { /** @defgroup lfts_variable_templates Variable template for type traits * @ingroup libfund-ts * @since Library Fundamentals TS v1. C++14. * @see variable_templates */ /** @ingroup lfts_variable_templates * @{ */ #define __cpp_lib_experimental_type_trait_variable_templates 201402 // See C++14 20.10.4.1, primary type categories template <typename _Tp> constexpr bool is_void_v = is_void<_Tp>::value; template <typename _Tp> constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; template <typename _Tp> constexpr bool is_integral_v = is_integral<_Tp>::value; template <typename _Tp> constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; template <typename _Tp> constexpr bool is_array_v = is_array<_Tp>::value; template <typename _Tp> constexpr bool is_pointer_v = is_pointer<_Tp>::value; template <typename _Tp> constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; template <typename _Tp> constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; template <typename _Tp> constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value; template <typename _Tp> constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value; template <typename _Tp> constexpr bool is_enum_v = is_enum<_Tp>::value; template <typename _Tp> constexpr bool is_union_v = is_union<_Tp>::value; template <typename _Tp> constexpr bool is_class_v = is_class<_Tp>::value; template <typename _Tp> constexpr bool is_function_v = is_function<_Tp>::value; // See C++14 20.10.4.2, composite type categories template <typename _Tp> constexpr bool is_reference_v = is_reference<_Tp>::value; template <typename _Tp> constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; template <typename _Tp> constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; template <typename _Tp> constexpr bool is_object_v = is_object<_Tp>::value; template <typename _Tp> constexpr bool is_scalar_v = is_scalar<_Tp>::value; template <typename _Tp> constexpr bool is_compound_v = is_compound<_Tp>::value; template <typename _Tp> constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; // See C++14 20.10.4.3, type properties template <typename _Tp> constexpr bool is_const_v = is_const<_Tp>::value; template <typename _Tp> constexpr bool is_volatile_v = is_volatile<_Tp>::value; template <typename _Tp> constexpr bool is_trivial_v = is_trivial<_Tp>::value; template <typename _Tp> constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value; template <typename _Tp> constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" template <typename _Tp> constexpr bool is_pod_v = is_pod<_Tp>::value; template <typename _Tp> constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; #pragma GCC diagnostic pop template <typename _Tp> constexpr bool is_empty_v = is_empty<_Tp>::value; template <typename _Tp> constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; template <typename _Tp> constexpr bool is_abstract_v = is_abstract<_Tp>::value; template <typename _Tp> constexpr bool is_final_v = is_final<_Tp>::value; template <typename _Tp> constexpr bool is_signed_v = is_signed<_Tp>::value; template <typename _Tp> constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; template <typename _Tp, typename... _Args> constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value; template <typename _Tp> constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value; template <typename _Tp> constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value; template <typename _Tp> constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value; template <typename _Tp, typename _Up> constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; template <typename _Tp> constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; template <typename _Tp> constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; template <typename _Tp> constexpr bool is_destructible_v = is_destructible<_Tp>::value; template <typename _Tp, typename... _Args> constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value; template <typename _Tp> constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value; template <typename _Tp> constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value; template <typename _Tp> constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value; template <typename _Tp, typename _Up> constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Up>::value; template <typename _Tp> constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value; template <typename _Tp> constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value; template <typename _Tp> constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value; template <typename _Tp, typename... _Args> constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value; template <typename _Tp> constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value; template <typename _Tp> constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value; template <typename _Tp> constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value; template <typename _Tp, typename _Up> constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Up>::value; template <typename _Tp> constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value; template <typename _Tp> constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value; template <typename _Tp> constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value; template <typename _Tp> constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value; // See C++14 20.10.5, type property queries template <typename _Tp> constexpr size_t alignment_of_v = alignment_of<_Tp>::value; template <typename _Tp> constexpr size_t rank_v = rank<_Tp>::value; template <typename _Tp, unsigned _Idx = 0> constexpr size_t extent_v = extent<_Tp, _Idx>::value; // See C++14 20.10.6, type relations template <typename _Tp, typename _Up> constexpr bool is_same_v = is_same<_Tp, _Up>::value; template <typename _Base, typename _Derived> constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; template <typename _From, typename _To> constexpr bool is_convertible_v = is_convertible<_From, _To>::value; /// @} // 3.3.2, Other type transformations // invocation_type (still unimplemented) // raw_invocation_type (still unimplemented) // invocation_type_t (still unimplemented) // raw_invocation_type_t (still unimplemented) } // namespace fundamentals_v1 inline namespace fundamentals_v2 { /** * @defgroup lfts_detect Detection idiom * @ingroup libfund-ts * @since Library Fundamentals TS v2. C++14. */ /** @ingroup lfts_detect * @{ */ #define __cpp_lib_experimental_detect 201505 // [meta.detect] /// A metafunction that always yields void, used for detecting valid types. template<typename...> using void_t = void; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" /// @internal struct __nonesuchbase {}; struct nonesuch : private __nonesuchbase { ~nonesuch() = delete; nonesuch(nonesuch const&) = delete; void operator=(nonesuch const&) = delete; }; #pragma GCC diagnostic pop template<template<typename...> class _Op, typename... _Args> using is_detected = typename std::__detector<nonesuch, void, _Op, _Args...>::value_t; template<template<typename...> class _Op, typename... _Args> constexpr bool is_detected_v = is_detected<_Op, _Args...>::value; template<template<typename...> class _Op, typename... _Args> using detected_t = typename std::__detector<nonesuch, void, _Op, _Args...>::type; template<typename _Default, template<typename...> class _Op, typename... _Args> using detected_or = std::__detected_or<_Default, _Op, _Args...>; template<typename _Default, template<typename...> class _Op, typename... _Args> using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type; template<typename _Expected, template<typename...> class _Op, typename... _Args> using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>; template<typename _Expected, template<typename...> class _Op, typename... _Args> constexpr bool is_detected_exact_v = is_detected_exact<_Expected, _Op, _Args...>::value; template<typename _To, template<typename...> class _Op, typename... _Args> using is_detected_convertible = is_convertible<detected_t<_Op, _Args...>, _To>; template<typename _To, template<typename...> class _Op, typename... _Args> constexpr bool is_detected_convertible_v = is_detected_convertible<_To, _Op, _Args...>::value; /// @} /** * @defgroup lfts_logical Logical operator traits * @ingroup libfund-ts * @since Library Fundamentals TS v2. C++14. */ /** @ingroup lfts_logical * @{ */ #define __cpp_lib_experimental_logical_traits 201511 template<typename... _Bn> struct conjunction : __and_<_Bn...> { }; template<typename... _Bn> struct disjunction : __or_<_Bn...> { }; template<typename _Pp> struct negation : __not_<_Pp> { }; template<typename... _Bn> constexpr bool conjunction_v = conjunction<_Bn...>::value; template<typename... _Bn> constexpr bool disjunction_v = disjunction<_Bn...>::value; template<typename _Pp> constexpr bool negation_v = negation<_Pp>::value; /// @} } // namespace fundamentals_v2 } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // __cplusplus <= 201103L #endif // _GLIBCXX_EXPERIMENTAL_TYPE_TRAITS // <experimental/iterator> -*- C++ -*- // Copyright (C) 2015-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/iterator * This is a TS C++ Library header. * @ingroup libfund-ts */ // // N4336 Working Draft, C++ Extensions for Library Fundamentals, Version 2 // #ifndef _GLIBCXX_EXPERIMENTAL_ITERATOR #define _GLIBCXX_EXPERIMENTAL_ITERATOR 1 #pragma GCC system_header #if __cplusplus >= 201402L #include <iterator> #include <iosfwd> #include <experimental/type_traits> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { inline namespace fundamentals_v2 { #define __cpp_lib_experimental_ostream_joiner 201411 /// Output iterator that inserts a delimiter between elements. template<typename _DelimT, typename _CharT = char, typename _Traits = char_traits<_CharT>> class ostream_joiner { public: typedef _CharT char_type; typedef _Traits traits_type; typedef basic_ostream<_CharT, _Traits> ostream_type; typedef output_iterator_tag iterator_category; typedef void value_type; typedef void difference_type; typedef void pointer; typedef void reference; ostream_joiner(ostream_type& __os, const _DelimT& __delimiter) noexcept(is_nothrow_copy_constructible_v<_DelimT>) : _M_out(std::__addressof(__os)), _M_delim(__delimiter) { } ostream_joiner(ostream_type& __os, _DelimT&& __delimiter) noexcept(is_nothrow_move_constructible_v<_DelimT>) : _M_out(std::__addressof(__os)), _M_delim(std::move(__delimiter)) { } template<typename _Tp> ostream_joiner& operator=(const _Tp& __value) { if (!_M_first) *_M_out << _M_delim; _M_first = false; *_M_out << __value; return *this; } ostream_joiner& operator*() noexcept { return *this; } ostream_joiner& operator++() noexcept { return *this; } ostream_joiner& operator++(int) noexcept { return *this; } private: ostream_type* _M_out; _DelimT _M_delim; bool _M_first = true; }; /// Object generator for ostream_joiner. template<typename _CharT, typename _Traits, typename _DelimT> inline ostream_joiner<decay_t<_DelimT>, _CharT, _Traits> make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _DelimT&& __delimiter) { return { __os, std::forward<_DelimT>(__delimiter) }; } } // namespace fundamentals_v2 } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // __cplusplus <= 201103L #endif // _GLIBCXX_EXPERIMENTAL_ITERATOR // <experimental/timer> -*- C++ -*- // Copyright (C) 2015-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/timer * This is a TS C++ Library header. * @ingroup networking-ts */ #ifndef _GLIBCXX_EXPERIMENTAL_TIMER #define _GLIBCXX_EXPERIMENTAL_TIMER 1 #pragma GCC system_header #if __cplusplus >= 201402L #include <chrono> #include <system_error> #include <thread> #include <experimental/netfwd> #include <experimental/io_context> #include <experimental/bits/net.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { namespace net { inline namespace v1 { /** @addtogroup networking-ts * @{ */ template<typename _Clock> struct wait_traits { static typename _Clock::duration to_wait_duration(const typename _Clock::duration& __d) { return __d; } static typename _Clock::duration to_wait_duration(const typename _Clock::time_point& __t) { auto __now = _Clock::now(); auto __diff = __t - __now; if (__diff > _Clock::duration::max()) return _Clock::duration::max(); if (__diff < _Clock::duration::min()) return _Clock::duration::min(); return __diff; } }; template<typename _Clock, typename _WaitTraits> class basic_waitable_timer { public: // types: using executor_type = io_context::executor_type; using clock_type = _Clock; using duration = typename clock_type::duration; using time_point = typename clock_type::time_point; using traits_type = _WaitTraits; // construct / copy / destroy: explicit basic_waitable_timer(io_context& __ctx) : _M_ex(__ctx.get_executor()), _M_expiry() { } basic_waitable_timer(io_context& __ctx, const time_point& __t) : _M_ex(__ctx.get_executor()), _M_expiry(__t) { } basic_waitable_timer(io_context& __ctx, const duration& __d) : _M_ex(__ctx.get_executor()), _M_expiry(_Clock::now() + __d) { } basic_waitable_timer(const basic_waitable_timer&) = delete; basic_waitable_timer(basic_waitable_timer&& __rhs) : _M_ex(std::move(__rhs._M_ex)), _M_expiry(__rhs._M_expiry) { _M_key.swap(__rhs._M_key); __rhs._M_expiry = time_point{}; } ~basic_waitable_timer() { cancel(); } basic_waitable_timer& operator=(const basic_waitable_timer&) = delete; basic_waitable_timer& operator=(basic_waitable_timer&& __rhs) { if (this == std::addressof(__rhs)) return *this; cancel(); _M_ex = std::move(__rhs._M_ex); _M_expiry = __rhs._M_expiry; __rhs._M_expiry = time_point{}; _M_key.swap(__rhs._M_key); return *this; } // basic_waitable_timer operations: executor_type get_executor() noexcept { return _M_ex; } size_t cancel() { return _M_ex.context().cancel(*this); } size_t cancel_one() { return _M_ex.context().cancel_one(*this); } time_point expiry() const { return _M_expiry; } size_t expires_at(const time_point& __t) { size_t __cancelled = cancel(); _M_expiry = __t; return __cancelled; } size_t expires_after(const duration& __d) { return expires_at(_Clock::now() + __d); } void wait(); void wait(error_code& __ec); template<typename _CompletionToken> __deduced_t<_CompletionToken, void(error_code)> async_wait(_CompletionToken&& __token) { async_completion<_CompletionToken, void(error_code)> __init(__token); _M_ex.context().async_wait(*this, std::move(__init.completion_handler)); return __init.result.get(); } private: executor_type _M_ex; time_point _M_expiry; struct _Key { }; // TODO move _M_expiry into here? unique_ptr<_Key> _M_key{new _Key}; friend class io_context; }; using system_timer = basic_waitable_timer<chrono::system_clock>; using steady_timer = basic_waitable_timer<chrono::steady_clock>; using high_resolution_timer = basic_waitable_timer<chrono::high_resolution_clock>; template<typename _Clock, typename _WaitTraits> void basic_waitable_timer<_Clock, _WaitTraits>::wait() { _M_ex.dispatch([this] { while (clock_type::now() < _M_expiry) this_thread::sleep_for(traits_type::to_wait_duration(_M_expiry)); }, allocator<void>{}); } template<typename _Clock, typename _WaitTraits> void basic_waitable_timer<_Clock, _WaitTraits>::wait(error_code&) { _M_ex.dispatch([this] { while (clock_type::now() < _M_expiry) this_thread::sleep_for(traits_type::to_wait_duration(_M_expiry)); }, allocator<void>{}); } /// @} } // namespace v1 } // namespace net } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++14 #endif // _GLIBCXX_EXPERIMENTAL_TIMER // <experimental/set> -*- C++ -*- // Copyright (C) 2015-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/set * This is a TS C++ Library header. * @ingroup libfund-ts */ #ifndef _GLIBCXX_EXPERIMENTAL_SET #define _GLIBCXX_EXPERIMENTAL_SET 1 #pragma GCC system_header #if __cplusplus >= 201402L #include <set> #include <bits/erase_if.h> #include <experimental/memory_resource> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { inline namespace fundamentals_v2 { template<typename _Key, typename _Compare, typename _Alloc, typename _Predicate> inline void erase_if(set<_Key, _Compare, _Alloc>& __cont, _Predicate __pred) { std::__detail::__erase_nodes_if(__cont, __pred); } template<typename _Key, typename _Compare, typename _Alloc, typename _Predicate> inline void erase_if(multiset<_Key, _Compare, _Alloc>& __cont, _Predicate __pred) { std::__detail::__erase_nodes_if(__cont, __pred); } namespace pmr { template<typename _Key, typename _Compare = less<_Key>> using set = std::set<_Key, _Compare, polymorphic_allocator<_Key>>; template<typename _Key, typename _Compare = less<_Key>> using multiset = std::multiset<_Key, _Compare, polymorphic_allocator<_Key>>; } // namespace pmr } // namespace fundamentals_v2 } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++14 #endif // _GLIBCXX_EXPERIMENTAL_SET // <experimental/array> -*- C++ -*- // Copyright (C) 2015-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/array * This is a TS C++ Library header. * @ingroup libfund-ts */ #ifndef _GLIBCXX_EXPERIMENTAL_ARRAY #define _GLIBCXX_EXPERIMENTAL_ARRAY 1 #pragma GCC system_header #if __cplusplus >= 201402L #include <array> #include <experimental/type_traits> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { inline namespace fundamentals_v2 { #define __cpp_lib_experimental_make_array 201505 /** * @defgroup make_array Array creation functions * @ingroup libfund-ts * * Array creation functions as described in N4529, * Working Draft, C++ Extensions for Library Fundamentals, Version 2 * * @{ */ template<typename _Dest, typename... _Types> struct __make_array_elem { using type = _Dest; }; template<typename... _Types> struct __make_array_elem<void, _Types...> : common_type<_Types...> { template <typename> struct __is_reference_wrapper : false_type {}; template <typename _Up> struct __is_reference_wrapper<reference_wrapper<_Up>> : true_type {}; static_assert(!__or_<__is_reference_wrapper<decay_t<_Types>>...>::value, "make_array must be used with an explicit target type when" "any of the arguments is a reference_wrapper"); }; /// Create a std::array from a variable-length list of arguments. template <typename _Dest = void, typename... _Types> constexpr array<typename __make_array_elem<_Dest, _Types...>::type, sizeof...(_Types)> make_array(_Types&&... __t) { return {{ std::forward<_Types>(__t)... }}; } template <typename _Tp, size_t _Nm, size_t... _Idx> constexpr array<remove_cv_t<_Tp>, _Nm> __to_array(_Tp (&__a)[_Nm], index_sequence<_Idx...>) { return {{__a[_Idx]...}}; } /// Create a std::array from an array. template <typename _Tp, size_t _Nm> constexpr array<remove_cv_t<_Tp>, _Nm> to_array(_Tp (&__a)[_Nm]) noexcept(is_nothrow_constructible<remove_cv_t<_Tp>, _Tp&>::value) { return experimental::__to_array(__a, make_index_sequence<_Nm>{}); } /// @} group make_array } // namespace fundamentals_v2 } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++14 #endif // _GLIBCXX_EXPERIMENTAL_ARRAY // <experimental/optional> -*- C++ -*- // Copyright (C) 2013-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/optional * This is a TS C++ Library header. * @ingroup libfund-ts */ #ifndef _GLIBCXX_EXPERIMENTAL_OPTIONAL #define _GLIBCXX_EXPERIMENTAL_OPTIONAL 1 #if __cplusplus >= 201402L #include <utility> #include <type_traits> #include <stdexcept> #include <new> #include <initializer_list> #include <bits/functexcept.h> #include <bits/functional_hash.h> #include <bits/enable_special_members.h> #include <experimental/bits/lfts_config.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { inline namespace fundamentals_v1 { /** * @defgroup optional Optional values * @ingroup libfund-ts * * Class template for optional values and surrounding facilities, as * described in n3793 "A proposal to add a utility class to represent * optional objects (Revision 5)". * * @{ */ #define __cpp_lib_experimental_optional 201411 // All subsequent [X.Y.n] references are against n3793. // [X.Y.4] template<typename _Tp> class optional; // [X.Y.5] /// Tag type for in-place construction. struct in_place_t { }; /// Tag for in-place construction. constexpr in_place_t in_place { }; // [X.Y.6] /// Tag type to disengage optional objects. struct nullopt_t { // Do not user-declare default constructor at all for // optional_value = {} syntax to work. // nullopt_t() = delete; // Used for constructing nullopt. enum class _Construct { _Token }; // Must be constexpr for nullopt_t to be literal. explicit constexpr nullopt_t(_Construct) { } }; // [X.Y.6] /// Tag to disengage optional objects. constexpr nullopt_t nullopt { nullopt_t::_Construct::_Token }; // [X.Y.7] /** * @brief Exception class thrown when a disengaged optional object is * dereferenced. * @ingroup exceptions */ class bad_optional_access : public logic_error { public: bad_optional_access() : logic_error("bad optional access") { } // XXX This constructor is non-standard. Should not be inline explicit bad_optional_access(const char* __arg) : logic_error(__arg) { } virtual ~bad_optional_access() noexcept = default; }; /// @cond undocumented // XXX Does not belong here. [[noreturn]] inline void __throw_bad_optional_access(const char* __s) { _GLIBCXX_THROW_OR_ABORT(bad_optional_access(__s)); } /** * @brief Class template that holds the necessary state for @ref optional * and that has the responsibility for construction and the special members. * * Such a separate base class template is necessary in order to * conditionally enable the special members (e.g. copy/move constructors). * Note that this means that @ref _Optional_base implements the * functionality for copy and move assignment, but not for converting * assignment. * * @see optional, _Enable_special_members */ template<typename _Tp, bool _ShouldProvideDestructor = !is_trivially_destructible<_Tp>::value> class _Optional_base { private: // Remove const to avoid prohibition of reusing object storage for // const-qualified types in [3.8/9]. This is strictly internal // and even optional itself is oblivious to it. using _Stored_type = remove_const_t<_Tp>; public: // [X.Y.4.1] Constructors. // Constructors for disengaged optionals. constexpr _Optional_base() noexcept : _M_empty{} { } constexpr _Optional_base(nullopt_t) noexcept : _Optional_base{} { } // Constructors for engaged optionals. template<typename... _Args> constexpr explicit _Optional_base(in_place_t, _Args&&... __args) : _M_payload(std::forward<_Args>(__args)...), _M_engaged(true) { } template<typename _Up, typename... _Args, enable_if_t<is_constructible<_Tp, initializer_list<_Up>&, _Args&&...>::value, int>...> constexpr explicit _Optional_base(in_place_t, initializer_list<_Up> __il, _Args&&... __args) : _M_payload(__il, std::forward<_Args>(__args)...), _M_engaged(true) { } // Copy and move constructors. _Optional_base(const _Optional_base& __other) { if (__other._M_engaged) this->_M_construct(__other._M_get()); } _Optional_base(_Optional_base&& __other) noexcept(is_nothrow_move_constructible<_Tp>()) { if (__other._M_engaged) this->_M_construct(std::move(__other._M_get())); } // [X.Y.4.3] (partly) Assignment. _Optional_base& operator=(const _Optional_base& __other) { if (this->_M_engaged && __other._M_engaged) this->_M_get() = __other._M_get(); else { if (__other._M_engaged) this->_M_construct(__other._M_get()); else this->_M_reset(); } return *this; } _Optional_base& operator=(_Optional_base&& __other) noexcept(__and_<is_nothrow_move_constructible<_Tp>, is_nothrow_move_assignable<_Tp>>()) { if (this->_M_engaged && __other._M_engaged) this->_M_get() = std::move(__other._M_get()); else { if (__other._M_engaged) this->_M_construct(std::move(__other._M_get())); else this->_M_reset(); } return *this; } // [X.Y.4.2] Destructor. ~_Optional_base() { if (this->_M_engaged) this->_M_payload.~_Stored_type(); } // The following functionality is also needed by optional, hence the // protected accessibility. protected: constexpr bool _M_is_engaged() const noexcept { return this->_M_engaged; } // The _M_get operations have _M_engaged as a precondition. constexpr _Tp& _M_get() noexcept { return _M_payload; } constexpr const _Tp& _M_get() const noexcept { return _M_payload; } // The _M_construct operation has !_M_engaged as a precondition // while _M_destruct has _M_engaged as a precondition. template<typename... _Args> void _M_construct(_Args&&... __args) noexcept(is_nothrow_constructible<_Stored_type, _Args...>()) { ::new (std::__addressof(this->_M_payload)) _Stored_type(std::forward<_Args>(__args)...); this->_M_engaged = true; } void _M_destruct() { this->_M_engaged = false; this->_M_payload.~_Stored_type(); } // _M_reset is a 'safe' operation with no precondition. void _M_reset() { if (this->_M_engaged) this->_M_destruct(); } private: struct _Empty_byte { }; union { _Empty_byte _M_empty; _Stored_type _M_payload; }; bool _M_engaged = false; }; /// Partial specialization that is exactly identical to the primary template /// save for not providing a destructor, to fulfill triviality requirements. template<typename _Tp> class _Optional_base<_Tp, false> { private: using _Stored_type = remove_const_t<_Tp>; public: constexpr _Optional_base() noexcept : _M_empty{} { } constexpr _Optional_base(nullopt_t) noexcept : _Optional_base{} { } template<typename... _Args> constexpr explicit _Optional_base(in_place_t, _Args&&... __args) : _M_payload(std::forward<_Args>(__args)...), _M_engaged(true) { } template<typename _Up, typename... _Args, enable_if_t<is_constructible<_Tp, initializer_list<_Up>&, _Args&&...>::value, int>...> constexpr explicit _Optional_base(in_place_t, initializer_list<_Up> __il, _Args&&... __args) : _M_payload(__il, std::forward<_Args>(__args)...), _M_engaged(true) { } _Optional_base(const _Optional_base& __other) { if (__other._M_engaged) this->_M_construct(__other._M_get()); } _Optional_base(_Optional_base&& __other) noexcept(is_nothrow_move_constructible<_Tp>()) { if (__other._M_engaged) this->_M_construct(std::move(__other._M_get())); } _Optional_base& operator=(const _Optional_base& __other) { if (this->_M_engaged && __other._M_engaged) this->_M_get() = __other._M_get(); else { if (__other._M_engaged) this->_M_construct(__other._M_get()); else this->_M_reset(); } return *this; } _Optional_base& operator=(_Optional_base&& __other) noexcept(__and_<is_nothrow_move_constructible<_Tp>, is_nothrow_move_assignable<_Tp>>()) { if (this->_M_engaged && __other._M_engaged) this->_M_get() = std::move(__other._M_get()); else { if (__other._M_engaged) this->_M_construct(std::move(__other._M_get())); else this->_M_reset(); } return *this; } // Sole difference // ~_Optional_base() noexcept = default; protected: constexpr bool _M_is_engaged() const noexcept { return this->_M_engaged; } _Tp& _M_get() noexcept { return _M_payload; } constexpr const _Tp& _M_get() const noexcept { return _M_payload; } template<typename... _Args> void _M_construct(_Args&&... __args) noexcept(is_nothrow_constructible<_Stored_type, _Args...>()) { ::new (std::__addressof(this->_M_payload)) _Stored_type(std::forward<_Args>(__args)...); this->_M_engaged = true; } void _M_destruct() { this->_M_engaged = false; this->_M_payload.~_Stored_type(); } void _M_reset() { if (this->_M_engaged) this->_M_destruct(); } private: struct _Empty_byte { }; union { _Empty_byte _M_empty; _Stored_type _M_payload; }; bool _M_engaged = false; }; template<typename _Tp, typename _Up> using __converts_from_optional = __or_<is_constructible<_Tp, const optional<_Up>&>, is_constructible<_Tp, optional<_Up>&>, is_constructible<_Tp, const optional<_Up>&&>, is_constructible<_Tp, optional<_Up>&&>, is_convertible<const optional<_Up>&, _Tp>, is_convertible<optional<_Up>&, _Tp>, is_convertible<const optional<_Up>&&, _Tp>, is_convertible<optional<_Up>&&, _Tp>>; template<typename _Tp, typename _Up> using __assigns_from_optional = __or_<is_assignable<_Tp&, const optional<_Up>&>, is_assignable<_Tp&, optional<_Up>&>, is_assignable<_Tp&, const optional<_Up>&&>, is_assignable<_Tp&, optional<_Up>&&>>; /// @endcond /** * @brief Class template for optional values. */ template<typename _Tp> class optional : private _Optional_base<_Tp>, private _Enable_copy_move< // Copy constructor. is_copy_constructible<_Tp>::value, // Copy assignment. __and_<is_copy_constructible<_Tp>, is_copy_assignable<_Tp>>::value, // Move constructor. is_move_constructible<_Tp>::value, // Move assignment. __and_<is_move_constructible<_Tp>, is_move_assignable<_Tp>>::value, // Unique tag type. optional<_Tp>> { static_assert(__and_<__not_<is_same<remove_cv_t<_Tp>, nullopt_t>>, __not_<is_same<remove_cv_t<_Tp>, in_place_t>>, __not_<is_reference<_Tp>>>(), "Invalid instantiation of optional<T>"); private: using _Base = _Optional_base<_Tp>; public: using value_type = _Tp; // _Optional_base has the responsibility for construction. using _Base::_Base; constexpr optional() = default; // Converting constructors for engaged optionals. template <typename _Up = _Tp, enable_if_t<__and_< __not_<is_same<optional<_Tp>, decay_t<_Up>>>, is_constructible<_Tp, _Up&&>, is_convertible<_Up&&, _Tp> >::value, bool> = true> constexpr optional(_Up&& __t) : _Base(in_place, std::forward<_Up>(__t)) { } template <typename _Up = _Tp, enable_if_t<__and_< __not_<is_same<optional<_Tp>, decay_t<_Up>>>, is_constructible<_Tp, _Up&&>, __not_<is_convertible<_Up&&, _Tp>> >::value, bool> = false> explicit constexpr optional(_Up&& __t) : _Base(in_place, std::forward<_Up>(__t)) { } template <typename _Up, enable_if_t<__and_< __not_<is_same<_Tp, _Up>>, is_constructible<_Tp, const _Up&>, is_convertible<const _Up&, _Tp>, __not_<__converts_from_optional<_Tp, _Up>> >::value, bool> = true> constexpr optional(const optional<_Up>& __t) { if (__t) emplace(*__t); } template <typename _Up, enable_if_t<__and_< __not_<is_same<_Tp, _Up>>, is_constructible<_Tp, const _Up&>, __not_<is_convertible<const _Up&, _Tp>>, __not_<__converts_from_optional<_Tp, _Up>> >::value, bool> = false> explicit constexpr optional(const optional<_Up>& __t) { if (__t) emplace(*__t); } template <typename _Up, enable_if_t<__and_< __not_<is_same<_Tp, _Up>>, is_constructible<_Tp, _Up&&>, is_convertible<_Up&&, _Tp>, __not_<__converts_from_optional<_Tp, _Up>> >::value, bool> = true> constexpr optional(optional<_Up>&& __t) { if (__t) emplace(std::move(*__t)); } template <typename _Up, enable_if_t<__and_< __not_<is_same<_Tp, _Up>>, is_constructible<_Tp, _Up&&>, __not_<is_convertible<_Up&&, _Tp>>, __not_<__converts_from_optional<_Tp, _Up>> >::value, bool> = false> explicit constexpr optional(optional<_Up>&& __t) { if (__t) emplace(std::move(*__t)); } // [X.Y.4.3] (partly) Assignment. optional& operator=(nullopt_t) noexcept { this->_M_reset(); return *this; } template<typename _Up = _Tp> enable_if_t<__and_< __not_<is_same<optional<_Tp>, decay_t<_Up>>>, is_constructible<_Tp, _Up>, __not_<__and_<is_scalar<_Tp>, is_same<_Tp, decay_t<_Up>>>>, is_assignable<_Tp&, _Up>>::value, optional&> operator=(_Up&& __u) { if (this->_M_is_engaged()) this->_M_get() = std::forward<_Up>(__u); else this->_M_construct(std::forward<_Up>(__u)); return *this; } template<typename _Up> enable_if_t<__and_< __not_<is_same<_Tp, _Up>>, is_constructible<_Tp, const _Up&>, is_assignable<_Tp&, _Up>, __not_<__converts_from_optional<_Tp, _Up>>, __not_<__assigns_from_optional<_Tp, _Up>> >::value, optional&> operator=(const optional<_Up>& __u) { if (__u) { if (this->_M_is_engaged()) this->_M_get() = *__u; else this->_M_construct(*__u); } else { this->_M_reset(); } return *this; } template<typename _Up> enable_if_t<__and_< __not_<is_same<_Tp, _Up>>, is_constructible<_Tp, _Up>, is_assignable<_Tp&, _Up>, __not_<__converts_from_optional<_Tp, _Up>>, __not_<__assigns_from_optional<_Tp, _Up>> >::value, optional&> operator=(optional<_Up>&& __u) { if (__u) { if (this->_M_is_engaged()) this->_M_get() = std::move(*__u); else this->_M_construct(std::move(*__u)); } else { this->_M_reset(); } return *this; } template<typename... _Args> enable_if_t<is_constructible<_Tp, _Args&&...>::value> emplace(_Args&&... __args) { this->_M_reset(); this->_M_construct(std::forward<_Args>(__args)...); } template<typename _Up, typename... _Args> enable_if_t<is_constructible<_Tp, initializer_list<_Up>&, _Args&&...>::value> emplace(initializer_list<_Up> __il, _Args&&... __args) { this->_M_reset(); this->_M_construct(__il, std::forward<_Args>(__args)...); } // [X.Y.4.2] Destructor is implicit, implemented in _Optional_base. // [X.Y.4.4] Swap. void swap(optional& __other) noexcept(is_nothrow_move_constructible<_Tp>() && __is_nothrow_swappable<_Tp>::value) { using std::swap; if (this->_M_is_engaged() && __other._M_is_engaged()) swap(this->_M_get(), __other._M_get()); else if (this->_M_is_engaged()) { __other._M_construct(std::move(this->_M_get())); this->_M_destruct(); } else if (__other._M_is_engaged()) { this->_M_construct(std::move(__other._M_get())); __other._M_destruct(); } } // [X.Y.4.5] Observers. constexpr const _Tp* operator->() const { return std::__addressof(this->_M_get()); } _Tp* operator->() { return std::__addressof(this->_M_get()); } constexpr const _Tp& operator*() const& { return this->_M_get(); } constexpr _Tp& operator*()& { return this->_M_get(); } constexpr _Tp&& operator*()&& { return std::move(this->_M_get()); } constexpr const _Tp&& operator*() const&& { return std::move(this->_M_get()); } constexpr explicit operator bool() const noexcept { return this->_M_is_engaged(); } constexpr const _Tp& value() const& { if (this->_M_is_engaged()) return this->_M_get(); __throw_bad_optional_access("Attempt to access value of a " "disengaged optional object"); } constexpr _Tp& value()& { if (this->_M_is_engaged()) return this->_M_get(); __throw_bad_optional_access("Attempt to access value of a " "disengaged optional object"); } constexpr _Tp&& value()&& { if (this->_M_is_engaged()) return std::move(this->_M_get()); __throw_bad_optional_access("Attempt to access value of a " "disengaged optional object"); } constexpr const _Tp&& value() const&& { if (this->_M_is_engaged()) return std::move(this->_M_get()); __throw_bad_optional_access("Attempt to access value of a " "disengaged optional object"); } template<typename _Up> constexpr _Tp value_or(_Up&& __u) const& { static_assert(__and_<is_copy_constructible<_Tp>, is_convertible<_Up&&, _Tp>>(), "Cannot return value"); if (this->_M_is_engaged()) return this->_M_get(); else return static_cast<_Tp>(std::forward<_Up>(__u)); } template<typename _Up> _Tp value_or(_Up&& __u) && { static_assert(__and_<is_move_constructible<_Tp>, is_convertible<_Up&&, _Tp>>(), "Cannot return value" ); if (this->_M_is_engaged()) return std::move(this->_M_get()); else return static_cast<_Tp>(std::forward<_Up>(__u)); } }; /// @relates experimental::optional @{ // [X.Y.8] Comparisons between optional values. template<typename _Tp> constexpr bool operator==(const optional<_Tp>& __lhs, const optional<_Tp>& __rhs) { return static_cast<bool>(__lhs) == static_cast<bool>(__rhs) && (!__lhs || *__lhs == *__rhs); } template<typename _Tp> constexpr bool operator!=(const optional<_Tp>& __lhs, const optional<_Tp>& __rhs) { return !(__lhs == __rhs); } template<typename _Tp> constexpr bool operator<(const optional<_Tp>& __lhs, const optional<_Tp>& __rhs) { return static_cast<bool>(__rhs) && (!__lhs || *__lhs < *__rhs); } template<typename _Tp> constexpr bool operator>(const optional<_Tp>& __lhs, const optional<_Tp>& __rhs) { return __rhs < __lhs; } template<typename _Tp> constexpr bool operator<=(const optional<_Tp>& __lhs, const optional<_Tp>& __rhs) { return !(__rhs < __lhs); } template<typename _Tp> constexpr bool operator>=(const optional<_Tp>& __lhs, const optional<_Tp>& __rhs) { return !(__lhs < __rhs); } // [X.Y.9] Comparisons with nullopt. template<typename _Tp> constexpr bool operator==(const optional<_Tp>& __lhs, nullopt_t) noexcept { return !__lhs; } template<typename _Tp> constexpr bool operator==(nullopt_t, const optional<_Tp>& __rhs) noexcept { return !__rhs; } template<typename _Tp> constexpr bool operator!=(const optional<_Tp>& __lhs, nullopt_t) noexcept { return static_cast<bool>(__lhs); } template<typename _Tp> constexpr bool operator!=(nullopt_t, const optional<_Tp>& __rhs) noexcept { return static_cast<bool>(__rhs); } template<typename _Tp> constexpr bool operator<(const optional<_Tp>& /* __lhs */, nullopt_t) noexcept { return false; } template<typename _Tp> constexpr bool operator<(nullopt_t, const optional<_Tp>& __rhs) noexcept { return static_cast<bool>(__rhs); } template<typename _Tp> constexpr bool operator>(const optional<_Tp>& __lhs, nullopt_t) noexcept { return static_cast<bool>(__lhs); } template<typename _Tp> constexpr bool operator>(nullopt_t, const optional<_Tp>& /* __rhs */) noexcept { return false; } template<typename _Tp> constexpr bool operator<=(const optional<_Tp>& __lhs, nullopt_t) noexcept { return !__lhs; } template<typename _Tp> constexpr bool operator<=(nullopt_t, const optional<_Tp>& /* __rhs */) noexcept { return true; } template<typename _Tp> constexpr bool operator>=(const optional<_Tp>& /* __lhs */, nullopt_t) noexcept { return true; } template<typename _Tp> constexpr bool operator>=(nullopt_t, const optional<_Tp>& __rhs) noexcept { return !__rhs; } // [X.Y.10] Comparisons with value type. template<typename _Tp> constexpr bool operator==(const optional<_Tp>& __lhs, const _Tp& __rhs) { return __lhs && *__lhs == __rhs; } template<typename _Tp> constexpr bool operator==(const _Tp& __lhs, const optional<_Tp>& __rhs) { return __rhs && __lhs == *__rhs; } template<typename _Tp> constexpr bool operator!=(const optional<_Tp>& __lhs, _Tp const& __rhs) { return !__lhs || !(*__lhs == __rhs); } template<typename _Tp> constexpr bool operator!=(const _Tp& __lhs, const optional<_Tp>& __rhs) { return !__rhs || !(__lhs == *__rhs); } template<typename _Tp> constexpr bool operator<(const optional<_Tp>& __lhs, const _Tp& __rhs) { return !__lhs || *__lhs < __rhs; } template<typename _Tp> constexpr bool operator<(const _Tp& __lhs, const optional<_Tp>& __rhs) { return __rhs && __lhs < *__rhs; } template<typename _Tp> constexpr bool operator>(const optional<_Tp>& __lhs, const _Tp& __rhs) { return __lhs && __rhs < *__lhs; } template<typename _Tp> constexpr bool operator>(const _Tp& __lhs, const optional<_Tp>& __rhs) { return !__rhs || *__rhs < __lhs; } template<typename _Tp> constexpr bool operator<=(const optional<_Tp>& __lhs, const _Tp& __rhs) { return !__lhs || !(__rhs < *__lhs); } template<typename _Tp> constexpr bool operator<=(const _Tp& __lhs, const optional<_Tp>& __rhs) { return __rhs && !(*__rhs < __lhs); } template<typename _Tp> constexpr bool operator>=(const optional<_Tp>& __lhs, const _Tp& __rhs) { return __lhs && !(*__lhs < __rhs); } template<typename _Tp> constexpr bool operator>=(const _Tp& __lhs, const optional<_Tp>& __rhs) { return !__rhs || !(__lhs < *__rhs); } // [X.Y.11] template<typename _Tp> inline void swap(optional<_Tp>& __lhs, optional<_Tp>& __rhs) noexcept(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } template<typename _Tp> constexpr optional<decay_t<_Tp>> make_optional(_Tp&& __t) { return optional<decay_t<_Tp>> { std::forward<_Tp>(__t) }; } /// @} relates experimental::optional /// @} group optional } // namespace fundamentals_v1 } // namespace experimental // [X.Y.12] /// std::hash partial specialization for experimental::optional /// @relates experimental::optional template<typename _Tp> struct hash<experimental::optional<_Tp>> { using result_type = size_t; using argument_type = experimental::optional<_Tp>; size_t operator()(const experimental::optional<_Tp>& __t) const noexcept(noexcept(hash<_Tp> {}(*__t))) { // We pick an arbitrary hash for disengaged optionals which hopefully // usual values of _Tp won't typically hash to. constexpr size_t __magic_disengaged_hash = static_cast<size_t>(-3333); return __t ? hash<_Tp> {}(*__t) : __magic_disengaged_hash; } }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++14 #endif // _GLIBCXX_EXPERIMENTAL_OPTIONAL // <experimental/unordered_set> -*- C++ -*- // Copyright (C) 2015-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/unordered_set * This is a TS C++ Library header. * @ingroup libfund-ts */ #ifndef _GLIBCXX_EXPERIMENTAL_UNORDERED_SET #define _GLIBCXX_EXPERIMENTAL_UNORDERED_SET 1 #pragma GCC system_header #if __cplusplus >= 201402L #include <unordered_set> #include <bits/erase_if.h> #include <experimental/memory_resource> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { inline namespace fundamentals_v2 { template<typename _Key, typename _Hash, typename _CPred, typename _Alloc, typename _Predicate> inline void erase_if(unordered_set<_Key, _Hash, _CPred, _Alloc>& __cont, _Predicate __pred) { std::__detail::__erase_nodes_if(__cont, __pred); } template<typename _Key, typename _Hash, typename _CPred, typename _Alloc, typename _Predicate> inline void erase_if(unordered_multiset<_Key, _Hash, _CPred, _Alloc>& __cont, _Predicate __pred) { std::__detail::__erase_nodes_if(__cont, __pred); } namespace pmr { template<typename _Key, typename _Hash = hash<_Key>, typename _Pred = equal_to<_Key>> using unordered_set = std::unordered_set<_Key, _Hash, _Pred, polymorphic_allocator<_Key>>; template<typename _Key, typename _Hash = hash<_Key>, typename _Pred = equal_to<_Key>> using unordered_multiset = std::unordered_multiset<_Key, _Hash, _Pred, polymorphic_allocator<_Key>>; } // namespace pmr } // namespace fundamentals_v2 } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++14 #endif // _GLIBCXX_EXPERIMENTAL_UNORDERED_SET // <experimental/internet> -*- C++ -*- // Copyright (C) 2015-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/internet * This is a TS C++ Library header. * @ingroup networking-ts */ #ifndef _GLIBCXX_EXPERIMENTAL_INTERNET #define _GLIBCXX_EXPERIMENTAL_INTERNET #pragma GCC system_header #if __cplusplus >= 201402L #include <experimental/netfwd> #include <experimental/io_context> #include <experimental/bits/net.h> #include <array> #include <forward_list> #include <sstream> #include <cstdint> #include <experimental/string_view> #ifdef _GLIBCXX_HAVE_UNISTD_H # include <unistd.h> #endif #ifdef _GLIBCXX_HAVE_SYS_SOCKET_H # include <sys/socket.h> // AF_INET, AF_INET6, SOCK_DGRAM, SOCK_STREAM #endif #ifdef _GLIBCXX_HAVE_ARPA_INET_H # include <arpa/inet.h> // inet_ntop #endif #ifdef _GLIBCXX_HAVE_NETINET_IN_H # include <netinet/in.h> // IPPROTO_IP, IPPROTO_IPV6, in_addr, in6_addr #endif #ifdef _GLIBCXX_HAVE_NETINET_TCP_H # include <netinet/tcp.h> // TCP_NODELAY #endif #ifdef _GLIBCXX_HAVE_NETDB_H # include <netdb.h> // getaddrinfo etc. #endif #if defined _WIN32 && __has_include(<ws2tcpip.h>) # include <ws2tcpip.h> #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { namespace net { inline namespace v1 { namespace ip { /** @addtogroup networking-ts * @{ */ /** Error codes for resolver errors. * @{ */ enum class resolver_errc : int { #ifdef _GLIBCXX_HAVE_NETDB_H host_not_found = EAI_NONAME, host_not_found_try_again = EAI_AGAIN, service_not_found = EAI_SERVICE #endif }; /// Error category for resolver errors. inline const error_category& resolver_category() noexcept // TODO non-inline { struct __cat : error_category { const char* name() const noexcept { return "resolver"; } std::string message(int __e) const { #ifdef _GLIBCXX_HAVE_NETDB_H return ::gai_strerror(__e); #else return "name resolution requires <netdb.h>"; #endif } virtual void __message(int) { } // TODO dual ABI XXX }; static __cat __c; return __c; } inline error_code make_error_code(resolver_errc __e) noexcept { return error_code(static_cast<int>(__e), resolver_category()); } inline error_condition make_error_condition(resolver_errc __e) noexcept { return error_condition(static_cast<int>(__e), resolver_category()); } /// @} using port_type = uint_least16_t; ///< Type used for port numbers. using scope_id_type = uint_least32_t; ///< Type used for IPv6 scope IDs. /// Convenience alias for constraining allocators for strings. template<typename _Alloc> using __string_with = enable_if_t<std::is_same<typename _Alloc::value_type, char>::value, std::basic_string<char, std::char_traits<char>, _Alloc>>; constexpr errc __unsupported_err() noexcept { #if defined EAFNOSUPPORT return std::errc::address_family_not_supported; #else return std::errc::operation_not_supported; #endif } /** Tag indicating conversion between IPv4 and IPv4-mapped IPv6 addresses. * @{ */ struct v4_mapped_t {}; constexpr v4_mapped_t v4_mapped; /// @} /// An IPv4 address. class address_v4 { public: // types: using uint_type = uint_least32_t; struct bytes_type : array<unsigned char, 4> { template<typename... _Tp> explicit constexpr bytes_type(_Tp... __tp) : array<unsigned char, 4>{{static_cast<unsigned char>(__tp)...}} { #if UCHAR_MAX > 0xFF for (auto __b : *this) if (__b > 0xFF) __throw_out_of_range("invalid address_v4::bytes_type value"); #endif } }; // constructors: constexpr address_v4() noexcept : _M_addr(0) { } constexpr address_v4(const address_v4& a) noexcept = default; constexpr address_v4(const bytes_type& __b) : _M_addr((__b[0] << 24) | (__b[1] << 16) | (__b[2] << 8) | __b[3]) { } explicit constexpr address_v4(uint_type __val) : _M_addr(_S_hton_32(__val)) { #if UINT_LEAST32_MAX > 0xFFFFFFFF if (__val > 0xFFFFFFFF) __throw_out_of_range("invalid address_v4::uint_type value"); #endif } // assignment: address_v4& operator=(const address_v4& a) noexcept = default; // members: constexpr bool is_unspecified() const noexcept { return to_uint() == 0; } constexpr bool is_loopback() const noexcept { return (to_uint() & 0xFF000000) == 0x7F000000; } constexpr bool is_multicast() const noexcept { return (to_uint() & 0xF0000000) == 0xE0000000; } constexpr bytes_type to_bytes() const noexcept { return bytes_type{ (_M_addr >> 24) & 0xFF, (_M_addr >> 16) & 0xFF, (_M_addr >> 8) & 0xFF, _M_addr & 0xFF }; } constexpr uint_type to_uint() const noexcept { return _S_ntoh_32(_M_addr); } template<typename _Allocator = allocator<char>> __string_with<_Allocator> to_string(const _Allocator& __a = _Allocator()) const { #ifdef _GLIBCXX_HAVE_ARPA_INET_H __string_with<_Allocator> __str(__a); __str.resize(INET_ADDRSTRLEN); if (inet_ntop(AF_INET, &_M_addr, &__str.front(), __str.size())) __str.erase(__str.find('\0')); else __str.resize(0); return __str; #else std::__throw_system_error((int)__unsupported_err()); #endif } // static members: static constexpr address_v4 any() noexcept { return address_v4{}; } static constexpr address_v4 loopback() noexcept { return address_v4{0x7F000001}; } static constexpr address_v4 broadcast() noexcept { return address_v4{0xFFFFFFFF}; } private: template<typename _InternetProtocol> friend class basic_endpoint; friend address_v4 make_address_v4(const char*, error_code&) noexcept; #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ static constexpr uint16_t _S_hton_16(uint16_t __h) { return __h; } static constexpr uint16_t _S_ntoh_16(uint16_t __n) { return __n; } static constexpr uint32_t _S_hton_32(uint32_t __h) { return __h; } static constexpr uint32_t _S_ntoh_32(uint32_t __n) { return __n; } #else static constexpr uint16_t _S_hton_16(uint16_t __h) { return __builtin_bswap16(__h); } static constexpr uint16_t _S_ntoh_16(uint16_t __n) { return __builtin_bswap16(__n); } static constexpr uint32_t _S_hton_32(uint32_t __h) { return __builtin_bswap32(__h); } static constexpr uint32_t _S_ntoh_32(uint32_t __n) { return __builtin_bswap32(__n); } #endif #ifdef _GLIBCXX_HAVE_ARPA_INET_H in_addr_t _M_addr; // network byte order #else uint32_t _M_addr; #endif }; /// An IPv6 address. class address_v6 { public: // types: struct bytes_type : array<unsigned char, 16> { template<typename... _Tp> explicit constexpr bytes_type(_Tp... __t) : array<unsigned char, 16>{{static_cast<unsigned char>(__t)...}} { } }; // constructors: constexpr address_v6() noexcept : _M_bytes(), _M_scope_id() { } constexpr address_v6(const address_v6& __a) noexcept = default; constexpr address_v6(const bytes_type& __bytes, scope_id_type __scope = 0) : _M_bytes(__bytes), _M_scope_id(__scope) { } // assignment: address_v6& operator=(const address_v6& __a) noexcept = default; // members: void scope_id(scope_id_type __id) noexcept { _M_scope_id = __id; } constexpr scope_id_type scope_id() const noexcept { return _M_scope_id; } constexpr bool is_unspecified() const noexcept { for (int __i = 0; __i < 16; ++__i) if (_M_bytes[__i] != 0x00) return false; return _M_scope_id == 0; } constexpr bool is_loopback() const noexcept { for (int __i = 0; __i < 15; ++__i) if (_M_bytes[__i] != 0x00) return false; return _M_bytes[15] == 0x01 && _M_scope_id == 0; } constexpr bool is_multicast() const noexcept { return _M_bytes[0] == 0xFF; } constexpr bool is_link_local() const noexcept { return _M_bytes[0] == 0xFE && (_M_bytes[1] & 0xC0) == 0x80; } constexpr bool is_site_local() const noexcept { return _M_bytes[0] == 0xFE && (_M_bytes[1] & 0xC0) == 0xC0; } constexpr bool is_v4_mapped() const noexcept { const bytes_type& __b = _M_bytes; return __b[0] == 0 && __b[1] == 0 && __b[ 2] == 0 && __b[ 3] == 0 && __b[4] == 0 && __b[5] == 0 && __b[ 6] == 0 && __b[ 7] == 0 && __b[8] == 0 && __b[9] == 0 && __b[10] == 0xFF && __b[11] == 0xFF; } constexpr bool is_multicast_node_local() const noexcept { return is_multicast() && (_M_bytes[1] & 0x0F) == 0x01; } constexpr bool is_multicast_link_local() const noexcept { return is_multicast() && (_M_bytes[1] & 0x0F) == 0x02; } constexpr bool is_multicast_site_local() const noexcept { return is_multicast() && (_M_bytes[1] & 0x0F) == 0x05; } constexpr bool is_multicast_org_local() const noexcept { return is_multicast() && (_M_bytes[1] & 0x0F) == 0x08; } constexpr bool is_multicast_global() const noexcept { return is_multicast() && (_M_bytes[1] & 0x0F) == 0x0b; } constexpr bytes_type to_bytes() const noexcept { return _M_bytes; } template<typename _Allocator = allocator<char>> __string_with<_Allocator> to_string(const _Allocator& __a = _Allocator()) const { #ifdef _GLIBCXX_HAVE_ARPA_INET_H __string_with<_Allocator> __str(__a); __str.resize(INET6_ADDRSTRLEN + (_M_scope_id ? 11 : 0)); char* const __p = &__str.front(); if (inet_ntop(AF_INET6, &_M_bytes, __p, __str.size())) { auto __end = __str.find('\0'); if (unsigned long __scope = _M_scope_id) { __end += #if _GLIBCXX_USE_C99_STDIO __builtin_snprintf(__p + __end, __str.size() - __end, "%%%lu", __scope); #else __builtin_sprintf(__p + __end, "%%%lu", __scope); #endif } __str.erase(__end); } else __str.resize(0); return __str; #else std::__throw_system_error((int)__unsupported_err()); #endif } // static members: static constexpr address_v6 any() noexcept { return {}; } static constexpr address_v6 loopback() noexcept { return {bytes_type{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}}; } private: template<typename _InternetProtocol> friend class basic_endpoint; friend constexpr bool operator==(const address_v6&, const address_v6&) noexcept; friend constexpr bool operator< (const address_v6&, const address_v6&) noexcept; bytes_type _M_bytes; scope_id_type _M_scope_id; }; /// Exception type thrown on misuse of IPv4 addresses as IPv6 or vice versa. class bad_address_cast : public bad_cast { public: bad_address_cast() { } const char* what() const noexcept { return "bad address cast"; } }; /// An IPv4 or IPv6 address. class address { public: // constructors: constexpr address() noexcept : _M_v4(), _M_is_v4(true) { } #if __cpp_constexpr_dynamic_alloc constexpr #endif address(const address& __a) noexcept : _M_uninit(), _M_is_v4(__a._M_is_v4) { if (_M_is_v4) std::_Construct(std::addressof(_M_v4), __a.to_v4()); else std::_Construct(std::addressof(_M_v6), __a.to_v6()); } constexpr address(const address_v4& __a) noexcept : _M_v4(__a), _M_is_v4(true) { } constexpr address(const address_v6& __a) noexcept : _M_v6(__a), _M_is_v4(false) { } // assignment: address& operator=(const address& __a) noexcept { if (__a._M_is_v4) *this = __a.to_v4(); else *this = __a.to_v6(); return *this; } address& operator=(const address_v4& __a) noexcept { std::_Construct(std::addressof(_M_v4), __a); _M_is_v4 = true; return *this; } address& operator=(const address_v6& __a) noexcept { std::_Construct(std::addressof(_M_v6), __a); _M_is_v4 = false; return *this; } // members: constexpr bool is_v4() const noexcept { return _M_is_v4; } constexpr bool is_v6() const noexcept { return !_M_is_v4; } constexpr address_v4 to_v4() const { if (!is_v4()) _GLIBCXX_THROW_OR_ABORT(bad_address_cast()); return _M_v4; } constexpr address_v6 to_v6() const { if (!is_v6()) _GLIBCXX_THROW_OR_ABORT(bad_address_cast()); return _M_v6; } constexpr bool is_unspecified() const noexcept { return _M_is_v4 ? _M_v4.is_unspecified() : _M_v6.is_unspecified(); } constexpr bool is_loopback() const noexcept { return _M_is_v4 ? _M_v4.is_loopback() : _M_v6.is_loopback(); } constexpr bool is_multicast() const noexcept { return _M_is_v4 ? _M_v4.is_multicast() : _M_v6.is_multicast(); } template<typename _Allocator = allocator<char>> __string_with<_Allocator> to_string(const _Allocator& __a = _Allocator()) const { if (_M_is_v4) return to_v4().to_string(__a); return to_v6().to_string(__a); } private: template<typename _InternetProtocol> friend class basic_endpoint; friend constexpr bool operator==(const address&, const address&) noexcept; friend constexpr bool operator<(const address&, const address&) noexcept; union { address_v4 _M_v4; address_v6 _M_v6; bool _M_uninit; }; bool _M_is_v4; }; /** ip::address_v4 comparisons * @{ */ constexpr bool operator==(const address_v4& __a, const address_v4& __b) noexcept { return __a.to_uint() == __b.to_uint(); } constexpr bool operator!=(const address_v4& __a, const address_v4& __b) noexcept { return !(__a == __b); } constexpr bool operator< (const address_v4& __a, const address_v4& __b) noexcept { return __a.to_uint() < __b.to_uint(); } constexpr bool operator> (const address_v4& __a, const address_v4& __b) noexcept { return __b < __a; } constexpr bool operator<=(const address_v4& __a, const address_v4& __b) noexcept { return !(__b < __a); } constexpr bool operator>=(const address_v4& __a, const address_v4& __b) noexcept { return !(__a < __b); } /// @} /** ip::address_v6 comparisons * @{ */ constexpr bool operator==(const address_v6& __a, const address_v6& __b) noexcept { const auto& __aa = __a._M_bytes; const auto& __bb = __b._M_bytes; int __i = 0; for (; __i < 16 && __aa[__i] == __bb[__i]; ++__i) ; return __i == 16 ? __a.scope_id() == __b.scope_id() : false; } constexpr bool operator!=(const address_v6& __a, const address_v6& __b) noexcept { return !(__a == __b); } constexpr bool operator< (const address_v6& __a, const address_v6& __b) noexcept { const auto& __aa = __a._M_bytes; const auto& __bb = __b._M_bytes; int __i = 0; for (; __i < 16 && __aa[__i] == __bb[__i]; ++__i) ; return __i == 16 ? __a.scope_id() < __b.scope_id() : __aa[__i] < __bb[__i]; } constexpr bool operator> (const address_v6& __a, const address_v6& __b) noexcept { return __b < __a; } constexpr bool operator<=(const address_v6& __a, const address_v6& __b) noexcept { return !(__b < __a); } constexpr bool operator>=(const address_v6& __a, const address_v6& __b) noexcept { return !(__a < __b); } /// @} /** ip::address comparisons * @{ */ constexpr bool operator==(const address& __a, const address& __b) noexcept { if (__a.is_v4()) return __b.is_v4() ? __a._M_v4 == __b._M_v4 : false; return __b.is_v4() ? false : __a._M_v6 == __b._M_v6; } constexpr bool operator!=(const address& __a, const address& __b) noexcept { return !(__a == __b); } constexpr bool operator< (const address& __a, const address& __b) noexcept { if (__a.is_v4()) return __b.is_v4() ? __a._M_v4 < __b._M_v4 : true; return __b.is_v4() ? false : __a._M_v6 < __b._M_v6; } constexpr bool operator> (const address& __a, const address& __b) noexcept { return __b < __a; } constexpr bool operator<=(const address& __a, const address& __b) noexcept { return !(__b < __a); } constexpr bool operator>=(const address& __a, const address& __b) noexcept { return !(__a < __b); } /// @} /** ip::address_v4 creation * @{ */ constexpr address_v4 make_address_v4(const address_v4::bytes_type& __b) { return address_v4{__b}; } constexpr address_v4 make_address_v4(address_v4::uint_type __val) { return address_v4{__val}; } constexpr address_v4 make_address_v4(v4_mapped_t, const address_v6& __a) { if (!__a.is_v4_mapped()) _GLIBCXX_THROW_OR_ABORT(bad_address_cast()); const auto __v6b = __a.to_bytes(); return address_v4::bytes_type(__v6b[12], __v6b[13], __v6b[14], __v6b[15]); } inline address_v4 make_address_v4(const char* __str, error_code& __ec) noexcept { #ifdef _GLIBCXX_HAVE_ARPA_INET_H address_v4 __a; const int __res = ::inet_pton(AF_INET, __str, &__a._M_addr); if (__res == 1) { __ec.clear(); return __a; } if (__res == 0) __ec = std::make_error_code(std::errc::invalid_argument); else __ec.assign(errno, generic_category()); #else __ec = std::make_error_code(__unsupported_err()); #endif return {}; } inline address_v4 make_address_v4(const char* __str) { return make_address_v4(__str, __throw_on_error{"make_address_v4"}); } inline address_v4 make_address_v4(const string& __str, error_code& __ec) noexcept { return make_address_v4(__str.c_str(), __ec); } inline address_v4 make_address_v4(const string& __str) { return make_address_v4(__str.c_str()); } inline address_v4 make_address_v4(string_view __str, error_code& __ec) noexcept { char __buf[16]; // INET_ADDRSTRLEN isn't defined on Windows auto __len = __str.copy(__buf, sizeof(__buf)); if (__len == sizeof(__buf)) { __ec = std::make_error_code(std::errc::invalid_argument); return {}; } __ec.clear(); __buf[__len] = '\0'; return make_address_v4(__buf, __ec); } inline address_v4 make_address_v4(string_view __str) { return make_address_v4(__str, __throw_on_error{"make_address_v4"}); } /// @} /** ip::address_v6 creation * @{ */ constexpr address_v6 make_address_v6(const address_v6::bytes_type& __b, scope_id_type __scope = 0) { return address_v6{__b, __scope}; } constexpr address_v6 make_address_v6(v4_mapped_t, const address_v4& __a) noexcept { const address_v4::bytes_type __v4b = __a.to_bytes(); address_v6::bytes_type __v6b(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, __v4b[0], __v4b[1], __v4b[2], __v4b[3]); return address_v6(__v6b); } inline address_v6 __make_address_v6(const char* __addr, const char* __scope, error_code& __ec) { #ifdef _GLIBCXX_HAVE_ARPA_INET_H address_v6::bytes_type __b; const int __res = ::inet_pton(AF_INET6, __addr, __b.data()); if (__res == 1) { __ec.clear(); if (!__scope) { return { __b }; } char* __eptr; unsigned long __val = std::strtoul(__scope, &__eptr, 10); if (__eptr != __scope && !*__eptr && __val <= numeric_limits<scope_id_type>::max()) { return { __b, static_cast<scope_id_type>(__val) }; } __ec = std::make_error_code(std::errc::invalid_argument); } else if (__res == 0) __ec = std::make_error_code(std::errc::invalid_argument); else __ec.assign(errno, generic_category()); #else __ec = std::make_error_code(__unsupported_err()); #endif return {}; } inline address_v6 make_address_v6(const char* __str, error_code& __ec) noexcept { auto __p = __builtin_strchr(__str, '%'); if (__p == nullptr) return __make_address_v6(__str, nullptr, __ec); char __buf[64]; char* __out = __buf; bool __skip_leading_zero = true; while (__str < __p && __out < std::end(__buf)) { if (!__skip_leading_zero || *__str != '0') { if (*__str == ':' || *__str == '.') __skip_leading_zero = true; else __skip_leading_zero = false; *__out = *__str; } __str++; } if (__out == std::end(__buf)) { __ec = std::make_error_code(std::errc::invalid_argument); return {}; } else { *__out = '\0'; return __make_address_v6(__buf, __p + 1, __ec); } } inline address_v6 make_address_v6(const char* __str) { return make_address_v6(__str, __throw_on_error{"make_address_v6"}); } inline address_v6 make_address_v6(const string& __str, error_code& __ec) noexcept { auto __pos = __str.find('%'); if (__pos == string::npos) return __make_address_v6(__str.c_str(), nullptr, __ec); char __buf[64]; char* __out = __buf; bool __skip_leading_zero = true; size_t __n = 0; while (__n < __pos && __out < std::end(__buf)) { if (!__skip_leading_zero || __str[__n] != '0') { if (__str[__n] == ':' || __str[__n] == '.') __skip_leading_zero = true; else __skip_leading_zero = false; *__out = __str[__n]; } __n++; } if (__out == std::end(__buf)) { __ec = std::make_error_code(std::errc::invalid_argument); return {}; } else { *__out = '\0'; return __make_address_v6(__buf, __str.c_str() + __pos + 1, __ec); } } inline address_v6 make_address_v6(const string& __str) { return make_address_v6(__str, __throw_on_error{"make_address_v6"}); } inline address_v6 make_address_v6(string_view __str, error_code& __ec) noexcept { char __buf[64]; char* __out = __buf; char* __scope = nullptr; bool __skip_leading_zero = true; size_t __n = 0; while (__n < __str.length() && __out < std::end(__buf)) { if (__str[__n] == '%') { if (__scope) __out = std::end(__buf); else { *__out = '\0'; __scope = ++__out; __skip_leading_zero = true; } } else if (!__skip_leading_zero || __str[__n] != '0') { if (__str[__n] == ':' || __str[__n] == '.') __skip_leading_zero = true; else __skip_leading_zero = false; *__out = __str[__n]; __out++; } __n++; } if (__out == std::end(__buf)) { __ec = std::make_error_code(std::errc::invalid_argument); return {}; } else { *__out = '\0'; return __make_address_v6(__buf, __scope, __ec); } } inline address_v6 make_address_v6(string_view __str) { return make_address_v6(__str, __throw_on_error{"make_address_v6"}); } /// @} /** ip::address creation * @{ */ inline address make_address(const char* __str, error_code& __ec) noexcept { address __a; address_v6 __v6a = make_address_v6(__str, __ec); if (!__ec) __a = __v6a; else { address_v4 __v4a = make_address_v4(__str, __ec); if (!__ec) __a = __v4a; } return __a; } inline address make_address(const char* __str) { return make_address(__str, __throw_on_error{"make_address"}); } inline address make_address(const string& __str, error_code& __ec) noexcept; // TODO inline address make_address(const string& __str) { return make_address(__str, __throw_on_error{"make_address"}); } inline address make_address(string_view __str, error_code& __ec) noexcept { if (__str.rfind('\0') != string_view::npos) return make_address(__str.data(), __ec); return make_address(__str.to_string(), __ec); // TODO don't allocate } inline address make_address(string_view __str) { return make_address(__str, __throw_on_error{"make_address"}); } /// @} /// ip::address I/O template<typename _CharT, typename _Traits> inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const address& __a) { return __os << __a.to_string(); } /// ip::address_v4 I/O template<typename _CharT, typename _Traits> inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const address_v4& __a) { return __os << __a.to_string(); } /// ip::address_v6 I/O template<typename _CharT, typename _Traits> inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const address_v6& __a) { return __os << __a.to_string(); } template<typename> class basic_address_iterator; // not defined template<> class basic_address_iterator<address_v4> { public: // types: using value_type = address_v4; using difference_type = ptrdiff_t; using pointer = const address_v4*; using reference = const address_v4&; using iterator_category = input_iterator_tag; // constructors: basic_address_iterator(const address_v4& __a) noexcept : _M_address(__a) { } // members: reference operator*() const noexcept { return _M_address; } pointer operator->() const noexcept { return &_M_address; } basic_address_iterator& operator++() noexcept { _M_address = value_type(_M_address.to_uint() + 1); return *this; } basic_address_iterator operator++(int) noexcept { auto __tmp = *this; ++*this; return __tmp; } basic_address_iterator& operator--() noexcept { _M_address = value_type(_M_address.to_uint() - 1); return *this; } basic_address_iterator operator--(int) noexcept { auto __tmp = *this; --*this; return __tmp; } bool operator==(const basic_address_iterator& __rhs) const noexcept { return _M_address == __rhs._M_address; } bool operator!=(const basic_address_iterator& __rhs) const noexcept { return _M_address != __rhs._M_address; } private: address_v4 _M_address; }; using address_v4_iterator = basic_address_iterator<address_v4>; template<> class basic_address_iterator<address_v6> { public: // types: using value_type = address_v6; using difference_type = ptrdiff_t; using pointer = const address_v6*; using reference = const address_v6&; using iterator_category = input_iterator_tag; // constructors: basic_address_iterator(const address_v6& __a) noexcept : _M_address(__a) { } // members: reference operator*() const noexcept { return _M_address; } pointer operator->() const noexcept { return &_M_address; } basic_address_iterator& operator++() noexcept; // TODO basic_address_iterator operator++(int) noexcept { auto __tmp = *this; ++*this; return __tmp; } basic_address_iterator& operator--() noexcept; // TODO basic_address_iterator operator--(int) noexcept { auto __tmp = *this; --*this; return __tmp; } bool operator==(const basic_address_iterator& __rhs) const noexcept { return _M_address == __rhs._M_address; } bool operator!=(const basic_address_iterator& __rhs) const noexcept { return _M_address != __rhs._M_address; } private: address_v6 _M_address; }; using address_v6_iterator = basic_address_iterator<address_v6>; template<typename> class basic_address_range; // not defined /** An IPv6 address range. * @{ */ template<> class basic_address_range<address_v4> { public: // types: using iterator = basic_address_iterator<address_v4>; // constructors: basic_address_range() noexcept : _M_begin({}), _M_end({}) { } basic_address_range(const address_v4& __first, const address_v4& __last) noexcept : _M_begin(__first), _M_end(__last) { } // members: iterator begin() const noexcept { return _M_begin; } iterator end() const noexcept { return _M_end; } _GLIBCXX_NODISCARD bool empty() const noexcept { return _M_begin == _M_end; } size_t size() const noexcept { return _M_end->to_uint() - _M_begin->to_uint(); } iterator find(const address_v4& __addr) const noexcept { if (*_M_begin <= __addr && __addr < *_M_end) return iterator{__addr}; return end(); } private: iterator _M_begin; iterator _M_end; }; using address_v4_range = basic_address_range<address_v4>; /// @} /** An IPv6 address range. * @{ */ template<> class basic_address_range<address_v6> { public: // types: using iterator = basic_address_iterator<address_v6>; // constructors: basic_address_range() noexcept : _M_begin({}), _M_end({}) { } basic_address_range(const address_v6& __first, const address_v6& __last) noexcept : _M_begin(__first), _M_end(__last) { } // members: iterator begin() const noexcept { return _M_begin; } iterator end() const noexcept { return _M_end; } _GLIBCXX_NODISCARD bool empty() const noexcept { return _M_begin == _M_end; } iterator find(const address_v6& __addr) const noexcept { if (*_M_begin <= __addr && __addr < *_M_end) return iterator{__addr}; return end(); } private: iterator _M_begin; iterator _M_end; }; using address_v6_range = basic_address_range<address_v6>; /// @} bool operator==(const network_v4& __a, const network_v4& __b) noexcept; bool operator==(const network_v6& __a, const network_v6& __b) noexcept; /// An IPv4 network address. class network_v4 { public: // constructors: constexpr network_v4() noexcept : _M_addr(), _M_prefix_len(0) { } constexpr network_v4(const address_v4& __addr, int __prefix_len) : _M_addr(__addr), _M_prefix_len(__prefix_len) { if (_M_prefix_len < 0 || _M_prefix_len > 32) __throw_out_of_range("network_v4: invalid prefix length"); } constexpr network_v4(const address_v4& __addr, const address_v4& __mask) : _M_addr(__addr), _M_prefix_len(__builtin_popcount(__mask.to_uint())) { if (_M_prefix_len != 0) { address_v4::uint_type __mask_uint = __mask.to_uint(); if (__builtin_ctz(__mask_uint) != (32 - _M_prefix_len)) __throw_invalid_argument("network_v4: invalid mask"); if ((__mask_uint & 0x80000000) == 0) __throw_invalid_argument("network_v4: invalid mask"); } } // members: constexpr address_v4 address() const noexcept { return _M_addr; } constexpr int prefix_length() const noexcept { return _M_prefix_len; } constexpr address_v4 netmask() const noexcept { address_v4::uint_type __val = address_v4::broadcast().to_uint(); __val >>= (32 - _M_prefix_len); __val <<= (32 - _M_prefix_len); return address_v4{__val}; } constexpr address_v4 network() const noexcept { return address_v4{_M_addr.to_uint() & netmask().to_uint()}; } constexpr address_v4 broadcast() const noexcept { return address_v4{_M_addr.to_uint() | ~netmask().to_uint()}; } address_v4_range hosts() const noexcept { if (is_host()) return { address(), *++address_v4_iterator(address()) }; return { network(), broadcast() }; } constexpr network_v4 canonical() const noexcept { return network_v4(network(), prefix_length()); } constexpr bool is_host() const noexcept { return _M_prefix_len == 32; } constexpr bool is_subnet_of(const network_v4& __other) const noexcept { if (__other.prefix_length() < prefix_length()) { network_v4 __net(address(), __other.prefix_length()); return __net.canonical() == __other.canonical(); } return false; } template<typename _Allocator = allocator<char>> __string_with<_Allocator> to_string(const _Allocator& __a = _Allocator()) const { return address().to_string(__a) + '/' + std::to_string(prefix_length()); } private: address_v4 _M_addr; int _M_prefix_len; }; /// An IPv6 network address. class network_v6 { public: // constructors: constexpr network_v6() noexcept : _M_addr(), _M_prefix_len(0) { } constexpr network_v6(const address_v6& __addr, int __prefix_len) : _M_addr(__addr), _M_prefix_len(__prefix_len) { if (_M_prefix_len < 0 || _M_prefix_len > 128) __throw_out_of_range("network_v6: invalid prefix length"); } // members: constexpr address_v6 address() const noexcept { return _M_addr; } constexpr int prefix_length() const noexcept { return _M_prefix_len; } constexpr address_v6 network() const noexcept; // TODO address_v6_range hosts() const noexcept { if (is_host()) return { address(), *++address_v6_iterator(address()) }; return {}; // { network(), XXX broadcast() XXX }; // TODO } constexpr network_v6 canonical() const noexcept { return network_v6{network(), prefix_length()}; } constexpr bool is_host() const noexcept { return _M_prefix_len == 128; } constexpr bool is_subnet_of(const network_v6& __other) const noexcept { if (__other.prefix_length() < prefix_length()) { network_v6 __net(address(), __other.prefix_length()); return __net.canonical() == __other.canonical(); } return false; } template<typename _Allocator = allocator<char>> __string_with<_Allocator> to_string(const _Allocator& __a = _Allocator()) const { return address().to_string(__a) + '/' + std::to_string(prefix_length()); } private: address_v6 _M_addr; int _M_prefix_len; }; /** ip::network_v4 comparisons * @{ */ inline bool operator==(const network_v4& __a, const network_v4& __b) noexcept { return __a.address() == __b.address() && __a.prefix_length() == __b.prefix_length(); } inline bool operator!=(const network_v4& __a, const network_v4& __b) noexcept { return !(__a == __b); } /// @} /** ip::network_v6 comparisons * @{ */ inline bool operator==(const network_v6& __a, const network_v6& __b) noexcept { return __a.address() == __b.address() && __a.prefix_length() == __b.prefix_length(); } inline bool operator!=(const network_v6& __a, const network_v6& __b) noexcept { return !(__a == __b); } /// @} /** ip::network_v4 creation * @{ */ inline network_v4 make_network_v4(const address_v4& __a, int __prefix_len) { return network_v4{__a, __prefix_len}; } inline network_v4 make_network_v4(const address_v4& __a, const address_v4& __mask) { return network_v4{ __a, __mask }; } network_v4 make_network_v4(const char*, error_code&) noexcept; // TODO inline network_v4 make_network_v4(const char* __str) { return make_network_v4(__str, __throw_on_error{"make_network_v4"}); } network_v4 make_network_v4(const string&, error_code&) noexcept; // TODO inline network_v4 make_network_v4(const string& __str) { return make_network_v4(__str, __throw_on_error{"make_network_v4"}); } network_v4 make_network_v4(string_view, error_code&) noexcept; // TODO inline network_v4 make_network_v4(string_view __str) { return make_network_v4(__str, __throw_on_error{"make_network_v4"}); } /// @} /** ip::network_v6 creation * @{ */ inline network_v6 make_network_v6(const address_v6& __a, int __prefix_len) { return network_v6{__a, __prefix_len}; } network_v6 make_network_v6(const char*, error_code&) noexcept; // TODO inline network_v6 make_network_v6(const char* __str) { return make_network_v6(__str, __throw_on_error{"make_network_v6"}); } network_v6 make_network_v6(const string&, error_code&) noexcept; // TODO inline network_v6 make_network_v6(const string& __str) { return make_network_v6(__str, __throw_on_error{"make_network_v6"}); } network_v6 make_network_v6(string_view, error_code&) noexcept; // TODO inline network_v6 make_network_v6(string_view __str) { return make_network_v6(__str, __throw_on_error{"make_network_v6"}); } /// @} /// ip::network_v4 I/O template<typename _CharT, typename _Traits> inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const network_v4& __net) { return __os << __net.to_string(); } /// ip::network_v6 I/O template<typename _CharT, typename _Traits> inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const network_v6& __net) { return __os << __net.to_string(); } /// An IP endpoint. template<typename _InternetProtocol> class basic_endpoint { public: // types: using protocol_type = _InternetProtocol; // constructors: constexpr basic_endpoint() noexcept : _M_data() { _M_data._M_v4.sin_family = protocol_type::v4().family(); } constexpr basic_endpoint(const protocol_type& __proto, port_type __port_num) noexcept : _M_data() { __glibcxx_assert(__proto == protocol_type::v4() || __proto == protocol_type::v6()); _M_data._M_v4.sin_family = __proto.family(); _M_data._M_v4.sin_port = address_v4::_S_hton_16(__port_num); } constexpr basic_endpoint(const ip::address& __addr, port_type __port_num) noexcept : _M_data() { if (__addr.is_v4()) { _M_data._M_v4.sin_family = protocol_type::v4().family(); _M_data._M_v4.sin_port = address_v4::_S_hton_16(__port_num); _M_data._M_v4.sin_addr.s_addr = __addr._M_v4._M_addr; } else { _M_data._M_v6 = {}; _M_data._M_v6.sin6_family = protocol_type::v6().family(); _M_data._M_v6.sin6_port = address_v4::_S_hton_16(__port_num); __builtin_memcpy(_M_data._M_v6.sin6_addr.s6_addr, __addr._M_v6._M_bytes.data(), 16); _M_data._M_v6.sin6_scope_id = __addr._M_v6._M_scope_id; } } // members: constexpr protocol_type protocol() const noexcept { return _M_is_v6() ? protocol_type::v6() : protocol_type::v4(); } constexpr ip::address address() const noexcept { ip::address __addr; if (_M_is_v6()) { __builtin_memcpy(&__addr._M_v6._M_bytes, _M_data._M_v6.sin6_addr.s6_addr, 16); __addr._M_is_v4 = false; } else { __builtin_memcpy(&__addr._M_v4._M_addr, &_M_data._M_v4.sin_addr.s_addr, 4); } return __addr; } void address(const ip::address& __addr) noexcept { if (__addr.is_v6()) { _M_data._M_v6 = {}; _M_data._M_v6.sin6_family = protocol_type::v6().family(); __builtin_memcpy(_M_data._M_v6.sin6_addr.s6_addr, __addr._M_v6._M_bytes.data(), 16); _M_data._M_v6.sin6_scope_id = __addr._M_v6._M_scope_id; } else { _M_data._M_v4.sin_family = protocol_type::v4().family(); _M_data._M_v4.sin_addr.s_addr = __addr._M_v4._M_addr; } } constexpr port_type port() const noexcept { return address_v4::_S_ntoh_16(_M_data._M_v4.sin_port); } void port(port_type __port_num) noexcept { _M_data._M_v4.sin_port = address_v4::_S_hton_16(__port_num); } void* data() noexcept { return &_M_data; } const void* data() const noexcept { return &_M_data; } constexpr size_t size() const noexcept { return _M_is_v6() ? sizeof(sockaddr_in6) : sizeof(sockaddr_in); } void resize(size_t __s) { if (__s != size()) __throw_length_error("net::ip::basic_endpoint::resize"); } constexpr size_t capacity() const noexcept { return sizeof(_M_data); } private: union { sockaddr_in _M_v4; sockaddr_in6 _M_v6; } _M_data; constexpr bool _M_is_v6() const noexcept { return _M_data._M_v4.sin_family == AF_INET6; } }; /** basic_endpoint comparisons * @{ */ template<typename _InternetProtocol> inline bool operator==(const basic_endpoint<_InternetProtocol>& __a, const basic_endpoint<_InternetProtocol>& __b) { return __a.address() == __b.address() && __a.port() == __b.port(); } template<typename _InternetProtocol> inline bool operator!=(const basic_endpoint<_InternetProtocol>& __a, const basic_endpoint<_InternetProtocol>& __b) { return !(__a == __b); } template<typename _InternetProtocol> inline bool operator< (const basic_endpoint<_InternetProtocol>& __a, const basic_endpoint<_InternetProtocol>& __b) { return __a.address() < __b.address() || (!(__b.address() < __a.address()) && __a.port() < __b.port()); } template<typename _InternetProtocol> inline bool operator> (const basic_endpoint<_InternetProtocol>& __a, const basic_endpoint<_InternetProtocol>& __b) { return __b < __a; } template<typename _InternetProtocol> inline bool operator<=(const basic_endpoint<_InternetProtocol>& __a, const basic_endpoint<_InternetProtocol>& __b) { return !(__b < __a); } template<typename _InternetProtocol> inline bool operator>=(const basic_endpoint<_InternetProtocol>& __a, const basic_endpoint<_InternetProtocol>& __b) { return !(__a < __b); } /// @} /// basic_endpoint I/O template<typename _CharT, typename _Traits, typename _InternetProtocol> inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const basic_endpoint<_InternetProtocol>& __ep) { basic_ostringstream<_CharT, _Traits> __ss; if (__ep.protocol() == basic_endpoint<_InternetProtocol>::protocol_type::v6()) __ss << '[' << __ep.address() << ']'; else __ss << __ep.address(); __ss << ':' << __ep.port(); __os << __ss.str(); return __os; } /** Type representing a single result of name/address resolution. * @{ */ template<typename _InternetProtocol> class basic_resolver_entry { public: // types: using protocol_type = _InternetProtocol; using endpoint_type = typename _InternetProtocol::endpoint; // constructors: basic_resolver_entry() { } basic_resolver_entry(const endpoint_type& __ep, string_view __h, string_view __s) : _M_ep(__ep), _M_host(__h), _M_svc(__s) { } // members: endpoint_type endpoint() const { return _M_ep; } operator endpoint_type() const { return _M_ep; } template<typename _Allocator = allocator<char>> __string_with<_Allocator> host_name(const _Allocator& __a = _Allocator()) const { return { _M_host, __a }; } template<typename _Allocator = allocator<char>> __string_with<_Allocator> service_name(const _Allocator& __a = _Allocator()) const { return { _M_svc, __a }; } private: basic_endpoint<_InternetProtocol> _M_ep; string _M_host; string _M_svc; }; template<typename _InternetProtocol> inline bool operator==(const basic_resolver_entry<_InternetProtocol>& __a, const basic_resolver_entry<_InternetProtocol>& __b) { return __a.endpoint() == __b.endpoint() && __a.host_name() == __b.host_name() && __a.service_name() == __b.service_name(); } template<typename _InternetProtocol> inline bool operator!=(const basic_resolver_entry<_InternetProtocol>& __a, const basic_resolver_entry<_InternetProtocol>& __b) { return !(__a == __b); } /// @} /** Base class defining flags for name/address resolution. * @{ */ class resolver_base { public: enum flags : int { }; static constexpr flags passive = (flags)AI_PASSIVE; static constexpr flags canonical_name = (flags)AI_CANONNAME; static constexpr flags numeric_host = (flags)AI_NUMERICHOST; #ifdef AI_NUMERICSERV static constexpr flags numeric_service = (flags)AI_NUMERICSERV; #endif #ifdef AI_V4MAPPED static constexpr flags v4_mapped = (flags)AI_V4MAPPED; #endif #ifdef AI_ALL static constexpr flags all_matching = (flags)AI_ALL; #endif #ifdef AI_ADDRCONFIG static constexpr flags address_configured = (flags)AI_ADDRCONFIG; #endif friend constexpr flags operator&(flags __f1, flags __f2) noexcept { return flags( int(__f1) & int(__f2) ); } friend constexpr flags operator|(flags __f1, flags __f2) noexcept { return flags( int(__f1) | int(__f2) ); } friend constexpr flags operator^(flags __f1, flags __f2) noexcept { return flags( int(__f1) ^ int(__f2) ); } friend constexpr flags operator~(flags __f) noexcept { return flags( ~int(__f) ); } friend constexpr flags& operator&=(flags& __f1, flags __f2) noexcept { return __f1 = (__f1 & __f2); } friend constexpr flags& operator|=(flags& __f1, flags __f2) noexcept { return __f1 = (__f1 | __f2); } friend constexpr flags& operator^=(flags& __f1, flags __f2) noexcept { return __f1 = (__f1 ^ __f2); } protected: resolver_base() = default; ~resolver_base() = default; }; // TODO define resolver_base::flags static constants in .so for C++14 mode /// @} /** Container for results of name/address resolution. * @{ */ template<typename _InternetProtocol> class basic_resolver_results { public: // types: using protocol_type = _InternetProtocol; using endpoint_type = typename protocol_type::endpoint; using value_type = basic_resolver_entry<protocol_type>; using const_reference = const value_type&; using reference = value_type&; using const_iterator = typename forward_list<value_type>::const_iterator; using iterator = const_iterator; using difference_type = ptrdiff_t; using size_type = size_t; // construct / copy / destroy: basic_resolver_results() = default; basic_resolver_results(const basic_resolver_results&) = default; basic_resolver_results(basic_resolver_results&&) noexcept = default; basic_resolver_results& operator=(const basic_resolver_results&) = default; basic_resolver_results& operator=(basic_resolver_results&&) = default; ~basic_resolver_results() = default; // size: size_type size() const noexcept { return _M_size; } size_type max_size() const noexcept { return _M_results.max_size(); } _GLIBCXX_NODISCARD bool empty() const noexcept { return _M_results.empty(); } // element access: const_iterator begin() const { return _M_results.begin(); } const_iterator end() const { return _M_results.end(); } const_iterator cbegin() const { return _M_results.begin(); } const_iterator cend() const { return _M_results.end(); } // swap: void swap(basic_resolver_results& __that) noexcept { _M_results.swap(__that._M_results); } private: friend class basic_resolver<protocol_type>; basic_resolver_results(string_view, string_view, resolver_base::flags, error_code&, protocol_type* = nullptr); basic_resolver_results(const endpoint_type&, error_code&); forward_list<value_type> _M_results; size_t _M_size = 0; }; template<typename _InternetProtocol> inline bool operator==(const basic_resolver_results<_InternetProtocol>& __a, const basic_resolver_results<_InternetProtocol>& __b) { return __a.size() == __b.size() && std::equal(__a.begin(), __a.end(), __b.begin()); } template<typename _InternetProtocol> inline bool operator!=(const basic_resolver_results<_InternetProtocol>& __a, const basic_resolver_results<_InternetProtocol>& __b) { return !(__a == __b); } /// @} /// Perform name/address resolution. template<typename _InternetProtocol> class basic_resolver : public resolver_base { public: // types: using executor_type = io_context::executor_type; using protocol_type = _InternetProtocol; using endpoint_type = typename _InternetProtocol::endpoint; using results_type = basic_resolver_results<_InternetProtocol>; // construct / copy / destroy: explicit basic_resolver(io_context& __ctx) : _M_ctx(&__ctx) { } basic_resolver(const basic_resolver&) = delete; basic_resolver(basic_resolver&& __rhs) noexcept : _M_ctx(__rhs._M_ctx) { } // TODO move state/tasks etc. ~basic_resolver() { cancel(); } basic_resolver& operator=(const basic_resolver&) = delete; basic_resolver& operator=(basic_resolver&& __rhs) { cancel(); _M_ctx = __rhs._M_ctx; // TODO move state/tasks etc. return *this; } // basic_resolver operations: executor_type get_executor() noexcept { return _M_ctx->get_executor(); } void cancel() { } // TODO results_type resolve(string_view __host_name, string_view __service_name) { return resolve(__host_name, __service_name, resolver_base::flags(), __throw_on_error{"basic_resolver::resolve"}); } results_type resolve(string_view __host_name, string_view __service_name, error_code& __ec) { return resolve(__host_name, __service_name, resolver_base::flags(), __ec); } results_type resolve(string_view __host_name, string_view __service_name, flags __f) { return resolve(__host_name, __service_name, __f, __throw_on_error{"basic_resolver::resolve"}); } results_type resolve(string_view __host_name, string_view __service_name, flags __f, error_code& __ec) { return {__host_name, __service_name, __f, __ec}; } template<typename _CompletionToken> __deduced_t<_CompletionToken, void(error_code, results_type)> async_resolve(string_view __host_name, string_view __service_name, _CompletionToken&& __token) { return async_resolve(__host_name, __service_name, resolver_base::flags(), forward<_CompletionToken>(__token)); } template<typename _CompletionToken> __deduced_t<_CompletionToken, void(error_code, results_type)> async_resolve(string_view __host_name, string_view __service_name, flags __f, _CompletionToken&& __token); // TODO results_type resolve(const protocol_type& __protocol, string_view __host_name, string_view __service_name) { return resolve(__protocol, __host_name, __service_name, resolver_base::flags(), __throw_on_error{"basic_resolver::resolve"}); } results_type resolve(const protocol_type& __protocol, string_view __host_name, string_view __service_name, error_code& __ec) { return resolve(__protocol, __host_name, __service_name, resolver_base::flags(), __ec); } results_type resolve(const protocol_type& __protocol, string_view __host_name, string_view __service_name, flags __f) { return resolve(__protocol, __host_name, __service_name, __f, __throw_on_error{"basic_resolver::resolve"}); } results_type resolve(const protocol_type& __protocol, string_view __host_name, string_view __service_name, flags __f, error_code& __ec) { return {__host_name, __service_name, __f, __ec, &__protocol}; } template<typename _CompletionToken> __deduced_t<_CompletionToken, void(error_code, results_type)> async_resolve(const protocol_type& __protocol, string_view __host_name, string_view __service_name, _CompletionToken&& __token) { return async_resolve(__protocol, __host_name, __service_name, resolver_base::flags(), forward<_CompletionToken>(__token)); } template<typename _CompletionToken> __deduced_t<_CompletionToken, void(error_code, results_type)> async_resolve(const protocol_type& __protocol, string_view __host_name, string_view __service_name, flags __f, _CompletionToken&& __token); // TODO results_type resolve(const endpoint_type& __ep) { return resolve(__ep, __throw_on_error{"basic_resolver::resolve"}); } results_type resolve(const endpoint_type& __ep, error_code& __ec) { return { __ep, __ec }; } template<typename _CompletionToken> // TODO __deduced_t<_CompletionToken, void(error_code, results_type)> async_resolve(const endpoint_type& __ep, _CompletionToken&& __token); private: io_context* _M_ctx; }; /// Private constructor to synchronously resolve host and service names. template<typename _InternetProtocol> basic_resolver_results<_InternetProtocol>:: basic_resolver_results(string_view __host_name, string_view __service_name, resolver_base::flags __f, error_code& __ec, protocol_type* __protocol) { #ifdef _GLIBCXX_HAVE_NETDB_H string __host; const char* __h = __host_name.data() ? (__host = __host_name.to_string()).c_str() : nullptr; string __svc; const char* __s = __service_name.data() ? (__svc = __service_name.to_string()).c_str() : nullptr; ::addrinfo __hints{ }; __hints.ai_flags = static_cast<int>(__f); if (__protocol) { __hints.ai_family = __protocol->family(); __hints.ai_socktype = __protocol->type(); __hints.ai_protocol = __protocol->protocol(); } else { auto __p = endpoint_type{}.protocol(); __hints.ai_family = AF_UNSPEC; __hints.ai_socktype = __p.type(); __hints.ai_protocol = __p.protocol(); } struct __scoped_addrinfo { ~__scoped_addrinfo() { if (_M_p) ::freeaddrinfo(_M_p); } ::addrinfo* _M_p = nullptr; } __sai; if (int __err = ::getaddrinfo(__h, __s, &__hints, &__sai._M_p)) { __ec.assign(__err, resolver_category()); return; } __ec.clear(); endpoint_type __ep; auto __tail = _M_results.before_begin(); for (auto __ai = __sai._M_p; __ai != nullptr; __ai = __ai->ai_next) { if (__ai->ai_family == AF_INET || __ai->ai_family == AF_INET6) { if (__ai->ai_addrlen <= __ep.capacity()) __builtin_memcpy(__ep.data(), __ai->ai_addr, __ai->ai_addrlen); __ep.resize(__ai->ai_addrlen); __tail = _M_results.emplace_after(__tail, __ep, __host, __svc); _M_size++; } } #else __ec = std::make_error_code(errc::operation_not_supported); #endif } /// Private constructor to synchronously resolve an endpoint. template<typename _InternetProtocol> basic_resolver_results<_InternetProtocol>:: basic_resolver_results(const endpoint_type& __ep, error_code& __ec) { #ifdef _GLIBCXX_HAVE_NETDB_H char __host_name[256]; char __service_name[128]; int __flags = 0; if (__ep.protocol().type() == SOCK_DGRAM) __flags |= NI_DGRAM; auto __sa = static_cast<const sockaddr*>(__ep.data()); int __err = ::getnameinfo(__sa, __ep.size(), __host_name, sizeof(__host_name), __service_name, sizeof(__service_name), __flags); if (__err) { __flags |= NI_NUMERICSERV; __err = ::getnameinfo(__sa, __ep.size(), __host_name, sizeof(__host_name), __service_name, sizeof(__service_name), __flags); } if (__err) __ec.assign(__err, resolver_category()); else { __ec.clear(); _M_results.emplace_front(__ep, __host_name, __service_name); _M_size = 1; } #else __ec = std::make_error_code(errc::operation_not_supported); #endif } /** The name of the local host. * @{ */ template<typename _Allocator> __string_with<_Allocator> host_name(const _Allocator& __a, error_code& __ec) { #ifdef HOST_NAME_MAX constexpr size_t __maxlen = HOST_NAME_MAX; #else constexpr size_t __maxlen = 256; #endif char __buf[__maxlen + 1]; if (::gethostname(__buf, __maxlen) == -1) __ec.assign(errno, generic_category()); __buf[__maxlen] = '\0'; return { __buf, __a }; } template<typename _Allocator> inline __string_with<_Allocator> host_name(const _Allocator& __a) { return host_name(__a, __throw_on_error{"host_name"}); } inline string host_name(error_code& __ec) { return host_name(std::allocator<char>{}, __ec); } inline string host_name() { return host_name(std::allocator<char>{}, __throw_on_error{"host_name"}); } /// @} #ifdef IPPROTO_TCP /// The TCP byte-stream protocol. class tcp { public: // types: using endpoint = basic_endpoint<tcp>; ///< A TCP endpoint. using resolver = basic_resolver<tcp>; ///< A TCP resolver. using socket = basic_stream_socket<tcp>; ///< A TCP socket. using acceptor = basic_socket_acceptor<tcp>; ///< A TCP acceptor. using iostream = basic_socket_iostream<tcp>; /// A TCP iostream. #ifdef TCP_NODELAY /// Disable coalescing of small segments (i.e. the Nagle algorithm). struct no_delay : __sockopt_crtp<no_delay, bool> { using __sockopt_crtp::__sockopt_crtp; using __sockopt_crtp::operator=; static const int _S_level = IPPROTO_TCP; static const int _S_name = TCP_NODELAY; }; #endif // static members: /// A protocol object representing IPv4 TCP. static constexpr tcp v4() noexcept { return tcp(AF_INET); } /// A protocol object representing IPv6 TCP. static constexpr tcp v6() noexcept { return tcp(AF_INET6); } tcp() = delete; constexpr int family() const noexcept { return _M_family; } constexpr int type() const noexcept { return SOCK_STREAM; } constexpr int protocol() const noexcept { return IPPROTO_TCP; } private: constexpr explicit tcp(int __family) : _M_family(__family) { } int _M_family; }; /** tcp comparisons * @{ */ constexpr bool operator==(const tcp& __a, const tcp& __b) noexcept { return __a.family() == __b.family(); } constexpr bool operator!=(const tcp& __a, const tcp& __b) noexcept { return !(__a == __b); } /// @} #endif // IPPROTO_TCP #ifdef IPPROTO_UDP /// The UDP datagram protocol. class udp { public: // types: using endpoint = basic_endpoint<udp>; using resolver = basic_resolver<udp>; using socket = basic_datagram_socket<udp>; // static members: static constexpr udp v4() noexcept { return udp(AF_INET); } static constexpr udp v6() noexcept { return udp(AF_INET6); } udp() = delete; constexpr int family() const noexcept { return _M_family; } constexpr int type() const noexcept { return SOCK_DGRAM; } constexpr int protocol() const noexcept { return IPPROTO_UDP; } private: constexpr explicit udp(int __family) : _M_family(__family) { } int _M_family; }; /** udp comparisons * @{ */ constexpr bool operator==(const udp& __a, const udp& __b) noexcept { return __a.family() == __b.family(); } constexpr bool operator!=(const udp& __a, const udp& __b) noexcept { return !(__a == __b); } /// @} #endif // IPPROTO_UDP #if defined IPPROTO_IP && defined IPPROTO_IPV6 /// Restrict a socket created for an IPv6 protocol to IPv6 only. class v6_only : public __sockopt_crtp<v6_only, bool> { public: using __sockopt_crtp::__sockopt_crtp; using __sockopt_crtp::operator=; private: friend __sockopt_crtp<v6_only, bool>; static const int _S_level = IPPROTO_IPV6; static const int _S_name = IPV6_V6ONLY; }; namespace unicast { /// Set the default number of hops (TTL) for outbound datagrams. class hops : public __sockopt_crtp<hops> { public: using __sockopt_crtp::__sockopt_crtp; using __sockopt_crtp::operator=; template<typename _Protocol> int level(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? IPPROTO_IPV6 : IPPROTO_IP; } template<typename _Protocol> int name(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? IPV6_UNICAST_HOPS : IP_TTL; } }; } // namespace unicast namespace multicast { class __mcastopt { public: explicit __mcastopt(const address& __grp) noexcept : __mcastopt(__grp.is_v4() ? __mcastopt(__grp.to_v4()) : __mcastopt(__grp.to_v6())) { } explicit __mcastopt(const address_v4& __grp, const address_v4& __iface = address_v4::any()) noexcept { #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ _M_v4.imr_multiaddr.s_addr = __grp.to_uint(); _M_v4.imr_interface.s_addr = __iface.to_uint(); #else _M_v4.imr_multiaddr.s_addr = __builtin_bswap32(__grp.to_uint()); _M_v4.imr_interface.s_addr = __builtin_bswap32(__iface.to_uint()); #endif } explicit __mcastopt(const address_v6& __grp, unsigned int __iface = 0) noexcept { const auto __addr = __grp.to_bytes(); __builtin_memcpy(_M_v6.ipv6mr_multiaddr.s6_addr, __addr.data(), 16); _M_v6.ipv6mr_interface = __iface; } template<typename _Protocol> int level(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? IPPROTO_IPV6 : IPPROTO_IP; } template<typename _Protocol> const void* data(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? &_M_v6 : &_M_v4; } template<typename _Protocol> size_t size(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? sizeof(_M_v6) : sizeof(_M_v4); } private: ipv6_mreq _M_v6 = {}; ip_mreq _M_v4 = {}; }; /// Request that a socket joins a multicast group. class join_group : private __mcastopt { public: using __mcastopt::__mcastopt; using __mcastopt::level; using __mcastopt::data; using __mcastopt::size; template<typename _Protocol> int name(const _Protocol& __p) const noexcept { if (__p.family() == AF_INET6) return IPV6_JOIN_GROUP; return IP_ADD_MEMBERSHIP; } }; /// Request that a socket leaves a multicast group. class leave_group : private __mcastopt { public: using __mcastopt::__mcastopt; using __mcastopt::level; using __mcastopt::data; using __mcastopt::size; template<typename _Protocol> int name(const _Protocol& __p) const noexcept { if (__p.family() == AF_INET6) return IPV6_LEAVE_GROUP; return IP_DROP_MEMBERSHIP; } }; /// Specify the network interface for outgoing multicast datagrams. class outbound_interface { public: explicit outbound_interface(const address_v4& __v4) noexcept { #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ _M_v4.s_addr = __v4.to_uint(); #else _M_v4.s_addr = __builtin_bswap32(__v4.to_uint()); #endif } explicit outbound_interface(unsigned int __v6) noexcept : _M_v4(), _M_v6(__v6) { } template<typename _Protocol> int level(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? IPPROTO_IPV6 : IPPROTO_IP; } template<typename _Protocol> int name(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? IPV6_MULTICAST_IF : IP_MULTICAST_IF; } template<typename _Protocol> const void* data(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? &_M_v6 : &_M_v4; } template<typename _Protocol> size_t size(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? sizeof(_M_v6) : sizeof(_M_v4); } private: in_addr _M_v4; unsigned _M_v6 = 0; }; /// Set the default number of hops (TTL) for outbound datagrams. class hops : public __sockopt_crtp<hops> { public: using __sockopt_crtp::__sockopt_crtp; using __sockopt_crtp::operator=; template<typename _Protocol> int level(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? IPPROTO_IPV6 : IPPROTO_IP; } template<typename _Protocol> int name(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? IPV6_MULTICAST_HOPS : IP_MULTICAST_TTL; } }; /// Set whether datagrams are delivered back to the local application. class enable_loopback : public __sockopt_crtp<enable_loopback, bool> { public: using __sockopt_crtp::__sockopt_crtp; using __sockopt_crtp::operator=; template<typename _Protocol> int level(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? IPPROTO_IPV6 : IPPROTO_IP; } template<typename _Protocol> int name(const _Protocol& __p) const noexcept { return __p.family() == AF_INET6 ? IPV6_MULTICAST_LOOP : IP_MULTICAST_LOOP; } }; } // namespace multicast #endif // IPPROTO_IP && IPPROTO_IPV6 /// @} } // namespace ip } // namespace v1 } // namespace net } // namespace experimental template<> struct is_error_condition_enum<experimental::net::v1::ip::resolver_errc> : public true_type {}; // hash support template<typename _Tp> struct hash; template<> struct hash<experimental::net::v1::ip::address> : __hash_base<size_t, experimental::net::v1::ip::address> { size_t operator()(const experimental::net::v1::ip::address& __a) const { if (__a.is_v4()) return _Hash_impl::hash(__a.to_v4()); else return _Hash_impl::hash(__a.to_v6()); } }; template<> struct hash<experimental::net::v1::ip::address_v4> : __hash_base<size_t, experimental::net::v1::ip::address_v4> { size_t operator()(const experimental::net::v1::ip::address_v4& __a) const { return _Hash_impl::hash(__a.to_bytes()); } }; template<> struct hash<experimental::net::v1::ip::address_v6> : __hash_base<size_t, experimental::net::v1::ip::address_v6> { size_t operator()(const experimental::net::v1::ip::address_v6& __a) const { return _Hash_impl::hash(__a.to_bytes()); } }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++14 #endif // _GLIBCXX_EXPERIMENTAL_INTERNET // Variable Templates For chrono -*- C++ -*- // Copyright (C) 2014-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/chrono * This is a TS C++ Library header. * @ingroup libfund-ts */ // // N3932 Variable Templates For Type Traits (Revision 1) // #ifndef _GLIBCXX_EXPERIMENTAL_CHRONO #define _GLIBCXX_EXPERIMENTAL_CHRONO 1 #pragma GCC system_header #if __cplusplus >= 201402L #include <chrono> #include <experimental/bits/lfts_config.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace chrono { namespace experimental { inline namespace fundamentals_v1 { // See C++14 20.12.4, customization traits template <typename _Rep> constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value; } // namespace fundamentals_v1 } // namespace experimental } // namespace chrono _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // __cplusplus <= 201103L #endif // _GLIBCXX_EXPERIMENTAL_CHRONO // <experimental/functional> -*- C++ -*- // Copyright (C) 2014-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/functional * This is a TS C++ Library header. * @ingroup libfund-ts */ #ifndef _GLIBCXX_EXPERIMENTAL_FUNCTIONAL #define _GLIBCXX_EXPERIMENTAL_FUNCTIONAL 1 #pragma GCC system_header #if __cplusplus >= 201402L #include <functional> #include <tuple> #include <iterator> #include <unordered_map> #include <vector> #include <array> #include <bits/stl_algo.h> #ifdef _GLIBCXX_PARALLEL # include <parallel/algorithm> // For std::__parallel::search #endif #include <experimental/bits/lfts_config.h> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { inline namespace fundamentals_v1 { // See C++14 20.9.9, Function object binders /// Variable template for std::is_bind_expression template<typename _Tp> constexpr bool is_bind_expression_v = std::is_bind_expression<_Tp>::value; /// Variable template for std::is_placeholder template<typename _Tp> constexpr int is_placeholder_v = std::is_placeholder<_Tp>::value; #define __cpp_lib_experimental_boyer_moore_searching 201411 // Searchers template<typename _ForwardIterator1, typename _BinaryPredicate = equal_to<>> class default_searcher { public: default_searcher(_ForwardIterator1 __pat_first, _ForwardIterator1 __pat_last, _BinaryPredicate __pred = _BinaryPredicate()) : _M_m(__pat_first, __pat_last, std::move(__pred)) { } template<typename _ForwardIterator2> _ForwardIterator2 operator()(_ForwardIterator2 __first, _ForwardIterator2 __last) const { return std::search(__first, __last, std::get<0>(_M_m), std::get<1>(_M_m), std::get<2>(_M_m)); } private: std::tuple<_ForwardIterator1, _ForwardIterator1, _BinaryPredicate> _M_m; }; template<typename _Key, typename _Tp, typename _Hash, typename _Pred> struct __boyer_moore_map_base { template<typename _RAIter> __boyer_moore_map_base(_RAIter __pat, size_t __patlen, _Hash&& __hf, _Pred&& __pred) : _M_bad_char{ __patlen, std::move(__hf), std::move(__pred) } { if (__patlen > 0) for (__diff_type __i = 0; __i < __patlen - 1; ++__i) _M_bad_char[__pat[__i]] = __patlen - 1 - __i; } using __diff_type = _Tp; __diff_type _M_lookup(_Key __key, __diff_type __not_found) const { auto __iter = _M_bad_char.find(__key); if (__iter == _M_bad_char.end()) return __not_found; return __iter->second; } _Pred _M_pred() const { return _M_bad_char.key_eq(); } _GLIBCXX_STD_C::unordered_map<_Key, _Tp, _Hash, _Pred> _M_bad_char; }; template<typename _Tp, size_t _Len, typename _Pred> struct __boyer_moore_array_base { template<typename _RAIter, typename _Unused> __boyer_moore_array_base(_RAIter __pat, size_t __patlen, _Unused&&, _Pred&& __pred) : _M_bad_char{ std::array<_Tp, _Len>{}, std::move(__pred) } { std::get<0>(_M_bad_char).fill(__patlen); if (__patlen > 0) for (__diff_type __i = 0; __i < __patlen - 1; ++__i) { auto __ch = __pat[__i]; using _UCh = std::make_unsigned_t<decltype(__ch)>; auto __uch = static_cast<_UCh>(__ch); std::get<0>(_M_bad_char)[__uch] = __patlen - 1 - __i; } } using __diff_type = _Tp; template<typename _Key> __diff_type _M_lookup(_Key __key, __diff_type __not_found) const { auto __ukey = static_cast<std::make_unsigned_t<_Key>>(__key); if (__ukey >= _Len) return __not_found; return std::get<0>(_M_bad_char)[__ukey]; } const _Pred& _M_pred() const { return std::get<1>(_M_bad_char); } std::tuple<std::array<_Tp, _Len>, _Pred> _M_bad_char; }; // Use __boyer_moore_array_base when pattern consists of narrow characters // (or std::byte) and uses std::equal_to as the predicate. template<typename _RAIter, typename _Hash, typename _Pred, typename _Val = typename iterator_traits<_RAIter>::value_type, typename _Diff = typename iterator_traits<_RAIter>::difference_type> using __boyer_moore_base_t = std::conditional_t<std::__is_byte_like<_Val, _Pred>::value, __boyer_moore_array_base<_Diff, 256, _Pred>, __boyer_moore_map_base<_Val, _Diff, _Hash, _Pred>>; template<typename _RAIter, typename _Hash = std::hash<typename std::iterator_traits<_RAIter>::value_type>, typename _BinaryPredicate = std::equal_to<>> class boyer_moore_searcher : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate> { using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>; using typename _Base::__diff_type; public: boyer_moore_searcher(_RAIter __pat_first, _RAIter __pat_last, _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate()); template<typename _RandomAccessIterator2> _RandomAccessIterator2 operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const; private: bool _M_is_prefix(_RAIter __word, __diff_type __len, __diff_type __pos) { const auto& __pred = this->_M_pred(); __diff_type __suffixlen = __len - __pos; for (__diff_type __i = 0; __i < __suffixlen; ++__i) if (!__pred(__word[__i], __word[__pos + __i])) return false; return true; } __diff_type _M_suffix_length(_RAIter __word, __diff_type __len, __diff_type __pos) { const auto& __pred = this->_M_pred(); __diff_type __i = 0; while (__pred(__word[__pos - __i], __word[__len - 1 - __i]) && __i < __pos) { ++__i; } return __i; } template<typename _Tp> __diff_type _M_bad_char_shift(_Tp __c) const { return this->_M_lookup(__c, _M_pat_end - _M_pat); } _RAIter _M_pat; _RAIter _M_pat_end; _GLIBCXX_STD_C::vector<__diff_type> _M_good_suffix; }; template<typename _RAIter, typename _Hash = std::hash<typename std::iterator_traits<_RAIter>::value_type>, typename _BinaryPredicate = std::equal_to<>> class boyer_moore_horspool_searcher : __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate> { using _Base = __boyer_moore_base_t<_RAIter, _Hash, _BinaryPredicate>; using typename _Base::__diff_type; public: boyer_moore_horspool_searcher(_RAIter __pat, _RAIter __pat_end, _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate()) : _Base(__pat, __pat_end - __pat, std::move(__hf), std::move(__pred)), _M_pat(__pat), _M_pat_end(__pat_end) { } template<typename _RandomAccessIterator2> _RandomAccessIterator2 operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const { const auto& __pred = this->_M_pred(); auto __patlen = _M_pat_end - _M_pat; if (__patlen == 0) return __first; auto __len = __last - __first; while (__len >= __patlen) { for (auto __scan = __patlen - 1; __pred(__first[__scan], _M_pat[__scan]); --__scan) if (__scan == 0) return __first; auto __shift = _M_bad_char_shift(__first[__patlen - 1]); __len -= __shift; __first += __shift; } return __last; } private: template<typename _Tp> __diff_type _M_bad_char_shift(_Tp __c) const { return this->_M_lookup(__c, _M_pat_end - _M_pat); } _RAIter _M_pat; _RAIter _M_pat_end; }; /// Generator function for default_searcher template<typename _ForwardIterator, typename _BinaryPredicate = std::equal_to<>> inline default_searcher<_ForwardIterator, _BinaryPredicate> make_default_searcher(_ForwardIterator __pat_first, _ForwardIterator __pat_last, _BinaryPredicate __pred = _BinaryPredicate()) { return { __pat_first, __pat_last, __pred }; } /// Generator function for boyer_moore_searcher template<typename _RAIter, typename _Hash = std::hash<typename std::iterator_traits<_RAIter>::value_type>, typename _BinaryPredicate = equal_to<>> inline boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate> make_boyer_moore_searcher(_RAIter __pat_first, _RAIter __pat_last, _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate()) { return { __pat_first, __pat_last, std::move(__hf), std::move(__pred) }; } /// Generator function for boyer_moore_horspool_searcher template<typename _RAIter, typename _Hash = std::hash<typename std::iterator_traits<_RAIter>::value_type>, typename _BinaryPredicate = equal_to<>> inline boyer_moore_horspool_searcher<_RAIter, _Hash, _BinaryPredicate> make_boyer_moore_horspool_searcher(_RAIter __pat_first, _RAIter __pat_last, _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate()) { return { __pat_first, __pat_last, std::move(__hf), std::move(__pred) }; } template<typename _RAIter, typename _Hash, typename _BinaryPredicate> boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>:: boyer_moore_searcher(_RAIter __pat, _RAIter __pat_end, _Hash __hf, _BinaryPredicate __pred) : _Base(__pat, __pat_end - __pat, std::move(__hf), std::move(__pred)), _M_pat(__pat), _M_pat_end(__pat_end), _M_good_suffix(__pat_end - __pat) { auto __patlen = __pat_end - __pat; if (__patlen == 0) return; __diff_type __last_prefix = __patlen - 1; for (__diff_type __p = __patlen - 1; __p >= 0; --__p) { if (_M_is_prefix(__pat, __patlen, __p + 1)) __last_prefix = __p + 1; _M_good_suffix[__p] = __last_prefix + (__patlen - 1 - __p); } for (__diff_type __p = 0; __p < __patlen - 1; ++__p) { auto __slen = _M_suffix_length(__pat, __patlen, __p); auto __pos = __patlen - 1 - __slen; if (!__pred(__pat[__p - __slen], __pat[__pos])) _M_good_suffix[__pos] = __patlen - 1 - __p + __slen; } } template<typename _RAIter, typename _Hash, typename _BinaryPredicate> template<typename _RandomAccessIterator2> _RandomAccessIterator2 boyer_moore_searcher<_RAIter, _Hash, _BinaryPredicate>:: operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const { auto __patlen = _M_pat_end - _M_pat; if (__patlen == 0) return __first; const auto& __pred = this->_M_pred(); __diff_type __i = __patlen - 1; auto __stringlen = __last - __first; while (__i < __stringlen) { __diff_type __j = __patlen - 1; while (__j >= 0 && __pred(__first[__i], _M_pat[__j])) { --__i; --__j; } if (__j < 0) return __first + __i + 1; __i += std::max(_M_bad_char_shift(__first[__i]), _M_good_suffix[__j]); } return __last; } } // namespace fundamentals_v1 inline namespace fundamentals_v2 { #define __cpp_lib_experimental_not_fn 201406 /// [func.not_fn] Function template not_fn template<typename _Fn> inline auto not_fn(_Fn&& __fn) noexcept(std::is_nothrow_constructible<std::decay_t<_Fn>, _Fn&&>::value) { return std::_Not_fn<std::decay_t<_Fn>>{std::forward<_Fn>(__fn), 0}; } } // namespace fundamentals_v2 } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++14 #endif // _GLIBCXX_EXPERIMENTAL_FUNCTIONAL // <experimental/regex> -*- C++ -*- // Copyright (C) 2015-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/regex * This is a TS C++ Library header. * @ingroup libfund-ts */ #ifndef _GLIBCXX_EXPERIMENTAL_REGEX #define _GLIBCXX_EXPERIMENTAL_REGEX 1 #pragma GCC system_header #if __cplusplus >= 201402L #include <regex> #include <experimental/string> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { inline namespace fundamentals_v2 { #if _GLIBCXX_USE_CXX11_ABI namespace pmr { template<typename _BidirectionalIterator> using match_results = std::match_results<_BidirectionalIterator, polymorphic_allocator< sub_match<_BidirectionalIterator>>>; typedef match_results<const char*> cmatch; typedef match_results<const wchar_t*> wcmatch; typedef match_results<string::const_iterator> smatch; typedef match_results<wstring::const_iterator> wsmatch; } // namespace pmr #endif } // namespace fundamentals_v2 } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++14 #endif // _GLIBCXX_EXPERIMENTAL_REGEX // <experimental/netfwd> -*- C++ -*- // Copyright (C) 2015-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/netfwd * This is a TS C++ Library header. * @ingroup networking-ts */ #ifndef _GLIBCXX_EXPERIMENTAL_NETFWD #define _GLIBCXX_EXPERIMENTAL_NETFWD 1 #pragma GCC system_header #if __cplusplus >= 201402L // #define __cpp_lib_experimental_net 201803 // #define __cpp_lib_experimental_net_extensible 201803 #include <chrono> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { namespace net { inline namespace v1 { /** @defgroup networking-ts Networking TS * @ingroup experimental * * ISO/IEC TS 19216:2018 C++ Extensions for Networking * @{ */ class execution_context; template<typename _Tp, typename _Executor> class executor_binder; template<typename _Executor> class executor_work_guard; class system_executor; class executor; template<typename _Executor> class strand; class io_service; template<typename _Clock> struct wait_traits; template<typename _Clock, typename _WaitTraits = wait_traits<_Clock>> class basic_waitable_timer; typedef basic_waitable_timer<chrono::system_clock> system_timer; typedef basic_waitable_timer<chrono::steady_clock> steady_timer; typedef basic_waitable_timer<chrono::high_resolution_clock> high_resolution_timer; template<typename _Protocol> class basic_socket; template<typename _Protocol> class basic_datagram_socket; template<typename _Protocol> class basic_stream_socket; template<typename _Protocol> class basic_socket_acceptor; template<typename _Protocol, typename _Clock = chrono::steady_clock, typename _WaitTraits = wait_traits<_Clock>> class basic_socket_streambuf; template<typename _Protocol, typename _Clock = chrono::steady_clock, typename _WaitTraits = wait_traits<_Clock>> class basic_socket_iostream; /// @} namespace ip { /** * @addtogroup networking-ts * @{ */ class address; class address_v4; class address_v6; class address_iterator_v4; class address_iterator_v6; class address_range_v4; class address_range_v6; class network_v4; class network_v6; template<typename _InternetProtocol> class basic_endpoint; template<typename _InternetProtocol> class basic_resolver_entry; template<typename _InternetProtocol> class basic_resolver_results; template<typename _InternetProtocol> class basic_resolver; class tcp; class udp; /// @} } // namespace ip } // namespace v1 } // namespace net } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++14 #endif // _GLIBCXX_EXPERIMENTAL_NETFWD // <experimental/source_location> -*- C++ -*- // Copyright (C) 2015-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/source_location * This is a TS C++ Library header. * @ingroup libfund-ts */ #ifndef _GLIBCXX_EXPERIMENTAL_SRCLOC #define _GLIBCXX_EXPERIMENTAL_SRCLOC 1 #if __cplusplus >= 201402L #include <cstdint> namespace std { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { inline namespace fundamentals_v2 { #define __cpp_lib_experimental_source_location 201505 struct source_location { #ifndef _GLIBCXX_USE_C99_STDINT_TR1 private: using uint_least32_t = unsigned; public: #endif // 14.1.2, source_location creation static constexpr source_location current(const char* __file = __builtin_FILE(), const char* __func = __builtin_FUNCTION(), int __line = __builtin_LINE(), int __col = 0) noexcept { source_location __loc; __loc._M_file = __file; __loc._M_func = __func; __loc._M_line = __line; __loc._M_col = __col; return __loc; } constexpr source_location() noexcept : _M_file("unknown"), _M_func(_M_file), _M_line(0), _M_col(0) { } // 14.1.3, source_location field access constexpr uint_least32_t line() const noexcept { return _M_line; } constexpr uint_least32_t column() const noexcept { return _M_col; } constexpr const char* file_name() const noexcept { return _M_file; } constexpr const char* function_name() const noexcept { return _M_func; } private: const char* _M_file; const char* _M_func; uint_least32_t _M_line; uint_least32_t _M_col; }; } // namespace fundamentals_v2 } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++14 #endif // _GLIBCXX_EXPERIMENTAL_SRCLOC // Math overloads for simd -*- C++ -*- // Copyright (C) 2020-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. #ifndef _GLIBCXX_EXPERIMENTAL_SIMD_MATH_H_ #define _GLIBCXX_EXPERIMENTAL_SIMD_MATH_H_ #if __cplusplus >= 201703L #include <utility> #include <iomanip> _GLIBCXX_SIMD_BEGIN_NAMESPACE template <typename _Tp, typename _V> using _Samesize = fixed_size_simd<_Tp, _V::size()>; // _Math_return_type {{{ template <typename _DoubleR, typename _Tp, typename _Abi> struct _Math_return_type; template <typename _DoubleR, typename _Tp, typename _Abi> using _Math_return_type_t = typename _Math_return_type<_DoubleR, _Tp, _Abi>::type; template <typename _Tp, typename _Abi> struct _Math_return_type<double, _Tp, _Abi> { using type = simd<_Tp, _Abi>; }; template <typename _Tp, typename _Abi> struct _Math_return_type<bool, _Tp, _Abi> { using type = simd_mask<_Tp, _Abi>; }; template <typename _DoubleR, typename _Tp, typename _Abi> struct _Math_return_type { using type = fixed_size_simd<_DoubleR, simd_size_v<_Tp, _Abi>>; }; //}}} // _GLIBCXX_SIMD_MATH_CALL_ {{{ #define _GLIBCXX_SIMD_MATH_CALL_(__name) \ template <typename _Tp, typename _Abi, typename..., \ typename _R = _Math_return_type_t< \ decltype(std::__name(declval<double>())), _Tp, _Abi>> \ enable_if_t<is_floating_point_v<_Tp>, _R> \ __name(simd<_Tp, _Abi> __x) \ { return {__private_init, _Abi::_SimdImpl::_S_##__name(__data(__x))}; } // }}} //_Extra_argument_type{{{ template <typename _Up, typename _Tp, typename _Abi> struct _Extra_argument_type; template <typename _Tp, typename _Abi> struct _Extra_argument_type<_Tp*, _Tp, _Abi> { using type = simd<_Tp, _Abi>*; static constexpr double* declval(); static constexpr bool __needs_temporary_scalar = true; _GLIBCXX_SIMD_INTRINSIC static constexpr auto _S_data(type __x) { return &__data(*__x); } }; template <typename _Up, typename _Tp, typename _Abi> struct _Extra_argument_type<_Up*, _Tp, _Abi> { static_assert(is_integral_v<_Up>); using type = fixed_size_simd<_Up, simd_size_v<_Tp, _Abi>>*; static constexpr _Up* declval(); static constexpr bool __needs_temporary_scalar = true; _GLIBCXX_SIMD_INTRINSIC static constexpr auto _S_data(type __x) { return &__data(*__x); } }; template <typename _Tp, typename _Abi> struct _Extra_argument_type<_Tp, _Tp, _Abi> { using type = simd<_Tp, _Abi>; static constexpr double declval(); static constexpr bool __needs_temporary_scalar = false; _GLIBCXX_SIMD_INTRINSIC static constexpr decltype(auto) _S_data(const type& __x) { return __data(__x); } }; template <typename _Up, typename _Tp, typename _Abi> struct _Extra_argument_type { static_assert(is_integral_v<_Up>); using type = fixed_size_simd<_Up, simd_size_v<_Tp, _Abi>>; static constexpr _Up declval(); static constexpr bool __needs_temporary_scalar = false; _GLIBCXX_SIMD_INTRINSIC static constexpr decltype(auto) _S_data(const type& __x) { return __data(__x); } }; //}}} // _GLIBCXX_SIMD_MATH_CALL2_ {{{ #define _GLIBCXX_SIMD_MATH_CALL2_(__name, arg2_) \ template < \ typename _Tp, typename _Abi, typename..., \ typename _Arg2 = _Extra_argument_type<arg2_, _Tp, _Abi>, \ typename _R = _Math_return_type_t< \ decltype(std::__name(declval<double>(), _Arg2::declval())), _Tp, _Abi>> \ enable_if_t<is_floating_point_v<_Tp>, _R> \ __name(const simd<_Tp, _Abi>& __x, const typename _Arg2::type& __y) \ { \ return {__private_init, \ _Abi::_SimdImpl::_S_##__name(__data(__x), _Arg2::_S_data(__y))}; \ } \ template <typename _Up, typename _Tp, typename _Abi> \ _GLIBCXX_SIMD_INTRINSIC _Math_return_type_t< \ decltype(std::__name( \ declval<double>(), \ declval<enable_if_t< \ conjunction_v< \ is_same<arg2_, _Tp>, \ negation<is_same<__remove_cvref_t<_Up>, simd<_Tp, _Abi>>>, \ is_convertible<_Up, simd<_Tp, _Abi>>, is_floating_point<_Tp>>, \ double>>())), \ _Tp, _Abi> \ __name(_Up&& __xx, const simd<_Tp, _Abi>& __yy) \ { return __name(simd<_Tp, _Abi>(static_cast<_Up&&>(__xx)), __yy); } // }}} // _GLIBCXX_SIMD_MATH_CALL3_ {{{ #define _GLIBCXX_SIMD_MATH_CALL3_(__name, arg2_, arg3_) \ template <typename _Tp, typename _Abi, typename..., \ typename _Arg2 = _Extra_argument_type<arg2_, _Tp, _Abi>, \ typename _Arg3 = _Extra_argument_type<arg3_, _Tp, _Abi>, \ typename _R = _Math_return_type_t< \ decltype(std::__name(declval<double>(), _Arg2::declval(), \ _Arg3::declval())), \ _Tp, _Abi>> \ enable_if_t<is_floating_point_v<_Tp>, _R> \ __name(const simd<_Tp, _Abi>& __x, const typename _Arg2::type& __y, \ const typename _Arg3::type& __z) \ { \ return {__private_init, \ _Abi::_SimdImpl::_S_##__name(__data(__x), _Arg2::_S_data(__y), \ _Arg3::_S_data(__z))}; \ } \ template < \ typename _T0, typename _T1, typename _T2, typename..., \ typename _U0 = __remove_cvref_t<_T0>, \ typename _U1 = __remove_cvref_t<_T1>, \ typename _U2 = __remove_cvref_t<_T2>, \ typename _Simd = conditional_t<is_simd_v<_U1>, _U1, _U2>, \ typename = enable_if_t<conjunction_v< \ is_simd<_Simd>, is_convertible<_T0&&, _Simd>, \ is_convertible<_T1&&, _Simd>, is_convertible<_T2&&, _Simd>, \ negation<conjunction< \ is_simd<_U0>, is_floating_point<__value_type_or_identity_t<_U0>>>>>>> \ _GLIBCXX_SIMD_INTRINSIC decltype(__name(declval<const _Simd&>(), \ declval<const _Simd&>(), \ declval<const _Simd&>())) \ __name(_T0&& __xx, _T1&& __yy, _T2&& __zz) \ { \ return __name(_Simd(static_cast<_T0&&>(__xx)), \ _Simd(static_cast<_T1&&>(__yy)), \ _Simd(static_cast<_T2&&>(__zz))); \ } // }}} // __cosSeries {{{ template <typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE static simd<float, _Abi> __cosSeries(const simd<float, _Abi>& __x) { const simd<float, _Abi> __x2 = __x * __x; simd<float, _Abi> __y; __y = 0x1.ap-16f; // 1/8! __y = __y * __x2 - 0x1.6c1p-10f; // -1/6! __y = __y * __x2 + 0x1.555556p-5f; // 1/4! return __y * (__x2 * __x2) - .5f * __x2 + 1.f; } template <typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE static simd<double, _Abi> __cosSeries(const simd<double, _Abi>& __x) { const simd<double, _Abi> __x2 = __x * __x; simd<double, _Abi> __y; __y = 0x1.AC00000000000p-45; // 1/16! __y = __y * __x2 - 0x1.9394000000000p-37; // -1/14! __y = __y * __x2 + 0x1.1EED8C0000000p-29; // 1/12! __y = __y * __x2 - 0x1.27E4FB7400000p-22; // -1/10! __y = __y * __x2 + 0x1.A01A01A018000p-16; // 1/8! __y = __y * __x2 - 0x1.6C16C16C16C00p-10; // -1/6! __y = __y * __x2 + 0x1.5555555555554p-5; // 1/4! return (__y * __x2 - .5f) * __x2 + 1.f; } // }}} // __sinSeries {{{ template <typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE static simd<float, _Abi> __sinSeries(const simd<float, _Abi>& __x) { const simd<float, _Abi> __x2 = __x * __x; simd<float, _Abi> __y; __y = -0x1.9CC000p-13f; // -1/7! __y = __y * __x2 + 0x1.111100p-7f; // 1/5! __y = __y * __x2 - 0x1.555556p-3f; // -1/3! return __y * (__x2 * __x) + __x; } template <typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE static simd<double, _Abi> __sinSeries(const simd<double, _Abi>& __x) { // __x = [0, 0.7854 = pi/4] // __x² = [0, 0.6169 = pi²/8] const simd<double, _Abi> __x2 = __x * __x; simd<double, _Abi> __y; __y = -0x1.ACF0000000000p-41; // -1/15! __y = __y * __x2 + 0x1.6124400000000p-33; // 1/13! __y = __y * __x2 - 0x1.AE64567000000p-26; // -1/11! __y = __y * __x2 + 0x1.71DE3A5540000p-19; // 1/9! __y = __y * __x2 - 0x1.A01A01A01A000p-13; // -1/7! __y = __y * __x2 + 0x1.1111111111110p-7; // 1/5! __y = __y * __x2 - 0x1.5555555555555p-3; // -1/3! return __y * (__x2 * __x) + __x; } // }}} // __zero_low_bits {{{ template <int _Bits, typename _Tp, typename _Abi> _GLIBCXX_SIMD_INTRINSIC simd<_Tp, _Abi> __zero_low_bits(simd<_Tp, _Abi> __x) { const simd<_Tp, _Abi> __bitmask = __bit_cast<_Tp>(~make_unsigned_t<__int_for_sizeof_t<_Tp>>() << _Bits); return {__private_init, _Abi::_SimdImpl::_S_bit_and(__data(__x), __data(__bitmask))}; } // }}} // __fold_input {{{ /**@internal * Fold @p x into [-¼π, ¼π] and remember the quadrant it came from: * quadrant 0: [-¼π, ¼π] * quadrant 1: [ ¼π, ¾π] * quadrant 2: [ ¾π, 1¼π] * quadrant 3: [1¼π, 1¾π] * * The algorithm determines `y` as the multiple `x - y * ¼π = [-¼π, ¼π]`. Using * a bitmask, `y` is reduced to `quadrant`. `y` can be calculated as * ``` * y = trunc(x / ¼π); * y += fmod(y, 2); * ``` * This can be simplified by moving the (implicit) division by 2 into the * truncation expression. The `+= fmod` effect can the be achieved by using * rounding instead of truncation: `y = round(x / ½π) * 2`. If precision allows, * `2/π * x` is better (faster). */ template <typename _Tp, typename _Abi> struct _Folded { simd<_Tp, _Abi> _M_x; rebind_simd_t<int, simd<_Tp, _Abi>> _M_quadrant; }; namespace __math_float { inline constexpr float __pi_over_4 = 0x1.921FB6p-1f; // π/4 inline constexpr float __2_over_pi = 0x1.45F306p-1f; // 2/π inline constexpr float __pi_2_5bits0 = 0x1.921fc0p0f; // π/2, 5 0-bits (least significant) inline constexpr float __pi_2_5bits0_rem = -0x1.5777a6p-21f; // π/2 - __pi_2_5bits0 } // namespace __math_float namespace __math_double { inline constexpr double __pi_over_4 = 0x1.921fb54442d18p-1; // π/4 inline constexpr double __2_over_pi = 0x1.45F306DC9C883p-1; // 2/π inline constexpr double __pi_2 = 0x1.921fb54442d18p0; // π/2 } // namespace __math_double template <typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE _Folded<float, _Abi> __fold_input(const simd<float, _Abi>& __x) { using _V = simd<float, _Abi>; using _IV = rebind_simd_t<int, _V>; using namespace __math_float; _Folded<float, _Abi> __r; __r._M_x = abs(__x); #if 0 // zero most mantissa bits: constexpr float __1_over_pi = 0x1.45F306p-2f; // 1/π const auto __y = (__r._M_x * __1_over_pi + 0x1.8p23f) - 0x1.8p23f; // split π into 4 parts, the first three with 13 trailing zeros (to make the // following multiplications precise): constexpr float __pi0 = 0x1.920000p1f; constexpr float __pi1 = 0x1.fb4000p-11f; constexpr float __pi2 = 0x1.444000p-23f; constexpr float __pi3 = 0x1.68c234p-38f; __r._M_x - __y*__pi0 - __y*__pi1 - __y*__pi2 - __y*__pi3 #else if (_GLIBCXX_SIMD_IS_UNLIKELY(all_of(__r._M_x < __pi_over_4))) __r._M_quadrant = 0; else if (_GLIBCXX_SIMD_IS_LIKELY(all_of(__r._M_x < 6 * __pi_over_4))) { const _V __y = nearbyint(__r._M_x * __2_over_pi); __r._M_quadrant = static_simd_cast<_IV>(__y) & 3; // __y mod 4 __r._M_x -= __y * __pi_2_5bits0; __r._M_x -= __y * __pi_2_5bits0_rem; } else { using __math_double::__2_over_pi; using __math_double::__pi_2; using _VD = rebind_simd_t<double, _V>; _VD __xd = static_simd_cast<_VD>(__r._M_x); _VD __y = nearbyint(__xd * __2_over_pi); __r._M_quadrant = static_simd_cast<_IV>(__y) & 3; // = __y mod 4 __r._M_x = static_simd_cast<_V>(__xd - __y * __pi_2); } #endif return __r; } template <typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE _Folded<double, _Abi> __fold_input(const simd<double, _Abi>& __x) { using _V = simd<double, _Abi>; using _IV = rebind_simd_t<int, _V>; using namespace __math_double; _Folded<double, _Abi> __r; __r._M_x = abs(__x); if (_GLIBCXX_SIMD_IS_UNLIKELY(all_of(__r._M_x < __pi_over_4))) { __r._M_quadrant = 0; return __r; } const _V __y = nearbyint(__r._M_x / (2 * __pi_over_4)); __r._M_quadrant = static_simd_cast<_IV>(__y) & 3; if (_GLIBCXX_SIMD_IS_LIKELY(all_of(__r._M_x < 1025 * __pi_over_4))) { // x - y * pi/2, y uses no more than 11 mantissa bits __r._M_x -= __y * 0x1.921FB54443000p0; __r._M_x -= __y * -0x1.73DCB3B39A000p-43; __r._M_x -= __y * 0x1.45C06E0E68948p-86; } else if (_GLIBCXX_SIMD_IS_LIKELY(all_of(__y <= 0x1.0p30))) { // x - y * pi/2, y uses no more than 29 mantissa bits __r._M_x -= __y * 0x1.921FB40000000p0; __r._M_x -= __y * 0x1.4442D00000000p-24; __r._M_x -= __y * 0x1.8469898CC5170p-48; } else { // x - y * pi/2, y may require all mantissa bits const _V __y_hi = __zero_low_bits<26>(__y); const _V __y_lo = __y - __y_hi; const auto __pi_2_1 = 0x1.921FB50000000p0; const auto __pi_2_2 = 0x1.110B460000000p-26; const auto __pi_2_3 = 0x1.1A62630000000p-54; const auto __pi_2_4 = 0x1.8A2E03707344Ap-81; __r._M_x = __r._M_x - __y_hi * __pi_2_1 - max(__y_hi * __pi_2_2, __y_lo * __pi_2_1) - min(__y_hi * __pi_2_2, __y_lo * __pi_2_1) - max(__y_hi * __pi_2_3, __y_lo * __pi_2_2) - min(__y_hi * __pi_2_3, __y_lo * __pi_2_2) - max(__y * __pi_2_4, __y_lo * __pi_2_3) - min(__y * __pi_2_4, __y_lo * __pi_2_3); } return __r; } // }}} // __extract_exponent_as_int {{{ template <typename _Tp, typename _Abi> rebind_simd_t<int, simd<_Tp, _Abi>> __extract_exponent_as_int(const simd<_Tp, _Abi>& __v) { using _Vp = simd<_Tp, _Abi>; using _Up = make_unsigned_t<__int_for_sizeof_t<_Tp>>; using namespace std::experimental::__float_bitwise_operators; const _Vp __exponent_mask = __infinity_v<_Tp>; // 0x7f800000 or 0x7ff0000000000000 return static_simd_cast<rebind_simd_t<int, _Vp>>( __bit_cast<rebind_simd_t<_Up, _Vp>>(__v & __exponent_mask) >> (__digits_v<_Tp> - 1)); } // }}} // __impl_or_fallback {{{ template <typename ImplFun, typename FallbackFun, typename... _Args> _GLIBCXX_SIMD_INTRINSIC auto __impl_or_fallback_dispatch(int, ImplFun&& __impl_fun, FallbackFun&&, _Args&&... __args) -> decltype(__impl_fun(static_cast<_Args&&>(__args)...)) { return __impl_fun(static_cast<_Args&&>(__args)...); } template <typename ImplFun, typename FallbackFun, typename... _Args> inline auto __impl_or_fallback_dispatch(float, ImplFun&&, FallbackFun&& __fallback_fun, _Args&&... __args) -> decltype(__fallback_fun(static_cast<_Args&&>(__args)...)) { return __fallback_fun(static_cast<_Args&&>(__args)...); } template <typename... _Args> _GLIBCXX_SIMD_INTRINSIC auto __impl_or_fallback(_Args&&... __args) { return __impl_or_fallback_dispatch(int(), static_cast<_Args&&>(__args)...); } //}}} // trigonometric functions {{{ _GLIBCXX_SIMD_MATH_CALL_(acos) _GLIBCXX_SIMD_MATH_CALL_(asin) _GLIBCXX_SIMD_MATH_CALL_(atan) _GLIBCXX_SIMD_MATH_CALL2_(atan2, _Tp) /* * algorithm for sine and cosine: * * The result can be calculated with sine or cosine depending on the π/4 section * the input is in. sine ≈ __x + __x³ cosine ≈ 1 - __x² * * sine: * Map -__x to __x and invert the output * Extend precision of __x - n * π/4 by calculating * ((__x - n * p1) - n * p2) - n * p3 (p1 + p2 + p3 = π/4) * * Calculate Taylor series with tuned coefficients. * Fix sign. */ // cos{{{ template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> cos(const simd<_Tp, _Abi>& __x) { using _V = simd<_Tp, _Abi>; if constexpr (__is_scalar_abi<_Abi>() || __is_fixed_size_abi_v<_Abi>) return {__private_init, _Abi::_SimdImpl::_S_cos(__data(__x))}; else { if constexpr (is_same_v<_Tp, float>) if (_GLIBCXX_SIMD_IS_UNLIKELY(any_of(abs(__x) >= 393382))) return static_simd_cast<_V>( cos(static_simd_cast<rebind_simd_t<double, _V>>(__x))); const auto __f = __fold_input(__x); // quadrant | effect // 0 | cosSeries, + // 1 | sinSeries, - // 2 | cosSeries, - // 3 | sinSeries, + using namespace std::experimental::__float_bitwise_operators; const _V __sign_flip = _V(-0.f) & static_simd_cast<_V>((1 + __f._M_quadrant) << 30); const auto __need_cos = (__f._M_quadrant & 1) == 0; if (_GLIBCXX_SIMD_IS_UNLIKELY(all_of(__need_cos))) return __sign_flip ^ __cosSeries(__f._M_x); else if (_GLIBCXX_SIMD_IS_UNLIKELY(none_of(__need_cos))) return __sign_flip ^ __sinSeries(__f._M_x); else // some_of(__need_cos) { _V __r = __sinSeries(__f._M_x); where(__need_cos.__cvt(), __r) = __cosSeries(__f._M_x); return __r ^ __sign_flip; } } } template <typename _Tp> _GLIBCXX_SIMD_ALWAYS_INLINE enable_if_t<is_floating_point<_Tp>::value, simd<_Tp, simd_abi::scalar>> cos(simd<_Tp, simd_abi::scalar> __x) { return std::cos(__data(__x)); } //}}} // sin{{{ template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> sin(const simd<_Tp, _Abi>& __x) { using _V = simd<_Tp, _Abi>; if constexpr (__is_scalar_abi<_Abi>() || __is_fixed_size_abi_v<_Abi>) return {__private_init, _Abi::_SimdImpl::_S_sin(__data(__x))}; else { if constexpr (is_same_v<_Tp, float>) if (_GLIBCXX_SIMD_IS_UNLIKELY(any_of(abs(__x) >= 527449))) return static_simd_cast<_V>( sin(static_simd_cast<rebind_simd_t<double, _V>>(__x))); const auto __f = __fold_input(__x); // quadrant | effect // 0 | sinSeries // 1 | cosSeries // 2 | sinSeries, sign flip // 3 | cosSeries, sign flip using namespace std::experimental::__float_bitwise_operators; const auto __sign_flip = (__x ^ static_simd_cast<_V>(1 - __f._M_quadrant)) & _V(_Tp(-0.)); const auto __need_sin = (__f._M_quadrant & 1) == 0; if (_GLIBCXX_SIMD_IS_UNLIKELY(all_of(__need_sin))) return __sign_flip ^ __sinSeries(__f._M_x); else if (_GLIBCXX_SIMD_IS_UNLIKELY(none_of(__need_sin))) return __sign_flip ^ __cosSeries(__f._M_x); else // some_of(__need_sin) { _V __r = __cosSeries(__f._M_x); where(__need_sin.__cvt(), __r) = __sinSeries(__f._M_x); return __sign_flip ^ __r; } } } template <typename _Tp> _GLIBCXX_SIMD_ALWAYS_INLINE enable_if_t<is_floating_point<_Tp>::value, simd<_Tp, simd_abi::scalar>> sin(simd<_Tp, simd_abi::scalar> __x) { return std::sin(__data(__x)); } //}}} _GLIBCXX_SIMD_MATH_CALL_(tan) _GLIBCXX_SIMD_MATH_CALL_(acosh) _GLIBCXX_SIMD_MATH_CALL_(asinh) _GLIBCXX_SIMD_MATH_CALL_(atanh) _GLIBCXX_SIMD_MATH_CALL_(cosh) _GLIBCXX_SIMD_MATH_CALL_(sinh) _GLIBCXX_SIMD_MATH_CALL_(tanh) // }}} // exponential functions {{{ _GLIBCXX_SIMD_MATH_CALL_(exp) _GLIBCXX_SIMD_MATH_CALL_(exp2) _GLIBCXX_SIMD_MATH_CALL_(expm1) // }}} // frexp {{{ #if _GLIBCXX_SIMD_X86INTRIN template <typename _Tp, size_t _Np> _SimdWrapper<_Tp, _Np> __getexp(_SimdWrapper<_Tp, _Np> __x) { if constexpr (__have_avx512vl && __is_sse_ps<_Tp, _Np>()) return __auto_bitcast(_mm_getexp_ps(__to_intrin(__x))); else if constexpr (__have_avx512f && __is_sse_ps<_Tp, _Np>()) return __auto_bitcast(_mm512_getexp_ps(__auto_bitcast(__to_intrin(__x)))); else if constexpr (__have_avx512vl && __is_sse_pd<_Tp, _Np>()) return _mm_getexp_pd(__x); else if constexpr (__have_avx512f && __is_sse_pd<_Tp, _Np>()) return __lo128(_mm512_getexp_pd(__auto_bitcast(__x))); else if constexpr (__have_avx512vl && __is_avx_ps<_Tp, _Np>()) return _mm256_getexp_ps(__x); else if constexpr (__have_avx512f && __is_avx_ps<_Tp, _Np>()) return __lo256(_mm512_getexp_ps(__auto_bitcast(__x))); else if constexpr (__have_avx512vl && __is_avx_pd<_Tp, _Np>()) return _mm256_getexp_pd(__x); else if constexpr (__have_avx512f && __is_avx_pd<_Tp, _Np>()) return __lo256(_mm512_getexp_pd(__auto_bitcast(__x))); else if constexpr (__is_avx512_ps<_Tp, _Np>()) return _mm512_getexp_ps(__x); else if constexpr (__is_avx512_pd<_Tp, _Np>()) return _mm512_getexp_pd(__x); else __assert_unreachable<_Tp>(); } template <typename _Tp, size_t _Np> _SimdWrapper<_Tp, _Np> __getmant_avx512(_SimdWrapper<_Tp, _Np> __x) { if constexpr (__have_avx512vl && __is_sse_ps<_Tp, _Np>()) return __auto_bitcast(_mm_getmant_ps(__to_intrin(__x), _MM_MANT_NORM_p5_1, _MM_MANT_SIGN_src)); else if constexpr (__have_avx512f && __is_sse_ps<_Tp, _Np>()) return __auto_bitcast(_mm512_getmant_ps(__auto_bitcast(__to_intrin(__x)), _MM_MANT_NORM_p5_1, _MM_MANT_SIGN_src)); else if constexpr (__have_avx512vl && __is_sse_pd<_Tp, _Np>()) return _mm_getmant_pd(__x, _MM_MANT_NORM_p5_1, _MM_MANT_SIGN_src); else if constexpr (__have_avx512f && __is_sse_pd<_Tp, _Np>()) return __lo128(_mm512_getmant_pd(__auto_bitcast(__x), _MM_MANT_NORM_p5_1, _MM_MANT_SIGN_src)); else if constexpr (__have_avx512vl && __is_avx_ps<_Tp, _Np>()) return _mm256_getmant_ps(__x, _MM_MANT_NORM_p5_1, _MM_MANT_SIGN_src); else if constexpr (__have_avx512f && __is_avx_ps<_Tp, _Np>()) return __lo256(_mm512_getmant_ps(__auto_bitcast(__x), _MM_MANT_NORM_p5_1, _MM_MANT_SIGN_src)); else if constexpr (__have_avx512vl && __is_avx_pd<_Tp, _Np>()) return _mm256_getmant_pd(__x, _MM_MANT_NORM_p5_1, _MM_MANT_SIGN_src); else if constexpr (__have_avx512f && __is_avx_pd<_Tp, _Np>()) return __lo256(_mm512_getmant_pd(__auto_bitcast(__x), _MM_MANT_NORM_p5_1, _MM_MANT_SIGN_src)); else if constexpr (__is_avx512_ps<_Tp, _Np>()) return _mm512_getmant_ps(__x, _MM_MANT_NORM_p5_1, _MM_MANT_SIGN_src); else if constexpr (__is_avx512_pd<_Tp, _Np>()) return _mm512_getmant_pd(__x, _MM_MANT_NORM_p5_1, _MM_MANT_SIGN_src); else __assert_unreachable<_Tp>(); } #endif // _GLIBCXX_SIMD_X86INTRIN /** * splits @p __v into exponent and mantissa, the sign is kept with the mantissa * * The return value will be in the range [0.5, 1.0[ * The @p __e value will be an integer defining the power-of-two exponent */ template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> frexp(const simd<_Tp, _Abi>& __x, _Samesize<int, simd<_Tp, _Abi>>* __exp) { if constexpr (simd_size_v<_Tp, _Abi> == 1) { int __tmp; const auto __r = std::frexp(__x[0], &__tmp); (*__exp)[0] = __tmp; return __r; } else if constexpr (__is_fixed_size_abi_v<_Abi>) { return {__private_init, _Abi::_SimdImpl::_S_frexp(__data(__x), __data(*__exp))}; #if _GLIBCXX_SIMD_X86INTRIN } else if constexpr (__have_avx512f) { constexpr size_t _Np = simd_size_v<_Tp, _Abi>; constexpr size_t _NI = _Np < 4 ? 4 : _Np; const auto __v = __data(__x); const auto __isnonzero = _Abi::_SimdImpl::_S_isnonzerovalue_mask(__v._M_data); const _SimdWrapper<int, _NI> __exp_plus1 = 1 + __convert<_SimdWrapper<int, _NI>>(__getexp(__v))._M_data; const _SimdWrapper<int, _Np> __e = __wrapper_bitcast<int, _Np>( _Abi::_CommonImpl::_S_blend(_SimdWrapper<bool, _NI>(__isnonzero), _SimdWrapper<int, _NI>(), __exp_plus1)); simd_abi::deduce_t<int, _Np>::_CommonImpl::_S_store(__e, __exp); return {__private_init, _Abi::_CommonImpl::_S_blend(_SimdWrapper<bool, _Np>( __isnonzero), __v, __getmant_avx512(__v))}; #endif // _GLIBCXX_SIMD_X86INTRIN } else { // fallback implementation static_assert(sizeof(_Tp) == 4 || sizeof(_Tp) == 8); using _V = simd<_Tp, _Abi>; using _IV = rebind_simd_t<int, _V>; using namespace std::experimental::__proposed; using namespace std::experimental::__float_bitwise_operators; constexpr int __exp_adjust = sizeof(_Tp) == 4 ? 0x7e : 0x3fe; constexpr int __exp_offset = sizeof(_Tp) == 4 ? 0x70 : 0x200; constexpr _Tp __subnorm_scale = sizeof(_Tp) == 4 ? 0x1p112 : 0x1p512; _GLIBCXX_SIMD_USE_CONSTEXPR_API _V __exponent_mask = __infinity_v<_Tp>; // 0x7f800000 or 0x7ff0000000000000 _GLIBCXX_SIMD_USE_CONSTEXPR_API _V __p5_1_exponent = -(2 - __epsilon_v<_Tp>) / 2; // 0xbf7fffff or 0xbfefffffffffffff _V __mant = __p5_1_exponent & (__exponent_mask | __x); // +/-[.5, 1) const _IV __exponent_bits = __extract_exponent_as_int(__x); if (_GLIBCXX_SIMD_IS_LIKELY(all_of(isnormal(__x)))) { *__exp = simd_cast<_Samesize<int, _V>>(__exponent_bits - __exp_adjust); return __mant; } #if __FINITE_MATH_ONLY__ // at least one element of __x is 0 or subnormal, the rest is normal // (inf and NaN are excluded by -ffinite-math-only) const auto __iszero_inf_nan = __x == 0; #else const auto __as_int = __bit_cast<rebind_simd_t<__int_for_sizeof_t<_Tp>, _V>>(abs(__x)); const auto __inf = __bit_cast<rebind_simd_t<__int_for_sizeof_t<_Tp>, _V>>( _V(__infinity_v<_Tp>)); const auto __iszero_inf_nan = static_simd_cast<typename _V::mask_type>( __as_int == 0 || __as_int >= __inf); #endif const _V __scaled_subnormal = __x * __subnorm_scale; const _V __mant_subnormal = __p5_1_exponent & (__exponent_mask | __scaled_subnormal); where(!isnormal(__x), __mant) = __mant_subnormal; where(__iszero_inf_nan, __mant) = __x; _IV __e = __extract_exponent_as_int(__scaled_subnormal); using _MaskType = typename conditional_t<sizeof(typename _V::value_type) == sizeof(int), _V, _IV>::mask_type; const _MaskType __value_isnormal = isnormal(__x).__cvt(); where(__value_isnormal.__cvt(), __e) = __exponent_bits; static_assert(sizeof(_IV) == sizeof(__value_isnormal)); const _IV __offset = (__bit_cast<_IV>(__value_isnormal) & _IV(__exp_adjust)) | (__bit_cast<_IV>(static_simd_cast<_MaskType>(__exponent_bits == 0) & static_simd_cast<_MaskType>(__x != 0)) & _IV(__exp_adjust + __exp_offset)); *__exp = simd_cast<_Samesize<int, _V>>(__e - __offset); return __mant; } } // }}} _GLIBCXX_SIMD_MATH_CALL2_(ldexp, int) _GLIBCXX_SIMD_MATH_CALL_(ilogb) // logarithms {{{ _GLIBCXX_SIMD_MATH_CALL_(log) _GLIBCXX_SIMD_MATH_CALL_(log10) _GLIBCXX_SIMD_MATH_CALL_(log1p) _GLIBCXX_SIMD_MATH_CALL_(log2) //}}} // logb{{{ template <typename _Tp, typename _Abi> enable_if_t<is_floating_point<_Tp>::value, simd<_Tp, _Abi>> logb(const simd<_Tp, _Abi>& __x) { constexpr size_t _Np = simd_size_v<_Tp, _Abi>; if constexpr (_Np == 1) return std::logb(__x[0]); else if constexpr (__is_fixed_size_abi_v<_Abi>) { return {__private_init, __data(__x)._M_apply_per_chunk([](auto __impl, auto __xx) { using _V = typename decltype(__impl)::simd_type; return __data( std::experimental::logb(_V(__private_init, __xx))); })}; } #if _GLIBCXX_SIMD_X86INTRIN // {{{ else if constexpr (__have_avx512vl && __is_sse_ps<_Tp, _Np>()) return {__private_init, __auto_bitcast(_mm_getexp_ps(__to_intrin(__as_vector(__x))))}; else if constexpr (__have_avx512vl && __is_sse_pd<_Tp, _Np>()) return {__private_init, _mm_getexp_pd(__data(__x))}; else if constexpr (__have_avx512vl && __is_avx_ps<_Tp, _Np>()) return {__private_init, _mm256_getexp_ps(__data(__x))}; else if constexpr (__have_avx512vl && __is_avx_pd<_Tp, _Np>()) return {__private_init, _mm256_getexp_pd(__data(__x))}; else if constexpr (__have_avx512f && __is_avx_ps<_Tp, _Np>()) return {__private_init, __lo256(_mm512_getexp_ps(__auto_bitcast(__data(__x))))}; else if constexpr (__have_avx512f && __is_avx_pd<_Tp, _Np>()) return {__private_init, __lo256(_mm512_getexp_pd(__auto_bitcast(__data(__x))))}; else if constexpr (__is_avx512_ps<_Tp, _Np>()) return {__private_init, _mm512_getexp_ps(__data(__x))}; else if constexpr (__is_avx512_pd<_Tp, _Np>()) return {__private_init, _mm512_getexp_pd(__data(__x))}; #endif // _GLIBCXX_SIMD_X86INTRIN }}} else { using _V = simd<_Tp, _Abi>; using namespace std::experimental::__proposed; auto __is_normal = isnormal(__x); // work on abs(__x) to reflect the return value on Linux for negative // inputs (domain-error => implementation-defined value is returned) const _V abs_x = abs(__x); // __exponent(__x) returns the exponent value (bias removed) as // simd<_Up> with integral _Up auto&& __exponent = [](const _V& __v) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { using namespace std::experimental::__proposed; using _IV = rebind_simd_t< conditional_t<sizeof(_Tp) == sizeof(_LLong), _LLong, int>, _V>; return (__bit_cast<_IV>(__v) >> (__digits_v<_Tp> - 1)) - (__max_exponent_v<_Tp> - 1); }; _V __r = static_simd_cast<_V>(__exponent(abs_x)); if (_GLIBCXX_SIMD_IS_LIKELY(all_of(__is_normal))) // without corner cases (nan, inf, subnormal, zero) we have our // answer: return __r; const auto __is_zero = __x == 0; const auto __is_nan = isnan(__x); const auto __is_inf = isinf(__x); where(__is_zero, __r) = -__infinity_v<_Tp>; where(__is_nan, __r) = __x; where(__is_inf, __r) = __infinity_v<_Tp>; __is_normal |= __is_zero || __is_nan || __is_inf; if (all_of(__is_normal)) // at this point everything but subnormals is handled return __r; // subnormals repeat the exponent extraction after multiplication of the // input with __a floating point value that has 112 (0x70) in its exponent // (not too big for sp and large enough for dp) const _V __scaled = abs_x * _Tp(0x1p112); _V __scaled_exp = static_simd_cast<_V>(__exponent(__scaled) - 112); where(__is_normal, __scaled_exp) = __r; return __scaled_exp; } } //}}} template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> modf(const simd<_Tp, _Abi>& __x, simd<_Tp, _Abi>* __iptr) { if constexpr (__is_scalar_abi<_Abi>() || (__is_fixed_size_abi_v< _Abi> && simd_size_v<_Tp, _Abi> == 1)) { _Tp __tmp; _Tp __r = std::modf(__x[0], &__tmp); __iptr[0] = __tmp; return __r; } else { const auto __integral = trunc(__x); *__iptr = __integral; auto __r = __x - __integral; #if !__FINITE_MATH_ONLY__ where(isinf(__x), __r) = _Tp(); #endif return copysign(__r, __x); } } _GLIBCXX_SIMD_MATH_CALL2_(scalbn, int) _GLIBCXX_SIMD_MATH_CALL2_(scalbln, long) _GLIBCXX_SIMD_MATH_CALL_(cbrt) _GLIBCXX_SIMD_MATH_CALL_(abs) _GLIBCXX_SIMD_MATH_CALL_(fabs) // [parallel.simd.math] only asks for is_floating_point_v<_Tp> and forgot to // allow signed integral _Tp template <typename _Tp, typename _Abi> enable_if_t<!is_floating_point_v<_Tp> && is_signed_v<_Tp>, simd<_Tp, _Abi>> abs(const simd<_Tp, _Abi>& __x) { return {__private_init, _Abi::_SimdImpl::_S_abs(__data(__x))}; } template <typename _Tp, typename _Abi> enable_if_t<!is_floating_point_v<_Tp> && is_signed_v<_Tp>, simd<_Tp, _Abi>> fabs(const simd<_Tp, _Abi>& __x) { return {__private_init, _Abi::_SimdImpl::_S_abs(__data(__x))}; } // the following are overloads for functions in <cstdlib> and not covered by // [parallel.simd.math]. I don't see much value in making them work, though /* template <typename _Abi> simd<long, _Abi> labs(const simd<long, _Abi> &__x) { return {__private_init, _Abi::_SimdImpl::abs(__data(__x))}; } template <typename _Abi> simd<long long, _Abi> llabs(const simd<long long, _Abi> &__x) { return {__private_init, _Abi::_SimdImpl::abs(__data(__x))}; } */ #define _GLIBCXX_SIMD_CVTING2(_NAME) \ template <typename _Tp, typename _Abi> \ _GLIBCXX_SIMD_INTRINSIC simd<_Tp, _Abi> _NAME( \ const simd<_Tp, _Abi>& __x, const __type_identity_t<simd<_Tp, _Abi>>& __y) \ { \ return _NAME(__x, __y); \ } \ \ template <typename _Tp, typename _Abi> \ _GLIBCXX_SIMD_INTRINSIC simd<_Tp, _Abi> _NAME( \ const __type_identity_t<simd<_Tp, _Abi>>& __x, const simd<_Tp, _Abi>& __y) \ { \ return _NAME(__x, __y); \ } #define _GLIBCXX_SIMD_CVTING3(_NAME) \ template <typename _Tp, typename _Abi> \ _GLIBCXX_SIMD_INTRINSIC simd<_Tp, _Abi> _NAME( \ const __type_identity_t<simd<_Tp, _Abi>>& __x, const simd<_Tp, _Abi>& __y, \ const simd<_Tp, _Abi>& __z) \ { \ return _NAME(__x, __y, __z); \ } \ \ template <typename _Tp, typename _Abi> \ _GLIBCXX_SIMD_INTRINSIC simd<_Tp, _Abi> _NAME( \ const simd<_Tp, _Abi>& __x, const __type_identity_t<simd<_Tp, _Abi>>& __y, \ const simd<_Tp, _Abi>& __z) \ { \ return _NAME(__x, __y, __z); \ } \ \ template <typename _Tp, typename _Abi> \ _GLIBCXX_SIMD_INTRINSIC simd<_Tp, _Abi> _NAME( \ const simd<_Tp, _Abi>& __x, const simd<_Tp, _Abi>& __y, \ const __type_identity_t<simd<_Tp, _Abi>>& __z) \ { \ return _NAME(__x, __y, __z); \ } \ \ template <typename _Tp, typename _Abi> \ _GLIBCXX_SIMD_INTRINSIC simd<_Tp, _Abi> _NAME( \ const simd<_Tp, _Abi>& __x, const __type_identity_t<simd<_Tp, _Abi>>& __y, \ const __type_identity_t<simd<_Tp, _Abi>>& __z) \ { \ return _NAME(__x, __y, __z); \ } \ \ template <typename _Tp, typename _Abi> \ _GLIBCXX_SIMD_INTRINSIC simd<_Tp, _Abi> _NAME( \ const __type_identity_t<simd<_Tp, _Abi>>& __x, const simd<_Tp, _Abi>& __y, \ const __type_identity_t<simd<_Tp, _Abi>>& __z) \ { \ return _NAME(__x, __y, __z); \ } \ \ template <typename _Tp, typename _Abi> \ _GLIBCXX_SIMD_INTRINSIC simd<_Tp, _Abi> _NAME( \ const __type_identity_t<simd<_Tp, _Abi>>& __x, \ const __type_identity_t<simd<_Tp, _Abi>>& __y, const simd<_Tp, _Abi>& __z) \ { \ return _NAME(__x, __y, __z); \ } template <typename _R, typename _ToApply, typename _Tp, typename... _Tps> _GLIBCXX_SIMD_INTRINSIC _R __fixed_size_apply(_ToApply&& __apply, const _Tp& __arg0, const _Tps&... __args) { return {__private_init, __data(__arg0)._M_apply_per_chunk( [&](auto __impl, const auto&... __inner) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { using _V = typename decltype(__impl)::simd_type; return __data(__apply(_V(__private_init, __inner)...)); }, __data(__args)...)}; } template <typename _VV> __remove_cvref_t<_VV> __hypot(_VV __x, _VV __y) { using _V = __remove_cvref_t<_VV>; using _Tp = typename _V::value_type; if constexpr (_V::size() == 1) return std::hypot(_Tp(__x[0]), _Tp(__y[0])); else if constexpr (__is_fixed_size_abi_v<typename _V::abi_type>) { return __fixed_size_apply<_V>([](auto __a, auto __b) { return hypot(__a, __b); }, __x, __y); } else { // A simple solution for _Tp == float would be to cast to double and // simply calculate sqrt(x²+y²) as it can't over-/underflow anymore with // dp. It still needs the Annex F fixups though and isn't faster on // Skylake-AVX512 (not even for SSE and AVX vectors, and really bad for // AVX-512). using namespace __float_bitwise_operators; _V __absx = abs(__x); // no error _V __absy = abs(__y); // no error _V __hi = max(__absx, __absy); // no error _V __lo = min(__absy, __absx); // no error // round __hi down to the next power-of-2: _GLIBCXX_SIMD_USE_CONSTEXPR_API _V __inf(__infinity_v<_Tp>); #ifndef __FAST_MATH__ if constexpr (__have_neon && !__have_neon_a32) { // With ARMv7 NEON, we have no subnormals and must use slightly // different strategy const _V __hi_exp = __hi & __inf; _V __scale_back = __hi_exp; // For large exponents (max & max/2) the inversion comes too close // to subnormals. Subtract 3 from the exponent: where(__hi_exp > 1, __scale_back) = __hi_exp * _Tp(0.125); // Invert and adjust for the off-by-one error of inversion via xor: const _V __scale = (__scale_back ^ __inf) * _Tp(.5); const _V __h1 = __hi * __scale; const _V __l1 = __lo * __scale; _V __r = __scale_back * sqrt(__h1 * __h1 + __l1 * __l1); // Fix up hypot(0, 0) to not be NaN: where(__hi == 0, __r) = 0; return __r; } #endif #ifdef __FAST_MATH__ // With fast-math, ignore precision of subnormals and inputs from // __finite_max_v/2 to __finite_max_v. This removes all // branching/masking. if constexpr (true) #else if (_GLIBCXX_SIMD_IS_LIKELY(all_of(isnormal(__x)) && all_of(isnormal(__y)))) #endif { const _V __hi_exp = __hi & __inf; //((__hi + __hi) & __inf) ^ __inf almost works for computing //__scale, // except when (__hi + __hi) & __inf == __inf, in which case __scale // becomes 0 (should be min/2 instead) and thus loses the // information from __lo. #ifdef __FAST_MATH__ using _Ip = __int_for_sizeof_t<_Tp>; using _IV = rebind_simd_t<_Ip, _V>; const auto __as_int = __bit_cast<_IV>(__hi_exp); const _V __scale = __bit_cast<_V>(2 * __bit_cast<_Ip>(_Tp(1)) - __as_int); #else const _V __scale = (__hi_exp ^ __inf) * _Tp(.5); #endif _GLIBCXX_SIMD_USE_CONSTEXPR_API _V __mant_mask = __norm_min_v<_Tp> - __denorm_min_v<_Tp>; const _V __h1 = (__hi & __mant_mask) | _V(1); const _V __l1 = __lo * __scale; return __hi_exp * sqrt(__h1 * __h1 + __l1 * __l1); } else { // slower path to support subnormals // if __hi is subnormal, avoid scaling by inf & final mul by 0 // (which yields NaN) by using min() _V __scale = _V(1 / __norm_min_v<_Tp>); // invert exponent w/o error and w/o using the slow divider unit: // xor inverts the exponent but off by 1. Multiplication with .5 // adjusts for the discrepancy. where(__hi >= __norm_min_v<_Tp>, __scale) = ((__hi & __inf) ^ __inf) * _Tp(.5); // adjust final exponent for subnormal inputs _V __hi_exp = __norm_min_v<_Tp>; where(__hi >= __norm_min_v<_Tp>, __hi_exp) = __hi & __inf; // no error _V __h1 = __hi * __scale; // no error _V __l1 = __lo * __scale; // no error // sqrt(x²+y²) = e*sqrt((x/e)²+(y/e)²): // this ensures no overflow in the argument to sqrt _V __r = __hi_exp * sqrt(__h1 * __h1 + __l1 * __l1); #ifdef __STDC_IEC_559__ // fixup for Annex F requirements // the naive fixup goes like this: // // where(__l1 == 0, __r) = __hi; // where(isunordered(__x, __y), __r) = __quiet_NaN_v<_Tp>; // where(isinf(__absx) || isinf(__absy), __r) = __inf; // // The fixup can be prepared in parallel with the sqrt, requiring a // single blend step after hi_exp * sqrt, reducing latency and // throughput: _V __fixup = __hi; // __lo == 0 where(isunordered(__x, __y), __fixup) = __quiet_NaN_v<_Tp>; where(isinf(__absx) || isinf(__absy), __fixup) = __inf; where(!(__lo == 0 || isunordered(__x, __y) || (isinf(__absx) || isinf(__absy))), __fixup) = __r; __r = __fixup; #endif return __r; } } } template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_INTRINSIC simd<_Tp, _Abi> hypot(const simd<_Tp, _Abi>& __x, const simd<_Tp, _Abi>& __y) { return __hypot<conditional_t<__is_fixed_size_abi_v<_Abi>, const simd<_Tp, _Abi>&, simd<_Tp, _Abi>>>(__x, __y); } _GLIBCXX_SIMD_CVTING2(hypot) template <typename _VV> __remove_cvref_t<_VV> __hypot(_VV __x, _VV __y, _VV __z) { using _V = __remove_cvref_t<_VV>; using _Abi = typename _V::abi_type; using _Tp = typename _V::value_type; /* FIXME: enable after PR77776 is resolved if constexpr (_V::size() == 1) return std::hypot(_Tp(__x[0]), _Tp(__y[0]), _Tp(__z[0])); else */ if constexpr (__is_fixed_size_abi_v<_Abi> && _V::size() > 1) { return __fixed_size_apply<simd<_Tp, _Abi>>( [](auto __a, auto __b, auto __c) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return hypot(__a, __b, __c); }, __x, __y, __z); } else { using namespace __float_bitwise_operators; const _V __absx = abs(__x); // no error const _V __absy = abs(__y); // no error const _V __absz = abs(__z); // no error _V __hi = max(max(__absx, __absy), __absz); // no error _V __l0 = min(__absz, max(__absx, __absy)); // no error _V __l1 = min(__absy, __absx); // no error if constexpr (__digits_v<_Tp> == 64 && __max_exponent_v<_Tp> == 0x4000 && __min_exponent_v<_Tp> == -0x3FFD && _V::size() == 1) { // Seems like x87 fp80, where bit 63 is always 1 unless subnormal or // NaN. In this case the bit-tricks don't work, they require IEC559 // binary32 or binary64 format. #ifdef __STDC_IEC_559__ // fixup for Annex F requirements if (isinf(__absx[0]) || isinf(__absy[0]) || isinf(__absz[0])) return __infinity_v<_Tp>; else if (isunordered(__absx[0], __absy[0] + __absz[0])) return __quiet_NaN_v<_Tp>; else if (__l0[0] == 0 && __l1[0] == 0) return __hi; #endif _V __hi_exp = __hi; const _ULLong __tmp = 0x8000'0000'0000'0000ull; __builtin_memcpy(&__data(__hi_exp), &__tmp, 8); const _V __scale = 1 / __hi_exp; __hi *= __scale; __l0 *= __scale; __l1 *= __scale; return __hi_exp * sqrt((__l0 * __l0 + __l1 * __l1) + __hi * __hi); } else { // round __hi down to the next power-of-2: _GLIBCXX_SIMD_USE_CONSTEXPR_API _V __inf(__infinity_v<_Tp>); #ifndef __FAST_MATH__ if constexpr (_V::size() > 1 && __have_neon && !__have_neon_a32) { // With ARMv7 NEON, we have no subnormals and must use slightly // different strategy const _V __hi_exp = __hi & __inf; _V __scale_back = __hi_exp; // For large exponents (max & max/2) the inversion comes too // close to subnormals. Subtract 3 from the exponent: where(__hi_exp > 1, __scale_back) = __hi_exp * _Tp(0.125); // Invert and adjust for the off-by-one error of inversion via // xor: const _V __scale = (__scale_back ^ __inf) * _Tp(.5); const _V __h1 = __hi * __scale; __l0 *= __scale; __l1 *= __scale; _V __lo = __l0 * __l0 + __l1 * __l1; // add the two smaller values first asm("" : "+m"(__lo)); _V __r = __scale_back * sqrt(__h1 * __h1 + __lo); // Fix up hypot(0, 0, 0) to not be NaN: where(__hi == 0, __r) = 0; return __r; } #endif #ifdef __FAST_MATH__ // With fast-math, ignore precision of subnormals and inputs from // __finite_max_v/2 to __finite_max_v. This removes all // branching/masking. if constexpr (true) #else if (_GLIBCXX_SIMD_IS_LIKELY(all_of(isnormal(__x)) && all_of(isnormal(__y)) && all_of(isnormal(__z)))) #endif { const _V __hi_exp = __hi & __inf; //((__hi + __hi) & __inf) ^ __inf almost works for computing //__scale, except when (__hi + __hi) & __inf == __inf, in which // case __scale // becomes 0 (should be min/2 instead) and thus loses the // information from __lo. #ifdef __FAST_MATH__ using _Ip = __int_for_sizeof_t<_Tp>; using _IV = rebind_simd_t<_Ip, _V>; const auto __as_int = __bit_cast<_IV>(__hi_exp); const _V __scale = __bit_cast<_V>(2 * __bit_cast<_Ip>(_Tp(1)) - __as_int); #else const _V __scale = (__hi_exp ^ __inf) * _Tp(.5); #endif constexpr _Tp __mant_mask = __norm_min_v<_Tp> - __denorm_min_v<_Tp>; const _V __h1 = (__hi & _V(__mant_mask)) | _V(1); __l0 *= __scale; __l1 *= __scale; const _V __lo = __l0 * __l0 + __l1 * __l1; // add the two smaller values first return __hi_exp * sqrt(__lo + __h1 * __h1); } else { // slower path to support subnormals // if __hi is subnormal, avoid scaling by inf & final mul by 0 // (which yields NaN) by using min() _V __scale = _V(1 / __norm_min_v<_Tp>); // invert exponent w/o error and w/o using the slow divider // unit: xor inverts the exponent but off by 1. Multiplication // with .5 adjusts for the discrepancy. where(__hi >= __norm_min_v<_Tp>, __scale) = ((__hi & __inf) ^ __inf) * _Tp(.5); // adjust final exponent for subnormal inputs _V __hi_exp = __norm_min_v<_Tp>; where(__hi >= __norm_min_v<_Tp>, __hi_exp) = __hi & __inf; // no error _V __h1 = __hi * __scale; // no error __l0 *= __scale; // no error __l1 *= __scale; // no error _V __lo = __l0 * __l0 + __l1 * __l1; // add the two smaller values first _V __r = __hi_exp * sqrt(__lo + __h1 * __h1); #ifdef __STDC_IEC_559__ // fixup for Annex F requirements _V __fixup = __hi; // __lo == 0 // where(__lo == 0, __fixup) = __hi; where(isunordered(__x, __y + __z), __fixup) = __quiet_NaN_v<_Tp>; where(isinf(__absx) || isinf(__absy) || isinf(__absz), __fixup) = __inf; // Instead of __lo == 0, the following could depend on __h1² == // __h1² + __lo (i.e. __hi is so much larger than the other two // inputs that the result is exactly __hi). While this may // improve precision, it is likely to reduce efficiency if the // ISA has FMAs (because __h1² + __lo is an FMA, but the // intermediate // __h1² must be kept) where(!(__lo == 0 || isunordered(__x, __y + __z) || isinf(__absx) || isinf(__absy) || isinf(__absz)), __fixup) = __r; __r = __fixup; #endif return __r; } } } } template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_INTRINSIC simd<_Tp, _Abi> hypot(const simd<_Tp, _Abi>& __x, const simd<_Tp, _Abi>& __y, const simd<_Tp, _Abi>& __z) { return __hypot<conditional_t<__is_fixed_size_abi_v<_Abi>, const simd<_Tp, _Abi>&, simd<_Tp, _Abi>>>(__x, __y, __z); } _GLIBCXX_SIMD_CVTING3(hypot) _GLIBCXX_SIMD_MATH_CALL2_(pow, _Tp) _GLIBCXX_SIMD_MATH_CALL_(sqrt) _GLIBCXX_SIMD_MATH_CALL_(erf) _GLIBCXX_SIMD_MATH_CALL_(erfc) _GLIBCXX_SIMD_MATH_CALL_(lgamma) _GLIBCXX_SIMD_MATH_CALL_(tgamma) _GLIBCXX_SIMD_MATH_CALL_(ceil) _GLIBCXX_SIMD_MATH_CALL_(floor) _GLIBCXX_SIMD_MATH_CALL_(nearbyint) _GLIBCXX_SIMD_MATH_CALL_(rint) _GLIBCXX_SIMD_MATH_CALL_(lrint) _GLIBCXX_SIMD_MATH_CALL_(llrint) _GLIBCXX_SIMD_MATH_CALL_(round) _GLIBCXX_SIMD_MATH_CALL_(lround) _GLIBCXX_SIMD_MATH_CALL_(llround) _GLIBCXX_SIMD_MATH_CALL_(trunc) _GLIBCXX_SIMD_MATH_CALL2_(fmod, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(remainder, _Tp) _GLIBCXX_SIMD_MATH_CALL3_(remquo, _Tp, int*) template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> copysign(const simd<_Tp, _Abi>& __x, const simd<_Tp, _Abi>& __y) { if constexpr (simd_size_v<_Tp, _Abi> == 1) return std::copysign(__x[0], __y[0]); else if constexpr (is_same_v<_Tp, long double> && sizeof(_Tp) == 12) // Remove this case once __bit_cast is implemented via __builtin_bit_cast. // It is necessary, because __signmask below cannot be computed at compile // time. return simd<_Tp, _Abi>( [&](auto __i) { return std::copysign(__x[__i], __y[__i]); }); else { using _V = simd<_Tp, _Abi>; using namespace std::experimental::__float_bitwise_operators; _GLIBCXX_SIMD_USE_CONSTEXPR_API auto __signmask = _V(1) ^ _V(-1); return (__x & (__x ^ __signmask)) | (__y & __signmask); } } _GLIBCXX_SIMD_MATH_CALL2_(nextafter, _Tp) // not covered in [parallel.simd.math]: // _GLIBCXX_SIMD_MATH_CALL2_(nexttoward, long double) _GLIBCXX_SIMD_MATH_CALL2_(fdim, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(fmax, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(fmin, _Tp) _GLIBCXX_SIMD_MATH_CALL3_(fma, _Tp, _Tp) _GLIBCXX_SIMD_MATH_CALL_(fpclassify) _GLIBCXX_SIMD_MATH_CALL_(isfinite) // isnan and isinf require special treatment because old glibc may declare // `int isinf(double)`. template <typename _Tp, typename _Abi, typename..., typename _R = _Math_return_type_t<bool, _Tp, _Abi>> enable_if_t<is_floating_point_v<_Tp>, _R> isinf(simd<_Tp, _Abi> __x) { return {__private_init, _Abi::_SimdImpl::_S_isinf(__data(__x))}; } template <typename _Tp, typename _Abi, typename..., typename _R = _Math_return_type_t<bool, _Tp, _Abi>> enable_if_t<is_floating_point_v<_Tp>, _R> isnan(simd<_Tp, _Abi> __x) { return {__private_init, _Abi::_SimdImpl::_S_isnan(__data(__x))}; } _GLIBCXX_SIMD_MATH_CALL_(isnormal) template <typename..., typename _Tp, typename _Abi> simd_mask<_Tp, _Abi> signbit(simd<_Tp, _Abi> __x) { if constexpr (is_integral_v<_Tp>) { if constexpr (is_unsigned_v<_Tp>) return simd_mask<_Tp, _Abi>{}; // false else return __x < 0; } else return {__private_init, _Abi::_SimdImpl::_S_signbit(__data(__x))}; } _GLIBCXX_SIMD_MATH_CALL2_(isgreater, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(isgreaterequal, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(isless, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(islessequal, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(islessgreater, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(isunordered, _Tp) /* not covered in [parallel.simd.math] template <typename _Abi> __doublev<_Abi> nan(const char* tagp); template <typename _Abi> __floatv<_Abi> nanf(const char* tagp); template <typename _Abi> __ldoublev<_Abi> nanl(const char* tagp); template <typename _V> struct simd_div_t { _V quot, rem; }; template <typename _Abi> simd_div_t<_SCharv<_Abi>> div(_SCharv<_Abi> numer, _SCharv<_Abi> denom); template <typename _Abi> simd_div_t<__shortv<_Abi>> div(__shortv<_Abi> numer, __shortv<_Abi> denom); template <typename _Abi> simd_div_t<__intv<_Abi>> div(__intv<_Abi> numer, __intv<_Abi> denom); template <typename _Abi> simd_div_t<__longv<_Abi>> div(__longv<_Abi> numer, __longv<_Abi> denom); template <typename _Abi> simd_div_t<__llongv<_Abi>> div(__llongv<_Abi> numer, __llongv<_Abi> denom); */ // special math {{{ template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> assoc_laguerre(const fixed_size_simd<unsigned, simd_size_v<_Tp, _Abi>>& __n, const fixed_size_simd<unsigned, simd_size_v<_Tp, _Abi>>& __m, const simd<_Tp, _Abi>& __x) { return simd<_Tp, _Abi>([&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return std::assoc_laguerre(__n[__i], __m[__i], __x[__i]); }); } template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> assoc_legendre(const fixed_size_simd<unsigned, simd_size_v<_Tp, _Abi>>& __n, const fixed_size_simd<unsigned, simd_size_v<_Tp, _Abi>>& __m, const simd<_Tp, _Abi>& __x) { return simd<_Tp, _Abi>([&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return std::assoc_legendre(__n[__i], __m[__i], __x[__i]); }); } _GLIBCXX_SIMD_MATH_CALL2_(beta, _Tp) _GLIBCXX_SIMD_MATH_CALL_(comp_ellint_1) _GLIBCXX_SIMD_MATH_CALL_(comp_ellint_2) _GLIBCXX_SIMD_MATH_CALL2_(comp_ellint_3, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(cyl_bessel_i, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(cyl_bessel_j, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(cyl_bessel_k, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(cyl_neumann, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(ellint_1, _Tp) _GLIBCXX_SIMD_MATH_CALL2_(ellint_2, _Tp) _GLIBCXX_SIMD_MATH_CALL3_(ellint_3, _Tp, _Tp) _GLIBCXX_SIMD_MATH_CALL_(expint) template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> hermite(const fixed_size_simd<unsigned, simd_size_v<_Tp, _Abi>>& __n, const simd<_Tp, _Abi>& __x) { return simd<_Tp, _Abi>([&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return std::hermite(__n[__i], __x[__i]); }); } template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> laguerre(const fixed_size_simd<unsigned, simd_size_v<_Tp, _Abi>>& __n, const simd<_Tp, _Abi>& __x) { return simd<_Tp, _Abi>([&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return std::laguerre(__n[__i], __x[__i]); }); } template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> legendre(const fixed_size_simd<unsigned, simd_size_v<_Tp, _Abi>>& __n, const simd<_Tp, _Abi>& __x) { return simd<_Tp, _Abi>([&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return std::legendre(__n[__i], __x[__i]); }); } _GLIBCXX_SIMD_MATH_CALL_(riemann_zeta) template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> sph_bessel(const fixed_size_simd<unsigned, simd_size_v<_Tp, _Abi>>& __n, const simd<_Tp, _Abi>& __x) { return simd<_Tp, _Abi>([&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return std::sph_bessel(__n[__i], __x[__i]); }); } template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> sph_legendre(const fixed_size_simd<unsigned, simd_size_v<_Tp, _Abi>>& __l, const fixed_size_simd<unsigned, simd_size_v<_Tp, _Abi>>& __m, const simd<_Tp, _Abi>& theta) { return simd<_Tp, _Abi>([&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return std::assoc_legendre(__l[__i], __m[__i], theta[__i]); }); } template <typename _Tp, typename _Abi> enable_if_t<is_floating_point_v<_Tp>, simd<_Tp, _Abi>> sph_neumann(const fixed_size_simd<unsigned, simd_size_v<_Tp, _Abi>>& __n, const simd<_Tp, _Abi>& __x) { return simd<_Tp, _Abi>([&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return std::sph_neumann(__n[__i], __x[__i]); }); } // }}} #undef _GLIBCXX_SIMD_MATH_CALL_ #undef _GLIBCXX_SIMD_MATH_CALL2_ #undef _GLIBCXX_SIMD_MATH_CALL3_ _GLIBCXX_SIMD_END_NAMESPACE #endif // __cplusplus >= 201703L #endif // _GLIBCXX_EXPERIMENTAL_SIMD_MATH_H_ // vim: foldmethod=marker sw=2 ts=8 noet sts=2 // Internal macros for the simd implementation -*- C++ -*- // Copyright (C) 2020-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. #ifndef _GLIBCXX_EXPERIMENTAL_SIMD_DETAIL_H_ #define _GLIBCXX_EXPERIMENTAL_SIMD_DETAIL_H_ #if __cplusplus >= 201703L #include <cstddef> #include <cstdint> /// @cond undocumented #define _GLIBCXX_SIMD_BEGIN_NAMESPACE \ namespace std _GLIBCXX_VISIBILITY(default) \ { \ _GLIBCXX_BEGIN_NAMESPACE_VERSION \ namespace experimental { \ inline namespace parallelism_v2 { #define _GLIBCXX_SIMD_END_NAMESPACE \ } \ } \ _GLIBCXX_END_NAMESPACE_VERSION \ } // ISA extension detection. The following defines all the _GLIBCXX_SIMD_HAVE_XXX // macros ARM{{{ #if defined __ARM_NEON #define _GLIBCXX_SIMD_HAVE_NEON 1 #else #define _GLIBCXX_SIMD_HAVE_NEON 0 #endif #if defined __ARM_NEON && (__ARM_ARCH >= 8 || defined __aarch64__) #define _GLIBCXX_SIMD_HAVE_NEON_A32 1 #else #define _GLIBCXX_SIMD_HAVE_NEON_A32 0 #endif #if defined __ARM_NEON && defined __aarch64__ #define _GLIBCXX_SIMD_HAVE_NEON_A64 1 #else #define _GLIBCXX_SIMD_HAVE_NEON_A64 0 #endif //}}} // x86{{{ #ifdef __MMX__ #define _GLIBCXX_SIMD_HAVE_MMX 1 #else #define _GLIBCXX_SIMD_HAVE_MMX 0 #endif #if defined __SSE__ || defined __x86_64__ #define _GLIBCXX_SIMD_HAVE_SSE 1 #else #define _GLIBCXX_SIMD_HAVE_SSE 0 #endif #if defined __SSE2__ || defined __x86_64__ #define _GLIBCXX_SIMD_HAVE_SSE2 1 #else #define _GLIBCXX_SIMD_HAVE_SSE2 0 #endif #ifdef __SSE3__ #define _GLIBCXX_SIMD_HAVE_SSE3 1 #else #define _GLIBCXX_SIMD_HAVE_SSE3 0 #endif #ifdef __SSSE3__ #define _GLIBCXX_SIMD_HAVE_SSSE3 1 #else #define _GLIBCXX_SIMD_HAVE_SSSE3 0 #endif #ifdef __SSE4_1__ #define _GLIBCXX_SIMD_HAVE_SSE4_1 1 #else #define _GLIBCXX_SIMD_HAVE_SSE4_1 0 #endif #ifdef __SSE4_2__ #define _GLIBCXX_SIMD_HAVE_SSE4_2 1 #else #define _GLIBCXX_SIMD_HAVE_SSE4_2 0 #endif #ifdef __XOP__ #define _GLIBCXX_SIMD_HAVE_XOP 1 #else #define _GLIBCXX_SIMD_HAVE_XOP 0 #endif #ifdef __AVX__ #define _GLIBCXX_SIMD_HAVE_AVX 1 #else #define _GLIBCXX_SIMD_HAVE_AVX 0 #endif #ifdef __AVX2__ #define _GLIBCXX_SIMD_HAVE_AVX2 1 #else #define _GLIBCXX_SIMD_HAVE_AVX2 0 #endif #ifdef __BMI__ #define _GLIBCXX_SIMD_HAVE_BMI1 1 #else #define _GLIBCXX_SIMD_HAVE_BMI1 0 #endif #ifdef __BMI2__ #define _GLIBCXX_SIMD_HAVE_BMI2 1 #else #define _GLIBCXX_SIMD_HAVE_BMI2 0 #endif #ifdef __LZCNT__ #define _GLIBCXX_SIMD_HAVE_LZCNT 1 #else #define _GLIBCXX_SIMD_HAVE_LZCNT 0 #endif #ifdef __SSE4A__ #define _GLIBCXX_SIMD_HAVE_SSE4A 1 #else #define _GLIBCXX_SIMD_HAVE_SSE4A 0 #endif #ifdef __FMA__ #define _GLIBCXX_SIMD_HAVE_FMA 1 #else #define _GLIBCXX_SIMD_HAVE_FMA 0 #endif #ifdef __FMA4__ #define _GLIBCXX_SIMD_HAVE_FMA4 1 #else #define _GLIBCXX_SIMD_HAVE_FMA4 0 #endif #ifdef __F16C__ #define _GLIBCXX_SIMD_HAVE_F16C 1 #else #define _GLIBCXX_SIMD_HAVE_F16C 0 #endif #ifdef __POPCNT__ #define _GLIBCXX_SIMD_HAVE_POPCNT 1 #else #define _GLIBCXX_SIMD_HAVE_POPCNT 0 #endif #ifdef __AVX512F__ #define _GLIBCXX_SIMD_HAVE_AVX512F 1 #else #define _GLIBCXX_SIMD_HAVE_AVX512F 0 #endif #ifdef __AVX512DQ__ #define _GLIBCXX_SIMD_HAVE_AVX512DQ 1 #else #define _GLIBCXX_SIMD_HAVE_AVX512DQ 0 #endif #ifdef __AVX512VL__ #define _GLIBCXX_SIMD_HAVE_AVX512VL 1 #else #define _GLIBCXX_SIMD_HAVE_AVX512VL 0 #endif #ifdef __AVX512BW__ #define _GLIBCXX_SIMD_HAVE_AVX512BW 1 #else #define _GLIBCXX_SIMD_HAVE_AVX512BW 0 #endif #if _GLIBCXX_SIMD_HAVE_SSE #define _GLIBCXX_SIMD_HAVE_SSE_ABI 1 #else #define _GLIBCXX_SIMD_HAVE_SSE_ABI 0 #endif #if _GLIBCXX_SIMD_HAVE_SSE2 #define _GLIBCXX_SIMD_HAVE_FULL_SSE_ABI 1 #else #define _GLIBCXX_SIMD_HAVE_FULL_SSE_ABI 0 #endif #if _GLIBCXX_SIMD_HAVE_AVX #define _GLIBCXX_SIMD_HAVE_AVX_ABI 1 #else #define _GLIBCXX_SIMD_HAVE_AVX_ABI 0 #endif #if _GLIBCXX_SIMD_HAVE_AVX2 #define _GLIBCXX_SIMD_HAVE_FULL_AVX_ABI 1 #else #define _GLIBCXX_SIMD_HAVE_FULL_AVX_ABI 0 #endif #if _GLIBCXX_SIMD_HAVE_AVX512F #define _GLIBCXX_SIMD_HAVE_AVX512_ABI 1 #else #define _GLIBCXX_SIMD_HAVE_AVX512_ABI 0 #endif #if _GLIBCXX_SIMD_HAVE_AVX512BW #define _GLIBCXX_SIMD_HAVE_FULL_AVX512_ABI 1 #else #define _GLIBCXX_SIMD_HAVE_FULL_AVX512_ABI 0 #endif #if defined __x86_64__ && !_GLIBCXX_SIMD_HAVE_SSE2 #error "Use of SSE2 is required on AMD64" #endif //}}} #ifdef __clang__ #define _GLIBCXX_SIMD_NORMAL_MATH #define _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA #else #define _GLIBCXX_SIMD_NORMAL_MATH \ [[__gnu__::__optimize__("finite-math-only,no-signed-zeros")]] #define _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA __attribute__((__always_inline__)) #endif #define _GLIBCXX_SIMD_NEVER_INLINE [[__gnu__::__noinline__]] #define _GLIBCXX_SIMD_INTRINSIC \ [[__gnu__::__always_inline__, __gnu__::__artificial__]] inline #define _GLIBCXX_SIMD_ALWAYS_INLINE [[__gnu__::__always_inline__]] inline #define _GLIBCXX_SIMD_IS_UNLIKELY(__x) __builtin_expect(__x, 0) #define _GLIBCXX_SIMD_IS_LIKELY(__x) __builtin_expect(__x, 1) #if __STRICT_ANSI__ || defined __clang__ #define _GLIBCXX_SIMD_CONSTEXPR #define _GLIBCXX_SIMD_USE_CONSTEXPR_API const #else #define _GLIBCXX_SIMD_CONSTEXPR constexpr #define _GLIBCXX_SIMD_USE_CONSTEXPR_API constexpr #endif #if defined __clang__ #define _GLIBCXX_SIMD_USE_CONSTEXPR const #else #define _GLIBCXX_SIMD_USE_CONSTEXPR constexpr #endif #define _GLIBCXX_SIMD_LIST_BINARY(__macro) __macro(|) __macro(&) __macro(^) #define _GLIBCXX_SIMD_LIST_SHIFTS(__macro) __macro(<<) __macro(>>) #define _GLIBCXX_SIMD_LIST_ARITHMETICS(__macro) \ __macro(+) __macro(-) __macro(*) __macro(/) __macro(%) #define _GLIBCXX_SIMD_ALL_BINARY(__macro) \ _GLIBCXX_SIMD_LIST_BINARY(__macro) static_assert(true) #define _GLIBCXX_SIMD_ALL_SHIFTS(__macro) \ _GLIBCXX_SIMD_LIST_SHIFTS(__macro) static_assert(true) #define _GLIBCXX_SIMD_ALL_ARITHMETICS(__macro) \ _GLIBCXX_SIMD_LIST_ARITHMETICS(__macro) static_assert(true) #ifdef _GLIBCXX_SIMD_NO_ALWAYS_INLINE #undef _GLIBCXX_SIMD_ALWAYS_INLINE #define _GLIBCXX_SIMD_ALWAYS_INLINE inline #undef _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA #define _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA #undef _GLIBCXX_SIMD_INTRINSIC #define _GLIBCXX_SIMD_INTRINSIC inline #endif #if _GLIBCXX_SIMD_HAVE_SSE || _GLIBCXX_SIMD_HAVE_MMX #define _GLIBCXX_SIMD_X86INTRIN 1 #else #define _GLIBCXX_SIMD_X86INTRIN 0 #endif // workaround macros {{{ // use aliasing loads to help GCC understand the data accesses better // This also seems to hide a miscompilation on swap(x[i], x[i + 1]) with // fixed_size_simd<float, 16> x. #define _GLIBCXX_SIMD_USE_ALIASING_LOADS 1 // vector conversions on x86 not optimized: #if _GLIBCXX_SIMD_X86INTRIN #define _GLIBCXX_SIMD_WORKAROUND_PR85048 1 #endif // integer division not optimized #ifndef __clang__ #define _GLIBCXX_SIMD_WORKAROUND_PR90993 1 #endif // very bad codegen for extraction and concatenation of 128/256 "subregisters" // with sizeof(element type) < 8: https://godbolt.org/g/mqUsgM #if _GLIBCXX_SIMD_X86INTRIN #define _GLIBCXX_SIMD_WORKAROUND_XXX_1 1 #endif // bad codegen for 8 Byte memcpy to __vector_type_t<char, 16> #define _GLIBCXX_SIMD_WORKAROUND_PR90424 1 // bad codegen for zero-extend using simple concat(__x, 0) #if _GLIBCXX_SIMD_X86INTRIN #define _GLIBCXX_SIMD_WORKAROUND_XXX_3 1 #endif // https://github.com/cplusplus/parallelism-ts/issues/65 (incorrect return type // of static_simd_cast) #define _GLIBCXX_SIMD_FIX_P2TS_ISSUE65 1 // https://github.com/cplusplus/parallelism-ts/issues/66 (incorrect SFINAE // constraint on (static)_simd_cast) #define _GLIBCXX_SIMD_FIX_P2TS_ISSUE66 1 // }}} /// @endcond #endif // __cplusplus >= 201703L #endif // _GLIBCXX_EXPERIMENTAL_SIMD_DETAIL_H_ // vim: foldmethod=marker // Generic simd conversions -*- C++ -*- // Copyright (C) 2020-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. #ifndef _GLIBCXX_EXPERIMENTAL_SIMD_CONVERTER_H_ #define _GLIBCXX_EXPERIMENTAL_SIMD_CONVERTER_H_ #if __cplusplus >= 201703L _GLIBCXX_SIMD_BEGIN_NAMESPACE // _SimdConverter scalar -> scalar {{{ template <typename _From, typename _To> struct _SimdConverter<_From, simd_abi::scalar, _To, simd_abi::scalar, enable_if_t<!is_same_v<_From, _To>>> { _GLIBCXX_SIMD_INTRINSIC constexpr _To operator()(_From __a) const noexcept { return static_cast<_To>(__a); } }; // }}} // _SimdConverter scalar -> "native" {{{ template <typename _From, typename _To, typename _Abi> struct _SimdConverter<_From, simd_abi::scalar, _To, _Abi, enable_if_t<!is_same_v<_Abi, simd_abi::scalar>>> { using _Ret = typename _Abi::template __traits<_To>::_SimdMember; template <typename... _More> _GLIBCXX_SIMD_INTRINSIC constexpr _Ret operator()(_From __a, _More... __more) const noexcept { static_assert(sizeof...(_More) + 1 == _Abi::template _S_size<_To>); static_assert(conjunction_v<is_same<_From, _More>...>); return __make_vector<_To>(__a, __more...); } }; // }}} // _SimdConverter "native 1" -> "native 2" {{{ template <typename _From, typename _To, typename _AFrom, typename _ATo> struct _SimdConverter< _From, _AFrom, _To, _ATo, enable_if_t<!disjunction_v< __is_fixed_size_abi<_AFrom>, __is_fixed_size_abi<_ATo>, is_same<_AFrom, simd_abi::scalar>, is_same<_ATo, simd_abi::scalar>, conjunction<is_same<_From, _To>, is_same<_AFrom, _ATo>>>>> { using _Arg = typename _AFrom::template __traits<_From>::_SimdMember; using _Ret = typename _ATo::template __traits<_To>::_SimdMember; using _V = __vector_type_t<_To, simd_size_v<_To, _ATo>>; template <typename... _More> _GLIBCXX_SIMD_INTRINSIC constexpr _Ret operator()(_Arg __a, _More... __more) const noexcept { return __vector_convert<_V>(__a, __more...); } }; // }}} // _SimdConverter scalar -> fixed_size<1> {{{1 template <typename _From, typename _To> struct _SimdConverter<_From, simd_abi::scalar, _To, simd_abi::fixed_size<1>, void> { _GLIBCXX_SIMD_INTRINSIC constexpr _SimdTuple<_To, simd_abi::scalar> operator()(_From __x) const noexcept { return {static_cast<_To>(__x)}; } }; // _SimdConverter fixed_size<1> -> scalar {{{1 template <typename _From, typename _To> struct _SimdConverter<_From, simd_abi::fixed_size<1>, _To, simd_abi::scalar, void> { _GLIBCXX_SIMD_INTRINSIC constexpr _To operator()(_SimdTuple<_From, simd_abi::scalar> __x) const noexcept { return {static_cast<_To>(__x.first)}; } }; // _SimdConverter fixed_size<_Np> -> fixed_size<_Np> {{{1 template <typename _From, typename _To, int _Np> struct _SimdConverter<_From, simd_abi::fixed_size<_Np>, _To, simd_abi::fixed_size<_Np>, enable_if_t<!is_same_v<_From, _To>>> { using _Ret = __fixed_size_storage_t<_To, _Np>; using _Arg = __fixed_size_storage_t<_From, _Np>; _GLIBCXX_SIMD_INTRINSIC constexpr _Ret operator()(const _Arg& __x) const noexcept { if constexpr (is_same_v<_From, _To>) return __x; // special case (optimize) int signedness casts else if constexpr (sizeof(_From) == sizeof(_To) && is_integral_v<_From> && is_integral_v<_To>) return __bit_cast<_Ret>(__x); // special case if all ABI tags in _Ret are scalar else if constexpr (__is_scalar_abi<typename _Ret::_FirstAbi>()) { return __call_with_subscripts( __x, make_index_sequence<_Np>(), [](auto... __values) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA -> _Ret { return __make_simd_tuple<_To, decltype((void) __values, simd_abi::scalar())...>( static_cast<_To>(__values)...); }); } // from one vector to one vector else if constexpr (_Arg::_S_first_size == _Ret::_S_first_size) { _SimdConverter<_From, typename _Arg::_FirstAbi, _To, typename _Ret::_FirstAbi> __native_cvt; if constexpr (_Arg::_S_tuple_size == 1) return {__native_cvt(__x.first)}; else { constexpr size_t _NRemain = _Np - _Arg::_S_first_size; _SimdConverter<_From, simd_abi::fixed_size<_NRemain>, _To, simd_abi::fixed_size<_NRemain>> __remainder_cvt; return {__native_cvt(__x.first), __remainder_cvt(__x.second)}; } } // from one vector to multiple vectors else if constexpr (_Arg::_S_first_size > _Ret::_S_first_size) { const auto __multiple_return_chunks = __convert_all<__vector_type_t<_To, _Ret::_S_first_size>>( __x.first); constexpr auto __converted = __multiple_return_chunks.size() * _Ret::_FirstAbi::template _S_size<_To>; constexpr auto __remaining = _Np - __converted; if constexpr (_Arg::_S_tuple_size == 1 && __remaining == 0) return __to_simd_tuple<_To, _Np>(__multiple_return_chunks); else if constexpr (_Arg::_S_tuple_size == 1) { // e.g. <int, 3> -> <double, 2, 1> or <short, 7> -> <double, 4, 2, // 1> using _RetRem = __remove_cvref_t<decltype(__simd_tuple_pop_front<__converted>( _Ret()))>; const auto __return_chunks2 = __convert_all<__vector_type_t<_To, _RetRem::_S_first_size>, 0, __converted>(__x.first); constexpr auto __converted2 = __converted + __return_chunks2.size() * _RetRem::_S_first_size; if constexpr (__converted2 == _Np) return __to_simd_tuple<_To, _Np>(__multiple_return_chunks, __return_chunks2); else { using _RetRem2 = __remove_cvref_t< decltype(__simd_tuple_pop_front<__return_chunks2.size() * _RetRem::_S_first_size>( _RetRem()))>; const auto __return_chunks3 = __convert_all< __vector_type_t<_To, _RetRem2::_S_first_size>, 0, __converted2>(__x.first); constexpr auto __converted3 = __converted2 + __return_chunks3.size() * _RetRem2::_S_first_size; if constexpr (__converted3 == _Np) return __to_simd_tuple<_To, _Np>(__multiple_return_chunks, __return_chunks2, __return_chunks3); else { using _RetRem3 = __remove_cvref_t<decltype(__simd_tuple_pop_front< __return_chunks3.size() * _RetRem2::_S_first_size>( _RetRem2()))>; const auto __return_chunks4 = __convert_all< __vector_type_t<_To, _RetRem3::_S_first_size>, 0, __converted3>(__x.first); constexpr auto __converted4 = __converted3 + __return_chunks4.size() * _RetRem3::_S_first_size; if constexpr (__converted4 == _Np) return __to_simd_tuple<_To, _Np>( __multiple_return_chunks, __return_chunks2, __return_chunks3, __return_chunks4); else __assert_unreachable<_To>(); } } } else { constexpr size_t _NRemain = _Np - _Arg::_S_first_size; _SimdConverter<_From, simd_abi::fixed_size<_NRemain>, _To, simd_abi::fixed_size<_NRemain>> __remainder_cvt; return __simd_tuple_concat( __to_simd_tuple<_To, _Arg::_S_first_size>( __multiple_return_chunks), __remainder_cvt(__x.second)); } } // from multiple vectors to one vector // _Arg::_S_first_size < _Ret::_S_first_size // a) heterogeneous input at the end of the tuple (possible with partial // native registers in _Ret) else if constexpr (_Ret::_S_tuple_size == 1 && _Np % _Arg::_S_first_size != 0) { static_assert(_Ret::_FirstAbi::template _S_is_partial<_To>); return _Ret{__generate_from_n_evaluations< _Np, typename _VectorTraits<typename _Ret::_FirstType>::type>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return static_cast<_To>(__x[__i]); })}; } else { static_assert(_Arg::_S_tuple_size > 1); constexpr auto __n = __div_roundup(_Ret::_S_first_size, _Arg::_S_first_size); return __call_with_n_evaluations<__n>( [&__x](auto... __uncvted) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { // assuming _Arg Abi tags for all __i are _Arg::_FirstAbi _SimdConverter<_From, typename _Arg::_FirstAbi, _To, typename _Ret::_FirstAbi> __native_cvt; if constexpr (_Ret::_S_tuple_size == 1) return _Ret{__native_cvt(__uncvted...)}; else return _Ret{ __native_cvt(__uncvted...), _SimdConverter< _From, simd_abi::fixed_size<_Np - _Ret::_S_first_size>, _To, simd_abi::fixed_size<_Np - _Ret::_S_first_size>>()( __simd_tuple_pop_front<_Ret::_S_first_size>(__x))}; }, [&__x](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __get_tuple_at<__i>(__x); }); } } }; // _SimdConverter "native" -> fixed_size<_Np> {{{1 // i.e. 1 register to ? registers template <typename _From, typename _Ap, typename _To, int _Np> struct _SimdConverter<_From, _Ap, _To, simd_abi::fixed_size<_Np>, enable_if_t<!__is_fixed_size_abi_v<_Ap>>> { static_assert( _Np == simd_size_v<_From, _Ap>, "_SimdConverter to fixed_size only works for equal element counts"); using _Ret = __fixed_size_storage_t<_To, _Np>; _GLIBCXX_SIMD_INTRINSIC constexpr _Ret operator()(typename _SimdTraits<_From, _Ap>::_SimdMember __x) const noexcept { if constexpr (_Ret::_S_tuple_size == 1) return {__vector_convert<typename _Ret::_FirstType::_BuiltinType>(__x)}; else { using _FixedNp = simd_abi::fixed_size<_Np>; _SimdConverter<_From, _FixedNp, _To, _FixedNp> __fixed_cvt; using _FromFixedStorage = __fixed_size_storage_t<_From, _Np>; if constexpr (_FromFixedStorage::_S_tuple_size == 1) return __fixed_cvt(_FromFixedStorage{__x}); else if constexpr (_FromFixedStorage::_S_tuple_size == 2) { _FromFixedStorage __tmp; static_assert(sizeof(__tmp) <= sizeof(__x)); __builtin_memcpy(&__tmp.first, &__x, sizeof(__tmp.first)); __builtin_memcpy(&__tmp.second.first, reinterpret_cast<const char*>(&__x) + sizeof(__tmp.first), sizeof(__tmp.second.first)); return __fixed_cvt(__tmp); } else __assert_unreachable<_From>(); } } }; // _SimdConverter fixed_size<_Np> -> "native" {{{1 // i.e. ? register to 1 registers template <typename _From, int _Np, typename _To, typename _Ap> struct _SimdConverter<_From, simd_abi::fixed_size<_Np>, _To, _Ap, enable_if_t<!__is_fixed_size_abi_v<_Ap>>> { static_assert( _Np == simd_size_v<_To, _Ap>, "_SimdConverter to fixed_size only works for equal element counts"); using _Arg = __fixed_size_storage_t<_From, _Np>; _GLIBCXX_SIMD_INTRINSIC constexpr typename _SimdTraits<_To, _Ap>::_SimdMember operator()(_Arg __x) const noexcept { if constexpr (_Arg::_S_tuple_size == 1) return __vector_convert<__vector_type_t<_To, _Np>>(__x.first); else if constexpr (_Arg::_S_is_homogeneous) return __call_with_n_evaluations<_Arg::_S_tuple_size>( [](auto... __members) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { if constexpr ((is_convertible_v<decltype(__members), _To> && ...)) return __vector_type_t<_To, _Np>{static_cast<_To>(__members)...}; else return __vector_convert<__vector_type_t<_To, _Np>>(__members...); }, [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __get_tuple_at<__i>(__x); }); else if constexpr (__fixed_size_storage_t<_To, _Np>::_S_tuple_size == 1) { _SimdConverter<_From, simd_abi::fixed_size<_Np>, _To, simd_abi::fixed_size<_Np>> __fixed_cvt; return __fixed_cvt(__x).first; } else { const _SimdWrapper<_From, _Np> __xv = __generate_from_n_evaluations<_Np, __vector_type_t<_From, _Np>>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x[__i]; }); return __vector_convert<__vector_type_t<_To, _Np>>(__xv); } } }; // }}}1 _GLIBCXX_SIMD_END_NAMESPACE #endif // __cplusplus >= 201703L #endif // _GLIBCXX_EXPERIMENTAL_SIMD_CONVERTER_H_ // vim: foldmethod=marker sw=2 noet ts=8 sts=2 tw=80 // Class filesystem::path -*- C++ -*- // Copyright (C) 2014-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/bits/fs_path.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{experimental/filesystem} */ #ifndef _GLIBCXX_EXPERIMENTAL_FS_PATH_H #define _GLIBCXX_EXPERIMENTAL_FS_PATH_H 1 #if __cplusplus < 201103L # include <bits/c++0x_warning.h> #else #include <utility> #include <type_traits> #include <vector> #include <locale> #include <iosfwd> #include <codecvt> #include <system_error> #include <bits/stl_algobase.h> #include <bits/quoted_string.h> #include <bits/locale_conv.h> #if __cplusplus == 201402L # include <experimental/string_view> #endif #if defined(_WIN32) && !defined(__CYGWIN__) # define _GLIBCXX_FILESYSTEM_IS_WINDOWS 1 # include <algorithm> #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { namespace filesystem { inline namespace v1 { _GLIBCXX_BEGIN_NAMESPACE_CXX11 #if __cplusplus == 201402L using std::experimental::basic_string_view; #elif __cplusplus > 201402L using std::basic_string_view; #endif /// @cond undocumented namespace __detail { /** @addtogroup filesystem-ts * @{ */ template<typename _CharT, typename _Ch = typename remove_const<_CharT>::type> using __is_encoded_char = __or_<is_same<_Ch, char>, is_same<_Ch, wchar_t>, #ifdef _GLIBCXX_USE_CHAR8_T is_same<_Ch, char8_t>, #endif is_same<_Ch, char16_t>, is_same<_Ch, char32_t>>; template<typename _Iter, typename _Iter_traits = std::iterator_traits<_Iter>> using __is_path_iter_src = __and_<__is_encoded_char<typename _Iter_traits::value_type>, std::is_base_of<std::input_iterator_tag, typename _Iter_traits::iterator_category>>; template<typename _Iter> static __is_path_iter_src<_Iter> __is_path_src(_Iter, int); template<typename _CharT, typename _Traits, typename _Alloc> static __is_encoded_char<_CharT> __is_path_src(const basic_string<_CharT, _Traits, _Alloc>&, int); #if __cplusplus >= 201402L template<typename _CharT, typename _Traits> static __is_encoded_char<_CharT> __is_path_src(const basic_string_view<_CharT, _Traits>&, int); #endif template<typename _Unknown> static std::false_type __is_path_src(const _Unknown&, ...); template<typename _Tp1, typename _Tp2> struct __constructible_from; template<typename _Iter> struct __constructible_from<_Iter, _Iter> : __is_path_iter_src<_Iter> { }; template<typename _Source> struct __constructible_from<_Source, void> : decltype(__is_path_src(std::declval<const _Source&>(), 0)) { }; template<typename _Tp1, typename _Tp2 = void, typename _Tp1_nocv = typename remove_cv<_Tp1>::type, typename _Tp1_noptr = typename remove_pointer<_Tp1>::type> using _Path = typename std::enable_if<__and_<__not_<is_same<_Tp1_nocv, path>>, __not_<is_void<_Tp1_noptr>>, __constructible_from<_Tp1, _Tp2>>::value, path>::type; template<typename _Source> inline _Source _S_range_begin(_Source __begin) { return __begin; } struct __nul_terminated { }; template<typename _Source> inline __nul_terminated _S_range_end(_Source) { return {}; } template<typename _CharT, typename _Traits, typename _Alloc> inline const _CharT* _S_range_begin(const basic_string<_CharT, _Traits, _Alloc>& __str) { return __str.data(); } template<typename _CharT, typename _Traits, typename _Alloc> inline const _CharT* _S_range_end(const basic_string<_CharT, _Traits, _Alloc>& __str) { return __str.data() + __str.size(); } #if __cplusplus >= 201402L template<typename _CharT, typename _Traits> inline const _CharT* _S_range_begin(const basic_string_view<_CharT, _Traits>& __str) { return __str.data(); } template<typename _CharT, typename _Traits> inline const _CharT* _S_range_end(const basic_string_view<_CharT, _Traits>& __str) { return __str.data() + __str.size(); } #endif template<typename _Tp, typename _Iter = decltype(_S_range_begin(std::declval<_Tp>())), typename _Val = typename std::iterator_traits<_Iter>::value_type, typename _UnqualVal = typename std::remove_const<_Val>::type> using __value_type_is_char = typename std::enable_if< std::is_same<_UnqualVal, char>::value, _UnqualVal>::type; template<typename _Tp, typename _Iter = decltype(_S_range_begin(std::declval<_Tp>())), typename _Val = typename std::iterator_traits<_Iter>::value_type, typename _UnqualVal = typename std::remove_const<_Val>::type> using __value_type_is_char_or_char8_t = typename std::enable_if< __or_< std::is_same<_UnqualVal, char> #ifdef _GLIBCXX_USE_CHAR8_T ,std::is_same<_UnqualVal, char8_t> #endif >::value, _UnqualVal>::type; /// @} group filesystem-ts } // namespace __detail /// @endcond /** @addtogroup filesystem-ts * @{ */ /// A filesystem path. /// @ingroup filesystem-ts class path { public: #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS typedef wchar_t value_type; static constexpr value_type preferred_separator = L'\\'; #else typedef char value_type; static constexpr value_type preferred_separator = '/'; #endif typedef std::basic_string<value_type> string_type; // constructors and destructor path() noexcept { } path(const path& __p) = default; path(path&& __p) noexcept : _M_pathname(std::move(__p._M_pathname)), _M_type(__p._M_type) { if (_M_type == _Type::_Multi) _M_split_cmpts(); __p.clear(); } path(string_type&& __source) : _M_pathname(std::move(__source)) { _M_split_cmpts(); } template<typename _Source, typename _Require = __detail::_Path<_Source>> path(_Source const& __source) : _M_pathname(_S_convert(__detail::_S_range_begin(__source), __detail::_S_range_end(__source))) { _M_split_cmpts(); } template<typename _InputIterator, typename _Require = __detail::_Path<_InputIterator, _InputIterator>> path(_InputIterator __first, _InputIterator __last) : _M_pathname(_S_convert(__first, __last)) { _M_split_cmpts(); } template<typename _Source, typename _Require = __detail::_Path<_Source>, typename _Require2 = __detail::__value_type_is_char<_Source>> path(_Source const& __source, const locale& __loc) : _M_pathname(_S_convert_loc(__detail::_S_range_begin(__source), __detail::_S_range_end(__source), __loc)) { _M_split_cmpts(); } template<typename _InputIterator, typename _Require = __detail::_Path<_InputIterator, _InputIterator>, typename _Require2 = __detail::__value_type_is_char<_InputIterator>> path(_InputIterator __first, _InputIterator __last, const locale& __loc) : _M_pathname(_S_convert_loc(__first, __last, __loc)) { _M_split_cmpts(); } ~path() = default; // assignments path& operator=(const path& __p) = default; path& operator=(path&& __p) noexcept; path& operator=(string_type&& __source); path& assign(string_type&& __source); template<typename _Source> __detail::_Path<_Source>& operator=(_Source const& __source) { return *this = path(__source); } template<typename _Source> __detail::_Path<_Source>& assign(_Source const& __source) { return *this = path(__source); } template<typename _InputIterator> __detail::_Path<_InputIterator, _InputIterator>& assign(_InputIterator __first, _InputIterator __last) { return *this = path(__first, __last); } // appends path& operator/=(const path& __p) { return _M_append(__p._M_pathname); } template<typename _Source> __detail::_Path<_Source>& operator/=(_Source const& __source) { return append(__source); } template<typename _Source> __detail::_Path<_Source>& append(_Source const& __source) { return _M_append(_S_convert(__detail::_S_range_begin(__source), __detail::_S_range_end(__source))); } template<typename _InputIterator> __detail::_Path<_InputIterator, _InputIterator>& append(_InputIterator __first, _InputIterator __last) { return _M_append(_S_convert(__first, __last)); } // concatenation path& operator+=(const path& __x); path& operator+=(const string_type& __x); path& operator+=(const value_type* __x); path& operator+=(value_type __x); #if __cplusplus >= 201402L path& operator+=(basic_string_view<value_type> __x); #endif template<typename _Source> __detail::_Path<_Source>& operator+=(_Source const& __x) { return concat(__x); } template<typename _CharT> __detail::_Path<_CharT*, _CharT*>& operator+=(_CharT __x); template<typename _Source> __detail::_Path<_Source>& concat(_Source const& __x) { return *this += _S_convert(__detail::_S_range_begin(__x), __detail::_S_range_end(__x)); } template<typename _InputIterator> __detail::_Path<_InputIterator, _InputIterator>& concat(_InputIterator __first, _InputIterator __last) { return *this += _S_convert(__first, __last); } // modifiers void clear() noexcept { _M_pathname.clear(); _M_split_cmpts(); } path& make_preferred(); path& remove_filename(); path& replace_filename(const path& __replacement); path& replace_extension(const path& __replacement = path()); void swap(path& __rhs) noexcept; // native format observers const string_type& native() const noexcept { return _M_pathname; } const value_type* c_str() const noexcept { return _M_pathname.c_str(); } operator string_type() const { return _M_pathname; } template<typename _CharT, typename _Traits = std::char_traits<_CharT>, typename _Allocator = std::allocator<_CharT>> std::basic_string<_CharT, _Traits, _Allocator> string(const _Allocator& __a = _Allocator()) const; std::string string() const; #if _GLIBCXX_USE_WCHAR_T std::wstring wstring() const; #endif #ifdef _GLIBCXX_USE_CHAR8_T __attribute__((__abi_tag__("__u8"))) std::u8string u8string() const; #else std::string u8string() const; #endif // _GLIBCXX_USE_CHAR8_T std::u16string u16string() const; std::u32string u32string() const; // generic format observers template<typename _CharT, typename _Traits = std::char_traits<_CharT>, typename _Allocator = std::allocator<_CharT>> std::basic_string<_CharT, _Traits, _Allocator> generic_string(const _Allocator& __a = _Allocator()) const; std::string generic_string() const; #if _GLIBCXX_USE_WCHAR_T std::wstring generic_wstring() const; #endif #ifdef _GLIBCXX_USE_CHAR8_T __attribute__((__abi_tag__("__u8"))) std::u8string generic_u8string() const; #else std::string generic_u8string() const; #endif // _GLIBCXX_USE_CHAR8_T std::u16string generic_u16string() const; std::u32string generic_u32string() const; // compare int compare(const path& __p) const noexcept; int compare(const string_type& __s) const; int compare(const value_type* __s) const; #if __cplusplus >= 201402L int compare(const basic_string_view<value_type> __s) const; #endif // decomposition path root_name() const; path root_directory() const; path root_path() const; path relative_path() const; path parent_path() const; path filename() const; path stem() const; path extension() const; // query _GLIBCXX_NODISCARD bool empty() const noexcept { return _M_pathname.empty(); } bool has_root_name() const; bool has_root_directory() const; bool has_root_path() const; bool has_relative_path() const; bool has_parent_path() const; bool has_filename() const; bool has_stem() const; bool has_extension() const; bool is_absolute() const; bool is_relative() const { return !is_absolute(); } // iterators class iterator; typedef iterator const_iterator; iterator begin() const; iterator end() const; /// @cond undocumented // Create a basic_string by reading until a null character. template<typename _InputIterator, typename _Traits = std::iterator_traits<_InputIterator>, typename _CharT = typename std::remove_cv<typename _Traits::value_type>::type> static std::basic_string<_CharT> _S_string_from_iter(_InputIterator __source) { std::basic_string<_CharT> __str; for (_CharT __ch = *__source; __ch != _CharT(); __ch = *++__source) __str.push_back(__ch); return __str; } /// @endcond private: enum class _Type : unsigned char { _Multi, _Root_name, _Root_dir, _Filename }; path(string_type __str, _Type __type) : _M_pathname(__str), _M_type(__type) { __glibcxx_assert(!empty()); __glibcxx_assert(_M_type != _Type::_Multi); } enum class _Split { _Stem, _Extension }; path& _M_append(const string_type& __str) { if (!_M_pathname.empty() && !_S_is_dir_sep(_M_pathname.back()) && !__str.empty() && !_S_is_dir_sep(__str.front())) _M_pathname += preferred_separator; _M_pathname += __str; _M_split_cmpts(); return *this; } pair<const string_type*, size_t> _M_find_extension() const; template<typename _CharT> struct _Cvt; static string_type _S_convert(value_type* __src, __detail::__nul_terminated) { return string_type(__src); } static string_type _S_convert(const value_type* __src, __detail::__nul_terminated) { return string_type(__src); } template<typename _Iter> static string_type _S_convert(_Iter __first, _Iter __last) { using __value_type = typename std::iterator_traits<_Iter>::value_type; return _Cvt<typename remove_cv<__value_type>::type>:: _S_convert(__first, __last); } template<typename _InputIterator> static string_type _S_convert(_InputIterator __src, __detail::__nul_terminated) { auto __s = _S_string_from_iter(__src); return _S_convert(__s.c_str(), __s.c_str() + __s.size()); } static string_type _S_convert_loc(const char* __first, const char* __last, const std::locale& __loc); static string_type _S_convert_loc(char* __first, char* __last, const std::locale& __loc) { return _S_convert_loc(const_cast<const char*>(__first), const_cast<const char*>(__last), __loc); } template<typename _Iter> static string_type _S_convert_loc(_Iter __first, _Iter __last, const std::locale& __loc) { const std::string __str(__first, __last); return _S_convert_loc(__str.data(), __str.data()+__str.size(), __loc); } template<typename _InputIterator> static string_type _S_convert_loc(_InputIterator __src, __detail::__nul_terminated, const std::locale& __loc) { const std::string __s = _S_string_from_iter(__src); return _S_convert_loc(__s.data(), __s.data() + __s.size(), __loc); } static bool _S_is_dir_sep(value_type __ch) { #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS return __ch == L'/' || __ch == preferred_separator; #else return __ch == '/'; #endif } void _M_split_cmpts(); void _M_trim(); void _M_add_root_name(size_t __n); void _M_add_root_dir(size_t __pos); void _M_add_filename(size_t __pos, size_t __n); string_type _M_pathname; struct _Cmpt; using _List = _GLIBCXX_STD_C::vector<_Cmpt>; _List _M_cmpts; // empty unless _M_type == _Type::_Multi _Type _M_type = _Type::_Multi; }; /// @relates std::experimental::filesystem::path @{ /// Swap overload for paths inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); } /// Compute a hash value for a path size_t hash_value(const path& __p) noexcept; /// Compare paths inline bool operator<(const path& __lhs, const path& __rhs) noexcept; /// Compare paths inline bool operator<=(const path& __lhs, const path& __rhs) noexcept { return !(__rhs < __lhs); } /// Compare paths inline bool operator>(const path& __lhs, const path& __rhs) noexcept { return __rhs < __lhs; } /// Compare paths inline bool operator>=(const path& __lhs, const path& __rhs) noexcept { return !(__lhs < __rhs); } /// Compare paths inline bool operator==(const path& __lhs, const path& __rhs) noexcept; /// Compare paths inline bool operator!=(const path& __lhs, const path& __rhs) noexcept { return !(__lhs == __rhs); } /// Append one path to another inline path operator/(const path& __lhs, const path& __rhs) { path __result(__lhs); __result /= __rhs; return __result; } /// Write a path to a stream template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { auto __tmp = __p.string<_CharT, _Traits>(); using __quoted_string = std::__detail::_Quoted_string<decltype(__tmp)&, _CharT>; __os << __quoted_string{__tmp, _CharT('"'), _CharT('\\')}; return __os; } /// Read a path from a stream template<typename _CharT, typename _Traits> basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) { basic_string<_CharT, _Traits> __tmp; using __quoted_string = std::__detail::_Quoted_string<decltype(__tmp)&, _CharT>; if (__is >> __quoted_string{ __tmp, _CharT('"'), _CharT('\\') }) __p = std::move(__tmp); return __is; } /// Create a path from a UTF-8-encoded sequence of char #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS template<typename _InputIterator> inline path __u8path(_InputIterator __first, _InputIterator __last, char) { // XXX This assumes native wide encoding is UTF-16. std::codecvt_utf8_utf16<path::value_type> __cvt; path::string_type __tmp; const std::string __u8str{__first, __last}; const char* const __ptr = __u8str.data(); if (__str_codecvt_in_all(__ptr, __ptr + __u8str.size(), __tmp, __cvt)) return path{ __tmp }; _GLIBCXX_THROW_OR_ABORT(filesystem_error( "Cannot convert character sequence", std::make_error_code(errc::illegal_byte_sequence))); } #ifdef _GLIBCXX_USE_CHAR8_T template<typename _InputIterator> inline path __u8path(_InputIterator __first, _InputIterator __last, char8_t) { return path{ __first, __last }; } #endif // _GLIBCXX_USE_CHAR8_T #endif // _GLIBCXX_FILESYSTEM_IS_WINDOWS template<typename _InputIterator, typename _Require = __detail::_Path<_InputIterator, _InputIterator>, typename _CharT = __detail::__value_type_is_char_or_char8_t<_InputIterator>> inline path u8path(_InputIterator __first, _InputIterator __last) { #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS return __u8path(__first, __last, _CharT{}); #else return path{ __first, __last }; #endif } /// Create a path from a UTF-8-encoded sequence of char #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS inline path __u8path(const string& __s, char) { return filesystem::u8path(__s.data(), __s.data() + __s.size()); } template<typename _Source> inline __enable_if_t<is_convertible<const _Source&, string>::value, path> __u8path(const _Source& __source, char) { std::string __s = __source; return filesystem::u8path(__s.data(), __s.data() + __s.size()); } template<typename _Source> inline __enable_if_t<!is_convertible<const _Source&, string>::value, path> __u8path(const _Source& __source, char) { std::string __s = path::_S_string_from_iter(__source); return filesystem::u8path(__s.data(), __s.data() + __s.size()); } #ifdef _GLIBCXX_USE_CHAR8_T template<typename _Source> inline path __u8path(const _Source& __source, char8_t) { return path{ __source }; } #endif // _GLIBCXX_USE_CHAR8_T #endif // _GLIBCXX_FILESYSTEM_IS_WINDOWS template<typename _Source, typename _Require = __detail::_Path<_Source>, typename _CharT = __detail::__value_type_is_char_or_char8_t<_Source>> inline path u8path(const _Source& __source) { #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS return __u8path(__source, _CharT{}); #else return path{ __source }; #endif } /// @} /// Exception type thrown by the Filesystem TS library class filesystem_error : public std::system_error { public: filesystem_error(const string& __what_arg, error_code __ec) : system_error(__ec, __what_arg) { } filesystem_error(const string& __what_arg, const path& __p1, error_code __ec) : system_error(__ec, __what_arg), _M_path1(__p1) { } filesystem_error(const string& __what_arg, const path& __p1, const path& __p2, error_code __ec) : system_error(__ec, __what_arg), _M_path1(__p1), _M_path2(__p2) { } ~filesystem_error(); const path& path1() const noexcept { return _M_path1; } const path& path2() const noexcept { return _M_path2; } const char* what() const noexcept { return _M_what.c_str(); } private: std::string _M_gen_what(); path _M_path1; path _M_path2; std::string _M_what = _M_gen_what(); }; /// @cond undocumented struct path::_Cmpt : path { _Cmpt(string_type __s, _Type __t, size_t __pos) : path(std::move(__s), __t), _M_pos(__pos) { } _Cmpt() : _M_pos(-1) { } size_t _M_pos; }; // specialize _Cvt for degenerate 'noconv' case template<> struct path::_Cvt<path::value_type> { // We need this type to be defined because we don't have `if constexpr` // in C++11 and so path::string<C,T,A>(const A&) needs to be able to // declare a variable of this type and pass it to __str_codecvt_in_all. using __codecvt_utf8_to_wide = _Cvt; // Dummy overload used for unreachable calls in path::string<C,T,A>. template<typename _WStr> friend bool __str_codecvt_in_all(const char*, const char*, _WStr&, __codecvt_utf8_to_wide&) noexcept { return true; } template<typename _Iter> static string_type _S_convert(_Iter __first, _Iter __last) { return string_type{__first, __last}; } }; // Performs conversions from _CharT to path::string_type. template<typename _CharT> struct path::_Cvt { // FIXME: We currently assume that the native wide encoding for wchar_t // is either UTF-32 or UTF-16 (depending on the width of wchar_t). // See comments in <bits/fs_path.h> for further details. using __codecvt_utf8_to_wchar = typename conditional<sizeof(wchar_t) == sizeof(char32_t), std::codecvt_utf8<wchar_t>, // from UTF-32 std::codecvt_utf8_utf16<wchar_t> // from UTF-16 >::type; // Converts from char16_t or char32_t using std::codecvt<charNN_t, char>. // Need derived class here because std::codecvt has protected destructor. struct __codecvt_utf8_to_utfNN : std::codecvt<_CharT, char, mbstate_t> { }; // Convert from native pathname format (assumed to be UTF-8 everywhere) // to the encoding implied by the wide character type _CharT. using __codecvt_utf8_to_wide = typename conditional<is_same<_CharT, wchar_t>::value, __codecvt_utf8_to_wchar, __codecvt_utf8_to_utfNN>::type; #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS #ifdef _GLIBCXX_USE_CHAR8_T static string_type _S_wconvert(const char8_t* __f, const char8_t* __l, const char8_t*) { const char* __f2 = (const char*)__f; const char* __l2 = (const char*)__l; std::wstring __wstr; std::codecvt_utf8_utf16<wchar_t> __wcvt; if (__str_codecvt_in_all(__f2, __l2, __wstr, __wcvt)) return __wstr; } #endif static string_type _S_wconvert(const char* __f, const char* __l, const char*) { std::codecvt_utf8_utf16<wchar_t> __cvt; std::wstring __wstr; if (__str_codecvt_in_all(__f, __l, __wstr, __cvt)) return __wstr; _GLIBCXX_THROW_OR_ABORT(filesystem_error( "Cannot convert character sequence", std::make_error_code(errc::illegal_byte_sequence))); } static string_type _S_wconvert(const _CharT* __f, const _CharT* __l, const void*) { __codecvt_utf8_to_wide __cvt; std::string __str; if (__str_codecvt_out_all(__f, __l, __str, __cvt)) { const char* __f2 = __str.data(); const char* __l2 = __f2 + __str.size(); std::codecvt_utf8_utf16<wchar_t> __wcvt; std::wstring __wstr; if (__str_codecvt_in_all(__f2, __l2, __wstr, __wcvt)) return __wstr; } _GLIBCXX_THROW_OR_ABORT(filesystem_error( "Cannot convert character sequence", std::make_error_code(errc::illegal_byte_sequence))); } static string_type _S_convert(const _CharT* __f, const _CharT* __l) { return _S_wconvert(__f, __l, (const _CharT*)nullptr); } #else static string_type _S_convert(const _CharT* __f, const _CharT* __l) { #ifdef _GLIBCXX_USE_CHAR8_T if constexpr (is_same<_CharT, char8_t>::value) return string_type(__f, __l); else #endif { __codecvt_utf8_to_wide __cvt; std::string __str; if (__str_codecvt_out_all(__f, __l, __str, __cvt)) return __str; _GLIBCXX_THROW_OR_ABORT(filesystem_error( "Cannot convert character sequence", std::make_error_code(errc::illegal_byte_sequence))); } } #endif static string_type _S_convert(_CharT* __f, _CharT* __l) { return _S_convert(const_cast<const _CharT*>(__f), const_cast<const _CharT*>(__l)); } template<typename _Iter> static string_type _S_convert(_Iter __first, _Iter __last) { const std::basic_string<_CharT> __str(__first, __last); return _S_convert(__str.data(), __str.data() + __str.size()); } template<typename _Iter, typename _Cont> static string_type _S_convert(__gnu_cxx::__normal_iterator<_Iter, _Cont> __first, __gnu_cxx::__normal_iterator<_Iter, _Cont> __last) { return _S_convert(__first.base(), __last.base()); } }; /// @endcond /// An iterator for the components of a path class path::iterator { public: using difference_type = std::ptrdiff_t; using value_type = path; using reference = const path&; using pointer = const path*; using iterator_category = std::bidirectional_iterator_tag; iterator() : _M_path(nullptr), _M_cur(), _M_at_end() { } iterator(const iterator&) = default; iterator& operator=(const iterator&) = default; reference operator*() const; pointer operator->() const { return std::__addressof(**this); } iterator& operator++(); iterator operator++(int) { auto __tmp = *this; ++*this; return __tmp; } iterator& operator--(); iterator operator--(int) { auto __tmp = *this; --*this; return __tmp; } friend bool operator==(const iterator& __lhs, const iterator& __rhs) { return __lhs._M_equals(__rhs); } friend bool operator!=(const iterator& __lhs, const iterator& __rhs) { return !__lhs._M_equals(__rhs); } private: friend class path; iterator(const path* __path, path::_List::const_iterator __iter) : _M_path(__path), _M_cur(__iter), _M_at_end() { } iterator(const path* __path, bool __at_end) : _M_path(__path), _M_cur(), _M_at_end(__at_end) { } bool _M_equals(iterator) const; const path* _M_path; path::_List::const_iterator _M_cur; bool _M_at_end; // only used when type != _Multi }; inline path& path::operator=(path&& __p) noexcept { _M_pathname = std::move(__p._M_pathname); _M_cmpts = std::move(__p._M_cmpts); _M_type = __p._M_type; __p.clear(); return *this; } inline path& path::operator=(string_type&& __source) { return *this = path(std::move(__source)); } inline path& path::assign(string_type&& __source) { return *this = path(std::move(__source)); } inline path& path::operator+=(const path& __p) { return operator+=(__p.native()); } inline path& path::operator+=(const string_type& __x) { _M_pathname += __x; _M_split_cmpts(); return *this; } inline path& path::operator+=(const value_type* __x) { _M_pathname += __x; _M_split_cmpts(); return *this; } inline path& path::operator+=(value_type __x) { _M_pathname += __x; _M_split_cmpts(); return *this; } #if __cplusplus >= 201402L inline path& path::operator+=(basic_string_view<value_type> __x) { _M_pathname.append(__x.data(), __x.size()); _M_split_cmpts(); return *this; } #endif template<typename _CharT> inline __detail::_Path<_CharT*, _CharT*>& path::operator+=(_CharT __x) { auto* __addr = std::__addressof(__x); return concat(__addr, __addr + 1); } inline path& path::make_preferred() { #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS std::replace(_M_pathname.begin(), _M_pathname.end(), L'/', preferred_separator); #endif return *this; } inline void path::swap(path& __rhs) noexcept { _M_pathname.swap(__rhs._M_pathname); _M_cmpts.swap(__rhs._M_cmpts); std::swap(_M_type, __rhs._M_type); } template<typename _CharT, typename _Traits, typename _Allocator> inline std::basic_string<_CharT, _Traits, _Allocator> path::string(const _Allocator& __a) const { if _GLIBCXX17_CONSTEXPR (is_same<_CharT, value_type>::value) return { _M_pathname.begin(), _M_pathname.end(), __a }; using _WString = basic_string<_CharT, _Traits, _Allocator>; const value_type* __first = _M_pathname.data(); const value_type* __last = __first + _M_pathname.size(); #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS using _CharAlloc = __alloc_rebind<_Allocator, char>; using _String = basic_string<char, char_traits<char>, _CharAlloc>; // First convert native string from UTF-16 to to UTF-8. // XXX This assumes that the execution wide-character set is UTF-16. codecvt_utf8_utf16<value_type> __cvt; _String __u8str{_CharAlloc{__a}}; if (__str_codecvt_out_all(__first, __last, __u8str, __cvt)) { struct { const _String* operator()(const _String& __from, _String&, true_type) { return std::__addressof(__from); } _WString* operator()(const _String& __from, _WString& __to, false_type) { #ifdef _GLIBCXX_USE_CHAR8_T if constexpr (is_same<_CharT, char8_t>::value) { __to.assign(__from.begin(), __from.end()); return std::__addressof(__to); } else #endif { // Convert UTF-8 to char16_t or char32_t string. typename path::_Cvt<_CharT>::__codecvt_utf8_to_wide __cvt; const char* __f = __from.data(); const char* __l = __f + __from.size(); if (__str_codecvt_in_all(__f, __l, __to, __cvt)) return std::__addressof(__to); } return nullptr; } } __dispatch; _WString __wstr(__a); if (auto* __p = __dispatch(__u8str, __wstr, is_same<_CharT, char>{})) return *__p; } #else // ! Windows #ifdef _GLIBCXX_USE_CHAR8_T if constexpr (is_same<_CharT, char8_t>::value) return _WString(__first, __last, __a); else #endif { typename path::_Cvt<_CharT>::__codecvt_utf8_to_wide __cvt; _WString __wstr(__a); if (__str_codecvt_in_all(__first, __last, __wstr, __cvt)) return __wstr; } #endif _GLIBCXX_THROW_OR_ABORT(filesystem_error( "Cannot convert character sequence", std::make_error_code(errc::illegal_byte_sequence))); } inline std::string path::string() const { return string<char>(); } #if _GLIBCXX_USE_WCHAR_T inline std::wstring path::wstring() const { return string<wchar_t>(); } #endif #ifdef _GLIBCXX_USE_CHAR8_T inline std::u8string path::u8string() const { return string<char8_t>(); } #else inline std::string path::u8string() const { #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS std::string __str; // convert from native wide encoding (assumed to be UTF-16) to UTF-8 std::codecvt_utf8_utf16<value_type> __cvt; const value_type* __first = _M_pathname.data(); const value_type* __last = __first + _M_pathname.size(); if (__str_codecvt_out_all(__first, __last, __str, __cvt)) return __str; _GLIBCXX_THROW_OR_ABORT(filesystem_error( "Cannot convert character sequence", std::make_error_code(errc::illegal_byte_sequence))); #else return _M_pathname; #endif } #endif // _GLIBCXX_USE_CHAR8_T inline std::u16string path::u16string() const { return string<char16_t>(); } inline std::u32string path::u32string() const { return string<char32_t>(); } template<typename _CharT, typename _Traits, typename _Allocator> inline std::basic_string<_CharT, _Traits, _Allocator> path::generic_string(const _Allocator& __a) const { #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS const _CharT __slash = is_same<_CharT, wchar_t>::value ? _CharT(L'/') : _CharT('/'); // Assume value is correct for the encoding. #else const _CharT __slash = _CharT('/'); #endif basic_string<_CharT, _Traits, _Allocator> __str(__a); __str.reserve(_M_pathname.size()); bool __add_slash = false; for (auto& __elem : *this) { if (__elem._M_type == _Type::_Root_dir) { __str += __slash; continue; } if (__add_slash) __str += __slash; __str += __elem.string<_CharT, _Traits, _Allocator>(__a); __add_slash = __elem._M_type == _Type::_Filename; } return __str; } inline std::string path::generic_string() const { return generic_string<char>(); } #if _GLIBCXX_USE_WCHAR_T inline std::wstring path::generic_wstring() const { return generic_string<wchar_t>(); } #endif #ifdef _GLIBCXX_USE_CHAR8_T inline std::u8string path::generic_u8string() const { return generic_string<char8_t>(); } #else inline std::string path::generic_u8string() const { return generic_string<char>(); } #endif inline std::u16string path::generic_u16string() const { return generic_string<char16_t>(); } inline std::u32string path::generic_u32string() const { return generic_string<char32_t>(); } inline int path::compare(const string_type& __s) const { return compare(path(__s)); } inline int path::compare(const value_type* __s) const { return compare(path(__s)); } #if __cplusplus >= 201402L inline int path::compare(basic_string_view<value_type> __s) const { return compare(path(__s)); } #endif inline path path::filename() const { return empty() ? path() : *--end(); } inline path path::stem() const { auto ext = _M_find_extension(); if (ext.first && ext.second != 0) return path{ext.first->substr(0, ext.second)}; return {}; } inline path path::extension() const { auto ext = _M_find_extension(); if (ext.first && ext.second != string_type::npos) return path{ext.first->substr(ext.second)}; return {}; } inline bool path::has_stem() const { auto ext = _M_find_extension(); return ext.first && ext.second != 0; } inline bool path::has_extension() const { auto ext = _M_find_extension(); return ext.first && ext.second != string_type::npos; } inline bool path::is_absolute() const { #ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS return has_root_name() && has_root_directory(); #else return has_root_directory(); #endif } inline path::iterator path::begin() const { if (_M_type == _Type::_Multi) return iterator(this, _M_cmpts.begin()); return iterator(this, false); } inline path::iterator path::end() const { if (_M_type == _Type::_Multi) return iterator(this, _M_cmpts.end()); return iterator(this, true); } inline path::iterator& path::iterator::operator++() { __glibcxx_assert(_M_path != nullptr); if (_M_path->_M_type == _Type::_Multi) { __glibcxx_assert(_M_cur != _M_path->_M_cmpts.end()); ++_M_cur; } else { __glibcxx_assert(!_M_at_end); _M_at_end = true; } return *this; } inline path::iterator& path::iterator::operator--() { __glibcxx_assert(_M_path != nullptr); if (_M_path->_M_type == _Type::_Multi) { __glibcxx_assert(_M_cur != _M_path->_M_cmpts.begin()); --_M_cur; } else { __glibcxx_assert(_M_at_end); _M_at_end = false; } return *this; } inline path::iterator::reference path::iterator::operator*() const { __glibcxx_assert(_M_path != nullptr); if (_M_path->_M_type == _Type::_Multi) { __glibcxx_assert(_M_cur != _M_path->_M_cmpts.end()); return *_M_cur; } return *_M_path; } inline bool path::iterator::_M_equals(iterator __rhs) const { if (_M_path != __rhs._M_path) return false; if (_M_path == nullptr) return true; if (_M_path->_M_type == path::_Type::_Multi) return _M_cur == __rhs._M_cur; return _M_at_end == __rhs._M_at_end; } // Define these now that path and path::iterator are complete. // They needs to consider the string_view(Range&&) constructor during // overload resolution, which depends on whether range<path> is satisfied, // which depends on whether path::iterator is complete. inline bool operator<(const path& __lhs, const path& __rhs) noexcept { return __lhs.compare(__rhs) < 0; } inline bool operator==(const path& __lhs, const path& __rhs) noexcept { return __lhs.compare(__rhs) == 0; } /// @} group filesystem-ts _GLIBCXX_END_NAMESPACE_CXX11 } // namespace v1 } // namespace filesystem } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++11 #endif // _GLIBCXX_EXPERIMENTAL_FS_PATH_H // Simd PowerPC specific implementations -*- C++ -*- // Copyright (C) 2020-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. #ifndef _GLIBCXX_EXPERIMENTAL_SIMD_PPC_H_ #define _GLIBCXX_EXPERIMENTAL_SIMD_PPC_H_ #if __cplusplus >= 201703L #ifndef __ALTIVEC__ #error "simd_ppc.h may only be included when AltiVec/VMX is available" #endif #include <altivec.h> _GLIBCXX_SIMD_BEGIN_NAMESPACE // _SimdImplPpc {{{ template <typename _Abi> struct _SimdImplPpc : _SimdImplBuiltin<_Abi> { using _Base = _SimdImplBuiltin<_Abi>; // Byte and halfword shift instructions on PPC only consider the low 3 or 4 // bits of the RHS. Consequently, shifting by sizeof(_Tp)*CHAR_BIT (or more) // is UB without extra measures. To match scalar behavior, byte and halfword // shifts need an extra fixup step. // _S_bit_shift_left {{{ template <typename _Tp, size_t _Np> _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdWrapper<_Tp, _Np> _S_bit_shift_left(_SimdWrapper<_Tp, _Np> __x, _SimdWrapper<_Tp, _Np> __y) { __x = _Base::_S_bit_shift_left(__x, __y); if constexpr (sizeof(_Tp) < sizeof(int)) __x._M_data = (__y._M_data < sizeof(_Tp) * __CHAR_BIT__) & __x._M_data; return __x; } template <typename _Tp, size_t _Np> _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdWrapper<_Tp, _Np> _S_bit_shift_left(_SimdWrapper<_Tp, _Np> __x, int __y) { __x = _Base::_S_bit_shift_left(__x, __y); if constexpr (sizeof(_Tp) < sizeof(int)) { if (__y >= int(sizeof(_Tp) * __CHAR_BIT__)) return {}; } return __x; } // }}} // _S_bit_shift_right {{{ template <typename _Tp, size_t _Np> _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdWrapper<_Tp, _Np> _S_bit_shift_right(_SimdWrapper<_Tp, _Np> __x, _SimdWrapper<_Tp, _Np> __y) { if constexpr (sizeof(_Tp) < sizeof(int)) { constexpr int __nbits = sizeof(_Tp) * __CHAR_BIT__; if constexpr (is_unsigned_v<_Tp>) return (__y._M_data < __nbits) & _Base::_S_bit_shift_right(__x, __y)._M_data; else { _Base::_S_masked_assign(_SimdWrapper<_Tp, _Np>(__y._M_data >= __nbits), __y, __nbits - 1); return _Base::_S_bit_shift_right(__x, __y); } } else return _Base::_S_bit_shift_right(__x, __y); } template <typename _Tp, size_t _Np> _GLIBCXX_SIMD_INTRINSIC static constexpr _SimdWrapper<_Tp, _Np> _S_bit_shift_right(_SimdWrapper<_Tp, _Np> __x, int __y) { if constexpr (sizeof(_Tp) < sizeof(int)) { constexpr int __nbits = sizeof(_Tp) * __CHAR_BIT__; if (__y >= __nbits) { if constexpr (is_unsigned_v<_Tp>) return {}; else return _Base::_S_bit_shift_right(__x, __nbits - 1); } } return _Base::_S_bit_shift_right(__x, __y); } // }}} }; // }}} // _MaskImplPpc {{{ template <typename _Abi> struct _MaskImplPpc : _MaskImplBuiltin<_Abi> { using _Base = _MaskImplBuiltin<_Abi>; // _S_popcount {{{ template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static int _S_popcount(simd_mask<_Tp, _Abi> __k) { const auto __kv = __as_vector(__k); if constexpr (__have_power10vec) { using _Intrin = __intrinsic_type16_t<make_unsigned_t<__int_for_sizeof_t<_Tp>>>; return vec_cntm(reinterpret_cast<_Intrin>(__kv), 1); } else if constexpr (sizeof(_Tp) >= sizeof(int)) { using _Intrin = __intrinsic_type16_t<int>; const int __sum = -vec_sums(__intrin_bitcast<_Intrin>(__kv), _Intrin())[3]; return __sum / (sizeof(_Tp) / sizeof(int)); } else { const auto __summed_to_int = vec_sum4s(__to_intrin(__kv), __intrinsic_type16_t<int>()); return -vec_sums(__summed_to_int, __intrinsic_type16_t<int>())[3]; } } // }}} }; // }}} _GLIBCXX_SIMD_END_NAMESPACE #endif // __cplusplus >= 201703L #endif // _GLIBCXX_EXPERIMENTAL_SIMD_PPC_H_ // vim: foldmethod=marker foldmarker={{{,}}} sw=2 noet ts=8 sts=2 tw=100 // Components for manipulating non-owning sequences of characters -*- C++ -*- // Copyright (C) 2013-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/bits/string_view.tcc * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{experimental/string_view} */ // // N3762 basic_string_view library // #ifndef _GLIBCXX_EXPERIMENTAL_STRING_VIEW_TCC #define _GLIBCXX_EXPERIMENTAL_STRING_VIEW_TCC 1 #pragma GCC system_header #if __cplusplus >= 201402L namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { inline namespace fundamentals_v1 { template<typename _CharT, typename _Traits> constexpr typename basic_string_view<_CharT, _Traits>::size_type basic_string_view<_CharT, _Traits>:: find(const _CharT* __str, size_type __pos, size_type __n) const noexcept { __glibcxx_requires_string_len(__str, __n); if (__n == 0) return __pos <= this->_M_len ? __pos : npos; if (__n <= this->_M_len) { for (; __pos <= this->_M_len - __n; ++__pos) if (traits_type::eq(this->_M_str[__pos], __str[0]) && traits_type::compare(this->_M_str + __pos + 1, __str + 1, __n - 1) == 0) return __pos; } return npos; } template<typename _CharT, typename _Traits> constexpr typename basic_string_view<_CharT, _Traits>::size_type basic_string_view<_CharT, _Traits>:: find(_CharT __c, size_type __pos) const noexcept { size_type __ret = npos; if (__pos < this->_M_len) { const size_type __n = this->_M_len - __pos; const _CharT* __p = traits_type::find(this->_M_str + __pos, __n, __c); if (__p) __ret = __p - this->_M_str; } return __ret; } template<typename _CharT, typename _Traits> constexpr typename basic_string_view<_CharT, _Traits>::size_type basic_string_view<_CharT, _Traits>:: rfind(const _CharT* __str, size_type __pos, size_type __n) const noexcept { __glibcxx_requires_string_len(__str, __n); if (__n <= this->_M_len) { __pos = std::min(size_type(this->_M_len - __n), __pos); do { if (traits_type::compare(this->_M_str + __pos, __str, __n) == 0) return __pos; } while (__pos-- > 0); } return npos; } template<typename _CharT, typename _Traits> constexpr typename basic_string_view<_CharT, _Traits>::size_type basic_string_view<_CharT, _Traits>:: rfind(_CharT __c, size_type __pos) const noexcept { size_type __size = this->_M_len; if (__size > 0) { if (--__size > __pos) __size = __pos; for (++__size; __size-- > 0; ) if (traits_type::eq(this->_M_str[__size], __c)) return __size; } return npos; } template<typename _CharT, typename _Traits> constexpr typename basic_string_view<_CharT, _Traits>::size_type basic_string_view<_CharT, _Traits>:: find_first_of(const _CharT* __str, size_type __pos, size_type __n) const { __glibcxx_requires_string_len(__str, __n); for (; __n && __pos < this->_M_len; ++__pos) { const _CharT* __p = traits_type::find(__str, __n, this->_M_str[__pos]); if (__p) return __pos; } return npos; } template<typename _CharT, typename _Traits> constexpr typename basic_string_view<_CharT, _Traits>::size_type basic_string_view<_CharT, _Traits>:: find_last_of(const _CharT* __str, size_type __pos, size_type __n) const { __glibcxx_requires_string_len(__str, __n); size_type __size = this->size(); if (__size && __n) { if (--__size > __pos) __size = __pos; do { if (traits_type::find(__str, __n, this->_M_str[__size])) return __size; } while (__size-- != 0); } return npos; } template<typename _CharT, typename _Traits> constexpr typename basic_string_view<_CharT, _Traits>::size_type basic_string_view<_CharT, _Traits>:: find_first_not_of(const _CharT* __str, size_type __pos, size_type __n) const { __glibcxx_requires_string_len(__str, __n); for (; __pos < this->_M_len; ++__pos) if (!traits_type::find(__str, __n, this->_M_str[__pos])) return __pos; return npos; } template<typename _CharT, typename _Traits> constexpr typename basic_string_view<_CharT, _Traits>::size_type basic_string_view<_CharT, _Traits>:: find_first_not_of(_CharT __c, size_type __pos) const noexcept { for (; __pos < this->_M_len; ++__pos) if (!traits_type::eq(this->_M_str[__pos], __c)) return __pos; return npos; } template<typename _CharT, typename _Traits> constexpr typename basic_string_view<_CharT, _Traits>::size_type basic_string_view<_CharT, _Traits>:: find_last_not_of(const _CharT* __str, size_type __pos, size_type __n) const { __glibcxx_requires_string_len(__str, __n); size_type __size = this->_M_len; if (__size) { if (--__size > __pos) __size = __pos; do { if (!traits_type::find(__str, __n, this->_M_str[__size])) return __size; } while (__size--); } return npos; } template<typename _CharT, typename _Traits> constexpr typename basic_string_view<_CharT, _Traits>::size_type basic_string_view<_CharT, _Traits>:: find_last_not_of(_CharT __c, size_type __pos) const noexcept { size_type __size = this->_M_len; if (__size) { if (--__size > __pos) __size = __pos; do { if (!traits_type::eq(this->_M_str[__size], __c)) return __size; } while (__size--); } return npos; } } // namespace fundamentals_v1 } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // __cplusplus <= 201103L #endif // _GLIBCXX_EXPERIMENTAL_STRING_VIEW_TCC // Definition of the public simd interfaces -*- C++ -*- // Copyright (C) 2020-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. #ifndef _GLIBCXX_EXPERIMENTAL_SIMD_H #define _GLIBCXX_EXPERIMENTAL_SIMD_H #if __cplusplus >= 201703L #include "simd_detail.h" #include "numeric_traits.h" #include <bit> #include <bitset> #ifdef _GLIBCXX_DEBUG_UB #include <cstdio> // for stderr #endif #include <cstring> #include <functional> #include <iosfwd> #include <utility> #if _GLIBCXX_SIMD_X86INTRIN #include <x86intrin.h> #elif _GLIBCXX_SIMD_HAVE_NEON #pragma GCC diagnostic push // narrowing conversion of '__a' from 'uint64_t' {aka 'long long unsigned int'} to // 'int64x1_t' {aka 'long long int'} [-Wnarrowing] #pragma GCC diagnostic ignored "-Wnarrowing" #include <arm_neon.h> #pragma GCC diagnostic pop #endif /** @ingroup ts_simd * @{ */ /* There are several closely related types, with the following naming * convention: * _Tp: vectorizable (arithmetic) type (or any type) * _TV: __vector_type_t<_Tp, _Np> * _TW: _SimdWrapper<_Tp, _Np> * _TI: __intrinsic_type_t<_Tp, _Np> * _TVT: _VectorTraits<_TV> or _VectorTraits<_TW> * If one additional type is needed use _U instead of _T. * Otherwise use _T\d, _TV\d, _TW\d, TI\d, _TVT\d. * * More naming conventions: * _Ap or _Abi: An ABI tag from the simd_abi namespace * _Ip: often used for integer types with sizeof(_Ip) == sizeof(_Tp), * _IV, _IW as for _TV, _TW * _Np: number of elements (not bytes) * _Bytes: number of bytes * * Variable names: * __k: mask object (vector- or bitmask) */ _GLIBCXX_SIMD_BEGIN_NAMESPACE #if !_GLIBCXX_SIMD_X86INTRIN using __m128 [[__gnu__::__vector_size__(16)]] = float; using __m128d [[__gnu__::__vector_size__(16)]] = double; using __m128i [[__gnu__::__vector_size__(16)]] = long long; using __m256 [[__gnu__::__vector_size__(32)]] = float; using __m256d [[__gnu__::__vector_size__(32)]] = double; using __m256i [[__gnu__::__vector_size__(32)]] = long long; using __m512 [[__gnu__::__vector_size__(64)]] = float; using __m512d [[__gnu__::__vector_size__(64)]] = double; using __m512i [[__gnu__::__vector_size__(64)]] = long long; #endif namespace simd_abi { // simd_abi forward declarations {{{ // implementation details: struct _Scalar; template <int _Np> struct _Fixed; // There are two major ABIs that appear on different architectures. // Both have non-boolean values packed into an N Byte register // -> #elements = N / sizeof(T) // Masks differ: // 1. Use value vector registers for masks (all 0 or all 1) // 2. Use bitmasks (mask registers) with one bit per value in the corresponding // value vector // // Both can be partially used, masking off the rest when doing horizontal // operations or operations that can trap (e.g. FP_INVALID or integer division // by 0). This is encoded as the number of used bytes. template <int _UsedBytes> struct _VecBuiltin; template <int _UsedBytes> struct _VecBltnBtmsk; template <typename _Tp, int _Np> using _VecN = _VecBuiltin<sizeof(_Tp) * _Np>; template <int _UsedBytes = 16> using _Sse = _VecBuiltin<_UsedBytes>; template <int _UsedBytes = 32> using _Avx = _VecBuiltin<_UsedBytes>; template <int _UsedBytes = 64> using _Avx512 = _VecBltnBtmsk<_UsedBytes>; template <int _UsedBytes = 16> using _Neon = _VecBuiltin<_UsedBytes>; // implementation-defined: using __sse = _Sse<>; using __avx = _Avx<>; using __avx512 = _Avx512<>; using __neon = _Neon<>; using __neon128 = _Neon<16>; using __neon64 = _Neon<8>; // standard: template <typename _Tp, size_t _Np, typename...> struct deduce; template <int _Np> using fixed_size = _Fixed<_Np>; using scalar = _Scalar; // }}} } // namespace simd_abi // forward declarations is_simd(_mask), simd(_mask), simd_size {{{ template <typename _Tp> struct is_simd; template <typename _Tp> struct is_simd_mask; template <typename _Tp, typename _Abi> class simd; template <typename _Tp, typename _Abi> class simd_mask; template <typename _Tp, typename _Abi> struct simd_size; // }}} // load/store flags {{{ struct element_aligned_tag { template <typename _Tp, typename _Up = typename _Tp::value_type> static constexpr size_t _S_alignment = alignof(_Up); template <typename _Tp, typename _Up> _GLIBCXX_SIMD_INTRINSIC static constexpr _Up* _S_apply(_Up* __ptr) { return __ptr; } }; struct vector_aligned_tag { template <typename _Tp, typename _Up = typename _Tp::value_type> static constexpr size_t _S_alignment = std::__bit_ceil(sizeof(_Up) * _Tp::size()); template <typename _Tp, typename _Up> _GLIBCXX_SIMD_INTRINSIC static constexpr _Up* _S_apply(_Up* __ptr) { return static_cast<_Up*>(__builtin_assume_aligned(__ptr, _S_alignment<_Tp, _Up>)); } }; template <size_t _Np> struct overaligned_tag { template <typename _Tp, typename _Up = typename _Tp::value_type> static constexpr size_t _S_alignment = _Np; template <typename _Tp, typename _Up> _GLIBCXX_SIMD_INTRINSIC static constexpr _Up* _S_apply(_Up* __ptr) { return static_cast<_Up*>(__builtin_assume_aligned(__ptr, _Np)); } }; inline constexpr element_aligned_tag element_aligned = {}; inline constexpr vector_aligned_tag vector_aligned = {}; template <size_t _Np> inline constexpr overaligned_tag<_Np> overaligned = {}; // }}} template <size_t _Xp> using _SizeConstant = integral_constant<size_t, _Xp>; namespace __detail { struct _Minimum { template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC constexpr _Tp operator()(_Tp __a, _Tp __b) const { using std::min; return min(__a, __b); } }; struct _Maximum { template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC constexpr _Tp operator()(_Tp __a, _Tp __b) const { using std::max; return max(__a, __b); } }; } // namespace __detail // unrolled/pack execution helpers // __execute_n_times{{{ template <typename _Fp, size_t... _I> _GLIBCXX_SIMD_INTRINSIC constexpr void __execute_on_index_sequence(_Fp&& __f, index_sequence<_I...>) { ((void)__f(_SizeConstant<_I>()), ...); } template <typename _Fp> _GLIBCXX_SIMD_INTRINSIC constexpr void __execute_on_index_sequence(_Fp&&, index_sequence<>) { } template <size_t _Np, typename _Fp> _GLIBCXX_SIMD_INTRINSIC constexpr void __execute_n_times(_Fp&& __f) { __execute_on_index_sequence(static_cast<_Fp&&>(__f), make_index_sequence<_Np>{}); } // }}} // __generate_from_n_evaluations{{{ template <typename _R, typename _Fp, size_t... _I> _GLIBCXX_SIMD_INTRINSIC constexpr _R __execute_on_index_sequence_with_return(_Fp&& __f, index_sequence<_I...>) { return _R{__f(_SizeConstant<_I>())...}; } template <size_t _Np, typename _R, typename _Fp> _GLIBCXX_SIMD_INTRINSIC constexpr _R __generate_from_n_evaluations(_Fp&& __f) { return __execute_on_index_sequence_with_return<_R>( static_cast<_Fp&&>(__f), make_index_sequence<_Np>{}); } // }}} // __call_with_n_evaluations{{{ template <size_t... _I, typename _F0, typename _FArgs> _GLIBCXX_SIMD_INTRINSIC constexpr auto __call_with_n_evaluations(index_sequence<_I...>, _F0&& __f0, _FArgs&& __fargs) { return __f0(__fargs(_SizeConstant<_I>())...); } template <size_t _Np, typename _F0, typename _FArgs> _GLIBCXX_SIMD_INTRINSIC constexpr auto __call_with_n_evaluations(_F0&& __f0, _FArgs&& __fargs) { return __call_with_n_evaluations(make_index_sequence<_Np>{}, static_cast<_F0&&>(__f0), static_cast<_FArgs&&>(__fargs)); } // }}} // __call_with_subscripts{{{ template <size_t _First = 0, size_t... _It, typename _Tp, typename _Fp> _GLIBCXX_SIMD_INTRINSIC constexpr auto __call_with_subscripts(_Tp&& __x, index_sequence<_It...>, _Fp&& __fun) { return __fun(__x[_First + _It]...); } template <size_t _Np, size_t _First = 0, typename _Tp, typename _Fp> _GLIBCXX_SIMD_INTRINSIC constexpr auto __call_with_subscripts(_Tp&& __x, _Fp&& __fun) { return __call_with_subscripts<_First>(static_cast<_Tp&&>(__x), make_index_sequence<_Np>(), static_cast<_Fp&&>(__fun)); } // }}} // vvv ---- type traits ---- vvv // integer type aliases{{{ using _UChar = unsigned char; using _SChar = signed char; using _UShort = unsigned short; using _UInt = unsigned int; using _ULong = unsigned long; using _ULLong = unsigned long long; using _LLong = long long; //}}} // __first_of_pack{{{ template <typename _T0, typename...> struct __first_of_pack { using type = _T0; }; template <typename... _Ts> using __first_of_pack_t = typename __first_of_pack<_Ts...>::type; //}}} // __value_type_or_identity_t {{{ template <typename _Tp> typename _Tp::value_type __value_type_or_identity_impl(int); template <typename _Tp> _Tp __value_type_or_identity_impl(float); template <typename _Tp> using __value_type_or_identity_t = decltype(__value_type_or_identity_impl<_Tp>(int())); // }}} // __is_vectorizable {{{ template <typename _Tp> struct __is_vectorizable : public is_arithmetic<_Tp> {}; template <> struct __is_vectorizable<bool> : public false_type {}; template <typename _Tp> inline constexpr bool __is_vectorizable_v = __is_vectorizable<_Tp>::value; // Deduces to a vectorizable type template <typename _Tp, typename = enable_if_t<__is_vectorizable_v<_Tp>>> using _Vectorizable = _Tp; // }}} // _LoadStorePtr / __is_possible_loadstore_conversion {{{ template <typename _Ptr, typename _ValueType> struct __is_possible_loadstore_conversion : conjunction<__is_vectorizable<_Ptr>, __is_vectorizable<_ValueType>> {}; template <> struct __is_possible_loadstore_conversion<bool, bool> : true_type {}; // Deduces to a type allowed for load/store with the given value type. template <typename _Ptr, typename _ValueType, typename = enable_if_t< __is_possible_loadstore_conversion<_Ptr, _ValueType>::value>> using _LoadStorePtr = _Ptr; // }}} // __is_bitmask{{{ template <typename _Tp, typename = void_t<>> struct __is_bitmask : false_type {}; template <typename _Tp> inline constexpr bool __is_bitmask_v = __is_bitmask<_Tp>::value; // the __mmaskXX case: template <typename _Tp> struct __is_bitmask<_Tp, void_t<decltype(declval<unsigned&>() = declval<_Tp>() & 1u)>> : true_type {}; // }}} // __int_for_sizeof{{{ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" template <size_t _Bytes> constexpr auto __int_for_sizeof() { static_assert(_Bytes > 0); if constexpr (_Bytes == sizeof(int)) return int(); #ifdef __clang__ else if constexpr (_Bytes == sizeof(char)) return char(); #else else if constexpr (_Bytes == sizeof(_SChar)) return _SChar(); #endif else if constexpr (_Bytes == sizeof(short)) return short(); #ifndef __clang__ else if constexpr (_Bytes == sizeof(long)) return long(); #endif else if constexpr (_Bytes == sizeof(_LLong)) return _LLong(); #ifdef __SIZEOF_INT128__ else if constexpr (_Bytes == sizeof(__int128)) return __int128(); #endif // __SIZEOF_INT128__ else if constexpr (_Bytes % sizeof(int) == 0) { constexpr size_t _Np = _Bytes / sizeof(int); struct _Ip { int _M_data[_Np]; _GLIBCXX_SIMD_INTRINSIC constexpr _Ip operator&(_Ip __rhs) const { return __generate_from_n_evaluations<_Np, _Ip>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __rhs._M_data[__i] & _M_data[__i]; }); } _GLIBCXX_SIMD_INTRINSIC constexpr _Ip operator|(_Ip __rhs) const { return __generate_from_n_evaluations<_Np, _Ip>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __rhs._M_data[__i] | _M_data[__i]; }); } _GLIBCXX_SIMD_INTRINSIC constexpr _Ip operator^(_Ip __rhs) const { return __generate_from_n_evaluations<_Np, _Ip>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __rhs._M_data[__i] ^ _M_data[__i]; }); } _GLIBCXX_SIMD_INTRINSIC constexpr _Ip operator~() const { return __generate_from_n_evaluations<_Np, _Ip>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return ~_M_data[__i]; }); } }; return _Ip{}; } else static_assert(_Bytes == 0, "this should be unreachable"); } #pragma GCC diagnostic pop template <typename _Tp> using __int_for_sizeof_t = decltype(__int_for_sizeof<sizeof(_Tp)>()); template <size_t _Np> using __int_with_sizeof_t = decltype(__int_for_sizeof<_Np>()); // }}} // __is_fixed_size_abi{{{ template <typename _Tp> struct __is_fixed_size_abi : false_type {}; template <int _Np> struct __is_fixed_size_abi<simd_abi::fixed_size<_Np>> : true_type {}; template <typename _Tp> inline constexpr bool __is_fixed_size_abi_v = __is_fixed_size_abi<_Tp>::value; // }}} // constexpr feature detection{{{ constexpr inline bool __have_mmx = _GLIBCXX_SIMD_HAVE_MMX; constexpr inline bool __have_sse = _GLIBCXX_SIMD_HAVE_SSE; constexpr inline bool __have_sse2 = _GLIBCXX_SIMD_HAVE_SSE2; constexpr inline bool __have_sse3 = _GLIBCXX_SIMD_HAVE_SSE3; constexpr inline bool __have_ssse3 = _GLIBCXX_SIMD_HAVE_SSSE3; constexpr inline bool __have_sse4_1 = _GLIBCXX_SIMD_HAVE_SSE4_1; constexpr inline bool __have_sse4_2 = _GLIBCXX_SIMD_HAVE_SSE4_2; constexpr inline bool __have_xop = _GLIBCXX_SIMD_HAVE_XOP; constexpr inline bool __have_avx = _GLIBCXX_SIMD_HAVE_AVX; constexpr inline bool __have_avx2 = _GLIBCXX_SIMD_HAVE_AVX2; constexpr inline bool __have_bmi = _GLIBCXX_SIMD_HAVE_BMI1; constexpr inline bool __have_bmi2 = _GLIBCXX_SIMD_HAVE_BMI2; constexpr inline bool __have_lzcnt = _GLIBCXX_SIMD_HAVE_LZCNT; constexpr inline bool __have_sse4a = _GLIBCXX_SIMD_HAVE_SSE4A; constexpr inline bool __have_fma = _GLIBCXX_SIMD_HAVE_FMA; constexpr inline bool __have_fma4 = _GLIBCXX_SIMD_HAVE_FMA4; constexpr inline bool __have_f16c = _GLIBCXX_SIMD_HAVE_F16C; constexpr inline bool __have_popcnt = _GLIBCXX_SIMD_HAVE_POPCNT; constexpr inline bool __have_avx512f = _GLIBCXX_SIMD_HAVE_AVX512F; constexpr inline bool __have_avx512dq = _GLIBCXX_SIMD_HAVE_AVX512DQ; constexpr inline bool __have_avx512vl = _GLIBCXX_SIMD_HAVE_AVX512VL; constexpr inline bool __have_avx512bw = _GLIBCXX_SIMD_HAVE_AVX512BW; constexpr inline bool __have_avx512dq_vl = __have_avx512dq && __have_avx512vl; constexpr inline bool __have_avx512bw_vl = __have_avx512bw && __have_avx512vl; constexpr inline bool __have_neon = _GLIBCXX_SIMD_HAVE_NEON; constexpr inline bool __have_neon_a32 = _GLIBCXX_SIMD_HAVE_NEON_A32; constexpr inline bool __have_neon_a64 = _GLIBCXX_SIMD_HAVE_NEON_A64; constexpr inline bool __support_neon_float = #if defined __GCC_IEC_559 __GCC_IEC_559 == 0; #elif defined __FAST_MATH__ true; #else false; #endif #ifdef _ARCH_PWR10 constexpr inline bool __have_power10vec = true; #else constexpr inline bool __have_power10vec = false; #endif #ifdef __POWER9_VECTOR__ constexpr inline bool __have_power9vec = true; #else constexpr inline bool __have_power9vec = false; #endif #if defined __POWER8_VECTOR__ constexpr inline bool __have_power8vec = true; #else constexpr inline bool __have_power8vec = __have_power9vec; #endif #if defined __VSX__ constexpr inline bool __have_power_vsx = true; #else constexpr inline bool __have_power_vsx = __have_power8vec; #endif #if defined __ALTIVEC__ constexpr inline bool __have_power_vmx = true; #else constexpr inline bool __have_power_vmx = __have_power_vsx; #endif // }}} // __is_scalar_abi {{{ template <typename _Abi> constexpr bool __is_scalar_abi() { return is_same_v<simd_abi::scalar, _Abi>; } // }}} // __abi_bytes_v {{{ template <template <int> class _Abi, int _Bytes> constexpr int __abi_bytes_impl(_Abi<_Bytes>*) { return _Bytes; } template <typename _Tp> constexpr int __abi_bytes_impl(_Tp*) { return -1; } template <typename _Abi> inline constexpr int __abi_bytes_v = __abi_bytes_impl(static_cast<_Abi*>(nullptr)); // }}} // __is_builtin_bitmask_abi {{{ template <typename _Abi> constexpr bool __is_builtin_bitmask_abi() { return is_same_v<simd_abi::_VecBltnBtmsk<__abi_bytes_v<_Abi>>, _Abi>; } // }}} // __is_sse_abi {{{ template <typename _Abi> constexpr bool __is_sse_abi() { constexpr auto _Bytes = __abi_bytes_v<_Abi>; return _Bytes <= 16 && is_same_v<simd_abi::_VecBuiltin<_Bytes>, _Abi>; } // }}} // __is_avx_abi {{{ template <typename _Abi> constexpr bool __is_avx_abi() { constexpr auto _Bytes = __abi_bytes_v<_Abi>; return _Bytes > 16 && _Bytes <= 32 && is_same_v<simd_abi::_VecBuiltin<_Bytes>, _Abi>; } // }}} // __is_avx512_abi {{{ template <typename _Abi> constexpr bool __is_avx512_abi() { constexpr auto _Bytes = __abi_bytes_v<_Abi>; return _Bytes <= 64 && is_same_v<simd_abi::_Avx512<_Bytes>, _Abi>; } // }}} // __is_neon_abi {{{ template <typename _Abi> constexpr bool __is_neon_abi() { constexpr auto _Bytes = __abi_bytes_v<_Abi>; return _Bytes <= 16 && is_same_v<simd_abi::_VecBuiltin<_Bytes>, _Abi>; } // }}} // __make_dependent_t {{{ template <typename, typename _Up> struct __make_dependent { using type = _Up; }; template <typename _Tp, typename _Up> using __make_dependent_t = typename __make_dependent<_Tp, _Up>::type; // }}} // ^^^ ---- type traits ---- ^^^ // __invoke_ub{{{ template <typename... _Args> [[noreturn]] _GLIBCXX_SIMD_ALWAYS_INLINE void __invoke_ub([[maybe_unused]] const char* __msg, [[maybe_unused]] const _Args&... __args) { #ifdef _GLIBCXX_DEBUG_UB __builtin_fprintf(stderr, __msg, __args...); __builtin_trap(); #else __builtin_unreachable(); #endif } // }}} // __assert_unreachable{{{ template <typename _Tp> struct __assert_unreachable { static_assert(!is_same_v<_Tp, _Tp>, "this should be unreachable"); }; // }}} // __size_or_zero_v {{{ template <typename _Tp, typename _Ap, size_t _Np = simd_size<_Tp, _Ap>::value> constexpr size_t __size_or_zero_dispatch(int) { return _Np; } template <typename _Tp, typename _Ap> constexpr size_t __size_or_zero_dispatch(float) { return 0; } template <typename _Tp, typename _Ap> inline constexpr size_t __size_or_zero_v = __size_or_zero_dispatch<_Tp, _Ap>(0); // }}} // __div_roundup {{{ inline constexpr size_t __div_roundup(size_t __a, size_t __b) { return (__a + __b - 1) / __b; } // }}} // _ExactBool{{{ class _ExactBool { const bool _M_data; public: _GLIBCXX_SIMD_INTRINSIC constexpr _ExactBool(bool __b) : _M_data(__b) {} _ExactBool(int) = delete; _GLIBCXX_SIMD_INTRINSIC constexpr operator bool() const { return _M_data; } }; // }}} // __may_alias{{{ /**@internal * Helper __may_alias<_Tp> that turns _Tp into the type to be used for an * aliasing pointer. This adds the __may_alias attribute to _Tp (with compilers * that support it). */ template <typename _Tp> using __may_alias [[__gnu__::__may_alias__]] = _Tp; // }}} // _UnsupportedBase {{{ // simd and simd_mask base for unsupported <_Tp, _Abi> struct _UnsupportedBase { _UnsupportedBase() = delete; _UnsupportedBase(const _UnsupportedBase&) = delete; _UnsupportedBase& operator=(const _UnsupportedBase&) = delete; ~_UnsupportedBase() = delete; }; // }}} // _InvalidTraits {{{ /** * @internal * Defines the implementation of __a given <_Tp, _Abi>. * * Implementations must ensure that only valid <_Tp, _Abi> instantiations are * possible. Static assertions in the type definition do not suffice. It is * important that SFINAE works. */ struct _InvalidTraits { using _IsValid = false_type; using _SimdBase = _UnsupportedBase; using _MaskBase = _UnsupportedBase; static constexpr size_t _S_full_size = 0; static constexpr bool _S_is_partial = false; static constexpr size_t _S_simd_align = 1; struct _SimdImpl; struct _SimdMember {}; struct _SimdCastType; static constexpr size_t _S_mask_align = 1; struct _MaskImpl; struct _MaskMember {}; struct _MaskCastType; }; // }}} // _SimdTraits {{{ template <typename _Tp, typename _Abi, typename = void_t<>> struct _SimdTraits : _InvalidTraits {}; // }}} // __private_init, __bitset_init{{{ /** * @internal * Tag used for private init constructor of simd and simd_mask */ inline constexpr struct _PrivateInit {} __private_init = {}; inline constexpr struct _BitsetInit {} __bitset_init = {}; // }}} // __is_narrowing_conversion<_From, _To>{{{ template <typename _From, typename _To, bool = is_arithmetic_v<_From>, bool = is_arithmetic_v<_To>> struct __is_narrowing_conversion; // ignore "signed/unsigned mismatch" in the following trait. // The implicit conversions will do the right thing here. template <typename _From, typename _To> struct __is_narrowing_conversion<_From, _To, true, true> : public __bool_constant<( __digits_v<_From> > __digits_v<_To> || __finite_max_v<_From> > __finite_max_v<_To> || __finite_min_v<_From> < __finite_min_v<_To> || (is_signed_v<_From> && is_unsigned_v<_To>))> {}; template <typename _Tp> struct __is_narrowing_conversion<_Tp, bool, true, true> : public true_type {}; template <> struct __is_narrowing_conversion<bool, bool, true, true> : public false_type {}; template <typename _Tp> struct __is_narrowing_conversion<_Tp, _Tp, true, true> : public false_type {}; template <typename _From, typename _To> struct __is_narrowing_conversion<_From, _To, false, true> : public negation<is_convertible<_From, _To>> {}; // }}} // __converts_to_higher_integer_rank{{{ template <typename _From, typename _To, bool = (sizeof(_From) < sizeof(_To))> struct __converts_to_higher_integer_rank : public true_type {}; // this may fail for char -> short if sizeof(char) == sizeof(short) template <typename _From, typename _To> struct __converts_to_higher_integer_rank<_From, _To, false> : public is_same<decltype(declval<_From>() + declval<_To>()), _To> {}; // }}} // __data(simd/simd_mask) {{{ template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC constexpr const auto& __data(const simd<_Tp, _Ap>& __x); template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC constexpr auto& __data(simd<_Tp, _Ap>& __x); template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC constexpr const auto& __data(const simd_mask<_Tp, _Ap>& __x); template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC constexpr auto& __data(simd_mask<_Tp, _Ap>& __x); // }}} // _SimdConverter {{{ template <typename _FromT, typename _FromA, typename _ToT, typename _ToA, typename = void> struct _SimdConverter; template <typename _Tp, typename _Ap> struct _SimdConverter<_Tp, _Ap, _Tp, _Ap, void> { template <typename _Up> _GLIBCXX_SIMD_INTRINSIC const _Up& operator()(const _Up& __x) { return __x; } }; // }}} // __to_value_type_or_member_type {{{ template <typename _V> _GLIBCXX_SIMD_INTRINSIC constexpr auto __to_value_type_or_member_type(const _V& __x) -> decltype(__data(__x)) { return __data(__x); } template <typename _V> _GLIBCXX_SIMD_INTRINSIC constexpr const typename _V::value_type& __to_value_type_or_member_type(const typename _V::value_type& __x) { return __x; } // }}} // __bool_storage_member_type{{{ template <size_t _Size> struct __bool_storage_member_type; template <size_t _Size> using __bool_storage_member_type_t = typename __bool_storage_member_type<_Size>::type; // }}} // _SimdTuple {{{ // why not tuple? // 1. tuple gives no guarantee about the storage order, but I require // storage // equivalent to array<_Tp, _Np> // 2. direct access to the element type (first template argument) // 3. enforces equal element type, only different _Abi types are allowed template <typename _Tp, typename... _Abis> struct _SimdTuple; //}}} // __fixed_size_storage_t {{{ template <typename _Tp, int _Np> struct __fixed_size_storage; template <typename _Tp, int _Np> using __fixed_size_storage_t = typename __fixed_size_storage<_Tp, _Np>::type; // }}} // _SimdWrapper fwd decl{{{ template <typename _Tp, size_t _Size, typename = void_t<>> struct _SimdWrapper; template <typename _Tp> using _SimdWrapper8 = _SimdWrapper<_Tp, 8 / sizeof(_Tp)>; template <typename _Tp> using _SimdWrapper16 = _SimdWrapper<_Tp, 16 / sizeof(_Tp)>; template <typename _Tp> using _SimdWrapper32 = _SimdWrapper<_Tp, 32 / sizeof(_Tp)>; template <typename _Tp> using _SimdWrapper64 = _SimdWrapper<_Tp, 64 / sizeof(_Tp)>; // }}} // __is_simd_wrapper {{{ template <typename _Tp> struct __is_simd_wrapper : false_type {}; template <typename _Tp, size_t _Np> struct __is_simd_wrapper<_SimdWrapper<_Tp, _Np>> : true_type {}; template <typename _Tp> inline constexpr bool __is_simd_wrapper_v = __is_simd_wrapper<_Tp>::value; // }}} // _BitOps {{{ struct _BitOps { // _S_bit_iteration {{{ template <typename _Tp, typename _Fp> static void _S_bit_iteration(_Tp __mask, _Fp&& __f) { static_assert(sizeof(_ULLong) >= sizeof(_Tp)); conditional_t<sizeof(_Tp) <= sizeof(_UInt), _UInt, _ULLong> __k; if constexpr (is_convertible_v<_Tp, decltype(__k)>) __k = __mask; else __k = __mask.to_ullong(); while(__k) { __f(std::__countr_zero(__k)); __k &= (__k - 1); } } //}}} }; //}}} // __increment, __decrement {{{ template <typename _Tp = void> struct __increment { constexpr _Tp operator()(_Tp __a) const { return ++__a; } }; template <> struct __increment<void> { template <typename _Tp> constexpr _Tp operator()(_Tp __a) const { return ++__a; } }; template <typename _Tp = void> struct __decrement { constexpr _Tp operator()(_Tp __a) const { return --__a; } }; template <> struct __decrement<void> { template <typename _Tp> constexpr _Tp operator()(_Tp __a) const { return --__a; } }; // }}} // _ValuePreserving(OrInt) {{{ template <typename _From, typename _To, typename = enable_if_t<negation< __is_narrowing_conversion<__remove_cvref_t<_From>, _To>>::value>> using _ValuePreserving = _From; template <typename _From, typename _To, typename _DecayedFrom = __remove_cvref_t<_From>, typename = enable_if_t<conjunction< is_convertible<_From, _To>, disjunction< is_same<_DecayedFrom, _To>, is_same<_DecayedFrom, int>, conjunction<is_same<_DecayedFrom, _UInt>, is_unsigned<_To>>, negation<__is_narrowing_conversion<_DecayedFrom, _To>>>>::value>> using _ValuePreservingOrInt = _From; // }}} // __intrinsic_type {{{ template <typename _Tp, size_t _Bytes, typename = void_t<>> struct __intrinsic_type; template <typename _Tp, size_t _Size> using __intrinsic_type_t = typename __intrinsic_type<_Tp, _Size * sizeof(_Tp)>::type; template <typename _Tp> using __intrinsic_type2_t = typename __intrinsic_type<_Tp, 2>::type; template <typename _Tp> using __intrinsic_type4_t = typename __intrinsic_type<_Tp, 4>::type; template <typename _Tp> using __intrinsic_type8_t = typename __intrinsic_type<_Tp, 8>::type; template <typename _Tp> using __intrinsic_type16_t = typename __intrinsic_type<_Tp, 16>::type; template <typename _Tp> using __intrinsic_type32_t = typename __intrinsic_type<_Tp, 32>::type; template <typename _Tp> using __intrinsic_type64_t = typename __intrinsic_type<_Tp, 64>::type; // }}} // _BitMask {{{ template <size_t _Np, bool _Sanitized = false> struct _BitMask; template <size_t _Np, bool _Sanitized> struct __is_bitmask<_BitMask<_Np, _Sanitized>, void> : true_type {}; template <size_t _Np> using _SanitizedBitMask = _BitMask<_Np, true>; template <size_t _Np, bool _Sanitized> struct _BitMask { static_assert(_Np > 0); static constexpr size_t _NBytes = __div_roundup(_Np, __CHAR_BIT__); using _Tp = conditional_t<_Np == 1, bool, make_unsigned_t<__int_with_sizeof_t<std::min( sizeof(_ULLong), std::__bit_ceil(_NBytes))>>>; static constexpr int _S_array_size = __div_roundup(_NBytes, sizeof(_Tp)); _Tp _M_bits[_S_array_size]; static constexpr int _S_unused_bits = _Np == 1 ? 0 : _S_array_size * sizeof(_Tp) * __CHAR_BIT__ - _Np; static constexpr _Tp _S_bitmask = +_Tp(~_Tp()) >> _S_unused_bits; constexpr _BitMask() noexcept = default; constexpr _BitMask(unsigned long long __x) noexcept : _M_bits{static_cast<_Tp>(__x)} {} _BitMask(bitset<_Np> __x) noexcept : _BitMask(__x.to_ullong()) {} constexpr _BitMask(const _BitMask&) noexcept = default; template <bool _RhsSanitized, typename = enable_if_t<_RhsSanitized == false && _Sanitized == true>> constexpr _BitMask(const _BitMask<_Np, _RhsSanitized>& __rhs) noexcept : _BitMask(__rhs._M_sanitized()) {} constexpr operator _SimdWrapper<bool, _Np>() const noexcept { static_assert(_S_array_size == 1); return _M_bits[0]; } // precondition: is sanitized constexpr _Tp _M_to_bits() const noexcept { static_assert(_S_array_size == 1); return _M_bits[0]; } // precondition: is sanitized constexpr unsigned long long to_ullong() const noexcept { static_assert(_S_array_size == 1); return _M_bits[0]; } // precondition: is sanitized constexpr unsigned long to_ulong() const noexcept { static_assert(_S_array_size == 1); return _M_bits[0]; } constexpr bitset<_Np> _M_to_bitset() const noexcept { static_assert(_S_array_size == 1); return _M_bits[0]; } constexpr decltype(auto) _M_sanitized() const noexcept { if constexpr (_Sanitized) return *this; else if constexpr (_Np == 1) return _SanitizedBitMask<_Np>(_M_bits[0]); else { _SanitizedBitMask<_Np> __r = {}; for (int __i = 0; __i < _S_array_size; ++__i) __r._M_bits[__i] = _M_bits[__i]; if constexpr (_S_unused_bits > 0) __r._M_bits[_S_array_size - 1] &= _S_bitmask; return __r; } } template <size_t _Mp, bool _LSanitized> constexpr _BitMask<_Np + _Mp, _Sanitized> _M_prepend(_BitMask<_Mp, _LSanitized> __lsb) const noexcept { constexpr size_t _RN = _Np + _Mp; using _Rp = _BitMask<_RN, _Sanitized>; if constexpr (_Rp::_S_array_size == 1) { _Rp __r{{_M_bits[0]}}; __r._M_bits[0] <<= _Mp; __r._M_bits[0] |= __lsb._M_sanitized()._M_bits[0]; return __r; } else __assert_unreachable<_Rp>(); } // Return a new _BitMask with size _NewSize while dropping _DropLsb least // significant bits. If the operation implicitly produces a sanitized bitmask, // the result type will have _Sanitized set. template <size_t _DropLsb, size_t _NewSize = _Np - _DropLsb> constexpr auto _M_extract() const noexcept { static_assert(_Np > _DropLsb); static_assert(_DropLsb + _NewSize <= sizeof(_ULLong) * __CHAR_BIT__, "not implemented for bitmasks larger than one ullong"); if constexpr (_NewSize == 1) // must sanitize because the return _Tp is bool return _SanitizedBitMask<1>(_M_bits[0] & (_Tp(1) << _DropLsb)); else return _BitMask<_NewSize, ((_NewSize + _DropLsb == sizeof(_Tp) * __CHAR_BIT__ && _NewSize + _DropLsb <= _Np) || ((_Sanitized || _Np == sizeof(_Tp) * __CHAR_BIT__) && _NewSize + _DropLsb >= _Np))>(_M_bits[0] >> _DropLsb); } // True if all bits are set. Implicitly sanitizes if _Sanitized == false. constexpr bool all() const noexcept { if constexpr (_Np == 1) return _M_bits[0]; else if constexpr (!_Sanitized) return _M_sanitized().all(); else { constexpr _Tp __allbits = ~_Tp(); for (int __i = 0; __i < _S_array_size - 1; ++__i) if (_M_bits[__i] != __allbits) return false; return _M_bits[_S_array_size - 1] == _S_bitmask; } } // True if at least one bit is set. Implicitly sanitizes if _Sanitized == // false. constexpr bool any() const noexcept { if constexpr (_Np == 1) return _M_bits[0]; else if constexpr (!_Sanitized) return _M_sanitized().any(); else { for (int __i = 0; __i < _S_array_size - 1; ++__i) if (_M_bits[__i] != 0) return true; return _M_bits[_S_array_size - 1] != 0; } } // True if no bit is set. Implicitly sanitizes if _Sanitized == false. constexpr bool none() const noexcept { if constexpr (_Np == 1) return !_M_bits[0]; else if constexpr (!_Sanitized) return _M_sanitized().none(); else { for (int __i = 0; __i < _S_array_size - 1; ++__i) if (_M_bits[__i] != 0) return false; return _M_bits[_S_array_size - 1] == 0; } } // Returns the number of set bits. Implicitly sanitizes if _Sanitized == // false. constexpr int count() const noexcept { if constexpr (_Np == 1) return _M_bits[0]; else if constexpr (!_Sanitized) return _M_sanitized().none(); else { int __result = __builtin_popcountll(_M_bits[0]); for (int __i = 1; __i < _S_array_size; ++__i) __result += __builtin_popcountll(_M_bits[__i]); return __result; } } // Returns the bit at offset __i as bool. constexpr bool operator[](size_t __i) const noexcept { if constexpr (_Np == 1) return _M_bits[0]; else if constexpr (_S_array_size == 1) return (_M_bits[0] >> __i) & 1; else { const size_t __j = __i / (sizeof(_Tp) * __CHAR_BIT__); const size_t __shift = __i % (sizeof(_Tp) * __CHAR_BIT__); return (_M_bits[__j] >> __shift) & 1; } } template <size_t __i> constexpr bool operator[](_SizeConstant<__i>) const noexcept { static_assert(__i < _Np); constexpr size_t __j = __i / (sizeof(_Tp) * __CHAR_BIT__); constexpr size_t __shift = __i % (sizeof(_Tp) * __CHAR_BIT__); return static_cast<bool>(_M_bits[__j] & (_Tp(1) << __shift)); } // Set the bit at offset __i to __x. constexpr void set(size_t __i, bool __x) noexcept { if constexpr (_Np == 1) _M_bits[0] = __x; else if constexpr (_S_array_size == 1) { _M_bits[0] &= ~_Tp(_Tp(1) << __i); _M_bits[0] |= _Tp(_Tp(__x) << __i); } else { const size_t __j = __i / (sizeof(_Tp) * __CHAR_BIT__); const size_t __shift = __i % (sizeof(_Tp) * __CHAR_BIT__); _M_bits[__j] &= ~_Tp(_Tp(1) << __shift); _M_bits[__j] |= _Tp(_Tp(__x) << __shift); } } template <size_t __i> constexpr void set(_SizeConstant<__i>, bool __x) noexcept { static_assert(__i < _Np); if constexpr (_Np == 1) _M_bits[0] = __x; else { constexpr size_t __j = __i / (sizeof(_Tp) * __CHAR_BIT__); constexpr size_t __shift = __i % (sizeof(_Tp) * __CHAR_BIT__); constexpr _Tp __mask = ~_Tp(_Tp(1) << __shift); _M_bits[__j] &= __mask; _M_bits[__j] |= _Tp(_Tp(__x) << __shift); } } // Inverts all bits. Sanitized input leads to sanitized output. constexpr _BitMask operator~() const noexcept { if constexpr (_Np == 1) return !_M_bits[0]; else { _BitMask __result{}; for (int __i = 0; __i < _S_array_size - 1; ++__i) __result._M_bits[__i] = ~_M_bits[__i]; if constexpr (_Sanitized) __result._M_bits[_S_array_size - 1] = _M_bits[_S_array_size - 1] ^ _S_bitmask; else __result._M_bits[_S_array_size - 1] = ~_M_bits[_S_array_size - 1]; return __result; } } constexpr _BitMask& operator^=(const _BitMask& __b) & noexcept { __execute_n_times<_S_array_size>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { _M_bits[__i] ^= __b._M_bits[__i]; }); return *this; } constexpr _BitMask& operator|=(const _BitMask& __b) & noexcept { __execute_n_times<_S_array_size>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { _M_bits[__i] |= __b._M_bits[__i]; }); return *this; } constexpr _BitMask& operator&=(const _BitMask& __b) & noexcept { __execute_n_times<_S_array_size>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { _M_bits[__i] &= __b._M_bits[__i]; }); return *this; } friend constexpr _BitMask operator^(const _BitMask& __a, const _BitMask& __b) noexcept { _BitMask __r = __a; __r ^= __b; return __r; } friend constexpr _BitMask operator|(const _BitMask& __a, const _BitMask& __b) noexcept { _BitMask __r = __a; __r |= __b; return __r; } friend constexpr _BitMask operator&(const _BitMask& __a, const _BitMask& __b) noexcept { _BitMask __r = __a; __r &= __b; return __r; } _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop() const { if constexpr (_S_array_size == 0) return __builtin_constant_p(_M_bits[0]); else { for (int __i = 0; __i < _S_array_size; ++__i) if (!__builtin_constant_p(_M_bits[__i])) return false; return true; } } }; // }}} // vvv ---- builtin vector types [[gnu::vector_size(N)]] and operations ---- vvv // __min_vector_size {{{ template <typename _Tp = void> static inline constexpr int __min_vector_size = 2 * sizeof(_Tp); #if _GLIBCXX_SIMD_HAVE_NEON template <> inline constexpr int __min_vector_size<void> = 8; #else template <> inline constexpr int __min_vector_size<void> = 16; #endif // }}} // __vector_type {{{ template <typename _Tp, size_t _Np, typename = void> struct __vector_type_n {}; // substition failure for 0-element case template <typename _Tp> struct __vector_type_n<_Tp, 0, void> {}; // special case 1-element to be _Tp itself template <typename _Tp> struct __vector_type_n<_Tp, 1, enable_if_t<__is_vectorizable_v<_Tp>>> { using type = _Tp; }; // else, use GNU-style builtin vector types template <typename _Tp, size_t _Np> struct __vector_type_n<_Tp, _Np, enable_if_t<__is_vectorizable_v<_Tp> && _Np >= 2>> { static constexpr size_t _S_Np2 = std::__bit_ceil(_Np * sizeof(_Tp)); static constexpr size_t _S_Bytes = #ifdef __i386__ // Using [[gnu::vector_size(8)]] would wreak havoc on the FPU because // those objects are passed via MMX registers and nothing ever calls EMMS. _S_Np2 == 8 ? 16 : #endif _S_Np2 < __min_vector_size<_Tp> ? __min_vector_size<_Tp> : _S_Np2; using type [[__gnu__::__vector_size__(_S_Bytes)]] = _Tp; }; template <typename _Tp, size_t _Bytes, size_t = _Bytes % sizeof(_Tp)> struct __vector_type; template <typename _Tp, size_t _Bytes> struct __vector_type<_Tp, _Bytes, 0> : __vector_type_n<_Tp, _Bytes / sizeof(_Tp)> {}; template <typename _Tp, size_t _Size> using __vector_type_t = typename __vector_type_n<_Tp, _Size>::type; template <typename _Tp> using __vector_type2_t = typename __vector_type<_Tp, 2>::type; template <typename _Tp> using __vector_type4_t = typename __vector_type<_Tp, 4>::type; template <typename _Tp> using __vector_type8_t = typename __vector_type<_Tp, 8>::type; template <typename _Tp> using __vector_type16_t = typename __vector_type<_Tp, 16>::type; template <typename _Tp> using __vector_type32_t = typename __vector_type<_Tp, 32>::type; template <typename _Tp> using __vector_type64_t = typename __vector_type<_Tp, 64>::type; // }}} // __is_vector_type {{{ template <typename _Tp, typename = void_t<>> struct __is_vector_type : false_type {}; template <typename _Tp> struct __is_vector_type< _Tp, void_t<typename __vector_type< remove_reference_t<decltype(declval<_Tp>()[0])>, sizeof(_Tp)>::type>> : is_same<_Tp, typename __vector_type< remove_reference_t<decltype(declval<_Tp>()[0])>, sizeof(_Tp)>::type> {}; template <typename _Tp> inline constexpr bool __is_vector_type_v = __is_vector_type<_Tp>::value; // }}} // __is_intrinsic_type {{{ #if _GLIBCXX_SIMD_HAVE_SSE_ABI template <typename _Tp> using __is_intrinsic_type = __is_vector_type<_Tp>; #else // not SSE (x86) template <typename _Tp, typename = void_t<>> struct __is_intrinsic_type : false_type {}; template <typename _Tp> struct __is_intrinsic_type< _Tp, void_t<typename __intrinsic_type< remove_reference_t<decltype(declval<_Tp>()[0])>, sizeof(_Tp)>::type>> : is_same<_Tp, typename __intrinsic_type< remove_reference_t<decltype(declval<_Tp>()[0])>, sizeof(_Tp)>::type> {}; #endif template <typename _Tp> inline constexpr bool __is_intrinsic_type_v = __is_intrinsic_type<_Tp>::value; // }}} // _VectorTraits{{{ template <typename _Tp, typename = void_t<>> struct _VectorTraitsImpl; template <typename _Tp> struct _VectorTraitsImpl<_Tp, enable_if_t<__is_vector_type_v<_Tp> || __is_intrinsic_type_v<_Tp>>> { using type = _Tp; using value_type = remove_reference_t<decltype(declval<_Tp>()[0])>; static constexpr int _S_full_size = sizeof(_Tp) / sizeof(value_type); using _Wrapper = _SimdWrapper<value_type, _S_full_size>; template <typename _Up, int _W = _S_full_size> static constexpr bool _S_is = is_same_v<value_type, _Up> && _W == _S_full_size; }; template <typename _Tp, size_t _Np> struct _VectorTraitsImpl<_SimdWrapper<_Tp, _Np>, void_t<__vector_type_t<_Tp, _Np>>> { using type = __vector_type_t<_Tp, _Np>; using value_type = _Tp; static constexpr int _S_full_size = sizeof(type) / sizeof(value_type); using _Wrapper = _SimdWrapper<_Tp, _Np>; static constexpr bool _S_is_partial = (_Np == _S_full_size); static constexpr int _S_partial_width = _Np; template <typename _Up, int _W = _S_full_size> static constexpr bool _S_is = is_same_v<value_type, _Up>&& _W == _S_full_size; }; template <typename _Tp, typename = typename _VectorTraitsImpl<_Tp>::type> using _VectorTraits = _VectorTraitsImpl<_Tp>; // }}} // __as_vector{{{ template <typename _V> _GLIBCXX_SIMD_INTRINSIC constexpr auto __as_vector(_V __x) { if constexpr (__is_vector_type_v<_V>) return __x; else if constexpr (is_simd<_V>::value || is_simd_mask<_V>::value) return __data(__x)._M_data; else if constexpr (__is_vectorizable_v<_V>) return __vector_type_t<_V, 2>{__x}; else return __x._M_data; } // }}} // __as_wrapper{{{ template <size_t _Np = 0, typename _V> _GLIBCXX_SIMD_INTRINSIC constexpr auto __as_wrapper(_V __x) { if constexpr (__is_vector_type_v<_V>) return _SimdWrapper<typename _VectorTraits<_V>::value_type, (_Np > 0 ? _Np : _VectorTraits<_V>::_S_full_size)>(__x); else if constexpr (is_simd<_V>::value || is_simd_mask<_V>::value) { static_assert(_V::size() == _Np); return __data(__x); } else { static_assert(_V::_S_size == _Np); return __x; } } // }}} // __intrin_bitcast{{{ template <typename _To, typename _From> _GLIBCXX_SIMD_INTRINSIC constexpr _To __intrin_bitcast(_From __v) { static_assert((__is_vector_type_v<_From> || __is_intrinsic_type_v<_From>) && (__is_vector_type_v<_To> || __is_intrinsic_type_v<_To>)); if constexpr (sizeof(_To) == sizeof(_From)) return reinterpret_cast<_To>(__v); else if constexpr (sizeof(_From) > sizeof(_To)) if constexpr (sizeof(_To) >= 16) return reinterpret_cast<const __may_alias<_To>&>(__v); else { _To __r; __builtin_memcpy(&__r, &__v, sizeof(_To)); return __r; } #if _GLIBCXX_SIMD_X86INTRIN && !defined __clang__ else if constexpr (__have_avx && sizeof(_From) == 16 && sizeof(_To) == 32) return reinterpret_cast<_To>(__builtin_ia32_ps256_ps( reinterpret_cast<__vector_type_t<float, 4>>(__v))); else if constexpr (__have_avx512f && sizeof(_From) == 16 && sizeof(_To) == 64) return reinterpret_cast<_To>(__builtin_ia32_ps512_ps( reinterpret_cast<__vector_type_t<float, 4>>(__v))); else if constexpr (__have_avx512f && sizeof(_From) == 32 && sizeof(_To) == 64) return reinterpret_cast<_To>(__builtin_ia32_ps512_256ps( reinterpret_cast<__vector_type_t<float, 8>>(__v))); #endif // _GLIBCXX_SIMD_X86INTRIN else if constexpr (sizeof(__v) <= 8) return reinterpret_cast<_To>( __vector_type_t<__int_for_sizeof_t<_From>, sizeof(_To) / sizeof(_From)>{ reinterpret_cast<__int_for_sizeof_t<_From>>(__v)}); else { static_assert(sizeof(_To) > sizeof(_From)); _To __r = {}; __builtin_memcpy(&__r, &__v, sizeof(_From)); return __r; } } // }}} // __vector_bitcast{{{ template <typename _To, size_t _NN = 0, typename _From, typename _FromVT = _VectorTraits<_From>, size_t _Np = _NN == 0 ? sizeof(_From) / sizeof(_To) : _NN> _GLIBCXX_SIMD_INTRINSIC constexpr __vector_type_t<_To, _Np> __vector_bitcast(_From __x) { using _R = __vector_type_t<_To, _Np>; return __intrin_bitcast<_R>(__x); } template <typename _To, size_t _NN = 0, typename _Tp, size_t _Nx, size_t _Np = _NN == 0 ? sizeof(_SimdWrapper<_Tp, _Nx>) / sizeof(_To) : _NN> _GLIBCXX_SIMD_INTRINSIC constexpr __vector_type_t<_To, _Np> __vector_bitcast(const _SimdWrapper<_Tp, _Nx>& __x) { static_assert(_Np > 1); return __intrin_bitcast<__vector_type_t<_To, _Np>>(__x._M_data); } // }}} // __convert_x86 declarations {{{ #ifdef _GLIBCXX_SIMD_WORKAROUND_PR85048 template <typename _To, typename _Tp, typename _TVT = _VectorTraits<_Tp>> _To __convert_x86(_Tp); template <typename _To, typename _Tp, typename _TVT = _VectorTraits<_Tp>> _To __convert_x86(_Tp, _Tp); template <typename _To, typename _Tp, typename _TVT = _VectorTraits<_Tp>> _To __convert_x86(_Tp, _Tp, _Tp, _Tp); template <typename _To, typename _Tp, typename _TVT = _VectorTraits<_Tp>> _To __convert_x86(_Tp, _Tp, _Tp, _Tp, _Tp, _Tp, _Tp, _Tp); template <typename _To, typename _Tp, typename _TVT = _VectorTraits<_Tp>> _To __convert_x86(_Tp, _Tp, _Tp, _Tp, _Tp, _Tp, _Tp, _Tp, _Tp, _Tp, _Tp, _Tp, _Tp, _Tp, _Tp, _Tp); #endif // _GLIBCXX_SIMD_WORKAROUND_PR85048 //}}} // __bit_cast {{{ template <typename _To, typename _From> _GLIBCXX_SIMD_INTRINSIC constexpr _To __bit_cast(const _From __x) { // TODO: implement with / replace by __builtin_bit_cast ASAP static_assert(sizeof(_To) == sizeof(_From)); constexpr bool __to_is_vectorizable = is_arithmetic_v<_To> || is_enum_v<_To>; constexpr bool __from_is_vectorizable = is_arithmetic_v<_From> || is_enum_v<_From>; if constexpr (__is_vector_type_v<_To> && __is_vector_type_v<_From>) return reinterpret_cast<_To>(__x); else if constexpr (__is_vector_type_v<_To> && __from_is_vectorizable) { using _FV [[__gnu__::__vector_size__(sizeof(_From))]] = _From; return reinterpret_cast<_To>(_FV{__x}); } else if constexpr (__to_is_vectorizable && __from_is_vectorizable) { using _TV [[__gnu__::__vector_size__(sizeof(_To))]] = _To; using _FV [[__gnu__::__vector_size__(sizeof(_From))]] = _From; return reinterpret_cast<_TV>(_FV{__x})[0]; } else if constexpr (__to_is_vectorizable && __is_vector_type_v<_From>) { using _TV [[__gnu__::__vector_size__(sizeof(_To))]] = _To; return reinterpret_cast<_TV>(__x)[0]; } else { _To __r; __builtin_memcpy(reinterpret_cast<char*>(&__r), reinterpret_cast<const char*>(&__x), sizeof(_To)); return __r; } } // }}} // __to_intrin {{{ template <typename _Tp, typename _TVT = _VectorTraits<_Tp>, typename _R = __intrinsic_type_t<typename _TVT::value_type, _TVT::_S_full_size>> _GLIBCXX_SIMD_INTRINSIC constexpr _R __to_intrin(_Tp __x) { static_assert(sizeof(__x) <= sizeof(_R), "__to_intrin may never drop values off the end"); if constexpr (sizeof(__x) == sizeof(_R)) return reinterpret_cast<_R>(__as_vector(__x)); else { using _Up = __int_for_sizeof_t<_Tp>; return reinterpret_cast<_R>( __vector_type_t<_Up, sizeof(_R) / sizeof(_Up)>{__bit_cast<_Up>(__x)}); } } // }}} // __make_vector{{{ template <typename _Tp, typename... _Args> _GLIBCXX_SIMD_INTRINSIC constexpr __vector_type_t<_Tp, sizeof...(_Args)> __make_vector(const _Args&... __args) { return __vector_type_t<_Tp, sizeof...(_Args)>{static_cast<_Tp>(__args)...}; } // }}} // __vector_broadcast{{{ template <size_t _Np, typename _Tp, size_t... _I> _GLIBCXX_SIMD_INTRINSIC constexpr __vector_type_t<_Tp, _Np> __vector_broadcast_impl(_Tp __x, index_sequence<_I...>) { return __vector_type_t<_Tp, _Np>{((void)_I, __x)...}; } template <size_t _Np, typename _Tp> _GLIBCXX_SIMD_INTRINSIC constexpr __vector_type_t<_Tp, _Np> __vector_broadcast(_Tp __x) { return __vector_broadcast_impl<_Np, _Tp>(__x, make_index_sequence<_Np>()); } // }}} // __generate_vector{{{ template <typename _Tp, size_t _Np, typename _Gp, size_t... _I> _GLIBCXX_SIMD_INTRINSIC constexpr __vector_type_t<_Tp, _Np> __generate_vector_impl(_Gp&& __gen, index_sequence<_I...>) { return __vector_type_t<_Tp, _Np>{ static_cast<_Tp>(__gen(_SizeConstant<_I>()))...}; } template <typename _V, typename _VVT = _VectorTraits<_V>, typename _Gp> _GLIBCXX_SIMD_INTRINSIC constexpr _V __generate_vector(_Gp&& __gen) { if constexpr (__is_vector_type_v<_V>) return __generate_vector_impl<typename _VVT::value_type, _VVT::_S_full_size>( static_cast<_Gp&&>(__gen), make_index_sequence<_VVT::_S_full_size>()); else return __generate_vector_impl<typename _VVT::value_type, _VVT::_S_partial_width>( static_cast<_Gp&&>(__gen), make_index_sequence<_VVT::_S_partial_width>()); } template <typename _Tp, size_t _Np, typename _Gp> _GLIBCXX_SIMD_INTRINSIC constexpr __vector_type_t<_Tp, _Np> __generate_vector(_Gp&& __gen) { return __generate_vector_impl<_Tp, _Np>(static_cast<_Gp&&>(__gen), make_index_sequence<_Np>()); } // }}} // __xor{{{ template <typename _TW> _GLIBCXX_SIMD_INTRINSIC constexpr _TW __xor(_TW __a, _TW __b) noexcept { if constexpr (__is_vector_type_v<_TW> || __is_simd_wrapper_v<_TW>) { using _Tp = typename conditional_t<__is_simd_wrapper_v<_TW>, _TW, _VectorTraitsImpl<_TW>>::value_type; if constexpr (is_floating_point_v<_Tp>) { using _Ip = make_unsigned_t<__int_for_sizeof_t<_Tp>>; return __vector_bitcast<_Tp>(__vector_bitcast<_Ip>(__a) ^ __vector_bitcast<_Ip>(__b)); } else if constexpr (__is_vector_type_v<_TW>) return __a ^ __b; else return __a._M_data ^ __b._M_data; } else return __a ^ __b; } // }}} // __or{{{ template <typename _TW> _GLIBCXX_SIMD_INTRINSIC constexpr _TW __or(_TW __a, _TW __b) noexcept { if constexpr (__is_vector_type_v<_TW> || __is_simd_wrapper_v<_TW>) { using _Tp = typename conditional_t<__is_simd_wrapper_v<_TW>, _TW, _VectorTraitsImpl<_TW>>::value_type; if constexpr (is_floating_point_v<_Tp>) { using _Ip = make_unsigned_t<__int_for_sizeof_t<_Tp>>; return __vector_bitcast<_Tp>(__vector_bitcast<_Ip>(__a) | __vector_bitcast<_Ip>(__b)); } else if constexpr (__is_vector_type_v<_TW>) return __a | __b; else return __a._M_data | __b._M_data; } else return __a | __b; } // }}} // __and{{{ template <typename _TW> _GLIBCXX_SIMD_INTRINSIC constexpr _TW __and(_TW __a, _TW __b) noexcept { if constexpr (__is_vector_type_v<_TW> || __is_simd_wrapper_v<_TW>) { using _Tp = typename conditional_t<__is_simd_wrapper_v<_TW>, _TW, _VectorTraitsImpl<_TW>>::value_type; if constexpr (is_floating_point_v<_Tp>) { using _Ip = make_unsigned_t<__int_for_sizeof_t<_Tp>>; return __vector_bitcast<_Tp>(__vector_bitcast<_Ip>(__a) & __vector_bitcast<_Ip>(__b)); } else if constexpr (__is_vector_type_v<_TW>) return __a & __b; else return __a._M_data & __b._M_data; } else return __a & __b; } // }}} // __andnot{{{ #if _GLIBCXX_SIMD_X86INTRIN && !defined __clang__ static constexpr struct { _GLIBCXX_SIMD_INTRINSIC __v4sf operator()(__v4sf __a, __v4sf __b) const noexcept { return __builtin_ia32_andnps(__a, __b); } _GLIBCXX_SIMD_INTRINSIC __v2df operator()(__v2df __a, __v2df __b) const noexcept { return __builtin_ia32_andnpd(__a, __b); } _GLIBCXX_SIMD_INTRINSIC __v2di operator()(__v2di __a, __v2di __b) const noexcept { return __builtin_ia32_pandn128(__a, __b); } _GLIBCXX_SIMD_INTRINSIC __v8sf operator()(__v8sf __a, __v8sf __b) const noexcept { return __builtin_ia32_andnps256(__a, __b); } _GLIBCXX_SIMD_INTRINSIC __v4df operator()(__v4df __a, __v4df __b) const noexcept { return __builtin_ia32_andnpd256(__a, __b); } _GLIBCXX_SIMD_INTRINSIC __v4di operator()(__v4di __a, __v4di __b) const noexcept { if constexpr (__have_avx2) return __builtin_ia32_andnotsi256(__a, __b); else return reinterpret_cast<__v4di>( __builtin_ia32_andnpd256(reinterpret_cast<__v4df>(__a), reinterpret_cast<__v4df>(__b))); } _GLIBCXX_SIMD_INTRINSIC __v16sf operator()(__v16sf __a, __v16sf __b) const noexcept { if constexpr (__have_avx512dq) return _mm512_andnot_ps(__a, __b); else return reinterpret_cast<__v16sf>( _mm512_andnot_si512(reinterpret_cast<__v8di>(__a), reinterpret_cast<__v8di>(__b))); } _GLIBCXX_SIMD_INTRINSIC __v8df operator()(__v8df __a, __v8df __b) const noexcept { if constexpr (__have_avx512dq) return _mm512_andnot_pd(__a, __b); else return reinterpret_cast<__v8df>( _mm512_andnot_si512(reinterpret_cast<__v8di>(__a), reinterpret_cast<__v8di>(__b))); } _GLIBCXX_SIMD_INTRINSIC __v8di operator()(__v8di __a, __v8di __b) const noexcept { return _mm512_andnot_si512(__a, __b); } } _S_x86_andnot; #endif // _GLIBCXX_SIMD_X86INTRIN && !__clang__ template <typename _TW> _GLIBCXX_SIMD_INTRINSIC constexpr _TW __andnot(_TW __a, _TW __b) noexcept { if constexpr (__is_vector_type_v<_TW> || __is_simd_wrapper_v<_TW>) { using _TVT = conditional_t<__is_simd_wrapper_v<_TW>, _TW, _VectorTraitsImpl<_TW>>; using _Tp = typename _TVT::value_type; #if _GLIBCXX_SIMD_X86INTRIN && !defined __clang__ if constexpr (sizeof(_TW) >= 16) { const auto __ai = __to_intrin(__a); const auto __bi = __to_intrin(__b); if (!__builtin_is_constant_evaluated() && !(__builtin_constant_p(__ai) && __builtin_constant_p(__bi))) { const auto __r = _S_x86_andnot(__ai, __bi); if constexpr (is_convertible_v<decltype(__r), _TW>) return __r; else return reinterpret_cast<typename _TVT::type>(__r); } } #endif // _GLIBCXX_SIMD_X86INTRIN using _Ip = make_unsigned_t<__int_for_sizeof_t<_Tp>>; return __vector_bitcast<_Tp>(~__vector_bitcast<_Ip>(__a) & __vector_bitcast<_Ip>(__b)); } else return ~__a & __b; } // }}} // __not{{{ template <typename _Tp, typename _TVT = _VectorTraits<_Tp>> _GLIBCXX_SIMD_INTRINSIC constexpr _Tp __not(_Tp __a) noexcept { if constexpr (is_floating_point_v<typename _TVT::value_type>) return reinterpret_cast<typename _TVT::type>( ~__vector_bitcast<unsigned>(__a)); else return ~__a; } // }}} // __concat{{{ template <typename _Tp, typename _TVT = _VectorTraits<_Tp>, typename _R = __vector_type_t<typename _TVT::value_type, _TVT::_S_full_size * 2>> constexpr _R __concat(_Tp a_, _Tp b_) { #ifdef _GLIBCXX_SIMD_WORKAROUND_XXX_1 using _W = conditional_t<is_floating_point_v<typename _TVT::value_type>, double, conditional_t<(sizeof(_Tp) >= 2 * sizeof(long long)), long long, typename _TVT::value_type>>; constexpr int input_width = sizeof(_Tp) / sizeof(_W); const auto __a = __vector_bitcast<_W>(a_); const auto __b = __vector_bitcast<_W>(b_); using _Up = __vector_type_t<_W, sizeof(_R) / sizeof(_W)>; #else constexpr int input_width = _TVT::_S_full_size; const _Tp& __a = a_; const _Tp& __b = b_; using _Up = _R; #endif if constexpr (input_width == 2) return reinterpret_cast<_R>(_Up{__a[0], __a[1], __b[0], __b[1]}); else if constexpr (input_width == 4) return reinterpret_cast<_R>( _Up{__a[0], __a[1], __a[2], __a[3], __b[0], __b[1], __b[2], __b[3]}); else if constexpr (input_width == 8) return reinterpret_cast<_R>( _Up{__a[0], __a[1], __a[2], __a[3], __a[4], __a[5], __a[6], __a[7], __b[0], __b[1], __b[2], __b[3], __b[4], __b[5], __b[6], __b[7]}); else if constexpr (input_width == 16) return reinterpret_cast<_R>( _Up{__a[0], __a[1], __a[2], __a[3], __a[4], __a[5], __a[6], __a[7], __a[8], __a[9], __a[10], __a[11], __a[12], __a[13], __a[14], __a[15], __b[0], __b[1], __b[2], __b[3], __b[4], __b[5], __b[6], __b[7], __b[8], __b[9], __b[10], __b[11], __b[12], __b[13], __b[14], __b[15]}); else if constexpr (input_width == 32) return reinterpret_cast<_R>( _Up{__a[0], __a[1], __a[2], __a[3], __a[4], __a[5], __a[6], __a[7], __a[8], __a[9], __a[10], __a[11], __a[12], __a[13], __a[14], __a[15], __a[16], __a[17], __a[18], __a[19], __a[20], __a[21], __a[22], __a[23], __a[24], __a[25], __a[26], __a[27], __a[28], __a[29], __a[30], __a[31], __b[0], __b[1], __b[2], __b[3], __b[4], __b[5], __b[6], __b[7], __b[8], __b[9], __b[10], __b[11], __b[12], __b[13], __b[14], __b[15], __b[16], __b[17], __b[18], __b[19], __b[20], __b[21], __b[22], __b[23], __b[24], __b[25], __b[26], __b[27], __b[28], __b[29], __b[30], __b[31]}); } // }}} // __zero_extend {{{ template <typename _Tp, typename _TVT = _VectorTraits<_Tp>> struct _ZeroExtendProxy { using value_type = typename _TVT::value_type; static constexpr size_t _Np = _TVT::_S_full_size; const _Tp __x; template <typename _To, typename _ToVT = _VectorTraits<_To>, typename = enable_if_t<is_same_v<typename _ToVT::value_type, value_type>>> _GLIBCXX_SIMD_INTRINSIC operator _To() const { constexpr size_t _ToN = _ToVT::_S_full_size; if constexpr (_ToN == _Np) return __x; else if constexpr (_ToN == 2 * _Np) { #ifdef _GLIBCXX_SIMD_WORKAROUND_XXX_3 if constexpr (__have_avx && _TVT::template _S_is<float, 4>) return __vector_bitcast<value_type>( _mm256_insertf128_ps(__m256(), __x, 0)); else if constexpr (__have_avx && _TVT::template _S_is<double, 2>) return __vector_bitcast<value_type>( _mm256_insertf128_pd(__m256d(), __x, 0)); else if constexpr (__have_avx2 && _Np * sizeof(value_type) == 16) return __vector_bitcast<value_type>( _mm256_insertf128_si256(__m256i(), __to_intrin(__x), 0)); else if constexpr (__have_avx512f && _TVT::template _S_is<float, 8>) { if constexpr (__have_avx512dq) return __vector_bitcast<value_type>( _mm512_insertf32x8(__m512(), __x, 0)); else return reinterpret_cast<__m512>( _mm512_insertf64x4(__m512d(), reinterpret_cast<__m256d>(__x), 0)); } else if constexpr (__have_avx512f && _TVT::template _S_is<double, 4>) return __vector_bitcast<value_type>( _mm512_insertf64x4(__m512d(), __x, 0)); else if constexpr (__have_avx512f && _Np * sizeof(value_type) == 32) return __vector_bitcast<value_type>( _mm512_inserti64x4(__m512i(), __to_intrin(__x), 0)); #endif return __concat(__x, _Tp()); } else if constexpr (_ToN == 4 * _Np) { #ifdef _GLIBCXX_SIMD_WORKAROUND_XXX_3 if constexpr (__have_avx512dq && _TVT::template _S_is<double, 2>) { return __vector_bitcast<value_type>( _mm512_insertf64x2(__m512d(), __x, 0)); } else if constexpr (__have_avx512f && is_floating_point_v<value_type>) { return __vector_bitcast<value_type>( _mm512_insertf32x4(__m512(), reinterpret_cast<__m128>(__x), 0)); } else if constexpr (__have_avx512f && _Np * sizeof(value_type) == 16) { return __vector_bitcast<value_type>( _mm512_inserti32x4(__m512i(), __to_intrin(__x), 0)); } #endif return __concat(__concat(__x, _Tp()), __vector_type_t<value_type, _Np * 2>()); } else if constexpr (_ToN == 8 * _Np) return __concat(operator __vector_type_t<value_type, _Np * 4>(), __vector_type_t<value_type, _Np * 4>()); else if constexpr (_ToN == 16 * _Np) return __concat(operator __vector_type_t<value_type, _Np * 8>(), __vector_type_t<value_type, _Np * 8>()); else __assert_unreachable<_Tp>(); } }; template <typename _Tp, typename _TVT = _VectorTraits<_Tp>> _GLIBCXX_SIMD_INTRINSIC _ZeroExtendProxy<_Tp, _TVT> __zero_extend(_Tp __x) { return {__x}; } // }}} // __extract<_Np, By>{{{ template <int _Offset, int _SplitBy, typename _Tp, typename _TVT = _VectorTraits<_Tp>, typename _R = __vector_type_t<typename _TVT::value_type, _TVT::_S_full_size / _SplitBy>> _GLIBCXX_SIMD_INTRINSIC constexpr _R __extract(_Tp __in) { using value_type = typename _TVT::value_type; #if _GLIBCXX_SIMD_X86INTRIN // {{{ if constexpr (sizeof(_Tp) == 64 && _SplitBy == 4 && _Offset > 0) { if constexpr (__have_avx512dq && is_same_v<double, value_type>) return _mm512_extractf64x2_pd(__to_intrin(__in), _Offset); else if constexpr (is_floating_point_v<value_type>) return __vector_bitcast<value_type>( _mm512_extractf32x4_ps(__intrin_bitcast<__m512>(__in), _Offset)); else return reinterpret_cast<_R>( _mm512_extracti32x4_epi32(__intrin_bitcast<__m512i>(__in), _Offset)); } else #endif // _GLIBCXX_SIMD_X86INTRIN }}} { #ifdef _GLIBCXX_SIMD_WORKAROUND_XXX_1 using _W = conditional_t< is_floating_point_v<value_type>, double, conditional_t<(sizeof(_R) >= 16), long long, value_type>>; static_assert(sizeof(_R) % sizeof(_W) == 0); constexpr int __return_width = sizeof(_R) / sizeof(_W); using _Up = __vector_type_t<_W, __return_width>; const auto __x = __vector_bitcast<_W>(__in); #else constexpr int __return_width = _TVT::_S_full_size / _SplitBy; using _Up = _R; const __vector_type_t<value_type, _TVT::_S_full_size>& __x = __in; // only needed for _Tp = _SimdWrapper<value_type, _Np> #endif constexpr int _O = _Offset * __return_width; return __call_with_subscripts<__return_width, _O>( __x, [](auto... __entries) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return reinterpret_cast<_R>(_Up{__entries...}); }); } } // }}} // __lo/__hi64[z]{{{ template <typename _Tp, typename _R = __vector_type8_t<typename _VectorTraits<_Tp>::value_type>> _GLIBCXX_SIMD_INTRINSIC constexpr _R __lo64(_Tp __x) { _R __r{}; __builtin_memcpy(&__r, &__x, 8); return __r; } template <typename _Tp, typename _R = __vector_type8_t<typename _VectorTraits<_Tp>::value_type>> _GLIBCXX_SIMD_INTRINSIC constexpr _R __hi64(_Tp __x) { static_assert(sizeof(_Tp) == 16, "use __hi64z if you meant it"); _R __r{}; __builtin_memcpy(&__r, reinterpret_cast<const char*>(&__x) + 8, 8); return __r; } template <typename _Tp, typename _R = __vector_type8_t<typename _VectorTraits<_Tp>::value_type>> _GLIBCXX_SIMD_INTRINSIC constexpr _R __hi64z([[maybe_unused]] _Tp __x) { _R __r{}; if constexpr (sizeof(_Tp) == 16) __builtin_memcpy(&__r, reinterpret_cast<const char*>(&__x) + 8, 8); return __r; } // }}} // __lo/__hi128{{{ template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC constexpr auto __lo128(_Tp __x) { return __extract<0, sizeof(_Tp) / 16>(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC constexpr auto __hi128(_Tp __x) { static_assert(sizeof(__x) == 32); return __extract<1, 2>(__x); } // }}} // __lo/__hi256{{{ template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC constexpr auto __lo256(_Tp __x) { static_assert(sizeof(__x) == 64); return __extract<0, 2>(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC constexpr auto __hi256(_Tp __x) { static_assert(sizeof(__x) == 64); return __extract<1, 2>(__x); } // }}} // __auto_bitcast{{{ template <typename _Tp> struct _AutoCast { static_assert(__is_vector_type_v<_Tp>); const _Tp __x; template <typename _Up, typename _UVT = _VectorTraits<_Up>> _GLIBCXX_SIMD_INTRINSIC constexpr operator _Up() const { return __intrin_bitcast<typename _UVT::type>(__x); } }; template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC constexpr _AutoCast<_Tp> __auto_bitcast(const _Tp& __x) { return {__x}; } template <typename _Tp, size_t _Np> _GLIBCXX_SIMD_INTRINSIC constexpr _AutoCast<typename _SimdWrapper<_Tp, _Np>::_BuiltinType> __auto_bitcast(const _SimdWrapper<_Tp, _Np>& __x) { return {__x._M_data}; } // }}} // ^^^ ---- builtin vector types [[gnu::vector_size(N)]] and operations ---- ^^^ #if _GLIBCXX_SIMD_HAVE_SSE_ABI // __bool_storage_member_type{{{ #if _GLIBCXX_SIMD_HAVE_AVX512F && _GLIBCXX_SIMD_X86INTRIN template <size_t _Size> struct __bool_storage_member_type { static_assert((_Size & (_Size - 1)) != 0, "This trait may only be used for non-power-of-2 sizes. " "Power-of-2 sizes must be specialized."); using type = typename __bool_storage_member_type<std::__bit_ceil(_Size)>::type; }; template <> struct __bool_storage_member_type<1> { using type = bool; }; template <> struct __bool_storage_member_type<2> { using type = __mmask8; }; template <> struct __bool_storage_member_type<4> { using type = __mmask8; }; template <> struct __bool_storage_member_type<8> { using type = __mmask8; }; template <> struct __bool_storage_member_type<16> { using type = __mmask16; }; template <> struct __bool_storage_member_type<32> { using type = __mmask32; }; template <> struct __bool_storage_member_type<64> { using type = __mmask64; }; #endif // _GLIBCXX_SIMD_HAVE_AVX512F // }}} // __intrinsic_type (x86){{{ // the following excludes bool via __is_vectorizable #if _GLIBCXX_SIMD_HAVE_SSE template <typename _Tp, size_t _Bytes> struct __intrinsic_type<_Tp, _Bytes, enable_if_t<__is_vectorizable_v<_Tp> && _Bytes <= 64>> { static_assert(!is_same_v<_Tp, long double>, "no __intrinsic_type support for long double on x86"); static constexpr size_t _S_VBytes = _Bytes <= 16 ? 16 : _Bytes <= 32 ? 32 : 64; using type [[__gnu__::__vector_size__(_S_VBytes)]] = conditional_t<is_integral_v<_Tp>, long long int, _Tp>; }; #endif // _GLIBCXX_SIMD_HAVE_SSE // }}} #endif // _GLIBCXX_SIMD_HAVE_SSE_ABI // __intrinsic_type (ARM){{{ #if _GLIBCXX_SIMD_HAVE_NEON template <> struct __intrinsic_type<float, 8, void> { using type = float32x2_t; }; template <> struct __intrinsic_type<float, 16, void> { using type = float32x4_t; }; template <> struct __intrinsic_type<double, 8, void> { #if _GLIBCXX_SIMD_HAVE_NEON_A64 using type = float64x1_t; #endif }; template <> struct __intrinsic_type<double, 16, void> { #if _GLIBCXX_SIMD_HAVE_NEON_A64 using type = float64x2_t; #endif }; #define _GLIBCXX_SIMD_ARM_INTRIN(_Bits, _Np) \ template <> \ struct __intrinsic_type<__int_with_sizeof_t<_Bits / 8>, \ _Np * _Bits / 8, void> \ { using type = int##_Bits##x##_Np##_t; }; \ template <> \ struct __intrinsic_type<make_unsigned_t<__int_with_sizeof_t<_Bits / 8>>, \ _Np * _Bits / 8, void> \ { using type = uint##_Bits##x##_Np##_t; } _GLIBCXX_SIMD_ARM_INTRIN(8, 8); _GLIBCXX_SIMD_ARM_INTRIN(8, 16); _GLIBCXX_SIMD_ARM_INTRIN(16, 4); _GLIBCXX_SIMD_ARM_INTRIN(16, 8); _GLIBCXX_SIMD_ARM_INTRIN(32, 2); _GLIBCXX_SIMD_ARM_INTRIN(32, 4); _GLIBCXX_SIMD_ARM_INTRIN(64, 1); _GLIBCXX_SIMD_ARM_INTRIN(64, 2); #undef _GLIBCXX_SIMD_ARM_INTRIN template <typename _Tp, size_t _Bytes> struct __intrinsic_type<_Tp, _Bytes, enable_if_t<__is_vectorizable_v<_Tp> && _Bytes <= 16>> { static constexpr int _SVecBytes = _Bytes <= 8 ? 8 : 16; using _Ip = __int_for_sizeof_t<_Tp>; using _Up = conditional_t< is_floating_point_v<_Tp>, _Tp, conditional_t<is_unsigned_v<_Tp>, make_unsigned_t<_Ip>, _Ip>>; static_assert(!is_same_v<_Tp, _Up> || _SVecBytes != _Bytes, "should use explicit specialization above"); using type = typename __intrinsic_type<_Up, _SVecBytes>::type; }; #endif // _GLIBCXX_SIMD_HAVE_NEON // }}} // __intrinsic_type (PPC){{{ #ifdef __ALTIVEC__ template <typename _Tp> struct __intrinsic_type_impl; #define _GLIBCXX_SIMD_PPC_INTRIN(_Tp) \ template <> \ struct __intrinsic_type_impl<_Tp> { using type = __vector _Tp; } _GLIBCXX_SIMD_PPC_INTRIN(float); #ifdef __VSX__ _GLIBCXX_SIMD_PPC_INTRIN(double); #endif _GLIBCXX_SIMD_PPC_INTRIN(signed char); _GLIBCXX_SIMD_PPC_INTRIN(unsigned char); _GLIBCXX_SIMD_PPC_INTRIN(signed short); _GLIBCXX_SIMD_PPC_INTRIN(unsigned short); _GLIBCXX_SIMD_PPC_INTRIN(signed int); _GLIBCXX_SIMD_PPC_INTRIN(unsigned int); #if defined __VSX__ || __SIZEOF_LONG__ == 4 _GLIBCXX_SIMD_PPC_INTRIN(signed long); _GLIBCXX_SIMD_PPC_INTRIN(unsigned long); #endif #ifdef __VSX__ _GLIBCXX_SIMD_PPC_INTRIN(signed long long); _GLIBCXX_SIMD_PPC_INTRIN(unsigned long long); #endif #undef _GLIBCXX_SIMD_PPC_INTRIN template <typename _Tp, size_t _Bytes> struct __intrinsic_type<_Tp, _Bytes, enable_if_t<__is_vectorizable_v<_Tp> && _Bytes <= 16>> { static constexpr bool _S_is_ldouble = is_same_v<_Tp, long double>; // allow _Tp == long double with -mlong-double-64 static_assert(!(_S_is_ldouble && sizeof(long double) > sizeof(double)), "no __intrinsic_type support for 128-bit floating point on PowerPC"); #ifndef __VSX__ static_assert(!(is_same_v<_Tp, double> || (_S_is_ldouble && sizeof(long double) == sizeof(double))), "no __intrinsic_type support for 64-bit floating point on PowerPC w/o VSX"); #endif static constexpr auto __element_type() { if constexpr (is_floating_point_v<_Tp>) { if constexpr (_S_is_ldouble) return double {}; else return _Tp {}; } else if constexpr (is_signed_v<_Tp>) { if constexpr (sizeof(_Tp) == sizeof(_SChar)) return _SChar {}; else if constexpr (sizeof(_Tp) == sizeof(short)) return short {}; else if constexpr (sizeof(_Tp) == sizeof(int)) return int {}; else if constexpr (sizeof(_Tp) == sizeof(_LLong)) return _LLong {}; } else { if constexpr (sizeof(_Tp) == sizeof(_UChar)) return _UChar {}; else if constexpr (sizeof(_Tp) == sizeof(_UShort)) return _UShort {}; else if constexpr (sizeof(_Tp) == sizeof(_UInt)) return _UInt {}; else if constexpr (sizeof(_Tp) == sizeof(_ULLong)) return _ULLong {}; } } using type = typename __intrinsic_type_impl<decltype(__element_type())>::type; }; #endif // __ALTIVEC__ // }}} // _SimdWrapper<bool>{{{1 template <size_t _Width> struct _SimdWrapper<bool, _Width, void_t<typename __bool_storage_member_type<_Width>::type>> { using _BuiltinType = typename __bool_storage_member_type<_Width>::type; using value_type = bool; static constexpr size_t _S_full_size = sizeof(_BuiltinType) * __CHAR_BIT__; _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper<bool, _S_full_size> __as_full_vector() const { return _M_data; } _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper() = default; _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper(_BuiltinType __k) : _M_data(__k) {}; _GLIBCXX_SIMD_INTRINSIC operator const _BuiltinType&() const { return _M_data; } _GLIBCXX_SIMD_INTRINSIC operator _BuiltinType&() { return _M_data; } _GLIBCXX_SIMD_INTRINSIC _BuiltinType __intrin() const { return _M_data; } _GLIBCXX_SIMD_INTRINSIC constexpr value_type operator[](size_t __i) const { return _M_data & (_BuiltinType(1) << __i); } template <size_t __i> _GLIBCXX_SIMD_INTRINSIC constexpr value_type operator[](_SizeConstant<__i>) const { return _M_data & (_BuiltinType(1) << __i); } _GLIBCXX_SIMD_INTRINSIC constexpr void _M_set(size_t __i, value_type __x) { if (__x) _M_data |= (_BuiltinType(1) << __i); else _M_data &= ~(_BuiltinType(1) << __i); } _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop() const { return __builtin_constant_p(_M_data); } _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop_none_of() const { if (__builtin_constant_p(_M_data)) { constexpr int __nbits = sizeof(_BuiltinType) * __CHAR_BIT__; constexpr _BuiltinType __active_mask = ~_BuiltinType() >> (__nbits - _Width); return (_M_data & __active_mask) == 0; } return false; } _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop_all_of() const { if (__builtin_constant_p(_M_data)) { constexpr int __nbits = sizeof(_BuiltinType) * __CHAR_BIT__; constexpr _BuiltinType __active_mask = ~_BuiltinType() >> (__nbits - _Width); return (_M_data & __active_mask) == __active_mask; } return false; } _BuiltinType _M_data; }; // _SimdWrapperBase{{{1 template <bool _MustZeroInitPadding, typename _BuiltinType> struct _SimdWrapperBase; template <typename _BuiltinType> struct _SimdWrapperBase<false, _BuiltinType> // no padding or no SNaNs { _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapperBase() = default; _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapperBase(_BuiltinType __init) : _M_data(__init) {} _BuiltinType _M_data; }; template <typename _BuiltinType> struct _SimdWrapperBase<true, _BuiltinType> // with padding that needs to // never become SNaN { _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapperBase() : _M_data() {} _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapperBase(_BuiltinType __init) : _M_data(__init) {} _BuiltinType _M_data; }; // }}} // _SimdWrapper{{{ template <typename _Tp, size_t _Width> struct _SimdWrapper< _Tp, _Width, void_t<__vector_type_t<_Tp, _Width>, __intrinsic_type_t<_Tp, _Width>>> : _SimdWrapperBase<__has_iec559_behavior<__signaling_NaN, _Tp>::value && sizeof(_Tp) * _Width == sizeof(__vector_type_t<_Tp, _Width>), __vector_type_t<_Tp, _Width>> { using _Base = _SimdWrapperBase<__has_iec559_behavior<__signaling_NaN, _Tp>::value && sizeof(_Tp) * _Width == sizeof(__vector_type_t<_Tp, _Width>), __vector_type_t<_Tp, _Width>>; static_assert(__is_vectorizable_v<_Tp>); static_assert(_Width >= 2); // 1 doesn't make sense, use _Tp directly then using _BuiltinType = __vector_type_t<_Tp, _Width>; using value_type = _Tp; static inline constexpr size_t _S_full_size = sizeof(_BuiltinType) / sizeof(value_type); static inline constexpr int _S_size = _Width; static inline constexpr bool _S_is_partial = _S_full_size != _S_size; using _Base::_M_data; _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper<_Tp, _S_full_size> __as_full_vector() const { return _M_data; } _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper(initializer_list<_Tp> __init) : _Base(__generate_from_n_evaluations<_Width, _BuiltinType>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __init.begin()[__i.value]; })) {} _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper() = default; _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper(const _SimdWrapper&) = default; _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper(_SimdWrapper&&) = default; _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper& operator=(const _SimdWrapper&) = default; _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper& operator=(_SimdWrapper&&) = default; template <typename _V, typename = enable_if_t<disjunction_v< is_same<_V, __vector_type_t<_Tp, _Width>>, is_same<_V, __intrinsic_type_t<_Tp, _Width>>>>> _GLIBCXX_SIMD_INTRINSIC constexpr _SimdWrapper(_V __x) // __vector_bitcast can convert e.g. __m128 to __vector(2) float : _Base(__vector_bitcast<_Tp, _Width>(__x)) {} template <typename... _As, typename = enable_if_t<((is_same_v<simd_abi::scalar, _As> && ...) && sizeof...(_As) <= _Width)>> _GLIBCXX_SIMD_INTRINSIC constexpr operator _SimdTuple<_Tp, _As...>() const { return __generate_from_n_evaluations<sizeof...(_As), _SimdTuple<_Tp, _As...>>( [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return _M_data[int(__i)]; }); } _GLIBCXX_SIMD_INTRINSIC constexpr operator const _BuiltinType&() const { return _M_data; } _GLIBCXX_SIMD_INTRINSIC constexpr operator _BuiltinType&() { return _M_data; } _GLIBCXX_SIMD_INTRINSIC constexpr _Tp operator[](size_t __i) const { return _M_data[__i]; } template <size_t __i> _GLIBCXX_SIMD_INTRINSIC constexpr _Tp operator[](_SizeConstant<__i>) const { return _M_data[__i]; } _GLIBCXX_SIMD_INTRINSIC constexpr void _M_set(size_t __i, _Tp __x) { if (__builtin_is_constant_evaluated()) _M_data = __generate_from_n_evaluations<_Width, _BuiltinType>([&](auto __j) { return __j == __i ? __x : _M_data[__j()]; }); else _M_data[__i] = __x; } _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop() const { return __builtin_constant_p(_M_data); } _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop_none_of() const { if (__builtin_constant_p(_M_data)) { bool __r = true; if constexpr (is_floating_point_v<_Tp>) { using _Ip = __int_for_sizeof_t<_Tp>; const auto __intdata = __vector_bitcast<_Ip>(_M_data); __execute_n_times<_Width>( [&](auto __i) { __r &= __intdata[__i.value] == _Ip(); }); } else __execute_n_times<_Width>( [&](auto __i) { __r &= _M_data[__i.value] == _Tp(); }); if (__builtin_constant_p(__r)) return __r; } return false; } _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop_all_of() const { if (__builtin_constant_p(_M_data)) { bool __r = true; if constexpr (is_floating_point_v<_Tp>) { using _Ip = __int_for_sizeof_t<_Tp>; const auto __intdata = __vector_bitcast<_Ip>(_M_data); __execute_n_times<_Width>( [&](auto __i) { __r &= __intdata[__i.value] == ~_Ip(); }); } else __execute_n_times<_Width>( [&](auto __i) { __r &= _M_data[__i.value] == ~_Tp(); }); if (__builtin_constant_p(__r)) return __r; } return false; } }; // }}} // __vectorized_sizeof {{{ template <typename _Tp> constexpr size_t __vectorized_sizeof() { if constexpr (!__is_vectorizable_v<_Tp>) return 0; if constexpr (sizeof(_Tp) <= 8) { // X86: if constexpr (__have_avx512bw) return 64; if constexpr (__have_avx512f && sizeof(_Tp) >= 4) return 64; if constexpr (__have_avx2) return 32; if constexpr (__have_avx && is_floating_point_v<_Tp>) return 32; if constexpr (__have_sse2) return 16; if constexpr (__have_sse && is_same_v<_Tp, float>) return 16; /* The following is too much trouble because of mixed MMX and x87 code. * While nothing here explicitly calls MMX instructions of registers, * they are still emitted but no EMMS cleanup is done. if constexpr (__have_mmx && sizeof(_Tp) <= 4 && is_integral_v<_Tp>) return 8; */ // PowerPC: if constexpr (__have_power8vec || (__have_power_vmx && (sizeof(_Tp) < 8)) || (__have_power_vsx && is_floating_point_v<_Tp>) ) return 16; // ARM: if constexpr (__have_neon_a64 || (__have_neon_a32 && !is_same_v<_Tp, double>) ) return 16; if constexpr (__have_neon && sizeof(_Tp) < 8 // Only allow fp if the user allows non-ICE559 fp (e.g. // via -ffast-math). ARMv7 NEON fp is not conforming to // IEC559. && (__support_neon_float || !is_floating_point_v<_Tp>)) return 16; } return sizeof(_Tp); } // }}} namespace simd_abi { // most of simd_abi is defined in simd_detail.h template <typename _Tp> inline constexpr int max_fixed_size = (__have_avx512bw && sizeof(_Tp) == 1) ? 64 : 32; // compatible {{{ #if defined __x86_64__ || defined __aarch64__ template <typename _Tp> using compatible = conditional_t<(sizeof(_Tp) <= 8), _VecBuiltin<16>, scalar>; #elif defined __ARM_NEON // FIXME: not sure, probably needs to be scalar (or dependent on the hard-float // ABI?) template <typename _Tp> using compatible = conditional_t<(sizeof(_Tp) < 8 && (__support_neon_float || !is_floating_point_v<_Tp>)), _VecBuiltin<16>, scalar>; #else template <typename> using compatible = scalar; #endif // }}} // native {{{ template <typename _Tp> constexpr auto __determine_native_abi() { constexpr size_t __bytes = __vectorized_sizeof<_Tp>(); if constexpr (__bytes == sizeof(_Tp)) return static_cast<scalar*>(nullptr); else if constexpr (__have_avx512vl || (__have_avx512f && __bytes == 64)) return static_cast<_VecBltnBtmsk<__bytes>*>(nullptr); else return static_cast<_VecBuiltin<__bytes>*>(nullptr); } template <typename _Tp, typename = enable_if_t<__is_vectorizable_v<_Tp>>> using native = remove_pointer_t<decltype(__determine_native_abi<_Tp>())>; // }}} // __default_abi {{{ #if defined _GLIBCXX_SIMD_DEFAULT_ABI template <typename _Tp> using __default_abi = _GLIBCXX_SIMD_DEFAULT_ABI<_Tp>; #else template <typename _Tp> using __default_abi = compatible<_Tp>; #endif // }}} } // namespace simd_abi // traits {{{1 template <typename _Tp> struct is_simd_flag_type : false_type {}; template <> struct is_simd_flag_type<element_aligned_tag> : true_type {}; template <> struct is_simd_flag_type<vector_aligned_tag> : true_type {}; template <size_t _Np> struct is_simd_flag_type<overaligned_tag<_Np>> : __bool_constant<(_Np > 0) and __has_single_bit(_Np)> {}; template <typename _Tp> inline constexpr bool is_simd_flag_type_v = is_simd_flag_type<_Tp>::value; template <typename _Tp, typename = enable_if_t<is_simd_flag_type_v<_Tp>>> using _IsSimdFlagType = _Tp; // is_abi_tag {{{2 template <typename _Tp, typename = void_t<>> struct is_abi_tag : false_type {}; template <typename _Tp> struct is_abi_tag<_Tp, void_t<typename _Tp::_IsValidAbiTag>> : public _Tp::_IsValidAbiTag {}; template <typename _Tp> inline constexpr bool is_abi_tag_v = is_abi_tag<_Tp>::value; // is_simd(_mask) {{{2 template <typename _Tp> struct is_simd : public false_type {}; template <typename _Tp> inline constexpr bool is_simd_v = is_simd<_Tp>::value; template <typename _Tp> struct is_simd_mask : public false_type {}; template <typename _Tp> inline constexpr bool is_simd_mask_v = is_simd_mask<_Tp>::value; // simd_size {{{2 template <typename _Tp, typename _Abi, typename = void> struct __simd_size_impl {}; template <typename _Tp, typename _Abi> struct __simd_size_impl< _Tp, _Abi, enable_if_t<conjunction_v<__is_vectorizable<_Tp>, is_abi_tag<_Abi>>>> : _SizeConstant<_Abi::template _S_size<_Tp>> {}; template <typename _Tp, typename _Abi = simd_abi::__default_abi<_Tp>> struct simd_size : __simd_size_impl<_Tp, _Abi> {}; template <typename _Tp, typename _Abi = simd_abi::__default_abi<_Tp>> inline constexpr size_t simd_size_v = simd_size<_Tp, _Abi>::value; // simd_abi::deduce {{{2 template <typename _Tp, size_t _Np, typename = void> struct __deduce_impl; namespace simd_abi { /** * @tparam _Tp The requested `value_type` for the elements. * @tparam _Np The requested number of elements. * @tparam _Abis This parameter is ignored, since this implementation cannot * make any use of it. Either __a good native ABI is matched and used as `type` * alias, or the `fixed_size<_Np>` ABI is used, which internally is built from * the best matching native ABIs. */ template <typename _Tp, size_t _Np, typename...> struct deduce : __deduce_impl<_Tp, _Np> {}; template <typename _Tp, size_t _Np, typename... _Abis> using deduce_t = typename deduce<_Tp, _Np, _Abis...>::type; } // namespace simd_abi // }}}2 // rebind_simd {{{2 template <typename _Tp, typename _V, typename = void> struct rebind_simd; template <typename _Tp, typename _Up, typename _Abi> struct rebind_simd<_Tp, simd<_Up, _Abi>, void_t<simd_abi::deduce_t<_Tp, simd_size_v<_Up, _Abi>, _Abi>>> { using type = simd<_Tp, simd_abi::deduce_t<_Tp, simd_size_v<_Up, _Abi>, _Abi>>; }; template <typename _Tp, typename _Up, typename _Abi> struct rebind_simd<_Tp, simd_mask<_Up, _Abi>, void_t<simd_abi::deduce_t<_Tp, simd_size_v<_Up, _Abi>, _Abi>>> { using type = simd_mask<_Tp, simd_abi::deduce_t<_Tp, simd_size_v<_Up, _Abi>, _Abi>>; }; template <typename _Tp, typename _V> using rebind_simd_t = typename rebind_simd<_Tp, _V>::type; // resize_simd {{{2 template <int _Np, typename _V, typename = void> struct resize_simd; template <int _Np, typename _Tp, typename _Abi> struct resize_simd<_Np, simd<_Tp, _Abi>, void_t<simd_abi::deduce_t<_Tp, _Np, _Abi>>> { using type = simd<_Tp, simd_abi::deduce_t<_Tp, _Np, _Abi>>; }; template <int _Np, typename _Tp, typename _Abi> struct resize_simd<_Np, simd_mask<_Tp, _Abi>, void_t<simd_abi::deduce_t<_Tp, _Np, _Abi>>> { using type = simd_mask<_Tp, simd_abi::deduce_t<_Tp, _Np, _Abi>>; }; template <int _Np, typename _V> using resize_simd_t = typename resize_simd<_Np, _V>::type; // }}}2 // memory_alignment {{{2 template <typename _Tp, typename _Up = typename _Tp::value_type> struct memory_alignment : public _SizeConstant<vector_aligned_tag::_S_alignment<_Tp, _Up>> {}; template <typename _Tp, typename _Up = typename _Tp::value_type> inline constexpr size_t memory_alignment_v = memory_alignment<_Tp, _Up>::value; // class template simd [simd] {{{1 template <typename _Tp, typename _Abi = simd_abi::__default_abi<_Tp>> class simd; template <typename _Tp, typename _Abi> struct is_simd<simd<_Tp, _Abi>> : public true_type {}; template <typename _Tp> using native_simd = simd<_Tp, simd_abi::native<_Tp>>; template <typename _Tp, int _Np> using fixed_size_simd = simd<_Tp, simd_abi::fixed_size<_Np>>; template <typename _Tp, size_t _Np> using __deduced_simd = simd<_Tp, simd_abi::deduce_t<_Tp, _Np>>; // class template simd_mask [simd_mask] {{{1 template <typename _Tp, typename _Abi = simd_abi::__default_abi<_Tp>> class simd_mask; template <typename _Tp, typename _Abi> struct is_simd_mask<simd_mask<_Tp, _Abi>> : public true_type {}; template <typename _Tp> using native_simd_mask = simd_mask<_Tp, simd_abi::native<_Tp>>; template <typename _Tp, int _Np> using fixed_size_simd_mask = simd_mask<_Tp, simd_abi::fixed_size<_Np>>; template <typename _Tp, size_t _Np> using __deduced_simd_mask = simd_mask<_Tp, simd_abi::deduce_t<_Tp, _Np>>; // casts [simd.casts] {{{1 // static_simd_cast {{{2 template <typename _Tp, typename _Up, typename _Ap, bool = is_simd_v<_Tp>, typename = void> struct __static_simd_cast_return_type; template <typename _Tp, typename _A0, typename _Up, typename _Ap> struct __static_simd_cast_return_type<simd_mask<_Tp, _A0>, _Up, _Ap, false, void> : __static_simd_cast_return_type<simd<_Tp, _A0>, _Up, _Ap> {}; template <typename _Tp, typename _Up, typename _Ap> struct __static_simd_cast_return_type< _Tp, _Up, _Ap, true, enable_if_t<_Tp::size() == simd_size_v<_Up, _Ap>>> { using type = _Tp; }; template <typename _Tp, typename _Ap> struct __static_simd_cast_return_type<_Tp, _Tp, _Ap, false, #ifdef _GLIBCXX_SIMD_FIX_P2TS_ISSUE66 enable_if_t<__is_vectorizable_v<_Tp>> #else void #endif > { using type = simd<_Tp, _Ap>; }; template <typename _Tp, typename = void> struct __safe_make_signed { using type = _Tp;}; template <typename _Tp> struct __safe_make_signed<_Tp, enable_if_t<is_integral_v<_Tp>>> { // the extra make_unsigned_t is because of PR85951 using type = make_signed_t<make_unsigned_t<_Tp>>; }; template <typename _Tp> using safe_make_signed_t = typename __safe_make_signed<_Tp>::type; template <typename _Tp, typename _Up, typename _Ap> struct __static_simd_cast_return_type<_Tp, _Up, _Ap, false, #ifdef _GLIBCXX_SIMD_FIX_P2TS_ISSUE66 enable_if_t<__is_vectorizable_v<_Tp>> #else void #endif > { using type = conditional_t< (is_integral_v<_Up> && is_integral_v<_Tp> && #ifndef _GLIBCXX_SIMD_FIX_P2TS_ISSUE65 is_signed_v<_Up> != is_signed_v<_Tp> && #endif is_same_v<safe_make_signed_t<_Up>, safe_make_signed_t<_Tp>>), simd<_Tp, _Ap>, fixed_size_simd<_Tp, simd_size_v<_Up, _Ap>>>; }; template <typename _Tp, typename _Up, typename _Ap, typename _R = typename __static_simd_cast_return_type<_Tp, _Up, _Ap>::type> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR _R static_simd_cast(const simd<_Up, _Ap>& __x) { if constexpr (is_same<_R, simd<_Up, _Ap>>::value) return __x; else { _SimdConverter<_Up, _Ap, typename _R::value_type, typename _R::abi_type> __c; return _R(__private_init, __c(__data(__x))); } } namespace __proposed { template <typename _Tp, typename _Up, typename _Ap, typename _R = typename __static_simd_cast_return_type<_Tp, _Up, _Ap>::type> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR typename _R::mask_type static_simd_cast(const simd_mask<_Up, _Ap>& __x) { using _RM = typename _R::mask_type; return {__private_init, _RM::abi_type::_MaskImpl::template _S_convert< typename _RM::simd_type::value_type>(__x)}; } } // namespace __proposed // simd_cast {{{2 template <typename _Tp, typename _Up, typename _Ap, typename _To = __value_type_or_identity_t<_Tp>> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR auto simd_cast(const simd<_ValuePreserving<_Up, _To>, _Ap>& __x) -> decltype(static_simd_cast<_Tp>(__x)) { return static_simd_cast<_Tp>(__x); } namespace __proposed { template <typename _Tp, typename _Up, typename _Ap, typename _To = __value_type_or_identity_t<_Tp>> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR auto simd_cast(const simd_mask<_ValuePreserving<_Up, _To>, _Ap>& __x) -> decltype(static_simd_cast<_Tp>(__x)) { return static_simd_cast<_Tp>(__x); } } // namespace __proposed // }}}2 // resizing_simd_cast {{{ namespace __proposed { /* Proposed spec: template <class T, class U, class Abi> T resizing_simd_cast(const simd<U, Abi>& x) p1 Constraints: - is_simd_v<T> is true and - T::value_type is the same type as U p2 Returns: A simd object with the i^th element initialized to x[i] for all i in the range of [0, min(T::size(), simd_size_v<U, Abi>)). If T::size() is larger than simd_size_v<U, Abi>, the remaining elements are value-initialized. template <class T, class U, class Abi> T resizing_simd_cast(const simd_mask<U, Abi>& x) p1 Constraints: is_simd_mask_v<T> is true p2 Returns: A simd_mask object with the i^th element initialized to x[i] for all i in the range of [0, min(T::size(), simd_size_v<U, Abi>)). If T::size() is larger than simd_size_v<U, Abi>, the remaining elements are initialized to false. */ template <typename _Tp, typename _Up, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR enable_if_t< conjunction_v<is_simd<_Tp>, is_same<typename _Tp::value_type, _Up>>, _Tp> resizing_simd_cast(const simd<_Up, _Ap>& __x) { if constexpr (is_same_v<typename _Tp::abi_type, _Ap>) return __x; else if (__builtin_is_constant_evaluated()) return _Tp([&](auto __i) constexpr { return __i < simd_size_v<_Up, _Ap> ? __x[__i] : _Up(); }); else if constexpr (simd_size_v<_Up, _Ap> == 1) { _Tp __r{}; __r[0] = __x[0]; return __r; } else if constexpr (_Tp::size() == 1) return __x[0]; else if constexpr (sizeof(_Tp) == sizeof(__x) && !__is_fixed_size_abi_v<_Ap>) return {__private_init, __vector_bitcast<typename _Tp::value_type, _Tp::size()>( _Ap::_S_masked(__data(__x))._M_data)}; else { _Tp __r{}; __builtin_memcpy(&__data(__r), &__data(__x), sizeof(_Up) * std::min(_Tp::size(), simd_size_v<_Up, _Ap>)); return __r; } } template <typename _Tp, typename _Up, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR enable_if_t<is_simd_mask_v<_Tp>, _Tp> resizing_simd_cast(const simd_mask<_Up, _Ap>& __x) { return {__private_init, _Tp::abi_type::_MaskImpl::template _S_convert< typename _Tp::simd_type::value_type>(__x)}; } } // namespace __proposed // }}} // to_fixed_size {{{2 template <typename _Tp, int _Np> _GLIBCXX_SIMD_INTRINSIC fixed_size_simd<_Tp, _Np> to_fixed_size(const fixed_size_simd<_Tp, _Np>& __x) { return __x; } template <typename _Tp, int _Np> _GLIBCXX_SIMD_INTRINSIC fixed_size_simd_mask<_Tp, _Np> to_fixed_size(const fixed_size_simd_mask<_Tp, _Np>& __x) { return __x; } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC fixed_size_simd<_Tp, simd_size_v<_Tp, _Ap>> to_fixed_size(const simd<_Tp, _Ap>& __x) { using _Rp = fixed_size_simd<_Tp, simd_size_v<_Tp, _Ap>>; return _Rp([&__x](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x[__i]; }); } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC fixed_size_simd_mask<_Tp, simd_size_v<_Tp, _Ap>> to_fixed_size(const simd_mask<_Tp, _Ap>& __x) { return {__private_init, [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x[__i]; }}; } // to_native {{{2 template <typename _Tp, int _Np> _GLIBCXX_SIMD_INTRINSIC enable_if_t<(_Np == native_simd<_Tp>::size()), native_simd<_Tp>> to_native(const fixed_size_simd<_Tp, _Np>& __x) { alignas(memory_alignment_v<native_simd<_Tp>>) _Tp __mem[_Np]; __x.copy_to(__mem, vector_aligned); return {__mem, vector_aligned}; } template <typename _Tp, int _Np> _GLIBCXX_SIMD_INTRINSIC enable_if_t<(_Np == native_simd_mask<_Tp>::size()), native_simd_mask<_Tp>> to_native(const fixed_size_simd_mask<_Tp, _Np>& __x) { return native_simd_mask<_Tp>( __private_init, [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x[__i]; }); } // to_compatible {{{2 template <typename _Tp, int _Np> _GLIBCXX_SIMD_INTRINSIC enable_if_t<(_Np == simd<_Tp>::size()), simd<_Tp>> to_compatible(const simd<_Tp, simd_abi::fixed_size<_Np>>& __x) { alignas(memory_alignment_v<simd<_Tp>>) _Tp __mem[_Np]; __x.copy_to(__mem, vector_aligned); return {__mem, vector_aligned}; } template <typename _Tp, int _Np> _GLIBCXX_SIMD_INTRINSIC enable_if_t<(_Np == simd_mask<_Tp>::size()), simd_mask<_Tp>> to_compatible(const simd_mask<_Tp, simd_abi::fixed_size<_Np>>& __x) { return simd_mask<_Tp>( __private_init, [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x[__i]; }); } // masked assignment [simd_mask.where] {{{1 // where_expression {{{1 // const_where_expression<M, T> {{{2 template <typename _M, typename _Tp> class const_where_expression { using _V = _Tp; static_assert(is_same_v<_V, __remove_cvref_t<_Tp>>); struct _Wrapper { using value_type = _V; }; protected: using _Impl = typename _V::_Impl; using value_type = typename conditional_t<is_arithmetic_v<_V>, _Wrapper, _V>::value_type; _GLIBCXX_SIMD_INTRINSIC friend const _M& __get_mask(const const_where_expression& __x) { return __x._M_k; } _GLIBCXX_SIMD_INTRINSIC friend const _Tp& __get_lvalue(const const_where_expression& __x) { return __x._M_value; } const _M& _M_k; _Tp& _M_value; public: const_where_expression(const const_where_expression&) = delete; const_where_expression& operator=(const const_where_expression&) = delete; _GLIBCXX_SIMD_INTRINSIC constexpr const_where_expression(const _M& __kk, const _Tp& dd) : _M_k(__kk), _M_value(const_cast<_Tp&>(dd)) {} _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR _V operator-() const&& { return {__private_init, _Impl::template _S_masked_unary<negate>(__data(_M_k), __data(_M_value))}; } template <typename _Up, typename _Flags> [[nodiscard]] _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR _V copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _IsSimdFlagType<_Flags>) const&& { return {__private_init, _Impl::_S_masked_load(__data(_M_value), __data(_M_k), _Flags::template _S_apply<_V>(__mem))}; } template <typename _Up, typename _Flags> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void copy_to(_LoadStorePtr<_Up, value_type>* __mem, _IsSimdFlagType<_Flags>) const&& { _Impl::_S_masked_store(__data(_M_value), _Flags::template _S_apply<_V>(__mem), __data(_M_k)); } }; // const_where_expression<bool, T> {{{2 template <typename _Tp> class const_where_expression<bool, _Tp> { using _M = bool; using _V = _Tp; static_assert(is_same_v<_V, __remove_cvref_t<_Tp>>); struct _Wrapper { using value_type = _V; }; protected: using value_type = typename conditional_t<is_arithmetic_v<_V>, _Wrapper, _V>::value_type; _GLIBCXX_SIMD_INTRINSIC friend const _M& __get_mask(const const_where_expression& __x) { return __x._M_k; } _GLIBCXX_SIMD_INTRINSIC friend const _Tp& __get_lvalue(const const_where_expression& __x) { return __x._M_value; } const bool _M_k; _Tp& _M_value; public: const_where_expression(const const_where_expression&) = delete; const_where_expression& operator=(const const_where_expression&) = delete; _GLIBCXX_SIMD_INTRINSIC constexpr const_where_expression(const bool __kk, const _Tp& dd) : _M_k(__kk), _M_value(const_cast<_Tp&>(dd)) {} _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR _V operator-() const&& { return _M_k ? -_M_value : _M_value; } template <typename _Up, typename _Flags> [[nodiscard]] _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR _V copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _IsSimdFlagType<_Flags>) const&& { return _M_k ? static_cast<_V>(__mem[0]) : _M_value; } template <typename _Up, typename _Flags> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void copy_to(_LoadStorePtr<_Up, value_type>* __mem, _IsSimdFlagType<_Flags>) const&& { if (_M_k) __mem[0] = _M_value; } }; // where_expression<M, T> {{{2 template <typename _M, typename _Tp> class where_expression : public const_where_expression<_M, _Tp> { using _Impl = typename const_where_expression<_M, _Tp>::_Impl; static_assert(!is_const<_Tp>::value, "where_expression may only be instantiated with __a non-const " "_Tp parameter"); using typename const_where_expression<_M, _Tp>::value_type; using const_where_expression<_M, _Tp>::_M_k; using const_where_expression<_M, _Tp>::_M_value; static_assert( is_same<typename _M::abi_type, typename _Tp::abi_type>::value, ""); static_assert(_M::size() == _Tp::size(), ""); _GLIBCXX_SIMD_INTRINSIC friend constexpr _Tp& __get_lvalue(where_expression& __x) { return __x._M_value; } public: where_expression(const where_expression&) = delete; where_expression& operator=(const where_expression&) = delete; _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR where_expression(const _M& __kk, _Tp& dd) : const_where_expression<_M, _Tp>(__kk, dd) {} template <typename _Up> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void operator=(_Up&& __x) && { _Impl::_S_masked_assign(__data(_M_k), __data(_M_value), __to_value_type_or_member_type<_Tp>( static_cast<_Up&&>(__x))); } #define _GLIBCXX_SIMD_OP_(__op, __name) \ template <typename _Up> \ _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void \ operator __op##=(_Up&& __x)&& \ { \ _Impl::template _S_masked_cassign( \ __data(_M_k), __data(_M_value), \ __to_value_type_or_member_type<_Tp>(static_cast<_Up&&>(__x)), \ [](auto __impl, auto __lhs, auto __rhs) \ constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA \ { return __impl.__name(__lhs, __rhs); }); \ } \ static_assert(true) _GLIBCXX_SIMD_OP_(+, _S_plus); _GLIBCXX_SIMD_OP_(-, _S_minus); _GLIBCXX_SIMD_OP_(*, _S_multiplies); _GLIBCXX_SIMD_OP_(/, _S_divides); _GLIBCXX_SIMD_OP_(%, _S_modulus); _GLIBCXX_SIMD_OP_(&, _S_bit_and); _GLIBCXX_SIMD_OP_(|, _S_bit_or); _GLIBCXX_SIMD_OP_(^, _S_bit_xor); _GLIBCXX_SIMD_OP_(<<, _S_shift_left); _GLIBCXX_SIMD_OP_(>>, _S_shift_right); #undef _GLIBCXX_SIMD_OP_ _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void operator++() && { __data(_M_value) = _Impl::template _S_masked_unary<__increment>(__data(_M_k), __data(_M_value)); } _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void operator++(int) && { __data(_M_value) = _Impl::template _S_masked_unary<__increment>(__data(_M_k), __data(_M_value)); } _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void operator--() && { __data(_M_value) = _Impl::template _S_masked_unary<__decrement>(__data(_M_k), __data(_M_value)); } _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void operator--(int) && { __data(_M_value) = _Impl::template _S_masked_unary<__decrement>(__data(_M_k), __data(_M_value)); } // intentionally hides const_where_expression::copy_from template <typename _Up, typename _Flags> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _IsSimdFlagType<_Flags>) && { __data(_M_value) = _Impl::_S_masked_load(__data(_M_value), __data(_M_k), _Flags::template _S_apply<_Tp>(__mem)); } }; // where_expression<bool, T> {{{2 template <typename _Tp> class where_expression<bool, _Tp> : public const_where_expression<bool, _Tp> { using _M = bool; using typename const_where_expression<_M, _Tp>::value_type; using const_where_expression<_M, _Tp>::_M_k; using const_where_expression<_M, _Tp>::_M_value; public: where_expression(const where_expression&) = delete; where_expression& operator=(const where_expression&) = delete; _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR where_expression(const _M& __kk, _Tp& dd) : const_where_expression<_M, _Tp>(__kk, dd) {} #define _GLIBCXX_SIMD_OP_(__op) \ template <typename _Up> \ _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void \ operator __op(_Up&& __x)&& \ { if (_M_k) _M_value __op static_cast<_Up&&>(__x); } _GLIBCXX_SIMD_OP_(=) _GLIBCXX_SIMD_OP_(+=) _GLIBCXX_SIMD_OP_(-=) _GLIBCXX_SIMD_OP_(*=) _GLIBCXX_SIMD_OP_(/=) _GLIBCXX_SIMD_OP_(%=) _GLIBCXX_SIMD_OP_(&=) _GLIBCXX_SIMD_OP_(|=) _GLIBCXX_SIMD_OP_(^=) _GLIBCXX_SIMD_OP_(<<=) _GLIBCXX_SIMD_OP_(>>=) #undef _GLIBCXX_SIMD_OP_ _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void operator++() && { if (_M_k) ++_M_value; } _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void operator++(int) && { if (_M_k) ++_M_value; } _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void operator--() && { if (_M_k) --_M_value; } _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void operator--(int) && { if (_M_k) --_M_value; } // intentionally hides const_where_expression::copy_from template <typename _Up, typename _Flags> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR void copy_from(const _LoadStorePtr<_Up, value_type>* __mem, _IsSimdFlagType<_Flags>) && { if (_M_k) _M_value = __mem[0]; } }; // where {{{1 template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR where_expression<simd_mask<_Tp, _Ap>, simd<_Tp, _Ap>> where(const typename simd<_Tp, _Ap>::mask_type& __k, simd<_Tp, _Ap>& __value) { return {__k, __value}; } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR const_where_expression<simd_mask<_Tp, _Ap>, simd<_Tp, _Ap>> where(const typename simd<_Tp, _Ap>::mask_type& __k, const simd<_Tp, _Ap>& __value) { return {__k, __value}; } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR where_expression<simd_mask<_Tp, _Ap>, simd_mask<_Tp, _Ap>> where(const remove_const_t<simd_mask<_Tp, _Ap>>& __k, simd_mask<_Tp, _Ap>& __value) { return {__k, __value}; } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR const_where_expression<simd_mask<_Tp, _Ap>, simd_mask<_Tp, _Ap>> where(const remove_const_t<simd_mask<_Tp, _Ap>>& __k, const simd_mask<_Tp, _Ap>& __value) { return {__k, __value}; } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR where_expression<bool, _Tp> where(_ExactBool __k, _Tp& __value) { return {__k, __value}; } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR const_where_expression<bool, _Tp> where(_ExactBool __k, const _Tp& __value) { return {__k, __value}; } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_CONSTEXPR void where(bool __k, simd<_Tp, _Ap>& __value) = delete; template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_CONSTEXPR void where(bool __k, const simd<_Tp, _Ap>& __value) = delete; // proposed mask iterations {{{1 namespace __proposed { template <size_t _Np> class where_range { const bitset<_Np> __bits; public: where_range(bitset<_Np> __b) : __bits(__b) {} class iterator { size_t __mask; size_t __bit; _GLIBCXX_SIMD_INTRINSIC void __next_bit() { __bit = __builtin_ctzl(__mask); } _GLIBCXX_SIMD_INTRINSIC void __reset_lsb() { // 01100100 - 1 = 01100011 __mask &= (__mask - 1); // __asm__("btr %1,%0" : "+r"(__mask) : "r"(__bit)); } public: iterator(decltype(__mask) __m) : __mask(__m) { __next_bit(); } iterator(const iterator&) = default; iterator(iterator&&) = default; _GLIBCXX_SIMD_ALWAYS_INLINE size_t operator->() const { return __bit; } _GLIBCXX_SIMD_ALWAYS_INLINE size_t operator*() const { return __bit; } _GLIBCXX_SIMD_ALWAYS_INLINE iterator& operator++() { __reset_lsb(); __next_bit(); return *this; } _GLIBCXX_SIMD_ALWAYS_INLINE iterator operator++(int) { iterator __tmp = *this; __reset_lsb(); __next_bit(); return __tmp; } _GLIBCXX_SIMD_ALWAYS_INLINE bool operator==(const iterator& __rhs) const { return __mask == __rhs.__mask; } _GLIBCXX_SIMD_ALWAYS_INLINE bool operator!=(const iterator& __rhs) const { return __mask != __rhs.__mask; } }; iterator begin() const { return __bits.to_ullong(); } iterator end() const { return 0; } }; template <typename _Tp, typename _Ap> where_range<simd_size_v<_Tp, _Ap>> where(const simd_mask<_Tp, _Ap>& __k) { return __k.__to_bitset(); } } // namespace __proposed // }}}1 // reductions [simd.reductions] {{{1 template <typename _Tp, typename _Abi, typename _BinaryOperation = plus<>> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR _Tp reduce(const simd<_Tp, _Abi>& __v, _BinaryOperation __binary_op = _BinaryOperation()) { return _Abi::_SimdImpl::_S_reduce(__v, __binary_op); } template <typename _M, typename _V, typename _BinaryOperation = plus<>> _GLIBCXX_SIMD_INTRINSIC typename _V::value_type reduce(const const_where_expression<_M, _V>& __x, typename _V::value_type __identity_element, _BinaryOperation __binary_op) { if (__builtin_expect(none_of(__get_mask(__x)), false)) return __identity_element; _V __tmp = __identity_element; _V::_Impl::_S_masked_assign(__data(__get_mask(__x)), __data(__tmp), __data(__get_lvalue(__x))); return reduce(__tmp, __binary_op); } template <typename _M, typename _V> _GLIBCXX_SIMD_INTRINSIC typename _V::value_type reduce(const const_where_expression<_M, _V>& __x, plus<> __binary_op = {}) { return reduce(__x, 0, __binary_op); } template <typename _M, typename _V> _GLIBCXX_SIMD_INTRINSIC typename _V::value_type reduce(const const_where_expression<_M, _V>& __x, multiplies<> __binary_op) { return reduce(__x, 1, __binary_op); } template <typename _M, typename _V> _GLIBCXX_SIMD_INTRINSIC typename _V::value_type reduce(const const_where_expression<_M, _V>& __x, bit_and<> __binary_op) { return reduce(__x, ~typename _V::value_type(), __binary_op); } template <typename _M, typename _V> _GLIBCXX_SIMD_INTRINSIC typename _V::value_type reduce(const const_where_expression<_M, _V>& __x, bit_or<> __binary_op) { return reduce(__x, 0, __binary_op); } template <typename _M, typename _V> _GLIBCXX_SIMD_INTRINSIC typename _V::value_type reduce(const const_where_expression<_M, _V>& __x, bit_xor<> __binary_op) { return reduce(__x, 0, __binary_op); } template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR _Tp hmin(const simd<_Tp, _Abi>& __v) noexcept { return _Abi::_SimdImpl::_S_reduce(__v, __detail::_Minimum()); } template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR _Tp hmax(const simd<_Tp, _Abi>& __v) noexcept { return _Abi::_SimdImpl::_S_reduce(__v, __detail::_Maximum()); } template <typename _M, typename _V> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR typename _V::value_type hmin(const const_where_expression<_M, _V>& __x) noexcept { using _Tp = typename _V::value_type; constexpr _Tp __id_elem = #ifdef __FINITE_MATH_ONLY__ __finite_max_v<_Tp>; #else __value_or<__infinity, _Tp>(__finite_max_v<_Tp>); #endif _V __tmp = __id_elem; _V::_Impl::_S_masked_assign(__data(__get_mask(__x)), __data(__tmp), __data(__get_lvalue(__x))); return _V::abi_type::_SimdImpl::_S_reduce(__tmp, __detail::_Minimum()); } template <typename _M, typename _V> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR typename _V::value_type hmax(const const_where_expression<_M, _V>& __x) noexcept { using _Tp = typename _V::value_type; constexpr _Tp __id_elem = #ifdef __FINITE_MATH_ONLY__ __finite_min_v<_Tp>; #else [] { if constexpr (__value_exists_v<__infinity, _Tp>) return -__infinity_v<_Tp>; else return __finite_min_v<_Tp>; }(); #endif _V __tmp = __id_elem; _V::_Impl::_S_masked_assign(__data(__get_mask(__x)), __data(__tmp), __data(__get_lvalue(__x))); return _V::abi_type::_SimdImpl::_S_reduce(__tmp, __detail::_Maximum()); } // }}}1 // algorithms [simd.alg] {{{ template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR simd<_Tp, _Ap> min(const simd<_Tp, _Ap>& __a, const simd<_Tp, _Ap>& __b) { return {__private_init, _Ap::_SimdImpl::_S_min(__data(__a), __data(__b))}; } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR simd<_Tp, _Ap> max(const simd<_Tp, _Ap>& __a, const simd<_Tp, _Ap>& __b) { return {__private_init, _Ap::_SimdImpl::_S_max(__data(__a), __data(__b))}; } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR pair<simd<_Tp, _Ap>, simd<_Tp, _Ap>> minmax(const simd<_Tp, _Ap>& __a, const simd<_Tp, _Ap>& __b) { const auto pair_of_members = _Ap::_SimdImpl::_S_minmax(__data(__a), __data(__b)); return {simd<_Tp, _Ap>(__private_init, pair_of_members.first), simd<_Tp, _Ap>(__private_init, pair_of_members.second)}; } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR simd<_Tp, _Ap> clamp(const simd<_Tp, _Ap>& __v, const simd<_Tp, _Ap>& __lo, const simd<_Tp, _Ap>& __hi) { using _Impl = typename _Ap::_SimdImpl; return {__private_init, _Impl::_S_min(__data(__hi), _Impl::_S_max(__data(__lo), __data(__v)))}; } // }}} template <size_t... _Sizes, typename _Tp, typename _Ap, typename = enable_if_t<((_Sizes + ...) == simd<_Tp, _Ap>::size())>> inline tuple<simd<_Tp, simd_abi::deduce_t<_Tp, _Sizes>>...> split(const simd<_Tp, _Ap>&); // __extract_part {{{ template <int _Index, int _Total, int _Combine = 1, typename _Tp, size_t _Np> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_CONST constexpr _SimdWrapper<_Tp, _Np / _Total * _Combine> __extract_part(const _SimdWrapper<_Tp, _Np> __x); template <int _Index, int _Parts, int _Combine = 1, typename _Tp, typename _A0, typename... _As> _GLIBCXX_SIMD_INTRINSIC constexpr auto __extract_part(const _SimdTuple<_Tp, _A0, _As...>& __x); // }}} // _SizeList {{{ template <size_t _V0, size_t... _Values> struct _SizeList { template <size_t _I> static constexpr size_t _S_at(_SizeConstant<_I> = {}) { if constexpr (_I == 0) return _V0; else return _SizeList<_Values...>::template _S_at<_I - 1>(); } template <size_t _I> static constexpr auto _S_before(_SizeConstant<_I> = {}) { if constexpr (_I == 0) return _SizeConstant<0>(); else return _SizeConstant< _V0 + _SizeList<_Values...>::template _S_before<_I - 1>()>(); } template <size_t _Np> static constexpr auto _S_pop_front(_SizeConstant<_Np> = {}) { if constexpr (_Np == 0) return _SizeList(); else return _SizeList<_Values...>::template _S_pop_front<_Np - 1>(); } }; // }}} // __extract_center {{{ template <typename _Tp, size_t _Np> _GLIBCXX_SIMD_INTRINSIC _SimdWrapper<_Tp, _Np / 2> __extract_center(_SimdWrapper<_Tp, _Np> __x) { static_assert(_Np >= 4); static_assert(_Np % 4 == 0); // x0 - x1 - x2 - x3 -> return {x1, x2} #if _GLIBCXX_SIMD_X86INTRIN // {{{ if constexpr (__have_avx512f && sizeof(_Tp) * _Np == 64) { const auto __intrin = __to_intrin(__x); if constexpr (is_integral_v<_Tp>) return __vector_bitcast<_Tp>(_mm512_castsi512_si256( _mm512_shuffle_i32x4(__intrin, __intrin, 1 + 2 * 0x4 + 2 * 0x10 + 3 * 0x40))); else if constexpr (sizeof(_Tp) == 4) return __vector_bitcast<_Tp>(_mm512_castps512_ps256( _mm512_shuffle_f32x4(__intrin, __intrin, 1 + 2 * 0x4 + 2 * 0x10 + 3 * 0x40))); else if constexpr (sizeof(_Tp) == 8) return __vector_bitcast<_Tp>(_mm512_castpd512_pd256( _mm512_shuffle_f64x2(__intrin, __intrin, 1 + 2 * 0x4 + 2 * 0x10 + 3 * 0x40))); else __assert_unreachable<_Tp>(); } else if constexpr (sizeof(_Tp) * _Np == 32 && is_floating_point_v<_Tp>) return __vector_bitcast<_Tp>( _mm_shuffle_pd(__lo128(__vector_bitcast<double>(__x)), __hi128(__vector_bitcast<double>(__x)), 1)); else if constexpr (sizeof(__x) == 32 && sizeof(_Tp) * _Np <= 32) return __vector_bitcast<_Tp>( _mm_alignr_epi8(__hi128(__vector_bitcast<_LLong>(__x)), __lo128(__vector_bitcast<_LLong>(__x)), sizeof(_Tp) * _Np / 4)); else #endif // _GLIBCXX_SIMD_X86INTRIN }}} { __vector_type_t<_Tp, _Np / 2> __r; __builtin_memcpy(&__r, reinterpret_cast<const char*>(&__x) + sizeof(_Tp) * _Np / 4, sizeof(_Tp) * _Np / 2); return __r; } } template <typename _Tp, typename _A0, typename... _As> _GLIBCXX_SIMD_INTRINSIC _SimdWrapper<_Tp, _SimdTuple<_Tp, _A0, _As...>::_S_size() / 2> __extract_center(const _SimdTuple<_Tp, _A0, _As...>& __x) { if constexpr (sizeof...(_As) == 0) return __extract_center(__x.first); else return __extract_part<1, 4, 2>(__x); } // }}} // __split_wrapper {{{ template <size_t... _Sizes, typename _Tp, typename... _As> auto __split_wrapper(_SizeList<_Sizes...>, const _SimdTuple<_Tp, _As...>& __x) { return split<_Sizes...>( fixed_size_simd<_Tp, _SimdTuple<_Tp, _As...>::_S_size()>(__private_init, __x)); } // }}} // split<simd>(simd) {{{ template <typename _V, typename _Ap, size_t _Parts = simd_size_v<typename _V::value_type, _Ap> / _V::size()> enable_if_t<simd_size_v<typename _V::value_type, _Ap> == _Parts * _V::size() && is_simd_v<_V>, array<_V, _Parts>> split(const simd<typename _V::value_type, _Ap>& __x) { using _Tp = typename _V::value_type; if constexpr (_Parts == 1) { return {simd_cast<_V>(__x)}; } else if (__x._M_is_constprop()) { return __generate_from_n_evaluations<_Parts, array<_V, _Parts>>( [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return _V([&](auto __j) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x[__i * _V::size() + __j]; }); }); } else if constexpr ( __is_fixed_size_abi_v<_Ap> && (is_same_v<typename _V::abi_type, simd_abi::scalar> || (__is_fixed_size_abi_v<typename _V::abi_type> && sizeof(_V) == sizeof(_Tp) * _V::size() // _V doesn't have padding ))) { // fixed_size -> fixed_size (w/o padding) or scalar #ifdef _GLIBCXX_SIMD_USE_ALIASING_LOADS const __may_alias<_Tp>* const __element_ptr = reinterpret_cast<const __may_alias<_Tp>*>(&__data(__x)); return __generate_from_n_evaluations<_Parts, array<_V, _Parts>>( [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return _V(__element_ptr + __i * _V::size(), vector_aligned); }); #else const auto& __xx = __data(__x); return __generate_from_n_evaluations<_Parts, array<_V, _Parts>>( [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { [[maybe_unused]] constexpr size_t __offset = decltype(__i)::value * _V::size(); return _V([&](auto __j) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { constexpr _SizeConstant<__j + __offset> __k; return __xx[__k]; }); }); #endif } else if constexpr (is_same_v<typename _V::abi_type, simd_abi::scalar>) { // normally memcpy should work here as well return __generate_from_n_evaluations<_Parts, array<_V, _Parts>>( [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x[__i]; }); } else { return __generate_from_n_evaluations<_Parts, array<_V, _Parts>>( [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { if constexpr (__is_fixed_size_abi_v<typename _V::abi_type>) return _V([&](auto __j) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x[__i * _V::size() + __j]; }); else return _V(__private_init, __extract_part<decltype(__i)::value, _Parts>(__data(__x))); }); } } // }}} // split<simd_mask>(simd_mask) {{{ template <typename _V, typename _Ap, size_t _Parts = simd_size_v<typename _V::simd_type::value_type, _Ap> / _V::size()> enable_if_t<is_simd_mask_v<_V> && simd_size_v<typename _V::simd_type::value_type, _Ap> == _Parts * _V::size(), array<_V, _Parts>> split(const simd_mask<typename _V::simd_type::value_type, _Ap>& __x) { if constexpr (is_same_v<_Ap, typename _V::abi_type>) return {__x}; else if constexpr (_Parts == 1) return {__proposed::static_simd_cast<_V>(__x)}; else if constexpr (_Parts == 2 && __is_sse_abi<typename _V::abi_type>() && __is_avx_abi<_Ap>()) return {_V(__private_init, __lo128(__data(__x))), _V(__private_init, __hi128(__data(__x)))}; else if constexpr (_V::size() <= __CHAR_BIT__ * sizeof(_ULLong)) { const bitset __bits = __x.__to_bitset(); return __generate_from_n_evaluations<_Parts, array<_V, _Parts>>( [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { constexpr size_t __offset = __i * _V::size(); return _V(__bitset_init, (__bits >> __offset).to_ullong()); }); } else { return __generate_from_n_evaluations<_Parts, array<_V, _Parts>>( [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { constexpr size_t __offset = __i * _V::size(); return _V(__private_init, [&](auto __j) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x[__j + __offset]; }); }); } } // }}} // split<_Sizes...>(simd) {{{ template <size_t... _Sizes, typename _Tp, typename _Ap, typename> _GLIBCXX_SIMD_ALWAYS_INLINE tuple<simd<_Tp, simd_abi::deduce_t<_Tp, _Sizes>>...> split(const simd<_Tp, _Ap>& __x) { using _SL = _SizeList<_Sizes...>; using _Tuple = tuple<__deduced_simd<_Tp, _Sizes>...>; constexpr size_t _Np = simd_size_v<_Tp, _Ap>; constexpr size_t _N0 = _SL::template _S_at<0>(); using _V = __deduced_simd<_Tp, _N0>; if (__x._M_is_constprop()) return __generate_from_n_evaluations<sizeof...(_Sizes), _Tuple>( [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { using _Vi = __deduced_simd<_Tp, _SL::_S_at(__i)>; constexpr size_t __offset = _SL::_S_before(__i); return _Vi([&](auto __j) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __x[__offset + __j]; }); }); else if constexpr (_Np == _N0) { static_assert(sizeof...(_Sizes) == 1); return {simd_cast<_V>(__x)}; } else if constexpr // split from fixed_size, such that __x::first.size == _N0 (__is_fixed_size_abi_v< _Ap> && __fixed_size_storage_t<_Tp, _Np>::_S_first_size == _N0) { static_assert( !__is_fixed_size_abi_v<typename _V::abi_type>, "How can <_Tp, _Np> be __a single _SimdTuple entry but __a " "fixed_size_simd " "when deduced?"); // extract first and recurse (__split_wrapper is needed to deduce a new // _Sizes pack) return tuple_cat(make_tuple(_V(__private_init, __data(__x).first)), __split_wrapper(_SL::template _S_pop_front<1>(), __data(__x).second)); } else if constexpr ((!is_same_v<simd_abi::scalar, simd_abi::deduce_t<_Tp, _Sizes>> && ...) && (!__is_fixed_size_abi_v< simd_abi::deduce_t<_Tp, _Sizes>> && ...)) { if constexpr (((_Sizes * 2 == _Np) && ...)) return {{__private_init, __extract_part<0, 2>(__data(__x))}, {__private_init, __extract_part<1, 2>(__data(__x))}}; else if constexpr (is_same_v<_SizeList<_Sizes...>, _SizeList<_Np / 3, _Np / 3, _Np / 3>>) return {{__private_init, __extract_part<0, 3>(__data(__x))}, {__private_init, __extract_part<1, 3>(__data(__x))}, {__private_init, __extract_part<2, 3>(__data(__x))}}; else if constexpr (is_same_v<_SizeList<_Sizes...>, _SizeList<2 * _Np / 3, _Np / 3>>) return {{__private_init, __extract_part<0, 3, 2>(__data(__x))}, {__private_init, __extract_part<2, 3>(__data(__x))}}; else if constexpr (is_same_v<_SizeList<_Sizes...>, _SizeList<_Np / 3, 2 * _Np / 3>>) return {{__private_init, __extract_part<0, 3>(__data(__x))}, {__private_init, __extract_part<1, 3, 2>(__data(__x))}}; else if constexpr (is_same_v<_SizeList<_Sizes...>, _SizeList<_Np / 2, _Np / 4, _Np / 4>>) return {{__private_init, __extract_part<0, 2>(__data(__x))}, {__private_init, __extract_part<2, 4>(__data(__x))}, {__private_init, __extract_part<3, 4>(__data(__x))}}; else if constexpr (is_same_v<_SizeList<_Sizes...>, _SizeList<_Np / 4, _Np / 4, _Np / 2>>) return {{__private_init, __extract_part<0, 4>(__data(__x))}, {__private_init, __extract_part<1, 4>(__data(__x))}, {__private_init, __extract_part<1, 2>(__data(__x))}}; else if constexpr (is_same_v<_SizeList<_Sizes...>, _SizeList<_Np / 4, _Np / 2, _Np / 4>>) return {{__private_init, __extract_part<0, 4>(__data(__x))}, {__private_init, __extract_center(__data(__x))}, {__private_init, __extract_part<3, 4>(__data(__x))}}; else if constexpr (((_Sizes * 4 == _Np) && ...)) return {{__private_init, __extract_part<0, 4>(__data(__x))}, {__private_init, __extract_part<1, 4>(__data(__x))}, {__private_init, __extract_part<2, 4>(__data(__x))}, {__private_init, __extract_part<3, 4>(__data(__x))}}; // else fall through } #ifdef _GLIBCXX_SIMD_USE_ALIASING_LOADS const __may_alias<_Tp>* const __element_ptr = reinterpret_cast<const __may_alias<_Tp>*>(&__x); return __generate_from_n_evaluations<sizeof...(_Sizes), _Tuple>( [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { using _Vi = __deduced_simd<_Tp, _SL::_S_at(__i)>; constexpr size_t __offset = _SL::_S_before(__i); constexpr size_t __base_align = alignof(simd<_Tp, _Ap>); constexpr size_t __a = __base_align - ((__offset * sizeof(_Tp)) % __base_align); constexpr size_t __b = ((__a - 1) & __a) ^ __a; constexpr size_t __alignment = __b == 0 ? __a : __b; return _Vi(__element_ptr + __offset, overaligned<__alignment>); }); #else return __generate_from_n_evaluations<sizeof...(_Sizes), _Tuple>( [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { using _Vi = __deduced_simd<_Tp, _SL::_S_at(__i)>; const auto& __xx = __data(__x); using _Offset = decltype(_SL::_S_before(__i)); return _Vi([&](auto __j) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { constexpr _SizeConstant<_Offset::value + __j> __k; return __xx[__k]; }); }); #endif } // }}} // __subscript_in_pack {{{ template <size_t _I, typename _Tp, typename _Ap, typename... _As> _GLIBCXX_SIMD_INTRINSIC constexpr _Tp __subscript_in_pack(const simd<_Tp, _Ap>& __x, const simd<_Tp, _As>&... __xs) { if constexpr (_I < simd_size_v<_Tp, _Ap>) return __x[_I]; else return __subscript_in_pack<_I - simd_size_v<_Tp, _Ap>>(__xs...); } // }}} // __store_pack_of_simd {{{ template <typename _Tp, typename _A0, typename... _As> _GLIBCXX_SIMD_INTRINSIC void __store_pack_of_simd(char* __mem, const simd<_Tp, _A0>& __x0, const simd<_Tp, _As>&... __xs) { constexpr size_t __n_bytes = sizeof(_Tp) * simd_size_v<_Tp, _A0>; __builtin_memcpy(__mem, &__data(__x0), __n_bytes); if constexpr (sizeof...(__xs) > 0) __store_pack_of_simd(__mem + __n_bytes, __xs...); } // }}} // concat(simd...) {{{ template <typename _Tp, typename... _As> inline _GLIBCXX_SIMD_CONSTEXPR simd<_Tp, simd_abi::deduce_t<_Tp, (simd_size_v<_Tp, _As> + ...)>> concat(const simd<_Tp, _As>&... __xs) { using _Rp = __deduced_simd<_Tp, (simd_size_v<_Tp, _As> + ...)>; if constexpr (sizeof...(__xs) == 1) return simd_cast<_Rp>(__xs...); else if ((... && __xs._M_is_constprop())) return simd<_Tp, simd_abi::deduce_t<_Tp, (simd_size_v<_Tp, _As> + ...)>>( [&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __subscript_in_pack<__i>(__xs...); }); else { _Rp __r{}; __store_pack_of_simd(reinterpret_cast<char*>(&__data(__r)), __xs...); return __r; } } // }}} // concat(array<simd>) {{{ template <typename _Tp, typename _Abi, size_t _Np> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR __deduced_simd<_Tp, simd_size_v<_Tp, _Abi> * _Np> concat(const array<simd<_Tp, _Abi>, _Np>& __x) { return __call_with_subscripts<_Np>( __x, [](const auto&... __xs) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return concat(__xs...); }); } // }}} /// @cond undocumented // _SmartReference {{{ template <typename _Up, typename _Accessor = _Up, typename _ValueType = typename _Up::value_type> class _SmartReference { friend _Accessor; int _M_index; _Up& _M_obj; _GLIBCXX_SIMD_INTRINSIC constexpr _ValueType _M_read() const noexcept { if constexpr (is_arithmetic_v<_Up>) return _M_obj; else return _M_obj[_M_index]; } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC constexpr void _M_write(_Tp&& __x) const { _Accessor::_S_set(_M_obj, _M_index, static_cast<_Tp&&>(__x)); } public: _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference(_Up& __o, int __i) noexcept : _M_index(__i), _M_obj(__o) {} using value_type = _ValueType; _GLIBCXX_SIMD_INTRINSIC _SmartReference(const _SmartReference&) = delete; _GLIBCXX_SIMD_INTRINSIC constexpr operator value_type() const noexcept { return _M_read(); } template <typename _Tp, typename = _ValuePreservingOrInt<__remove_cvref_t<_Tp>, value_type>> _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference operator=(_Tp&& __x) && { _M_write(static_cast<_Tp&&>(__x)); return {_M_obj, _M_index}; } #define _GLIBCXX_SIMD_OP_(__op) \ template <typename _Tp, \ typename _TT = decltype(declval<value_type>() __op declval<_Tp>()), \ typename = _ValuePreservingOrInt<__remove_cvref_t<_Tp>, _TT>, \ typename = _ValuePreservingOrInt<_TT, value_type>> \ _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference \ operator __op##=(_Tp&& __x) && \ { \ const value_type& __lhs = _M_read(); \ _M_write(__lhs __op __x); \ return {_M_obj, _M_index}; \ } _GLIBCXX_SIMD_ALL_ARITHMETICS(_GLIBCXX_SIMD_OP_); _GLIBCXX_SIMD_ALL_SHIFTS(_GLIBCXX_SIMD_OP_); _GLIBCXX_SIMD_ALL_BINARY(_GLIBCXX_SIMD_OP_); #undef _GLIBCXX_SIMD_OP_ template <typename _Tp = void, typename = decltype(++declval<conditional_t<true, value_type, _Tp>&>())> _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference operator++() && { value_type __x = _M_read(); _M_write(++__x); return {_M_obj, _M_index}; } template <typename _Tp = void, typename = decltype(declval<conditional_t<true, value_type, _Tp>&>()++)> _GLIBCXX_SIMD_INTRINSIC constexpr value_type operator++(int) && { const value_type __r = _M_read(); value_type __x = __r; _M_write(++__x); return __r; } template <typename _Tp = void, typename = decltype(--declval<conditional_t<true, value_type, _Tp>&>())> _GLIBCXX_SIMD_INTRINSIC constexpr _SmartReference operator--() && { value_type __x = _M_read(); _M_write(--__x); return {_M_obj, _M_index}; } template <typename _Tp = void, typename = decltype(declval<conditional_t<true, value_type, _Tp>&>()--)> _GLIBCXX_SIMD_INTRINSIC constexpr value_type operator--(int) && { const value_type __r = _M_read(); value_type __x = __r; _M_write(--__x); return __r; } _GLIBCXX_SIMD_INTRINSIC friend void swap(_SmartReference&& __a, _SmartReference&& __b) noexcept( conjunction< is_nothrow_constructible<value_type, _SmartReference&&>, is_nothrow_assignable<_SmartReference&&, value_type&&>>::value) { value_type __tmp = static_cast<_SmartReference&&>(__a); static_cast<_SmartReference&&>(__a) = static_cast<value_type>(__b); static_cast<_SmartReference&&>(__b) = std::move(__tmp); } _GLIBCXX_SIMD_INTRINSIC friend void swap(value_type& __a, _SmartReference&& __b) noexcept( conjunction< is_nothrow_constructible<value_type, value_type&&>, is_nothrow_assignable<value_type&, value_type&&>, is_nothrow_assignable<_SmartReference&&, value_type&&>>::value) { value_type __tmp(std::move(__a)); __a = static_cast<value_type>(__b); static_cast<_SmartReference&&>(__b) = std::move(__tmp); } _GLIBCXX_SIMD_INTRINSIC friend void swap(_SmartReference&& __a, value_type& __b) noexcept( conjunction< is_nothrow_constructible<value_type, _SmartReference&&>, is_nothrow_assignable<value_type&, value_type&&>, is_nothrow_assignable<_SmartReference&&, value_type&&>>::value) { value_type __tmp(__a); static_cast<_SmartReference&&>(__a) = std::move(__b); __b = std::move(__tmp); } }; // }}} // __scalar_abi_wrapper {{{ template <int _Bytes> struct __scalar_abi_wrapper { template <typename _Tp> static constexpr size_t _S_full_size = 1; template <typename _Tp> static constexpr size_t _S_size = 1; template <typename _Tp> static constexpr size_t _S_is_partial = false; template <typename _Tp, typename _Abi = simd_abi::scalar> static constexpr bool _S_is_valid_v = _Abi::template _IsValid<_Tp>::value && sizeof(_Tp) == _Bytes; }; // }}} // __decay_abi metafunction {{{ template <typename _Tp> struct __decay_abi { using type = _Tp; }; template <int _Bytes> struct __decay_abi<__scalar_abi_wrapper<_Bytes>> { using type = simd_abi::scalar; }; // }}} // __find_next_valid_abi metafunction {{{1 // Given an ABI tag A<N>, find an N2 < N such that A<N2>::_S_is_valid_v<_Tp> == // true, N2 is a power-of-2, and A<N2>::_S_is_partial<_Tp> is false. Break // recursion at 2 elements in the resulting ABI tag. In this case // type::_S_is_valid_v<_Tp> may be false. template <template <int> class _Abi, int _Bytes, typename _Tp> struct __find_next_valid_abi { static constexpr auto _S_choose() { constexpr int _NextBytes = std::__bit_ceil(_Bytes) / 2; using _NextAbi = _Abi<_NextBytes>; if constexpr (_NextBytes < sizeof(_Tp) * 2) // break recursion return _Abi<_Bytes>(); else if constexpr (_NextAbi::template _S_is_partial<_Tp> == false && _NextAbi::template _S_is_valid_v<_Tp>) return _NextAbi(); else return __find_next_valid_abi<_Abi, _NextBytes, _Tp>::_S_choose(); } using type = decltype(_S_choose()); }; template <int _Bytes, typename _Tp> struct __find_next_valid_abi<__scalar_abi_wrapper, _Bytes, _Tp> { using type = simd_abi::scalar; }; // _AbiList {{{1 template <template <int> class...> struct _AbiList { template <typename, int> static constexpr bool _S_has_valid_abi = false; template <typename, int> using _FirstValidAbi = void; template <typename, int> using _BestAbi = void; }; template <template <int> class _A0, template <int> class... _Rest> struct _AbiList<_A0, _Rest...> { template <typename _Tp, int _Np> static constexpr bool _S_has_valid_abi = _A0<sizeof(_Tp) * _Np>::template _S_is_valid_v< _Tp> || _AbiList<_Rest...>::template _S_has_valid_abi<_Tp, _Np>; template <typename _Tp, int _Np> using _FirstValidAbi = conditional_t< _A0<sizeof(_Tp) * _Np>::template _S_is_valid_v<_Tp>, typename __decay_abi<_A0<sizeof(_Tp) * _Np>>::type, typename _AbiList<_Rest...>::template _FirstValidAbi<_Tp, _Np>>; template <typename _Tp, int _Np> static constexpr auto _S_determine_best_abi() { static_assert(_Np >= 1); constexpr int _Bytes = sizeof(_Tp) * _Np; if constexpr (_Np == 1) return __make_dependent_t<_Tp, simd_abi::scalar>{}; else { constexpr int __fullsize = _A0<_Bytes>::template _S_full_size<_Tp>; // _A0<_Bytes> is good if: // 1. The ABI tag is valid for _Tp // 2. The storage overhead is no more than padding to fill the next // power-of-2 number of bytes if constexpr (_A0<_Bytes>::template _S_is_valid_v< _Tp> && __fullsize / 2 < _Np) return typename __decay_abi<_A0<_Bytes>>::type{}; else { using _Bp = typename __find_next_valid_abi<_A0, _Bytes, _Tp>::type; if constexpr (_Bp::template _S_is_valid_v< _Tp> && _Bp::template _S_size<_Tp> <= _Np) return _Bp{}; else return typename _AbiList<_Rest...>::template _BestAbi<_Tp, _Np>{}; } } } template <typename _Tp, int _Np> using _BestAbi = decltype(_S_determine_best_abi<_Tp, _Np>()); }; // }}}1 // the following lists all native ABIs, which makes them accessible to // simd_abi::deduce and select_best_vector_type_t (for fixed_size). Order // matters: Whatever comes first has higher priority. using _AllNativeAbis = _AbiList<simd_abi::_VecBltnBtmsk, simd_abi::_VecBuiltin, __scalar_abi_wrapper>; // valid _SimdTraits specialization {{{1 template <typename _Tp, typename _Abi> struct _SimdTraits<_Tp, _Abi, void_t<typename _Abi::template _IsValid<_Tp>>> : _Abi::template __traits<_Tp> {}; // __deduce_impl specializations {{{1 // try all native ABIs (including scalar) first template <typename _Tp, size_t _Np> struct __deduce_impl< _Tp, _Np, enable_if_t<_AllNativeAbis::template _S_has_valid_abi<_Tp, _Np>>> { using type = _AllNativeAbis::_FirstValidAbi<_Tp, _Np>; }; // fall back to fixed_size only if scalar and native ABIs don't match template <typename _Tp, size_t _Np, typename = void> struct __deduce_fixed_size_fallback {}; template <typename _Tp, size_t _Np> struct __deduce_fixed_size_fallback<_Tp, _Np, enable_if_t<simd_abi::fixed_size<_Np>::template _S_is_valid_v<_Tp>>> { using type = simd_abi::fixed_size<_Np>; }; template <typename _Tp, size_t _Np, typename> struct __deduce_impl : public __deduce_fixed_size_fallback<_Tp, _Np> {}; //}}}1 /// @endcond // simd_mask {{{ template <typename _Tp, typename _Abi> class simd_mask : public _SimdTraits<_Tp, _Abi>::_MaskBase { // types, tags, and friends {{{ using _Traits = _SimdTraits<_Tp, _Abi>; using _MemberType = typename _Traits::_MaskMember; // We map all masks with equal element sizeof to a single integer type, the // one given by __int_for_sizeof_t<_Tp>. This is the approach // [[gnu::vector_size(N)]] types take as well and it reduces the number of // template specializations in the implementation classes. using _Ip = __int_for_sizeof_t<_Tp>; static constexpr _Ip* _S_type_tag = nullptr; friend typename _Traits::_MaskBase; friend class simd<_Tp, _Abi>; // to construct masks on return friend typename _Traits::_SimdImpl; // to construct masks on return and // inspect data on masked operations public: using _Impl = typename _Traits::_MaskImpl; friend _Impl; // }}} // member types {{{ using value_type = bool; using reference = _SmartReference<_MemberType, _Impl, value_type>; using simd_type = simd<_Tp, _Abi>; using abi_type = _Abi; // }}} static constexpr size_t size() // {{{ { return __size_or_zero_v<_Tp, _Abi>; } // }}} // constructors & assignment {{{ simd_mask() = default; simd_mask(const simd_mask&) = default; simd_mask(simd_mask&&) = default; simd_mask& operator=(const simd_mask&) = default; simd_mask& operator=(simd_mask&&) = default; // }}} // access to internal representation (optional feature) {{{ _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR explicit simd_mask(typename _Traits::_MaskCastType __init) : _M_data{__init} {} // conversions to internal type is done in _MaskBase // }}} // bitset interface (extension to be proposed) {{{ // TS_FEEDBACK: // Conversion of simd_mask to and from bitset makes it much easier to // interface with other facilities. I suggest adding `static // simd_mask::from_bitset` and `simd_mask::to_bitset`. _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR static simd_mask __from_bitset(bitset<size()> bs) { return {__bitset_init, bs}; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR bitset<size()> __to_bitset() const { return _Impl::_S_to_bits(_M_data)._M_to_bitset(); } // }}} // explicit broadcast constructor {{{ _GLIBCXX_SIMD_ALWAYS_INLINE explicit _GLIBCXX_SIMD_CONSTEXPR simd_mask(value_type __x) : _M_data(_Impl::template _S_broadcast<_Ip>(__x)) {} // }}} // implicit type conversion constructor {{{ #ifdef _GLIBCXX_SIMD_ENABLE_IMPLICIT_MASK_CAST // proposed improvement template <typename _Up, typename _A2, typename = enable_if_t<simd_size_v<_Up, _A2> == size()>> _GLIBCXX_SIMD_ALWAYS_INLINE explicit(sizeof(_MemberType) != sizeof(typename _SimdTraits<_Up, _A2>::_MaskMember)) simd_mask(const simd_mask<_Up, _A2>& __x) : simd_mask(__proposed::static_simd_cast<simd_mask>(__x)) {} #else // conforming to ISO/IEC 19570:2018 template <typename _Up, typename = enable_if_t<conjunction< is_same<abi_type, simd_abi::fixed_size<size()>>, is_same<_Up, _Up>>::value>> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd_mask(const simd_mask<_Up, simd_abi::fixed_size<size()>>& __x) : _M_data(_Impl::_S_from_bitmask(__data(__x), _S_type_tag)) {} #endif // }}} // load constructor {{{ template <typename _Flags> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd_mask(const value_type* __mem, _IsSimdFlagType<_Flags>) : _M_data(_Impl::template _S_load<_Ip>(_Flags::template _S_apply<simd_mask>(__mem))) {} template <typename _Flags> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd_mask(const value_type* __mem, simd_mask __k, _IsSimdFlagType<_Flags>) : _M_data{} { _M_data = _Impl::_S_masked_load(_M_data, __k._M_data, _Flags::template _S_apply<simd_mask>(__mem)); } // }}} // loads [simd_mask.load] {{{ template <typename _Flags> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR void copy_from(const value_type* __mem, _IsSimdFlagType<_Flags>) { _M_data = _Impl::template _S_load<_Ip>(_Flags::template _S_apply<simd_mask>(__mem)); } // }}} // stores [simd_mask.store] {{{ template <typename _Flags> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR void copy_to(value_type* __mem, _IsSimdFlagType<_Flags>) const { _Impl::_S_store(_M_data, _Flags::template _S_apply<simd_mask>(__mem)); } // }}} // scalar access {{{ _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR reference operator[](size_t __i) { if (__i >= size()) __invoke_ub("Subscript %d is out of range [0, %d]", __i, size() - 1); return {_M_data, int(__i)}; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR value_type operator[](size_t __i) const { if (__i >= size()) __invoke_ub("Subscript %d is out of range [0, %d]", __i, size() - 1); if constexpr (__is_scalar_abi<_Abi>()) return _M_data; else return static_cast<bool>(_M_data[__i]); } // }}} // negation {{{ _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd_mask operator!() const { return {__private_init, _Impl::_S_bit_not(_M_data)}; } // }}} // simd_mask binary operators [simd_mask.binary] {{{ #ifdef _GLIBCXX_SIMD_ENABLE_IMPLICIT_MASK_CAST // simd_mask<int> && simd_mask<uint> needs disambiguation template <typename _Up, typename _A2, typename = enable_if_t<is_convertible_v<simd_mask<_Up, _A2>, simd_mask>>> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask operator&&(const simd_mask& __x, const simd_mask<_Up, _A2>& __y) { return {__private_init, _Impl::_S_logical_and(__x._M_data, simd_mask(__y)._M_data)}; } template <typename _Up, typename _A2, typename = enable_if_t<is_convertible_v<simd_mask<_Up, _A2>, simd_mask>>> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask operator||(const simd_mask& __x, const simd_mask<_Up, _A2>& __y) { return {__private_init, _Impl::_S_logical_or(__x._M_data, simd_mask(__y)._M_data)}; } #endif // _GLIBCXX_SIMD_ENABLE_IMPLICIT_MASK_CAST _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask operator&&(const simd_mask& __x, const simd_mask& __y) { return {__private_init, _Impl::_S_logical_and(__x._M_data, __y._M_data)}; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask operator||(const simd_mask& __x, const simd_mask& __y) { return {__private_init, _Impl::_S_logical_or(__x._M_data, __y._M_data)}; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask operator&(const simd_mask& __x, const simd_mask& __y) { return {__private_init, _Impl::_S_bit_and(__x._M_data, __y._M_data)}; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask operator|(const simd_mask& __x, const simd_mask& __y) { return {__private_init, _Impl::_S_bit_or(__x._M_data, __y._M_data)}; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask operator^(const simd_mask& __x, const simd_mask& __y) { return {__private_init, _Impl::_S_bit_xor(__x._M_data, __y._M_data)}; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask& operator&=(simd_mask& __x, const simd_mask& __y) { __x._M_data = _Impl::_S_bit_and(__x._M_data, __y._M_data); return __x; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask& operator|=(simd_mask& __x, const simd_mask& __y) { __x._M_data = _Impl::_S_bit_or(__x._M_data, __y._M_data); return __x; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask& operator^=(simd_mask& __x, const simd_mask& __y) { __x._M_data = _Impl::_S_bit_xor(__x._M_data, __y._M_data); return __x; } // }}} // simd_mask compares [simd_mask.comparison] {{{ _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask operator==(const simd_mask& __x, const simd_mask& __y) { return !operator!=(__x, __y); } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask operator!=(const simd_mask& __x, const simd_mask& __y) { return {__private_init, _Impl::_S_bit_xor(__x._M_data, __y._M_data)}; } // }}} // private_init ctor {{{ _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR simd_mask(_PrivateInit, typename _Traits::_MaskMember __init) : _M_data(__init) {} // }}} // private_init generator ctor {{{ template <typename _Fp, typename = decltype(bool(declval<_Fp>()(size_t())))> _GLIBCXX_SIMD_INTRINSIC constexpr simd_mask(_PrivateInit, _Fp&& __gen) : _M_data() { __execute_n_times<size()>([&](auto __i) constexpr _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { _Impl::_S_set(_M_data, __i, __gen(__i)); }); } // }}} // bitset_init ctor {{{ _GLIBCXX_SIMD_INTRINSIC constexpr simd_mask(_BitsetInit, bitset<size()> __init) : _M_data(_Impl::_S_from_bitmask(_SanitizedBitMask<size()>(__init), _S_type_tag)) {} // }}} // __cvt {{{ // TS_FEEDBACK: // The conversion operator this implements should be a ctor on simd_mask. // Once you call .__cvt() on a simd_mask it converts conveniently. // A useful variation: add `explicit(sizeof(_Tp) != sizeof(_Up))` struct _CvtProxy { template <typename _Up, typename _A2, typename = enable_if_t<simd_size_v<_Up, _A2> == simd_size_v<_Tp, _Abi>>> operator simd_mask<_Up, _A2>() && { using namespace std::experimental::__proposed; return static_simd_cast<simd_mask<_Up, _A2>>(_M_data); } const simd_mask<_Tp, _Abi>& _M_data; }; _GLIBCXX_SIMD_INTRINSIC _CvtProxy __cvt() const { return {*this}; } // }}} // operator?: overloads (suggested extension) {{{ #ifdef __GXX_CONDITIONAL_IS_OVERLOADABLE__ _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask operator?:(const simd_mask& __k, const simd_mask& __where_true, const simd_mask& __where_false) { auto __ret = __where_false; _Impl::_S_masked_assign(__k._M_data, __ret._M_data, __where_true._M_data); return __ret; } template <typename _U1, typename _U2, typename _Rp = simd<common_type_t<_U1, _U2>, _Abi>, typename = enable_if_t<conjunction_v< is_convertible<_U1, _Rp>, is_convertible<_U2, _Rp>, is_convertible<simd_mask, typename _Rp::mask_type>>>> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend _Rp operator?:(const simd_mask& __k, const _U1& __where_true, const _U2& __where_false) { _Rp __ret = __where_false; _Rp::_Impl::_S_masked_assign( __data(static_cast<typename _Rp::mask_type>(__k)), __data(__ret), __data(static_cast<_Rp>(__where_true))); return __ret; } #ifdef _GLIBCXX_SIMD_ENABLE_IMPLICIT_MASK_CAST template <typename _Kp, typename _Ak, typename _Up, typename _Au, typename = enable_if_t< conjunction_v<is_convertible<simd_mask<_Kp, _Ak>, simd_mask>, is_convertible<simd_mask<_Up, _Au>, simd_mask>>>> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd_mask operator?:(const simd_mask<_Kp, _Ak>& __k, const simd_mask& __where_true, const simd_mask<_Up, _Au>& __where_false) { simd_mask __ret = __where_false; _Impl::_S_masked_assign(simd_mask(__k)._M_data, __ret._M_data, __where_true._M_data); return __ret; } #endif // _GLIBCXX_SIMD_ENABLE_IMPLICIT_MASK_CAST #endif // __GXX_CONDITIONAL_IS_OVERLOADABLE__ // }}} // _M_is_constprop {{{ _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop() const { if constexpr (__is_scalar_abi<_Abi>()) return __builtin_constant_p(_M_data); else return _M_data._M_is_constprop(); } // }}} private: friend const auto& __data<_Tp, abi_type>(const simd_mask&); friend auto& __data<_Tp, abi_type>(simd_mask&); alignas(_Traits::_S_mask_align) _MemberType _M_data; }; // }}} /// @cond undocumented // __data(simd_mask) {{{ template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC constexpr const auto& __data(const simd_mask<_Tp, _Ap>& __x) { return __x._M_data; } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC constexpr auto& __data(simd_mask<_Tp, _Ap>& __x) { return __x._M_data; } // }}} /// @endcond // simd_mask reductions [simd_mask.reductions] {{{ template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR bool all_of(const simd_mask<_Tp, _Abi>& __k) noexcept { if (__builtin_is_constant_evaluated() || __k._M_is_constprop()) { for (size_t __i = 0; __i < simd_size_v<_Tp, _Abi>; ++__i) if (!__k[__i]) return false; return true; } else return _Abi::_MaskImpl::_S_all_of(__k); } template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR bool any_of(const simd_mask<_Tp, _Abi>& __k) noexcept { if (__builtin_is_constant_evaluated() || __k._M_is_constprop()) { for (size_t __i = 0; __i < simd_size_v<_Tp, _Abi>; ++__i) if (__k[__i]) return true; return false; } else return _Abi::_MaskImpl::_S_any_of(__k); } template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR bool none_of(const simd_mask<_Tp, _Abi>& __k) noexcept { if (__builtin_is_constant_evaluated() || __k._M_is_constprop()) { for (size_t __i = 0; __i < simd_size_v<_Tp, _Abi>; ++__i) if (__k[__i]) return false; return true; } else return _Abi::_MaskImpl::_S_none_of(__k); } template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR bool some_of(const simd_mask<_Tp, _Abi>& __k) noexcept { if (__builtin_is_constant_evaluated() || __k._M_is_constprop()) { for (size_t __i = 1; __i < simd_size_v<_Tp, _Abi>; ++__i) if (__k[__i] != __k[__i - 1]) return true; return false; } else return _Abi::_MaskImpl::_S_some_of(__k); } template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR int popcount(const simd_mask<_Tp, _Abi>& __k) noexcept { if (__builtin_is_constant_evaluated() || __k._M_is_constprop()) { const int __r = __call_with_subscripts<simd_size_v<_Tp, _Abi>>( __k, [](auto... __elements) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return ((__elements != 0) + ...); }); if (__builtin_is_constant_evaluated() || __builtin_constant_p(__r)) return __r; } return _Abi::_MaskImpl::_S_popcount(__k); } template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR int find_first_set(const simd_mask<_Tp, _Abi>& __k) { if (__builtin_is_constant_evaluated() || __k._M_is_constprop()) { constexpr size_t _Np = simd_size_v<_Tp, _Abi>; const size_t _Idx = __call_with_n_evaluations<_Np>( [](auto... __indexes) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return std::min({__indexes...}); }, [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __k[__i] ? +__i : _Np; }); if (_Idx >= _Np) __invoke_ub("find_first_set(empty mask) is UB"); if (__builtin_constant_p(_Idx)) return _Idx; } return _Abi::_MaskImpl::_S_find_first_set(__k); } template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR int find_last_set(const simd_mask<_Tp, _Abi>& __k) { if (__builtin_is_constant_evaluated() || __k._M_is_constprop()) { constexpr size_t _Np = simd_size_v<_Tp, _Abi>; const int _Idx = __call_with_n_evaluations<_Np>( [](auto... __indexes) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return std::max({__indexes...}); }, [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return __k[__i] ? int(__i) : -1; }); if (_Idx < 0) __invoke_ub("find_first_set(empty mask) is UB"); if (__builtin_constant_p(_Idx)) return _Idx; } return _Abi::_MaskImpl::_S_find_last_set(__k); } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR bool all_of(_ExactBool __x) noexcept { return __x; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR bool any_of(_ExactBool __x) noexcept { return __x; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR bool none_of(_ExactBool __x) noexcept { return !__x; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR bool some_of(_ExactBool) noexcept { return false; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR int popcount(_ExactBool __x) noexcept { return __x; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR int find_first_set(_ExactBool) { return 0; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR int find_last_set(_ExactBool) { return 0; } // }}} /// @cond undocumented // _SimdIntOperators{{{1 template <typename _V, typename _Impl, bool> class _SimdIntOperators {}; template <typename _V, typename _Impl> class _SimdIntOperators<_V, _Impl, true> { _GLIBCXX_SIMD_INTRINSIC constexpr const _V& __derived() const { return *static_cast<const _V*>(this); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _GLIBCXX_SIMD_CONSTEXPR _V _S_make_derived(_Tp&& __d) { return {__private_init, static_cast<_Tp&&>(__d)}; } public: _GLIBCXX_SIMD_CONSTEXPR friend _V& operator%=(_V& __lhs, const _V& __x) { return __lhs = __lhs % __x; } _GLIBCXX_SIMD_CONSTEXPR friend _V& operator&=(_V& __lhs, const _V& __x) { return __lhs = __lhs & __x; } _GLIBCXX_SIMD_CONSTEXPR friend _V& operator|=(_V& __lhs, const _V& __x) { return __lhs = __lhs | __x; } _GLIBCXX_SIMD_CONSTEXPR friend _V& operator^=(_V& __lhs, const _V& __x) { return __lhs = __lhs ^ __x; } _GLIBCXX_SIMD_CONSTEXPR friend _V& operator<<=(_V& __lhs, const _V& __x) { return __lhs = __lhs << __x; } _GLIBCXX_SIMD_CONSTEXPR friend _V& operator>>=(_V& __lhs, const _V& __x) { return __lhs = __lhs >> __x; } _GLIBCXX_SIMD_CONSTEXPR friend _V& operator<<=(_V& __lhs, int __x) { return __lhs = __lhs << __x; } _GLIBCXX_SIMD_CONSTEXPR friend _V& operator>>=(_V& __lhs, int __x) { return __lhs = __lhs >> __x; } _GLIBCXX_SIMD_CONSTEXPR friend _V operator%(const _V& __x, const _V& __y) { return _SimdIntOperators::_S_make_derived( _Impl::_S_modulus(__data(__x), __data(__y))); } _GLIBCXX_SIMD_CONSTEXPR friend _V operator&(const _V& __x, const _V& __y) { return _SimdIntOperators::_S_make_derived( _Impl::_S_bit_and(__data(__x), __data(__y))); } _GLIBCXX_SIMD_CONSTEXPR friend _V operator|(const _V& __x, const _V& __y) { return _SimdIntOperators::_S_make_derived( _Impl::_S_bit_or(__data(__x), __data(__y))); } _GLIBCXX_SIMD_CONSTEXPR friend _V operator^(const _V& __x, const _V& __y) { return _SimdIntOperators::_S_make_derived( _Impl::_S_bit_xor(__data(__x), __data(__y))); } _GLIBCXX_SIMD_CONSTEXPR friend _V operator<<(const _V& __x, const _V& __y) { return _SimdIntOperators::_S_make_derived( _Impl::_S_bit_shift_left(__data(__x), __data(__y))); } _GLIBCXX_SIMD_CONSTEXPR friend _V operator>>(const _V& __x, const _V& __y) { return _SimdIntOperators::_S_make_derived( _Impl::_S_bit_shift_right(__data(__x), __data(__y))); } template <typename _VV = _V> _GLIBCXX_SIMD_CONSTEXPR friend _V operator<<(const _V& __x, int __y) { using _Tp = typename _VV::value_type; if (__y < 0) __invoke_ub("The behavior is undefined if the right operand of a " "shift operation is negative. [expr.shift]\nA shift by " "%d was requested", __y); if (size_t(__y) >= sizeof(declval<_Tp>() << __y) * __CHAR_BIT__) __invoke_ub( "The behavior is undefined if the right operand of a " "shift operation is greater than or equal to the width of the " "promoted left operand. [expr.shift]\nA shift by %d was requested", __y); return _SimdIntOperators::_S_make_derived( _Impl::_S_bit_shift_left(__data(__x), __y)); } template <typename _VV = _V> _GLIBCXX_SIMD_CONSTEXPR friend _V operator>>(const _V& __x, int __y) { using _Tp = typename _VV::value_type; if (__y < 0) __invoke_ub( "The behavior is undefined if the right operand of a shift " "operation is negative. [expr.shift]\nA shift by %d was requested", __y); if (size_t(__y) >= sizeof(declval<_Tp>() << __y) * __CHAR_BIT__) __invoke_ub( "The behavior is undefined if the right operand of a shift " "operation is greater than or equal to the width of the promoted " "left operand. [expr.shift]\nA shift by %d was requested", __y); return _SimdIntOperators::_S_make_derived( _Impl::_S_bit_shift_right(__data(__x), __y)); } // unary operators (for integral _Tp) _GLIBCXX_SIMD_CONSTEXPR _V operator~() const { return {__private_init, _Impl::_S_complement(__derived()._M_data)}; } }; //}}}1 /// @endcond // simd {{{ template <typename _Tp, typename _Abi> class simd : public _SimdIntOperators< simd<_Tp, _Abi>, typename _SimdTraits<_Tp, _Abi>::_SimdImpl, conjunction<is_integral<_Tp>, typename _SimdTraits<_Tp, _Abi>::_IsValid>::value>, public _SimdTraits<_Tp, _Abi>::_SimdBase { using _Traits = _SimdTraits<_Tp, _Abi>; using _MemberType = typename _Traits::_SimdMember; using _CastType = typename _Traits::_SimdCastType; static constexpr _Tp* _S_type_tag = nullptr; friend typename _Traits::_SimdBase; public: using _Impl = typename _Traits::_SimdImpl; friend _Impl; friend _SimdIntOperators<simd, _Impl, true>; using value_type = _Tp; using reference = _SmartReference<_MemberType, _Impl, value_type>; using mask_type = simd_mask<_Tp, _Abi>; using abi_type = _Abi; static constexpr size_t size() { return __size_or_zero_v<_Tp, _Abi>; } _GLIBCXX_SIMD_CONSTEXPR simd() = default; _GLIBCXX_SIMD_CONSTEXPR simd(const simd&) = default; _GLIBCXX_SIMD_CONSTEXPR simd(simd&&) noexcept = default; _GLIBCXX_SIMD_CONSTEXPR simd& operator=(const simd&) = default; _GLIBCXX_SIMD_CONSTEXPR simd& operator=(simd&&) noexcept = default; // implicit broadcast constructor template <typename _Up, typename = enable_if_t<!is_same_v<__remove_cvref_t<_Up>, bool>>> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd(_ValuePreservingOrInt<_Up, value_type>&& __x) : _M_data( _Impl::_S_broadcast(static_cast<value_type>(static_cast<_Up&&>(__x)))) {} // implicit type conversion constructor (convert from fixed_size to // fixed_size) template <typename _Up> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd(const simd<_Up, simd_abi::fixed_size<size()>>& __x, enable_if_t< conjunction< is_same<simd_abi::fixed_size<size()>, abi_type>, negation<__is_narrowing_conversion<_Up, value_type>>, __converts_to_higher_integer_rank<_Up, value_type>>::value, void*> = nullptr) : simd{static_cast<array<_Up, size()>>(__x).data(), vector_aligned} {} // explicit type conversion constructor #ifdef _GLIBCXX_SIMD_ENABLE_STATIC_CAST template <typename _Up, typename _A2, typename = decltype(static_simd_cast<simd>( declval<const simd<_Up, _A2>&>()))> _GLIBCXX_SIMD_ALWAYS_INLINE explicit _GLIBCXX_SIMD_CONSTEXPR simd(const simd<_Up, _A2>& __x) : simd(static_simd_cast<simd>(__x)) {} #endif // _GLIBCXX_SIMD_ENABLE_STATIC_CAST // generator constructor template <typename _Fp> _GLIBCXX_SIMD_ALWAYS_INLINE explicit _GLIBCXX_SIMD_CONSTEXPR simd(_Fp&& __gen, _ValuePreservingOrInt<decltype(declval<_Fp>()( declval<_SizeConstant<0>&>())), value_type>* = nullptr) : _M_data(_Impl::_S_generator(static_cast<_Fp&&>(__gen), _S_type_tag)) {} // load constructor template <typename _Up, typename _Flags> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd(const _Up* __mem, _IsSimdFlagType<_Flags>) : _M_data( _Impl::_S_load(_Flags::template _S_apply<simd>(__mem), _S_type_tag)) {} // loads [simd.load] template <typename _Up, typename _Flags> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR void copy_from(const _Vectorizable<_Up>* __mem, _IsSimdFlagType<_Flags>) { _M_data = static_cast<decltype(_M_data)>( _Impl::_S_load(_Flags::template _S_apply<simd>(__mem), _S_type_tag)); } // stores [simd.store] template <typename _Up, typename _Flags> _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR void copy_to(_Vectorizable<_Up>* __mem, _IsSimdFlagType<_Flags>) const { _Impl::_S_store(_M_data, _Flags::template _S_apply<simd>(__mem), _S_type_tag); } // scalar access _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR reference operator[](size_t __i) { return {_M_data, int(__i)}; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR value_type operator[]([[maybe_unused]] size_t __i) const { if constexpr (__is_scalar_abi<_Abi>()) { _GLIBCXX_DEBUG_ASSERT(__i == 0); return _M_data; } else return _M_data[__i]; } // increment and decrement: _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd& operator++() { _Impl::_S_increment(_M_data); return *this; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd operator++(int) { simd __r = *this; _Impl::_S_increment(_M_data); return __r; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd& operator--() { _Impl::_S_decrement(_M_data); return *this; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd operator--(int) { simd __r = *this; _Impl::_S_decrement(_M_data); return __r; } // unary operators (for any _Tp) _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR mask_type operator!() const { return {__private_init, _Impl::_S_negate(_M_data)}; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd operator+() const { return *this; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR simd operator-() const { return {__private_init, _Impl::_S_unary_minus(_M_data)}; } // access to internal representation (suggested extension) _GLIBCXX_SIMD_ALWAYS_INLINE explicit _GLIBCXX_SIMD_CONSTEXPR simd(_CastType __init) : _M_data(__init) {} // compound assignment [simd.cassign] _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd& operator+=(simd& __lhs, const simd& __x) { return __lhs = __lhs + __x; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd& operator-=(simd& __lhs, const simd& __x) { return __lhs = __lhs - __x; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd& operator*=(simd& __lhs, const simd& __x) { return __lhs = __lhs * __x; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd& operator/=(simd& __lhs, const simd& __x) { return __lhs = __lhs / __x; } // binary operators [simd.binary] _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd operator+(const simd& __x, const simd& __y) { return {__private_init, _Impl::_S_plus(__x._M_data, __y._M_data)}; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd operator-(const simd& __x, const simd& __y) { return {__private_init, _Impl::_S_minus(__x._M_data, __y._M_data)}; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd operator*(const simd& __x, const simd& __y) { return {__private_init, _Impl::_S_multiplies(__x._M_data, __y._M_data)}; } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd operator/(const simd& __x, const simd& __y) { return {__private_init, _Impl::_S_divides(__x._M_data, __y._M_data)}; } // compares [simd.comparison] _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend mask_type operator==(const simd& __x, const simd& __y) { return simd::_S_make_mask(_Impl::_S_equal_to(__x._M_data, __y._M_data)); } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend mask_type operator!=(const simd& __x, const simd& __y) { return simd::_S_make_mask( _Impl::_S_not_equal_to(__x._M_data, __y._M_data)); } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend mask_type operator<(const simd& __x, const simd& __y) { return simd::_S_make_mask(_Impl::_S_less(__x._M_data, __y._M_data)); } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend mask_type operator<=(const simd& __x, const simd& __y) { return simd::_S_make_mask(_Impl::_S_less_equal(__x._M_data, __y._M_data)); } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend mask_type operator>(const simd& __x, const simd& __y) { return simd::_S_make_mask(_Impl::_S_less(__y._M_data, __x._M_data)); } _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend mask_type operator>=(const simd& __x, const simd& __y) { return simd::_S_make_mask(_Impl::_S_less_equal(__y._M_data, __x._M_data)); } // operator?: overloads (suggested extension) {{{ #ifdef __GXX_CONDITIONAL_IS_OVERLOADABLE__ _GLIBCXX_SIMD_ALWAYS_INLINE _GLIBCXX_SIMD_CONSTEXPR friend simd operator?:(const mask_type& __k, const simd& __where_true, const simd& __where_false) { auto __ret = __where_false; _Impl::_S_masked_assign(__data(__k), __data(__ret), __data(__where_true)); return __ret; } #endif // __GXX_CONDITIONAL_IS_OVERLOADABLE__ // }}} // "private" because of the first arguments's namespace _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR simd(_PrivateInit, const _MemberType& __init) : _M_data(__init) {} // "private" because of the first arguments's namespace _GLIBCXX_SIMD_INTRINSIC simd(_BitsetInit, bitset<size()> __init) : _M_data() { where(mask_type(__bitset_init, __init), *this) = ~*this; } _GLIBCXX_SIMD_INTRINSIC constexpr bool _M_is_constprop() const { if constexpr (__is_scalar_abi<_Abi>()) return __builtin_constant_p(_M_data); else return _M_data._M_is_constprop(); } private: _GLIBCXX_SIMD_INTRINSIC static constexpr mask_type _S_make_mask(typename mask_type::_MemberType __k) { return {__private_init, __k}; } friend const auto& __data<value_type, abi_type>(const simd&); friend auto& __data<value_type, abi_type>(simd&); alignas(_Traits::_S_simd_align) _MemberType _M_data; }; // }}} /// @cond undocumented // __data {{{ template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC constexpr const auto& __data(const simd<_Tp, _Ap>& __x) { return __x._M_data; } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC constexpr auto& __data(simd<_Tp, _Ap>& __x) { return __x._M_data; } // }}} namespace __float_bitwise_operators { //{{{ template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR simd<_Tp, _Ap> operator^(const simd<_Tp, _Ap>& __a, const simd<_Tp, _Ap>& __b) { return {__private_init, _Ap::_SimdImpl::_S_bit_xor(__data(__a), __data(__b))}; } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR simd<_Tp, _Ap> operator|(const simd<_Tp, _Ap>& __a, const simd<_Tp, _Ap>& __b) { return {__private_init, _Ap::_SimdImpl::_S_bit_or(__data(__a), __data(__b))}; } template <typename _Tp, typename _Ap> _GLIBCXX_SIMD_INTRINSIC _GLIBCXX_SIMD_CONSTEXPR simd<_Tp, _Ap> operator&(const simd<_Tp, _Ap>& __a, const simd<_Tp, _Ap>& __b) { return {__private_init, _Ap::_SimdImpl::_S_bit_and(__data(__a), __data(__b))}; } } // namespace __float_bitwise_operators }}} /// @endcond /// @} _GLIBCXX_SIMD_END_NAMESPACE #endif // __cplusplus >= 201703L #endif // _GLIBCXX_EXPERIMENTAL_SIMD_H // vim: foldmethod=marker foldmarker={{{,}}} // Simd scalar ABI specific implementations -*- C++ -*- // Copyright (C) 2020-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. #ifndef _GLIBCXX_EXPERIMENTAL_SIMD_SCALAR_H_ #define _GLIBCXX_EXPERIMENTAL_SIMD_SCALAR_H_ #if __cplusplus >= 201703L #include <cmath> _GLIBCXX_SIMD_BEGIN_NAMESPACE // __promote_preserving_unsigned{{{ // work around crazy semantics of unsigned integers of lower rank than int: // Before applying an operator the operands are promoted to int. In which case // over- or underflow is UB, even though the operand types were unsigned. template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC constexpr decltype(auto) __promote_preserving_unsigned(const _Tp& __x) { if constexpr (is_signed_v<decltype(+__x)> && is_unsigned_v<_Tp>) return static_cast<unsigned int>(__x); else return __x; } // }}} struct _CommonImplScalar; struct _CommonImplBuiltin; struct _SimdImplScalar; struct _MaskImplScalar; // simd_abi::_Scalar {{{ struct simd_abi::_Scalar { template <typename _Tp> static constexpr size_t _S_size = 1; template <typename _Tp> static constexpr size_t _S_full_size = 1; template <typename _Tp> static constexpr bool _S_is_partial = false; struct _IsValidAbiTag : true_type {}; template <typename _Tp> struct _IsValidSizeFor : true_type {}; template <typename _Tp> struct _IsValid : __is_vectorizable<_Tp> {}; template <typename _Tp> static constexpr bool _S_is_valid_v = _IsValid<_Tp>::value; _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_masked(bool __x) { return __x; } using _CommonImpl = _CommonImplScalar; using _SimdImpl = _SimdImplScalar; using _MaskImpl = _MaskImplScalar; template <typename _Tp, bool = _S_is_valid_v<_Tp>> struct __traits : _InvalidTraits {}; template <typename _Tp> struct __traits<_Tp, true> { using _IsValid = true_type; using _SimdImpl = _SimdImplScalar; using _MaskImpl = _MaskImplScalar; using _SimdMember = _Tp; using _MaskMember = bool; static constexpr size_t _S_simd_align = alignof(_SimdMember); static constexpr size_t _S_mask_align = alignof(_MaskMember); // nothing the user can spell converts to/from simd/simd_mask struct _SimdCastType { _SimdCastType() = delete; }; struct _MaskCastType { _MaskCastType() = delete; }; struct _SimdBase {}; struct _MaskBase {}; }; }; // }}} // _CommonImplScalar {{{ struct _CommonImplScalar { // _S_store {{{ template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static void _S_store(_Tp __x, void* __addr) { __builtin_memcpy(__addr, &__x, sizeof(_Tp)); } // }}} // _S_store_bool_array(_BitMask) {{{ template <size_t _Np, bool _Sanitized> _GLIBCXX_SIMD_INTRINSIC static constexpr void _S_store_bool_array(_BitMask<_Np, _Sanitized> __x, bool* __mem) { __make_dependent_t<decltype(__x), _CommonImplBuiltin>::_S_store_bool_array( __x, __mem); } // }}} }; // }}} // _SimdImplScalar {{{ struct _SimdImplScalar { // member types {{{2 using abi_type = simd_abi::scalar; template <typename _Tp> using _TypeTag = _Tp*; // _S_broadcast {{{2 template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr _Tp _S_broadcast(_Tp __x) noexcept { return __x; } // _S_generator {{{2 template <typename _Fp, typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr _Tp _S_generator(_Fp&& __gen, _TypeTag<_Tp>) { return __gen(_SizeConstant<0>()); } // _S_load {{{2 template <typename _Tp, typename _Up> _GLIBCXX_SIMD_INTRINSIC static constexpr _Tp _S_load(const _Up* __mem, _TypeTag<_Tp>) noexcept { return static_cast<_Tp>(__mem[0]); } // _S_masked_load {{{2 template <typename _Tp, typename _Up> static constexpr _Tp _S_masked_load(_Tp __merge, bool __k, const _Up* __mem) noexcept { if (__k) __merge = static_cast<_Tp>(__mem[0]); return __merge; } // _S_store {{{2 template <typename _Tp, typename _Up> static constexpr void _S_store(_Tp __v, _Up* __mem, _TypeTag<_Tp>) noexcept { __mem[0] = static_cast<_Up>(__v); } // _S_masked_store {{{2 template <typename _Tp, typename _Up> static constexpr void _S_masked_store(const _Tp __v, _Up* __mem, const bool __k) noexcept { if (__k) __mem[0] = __v; } // _S_negate {{{2 template <typename _Tp> static constexpr inline bool _S_negate(_Tp __x) noexcept { return !__x; } // _S_reduce {{{2 template <typename _Tp, typename _BinaryOperation> static constexpr inline _Tp _S_reduce(const simd<_Tp, simd_abi::scalar>& __x, const _BinaryOperation&) { return __x._M_data; } // _S_min, _S_max {{{2 template <typename _Tp> static constexpr inline _Tp _S_min(const _Tp __a, const _Tp __b) { return std::min(__a, __b); } template <typename _Tp> static constexpr inline _Tp _S_max(const _Tp __a, const _Tp __b) { return std::max(__a, __b); } // _S_complement {{{2 template <typename _Tp> static constexpr inline _Tp _S_complement(_Tp __x) noexcept { return static_cast<_Tp>(~__x); } // _S_unary_minus {{{2 template <typename _Tp> static constexpr inline _Tp _S_unary_minus(_Tp __x) noexcept { return static_cast<_Tp>(-__x); } // arithmetic operators {{{2 template <typename _Tp> static constexpr inline _Tp _S_plus(_Tp __x, _Tp __y) { return static_cast<_Tp>(__promote_preserving_unsigned(__x) + __promote_preserving_unsigned(__y)); } template <typename _Tp> static constexpr inline _Tp _S_minus(_Tp __x, _Tp __y) { return static_cast<_Tp>(__promote_preserving_unsigned(__x) - __promote_preserving_unsigned(__y)); } template <typename _Tp> static constexpr inline _Tp _S_multiplies(_Tp __x, _Tp __y) { return static_cast<_Tp>(__promote_preserving_unsigned(__x) * __promote_preserving_unsigned(__y)); } template <typename _Tp> static constexpr inline _Tp _S_divides(_Tp __x, _Tp __y) { return static_cast<_Tp>(__promote_preserving_unsigned(__x) / __promote_preserving_unsigned(__y)); } template <typename _Tp> static constexpr inline _Tp _S_modulus(_Tp __x, _Tp __y) { return static_cast<_Tp>(__promote_preserving_unsigned(__x) % __promote_preserving_unsigned(__y)); } template <typename _Tp> static constexpr inline _Tp _S_bit_and(_Tp __x, _Tp __y) { if constexpr (is_floating_point_v<_Tp>) { using _Ip = __int_for_sizeof_t<_Tp>; return __bit_cast<_Tp>(__bit_cast<_Ip>(__x) & __bit_cast<_Ip>(__y)); } else return static_cast<_Tp>(__promote_preserving_unsigned(__x) & __promote_preserving_unsigned(__y)); } template <typename _Tp> static constexpr inline _Tp _S_bit_or(_Tp __x, _Tp __y) { if constexpr (is_floating_point_v<_Tp>) { using _Ip = __int_for_sizeof_t<_Tp>; return __bit_cast<_Tp>(__bit_cast<_Ip>(__x) | __bit_cast<_Ip>(__y)); } else return static_cast<_Tp>(__promote_preserving_unsigned(__x) | __promote_preserving_unsigned(__y)); } template <typename _Tp> static constexpr inline _Tp _S_bit_xor(_Tp __x, _Tp __y) { if constexpr (is_floating_point_v<_Tp>) { using _Ip = __int_for_sizeof_t<_Tp>; return __bit_cast<_Tp>(__bit_cast<_Ip>(__x) ^ __bit_cast<_Ip>(__y)); } else return static_cast<_Tp>(__promote_preserving_unsigned(__x) ^ __promote_preserving_unsigned(__y)); } template <typename _Tp> static constexpr inline _Tp _S_bit_shift_left(_Tp __x, int __y) { return static_cast<_Tp>(__promote_preserving_unsigned(__x) << __y); } template <typename _Tp> static constexpr inline _Tp _S_bit_shift_right(_Tp __x, int __y) { return static_cast<_Tp>(__promote_preserving_unsigned(__x) >> __y); } // math {{{2 // frexp, modf and copysign implemented in simd_math.h template <typename _Tp> using _ST = _SimdTuple<_Tp, simd_abi::scalar>; template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_acos(_Tp __x) { return std::acos(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_asin(_Tp __x) { return std::asin(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_atan(_Tp __x) { return std::atan(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_cos(_Tp __x) { return std::cos(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_sin(_Tp __x) { return std::sin(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_tan(_Tp __x) { return std::tan(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_acosh(_Tp __x) { return std::acosh(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_asinh(_Tp __x) { return std::asinh(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_atanh(_Tp __x) { return std::atanh(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_cosh(_Tp __x) { return std::cosh(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_sinh(_Tp __x) { return std::sinh(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_tanh(_Tp __x) { return std::tanh(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_atan2(_Tp __x, _Tp __y) { return std::atan2(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_exp(_Tp __x) { return std::exp(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_exp2(_Tp __x) { return std::exp2(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_expm1(_Tp __x) { return std::expm1(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_log(_Tp __x) { return std::log(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_log10(_Tp __x) { return std::log10(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_log1p(_Tp __x) { return std::log1p(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_log2(_Tp __x) { return std::log2(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_logb(_Tp __x) { return std::logb(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _ST<int> _S_ilogb(_Tp __x) { return {std::ilogb(__x)}; } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_pow(_Tp __x, _Tp __y) { return std::pow(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_abs(_Tp __x) { return std::abs(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_fabs(_Tp __x) { return std::fabs(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_sqrt(_Tp __x) { return std::sqrt(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_cbrt(_Tp __x) { return std::cbrt(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_erf(_Tp __x) { return std::erf(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_erfc(_Tp __x) { return std::erfc(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_lgamma(_Tp __x) { return std::lgamma(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_tgamma(_Tp __x) { return std::tgamma(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_trunc(_Tp __x) { return std::trunc(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_floor(_Tp __x) { return std::floor(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_ceil(_Tp __x) { return std::ceil(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_nearbyint(_Tp __x) { return std::nearbyint(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_rint(_Tp __x) { return std::rint(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _ST<long> _S_lrint(_Tp __x) { return {std::lrint(__x)}; } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _ST<long long> _S_llrint(_Tp __x) { return {std::llrint(__x)}; } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_round(_Tp __x) { return std::round(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _ST<long> _S_lround(_Tp __x) { return {std::lround(__x)}; } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _ST<long long> _S_llround(_Tp __x) { return {std::llround(__x)}; } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_ldexp(_Tp __x, _ST<int> __y) { return std::ldexp(__x, __y.first); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_scalbn(_Tp __x, _ST<int> __y) { return std::scalbn(__x, __y.first); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_scalbln(_Tp __x, _ST<long> __y) { return std::scalbln(__x, __y.first); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_fmod(_Tp __x, _Tp __y) { return std::fmod(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_remainder(_Tp __x, _Tp __y) { return std::remainder(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_nextafter(_Tp __x, _Tp __y) { return std::nextafter(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_fdim(_Tp __x, _Tp __y) { return std::fdim(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_fmax(_Tp __x, _Tp __y) { return std::fmax(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_fmin(_Tp __x, _Tp __y) { return std::fmin(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_fma(_Tp __x, _Tp __y, _Tp __z) { return std::fma(__x, __y, __z); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_remquo(_Tp __x, _Tp __y, _ST<int>* __z) { return std::remquo(__x, __y, &__z->first); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr _ST<int> _S_fpclassify(_Tp __x) { return {std::fpclassify(__x)}; } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_isfinite(_Tp __x) { return std::isfinite(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_isinf(_Tp __x) { return std::isinf(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_isnan(_Tp __x) { return std::isnan(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_isnormal(_Tp __x) { return std::isnormal(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_signbit(_Tp __x) { return std::signbit(__x); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_isgreater(_Tp __x, _Tp __y) { return std::isgreater(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_isgreaterequal(_Tp __x, _Tp __y) { return std::isgreaterequal(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_isless(_Tp __x, _Tp __y) { return std::isless(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_islessequal(_Tp __x, _Tp __y) { return std::islessequal(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_islessgreater(_Tp __x, _Tp __y) { return std::islessgreater(__x, __y); } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_isunordered(_Tp __x, _Tp __y) { return std::isunordered(__x, __y); } // _S_increment & _S_decrement{{{2 template <typename _Tp> static constexpr void _S_increment(_Tp& __x) { ++__x; } template <typename _Tp> static constexpr void _S_decrement(_Tp& __x) { --__x; } // compares {{{2 template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_equal_to(_Tp __x, _Tp __y) { return __x == __y; } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_not_equal_to(_Tp __x, _Tp __y) { return __x != __y; } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_less(_Tp __x, _Tp __y) { return __x < __y; } template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_less_equal(_Tp __x, _Tp __y) { return __x <= __y; } // smart_reference access {{{2 template <typename _Tp, typename _Up> static constexpr void _S_set(_Tp& __v, [[maybe_unused]] int __i, _Up&& __x) noexcept { _GLIBCXX_DEBUG_ASSERT(__i == 0); __v = static_cast<_Up&&>(__x); } // _S_masked_assign {{{2 template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr void _S_masked_assign(bool __k, _Tp& __lhs, _Tp __rhs) { if (__k) __lhs = __rhs; } // _S_masked_cassign {{{2 template <typename _Op, typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr void _S_masked_cassign(const bool __k, _Tp& __lhs, const _Tp __rhs, _Op __op) { if (__k) __lhs = __op(_SimdImplScalar{}, __lhs, __rhs); } // _S_masked_unary {{{2 template <template <typename> class _Op, typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr _Tp _S_masked_unary(const bool __k, const _Tp __v) { return static_cast<_Tp>(__k ? _Op<_Tp>{}(__v) : __v); } // }}}2 }; // }}} // _MaskImplScalar {{{ struct _MaskImplScalar { // member types {{{ template <typename _Tp> using _TypeTag = _Tp*; // }}} // _S_broadcast {{{ template <typename> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_broadcast(bool __x) { return __x; } // }}} // _S_load {{{ template <typename> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_load(const bool* __mem) { return __mem[0]; } // }}} // _S_to_bits {{{ _GLIBCXX_SIMD_INTRINSIC static constexpr _SanitizedBitMask<1> _S_to_bits(bool __x) { return __x; } // }}} // _S_convert {{{ template <typename, bool _Sanitized> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_convert(_BitMask<1, _Sanitized> __x) { return __x[0]; } template <typename, typename _Up, typename _UAbi> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_convert(simd_mask<_Up, _UAbi> __x) { return __x[0]; } // }}} // _S_from_bitmask {{{2 template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_from_bitmask(_SanitizedBitMask<1> __bits, _TypeTag<_Tp>) noexcept { return __bits[0]; } // _S_masked_load {{{2 _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_masked_load(bool __merge, bool __mask, const bool* __mem) noexcept { if (__mask) __merge = __mem[0]; return __merge; } // _S_store {{{2 _GLIBCXX_SIMD_INTRINSIC static constexpr void _S_store(bool __v, bool* __mem) noexcept { __mem[0] = __v; } // _S_masked_store {{{2 _GLIBCXX_SIMD_INTRINSIC static constexpr void _S_masked_store(const bool __v, bool* __mem, const bool __k) noexcept { if (__k) __mem[0] = __v; } // logical and bitwise operators {{{2 static constexpr bool _S_logical_and(bool __x, bool __y) { return __x && __y; } static constexpr bool _S_logical_or(bool __x, bool __y) { return __x || __y; } static constexpr bool _S_bit_not(bool __x) { return !__x; } static constexpr bool _S_bit_and(bool __x, bool __y) { return __x && __y; } static constexpr bool _S_bit_or(bool __x, bool __y) { return __x || __y; } static constexpr bool _S_bit_xor(bool __x, bool __y) { return __x != __y; } // smart_reference access {{{2 static constexpr void _S_set(bool& __k, [[maybe_unused]] int __i, bool __x) noexcept { _GLIBCXX_DEBUG_ASSERT(__i == 0); __k = __x; } // _S_masked_assign {{{2 _GLIBCXX_SIMD_INTRINSIC static constexpr void _S_masked_assign(bool __k, bool& __lhs, bool __rhs) { if (__k) __lhs = __rhs; } // }}}2 // _S_all_of {{{ template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_all_of(simd_mask<_Tp, _Abi> __k) { return __k._M_data; } // }}} // _S_any_of {{{ template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_any_of(simd_mask<_Tp, _Abi> __k) { return __k._M_data; } // }}} // _S_none_of {{{ template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_none_of(simd_mask<_Tp, _Abi> __k) { return !__k._M_data; } // }}} // _S_some_of {{{ template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_INTRINSIC static constexpr bool _S_some_of(simd_mask<_Tp, _Abi>) { return false; } // }}} // _S_popcount {{{ template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_INTRINSIC static constexpr int _S_popcount(simd_mask<_Tp, _Abi> __k) { return __k._M_data; } // }}} // _S_find_first_set {{{ template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_INTRINSIC static constexpr int _S_find_first_set(simd_mask<_Tp, _Abi>) { return 0; } // }}} // _S_find_last_set {{{ template <typename _Tp, typename _Abi> _GLIBCXX_SIMD_INTRINSIC static constexpr int _S_find_last_set(simd_mask<_Tp, _Abi>) { return 0; } // }}} }; // }}} _GLIBCXX_SIMD_END_NAMESPACE #endif // __cplusplus >= 201703L #endif // _GLIBCXX_EXPERIMENTAL_SIMD_SCALAR_H_ // vim: foldmethod=marker sw=2 noet ts=8 sts=2 tw=80 // Simd NEON specific implementations -*- C++ -*- // Copyright (C) 2020-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. #ifndef _GLIBCXX_EXPERIMENTAL_SIMD_NEON_H_ #define _GLIBCXX_EXPERIMENTAL_SIMD_NEON_H_ #if __cplusplus >= 201703L #if !_GLIBCXX_SIMD_HAVE_NEON #error "simd_neon.h may only be included when NEON on ARM is available" #endif _GLIBCXX_SIMD_BEGIN_NAMESPACE // _CommonImplNeon {{{ struct _CommonImplNeon : _CommonImplBuiltin { // _S_store {{{ using _CommonImplBuiltin::_S_store; // }}} }; // }}} // _SimdImplNeon {{{ template <typename _Abi> struct _SimdImplNeon : _SimdImplBuiltin<_Abi> { using _Base = _SimdImplBuiltin<_Abi>; template <typename _Tp> using _MaskMember = typename _Base::template _MaskMember<_Tp>; template <typename _Tp> static constexpr size_t _S_max_store_size = 16; // _S_masked_load {{{ template <typename _Tp, size_t _Np, typename _Up> static inline _SimdWrapper<_Tp, _Np> _S_masked_load(_SimdWrapper<_Tp, _Np> __merge, _MaskMember<_Tp> __k, const _Up* __mem) noexcept { __execute_n_times<_Np>([&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { if (__k[__i] != 0) __merge._M_set(__i, static_cast<_Tp>(__mem[__i])); }); return __merge; } // }}} // _S_masked_store_nocvt {{{ template <typename _Tp, size_t _Np> _GLIBCXX_SIMD_INTRINSIC static void _S_masked_store_nocvt(_SimdWrapper<_Tp, _Np> __v, _Tp* __mem, _MaskMember<_Tp> __k) { __execute_n_times<_Np>([&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { if (__k[__i] != 0) __mem[__i] = __v[__i]; }); } // }}} // _S_reduce {{{ template <typename _Tp, typename _BinaryOperation> _GLIBCXX_SIMD_INTRINSIC static constexpr _Tp _S_reduce(simd<_Tp, _Abi> __x, _BinaryOperation&& __binary_op) { if (not __builtin_is_constant_evaluated()) { constexpr size_t _Np = __x.size(); if constexpr (sizeof(__x) == 16 && _Np >= 4 && !_Abi::template _S_is_partial<_Tp>) { const auto __halves = split<simd<_Tp, simd_abi::_Neon<8>>>(__x); const auto __y = __binary_op(__halves[0], __halves[1]); return _SimdImplNeon<simd_abi::_Neon<8>>::_S_reduce( __y, static_cast<_BinaryOperation&&>(__binary_op)); } else if constexpr (_Np == 8) { __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( __vector_permute<1, 0, 3, 2, 5, 4, 7, 6>(__x._M_data))); __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( __vector_permute<3, 2, 1, 0, 7, 6, 5, 4>(__x._M_data))); __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( __vector_permute<7, 6, 5, 4, 3, 2, 1, 0>(__x._M_data))); return __x[0]; } else if constexpr (_Np == 4) { __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( __vector_permute<1, 0, 3, 2>(__x._M_data))); __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( __vector_permute<3, 2, 1, 0>(__x._M_data))); return __x[0]; } else if constexpr (_Np == 2) { __x = __binary_op(__x, _Base::template _M_make_simd<_Tp, _Np>( __vector_permute<1, 0>(__x._M_data))); return __x[0]; } } return _Base::_S_reduce(__x, static_cast<_BinaryOperation&&>(__binary_op)); } // }}} // math {{{ // _S_sqrt {{{ template <typename _Tp, typename _TVT = _VectorTraits<_Tp>> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_sqrt(_Tp __x) { if constexpr (__have_neon_a64) { const auto __intrin = __to_intrin(__x); if constexpr (_TVT::template _S_is<float, 2>) return vsqrt_f32(__intrin); else if constexpr (_TVT::template _S_is<float, 4>) return vsqrtq_f32(__intrin); else if constexpr (_TVT::template _S_is<double, 1>) return vsqrt_f64(__intrin); else if constexpr (_TVT::template _S_is<double, 2>) return vsqrtq_f64(__intrin); else __assert_unreachable<_Tp>(); } else return _Base::_S_sqrt(__x); } // }}} // _S_trunc {{{ template <typename _TW, typename _TVT = _VectorTraits<_TW>> _GLIBCXX_SIMD_INTRINSIC static _TW _S_trunc(_TW __x) { using _Tp = typename _TVT::value_type; if constexpr (__have_neon_a32) { const auto __intrin = __to_intrin(__x); if constexpr (_TVT::template _S_is<float, 2>) return vrnd_f32(__intrin); else if constexpr (_TVT::template _S_is<float, 4>) return vrndq_f32(__intrin); else if constexpr (_TVT::template _S_is<double, 1>) return vrnd_f64(__intrin); else if constexpr (_TVT::template _S_is<double, 2>) return vrndq_f64(__intrin); else __assert_unreachable<_Tp>(); } else if constexpr (is_same_v<_Tp, float>) { auto __intrin = __to_intrin(__x); if constexpr (sizeof(__x) == 16) __intrin = vcvtq_f32_s32(vcvtq_s32_f32(__intrin)); else __intrin = vcvt_f32_s32(vcvt_s32_f32(__intrin)); return _Base::_S_abs(__x)._M_data < 0x1p23f ? __vector_bitcast<float>(__intrin) : __x._M_data; } else return _Base::_S_trunc(__x); } // }}} // _S_round {{{ template <typename _Tp, size_t _Np> _GLIBCXX_SIMD_INTRINSIC static _SimdWrapper<_Tp, _Np> _S_round(_SimdWrapper<_Tp, _Np> __x) { if constexpr (__have_neon_a32) { const auto __intrin = __to_intrin(__x); if constexpr (sizeof(_Tp) == 4 && sizeof(__x) == 8) return vrnda_f32(__intrin); else if constexpr (sizeof(_Tp) == 4 && sizeof(__x) == 16) return vrndaq_f32(__intrin); else if constexpr (sizeof(_Tp) == 8 && sizeof(__x) == 8) return vrnda_f64(__intrin); else if constexpr (sizeof(_Tp) == 8 && sizeof(__x) == 16) return vrndaq_f64(__intrin); else __assert_unreachable<_Tp>(); } else return _Base::_S_round(__x); } // }}} // _S_floor {{{ template <typename _Tp, typename _TVT = _VectorTraits<_Tp>> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_floor(_Tp __x) { if constexpr (__have_neon_a32) { const auto __intrin = __to_intrin(__x); if constexpr (_TVT::template _S_is<float, 2>) return vrndm_f32(__intrin); else if constexpr (_TVT::template _S_is<float, 4>) return vrndmq_f32(__intrin); else if constexpr (_TVT::template _S_is<double, 1>) return vrndm_f64(__intrin); else if constexpr (_TVT::template _S_is<double, 2>) return vrndmq_f64(__intrin); else __assert_unreachable<_Tp>(); } else return _Base::_S_floor(__x); } // }}} // _S_ceil {{{ template <typename _Tp, typename _TVT = _VectorTraits<_Tp>> _GLIBCXX_SIMD_INTRINSIC static _Tp _S_ceil(_Tp __x) { if constexpr (__have_neon_a32) { const auto __intrin = __to_intrin(__x); if constexpr (_TVT::template _S_is<float, 2>) return vrndp_f32(__intrin); else if constexpr (_TVT::template _S_is<float, 4>) return vrndpq_f32(__intrin); else if constexpr (_TVT::template _S_is<double, 1>) return vrndp_f64(__intrin); else if constexpr (_TVT::template _S_is<double, 2>) return vrndpq_f64(__intrin); else __assert_unreachable<_Tp>(); } else return _Base::_S_ceil(__x); } //}}} }}} }; // }}} // _MaskImplNeonMixin {{{ struct _MaskImplNeonMixin { using _Base = _MaskImplBuiltinMixin; template <typename _Tp, size_t _Np> _GLIBCXX_SIMD_INTRINSIC static constexpr _SanitizedBitMask<_Np> _S_to_bits(_SimdWrapper<_Tp, _Np> __x) { if (__builtin_is_constant_evaluated()) return _Base::_S_to_bits(__x); using _I = __int_for_sizeof_t<_Tp>; if constexpr (sizeof(__x) == 16) { auto __asint = __vector_bitcast<_I>(__x); #ifdef __aarch64__ [[maybe_unused]] constexpr auto __zero = decltype(__asint)(); #else [[maybe_unused]] constexpr auto __zero = decltype(__lo64(__asint))(); #endif if constexpr (sizeof(_Tp) == 1) { constexpr auto __bitsel = __generate_from_n_evaluations<16, __vector_type_t<_I, 16>>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return static_cast<_I>( __i < _Np ? (__i < 8 ? 1 << __i : 1 << (__i - 8)) : 0); }); __asint &= __bitsel; #ifdef __aarch64__ return __vector_bitcast<_UShort>( vpaddq_s8(vpaddq_s8(vpaddq_s8(__asint, __zero), __zero), __zero))[0]; #else return __vector_bitcast<_UShort>( vpadd_s8(vpadd_s8(vpadd_s8(__lo64(__asint), __hi64(__asint)), __zero), __zero))[0]; #endif } else if constexpr (sizeof(_Tp) == 2) { constexpr auto __bitsel = __generate_from_n_evaluations<8, __vector_type_t<_I, 8>>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return static_cast<_I>(__i < _Np ? 1 << __i : 0); }); __asint &= __bitsel; #ifdef __aarch64__ return vaddvq_s16(__asint); #else return vpadd_s16( vpadd_s16(vpadd_s16(__lo64(__asint), __hi64(__asint)), __zero), __zero)[0]; #endif } else if constexpr (sizeof(_Tp) == 4) { constexpr auto __bitsel = __generate_from_n_evaluations<4, __vector_type_t<_I, 4>>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return static_cast<_I>(__i < _Np ? 1 << __i : 0); }); __asint &= __bitsel; #ifdef __aarch64__ return vaddvq_s32(__asint); #else return vpadd_s32(vpadd_s32(__lo64(__asint), __hi64(__asint)), __zero)[0]; #endif } else if constexpr (sizeof(_Tp) == 8) return (__asint[0] & 1) | (__asint[1] & 2); else __assert_unreachable<_Tp>(); } else if constexpr (sizeof(__x) == 8) { auto __asint = __vector_bitcast<_I>(__x); [[maybe_unused]] constexpr auto __zero = decltype(__asint)(); if constexpr (sizeof(_Tp) == 1) { constexpr auto __bitsel = __generate_from_n_evaluations<8, __vector_type_t<_I, 8>>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return static_cast<_I>(__i < _Np ? 1 << __i : 0); }); __asint &= __bitsel; #ifdef __aarch64__ return vaddv_s8(__asint); #else return vpadd_s8(vpadd_s8(vpadd_s8(__asint, __zero), __zero), __zero)[0]; #endif } else if constexpr (sizeof(_Tp) == 2) { constexpr auto __bitsel = __generate_from_n_evaluations<4, __vector_type_t<_I, 4>>( [&](auto __i) _GLIBCXX_SIMD_ALWAYS_INLINE_LAMBDA { return static_cast<_I>(__i < _Np ? 1 << __i : 0); }); __asint &= __bitsel; #ifdef __aarch64__ return vaddv_s16(__asint); #else return vpadd_s16(vpadd_s16(__asint, __zero), __zero)[0]; #endif } else if constexpr (sizeof(_Tp) == 4) { __asint &= __make_vector<_I>(0x1, 0x2); #ifdef __aarch64__ return vaddv_s32(__asint); #else return vpadd_s32(__asint, __zero)[0]; #endif } else __assert_unreachable<_Tp>(); } else return _Base::_S_to_bits(__x); } }; // }}} // _MaskImplNeon {{{ template <typename _Abi> struct _MaskImplNeon : _MaskImplNeonMixin, _MaskImplBuiltin<_Abi> { using _MaskImplBuiltinMixin::_S_to_maskvector; using _MaskImplNeonMixin::_S_to_bits; using _Base = _MaskImplBuiltin<_Abi>; using _Base::_S_convert; // _S_all_of {{{ template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static bool _S_all_of(simd_mask<_Tp, _Abi> __k) { const auto __kk = __vector_bitcast<char>(__k._M_data) | ~__vector_bitcast<char>(_Abi::template _S_implicit_mask<_Tp>()); if constexpr (sizeof(__k) == 16) { const auto __x = __vector_bitcast<long long>(__kk); return __x[0] + __x[1] == -2; } else if constexpr (sizeof(__k) <= 8) return __bit_cast<__int_for_sizeof_t<decltype(__kk)>>(__kk) == -1; else __assert_unreachable<_Tp>(); } // }}} // _S_any_of {{{ template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static bool _S_any_of(simd_mask<_Tp, _Abi> __k) { const auto __kk = __vector_bitcast<char>(__k._M_data) | ~__vector_bitcast<char>(_Abi::template _S_implicit_mask<_Tp>()); if constexpr (sizeof(__k) == 16) { const auto __x = __vector_bitcast<long long>(__kk); return (__x[0] | __x[1]) != 0; } else if constexpr (sizeof(__k) <= 8) return __bit_cast<__int_for_sizeof_t<decltype(__kk)>>(__kk) != 0; else __assert_unreachable<_Tp>(); } // }}} // _S_none_of {{{ template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static bool _S_none_of(simd_mask<_Tp, _Abi> __k) { const auto __kk = _Abi::_S_masked(__k._M_data); if constexpr (sizeof(__k) == 16) { const auto __x = __vector_bitcast<long long>(__kk); return (__x[0] | __x[1]) == 0; } else if constexpr (sizeof(__k) <= 8) return __bit_cast<__int_for_sizeof_t<decltype(__kk)>>(__kk) == 0; else __assert_unreachable<_Tp>(); } // }}} // _S_some_of {{{ template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static bool _S_some_of(simd_mask<_Tp, _Abi> __k) { if constexpr (sizeof(__k) <= 8) { const auto __kk = __vector_bitcast<char>(__k._M_data) | ~__vector_bitcast<char>( _Abi::template _S_implicit_mask<_Tp>()); using _Up = make_unsigned_t<__int_for_sizeof_t<decltype(__kk)>>; return __bit_cast<_Up>(__kk) + 1 > 1; } else return _Base::_S_some_of(__k); } // }}} // _S_popcount {{{ template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static int _S_popcount(simd_mask<_Tp, _Abi> __k) { if constexpr (sizeof(_Tp) == 1) { const auto __s8 = __vector_bitcast<_SChar>(__k._M_data); int8x8_t __tmp = __lo64(__s8) + __hi64z(__s8); return -vpadd_s8(vpadd_s8(vpadd_s8(__tmp, int8x8_t()), int8x8_t()), int8x8_t())[0]; } else if constexpr (sizeof(_Tp) == 2) { const auto __s16 = __vector_bitcast<short>(__k._M_data); int16x4_t __tmp = __lo64(__s16) + __hi64z(__s16); return -vpadd_s16(vpadd_s16(__tmp, int16x4_t()), int16x4_t())[0]; } else if constexpr (sizeof(_Tp) == 4) { const auto __s32 = __vector_bitcast<int>(__k._M_data); int32x2_t __tmp = __lo64(__s32) + __hi64z(__s32); return -vpadd_s32(__tmp, int32x2_t())[0]; } else if constexpr (sizeof(_Tp) == 8) { static_assert(sizeof(__k) == 16); const auto __s64 = __vector_bitcast<long>(__k._M_data); return -(__s64[0] + __s64[1]); } } // }}} // _S_find_first_set {{{ template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static int _S_find_first_set(simd_mask<_Tp, _Abi> __k) { // TODO: the _Base implementation is not optimal for NEON return _Base::_S_find_first_set(__k); } // }}} // _S_find_last_set {{{ template <typename _Tp> _GLIBCXX_SIMD_INTRINSIC static int _S_find_last_set(simd_mask<_Tp, _Abi> __k) { // TODO: the _Base implementation is not optimal for NEON return _Base::_S_find_last_set(__k); } // }}} }; // }}} _GLIBCXX_SIMD_END_NAMESPACE #endif // __cplusplus >= 201703L #endif // _GLIBCXX_EXPERIMENTAL_SIMD_NEON_H_ // vim: foldmethod=marker sw=2 noet ts=8 sts=2 tw=80 // Filesystem declarations -*- C++ -*- // Copyright (C) 2014-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file experimental/bits/fs_fwd.h * This is an internal header file, included by other library headers. * Do not attempt to use it directly. @headername{experimental/filesystem} */ #ifndef _GLIBCXX_EXPERIMENTAL_FS_FWD_H #define _GLIBCXX_EXPERIMENTAL_FS_FWD_H 1 #if __cplusplus < 201103L # include <bits/c++0x_warning.h> #else #include <system_error> #include <cstdint> #include <chrono> namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace experimental { namespace filesystem { inline namespace v1 { #if _GLIBCXX_USE_CXX11_ABI inline namespace __cxx11 __attribute__((__abi_tag__ ("cxx11"))) { } #endif /** * @defgroup filesystem-ts Filesystem TS * @ingroup experimental * * Utilities for performing operations on file systems and their components, * such as paths, regular files, and directories. * * ISO/IEC TS 18822:2015 C++ File System Technical Specification * * @since C++11 * * @remark Link using `-lstdc++fs` to use these types and functions. * * @{ */ class file_status; _GLIBCXX_BEGIN_NAMESPACE_CXX11 class path; class filesystem_error; class directory_entry; class directory_iterator; class recursive_directory_iterator; _GLIBCXX_END_NAMESPACE_CXX11 /// Information about free space on a disk struct space_info { uintmax_t capacity; uintmax_t free; uintmax_t available; }; /// Enumerated type representing the type of a file enum class file_type : signed char { none = 0, not_found = -1, regular = 1, directory = 2, symlink = 3, block = 4, character = 5, fifo = 6, socket = 7, unknown = 8 }; /// Bitmask type controlling effects of `filesystem::copy` enum class copy_options : unsigned short { none = 0, skip_existing = 1, overwrite_existing = 2, update_existing = 4, recursive = 8, copy_symlinks = 16, skip_symlinks = 32, directories_only = 64, create_symlinks = 128, create_hard_links = 256 }; /// @{ /// @relates copy_options constexpr copy_options operator&(copy_options __x, copy_options __y) noexcept { using __utype = typename std::underlying_type<copy_options>::type; return static_cast<copy_options>( static_cast<__utype>(__x) & static_cast<__utype>(__y)); } constexpr copy_options operator|(copy_options __x, copy_options __y) noexcept { using __utype = typename std::underlying_type<copy_options>::type; return static_cast<copy_options>( static_cast<__utype>(__x) | static_cast<__utype>(__y)); } constexpr copy_options operator^(copy_options __x, copy_options __y) noexcept { using __utype = typename std::underlying_type<copy_options>::type; return static_cast<copy_options>( static_cast<__utype>(__x) ^ static_cast<__utype>(__y)); } constexpr copy_options operator~(copy_options __x) noexcept { using __utype = typename std::underlying_type<copy_options>::type; return static_cast<copy_options>(~static_cast<__utype>(__x)); } inline copy_options& operator&=(copy_options& __x, copy_options __y) noexcept { return __x = __x & __y; } inline copy_options& operator|=(copy_options& __x, copy_options __y) noexcept { return __x = __x | __y; } inline copy_options& operator^=(copy_options& __x, copy_options __y) noexcept { return __x = __x ^ __y; } /// @} /// Bitmask type representing file access permissions enum class perms : unsigned { none = 0, owner_read = 0400, owner_write = 0200, owner_exec = 0100, owner_all = 0700, group_read = 040, group_write = 020, group_exec = 010, group_all = 070, others_read = 04, others_write = 02, others_exec = 01, others_all = 07, all = 0777, set_uid = 04000, set_gid = 02000, sticky_bit = 01000, mask = 07777, unknown = 0xFFFF, add_perms = 0x10000, remove_perms = 0x20000, symlink_nofollow = 0x40000 }; /// @{ /// @relates std::experimental::filesystem::perms constexpr perms operator&(perms __x, perms __y) noexcept { using __utype = typename std::underlying_type<perms>::type; return static_cast<perms>( static_cast<__utype>(__x) & static_cast<__utype>(__y)); } constexpr perms operator|(perms __x, perms __y) noexcept { using __utype = typename std::underlying_type<perms>::type; return static_cast<perms>( static_cast<__utype>(__x) | static_cast<__utype>(__y)); } constexpr perms operator^(perms __x, perms __y) noexcept { using __utype = typename std::underlying_type<perms>::type; return static_cast<perms>( static_cast<__utype>(__x) ^ static_cast<__utype>(__y)); } constexpr perms operator~(perms __x) noexcept { using __utype = typename std::underlying_type<perms>::type; return static_cast<perms>(~static_cast<__utype>(__x)); } inline perms& operator&=(perms& __x, perms __y) noexcept { return __x = __x & __y; } inline perms& operator|=(perms& __x, perms __y) noexcept { return __x = __x | __y; } inline perms& operator^=(perms& __x, perms __y) noexcept { return __x = __x ^ __y; } /// @} /// Bitmask type controlling directory iteration enum class directory_options : unsigned char { none = 0, follow_directory_symlink = 1, skip_permission_denied = 2 }; /// @{ /// @relates directory_options constexpr directory_options operator&(directory_options __x, directory_options __y) noexcept { using __utype = typename std::underlying_type<directory_options>::type; return static_cast<directory_options>( static_cast<__utype>(__x) & static_cast<__utype>(__y)); } constexpr directory_options operator|(directory_options __x, directory_options __y) noexcept { using __utype = typename std::underlying_type<directory_options>::type; return static_cast<directory_options>( static_cast<__utype>(__x) | static_cast<__utype>(__y)); } constexpr directory_options operator^(directory_options __x, directory_options __y) noexcept { using __utype = typename std::underlying_type<directory_options>::type; return static_cast<directory_options>( static_cast<__utype>(__x) ^ static_cast<__utype>(__y)); } constexpr directory_options operator~(directory_options __x) noexcept { using __utype = typename std::underlying_type<directory_options>::type; return static_cast<directory_options>(~static_cast<__utype>(__x)); } inline directory_options& operator&=(directory_options& __x, directory_options __y) noexcept { return __x = __x & __y; } inline directory_options& operator|=(directory_options& __x, directory_options __y) noexcept { return __x = __x | __y; } inline directory_options& operator^=(directory_options& __x, directory_options __y) noexcept { return __x = __x ^ __y; } /// @} /// The type used for file timestamps using file_time_type = std::chrono::system_clock::time_point; // operational functions void copy(const path& __from, const path& __to, copy_options __options); void copy(const path& __from, const path& __to, copy_options __options, error_code&) noexcept; bool copy_file(const path& __from, const path& __to, copy_options __option); bool copy_file(const path& __from, const path& __to, copy_options __option, error_code&); path current_path(); file_status status(const path&); file_status status(const path&, error_code&) noexcept; bool status_known(file_status) noexcept; file_status symlink_status(const path&); file_status symlink_status(const path&, error_code&) noexcept; bool is_regular_file(file_status) noexcept; bool is_symlink(file_status) noexcept; /// @} group filesystem-ts } // namespace v1 } // namespace filesystem } // namespace experimental _GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // C++11 #endif // _GLIBCXX_EXPERIMENTAL_FS_FWD_H // x86 specific conversion optimizations -*- C++ -*- // Copyright (C) 2020-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, 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 General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. #ifndef _GLIBCXX_EXPERIMENTAL_SIMD_X86_CONVERSIONS_H #define _GLIBCXX_EXPERIMENTAL_SIMD_X86_CONVERSIONS_H #if __cplusplus >= 201703L // work around PR85827 // 1-arg __convert_x86 {{{1 template <typename _To, typename _V, typename _Traits> _GLIBCXX_SIMD_INTRINSIC _To __convert_x86(_V __v) { static_assert(__is_vector_type_v<_V>); using _Tp = typename _Traits::value_type; constexpr size_t _Np = _Traits::_S_full_size; [[maybe_unused]] const auto __intrin = __to_intrin(__v); using _Up = typename _VectorTraits<_To>::value_type; constexpr size_t _M = _VectorTraits<_To>::_S_full_size; // [xyz]_to_[xyz] {{{2 [[maybe_unused]] constexpr bool __x_to_x = sizeof(__v) <= 16 && sizeof(_To) <= 16; [[maybe_unused]] constexpr bool __x_to_y = sizeof(__v) <= 16 && sizeof(_To) == 32; [[maybe_unused]] constexpr bool __x_to_z = sizeof(__v) <= 16 && sizeof(_To) == 64; [[maybe_unused]] constexpr bool __y_to_x = sizeof(__v) == 32 && sizeof(_To) <= 16; [[maybe_unused]] constexpr bool __y_to_y = sizeof(__v) == 32 && sizeof(_To) == 32; [[maybe_unused]] constexpr bool __y_to_z = sizeof(__v) == 32 && sizeof(_To) == 64; [[maybe_unused]] constexpr bool __z_to_x = sizeof(__v) == 64 && sizeof(_To) <= 16; [[maybe_unused]] constexpr bool __z_to_y = sizeof(__v) == 64 && sizeof(_To) == 32; [[maybe_unused]] constexpr bool __z_to_z = sizeof(__v) == 64 && sizeof(_To) == 64; // iX_to_iX {{{2 [[maybe_unused]] constexpr bool __i_to_i = is_integral_v<_Up> && is_integral_v<_Tp>; [[maybe_unused]] constexpr bool __i8_to_i16 = __i_to_i && sizeof(_Tp) == 1 && sizeof(_Up) == 2; [[maybe_unused]] constexpr bool __i8_to_i32 = __i_to_i && sizeof(_Tp) == 1 && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __i8_to_i64 = __i_to_i && sizeof(_Tp) == 1 && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __i16_to_i8 = __i_to_i && sizeof(_Tp) == 2 && sizeof(_Up) == 1; [[maybe_unused]] constexpr bool __i16_to_i32 = __i_to_i && sizeof(_Tp) == 2 && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __i16_to_i64 = __i_to_i && sizeof(_Tp) == 2 && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __i32_to_i8 = __i_to_i && sizeof(_Tp) == 4 && sizeof(_Up) == 1; [[maybe_unused]] constexpr bool __i32_to_i16 = __i_to_i && sizeof(_Tp) == 4 && sizeof(_Up) == 2; [[maybe_unused]] constexpr bool __i32_to_i64 = __i_to_i && sizeof(_Tp) == 4 && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __i64_to_i8 = __i_to_i && sizeof(_Tp) == 8 && sizeof(_Up) == 1; [[maybe_unused]] constexpr bool __i64_to_i16 = __i_to_i && sizeof(_Tp) == 8 && sizeof(_Up) == 2; [[maybe_unused]] constexpr bool __i64_to_i32 = __i_to_i && sizeof(_Tp) == 8 && sizeof(_Up) == 4; // [fsu]X_to_[fsu]X {{{2 // ibw = integral && byte or word, i.e. char and short with any signedness [[maybe_unused]] constexpr bool __s64_to_f32 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __s32_to_f32 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __s16_to_f32 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 2 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __s8_to_f32 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 1 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __u64_to_f32 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __u32_to_f32 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __u16_to_f32 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 2 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __u8_to_f32 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 1 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __s64_to_f64 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __s32_to_f64 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __u64_to_f64 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __u32_to_f64 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __f32_to_s64 = is_integral_v<_Up> && is_signed_v<_Up> && sizeof(_Up) == 8 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f32_to_s32 = is_integral_v<_Up> && is_signed_v<_Up> && sizeof(_Up) == 4 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f32_to_u64 = is_integral_v<_Up> && is_unsigned_v<_Up> && sizeof(_Up) == 8 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f32_to_u32 = is_integral_v<_Up> && is_unsigned_v<_Up> && sizeof(_Up) == 4 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f64_to_s64 = is_integral_v<_Up> && is_signed_v<_Up> && sizeof(_Up) == 8 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f64_to_s32 = is_integral_v<_Up> && is_signed_v<_Up> && sizeof(_Up) == 4 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f64_to_u64 = is_integral_v<_Up> && is_unsigned_v<_Up> && sizeof(_Up) == 8 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f64_to_u32 = is_integral_v<_Up> && is_unsigned_v<_Up> && sizeof(_Up) == 4 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __ibw_to_f32 = is_integral_v<_Tp> && sizeof(_Tp) <= 2 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __ibw_to_f64 = is_integral_v<_Tp> && sizeof(_Tp) <= 2 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __f32_to_ibw = is_integral_v<_Up> && sizeof(_Up) <= 2 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f64_to_ibw = is_integral_v<_Up> && sizeof(_Up) <= 2 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f32_to_f64 = is_floating_point_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __f64_to_f32 = is_floating_point_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 4; if constexpr (__i_to_i && __y_to_x && !__have_avx2) //{{{2 return __convert_x86<_To>(__lo128(__v), __hi128(__v)); else if constexpr (__i_to_i && __x_to_y && !__have_avx2) //{{{2 return __concat(__convert_x86<__vector_type_t<_Up, _M / 2>>(__v), __convert_x86<__vector_type_t<_Up, _M / 2>>( __extract_part<1, _Np / _M * 2>(__v))); else if constexpr (__i_to_i) //{{{2 { static_assert(__x_to_x || __have_avx2, "integral conversions with ymm registers require AVX2"); static_assert(__have_avx512bw || ((sizeof(_Tp) >= 4 || sizeof(__v) < 64) && (sizeof(_Up) >= 4 || sizeof(_To) < 64)), "8/16-bit integers in zmm registers require AVX512BW"); static_assert((sizeof(__v) < 64 && sizeof(_To) < 64) || __have_avx512f, "integral conversions with ymm registers require AVX2"); } if constexpr (is_floating_point_v<_Tp> == is_floating_point_v<_Up> && //{{{2 sizeof(_Tp) == sizeof(_Up)) { // conversion uses simple bit reinterpretation (or no conversion at all) if constexpr (_Np >= _M) return __intrin_bitcast<_To>(__v); else return __zero_extend(__vector_bitcast<_Up>(__v)); } else if constexpr (_Np < _M && sizeof(_To) > 16) //{{{2 // zero extend (eg. xmm -> ymm) return __zero_extend( __convert_x86<__vector_type_t< _Up, (16 / sizeof(_Up) > _Np) ? 16 / sizeof(_Up) : _Np>>(__v)); else if constexpr (_Np > _M && sizeof(__v) > 16) //{{{2 // partial input (eg. ymm -> xmm) return __convert_x86<_To>(__extract_part<0, _Np / _M>(__v)); else if constexpr (__i64_to_i32) //{{{2 { if constexpr (__x_to_x && __have_avx512vl) return __intrin_bitcast<_To>(_mm_cvtepi64_epi32(__intrin)); else if constexpr (__x_to_x) return __auto_bitcast( _mm_shuffle_ps(__vector_bitcast<float>(__v), __m128(), 8)); else if constexpr (__y_to_x && __have_avx512vl) return __intrin_bitcast<_To>(_mm256_cvtepi64_epi32(__intrin)); else if constexpr (__y_to_x && __have_avx512f) return __intrin_bitcast<_To>( __lo128(_mm512_cvtepi64_epi32(__auto_bitcast(__v)))); else if constexpr (__y_to_x) return __intrin_bitcast<_To>( __lo128(_mm256_permute4x64_epi64(_mm256_shuffle_epi32(__intrin, 8), 0 + 4 * 2))); else if constexpr (__z_to_y) return __intrin_bitcast<_To>(_mm512_cvtepi64_epi32(__intrin)); } else if constexpr (__i64_to_i16) //{{{2 { if constexpr (__x_to_x && __have_avx512vl) return __intrin_bitcast<_To>(_mm_cvtepi64_epi16(__intrin)); else if constexpr (__x_to_x && __have_avx512f) return __intrin_bitcast<_To>( __lo128(_mm512_cvtepi64_epi16(__auto_bitcast(__v)))); else if constexpr (__x_to_x && __have_ssse3) { return __intrin_bitcast<_To>( _mm_shuffle_epi8(__intrin, _mm_setr_epi8(0, 1, 8, 9, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80))); // fallback without SSSE3 } else if constexpr (__y_to_x && __have_avx512vl) return __intrin_bitcast<_To>(_mm256_cvtepi64_epi16(__intrin)); else if constexpr (__y_to_x && __have_avx512f) return __intrin_bitcast<_To>( __lo128(_mm512_cvtepi64_epi16(__auto_bitcast(__v)))); else if constexpr (__y_to_x) { const auto __a = _mm256_shuffle_epi8( __intrin, _mm256_setr_epi8(0, 1, 8, 9, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, 0, 1, 8, 9, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80)); return __intrin_bitcast<_To>(__lo128(__a) | __hi128(__a)); } else if constexpr (__z_to_x) return __intrin_bitcast<_To>(_mm512_cvtepi64_epi16(__intrin)); } else if constexpr (__i64_to_i8) //{{{2 { if constexpr (__x_to_x && __have_avx512vl) return __intrin_bitcast<_To>(_mm_cvtepi64_epi8(__intrin)); else if constexpr (__x_to_x && __have_avx512f) return __intrin_bitcast<_To>( __lo128(_mm512_cvtepi64_epi8(__zero_extend(__intrin)))); else if constexpr (__y_to_x && __have_avx512vl) return __intrin_bitcast<_To>(_mm256_cvtepi64_epi8(__intrin)); else if constexpr (__y_to_x && __have_avx512f) return __intrin_bitcast<_To>( _mm512_cvtepi64_epi8(__zero_extend(__intrin))); else if constexpr (__z_to_x) return __intrin_bitcast<_To>(_mm512_cvtepi64_epi8(__intrin)); } else if constexpr (__i32_to_i64) //{{{2 { if constexpr (__have_sse4_1 && __x_to_x) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm_cvtepi32_epi64(__intrin) : _mm_cvtepu32_epi64(__intrin)); else if constexpr (__x_to_x) { return __intrin_bitcast<_To>( _mm_unpacklo_epi32(__intrin, is_signed_v<_Tp> ? _mm_srai_epi32(__intrin, 31) : __m128i())); } else if constexpr (__x_to_y) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm256_cvtepi32_epi64(__intrin) : _mm256_cvtepu32_epi64(__intrin)); else if constexpr (__y_to_z) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm512_cvtepi32_epi64(__intrin) : _mm512_cvtepu32_epi64(__intrin)); } else if constexpr (__i32_to_i16) //{{{2 { if constexpr (__x_to_x && __have_avx512vl) return __intrin_bitcast<_To>(_mm_cvtepi32_epi16(__intrin)); else if constexpr (__x_to_x && __have_avx512f) return __intrin_bitcast<_To>( __lo128(_mm512_cvtepi32_epi16(__auto_bitcast(__v)))); else if constexpr (__x_to_x && __have_ssse3) return __intrin_bitcast<_To>(_mm_shuffle_epi8( __intrin, _mm_setr_epi8(0, 1, 4, 5, 8, 9, 12, 13, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80))); else if constexpr (__x_to_x) { auto __a = _mm_unpacklo_epi16(__intrin, __m128i()); // 0o.o 1o.o auto __b = _mm_unpackhi_epi16(__intrin, __m128i()); // 2o.o 3o.o auto __c = _mm_unpacklo_epi16(__a, __b); // 02oo ..oo auto __d = _mm_unpackhi_epi16(__a, __b); // 13oo ..oo return __intrin_bitcast<_To>( _mm_unpacklo_epi16(__c, __d)); // 0123 oooo } else if constexpr (__y_to_x && __have_avx512vl) return __intrin_bitcast<_To>(_mm256_cvtepi32_epi16(__intrin)); else if constexpr (__y_to_x && __have_avx512f) return __intrin_bitcast<_To>( __lo128(_mm512_cvtepi32_epi16(__auto_bitcast(__v)))); else if constexpr (__y_to_x) { auto __a = _mm256_shuffle_epi8( __intrin, _mm256_setr_epi8(0, 1, 4, 5, 8, 9, 12, 13, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, 0, 1, 4, 5, 8, 9, 12, 13, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80)); return __intrin_bitcast<_To>(__lo128( _mm256_permute4x64_epi64(__a, 0xf8))); // __a[0] __a[2] | __a[3] __a[3] } else if constexpr (__z_to_y) return __intrin_bitcast<_To>(_mm512_cvtepi32_epi16(__intrin)); } else if constexpr (__i32_to_i8) //{{{2 { if constexpr (__x_to_x && __have_avx512vl) return __intrin_bitcast<_To>(_mm_cvtepi32_epi8(__intrin)); else if constexpr (__x_to_x && __have_avx512f) return __intrin_bitcast<_To>( __lo128(_mm512_cvtepi32_epi8(__zero_extend(__intrin)))); else if constexpr (__x_to_x && __have_ssse3) { return __intrin_bitcast<_To>( _mm_shuffle_epi8(__intrin, _mm_setr_epi8(0, 4, 8, 12, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80))); } else if constexpr (__x_to_x) { const auto __a = _mm_unpacklo_epi8(__intrin, __intrin); // 0... .... 1... .... const auto __b = _mm_unpackhi_epi8(__intrin, __intrin); // 2... .... 3... .... const auto __c = _mm_unpacklo_epi8(__a, __b); // 02.. .... .... .... const auto __d = _mm_unpackhi_epi8(__a, __b); // 13.. .... .... .... const auto __e = _mm_unpacklo_epi8(__c, __d); // 0123 .... .... .... return __intrin_bitcast<_To>(__e & _mm_cvtsi32_si128(-1)); } else if constexpr (__y_to_x && __have_avx512vl) return __intrin_bitcast<_To>(_mm256_cvtepi32_epi8(__intrin)); else if constexpr (__y_to_x && __have_avx512f) return __intrin_bitcast<_To>( _mm512_cvtepi32_epi8(__zero_extend(__intrin))); else if constexpr (__z_to_x) return __intrin_bitcast<_To>(_mm512_cvtepi32_epi8(__intrin)); } else if constexpr (__i16_to_i64) //{{{2 { if constexpr (__x_to_x && __have_sse4_1) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm_cvtepi16_epi64(__intrin) : _mm_cvtepu16_epi64(__intrin)); else if constexpr (__x_to_x && is_signed_v<_Tp>) { auto __x = _mm_srai_epi16(__intrin, 15); auto __y = _mm_unpacklo_epi16(__intrin, __x); __x = _mm_unpacklo_epi16(__x, __x); return __intrin_bitcast<_To>(_mm_unpacklo_epi32(__y, __x)); } else if constexpr (__x_to_x) return __intrin_bitcast<_To>( _mm_unpacklo_epi32(_mm_unpacklo_epi16(__intrin, __m128i()), __m128i())); else if constexpr (__x_to_y) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm256_cvtepi16_epi64(__intrin) : _mm256_cvtepu16_epi64(__intrin)); else if constexpr (__x_to_z) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm512_cvtepi16_epi64(__intrin) : _mm512_cvtepu16_epi64(__intrin)); } else if constexpr (__i16_to_i32) //{{{2 { if constexpr (__x_to_x && __have_sse4_1) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm_cvtepi16_epi32(__intrin) : _mm_cvtepu16_epi32(__intrin)); else if constexpr (__x_to_x && is_signed_v<_Tp>) return __intrin_bitcast<_To>( _mm_srai_epi32(_mm_unpacklo_epi16(__intrin, __intrin), 16)); else if constexpr (__x_to_x && is_unsigned_v<_Tp>) return __intrin_bitcast<_To>(_mm_unpacklo_epi16(__intrin, __m128i())); else if constexpr (__x_to_y) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm256_cvtepi16_epi32(__intrin) : _mm256_cvtepu16_epi32(__intrin)); else if constexpr (__y_to_z) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm512_cvtepi16_epi32(__intrin) : _mm512_cvtepu16_epi32(__intrin)); } else if constexpr (__i16_to_i8) //{{{2 { if constexpr (__x_to_x && __have_avx512bw_vl) return __intrin_bitcast<_To>(_mm_cvtepi16_epi8(__intrin)); else if constexpr (__x_to_x && __have_avx512bw) return __intrin_bitcast<_To>( __lo128(_mm512_cvtepi16_epi8(__zero_extend(__intrin)))); else if constexpr (__x_to_x && __have_ssse3) return __intrin_bitcast<_To>(_mm_shuffle_epi8( __intrin, _mm_setr_epi8(0, 2, 4, 6, 8, 10, 12, 14, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80))); else if constexpr (__x_to_x) { auto __a = _mm_unpacklo_epi8(__intrin, __intrin); // 00.. 11.. 22.. 33.. auto __b = _mm_unpackhi_epi8(__intrin, __intrin); // 44.. 55.. 66.. 77.. auto __c = _mm_unpacklo_epi8(__a, __b); // 0404 .... 1515 .... auto __d = _mm_unpackhi_epi8(__a, __b); // 2626 .... 3737 .... auto __e = _mm_unpacklo_epi8(__c, __d); // 0246 0246 .... .... auto __f = _mm_unpackhi_epi8(__c, __d); // 1357 1357 .... .... return __intrin_bitcast<_To>(_mm_unpacklo_epi8(__e, __f)); } else if constexpr (__y_to_x && __have_avx512bw_vl) return __intrin_bitcast<_To>(_mm256_cvtepi16_epi8(__intrin)); else if constexpr (__y_to_x && __have_avx512bw) return __intrin_bitcast<_To>( __lo256(_mm512_cvtepi16_epi8(__zero_extend(__intrin)))); else if constexpr (__y_to_x) { auto __a = _mm256_shuffle_epi8( __intrin, _mm256_setr_epi8(0, 2, 4, 6, 8, 10, 12, 14, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, 0, 2, 4, 6, 8, 10, 12, 14)); return __intrin_bitcast<_To>(__lo128(__a) | __hi128(__a)); } else if constexpr (__z_to_y && __have_avx512bw) return __intrin_bitcast<_To>(_mm512_cvtepi16_epi8(__intrin)); else if constexpr (__z_to_y) __assert_unreachable<_Tp>(); } else if constexpr (__i8_to_i64) //{{{2 { if constexpr (__x_to_x && __have_sse4_1) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm_cvtepi8_epi64(__intrin) : _mm_cvtepu8_epi64(__intrin)); else if constexpr (__x_to_x && is_signed_v<_Tp>) { if constexpr (__have_ssse3) { auto __dup = _mm_unpacklo_epi8(__intrin, __intrin); auto __epi16 = _mm_srai_epi16(__dup, 8); _mm_shuffle_epi8(__epi16, _mm_setr_epi8(0, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3)); } else { auto __x = _mm_unpacklo_epi8(__intrin, __intrin); __x = _mm_unpacklo_epi16(__x, __x); return __intrin_bitcast<_To>( _mm_unpacklo_epi32(_mm_srai_epi32(__x, 24), _mm_srai_epi32(__x, 31))); } } else if constexpr (__x_to_x) { return __intrin_bitcast<_To>(_mm_unpacklo_epi32( _mm_unpacklo_epi16(_mm_unpacklo_epi8(__intrin, __m128i()), __m128i()), __m128i())); } else if constexpr (__x_to_y) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm256_cvtepi8_epi64(__intrin) : _mm256_cvtepu8_epi64(__intrin)); else if constexpr (__x_to_z) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm512_cvtepi8_epi64(__intrin) : _mm512_cvtepu8_epi64(__intrin)); } else if constexpr (__i8_to_i32) //{{{2 { if constexpr (__x_to_x && __have_sse4_1) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm_cvtepi8_epi32(__intrin) : _mm_cvtepu8_epi32(__intrin)); else if constexpr (__x_to_x && is_signed_v<_Tp>) { const auto __x = _mm_unpacklo_epi8(__intrin, __intrin); return __intrin_bitcast<_To>( _mm_srai_epi32(_mm_unpacklo_epi16(__x, __x), 24)); } else if constexpr (__x_to_x && is_unsigned_v<_Tp>) return __intrin_bitcast<_To>( _mm_unpacklo_epi16(_mm_unpacklo_epi8(__intrin, __m128i()), __m128i())); else if constexpr (__x_to_y) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm256_cvtepi8_epi32(__intrin) : _mm256_cvtepu8_epi32(__intrin)); else if constexpr (__x_to_z) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm512_cvtepi8_epi32(__intrin) : _mm512_cvtepu8_epi32(__intrin)); } else if constexpr (__i8_to_i16) //{{{2 { if constexpr (__x_to_x && __have_sse4_1) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm_cvtepi8_epi16(__intrin) : _mm_cvtepu8_epi16(__intrin)); else if constexpr (__x_to_x && is_signed_v<_Tp>) return __intrin_bitcast<_To>( _mm_srai_epi16(_mm_unpacklo_epi8(__intrin, __intrin), 8)); else if constexpr (__x_to_x && is_unsigned_v<_Tp>) return __intrin_bitcast<_To>(_mm_unpacklo_epi8(__intrin, __m128i())); else if constexpr (__x_to_y) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm256_cvtepi8_epi16(__intrin) : _mm256_cvtepu8_epi16(__intrin)); else if constexpr (__y_to_z && __have_avx512bw) return __intrin_bitcast<_To>(is_signed_v<_Tp> ? _mm512_cvtepi8_epi16(__intrin) : _mm512_cvtepu8_epi16(__intrin)); else if constexpr (__y_to_z) __assert_unreachable<_Tp>(); } else if constexpr (__f32_to_s64) //{{{2 { if constexpr (__have_avx512dq_vl && __x_to_x) return __intrin_bitcast<_To>(_mm_cvttps_epi64(__intrin)); else if constexpr (__have_avx512dq_vl && __x_to_y) return __intrin_bitcast<_To>(_mm256_cvttps_epi64(__intrin)); else if constexpr (__have_avx512dq && __y_to_z) return __intrin_bitcast<_To>(_mm512_cvttps_epi64(__intrin)); // else use scalar fallback } else if constexpr (__f32_to_u64) //{{{2 { if constexpr (__have_avx512dq_vl && __x_to_x) return __intrin_bitcast<_To>(_mm_cvttps_epu64(__intrin)); else if constexpr (__have_avx512dq_vl && __x_to_y) return __intrin_bitcast<_To>(_mm256_cvttps_epu64(__intrin)); else if constexpr (__have_avx512dq && __y_to_z) return __intrin_bitcast<_To>(_mm512_cvttps_epu64(__intrin)); // else use scalar fallback } else if constexpr (__f32_to_s32) //{{{2 { if constexpr (__x_to_x || __y_to_y || __z_to_z) { // go to fallback, it does the right thing } else __assert_unreachable<_Tp>(); } else if constexpr (__f32_to_u32) //{{{2 { if constexpr (__have_avx512vl && __x_to_x) return __auto_bitcast(_mm_cvttps_epu32(__intrin)); else if constexpr (__have_avx512f && __x_to_x) return __auto_bitcast( __lo128(_mm512_cvttps_epu32(__auto_bitcast(__v)))); else if constexpr (__have_avx512vl && __y_to_y) return __vector_bitcast<_Up>(_mm256_cvttps_epu32(__intrin)); else if constexpr (__have_avx512f && __y_to_y) return __vector_bitcast<_Up>( __lo256(_mm512_cvttps_epu32(__auto_bitcast(__v)))); else if constexpr (__x_to_x || __y_to_y || __z_to_z) { // go to fallback, it does the right thing. We can't use the // _mm_floor_ps - 0x8000'0000 trick for f32->u32 because it would // discard small input values (only 24 mantissa bits) } else __assert_unreachable<_Tp>(); } else if constexpr (__f32_to_ibw) //{{{2 return __convert_x86<_To>(__convert_x86<__vector_type_t<int, _Np>>(__v)); else if constexpr (__f64_to_s64) //{{{2 { if constexpr (__have_avx512dq_vl && __x_to_x) return __intrin_bitcast<_To>(_mm_cvttpd_epi64(__intrin)); else if constexpr (__have_avx512dq_vl && __y_to_y) return __intrin_bitcast<_To>(_mm256_cvttpd_epi64(__intrin)); else if constexpr (__have_avx512dq && __z_to_z) return __intrin_bitcast<_To>(_mm512_cvttpd_epi64(__intrin)); // else use scalar fallback } else if constexpr (__f64_to_u64) //{{{2 { if constexpr (__have_avx512dq_vl && __x_to_x) return __intrin_bitcast<_To>(_mm_cvttpd_epu64(__intrin)); else if constexpr (__have_avx512dq_vl && __y_to_y) return __intrin_bitcast<_To>(_mm256_cvttpd_epu64(__intrin)); else if constexpr (__have_avx512dq && __z_to_z) return __intrin_bitcast<_To>(_mm512_cvttpd_epu64(__intrin)); // else use scalar fallback } else if constexpr (__f64_to_s32) //{{{2 { if constexpr (__x_to_x) return __intrin_bitcast<_To>(_mm_cvttpd_epi32(__intrin)); else if constexpr (__y_to_x) return __intrin_bitcast<_To>(_mm256_cvttpd_epi32(__intrin)); else if constexpr (__z_to_y) return __intrin_bitcast<_To>(_mm512_cvttpd_epi32(__intrin)); } else if constexpr (__f64_to_u32) //{{{2 { if constexpr (__have_avx512vl && __x_to_x) return __intrin_bitcast<_To>(_mm_cvttpd_epu32(__intrin)); else if constexpr (__have_sse4_1 && __x_to_x) return __vector_bitcast<_Up, _M>( _mm_cvttpd_epi32(_mm_floor_pd(__intrin) - 0x8000'0000u)) ^ 0x8000'0000u; else if constexpr (__x_to_x) { // use scalar fallback: it's only 2 values to convert, can't get // much better than scalar decomposition } else if constexpr (__have_avx512vl && __y_to_x) return __intrin_bitcast<_To>(_mm256_cvttpd_epu32(__intrin)); else if constexpr (__y_to_x) { return __intrin_bitcast<_To>( __vector_bitcast<_Up>( _mm256_cvttpd_epi32(_mm256_floor_pd(__intrin) - 0x8000'0000u)) ^ 0x8000'0000u); } else if constexpr (__z_to_y) return __intrin_bitcast<_To>(_mm512_cvttpd_epu32(__intrin)); } else if constexpr (__f64_to_ibw) //{{{2 { return __convert_x86<_To>( __convert_x86<__vector_type_t<int, (_Np < 4 ? 4 : _Np)>>(__v)); } else if constexpr (__s64_to_f32) //{{{2 { if constexpr (__x_to_x && __have_avx512dq_vl) return __intrin_bitcast<_To>(_mm_cvtepi64_ps(__intrin)); else if constexpr (__y_to_x && __have_avx512dq_vl) return __intrin_bitcast<_To>(_mm256_cvtepi64_ps(__intrin)); else if constexpr (__z_to_y && __have_avx512dq) return __intrin_bitcast<_To>(_mm512_cvtepi64_ps(__intrin)); else if constexpr (__z_to_y) return __intrin_bitcast<_To>( _mm512_cvtpd_ps(__convert_x86<__vector_type_t<double, 8>>(__v))); } else if constexpr (__u64_to_f32) //{{{2 { if constexpr (__x_to_x && __have_avx512dq_vl) return __intrin_bitcast<_To>(_mm_cvtepu64_ps(__intrin)); else if constexpr (__y_to_x && __have_avx512dq_vl) return __intrin_bitcast<_To>(_mm256_cvtepu64_ps(__intrin)); else if constexpr (__z_to_y && __have_avx512dq) return __intrin_bitcast<_To>(_mm512_cvtepu64_ps(__intrin)); else if constexpr (__z_to_y) { return __intrin_bitcast<_To>( __lo256(_mm512_cvtepu32_ps(__auto_bitcast( _mm512_cvtepi64_epi32(_mm512_srai_epi64(__intrin, 32))))) * 0x100000000LL + __lo256(_mm512_cvtepu32_ps( __auto_bitcast(_mm512_cvtepi64_epi32(__intrin))))); } } else if constexpr (__s32_to_f32) //{{{2 { // use fallback (builtin conversion) } else if constexpr (__u32_to_f32) //{{{2 { if constexpr (__x_to_x && __have_avx512vl) { // use fallback } else if constexpr (__x_to_x && __have_avx512f) return __intrin_bitcast<_To>( __lo128(_mm512_cvtepu32_ps(__auto_bitcast(__v)))); else if constexpr (__x_to_x && (__have_fma || __have_fma4)) // work around PR85819 return __auto_bitcast(0x10000 * _mm_cvtepi32_ps(__to_intrin(__v >> 16)) + _mm_cvtepi32_ps(__to_intrin(__v & 0xffff))); else if constexpr (__y_to_y && __have_avx512vl) { // use fallback } else if constexpr (__y_to_y && __have_avx512f) return __intrin_bitcast<_To>( __lo256(_mm512_cvtepu32_ps(__auto_bitcast(__v)))); else if constexpr (__y_to_y) // work around PR85819 return 0x10000 * _mm256_cvtepi32_ps(__to_intrin(__v >> 16)) + _mm256_cvtepi32_ps(__to_intrin(__v & 0xffff)); // else use fallback (builtin conversion) } else if constexpr (__ibw_to_f32) //{{{2 { if constexpr (_M <= 4 || __have_avx2) return __convert_x86<_To>( __convert_x86<__vector_type_t<int, _M>>(__v)); else { static_assert(__x_to_y); __m128i __a, __b; if constexpr (__have_sse4_1) { __a = sizeof(_Tp) == 2 ? (is_signed_v<_Tp> ? _mm_cvtepi16_epi32(__intrin) : _mm_cvtepu16_epi32(__intrin)) : (is_signed_v<_Tp> ? _mm_cvtepi8_epi32(__intrin) : _mm_cvtepu8_epi32(__intrin)); const auto __w = _mm_shuffle_epi32(__intrin, sizeof(_Tp) == 2 ? 0xee : 0xe9); __b = sizeof(_Tp) == 2 ? (is_signed_v<_Tp> ? _mm_cvtepi16_epi32(__w) : _mm_cvtepu16_epi32(__w)) : (is_signed_v<_Tp> ? _mm_cvtepi8_epi32(__w) : _mm_cvtepu8_epi32(__w)); } else { __m128i __tmp; if constexpr (sizeof(_Tp) == 1) { __tmp = is_signed_v<_Tp> ? _mm_srai_epi16(_mm_unpacklo_epi8(__intrin, __intrin), 8) : _mm_unpacklo_epi8(__intrin, __m128i()); } else { static_assert(sizeof(_Tp) == 2); __tmp = __intrin; } __a = is_signed_v<_Tp> ? _mm_srai_epi32(_mm_unpacklo_epi16(__tmp, __tmp), 16) : _mm_unpacklo_epi16(__tmp, __m128i()); __b = is_signed_v<_Tp> ? _mm_srai_epi32(_mm_unpackhi_epi16(__tmp, __tmp), 16) : _mm_unpackhi_epi16(__tmp, __m128i()); } return __convert_x86<_To>(__vector_bitcast<int>(__a), __vector_bitcast<int>(__b)); } } else if constexpr (__s64_to_f64) //{{{2 { if constexpr (__x_to_x && __have_avx512dq_vl) return __intrin_bitcast<_To>(_mm_cvtepi64_pd(__intrin)); else if constexpr (__y_to_y && __have_avx512dq_vl) return __intrin_bitcast<_To>(_mm256_cvtepi64_pd(__intrin)); else if constexpr (__z_to_z && __have_avx512dq) return __intrin_bitcast<_To>(_mm512_cvtepi64_pd(__intrin)); else if constexpr (__z_to_z) { return __intrin_bitcast<_To>( _mm512_cvtepi32_pd(_mm512_cvtepi64_epi32(__to_intrin(__v >> 32))) * 0x100000000LL + _mm512_cvtepu32_pd(_mm512_cvtepi64_epi32(__intrin))); } } else if constexpr (__u64_to_f64) //{{{2 { if constexpr (__x_to_x && __have_avx512dq_vl) return __intrin_bitcast<_To>(_mm_cvtepu64_pd(__intrin)); else if constexpr (__y_to_y && __have_avx512dq_vl) return __intrin_bitcast<_To>(_mm256_cvtepu64_pd(__intrin)); else if constexpr (__z_to_z && __have_avx512dq) return __intrin_bitcast<_To>(_mm512_cvtepu64_pd(__intrin)); else if constexpr (__z_to_z) { return __intrin_bitcast<_To>( _mm512_cvtepu32_pd(_mm512_cvtepi64_epi32(__to_intrin(__v >> 32))) * 0x100000000LL + _mm512_cvtepu32_pd(_mm512_cvtepi64_epi32(__intrin))); } } else if constexpr (__s32_to_f64) //{{{2 { if constexpr (__x_to_x) return __intrin_bitcast<_To>(_mm_cvtepi32_pd(__intrin)); else if constexpr (__x_to_y) return __intrin_bitcast<_To>(_mm256_cvtepi32_pd(__intrin)); else if constexpr (__y_to_z) return __intrin_bitcast<_To>(_mm512_cvtepi32_pd(__intrin)); } else if constexpr (__u32_to_f64) //{{{2 { if constexpr (__x_to_x && __have_avx512vl) return __intrin_bitcast<_To>(_mm_cvtepu32_pd(__intrin)); else if constexpr (__x_to_x && __have_avx512f) return __intrin_bitcast<_To>( __lo128(_mm512_cvtepu32_pd(__auto_bitcast(__v)))); else if constexpr (__x_to_x) return __intrin_bitcast<_To>( _mm_cvtepi32_pd(__to_intrin(__v ^ 0x8000'0000u)) + 0x8000'0000u); else if constexpr (__x_to_y && __have_avx512vl) return __intrin_bitcast<_To>(_mm256_cvtepu32_pd(__intrin)); else if constexpr (__x_to_y && __have_avx512f) return __intrin_bitcast<_To>( __lo256(_mm512_cvtepu32_pd(__auto_bitcast(__v)))); else if constexpr (__x_to_y) return __intrin_bitcast<_To>( _mm256_cvtepi32_pd(__to_intrin(__v ^ 0x8000'0000u)) + 0x8000'0000u); else if constexpr (__y_to_z) return __intrin_bitcast<_To>(_mm512_cvtepu32_pd(__intrin)); } else if constexpr (__ibw_to_f64) //{{{2 { return __convert_x86<_To>( __convert_x86<__vector_type_t<int, std::max(size_t(4), _M)>>(__v)); } else if constexpr (__f32_to_f64) //{{{2 { if constexpr (__x_to_x) return __intrin_bitcast<_To>(_mm_cvtps_pd(__intrin)); else if constexpr (__x_to_y) return __intrin_bitcast<_To>(_mm256_cvtps_pd(__intrin)); else if constexpr (__y_to_z) return __intrin_bitcast<_To>(_mm512_cvtps_pd(__intrin)); } else if constexpr (__f64_to_f32) //{{{2 { if constexpr (__x_to_x) return __intrin_bitcast<_To>(_mm_cvtpd_ps(__intrin)); else if constexpr (__y_to_x) return __intrin_bitcast<_To>(_mm256_cvtpd_ps(__intrin)); else if constexpr (__z_to_y) return __intrin_bitcast<_To>(_mm512_cvtpd_ps(__intrin)); } else //{{{2 __assert_unreachable<_Tp>(); // fallback:{{{2 return __vector_convert<_To>(__v, make_index_sequence<std::min(_M, _Np)>()); //}}} } // }}} // 2-arg __convert_x86 {{{1 template <typename _To, typename _V, typename _Traits> _GLIBCXX_SIMD_INTRINSIC _To __convert_x86(_V __v0, _V __v1) { static_assert(__is_vector_type_v<_V>); using _Tp = typename _Traits::value_type; constexpr size_t _Np = _Traits::_S_full_size; [[maybe_unused]] const auto __i0 = __to_intrin(__v0); [[maybe_unused]] const auto __i1 = __to_intrin(__v1); using _Up = typename _VectorTraits<_To>::value_type; constexpr size_t _M = _VectorTraits<_To>::_S_full_size; static_assert(2 * _Np <= _M, "__v1 would be discarded; use the one-argument " "__convert_x86 overload instead"); // [xyz]_to_[xyz] {{{2 [[maybe_unused]] constexpr bool __x_to_x = sizeof(__v0) <= 16 && sizeof(_To) <= 16; [[maybe_unused]] constexpr bool __x_to_y = sizeof(__v0) <= 16 && sizeof(_To) == 32; [[maybe_unused]] constexpr bool __x_to_z = sizeof(__v0) <= 16 && sizeof(_To) == 64; [[maybe_unused]] constexpr bool __y_to_x = sizeof(__v0) == 32 && sizeof(_To) <= 16; [[maybe_unused]] constexpr bool __y_to_y = sizeof(__v0) == 32 && sizeof(_To) == 32; [[maybe_unused]] constexpr bool __y_to_z = sizeof(__v0) == 32 && sizeof(_To) == 64; [[maybe_unused]] constexpr bool __z_to_x = sizeof(__v0) == 64 && sizeof(_To) <= 16; [[maybe_unused]] constexpr bool __z_to_y = sizeof(__v0) == 64 && sizeof(_To) == 32; [[maybe_unused]] constexpr bool __z_to_z = sizeof(__v0) == 64 && sizeof(_To) == 64; // iX_to_iX {{{2 [[maybe_unused]] constexpr bool __i_to_i = is_integral_v<_Up> && is_integral_v<_Tp>; [[maybe_unused]] constexpr bool __i8_to_i16 = __i_to_i && sizeof(_Tp) == 1 && sizeof(_Up) == 2; [[maybe_unused]] constexpr bool __i8_to_i32 = __i_to_i && sizeof(_Tp) == 1 && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __i8_to_i64 = __i_to_i && sizeof(_Tp) == 1 && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __i16_to_i8 = __i_to_i && sizeof(_Tp) == 2 && sizeof(_Up) == 1; [[maybe_unused]] constexpr bool __i16_to_i32 = __i_to_i && sizeof(_Tp) == 2 && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __i16_to_i64 = __i_to_i && sizeof(_Tp) == 2 && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __i32_to_i8 = __i_to_i && sizeof(_Tp) == 4 && sizeof(_Up) == 1; [[maybe_unused]] constexpr bool __i32_to_i16 = __i_to_i && sizeof(_Tp) == 4 && sizeof(_Up) == 2; [[maybe_unused]] constexpr bool __i32_to_i64 = __i_to_i && sizeof(_Tp) == 4 && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __i64_to_i8 = __i_to_i && sizeof(_Tp) == 8 && sizeof(_Up) == 1; [[maybe_unused]] constexpr bool __i64_to_i16 = __i_to_i && sizeof(_Tp) == 8 && sizeof(_Up) == 2; [[maybe_unused]] constexpr bool __i64_to_i32 = __i_to_i && sizeof(_Tp) == 8 && sizeof(_Up) == 4; // [fsu]X_to_[fsu]X {{{2 // ibw = integral && byte or word, i.e. char and short with any signedness [[maybe_unused]] constexpr bool __i64_to_f32 = is_integral_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __s32_to_f32 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __s16_to_f32 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 2 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __s8_to_f32 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 1 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __u32_to_f32 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __u16_to_f32 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 2 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __u8_to_f32 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 1 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __s64_to_f64 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __s32_to_f64 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __s16_to_f64 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 2 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __s8_to_f64 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 1 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __u64_to_f64 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __u32_to_f64 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __u16_to_f64 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 2 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __u8_to_f64 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 1 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __f32_to_s64 = is_integral_v<_Up> && is_signed_v<_Up> && sizeof(_Up) == 8 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f32_to_s32 = is_integral_v<_Up> && is_signed_v<_Up> && sizeof(_Up) == 4 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f32_to_u64 = is_integral_v<_Up> && is_unsigned_v<_Up> && sizeof(_Up) == 8 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f32_to_u32 = is_integral_v<_Up> && is_unsigned_v<_Up> && sizeof(_Up) == 4 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f64_to_s64 = is_integral_v<_Up> && is_signed_v<_Up> && sizeof(_Up) == 8 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f64_to_s32 = is_integral_v<_Up> && is_signed_v<_Up> && sizeof(_Up) == 4 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f64_to_u64 = is_integral_v<_Up> && is_unsigned_v<_Up> && sizeof(_Up) == 8 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f64_to_u32 = is_integral_v<_Up> && is_unsigned_v<_Up> && sizeof(_Up) == 4 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f32_to_ibw = is_integral_v<_Up> && sizeof(_Up) <= 2 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f64_to_ibw = is_integral_v<_Up> && sizeof(_Up) <= 2 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f32_to_f64 = is_floating_point_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __f64_to_f32 = is_floating_point_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 4; if constexpr (__i_to_i && __y_to_x && !__have_avx2) //{{{2 // <double, 4>, <double, 4> => <short, 8> return __convert_x86<_To>(__lo128(__v0), __hi128(__v0), __lo128(__v1), __hi128(__v1)); else if constexpr (__i_to_i) // assert ISA {{{2 { static_assert(__x_to_x || __have_avx2, "integral conversions with ymm registers require AVX2"); static_assert(__have_avx512bw || ((sizeof(_Tp) >= 4 || sizeof(__v0) < 64) && (sizeof(_Up) >= 4 || sizeof(_To) < 64)), "8/16-bit integers in zmm registers require AVX512BW"); static_assert((sizeof(__v0) < 64 && sizeof(_To) < 64) || __have_avx512f, "integral conversions with ymm registers require AVX2"); } // concat => use 1-arg __convert_x86 {{{2 if constexpr (sizeof(__v0) < 16 || (sizeof(__v0) == 16 && __have_avx2) || (sizeof(__v0) == 16 && __have_avx && is_floating_point_v<_Tp>) || (sizeof(__v0) == 32 && __have_avx512f && (sizeof(_Tp) >= 4 || __have_avx512bw))) { // The ISA can handle wider input registers, so concat and use one-arg // implementation. This reduces code duplication considerably. return __convert_x86<_To>(__concat(__v0, __v1)); } else //{{{2 { // conversion using bit reinterpretation (or no conversion at all) // should all go through the concat branch above: static_assert( !(is_floating_point_v< _Tp> == is_floating_point_v<_Up> && sizeof(_Tp) == sizeof(_Up))); // handle all zero extension{{{2 if constexpr (2 * _Np < _M && sizeof(_To) > 16) { constexpr size_t Min = 16 / sizeof(_Up); return __zero_extend( __convert_x86< __vector_type_t<_Up, (Min > 2 * _Np) ? Min : 2 * _Np>>(__v0, __v1)); } else if constexpr (__i64_to_i32) //{{{2 { if constexpr (__x_to_x) return __auto_bitcast(_mm_shuffle_ps(__auto_bitcast(__v0), __auto_bitcast(__v1), 0x88)); else if constexpr (__y_to_y) { // AVX512F is not available (would concat otherwise) return __auto_bitcast( __xzyw(_mm256_shuffle_ps(__auto_bitcast(__v0), __auto_bitcast(__v1), 0x88))); // alternative: // const auto v0_abxxcdxx = _mm256_shuffle_epi32(__v0, 8); // const auto v1_efxxghxx = _mm256_shuffle_epi32(__v1, 8); // const auto v_abefcdgh = _mm256_unpacklo_epi64(v0_abxxcdxx, // v1_efxxghxx); return _mm256_permute4x64_epi64(v_abefcdgh, // 0x01 * 0 + 0x04 * 2 + 0x10 * 1 + 0x40 * 3); // abcdefgh } else if constexpr (__z_to_z) return __intrin_bitcast<_To>( __concat(_mm512_cvtepi64_epi32(__i0), _mm512_cvtepi64_epi32(__i1))); } else if constexpr (__i64_to_i16) //{{{2 { if constexpr (__x_to_x) { // AVX2 is not available (would concat otherwise) if constexpr (__have_sse4_1) { return __intrin_bitcast<_To>(_mm_shuffle_epi8( _mm_blend_epi16(__i0, _mm_slli_si128(__i1, 4), 0x44), _mm_setr_epi8(0, 1, 8, 9, 4, 5, 12, 13, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80))); } else { return __vector_type_t<_Up, _M>{_Up(__v0[0]), _Up(__v0[1]), _Up(__v1[0]), _Up(__v1[1])}; } } else if constexpr (__y_to_x) { auto __a = _mm256_unpacklo_epi16(__i0, __i1); // 04.. .... 26.. .... auto __b = _mm256_unpackhi_epi16(__i0, __i1); // 15.. .... 37.. .... auto __c = _mm256_unpacklo_epi16(__a, __b); // 0145 .... 2367 .... return __intrin_bitcast<_To>( _mm_unpacklo_epi32(__lo128(__c), __hi128(__c))); // 0123 4567 } else if constexpr (__z_to_y) return __intrin_bitcast<_To>( __concat(_mm512_cvtepi64_epi16(__i0), _mm512_cvtepi64_epi16(__i1))); } else if constexpr (__i64_to_i8) //{{{2 { if constexpr (__x_to_x && __have_sse4_1) { return __intrin_bitcast<_To>(_mm_shuffle_epi8( _mm_blend_epi16(__i0, _mm_slli_si128(__i1, 4), 0x44), _mm_setr_epi8(0, 8, 4, 12, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80))); } else if constexpr (__x_to_x && __have_ssse3) { return __intrin_bitcast<_To>(_mm_unpacklo_epi16( _mm_shuffle_epi8( __i0, _mm_setr_epi8(0, 8, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80)), _mm_shuffle_epi8( __i1, _mm_setr_epi8(0, 8, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80)))); } else if constexpr (__x_to_x) { return __vector_type_t<_Up, _M>{_Up(__v0[0]), _Up(__v0[1]), _Up(__v1[0]), _Up(__v1[1])}; } else if constexpr (__y_to_x) { const auto __a = _mm256_shuffle_epi8( _mm256_blend_epi32(__i0, _mm256_slli_epi64(__i1, 32), 0xAA), _mm256_setr_epi8(0, 8, -0x80, -0x80, 4, 12, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, 0, 8, -0x80, -0x80, 4, 12, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80)); return __intrin_bitcast<_To>(__lo128(__a) | __hi128(__a)); } // __z_to_x uses concat fallback } else if constexpr (__i32_to_i16) //{{{2 { if constexpr (__x_to_x) { // AVX2 is not available (would concat otherwise) if constexpr (__have_sse4_1) { return __intrin_bitcast<_To>(_mm_shuffle_epi8( _mm_blend_epi16(__i0, _mm_slli_si128(__i1, 2), 0xaa), _mm_setr_epi8(0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15))); } else if constexpr (__have_ssse3) { return __intrin_bitcast<_To>( _mm_hadd_epi16(__to_intrin(__v0 << 16), __to_intrin(__v1 << 16))); /* return _mm_unpacklo_epi64( _mm_shuffle_epi8(__i0, _mm_setr_epi8(0, 1, 4, 5, 8, 9, 12, 13, 8, 9, 12, 13, 12, 13, 14, 15)), _mm_shuffle_epi8(__i1, _mm_setr_epi8(0, 1, 4, 5, 8, 9, 12, 13, 8, 9, 12, 13, 12, 13, 14, 15))); */ } else { auto __a = _mm_unpacklo_epi16(__i0, __i1); // 04.. 15.. auto __b = _mm_unpackhi_epi16(__i0, __i1); // 26.. 37.. auto __c = _mm_unpacklo_epi16(__a, __b); // 0246 .... auto __d = _mm_unpackhi_epi16(__a, __b); // 1357 .... return __intrin_bitcast<_To>( _mm_unpacklo_epi16(__c, __d)); // 0123 4567 } } else if constexpr (__y_to_y) { const auto __shuf = _mm256_setr_epi8(0, 1, 4, 5, 8, 9, 12, 13, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, 0, 1, 4, 5, 8, 9, 12, 13, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80); auto __a = _mm256_shuffle_epi8(__i0, __shuf); auto __b = _mm256_shuffle_epi8(__i1, __shuf); return __intrin_bitcast<_To>( __xzyw(_mm256_unpacklo_epi64(__a, __b))); } // __z_to_z uses concat fallback } else if constexpr (__i32_to_i8) //{{{2 { if constexpr (__x_to_x && __have_ssse3) { const auto shufmask = _mm_setr_epi8(0, 4, 8, 12, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80); return __intrin_bitcast<_To>( _mm_unpacklo_epi32(_mm_shuffle_epi8(__i0, shufmask), _mm_shuffle_epi8(__i1, shufmask))); } else if constexpr (__x_to_x) { auto __a = _mm_unpacklo_epi8(__i0, __i1); // 04.. .... 15.. .... auto __b = _mm_unpackhi_epi8(__i0, __i1); // 26.. .... 37.. .... auto __c = _mm_unpacklo_epi8(__a, __b); // 0246 .... .... .... auto __d = _mm_unpackhi_epi8(__a, __b); // 1357 .... .... .... auto __e = _mm_unpacklo_epi8(__c, __d); // 0123 4567 .... .... return __intrin_bitcast<_To>(__e & __m128i{-1, 0}); } else if constexpr (__y_to_x) { const auto __a = _mm256_shuffle_epi8( _mm256_blend_epi16(__i0, _mm256_slli_epi32(__i1, 16), 0xAA), _mm256_setr_epi8(0, 4, 8, 12, -0x80, -0x80, -0x80, -0x80, 2, 6, 10, 14, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, -0x80, 0, 4, 8, 12, -0x80, -0x80, -0x80, -0x80, 2, 6, 10, 14)); return __intrin_bitcast<_To>(__lo128(__a) | __hi128(__a)); } // __z_to_y uses concat fallback } else if constexpr (__i16_to_i8) //{{{2 { if constexpr (__x_to_x && __have_ssse3) { const auto __shuf = reinterpret_cast<__m128i>( __vector_type_t<_UChar, 16>{0, 2, 4, 6, 8, 10, 12, 14, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80}); return __intrin_bitcast<_To>( _mm_unpacklo_epi64(_mm_shuffle_epi8(__i0, __shuf), _mm_shuffle_epi8(__i1, __shuf))); } else if constexpr (__x_to_x) { auto __a = _mm_unpacklo_epi8(__i0, __i1); // 08.. 19.. 2A.. 3B.. auto __b = _mm_unpackhi_epi8(__i0, __i1); // 4C.. 5D.. 6E.. 7F.. auto __c = _mm_unpacklo_epi8(__a, __b); // 048C .... 159D .... auto __d = _mm_unpackhi_epi8(__a, __b); // 26AE .... 37BF .... auto __e = _mm_unpacklo_epi8(__c, __d); // 0246 8ACE .... .... auto __f = _mm_unpackhi_epi8(__c, __d); // 1357 9BDF .... .... return __intrin_bitcast<_To>(_mm_unpacklo_epi8(__e, __f)); } else if constexpr (__y_to_y) { return __intrin_bitcast<_To>(__xzyw(_mm256_shuffle_epi8( (__to_intrin(__v0) & _mm256_set1_epi32(0x00ff00ff)) | _mm256_slli_epi16(__i1, 8), _mm256_setr_epi8(0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15, 0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15)))); } // __z_to_z uses concat fallback } else if constexpr (__i64_to_f32) //{{{2 { if constexpr (__x_to_x) return __make_wrapper<float>(__v0[0], __v0[1], __v1[0], __v1[1]); else if constexpr (__y_to_y) { static_assert(__y_to_y && __have_avx2); const auto __a = _mm256_unpacklo_epi32(__i0, __i1); // aeAE cgCG const auto __b = _mm256_unpackhi_epi32(__i0, __i1); // bfBF dhDH const auto __lo32 = _mm256_unpacklo_epi32(__a, __b); // abef cdgh const auto __hi32 = __vector_bitcast< conditional_t<is_signed_v<_Tp>, int, _UInt>>( _mm256_unpackhi_epi32(__a, __b)); // ABEF CDGH const auto __hi = 0x100000000LL * __convert_x86<__vector_type_t<float, 8>>(__hi32); const auto __mid = 0x10000 * _mm256_cvtepi32_ps(_mm256_srli_epi32(__lo32, 16)); const auto __lo = _mm256_cvtepi32_ps(_mm256_set1_epi32(0x0000ffffu) & __lo32); return __xzyw((__hi + __mid) + __lo); } else if constexpr (__z_to_z && __have_avx512dq) { return is_signed_v<_Tp> ? __concat(_mm512_cvtepi64_ps(__i0), _mm512_cvtepi64_ps(__i1)) : __concat(_mm512_cvtepu64_ps(__i0), _mm512_cvtepu64_ps(__i1)); } else if constexpr (__z_to_z && is_signed_v<_Tp>) { const __m512 __hi32 = _mm512_cvtepi32_ps( __concat(_mm512_cvtepi64_epi32(__to_intrin(__v0 >> 32)), _mm512_cvtepi64_epi32(__to_intrin(__v1 >> 32)))); const __m512i __lo32 = __concat(_mm512_cvtepi64_epi32(__i0), _mm512_cvtepi64_epi32(__i1)); // split low 32-bits, because if __hi32 is a small negative // number, the 24-bit mantissa may lose important information if // any of the high 8 bits of __lo32 is set, leading to // catastrophic cancelation in the FMA const __m512 __hi16 = _mm512_cvtepu32_ps(_mm512_set1_epi32(0xffff0000u) & __lo32); const __m512 __lo16 = _mm512_cvtepi32_ps(_mm512_set1_epi32(0x0000ffffu) & __lo32); return (__hi32 * 0x100000000LL + __hi16) + __lo16; } else if constexpr (__z_to_z && is_unsigned_v<_Tp>) { return __intrin_bitcast<_To>( _mm512_cvtepu32_ps(__concat( _mm512_cvtepi64_epi32(_mm512_srai_epi64(__i0, 32)), _mm512_cvtepi64_epi32(_mm512_srai_epi64(__i1, 32)))) * 0x100000000LL + _mm512_cvtepu32_ps(__concat(_mm512_cvtepi64_epi32(__i0), _mm512_cvtepi64_epi32(__i1)))); } } else if constexpr (__f64_to_s32) //{{{2 { // use concat fallback } else if constexpr (__f64_to_u32) //{{{2 { if constexpr (__x_to_x && __have_sse4_1) { return __vector_bitcast<_Up, _M>(_mm_unpacklo_epi64( _mm_cvttpd_epi32(_mm_floor_pd(__i0) - 0x8000'0000u), _mm_cvttpd_epi32(_mm_floor_pd(__i1) - 0x8000'0000u))) ^ 0x8000'0000u; // without SSE4.1 just use the scalar fallback, it's only four // values } else if constexpr (__y_to_y) { return __vector_bitcast<_Up>( __concat(_mm256_cvttpd_epi32(_mm256_floor_pd(__i0) - 0x8000'0000u), _mm256_cvttpd_epi32(_mm256_floor_pd(__i1) - 0x8000'0000u))) ^ 0x8000'0000u; } // __z_to_z uses fallback } else if constexpr (__f64_to_ibw) //{{{2 { // one-arg __f64_to_ibw goes via _SimdWrapper<int, ?>. The fallback // would go via two independet conversions to _SimdWrapper<_To> and // subsequent interleaving. This is better, because f64->__i32 // allows to combine __v0 and __v1 into one register: if constexpr // (__z_to_x || __y_to_x) { return __convert_x86<_To>( __convert_x86<__vector_type_t<int, _Np * 2>>(__v0, __v1)); //} } else if constexpr (__f32_to_ibw) //{{{2 { return __convert_x86<_To>( __convert_x86<__vector_type_t<int, _Np>>(__v0), __convert_x86<__vector_type_t<int, _Np>>(__v1)); } //}}} // fallback: {{{2 if constexpr (sizeof(_To) >= 32) // if _To is ymm or zmm, then _SimdWrapper<_Up, _M / 2> is xmm or ymm return __concat(__convert_x86<__vector_type_t<_Up, _M / 2>>(__v0), __convert_x86<__vector_type_t<_Up, _M / 2>>(__v1)); else if constexpr (sizeof(_To) == 16) { const auto __lo = __to_intrin(__convert_x86<_To>(__v0)); const auto __hi = __to_intrin(__convert_x86<_To>(__v1)); if constexpr (sizeof(_Up) * _Np == 8) { if constexpr (is_floating_point_v<_Up>) return __auto_bitcast( _mm_unpacklo_pd(__vector_bitcast<double>(__lo), __vector_bitcast<double>(__hi))); else return __intrin_bitcast<_To>(_mm_unpacklo_epi64(__lo, __hi)); } else if constexpr (sizeof(_Up) * _Np == 4) { if constexpr (is_floating_point_v<_Up>) return __auto_bitcast( _mm_unpacklo_ps(__vector_bitcast<float>(__lo), __vector_bitcast<float>(__hi))); else return __intrin_bitcast<_To>(_mm_unpacklo_epi32(__lo, __hi)); } else if constexpr (sizeof(_Up) * _Np == 2) return __intrin_bitcast<_To>(_mm_unpacklo_epi16(__lo, __hi)); else __assert_unreachable<_Tp>(); } else return __vector_convert<_To>(__v0, __v1, make_index_sequence<_Np>()); //}}} } } //}}}1 // 4-arg __convert_x86 {{{1 template <typename _To, typename _V, typename _Traits> _GLIBCXX_SIMD_INTRINSIC _To __convert_x86(_V __v0, _V __v1, _V __v2, _V __v3) { static_assert(__is_vector_type_v<_V>); using _Tp = typename _Traits::value_type; constexpr size_t _Np = _Traits::_S_full_size; [[maybe_unused]] const auto __i0 = __to_intrin(__v0); [[maybe_unused]] const auto __i1 = __to_intrin(__v1); [[maybe_unused]] const auto __i2 = __to_intrin(__v2); [[maybe_unused]] const auto __i3 = __to_intrin(__v3); using _Up = typename _VectorTraits<_To>::value_type; constexpr size_t _M = _VectorTraits<_To>::_S_full_size; static_assert(4 * _Np <= _M, "__v2/__v3 would be discarded; use the two/one-argument " "__convert_x86 overload instead"); // [xyz]_to_[xyz] {{{2 [[maybe_unused]] constexpr bool __x_to_x = sizeof(__v0) <= 16 && sizeof(_To) <= 16; [[maybe_unused]] constexpr bool __x_to_y = sizeof(__v0) <= 16 && sizeof(_To) == 32; [[maybe_unused]] constexpr bool __x_to_z = sizeof(__v0) <= 16 && sizeof(_To) == 64; [[maybe_unused]] constexpr bool __y_to_x = sizeof(__v0) == 32 && sizeof(_To) <= 16; [[maybe_unused]] constexpr bool __y_to_y = sizeof(__v0) == 32 && sizeof(_To) == 32; [[maybe_unused]] constexpr bool __y_to_z = sizeof(__v0) == 32 && sizeof(_To) == 64; [[maybe_unused]] constexpr bool __z_to_x = sizeof(__v0) == 64 && sizeof(_To) <= 16; [[maybe_unused]] constexpr bool __z_to_y = sizeof(__v0) == 64 && sizeof(_To) == 32; [[maybe_unused]] constexpr bool __z_to_z = sizeof(__v0) == 64 && sizeof(_To) == 64; // iX_to_iX {{{2 [[maybe_unused]] constexpr bool __i_to_i = is_integral_v<_Up> && is_integral_v<_Tp>; [[maybe_unused]] constexpr bool __i8_to_i16 = __i_to_i && sizeof(_Tp) == 1 && sizeof(_Up) == 2; [[maybe_unused]] constexpr bool __i8_to_i32 = __i_to_i && sizeof(_Tp) == 1 && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __i8_to_i64 = __i_to_i && sizeof(_Tp) == 1 && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __i16_to_i8 = __i_to_i && sizeof(_Tp) == 2 && sizeof(_Up) == 1; [[maybe_unused]] constexpr bool __i16_to_i32 = __i_to_i && sizeof(_Tp) == 2 && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __i16_to_i64 = __i_to_i && sizeof(_Tp) == 2 && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __i32_to_i8 = __i_to_i && sizeof(_Tp) == 4 && sizeof(_Up) == 1; [[maybe_unused]] constexpr bool __i32_to_i16 = __i_to_i && sizeof(_Tp) == 4 && sizeof(_Up) == 2; [[maybe_unused]] constexpr bool __i32_to_i64 = __i_to_i && sizeof(_Tp) == 4 && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __i64_to_i8 = __i_to_i && sizeof(_Tp) == 8 && sizeof(_Up) == 1; [[maybe_unused]] constexpr bool __i64_to_i16 = __i_to_i && sizeof(_Tp) == 8 && sizeof(_Up) == 2; [[maybe_unused]] constexpr bool __i64_to_i32 = __i_to_i && sizeof(_Tp) == 8 && sizeof(_Up) == 4; // [fsu]X_to_[fsu]X {{{2 // ibw = integral && byte or word, i.e. char and short with any signedness [[maybe_unused]] constexpr bool __i64_to_f32 = is_integral_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __s32_to_f32 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __s16_to_f32 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 2 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __s8_to_f32 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 1 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __u32_to_f32 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __u16_to_f32 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 2 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __u8_to_f32 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 1 && is_floating_point_v<_Up> && sizeof(_Up) == 4; [[maybe_unused]] constexpr bool __s64_to_f64 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __s32_to_f64 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __s16_to_f64 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 2 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __s8_to_f64 = is_integral_v<_Tp> && is_signed_v<_Tp> && sizeof(_Tp) == 1 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __u64_to_f64 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __u32_to_f64 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __u16_to_f64 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 2 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __u8_to_f64 = is_integral_v<_Tp> && is_unsigned_v<_Tp> && sizeof(_Tp) == 1 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __f32_to_s64 = is_integral_v<_Up> && is_signed_v<_Up> && sizeof(_Up) == 8 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f32_to_s32 = is_integral_v<_Up> && is_signed_v<_Up> && sizeof(_Up) == 4 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f32_to_u64 = is_integral_v<_Up> && is_unsigned_v<_Up> && sizeof(_Up) == 8 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f32_to_u32 = is_integral_v<_Up> && is_unsigned_v<_Up> && sizeof(_Up) == 4 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f64_to_s64 = is_integral_v<_Up> && is_signed_v<_Up> && sizeof(_Up) == 8 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f64_to_s32 = is_integral_v<_Up> && is_signed_v<_Up> && sizeof(_Up) == 4 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f64_to_u64 = is_integral_v<_Up> && is_unsigned_v<_Up> && sizeof(_Up) == 8 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f64_to_u32 = is_integral_v<_Up> && is_unsigned_v<_Up> && sizeof(_Up) == 4 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f32_to_ibw = is_integral_v<_Up> && sizeof(_Up) <= 2 && is_floating_point_v<_Tp> && sizeof(_Tp) == 4; [[maybe_unused]] constexpr bool __f64_to_ibw = is_integral_v<_Up> && sizeof(_Up) <= 2 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; [[maybe_unused]] constexpr bool __f32_to_f64 = is_floating_point_v<_Tp> && sizeof(_Tp) == 4 && is_floating_point_v<_Up> && sizeof(_Up) == 8; [[maybe_unused]] constexpr bool __f64_to_f32 = is_floating_point_v<_Tp> && sizeof(_Tp) == 8 && is_floating_point_v<_Up> && sizeof(_Up) == 4; if constexpr (__i_to_i && __y_to_x && !__have_avx2) //{{{2 { // <double, 4>, <double, 4>, <double, 4>, <double, 4> => <char, 16> return __convert_x86<_To>(__lo128(__v0), __hi128(__v0), __lo128(__v1), __hi128(__v1), __lo128(__v2), __hi128(__v2), __lo128(__v3), __hi128(__v3)); } else if constexpr (__i_to_i) // assert ISA {{{2 { static_assert(__x_to_x || __have_avx2, "integral conversions with ymm registers require AVX2"); static_assert(__have_avx512bw || ((sizeof(_Tp) >= 4 || sizeof(__v0) < 64) && (sizeof(_Up) >= 4 || sizeof(_To) < 64)), "8/16-bit integers in zmm registers require AVX512BW"); static_assert((sizeof(__v0) < 64 && sizeof(_To) < 64) || __have_avx512f, "integral conversions with ymm registers require AVX2"); } // concat => use 2-arg __convert_x86 {{{2 if constexpr (sizeof(__v0) < 16 || (sizeof(__v0) == 16 && __have_avx2) || (sizeof(__v0) == 16 && __have_avx && is_floating_point_v<_Tp>) || (sizeof(__v0) == 32 && __have_avx512f)) { // The ISA can handle wider input registers, so concat and use two-arg // implementation. This reduces code duplication considerably. return __convert_x86<_To>(__concat(__v0, __v1), __concat(__v2, __v3)); } else //{{{2 { // conversion using bit reinterpretation (or no conversion at all) // should all go through the concat branch above: static_assert( !(is_floating_point_v< _Tp> == is_floating_point_v<_Up> && sizeof(_Tp) == sizeof(_Up))); // handle all zero extension{{{2 if constexpr (4 * _Np < _M && sizeof(_To) > 16) { constexpr size_t Min = 16 / sizeof(_Up); return __zero_extend( __convert_x86< __vector_type_t<_Up, (Min > 4 * _Np) ? Min : 4 * _Np>>( __v0, __v1, __v2, __v3)); } else if constexpr (__i64_to_i16) //{{{2 { if constexpr (__x_to_x && __have_sse4_1) { return __intrin_bitcast<_To>(_mm_shuffle_epi8( _mm_blend_epi16( _mm_blend_epi16(__i0, _mm_slli_si128(__i1, 2), 0x22), _mm_blend_epi16(_mm_slli_si128(__i2, 4), _mm_slli_si128(__i3, 6), 0x88), 0xcc), _mm_setr_epi8(0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15))); } else if constexpr (__y_to_y && __have_avx2) { return __intrin_bitcast<_To>(_mm256_shuffle_epi8( __xzyw(_mm256_blend_epi16( __auto_bitcast( _mm256_shuffle_ps(__vector_bitcast<float>(__v0), __vector_bitcast<float>(__v2), 0x88)), // 0.1. 8.9. 2.3. A.B. __to_intrin(__vector_bitcast<int>(_mm256_shuffle_ps( __vector_bitcast<float>(__v1), __vector_bitcast<float>(__v3), 0x88)) << 16), // .4.5 .C.D .6.7 .E.F 0xaa) // 0415 8C9D 2637 AEBF ), // 0415 2637 8C9D AEBF _mm256_setr_epi8(0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15, 0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15))); /* auto __a = _mm256_unpacklo_epi16(__v0, __v1); // 04.. .... 26.. .... auto __b = _mm256_unpackhi_epi16(__v0, __v1); // 15.. .... 37.. .... auto __c = _mm256_unpacklo_epi16(__v2, __v3); // 8C.. .... AE.. .... auto __d = _mm256_unpackhi_epi16(__v2, __v3); // 9D.. .... BF.. .... auto __e = _mm256_unpacklo_epi16(__a, __b); // 0145 .... 2367 .... auto __f = _mm256_unpacklo_epi16(__c, __d); // 89CD .... ABEF .... auto __g = _mm256_unpacklo_epi64(__e, __f); // 0145 89CD 2367 ABEF return __concat( _mm_unpacklo_epi32(__lo128(__g), __hi128(__g)), _mm_unpackhi_epi32(__lo128(__g), __hi128(__g))); // 0123 4567 89AB CDEF */ } // else use fallback } else if constexpr (__i64_to_i8) //{{{2 { if constexpr (__x_to_x) { // TODO: use fallback for now } else if constexpr (__y_to_x) { auto __a = _mm256_srli_epi32(_mm256_slli_epi32(__i0, 24), 24) | _mm256_srli_epi32(_mm256_slli_epi32(__i1, 24), 16) | _mm256_srli_epi32(_mm256_slli_epi32(__i2, 24), 8) | _mm256_slli_epi32( __i3, 24); // 048C .... 159D .... 26AE .... 37BF .... /*return _mm_shuffle_epi8( _mm_blend_epi32(__lo128(__a) << 32, __hi128(__a), 0x5), _mm_setr_epi8(4, 12, 0, 8, 5, 13, 1, 9, 6, 14, 2, 10, 7, 15, 3, 11));*/ auto __b = _mm256_unpackhi_epi64( __a, __a); // 159D .... 159D .... 37BF .... 37BF .... auto __c = _mm256_unpacklo_epi8( __a, __b); // 0145 89CD .... .... 2367 ABEF .... .... return __intrin_bitcast<_To>( _mm_unpacklo_epi16(__lo128(__c), __hi128(__c))); // 0123 4567 89AB CDEF } } else if constexpr (__i32_to_i8) //{{{2 { if constexpr (__x_to_x) { if constexpr (__have_ssse3) { const auto __x0 = __vector_bitcast<_UInt>(__v0) & 0xff; const auto __x1 = (__vector_bitcast<_UInt>(__v1) & 0xff) << 8; const auto __x2 = (__vector_bitcast<_UInt>(__v2) & 0xff) << 16; const auto __x3 = __vector_bitcast<_UInt>(__v3) << 24; return __intrin_bitcast<_To>( _mm_shuffle_epi8(__to_intrin(__x0 | __x1 | __x2 | __x3), _mm_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15))); } else { auto __a = _mm_unpacklo_epi8(__i0, __i2); // 08.. .... 19.. .... auto __b = _mm_unpackhi_epi8(__i0, __i2); // 2A.. .... 3B.. .... auto __c = _mm_unpacklo_epi8(__i1, __i3); // 4C.. .... 5D.. .... auto __d = _mm_unpackhi_epi8(__i1, __i3); // 6E.. .... 7F.. .... auto __e = _mm_unpacklo_epi8(__a, __c); // 048C .... .... .... auto __f = _mm_unpackhi_epi8(__a, __c); // 159D .... .... .... auto __g = _mm_unpacklo_epi8(__b, __d); // 26AE .... .... .... auto __h = _mm_unpackhi_epi8(__b, __d); // 37BF .... .... .... return __intrin_bitcast<_To>(_mm_unpacklo_epi8( _mm_unpacklo_epi8(__e, __g), // 0246 8ACE .... .... _mm_unpacklo_epi8(__f, __h) // 1357 9BDF .... .... )); // 0123 4567 89AB CDEF } } else if constexpr (__y_to_y) { const auto __a = _mm256_shuffle_epi8( __to_intrin((__vector_bitcast<_UShort>(_mm256_blend_epi16( __i0, _mm256_slli_epi32(__i1, 16), 0xAA)) & 0xff) | (__vector_bitcast<_UShort>(_mm256_blend_epi16( __i2, _mm256_slli_epi32(__i3, 16), 0xAA)) << 8)), _mm256_setr_epi8(0, 4, 8, 12, 2, 6, 10, 14, 1, 5, 9, 13, 3, 7, 11, 15, 0, 4, 8, 12, 2, 6, 10, 14, 1, 5, 9, 13, 3, 7, 11, 15)); return __intrin_bitcast<_To>(_mm256_permutevar8x32_epi32( __a, _mm256_setr_epi32(0, 4, 1, 5, 2, 6, 3, 7))); } } else if constexpr (__i64_to_f32) //{{{2 { // this branch is only relevant with AVX and w/o AVX2 (i.e. no ymm // integers) if constexpr (__x_to_y) { return __make_wrapper<float>(__v0[0], __v0[1], __v1[0], __v1[1], __v2[0], __v2[1], __v3[0], __v3[1]); const auto __a = _mm_unpacklo_epi32(__i0, __i1); // acAC const auto __b = _mm_unpackhi_epi32(__i0, __i1); // bdBD const auto __c = _mm_unpacklo_epi32(__i2, __i3); // egEG const auto __d = _mm_unpackhi_epi32(__i2, __i3); // fhFH const auto __lo32a = _mm_unpacklo_epi32(__a, __b); // abcd const auto __lo32b = _mm_unpacklo_epi32(__c, __d); // efgh const auto __hi32 = __vector_bitcast< conditional_t<is_signed_v<_Tp>, int, _UInt>>( __concat(_mm_unpackhi_epi32(__a, __b), _mm_unpackhi_epi32(__c, __d))); // ABCD EFGH const auto __hi = 0x100000000LL * __convert_x86<__vector_type_t<float, 8>>(__hi32); const auto __mid = 0x10000 * _mm256_cvtepi32_ps(__concat(_mm_srli_epi32(__lo32a, 16), _mm_srli_epi32(__lo32b, 16))); const auto __lo = _mm256_cvtepi32_ps( __concat(_mm_set1_epi32(0x0000ffffu) & __lo32a, _mm_set1_epi32(0x0000ffffu) & __lo32b)); return (__hi + __mid) + __lo; } } else if constexpr (__f64_to_ibw) //{{{2 { return __convert_x86<_To>( __convert_x86<__vector_type_t<int, _Np * 2>>(__v0, __v1), __convert_x86<__vector_type_t<int, _Np * 2>>(__v2, __v3)); } else if constexpr (__f32_to_ibw) //{{{2 { return __convert_x86<_To>( __convert_x86<__vector_type_t<int, _Np>>(__v0), __convert_x86<__vector_type_t<int, _Np>>(__v1), __convert_x86<__vector_type_t<int, _Np>>(__v2), __convert_x86<__vector_type_t<int, _Np>>(__v3)); } //}}} // fallback: {{{2 if constexpr (sizeof(_To) >= 32) // if _To is ymm or zmm, then _SimdWrapper<_Up, _M / 2> is xmm or ymm return __concat(__convert_x86<__vector_type_t<_Up, _M / 2>>(__v0, __v1), __convert_x86<__vector_type_t<_Up, _M / 2>>(__v2, __v3)); else if constexpr (sizeof(_To) == 16) { const auto __lo = __to_intrin(__convert_x86<_To>(__v0, __v1)); const auto __hi = __to_intrin(__convert_x86<_To>(__v2, __v3)); if constexpr (sizeof(_Up) * _Np * 2 == 8) { if constexpr (is_floating_point_v<_Up>) return __auto_bitcast(_mm_unpacklo_pd(__lo, __hi)); else return __intrin_bitcast<_To>(_mm_unpacklo_epi64(__lo, __hi)); } else if constexpr (sizeof(_Up) * _Np * 2 == 4) { if constexpr (is_floating_point_v<_Up>) return __auto_bitcast(_mm_unpacklo_ps(__lo, __hi)); else return __intrin_bitcast<_To>(_mm_unpacklo_epi32(__lo, __hi)); } else __assert_unreachable<_Tp>(); } else return __vector_convert<_To>(__v0, __v1, __v2, __v3, make_index_sequence<_Np>()); //}}}2 } } //}}} // 8-arg __convert_x86 {{{1 template <typename _To, typename _V, typename _Traits> _GLIBCXX_SIMD_INTRINSIC _To __convert_x86(_V __v0, _V __v1, _V __v2, _V __v3, _V __v4, _V __v5, _V __v6, _V __v7) { static_assert(__is_vector_type_v<_V>); using _Tp = typename _Traits::value_type; constexpr size_t _Np = _Traits::_S_full_size; [[maybe_unused]] const auto __i0 = __to_intrin(__v0); [[maybe_unused]] const auto __i1 = __to_intrin(__v1); [[maybe_unused]] const auto __i2 = __to_intrin(__v2); [[maybe_unused]] const auto __i3 = __to_intrin(__v3); [[maybe_unused]] const auto __i4 = __to_intrin(__v4); [[maybe_unused]] const auto __i5 = __to_intrin(__v5); [[maybe_unused]] const auto __i6 = __to_intrin(__v6); [[maybe_unused]] const auto __i7 = __to_intrin(__v7); using _Up = typename _VectorTraits<_To>::value_type; constexpr size_t _M = _VectorTraits<_To>::_S_full_size; static_assert(8 * _Np <= _M, "__v4-__v7 would be discarded; use the four/two/one-argument " "__convert_x86 overload instead"); // [xyz]_to_[xyz] {{{2 [[maybe_unused]] constexpr bool __x_to_x = sizeof(__v0) <= 16 && sizeof(_To) <= 16; [[maybe_unused]] constexpr bool __x_to_y = sizeof(__v0) <= 16 && sizeof(_To) == 32; [[maybe_unused]] constexpr bool __x_to_z = sizeof(__v0) <= 16 && sizeof(_To) == 64; [[maybe_unused]] constexpr bool __y_to_x = sizeof(__v0) == 32 && sizeof(_To) <= 16; [[maybe_unused]] constexpr bool __y_to_y = sizeof(__v0) == 32 && sizeof(_To) == 32; [[maybe_unused]] constexpr bool __y_to_z = sizeof(__v0) == 32 && sizeof(_To) == 64; [[maybe_unused]] constexpr bool __z_to_x = sizeof(__v0) == 64 && sizeof(_To) <= 16; [[maybe_unused]] constexpr bool __z_to_y = sizeof(__v0) == 64 && sizeof(_To) == 32; [[maybe_unused]] constexpr bool __z_to_z = sizeof(__v0) == 64 && sizeof(_To) == 64; // [if]X_to_i8 {{{2 [[maybe_unused]] constexpr bool __i_to_i = is_integral_v<_Up> && is_integral_v<_Tp>; [[maybe_unused]] constexpr bool __i64_to_i8 = __i_to_i && sizeof(_Tp) == 8 && sizeof(_Up) == 1; [[maybe_unused]] constexpr bool __f64_to_i8 = is_integral_v<_Up> && sizeof(_Up) == 1 && is_floating_point_v<_Tp> && sizeof(_Tp) == 8; if constexpr (__i_to_i) // assert ISA {{{2 { static_assert(__x_to_x || __have_avx2, "integral conversions with ymm registers require AVX2"); static_assert(__have_avx512bw || ((sizeof(_Tp) >= 4 || sizeof(__v0) < 64) && (sizeof(_Up) >= 4 || sizeof(_To) < 64)), "8/16-bit integers in zmm registers require AVX512BW"); static_assert((sizeof(__v0) < 64 && sizeof(_To) < 64) || __have_avx512f, "integral conversions with ymm registers require AVX2"); } // concat => use 4-arg __convert_x86 {{{2 if constexpr (sizeof(__v0) < 16 || (sizeof(__v0) == 16 && __have_avx2) || (sizeof(__v0) == 16 && __have_avx && is_floating_point_v<_Tp>) || (sizeof(__v0) == 32 && __have_avx512f)) { // The ISA can handle wider input registers, so concat and use two-arg // implementation. This reduces code duplication considerably. return __convert_x86<_To>(__concat(__v0, __v1), __concat(__v2, __v3), __concat(__v4, __v5), __concat(__v6, __v7)); } else //{{{2 { // conversion using bit reinterpretation (or no conversion at all) // should all go through the concat branch above: static_assert( !(is_floating_point_v< _Tp> == is_floating_point_v<_Up> && sizeof(_Tp) == sizeof(_Up))); static_assert(!(8 * _Np < _M && sizeof(_To) > 16), "zero extension should be impossible"); if constexpr (__i64_to_i8) //{{{2 { if constexpr (__x_to_x && __have_ssse3) { // unsure whether this is better than the variant below return __intrin_bitcast<_To>(_mm_shuffle_epi8( __to_intrin( (((__v0 & 0xff) | ((__v1 & 0xff) << 8)) | (((__v2 & 0xff) << 16) | ((__v3 & 0xff) << 24))) | ((((__v4 & 0xff) << 32) | ((__v5 & 0xff) << 40)) | (((__v6 & 0xff) << 48) | (__v7 << 56)))), _mm_setr_epi8(0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15))); } else if constexpr (__x_to_x) { const auto __a = _mm_unpacklo_epi8(__i0, __i1); // ac const auto __b = _mm_unpackhi_epi8(__i0, __i1); // bd const auto __c = _mm_unpacklo_epi8(__i2, __i3); // eg const auto __d = _mm_unpackhi_epi8(__i2, __i3); // fh const auto __e = _mm_unpacklo_epi8(__i4, __i5); // ik const auto __f = _mm_unpackhi_epi8(__i4, __i5); // jl const auto __g = _mm_unpacklo_epi8(__i6, __i7); // mo const auto __h = _mm_unpackhi_epi8(__i6, __i7); // np return __intrin_bitcast<_To>(_mm_unpacklo_epi64( _mm_unpacklo_epi32(_mm_unpacklo_epi8(__a, __b), // abcd _mm_unpacklo_epi8(__c, __d)), // efgh _mm_unpacklo_epi32(_mm_unpacklo_epi8(__e, __f), // ijkl _mm_unpacklo_epi8(__g, __h)) // mnop )); } else if constexpr (__y_to_y) { auto __a = // 048C GKOS 159D HLPT 26AE IMQU 37BF JNRV __to_intrin( (((__v0 & 0xff) | ((__v1 & 0xff) << 8)) | (((__v2 & 0xff) << 16) | ((__v3 & 0xff) << 24))) | ((((__v4 & 0xff) << 32) | ((__v5 & 0xff) << 40)) | (((__v6 & 0xff) << 48) | ((__v7 << 56))))); /* auto __b = _mm256_unpackhi_epi64(__a, __a); // 159D HLPT 159D HLPT 37BF JNRV 37BF JNRV auto __c = _mm256_unpacklo_epi8(__a, __b); // 0145 89CD GHKL OPST 2367 ABEF IJMN QRUV auto __d = __xzyw(__c); // 0145 89CD 2367 ABEF GHKL OPST IJMN QRUV return _mm256_shuffle_epi8( __d, _mm256_setr_epi8(0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15, 0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15)); */ auto __b = _mm256_shuffle_epi8( // 0145 89CD GHKL OPST 2367 ABEF // IJMN QRUV __a, _mm256_setr_epi8(0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15, 0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15)); auto __c = __xzyw(__b); // 0145 89CD 2367 ABEF GHKL OPST IJMN QRUV return __intrin_bitcast<_To>(_mm256_shuffle_epi8( __c, _mm256_setr_epi8(0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15, 0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15))); } else if constexpr (__z_to_z) { return __concat( __convert_x86<__vector_type_t<_Up, _M / 2>>(__v0, __v1, __v2, __v3), __convert_x86<__vector_type_t<_Up, _M / 2>>(__v4, __v5, __v6, __v7)); } } else if constexpr (__f64_to_i8) //{{{2 { return __convert_x86<_To>( __convert_x86<__vector_type_t<int, _Np * 2>>(__v0, __v1), __convert_x86<__vector_type_t<int, _Np * 2>>(__v2, __v3), __convert_x86<__vector_type_t<int, _Np * 2>>(__v4, __v5), __convert_x86<__vector_type_t<int, _Np * 2>>(__v6, __v7)); } else // unreachable {{{2 __assert_unreachable<_Tp>(); //}}} // fallback: {{{2 if constexpr (sizeof(_To) >= 32) // if _To is ymm or zmm, then _SimdWrapper<_Up, _M / 2> is xmm or ymm return __concat( __convert_x86<__vector_type_t<_Up, _M / 2>>(__v0, __v1, __v2, __v3), __convert_x86<__vector_type_t<_Up, _M / 2>>(__v4, __v5, __v6, __v7)); else if constexpr (sizeof(_To) == 16) { const auto __lo = __to_intrin(__convert_x86<_To>(__v0, __v1, __v2, __v3)); const auto __hi = __to_intrin(__convert_x86<_To>(__v4, __v5, __v6, __v7)); static_assert(sizeof(_Up) == 1 && _Np == 2); return __intrin_bitcast<_To>(_mm_unpacklo_epi64(__lo, __hi)); } else { __assert_unreachable<_Tp>(); // return __vector_convert<_To>(__v0, __v1, __v2, __v3, __v4, __v5, // __v6, __v7, // make_index_sequence<_Np>()); } //}}}2 } } //}}} // 16-arg __convert_x86 {{{1 template <typename _To, typename _V, typename _Traits> _GLIBCXX_SIMD_INTRINSIC _To __convert_x86(_V __v0, _V __v1, _V __v2, _
Save