-
Notifications
You must be signed in to change notification settings - Fork 1
/
HTMLparser.go
executable file
·824 lines (709 loc) · 22.3 KB
/
HTMLparser.go
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
package goxml
/*
#cgo pkg-config: libxml-2.0
#include <libxml/HTMLparser.h>
*/
import "C"
import "unsafe"
import "fmt"
/*
Element value not recognized getter for elType:unsigned int goType:uint
*/
type HtmlEntityDesc struct {
handler C.htmlEntityDescPtr
}
/*
func (this *HtmlEntityDesc) GetValue() uint {
return int(this.handler.value)
}
*/
func (this *HtmlEntityDesc) GetName() string {
if this.handler.name == nil {
return ""
}
return C.GoString((*C.char)(unsafe.Pointer(this.handler.name)))
}
func (this *HtmlEntityDesc) GetDesc() string {
if this.handler.desc == nil {
return ""
}
return C.GoString((*C.char)(unsafe.Pointer(this.handler.desc)))
}
/*
Element subelts has not registered type char**
Element subelts not recognized getter for elType:char** goType:char**
Element attrs_opt has not registered type char**
Element attrs_opt not recognized getter for elType:char** goType:char**
Element attrs_depr has not registered type char**
Element attrs_depr not recognized getter for elType:char** goType:char**
Element attrs_req has not registered type char**
Element attrs_req not recognized getter for elType:char** goType:char**
*/
type HtmlElemDesc struct {
handler C.htmlElemDescPtr
}
func (this *HtmlElemDesc) GetName() string {
if this.handler.name == nil {
return ""
}
return C.GoString((*C.char)(unsafe.Pointer(this.handler.name)))
}
func (this *HtmlElemDesc) GetStartTag() byte {
return byte(this.handler.startTag)
}
func (this *HtmlElemDesc) GetEndTag() byte {
return byte(this.handler.endTag)
}
func (this *HtmlElemDesc) GetSaveEndTag() byte {
return byte(this.handler.saveEndTag)
}
func (this *HtmlElemDesc) GetEmpty() byte {
return byte(this.handler.empty)
}
func (this *HtmlElemDesc) GetDepr() byte {
return byte(this.handler.depr)
}
func (this *HtmlElemDesc) GetDtd() byte {
return byte(this.handler.dtd)
}
func (this *HtmlElemDesc) GetIsinline() byte {
return byte(this.handler.isinline)
}
func (this *HtmlElemDesc) GetDesc() string {
if this.handler.desc == nil {
return ""
}
return C.GoString((*C.char)(unsafe.Pointer(this.handler.desc)))
}
/*
func (this *HtmlElemDesc) GetSubelts() char** {
return int(this.handler.subelts)
}
*/
func (this *HtmlElemDesc) GetDefaultsubelt() string {
if this.handler.defaultsubelt == nil {
return ""
}
return C.GoString((*C.char)(unsafe.Pointer(this.handler.defaultsubelt)))
}
/*
func (this *HtmlElemDesc) GetAttrs_opt() char** {
return int(this.handler.attrs_opt)
}
*/
/*
func (this *HtmlElemDesc) GetAttrs_depr() char** {
return int(this.handler.attrs_depr)
}
*/
/*
func (this *HtmlElemDesc) GetAttrs_req() char** {
return int(this.handler.attrs_req)
}
*/
/*
Function: htmlIsScriptAttribute
ReturnType: int
Args: (('name', ['xmlChar', '*'], None),)
*/
func HtmlIsScriptAttribute(name string) int {
c_name := (*C.xmlChar)(unsafe.Pointer(C.CString(name)))
defer C.free(unsafe.Pointer(c_name))
c_ret := C.htmlIsScriptAttribute(c_name)
return int(c_ret)
}
/*
Function: htmlHandleOmittedElem
ReturnType: int
Args: (('val', ['int'], None),)
*/
func HtmlHandleOmittedElem(val int) int {
c_val := C.int(val)
c_ret := C.htmlHandleOmittedElem(c_val)
return int(c_ret)
}
/*
Function: htmlCtxtReadDoc
ReturnType: htmlDocPtr
Args: (('ctxt', ['xmlParserCtxtPtr'], None), ('cur', ['xmlChar', '*'], None), ('URL', ['char', '*'], None), ('encoding', ['char', '*'], None), ('options', ['int'], None))
*/
func HtmlCtxtReadDoc(ctxt *XmlParserCtxt, cur string, URL string, encoding string, options int) (g_ret *XmlDoc, err error) {
var c_ctxt C.xmlParserCtxtPtr = nil
if ctxt != nil {
c_ctxt = (C.xmlParserCtxtPtr)(ctxt.handler)
}
c_cur := (*C.xmlChar)(unsafe.Pointer(C.CString(cur)))
defer C.free(unsafe.Pointer(c_cur))
c_URL := (*C.char)(unsafe.Pointer(C.CString(URL)))
defer C.free(unsafe.Pointer(c_URL))
c_encoding := (*C.char)(unsafe.Pointer(C.CString(encoding)))
defer C.free(unsafe.Pointer(c_encoding))
c_options := C.int(options)
c_ret := C.htmlCtxtReadDoc(c_ctxt, c_cur, c_URL, c_encoding, c_options)
if c_ret == nil {
err = fmt.Errorf("htmlCtxtReadDoc errnox %d", c_ret)
} else {
g_ret = &XmlDoc{handler: (C.xmlDocPtr)(c_ret)}
}
return
}
/*
Function: htmlParseFile
ReturnType: htmlDocPtr
Args: (('filename', ['char', '*'], None), ('encoding', ['char', '*'], None))
*/
func HtmlParseFile(filename string, encoding string) *XmlDoc {
c_filename := (*C.char)(unsafe.Pointer(C.CString(filename)))
defer C.free(unsafe.Pointer(c_filename))
c_encoding := (*C.char)(unsafe.Pointer(C.CString(encoding)))
defer C.free(unsafe.Pointer(c_encoding))
c_ret := C.htmlParseFile(c_filename, c_encoding)
if c_ret == nil {
return nil
}
return &XmlDoc{handler: (C.xmlDocPtr)(c_ret)}
}
/*
Function: htmlReadFd
ReturnType: htmlDocPtr
Args: (('fd', ['int'], None), ('URL', ['char', '*'], None), ('encoding', ['char', '*'], None), ('options', ['int'], None))
*/
func HtmlReadFd(fd int, URL string, encoding string, options int) *XmlDoc {
c_fd := C.int(fd)
c_URL := (*C.char)(unsafe.Pointer(C.CString(URL)))
defer C.free(unsafe.Pointer(c_URL))
c_encoding := (*C.char)(unsafe.Pointer(C.CString(encoding)))
defer C.free(unsafe.Pointer(c_encoding))
c_options := C.int(options)
c_ret := C.htmlReadFd(c_fd, c_URL, c_encoding, c_options)
if c_ret == nil {
return nil
}
return &XmlDoc{handler: (C.xmlDocPtr)(c_ret)}
}
/*
Function: htmlAutoCloseTag
ReturnType: int
Args: (('doc', ['htmlDocPtr'], None), ('name', ['xmlChar', '*'], None), ('elem', ['htmlNodePtr'], None))
*/
func HtmlAutoCloseTag(doc *XmlDoc, name string, elem *XmlNode) int {
var c_doc C.htmlDocPtr = nil
if doc != nil {
c_doc = (C.htmlDocPtr)(doc.handler)
}
c_name := (*C.xmlChar)(unsafe.Pointer(C.CString(name)))
defer C.free(unsafe.Pointer(c_name))
var c_elem C.htmlNodePtr = nil
if elem != nil {
c_elem = (C.htmlNodePtr)(elem.handler)
}
c_ret := C.htmlAutoCloseTag(c_doc, c_name, c_elem)
return int(c_ret)
}
/*
Function: htmlAttrAllowed
ReturnType: htmlStatus
Args: ((None, ['htmlElemDesc', '*'], None), (None, ['xmlChar', '*'], None), (None, ['int'], None))
*/
func HtmlAttrAllowed(arg1 *HtmlElemDesc, arg2 string, arg3 int) int {
var c_arg1 C.htmlElemDescPtr = nil
if arg1 != nil {
c_arg1 = (C.htmlElemDescPtr)(arg1.handler)
}
c_arg2 := (*C.xmlChar)(unsafe.Pointer(C.CString(arg2)))
defer C.free(unsafe.Pointer(c_arg2))
c_arg3 := C.int(arg3)
c_ret := C.htmlAttrAllowed(c_arg1, c_arg2, c_arg3)
return int(c_ret)
}
/*
Function: htmlTagLookup
ReturnType: htmlElemDesc*
Args: (('tag', ['xmlChar', '*'], None),)
*/
func HtmlTagLookup(tag string) *HtmlElemDesc {
c_tag := (*C.xmlChar)(unsafe.Pointer(C.CString(tag)))
defer C.free(unsafe.Pointer(c_tag))
c_ret := C.htmlTagLookup(c_tag)
if c_ret == nil {
return nil
}
return &HtmlElemDesc{handler: (C.htmlElemDescPtr)(c_ret)}
}
/*
Function: htmlCreateMemoryParserCtxt
ReturnType: htmlParserCtxtPtr
Args: (('buffer', ['char', '*'], None), ('size', ['int'], None))
*/
func HtmlCreateMemoryParserCtxt(buffer string) (g_ret *XmlParserCtxt, err error) {
c_buffer := (*C.char)(unsafe.Pointer(C.CString(buffer)))
defer C.free(unsafe.Pointer(c_buffer))
c_size := C.int(len(buffer) * 1)
c_ret := C.htmlCreateMemoryParserCtxt(c_buffer, c_size)
if c_ret == nil {
err = fmt.Errorf("htmlCreateMemoryParserCtxt errno %d", c_ret)
} else {
g_ret = &XmlParserCtxt{handler: (C.xmlParserCtxtPtr)(c_ret)}
}
return
}
/*
Function: htmlCtxtReset
ReturnType: void
Args: (('ctxt', ['htmlParserCtxtPtr'], None),)
*/
func HtmlCtxtReset(ctxt *XmlParserCtxt) {
var c_ctxt C.htmlParserCtxtPtr = nil
if ctxt != nil {
c_ctxt = (C.htmlParserCtxtPtr)(ctxt.handler)
}
C.htmlCtxtReset(c_ctxt)
}
/*
Function: htmlElementAllowedHere
ReturnType: int
Args: ((None, ['htmlElemDesc', '*'], None), (None, ['xmlChar', '*'], None))
*/
func HtmlElementAllowedHere(arg1 *HtmlElemDesc, arg2 string) int {
var c_arg1 C.htmlElemDescPtr = nil
if arg1 != nil {
c_arg1 = (C.htmlElemDescPtr)(arg1.handler)
}
c_arg2 := (*C.xmlChar)(unsafe.Pointer(C.CString(arg2)))
defer C.free(unsafe.Pointer(c_arg2))
c_ret := C.htmlElementAllowedHere(c_arg1, c_arg2)
return int(c_ret)
}
/*
Function: htmlCreatePushParserCtxt
ReturnType: htmlParserCtxtPtr
Args: (('sax', ['htmlSAXHandlerPtr'], None), ('user_data', ['void', '*'], None), ('chunk', ['char', '*'], None), ('size', ['int'], None), ('filename', ['char', '*'], None), ('enc', ['xmlCharEncoding'], None))
*/
func HtmlCreatePushParserCtxt(sax *XmlSAXHandler, chunk string, filename string, enc int) (g_ret *XmlParserCtxt, err error) {
var c_sax C.htmlSAXHandlerPtr = nil
if sax != nil {
c_sax = (C.htmlSAXHandlerPtr)(sax.handler)
}
c_chunk := (*C.char)(unsafe.Pointer(C.CString(chunk)))
defer C.free(unsafe.Pointer(c_chunk))
c_filename := (*C.char)(unsafe.Pointer(C.CString(filename)))
defer C.free(unsafe.Pointer(c_filename))
c_enc := C.xmlCharEncoding(enc)
c_size := C.int(len(chunk) * 1)
c_ret := C.htmlCreatePushParserCtxt(c_sax, nil, c_chunk, c_size, c_filename, c_enc)
if c_ret == nil {
err = fmt.Errorf("htmlCreatePushParserCtxt errno %d", c_ret)
} else {
g_ret = &XmlParserCtxt{handler: (C.xmlParserCtxtPtr)(c_ret)}
}
return
}
/*
Function: htmlReadMemory
ReturnType: htmlDocPtr
Args: (('buffer', ['char', '*'], None), ('size', ['int'], None), ('URL', ['char', '*'], None), ('encoding', ['char', '*'], None), ('options', ['int'], None))
*/
func HtmlReadMemory(buffer string, size int, URL string, encoding string, options int) *XmlDoc {
c_buffer := (*C.char)(unsafe.Pointer(C.CString(buffer)))
defer C.free(unsafe.Pointer(c_buffer))
c_size := C.int(size)
c_URL := (*C.char)(unsafe.Pointer(C.CString(URL)))
defer C.free(unsafe.Pointer(c_URL))
c_encoding := (*C.char)(unsafe.Pointer(C.CString(encoding)))
defer C.free(unsafe.Pointer(c_encoding))
c_options := C.int(options)
c_ret := C.htmlReadMemory(c_buffer, c_size, c_URL, c_encoding, c_options)
if c_ret == nil {
return nil
}
return &XmlDoc{handler: (C.xmlDocPtr)(c_ret)}
}
/*
Function: htmlIsAutoClosed
ReturnType: int
Args: (('doc', ['htmlDocPtr'], None), ('elem', ['htmlNodePtr'], None))
*/
func HtmlIsAutoClosed(doc *XmlDoc, elem *XmlNode) int {
var c_doc C.htmlDocPtr = nil
if doc != nil {
c_doc = (C.htmlDocPtr)(doc.handler)
}
var c_elem C.htmlNodePtr = nil
if elem != nil {
c_elem = (C.htmlNodePtr)(elem.handler)
}
c_ret := C.htmlIsAutoClosed(c_doc, c_elem)
return int(c_ret)
}
/*
Function: htmlParseCharRef
ReturnType: int
Args: (('ctxt', ['htmlParserCtxtPtr'], None),)
*/
func HtmlParseCharRef(ctxt *XmlParserCtxt) int {
var c_ctxt C.htmlParserCtxtPtr = nil
if ctxt != nil {
c_ctxt = (C.htmlParserCtxtPtr)(ctxt.handler)
}
c_ret := C.htmlParseCharRef(c_ctxt)
return int(c_ret)
}
/*
Function: htmlReadDoc
ReturnType: htmlDocPtr
Args: (('cur', ['xmlChar', '*'], None), ('URL', ['char', '*'], None), ('encoding', ['char', '*'], None), ('options', ['int'], None))
*/
func HtmlReadDoc(cur string, URL string, encoding string, options int) *XmlDoc {
c_cur := (*C.xmlChar)(unsafe.Pointer(C.CString(cur)))
defer C.free(unsafe.Pointer(c_cur))
c_URL := (*C.char)(unsafe.Pointer(C.CString(URL)))
defer C.free(unsafe.Pointer(c_URL))
c_encoding := (*C.char)(unsafe.Pointer(C.CString(encoding)))
defer C.free(unsafe.Pointer(c_encoding))
c_options := C.int(options)
c_ret := C.htmlReadDoc(c_cur, c_URL, c_encoding, c_options)
if c_ret == nil {
return nil
}
return &XmlDoc{handler: (C.xmlDocPtr)(c_ret)}
}
/*
Function: htmlParseDocument
ReturnType: int
Args: (('ctxt', ['htmlParserCtxtPtr'], None),)
*/
func HtmlParseDocument(ctxt *XmlParserCtxt) int {
var c_ctxt C.htmlParserCtxtPtr = nil
if ctxt != nil {
c_ctxt = (C.htmlParserCtxtPtr)(ctxt.handler)
}
c_ret := C.htmlParseDocument(c_ctxt)
return int(c_ret)
}
/*
Function: htmlNodeStatus
ReturnType: htmlStatus
Args: ((None, ['htmlNodePtr'], None), (None, ['int'], None))
*/
func HtmlNodeStatus(arg1 *XmlNode, arg2 int) int {
var c_arg1 C.htmlNodePtr = nil
if arg1 != nil {
c_arg1 = (C.htmlNodePtr)(arg1.handler)
}
c_arg2 := C.int(arg2)
c_ret := C.htmlNodeStatus(c_arg1, c_arg2)
return int(c_ret)
}
/*
Function: htmlParseChunk
ReturnType: int
Args: (('ctxt', ['htmlParserCtxtPtr'], None), ('chunk', ['char', '*'], None), ('size', ['int'], None), ('terminate', ['int'], None))
*/
func HtmlParseChunk(ctxt *XmlParserCtxt, chunk string, size int, terminate int) int {
var c_ctxt C.htmlParserCtxtPtr = nil
if ctxt != nil {
c_ctxt = (C.htmlParserCtxtPtr)(ctxt.handler)
}
c_chunk := (*C.char)(unsafe.Pointer(C.CString(chunk)))
defer C.free(unsafe.Pointer(c_chunk))
c_size := C.int(size)
c_terminate := C.int(terminate)
c_ret := C.htmlParseChunk(c_ctxt, c_chunk, c_size, c_terminate)
return int(c_ret)
}
/*
Function: htmlSAXParseFile
ReturnType: htmlDocPtr
Args: (('filename', ['char', '*'], None), ('encoding', ['char', '*'], None), ('sax', ['htmlSAXHandlerPtr'], None), ('userData', ['void', '*'], None))
*/
func HtmlSAXParseFile(filename string, encoding string, sax *XmlSAXHandler) *XmlDoc {
c_filename := (*C.char)(unsafe.Pointer(C.CString(filename)))
defer C.free(unsafe.Pointer(c_filename))
c_encoding := (*C.char)(unsafe.Pointer(C.CString(encoding)))
defer C.free(unsafe.Pointer(c_encoding))
var c_sax C.htmlSAXHandlerPtr = nil
if sax != nil {
c_sax = (C.htmlSAXHandlerPtr)(sax.handler)
}
c_ret := C.htmlSAXParseFile(c_filename, c_encoding, c_sax, nil)
if c_ret == nil {
return nil
}
return &XmlDoc{handler: (C.xmlDocPtr)(c_ret)}
}
/*
Function: htmlElementStatusHere
ReturnType: htmlStatus
Args: ((None, ['htmlElemDesc', '*'], None), (None, ['htmlElemDesc', '*'], None))
*/
func HtmlElementStatusHere(arg1 *HtmlElemDesc, arg2 *HtmlElemDesc) int {
var c_arg1 C.htmlElemDescPtr = nil
if arg1 != nil {
c_arg1 = (C.htmlElemDescPtr)(arg1.handler)
}
var c_arg2 C.htmlElemDescPtr = nil
if arg2 != nil {
c_arg2 = (C.htmlElemDescPtr)(arg2.handler)
}
c_ret := C.htmlElementStatusHere(c_arg1, c_arg2)
return int(c_ret)
}
/*
Function: htmlEntityValueLookup
ReturnType: htmlEntityDesc*
Args: (('value', ['unsigned int'], None),)
*/
func HtmlEntityValueLookup(value uint) *HtmlEntityDesc {
c_value := C.uint(value)
c_ret := C.htmlEntityValueLookup(c_value)
if c_ret == nil {
return nil
}
return &HtmlEntityDesc{handler: (C.htmlEntityDescPtr)(c_ret)}
}
/*
Function: htmlParseElement
ReturnType: void
Args: (('ctxt', ['htmlParserCtxtPtr'], None),)
*/
func HtmlParseElement(ctxt *XmlParserCtxt) {
var c_ctxt C.htmlParserCtxtPtr = nil
if ctxt != nil {
c_ctxt = (C.htmlParserCtxtPtr)(ctxt.handler)
}
C.htmlParseElement(c_ctxt)
}
/*
Function: UTF8ToHtml
ReturnType: int
Args: (('out', ['unsigned char', '*'], None), ('outlen', ['int', '*'], None), ('in', ['unsigned char', '*'], None), ('inlen', ['int', '*'], None))
*/
func UTF8ToHtml(in string) (g_out string, err error) {
c_in := (*C.uchar)(unsafe.Pointer(C.CString(in)))
defer C.free(unsafe.Pointer(c_in))
c_out := (*C.uchar)(C.calloc((C.size_t)(len(in)*3+1), 1))
defer C.free(unsafe.Pointer(c_out))
c0_outlen := C.int(len(in) * 3)
c_outlen := &c0_outlen
c0_inlen := C.int(len(in) * 1)
c_inlen := &c0_inlen
c_ret := C.UTF8ToHtml(c_out, c_outlen, c_in, c_inlen)
if c_ret != 0 {
err = fmt.Errorf("UTF8ToHtml errno %d", c_ret)
} else {
if c_out == nil {
g_out = ""
} else {
g_out = C.GoString((*C.char)(unsafe.Pointer(c_out)))
}
}
return
}
/*
Function: htmlEntityLookup
ReturnType: htmlEntityDesc*
Args: (('name', ['xmlChar', '*'], None),)
*/
func HtmlEntityLookup(name string) *HtmlEntityDesc {
c_name := (*C.xmlChar)(unsafe.Pointer(C.CString(name)))
defer C.free(unsafe.Pointer(c_name))
c_ret := C.htmlEntityLookup(c_name)
if c_ret == nil {
return nil
}
return &HtmlEntityDesc{handler: (C.htmlEntityDescPtr)(c_ret)}
}
/*
Function: htmlFreeParserCtxt
ReturnType: void
Args: (('ctxt', ['htmlParserCtxtPtr'], None),)
*/
func HtmlFreeParserCtxt(ctxt *XmlParserCtxt) {
var c_ctxt C.htmlParserCtxtPtr = nil
if ctxt != nil {
c_ctxt = (C.htmlParserCtxtPtr)(ctxt.handler)
}
C.htmlFreeParserCtxt(c_ctxt)
}
/*
Function: htmlCtxtReadMemory
ReturnType: htmlDocPtr
Args: (('ctxt', ['xmlParserCtxtPtr'], None), ('buffer', ['char', '*'], None), ('size', ['int'], None), ('URL', ['char', '*'], None), ('encoding', ['char', '*'], None), ('options', ['int'], None))
*/
func HtmlCtxtReadMemory(ctxt *XmlParserCtxt, buffer string, URL string, encoding string, options int) (g_ret *XmlDoc, err error) {
var c_ctxt C.xmlParserCtxtPtr = nil
if ctxt != nil {
c_ctxt = (C.xmlParserCtxtPtr)(ctxt.handler)
}
c_buffer := (*C.char)(unsafe.Pointer(C.CString(buffer)))
defer C.free(unsafe.Pointer(c_buffer))
c_URL := (*C.char)(unsafe.Pointer(C.CString(URL)))
defer C.free(unsafe.Pointer(c_URL))
c_encoding := (*C.char)(unsafe.Pointer(C.CString(encoding)))
defer C.free(unsafe.Pointer(c_encoding))
c_options := C.int(options)
c_size := C.int(len(buffer) * 1)
c_ret := C.htmlCtxtReadMemory(c_ctxt, c_buffer, c_size, c_URL, c_encoding, c_options)
if c_ret == nil {
err = fmt.Errorf("htmlCtxtReadMemory errno %d", c_ret)
} else {
g_ret = &XmlDoc{handler: (C.xmlDocPtr)(c_ret)}
}
return
}
/*
Function: htmlParseDoc
ReturnType: htmlDocPtr
Args: (('cur', ['xmlChar', '*'], None), ('encoding', ['char', '*'], None))
*/
func HtmlParseDoc(cur string, encoding string) *XmlDoc {
c_cur := (*C.xmlChar)(unsafe.Pointer(C.CString(cur)))
defer C.free(unsafe.Pointer(c_cur))
c_encoding := (*C.char)(unsafe.Pointer(C.CString(encoding)))
defer C.free(unsafe.Pointer(c_encoding))
c_ret := C.htmlParseDoc(c_cur, c_encoding)
if c_ret == nil {
return nil
}
return &XmlDoc{handler: (C.xmlDocPtr)(c_ret)}
}
/*
Function: htmlReadFile
ReturnType: htmlDocPtr
Args: (('URL', ['char', '*'], None), ('encoding', ['char', '*'], None), ('options', ['int'], None))
*/
func HtmlReadFile(URL string, encoding string, options int) (g_ret *XmlDoc, err error) {
c_URL := (*C.char)(unsafe.Pointer(C.CString(URL)))
defer C.free(unsafe.Pointer(c_URL))
c_encoding := (*C.char)(unsafe.Pointer(C.CString(encoding)))
defer C.free(unsafe.Pointer(c_encoding))
c_options := C.int(options)
c_ret := C.htmlReadFile(c_URL, c_encoding, c_options)
if c_ret == nil {
err = fmt.Errorf("htmlReadFile errno %d", c_ret)
} else {
g_ret = &XmlDoc{handler: (C.xmlDocPtr)(c_ret)}
}
return
}
/*
Function: htmlCtxtReadFile
ReturnType: htmlDocPtr
Args: (('ctxt', ['xmlParserCtxtPtr'], None), ('filename', ['char', '*'], None), ('encoding', ['char', '*'], None), ('options', ['int'], None))
*/
func HtmlCtxtReadFile(ctxt *XmlParserCtxt, filename string, encoding string, options int) (g_ret *XmlDoc, err error) {
var c_ctxt C.xmlParserCtxtPtr = nil
if ctxt != nil {
c_ctxt = (C.xmlParserCtxtPtr)(ctxt.handler)
}
c_filename := (*C.char)(unsafe.Pointer(C.CString(filename)))
defer C.free(unsafe.Pointer(c_filename))
c_encoding := (*C.char)(unsafe.Pointer(C.CString(encoding)))
defer C.free(unsafe.Pointer(c_encoding))
c_options := C.int(options)
c_ret := C.htmlCtxtReadFile(c_ctxt, c_filename, c_encoding, c_options)
if c_ret == nil {
err = fmt.Errorf("htmlCtxtReadFile errno %d", c_ret)
} else {
g_ret = &XmlDoc{handler: (C.xmlDocPtr)(c_ret)}
}
return
}
/*
Function: htmlEncodeEntities
ReturnType: int
Args: (('out', ['unsigned char', '*'], None), ('outlen', ['int', '*'], None), ('in', ['unsigned char', '*'], None), ('inlen', ['int', '*'], None), ('quoteChar', ['int'], None))
*/
func HtmlEncodeEntities(in string, quoteChar int) (g_out string, err error) {
c_in := (*C.uchar)(unsafe.Pointer(C.CString(in)))
defer C.free(unsafe.Pointer(c_in))
c_quoteChar := C.int(quoteChar)
c_out := (*C.uchar)(C.calloc((C.size_t)(len(in)*3+1), 1))
defer C.free(unsafe.Pointer(c_out))
c0_outlen := C.int(len(in) * 1)
c_outlen := &c0_outlen
c0_inlen := C.int(len(in) * 1)
c_inlen := &c0_inlen
c_ret := C.htmlEncodeEntities(c_out, c_outlen, c_in, c_inlen, c_quoteChar)
if c_ret != 0 {
err = fmt.Errorf("htmlEncodeEntities errno %d", c_ret)
} else {
if c_out == nil {
g_out = ""
} else {
g_out = C.GoString((*C.char)(unsafe.Pointer(c_out)))
}
}
return
}
/*
Function: htmlNewParserCtxt
ReturnType: htmlParserCtxtPtr
Args: ((None, ['void'], None),)
*/
func HtmlNewParserCtxt() *XmlParserCtxt {
c_ret := C.htmlNewParserCtxt()
if c_ret == nil {
return nil
}
return &XmlParserCtxt{handler: (C.xmlParserCtxtPtr)(c_ret)}
}
/*
Function: htmlSAXParseDoc
ReturnType: htmlDocPtr
Args: (('cur', ['xmlChar', '*'], None), ('encoding', ['char', '*'], None), ('sax', ['htmlSAXHandlerPtr'], None), ('userData', ['void', '*'], None))
*/
/*
Warn: userData void* Not defined
Warn: userData void* No converter to C(go2cConverter)
func HtmlSAXParseDoc(cur string,encoding string,sax *XmlSAXHandler,userData void*) *XmlDoc {
c_cur:= (*C.xmlChar)(unsafe.Pointer(C.CString(cur)))
defer C.free(unsafe.Pointer(c_cur))
c_encoding:= (*C.char)(unsafe.Pointer(C.CString(encoding)))
defer C.free(unsafe.Pointer(c_encoding))
var c_sax C.htmlSAXHandlerPtr=nil
if sax !=nil { c_sax = (C.htmlSAXHandlerPtr)(sax.handler) }
userData
c_ret := C.htmlSAXParseDoc(c_cur,c_encoding,c_sax,c_userData)
if c_ret == nil {return nil}
return &XmlDoc{handler:(C.xmlDocPtr)(c_ret)}
}
*/
/*
Function: htmlCtxtUseOptions
ReturnType: int
Args: (('ctxt', ['htmlParserCtxtPtr'], None), ('options', ['int'], None))
*/
func HtmlCtxtUseOptions(ctxt *XmlParserCtxt, options int) int {
var c_ctxt C.htmlParserCtxtPtr = nil
if ctxt != nil {
c_ctxt = (C.htmlParserCtxtPtr)(ctxt.handler)
}
c_options := C.int(options)
c_ret := C.htmlCtxtUseOptions(c_ctxt, c_options)
return int(c_ret)
}
/*
Function: htmlCtxtReadFd
ReturnType: htmlDocPtr
Args: (('ctxt', ['xmlParserCtxtPtr'], None), ('fd', ['int'], None), ('URL', ['char', '*'], None), ('encoding', ['char', '*'], None), ('options', ['int'], None))
*/
func HtmlCtxtReadFd(ctxt *XmlParserCtxt, fd int, URL string, encoding string, options int) (g_ret *XmlDoc, err error) {
var c_ctxt C.xmlParserCtxtPtr = nil
if ctxt != nil {
c_ctxt = (C.xmlParserCtxtPtr)(ctxt.handler)
}
c_fd := C.int(fd)
c_URL := (*C.char)(unsafe.Pointer(C.CString(URL)))
defer C.free(unsafe.Pointer(c_URL))
c_encoding := (*C.char)(unsafe.Pointer(C.CString(encoding)))
defer C.free(unsafe.Pointer(c_encoding))
c_options := C.int(options)
c_ret := C.htmlCtxtReadFd(c_ctxt, c_fd, c_URL, c_encoding, c_options)
if c_ret == nil {
err = fmt.Errorf("htmlCtxtReadFd errno %d", c_ret)
} else {
g_ret = &XmlDoc{handler: (C.xmlDocPtr)(c_ret)}
}
return
}