-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvarnishapi.py
1963 lines (1618 loc) · 63.9 KB
/
varnishapi.py
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
# coding: utf-8
# Copyright (c) 2013-2017 Shohei Tanaka(@xcir)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# https://github.com/xcir/python-varnishapi
# v60.24
from ctypes import *
import getopt
import time
import signal
from threading import Thread
class VSC_level_desc(Structure):
_fields_ = [
("verbosity", c_uint), # unsigned verbosity;
("label", c_char_p), # const char *label; /* label */
("sdesc", c_char_p), # const char *sdesc; /* short description */
("ldesc", c_char_p), # const char *ldesc; /* long description */
]
class VSC_level_desc20(Structure):
_fields_ = [
("name", c_char_p), # const char *name; /* name */
("label", c_char_p), # const char *label; /* label */
("sdesc", c_char_p), # const char *sdesc; /* short description */
("ldesc", c_char_p), # const char *ldesc; /* long description */
]
class VSC_type_desc(Structure):
_fields_ = [
("label", c_char_p), # const char *label; /* label */
("sdesc", c_char_p), # const char *sdesc; /* short description */
("ldesc", c_char_p), # const char *ldesc; /* long description */
]
class VSM_fantom(Structure):
_fields_ = [
("chunk", c_void_p), # struct VSM_chunk *chunk;
("b", c_void_p), # void *b; /* first byte of payload */
("e", c_void_p), # void *e; /* first byte past payload */
("priv", c_void_p), # uintptr_t priv; /* VSM private */
("_class", c_char * 8), # char class[VSM_MARKER_LEN];
("type", c_char * 8), # char type[VSM_MARKER_LEN];
("ident", c_char * 128), # char ident[VSM_IDENT_LEN];
]
class VSC_section(Structure):
_fields_ = [
("type", c_char_p), # const char *type;
("ident", c_char_p), # const char *ident;
("desc", POINTER(VSC_type_desc)), # const struct VSC_type_desc *desc;
("fantom", POINTER(VSM_fantom)), # struct VSM_fantom *fantom;
]
class VSC_desc(Structure):
_fields_ = [
("name", c_char_p), # const char *name; /* field name */
("fmt", c_char_p), # const char *fmt; /* field format ("uint64_t") */
("flag", c_int), # int flag; /* 'c' = counter, 'g' = gauge */
("sdesc", c_char_p), # const char *sdesc; /* short description */
("ldesc", c_char_p), # const char *ldesc; /* long description */
("level", POINTER(VSC_level_desc)), # const struct VSC_level_desc *level;
]
class VSC_point(Structure):
_fields_ = [
("desc", POINTER(VSC_desc)), # const struct VSC_desc *desc; /* point description */
("ptr", POINTER(c_ulonglong)), # const volatile void *ptr; /* field value */
("section", POINTER(VSC_section)), # const struct VSC_section *section;
]
class VSC_point20(Structure):
_fields_ = [
("ptr", POINTER(c_ulonglong)), #const volatile uint64_t *ptr; /* field value */
("name", c_char_p), #const char *name; /* field name */
("ctype", c_char_p), #const char *ctype; /* C-type */
("semantics", c_int), #int semantics; /* semantics */
("format", c_int), #int format; /* display format */
("level", POINTER(VSC_level_desc20)), #const struct VSC_level_desc *level; /* verbosity level */
("sdesc", c_char_p), #const char *sdesc; /* short description */
("ldesc", c_char_p), #const char *ldesc; /* long description */
("priv", c_void_p), #void *priv; /* return val from VSC_new_f */
]
# typedef int VSC_iter_f(void *priv, const struct VSC_point *const pt);
VSC_iter_f = CFUNCTYPE(
c_int,
c_void_p,
POINTER(VSC_point)
)
# typedef int VSC_iter_f(void *priv, const struct VSC_point *const pt);
VSC_iter_f20 = CFUNCTYPE(
c_int,
c_void_p,
POINTER(VSC_point20)
)
# typedef void VSL_tagfind_f(int tag, void *priv);
VSL_tagfind_f = CFUNCTYPE(
c_int,
c_void_p
)
#typedef void *VSC_new_f(void *priv, const struct VSC_point *const pt);
VSC_new_f = CFUNCTYPE(
c_void_p,
c_void_p,
POINTER(VSC_point20)
)
#typedef void VSC_destroy_f(void *priv, const struct VSC_point *const pt);
VSC_destroy_f = CFUNCTYPE(
None,
c_void_p,
POINTER(VSC_point20)
)
#
class VSLC_ptr(Structure):
_fields_ = [
("ptr", POINTER(c_uint32)), # const uint32_t *ptr; /* Record pointer */
("priv", c_uint), # unsigned priv;
]
class VSL_cursor(Structure):
_fields_ = [
("rec", VSLC_ptr), # struct VSLC_ptr rec;
("priv_tbl", c_void_p), # const void *priv_tbl;
("priv_data", c_void_p), # void *priv_data;
]
class VSL_transaction(Structure):
_fields_ = [
("level", c_uint), # unsigned level;
("vxid", c_int32), # int32_t vxid;
("vxid_parent", c_int32), # int32_t vxid_parent;
("type", c_int), # enum VSL_transaction_e type;
("reason", c_int), # enum VSL_reason_e reason;
("c", POINTER(VSL_cursor)), # struct VSL_cursor *c;
]
class VTAILQ_HEAD(Structure):
_fields_ = [
("vtqh_first", c_void_p), # struct type *vtqh_first; /* first element */
("vtqh_last", POINTER(c_void_p)), # struct type **vtqh_last; /* addr of last next element */
]
class vbitmap(Structure):
_fields_ = [
("bits", c_void_p), # VBITMAP_TYPE *bits;
("nbits", c_uint), # unsigned nbits;
]
class vsb(Structure):
_fields_ = [
("magic", c_uint), # unsigned magic;
("s_buf", c_char_p), # char *s_buf; /* storage buffer */
("s_error", c_int), # int s_error; /* current error code */
("s_size", c_long), # ssize_t s_size; /* size of storage buffer */
("s_len", c_long), # ssize_t s_len; /* current length of string */
("s_flags", c_int), # int s_flags; /* flags */
]
class VSL_data(Structure):
_fields_ = [
("magic", c_uint), # unsigned magic;
("diag", POINTER(vsb)), # struct vsb *diag;
("flags", c_uint), # unsigned flags;
("vbm_select", POINTER(vbitmap)), # struct vbitmap *vbm_select;
("vbm_supress", POINTER(vbitmap)), # struct vbitmap *vbm_supress;
("vslf_select", VTAILQ_HEAD), # vslf_list vslf_select;
("vslf_suppress", VTAILQ_HEAD), # vslf_list vslf_suppress;
("b_opt", c_int), # int b_opt;
("c_opt", c_int), # int c_opt;
("C_opt", c_int), # int C_opt;
("L_opt", c_int), # int L_opt;
("T_opt", c_double), # double T_opt;
("v_opt", c_int), # int v_opt;
]
class timespec(Structure):
_fields_ = [
("tv_sec" , c_long), # time_t tv_sec; /* seconds */
("tv_nsec", c_long), # long tv_nsec; /* nanoseconds */
]
class timeval (Structure):
_fields_ = [
("tv_sec" , c_long), # time_t tv_sec;
("tv_usec", c_long), # suseconds_t tv_usec
]
class vopt_list (Structure):
_fields_ = [
("option" , c_char_p), #const char *option;
("synopsis" , c_char_p), #const char *synopsis;
("desc" , c_char_p), #const char *desc;
("ldesc" , c_char_p), #const char *ldesc;
]
class vopt_spec (Structure):
_fields_ = [
("vopt_list" , POINTER(vopt_list)), #const struct vopt_list *vopt_list;
("vopt_list_n" , c_uint), #unsigned vopt_list_n;
("vopt_optstring" , c_char_p), #const char *vopt_optstring;
("vopt_synopsis" , c_char_p), #const char *vopt_synopsis;
("vopt_usage" , POINTER(c_char_p)), #const char **vopt_usage;
]
class VarnishAPIDefine40:
def __init__(self):
self.VSL_COPT_TAIL = (1 << 0)
self.VSL_COPT_BATCH = (1 << 1)
self.VSL_COPT_TAILSTOP = (1 << 2)
self.SLT_F_UNSAFE = (1 << 1)
self.SLT_F_BINARY = (1 << 2)
self.VSM_MGT_RUNNING = (1 << 1)
self.VSM_MGT_CHANGED = (1 << 2)
self.VSM_MGT_RESTARTED =(1 << 3)
self.VSM_WRK_RUNNING = (1 << 9)
self.VSM_WRK_CHANGED = (1 << 10)
self.VSM_WRK_RESTARTED = (1 << 11)
'''
//////////////////////////////
enum VSL_transaction_e {
VSL_t_unknown,
VSL_t_sess,
VSL_t_req,
VSL_t_bereq,
VSL_t_raw,
VSL_t__MAX,
};
'''
self.VSL_t_unknown = 0
self.VSL_t_sess = 1
self.VSL_t_req = 2
self.VSL_t_bereq = 3
self.VSL_t_raw = 4
self.VSL_t__MAX = 5
'''
//////////////////////////////
enum VSL_reason_e {
VSL_r_unknown,
VSL_r_http_1,
VSL_r_rxreq,
VSL_r_esi,
VSL_r_restart,
VSL_r_pass,
VSL_r_fetch,
VSL_r_bgfetch,
VSL_r_pipe,
VSL_r__MAX,
};
'''
self.VSL_r_unknown = 0
self.VSL_r_http_1 = 1
self.VSL_r_rxreq = 2
self.VSL_r_esi = 3
self.VSL_r_restart = 4
self.VSL_r_pass = 5
self.VSL_r_fetch = 6
self.VSL_r_bgfetch = 7
self.VSL_r_pipe = 8
self.VSL_r__MAX = 9
'''
//////////////////////////////
enum VSM_valid_e {
VSM_invalid,
VSM_valid,
VSM_similar,
};
'''
self.VSM_invalid = 0
self.VSM_valid = 1
self.VSM_similar = 2
'''
//////////////////////////////
enum vas_e {
VAS_WRONG,
VAS_MISSING,
VAS_ASSERT,
VAS_INCOMPLETE,
VAS_VCL,
};
'''
self.VAS_WRONG = 0
self.VAS_MISSING = 1
self.VAS_ASSERT = 2
self.VAS_INCOMPLETE = 3
self.VAS_VCL = 4
#typedef void VUT_sighandler_f(int);
VUT_sighandler_f = CFUNCTYPE(
None,
c_int
)
# typedef int VSLQ_dispatch_f(struct VSL_data *vsl, struct VSL_transaction
# * const trans[], void *priv);
VSLQ_dispatch_f = CFUNCTYPE(
c_int,
POINTER(VSL_data),
POINTER(POINTER(VSL_transaction)),
c_void_p
)
# typedef int VUT_cb_f(struct VUT *);
VUT_cb_f = CFUNCTYPE(
c_int,
c_void_p #POINTER(VUT)
)
class VUT (Structure):
_fields_ = [
("magic" , c_uint), #unsigned magic;
("progname" , c_char_p), #const char *progname;
("d_opt" , c_int), #int d_opt;
("D_opt" , c_int), #int D_opt;
("g_arg" , c_int), #int g_arg;
("k_arg" , c_int), #int k_arg;
("n_arg" , c_char_p), #char *n_arg;
("P_arg" , c_char_p), #char *P_arg;
("q_arg" , c_char_p), #char *q_arg;
("r_arg" , c_char_p), #char *r_arg;
("t_arg" , c_char_p), #char *t_arg;
("vsl" , c_void_p), #struct VSL_data *vsl;
("vsm" , c_void_p), #struct vsm *vsm;
("vslq" , c_void_p), #struct VSLQ *vslq;
("sighup" , c_int), #int sighup;
("sigint" , c_int), #int sigint;
("sigusr1" , c_int), #int sigusr1;
("idle_f" , VUT_cb_f), #VUT_cb_f *idle_f;
("sighup_f" , VUT_cb_f), #VUT_cb_f *sighup_f;
("error_f" , c_void_p), #VUT_error_f *error_f;
("dispatch_f" , VSLQ_dispatch_f), #VSLQ_dispatch_f *dispatch_f;
("dispatch_priv" , c_void_p) #void *dispatch_priv;
]
class VUT_22 (Structure):
_fields_ = [
("magic" , c_uint), #unsigned magic;
("progname" , c_char_p), #const char *progname;
("d_opt" , c_int), #int d_opt;
("D_opt" , c_int), #int D_opt;
("g_arg" , c_int), #int g_arg;
("k_arg" , c_int), #int k_arg;
("n_arg" , c_char_p), #char *n_arg;
("P_arg" , c_char_p), #char *P_arg;
("q_arg" , c_char_p), #char *q_arg;
("r_arg" , c_char_p), #char *r_arg;
("t_arg" , c_char_p), #char *t_arg;
("vsl" , c_void_p), #struct VSL_data *vsl;
("vsm" , c_void_p), #struct vsm *vsm;
("vslq" , c_void_p), #struct VSLQ *vslq;
("last_sighup" , c_int), #sig_atomic_t last_sighup;
("last_sigusr1" , c_int), #sig_atomic_t last_sigusr1;
("idle_f" , VUT_cb_f), #VUT_cb_f *idle_f;
("sighup_f" , VUT_cb_f), #VUT_cb_f *sighup_f;
("error_f" , c_void_p), #VUT_error_f *error_f;
("dispatch_f" , VSLQ_dispatch_f), #VSLQ_dispatch_f *dispatch_f;
("dispatch_priv" , c_void_p) #void *dispatch_priv;
]
class LIBVARNISHAPI10:
def __init__(self, lc):
self.lc = lc
def run(self, lib):
if hasattr(lib, "VTIM_format"):
self.lc.apiversion = 1.6
elif hasattr(lib, "VUT_Init"):
self.lc.apiversion = 1.5
elif hasattr(lib, "VSM_IsOpen"):
self.lc.apiversion = 1.4
else:
self.lc.apiversion = 1.3
#LIBVARNISHAPI_1.0
#VSM_New;
self.lc.VSM_New = lib.VSM_New
self.lc.VSM_New.restype = c_void_p
#VSM_Diag; (undefined symbol at 4.0/4.1/5.0)
#VSM_n_Arg;
self.lc.VSM_n_Arg = lib.VSM_n_Arg
self.lc.VSM_n_Arg.restype = c_int
self.lc.VSM_n_Arg.argtypes = [c_void_p, c_char_p]
#VSM_Name;
self.lc.VSM_Name = lib.VSM_Name
self.lc.VSM_Name.restype = c_char_p
self.lc.VSM_Name.argtypes = [c_void_p]
#VSM_Delete;
self.lc.VSM_Delete = lib.VSM_Delete
self.lc.VSM_Delete.argtypes = [c_void_p]
#VSM_Open;
self.lc.VSM_Open = lib.VSM_Open
self.lc.VSM_Open.restype = c_int
self.lc.VSM_Open.argtypes = [c_void_p]
#VSM_ReOpen; (undefined symbol at 4.0/4.1/5.0)
#VSM_Seq; (undefined symbol at 4.0/4.1/5.0)
#VSM_Head; (undefined symbol at 4.0/4.1/5.0)
#VSM_Find_Chunk; (undefined symbol at 4.0/4.1/5.0)
#VSM_Close;
self.lc.VSM_Close = lib.VSM_Close
self.lc.VSM_Close.argtypes = [c_void_p]
#VSM_iter0; (undefined symbol at 4.0/4.1/5.0)
#VSM_intern; (undefined symbol at 4.0/4.1/5.0)
#
#VSC_Setup; (undefined symbol at 4.0/4.1/5.0)
#VSC_Arg;
self.lc.VSC_Arg = lib.VSC_Arg
self.lc.VSC_Arg.restype = c_int
self.lc.VSC_Arg.argtypes = [c_void_p, c_int, c_char_p]
#VSC_Open; (undefined symbol at 4.0/4.1/5.0)
#VSC_Main;
self.lc.VSC_Main = lib.VSC_Main
self.lc.VSC_Main.restype = c_void_p
self.lc.VSC_Main.argtypes = [c_void_p, c_void_p]
#VSC_Iter;
self.lc.VSC_Iter = lib.VSC_Iter
self.lc.VSC_Iter.argtypes = [c_void_p, c_void_p, VSC_iter_f, c_void_p]
#
#VSL_Setup; (private func at 5.0)
#VSL_Open; (undefined symbol at 4.0/4.1/5.0)
#VSL_Arg;
self.lc.VSL_Arg = lib.VSL_Arg
self.lc.VSL_Arg.restype = c_int
self.lc.VSL_Arg.argtypes = [c_void_p, c_int, c_char_p]
#VSL_H_Print; (undefined symbol at 4.0/4.1/5.0)
#VSL_Select; (undefined symbol at 4.0/4.1/5.0)
#VSL_NonBlocking; (undefined symbol at 4.0/4.1/5.0)
#VSL_Dispatch; (undefined symbol at 4.0/4.1/5.0)
#VSL_NextLog; (undefined symbol at 4.0/4.1/5.0)
#VSL_Matched; (undefined symbol at 4.0/4.1/5.0)
#
#VCLI_WriteResult;
#VCLI_ReadResult;
#VCLI_AuthResponse;
#
## Variables
#VSL_tags;
#LIBVARNISHAPI_1.1
# Functions:
#VSL_Name2Tag;
self.lc.VSL_Name2Tag = lib.VSL_Name2Tag
self.lc.VSL_Name2Tag.restype = c_int
self.lc.VSL_Name2Tag.argtypes = [c_char_p, c_int]
#LIBVARNISHAPI_1.2
# Functions:
#VSL_NextSLT; (undefined symbol at 4.0/4.1/5.0)
#VSM_Error;
self.lc.VSM_Error = lib.VSM_Error
self.lc.VSM_Error.restype = c_char_p
self.lc.VSM_Error.argtypes = [c_void_p]
#VSM_Get;
self.lc.VSM_Get = lib.VSM_Get
self.lc.VSM_Get.argtypes = [c_void_p, c_void_p, c_char_p, c_char_p, c_char_p]
#LIBVARNISHAPI_1.3
#VSM_Abandoned;
self.lc.VSM_Abandoned = lib.VSM_Abandoned
self.lc.VSM_Abandoned.argtypes = [c_void_p]
#VSM_ResetError;
self.lc.VSM_ResetError = lib.VSM_ResetError
self.lc.VSM_ResetError.argtypes = [c_void_p]
#VSM_StillValid;
self.lc.VSM_StillValid = lib.VSM_StillValid
self.lc.VSM_StillValid.argtypes = [c_void_p, c_void_p]
#VSC_Mgt;
self.lc.VSC_Mgt = lib.VSC_Mgt
self.lc.VSC_Mgt.restype = c_void_p
self.lc.VSC_Mgt.argtypes = [c_void_p, c_void_p]
#VSC_LevelDesc;
self.lc.VSC_LevelDesc = lib.VSC_LevelDesc
self.lc.VSC_LevelDesc.restype = c_void_p
self.lc.VSC_LevelDesc.argtypes = [c_uint]
#VSL_New;
self.lc.VSL_New = lib.VSL_New
self.lc.VSL_New.restype = c_void_p
#VSL_Delete;
self.lc.VSL_Delete = lib.VSL_Delete
self.lc.VSL_Delete.argtypes = [c_void_p]
#VSL_Error;
self.lc.VSL_Error = lib.VSL_Error
self.lc.VSL_Error.restype = c_char_p
self.lc.VSL_Error.argtypes = [c_void_p]
#VSL_ResetError;
self.lc.VSL_ResetError = lib.VSL_ResetError
self.lc.VSL_ResetError.argtypes = [c_void_p]
#VSL_CursorVSM;
self.lc.VSL_CursorVSM = lib.VSL_CursorVSM
self.lc.VSL_CursorVSM.restype = POINTER(VSL_cursor)
self.lc.VSL_CursorVSM.argtypes = [c_void_p, c_void_p, c_uint]
#VSL_CursorFile;
self.lc.VSL_CursorFile = lib.VSL_CursorFile
self.lc.VSL_CursorFile.restype = POINTER(VSL_cursor)
self.lc.VSL_CursorFile.argtypes = [c_void_p, c_char_p, c_uint]
#VSL_DeleteCursor;
self.lc.VSL_DeleteCursor = lib.VSL_DeleteCursor
self.lc.VSL_DeleteCursor.argtypes = [c_void_p]
#VSL_Next;
self.lc.VSL_Next = lib.VSL_Next
self.lc.VSL_Next.restype = c_int
self.lc.VSL_Next.argtypes = [POINTER(VSL_cursor)]
#VSL_Match;
self.lc.VSL_Match = lib.VSL_Match
self.lc.VSL_Match.restype = c_int
self.lc.VSL_Match.argtypes = [c_void_p, POINTER(VSL_cursor)]
#VSL_Print;
self.lc.VSL_Print = lib.VSL_Print
self.lc.VSL_Print.argtypes = [c_void_p, c_void_p, c_void_p]
#VSL_PrintTerse;
self.lc.VSL_PrintTerse = lib.VSL_PrintTerse
self.lc.VSL_PrintTerse.argtypes = [c_void_p, c_void_p, c_void_p]
#VSL_PrintAll;
self.lc.VSL_PrintAll = lib.VSL_PrintAll
self.lc.VSL_PrintAll.argtypes = [c_void_p, c_void_p, c_void_p]
#VSL_PrintTransactions;
self.lc.VSL_PrintTransactions = lib.VSL_PrintTransactions
self.lc.VSL_PrintTransactions.argtypes = [c_void_p, POINTER(POINTER(VSL_transaction)), c_void_p]
#VSL_WriteOpen;
self.lc.VSL_WriteOpen = lib.VSL_WriteOpen
self.lc.VSL_WriteOpen.restype = c_void_p
self.lc.VSL_WriteOpen.argtypes = [c_void_p, c_char_p, c_int, c_int]
#VSL_Write;
self.lc.VSL_Write = lib.VSL_Write
self.lc.VSL_Write.argtypes = [c_void_p, c_void_p, c_void_p]
#VSL_WriteAll;
self.lc.VSL_WriteAll = lib.VSL_WriteAll
self.lc.VSL_WriteAll.argtypes = [c_void_p, c_void_p, c_void_p]
#VSL_WriteTransactions;
self.lc.VSL_WriteTransactions = lib.VSL_WriteTransactions
self.lc.VSL_WriteTransactions.argtypes = [c_void_p, POINTER(POINTER(VSL_transaction)), c_void_p]
#VSLQ_New;
self.lc.VSLQ_New = lib.VSLQ_New
self.lc.VSLQ_New.restype = c_void_p
self.lc.VSLQ_New.argtypes = [c_void_p, POINTER(POINTER(VSL_cursor)), c_int, c_char_p]
#VSLQ_Delete;
self.lc.VSLQ_Delete = lib.VSLQ_Delete
self.lc.VSLQ_Delete.argtypes = [POINTER(c_void_p)]
#VSLQ_Dispatch;
self.lc.VSLQ_Dispatch = lib.VSLQ_Dispatch
self.lc.VSLQ_Dispatch.restype = c_int
self.lc.VSLQ_Dispatch.argtypes = [c_void_p, VSLQ_dispatch_f, c_void_p]
#VSLQ_Flush;
self.lc.VSLQ_Flush = lib.VSLQ_Flush
self.lc.VSLQ_Flush.restype = c_int
self.lc.VSLQ_Flush.argtypes = [c_void_p, VSLQ_dispatch_f, c_void_p]
#VSLQ_Name2Grouping;
self.lc.VSLQ_Name2Grouping = lib.VSLQ_Name2Grouping
self.lc.VSLQ_Name2Grouping.restype = c_int
self.lc.VSLQ_Name2Grouping.argtypes = [c_char_p, c_int]
#VSL_Glob2Tags;
self.lc.VSL_Glob2Tags = lib.VSL_Glob2Tags
self.lc.VSL_Glob2Tags.argtypes = [c_char_p, c_int, VSL_tagfind_f, c_void_p]
#VSL_List2Tags;
self.lc.VSL_List2Tags = lib.VSL_List2Tags
self.lc.VSL_List2Tags.argtypes = [c_char_p, c_int, VSL_tagfind_f, c_void_p]
#VSM_N_Arg;
self.lc.VSM_N_Arg = lib.VSM_N_Arg
self.lc.VSM_N_Arg.restype = c_int
self.lc.VSM_N_Arg.argtypes = [c_void_p, c_char_p]
#VSL_Check;
self.lc.VSL_Check = lib.VSL_Check
self.lc.VSL_Check.argtypes = [c_void_p, c_void_p]
#VSL_ResetCursor;
self.lc.VSL_ResetCursor = lib.VSL_ResetCursor
self.lc.VSL_ResetCursor.argtypes = [c_void_p]
## Variables:
#VSLQ_grouping;
#VSL_tagflags;
#LIBVARNISHAPI_1.4
if self.lc.apiversion < 1.4:
return
#VNUM;
#VSLQ_SetCursor;
self.lc.VSLQ_SetCursor = lib.VSLQ_SetCursor
self.lc.VSLQ_SetCursor.argtypes = [c_void_p, POINTER(c_void_p)]
#VSM_IsOpen;
self.lc.VSM_IsOpen = lib.VSM_IsOpen
self.lc.VSM_IsOpen.argtypes = [c_void_p]
#LIBVARNISHAPI_1.5
if self.lc.apiversion < 1.5:
return
#VUT_Error;
self.lc.VUT_Error = lib.VUT_Error
self.lc.VUT_Error.argtypes = [c_int, c_char_p]
#VUT_g_Arg;
self.lc.VUT_g_Arg = lib.VUT_g_Arg
self.lc.VUT_g_Arg.argtypes = [c_char_p]
#VUT_Arg;
self.lc.VUT_Arg = lib.VUT_Arg
self.lc.VUT_Arg.argtypes = [c_int, c_char_p]
#VUT_Setup;
self.lc.VUT_Setup = lib.VUT_Setup
#VUT_Init;
self.lc.VUT_Init = lib.VUT_Init
self.lc.VUT_Init.argtypes = [c_char_p]
#VUT_Fini;
self.lc.VUT_Fini = lib.VUT_Fini
#VUT_Main;
self.lc.VUT_Main = lib.VUT_Main
#VUT;
#VTIM_mono;
self.lc.VTIM_mono = lib.VTIM_mono
self.lc.VTIM_mono.restype = c_double
#VTIM_real;
self.lc.VTIM_real = lib.VTIM_real
self.lc.VTIM_real.restype = c_double
#VTIM_sleep;
self.lc.VTIM_sleep = lib.VTIM_sleep
self.lc.VTIM_sleep.argtypes = [c_double]
#VSB_new;
self.lc.VSB_new = lib.VSB_new
self.lc.VSB_new.restype = c_void_p
self.lc.VSB_new.argtypes = [c_void_p, c_char_p, c_int]
#VSB_destroy;
self.lc.VSB_destroy = lib.VSB_destroy
self.lc.VSB_destroy.argtypes = [POINTER(c_void_p)]
#VSB_error;
self.lc.VSB_error = lib.VSB_error
self.lc.VSB_error.argtypes = [c_void_p]
#VSB_cat;
self.lc.VSB_cat = lib.VSB_cat
self.lc.VSB_cat.argtypes = [c_void_p, c_char_p]
#VSB_putc;
self.lc.VSB_putc = lib.VSB_putc
self.lc.VSB_putc.argtypes = [c_void_p, c_int]
#VSB_printf;
self.lc.VSB_printf = lib.VSB_printf
self.lc.VSB_printf.argtypes = [c_void_p, c_char_p]
#VSB_clear;
self.lc.VSB_clear = lib.VSB_clear
self.lc.VSB_clear.argtypes = [c_void_p]
#VSB_finish;
self.lc.VSB_finish = lib.VSB_finish
self.lc.VSB_finish.argtypes = [c_void_p]
#VSB_len;
self.lc.VSB_len = lib.VSB_len
self.lc.VSB_len.restype = c_long
self.lc.VSB_len.argtypes = [c_void_p]
#VSB_data;
self.lc.VSB_data = lib.VSB_data
self.lc.VSB_data.restype = c_char_p
self.lc.VSB_data.argtypes = [c_void_p]
#VAS_Fail;
self.lc.VAS_Fail = lib.VAS_Fail
self.lc.VAS_Fail.argtypes = [c_char_p, c_char_p, c_int, c_char_p, c_int]
#VCS_Message;
self.lc.VCS_Message = lib.VCS_Message
self.lc.VCS_Message.argtypes = [c_char_p]
#LIBVARNISHAPI_1.6
if self.lc.apiversion < 1.6:
return
#VTIM_format
self.lc.VTIM_format = lib.VTIM_format
self.lc.VTIM_format.argtypes = [c_double, c_char_p]
#VSB_bcat
self.lc.VSB_bcat = lib.VSB_bcat
self.lc.VSB_bcat.restype = c_int
self.lc.VSB_bcat.argtypes = [c_void_p, c_void_p, c_long]
#VSB_quote
self.lc.VSB_quote = lib.VSB_quote
self.lc.VSB_quote.argtypes = [c_void_p, c_void_p, c_int, c_int]
#VSB_vprintf
self.lc.VSB_vprintf = lib.VSB_vprintf
self.lc.VSB_vprintf.restype = c_int
#VSB_delete
self.lc.VSB_delete = lib.VSB_delete
self.lc.VSB_delete.argtypes = [c_void_p]
#VSB_indent
self.lc.VSB_indent = lib.VSB_indent
self.lc.VSB_indent.argtypes = [c_void_p, c_int]
#VTIM_parse
self.lc.VTIM_parse = lib.VTIM_parse
self.lc.VTIM_parse.restype = c_double
self.lc.VTIM_parse.argtypes = [c_char_p]
#VTIM_timespec
self.lc.VTIM_timespec = lib.VTIM_timespec
self.lc.VTIM_timespec.restype = POINTER(timespec)
self.lc.VTIM_timespec.argtypes = [c_double]
#VTIM_timeval
self.lc.VTIM_timeval = lib.VTIM_timeval
self.lc.VTIM_timeval.restype = POINTER(timeval)
self.lc.VTIM_timeval.argtypes = [c_double]
#VCS_Message
self.lc.VCS_Message = lib.VCS_Message
self.lc.VCS_Message.argtypes = [c_char_p]
class LIBVARNISHAPI20:
def __init__(self, lc):
self.lc = lc
def run(self, lib):
if hasattr(lib, "VSIG_Got_int"):
self.lc.apiversion = 2.2
#elif hasattr(lib, "VUT_Usage"):
# self.lc.apiversion = 2.1
elif hasattr(lib, "VSM_Map"):
self.lc.apiversion = 2.0
# # vas.c
# VAS_Fail;
self.lc.VAS_Fail = lib.VAS_Fail
self.lc.VAS_Fail.argtypes = [c_char_p, c_char_p, c_int, c_char_p, c_int]
# VAS_Fail_Func;
#
# # vcli.c
# VCLI_AuthResponse;
self.lc.VCLI_AuthResponse = lib.VCLI_AuthResponse
self.lc.VCLI_AuthResponse.argtypes = [c_int, c_char_p, c_int, c_char *65]
# VCLI_ReadResult;
self.lc.VCLI_ReadResult = lib.VCLI_ReadResult
self.lc.VCLI_ReadResult.argtypes = [c_int, POINTER(c_uint), POINTER(c_char_p), c_double]
# VCLI_WriteResult;
self.lc.VCLI_WriteResult = lib.VCLI_WriteResult
self.lc.VCLI_WriteResult.argtypes = [c_int, c_uint, c_char_p]
#
# # vcs.c
# VCS_Message;
self.lc.VCS_Message = lib.VCS_Message
self.lc.VCS_Message.argtypes = [c_char_p]
#
# # vsb.c
# VSB_bcat;
self.lc.VSB_bcat = lib.VSB_bcat
self.lc.VSB_bcat.argtypes = [c_void_p, c_void_p, c_long]
# VSB_cat;
self.lc.VSB_cat = lib.VSB_cat
self.lc.VSB_cat.argtypes = [c_void_p, c_char_p]
# VSB_clear;
self.lc.VSB_clear = lib.VSB_clear
self.lc.VSB_clear.argtypes = [c_void_p]
# VSB_data;
self.lc.VSB_data = lib.VSB_data
self.lc.VSB_data.restype = c_char_p
self.lc.VSB_data.argtypes = [c_void_p]
# VSB_delete;
self.lc.VSB_delete = lib.VSB_delete
self.lc.VSB_delete.argtypes = [c_void_p]
# VSB_destroy;
self.lc.VSB_destroy = lib.VSB_destroy
self.lc.VSB_destroy.argtypes = [POINTER(c_void_p)]
# VSB_error;
self.lc.VSB_error = lib.VSB_error
self.lc.VSB_error.argtypes = [c_void_p]
# VSB_finish;
self.lc.VSB_finish = lib.VSB_finish
self.lc.VSB_finish.argtypes = [c_void_p]
# VSB_indent;
self.lc.VSB_indent = lib.VSB_indent
self.lc.VSB_indent.argtypes = [c_void_p, c_int]
# VSB_len;
self.lc.VSB_len = lib.VSB_len
self.lc.VSB_len.restype = c_long
self.lc.VSB_len.argtypes = [c_void_p]
# VSB_new;
self.lc.VSB_new = lib.VSB_new
self.lc.VSB_new.restype = c_void_p
self.lc.VSB_new.argtypes = [c_void_p, c_char_p, c_int]
# VSB_printf;
self.lc.VSB_printf = lib.VSB_printf
# VSB_putc;
self.lc.VSB_putc = lib.VSB_putc
self.lc.VSB_putc.argtypes = [c_void_p, c_int]
# VSB_quote;
self.lc.VSB_quote = lib.VSB_quote
self.lc.VSB_quote.argtypes = [c_void_p, c_void_p, c_int, c_int]
# VSB_quote_pfx;
self.lc.VSB_quote_pfx = lib.VSB_quote_pfx
self.lc.VSB_quote_pfx.argtypes = [c_void_p, c_char_p, c_void_p, c_int, c_int]
# VSB_vprintf;
self.lc.VSB_vprintf = lib.VSB_vprintf
####################################################
#
# # vsc.c
# VSC_Arg;
self.lc.VSC_Arg = lib.VSC_Arg
self.lc.VSC_Arg.argtypes = [c_void_p, c_int, c_char_p]
# VSC_ChangeLevel;
self.lc.VSC_ChangeLevel = lib.VSC_ChangeLevel
self.lc.VSC_ChangeLevel.restype = POINTER(VSC_level_desc)
self.lc.VSC_ChangeLevel.argtypes = [POINTER(VSC_level_desc), c_int]
# VSC_Destroy;
self.lc.VSC_Destroy = lib.VSC_Destroy
self.lc.VSC_Destroy.argtypes = [POINTER(c_void_p), c_void_p]
# VSC_Iter;
self.lc.VSC_Iter = lib.VSC_Iter
self.lc.VSC_Iter.argtypes = [c_void_p, c_void_p, VSC_iter_f20, c_void_p]
# VSC_New;
self.lc.VSC_New = lib.VSC_New
self.lc.VSC_New.restype = c_void_p
# VSC_State;
self.lc.VSC_State = lib.VSC_State
self.lc.VSC_State.argtypes = [c_void_p, VSC_new_f, VSC_destroy_f, c_void_p]
#
# # vsl*.c
# VSLQ_Delete;
self.lc.VSLQ_Delete = lib.VSLQ_Delete
self.lc.VSLQ_Delete.argtypes = [POINTER(c_void_p)]
# VSLQ_Dispatch;
self.lc.VSLQ_Dispatch = lib.VSLQ_Dispatch
self.lc.VSLQ_Dispatch.argtypes = [c_void_p, VSLQ_dispatch_f, c_void_p]
# VSLQ_Flush;
self.lc.VSLQ_Flush = lib.VSLQ_Flush
self.lc.VSLQ_Flush.argtypes = [c_void_p, VSLQ_dispatch_f, c_void_p]
# VSLQ_Name2Grouping;
self.lc.VSLQ_Name2Grouping = lib.VSLQ_Name2Grouping
self.lc.VSLQ_Name2Grouping.argtypes = [c_char_p, c_int]
# VSLQ_New;
self.lc.VSLQ_New = lib.VSLQ_New
self.lc.VSLQ_New.restype = c_void_p
self.lc.VSLQ_New.argtypes = [c_void_p, POINTER(POINTER(VSL_cursor)), c_int, c_char_p]
# VSLQ_SetCursor;
self.lc.VSLQ_SetCursor = lib.VSLQ_SetCursor
self.lc.VSLQ_SetCursor.argtypes = [c_void_p, POINTER(c_void_p)]
# VSLQ_grouping; (variables)
# VSL_Arg;
self.lc.VSL_Arg = lib.VSL_Arg
self.lc.VSL_Arg.argtypes = [c_void_p, c_int, c_char_p]
# VSL_Check;
self.lc.VSL_Check = lib.VSL_Check
self.lc.VSL_Check.argtypes = [c_void_p, c_void_p]
# VSL_CursorFile;
self.lc.VSL_CursorFile = lib.VSL_CursorFile
self.lc.VSL_CursorFile.restype = POINTER(VSL_cursor)
self.lc.VSL_CursorFile.argtypes = [c_void_p, c_char_p, c_uint]
# VSL_CursorVSM;
self.lc.VSL_CursorVSM = lib.VSL_CursorVSM
self.lc.VSL_CursorVSM.restype = POINTER(VSL_cursor)
self.lc.VSL_CursorVSM.argtypes = [c_void_p, c_void_p, c_uint]
# VSL_Delete;
self.lc.VSL_Delete = lib.VSL_Delete
self.lc.VSL_Delete.argtypes = [c_void_p]
# VSL_DeleteCursor;