undns 0.4.0a

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,108 @@
1
+ /* a ruleset is a hashtable of asnc's */
2
+ /* an asnc is a binding from asn-> (ordered) list of
3
+ conventions */
4
+ /* a convention is a regular expression, optionally with
5
+ type and location keys */
6
+ /* a key is a hashtable of identifier value pairs (eg 'sea
7
+ "Seattle, WA"') */
8
+ /* a key may have a default "identity" rule, which takes
9
+ unmatched identifiers and returns them as a value; useful
10
+ when there is a clear convention, but not time to
11
+ identify each of the players. */
12
+
13
+ #include "typed_queue.h"
14
+ #include "typed_hashtable.h"
15
+ #include "hashes.h"
16
+ #include "nscommon.h"
17
+ #include <stdio.h>
18
+
19
+ struct instrumentation {
20
+ const char *file; unsigned int line;
21
+ unsigned int dynamic_match_count;
22
+ unsigned int doubt_count; // strikes against this convention or pair in the last run.
23
+ };
24
+ void set_file_and_line(struct instrumentation *inst, const char *file, unsigned int line);
25
+
26
+ #include <sys/types.h>
27
+ #include <regex.h> /* must avoid the ruby regex.h */
28
+
29
+ struct stringpair {
30
+ char *key;
31
+ char *value;
32
+ struct instrumentation inst;
33
+ };
34
+
35
+ DECLARE_TYPED_HASHTABLE_K(struct stringpair, hash_cptr, key);
36
+
37
+ struct key_decl {
38
+ enum attributetype { attr_loc, attr_type, attr_unique, attr_poptag } id;
39
+ int regex_index;
40
+ boolean isDefault;
41
+ key_hashtable bindings;
42
+ const char *constant;
43
+ struct instrumentation inst;
44
+ };
45
+
46
+ struct key_decl *new_key_decl(char *id, int regex_index,
47
+ boolean isDefault,
48
+ key_hashtable bindings);
49
+ struct key_decl *new_key_decl_const(char *id, char *constant);
50
+
51
+ struct convention {
52
+ char *regex;
53
+ #ifdef DEPRECATED_GNU_REGEX
54
+ struct re_pattern_buffer rpbuf;
55
+ #else
56
+ regex_t rpbuf;
57
+ #endif
58
+ struct key_decl *loc, *type, *unique, *poptag;
59
+ long asn; /* so that it's easy to recover the asn after the match is made */ /* long to appease 64-bit compiler for void * size */
60
+ struct instrumentation inst;
61
+ };
62
+ struct convention *
63
+ new_convention(char *regex,
64
+ struct key_decl *a,
65
+ struct key_decl *b,
66
+ struct key_decl *c,
67
+ struct key_decl *d,
68
+ const char *filename,
69
+ int linenum);
70
+
71
+ DECLARE_TYPED_QUEUE(struct convention, conv);
72
+
73
+ struct asnc {
74
+ int asn; /* not short, for ease of hash */
75
+ char *prefilter_regex;
76
+ #ifdef DEPRECATED_GNU_REGEX
77
+ struct re_pattern_buffer prefilter_rpbuf;
78
+ #else
79
+ regex_t prefilter_rpbuf;
80
+ #endif
81
+ conv_queue conventions;
82
+ struct instrumentation inst;
83
+ };
84
+
85
+ DECLARE_TYPED_HASHTABLE_K(struct asnc, int, asnc);
86
+
87
+ void load_ruleset(const char *filename);
88
+
89
+ boolean match(const char *name,
90
+ struct convention *conv,
91
+ const char **location,
92
+ const char **typey);
93
+
94
+ const char *get_loc(int asn, const char *hostname);
95
+ /*@mustfree@*/ char *get_poptag(int asn, const char *hostname);
96
+ const char *get_role(int asn, const char *hostname);
97
+ /*@mustfree@*/ char *get_identifier(int asn, const char *hostname);
98
+ const char *get_loc_list(int asn, const char **hostname_list); /* majority rule */
99
+ int get_asn_bydns(const char *hostname);
100
+ /*@mustfree@*/ /*@null@*/ char * search_path(const char *path, const char *find_me);
101
+ /*@null@*/ FILE *fopen_path_r (const char *filename);
102
+ extern const char *ruleset_path; /* where to search */
103
+
104
+ void set_conventions_debug(boolean v);
105
+ void doubt_location(int asn, const char *hostname);
106
+
107
+ void dump_parsed_conventions_to_file(const char * filename);
108
+ void dump_single_asn_conventions_to_file(int asn, const char * filename);
@@ -0,0 +1,2995 @@
1
+ /* ----------------------------------------------------------------------------
2
+ * This file was automatically generated by SWIG (http://www.swig.org).
3
+ * Version 2.0.12
4
+ *
5
+ * This file is not intended to be easily readable and contains a number of
6
+ * coding conventions designed to improve portability and efficiency. Do not make
7
+ * changes to this file unless you know what you are doing--modify the SWIG
8
+ * interface file instead.
9
+ * ----------------------------------------------------------------------------- */
10
+
11
+ #define SWIGRUBY
12
+
13
+ /* -----------------------------------------------------------------------------
14
+ * This section contains generic SWIG labels for method/variable
15
+ * declarations/attributes, and other compiler dependent labels.
16
+ * ----------------------------------------------------------------------------- */
17
+
18
+ /* template workaround for compilers that cannot correctly implement the C++ standard */
19
+ #ifndef SWIGTEMPLATEDISAMBIGUATOR
20
+ # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
21
+ # define SWIGTEMPLATEDISAMBIGUATOR template
22
+ # elif defined(__HP_aCC)
23
+ /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
24
+ /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
25
+ # define SWIGTEMPLATEDISAMBIGUATOR template
26
+ # else
27
+ # define SWIGTEMPLATEDISAMBIGUATOR
28
+ # endif
29
+ #endif
30
+
31
+ /* inline attribute */
32
+ #ifndef SWIGINLINE
33
+ # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
34
+ # define SWIGINLINE inline
35
+ # else
36
+ # define SWIGINLINE
37
+ # endif
38
+ #endif
39
+
40
+ /* attribute recognised by some compilers to avoid 'unused' warnings */
41
+ #ifndef SWIGUNUSED
42
+ # if defined(__GNUC__)
43
+ # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
44
+ # define SWIGUNUSED __attribute__ ((__unused__))
45
+ # else
46
+ # define SWIGUNUSED
47
+ # endif
48
+ # elif defined(__ICC)
49
+ # define SWIGUNUSED __attribute__ ((__unused__))
50
+ # else
51
+ # define SWIGUNUSED
52
+ # endif
53
+ #endif
54
+
55
+ #ifndef SWIG_MSC_UNSUPPRESS_4505
56
+ # if defined(_MSC_VER)
57
+ # pragma warning(disable : 4505) /* unreferenced local function has been removed */
58
+ # endif
59
+ #endif
60
+
61
+ #ifndef SWIGUNUSEDPARM
62
+ # ifdef __cplusplus
63
+ # define SWIGUNUSEDPARM(p)
64
+ # else
65
+ # define SWIGUNUSEDPARM(p) p SWIGUNUSED
66
+ # endif
67
+ #endif
68
+
69
+ /* internal SWIG method */
70
+ #ifndef SWIGINTERN
71
+ # define SWIGINTERN static SWIGUNUSED
72
+ #endif
73
+
74
+ /* internal inline SWIG method */
75
+ #ifndef SWIGINTERNINLINE
76
+ # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
77
+ #endif
78
+
79
+ /* exporting methods */
80
+ #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
81
+ # ifndef GCC_HASCLASSVISIBILITY
82
+ # define GCC_HASCLASSVISIBILITY
83
+ # endif
84
+ #endif
85
+
86
+ #ifndef SWIGEXPORT
87
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
88
+ # if defined(STATIC_LINKED)
89
+ # define SWIGEXPORT
90
+ # else
91
+ # define SWIGEXPORT __declspec(dllexport)
92
+ # endif
93
+ # else
94
+ # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
95
+ # define SWIGEXPORT __attribute__ ((visibility("default")))
96
+ # else
97
+ # define SWIGEXPORT
98
+ # endif
99
+ # endif
100
+ #endif
101
+
102
+ /* calling conventions for Windows */
103
+ #ifndef SWIGSTDCALL
104
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
105
+ # define SWIGSTDCALL __stdcall
106
+ # else
107
+ # define SWIGSTDCALL
108
+ # endif
109
+ #endif
110
+
111
+ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
112
+ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
113
+ # define _CRT_SECURE_NO_DEPRECATE
114
+ #endif
115
+
116
+ /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
117
+ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
118
+ # define _SCL_SECURE_NO_DEPRECATE
119
+ #endif
120
+
121
+
122
+ /* -----------------------------------------------------------------------------
123
+ * This section contains generic SWIG labels for method/variable
124
+ * declarations/attributes, and other compiler dependent labels.
125
+ * ----------------------------------------------------------------------------- */
126
+
127
+ /* template workaround for compilers that cannot correctly implement the C++ standard */
128
+ #ifndef SWIGTEMPLATEDISAMBIGUATOR
129
+ # if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
130
+ # define SWIGTEMPLATEDISAMBIGUATOR template
131
+ # elif defined(__HP_aCC)
132
+ /* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
133
+ /* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
134
+ # define SWIGTEMPLATEDISAMBIGUATOR template
135
+ # else
136
+ # define SWIGTEMPLATEDISAMBIGUATOR
137
+ # endif
138
+ #endif
139
+
140
+ /* inline attribute */
141
+ #ifndef SWIGINLINE
142
+ # if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
143
+ # define SWIGINLINE inline
144
+ # else
145
+ # define SWIGINLINE
146
+ # endif
147
+ #endif
148
+
149
+ /* attribute recognised by some compilers to avoid 'unused' warnings */
150
+ #ifndef SWIGUNUSED
151
+ # if defined(__GNUC__)
152
+ # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
153
+ # define SWIGUNUSED __attribute__ ((__unused__))
154
+ # else
155
+ # define SWIGUNUSED
156
+ # endif
157
+ # elif defined(__ICC)
158
+ # define SWIGUNUSED __attribute__ ((__unused__))
159
+ # else
160
+ # define SWIGUNUSED
161
+ # endif
162
+ #endif
163
+
164
+ #ifndef SWIG_MSC_UNSUPPRESS_4505
165
+ # if defined(_MSC_VER)
166
+ # pragma warning(disable : 4505) /* unreferenced local function has been removed */
167
+ # endif
168
+ #endif
169
+
170
+ #ifndef SWIGUNUSEDPARM
171
+ # ifdef __cplusplus
172
+ # define SWIGUNUSEDPARM(p)
173
+ # else
174
+ # define SWIGUNUSEDPARM(p) p SWIGUNUSED
175
+ # endif
176
+ #endif
177
+
178
+ /* internal SWIG method */
179
+ #ifndef SWIGINTERN
180
+ # define SWIGINTERN static SWIGUNUSED
181
+ #endif
182
+
183
+ /* internal inline SWIG method */
184
+ #ifndef SWIGINTERNINLINE
185
+ # define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
186
+ #endif
187
+
188
+ /* exporting methods */
189
+ #if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
190
+ # ifndef GCC_HASCLASSVISIBILITY
191
+ # define GCC_HASCLASSVISIBILITY
192
+ # endif
193
+ #endif
194
+
195
+ #ifndef SWIGEXPORT
196
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
197
+ # if defined(STATIC_LINKED)
198
+ # define SWIGEXPORT
199
+ # else
200
+ # define SWIGEXPORT __declspec(dllexport)
201
+ # endif
202
+ # else
203
+ # if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
204
+ # define SWIGEXPORT __attribute__ ((visibility("default")))
205
+ # else
206
+ # define SWIGEXPORT
207
+ # endif
208
+ # endif
209
+ #endif
210
+
211
+ /* calling conventions for Windows */
212
+ #ifndef SWIGSTDCALL
213
+ # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
214
+ # define SWIGSTDCALL __stdcall
215
+ # else
216
+ # define SWIGSTDCALL
217
+ # endif
218
+ #endif
219
+
220
+ /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
221
+ #if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
222
+ # define _CRT_SECURE_NO_DEPRECATE
223
+ #endif
224
+
225
+ /* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
226
+ #if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
227
+ # define _SCL_SECURE_NO_DEPRECATE
228
+ #endif
229
+
230
+
231
+ /* -----------------------------------------------------------------------------
232
+ * swigrun.swg
233
+ *
234
+ * This file contains generic C API SWIG runtime support for pointer
235
+ * type checking.
236
+ * ----------------------------------------------------------------------------- */
237
+
238
+ /* This should only be incremented when either the layout of swig_type_info changes,
239
+ or for whatever reason, the runtime changes incompatibly */
240
+ #define SWIG_RUNTIME_VERSION "4"
241
+
242
+ /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
243
+ #ifdef SWIG_TYPE_TABLE
244
+ # define SWIG_QUOTE_STRING(x) #x
245
+ # define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
246
+ # define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
247
+ #else
248
+ # define SWIG_TYPE_TABLE_NAME
249
+ #endif
250
+
251
+ /*
252
+ You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
253
+ creating a static or dynamic library from the SWIG runtime code.
254
+ In 99.9% of the cases, SWIG just needs to declare them as 'static'.
255
+
256
+ But only do this if strictly necessary, ie, if you have problems
257
+ with your compiler or suchlike.
258
+ */
259
+
260
+ #ifndef SWIGRUNTIME
261
+ # define SWIGRUNTIME SWIGINTERN
262
+ #endif
263
+
264
+ #ifndef SWIGRUNTIMEINLINE
265
+ # define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
266
+ #endif
267
+
268
+ /* Generic buffer size */
269
+ #ifndef SWIG_BUFFER_SIZE
270
+ # define SWIG_BUFFER_SIZE 1024
271
+ #endif
272
+
273
+ /* Flags for pointer conversions */
274
+ #define SWIG_POINTER_DISOWN 0x1
275
+ #define SWIG_CAST_NEW_MEMORY 0x2
276
+
277
+ /* Flags for new pointer objects */
278
+ #define SWIG_POINTER_OWN 0x1
279
+
280
+
281
+ /*
282
+ Flags/methods for returning states.
283
+
284
+ The SWIG conversion methods, as ConvertPtr, return an integer
285
+ that tells if the conversion was successful or not. And if not,
286
+ an error code can be returned (see swigerrors.swg for the codes).
287
+
288
+ Use the following macros/flags to set or process the returning
289
+ states.
290
+
291
+ In old versions of SWIG, code such as the following was usually written:
292
+
293
+ if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
294
+ // success code
295
+ } else {
296
+ //fail code
297
+ }
298
+
299
+ Now you can be more explicit:
300
+
301
+ int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
302
+ if (SWIG_IsOK(res)) {
303
+ // success code
304
+ } else {
305
+ // fail code
306
+ }
307
+
308
+ which is the same really, but now you can also do
309
+
310
+ Type *ptr;
311
+ int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
312
+ if (SWIG_IsOK(res)) {
313
+ // success code
314
+ if (SWIG_IsNewObj(res) {
315
+ ...
316
+ delete *ptr;
317
+ } else {
318
+ ...
319
+ }
320
+ } else {
321
+ // fail code
322
+ }
323
+
324
+ I.e., now SWIG_ConvertPtr can return new objects and you can
325
+ identify the case and take care of the deallocation. Of course that
326
+ also requires SWIG_ConvertPtr to return new result values, such as
327
+
328
+ int SWIG_ConvertPtr(obj, ptr,...) {
329
+ if (<obj is ok>) {
330
+ if (<need new object>) {
331
+ *ptr = <ptr to new allocated object>;
332
+ return SWIG_NEWOBJ;
333
+ } else {
334
+ *ptr = <ptr to old object>;
335
+ return SWIG_OLDOBJ;
336
+ }
337
+ } else {
338
+ return SWIG_BADOBJ;
339
+ }
340
+ }
341
+
342
+ Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
343
+ more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
344
+ SWIG errors code.
345
+
346
+ Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
347
+ allows to return the 'cast rank', for example, if you have this
348
+
349
+ int food(double)
350
+ int fooi(int);
351
+
352
+ and you call
353
+
354
+ food(1) // cast rank '1' (1 -> 1.0)
355
+ fooi(1) // cast rank '0'
356
+
357
+ just use the SWIG_AddCast()/SWIG_CheckState()
358
+ */
359
+
360
+ #define SWIG_OK (0)
361
+ #define SWIG_ERROR (-1)
362
+ #define SWIG_IsOK(r) (r >= 0)
363
+ #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
364
+
365
+ /* The CastRankLimit says how many bits are used for the cast rank */
366
+ #define SWIG_CASTRANKLIMIT (1 << 8)
367
+ /* The NewMask denotes the object was created (using new/malloc) */
368
+ #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
369
+ /* The TmpMask is for in/out typemaps that use temporal objects */
370
+ #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
371
+ /* Simple returning values */
372
+ #define SWIG_BADOBJ (SWIG_ERROR)
373
+ #define SWIG_OLDOBJ (SWIG_OK)
374
+ #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
375
+ #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
376
+ /* Check, add and del mask methods */
377
+ #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
378
+ #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
379
+ #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
380
+ #define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
381
+ #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
382
+ #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
383
+
384
+ /* Cast-Rank Mode */
385
+ #if defined(SWIG_CASTRANK_MODE)
386
+ # ifndef SWIG_TypeRank
387
+ # define SWIG_TypeRank unsigned long
388
+ # endif
389
+ # ifndef SWIG_MAXCASTRANK /* Default cast allowed */
390
+ # define SWIG_MAXCASTRANK (2)
391
+ # endif
392
+ # define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
393
+ # define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
394
+ SWIGINTERNINLINE int SWIG_AddCast(int r) {
395
+ return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
396
+ }
397
+ SWIGINTERNINLINE int SWIG_CheckState(int r) {
398
+ return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
399
+ }
400
+ #else /* no cast-rank mode */
401
+ # define SWIG_AddCast(r) (r)
402
+ # define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
403
+ #endif
404
+
405
+
406
+ #include <string.h>
407
+
408
+ #ifdef __cplusplus
409
+ extern "C" {
410
+ #endif
411
+
412
+ typedef void *(*swig_converter_func)(void *, int *);
413
+ typedef struct swig_type_info *(*swig_dycast_func)(void **);
414
+
415
+ /* Structure to store information on one type */
416
+ typedef struct swig_type_info {
417
+ const char *name; /* mangled name of this type */
418
+ const char *str; /* human readable name of this type */
419
+ swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
420
+ struct swig_cast_info *cast; /* linked list of types that can cast into this type */
421
+ void *clientdata; /* language specific type data */
422
+ int owndata; /* flag if the structure owns the clientdata */
423
+ } swig_type_info;
424
+
425
+ /* Structure to store a type and conversion function used for casting */
426
+ typedef struct swig_cast_info {
427
+ swig_type_info *type; /* pointer to type that is equivalent to this type */
428
+ swig_converter_func converter; /* function to cast the void pointers */
429
+ struct swig_cast_info *next; /* pointer to next cast in linked list */
430
+ struct swig_cast_info *prev; /* pointer to the previous cast */
431
+ } swig_cast_info;
432
+
433
+ /* Structure used to store module information
434
+ * Each module generates one structure like this, and the runtime collects
435
+ * all of these structures and stores them in a circularly linked list.*/
436
+ typedef struct swig_module_info {
437
+ swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
438
+ size_t size; /* Number of types in this module */
439
+ struct swig_module_info *next; /* Pointer to next element in circularly linked list */
440
+ swig_type_info **type_initial; /* Array of initially generated type structures */
441
+ swig_cast_info **cast_initial; /* Array of initially generated casting structures */
442
+ void *clientdata; /* Language specific module data */
443
+ } swig_module_info;
444
+
445
+ /*
446
+ Compare two type names skipping the space characters, therefore
447
+ "char*" == "char *" and "Class<int>" == "Class<int >", etc.
448
+
449
+ Return 0 when the two name types are equivalent, as in
450
+ strncmp, but skipping ' '.
451
+ */
452
+ SWIGRUNTIME int
453
+ SWIG_TypeNameComp(const char *f1, const char *l1,
454
+ const char *f2, const char *l2) {
455
+ for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
456
+ while ((*f1 == ' ') && (f1 != l1)) ++f1;
457
+ while ((*f2 == ' ') && (f2 != l2)) ++f2;
458
+ if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
459
+ }
460
+ return (int)((l1 - f1) - (l2 - f2));
461
+ }
462
+
463
+ /*
464
+ Check type equivalence in a name list like <name1>|<name2>|...
465
+ Return 0 if equal, -1 if nb < tb, 1 if nb > tb
466
+ */
467
+ SWIGRUNTIME int
468
+ SWIG_TypeCmp(const char *nb, const char *tb) {
469
+ int equiv = 1;
470
+ const char* te = tb + strlen(tb);
471
+ const char* ne = nb;
472
+ while (equiv != 0 && *ne) {
473
+ for (nb = ne; *ne; ++ne) {
474
+ if (*ne == '|') break;
475
+ }
476
+ equiv = SWIG_TypeNameComp(nb, ne, tb, te);
477
+ if (*ne) ++ne;
478
+ }
479
+ return equiv;
480
+ }
481
+
482
+ /*
483
+ Check type equivalence in a name list like <name1>|<name2>|...
484
+ Return 0 if not equal, 1 if equal
485
+ */
486
+ SWIGRUNTIME int
487
+ SWIG_TypeEquiv(const char *nb, const char *tb) {
488
+ return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
489
+ }
490
+
491
+ /*
492
+ Check the typename
493
+ */
494
+ SWIGRUNTIME swig_cast_info *
495
+ SWIG_TypeCheck(const char *c, swig_type_info *ty) {
496
+ if (ty) {
497
+ swig_cast_info *iter = ty->cast;
498
+ while (iter) {
499
+ if (strcmp(iter->type->name, c) == 0) {
500
+ if (iter == ty->cast)
501
+ return iter;
502
+ /* Move iter to the top of the linked list */
503
+ iter->prev->next = iter->next;
504
+ if (iter->next)
505
+ iter->next->prev = iter->prev;
506
+ iter->next = ty->cast;
507
+ iter->prev = 0;
508
+ if (ty->cast) ty->cast->prev = iter;
509
+ ty->cast = iter;
510
+ return iter;
511
+ }
512
+ iter = iter->next;
513
+ }
514
+ }
515
+ return 0;
516
+ }
517
+
518
+ /*
519
+ Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
520
+ */
521
+ SWIGRUNTIME swig_cast_info *
522
+ SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
523
+ if (ty) {
524
+ swig_cast_info *iter = ty->cast;
525
+ while (iter) {
526
+ if (iter->type == from) {
527
+ if (iter == ty->cast)
528
+ return iter;
529
+ /* Move iter to the top of the linked list */
530
+ iter->prev->next = iter->next;
531
+ if (iter->next)
532
+ iter->next->prev = iter->prev;
533
+ iter->next = ty->cast;
534
+ iter->prev = 0;
535
+ if (ty->cast) ty->cast->prev = iter;
536
+ ty->cast = iter;
537
+ return iter;
538
+ }
539
+ iter = iter->next;
540
+ }
541
+ }
542
+ return 0;
543
+ }
544
+
545
+ /*
546
+ Cast a pointer up an inheritance hierarchy
547
+ */
548
+ SWIGRUNTIMEINLINE void *
549
+ SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
550
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
551
+ }
552
+
553
+ /*
554
+ Dynamic pointer casting. Down an inheritance hierarchy
555
+ */
556
+ SWIGRUNTIME swig_type_info *
557
+ SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
558
+ swig_type_info *lastty = ty;
559
+ if (!ty || !ty->dcast) return ty;
560
+ while (ty && (ty->dcast)) {
561
+ ty = (*ty->dcast)(ptr);
562
+ if (ty) lastty = ty;
563
+ }
564
+ return lastty;
565
+ }
566
+
567
+ /*
568
+ Return the name associated with this type
569
+ */
570
+ SWIGRUNTIMEINLINE const char *
571
+ SWIG_TypeName(const swig_type_info *ty) {
572
+ return ty->name;
573
+ }
574
+
575
+ /*
576
+ Return the pretty name associated with this type,
577
+ that is an unmangled type name in a form presentable to the user.
578
+ */
579
+ SWIGRUNTIME const char *
580
+ SWIG_TypePrettyName(const swig_type_info *type) {
581
+ /* The "str" field contains the equivalent pretty names of the
582
+ type, separated by vertical-bar characters. We choose
583
+ to print the last name, as it is often (?) the most
584
+ specific. */
585
+ if (!type) return NULL;
586
+ if (type->str != NULL) {
587
+ const char *last_name = type->str;
588
+ const char *s;
589
+ for (s = type->str; *s; s++)
590
+ if (*s == '|') last_name = s+1;
591
+ return last_name;
592
+ }
593
+ else
594
+ return type->name;
595
+ }
596
+
597
+ /*
598
+ Set the clientdata field for a type
599
+ */
600
+ SWIGRUNTIME void
601
+ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
602
+ swig_cast_info *cast = ti->cast;
603
+ /* if (ti->clientdata == clientdata) return; */
604
+ ti->clientdata = clientdata;
605
+
606
+ while (cast) {
607
+ if (!cast->converter) {
608
+ swig_type_info *tc = cast->type;
609
+ if (!tc->clientdata) {
610
+ SWIG_TypeClientData(tc, clientdata);
611
+ }
612
+ }
613
+ cast = cast->next;
614
+ }
615
+ }
616
+ SWIGRUNTIME void
617
+ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
618
+ SWIG_TypeClientData(ti, clientdata);
619
+ ti->owndata = 1;
620
+ }
621
+
622
+ /*
623
+ Search for a swig_type_info structure only by mangled name
624
+ Search is a O(log #types)
625
+
626
+ We start searching at module start, and finish searching when start == end.
627
+ Note: if start == end at the beginning of the function, we go all the way around
628
+ the circular list.
629
+ */
630
+ SWIGRUNTIME swig_type_info *
631
+ SWIG_MangledTypeQueryModule(swig_module_info *start,
632
+ swig_module_info *end,
633
+ const char *name) {
634
+ swig_module_info *iter = start;
635
+ do {
636
+ if (iter->size) {
637
+ register size_t l = 0;
638
+ register size_t r = iter->size - 1;
639
+ do {
640
+ /* since l+r >= 0, we can (>> 1) instead (/ 2) */
641
+ register size_t i = (l + r) >> 1;
642
+ const char *iname = iter->types[i]->name;
643
+ if (iname) {
644
+ register int compare = strcmp(name, iname);
645
+ if (compare == 0) {
646
+ return iter->types[i];
647
+ } else if (compare < 0) {
648
+ if (i) {
649
+ r = i - 1;
650
+ } else {
651
+ break;
652
+ }
653
+ } else if (compare > 0) {
654
+ l = i + 1;
655
+ }
656
+ } else {
657
+ break; /* should never happen */
658
+ }
659
+ } while (l <= r);
660
+ }
661
+ iter = iter->next;
662
+ } while (iter != end);
663
+ return 0;
664
+ }
665
+
666
+ /*
667
+ Search for a swig_type_info structure for either a mangled name or a human readable name.
668
+ It first searches the mangled names of the types, which is a O(log #types)
669
+ If a type is not found it then searches the human readable names, which is O(#types).
670
+
671
+ We start searching at module start, and finish searching when start == end.
672
+ Note: if start == end at the beginning of the function, we go all the way around
673
+ the circular list.
674
+ */
675
+ SWIGRUNTIME swig_type_info *
676
+ SWIG_TypeQueryModule(swig_module_info *start,
677
+ swig_module_info *end,
678
+ const char *name) {
679
+ /* STEP 1: Search the name field using binary search */
680
+ swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
681
+ if (ret) {
682
+ return ret;
683
+ } else {
684
+ /* STEP 2: If the type hasn't been found, do a complete search
685
+ of the str field (the human readable name) */
686
+ swig_module_info *iter = start;
687
+ do {
688
+ register size_t i = 0;
689
+ for (; i < iter->size; ++i) {
690
+ if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
691
+ return iter->types[i];
692
+ }
693
+ iter = iter->next;
694
+ } while (iter != end);
695
+ }
696
+
697
+ /* neither found a match */
698
+ return 0;
699
+ }
700
+
701
+ /*
702
+ Pack binary data into a string
703
+ */
704
+ SWIGRUNTIME char *
705
+ SWIG_PackData(char *c, void *ptr, size_t sz) {
706
+ static const char hex[17] = "0123456789abcdef";
707
+ register const unsigned char *u = (unsigned char *) ptr;
708
+ register const unsigned char *eu = u + sz;
709
+ for (; u != eu; ++u) {
710
+ register unsigned char uu = *u;
711
+ *(c++) = hex[(uu & 0xf0) >> 4];
712
+ *(c++) = hex[uu & 0xf];
713
+ }
714
+ return c;
715
+ }
716
+
717
+ /*
718
+ Unpack binary data from a string
719
+ */
720
+ SWIGRUNTIME const char *
721
+ SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
722
+ register unsigned char *u = (unsigned char *) ptr;
723
+ register const unsigned char *eu = u + sz;
724
+ for (; u != eu; ++u) {
725
+ register char d = *(c++);
726
+ register unsigned char uu;
727
+ if ((d >= '0') && (d <= '9'))
728
+ uu = ((d - '0') << 4);
729
+ else if ((d >= 'a') && (d <= 'f'))
730
+ uu = ((d - ('a'-10)) << 4);
731
+ else
732
+ return (char *) 0;
733
+ d = *(c++);
734
+ if ((d >= '0') && (d <= '9'))
735
+ uu |= (d - '0');
736
+ else if ((d >= 'a') && (d <= 'f'))
737
+ uu |= (d - ('a'-10));
738
+ else
739
+ return (char *) 0;
740
+ *u = uu;
741
+ }
742
+ return c;
743
+ }
744
+
745
+ /*
746
+ Pack 'void *' into a string buffer.
747
+ */
748
+ SWIGRUNTIME char *
749
+ SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
750
+ char *r = buff;
751
+ if ((2*sizeof(void *) + 2) > bsz) return 0;
752
+ *(r++) = '_';
753
+ r = SWIG_PackData(r,&ptr,sizeof(void *));
754
+ if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
755
+ strcpy(r,name);
756
+ return buff;
757
+ }
758
+
759
+ SWIGRUNTIME const char *
760
+ SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
761
+ if (*c != '_') {
762
+ if (strcmp(c,"NULL") == 0) {
763
+ *ptr = (void *) 0;
764
+ return name;
765
+ } else {
766
+ return 0;
767
+ }
768
+ }
769
+ return SWIG_UnpackData(++c,ptr,sizeof(void *));
770
+ }
771
+
772
+ SWIGRUNTIME char *
773
+ SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
774
+ char *r = buff;
775
+ size_t lname = (name ? strlen(name) : 0);
776
+ if ((2*sz + 2 + lname) > bsz) return 0;
777
+ *(r++) = '_';
778
+ r = SWIG_PackData(r,ptr,sz);
779
+ if (lname) {
780
+ strncpy(r,name,lname+1);
781
+ } else {
782
+ *r = 0;
783
+ }
784
+ return buff;
785
+ }
786
+
787
+ SWIGRUNTIME const char *
788
+ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
789
+ if (*c != '_') {
790
+ if (strcmp(c,"NULL") == 0) {
791
+ memset(ptr,0,sz);
792
+ return name;
793
+ } else {
794
+ return 0;
795
+ }
796
+ }
797
+ return SWIG_UnpackData(++c,ptr,sz);
798
+ }
799
+
800
+ #ifdef __cplusplus
801
+ }
802
+ #endif
803
+
804
+ /* Errors in SWIG */
805
+ #define SWIG_UnknownError -1
806
+ #define SWIG_IOError -2
807
+ #define SWIG_RuntimeError -3
808
+ #define SWIG_IndexError -4
809
+ #define SWIG_TypeError -5
810
+ #define SWIG_DivisionByZero -6
811
+ #define SWIG_OverflowError -7
812
+ #define SWIG_SyntaxError -8
813
+ #define SWIG_ValueError -9
814
+ #define SWIG_SystemError -10
815
+ #define SWIG_AttributeError -11
816
+ #define SWIG_MemoryError -12
817
+ #define SWIG_NullReferenceError -13
818
+
819
+
820
+
821
+ #include "my_ruby.h"
822
+
823
+ /* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which
824
+ * breaks using rb_intern as an lvalue, as SWIG does. We work around this
825
+ * issue for now by disabling this.
826
+ * https://sourceforge.net/tracker/?func=detail&aid=2859614&group_id=1645&atid=101645
827
+ */
828
+ #ifdef rb_intern
829
+ # undef rb_intern
830
+ #endif
831
+
832
+ /* Remove global macros defined in Ruby's win32.h */
833
+ #ifdef write
834
+ # undef write
835
+ #endif
836
+ #ifdef read
837
+ # undef read
838
+ #endif
839
+ #ifdef bind
840
+ # undef bind
841
+ #endif
842
+ #ifdef close
843
+ # undef close
844
+ #endif
845
+ #ifdef connect
846
+ # undef connect
847
+ #endif
848
+
849
+
850
+ /* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */
851
+ #ifndef NUM2LL
852
+ #define NUM2LL(x) NUM2LONG((x))
853
+ #endif
854
+ #ifndef LL2NUM
855
+ #define LL2NUM(x) INT2NUM((long) (x))
856
+ #endif
857
+ #ifndef ULL2NUM
858
+ #define ULL2NUM(x) UINT2NUM((unsigned long) (x))
859
+ #endif
860
+
861
+ /* Ruby 1.7 doesn't (yet) define NUM2ULL() */
862
+ #ifndef NUM2ULL
863
+ #ifdef HAVE_LONG_LONG
864
+ #define NUM2ULL(x) rb_num2ull((x))
865
+ #else
866
+ #define NUM2ULL(x) NUM2ULONG(x)
867
+ #endif
868
+ #endif
869
+
870
+ /* RSTRING_LEN, etc are new in Ruby 1.9, but ->ptr and ->len no longer work */
871
+ /* Define these for older versions so we can just write code the new way */
872
+ #ifndef RSTRING_LEN
873
+ # define RSTRING_LEN(x) RSTRING(x)->len
874
+ #endif
875
+ #ifndef RSTRING_PTR
876
+ # define RSTRING_PTR(x) RSTRING(x)->ptr
877
+ #endif
878
+ #ifndef RSTRING_END
879
+ # define RSTRING_END(x) (RSTRING_PTR(x) + RSTRING_LEN(x))
880
+ #endif
881
+ #ifndef RARRAY_LEN
882
+ # define RARRAY_LEN(x) RARRAY(x)->len
883
+ #endif
884
+ #ifndef RARRAY_PTR
885
+ # define RARRAY_PTR(x) RARRAY(x)->ptr
886
+ #endif
887
+ #ifndef RFLOAT_VALUE
888
+ # define RFLOAT_VALUE(x) RFLOAT(x)->value
889
+ #endif
890
+ #ifndef DOUBLE2NUM
891
+ # define DOUBLE2NUM(x) rb_float_new(x)
892
+ #endif
893
+ #ifndef RHASH_TBL
894
+ # define RHASH_TBL(x) (RHASH(x)->tbl)
895
+ #endif
896
+ #ifndef RHASH_ITER_LEV
897
+ # define RHASH_ITER_LEV(x) (RHASH(x)->iter_lev)
898
+ #endif
899
+ #ifndef RHASH_IFNONE
900
+ # define RHASH_IFNONE(x) (RHASH(x)->ifnone)
901
+ #endif
902
+ #ifndef RHASH_SIZE
903
+ # define RHASH_SIZE(x) (RHASH(x)->tbl->num_entries)
904
+ #endif
905
+ #ifndef RHASH_EMPTY_P
906
+ # define RHASH_EMPTY_P(x) (RHASH_SIZE(x) == 0)
907
+ #endif
908
+ #ifndef RSTRUCT_LEN
909
+ # define RSTRUCT_LEN(x) RSTRUCT(x)->len
910
+ #endif
911
+ #ifndef RSTRUCT_PTR
912
+ # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr
913
+ #endif
914
+
915
+
916
+
917
+ /*
918
+ * Need to be very careful about how these macros are defined, especially
919
+ * when compiling C++ code or C code with an ANSI C compiler.
920
+ *
921
+ * VALUEFUNC(f) is a macro used to typecast a C function that implements
922
+ * a Ruby method so that it can be passed as an argument to API functions
923
+ * like rb_define_method() and rb_define_singleton_method().
924
+ *
925
+ * VOIDFUNC(f) is a macro used to typecast a C function that implements
926
+ * either the "mark" or "free" stuff for a Ruby Data object, so that it
927
+ * can be passed as an argument to API functions like Data_Wrap_Struct()
928
+ * and Data_Make_Struct().
929
+ */
930
+
931
+ #ifdef __cplusplus
932
+ # ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */
933
+ # define PROTECTFUNC(f) ((VALUE (*)()) f)
934
+ # define VALUEFUNC(f) ((VALUE (*)()) f)
935
+ # define VOIDFUNC(f) ((void (*)()) f)
936
+ # else
937
+ # ifndef ANYARGS /* These definitions should work for Ruby 1.6 */
938
+ # define PROTECTFUNC(f) ((VALUE (*)()) f)
939
+ # define VALUEFUNC(f) ((VALUE (*)()) f)
940
+ # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
941
+ # else /* These definitions should work for Ruby 1.7+ */
942
+ # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
943
+ # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
944
+ # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
945
+ # endif
946
+ # endif
947
+ #else
948
+ # define VALUEFUNC(f) (f)
949
+ # define VOIDFUNC(f) (f)
950
+ #endif
951
+
952
+ /* Don't use for expressions have side effect */
953
+ #ifndef RB_STRING_VALUE
954
+ #define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s)))
955
+ #endif
956
+ #ifndef StringValue
957
+ #define StringValue(s) RB_STRING_VALUE(s)
958
+ #endif
959
+ #ifndef StringValuePtr
960
+ #define StringValuePtr(s) RSTRING_PTR(RB_STRING_VALUE(s))
961
+ #endif
962
+ #ifndef StringValueLen
963
+ #define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
964
+ #endif
965
+ #ifndef SafeStringValue
966
+ #define SafeStringValue(v) do {\
967
+ StringValue(v);\
968
+ rb_check_safe_str(v);\
969
+ } while (0)
970
+ #endif
971
+
972
+ #ifndef HAVE_RB_DEFINE_ALLOC_FUNC
973
+ #define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1)
974
+ #define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new")
975
+ #endif
976
+
977
+ static VALUE _mSWIG = Qnil;
978
+
979
+ /* -----------------------------------------------------------------------------
980
+ * error manipulation
981
+ * ----------------------------------------------------------------------------- */
982
+
983
+
984
+ /* Define some additional error types */
985
+ #define SWIG_ObjectPreviouslyDeletedError -100
986
+
987
+
988
+ /* Define custom exceptions for errors that do not map to existing Ruby
989
+ exceptions. Note this only works for C++ since a global cannot be
990
+ initialized by a function in C. For C, fallback to rb_eRuntimeError.*/
991
+
992
+ SWIGINTERN VALUE
993
+ getNullReferenceError(void) {
994
+ static int init = 0;
995
+ static VALUE rb_eNullReferenceError ;
996
+ if (!init) {
997
+ init = 1;
998
+ rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError);
999
+ }
1000
+ return rb_eNullReferenceError;
1001
+ }
1002
+
1003
+ SWIGINTERN VALUE
1004
+ getObjectPreviouslyDeletedError(void) {
1005
+ static int init = 0;
1006
+ static VALUE rb_eObjectPreviouslyDeleted ;
1007
+ if (!init) {
1008
+ init = 1;
1009
+ rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError);
1010
+ }
1011
+ return rb_eObjectPreviouslyDeleted;
1012
+ }
1013
+
1014
+
1015
+ SWIGINTERN VALUE
1016
+ SWIG_Ruby_ErrorType(int SWIG_code) {
1017
+ VALUE type;
1018
+ switch (SWIG_code) {
1019
+ case SWIG_MemoryError:
1020
+ type = rb_eNoMemError;
1021
+ break;
1022
+ case SWIG_IOError:
1023
+ type = rb_eIOError;
1024
+ break;
1025
+ case SWIG_RuntimeError:
1026
+ type = rb_eRuntimeError;
1027
+ break;
1028
+ case SWIG_IndexError:
1029
+ type = rb_eIndexError;
1030
+ break;
1031
+ case SWIG_TypeError:
1032
+ type = rb_eTypeError;
1033
+ break;
1034
+ case SWIG_DivisionByZero:
1035
+ type = rb_eZeroDivError;
1036
+ break;
1037
+ case SWIG_OverflowError:
1038
+ type = rb_eRangeError;
1039
+ break;
1040
+ case SWIG_SyntaxError:
1041
+ type = rb_eSyntaxError;
1042
+ break;
1043
+ case SWIG_ValueError:
1044
+ type = rb_eArgError;
1045
+ break;
1046
+ case SWIG_SystemError:
1047
+ type = rb_eFatal;
1048
+ break;
1049
+ case SWIG_AttributeError:
1050
+ type = rb_eRuntimeError;
1051
+ break;
1052
+ case SWIG_NullReferenceError:
1053
+ type = getNullReferenceError();
1054
+ break;
1055
+ case SWIG_ObjectPreviouslyDeletedError:
1056
+ type = getObjectPreviouslyDeletedError();
1057
+ break;
1058
+ case SWIG_UnknownError:
1059
+ type = rb_eRuntimeError;
1060
+ break;
1061
+ default:
1062
+ type = rb_eRuntimeError;
1063
+ }
1064
+ return type;
1065
+ }
1066
+
1067
+
1068
+ /* This function is called when a user inputs a wrong argument to
1069
+ a method.
1070
+ */
1071
+ SWIGINTERN
1072
+ const char* Ruby_Format_TypeError( const char* msg,
1073
+ const char* type,
1074
+ const char* name,
1075
+ const int argn,
1076
+ VALUE input )
1077
+ {
1078
+ char buf[128];
1079
+ VALUE str;
1080
+ VALUE asStr;
1081
+ if ( msg && *msg )
1082
+ {
1083
+ str = rb_str_new2(msg);
1084
+ }
1085
+ else
1086
+ {
1087
+ str = rb_str_new(NULL, 0);
1088
+ }
1089
+
1090
+ str = rb_str_cat2( str, "Expected argument " );
1091
+ sprintf( buf, "%d of type ", argn-1 );
1092
+ str = rb_str_cat2( str, buf );
1093
+ str = rb_str_cat2( str, type );
1094
+ str = rb_str_cat2( str, ", but got " );
1095
+ str = rb_str_cat2( str, rb_obj_classname(input) );
1096
+ str = rb_str_cat2( str, " " );
1097
+ asStr = rb_inspect(input);
1098
+ if ( RSTRING_LEN(asStr) > 30 )
1099
+ {
1100
+ str = rb_str_cat( str, StringValuePtr(asStr), 30 );
1101
+ str = rb_str_cat2( str, "..." );
1102
+ }
1103
+ else
1104
+ {
1105
+ str = rb_str_append( str, asStr );
1106
+ }
1107
+
1108
+ if ( name )
1109
+ {
1110
+ str = rb_str_cat2( str, "\n\tin SWIG method '" );
1111
+ str = rb_str_cat2( str, name );
1112
+ str = rb_str_cat2( str, "'" );
1113
+ }
1114
+
1115
+ return StringValuePtr( str );
1116
+ }
1117
+
1118
+ /* This function is called when an overloaded method fails */
1119
+ SWIGINTERN
1120
+ void Ruby_Format_OverloadedError(
1121
+ const int argc,
1122
+ const int maxargs,
1123
+ const char* method,
1124
+ const char* prototypes
1125
+ )
1126
+ {
1127
+ const char* msg = "Wrong # of arguments";
1128
+ if ( argc <= maxargs ) msg = "Wrong arguments";
1129
+ rb_raise(rb_eArgError,"%s for overloaded method '%s'.\n"
1130
+ "Possible C/C++ prototypes are:\n%s",
1131
+ msg, method, prototypes);
1132
+ }
1133
+
1134
+ /* -----------------------------------------------------------------------------
1135
+ * rubytracking.swg
1136
+ *
1137
+ * This file contains support for tracking mappings from
1138
+ * Ruby objects to C++ objects. This functionality is needed
1139
+ * to implement mark functions for Ruby's mark and sweep
1140
+ * garbage collector.
1141
+ * ----------------------------------------------------------------------------- */
1142
+
1143
+ #ifdef __cplusplus
1144
+ extern "C" {
1145
+ #endif
1146
+
1147
+ /* Ruby 1.8 actually assumes the first case. */
1148
+ #if SIZEOF_VOIDP == SIZEOF_LONG
1149
+ # define SWIG2NUM(v) LONG2NUM((unsigned long)v)
1150
+ # define NUM2SWIG(x) (unsigned long)NUM2LONG(x)
1151
+ #elif SIZEOF_VOIDP == SIZEOF_LONG_LONG
1152
+ # define SWIG2NUM(v) LL2NUM((unsigned long long)v)
1153
+ # define NUM2SWIG(x) (unsigned long long)NUM2LL(x)
1154
+ #else
1155
+ # error sizeof(void*) is not the same as long or long long
1156
+ #endif
1157
+
1158
+
1159
+ /* Global Ruby hash table to store Trackings from C/C++
1160
+ structs to Ruby Objects.
1161
+ */
1162
+ static VALUE swig_ruby_trackings = Qnil;
1163
+
1164
+ /* Global variable that stores a reference to the ruby
1165
+ hash table delete function. */
1166
+ static ID swig_ruby_hash_delete;
1167
+
1168
+ /* Setup a Ruby hash table to store Trackings */
1169
+ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
1170
+ /* Create a ruby hash table to store Trackings from C++
1171
+ objects to Ruby objects. */
1172
+
1173
+ /* Try to see if some other .so has already created a
1174
+ tracking hash table, which we keep hidden in an instance var
1175
+ in the SWIG module.
1176
+ This is done to allow multiple DSOs to share the same
1177
+ tracking table.
1178
+ */
1179
+ ID trackings_id = rb_intern( "@__trackings__" );
1180
+ VALUE verbose = rb_gv_get("VERBOSE");
1181
+ rb_gv_set("VERBOSE", Qfalse);
1182
+ swig_ruby_trackings = rb_ivar_get( _mSWIG, trackings_id );
1183
+ rb_gv_set("VERBOSE", verbose);
1184
+
1185
+ /* No, it hasn't. Create one ourselves */
1186
+ if ( swig_ruby_trackings == Qnil )
1187
+ {
1188
+ swig_ruby_trackings = rb_hash_new();
1189
+ rb_ivar_set( _mSWIG, trackings_id, swig_ruby_trackings );
1190
+ }
1191
+
1192
+ /* Now store a reference to the hash table delete function
1193
+ so that we only have to look it up once.*/
1194
+ swig_ruby_hash_delete = rb_intern("delete");
1195
+ }
1196
+
1197
+ /* Get a Ruby number to reference a pointer */
1198
+ SWIGRUNTIME VALUE SWIG_RubyPtrToReference(void* ptr) {
1199
+ /* We cast the pointer to an unsigned long
1200
+ and then store a reference to it using
1201
+ a Ruby number object. */
1202
+
1203
+ /* Convert the pointer to a Ruby number */
1204
+ return SWIG2NUM(ptr);
1205
+ }
1206
+
1207
+ /* Get a Ruby number to reference an object */
1208
+ SWIGRUNTIME VALUE SWIG_RubyObjectToReference(VALUE object) {
1209
+ /* We cast the object to an unsigned long
1210
+ and then store a reference to it using
1211
+ a Ruby number object. */
1212
+
1213
+ /* Convert the Object to a Ruby number */
1214
+ return SWIG2NUM(object);
1215
+ }
1216
+
1217
+ /* Get a Ruby object from a previously stored reference */
1218
+ SWIGRUNTIME VALUE SWIG_RubyReferenceToObject(VALUE reference) {
1219
+ /* The provided Ruby number object is a reference
1220
+ to the Ruby object we want.*/
1221
+
1222
+ /* Convert the Ruby number to a Ruby object */
1223
+ return NUM2SWIG(reference);
1224
+ }
1225
+
1226
+ /* Add a Tracking from a C/C++ struct to a Ruby object */
1227
+ SWIGRUNTIME void SWIG_RubyAddTracking(void* ptr, VALUE object) {
1228
+ /* In a Ruby hash table we store the pointer and
1229
+ the associated Ruby object. The trick here is
1230
+ that we cannot store the Ruby object directly - if
1231
+ we do then it cannot be garbage collected. So
1232
+ instead we typecast it as a unsigned long and
1233
+ convert it to a Ruby number object.*/
1234
+
1235
+ /* Get a reference to the pointer as a Ruby number */
1236
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1237
+
1238
+ /* Get a reference to the Ruby object as a Ruby number */
1239
+ VALUE value = SWIG_RubyObjectToReference(object);
1240
+
1241
+ /* Store the mapping to the global hash table. */
1242
+ rb_hash_aset(swig_ruby_trackings, key, value);
1243
+ }
1244
+
1245
+ /* Get the Ruby object that owns the specified C/C++ struct */
1246
+ SWIGRUNTIME VALUE SWIG_RubyInstanceFor(void* ptr) {
1247
+ /* Get a reference to the pointer as a Ruby number */
1248
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1249
+
1250
+ /* Now lookup the value stored in the global hash table */
1251
+ VALUE value = rb_hash_aref(swig_ruby_trackings, key);
1252
+
1253
+ if (value == Qnil) {
1254
+ /* No object exists - return nil. */
1255
+ return Qnil;
1256
+ }
1257
+ else {
1258
+ /* Convert this value to Ruby object */
1259
+ return SWIG_RubyReferenceToObject(value);
1260
+ }
1261
+ }
1262
+
1263
+ /* Remove a Tracking from a C/C++ struct to a Ruby object. It
1264
+ is very important to remove objects once they are destroyed
1265
+ since the same memory address may be reused later to create
1266
+ a new object. */
1267
+ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
1268
+ /* Get a reference to the pointer as a Ruby number */
1269
+ VALUE key = SWIG_RubyPtrToReference(ptr);
1270
+
1271
+ /* Delete the object from the hash table by calling Ruby's
1272
+ do this we need to call the Hash.delete method.*/
1273
+ rb_funcall(swig_ruby_trackings, swig_ruby_hash_delete, 1, key);
1274
+ }
1275
+
1276
+ /* This is a helper method that unlinks a Ruby object from its
1277
+ underlying C++ object. This is needed if the lifetime of the
1278
+ Ruby object is longer than the C++ object */
1279
+ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) {
1280
+ VALUE object = SWIG_RubyInstanceFor(ptr);
1281
+
1282
+ if (object != Qnil) {
1283
+ DATA_PTR(object) = 0;
1284
+ }
1285
+ }
1286
+
1287
+
1288
+ #ifdef __cplusplus
1289
+ }
1290
+ #endif
1291
+
1292
+ /* -----------------------------------------------------------------------------
1293
+ * Ruby API portion that goes into the runtime
1294
+ * ----------------------------------------------------------------------------- */
1295
+
1296
+ #ifdef __cplusplus
1297
+ extern "C" {
1298
+ #endif
1299
+
1300
+ SWIGINTERN VALUE
1301
+ SWIG_Ruby_AppendOutput(VALUE target, VALUE o) {
1302
+ if (NIL_P(target)) {
1303
+ target = o;
1304
+ } else {
1305
+ if (TYPE(target) != T_ARRAY) {
1306
+ VALUE o2 = target;
1307
+ target = rb_ary_new();
1308
+ rb_ary_push(target, o2);
1309
+ }
1310
+ rb_ary_push(target, o);
1311
+ }
1312
+ return target;
1313
+ }
1314
+
1315
+ /* For ruby1.8.4 and earlier. */
1316
+ #ifndef RUBY_INIT_STACK
1317
+ RUBY_EXTERN void Init_stack(VALUE* addr);
1318
+ # define RUBY_INIT_STACK \
1319
+ VALUE variable_in_this_stack_frame; \
1320
+ Init_stack(&variable_in_this_stack_frame);
1321
+ #endif
1322
+
1323
+
1324
+ #ifdef __cplusplus
1325
+ }
1326
+ #endif
1327
+
1328
+
1329
+ /* -----------------------------------------------------------------------------
1330
+ * rubyrun.swg
1331
+ *
1332
+ * This file contains the runtime support for Ruby modules
1333
+ * and includes code for managing global variables and pointer
1334
+ * type checking.
1335
+ * ----------------------------------------------------------------------------- */
1336
+
1337
+ /* For backward compatibility only */
1338
+ #define SWIG_POINTER_EXCEPTION 0
1339
+
1340
+ /* for raw pointers */
1341
+ #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
1342
+ #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Ruby_ConvertPtrAndOwn(obj, pptr, type, flags, own)
1343
+ #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Ruby_NewPointerObj(ptr, type, flags)
1344
+ #define SWIG_AcquirePtr(ptr, own) SWIG_Ruby_AcquirePtr(ptr, own)
1345
+ #define swig_owntype ruby_owntype
1346
+
1347
+ /* for raw packed data */
1348
+ #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags)
1349
+ #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type)
1350
+
1351
+ /* for class or struct pointers */
1352
+ #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
1353
+ #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
1354
+
1355
+ /* for C or C++ function pointers */
1356
+ #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0)
1357
+ #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0)
1358
+
1359
+ /* for C++ member pointers, ie, member methods */
1360
+ #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty)
1361
+ #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Ruby_NewPackedObj(ptr, sz, type)
1362
+
1363
+
1364
+ /* Runtime API */
1365
+
1366
+ #define SWIG_GetModule(clientdata) SWIG_Ruby_GetModule(clientdata)
1367
+ #define SWIG_SetModule(clientdata, pointer) SWIG_Ruby_SetModule(pointer)
1368
+
1369
+
1370
+ /* Error manipulation */
1371
+
1372
+ #define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code)
1373
+ #define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), "%s", msg)
1374
+ #define SWIG_fail goto fail
1375
+
1376
+
1377
+ /* Ruby-specific SWIG API */
1378
+
1379
+ #define SWIG_InitRuntime() SWIG_Ruby_InitRuntime()
1380
+ #define SWIG_define_class(ty) SWIG_Ruby_define_class(ty)
1381
+ #define SWIG_NewClassInstance(value, ty) SWIG_Ruby_NewClassInstance(value, ty)
1382
+ #define SWIG_MangleStr(value) SWIG_Ruby_MangleStr(value)
1383
+ #define SWIG_CheckConvert(value, ty) SWIG_Ruby_CheckConvert(value, ty)
1384
+
1385
+ #include "assert.h"
1386
+
1387
+ /* -----------------------------------------------------------------------------
1388
+ * pointers/data manipulation
1389
+ * ----------------------------------------------------------------------------- */
1390
+
1391
+ #ifdef __cplusplus
1392
+ extern "C" {
1393
+ #endif
1394
+
1395
+ typedef struct {
1396
+ VALUE klass;
1397
+ VALUE mImpl;
1398
+ void (*mark)(void *);
1399
+ void (*destroy)(void *);
1400
+ int trackObjects;
1401
+ } swig_class;
1402
+
1403
+
1404
+ /* Global pointer used to keep some internal SWIG stuff */
1405
+ static VALUE _cSWIG_Pointer = Qnil;
1406
+ static VALUE swig_runtime_data_type_pointer = Qnil;
1407
+
1408
+ /* Global IDs used to keep some internal SWIG stuff */
1409
+ static ID swig_arity_id = 0;
1410
+ static ID swig_call_id = 0;
1411
+
1412
+ /*
1413
+ If your swig extension is to be run within an embedded ruby and has
1414
+ director callbacks, you should set -DRUBY_EMBEDDED during compilation.
1415
+ This will reset ruby's stack frame on each entry point from the main
1416
+ program the first time a virtual director function is invoked (in a
1417
+ non-recursive way).
1418
+ If this is not done, you run the risk of Ruby trashing the stack.
1419
+ */
1420
+
1421
+ #ifdef RUBY_EMBEDDED
1422
+
1423
+ # define SWIG_INIT_STACK \
1424
+ if ( !swig_virtual_calls ) { RUBY_INIT_STACK } \
1425
+ ++swig_virtual_calls;
1426
+ # define SWIG_RELEASE_STACK --swig_virtual_calls;
1427
+ # define Ruby_DirectorTypeMismatchException(x) \
1428
+ rb_raise( rb_eTypeError, "%s", x ); return c_result;
1429
+
1430
+ static unsigned int swig_virtual_calls = 0;
1431
+
1432
+ #else /* normal non-embedded extension */
1433
+
1434
+ # define SWIG_INIT_STACK
1435
+ # define SWIG_RELEASE_STACK
1436
+ # define Ruby_DirectorTypeMismatchException(x) \
1437
+ throw Swig::DirectorTypeMismatchException( x );
1438
+
1439
+ #endif /* RUBY_EMBEDDED */
1440
+
1441
+
1442
+ SWIGRUNTIME VALUE
1443
+ getExceptionClass(void) {
1444
+ static int init = 0;
1445
+ static VALUE rubyExceptionClass ;
1446
+ if (!init) {
1447
+ init = 1;
1448
+ rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception"));
1449
+ }
1450
+ return rubyExceptionClass;
1451
+ }
1452
+
1453
+ /* This code checks to see if the Ruby object being raised as part
1454
+ of an exception inherits from the Ruby class Exception. If so,
1455
+ the object is simply returned. If not, then a new Ruby exception
1456
+ object is created and that will be returned to Ruby.*/
1457
+ SWIGRUNTIME VALUE
1458
+ SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) {
1459
+ VALUE exceptionClass = getExceptionClass();
1460
+ if (rb_obj_is_kind_of(obj, exceptionClass)) {
1461
+ return obj;
1462
+ } else {
1463
+ return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj));
1464
+ }
1465
+ }
1466
+
1467
+ /* Initialize Ruby runtime support */
1468
+ SWIGRUNTIME void
1469
+ SWIG_Ruby_InitRuntime(void)
1470
+ {
1471
+ if (_mSWIG == Qnil) {
1472
+ _mSWIG = rb_define_module("SWIG");
1473
+ swig_call_id = rb_intern("call");
1474
+ swig_arity_id = rb_intern("arity");
1475
+ }
1476
+ }
1477
+
1478
+ /* Define Ruby class for C type */
1479
+ SWIGRUNTIME void
1480
+ SWIG_Ruby_define_class(swig_type_info *type)
1481
+ {
1482
+ VALUE klass;
1483
+ char *klass_name = (char *) malloc(4 + strlen(type->name) + 1);
1484
+ sprintf(klass_name, "TYPE%s", type->name);
1485
+ if (NIL_P(_cSWIG_Pointer)) {
1486
+ _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
1487
+ rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
1488
+ }
1489
+ klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
1490
+ free((void *) klass_name);
1491
+ }
1492
+
1493
+ /* Create a new pointer object */
1494
+ SWIGRUNTIME VALUE
1495
+ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1496
+ {
1497
+ int own = flags & SWIG_POINTER_OWN;
1498
+ int track;
1499
+ char *klass_name;
1500
+ swig_class *sklass;
1501
+ VALUE klass;
1502
+ VALUE obj;
1503
+
1504
+ if (!ptr)
1505
+ return Qnil;
1506
+
1507
+ if (type->clientdata) {
1508
+ sklass = (swig_class *) type->clientdata;
1509
+
1510
+ /* Are we tracking this class and have we already returned this Ruby object? */
1511
+ track = sklass->trackObjects;
1512
+ if (track) {
1513
+ obj = SWIG_RubyInstanceFor(ptr);
1514
+
1515
+ /* Check the object's type and make sure it has the correct type.
1516
+ It might not in cases where methods do things like
1517
+ downcast methods. */
1518
+ if (obj != Qnil) {
1519
+ VALUE value = rb_iv_get(obj, "@__swigtype__");
1520
+ const char* type_name = RSTRING_PTR(value);
1521
+
1522
+ if (strcmp(type->name, type_name) == 0) {
1523
+ return obj;
1524
+ }
1525
+ }
1526
+ }
1527
+
1528
+ /* Create a new Ruby object */
1529
+ obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark),
1530
+ ( own ? VOIDFUNC(sklass->destroy) :
1531
+ (track ? VOIDFUNC(SWIG_RubyRemoveTracking) : 0 )
1532
+ ), ptr);
1533
+
1534
+ /* If tracking is on for this class then track this object. */
1535
+ if (track) {
1536
+ SWIG_RubyAddTracking(ptr, obj);
1537
+ }
1538
+ } else {
1539
+ klass_name = (char *) malloc(4 + strlen(type->name) + 1);
1540
+ sprintf(klass_name, "TYPE%s", type->name);
1541
+ klass = rb_const_get(_mSWIG, rb_intern(klass_name));
1542
+ free((void *) klass_name);
1543
+ obj = Data_Wrap_Struct(klass, 0, 0, ptr);
1544
+ }
1545
+ rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
1546
+
1547
+ return obj;
1548
+ }
1549
+
1550
+ /* Create a new class instance (always owned) */
1551
+ SWIGRUNTIME VALUE
1552
+ SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type)
1553
+ {
1554
+ VALUE obj;
1555
+ swig_class *sklass = (swig_class *) type->clientdata;
1556
+ obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0);
1557
+ rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
1558
+ return obj;
1559
+ }
1560
+
1561
+ /* Get type mangle from class name */
1562
+ SWIGRUNTIMEINLINE char *
1563
+ SWIG_Ruby_MangleStr(VALUE obj)
1564
+ {
1565
+ VALUE stype = rb_iv_get(obj, "@__swigtype__");
1566
+ return StringValuePtr(stype);
1567
+ }
1568
+
1569
+ /* Acquire a pointer value */
1570
+ typedef void (*ruby_owntype)(void*);
1571
+
1572
+ SWIGRUNTIME ruby_owntype
1573
+ SWIG_Ruby_AcquirePtr(VALUE obj, ruby_owntype own) {
1574
+ if (obj) {
1575
+ ruby_owntype oldown = RDATA(obj)->dfree;
1576
+ RDATA(obj)->dfree = own;
1577
+ return oldown;
1578
+ } else {
1579
+ return 0;
1580
+ }
1581
+ }
1582
+
1583
+ /* Convert a pointer value */
1584
+ SWIGRUNTIME int
1585
+ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags, ruby_owntype *own)
1586
+ {
1587
+ char *c;
1588
+ swig_cast_info *tc;
1589
+ void *vptr = 0;
1590
+
1591
+ /* Grab the pointer */
1592
+ if (NIL_P(obj)) {
1593
+ *ptr = 0;
1594
+ return SWIG_OK;
1595
+ } else {
1596
+ if (TYPE(obj) != T_DATA) {
1597
+ return SWIG_ERROR;
1598
+ }
1599
+ Data_Get_Struct(obj, void, vptr);
1600
+ }
1601
+
1602
+ if (own) *own = RDATA(obj)->dfree;
1603
+
1604
+ /* Check to see if the input object is giving up ownership
1605
+ of the underlying C struct or C++ object. If so then we
1606
+ need to reset the destructor since the Ruby object no
1607
+ longer owns the underlying C++ object.*/
1608
+ if (flags & SWIG_POINTER_DISOWN) {
1609
+ /* Is tracking on for this class? */
1610
+ int track = 0;
1611
+ if (ty && ty->clientdata) {
1612
+ swig_class *sklass = (swig_class *) ty->clientdata;
1613
+ track = sklass->trackObjects;
1614
+ }
1615
+
1616
+ if (track) {
1617
+ /* We are tracking objects for this class. Thus we change the destructor
1618
+ * to SWIG_RubyRemoveTracking. This allows us to
1619
+ * remove the mapping from the C++ to Ruby object
1620
+ * when the Ruby object is garbage collected. If we don't
1621
+ * do this, then it is possible we will return a reference
1622
+ * to a Ruby object that no longer exists thereby crashing Ruby. */
1623
+ RDATA(obj)->dfree = SWIG_RubyRemoveTracking;
1624
+ } else {
1625
+ RDATA(obj)->dfree = 0;
1626
+ }
1627
+ }
1628
+
1629
+ /* Do type-checking if type info was provided */
1630
+ if (ty) {
1631
+ if (ty->clientdata) {
1632
+ if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) {
1633
+ if (vptr == 0) {
1634
+ /* The object has already been deleted */
1635
+ return SWIG_ObjectPreviouslyDeletedError;
1636
+ }
1637
+ *ptr = vptr;
1638
+ return SWIG_OK;
1639
+ }
1640
+ }
1641
+ if ((c = SWIG_MangleStr(obj)) == NULL) {
1642
+ return SWIG_ERROR;
1643
+ }
1644
+ tc = SWIG_TypeCheck(c, ty);
1645
+ if (!tc) {
1646
+ return SWIG_ERROR;
1647
+ } else {
1648
+ int newmemory = 0;
1649
+ *ptr = SWIG_TypeCast(tc, vptr, &newmemory);
1650
+ assert(!newmemory); /* newmemory handling not yet implemented */
1651
+ }
1652
+ } else {
1653
+ *ptr = vptr;
1654
+ }
1655
+
1656
+ return SWIG_OK;
1657
+ }
1658
+
1659
+ /* Check convert */
1660
+ SWIGRUNTIMEINLINE int
1661
+ SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty)
1662
+ {
1663
+ char *c = SWIG_MangleStr(obj);
1664
+ if (!c) return 0;
1665
+ return SWIG_TypeCheck(c,ty) != 0;
1666
+ }
1667
+
1668
+ SWIGRUNTIME VALUE
1669
+ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
1670
+ char result[1024];
1671
+ char *r = result;
1672
+ if ((2*sz + 1 + strlen(type->name)) > 1000) return 0;
1673
+ *(r++) = '_';
1674
+ r = SWIG_PackData(r, ptr, sz);
1675
+ strcpy(r, type->name);
1676
+ return rb_str_new2(result);
1677
+ }
1678
+
1679
+ /* Convert a packed value value */
1680
+ SWIGRUNTIME int
1681
+ SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) {
1682
+ swig_cast_info *tc;
1683
+ const char *c;
1684
+
1685
+ if (TYPE(obj) != T_STRING) goto type_error;
1686
+ c = StringValuePtr(obj);
1687
+ /* Pointer values must start with leading underscore */
1688
+ if (*c != '_') goto type_error;
1689
+ c++;
1690
+ c = SWIG_UnpackData(c, ptr, sz);
1691
+ if (ty) {
1692
+ tc = SWIG_TypeCheck(c, ty);
1693
+ if (!tc) goto type_error;
1694
+ }
1695
+ return SWIG_OK;
1696
+
1697
+ type_error:
1698
+ return SWIG_ERROR;
1699
+ }
1700
+
1701
+ SWIGRUNTIME swig_module_info *
1702
+ SWIG_Ruby_GetModule(void *SWIGUNUSEDPARM(clientdata))
1703
+ {
1704
+ VALUE pointer;
1705
+ swig_module_info *ret = 0;
1706
+ VALUE verbose = rb_gv_get("VERBOSE");
1707
+
1708
+ /* temporarily disable warnings, since the pointer check causes warnings with 'ruby -w' */
1709
+ rb_gv_set("VERBOSE", Qfalse);
1710
+
1711
+ /* first check if pointer already created */
1712
+ pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
1713
+ if (pointer != Qnil) {
1714
+ Data_Get_Struct(pointer, swig_module_info, ret);
1715
+ }
1716
+
1717
+ /* reinstate warnings */
1718
+ rb_gv_set("VERBOSE", verbose);
1719
+ return ret;
1720
+ }
1721
+
1722
+ SWIGRUNTIME void
1723
+ SWIG_Ruby_SetModule(swig_module_info *pointer)
1724
+ {
1725
+ /* register a new class */
1726
+ VALUE cl = rb_define_class("swig_runtime_data", rb_cObject);
1727
+ /* create and store the structure pointer to a global variable */
1728
+ swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer);
1729
+ rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);
1730
+ }
1731
+
1732
+ /* This function can be used to check whether a proc or method or similarly
1733
+ callable function has been passed. Usually used in a %typecheck, like:
1734
+
1735
+ %typecheck(c_callback_t, precedence=SWIG_TYPECHECK_POINTER) {
1736
+ $result = SWIG_Ruby_isCallable( $input );
1737
+ }
1738
+ */
1739
+ SWIGINTERN
1740
+ int SWIG_Ruby_isCallable( VALUE proc )
1741
+ {
1742
+ if ( rb_respond_to( proc, swig_call_id ) )
1743
+ return 1;
1744
+ return 0;
1745
+ }
1746
+
1747
+ /* This function can be used to check the arity (number of arguments)
1748
+ a proc or method can take. Usually used in a %typecheck.
1749
+ Valid arities will be that equal to minimal or those < 0
1750
+ which indicate a variable number of parameters at the end.
1751
+ */
1752
+ SWIGINTERN
1753
+ int SWIG_Ruby_arity( VALUE proc, int minimal )
1754
+ {
1755
+ if ( rb_respond_to( proc, swig_arity_id ) )
1756
+ {
1757
+ VALUE num = rb_funcall( proc, swig_arity_id, 0 );
1758
+ int arity = NUM2INT(num);
1759
+ if ( arity < 0 && (arity+1) < -minimal ) return 1;
1760
+ if ( arity == minimal ) return 1;
1761
+ return 1;
1762
+ }
1763
+ return 0;
1764
+ }
1765
+
1766
+
1767
+ #ifdef __cplusplus
1768
+ }
1769
+ #endif
1770
+
1771
+
1772
+
1773
+ #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
1774
+
1775
+ #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
1776
+
1777
+
1778
+
1779
+ #define SWIG_exception(code, msg) do { SWIG_Error(code, msg);; } while(0)
1780
+
1781
+
1782
+ /* -------- TYPES TABLE (BEGIN) -------- */
1783
+
1784
+ #define SWIGTYPE_p_char swig_types[0]
1785
+ #define SWIGTYPE_p_in_addr_t swig_types[1]
1786
+ #define SWIGTYPE_p_unsigned_char swig_types[2]
1787
+ #define SWIGTYPE_p_unsigned_short swig_types[3]
1788
+ static swig_type_info *swig_types[5];
1789
+ static swig_module_info swig_module = {swig_types, 4, 0, 0, 0, 0};
1790
+ #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
1791
+ #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
1792
+
1793
+ /* -------- TYPES TABLE (END) -------- */
1794
+
1795
+ #define SWIG_init Init_undns
1796
+ #define SWIG_name "Undns"
1797
+
1798
+ static VALUE mUndns;
1799
+
1800
+ #define SWIG_RUBY_THREAD_BEGIN_BLOCK
1801
+ #define SWIG_RUBY_THREAD_END_BLOCK
1802
+
1803
+
1804
+ #define SWIGVERSION 0x020012
1805
+ #define SWIG_VERSION SWIGVERSION
1806
+
1807
+
1808
+ #define SWIG_as_voidptr(a) (void *)((const void *)(a))
1809
+ #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
1810
+
1811
+
1812
+ /* conflicts with ruby's autoconf'd ness */
1813
+ #undef PACKAGE_VERSION
1814
+ #undef PACKAGE_NAME
1815
+ #undef PACKAGE_STRING
1816
+ #undef PACKAGE_TARNAME
1817
+ #undef PACKAGE_BUGREPORT
1818
+ /* conflicts internally with regex.h, so when loading the ruby stuff,
1819
+ force its regex stuff away */
1820
+ #ifdef SWIGRUBY
1821
+ #define re_pattern_buffer mangled_re_pattern_buffer
1822
+ #ifdef HAVE_RUBY_IO_H
1823
+ #include "ruby/io.h"
1824
+ #endif
1825
+ #include "my_ruby.h"
1826
+ #undef re_pattern_buffer
1827
+ #endif
1828
+ #include "originAS.h"
1829
+ #include "ruleset.h"
1830
+ #include "earth.h"
1831
+ #include <stdbool.h>
1832
+
1833
+ /* appears to fix something odd in the mac mountain lion build, where whatever version of C is being used
1834
+ doesn't trigger the definition of _Bool */
1835
+ /* but then breaks in mavericks */
1836
+ #ifndef _Bool
1837
+ #ifndef bool
1838
+ #define bool unsigned char
1839
+ #endif
1840
+ #endif
1841
+
1842
+ bool want_debug;
1843
+ bool want_conventions_debug;
1844
+
1845
+ #ifdef SWIGRUBY
1846
+ static VALUE class_IPAddr;
1847
+ #endif
1848
+
1849
+ /* technique from swig manual */
1850
+ static char error_message[256];
1851
+ static int error_status = 0;
1852
+ void throw_exception(char *msg) {
1853
+ strncpy(error_message, msg, 255);
1854
+ error_message[255] = '\0';
1855
+ error_status = 1;
1856
+ }
1857
+ void clear_exception(void) {
1858
+ error_status = 0;
1859
+ }
1860
+ const char *check_exception(void) {
1861
+ if(error_status) return error_message;
1862
+ else return NULL;
1863
+ }
1864
+
1865
+
1866
+ SWIGINTERNINLINE VALUE
1867
+ SWIG_From_bool (bool value)
1868
+ {
1869
+ return value ? Qtrue : Qfalse;
1870
+ }
1871
+
1872
+
1873
+ #include <limits.h>
1874
+ #if !defined(SWIG_NO_LLONG_MAX)
1875
+ # if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
1876
+ # define LLONG_MAX __LONG_LONG_MAX__
1877
+ # define LLONG_MIN (-LLONG_MAX - 1LL)
1878
+ # define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
1879
+ # endif
1880
+ #endif
1881
+
1882
+
1883
+ SWIGINTERN VALUE
1884
+ SWIG_ruby_failed(void)
1885
+ {
1886
+ return Qnil;
1887
+ }
1888
+
1889
+
1890
+ /*@SWIG:/usr/share/swig2.0/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
1891
+ SWIGINTERN VALUE SWIG_AUX_NUM2LONG(VALUE *args)
1892
+ {
1893
+ VALUE obj = args[0];
1894
+ VALUE type = TYPE(obj);
1895
+ long *res = (long *)(args[1]);
1896
+ *res = type == T_FIXNUM ? NUM2LONG(obj) : rb_big2long(obj);
1897
+ return obj;
1898
+ }
1899
+ /*@SWIG@*/
1900
+
1901
+ SWIGINTERN int
1902
+ SWIG_AsVal_long (VALUE obj, long* val)
1903
+ {
1904
+ VALUE type = TYPE(obj);
1905
+ if ((type == T_FIXNUM) || (type == T_BIGNUM)) {
1906
+ long v;
1907
+ VALUE a[2];
1908
+ a[0] = obj;
1909
+ a[1] = (VALUE)(&v);
1910
+ if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
1911
+ if (val) *val = v;
1912
+ return SWIG_OK;
1913
+ }
1914
+ }
1915
+ return SWIG_TypeError;
1916
+ }
1917
+
1918
+
1919
+ SWIGINTERN int
1920
+ SWIG_AsVal_int (VALUE obj, int *val)
1921
+ {
1922
+ long v;
1923
+ int res = SWIG_AsVal_long (obj, &v);
1924
+ if (SWIG_IsOK(res)) {
1925
+ if ((v < INT_MIN || v > INT_MAX)) {
1926
+ return SWIG_OverflowError;
1927
+ } else {
1928
+ if (val) *val = (int)(v);
1929
+ }
1930
+ }
1931
+ return res;
1932
+ }
1933
+
1934
+
1935
+ SWIGINTERN int
1936
+ SWIG_AsVal_bool (VALUE obj, bool *val)
1937
+ {
1938
+ if (obj == Qtrue) {
1939
+ if (val) *val = true;
1940
+ return SWIG_OK;
1941
+ } else if (obj == Qfalse) {
1942
+ if (val) *val = false;
1943
+ return SWIG_OK;
1944
+ } else {
1945
+ int res = 0;
1946
+ if (SWIG_AsVal_int (obj, &res) == SWIG_OK) {
1947
+ if (val) *val = res ? true : false;
1948
+ return SWIG_OK;
1949
+ }
1950
+ }
1951
+ return SWIG_TypeError;
1952
+ }
1953
+
1954
+
1955
+ SWIGINTERN swig_type_info*
1956
+ SWIG_pchar_descriptor(void)
1957
+ {
1958
+ static int init = 0;
1959
+ static swig_type_info* info = 0;
1960
+ if (!init) {
1961
+ info = SWIG_TypeQuery("_p_char");
1962
+ init = 1;
1963
+ }
1964
+ return info;
1965
+ }
1966
+
1967
+
1968
+ SWIGINTERNINLINE VALUE
1969
+ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
1970
+ {
1971
+ if (carray) {
1972
+ if (size > LONG_MAX) {
1973
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
1974
+ return pchar_descriptor ?
1975
+ SWIG_NewPointerObj((char *)(carray), pchar_descriptor, 0) : Qnil;
1976
+ } else {
1977
+ return rb_str_new(carray, (long)(size));
1978
+ }
1979
+ } else {
1980
+ return Qnil;
1981
+ }
1982
+ }
1983
+
1984
+
1985
+ SWIGINTERNINLINE VALUE
1986
+ SWIG_FromCharPtr(const char *cptr)
1987
+ {
1988
+ return SWIG_FromCharPtrAndSize(cptr, (cptr ? strlen(cptr) : 0));
1989
+ }
1990
+
1991
+
1992
+ SWIGINTERN int
1993
+ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)
1994
+ {
1995
+ if (TYPE(obj) == T_STRING) {
1996
+ char *cstr = StringValuePtr(obj);
1997
+ size_t size = RSTRING_LEN(obj) + 1;
1998
+ if (cptr) {
1999
+ if (alloc) {
2000
+ if (*alloc == SWIG_NEWOBJ) {
2001
+ *cptr = (char *)memcpy((char *)malloc((size)*sizeof(char)), cstr, sizeof(char)*(size));
2002
+ } else {
2003
+ *cptr = cstr;
2004
+ *alloc = SWIG_OLDOBJ;
2005
+ }
2006
+ }
2007
+ }
2008
+ if (psize) *psize = size;
2009
+ return SWIG_OK;
2010
+ } else {
2011
+ swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
2012
+ if (pchar_descriptor) {
2013
+ void* vptr = 0;
2014
+ if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) {
2015
+ if (cptr) *cptr = (char *)vptr;
2016
+ if (psize) *psize = vptr ? (strlen((char*)vptr) + 1) : 0;
2017
+ if (alloc) *alloc = SWIG_OLDOBJ;
2018
+ return SWIG_OK;
2019
+ }
2020
+ }
2021
+ }
2022
+ return SWIG_TypeError;
2023
+ }
2024
+
2025
+
2026
+
2027
+
2028
+
2029
+ #define SWIG_From_long LONG2NUM
2030
+
2031
+
2032
+ SWIGINTERNINLINE VALUE
2033
+ SWIG_From_int (int value)
2034
+ {
2035
+ return SWIG_From_long (value);
2036
+ }
2037
+
2038
+
2039
+ #ifdef __cplusplus
2040
+ extern "C" {
2041
+ #endif
2042
+
2043
+ // Ruby 1.9 changed the file name of this header
2044
+ #ifdef HAVE_RUBY_IO_H
2045
+ #include "ruby/io.h"
2046
+ #else
2047
+ #include "rubyio.h"
2048
+ #endif
2049
+
2050
+ #ifdef __cplusplus
2051
+ }
2052
+ #endif
2053
+
2054
+
2055
+ #ifdef __cplusplus
2056
+ extern "C" {
2057
+ #endif
2058
+ #ifdef HAVE_SYS_TIME_H
2059
+ # include <sys/time.h>
2060
+ struct timeval rb_time_timeval(VALUE);
2061
+ #endif
2062
+ #ifdef __cplusplus
2063
+ }
2064
+ #endif
2065
+
2066
+
2067
+ SWIGINTERNINLINE VALUE
2068
+ SWIG_From_unsigned_SS_long (unsigned long value)
2069
+ {
2070
+ return ULONG2NUM(value);
2071
+ }
2072
+
2073
+
2074
+ SWIGINTERNINLINE VALUE
2075
+ SWIG_From_unsigned_SS_short (unsigned short value)
2076
+ {
2077
+ return SWIG_From_unsigned_SS_long (value);
2078
+ }
2079
+
2080
+
2081
+ #define output_helper SWIG_Ruby_AppendOutput
2082
+
2083
+
2084
+ SWIGINTERNINLINE VALUE
2085
+ SWIG_From_unsigned_SS_char (unsigned char value)
2086
+ {
2087
+ return SWIG_From_unsigned_SS_long (value);
2088
+ }
2089
+
2090
+
2091
+ #define SWIG_From_double rb_float_new
2092
+
2093
+ SWIGINTERN VALUE
2094
+ _wrap_want_debug_get(VALUE self) {
2095
+ VALUE _val;
2096
+
2097
+ _val = SWIG_From_bool((bool)(want_debug));
2098
+ return _val;
2099
+ }
2100
+
2101
+
2102
+ SWIGINTERN VALUE
2103
+ _wrap_want_debug_set(VALUE self, VALUE _val) {
2104
+ {
2105
+ bool val;
2106
+ int res = SWIG_AsVal_bool(_val, &val);
2107
+ if (!SWIG_IsOK(res)) {
2108
+ SWIG_exception_fail(SWIG_ArgError(res), "in variable '""want_debug""' of type '""bool""'");
2109
+ }
2110
+ want_debug = (bool)(val);
2111
+ }
2112
+ return _val;
2113
+ fail:
2114
+ return Qnil;
2115
+ }
2116
+
2117
+
2118
+ SWIGINTERN VALUE
2119
+ _wrap_want_conventions_debug_get(VALUE self) {
2120
+ VALUE _val;
2121
+
2122
+ _val = SWIG_From_bool((bool)(want_conventions_debug));
2123
+ return _val;
2124
+ }
2125
+
2126
+
2127
+ SWIGINTERN VALUE
2128
+ _wrap_want_conventions_debug_set(VALUE self, VALUE _val) {
2129
+ {
2130
+ bool val;
2131
+ int res = SWIG_AsVal_bool(_val, &val);
2132
+ if (!SWIG_IsOK(res)) {
2133
+ SWIG_exception_fail(SWIG_ArgError(res), "in variable '""want_conventions_debug""' of type '""bool""'");
2134
+ }
2135
+ want_conventions_debug = (bool)(val);
2136
+ }
2137
+ return _val;
2138
+ fail:
2139
+ return Qnil;
2140
+ }
2141
+
2142
+
2143
+ SWIGINTERN VALUE
2144
+ _wrap_ruleset_path_get(VALUE self) {
2145
+ VALUE _val;
2146
+
2147
+ _val = SWIG_FromCharPtr(ruleset_path);
2148
+ return _val;
2149
+ }
2150
+
2151
+
2152
+ SWIGINTERN VALUE
2153
+ _wrap_ruleset_path_set(VALUE self, VALUE _val) {
2154
+ {
2155
+ char *cptr = 0; size_t csize = 0; int alloc = SWIG_NEWOBJ;
2156
+ int res = SWIG_AsCharPtrAndSize(_val, &cptr, &csize, &alloc);
2157
+ if (!SWIG_IsOK(res)) {
2158
+ SWIG_exception_fail(SWIG_ArgError(res), "in variable '""ruleset_path""' of type '""char const *""'");
2159
+ }
2160
+ if (alloc == SWIG_NEWOBJ) {
2161
+ ruleset_path = cptr;
2162
+ } else {
2163
+ ruleset_path = csize ? (char const *)(char *)memcpy((char *)malloc((csize)*sizeof(char)), cptr, sizeof(char)*(csize)) : 0;
2164
+ }
2165
+ }
2166
+ return _val;
2167
+ fail:
2168
+ return Qnil;
2169
+ }
2170
+
2171
+
2172
+ SWIGINTERN VALUE
2173
+ _wrap_get_loc(int argc, VALUE *argv, VALUE self) {
2174
+ int arg1 ;
2175
+ char *arg2 = (char *) 0 ;
2176
+ int val1 ;
2177
+ int ecode1 = 0 ;
2178
+ int res2 ;
2179
+ char *buf2 = 0 ;
2180
+ int alloc2 = 0 ;
2181
+ char *result = 0 ;
2182
+ VALUE vresult = Qnil;
2183
+
2184
+ if ((argc < 2) || (argc > 2)) {
2185
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2186
+ }
2187
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2188
+ if (!SWIG_IsOK(ecode1)) {
2189
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","get_loc", 1, argv[0] ));
2190
+ }
2191
+ arg1 = (int)(val1);
2192
+ res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2);
2193
+ if (!SWIG_IsOK(res2)) {
2194
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","get_loc", 2, argv[1] ));
2195
+ }
2196
+ arg2 = (char *)(buf2);
2197
+ result = (char *)get_loc(arg1,(char const *)arg2);
2198
+ vresult = SWIG_FromCharPtr((const char *)result);
2199
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2200
+ return vresult;
2201
+ fail:
2202
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2203
+ return Qnil;
2204
+ }
2205
+
2206
+
2207
+ SWIGINTERN VALUE
2208
+ _wrap_get_role(int argc, VALUE *argv, VALUE self) {
2209
+ int arg1 ;
2210
+ char *arg2 = (char *) 0 ;
2211
+ int val1 ;
2212
+ int ecode1 = 0 ;
2213
+ int res2 ;
2214
+ char *buf2 = 0 ;
2215
+ int alloc2 = 0 ;
2216
+ char *result = 0 ;
2217
+ VALUE vresult = Qnil;
2218
+
2219
+ if ((argc < 2) || (argc > 2)) {
2220
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2221
+ }
2222
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2223
+ if (!SWIG_IsOK(ecode1)) {
2224
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","get_role", 1, argv[0] ));
2225
+ }
2226
+ arg1 = (int)(val1);
2227
+ res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2);
2228
+ if (!SWIG_IsOK(res2)) {
2229
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","get_role", 2, argv[1] ));
2230
+ }
2231
+ arg2 = (char *)(buf2);
2232
+ result = (char *)get_role(arg1,(char const *)arg2);
2233
+ vresult = SWIG_FromCharPtr((const char *)result);
2234
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2235
+ return vresult;
2236
+ fail:
2237
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2238
+ return Qnil;
2239
+ }
2240
+
2241
+
2242
+ SWIGINTERN VALUE
2243
+ _wrap_get_asn_bydns(int argc, VALUE *argv, VALUE self) {
2244
+ char *arg1 = (char *) 0 ;
2245
+ int res1 ;
2246
+ char *buf1 = 0 ;
2247
+ int alloc1 = 0 ;
2248
+ int result;
2249
+ VALUE vresult = Qnil;
2250
+
2251
+ if ((argc < 1) || (argc > 1)) {
2252
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2253
+ }
2254
+ res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1);
2255
+ if (!SWIG_IsOK(res1)) {
2256
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","get_asn_bydns", 1, argv[0] ));
2257
+ }
2258
+ arg1 = (char *)(buf1);
2259
+ result = (int)get_asn_bydns((char const *)arg1);
2260
+ vresult = SWIG_From_int((int)(result));
2261
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2262
+ return vresult;
2263
+ fail:
2264
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2265
+ return Qnil;
2266
+ }
2267
+
2268
+
2269
+ SWIGINTERN VALUE
2270
+ _wrap_doubt_location(int argc, VALUE *argv, VALUE self) {
2271
+ int arg1 ;
2272
+ char *arg2 = (char *) 0 ;
2273
+ int val1 ;
2274
+ int ecode1 = 0 ;
2275
+ int res2 ;
2276
+ char *buf2 = 0 ;
2277
+ int alloc2 = 0 ;
2278
+
2279
+ if ((argc < 2) || (argc > 2)) {
2280
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2281
+ }
2282
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2283
+ if (!SWIG_IsOK(ecode1)) {
2284
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","doubt_location", 1, argv[0] ));
2285
+ }
2286
+ arg1 = (int)(val1);
2287
+ res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2);
2288
+ if (!SWIG_IsOK(res2)) {
2289
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","doubt_location", 2, argv[1] ));
2290
+ }
2291
+ arg2 = (char *)(buf2);
2292
+ doubt_location(arg1,(char const *)arg2);
2293
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2294
+ return Qnil;
2295
+ fail:
2296
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2297
+ return Qnil;
2298
+ }
2299
+
2300
+
2301
+ SWIGINTERN VALUE
2302
+ _wrap_get_identifier(int argc, VALUE *argv, VALUE self) {
2303
+ int arg1 ;
2304
+ char *arg2 = (char *) 0 ;
2305
+ int val1 ;
2306
+ int ecode1 = 0 ;
2307
+ int res2 ;
2308
+ char *buf2 = 0 ;
2309
+ int alloc2 = 0 ;
2310
+ char *result = 0 ;
2311
+ VALUE vresult = Qnil;
2312
+
2313
+ if ((argc < 2) || (argc > 2)) {
2314
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2315
+ }
2316
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2317
+ if (!SWIG_IsOK(ecode1)) {
2318
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","get_identifier", 1, argv[0] ));
2319
+ }
2320
+ arg1 = (int)(val1);
2321
+ res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2);
2322
+ if (!SWIG_IsOK(res2)) {
2323
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","get_identifier", 2, argv[1] ));
2324
+ }
2325
+ arg2 = (char *)(buf2);
2326
+ result = (char *)get_identifier(arg1,(char const *)arg2);
2327
+ vresult = SWIG_FromCharPtr((const char *)result);
2328
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2329
+ return vresult;
2330
+ fail:
2331
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2332
+ return Qnil;
2333
+ }
2334
+
2335
+
2336
+ SWIGINTERN VALUE
2337
+ _wrap_get_poptag(int argc, VALUE *argv, VALUE self) {
2338
+ int arg1 ;
2339
+ char *arg2 = (char *) 0 ;
2340
+ int val1 ;
2341
+ int ecode1 = 0 ;
2342
+ int res2 ;
2343
+ char *buf2 = 0 ;
2344
+ int alloc2 = 0 ;
2345
+ char *result = 0 ;
2346
+ VALUE vresult = Qnil;
2347
+
2348
+ if ((argc < 2) || (argc > 2)) {
2349
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2350
+ }
2351
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2352
+ if (!SWIG_IsOK(ecode1)) {
2353
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","get_poptag", 1, argv[0] ));
2354
+ }
2355
+ arg1 = (int)(val1);
2356
+ res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2);
2357
+ if (!SWIG_IsOK(res2)) {
2358
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","get_poptag", 2, argv[1] ));
2359
+ }
2360
+ arg2 = (char *)(buf2);
2361
+ result = (char *)get_poptag(arg1,(char const *)arg2);
2362
+ vresult = SWIG_FromCharPtr((const char *)result);
2363
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2364
+ return vresult;
2365
+ fail:
2366
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2367
+ return Qnil;
2368
+ }
2369
+
2370
+
2371
+ SWIGINTERN VALUE
2372
+ _wrap_origin_prefix_for_address(int argc, VALUE *argv, VALUE self) {
2373
+ in_addr_t arg1 ;
2374
+ unsigned short *arg2 = (unsigned short *) 0 ;
2375
+ in_addr_t *arg3 = (in_addr_t *) 0 ;
2376
+ unsigned char *arg4 = (unsigned char *) 0 ;
2377
+ unsigned short temp2 ;
2378
+ int res2 = SWIG_TMPOBJ ;
2379
+ in_addr_t temp3 ;
2380
+ unsigned char temp4 ;
2381
+ int res4 = SWIG_TMPOBJ ;
2382
+ boolean result;
2383
+ VALUE vresult = Qnil;
2384
+
2385
+ arg2 = &temp2;
2386
+ arg3 = &temp3;
2387
+ arg4 = &temp4;
2388
+ if ((argc < 1) || (argc > 1)) {
2389
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2390
+ }
2391
+ {
2392
+ // printf("called typemap in on %d\n", TYPE(argv[0]));
2393
+ if (TYPE(argv[0]) == T_STRING) {
2394
+ SWIG_exception(SWIG_RuntimeError, "can't call function that expects in_addr_t with a string (conversion doesn't work). Call IPAddr.new(string) or convert to an integer first");
2395
+ }
2396
+ arg1 = htonl(NUM2UINT(rb_funcall(argv[0], rb_intern("to_i"), 0)));
2397
+ }
2398
+ {
2399
+ const char *err;
2400
+ clear_exception();
2401
+ result = origin_prefix_for_address(arg1,arg2,arg3,arg4);
2402
+ if((err = check_exception())) {
2403
+ SWIG_exception(SWIG_RuntimeError, (char *)err);
2404
+ }
2405
+ }
2406
+ {
2407
+ // printf("called typemap bool\n");
2408
+ vresult = (result) ? Qtrue : Qfalse;
2409
+ }
2410
+ if (SWIG_IsTmpObj(res2)) {
2411
+ vresult = SWIG_Ruby_AppendOutput(vresult, SWIG_From_unsigned_SS_short((*arg2)));
2412
+ } else {
2413
+ int new_flags = SWIG_IsNewObj(res2) ? (SWIG_POINTER_OWN | 0 ) : 0 ;
2414
+ vresult = SWIG_Ruby_AppendOutput(vresult, SWIG_NewPointerObj((void*)(arg2), SWIGTYPE_p_unsigned_short, new_flags));
2415
+ }
2416
+ {
2417
+ VALUE o = rb_funcall(class_IPAddr, rb_intern("new"), 1, UINT2NUM(htonl(*arg3)));
2418
+ // printf("creating addr from %p 0x%x\n", arg3, *arg3);
2419
+ vresult = output_helper(vresult, o);
2420
+ }
2421
+ if (SWIG_IsTmpObj(res4)) {
2422
+ vresult = SWIG_Ruby_AppendOutput(vresult, SWIG_From_unsigned_SS_char((*arg4)));
2423
+ } else {
2424
+ int new_flags = SWIG_IsNewObj(res4) ? (SWIG_POINTER_OWN | 0 ) : 0 ;
2425
+ vresult = SWIG_Ruby_AppendOutput(vresult, SWIG_NewPointerObj((void*)(arg4), SWIGTYPE_p_unsigned_char, new_flags));
2426
+ }
2427
+ return vresult;
2428
+ fail:
2429
+ return Qnil;
2430
+ }
2431
+
2432
+
2433
+ SWIGINTERN VALUE
2434
+ _wrap_load_ruleset(int argc, VALUE *argv, VALUE self) {
2435
+ char *arg1 = (char *) "Conventions.dat" ;
2436
+ int res1 ;
2437
+ char *buf1 = 0 ;
2438
+ int alloc1 = 0 ;
2439
+
2440
+ if ((argc < 0) || (argc > 1)) {
2441
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2442
+ }
2443
+ if (argc > 0) {
2444
+ res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1);
2445
+ if (!SWIG_IsOK(res1)) {
2446
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","load_ruleset", 1, argv[0] ));
2447
+ }
2448
+ arg1 = (char *)(buf1);
2449
+ }
2450
+ {
2451
+ const char *err;
2452
+ clear_exception();
2453
+ load_ruleset((char const *)arg1);
2454
+ if((err = check_exception())) {
2455
+ SWIG_exception(SWIG_RuntimeError, (char *)err);
2456
+ }
2457
+ }
2458
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2459
+ return Qnil;
2460
+ fail:
2461
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2462
+ return Qnil;
2463
+ }
2464
+
2465
+
2466
+ SWIGINTERN VALUE
2467
+ _wrap_origins_init(int argc, VALUE *argv, VALUE self) {
2468
+ char *arg1 = (char *) "origins.dat" ;
2469
+ int res1 ;
2470
+ char *buf1 = 0 ;
2471
+ int alloc1 = 0 ;
2472
+
2473
+ if ((argc < 0) || (argc > 1)) {
2474
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 0)",argc); SWIG_fail;
2475
+ }
2476
+ if (argc > 0) {
2477
+ res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1);
2478
+ if (!SWIG_IsOK(res1)) {
2479
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","origins_init", 1, argv[0] ));
2480
+ }
2481
+ arg1 = (char *)(buf1);
2482
+ }
2483
+ {
2484
+ const char *err;
2485
+ clear_exception();
2486
+ origins_init((char const *)arg1);
2487
+ if((err = check_exception())) {
2488
+ SWIG_exception(SWIG_RuntimeError, (char *)err);
2489
+ }
2490
+ }
2491
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2492
+ return Qnil;
2493
+ fail:
2494
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2495
+ return Qnil;
2496
+ }
2497
+
2498
+
2499
+ SWIGINTERN VALUE
2500
+ _wrap_origin_for_address_str(int argc, VALUE *argv, VALUE self) {
2501
+ char *arg1 = (char *) 0 ;
2502
+ int res1 ;
2503
+ char *buf1 = 0 ;
2504
+ int alloc1 = 0 ;
2505
+ unsigned short result;
2506
+ VALUE vresult = Qnil;
2507
+
2508
+ if ((argc < 1) || (argc > 1)) {
2509
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2510
+ }
2511
+ res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1);
2512
+ if (!SWIG_IsOK(res1)) {
2513
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","origin_for_address_str", 1, argv[0] ));
2514
+ }
2515
+ arg1 = (char *)(buf1);
2516
+ {
2517
+ const char *err;
2518
+ clear_exception();
2519
+ result = (unsigned short)origin_for_address_str((char const *)arg1);
2520
+ if((err = check_exception())) {
2521
+ SWIG_exception(SWIG_RuntimeError, (char *)err);
2522
+ }
2523
+ }
2524
+ vresult = SWIG_From_unsigned_SS_short((unsigned short)(result));
2525
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2526
+ return vresult;
2527
+ fail:
2528
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2529
+ return Qnil;
2530
+ }
2531
+
2532
+
2533
+ SWIGINTERN VALUE
2534
+ _wrap_dump_parsed_conventions_to_file(int argc, VALUE *argv, VALUE self) {
2535
+ char *arg1 = (char *) 0 ;
2536
+ int res1 ;
2537
+ char *buf1 = 0 ;
2538
+ int alloc1 = 0 ;
2539
+
2540
+ if ((argc < 1) || (argc > 1)) {
2541
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2542
+ }
2543
+ res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1);
2544
+ if (!SWIG_IsOK(res1)) {
2545
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","dump_parsed_conventions_to_file", 1, argv[0] ));
2546
+ }
2547
+ arg1 = (char *)(buf1);
2548
+ {
2549
+ const char *err;
2550
+ clear_exception();
2551
+ dump_parsed_conventions_to_file((char const *)arg1);
2552
+ if((err = check_exception())) {
2553
+ SWIG_exception(SWIG_RuntimeError, (char *)err);
2554
+ }
2555
+ }
2556
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2557
+ return Qnil;
2558
+ fail:
2559
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2560
+ return Qnil;
2561
+ }
2562
+
2563
+
2564
+ SWIGINTERN VALUE
2565
+ _wrap_dump_single_asn_conventions_to_file(int argc, VALUE *argv, VALUE self) {
2566
+ int arg1 ;
2567
+ char *arg2 = (char *) 0 ;
2568
+ int val1 ;
2569
+ int ecode1 = 0 ;
2570
+ int res2 ;
2571
+ char *buf2 = 0 ;
2572
+ int alloc2 = 0 ;
2573
+
2574
+ if ((argc < 2) || (argc > 2)) {
2575
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2576
+ }
2577
+ ecode1 = SWIG_AsVal_int(argv[0], &val1);
2578
+ if (!SWIG_IsOK(ecode1)) {
2579
+ SWIG_exception_fail(SWIG_ArgError(ecode1), Ruby_Format_TypeError( "", "int","dump_single_asn_conventions_to_file", 1, argv[0] ));
2580
+ }
2581
+ arg1 = (int)(val1);
2582
+ res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2);
2583
+ if (!SWIG_IsOK(res2)) {
2584
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","dump_single_asn_conventions_to_file", 2, argv[1] ));
2585
+ }
2586
+ arg2 = (char *)(buf2);
2587
+ {
2588
+ const char *err;
2589
+ clear_exception();
2590
+ dump_single_asn_conventions_to_file(arg1,(char const *)arg2);
2591
+ if((err = check_exception())) {
2592
+ SWIG_exception(SWIG_RuntimeError, (char *)err);
2593
+ }
2594
+ }
2595
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2596
+ return Qnil;
2597
+ fail:
2598
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2599
+ return Qnil;
2600
+ }
2601
+
2602
+
2603
+ SWIGINTERN VALUE
2604
+ _wrap_init_earth(int argc, VALUE *argv, VALUE self) {
2605
+ char *arg1 = (char *) 0 ;
2606
+ int res1 ;
2607
+ char *buf1 = 0 ;
2608
+ int alloc1 = 0 ;
2609
+
2610
+ if ((argc < 1) || (argc > 1)) {
2611
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc); SWIG_fail;
2612
+ }
2613
+ res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1);
2614
+ if (!SWIG_IsOK(res1)) {
2615
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","init_earth", 1, argv[0] ));
2616
+ }
2617
+ arg1 = (char *)(buf1);
2618
+ {
2619
+ const char *err;
2620
+ clear_exception();
2621
+ init_earth((char const *)arg1);
2622
+ if((err = check_exception())) {
2623
+ SWIG_exception(SWIG_RuntimeError, (char *)err);
2624
+ }
2625
+ }
2626
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2627
+ return Qnil;
2628
+ fail:
2629
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2630
+ return Qnil;
2631
+ }
2632
+
2633
+
2634
+ SWIGINTERN VALUE
2635
+ _wrap_min_latency_seconds(int argc, VALUE *argv, VALUE self) {
2636
+ char *arg1 = (char *) 0 ;
2637
+ char *arg2 = (char *) 0 ;
2638
+ int res1 ;
2639
+ char *buf1 = 0 ;
2640
+ int alloc1 = 0 ;
2641
+ int res2 ;
2642
+ char *buf2 = 0 ;
2643
+ int alloc2 = 0 ;
2644
+ double result;
2645
+ VALUE vresult = Qnil;
2646
+
2647
+ if ((argc < 2) || (argc > 2)) {
2648
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)",argc); SWIG_fail;
2649
+ }
2650
+ res1 = SWIG_AsCharPtrAndSize(argv[0], &buf1, NULL, &alloc1);
2651
+ if (!SWIG_IsOK(res1)) {
2652
+ SWIG_exception_fail(SWIG_ArgError(res1), Ruby_Format_TypeError( "", "char const *","min_latency_seconds", 1, argv[0] ));
2653
+ }
2654
+ arg1 = (char *)(buf1);
2655
+ res2 = SWIG_AsCharPtrAndSize(argv[1], &buf2, NULL, &alloc2);
2656
+ if (!SWIG_IsOK(res2)) {
2657
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "char const *","min_latency_seconds", 2, argv[1] ));
2658
+ }
2659
+ arg2 = (char *)(buf2);
2660
+ {
2661
+ const char *err;
2662
+ clear_exception();
2663
+ result = (double)min_latency_seconds((char const *)arg1,(char const *)arg2);
2664
+ if((err = check_exception())) {
2665
+ SWIG_exception(SWIG_RuntimeError, (char *)err);
2666
+ }
2667
+ }
2668
+ vresult = SWIG_From_double((double)(result));
2669
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2670
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2671
+ return vresult;
2672
+ fail:
2673
+ if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
2674
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
2675
+ return Qnil;
2676
+ }
2677
+
2678
+
2679
+
2680
+ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
2681
+
2682
+ static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
2683
+ static swig_type_info _swigt__p_in_addr_t = {"_p_in_addr_t", "in_addr_t *", 0, 0, (void*)0, 0};
2684
+ static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *", 0, 0, (void*)0, 0};
2685
+ static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *", 0, 0, (void*)0, 0};
2686
+
2687
+ static swig_type_info *swig_type_initial[] = {
2688
+ &_swigt__p_char,
2689
+ &_swigt__p_in_addr_t,
2690
+ &_swigt__p_unsigned_char,
2691
+ &_swigt__p_unsigned_short,
2692
+ };
2693
+
2694
+ static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
2695
+ static swig_cast_info _swigc__p_in_addr_t[] = { {&_swigt__p_in_addr_t, 0, 0, 0},{0, 0, 0, 0}};
2696
+ static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}};
2697
+ static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}};
2698
+
2699
+ static swig_cast_info *swig_cast_initial[] = {
2700
+ _swigc__p_char,
2701
+ _swigc__p_in_addr_t,
2702
+ _swigc__p_unsigned_char,
2703
+ _swigc__p_unsigned_short,
2704
+ };
2705
+
2706
+
2707
+ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
2708
+
2709
+ /* -----------------------------------------------------------------------------
2710
+ * Type initialization:
2711
+ * This problem is tough by the requirement that no dynamic
2712
+ * memory is used. Also, since swig_type_info structures store pointers to
2713
+ * swig_cast_info structures and swig_cast_info structures store pointers back
2714
+ * to swig_type_info structures, we need some lookup code at initialization.
2715
+ * The idea is that swig generates all the structures that are needed.
2716
+ * The runtime then collects these partially filled structures.
2717
+ * The SWIG_InitializeModule function takes these initial arrays out of
2718
+ * swig_module, and does all the lookup, filling in the swig_module.types
2719
+ * array with the correct data and linking the correct swig_cast_info
2720
+ * structures together.
2721
+ *
2722
+ * The generated swig_type_info structures are assigned staticly to an initial
2723
+ * array. We just loop through that array, and handle each type individually.
2724
+ * First we lookup if this type has been already loaded, and if so, use the
2725
+ * loaded structure instead of the generated one. Then we have to fill in the
2726
+ * cast linked list. The cast data is initially stored in something like a
2727
+ * two-dimensional array. Each row corresponds to a type (there are the same
2728
+ * number of rows as there are in the swig_type_initial array). Each entry in
2729
+ * a column is one of the swig_cast_info structures for that type.
2730
+ * The cast_initial array is actually an array of arrays, because each row has
2731
+ * a variable number of columns. So to actually build the cast linked list,
2732
+ * we find the array of casts associated with the type, and loop through it
2733
+ * adding the casts to the list. The one last trick we need to do is making
2734
+ * sure the type pointer in the swig_cast_info struct is correct.
2735
+ *
2736
+ * First off, we lookup the cast->type name to see if it is already loaded.
2737
+ * There are three cases to handle:
2738
+ * 1) If the cast->type has already been loaded AND the type we are adding
2739
+ * casting info to has not been loaded (it is in this module), THEN we
2740
+ * replace the cast->type pointer with the type pointer that has already
2741
+ * been loaded.
2742
+ * 2) If BOTH types (the one we are adding casting info to, and the
2743
+ * cast->type) are loaded, THEN the cast info has already been loaded by
2744
+ * the previous module so we just ignore it.
2745
+ * 3) Finally, if cast->type has not already been loaded, then we add that
2746
+ * swig_cast_info to the linked list (because the cast->type) pointer will
2747
+ * be correct.
2748
+ * ----------------------------------------------------------------------------- */
2749
+
2750
+ #ifdef __cplusplus
2751
+ extern "C" {
2752
+ #if 0
2753
+ } /* c-mode */
2754
+ #endif
2755
+ #endif
2756
+
2757
+ #if 0
2758
+ #define SWIGRUNTIME_DEBUG
2759
+ #endif
2760
+
2761
+
2762
+ SWIGRUNTIME void
2763
+ SWIG_InitializeModule(void *clientdata) {
2764
+ size_t i;
2765
+ swig_module_info *module_head, *iter;
2766
+ int found, init;
2767
+
2768
+ /* check to see if the circular list has been setup, if not, set it up */
2769
+ if (swig_module.next==0) {
2770
+ /* Initialize the swig_module */
2771
+ swig_module.type_initial = swig_type_initial;
2772
+ swig_module.cast_initial = swig_cast_initial;
2773
+ swig_module.next = &swig_module;
2774
+ init = 1;
2775
+ } else {
2776
+ init = 0;
2777
+ }
2778
+
2779
+ /* Try and load any already created modules */
2780
+ module_head = SWIG_GetModule(clientdata);
2781
+ if (!module_head) {
2782
+ /* This is the first module loaded for this interpreter */
2783
+ /* so set the swig module into the interpreter */
2784
+ SWIG_SetModule(clientdata, &swig_module);
2785
+ module_head = &swig_module;
2786
+ } else {
2787
+ /* the interpreter has loaded a SWIG module, but has it loaded this one? */
2788
+ found=0;
2789
+ iter=module_head;
2790
+ do {
2791
+ if (iter==&swig_module) {
2792
+ found=1;
2793
+ break;
2794
+ }
2795
+ iter=iter->next;
2796
+ } while (iter!= module_head);
2797
+
2798
+ /* if the is found in the list, then all is done and we may leave */
2799
+ if (found) return;
2800
+ /* otherwise we must add out module into the list */
2801
+ swig_module.next = module_head->next;
2802
+ module_head->next = &swig_module;
2803
+ }
2804
+
2805
+ /* When multiple interpreters are used, a module could have already been initialized in
2806
+ a different interpreter, but not yet have a pointer in this interpreter.
2807
+ In this case, we do not want to continue adding types... everything should be
2808
+ set up already */
2809
+ if (init == 0) return;
2810
+
2811
+ /* Now work on filling in swig_module.types */
2812
+ #ifdef SWIGRUNTIME_DEBUG
2813
+ printf("SWIG_InitializeModule: size %d\n", swig_module.size);
2814
+ #endif
2815
+ for (i = 0; i < swig_module.size; ++i) {
2816
+ swig_type_info *type = 0;
2817
+ swig_type_info *ret;
2818
+ swig_cast_info *cast;
2819
+
2820
+ #ifdef SWIGRUNTIME_DEBUG
2821
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
2822
+ #endif
2823
+
2824
+ /* if there is another module already loaded */
2825
+ if (swig_module.next != &swig_module) {
2826
+ type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
2827
+ }
2828
+ if (type) {
2829
+ /* Overwrite clientdata field */
2830
+ #ifdef SWIGRUNTIME_DEBUG
2831
+ printf("SWIG_InitializeModule: found type %s\n", type->name);
2832
+ #endif
2833
+ if (swig_module.type_initial[i]->clientdata) {
2834
+ type->clientdata = swig_module.type_initial[i]->clientdata;
2835
+ #ifdef SWIGRUNTIME_DEBUG
2836
+ printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
2837
+ #endif
2838
+ }
2839
+ } else {
2840
+ type = swig_module.type_initial[i];
2841
+ }
2842
+
2843
+ /* Insert casting types */
2844
+ cast = swig_module.cast_initial[i];
2845
+ while (cast->type) {
2846
+
2847
+ /* Don't need to add information already in the list */
2848
+ ret = 0;
2849
+ #ifdef SWIGRUNTIME_DEBUG
2850
+ printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
2851
+ #endif
2852
+ if (swig_module.next != &swig_module) {
2853
+ ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
2854
+ #ifdef SWIGRUNTIME_DEBUG
2855
+ if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
2856
+ #endif
2857
+ }
2858
+ if (ret) {
2859
+ if (type == swig_module.type_initial[i]) {
2860
+ #ifdef SWIGRUNTIME_DEBUG
2861
+ printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
2862
+ #endif
2863
+ cast->type = ret;
2864
+ ret = 0;
2865
+ } else {
2866
+ /* Check for casting already in the list */
2867
+ swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
2868
+ #ifdef SWIGRUNTIME_DEBUG
2869
+ if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
2870
+ #endif
2871
+ if (!ocast) ret = 0;
2872
+ }
2873
+ }
2874
+
2875
+ if (!ret) {
2876
+ #ifdef SWIGRUNTIME_DEBUG
2877
+ printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
2878
+ #endif
2879
+ if (type->cast) {
2880
+ type->cast->prev = cast;
2881
+ cast->next = type->cast;
2882
+ }
2883
+ type->cast = cast;
2884
+ }
2885
+ cast++;
2886
+ }
2887
+ /* Set entry in modules->types array equal to the type */
2888
+ swig_module.types[i] = type;
2889
+ }
2890
+ swig_module.types[i] = 0;
2891
+
2892
+ #ifdef SWIGRUNTIME_DEBUG
2893
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
2894
+ for (i = 0; i < swig_module.size; ++i) {
2895
+ int j = 0;
2896
+ swig_cast_info *cast = swig_module.cast_initial[i];
2897
+ printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
2898
+ while (cast->type) {
2899
+ printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
2900
+ cast++;
2901
+ ++j;
2902
+ }
2903
+ printf("---- Total casts: %d\n",j);
2904
+ }
2905
+ printf("**** SWIG_InitializeModule: Cast List ******\n");
2906
+ #endif
2907
+ }
2908
+
2909
+ /* This function will propagate the clientdata field of type to
2910
+ * any new swig_type_info structures that have been added into the list
2911
+ * of equivalent types. It is like calling
2912
+ * SWIG_TypeClientData(type, clientdata) a second time.
2913
+ */
2914
+ SWIGRUNTIME void
2915
+ SWIG_PropagateClientData(void) {
2916
+ size_t i;
2917
+ swig_cast_info *equiv;
2918
+ static int init_run = 0;
2919
+
2920
+ if (init_run) return;
2921
+ init_run = 1;
2922
+
2923
+ for (i = 0; i < swig_module.size; i++) {
2924
+ if (swig_module.types[i]->clientdata) {
2925
+ equiv = swig_module.types[i]->cast;
2926
+ while (equiv) {
2927
+ if (!equiv->converter) {
2928
+ if (equiv->type && !equiv->type->clientdata)
2929
+ SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
2930
+ }
2931
+ equiv = equiv->next;
2932
+ }
2933
+ }
2934
+ }
2935
+ }
2936
+
2937
+ #ifdef __cplusplus
2938
+ #if 0
2939
+ { /* c-mode */
2940
+ #endif
2941
+ }
2942
+ #endif
2943
+
2944
+ /*
2945
+
2946
+ */
2947
+ #ifdef __cplusplus
2948
+ extern "C"
2949
+ #endif
2950
+ SWIGEXPORT void Init_undns(void) {
2951
+ size_t i;
2952
+
2953
+ SWIG_InitRuntime();
2954
+ mUndns = rb_define_module("Undns");
2955
+
2956
+ SWIG_InitializeModule(0);
2957
+ for (i = 0; i < swig_module.size; i++) {
2958
+ SWIG_define_class(swig_module.types[i]);
2959
+ }
2960
+
2961
+ SWIG_RubyInitializeTrackings();
2962
+ rb_define_singleton_method(mUndns, "want_debug", _wrap_want_debug_get, 0);
2963
+ rb_define_singleton_method(mUndns, "want_debug=", _wrap_want_debug_set, 1);
2964
+ rb_define_singleton_method(mUndns, "want_conventions_debug", _wrap_want_conventions_debug_get, 0);
2965
+ rb_define_singleton_method(mUndns, "want_conventions_debug=", _wrap_want_conventions_debug_set, 1);
2966
+ rb_define_singleton_method(mUndns, "ruleset_path", _wrap_ruleset_path_get, 0);
2967
+ rb_define_singleton_method(mUndns, "ruleset_path=", _wrap_ruleset_path_set, 1);
2968
+ rb_define_module_function(mUndns, "get_loc", _wrap_get_loc, -1);
2969
+ rb_define_module_function(mUndns, "get_role", _wrap_get_role, -1);
2970
+ rb_define_module_function(mUndns, "get_asn_bydns", _wrap_get_asn_bydns, -1);
2971
+ rb_define_module_function(mUndns, "doubt_location", _wrap_doubt_location, -1);
2972
+ rb_define_module_function(mUndns, "get_identifier", _wrap_get_identifier, -1);
2973
+ rb_define_module_function(mUndns, "get_poptag", _wrap_get_poptag, -1);
2974
+
2975
+ rb_require("ipaddr");
2976
+ /* skip validation of the arguments; there's no way we're going to
2977
+ provide a non-32-bit unsigned value */
2978
+ rb_eval_string("class IPAddr4 < IPAddr\n"
2979
+ " def initialize(addr)\n"
2980
+ " @addr = addr\n"
2981
+ " @family = Socket::AF_INET\n"
2982
+ " end\n"
2983
+ "end\n");
2984
+ class_IPAddr = rb_path2class("IPAddr4");
2985
+
2986
+ rb_define_module_function(mUndns, "origin_prefix_for_address", _wrap_origin_prefix_for_address, -1);
2987
+ rb_define_module_function(mUndns, "load_ruleset", _wrap_load_ruleset, -1);
2988
+ rb_define_module_function(mUndns, "origins_init", _wrap_origins_init, -1);
2989
+ rb_define_module_function(mUndns, "origin_for_address_str", _wrap_origin_for_address_str, -1);
2990
+ rb_define_module_function(mUndns, "dump_parsed_conventions_to_file", _wrap_dump_parsed_conventions_to_file, -1);
2991
+ rb_define_module_function(mUndns, "dump_single_asn_conventions_to_file", _wrap_dump_single_asn_conventions_to_file, -1);
2992
+ rb_define_module_function(mUndns, "init_earth", _wrap_init_earth, -1);
2993
+ rb_define_module_function(mUndns, "min_latency_seconds", _wrap_min_latency_seconds, -1);
2994
+ }
2995
+