Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2026-06-19 0cfc87bd32822e5ba22d8c2b1a26fa60f63ad7fa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
#include <string>
 
#include "dbms/htp.h"
#include <libxml/HTMLparser.h>
#include <libxml/HTMLtree.h>
#include "dbms/owa.h"
 
extern "C"
{
#include "utils/builtins.h"
#include "utils/elog.h"
#include "mb/pg_wchar.h"
#include "lib/stringinfo.h"
}
 
static std::string html_buffer{};
bool test_mode = false;
 
namespace htp{
typedef enum StringEscapeFormat{
    StringEscapeFormatNone,
    StringEscapeFormatSpecialChars,   // xmlEncodeSpecialChars из libxml2
    StringEscapeFormatOracle,         // oracle-style from htp
    StringEscapeFormatOracleFull,     // oracle-style + for symbol "<>& - &quot;, &qt; ... etc.
    StringEscapeLtGtChars             // escape only <> symbols (used for tag attributes)
} StringEscapeFormat;
void html_buffer_add(const char *str){
    if (test_mode)
    {
        html_buffer.clear();
    }
    html_buffer.append(str);
    html_buffer.push_back('\n');
    ereport(NOTICE, (errmsg("HTML: \n%s", html_buffer.c_str())));
}
 
// Вспомогательная функция для одиночного указателя
template<typename T>
static inline void pfree_if_not_null(T*& ptr) {
    if (ptr != NULL) {
        pfree(ptr);
        ptr = NULL;  // предотвращает случайное повторное освобождение
    }
}
 
// Вариативный шаблон для произвольного числа аргументов (по ссылке)
template<typename... Args>
static void pfree_all(Args&... args) {
    (pfree_if_not_null(args), ...);
}
 
// латинские буквы, _,-, цифры - оставляем как есть, остальное экранируем 
// full - смешанный стиль (дополняется тем, что для односимвольного текста стандартное xml экранирование)
char *
escape_to_numeric_entity(text *input, bool full = false)
{
    const char    *data = VARDATA_ANY(input);
    int            len = VARSIZE_ANY_EXHDR(input);
    StringInfoData result;
 
    /* Инициализация буфера для результата */
    initStringInfo(&result);
    if (len == 0)
        return result.data;
 
    int            encoding = GetDatabaseEncoding();
    int            byte_pos = 0;
 
    while (byte_pos < len)
    {
        int char_len = pg_encoding_mblen(encoding, data + byte_pos);
        if (char_len <= 0 || byte_pos + char_len > len)
            break;
 
        if (char_len == 1)
        {
            unsigned char c = data[byte_pos];
            if(full) {
                if(c == '"'){
                    appendStringInfo(&result, "&quot;");
                    byte_pos += char_len;
                    continue;
                }
                if(c == '<'){
                    appendStringInfo(&result, "&lt;");
                    byte_pos += char_len;
                    continue;
                }
                if(c == '>'){
                    appendStringInfo(&result, "&gt;");
                    byte_pos += char_len;
                    continue;
                }
                if(c == '&'){
                    appendStringInfo(&result, "&amp;");
                    byte_pos += char_len;
                    continue;
                }
                if(c<='~'){
                    appendStringInfoChar(&result, c);
                    byte_pos += char_len;
                    continue;
                }
            }
            if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') ||
                (c >= '0' && c <= '9') || c == '_' || c == '-' || c == '.' ||
                c == ',')
            {
                appendStringInfoChar(&result, c);
                byte_pos += char_len;
                continue;
            }
        }
 
        /* Для однобайтовых небезопасных и многобайтовых — декодируем */
        pg_wchar wc_buf[2];
        int conv = pg_mb2wchar_with_len(data + byte_pos, wc_buf, char_len);
        if (conv > 0){
            int digits = 1;
            unsigned int temp = wc_buf[0];
            while (temp > 15) {
                temp >>= 4;
                digits++;
            }
            // Если цифр нечётное - увеличиваем на 1 (добавим один ведущий ноль)
            if (digits % 2 != 0) {
                digits++;
            }
            appendStringInfo(&result, "&#x%0*X;", digits, (unsigned int) wc_buf[0]);
        }
        else
            appendStringInfoChar(&result, '?');
 
        byte_pos += char_len;
    }
 
    return result.data;
}
char *escape_special_chars(text *input){
    if(input == NULL)
        return NULL;
    char *str = text_to_cstring(input);
    xmlBufferPtr buf = xmlBufferCreate();
    if (!buf) return NULL;
    xmlOutputBufferPtr out = xmlOutputBufferCreateBuffer(buf, NULL);
    if (!out) {
        xmlBufferFree(buf);
        return NULL;
    }
    
    xmlChar *escaped_code = xmlEncodeSpecialChars(NULL, (xmlChar*)str);
    xmlOutputBufferWriteString(out, (char*)escaped_code);
    xmlFree(escaped_code);
    pfree(str);
    
 
    xmlOutputBufferFlush(out);    
    const xmlChar *content = xmlBufferContent(buf);
    size_t len = xmlBufferLength(buf);
    
    char *result = (char*)palloc(len + 1);
    if (result) {
        memcpy(result, content, len);
        result[len] = '\0';
    }
    
    xmlOutputBufferClose(out); // также освобождает buf
    return result; // освобождать через pfree()
}
char *escape_ltgt_chars(text *input){
    if (input == nullptr)
    {
        return nullptr;
    }
    const char    *data = VARDATA_ANY(input);
    int            len = VARSIZE_ANY_EXHDR(input);
    int            byte_pos = 0;
    StringInfoData result;
 
    initStringInfo(&result);
    if (len == 0)
    {
        return result.data;
    }
 
    // processing as ASCII as it is considered to be ASCII (observation from tests)
    while (byte_pos < len)
    {
        if (data[byte_pos] == '<')
        {
            appendStringInfo(&result, "&lt;");
        }
        else if (data[byte_pos] == '>')
        {
            appendStringInfo(&result, "&gt;");
        }
        else
        {
            appendStringInfoChar(&result, data[byte_pos]);
        }
        byte_pos++;
    }
 
    return result.data;
}
char *
get_string_argument(FunctionCallInfo fcinfo, int argnum, StringEscapeFormat type = StringEscapeFormatNone)
{
    if (PG_ARGISNULL(argnum))
        return NULL;
    text *arg_txt = PG_GETARG_TEXT_PP(argnum);
    char *result = NULL;
    if (VARSIZE_ANY_EXHDR(arg_txt) == 0)
        return NULL;
    switch(type){
        case StringEscapeFormatSpecialChars:
        result = escape_special_chars(arg_txt);
        break;
        case StringEscapeFormatOracle:
        result = escape_to_numeric_entity(arg_txt);
        break;
        case StringEscapeFormatOracleFull:
        result = escape_to_numeric_entity(arg_txt, true);
        break;
        case StringEscapeLtGtChars:
        result = escape_ltgt_chars(arg_txt);
        break;
        default:
        result = text_to_cstring(arg_txt);
        break;
    }
    return result;
}
static char *
get_numeric_argument_as_string(FunctionCallInfo fcinfo, int argnum)
{
    /* Проверяем, не NULL ли аргумент */
    if (PG_ARGISNULL(argnum))
        return NULL;
 
    /* Получаем Datum с аргументом типа NUMERIC */
    Datum numeric_datum = PG_GETARG_DATUM(argnum);
 
    /* Преобразуем NUMERIC в C-строку через выходную функцию типа */
    Datum str_datum = DirectFunctionCall1(numeric_out, numeric_datum);
 
    /* Возвращаем строку (char* уже в памяти palloc) */
    return DatumGetCString(str_datum);
}
char* generate_applet_tag(const char *code, int width, bool width_is_set, int height, bool height_is_set, const char *other_attrs) {
    xmlBufferPtr buf = xmlBufferCreate();
    if (!buf) return NULL;
    
    xmlOutputBufferPtr out = xmlOutputBufferCreateBuffer(buf, NULL);
    if (!out) {
        xmlBufferFree(buf);
        return NULL;
    }
    
    // <applet code=...>
    xmlOutputBufferWriteString(out, "<applet code=");
    if(code){
        xmlChar *escaped_code = xmlEncodeSpecialChars(NULL, (xmlChar*)code);
        xmlOutputBufferWriteString(out, (char*)escaped_code);
        xmlFree(escaped_code);
    }
    
    // width без кавычек
    xmlOutputBufferWriteString(out, " width=");
    if(width_is_set){
        char wbuf[32];
        snprintf(wbuf, sizeof(wbuf), "%d", width);
        xmlOutputBufferWriteString(out, wbuf);
    }
    
    // height без кавычек
    xmlOutputBufferWriteString(out, " height=");
    if(height_is_set){
        char hbuf[32];
        snprintf(hbuf, sizeof(hbuf), "%d", height);
        xmlOutputBufferWriteString(out, hbuf);
    }
    
 
    // other_attrs
    if(other_attrs){
        // если атрибуты заданы - добавляем без анализа
        xmlOutputBufferWriteString(out, " "); // разделитель
        xmlOutputBufferWriteString(out, other_attrs);
    }
    
    // Закрываем тег (не самозакрывающийся)
    xmlOutputBufferWriteString(out, ">");
    
    xmlOutputBufferFlush(out);
    
    const xmlChar *content = xmlBufferContent(buf);
    size_t len = xmlBufferLength(buf);
    
    char *result = (char*)palloc(len + 1);
    if (result) {
        memcpy(result, content, len);
        result[len] = '\0';
    }
    
    xmlOutputBufferClose(out); // также освобождает buf
    return result; // освобождать через pfree()
}
 
char *generate_blockquote_tag(bool cnowrap, const char *cclear, const char * cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<blockquote");
 
    if(cclear){
        appendStringInfo(result, " clear=\"%s\"", cclear);
    }
    if(cnowrap){
         appendStringInfo(result, " nowrap=\"nowrap\"");
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_body_tag(const char *cbackground, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<body");
 
    if(cbackground){
        appendStringInfo(result, " background=\"%s\"", cbackground);
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_dlist_tag(const char *cclear, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<dl");
 
    if(cclear){
        appendStringInfo(result, " clear=\"%s\"", cclear);
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_form_tag(const char *curl, const char *cmethod, const char *ctarget, const char *cenctype, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<form");
 
    if(curl){
        appendStringInfo(result, " action=\"%s\"", curl);
    }
    if(cmethod){
        appendStringInfo(result, " method=\"%s\"", cmethod);
    }
    if(ctarget){
        appendStringInfo(result, " target=\"%s\"", ctarget);
    }
    if(cenctype){
        appendStringInfo(result, " enctype=\"%s\"", cenctype);
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_font_tag(const char *ccolor, const char *cface, const char *csize, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<font");
 
    if(ccolor){
        appendStringInfo(result, " color=\"%s\"", ccolor);
    }
    if(cface){
        appendStringInfo(result, " face=\"%s\"", cface);
    }
    if(csize){
        appendStringInfo(result, " size=\"%s\"", csize);
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_formselect_tag(const char *cname, const char *cprompt, const char *csize, const char *cattributes){
    StringInfo result = makeStringInfo();
    if(cprompt){
        appendStringInfo(result, " %s", cprompt);
    }
    appendStringInfo(result, "<select");
 
    if(cname){
        appendStringInfo(result, " name=\"%s\"", cname);
    }
    if(csize){
        appendStringInfo(result, " size=\"%s\"", csize);
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_textarea_tag(const char *cname, const char *crows, const char *ccols, const char * calign, const char *cattributes,
                            const char *cwrap = NULL){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<textarea");
 
    if(cname){
        appendStringInfo(result, " name=\"%s\"", cname);
    }
    else
        appendStringInfo(result, " name=\"\"");
    if(crows){
        appendStringInfo(result, " rows=\"%s\"", crows);
    }
    else
        appendStringInfo(result, " rows=\"\"");
    if(ccols){
        appendStringInfo(result, " cols=\"%s\"", ccols);
    }
    else
        appendStringInfo(result, " cols=\"\"");
    if(calign){
        appendStringInfo(result, " align=\"%s\"", calign);
    }
    if(cwrap){
        appendStringInfo(result, " wrap=\"%s\"", cwrap);
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_frameset_tag(const char *crows, const char *ccols, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<frameset");
 
    if(crows){
        appendStringInfo(result, " rows=\"%s\"", crows);
    }
    if(ccols){
        appendStringInfo(result, " cols=\"%s\"", ccols);
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_map_tag(const char *cname, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<map");
 
    if(cname){
        appendStringInfo(result, " name=\"%s\"", cname);
    }
    else
        appendStringInfo(result, " name=\"\"");
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_olist_tag(const char *cclear, const char* cwrap, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<ol");
 
    if(cclear){
        appendStringInfo(result, " clear=\"%s\"", cclear);
    }
    if(cwrap){
        appendStringInfo(result, " wrap=\"%s\"", cwrap);
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_pre_tag(const char *cclear, const char* cwidth, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<pre");
 
    if(cclear){
        appendStringInfo(result, " clear=\"%s\"", cclear);
    }
    if(cwidth){
        appendStringInfo(result, " width=\"%s\"", cwidth);
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_table_tag(const char *cborder, const char* calign, const char *cnowrap, const char* cclear, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<table ");
 
    if(cborder){
        appendStringInfo(result, " %s", cborder);
    }
    if(cnowrap){
        appendStringInfo(result, " nowrap=\"nowrap\"");
    }
    if(calign){
        appendStringInfo(result, " align=\"%s\"", calign);
    }
    if(cclear){
        appendStringInfo(result, " clear=\"%s\"", cclear);
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_tablerow_tag(const char *calign, const char* cvalign, const char *cdp, const char* cnowrap, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<tr");
 
    if(calign){
        appendStringInfo(result, " align=\"%s\"", calign);
    }
    if(cvalign){
        appendStringInfo(result, " valign=\"%s\"", cvalign);
    }
    if(cdp){
        appendStringInfo(result, " dp=\"%s\"", cdp);
    }
    if(cnowrap){
        appendStringInfo(result, " nowrap=\"nowrap\"");
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_ulist_tag(const char *cclear, const char* cwrap, const char *cdingbat, const char* csrc, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<ul");
 
    if(cclear){
        appendStringInfo(result, " clear=\"%s\"", cclear);
    }
    if(cwrap){
        appendStringInfo(result, " wrap=\"%s\"", cwrap);
    }
    if(cdingbat){
        appendStringInfo(result, " dingbat=\"%s\"", cdingbat);
    }
    if(csrc){
        appendStringInfo(result, " src=\"%s\"", csrc);
    }        
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_checkbox_tag(const char *cname, const char *cvalue, const char* cchecked, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<input type=\"checkbox\"");
 
    if(cname){
        appendStringInfo(result, " name=\"%s\"", cname);
    }
    if(cvalue){
        appendStringInfo(result, " value=\"%s\"", cvalue);
    }
    if(cchecked){
        appendStringInfo(result, " checked=\"checked\"");
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, " />");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
void append_attribute(StringInfo res, const char *name, const char *value){
    if(name){
        if(value)
            appendStringInfo(res, " %s=\"%s\"", name, value);
    }
}
void append_attribute_chk_len(StringInfo res, const char *tag_name, 
                              const char *tag_value) noexcept {
    if(tag_name != nullptr)
    {
        if(tag_value != nullptr && strlen(tag_value))
        {
            appendStringInfo(res, " %s=\"%s\"", tag_name, tag_value);
        }
    }
}
char* generate_file_tag(const char *cname, const char *caccept, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<input type=\"file\"");
 
    append_attribute(result, "name", cname);
    append_attribute(result, "accept", caccept);
    
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, " />");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_hidden_tag(const char *cname, const char *cvalue, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<input type=\"hidden\"");
 
    append_attribute(result, "name", cname);
    append_attribute(result, "value", cvalue);
    
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, " />");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_image_tag(const char *cname, const char *csrc, const char *calign, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<input type=\"image\"");
 
    append_attribute(result, "name", cname);
    append_attribute(result, "src", csrc);
    append_attribute(result, "align", calign);
 
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, " />");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_password_tag(const char *cname, const char *csize, const char *cmaxlength, const char *cvalue, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<input type=\"password\"");
 
    append_attribute(result, "name", cname);
    append_attribute(result, "size", csize);
    append_attribute(result, "maxlength", cmaxlength);
    append_attribute(result, "value", cvalue);
 
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, " />");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_radio_tag(const char *cname, const char *cvalue, const char *cchecked, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<input type=\"radio\"");
 
    append_attribute(result, "name", cname);
    append_attribute(result, "value", cvalue);
    if(cchecked){
        appendStringInfo(result, " checked=\"checked\"");
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, " />");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_reset_tag(const char *cvalue, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<input type=\"reset\"");
 
    append_attribute(result, "VALUE", cvalue);
    
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, " />");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_selectoption_tag(const char *cvalue, const char *cselected, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<option");
 
    if(cselected){
        appendStringInfo(result, " selected=\"selected\"");
    }
    
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">%s</option>", cvalue ? cvalue : "");
    
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_submit_tag(const char *cname, const char *cvalue, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<input type=\"submit\"");
 
    append_attribute(result, "name", cname);
    append_attribute(result, "value", cvalue);
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, " />");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_formtext_tag(const char *cname, const char *csize, const char *cmaxlength, const char *cvalue, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<input type=\"text\"");
 
    append_attribute(result, "name", cname);
    append_attribute(result, "size", csize);
    append_attribute(result, "maxlength", cmaxlength);
    append_attribute(result, "value", cvalue);
 
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, " />");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_formtextarea_tag(const char *cname, const char *crows, const char *ccolumns, const char *calign, const char *cattributes, 
        const char *cwrap = NULL){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<textarea");
 
    append_attribute(result, "name", cname);
    append_attribute(result, "rows", crows);
    append_attribute(result, "cols", ccolumns);
    append_attribute(result, "align", calign);
    append_attribute(result, "wrap", cwrap);
 
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, "></textarea>");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_address_tag(const char *cvalue, const char *cnowrap, const char *cclear, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<address");
 
    append_attribute(result, "clear", cclear);
    if(cnowrap){
        appendStringInfo(result, " nowrap=\"nowrap\"");
    }
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">%s</address>", cvalue ? cvalue : "");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_anchor_tag(const char *curl, const char *ctext, const char *cname, const char *cattributes,
                            const char *ctarget = NULL){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<a");
 
    append_attribute(result, "href", curl);
    append_attribute(result, "name", cname);
    append_attribute(result, "target", ctarget);
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">%s</a>", ctext ? ctext : "");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_area_tag(const char *ccoord, const char *cshape, const char *chref, const char *cnohref, const char *ctarget, const char *cattributes){
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<area");
 
    append_attribute(result, "shape", cshape);
    append_attribute(result, "coord", ccoord);
    append_attribute(result, "href", chref);
    if(cnohref){
        appendStringInfo(result, " nohref=\"nohref\"");
    }
    append_attribute(result, "target", ctarget);
    if(cattributes){
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, " />");
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
    return ret;
}
char* generate_em_tag(const char *ctext, const char *cattributes) noexcept {
    char *result = nullptr;
    constexpr int em_tag_len = 10; // <em ></em> is 10 symbols
    int ctext_len = 0;
    int cattr_len = 0;
    bool inc_space = false;
 
    if (ctext != nullptr)
    {
        ctext_len = strlen(ctext);
    }
    if (cattributes != nullptr)
    {
        cattr_len = strlen(cattributes);
        if (cattr_len)
        {
            inc_space = true;
        }
    }
 
    result = (char*)palloc0(ctext_len + cattr_len + em_tag_len + 1);
 
    sprintf(result, "<em%s%s>%s</em>", inc_space ? " " : "",
                                       cattributes ? cattributes : "",
                                       ctext ? ctext : "");
 
    return result;
}
char* generate_frame_tag(const char *csrc, const char *cname, const char *cmarginwidth, 
                         const char *cmarginheight, const char *cscrolling, 
                         const char *cnoresize, const char *cattributes) noexcept {
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<frame src=\"");
 
    appendStringInfo(result, "%s\"", csrc);
 
    append_attribute_chk_len(result, "name", cname);
    append_attribute_chk_len(result, "marginwidth", cmarginwidth);
    append_attribute_chk_len(result, "marginheight", cmarginheight);
    append_attribute_chk_len(result, "scrolling", cscrolling);
 
    if(cnoresize != nullptr && strlen(cnoresize))
    {
        appendStringInfo(result, " noresize=\"noresize\"");
    }
 
    if (cattributes != nullptr && strlen(cattributes))
    {
        appendStringInfo(result, " %s", cattributes);
    }
    
    appendStringInfo(result, " />");
    
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
 
    return ret;
}
char* generate_header_tag(int32 clevel, bool clevel_is_set, const char *cheader, const char *calign, 
                          const char *cnowrap, const char *cclear, const char *cattributes) noexcept {
    StringInfo result = makeStringInfo();
    char       clevel_str[1 + 1] = {0};
 
    if (clevel_is_set)
    {
        if (clevel < 0)
        {
            clevel *= -1; 
        }
        if (clevel > 6)
        {
            clevel = 6;
        }
        sprintf(clevel_str, "%d", clevel);
    }
    appendStringInfo(result, "<h%s", clevel_str);
 
    append_attribute_chk_len(result, "align", calign);
    if(cnowrap != nullptr && strlen(cnowrap))
    {
        appendStringInfo(result, " nowrap=\"nowrap\"");
    }
    append_attribute_chk_len(result, "clear", cclear);
    if (cattributes != nullptr && strlen(cattributes))
    {
        appendStringInfo(result, " %s", cattributes);
    }
    
    appendStringInfo(result, ">%s</h%s>", cheader ? cheader : "", clevel_str);
    
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
 
    return ret;
}
char* generate_dlistterm_tag(const char *ctext, const char *cclear, const char *cattributes) noexcept {
    StringInfo result = makeStringInfo();
    appendStringInfo(result, "<dt");
 
    append_attribute_chk_len(result, "clear", cclear);
    if (cattributes != nullptr && strlen(cattributes))
    {
        appendStringInfo(result, " %s", cattributes);
    }
    appendStringInfo(result, ">%s", ctext ? ctext : "");
 
    char *ret = pstrdup(result->data);
    destroyStringInfo(result);
 
    return ret;
}
}// end namespace htp
 
extern "C"
{
 
PG_FUNCTION_INFO_V1(htp_enable_test_mode);
PG_FUNCTION_INFO_V1(htp_adddefaulthtmlhdr);
PG_FUNCTION_INFO_V1(htp_address);
PG_FUNCTION_INFO_V1(htp_anchor);
PG_FUNCTION_INFO_V1(htp_anchor2);
PG_FUNCTION_INFO_V1(htp_appletopen);
PG_FUNCTION_INFO_V1(htp_area);
PG_FUNCTION_INFO_V1(htp_base);
PG_FUNCTION_INFO_V1(htp_basefont);
PG_FUNCTION_INFO_V1(htp_bgsound);
PG_FUNCTION_INFO_V1(htp_big);
PG_FUNCTION_INFO_V1(htp_blockquoteopen);
PG_FUNCTION_INFO_V1(htp_bodyopen);
PG_FUNCTION_INFO_V1(htp_bold);
PG_FUNCTION_INFO_V1(htp_br);
PG_FUNCTION_INFO_V1(htp_center);
PG_FUNCTION_INFO_V1(htp_cite);
PG_FUNCTION_INFO_V1(htp_code);
PG_FUNCTION_INFO_V1(htp_comment);
PG_FUNCTION_INFO_V1(htp_dfn);
PG_FUNCTION_INFO_V1(htp_div);
PG_FUNCTION_INFO_V1(htp_dlistdef);
PG_FUNCTION_INFO_V1(htp_dlistopen);
PG_FUNCTION_INFO_V1(htp_dlistterm);
PG_FUNCTION_INFO_V1(htp_download_file);
PG_FUNCTION_INFO_V1(htp_em);
PG_FUNCTION_INFO_V1(htp_emphasis);
PG_FUNCTION_INFO_V1(htp_escape_oracle_full);
PG_FUNCTION_INFO_V1(htp_escape_sc);
PG_FUNCTION_INFO_V1(htp_flush_charset_convert);
PG_FUNCTION_INFO_V1(htp_fontopen);
PG_FUNCTION_INFO_V1(htp_formcheckbox);
PG_FUNCTION_INFO_V1(htp_formfile);
PG_FUNCTION_INFO_V1(htp_formhidden);
PG_FUNCTION_INFO_V1(htp_formimage);
PG_FUNCTION_INFO_V1(htp_formopen);
PG_FUNCTION_INFO_V1(htp_formpassword);
PG_FUNCTION_INFO_V1(htp_formradio);
PG_FUNCTION_INFO_V1(htp_formreset);
PG_FUNCTION_INFO_V1(htp_formselectopen);
PG_FUNCTION_INFO_V1(htp_formselectoption);
PG_FUNCTION_INFO_V1(htp_formsubmit);
PG_FUNCTION_INFO_V1(htp_formtext);
PG_FUNCTION_INFO_V1(htp_formtextarea);
PG_FUNCTION_INFO_V1(htp_formtextarea2);
PG_FUNCTION_INFO_V1(htp_formtextareaopen);
PG_FUNCTION_INFO_V1(htp_formtextareaopen2);
PG_FUNCTION_INFO_V1(htp_frame);
PG_FUNCTION_INFO_V1(htp_framesetopen);
PG_FUNCTION_INFO_V1(htp_get_download_files_list);
PG_FUNCTION_INFO_V1(htp_get_line);
PG_FUNCTION_INFO_V1(htp_get_page);
PG_FUNCTION_INFO_V1(htp_get_page_charset_convert);
PG_FUNCTION_INFO_V1(htp_get_page_raw);
PG_FUNCTION_INFO_V1(htp_header);
PG_FUNCTION_INFO_V1(htp_hr);
PG_FUNCTION_INFO_V1(htp_htitle);
PG_FUNCTION_INFO_V1(htp_img);
PG_FUNCTION_INFO_V1(htp_img2);
PG_FUNCTION_INFO_V1(htp_isindex);
PG_FUNCTION_INFO_V1(htp_italic);
PG_FUNCTION_INFO_V1(htp_kbd);
PG_FUNCTION_INFO_V1(htp_keyboard);
PG_FUNCTION_INFO_V1(htp_line);
PG_FUNCTION_INFO_V1(htp_linkrel);
PG_FUNCTION_INFO_V1(htp_linkrev);
PG_FUNCTION_INFO_V1(htp_listheader);
PG_FUNCTION_INFO_V1(htp_listitem);
PG_FUNCTION_INFO_V1(htp_mailto);
PG_FUNCTION_INFO_V1(htp_mapopen);
PG_FUNCTION_INFO_V1(htp_meta);
PG_FUNCTION_INFO_V1(htp_nextid);
PG_FUNCTION_INFO_V1(htp_nl);
PG_FUNCTION_INFO_V1(htp_nobr);
PG_FUNCTION_INFO_V1(htp_olistopen);
PG_FUNCTION_INFO_V1(htp_p_ovr1);
PG_FUNCTION_INFO_V1(htp_p_ovr2);
PG_FUNCTION_INFO_V1(htp_p_ovr3);
PG_FUNCTION_INFO_V1(htp_paragraph);
PG_FUNCTION_INFO_V1(htp_param);
PG_FUNCTION_INFO_V1(htp_plaintext);
PG_FUNCTION_INFO_V1(htp_preopen);
PG_FUNCTION_INFO_V1(htp_print_ovr1);
PG_FUNCTION_INFO_V1(htp_print_ovr2);
PG_FUNCTION_INFO_V1(htp_print_ovr3);
PG_FUNCTION_INFO_V1(htp_prints);
PG_FUNCTION_INFO_V1(htp_print_header);
PG_FUNCTION_INFO_V1(htp_prn_ovr1);
PG_FUNCTION_INFO_V1(htp_prn_ovr2);
PG_FUNCTION_INFO_V1(htp_prn_ovr3);
PG_FUNCTION_INFO_V1(htp_ps);
PG_FUNCTION_INFO_V1(htp_putraw);
PG_FUNCTION_INFO_V1(htp_s);
PG_FUNCTION_INFO_V1(htp_sample);
PG_FUNCTION_INFO_V1(htp_script);
PG_FUNCTION_INFO_V1(htp_sethttpcharset);
PG_FUNCTION_INFO_V1(htp_set_transfer_mode);
PG_FUNCTION_INFO_V1(htp_small);
PG_FUNCTION_INFO_V1(htp_strike);
PG_FUNCTION_INFO_V1(htp_strong);
PG_FUNCTION_INFO_V1(htp_style);
PG_FUNCTION_INFO_V1(htp_sub);
PG_FUNCTION_INFO_V1(htp_sup);
PG_FUNCTION_INFO_V1(htp_tablecaption);
PG_FUNCTION_INFO_V1(htp_tabledata);
PG_FUNCTION_INFO_V1(htp_tableheader);
PG_FUNCTION_INFO_V1(htp_tableopen);
PG_FUNCTION_INFO_V1(htp_tablerowopen);
PG_FUNCTION_INFO_V1(htp_teletype);
PG_FUNCTION_INFO_V1(htp_title);
PG_FUNCTION_INFO_V1(htp_ulistopen);
PG_FUNCTION_INFO_V1(htp_underline);
PG_FUNCTION_INFO_V1(htp_variable);
 
PG_FUNCTION_INFO_V1(htp_appletclose);
PG_FUNCTION_INFO_V1(htp_blockquoteclose);
PG_FUNCTION_INFO_V1(htp_bodyclose);
PG_FUNCTION_INFO_V1(htp_centerclose);
PG_FUNCTION_INFO_V1(htp_centeropen);
PG_FUNCTION_INFO_V1(htp_dirlistclose);
PG_FUNCTION_INFO_V1(htp_dirlistopen);
PG_FUNCTION_INFO_V1(htp_dlistclose);
PG_FUNCTION_INFO_V1(htp_flush);
PG_FUNCTION_INFO_V1(htp_fontclose);
PG_FUNCTION_INFO_V1(htp_formclose);
PG_FUNCTION_INFO_V1(htp_formselectclose);
PG_FUNCTION_INFO_V1(htp_formtextareaclose);
PG_FUNCTION_INFO_V1(htp_framesetclose);
PG_FUNCTION_INFO_V1(htp_headclose);
PG_FUNCTION_INFO_V1(htp_headopen);
PG_FUNCTION_INFO_V1(htp_htmlclose);
PG_FUNCTION_INFO_V1(htp_htmlopen);
PG_FUNCTION_INFO_V1(htp_init);
PG_FUNCTION_INFO_V1(htp_listingclose);
PG_FUNCTION_INFO_V1(htp_listingopen);
PG_FUNCTION_INFO_V1(htp_mapclose);
PG_FUNCTION_INFO_V1(htp_menulistclose);
PG_FUNCTION_INFO_V1(htp_menulistopen);
PG_FUNCTION_INFO_V1(htp_noframesclose);
PG_FUNCTION_INFO_V1(htp_noframesopen);
PG_FUNCTION_INFO_V1(htp_olistclose);
PG_FUNCTION_INFO_V1(htp_para);
PG_FUNCTION_INFO_V1(htp_preclose);
PG_FUNCTION_INFO_V1(htp_reset_get_page);
PG_FUNCTION_INFO_V1(htp_showpage);
PG_FUNCTION_INFO_V1(htp_tableclose);
PG_FUNCTION_INFO_V1(htp_tablerowclose);
PG_FUNCTION_INFO_V1(htp_ulistclose);
PG_FUNCTION_INFO_V1(htp_wbr);
 
 
/**
 * @brief TODO: Enable test mode for HTP
 * @details TODO: Sets test_mode variable to TRUE thus enabling buffer cleaning before any tag adding
 *  * Parameters:
 *  * @param TEST_MODE (in) INT32: turns test mode on/off
 *  *  *  *  *
 */
Datum htp_enable_test_mode(PG_FUNCTION_ARGS)
{
    int32       mode = PG_GETARG_INT32(0);
    char        msg[13 + 1] = {0}; // "test mode off"
 
    if (mode)
    {
        test_mode = true;
        sprintf(msg, "test mode on");
    }
    else
    {
        test_mode = false;
        sprintf(msg, "test mode off");
    }
 
    htp::html_buffer_add(msg);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param BADDHTMLHDR (in) BOOLEAN: TODO: Описание параметра BADDHTMLHDR
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_adddefaulthtmlhdr(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.adddefaulthtmlhdr еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<ADDRESS>and</ADDRESS>tags which specify the address, author and signature of a document.
 * @details This procedure generates the<ADDRESS>and</ADDRESS>tags which specify the address, author and signature of a document.
 *  * Parameters:
 *  * @param CVALUE (in) VARCHAR2: The string that goes between the<ADDRESS>and</ADDRESS>tags.
 *  * @param CNOWRAP (in) VARCHAR2: If the value for this parameter is notNULL, theNOWRAPattribute is included in the tag
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_address(PG_FUNCTION_ARGS)
{
    char *cvalue = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracleFull);
    char *cnowrap = htp::get_string_argument(fcinfo, 1);
    char *cclear = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 3);
 
    char *tag = htp::generate_address_tag(cvalue, cnowrap, cclear, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cvalue, cnowrap, cclear, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief Like the ANCHOR2 procedure, this procedure generates the<A>and</A>HTML tags which specify the source or destination of a hypertext link.
 * @details Like the ANCHOR2 procedure, this procedure generates the<A>and</A>HTML tags which specify the source or destination of a hypertext link.
 *  * Parameters:
 *  * @param CURL (in) VARCHAR2: The value for theHREFattribute.
 *  * @param CTEXT (in) VARCHAR2: The string that goes between the<A>and</A>tags.
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_anchor(PG_FUNCTION_ARGS)
{
    char *curl = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatSpecialChars);
    char *ctext = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracleFull);
    char *cname = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 3);
 
    char *tag = htp::generate_anchor_tag(curl, ctext, cname, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(curl, ctext, cname, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief Like the ANCHOR procedure, this procedure generates the<A>and</A>HTML tags which specify the source or destination of a hypertext link.
 * @details Like the ANCHOR procedure, this procedure generates the<A>and</A>HTML tags which specify the source or destination of a hypertext link.
 *  * Parameters:
 *  * @param CURL (in) VARCHAR2: The value for theHREFattribute.
 *  * @param CTEXT (in) VARCHAR2: The string that goes between the<A>and</A>tags.
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute
 *  * @param CTARGET (in) VARCHAR2: The value for theTARGETattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_anchor2(PG_FUNCTION_ARGS)
{
    char *curl = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatSpecialChars);
    char *ctext = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracleFull);
    char *cname = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *ctarget = htp::get_string_argument(fcinfo, 3, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 4);
 
    char *tag = htp::generate_anchor_tag(curl, ctext, cname, cattributes, ctarget);
    htp::html_buffer_add(tag);
    htp::pfree_all(curl, ctext, cname, ctarget, cattributes, tag);
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<APPLET>tag which begins the invocation of a Java applet.
 * @details This procedure generates the<APPLET>tag which begins the invocation of a Java applet.
 
Specify parameters to the Java applet using thePARAM Procedure.
Use thecattributesparameter to specify theCODEBASEattribute since the PL/SQL cartridge does not know where to find the class files. TheCODEBASEattribute specifies the virtual path containing the class files.
 *  * Parameters:
 *  * @param CCODE (in) VARCHAR2: The the value for theCODEattribute which specifies the name of the applet class.
 *  * @param CWIDTH (in) NUMBER: The value for theWIDTHattribute.
 *  * @param CHEIGHT (in) NUMBER: The value for theHEIGHTattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_appletopen(PG_FUNCTION_ARGS)
{
    text *ccode_text = PG_ARGISNULL(0) ? NULL : PG_GETARG_TEXT_PP(0);
    text *cattributes_text = PG_ARGISNULL(3) ? NULL : PG_GETARG_TEXT_PP(3);
    Numeric cwidth_num = PG_ARGISNULL(1) ? NULL : PG_GETARG_NUMERIC(1);
    Numeric cheight_num = PG_ARGISNULL(2) ? NULL : PG_GETARG_NUMERIC(2);
    char *ccode = NULL;
    char *cattributes = NULL;
 
    int32 cwidth = 0;
    int32 cheight = 0;
    bool cwidth_is_set = false;
    bool cheight_is_set = false;
    
    if(cwidth_num){
        cwidth = DatumGetInt32(DirectFunctionCall1(numeric_int4, NumericGetDatum(cwidth_num)));
        cwidth_is_set = true;
    }
    if(cheight_num){
        cheight = DatumGetInt32(DirectFunctionCall1(numeric_int4, NumericGetDatum(cheight_num)));
        cheight_is_set = true;
    }
 
    if(ccode_text && VARSIZE_ANY_EXHDR(ccode_text)!=0) {
        ccode = text_to_cstring(ccode_text);
    }
    if(cattributes_text && VARSIZE_ANY_EXHDR(cattributes_text)!=0){
        cattributes = text_to_cstring(cattributes_text);
    }
 
    char *tag = htp::generate_applet_tag(ccode, cwidth, cwidth_is_set, cheight, cheight_is_set, cattributes);
    htp::html_buffer_add(tag);
    pfree(tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<AREA>tag, which defines a client-side image map. The<AREA>tag defines areas within the image and destinations for the areas.
 * @details This procedure generates the<AREA>tag, which defines a client-side image map. The<AREA>tag defines areas within the image and destinations for the areas.
 *  * Parameters:
 *  * @param CCOORDS (in) VARCHAR2: TODO: Описание параметра CCOORDS
 *  * @param CSHAPE (in) VARCHAR2: The value for theSHAPEattribute.
 *  * @param CHREF (in) VARCHAR2: The value for theHREFattribute.
 *  * @param CNOHREF (in) VARCHAR2: If the value for this parameter is notNULL, theNOHREFattribute is added to the tag.
 *  * @param CTARGET (in) VARCHAR2: The value for theTARGETattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_area(PG_FUNCTION_ARGS)
{
    char *ccoords = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *cshape = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *chref = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatSpecialChars);
    char *cnohref = htp::get_string_argument(fcinfo, 3, htp::StringEscapeFormatOracle);
    char *ctarget = htp::get_string_argument(fcinfo, 4, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 5);
 
    char *tag = htp::generate_area_tag(ccoords, cshape, chref, cnohref, ctarget, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(ccoords, cshape, chref, cnohref, ctarget, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<BASE>tag which records the URL of the document.
 * @details This procedure generates the<BASE>tag which records the URL of the document.
 *  * Parameters:
 *  * @param CTARGET (in) VARCHAR2: The value for theTARGETattribute which establishes a window name to which all links in this document are targeted.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_base(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.base еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<BASEFONT>tag which specifies the base font size for a Web page.
 * @details This procedure generates the<BASEFONT>tag which specifies the base font size for a Web page.
 *  * Parameters:
 *  * @param NSIZE (in) NUMBER: The value for theSIZEattribute.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_basefont(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.basefont еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<BGSOUND>tag which includes audio for a Web page.
 * @details This procedure generates the<BGSOUND>tag which includes audio for a Web page.
 *  * Parameters:
 *  * @param CSRC (in) VARCHAR2: The value for theSRCattribute.
 *  * @param CLOOP (in) VARCHAR2: The value for theLOOPattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_bgsound(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.bgsound еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<BIG>and</BIG>tags which direct the browser to render the text in a bigger font.
 * @details This procedure generates the<BIG>and</BIG>tags which direct the browser to render the text in a bigger font.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The the text that goes between the tags.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_big(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.big еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<BLOCKQUOTE>tag, which marks the beginning of a section of quoted text.
 * @details This procedure generates the<BLOCKQUOTE>tag, which marks the beginning of a section of quoted text.
 *  * Parameters:
 *  * @param CNOWRAP (in) VARCHAR2: If the value for this parameter is notNULL, theNOWRAPattribute is added to the tag.
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_blockquoteopen(PG_FUNCTION_ARGS)
{
    text *cnowrap_txt = PG_ARGISNULL(0) ? NULL : PG_GETARG_TEXT_PP(0);
    text *cclear_txt = PG_ARGISNULL(1) ? NULL : PG_GETARG_TEXT_PP(1);
    text *cattributes_txt =  PG_ARGISNULL(2) ? NULL : PG_GETARG_TEXT_PP(2);
    bool nowrap = false;
    char *cclear = NULL;
    char *cattributes = NULL;
 
    if(cnowrap_txt && VARSIZE_ANY_EXHDR(cnowrap_txt)!=0) {
        nowrap = true;
    }
    if(cclear_txt && VARSIZE_ANY_EXHDR(cclear_txt)!=0) {
        cclear = htp::escape_to_numeric_entity(cclear_txt);
    }
    if(cattributes_txt && VARSIZE_ANY_EXHDR(cattributes_txt)!=0) {
        cattributes = text_to_cstring(cattributes_txt);
    }
    
    char *tag = htp::generate_blockquote_tag(nowrap, cclear, cattributes);
    htp::html_buffer_add(tag);
 
    pfree(tag);
    if(cclear)
        pfree(cclear);
    if(cattributes)
        pfree(cattributes);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<BODY>tag which marks the beginning of the body section of an HTML document.
 * @details This procedure generates the<BODY>tag which marks the beginning of the body section of an HTML document.
 *  * Parameters:
 *  * @param CBACKGROUND (in) VARCHAR2: The value for theBACKGROUNDattribute which specifies a graphic file to use for the background of the document.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_bodyopen(PG_FUNCTION_ARGS)
{
    text *cbackground_txt = PG_ARGISNULL(0) ? NULL : PG_GETARG_TEXT_PP(0);
    text *cattributes_txt = PG_ARGISNULL(1) ? NULL : PG_GETARG_TEXT_PP(1);
    char *cbackground = NULL;
    char *cattributes = NULL;
 
    if(cbackground_txt && VARSIZE_ANY_EXHDR(cbackground_txt)!=0) {
        cbackground = htp::escape_to_numeric_entity(cbackground_txt);
    }
    if(cattributes_txt && VARSIZE_ANY_EXHDR(cattributes_txt)!=0) {
        cattributes = text_to_cstring(cattributes_txt);
    }
 
    char *tag = htp::generate_body_tag(cbackground, cattributes);
    htp::html_buffer_add(tag);
 
    pfree(tag);
 
    if(cbackground)
        pfree(cbackground);
    if(cattributes)
        pfree(cattributes);
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<B>and</B>tags which direct the browser to display the text in boldface.
 * @details This procedure generates the<B>and</B>tags which direct the browser to display the text in boldface.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text that goes between the tags.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_bold(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.bold еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<BR>tag which begins a new line of text.
 * @details This procedure generates the<BR>tag which begins a new line of text.
 *  * Parameters:
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_br(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.br еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<CENTER>and</CENTER>tags which center a section of text within a Web page.
 * @details This procedure generates the<CENTER>and</CENTER>tags which center a section of text within a Web page.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text that goes between the tags.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_center(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.center еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<CITE>and</CITE>tags which direct the browser to render the text as a citation.
 * @details This procedure generates the<CITE>and</CITE>tags which direct the browser to render the text as a citation.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to render as citation.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_cite(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.cite еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<CODE>and</CODE>tags which direct the browser to render the text in monospace font or however "code" is defined stylistically.
 * @details This procedure generates the<CODE>and</CODE>tags which direct the browser to render the text in monospace font or however "code" is defined stylistically.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to render as code.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_code(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.code еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the comment tags.
 * @details This procedure generates the comment tags.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The comment.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_comment(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.comment еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<DFN>and</DFN>tags which direct the browser to mark the text in italics or however "definition" is described stylistically.
 * @details This procedure generates the<DFN>and</DFN>tags which direct the browser to mark the text in italics or however "definition" is described stylistically.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to render in italics.
 *  * @param CATTRIBUTES (in) VARCHAR2: TODO: Описание параметра CATTRIBUTES
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_dfn(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.dfn еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<DIV>tag which creates document divisions.
 * @details This procedure generates the<DIV>tag which creates document divisions.
 *  * Parameters:
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_div(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.div еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<DD>tag, which inserts definitions of terms. Use this tag for a definition list<DL>. Terms are tagged<DT>and definitions are tagged<DD>.
 * @details This procedure generates the<DD>tag, which inserts definitions of terms. Use this tag for a definition list<DL>. Terms are tagged<DT>and definitions are tagged<DD>.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The definition of the term.
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_dlistdef(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.dlistdef еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<DL>tag which starts a definition list. You end a definition list by means of the DLISTCLOSE Procedure.
 * @details This procedure generates the<DL>tag which starts a definition list. You end a definition list by means of the DLISTCLOSE Procedure.
 *  * Parameters:
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_dlistopen(PG_FUNCTION_ARGS)
{
    text *cclear_txt = PG_ARGISNULL(0) ? NULL : PG_GETARG_TEXT_PP(0);
    text *cattributes_txt =  PG_ARGISNULL(1) ? NULL : PG_GETARG_TEXT_PP(1);
    char *cclear = NULL;
    char *cattributes = NULL;
 
    if(cclear_txt && VARSIZE_ANY_EXHDR(cclear_txt)!=0) {
        cclear = htp::escape_to_numeric_entity(cclear_txt);
    }
    if(cattributes_txt && VARSIZE_ANY_EXHDR(cattributes_txt)!=0) {
        cattributes = text_to_cstring(cattributes_txt);
    }
 
    char *tag = htp::generate_dlist_tag(cclear, cattributes);
    htp::html_buffer_add(tag);
 
    pfree(tag);
    if(cclear)
        pfree(cclear);
    if(cattributes)
        pfree(cattributes);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<DT>tag which defines a term in a definition list<DL>.
 * @details This procedure generates the<DT>tag which defines a term in a definition list<DL>.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The term.
 *  * @param CCLEAR (in) VARCHAR2: The value for the CLEAR attribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_dlistterm(PG_FUNCTION_ARGS)
{
    char *ctext = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracleFull);
    char *cclear = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 2, htp::StringEscapeLtGtChars);
 
    char *tag = htp::generate_dlistterm_tag(ctext, cclear, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(ctext, cclear, cattributes);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param SFILENAME (in) VARCHAR2: TODO: Описание параметра SFILENAME
 *  * @param BCOMPRESS (in) BOOLEAN: TODO: Описание параметра BCOMPRESS
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_download_file(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.download_file еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<EM>and</EM>tags, which define text to be emphasized.
 * @details Generates the<EM>and</EM>tags by including preprocessed cattributes parameter as tag 
 * attribute and preprocessed ctext parameter as the tag body.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to emphasize.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_em(PG_FUNCTION_ARGS)
{
    char *ctext = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracleFull);
    char *cattributes = htp::get_string_argument(fcinfo, 1, htp::StringEscapeLtGtChars);
 
    char *tag = htp::generate_em_tag(ctext, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(tag, ctext, cattributes);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<EM>and</EM>tags, which define text to be emphasized.
 * @details Generates the<EM>and</EM>tags by including preprocessed cattributes parameter as the tag 
 * attribute and preprocessed ctext parameter as the tag body.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to emphasize.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_emphasis(PG_FUNCTION_ARGS)
{
    char *ctext = NULL;
    char *cattributes = htp::get_string_argument(fcinfo, 1, htp::StringEscapeLtGtChars);
    text *textarg = PG_ARGISNULL(0) ? NULL : PG_GETARG_TEXT_PP(0);
    
    LOCAL_FCINFO(local_fcinfo, 1);
    InitFunctionCallInfoData(*local_fcinfo, NULL, 1, PG_GET_COLLATION(), fcinfo->context, NULL);
    local_fcinfo->args[0].value = PointerGetDatum(textarg);
    local_fcinfo->args[0].isnull = (textarg == NULL ? true : false);
    Datum esc_text_datum = (*htf_escape_oracle_full) (local_fcinfo);
    text *esc_text = NULL;
    if (DatumGetPointer(esc_text_datum) != NULL) {
        esc_text = DatumGetTextPP(esc_text_datum);
    }
    
    if(esc_text)
        ctext = text_to_cstring(esc_text);
 
    char *tag = htp::generate_em_tag(ctext, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(tag, ctext, cattributes);
    if(esc_text)
        pfree(esc_text);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief заменяет символы, имеющие специальное значение в HTML, их escape-последовательностями.
 * @details Функция преобразует символы <, >, & и другие в HTML-сущности для безопасного отображения.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: Строка для преобразования.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTF.html
 */
Datum htp_escape_oracle_full(PG_FUNCTION_ARGS)
{
    char *res_str = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracleFull);
    if(res_str){
        text *result = cstring_to_text(res_str);
        pfree(res_str);
        PG_RETURN_TEXT_P(result);
    }
 
    PG_RETURN_NULL();
}
 
/**
 * @brief This procedure replaces characters that have special meaning in HTML with their escape sequences.
 * @details This procedure replaces characters that have special meaning in HTML with their escape sequences.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text string to convert.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_escape_sc(PG_FUNCTION_ARGS)
{
    char *ctext = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatSpecialChars);
    htp::html_buffer_add(ctext);
    htp::pfree_all(ctext);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param CHARSET (in) VARCHAR2: TODO: Описание параметра CHARSET
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_flush_charset_convert(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.flush_charset_convert еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<FONT>which marks the beginning of section of text with the specified font characteristics.
 * @details This procedure generates the<FONT>which marks the beginning of section of text with the specified font characteristics.
 *  * Parameters:
 *  * @param CCOLOR (in) VARCHAR2: The value for theCOLORattribute.
 *  * @param CFACE (in) VARCHAR2: The value for theFACEattribute
 *  * @param CSIZE (in) VARCHAR2: The value for theSIZEattribute
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_fontopen(PG_FUNCTION_ARGS)
{
    text *ccolor_txt = PG_ARGISNULL(0) ? NULL : PG_GETARG_TEXT_PP(0);
    text *cface_txt = PG_ARGISNULL(1) ? NULL : PG_GETARG_TEXT_PP(1);
    text *csize_txt = PG_ARGISNULL(2) ? NULL : PG_GETARG_TEXT_PP(2);
    text *cattributes_txt =  PG_ARGISNULL(3) ? NULL : PG_GETARG_TEXT_PP(3);
    char *ccolor = NULL;
    char *cface = NULL;
    char *csize = NULL;
    char *cattributes = NULL;
 
    if(ccolor_txt && VARSIZE_ANY_EXHDR(ccolor_txt)!=0) {
        ccolor = htp::escape_to_numeric_entity(ccolor_txt);
    }
    if(cface_txt && VARSIZE_ANY_EXHDR(cface_txt)!=0) {
        cface = htp::escape_to_numeric_entity(cface_txt);
    }
    if(csize_txt && VARSIZE_ANY_EXHDR(csize_txt)!=0) {
        csize = htp::escape_to_numeric_entity(csize_txt);
    }
    if(cattributes_txt && VARSIZE_ANY_EXHDR(cattributes_txt)!=0) {
        cattributes = text_to_cstring(cattributes_txt);
    }
 
    char *tag = htp::generate_font_tag(ccolor, cface, csize, cattributes);
    htp::html_buffer_add(tag);
 
    pfree(tag);
    if(ccolor)
        pfree(ccolor);
    if(cface)
        pfree(cface);
    if(csize)
        pfree(csize);
    if(cattributes)
        pfree(cattributes);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<INPUT>tag withTYPE="checkbox"which inserts a checkbox element in a form.
 * @details This procedure generates the<INPUT>tag withTYPE="checkbox"which inserts a checkbox element in a form.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CVALUE (in) VARCHAR2: The value for theVALUEattribute.
 *  * @param CCHECKED (in) VARCHAR2: If the value for this parameter is notNULL, theCHECKEDattribute is added to the tag.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formcheckbox(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *cvalue = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cchecked = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 3);
    char *tag = htp::generate_checkbox_tag(cname, cvalue, cchecked, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, cvalue, cchecked, cattributes, tag);
 
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<INPUT>tag withTYPE="file"which inserts a file form element. This is used for file uploading for a given page.
 * @details This procedure generates the<INPUT>tag withTYPE="file"which inserts a file form element. This is used for file uploading for a given page.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CACCEPT (in) VARCHAR2: A comma-delimited list of MIME types for upload.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formfile(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *caccept = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 2);
    char *tag = htp::generate_file_tag(cname, caccept, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, caccept, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<INPUT>tag with TYPE="hidden", which inserts a hidden form element.
 * @details This procedure generates the<INPUT>tag with TYPE="hidden", which inserts a hidden form element.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CVALUE (in) VARCHAR2: The value for theVALUEattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formhidden(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *value = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 2);
    char *tag = htp::generate_hidden_tag(cname, value, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, value, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<INPUT>tag withTYPE="image"which creates an image field that the user clicks to submit the form immediately.
 * @details This procedure generates the<INPUT>tag withTYPE="image"which creates an image field that the user clicks to submit the form immediately.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CSRC (in) VARCHAR2: The value for theSRCattribute that specifies the image file.
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formimage(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *csrc = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *calign = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 3);
 
    char *tag = htp::generate_image_tag(cname, csrc, calign, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, csrc, calign, cattributes, tag);
    
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<FORM>tag which marks the beginning of a form section in an HTML document.
 * @details This procedure generates the<FORM>tag which marks the beginning of a form section in an HTML document.
 *  * Parameters:
 *  * @param CURL (in) VARCHAR2: The URL of the WRB or CGI script where the contents of the form is sent. This parameter is required.
 *  * @param CMETHOD (in) VARCHAR2: The value for theMETHODattribute. The value can be "GET" or "POST".
 *  * @param CTARGET (in) VARCHAR2: The value for theTARGETattribute.
 *  * @param CENCTYPE (in) VARCHAR2: The value for theENCTYPEattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formopen(PG_FUNCTION_ARGS)
{
    text *curl_txt = PG_ARGISNULL(0) ? NULL : PG_GETARG_TEXT_PP(0);
    text *cmethod_txt = PG_ARGISNULL(1) ? NULL : PG_GETARG_TEXT_PP(1);
    text *ctarget_txt = PG_ARGISNULL(2) ? NULL : PG_GETARG_TEXT_PP(2);
    text *cenctype_txt = PG_ARGISNULL(3) ? NULL : PG_GETARG_TEXT_PP(3);
    text *cattributes_txt =  PG_ARGISNULL(4) ? NULL : PG_GETARG_TEXT_PP(4);
    char *curl = NULL;
    char *cmethod = NULL;
    char *ctarget = NULL;
    char *cenctype = NULL;
    char *cattributes = NULL;
 
    if(curl_txt && VARSIZE_ANY_EXHDR(curl_txt)!=0) {
        curl = htp::escape_special_chars(curl_txt);
    }
    if(cmethod_txt && VARSIZE_ANY_EXHDR(cmethod_txt)!=0) {
        cmethod = htp::escape_to_numeric_entity(cmethod_txt);
    }
    if(ctarget_txt && VARSIZE_ANY_EXHDR(ctarget_txt)!=0) {
        ctarget = htp::escape_to_numeric_entity(ctarget_txt);
    }
    if(cenctype_txt && VARSIZE_ANY_EXHDR(cenctype_txt)!=0) {
        cenctype = htp::escape_to_numeric_entity(cenctype_txt);
    }
    if(cattributes_txt && VARSIZE_ANY_EXHDR(cattributes_txt)!=0) {
        cattributes = text_to_cstring(cattributes_txt);
    }
 
    char *tag = htp::generate_form_tag(curl, cmethod, ctarget, cenctype, cattributes);
    htp::html_buffer_add(tag);
 
    pfree(tag);
    if(curl)
        pfree(curl);
    if(cmethod)
        pfree(cmethod);
    if(ctarget)
        pfree(ctarget);
    if(cenctype)
        pfree(cenctype);
    if(cattributes)
        pfree(cattributes);
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<INPUT>tag withTYPE="password"which creates a single-line text entry field. When the user enters text in the field, each character is represented by one asterisk. This is used for entering passwords.
 * @details This procedure generates the<INPUT>tag withTYPE="password"which creates a single-line text entry field. When the user enters text in the field, each character is represented by one asterisk. This is used for entering passwords.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CSIZE (in) VARCHAR2: The value for theSIZEattribute.
 *  * @param CMAXLENGTH (in) VARCHAR2: The value for theMAXLENGTHattribute.
 *  * @param CVALUE (in) VARCHAR2: The value for theVALUEattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formpassword(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *csize = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cmaxlength = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *cvalue = htp::get_string_argument(fcinfo, 3, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 4);
 
    char *tag = htp::generate_password_tag(cname, csize, cmaxlength, cvalue, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, csize, cmaxlength, cvalue, cattributes, tag);
    
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<INPUT>tag withTYPE="radio", which creates a radio button on the HTML form. Within a set of radio buttons, the user selects only one. Each radio button in the same set has the same name, but different values. The selected radio button generates a name/value pair.
 * @details This procedure generates the<INPUT>tag withTYPE="radio", which creates a radio button on the HTML form. Within a set of radio buttons, the user selects only one. Each radio button in the same set has the same name, but different values. The selected radio button generates a name/value pair.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CVALUE (in) VARCHAR2: The value for theVALUEattribute.
 *  * @param CCHECKED (in) VARCHAR2: If the value for this parameter is notNULL, theCHECKEDattribute is added to the tag.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formradio(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *cvalue = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cchecked = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 3);
 
    char *tag = htp::generate_radio_tag(cname, cvalue, cchecked, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, cvalue, cchecked, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<INPUT>tag withTYPE="reset"which creates a button that, when selected, resets the form fields to their initial values.
 * @details This procedure generates the<INPUT>tag withTYPE="reset"which creates a button that, when selected, resets the form fields to their initial values.
 *  * Parameters:
 *  * @param CVALUE (in) VARCHAR2: The value for theVALUEattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formreset(PG_FUNCTION_ARGS)
{
    char *cvalue = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 1);
 
    char *tag = htp::generate_reset_tag(cvalue, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cvalue, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<SELECT>tags which creates a Select form element.
 * @details This procedure generates the<SELECT>tags which creates a Select form element.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CPROMPT (in) VARCHAR2: The string preceding the list box.
 *  * @param NSIZE (in) NUMBER: The value for theSIZEattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formselectopen(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *cprompt = htp::get_string_argument(fcinfo, 1);
    char *csize = htp::get_numeric_argument_as_string(fcinfo, 2);
    char *cattributes = htp::get_string_argument(fcinfo, 3);
 
    char *tag = htp::generate_formselect_tag(cname, cprompt, csize, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, cprompt, csize, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<OPTION>tag which represents one choice in a Select element.
 * @details This procedure generates the<OPTION>tag which represents one choice in a Select element.
 *  * Parameters:
 *  * @param CVALUE (in) VARCHAR2: The text for the option.
 *  * @param CSELECTED (in) VARCHAR2: TODO: Описание параметра CSELECTED
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formselectoption(PG_FUNCTION_ARGS)
{
    char *cvalue = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatSpecialChars);
    char *cselected = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 2);
 
    char *tag = htp::generate_selectoption_tag(cvalue, cselected, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cvalue, cselected, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<INPUT>tag withTYPE="submit"which creates a button that, when clicked, submits the form. If the button has aNAMEattribute, the button contributes a name/value pair to the submitted data.
 * @details This procedure generates the<INPUT>tag withTYPE="submit"which creates a button that, when clicked, submits the form. If the button has aNAMEattribute, the button contributes a name/value pair to the submitted data.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CVALUE (in) VARCHAR2: The value for theVALUEattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formsubmit(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *cvalue = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 2);
 
    char *tag = htp::generate_submit_tag(cname, cvalue, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, cvalue, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<INPUT>tag withTYPE="text", which creates a field for a single line of text.
 * @details This procedure generates the<INPUT>tag withTYPE="text", which creates a field for a single line of text.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CSIZE (in) VARCHAR2: The value for theSIZEattribute.
 *  * @param CMAXLENGTH (in) VARCHAR2: The value for theMAXLENGTHattribute.
 *  * @param CVALUE (in) VARCHAR2: The value for theVALUEattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formtext(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *csize = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cmaxlength = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *cvalue = htp::get_string_argument(fcinfo, 3, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 4);
 
    char *tag = htp::generate_formtext_tag(cname, csize, cmaxlength, cvalue, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, csize, cmaxlength, cvalue, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<TEXTAREA>tag, which creates a text field that has no predefined text in the text area. This field enables entering several lines of text.
 * @details This procedure generates the<TEXTAREA>tag, which creates a text field that has no predefined text in the text area. This field enables entering several lines of text.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param NROWS (in) NUMBER: The value for theROWSattribute.This is an integer.
 *  * @param NCOLUMNS (in) NUMBER: The value for theCOLSattribute.This is an integer.
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formtextarea(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *crows = htp::get_numeric_argument_as_string(fcinfo, 1);
    char *ccolumns = htp::get_numeric_argument_as_string(fcinfo, 2);
    char *calign = htp::get_string_argument(fcinfo, 3, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 4);
 
    char *tag = htp::generate_formtextarea_tag(cname, crows, ccolumns, calign, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, crows, ccolumns, calign, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<TEXTAREA>tag, which creates a text field that has no predefined text in the text area. This field enables entering several lines of text.
 * @details This procedure generates the<TEXTAREA>tag, which creates a text field that has no predefined text in the text area. This field enables entering several lines of text.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param NROWS (in) NUMBER: The value for theROWSattribute.This is an integer.
 *  * @param NCOLUMNS (in) NUMBER: The value for theCOLSattribute.This is an integer.
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CWRAP (in) VARCHAR2: The value for theWRAPattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formtextarea2(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *crows = htp::get_numeric_argument_as_string(fcinfo, 1);
    char *ccolumns = htp::get_numeric_argument_as_string(fcinfo, 2);
    char *calign = htp::get_string_argument(fcinfo, 3, htp::StringEscapeFormatOracle);
    char *cwrap = htp::get_string_argument(fcinfo, 4, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 5);
 
    char *tag = htp::generate_formtextarea_tag(cname, crows, ccolumns, calign, cattributes, cwrap);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, crows, ccolumns, calign, cattributes, cwrap, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<TEXTAREA>which marks the beginning of a text area form element.
 * @details This procedure generates the<TEXTAREA>which marks the beginning of a text area form element.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param NROWS (in) NUMBER: The value for theROWSattribute.This is an integer.
 *  * @param NCOLUMNS (in) NUMBER: The value for theCOLSattribute.This is an integer.
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formtextareaopen(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *crows = htp::get_numeric_argument_as_string(fcinfo, 1);
    char *ccolumns = htp::get_numeric_argument_as_string(fcinfo, 2);
    char *calign = htp::get_string_argument(fcinfo, 3, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 4);
 
    char *tag = htp::generate_textarea_tag(cname, crows, ccolumns, calign, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, crows, ccolumns, calign, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<TEXTAREA>which marks the beginning of a text area form element.
 * @details This procedure generates the<TEXTAREA>which marks the beginning of a text area form element.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param NROWS (in) NUMBER: The value for theROWSattribute.This is an integer.
 *  * @param NCOLUMNS (in) NUMBER: The value for theCOLSattribute.This is an integer.
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CWRAP (in) VARCHAR2: The value for theWRAPattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_formtextareaopen2(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *crows = htp::get_numeric_argument_as_string(fcinfo, 1);
    char *ccolumns = htp::get_numeric_argument_as_string(fcinfo, 2);
    char *calign = htp::get_string_argument(fcinfo, 3, htp::StringEscapeFormatOracle);
    char *cwrap = htp::get_string_argument(fcinfo, 4, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 5);
 
    char *tag = htp::generate_textarea_tag(cname, crows, ccolumns, calign, cattributes, cwrap);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, crows, ccolumns, calign, cwrap, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<FRAME>tag which begins the characteristics of a frame created by a<FRAMESET>tag.
 * @details This procedure generates the<FRAME>tag which begins the characteristics of a frame created by a<FRAMESET>tag.
 *  * Parameters:
 *  * @param CSRC (in) VARCHAR2: The URL to display in the frame.
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CMARGINWIDTH (in) VARCHAR2: The value for theMARGINWIDTHattribute.
 *  * @param CMARGINHEIGHT (in) VARCHAR2: TODO: Описание параметра CMARGINHEIGHT
 *  * @param CSCROLLING (in) VARCHAR2: The value for theSCROLLINGattribute.
 *  * @param CNORESIZE (in) VARCHAR2: If the value for this parameter is notNULL, theNORESIZEattribute is added to the tag.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_frame(PG_FUNCTION_ARGS)
{
    char *csrc = htp::get_string_argument(fcinfo, 0);
    char *cname = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cmarginwidth = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *cmarginheight = htp::get_string_argument(fcinfo, 3, htp::StringEscapeFormatOracle);
    char *cscrolling = htp::get_string_argument(fcinfo, 4, htp::StringEscapeFormatOracle);
    char *cnoresize = htp::get_string_argument(fcinfo, 5);
    char *cattributes = htp::get_string_argument(fcinfo, 6, htp::StringEscapeLtGtChars);
 
    char *tag = htp::generate_frame_tag(csrc, cname, cmarginwidth, cmarginheight, cscrolling, 
                                        cnoresize, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(csrc, cname, cmarginwidth, cmarginheight, cscrolling, cnoresize, cattributes);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<FRAMESET>tag which define a frameset section.
 * @details This procedure generates the<FRAMESET>tag which define a frameset section.
 *  * Parameters:
 *  * @param CROWS (in) VARCHAR2: The value for theROWSattribute.
 *  * @param CCOLS (in) VARCHAR2: The value for theCOLSattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_framesetopen(PG_FUNCTION_ARGS)
{
    char *crows = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *ccols = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 2);
 
    char *tag = htp::generate_frameset_tag(crows, ccols, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(crows, ccols, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  *  * @param SFILESLIST (out) VARCHAR2: TODO: Описание параметра SFILESLIST (Возвращается через результат)
 *  * @param NCOMPRESS (out) BINARY_INTEGER: TODO: Описание параметра NCOMPRESS (Возвращается через результат)
 *  *  *  * @return record: Композитный тип (varchar2 binary_integer), содержащий OUT/INOUT параметры.
 *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_get_download_files_list(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.get_download_files_list еще не реализована.")));
 
    PG_RETURN_NULL();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  *  * @param IROWS (out) NUMBER: TODO: Описание параметра IROWS (Возвращается через результат)
 *  *  *  * @return record: Композитный тип (), содержащий OUT/INOUT параметры.
 *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_get_line(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.get_line еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param IROWS (in/out) NUMBER: TODO: Описание параметра IROWS
 *  *  * @param THEPAGE (out) PL/SQL TABLE: TODO: Описание параметра THEPAGE (Возвращается через результат)
 *  * @param IROWS (in/out) NUMBER: TODO: Описание параметра IROWS (Возвращается через результат)
 *  *  *  * @return record: Композитный тип (pl/sql table number), содержащий OUT/INOUT параметры.
 *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_get_page(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.get_page еще не реализована.")));
 
    PG_RETURN_NULL();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param IROWS (in/out) NUMBER: TODO: Описание параметра IROWS
 *  * @param CHARSET (in) VARCHAR2: TODO: Описание параметра CHARSET
 *  *  * @param THEPAGE (out) PL/SQL TABLE: TODO: Описание параметра THEPAGE (Возвращается через результат)
 *  * @param IROWS (in/out) NUMBER: TODO: Описание параметра IROWS (Возвращается через результат)
 *  *  *  * @return record: Композитный тип (pl/sql table number), содержащий OUT/INOUT параметры.
 *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_get_page_charset_convert(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.get_page_charset_convert еще не реализована.")));
 
    PG_RETURN_NULL();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param IROWS (in/out) NUMBER: TODO: Описание параметра IROWS
 *  *  * @param THEPAGE (out) PL/SQL TABLE: TODO: Описание параметра THEPAGE (Возвращается через результат)
 *  * @param IROWS (in/out) NUMBER: TODO: Описание параметра IROWS (Возвращается через результат)
 *  *  *  * @return record: Композитный тип (pl/sql table number), содержащий OUT/INOUT параметры.
 *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_get_page_raw(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.get_page_raw еще не реализована.")));
 
    PG_RETURN_NULL();
}
 
/**
 * @brief This procedure generates opening heading tags(<H1>to<H6>)and their corresponding closing tags (</H1>to</H6>).
 * @details This procedure generates opening heading tags(<H1>to<H6>)and their corresponding closing tags (</H1>to</H6>).
 *  * Parameters:
 *  * @param NSIZE (in) NUMBER: The the heading level. This is an integer between 1 and 6.
 *  * @param CHEADER (in) VARCHAR2: The text to display in the heading.
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CNOWRAP (in) VARCHAR2: The value for theNOWRAPattribute.
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_header(PG_FUNCTION_ARGS)
{
    int32 clevel = 0;
    bool  clevel_is_set = false;
    char *cheader = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracleFull);
    char *calign = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *cnowrap = htp::get_string_argument(fcinfo, 3);
    char *cclear = htp::get_string_argument(fcinfo, 4, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 5, htp::StringEscapeLtGtChars);
 
    Numeric clevel_num = PG_ARGISNULL(0) ? NULL : PG_GETARG_NUMERIC(0);
    if(clevel_num){
        clevel = DatumGetInt32(DirectFunctionCall1(numeric_int4, NumericGetDatum(clevel_num)));
        clevel_is_set = true;
    }
 
    char *tag = htp::generate_header_tag(clevel, clevel_is_set, cheader, calign, cnowrap, 
                                         cclear, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cheader, calign, cnowrap, cclear, cattributes);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<HR>tag, which generates a line in the HTML document.
 * @details This procedure generates the<HR>tag, which generates a line in the HTML document.
 *  * Parameters:
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CSRC (in) VARCHAR2: The value for theSRCattribute which specifies a custom image as the source of the line.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_hr(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.hr еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param CTITLE (in) VARCHAR2: TODO: Описание параметра CTITLE
 *  * @param NSIZE (in) NUMBER: TODO: Описание параметра NSIZE
 *  * @param CALIGN (in) VARCHAR2: TODO: Описание параметра CALIGN
 *  * @param CNOWRAP (in) VARCHAR2: TODO: Описание параметра CNOWRAP
 *  * @param CCLEAR (in) VARCHAR2: TODO: Описание параметра CCLEAR
 *  * @param CATTRIBUTES (in) VARCHAR2: TODO: Описание параметра CATTRIBUTES
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_htitle(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.htitle еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<IMG>tag which directs the browser to load an image onto the HTML page.
 * @details This procedure generates the<IMG>tag which directs the browser to load an image onto the HTML page.
 *  * Parameters:
 *  * @param CURL (in) VARCHAR2: The value for the SRC attribute.
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CALT (in) VARCHAR2: The value for theALTattribute which specifies alternative text to display if the browser does not support images.
 *  * @param CISMAP (in) VARCHAR2: If the value for this parameter is notNULL, theISMAPattribute is added to the tag. The attribute indicates that the image is an imagemap.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_img(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.img еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the <IMG> tag, which directs the browser to load an image onto the HTML page.
 * @details This procedure generates the <IMG> tag, which directs the browser to load an image onto the HTML page.
 *  * Parameters:
 *  * @param CURL (in) VARCHAR2: The value for the SRC attribute.
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CALT (in) VARCHAR2: The value for theALTattribute which specifies alternative text to display if the browser does not support images.
 *  * @param CISMAP (in) VARCHAR2: If the value for this parameter is notNULL, theISMAPattribute is added to the tag. The attribute indicates that the image is an imagemap.
 *  * @param CUSEMAP (in) VARCHAR2: The value for theUSEMAPattribute which specifies a client-side image map.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_img2(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.img2 еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure creates a single entry field with a prompting text, such as "enter value," then sends that value to the URL of the page or program.
 * @details This procedure creates a single entry field with a prompting text, such as "enter value," then sends that value to the URL of the page or program.
 *  * Parameters:
 *  * @param CPROMPT (in) VARCHAR2: The value for thePROMPTattribute.
 *  * @param CURL (in) VARCHAR2: The value for theHREFattribute.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_isindex(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.isindex еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<I>and</I>tags which direct the browser to render the text in italics.
 * @details This procedure generates the<I>and</I>tags which direct the browser to render the text in italics.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to be rendered in italics.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_italic(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.italic еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<KBD>and</KBD>tags which direct the browser to render the text in monospace font.
 * @details This procedure generates the<KBD>and</KBD>tags which direct the browser to render the text in monospace font.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to be rendered in monospace.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_kbd(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.kbd еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the <KBD> and </KBD> tags, which direct the browser to render the text in monospace font.
 * @details This procedure generates the <KBD> and </KBD> tags, which direct the browser to render the text in monospace font.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to be rendered in monospace.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_keyboard(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.keyboard еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<HR>tag, which generates a line in the HTML document.
 * @details This procedure generates the<HR>tag, which generates a line in the HTML document.
 *  * Parameters:
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CSRC (in) VARCHAR2: The value for theSRCattribute which specifies a custom image as the source of the line.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_line(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.line еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<LINK>tag with theRELattribute which delineates the relationship described by the hypertext link from the anchor to the target. This is only used when theHREFattribute is present.
 * @details This procedure generates the<LINK>tag with theRELattribute which delineates the relationship described by the hypertext link from the anchor to the target. This is only used when theHREFattribute is present.
 *  * Parameters:
 *  * @param CREL (in) VARCHAR2: The value for theRELattribute.
 *  * @param CURL (in) VARCHAR2: The value for theURLattribute.
 *  * @param CTITLE (in) VARCHAR2: The value for theTITLEattribute.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_linkrel(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.linkrel еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<LINK>tag with theREVattribute which delineates the relationship described by the hypertext link from the target to the anchor.
 * @details This procedure generates the<LINK>tag with theREVattribute which delineates the relationship described by the hypertext link from the target to the anchor.
 *  * Parameters:
 *  * @param CREV (in) VARCHAR2: TODO: Описание параметра CREV
 *  * @param CURL (in) VARCHAR2: The value for theURLattribute.
 *  * @param CTITLE (in) VARCHAR2: The value for theTITLEattribute.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_linkrev(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.linkrev еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<LH>and</LH>tags which print an HTML tag at the beginning of the list.
 * @details This procedure generates the<LH>and</LH>tags which print an HTML tag at the beginning of the list.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to place between<LH>and</LH>.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_listheader(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.listheader еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<LI>tag, which indicates a list item.
 * @details This procedure generates the<LI>tag, which indicates a list item.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text for the list item.
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CDINGBAT (in) VARCHAR2: The value for theDINGBATattribute.
 *  * @param CSRC (in) VARCHAR2: The value for theSRCattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_listitem(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.listitem еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<A>tag with theHREFset to 'mailto' prepended to the mail address argument.
 * @details This procedure generates the<A>tag with theHREFset to 'mailto' prepended to the mail address argument.
 *  * Parameters:
 *  * @param CADDRESS (in) VARCHAR2: The email address of the recipient.
 *  * @param CTEXT (in) VARCHAR2: The clickable portion of the link.
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_mailto(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.mailto еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<MAP>tag which mark the beginning of a set of regions in a client-side image map.
 * @details This procedure generates the<MAP>tag which mark the beginning of a set of regions in a client-side image map.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_mapopen(PG_FUNCTION_ARGS)
{
    char *cname = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 1);
 
    char *tag = htp::generate_map_tag(cname, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cname, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<META>tag, which embeds meta-information about the document and also specifies values for HTTP headers. For example, you can specify the expiration date, keywords, and author name.
 * @details This procedure generates the<META>tag, which embeds meta-information about the document and also specifies values for HTTP headers. For example, you can specify the expiration date, keywords, and author name.
 *  * Parameters:
 *  * @param CHTTP_EQUIV (in) VARCHAR2: The value for theCHTTP_EQUIVattribute.
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CCONTENT (in) VARCHAR2: The value for theCONTENTattribute.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_meta(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.meta еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param CIDENTIFIER (in) VARCHAR2: TODO: Описание параметра CIDENTIFIER
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_nextid(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.nextid еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<BR>tag which begins a new line of text.
 * @details This procedure generates the<BR>tag which begins a new line of text.
 *  * Parameters:
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_nl(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.nl еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<NOBR>and</NOBR>tags which turn off line-breaking in a section of text.
 * @details This procedure generates the<NOBR>and</NOBR>tags which turn off line-breaking in a section of text.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text that is to be rendered on one line.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_nobr(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.nobr еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<OL>tag which marks the beginning of an ordered list. An ordered list presents a list of numbered items.
 * @details This procedure generates the<OL>tag which marks the beginning of an ordered list. An ordered list presents a list of numbered items.
 *  * Parameters:
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CWRAP (in) VARCHAR2: The value for theWRAPattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_olistopen(PG_FUNCTION_ARGS)
{
    char *cclear = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *cwrap = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 2);
 
    char *tag = htp::generate_olist_tag(cclear, cwrap, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cclear, cwrap, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param CBUF (in) VARCHAR2: TODO: Описание параметра CBUF
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_p_ovr1(PG_FUNCTION_ARGS)
{
    if (PG_ARGISNULL(0))
    {
        Owa::appendHtpText("", true);
        PG_RETURN_VOID();
    }
 
    text *str_t = PG_GETARG_TEXT_P(0);
    char *str = text_to_cstring(str_t);
 
    Owa::appendHtpText(str, true);
    pfree(str);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param DBUF (in) DATE: TODO: Описание параметра DBUF
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_p_ovr2(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.p еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param NBUF (in) NUMBER: TODO: Описание параметра NBUF
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_p_ovr3(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.p еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief You can use this procedure to add attributes to the<P>tag created by the PARA Procedure.
 * @details You can use this procedure to add attributes to the<P>tag created by the PARA Procedure.
 *  * Parameters:
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CNOWRAP (in) VARCHAR2: If the value for this parameter is notNULL, theNOWRAPattribute is added to the tag.
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_paragraph(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.paragraph еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<PARAM>tag which specifies parameter values for Java applets.
 * @details This procedure generates the<PARAM>tag which specifies parameter values for Java applets.
 *  * Parameters:
 *  * @param CNAME (in) VARCHAR2: The value for theNAMEattribute.
 *  * @param CVALUE (in) VARCHAR2: The value for theVALUEattribute.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_param(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.param еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<PLAINTEXT>and</PLAINTEXT>tags which direct the browser to render the text they surround in fixed-width type.
 * @details This procedure generates the<PLAINTEXT>and</PLAINTEXT>tags which direct the browser to render the text they surround in fixed-width type.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to be rendered in fixed-width font.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_plaintext(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.plaintext еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<PRE>tag which marks the beginning of a section of preformatted text in the body of the HTML page.
 * @details This procedure generates the<PRE>tag which marks the beginning of a section of preformatted text in the body of the HTML page.
 *  * Parameters:
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CWIDTH (in) VARCHAR2: The value for theWIDTHattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_preopen(PG_FUNCTION_ARGS)
{
    char *cclear = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *cwidth = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 2);
 
    char *tag = htp::generate_pre_tag(cclear, cwidth, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cclear, cwidth, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief These procedures generate the specified parameter as a string terminated with the\nnewline character.
 * @details These procedures generate the specified parameter as a string terminated with the\nnewline character.
 *  * Parameters:
 *  * @param CBUF (in) VARCHAR2: The string to generate terminated by a newline.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_print_ovr1(PG_FUNCTION_ARGS)
{
    text *str_t = PG_GETARG_TEXT_P(0);
    char *str = text_to_cstring(str_t);
    html_buffer.append(str);
    html_buffer.push_back('\n');
 
    pfree(str);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief These procedures generate the specified parameter as a string terminated with the\nnewline character.
 * @details These procedures generate the specified parameter as a string terminated with the\nnewline character.
 *  * Parameters:
 *  * @param DBUF (in) DATE: The string to generate terminated by a newline.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_print_ovr2(PG_FUNCTION_ARGS)
{
    Datum date = PG_GETARG_DATUM(0);
    char *date_str = DatumGetCString(DirectFunctionCall1(date_out, date));
 
    html_buffer.append(date_str);
    html_buffer.push_back('\n');
 
    pfree(date_str);
    PG_RETURN_VOID();
}
 
/**
 * @brief These procedures generate the specified parameter as a string terminated with the\nnewline character.
 * @details These procedures generate the specified parameter as a string terminated with the\nnewline character.
 *  * Parameters:
 *  * @param NBUF (in) NUMBER: The string to generate terminated by a newline.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_print_ovr3(PG_FUNCTION_ARGS)
{
    Datum num = PG_GETARG_DATUM(0);
    char *num_str = DatumGetCString(DirectFunctionCall1(numeric_out, num));
 
    html_buffer.append(num_str);
    html_buffer.push_back('\n');
 
    pfree(num_str);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates a string and replaces certain characters with a corresponding escape sequence.
 * @details This procedure generates a string and replaces certain characters with a corresponding escape sequence.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The string where to perform character substitution.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_prints(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.prints еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param CBUF (in) VARCHAR2: TODO: Описание параметра CBUF
 *  * @param NLINE (in) NUMBER: TODO: Описание параметра NLINE
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_print_header(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.print_header еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief These procedures generate the specified parameter as a string.
 * @details These procedures generate the specified parameter as a string.
 *  * Parameters:
 *  * @param CBUF (in) VARCHAR2: The string to generate (not terminated by a newline).
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_prn_ovr1(PG_FUNCTION_ARGS)
{
    text *str_t = PG_GETARG_TEXT_P(0);
    char *str = text_to_cstring(str_t);
    Owa::appendHtpText(str, false);
    html_buffer.append(str);
 
    pfree(str);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief These procedures generate the specified parameter as a string.
 * @details These procedures generate the specified parameter as a string.
 *  * Parameters:
 *  * @param DBUF (in) DATE: The string to generate (not terminated by a newline).
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_prn_ovr2(PG_FUNCTION_ARGS)
{
    Datum date = PG_GETARG_DATUM(0);
    char *date_str = DatumGetCString(DirectFunctionCall1(date_out, date));
 
    html_buffer.append(date_str);
 
    pfree(date_str);
    PG_RETURN_VOID();
}
 
/**
 * @brief These procedures generate the specified parameter as a string.
 * @details These procedures generate the specified parameter as a string.
 *  * Parameters:
 *  * @param NBUF (in) NUMBER: The string to generate (not terminated by a newline).
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_prn_ovr3(PG_FUNCTION_ARGS)
{
    Datum num = PG_GETARG_DATUM(0);
    char *num_str = DatumGetCString(DirectFunctionCall1(numeric_out, num));
 
    html_buffer.append(num_str);
 
    pfree(num_str);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates a string and replaces certain characters with the corresponding escape sequence.
 * @details This procedure generates a string and replaces certain characters with the corresponding escape sequence.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The string where to perform character substitution.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_ps(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.ps еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param BBUF (in) RAW: TODO: Описание параметра BBUF
 *  * @param BUFLEN (in) BINARY_INTEGER: TODO: Описание параметра BUFLEN
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_putraw(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.putraw еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<S>and</S>tags which direct the browser to render the text they surround in strikethrough type.
 * @details This procedure generates the<S>and</S>tags which direct the browser to render the text they surround in strikethrough type.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to be rendered in strikethrough type.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_s(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.s еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<SAMP>and</SAMP>tags which direct the browser to render the text they surround in monospace font or however "sample" is defined stylistically.
 * @details This procedure generates the<SAMP>and</SAMP>tags which direct the browser to render the text they surround in monospace font or however "sample" is defined stylistically.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to be rendered in monospace font.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_sample(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.sample еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<SCRIPT>and</SCRIPT>tags which contain a script written in languages such as JavaScript and VBscript.
 * @details This procedure generates the<SCRIPT>and</SCRIPT>tags which contain a script written in languages such as JavaScript and VBscript.
 *  * Parameters:
 *  * @param CSCRIPT (in) VARCHAR2: The text of the script. This is the text that makes up the script itself, not the name of a file containing the script.
 *  * @param CLANGUAGE (in) VARCHAR2: The language in which the script is written. If this parameter is omitted, the user's browser determines the scripting language.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_script(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.script еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param IANA_CHARSET (in) VARCHAR2: TODO: Описание параметра IANA_CHARSET
 *  * @param ORA_CHARSET (in) VARCHAR2: TODO: Описание параметра ORA_CHARSET
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_sethttpcharset(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.sethttpcharset еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief TODO: Добавить описание
 * @details TODO: Добавить детальное описание
 *  * Parameters:
 *  * @param TMODE (in) VARCHAR2: TODO: Описание параметра TMODE
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_set_transfer_mode(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.set_transfer_mode еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<SMALL>and</SMALL>tags, which direct the browser to render the text they surround using a small font.
 * @details This procedure generates the<SMALL>and</SMALL>tags, which direct the browser to render the text they surround using a small font.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to be rendered in small font.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_small(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.small еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<STRIKE>and</STRIKE>tags which direct the browser to render the text they surround in strikethrough type.
 * @details This procedure generates the<STRIKE>and</STRIKE>tags which direct the browser to render the text they surround in strikethrough type.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to be rendered in strikethrough type.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_strike(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.strike еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<STRONG>and</STRONG>tags which direct the browser to render the text they surround in bold, or however "strong" is defined.
 * @details This procedure generates the<STRONG>and</STRONG>tags which direct the browser to render the text they surround in bold, or however "strong" is defined.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to be emphasized.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_strong(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.strong еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<STYLE>and</STYLE>tags which include a style sheet in a Web page.
 * @details This procedure generates the<STYLE>and</STYLE>tags which include a style sheet in a Web page.
 *  * Parameters:
 *  * @param CSTYLE (in) VARCHAR2: The the style information to include.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_style(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.style еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<SUB>and</SUB>tags which direct the browser to render the text they surround as subscript.
 * @details This procedure generates the<SUB>and</SUB>tags which direct the browser to render the text they surround as subscript.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to render in subscript.
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_sub(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.sub еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<SUP>and</SUP>tags which direct the browser to render the text they surround as superscript.
 * @details This procedure generates the<SUP>and</SUP>tags which direct the browser to render the text they surround as superscript.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to render in superscript.
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_sup(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.sup еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<CAPTION>and</CAPTION>tags which place a caption in an HTML table.
 * @details This procedure generates the<CAPTION>and</CAPTION>tags which place a caption in an HTML table.
 *  * Parameters:
 *  * @param CCAPTION (in) VARCHAR2: TODO: Описание параметра CCAPTION
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_tablecaption(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.tablecaption еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<TD>and</TD>tags which insert data into a cell of an HTML table.
 * @details This procedure generates the<TD>and</TD>tags which insert data into a cell of an HTML table.
 *  * Parameters:
 *  * @param CVALUE (in) VARCHAR2: The data for the cell in the table.
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CDP (in) VARCHAR2: The value for theDPattribute.
 *  * @param CNOWRAP (in) VARCHAR2: If the value of this parameter is notNULL, theNOWRAPattribute is added to the tag.
 *  * @param CROWSPAN (in) VARCHAR2: TODO: Описание параметра CROWSPAN
 *  * @param CCOLSPAN (in) VARCHAR2: The value for theCOLSPANattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_tabledata(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.tabledata еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<TH>and</TH>tags which insert a header cell in an HTML table.
 * @details This procedure generates the<TH>and</TH>tags which insert a header cell in an HTML table.
 *  * Parameters:
 *  * @param CVALUE (in) VARCHAR2: The data for the cell in the table.
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CDP (in) VARCHAR2: The value for theDPattribute.
 *  * @param CNOWRAP (in) VARCHAR2: If the value of this parameter is notNULL, theNOWRAPattribute is added to the tag.
 *  * @param CROWSPAN (in) VARCHAR2: TODO: Описание параметра CROWSPAN
 *  * @param CCOLSPAN (in) VARCHAR2: The value for theCOLSPANattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_tableheader(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.tableheader еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the <TABLE> tag which marks the beginning of an HTML table.
 * @details This procedure generates the <TABLE> tag which marks the beginning of an HTML table.
 *  * Parameters:
 *  * @param CBORDER (in) VARCHAR2: TODO: Описание параметра CBORDER
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CNOWRAP (in) VARCHAR2: If the value of this parameter is notNULL, theNOWRAPattribute is added to the tag.
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_tableopen(PG_FUNCTION_ARGS)
{
    char *cborder = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *calign = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cnowrap = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *cclear = htp::get_string_argument(fcinfo, 3, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 4);
 
    char *tag = htp::generate_table_tag(cborder, calign, cnowrap, cclear, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cborder, calign, cnowrap, cclear, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<TR>tag which marks the beginning of a new row in an HTML table.
 * @details This procedure generates the<TR>tag which marks the beginning of a new row in an HTML table.
 *  * Parameters:
 *  * @param CALIGN (in) VARCHAR2: The value for theALIGNattribute.
 *  * @param CVALIGN (in) VARCHAR2: The value for theVALIGNattribute.
 *  * @param CDP (in) VARCHAR2: The value for theDPattribute.
 *  * @param CNOWRAP (in) VARCHAR2: If the value of this parameter is notNULL, theNOWRAPattribute is added to the tag.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_tablerowopen(PG_FUNCTION_ARGS)
{
    char *calign = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *cvalign = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cdp = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *cnowrap = htp::get_string_argument(fcinfo, 3, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 4);
 
    char *tag = htp::generate_tablerow_tag(calign, cvalign, cdp, cnowrap, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(calign, cvalign, cdp, cnowrap, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<TT>and</TT>tags which direct the browser to render the text they surround in a fixed width typewriter font, for example, the courier font.
 * @details This procedure generates the<TT>and</TT>tags which direct the browser to render the text they surround in a fixed width typewriter font, for example, the courier font.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to render in a fixed width typewriter font.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_teletype(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.teletype еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<TITLE>and</TITLE>tags which specify the text to display in the titlebar of the browser window.
 * @details This procedure generates the<TITLE>and</TITLE>tags which specify the text to display in the titlebar of the browser window.
 *  * Parameters:
 *  * @param CTITLE (in) VARCHAR2: The text to display in the titlebar of the browser window.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_title(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.title еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<UL>tag which marks the beginning of an unordered list. An unordered list presents items with bullets.
 * @details This procedure generates the<UL>tag which marks the beginning of an unordered list. An unordered list presents items with bullets.
 *  * Parameters:
 *  * @param CCLEAR (in) VARCHAR2: The value for theCLEARattribute.
 *  * @param CWRAP (in) VARCHAR2: The value for theWRAPattribute.
 *  * @param CDINGBAT (in) VARCHAR2: The value for theDINGBATattribute.
 *  * @param CSRC (in) VARCHAR2: The value for theSRCattribute.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_ulistopen(PG_FUNCTION_ARGS)
{
    char *cclear = htp::get_string_argument(fcinfo, 0, htp::StringEscapeFormatOracle);
    char *cwrap = htp::get_string_argument(fcinfo, 1, htp::StringEscapeFormatOracle);
    char *cdingbat = htp::get_string_argument(fcinfo, 2, htp::StringEscapeFormatOracle);
    char *csrc = htp::get_string_argument(fcinfo, 3, htp::StringEscapeFormatOracle);
    char *cattributes = htp::get_string_argument(fcinfo, 4);
 
    char *tag = htp::generate_ulist_tag(cclear, cwrap, cdingbat, csrc, cattributes);
    htp::html_buffer_add(tag);
    htp::pfree_all(cclear, cwrap, cdingbat, csrc, cattributes, tag);
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<U>and</U>tags, which direct the browser to render the text they surround with an underline.
 * @details This procedure generates the<U>and</U>tags, which direct the browser to render the text they surround with an underline.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to render with an underline.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_underline(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.underline еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
/**
 * @brief This procedure generates the<VAR>and</VAR>tags which direct the browser to render the text they surround in italics or however "variable" is defined stylistically.
 * @details This procedure generates the<VAR>and</VAR>tags which direct the browser to render the text they surround in italics or however "variable" is defined stylistically.
 *  * Parameters:
 *  * @param CTEXT (in) VARCHAR2: The text to render in italics.
 *  * @param CATTRIBUTES (in) VARCHAR2: The other attributes to be included as-is in the tag.
 *  *  *  *  *
 * @see https://docs.oracle.com/en/database/oracle/oracle-database/23/arpls/HTP.html
 */
Datum htp_variable(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.variable еще не реализована.")));
 
    PG_RETURN_VOID();
}
 
// NO ARGUMENTS
Datum htp_appletclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</applet>");
    PG_RETURN_VOID();
}
 
Datum htp_blockquoteclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</blockquote>");
    PG_RETURN_VOID();
}
 
Datum htp_bodyclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</body>");
    PG_RETURN_VOID();
}
 
Datum htp_centerclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</center>");
    PG_RETURN_VOID();
}
 
Datum htp_centeropen(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("<center>");
    PG_RETURN_VOID();
}
 
Datum htp_dirlistclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</dir>");
    PG_RETURN_VOID();
}
 
Datum htp_dirlistopen(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("<dir>");
    PG_RETURN_VOID();
}
 
Datum htp_dlistclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</dl>");
    PG_RETURN_VOID();
}
 
Datum htp_flush(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.flush еще не реализована.")));
    PG_RETURN_VOID();
}
 
Datum htp_fontclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</font>");
    PG_RETURN_VOID();
}
 
Datum htp_formclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</form>");
    PG_RETURN_VOID();
}
 
Datum htp_formselectclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</select>");
    PG_RETURN_VOID();
}
 
Datum htp_formtextareaclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</textarea>");
    PG_RETURN_VOID();
}
 
Datum htp_framesetclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</frameset>");
    PG_RETURN_VOID();
}
 
Datum htp_headclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</head>");
    PG_RETURN_VOID();
}
 
Datum htp_headopen(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("<head>");
    PG_RETURN_VOID();
}
 
Datum htp_htmlclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</html>");
    PG_RETURN_VOID();
}
 
Datum htp_htmlopen(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("<html>");
    PG_RETURN_VOID();
}
 
Datum htp_init(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.init еще не реализована.")));
    PG_RETURN_VOID();
}
 
Datum htp_listingclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</listing>");
    PG_RETURN_VOID();
}
 
Datum htp_listingopen(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("<listing>");
    PG_RETURN_VOID();
}
 
Datum htp_mapclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</map>");
    PG_RETURN_VOID();
}
 
Datum htp_menulistclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</menu>");
    PG_RETURN_VOID();
}
 
Datum htp_menulistopen(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("<menu>");
    PG_RETURN_VOID();
}
 
Datum htp_noframesclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</noframes>");
    PG_RETURN_VOID();
}
 
Datum htp_noframesopen(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("<noframes>");
    PG_RETURN_VOID();
}
 
Datum htp_olistclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</ol>");
    PG_RETURN_VOID();
}
 
Datum htp_para(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.para еще не реализована.")));
    PG_RETURN_VOID();
}
 
Datum htp_preclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</pre>");
    PG_RETURN_VOID();
}
 
Datum htp_reset_get_page(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.reset_get_page еще не реализована.")));
    PG_RETURN_VOID();
}
 
Datum htp_showpage(PG_FUNCTION_ARGS)
{
    DirectFunctionCall1(owa_util_showpage_utils, Int32GetDatum(0));
    PG_RETURN_VOID();
}
 
Datum htp_tableclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</table>");
    PG_RETURN_VOID();
}
 
Datum htp_tablerowclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</tr>");
    PG_RETURN_VOID();
}
 
Datum htp_ulistclose(PG_FUNCTION_ARGS)
{
    htp::html_buffer_add("</ul>");
    PG_RETURN_VOID();
}
 
Datum htp_wbr(PG_FUNCTION_ARGS)
{
    ereport(NOTICE, (errmsg("Функция htp.wbr еще не реализована.")));
    PG_RETURN_VOID();
}
 
 
} // extern "C"