undns 0.4.0a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,158 @@
1
+ /*
2
+ * Copyright (c) 2002
3
+ * Neil Spring and the University of Washington.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * 3. The name of the author(s) may not be used to endorse or promote
15
+ * products derived from this software without specific prior
16
+ * written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
19
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
22
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ */
29
+
30
+ #ifndef _typed_hashtable_h
31
+ #define _typed_hashtable_h
32
+ #include "hashtable.h"
33
+
34
+ #define DECLARE_TYPED_HASHTABLE(type, pr) \
35
+ struct pr##hashtable_struct; \
36
+ typedef struct pr##hashtable_struct *pr##_hashtable; \
37
+ /*@unused@*/ \
38
+ static __inline void \
39
+ pr##_ht_delete(/*@only@*/ pr##_hashtable d, boolean pro) { \
40
+ ht_delete((hashtable)d, pro); \
41
+ } \
42
+ typedef unsigned int (*pr##_hash_fn)(const type *k); \
43
+ typedef boolean (*pr##_iseq_fn)(const type *k1, const type *k2); \
44
+ typedef type *(*pr##_ht_constructor_cb)(const type *k1); \
45
+ typedef boolean (*pr##_ht_iterator_cb)(const type *keyval, void *user); \
46
+ typedef boolean (*pr##_ht_iterator_pair_cb)(const type *keyval, const type *keyval2); \
47
+ typedef boolean (*pr##_ht_iterator_cb_nc)(type *keyval, void *user); \
48
+ typedef boolean (*pr##_ht_delete_if_cb)(type *keyval, void *user); \
49
+ /* would be type *keyval, but c++ is unhappy about contravariance */ \
50
+ typedef void (*pr##_ht_delete_cb)(void *keyval); \
51
+ /*@unused@*/ \
52
+ static __inline pr##_hashtable \
53
+ pr##_ht_new(unsigned int s, \
54
+ pr##_hash_fn hash, pr##_iseq_fn iseq, \
55
+ pr##_ht_delete_cb freek) { \
56
+ return((pr##_hashtable)ht_new(s, (hash_cb)hash, (isequal_cb)iseq, \
57
+ (delete_cb)freek)); \
58
+ } \
59
+ /*@unused@*/ \
60
+ static __inline void \
61
+ pr##_ht_insert(pr##_hashtable h, /*@owned@*/ type *k) { \
62
+ ht_insert((hashtable)h, k); \
63
+ } \
64
+ /*@unused@*/ \
65
+ static __inline boolean \
66
+ pr##_ht_remove(pr##_hashtable h, type *k) { \
67
+ return ht_remove((hashtable)h, k); \
68
+ } \
69
+ /*@unused@*/ \
70
+ static __inline unsigned int \
71
+ pr##_ht_delete_if(pr##_hashtable h, pr##_ht_delete_if_cb c, /*@null@*/ void *a) { \
72
+ return ht_delete_if((hashtable)h, (ht_delete_if_cb)c, a); \
73
+ } \
74
+ /*@unused@*/ \
75
+ static __inline /*@null@*/ /*@dependent@*/ type * \
76
+ pr##_ht_lookup(pr##_hashtable h, /*@out@*/ const type *k) { \
77
+ /*out = not neccessarily defined */ \
78
+ return((type *)ht_lookup((hashtable)h,k)); \
79
+ } \
80
+ /*@unused@*/ \
81
+ static __inline /*@dependent@*/ type * \
82
+ pr##_ht_lookup_nofail(pr##_hashtable h, \
83
+ const type *key, \
84
+ type *(*constructor)(const type*k)) { \
85
+ return((type *)ht_lookup_nofail((hashtable)h, key, (ht_constructor_cb)constructor)); \
86
+ } \
87
+ /*@unused@*/ \
88
+ static __inline boolean \
89
+ pr##_ht_iterate(pr##_hashtable h, \
90
+ pr##_ht_iterator_cb cb, \
91
+ void *user) { \
92
+ return(ht_iterate((hashtable)h,(ht_iterator_cb)cb,user)); \
93
+ } \
94
+ /*@unused@*/ \
95
+ static __inline boolean \
96
+ pr##_ht_iterate_pairs(pr##_hashtable h, unsigned int nThreads, unsigned int chunkSize, \
97
+ pr##_ht_iterator_pair_cb cb) { \
98
+ return(ht_iterate_pairs((hashtable)h,nThreads,chunkSize,(ht_iterator_pair_cb)cb)); \
99
+ } \
100
+ /*@unused@*/ \
101
+ static __inline boolean \
102
+ pr##_ht_iterate_nc(pr##_hashtable h, \
103
+ pr##_ht_iterator_cb_nc cb, \
104
+ void *user) { \
105
+ return(ht_iterate((hashtable)h,(ht_iterator_cb)cb,user)); \
106
+ } \
107
+ /*@unused@*/ \
108
+ static __inline unsigned long \
109
+ pr##_ht_count(pr##_hashtable h) { \
110
+ return(ht_count((hashtable)h)); \
111
+ } \
112
+ /*@unused@*/ \
113
+ static __inline void \
114
+ pr##_ht_occupancyjgr(const pr##_hashtable h, const char *fname) { \
115
+ ht_occupancyjgr((const hashtable)h, fname); \
116
+ } \
117
+ \
118
+ /*@unused@*/ \
119
+ static __inline void \
120
+ pr##_ht_free_entry(pr##_hashtable ht, type *keyval) { \
121
+ ht_free_entry((hashtable)ht, keyval); \
122
+ }
123
+
124
+ #define DECLARE_TYPED_HASHTABLE_K(type, keytype, pr) \
125
+ DECLARE_TYPED_HASHTABLE(type, pr); \
126
+ typedef unsigned int (*pr##_hash_k_fn)(const keytype *k); \
127
+ typedef boolean (*pr##_iseq_k_fn)(const keytype *k1, const keytype *k2); \
128
+ /*@unused@*/ \
129
+ static __inline /*@null@*/ /*@dependent@*/ type * \
130
+ pr##_ht_lookup_k(pr##_hashtable h, const keytype *k) { \
131
+ return((type *)ht_lookup((hashtable)h,k)); \
132
+ } \
133
+ /*@unused@*/ \
134
+ static __inline /*@dependent@*/ type * \
135
+ pr##_ht_lookup_nofail_k(pr##_hashtable h, \
136
+ const keytype *key, \
137
+ type *(*constructor)(const type*k)) { \
138
+ return((type *)ht_lookup_nofail((hashtable)h, key, (ht_constructor_cb)constructor)); \
139
+ } \
140
+ /*@unused@*/ \
141
+ static __inline /*@dependent@*/ type * \
142
+ pr##_ht_lookup_nofail_kk(pr##_hashtable h, \
143
+ const keytype *key, \
144
+ type *(*constructor)(const keytype*k)) { \
145
+ return((type *)ht_lookup_nofail((hashtable)h, key, (ht_constructor_cb)constructor)); \
146
+ } \
147
+ /*@unused@*/ \
148
+ static __inline pr##_hashtable \
149
+ pr##_ht_new_k(unsigned int s, \
150
+ pr##_hash_k_fn hash, pr##_iseq_k_fn iseq, \
151
+ /*@null@*/ pr##_ht_delete_cb freek) { \
152
+ return((pr##_hashtable)ht_new(s, (hash_cb)hash, (isequal_cb)iseq, \
153
+ (delete_cb)freek)); \
154
+ } \
155
+
156
+
157
+
158
+ #endif
@@ -0,0 +1,112 @@
1
+ /*
2
+ * Copyright (c) 2002
3
+ * Neil Spring and the University of Washington.
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * 3. The name of the author(s) may not be used to endorse or promote
15
+ * products derived from this software without specific prior
16
+ * written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
19
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
22
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ */
29
+
30
+ #ifndef _typed_queue_h
31
+ #define _typed_queue_h
32
+ #include "queue.h"
33
+
34
+ #define DECLARE_TYPED_QUEUE(type, pr) \
35
+ struct pr##queue_struct; \
36
+ typedef struct pr##queue_struct *pr##_queue; \
37
+ struct pr##queue_element_struct; \
38
+ typedef struct pr##queue_element_struct *pr##_q_element; \
39
+ /*@unused@*/ \
40
+ static __inline void \
41
+ pr##_q_delete(/*@only@*/ pr##_queue d) { \
42
+ q_delete((queue)d); \
43
+ } \
44
+ \
45
+ /*@unused@*/ \
46
+ static __inline pr##_queue \
47
+ pr##_q_new(/*@null@*/ int (*cmp)(const type *v1, \
48
+ const type *v2), \
49
+ /*@null@*/ void (*relse)(void *)) { \
50
+ return((pr##_queue)q_new((q_comparator)cmp, relse)); \
51
+ } \
52
+ \
53
+ /*@unused@*/ \
54
+ static __inline pr##_q_element \
55
+ pr##_q_insert(pr##_queue h, /*@owned@*/ type *k) { \
56
+ return((pr##_q_element)q_insert((queue)h, k)); \
57
+ } \
58
+ /*@unused@*/ \
59
+ static __inline pr##_q_element \
60
+ pr##_q_insert_fromdir(pr##_queue h, /*@owned@*/ type *k, boolean go_backwards) { \
61
+ return((pr##_q_element)q_insert_fromdir((queue)h, k, go_backwards)); \
62
+ } \
63
+ /*@unused@*/ \
64
+ static __inline void \
65
+ pr##_q_append(pr##_queue h, /*@owned@*/ type *k) { \
66
+ q_append((queue)h, k); \
67
+ } \
68
+ /*@unused@*/ \
69
+ static __inline boolean \
70
+ pr##_q_remove(pr##_queue h, type *k) { \
71
+ return(q_remove((queue)h, k)); \
72
+ } \
73
+ /*@unused@*/ \
74
+ static __inline void \
75
+ pr##_q_expunge(pr##_queue h, pr##_q_element k) { \
76
+ return(q_expunge((queue)h, (q_element)k)); \
77
+ } \
78
+ /*@unused@*/ \
79
+ static __inline /*@null@*/ type * \
80
+ pr##_q_pop(pr##_queue h) { \
81
+ return((type *)q_pop((queue)h)); \
82
+ } \
83
+ /*@unused@*/ \
84
+ static __inline /*@null@*/ /*@dependent@*/ type * \
85
+ pr##_q_top(pr##_queue h) { \
86
+ return((type *)q_top((queue)h)); \
87
+ } \
88
+ /*@unused@*/ \
89
+ static __inline boolean \
90
+ pr##_q_iterate(pr##_queue h, \
91
+ boolean (*cb)(const type *keyval, void *user), \
92
+ void *user) { \
93
+ return(q_iterate((queue)h,(q_iterator)cb,user)); \
94
+ } \
95
+ /*@unused@*/ \
96
+ static __inline boolean \
97
+ pr##_q_iterate_nonconst(pr##_queue h, \
98
+ boolean (*cb)(type *keyval, void *user), \
99
+ void *user) { \
100
+ return(q_iterate((queue)h,(q_iterator)cb,user)); \
101
+ } \
102
+ /*@unused@*/ \
103
+ static __inline void * \
104
+ pr##_q_find(pr##_queue q, const type *findme) { \
105
+ return(q_find((queue)q,(const void *)findme)); \
106
+ } \
107
+ /*@unused@*/ \
108
+ static __inline unsigned long \
109
+ pr##_q_length(pr##_queue h) { \
110
+ return(q_length((queue)h)); \
111
+ }
112
+ #endif
@@ -0,0 +1,153 @@
1
+ /* xmalloc.c -- malloc with out of memory checking
2
+ Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 99 Free Software Foundation, Inc.
3
+
4
+ This program is free software; you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation; either version 2, or (at your option)
7
+ any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software Foundation,
16
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17
+
18
+ #if HAVE_CONFIG_H
19
+ # include <config.h>
20
+ #endif
21
+
22
+ #if __STDC__
23
+ # define VOID void
24
+ #else
25
+ # define VOID char
26
+ #endif
27
+
28
+ #include <sys/types.h>
29
+
30
+ #include <stdlib.h>
31
+ #include <string.h>
32
+
33
+ #if ENABLE_NLS
34
+ # include <libintl.h>
35
+ # define _(Text) gettext (Text)
36
+ #else
37
+ # define textdomain(Domain)
38
+ # define _(Text) Text
39
+ #endif
40
+
41
+ /* nspring: /usr/include/error.h, but perhaps I'm
42
+ expected to distribute this? (was "") */
43
+ #ifdef __LCLINT__
44
+ /*@exits@*/
45
+ extern void error (int status, int errnum, const char *format, ...);
46
+ #else
47
+ #ifdef HAVE_ERROR_H
48
+ #include <error.h>
49
+ #endif
50
+ #endif
51
+
52
+
53
+
54
+ #ifndef EXIT_FAILURE
55
+ # define EXIT_FAILURE 1
56
+ #endif
57
+
58
+ /* Prototypes for functions defined here. */
59
+ #if defined (__STDC__) && __STDC__
60
+ static VOID *fixup_null_alloc (size_t n);
61
+ VOID *xmalloc (size_t n);
62
+ VOID *xcalloc (size_t n, size_t s);
63
+ VOID *xrealloc (VOID *p, size_t n);
64
+ char *xstrdup (const char *p);
65
+ #endif
66
+
67
+
68
+ /* Exit value when the requested amount of memory is not available.
69
+ The caller may set it to some other value. */
70
+ /*@-exportlocal@*/
71
+ int xmalloc_exit_failure = EXIT_FAILURE;
72
+ /*@+exportlocal@*/
73
+
74
+ /* this is in error.h */
75
+ #ifndef HAVE_ERROR_H
76
+ #if __STDC__ && (HAVE_VPRINTF || HAVE_DOPRNT)
77
+ void error (int, int, const char *, ...);
78
+ #else
79
+ void error ();
80
+ #endif
81
+ #endif
82
+
83
+ static VOID *
84
+ fixup_null_alloc (n)
85
+ size_t n;
86
+ {
87
+ VOID *p;
88
+
89
+ p = 0;
90
+ if (n == 0)
91
+ p = malloc ((size_t) 1);
92
+ if (p == 0)
93
+ error (xmalloc_exit_failure, 0, _("Memory exhausted"));
94
+ return p;
95
+ }
96
+
97
+ /* Allocate N bytes of memory dynamically, with error checking. */
98
+
99
+ VOID *
100
+ xmalloc (n)
101
+ size_t n;
102
+ {
103
+ VOID *p;
104
+
105
+ p = malloc (n);
106
+ if (p == 0)
107
+ p = fixup_null_alloc (n);
108
+ return p;
109
+ }
110
+
111
+ /* Allocate memory for N elements of S bytes, with error checking. */
112
+
113
+ VOID *
114
+ xcalloc (n, s)
115
+ size_t n, s;
116
+ {
117
+ VOID *p;
118
+
119
+ p = calloc (n, s);
120
+ if (p == 0)
121
+ p = fixup_null_alloc (n);
122
+ return p;
123
+ }
124
+
125
+ /* Change the size of an allocated block of memory P to N bytes,
126
+ with error checking.
127
+ If P is NULL, run xmalloc. */
128
+
129
+ VOID *
130
+ xrealloc (p, n)
131
+ VOID *p;
132
+ size_t n;
133
+ {
134
+ if (p == 0)
135
+ return xmalloc (n);
136
+ p = realloc (p, n);
137
+ if (p == 0)
138
+ p = fixup_null_alloc (n);
139
+ return p;
140
+ }
141
+
142
+ /* Make a copy of a string in a newly allocated block of memory. */
143
+
144
+ char *
145
+ xstrdup (str)
146
+ const char *str;
147
+ {
148
+ VOID *p;
149
+
150
+ p = xmalloc (strlen (str) + 1);
151
+ strcpy (p, str);
152
+ return p;
153
+ }
@@ -0,0 +1,14 @@
1
+ #include <stdio.h> /* size_t? */
2
+ #if __STDC__
3
+ # define VOID void
4
+ #else
5
+ # define VOID char
6
+ #endif
7
+
8
+ /* like the versions without the x, only never return NULL */
9
+ /*@only@*/ /*@out@*/ /*@notnull@*/
10
+ VOID *xmalloc (size_t n);
11
+
12
+ VOID *xcalloc (size_t n, size_t s);
13
+ VOID *xrealloc (VOID *p, size_t n);
14
+ char *xstrdup (const char *p);
@@ -0,0 +1,5 @@
1
+ require 'undns/undns'
2
+
3
+ module Undns
4
+
5
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: undns
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0a
5
+ platform: ruby
6
+ authors:
7
+ - Neil Spring
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Undns parses router host names to extract geographic location and other
14
+ apparent information within the name. It was initially developed as part of the
15
+ Rocketfuel project at the University of Washington.
16
+ email: nspring@cs.umd.edu
17
+ executables:
18
+ - undns_decode
19
+ extensions:
20
+ - ext/undns/extconf.rb
21
+ extra_rdoc_files: []
22
+ files:
23
+ - bin/undns_decode
24
+ - ext/undns/buffer.c
25
+ - ext/undns/buffer.h
26
+ - ext/undns/config.h
27
+ - ext/undns/conventions.c
28
+ - ext/undns/conventions.h
29
+ - ext/undns/conventlex.c
30
+ - ext/undns/earth.c
31
+ - ext/undns/earth.h
32
+ - ext/undns/exception.h
33
+ - ext/undns/extconf.rb
34
+ - ext/undns/filetest.c
35
+ - ext/undns/filetest.h
36
+ - ext/undns/hashes.c
37
+ - ext/undns/hashes.h
38
+ - ext/undns/hashtable.c
39
+ - ext/undns/hashtable.h
40
+ - ext/undns/my_ruby.h
41
+ - ext/undns/nscommon.h
42
+ - ext/undns/originAS.c
43
+ - ext/undns/originAS.h
44
+ - ext/undns/progress.c
45
+ - ext/undns/progress.h
46
+ - ext/undns/queue.c
47
+ - ext/undns/queue.h
48
+ - ext/undns/radix.c
49
+ - ext/undns/radix.h
50
+ - ext/undns/ruleset.c
51
+ - ext/undns/ruleset.h
52
+ - ext/undns/swig-undns_wrap-rb.c
53
+ - ext/undns/typed_hashtable.h
54
+ - ext/undns/typed_queue.h
55
+ - ext/undns/xmalloc.c
56
+ - ext/undns/xmalloc.h
57
+ - lib/undns.rb
58
+ homepage: http://www.scriptroute.org/
59
+ licenses:
60
+ - GPL
61
+ metadata: {}
62
+ post_install_message: 'Now run: undns_decode [router name]'
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ - ext
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">"
75
+ - !ruby/object:Gem::Version
76
+ version: 1.3.1
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.2.2
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Undns client in ruby
83
+ test_files: []
84
+ has_rdoc: