Codebase list getdns / 1c879fa
New upstream version 0.1.0 Ondřej Surý 10 years ago
141 changed file(s) with 70248 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 Craig Despeaux <cedespeaux@verisign.com>
1 Neel Goyal <ngoyal@verisign.com>
2 Allison Mankin <amankin@verisign.com>
3 Melinda Shore <melinda.shore@nomountain.net>
4 Willem Toorop <willem@NLnetLabs.nl>
5 W.C.A. Wijngaards <wouter@NLnetLabs.nl>
6 Glen Wiley <gwiley@verisign.com>
0 Copyright (c) 2013, Verisign, Inc., NLnet Labs
1 All rights reserved.
2
3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions are met:
5 * Redistributions of source code must retain the above copyright
6 notice, this list of conditions and the following disclaimer.
7 * Redistributions in binary form must reproduce the above copyright
8 notice, this list of conditions and the following disclaimer in the
9 documentation and/or other materials provided with the distribution.
10 * Neither the names of the copyright holders nor the
11 names of its contributors may be used to endorse or promote products
12 derived from this software without specific prior written permission.
13
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
18 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0 * 2014-02-25 : Version 0.1.0
1 * Initial public release of the getdns API
0 Installation Instructions
1 *************************
2
3 Copyright (C) 1994-1996, 1999-2002, 2004-2012 Free Software Foundation,
4 Inc.
5
6 Copying and distribution of this file, with or without modification,
7 are permitted in any medium without royalty provided the copyright
8 notice and this notice are preserved. This file is offered as-is,
9 without warranty of any kind.
10
11 Basic Installation
12 ==================
13
14 Briefly, the shell commands `./configure; make; make install' should
15 configure, build, and install this package. The following
16 more-detailed instructions are generic; see the `README' file for
17 instructions specific to this package. Some packages provide this
18 `INSTALL' file but do not implement all of the features documented
19 below. The lack of an optional feature in a given package is not
20 necessarily a bug. More recommendations for GNU packages can be found
21 in *note Makefile Conventions: (standards)Makefile Conventions.
22
23 The `configure' shell script attempts to guess correct values for
24 various system-dependent variables used during compilation. It uses
25 those values to create a `Makefile' in each directory of the package.
26 It may also create one or more `.h' files containing system-dependent
27 definitions. Finally, it creates a shell script `config.status' that
28 you can run in the future to recreate the current configuration, and a
29 file `config.log' containing compiler output (useful mainly for
30 debugging `configure').
31
32 It can also use an optional file (typically called `config.cache'
33 and enabled with `--cache-file=config.cache' or simply `-C') that saves
34 the results of its tests to speed up reconfiguring. Caching is
35 disabled by default to prevent problems with accidental use of stale
36 cache files.
37
38 If you need to do unusual things to compile the package, please try
39 to figure out how `configure' could check whether to do them, and mail
40 diffs or instructions to the address given in the `README' so they can
41 be considered for the next release. If you are using the cache, and at
42 some point `config.cache' contains results you don't want to keep, you
43 may remove or edit it.
44
45 The file `configure.ac' (or `configure.in') is used to create
46 `configure' by a program called `autoconf'. You need `configure.ac' if
47 you want to change it or regenerate `configure' using a newer version
48 of `autoconf'.
49
50 The simplest way to compile this package is:
51
52 1. `cd' to the directory containing the package's source code and type
53 `./configure' to configure the package for your system.
54
55 Running `configure' might take a while. While running, it prints
56 some messages telling which features it is checking for.
57
58 2. Type `make' to compile the package.
59
60 3. Optionally, type `make check' to run any self-tests that come with
61 the package, generally using the just-built uninstalled binaries.
62
63 4. Type `make install' to install the programs and any data files and
64 documentation. When installing into a prefix owned by root, it is
65 recommended that the package be configured and built as a regular
66 user, and only the `make install' phase executed with root
67 privileges.
68
69 5. Optionally, type `make installcheck' to repeat any self-tests, but
70 this time using the binaries in their final installed location.
71 This target does not install anything. Running this target as a
72 regular user, particularly if the prior `make install' required
73 root privileges, verifies that the installation completed
74 correctly.
75
76 6. You can remove the program binaries and object files from the
77 source code directory by typing `make clean'. To also remove the
78 files that `configure' created (so you can compile the package for
79 a different kind of computer), type `make distclean'. There is
80 also a `make maintainer-clean' target, but that is intended mainly
81 for the package's developers. If you use it, you may have to get
82 all sorts of other programs in order to regenerate files that came
83 with the distribution.
84
85 7. Often, you can also type `make uninstall' to remove the installed
86 files again. In practice, not all packages have tested that
87 uninstallation works correctly, even though it is required by the
88 GNU Coding Standards.
89
90 8. Some packages, particularly those that use Automake, provide `make
91 distcheck', which can by used by developers to test that all other
92 targets like `make install' and `make uninstall' work correctly.
93 This target is generally not run by end users.
94
95 Compilers and Options
96 =====================
97
98 Some systems require unusual options for compilation or linking that
99 the `configure' script does not know about. Run `./configure --help'
100 for details on some of the pertinent environment variables.
101
102 You can give `configure' initial values for configuration parameters
103 by setting variables in the command line or in the environment. Here
104 is an example:
105
106 ./configure CC=c99 CFLAGS=-g LIBS=-lposix
107
108 *Note Defining Variables::, for more details.
109
110 Compiling For Multiple Architectures
111 ====================================
112
113 You can compile the package for more than one kind of computer at the
114 same time, by placing the object files for each architecture in their
115 own directory. To do this, you can use GNU `make'. `cd' to the
116 directory where you want the object files and executables to go and run
117 the `configure' script. `configure' automatically checks for the
118 source code in the directory that `configure' is in and in `..'. This
119 is known as a "VPATH" build.
120
121 With a non-GNU `make', it is safer to compile the package for one
122 architecture at a time in the source code directory. After you have
123 installed the package for one architecture, use `make distclean' before
124 reconfiguring for another architecture.
125
126 On MacOS X 10.5 and later systems, you can create libraries and
127 executables that work on multiple system types--known as "fat" or
128 "universal" binaries--by specifying multiple `-arch' options to the
129 compiler but only a single `-arch' option to the preprocessor. Like
130 this:
131
132 ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
133 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
134 CPP="gcc -E" CXXCPP="g++ -E"
135
136 This is not guaranteed to produce working output in all cases, you
137 may have to build one architecture at a time and combine the results
138 using the `lipo' tool if you have problems.
139
140 Installation Names
141 ==================
142
143 By default, `make install' installs the package's commands under
144 `/usr/local/bin', include files under `/usr/local/include', etc. You
145 can specify an installation prefix other than `/usr/local' by giving
146 `configure' the option `--prefix=PREFIX', where PREFIX must be an
147 absolute file name.
148
149 You can specify separate installation prefixes for
150 architecture-specific files and architecture-independent files. If you
151 pass the option `--exec-prefix=PREFIX' to `configure', the package uses
152 PREFIX as the prefix for installing programs and libraries.
153 Documentation and other data files still use the regular prefix.
154
155 In addition, if you use an unusual directory layout you can give
156 options like `--bindir=DIR' to specify different values for particular
157 kinds of files. Run `configure --help' for a list of the directories
158 you can set and what kinds of files go in them. In general, the
159 default for these options is expressed in terms of `${prefix}', so that
160 specifying just `--prefix' will affect all of the other directory
161 specifications that were not explicitly provided.
162
163 The most portable way to affect installation locations is to pass the
164 correct locations to `configure'; however, many packages provide one or
165 both of the following shortcuts of passing variable assignments to the
166 `make install' command line to change installation locations without
167 having to reconfigure or recompile.
168
169 The first method involves providing an override variable for each
170 affected directory. For example, `make install
171 prefix=/alternate/directory' will choose an alternate location for all
172 directory configuration variables that were expressed in terms of
173 `${prefix}'. Any directories that were specified during `configure',
174 but not in terms of `${prefix}', must each be overridden at install
175 time for the entire installation to be relocated. The approach of
176 makefile variable overrides for each directory variable is required by
177 the GNU Coding Standards, and ideally causes no recompilation.
178 However, some platforms have known limitations with the semantics of
179 shared libraries that end up requiring recompilation when using this
180 method, particularly noticeable in packages that use GNU Libtool.
181
182 The second method involves providing the `DESTDIR' variable. For
183 example, `make install DESTDIR=/alternate/directory' will prepend
184 `/alternate/directory' before all installation names. The approach of
185 `DESTDIR' overrides is not required by the GNU Coding Standards, and
186 does not work on platforms that have drive letters. On the other hand,
187 it does better at avoiding recompilation issues, and works well even
188 when some directory options were not specified in terms of `${prefix}'
189 at `configure' time.
190
191 Optional Features
192 =================
193
194 If the package supports it, you can cause programs to be installed
195 with an extra prefix or suffix on their names by giving `configure' the
196 option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
197
198 Some packages pay attention to `--enable-FEATURE' options to
199 `configure', where FEATURE indicates an optional part of the package.
200 They may also pay attention to `--with-PACKAGE' options, where PACKAGE
201 is something like `gnu-as' or `x' (for the X Window System). The
202 `README' should mention any `--enable-' and `--with-' options that the
203 package recognizes.
204
205 For packages that use the X Window System, `configure' can usually
206 find the X include and library files automatically, but if it doesn't,
207 you can use the `configure' options `--x-includes=DIR' and
208 `--x-libraries=DIR' to specify their locations.
209
210 Some packages offer the ability to configure how verbose the
211 execution of `make' will be. For these packages, running `./configure
212 --enable-silent-rules' sets the default to minimal output, which can be
213 overridden with `make V=1'; while running `./configure
214 --disable-silent-rules' sets the default to verbose, which can be
215 overridden with `make V=0'.
216
217 Particular systems
218 ==================
219
220 On HP-UX, the default C compiler is not ANSI C compatible. If GNU
221 CC is not installed, it is recommended to use the following options in
222 order to use an ANSI C compiler:
223
224 ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
225
226 and if that doesn't work, install pre-built binaries of GCC for HP-UX.
227
228 HP-UX `make' updates targets which have the same time stamps as
229 their prerequisites, which makes it generally unusable when shipped
230 generated files such as `configure' are involved. Use GNU `make'
231 instead.
232
233 On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
234 parse its `<wchar.h>' header file. The option `-nodtk' can be used as
235 a workaround. If GNU CC is not installed, it is therefore recommended
236 to try
237
238 ./configure CC="cc"
239
240 and if that doesn't work, try
241
242 ./configure CC="cc -nodtk"
243
244 On Solaris, don't put `/usr/ucb' early in your `PATH'. This
245 directory contains several dysfunctional programs; working variants of
246 these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
247 in your `PATH', put it _after_ `/usr/bin'.
248
249 On Haiku, software installed for all users goes in `/boot/common',
250 not `/usr/local'. It is recommended to use the following options:
251
252 ./configure --prefix=/boot/common
253
254 Specifying the System Type
255 ==========================
256
257 There may be some features `configure' cannot figure out
258 automatically, but needs to determine by the type of machine the package
259 will run on. Usually, assuming the package is built to be run on the
260 _same_ architectures, `configure' can figure that out, but if it prints
261 a message saying it cannot guess the machine type, give it the
262 `--build=TYPE' option. TYPE can either be a short name for the system
263 type, such as `sun4', or a canonical name which has the form:
264
265 CPU-COMPANY-SYSTEM
266
267 where SYSTEM can have one of these forms:
268
269 OS
270 KERNEL-OS
271
272 See the file `config.sub' for the possible values of each field. If
273 `config.sub' isn't included in this package, then this package doesn't
274 need to know the machine type.
275
276 If you are _building_ compiler tools for cross-compiling, you should
277 use the option `--target=TYPE' to select the type of system they will
278 produce code for.
279
280 If you want to _use_ a cross compiler, that generates code for a
281 platform different from the build platform, you should specify the
282 "host" platform (i.e., that on which the generated programs will
283 eventually be run) with `--host=TYPE'.
284
285 Sharing Defaults
286 ================
287
288 If you want to set default values for `configure' scripts to share,
289 you can create a site shell script called `config.site' that gives
290 default values for variables like `CC', `cache_file', and `prefix'.
291 `configure' looks for `PREFIX/share/config.site' if it exists, then
292 `PREFIX/etc/config.site' if it exists. Or, you can set the
293 `CONFIG_SITE' environment variable to the location of the site script.
294 A warning: not all `configure' scripts look for a site script.
295
296 Defining Variables
297 ==================
298
299 Variables not defined in a site shell script can be set in the
300 environment passed to `configure'. However, some packages may run
301 configure again during the build, and the customized values of these
302 variables may be lost. In order to avoid this problem, you should set
303 them in the `configure' command line, using `VAR=value'. For example:
304
305 ./configure CC=/usr/local2/bin/gcc
306
307 causes the specified `gcc' to be used as the C compiler (unless it is
308 overridden in the site shell script).
309
310 Unfortunately, this technique does not work for `CONFIG_SHELL' due to
311 an Autoconf limitation. Until the limitation is lifted, you can use
312 this workaround:
313
314 CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
315
316 `configure' Invocation
317 ======================
318
319 `configure' recognizes the following options to control how it
320 operates.
321
322 `--help'
323 `-h'
324 Print a summary of all of the options to `configure', and exit.
325
326 `--help=short'
327 `--help=recursive'
328 Print a summary of the options unique to this package's
329 `configure', and exit. The `short' variant lists options used
330 only in the top level, while the `recursive' variant lists options
331 also present in any nested packages.
332
333 `--version'
334 `-V'
335 Print the version of Autoconf used to generate the `configure'
336 script, and exit.
337
338 `--cache-file=FILE'
339 Enable the cache: use and save the results of the tests in FILE,
340 traditionally `config.cache'. FILE defaults to `/dev/null' to
341 disable caching.
342
343 `--config-cache'
344 `-C'
345 Alias for `--cache-file=config.cache'.
346
347 `--quiet'
348 `--silent'
349 `-q'
350 Do not print messages saying which checks are being made. To
351 suppress all normal output, redirect it to `/dev/null' (any error
352 messages will still be shown).
353
354 `--srcdir=DIR'
355 Look for the package's source code in directory DIR. Usually
356 `configure' can determine that directory automatically.
357
358 `--prefix=DIR'
359 Use DIR as the installation prefix. *note Installation Names::
360 for more details, including other options available for fine-tuning
361 the installation locations.
362
363 `--no-create'
364 `-n'
365 Run the configure checks, but stop before creating any output
366 files.
367
368 `configure' also accepts some other, not widely useful, options. Run
369 `configure --help' for more details.
0 Copyright (c) 2013, Verisign, Inc., NLnet Labs
1 All rights reserved.
2
3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions are met:
5 * Redistributions of source code must retain the above copyright
6 notice, this list of conditions and the following disclaimer.
7 * Redistributions in binary form must reproduce the above copyright
8 notice, this list of conditions and the following disclaimer in the
9 documentation and/or other materials provided with the distribution.
10 * Neither the names of the copyright holders nor the
11 names of its contributors may be used to endorse or promote products
12 derived from this software without specific prior written permission.
13
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
18 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0 #
1 # @configure_input@
2 #
3 #
4 # Copyright (c) 2013, Verisign, Inc., NLnet Labs
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * 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 # * Neither the names of the copyright holders nor the
15 # names of its contributors may be used to endorse or promote products
16 # derived from this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 package = @PACKAGE_NAME@
30 version = @PACKAGE_VERSION@
31 tarname = @PACKAGE_TARNAME@
32 distdir = $(tarname)-$(version)
33 bintar = $(distdir)-bin.tar.gz
34
35 prefix = @prefix@
36 exec_prefix = @exec_prefix@
37 bindir = @bindir@
38 sharedoc = $(prefix)/share/doc/getdns-$(version)
39
40 srcdir = @srcdir@
41 VPATH = @srcdir@
42 INSTALL = @INSTALL@
43
44 default:
45 cd src && $(MAKE) $@
46
47 all : default
48
49 install: all
50 $(INSTALL) -m 755 -d $(sharedoc)
51 $(INSTALL) -m 644 AUTHORS $(sharedoc)
52 $(INSTALL) -m 644 ChangeLog $(sharedoc)
53 $(INSTALL) -m 644 COPYING $(sharedoc)
54 $(INSTALL) -m 644 INSTALL $(sharedoc)
55 $(INSTALL) -m 644 LICENSE $(sharedoc)
56 $(INSTALL) -m 644 NEWS $(sharedoc)
57 $(INSTALL) -m 644 README.md $(sharedoc)
58 $(INSTALL) -m 755 -d $(sharedoc)/spec
59 $(INSTALL) -m 644 spec/index.html $(sharedoc)/spec
60 $(INSTALL) -m 644 spec/getdns*tgz $(sharedoc)/spec
61 cd src && $(MAKE) $@
62 cd doc && $(MAKE) $@
63 @echo "***"
64 @echo "*** !!! IMPORTANT !!!! libgetdns needs a DNSSEC trust anchor!"
65 @echo "***"
66 @echo "*** For the library to be able to perform DNSSEC, the root"
67 @echo "*** trust anchor needs to be present in presentation format"
68 @echo "*** in the file: "
69 @echo "*** @TRUST_ANCHOR_FILE@"
70 @echo "***"
71 @echo "*** We recomend using unbound-anchor to retrieve and install"
72 @echo "*** the root trust anchor like this: "
73 @echo "*** unbound-anchor -a \"@TRUST_ANCHOR_FILE@\""
74 @echo "***"
75 @echo "*** We strongly recommend package maintainers to provide the"
76 @echo "*** root trust anchor by installing it with unbound-anchor"
77 @echo "*** at package installation time from the post-install script."
78 @echo "***"
79
80 uninstall:
81 rm -rf -d $(sharedoc)
82 cd doc && $(MAKE) $@
83 cd src && $(MAKE) $@
84
85 doc: FORCE
86 cd doc && $(MAKE) $@
87
88 example:
89 cd src && $(MAKE) $@
90
91 test:
92 cd src && $(MAKE) $@
93
94 clean:
95 cd src && $(MAKE) $@
96 cd doc && $(MAKE) $@
97 rm -f *.o
98
99 distclean:
100 cd src && $(MAKE) $@
101 rm -f config.log config.status Makefile
102 rm -fR autom4te.cache
103
104 dist: $(distdir).tar.gz
105
106 bindist: $(bintar)
107
108 $(bintar): $(distdir)
109 chown -R 0:0 $(distdir)
110 cd $(distdir); ./configure; make
111 tar chof - $(distdir) | gzip -9 -c > $@
112 rm -rf $(distdir)
113
114 $(distdir).tar.gz: $(distdir)
115 chown -R 0:0 $(distdir)
116 tar chof - $(distdir) | gzip -9 -c > $@
117 rm -rf $(distdir)
118
119 $(distdir):
120 mkdir -p $(distdir)/src
121 mkdir -p $(distdir)/src/getdns
122 mkdir -p $(distdir)/src/test
123 mkdir -p $(distdir)/src/example
124 mkdir -p $(distdir)/src/extension
125 mkdir -p $(distdir)/doc
126 mkdir -p $(distdir)/spec
127 cp $(srcdir)/configure.ac $(distdir)
128 cp $(srcdir)/configure $(distdir)
129 cp $(srcdir)/AUTHORS $(distdir)
130 cp $(srcdir)/ChangeLog $(distdir)
131 cp $(srcdir)/COPYING $(distdir)
132 cp $(srcdir)/INSTALL $(distdir)
133 cp $(srcdir)/LICENSE $(distdir)
134 cp $(srcdir)/NEWS $(distdir)
135 cp $(srcdir)/README.md $(distdir)
136 cp $(srcdir)/Makefile.in $(distdir)
137 cp $(srcdir)/install-sh $(distdir)
138 cp $(srcdir)/config.sub $(distdir)
139 cp $(srcdir)/config.guess $(distdir)
140 cp $(srcdir)/libtool $(distdir)
141 cp $(srcdir)/ltmain.sh $(distdir)
142 cp $(srcdir)/src/*.in $(distdir)/src
143 cp $(srcdir)/src/*.[ch] $(distdir)/src
144 cp $(srcdir)/src/extension/*.[ch] $(distdir)/src/extension
145 cp $(srcdir)/src/getdns/*.in $(distdir)/src/getdns
146 cp $(srcdir)/src/getdns/getdns_*.h $(distdir)/src/getdns
147 cp $(srcdir)/src/test/Makefile.in $(distdir)/src/test
148 cp $(srcdir)/src/test/*.[ch] $(distdir)/src/test
149 cp $(srcdir)/src/test/*.sh $(distdir)/src/test
150 cp $(srcdir)/src/test/*.good $(distdir)/src/test
151 cp $(srcdir)/src/example/Makefile.in $(distdir)/src/example
152 cp $(srcdir)/src/example/*.[ch] $(distdir)/src/example
153 cp $(srcdir)/doc/Makefile.in $(distdir)/doc
154 cp $(srcdir)/doc/*.in $(distdir)/doc
155 cp $(srcdir)/doc/manpgaltnames $(distdir)/doc
156 cp $(srcdir)/spec/* $(distdir)/spec
157
158 distcheck: $(distdir).tar.gz
159 gzip -cd $(distdir).tar.gz | tar xvf -
160 cd $(distdir) && ./configure
161 cd $(distdir) && $(MAKE) all
162 cd $(distdir) && $(MAKE) check
163 cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst install
164 cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst uninstall
165 @remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \
166 if test "$${remaining}" -ne 0; then
167 echo "@@@ $${remaining} file(s) remaining in stage directory!"; \
168 exit 1; \
169 fi
170 cd $(distdir) && $(MAKE) clean
171 rm -rf $(distdir)
172 @echo "*** Package $(distdir).tar.gz is ready for distribution"
173
174 Makefile: Makefile.in config.status
175 ./config.status $@
176
177 configure.status: configure
178 ./config.status --recheck
179
180 .PHONY: all distclean clean default doc test
181 FORCE:
0 this page intentionally left blank
0 [![Build Status](https://magnum.travis-ci.com/verisign/getdns.png?token=J2HZXstzJqePUsG523am&branch=develop)](https://magnum.travis-ci.com/verisign/getdns)
1
2 getdns API {#mainpage}
3 ==========
4
5 * Date: 2014-02-26
6 * GitHub: <https://github.com/verisign/getdns>
7
8 getdns is a [modern asynchronous DNS API](http://www.vpnc.org/getdns-api/) intended to make all types of DNS information easily available as described by Paul Hoffman. This implementation is licensed under the New BSD License (BSD-new).
9
10 The [getdns-api mailing list](http://www.vpnc.org/mailman/listinfo/getdns-api) is a good place to engage in discussions regarding the design of the API.
11
12 If you are just getting started with the library take a look at the section below that
13 describes building and handling external dependencies for the library. Once it is
14 built you should take a look at src/examples to see how the library is used.
15
16 This file captures the goals and direction of the project and the current state of the implementation.
17
18 The goals of this implementation of the getdns API are:
19
20 * Provide an open source implementation, in C, of the formally described getdns API by Paul Hoffman at <http://www.vpnc.org/getdns-api/>
21 * Initial support for FreeBSD, OSX, Linux (CentOS/RHEL, Ubuntu) via functional "configure" script
22 * Initial support to include the Android platform
23 * Include examples and tests as part of the build
24 * Document code using doxygen
25 * Leverage github as much as possible for project coordination
26 * Coding style/standards follow the BSD coding style <ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/share/misc/style>
27 * Follow the git flow branching model described at <http://nvie.com/posts/a-successful-git-branching-model/>
28 ** the master branch is always in a production ready state
29 ** the develop branch contains the latest development changes which are merged from develop into master once they are considered production ready
30
31 Non-goals (things we will not be doing at least initially) include:
32 * implementation of the traditional DNS related routines (gethostbyname, etc.)
33
34 ## Language Bindings
35
36 In parallel, the team is actively developing bindings for various languages. For more information, visit the [wiki](https://github.com/verisign/getdns/wiki/Language-Bindings).
37
38 Motivation for providing the API
39 ================================
40
41 The developers are of the opinion that DNSSEC offers a unique global infrastructure for establishing and enhancing cryptographic trust relations. With the development of this API we intend to offer application developers a modern and flexible way that enables end-to-end trust in the DNS architecture and will inspire application developers towards innovative security solutions in their applications.
42
43
44 Releases
45 ========
46 Release numbering follows the [Semantic Versioning](http://semver.org/) approach. The code is currently under active development.
47
48 The following requirements were met as conditions for the present release:
49
50 * code compiles cleanly on at least the primary target platforms: RHEL/CentOS 6.3 Linux, FreeBSD 9.2
51 * examples must compile and be clean
52 * clearly document supported/unsupported elements of the API
53
54
55 Tickets/Bug Reports
56 ===================
57 Tickets and bug reports should be reported via the [GitHub issues list](https://github.com/verisign/getdns/issues).
58
59 Additionally, we have a mailing list at users@getdns.net.
60
61
62 Building/External Dependencies
63 ==============================
64
65 External dependencies are linked outside the getdns API build tree (we rely on configure to find them). We would like to keep the dependency tree short.
66
67 * [libldns from NLnet Labs](https://www.nlnetlabs.nl/projects/ldns/) version 1.6.11 or later (ldns requires openssl headers and libraries)
68 * [libunbound from NLnet Labs](http://www.nlnetlabs.nl/projects/unbound/) version 1.4.16 or later
69 * [libexpat](http://expat.sourceforge.net/) for libunbound.
70 * [libidn from the FSF](http://www.gnu.org/software/libidn/) version 1.
71 * Doxygen is used to generate documentation, while this is not technically necessary for the build it makes things a lot more pleasant.
72
73 You have to install the library and also the library-devel (or -dev) for your
74 package management system to install the compile time files. If you checked
75 out our git; the configure script is built with autoreconf --install.
76
77 ## Extensions / Event loop dependencies
78
79 The implementation works with a variety of event loops, each built as a separate shared library. See [the wiki](https://github.com/verisign/getdns/wiki/Asynchronous-Support#wiki-included-event-loop-integrations) for more details.
80
81 * [libevent](http://libevent.org). Note: the examples *require* this and should work with either libevent 1.x or 2.x. 2.x is preferred.
82 * [libuv](https://github.com/joyent/libuv)
83 * [libev](http://software.schmorp.de/pkg/libev.html)
84
85 ##Regression Tests
86
87 A suite of regression tests are included with the library, if you make changes or just
88 want to sanity check things on your system take a look at src/test. You will need
89 to install [libcheck](http://check.sourceforge.net/). Check is also available from
90 many of the package repositories for the more popular operating systems.
91
92 ## DNSSEC
93
94 For the library to be DNSSEC capable, it needs to know the root trust anchor.
95 The library will try to load the root trust anchor from
96 `/etc/unbound/getdns-root.key` by default. This file is expected to have one
97 or more `DS` or `DNSKEY` resource records in presentation (i.e. zone file)
98 format. Note that this is different than the format of BIND.keys.
99
100 The best way to setup or update the root trust anchor is by using
101 [`unbound-anchor`](http://www.unbound.net/documentation/unbound-anchor.html).
102 To setup the library with the root trust anchor at the default location,
103 execute the following steps as root:
104
105 # mkdir -p /etc/unbound
106 # unbound-anchor -a /etc/unbound/getdns-root.key
107
108 #Unsupported Features
109
110 The following API calls are documented in getDNS but *not supported* by the implementation at this time:
111
112 * Support for OPT Records in `getdns_general` and variants via the `extensions` parameter.
113 * EDNS options
114 * `getdns_context_set_edns_do_bit`
115 * `getdns_context_set_edns_version`
116 * `getdns_context_set_edns_extended_rcode`
117 * `GETDNS_CONTEXT_TCP_ONLY_KEEP_CONNECTIONS_OPEN` with `getdns_context_set_dns_transport`
118 * DNS Search suffixes / local file support
119 * `getdns_context_set_append_name`
120 * `getdns_context_set_suffix`
121 * Setting root servers via `getdns_context_set_dns_root_servers`
122 * `getdns_context_set_dnssec_trust_anchors`
123 * Detecting changes to resolv.conf and hosts
124 * MDNS and NetBIOS namespaces (only DNS and LOCALFILES are supported)
125
126 Some platform specific features are not implemented in the first public release of getdns, however they are on the radar. These include:
127
128 * Respecting settings in /etc/nsswitch.conf (linux and some other OSes), for the first release we simply check local files (/etc/hosts) before checking the DNS.
129 * Search suffixes specified in /etc/resolv.conf
130
131 #Known Issues
132
133 There are a few known issues which we have summarized below - the most recent
134 and helpful list is being maintained in the git issues list in the repository.
135
136 * (#113) Changing the resolution type between stub and recursive after a query has been issued with a context will not work - the previous resolution type will continue to be used. If you want to change the resolution type you will need to create a new context and set the resolution type for that context.
137
138 #Supported Platforms
139
140 The primary platforms targeted are Linux and FreeBSD, other platform are supported as we get time. The names listed here are intended to help ensure that we catch platform specific breakage, not to limit the work that folks are doing.
141
142 * Debian 7.0, 7.3
143 * FreeBSD 8.4, 9.2, 10.0
144 * RHEL/CentOS 6.4, 6.5
145 * OSX 10.8, 10.9
146 * Ubuntu 12.04, 13.10
147
148 For most platforms where we have provided a binary distribution as a compressed tar you
149 can simply untar the file and run "make install". Bear in mind that any dependencies
150 will need to be resolved before you can get the library to do it's work.
151
152 In some cases we have provided binaries that use the native packaging for the platform,
153 where possible dependencies are identified using the method specific to the platform.
154
155 We intend to add MS-Windows, Android and other platforms to the releases as we have time to port it.
156
157
158 ##Build Reports
159
160
161 ###CentOS/RHEL 6.5
162
163 We rely on the most excellent package manager fpm to build the linux packages which
164 means that the packaging platform requires ruby 2.1.0. There are other ways to
165 build the packages, this is simplythe one we chose to use.
166
167 # cat /etc/redhat-release
168 CentOS release 6.5 (Final)
169 # uname -a
170 Linux host-10-1-1-6 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
171 # cd getdns-0.1.0
172 # ./configure --prefix=/home/deploy/build
173 # make; make install
174 # cd /home/deploy/build
175 # mv lib lib64
176 # . /usr/local/rvm/config/alias
177 # fpm -x "*.la" -a native -s dir -t rpm -n getdns -v 0.1.0 -d "unbound" -d "ldns" -d "libevent" -d "libidn" --prefix /usr --vendor "Verisign Inc., NLnet Labs" --license "BSD New" --url "http://www.getdnsapi.net" --description "Modern asynchronous API to the DNS" .
178
179 ###OSX
180
181 # sw_vers
182 ProductName: Mac OS X
183 ProductVersion: 10.8.5
184 BuildVersion: 12F45
185
186 Built using PackageMaker.
187
188 Contributors
189 ============
190 * Craig Despeaux, Verisign, Inc.
191 * Neel Goyal, Verisign, Inc.
192 * Allison Mankin, Verisign, Inc. - Verisign Labs.
193 * Melinda Shore, No Mountain Software LLC
194 * Willem Toorop, NLnet Labs
195 * Wouter Wijngaards, NLnet Labs
196 * Glen Wiley, Verisign, Inc.
197
198 Acknowledgements
199 ================
200 The development team explicitly acknowledges Paul Hoffman for his initiative and efforts to develop a consensus based DNS API. We would like to thank the participants of the [mailing list](http://www.vpnc.org/mailman/listinfo/getdns-api) for their contributions.
0 #! /bin/sh
1 # Attempt to guess a canonical system name.
2 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
4 # 2011, 2012 Free Software Foundation, Inc.
5
6 timestamp='2012-06-10'
7
8 # This file is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #
21 # As a special exception to the GNU General Public License, if you
22 # distribute this file as part of a program that contains a
23 # configuration script generated by Autoconf, you may include it under
24 # the same distribution terms that you use for the rest of that program.
25
26
27 # Originally written by Per Bothner. Please send patches (context
28 # diff format) to <config-patches@gnu.org> and include a ChangeLog
29 # entry.
30 #
31 # This script attempts to guess a canonical system name similar to
32 # config.sub. If it succeeds, it prints the system name on stdout, and
33 # exits with 0. Otherwise, it exits with 1.
34 #
35 # You can get the latest version of this script from:
36 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
37
38 me=`echo "$0" | sed -e 's,.*/,,'`
39
40 usage="\
41 Usage: $0 [OPTION]
42
43 Output the configuration name of the system \`$me' is run on.
44
45 Operation modes:
46 -h, --help print this help, then exit
47 -t, --time-stamp print date of last modification, then exit
48 -v, --version print version number, then exit
49
50 Report bugs and patches to <config-patches@gnu.org>."
51
52 version="\
53 GNU config.guess ($timestamp)
54
55 Originally written by Per Bothner.
56 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
57 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
58 Free Software Foundation, Inc.
59
60 This is free software; see the source for copying conditions. There is NO
61 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
62
63 help="
64 Try \`$me --help' for more information."
65
66 # Parse command line
67 while test $# -gt 0 ; do
68 case $1 in
69 --time-stamp | --time* | -t )
70 echo "$timestamp" ; exit ;;
71 --version | -v )
72 echo "$version" ; exit ;;
73 --help | --h* | -h )
74 echo "$usage"; exit ;;
75 -- ) # Stop option processing
76 shift; break ;;
77 - ) # Use stdin as input.
78 break ;;
79 -* )
80 echo "$me: invalid option $1$help" >&2
81 exit 1 ;;
82 * )
83 break ;;
84 esac
85 done
86
87 if test $# != 0; then
88 echo "$me: too many arguments$help" >&2
89 exit 1
90 fi
91
92 trap 'exit 1' 1 2 15
93
94 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
95 # compiler to aid in system detection is discouraged as it requires
96 # temporary files to be created and, as you can see below, it is a
97 # headache to deal with in a portable fashion.
98
99 # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
100 # use `HOST_CC' if defined, but it is deprecated.
101
102 # Portable tmp directory creation inspired by the Autoconf team.
103
104 set_cc_for_build='
105 trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
106 trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
107 : ${TMPDIR=/tmp} ;
108 { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
109 { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
110 { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
111 { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
112 dummy=$tmp/dummy ;
113 tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
114 case $CC_FOR_BUILD,$HOST_CC,$CC in
115 ,,) echo "int x;" > $dummy.c ;
116 for c in cc gcc c89 c99 ; do
117 if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
118 CC_FOR_BUILD="$c"; break ;
119 fi ;
120 done ;
121 if test x"$CC_FOR_BUILD" = x ; then
122 CC_FOR_BUILD=no_compiler_found ;
123 fi
124 ;;
125 ,,*) CC_FOR_BUILD=$CC ;;
126 ,*,*) CC_FOR_BUILD=$HOST_CC ;;
127 esac ; set_cc_for_build= ;'
128
129 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
130 # (ghazi@noc.rutgers.edu 1994-08-24)
131 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
132 PATH=$PATH:/.attbin ; export PATH
133 fi
134
135 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
136 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
137 UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
138 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
139
140 # Note: order is significant - the case branches are not exclusive.
141
142 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
143 *:NetBSD:*:*)
144 # NetBSD (nbsd) targets should (where applicable) match one or
145 # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
146 # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
147 # switched to ELF, *-*-netbsd* would select the old
148 # object file format. This provides both forward
149 # compatibility and a consistent mechanism for selecting the
150 # object file format.
151 #
152 # Note: NetBSD doesn't particularly care about the vendor
153 # portion of the name. We always set it to "unknown".
154 sysctl="sysctl -n hw.machine_arch"
155 UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
156 /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
157 case "${UNAME_MACHINE_ARCH}" in
158 armeb) machine=armeb-unknown ;;
159 arm*) machine=arm-unknown ;;
160 sh3el) machine=shl-unknown ;;
161 sh3eb) machine=sh-unknown ;;
162 sh5el) machine=sh5le-unknown ;;
163 *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
164 esac
165 # The Operating System including object format, if it has switched
166 # to ELF recently, or will in the future.
167 case "${UNAME_MACHINE_ARCH}" in
168 arm*|i386|m68k|ns32k|sh3*|sparc|vax)
169 eval $set_cc_for_build
170 if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
171 | grep -q __ELF__
172 then
173 # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
174 # Return netbsd for either. FIX?
175 os=netbsd
176 else
177 os=netbsdelf
178 fi
179 ;;
180 *)
181 os=netbsd
182 ;;
183 esac
184 # The OS release
185 # Debian GNU/NetBSD machines have a different userland, and
186 # thus, need a distinct triplet. However, they do not need
187 # kernel version information, so it can be replaced with a
188 # suitable tag, in the style of linux-gnu.
189 case "${UNAME_VERSION}" in
190 Debian*)
191 release='-gnu'
192 ;;
193 *)
194 release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
195 ;;
196 esac
197 # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
198 # contains redundant information, the shorter form:
199 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
200 echo "${machine}-${os}${release}"
201 exit ;;
202 *:OpenBSD:*:*)
203 UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
204 echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
205 exit ;;
206 *:ekkoBSD:*:*)
207 echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
208 exit ;;
209 *:SolidBSD:*:*)
210 echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
211 exit ;;
212 macppc:MirBSD:*:*)
213 echo powerpc-unknown-mirbsd${UNAME_RELEASE}
214 exit ;;
215 *:MirBSD:*:*)
216 echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
217 exit ;;
218 alpha:OSF1:*:*)
219 case $UNAME_RELEASE in
220 *4.0)
221 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
222 ;;
223 *5.*)
224 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
225 ;;
226 esac
227 # According to Compaq, /usr/sbin/psrinfo has been available on
228 # OSF/1 and Tru64 systems produced since 1995. I hope that
229 # covers most systems running today. This code pipes the CPU
230 # types through head -n 1, so we only detect the type of CPU 0.
231 ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
232 case "$ALPHA_CPU_TYPE" in
233 "EV4 (21064)")
234 UNAME_MACHINE="alpha" ;;
235 "EV4.5 (21064)")
236 UNAME_MACHINE="alpha" ;;
237 "LCA4 (21066/21068)")
238 UNAME_MACHINE="alpha" ;;
239 "EV5 (21164)")
240 UNAME_MACHINE="alphaev5" ;;
241 "EV5.6 (21164A)")
242 UNAME_MACHINE="alphaev56" ;;
243 "EV5.6 (21164PC)")
244 UNAME_MACHINE="alphapca56" ;;
245 "EV5.7 (21164PC)")
246 UNAME_MACHINE="alphapca57" ;;
247 "EV6 (21264)")
248 UNAME_MACHINE="alphaev6" ;;
249 "EV6.7 (21264A)")
250 UNAME_MACHINE="alphaev67" ;;
251 "EV6.8CB (21264C)")
252 UNAME_MACHINE="alphaev68" ;;
253 "EV6.8AL (21264B)")
254 UNAME_MACHINE="alphaev68" ;;
255 "EV6.8CX (21264D)")
256 UNAME_MACHINE="alphaev68" ;;
257 "EV6.9A (21264/EV69A)")
258 UNAME_MACHINE="alphaev69" ;;
259 "EV7 (21364)")
260 UNAME_MACHINE="alphaev7" ;;
261 "EV7.9 (21364A)")
262 UNAME_MACHINE="alphaev79" ;;
263 esac
264 # A Pn.n version is a patched version.
265 # A Vn.n version is a released version.
266 # A Tn.n version is a released field test version.
267 # A Xn.n version is an unreleased experimental baselevel.
268 # 1.2 uses "1.2" for uname -r.
269 echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
270 # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
271 exitcode=$?
272 trap '' 0
273 exit $exitcode ;;
274 Alpha\ *:Windows_NT*:*)
275 # How do we know it's Interix rather than the generic POSIX subsystem?
276 # Should we change UNAME_MACHINE based on the output of uname instead
277 # of the specific Alpha model?
278 echo alpha-pc-interix
279 exit ;;
280 21064:Windows_NT:50:3)
281 echo alpha-dec-winnt3.5
282 exit ;;
283 Amiga*:UNIX_System_V:4.0:*)
284 echo m68k-unknown-sysv4
285 exit ;;
286 *:[Aa]miga[Oo][Ss]:*:*)
287 echo ${UNAME_MACHINE}-unknown-amigaos
288 exit ;;
289 *:[Mm]orph[Oo][Ss]:*:*)
290 echo ${UNAME_MACHINE}-unknown-morphos
291 exit ;;
292 *:OS/390:*:*)
293 echo i370-ibm-openedition
294 exit ;;
295 *:z/VM:*:*)
296 echo s390-ibm-zvmoe
297 exit ;;
298 *:OS400:*:*)
299 echo powerpc-ibm-os400
300 exit ;;
301 arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
302 echo arm-acorn-riscix${UNAME_RELEASE}
303 exit ;;
304 arm:riscos:*:*|arm:RISCOS:*:*)
305 echo arm-unknown-riscos
306 exit ;;
307 SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
308 echo hppa1.1-hitachi-hiuxmpp
309 exit ;;
310 Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
311 # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
312 if test "`(/bin/universe) 2>/dev/null`" = att ; then
313 echo pyramid-pyramid-sysv3
314 else
315 echo pyramid-pyramid-bsd
316 fi
317 exit ;;
318 NILE*:*:*:dcosx)
319 echo pyramid-pyramid-svr4
320 exit ;;
321 DRS?6000:unix:4.0:6*)
322 echo sparc-icl-nx6
323 exit ;;
324 DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
325 case `/usr/bin/uname -p` in
326 sparc) echo sparc-icl-nx7; exit ;;
327 esac ;;
328 s390x:SunOS:*:*)
329 echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
330 exit ;;
331 sun4H:SunOS:5.*:*)
332 echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
333 exit ;;
334 sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
335 echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
336 exit ;;
337 i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
338 echo i386-pc-auroraux${UNAME_RELEASE}
339 exit ;;
340 i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
341 eval $set_cc_for_build
342 SUN_ARCH="i386"
343 # If there is a compiler, see if it is configured for 64-bit objects.
344 # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
345 # This test works for both compilers.
346 if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
347 if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
348 (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
349 grep IS_64BIT_ARCH >/dev/null
350 then
351 SUN_ARCH="x86_64"
352 fi
353 fi
354 echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
355 exit ;;
356 sun4*:SunOS:6*:*)
357 # According to config.sub, this is the proper way to canonicalize
358 # SunOS6. Hard to guess exactly what SunOS6 will be like, but
359 # it's likely to be more like Solaris than SunOS4.
360 echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
361 exit ;;
362 sun4*:SunOS:*:*)
363 case "`/usr/bin/arch -k`" in
364 Series*|S4*)
365 UNAME_RELEASE=`uname -v`
366 ;;
367 esac
368 # Japanese Language versions have a version number like `4.1.3-JL'.
369 echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
370 exit ;;
371 sun3*:SunOS:*:*)
372 echo m68k-sun-sunos${UNAME_RELEASE}
373 exit ;;
374 sun*:*:4.2BSD:*)
375 UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
376 test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
377 case "`/bin/arch`" in
378 sun3)
379 echo m68k-sun-sunos${UNAME_RELEASE}
380 ;;
381 sun4)
382 echo sparc-sun-sunos${UNAME_RELEASE}
383 ;;
384 esac
385 exit ;;
386 aushp:SunOS:*:*)
387 echo sparc-auspex-sunos${UNAME_RELEASE}
388 exit ;;
389 # The situation for MiNT is a little confusing. The machine name
390 # can be virtually everything (everything which is not
391 # "atarist" or "atariste" at least should have a processor
392 # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
393 # to the lowercase version "mint" (or "freemint"). Finally
394 # the system name "TOS" denotes a system which is actually not
395 # MiNT. But MiNT is downward compatible to TOS, so this should
396 # be no problem.
397 atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
398 echo m68k-atari-mint${UNAME_RELEASE}
399 exit ;;
400 atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
401 echo m68k-atari-mint${UNAME_RELEASE}
402 exit ;;
403 *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
404 echo m68k-atari-mint${UNAME_RELEASE}
405 exit ;;
406 milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
407 echo m68k-milan-mint${UNAME_RELEASE}
408 exit ;;
409 hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
410 echo m68k-hades-mint${UNAME_RELEASE}
411 exit ;;
412 *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
413 echo m68k-unknown-mint${UNAME_RELEASE}
414 exit ;;
415 m68k:machten:*:*)
416 echo m68k-apple-machten${UNAME_RELEASE}
417 exit ;;
418 powerpc:machten:*:*)
419 echo powerpc-apple-machten${UNAME_RELEASE}
420 exit ;;
421 RISC*:Mach:*:*)
422 echo mips-dec-mach_bsd4.3
423 exit ;;
424 RISC*:ULTRIX:*:*)
425 echo mips-dec-ultrix${UNAME_RELEASE}
426 exit ;;
427 VAX*:ULTRIX*:*:*)
428 echo vax-dec-ultrix${UNAME_RELEASE}
429 exit ;;
430 2020:CLIX:*:* | 2430:CLIX:*:*)
431 echo clipper-intergraph-clix${UNAME_RELEASE}
432 exit ;;
433 mips:*:*:UMIPS | mips:*:*:RISCos)
434 eval $set_cc_for_build
435 sed 's/^ //' << EOF >$dummy.c
436 #ifdef __cplusplus
437 #include <stdio.h> /* for printf() prototype */
438 int main (int argc, char *argv[]) {
439 #else
440 int main (argc, argv) int argc; char *argv[]; {
441 #endif
442 #if defined (host_mips) && defined (MIPSEB)
443 #if defined (SYSTYPE_SYSV)
444 printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
445 #endif
446 #if defined (SYSTYPE_SVR4)
447 printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
448 #endif
449 #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
450 printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
451 #endif
452 #endif
453 exit (-1);
454 }
455 EOF
456 $CC_FOR_BUILD -o $dummy $dummy.c &&
457 dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
458 SYSTEM_NAME=`$dummy $dummyarg` &&
459 { echo "$SYSTEM_NAME"; exit; }
460 echo mips-mips-riscos${UNAME_RELEASE}
461 exit ;;
462 Motorola:PowerMAX_OS:*:*)
463 echo powerpc-motorola-powermax
464 exit ;;
465 Motorola:*:4.3:PL8-*)
466 echo powerpc-harris-powermax
467 exit ;;
468 Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
469 echo powerpc-harris-powermax
470 exit ;;
471 Night_Hawk:Power_UNIX:*:*)
472 echo powerpc-harris-powerunix
473 exit ;;
474 m88k:CX/UX:7*:*)
475 echo m88k-harris-cxux7
476 exit ;;
477 m88k:*:4*:R4*)
478 echo m88k-motorola-sysv4
479 exit ;;
480 m88k:*:3*:R3*)
481 echo m88k-motorola-sysv3
482 exit ;;
483 AViiON:dgux:*:*)
484 # DG/UX returns AViiON for all architectures
485 UNAME_PROCESSOR=`/usr/bin/uname -p`
486 if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
487 then
488 if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
489 [ ${TARGET_BINARY_INTERFACE}x = x ]
490 then
491 echo m88k-dg-dgux${UNAME_RELEASE}
492 else
493 echo m88k-dg-dguxbcs${UNAME_RELEASE}
494 fi
495 else
496 echo i586-dg-dgux${UNAME_RELEASE}
497 fi
498 exit ;;
499 M88*:DolphinOS:*:*) # DolphinOS (SVR3)
500 echo m88k-dolphin-sysv3
501 exit ;;
502 M88*:*:R3*:*)
503 # Delta 88k system running SVR3
504 echo m88k-motorola-sysv3
505 exit ;;
506 XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
507 echo m88k-tektronix-sysv3
508 exit ;;
509 Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
510 echo m68k-tektronix-bsd
511 exit ;;
512 *:IRIX*:*:*)
513 echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
514 exit ;;
515 ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
516 echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
517 exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
518 i*86:AIX:*:*)
519 echo i386-ibm-aix
520 exit ;;
521 ia64:AIX:*:*)
522 if [ -x /usr/bin/oslevel ] ; then
523 IBM_REV=`/usr/bin/oslevel`
524 else
525 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
526 fi
527 echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
528 exit ;;
529 *:AIX:2:3)
530 if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
531 eval $set_cc_for_build
532 sed 's/^ //' << EOF >$dummy.c
533 #include <sys/systemcfg.h>
534
535 main()
536 {
537 if (!__power_pc())
538 exit(1);
539 puts("powerpc-ibm-aix3.2.5");
540 exit(0);
541 }
542 EOF
543 if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
544 then
545 echo "$SYSTEM_NAME"
546 else
547 echo rs6000-ibm-aix3.2.5
548 fi
549 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
550 echo rs6000-ibm-aix3.2.4
551 else
552 echo rs6000-ibm-aix3.2
553 fi
554 exit ;;
555 *:AIX:*:[4567])
556 IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
557 if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
558 IBM_ARCH=rs6000
559 else
560 IBM_ARCH=powerpc
561 fi
562 if [ -x /usr/bin/oslevel ] ; then
563 IBM_REV=`/usr/bin/oslevel`
564 else
565 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
566 fi
567 echo ${IBM_ARCH}-ibm-aix${IBM_REV}
568 exit ;;
569 *:AIX:*:*)
570 echo rs6000-ibm-aix
571 exit ;;
572 ibmrt:4.4BSD:*|romp-ibm:BSD:*)
573 echo romp-ibm-bsd4.4
574 exit ;;
575 ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
576 echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
577 exit ;; # report: romp-ibm BSD 4.3
578 *:BOSX:*:*)
579 echo rs6000-bull-bosx
580 exit ;;
581 DPX/2?00:B.O.S.:*:*)
582 echo m68k-bull-sysv3
583 exit ;;
584 9000/[34]??:4.3bsd:1.*:*)
585 echo m68k-hp-bsd
586 exit ;;
587 hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
588 echo m68k-hp-bsd4.4
589 exit ;;
590 9000/[34678]??:HP-UX:*:*)
591 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
592 case "${UNAME_MACHINE}" in
593 9000/31? ) HP_ARCH=m68000 ;;
594 9000/[34]?? ) HP_ARCH=m68k ;;
595 9000/[678][0-9][0-9])
596 if [ -x /usr/bin/getconf ]; then
597 sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
598 sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
599 case "${sc_cpu_version}" in
600 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
601 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
602 532) # CPU_PA_RISC2_0
603 case "${sc_kernel_bits}" in
604 32) HP_ARCH="hppa2.0n" ;;
605 64) HP_ARCH="hppa2.0w" ;;
606 '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
607 esac ;;
608 esac
609 fi
610 if [ "${HP_ARCH}" = "" ]; then
611 eval $set_cc_for_build
612 sed 's/^ //' << EOF >$dummy.c
613
614 #define _HPUX_SOURCE
615 #include <stdlib.h>
616 #include <unistd.h>
617
618 int main ()
619 {
620 #if defined(_SC_KERNEL_BITS)
621 long bits = sysconf(_SC_KERNEL_BITS);
622 #endif
623 long cpu = sysconf (_SC_CPU_VERSION);
624
625 switch (cpu)
626 {
627 case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
628 case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
629 case CPU_PA_RISC2_0:
630 #if defined(_SC_KERNEL_BITS)
631 switch (bits)
632 {
633 case 64: puts ("hppa2.0w"); break;
634 case 32: puts ("hppa2.0n"); break;
635 default: puts ("hppa2.0"); break;
636 } break;
637 #else /* !defined(_SC_KERNEL_BITS) */
638 puts ("hppa2.0"); break;
639 #endif
640 default: puts ("hppa1.0"); break;
641 }
642 exit (0);
643 }
644 EOF
645 (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
646 test -z "$HP_ARCH" && HP_ARCH=hppa
647 fi ;;
648 esac
649 if [ ${HP_ARCH} = "hppa2.0w" ]
650 then
651 eval $set_cc_for_build
652
653 # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
654 # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
655 # generating 64-bit code. GNU and HP use different nomenclature:
656 #
657 # $ CC_FOR_BUILD=cc ./config.guess
658 # => hppa2.0w-hp-hpux11.23
659 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
660 # => hppa64-hp-hpux11.23
661
662 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
663 grep -q __LP64__
664 then
665 HP_ARCH="hppa2.0w"
666 else
667 HP_ARCH="hppa64"
668 fi
669 fi
670 echo ${HP_ARCH}-hp-hpux${HPUX_REV}
671 exit ;;
672 ia64:HP-UX:*:*)
673 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
674 echo ia64-hp-hpux${HPUX_REV}
675 exit ;;
676 3050*:HI-UX:*:*)
677 eval $set_cc_for_build
678 sed 's/^ //' << EOF >$dummy.c
679 #include <unistd.h>
680 int
681 main ()
682 {
683 long cpu = sysconf (_SC_CPU_VERSION);
684 /* The order matters, because CPU_IS_HP_MC68K erroneously returns
685 true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
686 results, however. */
687 if (CPU_IS_PA_RISC (cpu))
688 {
689 switch (cpu)
690 {
691 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
692 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
693 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
694 default: puts ("hppa-hitachi-hiuxwe2"); break;
695 }
696 }
697 else if (CPU_IS_HP_MC68K (cpu))
698 puts ("m68k-hitachi-hiuxwe2");
699 else puts ("unknown-hitachi-hiuxwe2");
700 exit (0);
701 }
702 EOF
703 $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
704 { echo "$SYSTEM_NAME"; exit; }
705 echo unknown-hitachi-hiuxwe2
706 exit ;;
707 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
708 echo hppa1.1-hp-bsd
709 exit ;;
710 9000/8??:4.3bsd:*:*)
711 echo hppa1.0-hp-bsd
712 exit ;;
713 *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
714 echo hppa1.0-hp-mpeix
715 exit ;;
716 hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
717 echo hppa1.1-hp-osf
718 exit ;;
719 hp8??:OSF1:*:*)
720 echo hppa1.0-hp-osf
721 exit ;;
722 i*86:OSF1:*:*)
723 if [ -x /usr/sbin/sysversion ] ; then
724 echo ${UNAME_MACHINE}-unknown-osf1mk
725 else
726 echo ${UNAME_MACHINE}-unknown-osf1
727 fi
728 exit ;;
729 parisc*:Lites*:*:*)
730 echo hppa1.1-hp-lites
731 exit ;;
732 C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
733 echo c1-convex-bsd
734 exit ;;
735 C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
736 if getsysinfo -f scalar_acc
737 then echo c32-convex-bsd
738 else echo c2-convex-bsd
739 fi
740 exit ;;
741 C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
742 echo c34-convex-bsd
743 exit ;;
744 C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
745 echo c38-convex-bsd
746 exit ;;
747 C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
748 echo c4-convex-bsd
749 exit ;;
750 CRAY*Y-MP:*:*:*)
751 echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
752 exit ;;
753 CRAY*[A-Z]90:*:*:*)
754 echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
755 | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
756 -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
757 -e 's/\.[^.]*$/.X/'
758 exit ;;
759 CRAY*TS:*:*:*)
760 echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
761 exit ;;
762 CRAY*T3E:*:*:*)
763 echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
764 exit ;;
765 CRAY*SV1:*:*:*)
766 echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
767 exit ;;
768 *:UNICOS/mp:*:*)
769 echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
770 exit ;;
771 F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
772 FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
773 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
774 FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
775 echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
776 exit ;;
777 5000:UNIX_System_V:4.*:*)
778 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
779 FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
780 echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
781 exit ;;
782 i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
783 echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
784 exit ;;
785 sparc*:BSD/OS:*:*)
786 echo sparc-unknown-bsdi${UNAME_RELEASE}
787 exit ;;
788 *:BSD/OS:*:*)
789 echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
790 exit ;;
791 *:FreeBSD:*:*)
792 UNAME_PROCESSOR=`/usr/bin/uname -p`
793 case ${UNAME_PROCESSOR} in
794 amd64)
795 echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
796 *)
797 echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
798 esac
799 exit ;;
800 i*:CYGWIN*:*)
801 echo ${UNAME_MACHINE}-pc-cygwin
802 exit ;;
803 *:MINGW*:*)
804 echo ${UNAME_MACHINE}-pc-mingw32
805 exit ;;
806 i*:MSYS*:*)
807 echo ${UNAME_MACHINE}-pc-msys
808 exit ;;
809 i*:windows32*:*)
810 # uname -m includes "-pc" on this system.
811 echo ${UNAME_MACHINE}-mingw32
812 exit ;;
813 i*:PW*:*)
814 echo ${UNAME_MACHINE}-pc-pw32
815 exit ;;
816 *:Interix*:*)
817 case ${UNAME_MACHINE} in
818 x86)
819 echo i586-pc-interix${UNAME_RELEASE}
820 exit ;;
821 authenticamd | genuineintel | EM64T)
822 echo x86_64-unknown-interix${UNAME_RELEASE}
823 exit ;;
824 IA64)
825 echo ia64-unknown-interix${UNAME_RELEASE}
826 exit ;;
827 esac ;;
828 [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
829 echo i${UNAME_MACHINE}-pc-mks
830 exit ;;
831 8664:Windows_NT:*)
832 echo x86_64-pc-mks
833 exit ;;
834 i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
835 # How do we know it's Interix rather than the generic POSIX subsystem?
836 # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
837 # UNAME_MACHINE based on the output of uname instead of i386?
838 echo i586-pc-interix
839 exit ;;
840 i*:UWIN*:*)
841 echo ${UNAME_MACHINE}-pc-uwin
842 exit ;;
843 amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
844 echo x86_64-unknown-cygwin
845 exit ;;
846 p*:CYGWIN*:*)
847 echo powerpcle-unknown-cygwin
848 exit ;;
849 prep*:SunOS:5.*:*)
850 echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
851 exit ;;
852 *:GNU:*:*)
853 # the GNU system
854 echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
855 exit ;;
856 *:GNU/*:*:*)
857 # other systems with GNU libc and userland
858 echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
859 exit ;;
860 i*86:Minix:*:*)
861 echo ${UNAME_MACHINE}-pc-minix
862 exit ;;
863 aarch64:Linux:*:*)
864 echo ${UNAME_MACHINE}-unknown-linux-gnu
865 exit ;;
866 aarch64_be:Linux:*:*)
867 UNAME_MACHINE=aarch64_be
868 echo ${UNAME_MACHINE}-unknown-linux-gnu
869 exit ;;
870 alpha:Linux:*:*)
871 case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
872 EV5) UNAME_MACHINE=alphaev5 ;;
873 EV56) UNAME_MACHINE=alphaev56 ;;
874 PCA56) UNAME_MACHINE=alphapca56 ;;
875 PCA57) UNAME_MACHINE=alphapca56 ;;
876 EV6) UNAME_MACHINE=alphaev6 ;;
877 EV67) UNAME_MACHINE=alphaev67 ;;
878 EV68*) UNAME_MACHINE=alphaev68 ;;
879 esac
880 objdump --private-headers /bin/sh | grep -q ld.so.1
881 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
882 echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
883 exit ;;
884 arm*:Linux:*:*)
885 eval $set_cc_for_build
886 if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
887 | grep -q __ARM_EABI__
888 then
889 echo ${UNAME_MACHINE}-unknown-linux-gnu
890 else
891 if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
892 | grep -q __ARM_PCS_VFP
893 then
894 echo ${UNAME_MACHINE}-unknown-linux-gnueabi
895 else
896 echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
897 fi
898 fi
899 exit ;;
900 avr32*:Linux:*:*)
901 echo ${UNAME_MACHINE}-unknown-linux-gnu
902 exit ;;
903 cris:Linux:*:*)
904 echo ${UNAME_MACHINE}-axis-linux-gnu
905 exit ;;
906 crisv32:Linux:*:*)
907 echo ${UNAME_MACHINE}-axis-linux-gnu
908 exit ;;
909 frv:Linux:*:*)
910 echo ${UNAME_MACHINE}-unknown-linux-gnu
911 exit ;;
912 hexagon:Linux:*:*)
913 echo ${UNAME_MACHINE}-unknown-linux-gnu
914 exit ;;
915 i*86:Linux:*:*)
916 LIBC=gnu
917 eval $set_cc_for_build
918 sed 's/^ //' << EOF >$dummy.c
919 #ifdef __dietlibc__
920 LIBC=dietlibc
921 #endif
922 EOF
923 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
924 echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
925 exit ;;
926 ia64:Linux:*:*)
927 echo ${UNAME_MACHINE}-unknown-linux-gnu
928 exit ;;
929 m32r*:Linux:*:*)
930 echo ${UNAME_MACHINE}-unknown-linux-gnu
931 exit ;;
932 m68*:Linux:*:*)
933 echo ${UNAME_MACHINE}-unknown-linux-gnu
934 exit ;;
935 mips:Linux:*:* | mips64:Linux:*:*)
936 eval $set_cc_for_build
937 sed 's/^ //' << EOF >$dummy.c
938 #undef CPU
939 #undef ${UNAME_MACHINE}
940 #undef ${UNAME_MACHINE}el
941 #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
942 CPU=${UNAME_MACHINE}el
943 #else
944 #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
945 CPU=${UNAME_MACHINE}
946 #else
947 CPU=
948 #endif
949 #endif
950 EOF
951 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
952 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
953 ;;
954 or32:Linux:*:*)
955 echo ${UNAME_MACHINE}-unknown-linux-gnu
956 exit ;;
957 padre:Linux:*:*)
958 echo sparc-unknown-linux-gnu
959 exit ;;
960 parisc64:Linux:*:* | hppa64:Linux:*:*)
961 echo hppa64-unknown-linux-gnu
962 exit ;;
963 parisc:Linux:*:* | hppa:Linux:*:*)
964 # Look for CPU level
965 case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
966 PA7*) echo hppa1.1-unknown-linux-gnu ;;
967 PA8*) echo hppa2.0-unknown-linux-gnu ;;
968 *) echo hppa-unknown-linux-gnu ;;
969 esac
970 exit ;;
971 ppc64:Linux:*:*)
972 echo powerpc64-unknown-linux-gnu
973 exit ;;
974 ppc:Linux:*:*)
975 echo powerpc-unknown-linux-gnu
976 exit ;;
977 s390:Linux:*:* | s390x:Linux:*:*)
978 echo ${UNAME_MACHINE}-ibm-linux
979 exit ;;
980 sh64*:Linux:*:*)
981 echo ${UNAME_MACHINE}-unknown-linux-gnu
982 exit ;;
983 sh*:Linux:*:*)
984 echo ${UNAME_MACHINE}-unknown-linux-gnu
985 exit ;;
986 sparc:Linux:*:* | sparc64:Linux:*:*)
987 echo ${UNAME_MACHINE}-unknown-linux-gnu
988 exit ;;
989 tile*:Linux:*:*)
990 echo ${UNAME_MACHINE}-unknown-linux-gnu
991 exit ;;
992 vax:Linux:*:*)
993 echo ${UNAME_MACHINE}-dec-linux-gnu
994 exit ;;
995 x86_64:Linux:*:*)
996 echo ${UNAME_MACHINE}-unknown-linux-gnu
997 exit ;;
998 xtensa*:Linux:*:*)
999 echo ${UNAME_MACHINE}-unknown-linux-gnu
1000 exit ;;
1001 i*86:DYNIX/ptx:4*:*)
1002 # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
1003 # earlier versions are messed up and put the nodename in both
1004 # sysname and nodename.
1005 echo i386-sequent-sysv4
1006 exit ;;
1007 i*86:UNIX_SV:4.2MP:2.*)
1008 # Unixware is an offshoot of SVR4, but it has its own version
1009 # number series starting with 2...
1010 # I am not positive that other SVR4 systems won't match this,
1011 # I just have to hope. -- rms.
1012 # Use sysv4.2uw... so that sysv4* matches it.
1013 echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
1014 exit ;;
1015 i*86:OS/2:*:*)
1016 # If we were able to find `uname', then EMX Unix compatibility
1017 # is probably installed.
1018 echo ${UNAME_MACHINE}-pc-os2-emx
1019 exit ;;
1020 i*86:XTS-300:*:STOP)
1021 echo ${UNAME_MACHINE}-unknown-stop
1022 exit ;;
1023 i*86:atheos:*:*)
1024 echo ${UNAME_MACHINE}-unknown-atheos
1025 exit ;;
1026 i*86:syllable:*:*)
1027 echo ${UNAME_MACHINE}-pc-syllable
1028 exit ;;
1029 i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
1030 echo i386-unknown-lynxos${UNAME_RELEASE}
1031 exit ;;
1032 i*86:*DOS:*:*)
1033 echo ${UNAME_MACHINE}-pc-msdosdjgpp
1034 exit ;;
1035 i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
1036 UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
1037 if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1038 echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
1039 else
1040 echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
1041 fi
1042 exit ;;
1043 i*86:*:5:[678]*)
1044 # UnixWare 7.x, OpenUNIX and OpenServer 6.
1045 case `/bin/uname -X | grep "^Machine"` in
1046 *486*) UNAME_MACHINE=i486 ;;
1047 *Pentium) UNAME_MACHINE=i586 ;;
1048 *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1049 esac
1050 echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1051 exit ;;
1052 i*86:*:3.2:*)
1053 if test -f /usr/options/cb.name; then
1054 UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1055 echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
1056 elif /bin/uname -X 2>/dev/null >/dev/null ; then
1057 UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1058 (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1059 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1060 && UNAME_MACHINE=i586
1061 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1062 && UNAME_MACHINE=i686
1063 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1064 && UNAME_MACHINE=i686
1065 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
1066 else
1067 echo ${UNAME_MACHINE}-pc-sysv32
1068 fi
1069 exit ;;
1070 pc:*:*:*)
1071 # Left here for compatibility:
1072 # uname -m prints for DJGPP always 'pc', but it prints nothing about
1073 # the processor, so we play safe by assuming i586.
1074 # Note: whatever this is, it MUST be the same as what config.sub
1075 # prints for the "djgpp" host, or else GDB configury will decide that
1076 # this is a cross-build.
1077 echo i586-pc-msdosdjgpp
1078 exit ;;
1079 Intel:Mach:3*:*)
1080 echo i386-pc-mach3
1081 exit ;;
1082 paragon:*:*:*)
1083 echo i860-intel-osf1
1084 exit ;;
1085 i860:*:4.*:*) # i860-SVR4
1086 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1087 echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
1088 else # Add other i860-SVR4 vendors below as they are discovered.
1089 echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
1090 fi
1091 exit ;;
1092 mini*:CTIX:SYS*5:*)
1093 # "miniframe"
1094 echo m68010-convergent-sysv
1095 exit ;;
1096 mc68k:UNIX:SYSTEM5:3.51m)
1097 echo m68k-convergent-sysv
1098 exit ;;
1099 M680?0:D-NIX:5.3:*)
1100 echo m68k-diab-dnix
1101 exit ;;
1102 M68*:*:R3V[5678]*:*)
1103 test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
1104 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
1105 OS_REL=''
1106 test -r /etc/.relid \
1107 && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1108 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1109 && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
1110 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1111 && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
1112 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1113 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1114 && { echo i486-ncr-sysv4; exit; } ;;
1115 NCR*:*:4.2:* | MPRAS*:*:4.2:*)
1116 OS_REL='.3'
1117 test -r /etc/.relid \
1118 && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1119 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1120 && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
1121 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1122 && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
1123 /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
1124 && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
1125 m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1126 echo m68k-unknown-lynxos${UNAME_RELEASE}
1127 exit ;;
1128 mc68030:UNIX_System_V:4.*:*)
1129 echo m68k-atari-sysv4
1130 exit ;;
1131 TSUNAMI:LynxOS:2.*:*)
1132 echo sparc-unknown-lynxos${UNAME_RELEASE}
1133 exit ;;
1134 rs6000:LynxOS:2.*:*)
1135 echo rs6000-unknown-lynxos${UNAME_RELEASE}
1136 exit ;;
1137 PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
1138 echo powerpc-unknown-lynxos${UNAME_RELEASE}
1139 exit ;;
1140 SM[BE]S:UNIX_SV:*:*)
1141 echo mips-dde-sysv${UNAME_RELEASE}
1142 exit ;;
1143 RM*:ReliantUNIX-*:*:*)
1144 echo mips-sni-sysv4
1145 exit ;;
1146 RM*:SINIX-*:*:*)
1147 echo mips-sni-sysv4
1148 exit ;;
1149 *:SINIX-*:*:*)
1150 if uname -p 2>/dev/null >/dev/null ; then
1151 UNAME_MACHINE=`(uname -p) 2>/dev/null`
1152 echo ${UNAME_MACHINE}-sni-sysv4
1153 else
1154 echo ns32k-sni-sysv
1155 fi
1156 exit ;;
1157 PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1158 # says <Richard.M.Bartel@ccMail.Census.GOV>
1159 echo i586-unisys-sysv4
1160 exit ;;
1161 *:UNIX_System_V:4*:FTX*)
1162 # From Gerald Hewes <hewes@openmarket.com>.
1163 # How about differentiating between stratus architectures? -djm
1164 echo hppa1.1-stratus-sysv4
1165 exit ;;
1166 *:*:*:FTX*)
1167 # From seanf@swdc.stratus.com.
1168 echo i860-stratus-sysv4
1169 exit ;;
1170 i*86:VOS:*:*)
1171 # From Paul.Green@stratus.com.
1172 echo ${UNAME_MACHINE}-stratus-vos
1173 exit ;;
1174 *:VOS:*:*)
1175 # From Paul.Green@stratus.com.
1176 echo hppa1.1-stratus-vos
1177 exit ;;
1178 mc68*:A/UX:*:*)
1179 echo m68k-apple-aux${UNAME_RELEASE}
1180 exit ;;
1181 news*:NEWS-OS:6*:*)
1182 echo mips-sony-newsos6
1183 exit ;;
1184 R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1185 if [ -d /usr/nec ]; then
1186 echo mips-nec-sysv${UNAME_RELEASE}
1187 else
1188 echo mips-unknown-sysv${UNAME_RELEASE}
1189 fi
1190 exit ;;
1191 BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
1192 echo powerpc-be-beos
1193 exit ;;
1194 BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
1195 echo powerpc-apple-beos
1196 exit ;;
1197 BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
1198 echo i586-pc-beos
1199 exit ;;
1200 BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
1201 echo i586-pc-haiku
1202 exit ;;
1203 SX-4:SUPER-UX:*:*)
1204 echo sx4-nec-superux${UNAME_RELEASE}
1205 exit ;;
1206 SX-5:SUPER-UX:*:*)
1207 echo sx5-nec-superux${UNAME_RELEASE}
1208 exit ;;
1209 SX-6:SUPER-UX:*:*)
1210 echo sx6-nec-superux${UNAME_RELEASE}
1211 exit ;;
1212 SX-7:SUPER-UX:*:*)
1213 echo sx7-nec-superux${UNAME_RELEASE}
1214 exit ;;
1215 SX-8:SUPER-UX:*:*)
1216 echo sx8-nec-superux${UNAME_RELEASE}
1217 exit ;;
1218 SX-8R:SUPER-UX:*:*)
1219 echo sx8r-nec-superux${UNAME_RELEASE}
1220 exit ;;
1221 Power*:Rhapsody:*:*)
1222 echo powerpc-apple-rhapsody${UNAME_RELEASE}
1223 exit ;;
1224 *:Rhapsody:*:*)
1225 echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
1226 exit ;;
1227 *:Darwin:*:*)
1228 UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
1229 case $UNAME_PROCESSOR in
1230 i386)
1231 eval $set_cc_for_build
1232 if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
1233 if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
1234 (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
1235 grep IS_64BIT_ARCH >/dev/null
1236 then
1237 UNAME_PROCESSOR="x86_64"
1238 fi
1239 fi ;;
1240 unknown) UNAME_PROCESSOR=powerpc ;;
1241 esac
1242 echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
1243 exit ;;
1244 *:procnto*:*:* | *:QNX:[0123456789]*:*)
1245 UNAME_PROCESSOR=`uname -p`
1246 if test "$UNAME_PROCESSOR" = "x86"; then
1247 UNAME_PROCESSOR=i386
1248 UNAME_MACHINE=pc
1249 fi
1250 echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
1251 exit ;;
1252 *:QNX:*:4*)
1253 echo i386-pc-qnx
1254 exit ;;
1255 NEO-?:NONSTOP_KERNEL:*:*)
1256 echo neo-tandem-nsk${UNAME_RELEASE}
1257 exit ;;
1258 NSE-*:NONSTOP_KERNEL:*:*)
1259 echo nse-tandem-nsk${UNAME_RELEASE}
1260 exit ;;
1261 NSR-?:NONSTOP_KERNEL:*:*)
1262 echo nsr-tandem-nsk${UNAME_RELEASE}
1263 exit ;;
1264 *:NonStop-UX:*:*)
1265 echo mips-compaq-nonstopux
1266 exit ;;
1267 BS2000:POSIX*:*:*)
1268 echo bs2000-siemens-sysv
1269 exit ;;
1270 DS/*:UNIX_System_V:*:*)
1271 echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
1272 exit ;;
1273 *:Plan9:*:*)
1274 # "uname -m" is not consistent, so use $cputype instead. 386
1275 # is converted to i386 for consistency with other x86
1276 # operating systems.
1277 if test "$cputype" = "386"; then
1278 UNAME_MACHINE=i386
1279 else
1280 UNAME_MACHINE="$cputype"
1281 fi
1282 echo ${UNAME_MACHINE}-unknown-plan9
1283 exit ;;
1284 *:TOPS-10:*:*)
1285 echo pdp10-unknown-tops10
1286 exit ;;
1287 *:TENEX:*:*)
1288 echo pdp10-unknown-tenex
1289 exit ;;
1290 KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1291 echo pdp10-dec-tops20
1292 exit ;;
1293 XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1294 echo pdp10-xkl-tops20
1295 exit ;;
1296 *:TOPS-20:*:*)
1297 echo pdp10-unknown-tops20
1298 exit ;;
1299 *:ITS:*:*)
1300 echo pdp10-unknown-its
1301 exit ;;
1302 SEI:*:*:SEIUX)
1303 echo mips-sei-seiux${UNAME_RELEASE}
1304 exit ;;
1305 *:DragonFly:*:*)
1306 echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
1307 exit ;;
1308 *:*VMS:*:*)
1309 UNAME_MACHINE=`(uname -p) 2>/dev/null`
1310 case "${UNAME_MACHINE}" in
1311 A*) echo alpha-dec-vms ; exit ;;
1312 I*) echo ia64-dec-vms ; exit ;;
1313 V*) echo vax-dec-vms ; exit ;;
1314 esac ;;
1315 *:XENIX:*:SysV)
1316 echo i386-pc-xenix
1317 exit ;;
1318 i*86:skyos:*:*)
1319 echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
1320 exit ;;
1321 i*86:rdos:*:*)
1322 echo ${UNAME_MACHINE}-pc-rdos
1323 exit ;;
1324 i*86:AROS:*:*)
1325 echo ${UNAME_MACHINE}-pc-aros
1326 exit ;;
1327 x86_64:VMkernel:*:*)
1328 echo ${UNAME_MACHINE}-unknown-esx
1329 exit ;;
1330 esac
1331
1332 #echo '(No uname command or uname output not recognized.)' 1>&2
1333 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
1334
1335 eval $set_cc_for_build
1336 cat >$dummy.c <<EOF
1337 #ifdef _SEQUENT_
1338 # include <sys/types.h>
1339 # include <sys/utsname.h>
1340 #endif
1341 main ()
1342 {
1343 #if defined (sony)
1344 #if defined (MIPSEB)
1345 /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
1346 I don't know.... */
1347 printf ("mips-sony-bsd\n"); exit (0);
1348 #else
1349 #include <sys/param.h>
1350 printf ("m68k-sony-newsos%s\n",
1351 #ifdef NEWSOS4
1352 "4"
1353 #else
1354 ""
1355 #endif
1356 ); exit (0);
1357 #endif
1358 #endif
1359
1360 #if defined (__arm) && defined (__acorn) && defined (__unix)
1361 printf ("arm-acorn-riscix\n"); exit (0);
1362 #endif
1363
1364 #if defined (hp300) && !defined (hpux)
1365 printf ("m68k-hp-bsd\n"); exit (0);
1366 #endif
1367
1368 #if defined (NeXT)
1369 #if !defined (__ARCHITECTURE__)
1370 #define __ARCHITECTURE__ "m68k"
1371 #endif
1372 int version;
1373 version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1374 if (version < 4)
1375 printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1376 else
1377 printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1378 exit (0);
1379 #endif
1380
1381 #if defined (MULTIMAX) || defined (n16)
1382 #if defined (UMAXV)
1383 printf ("ns32k-encore-sysv\n"); exit (0);
1384 #else
1385 #if defined (CMU)
1386 printf ("ns32k-encore-mach\n"); exit (0);
1387 #else
1388 printf ("ns32k-encore-bsd\n"); exit (0);
1389 #endif
1390 #endif
1391 #endif
1392
1393 #if defined (__386BSD__)
1394 printf ("i386-pc-bsd\n"); exit (0);
1395 #endif
1396
1397 #if defined (sequent)
1398 #if defined (i386)
1399 printf ("i386-sequent-dynix\n"); exit (0);
1400 #endif
1401 #if defined (ns32000)
1402 printf ("ns32k-sequent-dynix\n"); exit (0);
1403 #endif
1404 #endif
1405
1406 #if defined (_SEQUENT_)
1407 struct utsname un;
1408
1409 uname(&un);
1410
1411 if (strncmp(un.version, "V2", 2) == 0) {
1412 printf ("i386-sequent-ptx2\n"); exit (0);
1413 }
1414 if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1415 printf ("i386-sequent-ptx1\n"); exit (0);
1416 }
1417 printf ("i386-sequent-ptx\n"); exit (0);
1418
1419 #endif
1420
1421 #if defined (vax)
1422 # if !defined (ultrix)
1423 # include <sys/param.h>
1424 # if defined (BSD)
1425 # if BSD == 43
1426 printf ("vax-dec-bsd4.3\n"); exit (0);
1427 # else
1428 # if BSD == 199006
1429 printf ("vax-dec-bsd4.3reno\n"); exit (0);
1430 # else
1431 printf ("vax-dec-bsd\n"); exit (0);
1432 # endif
1433 # endif
1434 # else
1435 printf ("vax-dec-bsd\n"); exit (0);
1436 # endif
1437 # else
1438 printf ("vax-dec-ultrix\n"); exit (0);
1439 # endif
1440 #endif
1441
1442 #if defined (alliant) && defined (i860)
1443 printf ("i860-alliant-bsd\n"); exit (0);
1444 #endif
1445
1446 exit (1);
1447 }
1448 EOF
1449
1450 $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
1451 { echo "$SYSTEM_NAME"; exit; }
1452
1453 # Apollos put the system type in the environment.
1454
1455 test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
1456
1457 # Convex versions that predate uname can use getsysinfo(1)
1458
1459 if [ -x /usr/convex/getsysinfo ]
1460 then
1461 case `getsysinfo -f cpu_type` in
1462 c1*)
1463 echo c1-convex-bsd
1464 exit ;;
1465 c2*)
1466 if getsysinfo -f scalar_acc
1467 then echo c32-convex-bsd
1468 else echo c2-convex-bsd
1469 fi
1470 exit ;;
1471 c34*)
1472 echo c34-convex-bsd
1473 exit ;;
1474 c38*)
1475 echo c38-convex-bsd
1476 exit ;;
1477 c4*)
1478 echo c4-convex-bsd
1479 exit ;;
1480 esac
1481 fi
1482
1483 cat >&2 <<EOF
1484 $0: unable to guess system type
1485
1486 This script, last modified $timestamp, has failed to recognize
1487 the operating system you are using. It is advised that you
1488 download the most up to date version of the config scripts from
1489
1490 http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
1491 and
1492 http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
1493
1494 If the version you run ($0) is already up to date, please
1495 send the following data and any information you think might be
1496 pertinent to <config-patches@gnu.org> in order to provide the needed
1497 information to handle your system.
1498
1499 config.guess timestamp = $timestamp
1500
1501 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1502 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1503 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1504 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1505
1506 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1507 /bin/uname -X = `(/bin/uname -X) 2>/dev/null`
1508
1509 hostinfo = `(hostinfo) 2>/dev/null`
1510 /bin/universe = `(/bin/universe) 2>/dev/null`
1511 /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
1512 /bin/arch = `(/bin/arch) 2>/dev/null`
1513 /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
1514 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1515
1516 UNAME_MACHINE = ${UNAME_MACHINE}
1517 UNAME_RELEASE = ${UNAME_RELEASE}
1518 UNAME_SYSTEM = ${UNAME_SYSTEM}
1519 UNAME_VERSION = ${UNAME_VERSION}
1520 EOF
1521
1522 exit 1
1523
1524 # Local variables:
1525 # eval: (add-hook 'write-file-hooks 'time-stamp)
1526 # time-stamp-start: "timestamp='"
1527 # time-stamp-format: "%:y-%02m-%02d"
1528 # time-stamp-end: "'"
1529 # End:
0 #! /bin/sh
1 # Configuration validation subroutine script.
2 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
4 # 2011, 2012 Free Software Foundation, Inc.
5
6 timestamp='2012-04-18'
7
8 # This file is (in principle) common to ALL GNU software.
9 # The presence of a machine in this file suggests that SOME GNU software
10 # can handle that machine. It does not imply ALL GNU software can.
11 #
12 # This file is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, see <http://www.gnu.org/licenses/>.
24 #
25 # As a special exception to the GNU General Public License, if you
26 # distribute this file as part of a program that contains a
27 # configuration script generated by Autoconf, you may include it under
28 # the same distribution terms that you use for the rest of that program.
29
30
31 # Please send patches to <config-patches@gnu.org>. Submit a context
32 # diff and a properly formatted GNU ChangeLog entry.
33 #
34 # Configuration subroutine to validate and canonicalize a configuration type.
35 # Supply the specified configuration type as an argument.
36 # If it is invalid, we print an error message on stderr and exit with code 1.
37 # Otherwise, we print the canonical config type on stdout and succeed.
38
39 # You can get the latest version of this script from:
40 # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
41
42 # This file is supposed to be the same for all GNU packages
43 # and recognize all the CPU types, system types and aliases
44 # that are meaningful with *any* GNU software.
45 # Each package is responsible for reporting which valid configurations
46 # it does not support. The user should be able to distinguish
47 # a failure to support a valid configuration from a meaningless
48 # configuration.
49
50 # The goal of this file is to map all the various variations of a given
51 # machine specification into a single specification in the form:
52 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
53 # or in some cases, the newer four-part form:
54 # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
55 # It is wrong to echo any other type of specification.
56
57 me=`echo "$0" | sed -e 's,.*/,,'`
58
59 usage="\
60 Usage: $0 [OPTION] CPU-MFR-OPSYS
61 $0 [OPTION] ALIAS
62
63 Canonicalize a configuration name.
64
65 Operation modes:
66 -h, --help print this help, then exit
67 -t, --time-stamp print date of last modification, then exit
68 -v, --version print version number, then exit
69
70 Report bugs and patches to <config-patches@gnu.org>."
71
72 version="\
73 GNU config.sub ($timestamp)
74
75 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
76 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
77 Free Software Foundation, Inc.
78
79 This is free software; see the source for copying conditions. There is NO
80 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
81
82 help="
83 Try \`$me --help' for more information."
84
85 # Parse command line
86 while test $# -gt 0 ; do
87 case $1 in
88 --time-stamp | --time* | -t )
89 echo "$timestamp" ; exit ;;
90 --version | -v )
91 echo "$version" ; exit ;;
92 --help | --h* | -h )
93 echo "$usage"; exit ;;
94 -- ) # Stop option processing
95 shift; break ;;
96 - ) # Use stdin as input.
97 break ;;
98 -* )
99 echo "$me: invalid option $1$help"
100 exit 1 ;;
101
102 *local*)
103 # First pass through any local machine types.
104 echo $1
105 exit ;;
106
107 * )
108 break ;;
109 esac
110 done
111
112 case $# in
113 0) echo "$me: missing argument$help" >&2
114 exit 1;;
115 1) ;;
116 *) echo "$me: too many arguments$help" >&2
117 exit 1;;
118 esac
119
120 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
121 # Here we must recognize all the valid KERNEL-OS combinations.
122 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
123 case $maybe_os in
124 nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
125 linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
126 knetbsd*-gnu* | netbsd*-gnu* | \
127 kopensolaris*-gnu* | \
128 storm-chaos* | os2-emx* | rtmk-nova*)
129 os=-$maybe_os
130 basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
131 ;;
132 android-linux)
133 os=-linux-android
134 basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
135 ;;
136 *)
137 basic_machine=`echo $1 | sed 's/-[^-]*$//'`
138 if [ $basic_machine != $1 ]
139 then os=`echo $1 | sed 's/.*-/-/'`
140 else os=; fi
141 ;;
142 esac
143
144 ### Let's recognize common machines as not being operating systems so
145 ### that things like config.sub decstation-3100 work. We also
146 ### recognize some manufacturers as not being operating systems, so we
147 ### can provide default operating systems below.
148 case $os in
149 -sun*os*)
150 # Prevent following clause from handling this invalid input.
151 ;;
152 -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
153 -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
154 -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
155 -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
156 -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
157 -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
158 -apple | -axis | -knuth | -cray | -microblaze)
159 os=
160 basic_machine=$1
161 ;;
162 -bluegene*)
163 os=-cnk
164 ;;
165 -sim | -cisco | -oki | -wec | -winbond)
166 os=
167 basic_machine=$1
168 ;;
169 -scout)
170 ;;
171 -wrs)
172 os=-vxworks
173 basic_machine=$1
174 ;;
175 -chorusos*)
176 os=-chorusos
177 basic_machine=$1
178 ;;
179 -chorusrdb)
180 os=-chorusrdb
181 basic_machine=$1
182 ;;
183 -hiux*)
184 os=-hiuxwe2
185 ;;
186 -sco6)
187 os=-sco5v6
188 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
189 ;;
190 -sco5)
191 os=-sco3.2v5
192 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
193 ;;
194 -sco4)
195 os=-sco3.2v4
196 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
197 ;;
198 -sco3.2.[4-9]*)
199 os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
200 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
201 ;;
202 -sco3.2v[4-9]*)
203 # Don't forget version if it is 3.2v4 or newer.
204 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
205 ;;
206 -sco5v6*)
207 # Don't forget version if it is 3.2v4 or newer.
208 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
209 ;;
210 -sco*)
211 os=-sco3.2v2
212 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
213 ;;
214 -udk*)
215 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
216 ;;
217 -isc)
218 os=-isc2.2
219 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
220 ;;
221 -clix*)
222 basic_machine=clipper-intergraph
223 ;;
224 -isc*)
225 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
226 ;;
227 -lynx*178)
228 os=-lynxos178
229 ;;
230 -lynx*5)
231 os=-lynxos5
232 ;;
233 -lynx*)
234 os=-lynxos
235 ;;
236 -ptx*)
237 basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
238 ;;
239 -windowsnt*)
240 os=`echo $os | sed -e 's/windowsnt/winnt/'`
241 ;;
242 -psos*)
243 os=-psos
244 ;;
245 -mint | -mint[0-9]*)
246 basic_machine=m68k-atari
247 os=-mint
248 ;;
249 esac
250
251 # Decode aliases for certain CPU-COMPANY combinations.
252 case $basic_machine in
253 # Recognize the basic CPU types without company name.
254 # Some are omitted here because they have special meanings below.
255 1750a | 580 \
256 | a29k \
257 | aarch64 | aarch64_be \
258 | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
259 | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
260 | am33_2.0 \
261 | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
262 | be32 | be64 \
263 | bfin \
264 | c4x | clipper \
265 | d10v | d30v | dlx | dsp16xx \
266 | epiphany \
267 | fido | fr30 | frv \
268 | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
269 | hexagon \
270 | i370 | i860 | i960 | ia64 \
271 | ip2k | iq2000 \
272 | le32 | le64 \
273 | lm32 \
274 | m32c | m32r | m32rle | m68000 | m68k | m88k \
275 | maxq | mb | microblaze | mcore | mep | metag \
276 | mips | mipsbe | mipseb | mipsel | mipsle \
277 | mips16 \
278 | mips64 | mips64el \
279 | mips64octeon | mips64octeonel \
280 | mips64orion | mips64orionel \
281 | mips64r5900 | mips64r5900el \
282 | mips64vr | mips64vrel \
283 | mips64vr4100 | mips64vr4100el \
284 | mips64vr4300 | mips64vr4300el \
285 | mips64vr5000 | mips64vr5000el \
286 | mips64vr5900 | mips64vr5900el \
287 | mipsisa32 | mipsisa32el \
288 | mipsisa32r2 | mipsisa32r2el \
289 | mipsisa64 | mipsisa64el \
290 | mipsisa64r2 | mipsisa64r2el \
291 | mipsisa64sb1 | mipsisa64sb1el \
292 | mipsisa64sr71k | mipsisa64sr71kel \
293 | mipstx39 | mipstx39el \
294 | mn10200 | mn10300 \
295 | moxie \
296 | mt \
297 | msp430 \
298 | nds32 | nds32le | nds32be \
299 | nios | nios2 \
300 | ns16k | ns32k \
301 | open8 \
302 | or32 \
303 | pdp10 | pdp11 | pj | pjl \
304 | powerpc | powerpc64 | powerpc64le | powerpcle \
305 | pyramid \
306 | rl78 | rx \
307 | score \
308 | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
309 | sh64 | sh64le \
310 | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
311 | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
312 | spu \
313 | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
314 | ubicom32 \
315 | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
316 | we32k \
317 | x86 | xc16x | xstormy16 | xtensa \
318 | z8k | z80)
319 basic_machine=$basic_machine-unknown
320 ;;
321 c54x)
322 basic_machine=tic54x-unknown
323 ;;
324 c55x)
325 basic_machine=tic55x-unknown
326 ;;
327 c6x)
328 basic_machine=tic6x-unknown
329 ;;
330 m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
331 basic_machine=$basic_machine-unknown
332 os=-none
333 ;;
334 m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
335 ;;
336 ms1)
337 basic_machine=mt-unknown
338 ;;
339
340 strongarm | thumb | xscale)
341 basic_machine=arm-unknown
342 ;;
343 xgate)
344 basic_machine=$basic_machine-unknown
345 os=-none
346 ;;
347 xscaleeb)
348 basic_machine=armeb-unknown
349 ;;
350
351 xscaleel)
352 basic_machine=armel-unknown
353 ;;
354
355 # We use `pc' rather than `unknown'
356 # because (1) that's what they normally are, and
357 # (2) the word "unknown" tends to confuse beginning users.
358 i*86 | x86_64)
359 basic_machine=$basic_machine-pc
360 ;;
361 # Object if more than one company name word.
362 *-*-*)
363 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
364 exit 1
365 ;;
366 # Recognize the basic CPU types with company name.
367 580-* \
368 | a29k-* \
369 | aarch64-* | aarch64_be-* \
370 | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
371 | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
372 | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
373 | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
374 | avr-* | avr32-* \
375 | be32-* | be64-* \
376 | bfin-* | bs2000-* \
377 | c[123]* | c30-* | [cjt]90-* | c4x-* \
378 | clipper-* | craynv-* | cydra-* \
379 | d10v-* | d30v-* | dlx-* \
380 | elxsi-* \
381 | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
382 | h8300-* | h8500-* \
383 | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
384 | hexagon-* \
385 | i*86-* | i860-* | i960-* | ia64-* \
386 | ip2k-* | iq2000-* \
387 | le32-* | le64-* \
388 | lm32-* \
389 | m32c-* | m32r-* | m32rle-* \
390 | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
391 | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
392 | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
393 | mips16-* \
394 | mips64-* | mips64el-* \
395 | mips64octeon-* | mips64octeonel-* \
396 | mips64orion-* | mips64orionel-* \
397 | mips64r5900-* | mips64r5900el-* \
398 | mips64vr-* | mips64vrel-* \
399 | mips64vr4100-* | mips64vr4100el-* \
400 | mips64vr4300-* | mips64vr4300el-* \
401 | mips64vr5000-* | mips64vr5000el-* \
402 | mips64vr5900-* | mips64vr5900el-* \
403 | mipsisa32-* | mipsisa32el-* \
404 | mipsisa32r2-* | mipsisa32r2el-* \
405 | mipsisa64-* | mipsisa64el-* \
406 | mipsisa64r2-* | mipsisa64r2el-* \
407 | mipsisa64sb1-* | mipsisa64sb1el-* \
408 | mipsisa64sr71k-* | mipsisa64sr71kel-* \
409 | mipstx39-* | mipstx39el-* \
410 | mmix-* \
411 | mt-* \
412 | msp430-* \
413 | nds32-* | nds32le-* | nds32be-* \
414 | nios-* | nios2-* \
415 | none-* | np1-* | ns16k-* | ns32k-* \
416 | open8-* \
417 | orion-* \
418 | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
419 | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
420 | pyramid-* \
421 | rl78-* | romp-* | rs6000-* | rx-* \
422 | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
423 | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
424 | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
425 | sparclite-* \
426 | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
427 | tahoe-* \
428 | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
429 | tile*-* \
430 | tron-* \
431 | ubicom32-* \
432 | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
433 | vax-* \
434 | we32k-* \
435 | x86-* | x86_64-* | xc16x-* | xps100-* \
436 | xstormy16-* | xtensa*-* \
437 | ymp-* \
438 | z8k-* | z80-*)
439 ;;
440 # Recognize the basic CPU types without company name, with glob match.
441 xtensa*)
442 basic_machine=$basic_machine-unknown
443 ;;
444 # Recognize the various machine names and aliases which stand
445 # for a CPU type and a company and sometimes even an OS.
446 386bsd)
447 basic_machine=i386-unknown
448 os=-bsd
449 ;;
450 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
451 basic_machine=m68000-att
452 ;;
453 3b*)
454 basic_machine=we32k-att
455 ;;
456 a29khif)
457 basic_machine=a29k-amd
458 os=-udi
459 ;;
460 abacus)
461 basic_machine=abacus-unknown
462 ;;
463 adobe68k)
464 basic_machine=m68010-adobe
465 os=-scout
466 ;;
467 alliant | fx80)
468 basic_machine=fx80-alliant
469 ;;
470 altos | altos3068)
471 basic_machine=m68k-altos
472 ;;
473 am29k)
474 basic_machine=a29k-none
475 os=-bsd
476 ;;
477 amd64)
478 basic_machine=x86_64-pc
479 ;;
480 amd64-*)
481 basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
482 ;;
483 amdahl)
484 basic_machine=580-amdahl
485 os=-sysv
486 ;;
487 amiga | amiga-*)
488 basic_machine=m68k-unknown
489 ;;
490 amigaos | amigados)
491 basic_machine=m68k-unknown
492 os=-amigaos
493 ;;
494 amigaunix | amix)
495 basic_machine=m68k-unknown
496 os=-sysv4
497 ;;
498 apollo68)
499 basic_machine=m68k-apollo
500 os=-sysv
501 ;;
502 apollo68bsd)
503 basic_machine=m68k-apollo
504 os=-bsd
505 ;;
506 aros)
507 basic_machine=i386-pc
508 os=-aros
509 ;;
510 aux)
511 basic_machine=m68k-apple
512 os=-aux
513 ;;
514 balance)
515 basic_machine=ns32k-sequent
516 os=-dynix
517 ;;
518 blackfin)
519 basic_machine=bfin-unknown
520 os=-linux
521 ;;
522 blackfin-*)
523 basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
524 os=-linux
525 ;;
526 bluegene*)
527 basic_machine=powerpc-ibm
528 os=-cnk
529 ;;
530 c54x-*)
531 basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
532 ;;
533 c55x-*)
534 basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
535 ;;
536 c6x-*)
537 basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
538 ;;
539 c90)
540 basic_machine=c90-cray
541 os=-unicos
542 ;;
543 cegcc)
544 basic_machine=arm-unknown
545 os=-cegcc
546 ;;
547 convex-c1)
548 basic_machine=c1-convex
549 os=-bsd
550 ;;
551 convex-c2)
552 basic_machine=c2-convex
553 os=-bsd
554 ;;
555 convex-c32)
556 basic_machine=c32-convex
557 os=-bsd
558 ;;
559 convex-c34)
560 basic_machine=c34-convex
561 os=-bsd
562 ;;
563 convex-c38)
564 basic_machine=c38-convex
565 os=-bsd
566 ;;
567 cray | j90)
568 basic_machine=j90-cray
569 os=-unicos
570 ;;
571 craynv)
572 basic_machine=craynv-cray
573 os=-unicosmp
574 ;;
575 cr16 | cr16-*)
576 basic_machine=cr16-unknown
577 os=-elf
578 ;;
579 crds | unos)
580 basic_machine=m68k-crds
581 ;;
582 crisv32 | crisv32-* | etraxfs*)
583 basic_machine=crisv32-axis
584 ;;
585 cris | cris-* | etrax*)
586 basic_machine=cris-axis
587 ;;
588 crx)
589 basic_machine=crx-unknown
590 os=-elf
591 ;;
592 da30 | da30-*)
593 basic_machine=m68k-da30
594 ;;
595 decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
596 basic_machine=mips-dec
597 ;;
598 decsystem10* | dec10*)
599 basic_machine=pdp10-dec
600 os=-tops10
601 ;;
602 decsystem20* | dec20*)
603 basic_machine=pdp10-dec
604 os=-tops20
605 ;;
606 delta | 3300 | motorola-3300 | motorola-delta \
607 | 3300-motorola | delta-motorola)
608 basic_machine=m68k-motorola
609 ;;
610 delta88)
611 basic_machine=m88k-motorola
612 os=-sysv3
613 ;;
614 dicos)
615 basic_machine=i686-pc
616 os=-dicos
617 ;;
618 djgpp)
619 basic_machine=i586-pc
620 os=-msdosdjgpp
621 ;;
622 dpx20 | dpx20-*)
623 basic_machine=rs6000-bull
624 os=-bosx
625 ;;
626 dpx2* | dpx2*-bull)
627 basic_machine=m68k-bull
628 os=-sysv3
629 ;;
630 ebmon29k)
631 basic_machine=a29k-amd
632 os=-ebmon
633 ;;
634 elxsi)
635 basic_machine=elxsi-elxsi
636 os=-bsd
637 ;;
638 encore | umax | mmax)
639 basic_machine=ns32k-encore
640 ;;
641 es1800 | OSE68k | ose68k | ose | OSE)
642 basic_machine=m68k-ericsson
643 os=-ose
644 ;;
645 fx2800)
646 basic_machine=i860-alliant
647 ;;
648 genix)
649 basic_machine=ns32k-ns
650 ;;
651 gmicro)
652 basic_machine=tron-gmicro
653 os=-sysv
654 ;;
655 go32)
656 basic_machine=i386-pc
657 os=-go32
658 ;;
659 h3050r* | hiux*)
660 basic_machine=hppa1.1-hitachi
661 os=-hiuxwe2
662 ;;
663 h8300hms)
664 basic_machine=h8300-hitachi
665 os=-hms
666 ;;
667 h8300xray)
668 basic_machine=h8300-hitachi
669 os=-xray
670 ;;
671 h8500hms)
672 basic_machine=h8500-hitachi
673 os=-hms
674 ;;
675 harris)
676 basic_machine=m88k-harris
677 os=-sysv3
678 ;;
679 hp300-*)
680 basic_machine=m68k-hp
681 ;;
682 hp300bsd)
683 basic_machine=m68k-hp
684 os=-bsd
685 ;;
686 hp300hpux)
687 basic_machine=m68k-hp
688 os=-hpux
689 ;;
690 hp3k9[0-9][0-9] | hp9[0-9][0-9])
691 basic_machine=hppa1.0-hp
692 ;;
693 hp9k2[0-9][0-9] | hp9k31[0-9])
694 basic_machine=m68000-hp
695 ;;
696 hp9k3[2-9][0-9])
697 basic_machine=m68k-hp
698 ;;
699 hp9k6[0-9][0-9] | hp6[0-9][0-9])
700 basic_machine=hppa1.0-hp
701 ;;
702 hp9k7[0-79][0-9] | hp7[0-79][0-9])
703 basic_machine=hppa1.1-hp
704 ;;
705 hp9k78[0-9] | hp78[0-9])
706 # FIXME: really hppa2.0-hp
707 basic_machine=hppa1.1-hp
708 ;;
709 hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
710 # FIXME: really hppa2.0-hp
711 basic_machine=hppa1.1-hp
712 ;;
713 hp9k8[0-9][13679] | hp8[0-9][13679])
714 basic_machine=hppa1.1-hp
715 ;;
716 hp9k8[0-9][0-9] | hp8[0-9][0-9])
717 basic_machine=hppa1.0-hp
718 ;;
719 hppa-next)
720 os=-nextstep3
721 ;;
722 hppaosf)
723 basic_machine=hppa1.1-hp
724 os=-osf
725 ;;
726 hppro)
727 basic_machine=hppa1.1-hp
728 os=-proelf
729 ;;
730 i370-ibm* | ibm*)
731 basic_machine=i370-ibm
732 ;;
733 i*86v32)
734 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
735 os=-sysv32
736 ;;
737 i*86v4*)
738 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
739 os=-sysv4
740 ;;
741 i*86v)
742 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
743 os=-sysv
744 ;;
745 i*86sol2)
746 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
747 os=-solaris2
748 ;;
749 i386mach)
750 basic_machine=i386-mach
751 os=-mach
752 ;;
753 i386-vsta | vsta)
754 basic_machine=i386-unknown
755 os=-vsta
756 ;;
757 iris | iris4d)
758 basic_machine=mips-sgi
759 case $os in
760 -irix*)
761 ;;
762 *)
763 os=-irix4
764 ;;
765 esac
766 ;;
767 isi68 | isi)
768 basic_machine=m68k-isi
769 os=-sysv
770 ;;
771 m68knommu)
772 basic_machine=m68k-unknown
773 os=-linux
774 ;;
775 m68knommu-*)
776 basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
777 os=-linux
778 ;;
779 m88k-omron*)
780 basic_machine=m88k-omron
781 ;;
782 magnum | m3230)
783 basic_machine=mips-mips
784 os=-sysv
785 ;;
786 merlin)
787 basic_machine=ns32k-utek
788 os=-sysv
789 ;;
790 microblaze)
791 basic_machine=microblaze-xilinx
792 ;;
793 mingw32)
794 basic_machine=i386-pc
795 os=-mingw32
796 ;;
797 mingw32ce)
798 basic_machine=arm-unknown
799 os=-mingw32ce
800 ;;
801 miniframe)
802 basic_machine=m68000-convergent
803 ;;
804 *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
805 basic_machine=m68k-atari
806 os=-mint
807 ;;
808 mips3*-*)
809 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
810 ;;
811 mips3*)
812 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
813 ;;
814 monitor)
815 basic_machine=m68k-rom68k
816 os=-coff
817 ;;
818 morphos)
819 basic_machine=powerpc-unknown
820 os=-morphos
821 ;;
822 msdos)
823 basic_machine=i386-pc
824 os=-msdos
825 ;;
826 ms1-*)
827 basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
828 ;;
829 msys)
830 basic_machine=i386-pc
831 os=-msys
832 ;;
833 mvs)
834 basic_machine=i370-ibm
835 os=-mvs
836 ;;
837 nacl)
838 basic_machine=le32-unknown
839 os=-nacl
840 ;;
841 ncr3000)
842 basic_machine=i486-ncr
843 os=-sysv4
844 ;;
845 netbsd386)
846 basic_machine=i386-unknown
847 os=-netbsd
848 ;;
849 netwinder)
850 basic_machine=armv4l-rebel
851 os=-linux
852 ;;
853 news | news700 | news800 | news900)
854 basic_machine=m68k-sony
855 os=-newsos
856 ;;
857 news1000)
858 basic_machine=m68030-sony
859 os=-newsos
860 ;;
861 news-3600 | risc-news)
862 basic_machine=mips-sony
863 os=-newsos
864 ;;
865 necv70)
866 basic_machine=v70-nec
867 os=-sysv
868 ;;
869 next | m*-next )
870 basic_machine=m68k-next
871 case $os in
872 -nextstep* )
873 ;;
874 -ns2*)
875 os=-nextstep2
876 ;;
877 *)
878 os=-nextstep3
879 ;;
880 esac
881 ;;
882 nh3000)
883 basic_machine=m68k-harris
884 os=-cxux
885 ;;
886 nh[45]000)
887 basic_machine=m88k-harris
888 os=-cxux
889 ;;
890 nindy960)
891 basic_machine=i960-intel
892 os=-nindy
893 ;;
894 mon960)
895 basic_machine=i960-intel
896 os=-mon960
897 ;;
898 nonstopux)
899 basic_machine=mips-compaq
900 os=-nonstopux
901 ;;
902 np1)
903 basic_machine=np1-gould
904 ;;
905 neo-tandem)
906 basic_machine=neo-tandem
907 ;;
908 nse-tandem)
909 basic_machine=nse-tandem
910 ;;
911 nsr-tandem)
912 basic_machine=nsr-tandem
913 ;;
914 op50n-* | op60c-*)
915 basic_machine=hppa1.1-oki
916 os=-proelf
917 ;;
918 openrisc | openrisc-*)
919 basic_machine=or32-unknown
920 ;;
921 os400)
922 basic_machine=powerpc-ibm
923 os=-os400
924 ;;
925 OSE68000 | ose68000)
926 basic_machine=m68000-ericsson
927 os=-ose
928 ;;
929 os68k)
930 basic_machine=m68k-none
931 os=-os68k
932 ;;
933 pa-hitachi)
934 basic_machine=hppa1.1-hitachi
935 os=-hiuxwe2
936 ;;
937 paragon)
938 basic_machine=i860-intel
939 os=-osf
940 ;;
941 parisc)
942 basic_machine=hppa-unknown
943 os=-linux
944 ;;
945 parisc-*)
946 basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
947 os=-linux
948 ;;
949 pbd)
950 basic_machine=sparc-tti
951 ;;
952 pbb)
953 basic_machine=m68k-tti
954 ;;
955 pc532 | pc532-*)
956 basic_machine=ns32k-pc532
957 ;;
958 pc98)
959 basic_machine=i386-pc
960 ;;
961 pc98-*)
962 basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
963 ;;
964 pentium | p5 | k5 | k6 | nexgen | viac3)
965 basic_machine=i586-pc
966 ;;
967 pentiumpro | p6 | 6x86 | athlon | athlon_*)
968 basic_machine=i686-pc
969 ;;
970 pentiumii | pentium2 | pentiumiii | pentium3)
971 basic_machine=i686-pc
972 ;;
973 pentium4)
974 basic_machine=i786-pc
975 ;;
976 pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
977 basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
978 ;;
979 pentiumpro-* | p6-* | 6x86-* | athlon-*)
980 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
981 ;;
982 pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
983 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
984 ;;
985 pentium4-*)
986 basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
987 ;;
988 pn)
989 basic_machine=pn-gould
990 ;;
991 power) basic_machine=power-ibm
992 ;;
993 ppc | ppcbe) basic_machine=powerpc-unknown
994 ;;
995 ppc-* | ppcbe-*)
996 basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
997 ;;
998 ppcle | powerpclittle | ppc-le | powerpc-little)
999 basic_machine=powerpcle-unknown
1000 ;;
1001 ppcle-* | powerpclittle-*)
1002 basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
1003 ;;
1004 ppc64) basic_machine=powerpc64-unknown
1005 ;;
1006 ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
1007 ;;
1008 ppc64le | powerpc64little | ppc64-le | powerpc64-little)
1009 basic_machine=powerpc64le-unknown
1010 ;;
1011 ppc64le-* | powerpc64little-*)
1012 basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
1013 ;;
1014 ps2)
1015 basic_machine=i386-ibm
1016 ;;
1017 pw32)
1018 basic_machine=i586-unknown
1019 os=-pw32
1020 ;;
1021 rdos)
1022 basic_machine=i386-pc
1023 os=-rdos
1024 ;;
1025 rom68k)
1026 basic_machine=m68k-rom68k
1027 os=-coff
1028 ;;
1029 rm[46]00)
1030 basic_machine=mips-siemens
1031 ;;
1032 rtpc | rtpc-*)
1033 basic_machine=romp-ibm
1034 ;;
1035 s390 | s390-*)
1036 basic_machine=s390-ibm
1037 ;;
1038 s390x | s390x-*)
1039 basic_machine=s390x-ibm
1040 ;;
1041 sa29200)
1042 basic_machine=a29k-amd
1043 os=-udi
1044 ;;
1045 sb1)
1046 basic_machine=mipsisa64sb1-unknown
1047 ;;
1048 sb1el)
1049 basic_machine=mipsisa64sb1el-unknown
1050 ;;
1051 sde)
1052 basic_machine=mipsisa32-sde
1053 os=-elf
1054 ;;
1055 sei)
1056 basic_machine=mips-sei
1057 os=-seiux
1058 ;;
1059 sequent)
1060 basic_machine=i386-sequent
1061 ;;
1062 sh)
1063 basic_machine=sh-hitachi
1064 os=-hms
1065 ;;
1066 sh5el)
1067 basic_machine=sh5le-unknown
1068 ;;
1069 sh64)
1070 basic_machine=sh64-unknown
1071 ;;
1072 sparclite-wrs | simso-wrs)
1073 basic_machine=sparclite-wrs
1074 os=-vxworks
1075 ;;
1076 sps7)
1077 basic_machine=m68k-bull
1078 os=-sysv2
1079 ;;
1080 spur)
1081 basic_machine=spur-unknown
1082 ;;
1083 st2000)
1084 basic_machine=m68k-tandem
1085 ;;
1086 stratus)
1087 basic_machine=i860-stratus
1088 os=-sysv4
1089 ;;
1090 strongarm-* | thumb-*)
1091 basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
1092 ;;
1093 sun2)
1094 basic_machine=m68000-sun
1095 ;;
1096 sun2os3)
1097 basic_machine=m68000-sun
1098 os=-sunos3
1099 ;;
1100 sun2os4)
1101 basic_machine=m68000-sun
1102 os=-sunos4
1103 ;;
1104 sun3os3)
1105 basic_machine=m68k-sun
1106 os=-sunos3
1107 ;;
1108 sun3os4)
1109 basic_machine=m68k-sun
1110 os=-sunos4
1111 ;;
1112 sun4os3)
1113 basic_machine=sparc-sun
1114 os=-sunos3
1115 ;;
1116 sun4os4)
1117 basic_machine=sparc-sun
1118 os=-sunos4
1119 ;;
1120 sun4sol2)
1121 basic_machine=sparc-sun
1122 os=-solaris2
1123 ;;
1124 sun3 | sun3-*)
1125 basic_machine=m68k-sun
1126 ;;
1127 sun4)
1128 basic_machine=sparc-sun
1129 ;;
1130 sun386 | sun386i | roadrunner)
1131 basic_machine=i386-sun
1132 ;;
1133 sv1)
1134 basic_machine=sv1-cray
1135 os=-unicos
1136 ;;
1137 symmetry)
1138 basic_machine=i386-sequent
1139 os=-dynix
1140 ;;
1141 t3e)
1142 basic_machine=alphaev5-cray
1143 os=-unicos
1144 ;;
1145 t90)
1146 basic_machine=t90-cray
1147 os=-unicos
1148 ;;
1149 tile*)
1150 basic_machine=$basic_machine-unknown
1151 os=-linux-gnu
1152 ;;
1153 tx39)
1154 basic_machine=mipstx39-unknown
1155 ;;
1156 tx39el)
1157 basic_machine=mipstx39el-unknown
1158 ;;
1159 toad1)
1160 basic_machine=pdp10-xkl
1161 os=-tops20
1162 ;;
1163 tower | tower-32)
1164 basic_machine=m68k-ncr
1165 ;;
1166 tpf)
1167 basic_machine=s390x-ibm
1168 os=-tpf
1169 ;;
1170 udi29k)
1171 basic_machine=a29k-amd
1172 os=-udi
1173 ;;
1174 ultra3)
1175 basic_machine=a29k-nyu
1176 os=-sym1
1177 ;;
1178 v810 | necv810)
1179 basic_machine=v810-nec
1180 os=-none
1181 ;;
1182 vaxv)
1183 basic_machine=vax-dec
1184 os=-sysv
1185 ;;
1186 vms)
1187 basic_machine=vax-dec
1188 os=-vms
1189 ;;
1190 vpp*|vx|vx-*)
1191 basic_machine=f301-fujitsu
1192 ;;
1193 vxworks960)
1194 basic_machine=i960-wrs
1195 os=-vxworks
1196 ;;
1197 vxworks68)
1198 basic_machine=m68k-wrs
1199 os=-vxworks
1200 ;;
1201 vxworks29k)
1202 basic_machine=a29k-wrs
1203 os=-vxworks
1204 ;;
1205 w65*)
1206 basic_machine=w65-wdc
1207 os=-none
1208 ;;
1209 w89k-*)
1210 basic_machine=hppa1.1-winbond
1211 os=-proelf
1212 ;;
1213 xbox)
1214 basic_machine=i686-pc
1215 os=-mingw32
1216 ;;
1217 xps | xps100)
1218 basic_machine=xps100-honeywell
1219 ;;
1220 xscale-* | xscalee[bl]-*)
1221 basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
1222 ;;
1223 ymp)
1224 basic_machine=ymp-cray
1225 os=-unicos
1226 ;;
1227 z8k-*-coff)
1228 basic_machine=z8k-unknown
1229 os=-sim
1230 ;;
1231 z80-*-coff)
1232 basic_machine=z80-unknown
1233 os=-sim
1234 ;;
1235 none)
1236 basic_machine=none-none
1237 os=-none
1238 ;;
1239
1240 # Here we handle the default manufacturer of certain CPU types. It is in
1241 # some cases the only manufacturer, in others, it is the most popular.
1242 w89k)
1243 basic_machine=hppa1.1-winbond
1244 ;;
1245 op50n)
1246 basic_machine=hppa1.1-oki
1247 ;;
1248 op60c)
1249 basic_machine=hppa1.1-oki
1250 ;;
1251 romp)
1252 basic_machine=romp-ibm
1253 ;;
1254 mmix)
1255 basic_machine=mmix-knuth
1256 ;;
1257 rs6000)
1258 basic_machine=rs6000-ibm
1259 ;;
1260 vax)
1261 basic_machine=vax-dec
1262 ;;
1263 pdp10)
1264 # there are many clones, so DEC is not a safe bet
1265 basic_machine=pdp10-unknown
1266 ;;
1267 pdp11)
1268 basic_machine=pdp11-dec
1269 ;;
1270 we32k)
1271 basic_machine=we32k-att
1272 ;;
1273 sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
1274 basic_machine=sh-unknown
1275 ;;
1276 sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
1277 basic_machine=sparc-sun
1278 ;;
1279 cydra)
1280 basic_machine=cydra-cydrome
1281 ;;
1282 orion)
1283 basic_machine=orion-highlevel
1284 ;;
1285 orion105)
1286 basic_machine=clipper-highlevel
1287 ;;
1288 mac | mpw | mac-mpw)
1289 basic_machine=m68k-apple
1290 ;;
1291 pmac | pmac-mpw)
1292 basic_machine=powerpc-apple
1293 ;;
1294 *-unknown)
1295 # Make sure to match an already-canonicalized machine name.
1296 ;;
1297 *)
1298 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
1299 exit 1
1300 ;;
1301 esac
1302
1303 # Here we canonicalize certain aliases for manufacturers.
1304 case $basic_machine in
1305 *-digital*)
1306 basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
1307 ;;
1308 *-commodore*)
1309 basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
1310 ;;
1311 *)
1312 ;;
1313 esac
1314
1315 # Decode manufacturer-specific aliases for certain operating systems.
1316
1317 if [ x"$os" != x"" ]
1318 then
1319 case $os in
1320 # First match some system type aliases
1321 # that might get confused with valid system types.
1322 # -solaris* is a basic system type, with this one exception.
1323 -auroraux)
1324 os=-auroraux
1325 ;;
1326 -solaris1 | -solaris1.*)
1327 os=`echo $os | sed -e 's|solaris1|sunos4|'`
1328 ;;
1329 -solaris)
1330 os=-solaris2
1331 ;;
1332 -svr4*)
1333 os=-sysv4
1334 ;;
1335 -unixware*)
1336 os=-sysv4.2uw
1337 ;;
1338 -gnu/linux*)
1339 os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
1340 ;;
1341 # First accept the basic system types.
1342 # The portable systems comes first.
1343 # Each alternative MUST END IN A *, to match a version number.
1344 # -sysv* is not here because it comes later, after sysvr4.
1345 -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
1346 | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
1347 | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
1348 | -sym* | -kopensolaris* \
1349 | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
1350 | -aos* | -aros* \
1351 | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
1352 | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
1353 | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
1354 | -openbsd* | -solidbsd* \
1355 | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
1356 | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
1357 | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
1358 | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
1359 | -chorusos* | -chorusrdb* | -cegcc* \
1360 | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
1361 | -mingw32* | -linux-gnu* | -linux-android* \
1362 | -linux-newlib* | -linux-uclibc* \
1363 | -uxpv* | -beos* | -mpeix* | -udk* \
1364 | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
1365 | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
1366 | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
1367 | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
1368 | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
1369 | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
1370 | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
1371 # Remember, each alternative MUST END IN *, to match a version number.
1372 ;;
1373 -qnx*)
1374 case $basic_machine in
1375 x86-* | i*86-*)
1376 ;;
1377 *)
1378 os=-nto$os
1379 ;;
1380 esac
1381 ;;
1382 -nto-qnx*)
1383 ;;
1384 -nto*)
1385 os=`echo $os | sed -e 's|nto|nto-qnx|'`
1386 ;;
1387 -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
1388 | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
1389 | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
1390 ;;
1391 -mac*)
1392 os=`echo $os | sed -e 's|mac|macos|'`
1393 ;;
1394 -linux-dietlibc)
1395 os=-linux-dietlibc
1396 ;;
1397 -linux*)
1398 os=`echo $os | sed -e 's|linux|linux-gnu|'`
1399 ;;
1400 -sunos5*)
1401 os=`echo $os | sed -e 's|sunos5|solaris2|'`
1402 ;;
1403 -sunos6*)
1404 os=`echo $os | sed -e 's|sunos6|solaris3|'`
1405 ;;
1406 -opened*)
1407 os=-openedition
1408 ;;
1409 -os400*)
1410 os=-os400
1411 ;;
1412 -wince*)
1413 os=-wince
1414 ;;
1415 -osfrose*)
1416 os=-osfrose
1417 ;;
1418 -osf*)
1419 os=-osf
1420 ;;
1421 -utek*)
1422 os=-bsd
1423 ;;
1424 -dynix*)
1425 os=-bsd
1426 ;;
1427 -acis*)
1428 os=-aos
1429 ;;
1430 -atheos*)
1431 os=-atheos
1432 ;;
1433 -syllable*)
1434 os=-syllable
1435 ;;
1436 -386bsd)
1437 os=-bsd
1438 ;;
1439 -ctix* | -uts*)
1440 os=-sysv
1441 ;;
1442 -nova*)
1443 os=-rtmk-nova
1444 ;;
1445 -ns2 )
1446 os=-nextstep2
1447 ;;
1448 -nsk*)
1449 os=-nsk
1450 ;;
1451 # Preserve the version number of sinix5.
1452 -sinix5.*)
1453 os=`echo $os | sed -e 's|sinix|sysv|'`
1454 ;;
1455 -sinix*)
1456 os=-sysv4
1457 ;;
1458 -tpf*)
1459 os=-tpf
1460 ;;
1461 -triton*)
1462 os=-sysv3
1463 ;;
1464 -oss*)
1465 os=-sysv3
1466 ;;
1467 -svr4)
1468 os=-sysv4
1469 ;;
1470 -svr3)
1471 os=-sysv3
1472 ;;
1473 -sysvr4)
1474 os=-sysv4
1475 ;;
1476 # This must come after -sysvr4.
1477 -sysv*)
1478 ;;
1479 -ose*)
1480 os=-ose
1481 ;;
1482 -es1800*)
1483 os=-ose
1484 ;;
1485 -xenix)
1486 os=-xenix
1487 ;;
1488 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
1489 os=-mint
1490 ;;
1491 -aros*)
1492 os=-aros
1493 ;;
1494 -kaos*)
1495 os=-kaos
1496 ;;
1497 -zvmoe)
1498 os=-zvmoe
1499 ;;
1500 -dicos*)
1501 os=-dicos
1502 ;;
1503 -nacl*)
1504 ;;
1505 -none)
1506 ;;
1507 *)
1508 # Get rid of the `-' at the beginning of $os.
1509 os=`echo $os | sed 's/[^-]*-//'`
1510 echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
1511 exit 1
1512 ;;
1513 esac
1514 else
1515
1516 # Here we handle the default operating systems that come with various machines.
1517 # The value should be what the vendor currently ships out the door with their
1518 # machine or put another way, the most popular os provided with the machine.
1519
1520 # Note that if you're going to try to match "-MANUFACTURER" here (say,
1521 # "-sun"), then you have to tell the case statement up towards the top
1522 # that MANUFACTURER isn't an operating system. Otherwise, code above
1523 # will signal an error saying that MANUFACTURER isn't an operating
1524 # system, and we'll never get to this point.
1525
1526 case $basic_machine in
1527 score-*)
1528 os=-elf
1529 ;;
1530 spu-*)
1531 os=-elf
1532 ;;
1533 *-acorn)
1534 os=-riscix1.2
1535 ;;
1536 arm*-rebel)
1537 os=-linux
1538 ;;
1539 arm*-semi)
1540 os=-aout
1541 ;;
1542 c4x-* | tic4x-*)
1543 os=-coff
1544 ;;
1545 hexagon-*)
1546 os=-elf
1547 ;;
1548 tic54x-*)
1549 os=-coff
1550 ;;
1551 tic55x-*)
1552 os=-coff
1553 ;;
1554 tic6x-*)
1555 os=-coff
1556 ;;
1557 # This must come before the *-dec entry.
1558 pdp10-*)
1559 os=-tops20
1560 ;;
1561 pdp11-*)
1562 os=-none
1563 ;;
1564 *-dec | vax-*)
1565 os=-ultrix4.2
1566 ;;
1567 m68*-apollo)
1568 os=-domain
1569 ;;
1570 i386-sun)
1571 os=-sunos4.0.2
1572 ;;
1573 m68000-sun)
1574 os=-sunos3
1575 ;;
1576 m68*-cisco)
1577 os=-aout
1578 ;;
1579 mep-*)
1580 os=-elf
1581 ;;
1582 mips*-cisco)
1583 os=-elf
1584 ;;
1585 mips*-*)
1586 os=-elf
1587 ;;
1588 or32-*)
1589 os=-coff
1590 ;;
1591 *-tti) # must be before sparc entry or we get the wrong os.
1592 os=-sysv3
1593 ;;
1594 sparc-* | *-sun)
1595 os=-sunos4.1.1
1596 ;;
1597 *-be)
1598 os=-beos
1599 ;;
1600 *-haiku)
1601 os=-haiku
1602 ;;
1603 *-ibm)
1604 os=-aix
1605 ;;
1606 *-knuth)
1607 os=-mmixware
1608 ;;
1609 *-wec)
1610 os=-proelf
1611 ;;
1612 *-winbond)
1613 os=-proelf
1614 ;;
1615 *-oki)
1616 os=-proelf
1617 ;;
1618 *-hp)
1619 os=-hpux
1620 ;;
1621 *-hitachi)
1622 os=-hiux
1623 ;;
1624 i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1625 os=-sysv
1626 ;;
1627 *-cbm)
1628 os=-amigaos
1629 ;;
1630 *-dg)
1631 os=-dgux
1632 ;;
1633 *-dolphin)
1634 os=-sysv3
1635 ;;
1636 m68k-ccur)
1637 os=-rtu
1638 ;;
1639 m88k-omron*)
1640 os=-luna
1641 ;;
1642 *-next )
1643 os=-nextstep
1644 ;;
1645 *-sequent)
1646 os=-ptx
1647 ;;
1648 *-crds)
1649 os=-unos
1650 ;;
1651 *-ns)
1652 os=-genix
1653 ;;
1654 i370-*)
1655 os=-mvs
1656 ;;
1657 *-next)
1658 os=-nextstep3
1659 ;;
1660 *-gould)
1661 os=-sysv
1662 ;;
1663 *-highlevel)
1664 os=-bsd
1665 ;;
1666 *-encore)
1667 os=-bsd
1668 ;;
1669 *-sgi)
1670 os=-irix
1671 ;;
1672 *-siemens)
1673 os=-sysv4
1674 ;;
1675 *-masscomp)
1676 os=-rtu
1677 ;;
1678 f30[01]-fujitsu | f700-fujitsu)
1679 os=-uxpv
1680 ;;
1681 *-rom68k)
1682 os=-coff
1683 ;;
1684 *-*bug)
1685 os=-coff
1686 ;;
1687 *-apple)
1688 os=-macos
1689 ;;
1690 *-atari*)
1691 os=-mint
1692 ;;
1693 *)
1694 os=-none
1695 ;;
1696 esac
1697 fi
1698
1699 # Here we handle the case where we know the os, and the CPU type, but not the
1700 # manufacturer. We pick the logical manufacturer.
1701 vendor=unknown
1702 case $basic_machine in
1703 *-unknown)
1704 case $os in
1705 -riscix*)
1706 vendor=acorn
1707 ;;
1708 -sunos*)
1709 vendor=sun
1710 ;;
1711 -cnk*|-aix*)
1712 vendor=ibm
1713 ;;
1714 -beos*)
1715 vendor=be
1716 ;;
1717 -hpux*)
1718 vendor=hp
1719 ;;
1720 -mpeix*)
1721 vendor=hp
1722 ;;
1723 -hiux*)
1724 vendor=hitachi
1725 ;;
1726 -unos*)
1727 vendor=crds
1728 ;;
1729 -dgux*)
1730 vendor=dg
1731 ;;
1732 -luna*)
1733 vendor=omron
1734 ;;
1735 -genix*)
1736 vendor=ns
1737 ;;
1738 -mvs* | -opened*)
1739 vendor=ibm
1740 ;;
1741 -os400*)
1742 vendor=ibm
1743 ;;
1744 -ptx*)
1745 vendor=sequent
1746 ;;
1747 -tpf*)
1748 vendor=ibm
1749 ;;
1750 -vxsim* | -vxworks* | -windiss*)
1751 vendor=wrs
1752 ;;
1753 -aux*)
1754 vendor=apple
1755 ;;
1756 -hms*)
1757 vendor=hitachi
1758 ;;
1759 -mpw* | -macos*)
1760 vendor=apple
1761 ;;
1762 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
1763 vendor=atari
1764 ;;
1765 -vos*)
1766 vendor=stratus
1767 ;;
1768 esac
1769 basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
1770 ;;
1771 esac
1772
1773 echo $basic_machine$os
1774 exit
1775
1776 # Local variables:
1777 # eval: (add-hook 'write-file-hooks 'time-stamp)
1778 # time-stamp-start: "timestamp='"
1779 # time-stamp-format: "%:y-%02m-%02d"
1780 # time-stamp-end: "'"
1781 # End:
0 #! /bin/sh
1 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.69 for getdns 0.1.0.
3 #
4 # Report bugs to <stub-resolver@verisignlabs.com>.
5 #
6 #
7 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
8 #
9 #
10 # This configure script is free software; the Free Software Foundation
11 # gives unlimited permission to copy, distribute and modify it.
12 ## -------------------- ##
13 ## M4sh Initialization. ##
14 ## -------------------- ##
15
16 # Be more Bourne compatible
17 DUALCASE=1; export DUALCASE # for MKS sh
18 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
19 emulate sh
20 NULLCMD=:
21 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
22 # is contrary to our usage. Disable this feature.
23 alias -g '${1+"$@"}'='"$@"'
24 setopt NO_GLOB_SUBST
25 else
26 case `(set -o) 2>/dev/null` in #(
27 *posix*) :
28 set -o posix ;; #(
29 *) :
30 ;;
31 esac
32 fi
33
34
35 as_nl='
36 '
37 export as_nl
38 # Printing a long string crashes Solaris 7 /usr/bin/printf.
39 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
40 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
41 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
42 # Prefer a ksh shell builtin over an external printf program on Solaris,
43 # but without wasting forks for bash or zsh.
44 if test -z "$BASH_VERSION$ZSH_VERSION" \
45 && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
46 as_echo='print -r --'
47 as_echo_n='print -rn --'
48 elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
49 as_echo='printf %s\n'
50 as_echo_n='printf %s'
51 else
52 if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
53 as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
54 as_echo_n='/usr/ucb/echo -n'
55 else
56 as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
57 as_echo_n_body='eval
58 arg=$1;
59 case $arg in #(
60 *"$as_nl"*)
61 expr "X$arg" : "X\\(.*\\)$as_nl";
62 arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
63 esac;
64 expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
65 '
66 export as_echo_n_body
67 as_echo_n='sh -c $as_echo_n_body as_echo'
68 fi
69 export as_echo_body
70 as_echo='sh -c $as_echo_body as_echo'
71 fi
72
73 # The user is always right.
74 if test "${PATH_SEPARATOR+set}" != set; then
75 PATH_SEPARATOR=:
76 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
77 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
78 PATH_SEPARATOR=';'
79 }
80 fi
81
82
83 # IFS
84 # We need space, tab and new line, in precisely that order. Quoting is
85 # there to prevent editors from complaining about space-tab.
86 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
87 # splitting by setting IFS to empty value.)
88 IFS=" "" $as_nl"
89
90 # Find who we are. Look in the path if we contain no directory separator.
91 as_myself=
92 case $0 in #((
93 *[\\/]* ) as_myself=$0 ;;
94 *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
95 for as_dir in $PATH
96 do
97 IFS=$as_save_IFS
98 test -z "$as_dir" && as_dir=.
99 test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
100 done
101 IFS=$as_save_IFS
102
103 ;;
104 esac
105 # We did not find ourselves, most probably we were run as `sh COMMAND'
106 # in which case we are not to be found in the path.
107 if test "x$as_myself" = x; then
108 as_myself=$0
109 fi
110 if test ! -f "$as_myself"; then
111 $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
112 exit 1
113 fi
114
115 # Unset variables that we do not need and which cause bugs (e.g. in
116 # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
117 # suppresses any "Segmentation fault" message there. '((' could
118 # trigger a bug in pdksh 5.2.14.
119 for as_var in BASH_ENV ENV MAIL MAILPATH
120 do eval test x\${$as_var+set} = xset \
121 && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
122 done
123 PS1='$ '
124 PS2='> '
125 PS4='+ '
126
127 # NLS nuisances.
128 LC_ALL=C
129 export LC_ALL
130 LANGUAGE=C
131 export LANGUAGE
132
133 # CDPATH.
134 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
135
136 # Use a proper internal environment variable to ensure we don't fall
137 # into an infinite loop, continuously re-executing ourselves.
138 if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
139 _as_can_reexec=no; export _as_can_reexec;
140 # We cannot yet assume a decent shell, so we have to provide a
141 # neutralization value for shells without unset; and this also
142 # works around shells that cannot unset nonexistent variables.
143 # Preserve -v and -x to the replacement shell.
144 BASH_ENV=/dev/null
145 ENV=/dev/null
146 (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
147 case $- in # ((((
148 *v*x* | *x*v* ) as_opts=-vx ;;
149 *v* ) as_opts=-v ;;
150 *x* ) as_opts=-x ;;
151 * ) as_opts= ;;
152 esac
153 exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
154 # Admittedly, this is quite paranoid, since all the known shells bail
155 # out after a failed `exec'.
156 $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
157 as_fn_exit 255
158 fi
159 # We don't want this to propagate to other subprocesses.
160 { _as_can_reexec=; unset _as_can_reexec;}
161 if test "x$CONFIG_SHELL" = x; then
162 as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
163 emulate sh
164 NULLCMD=:
165 # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
166 # is contrary to our usage. Disable this feature.
167 alias -g '\${1+\"\$@\"}'='\"\$@\"'
168 setopt NO_GLOB_SUBST
169 else
170 case \`(set -o) 2>/dev/null\` in #(
171 *posix*) :
172 set -o posix ;; #(
173 *) :
174 ;;
175 esac
176 fi
177 "
178 as_required="as_fn_return () { (exit \$1); }
179 as_fn_success () { as_fn_return 0; }
180 as_fn_failure () { as_fn_return 1; }
181 as_fn_ret_success () { return 0; }
182 as_fn_ret_failure () { return 1; }
183
184 exitcode=0
185 as_fn_success || { exitcode=1; echo as_fn_success failed.; }
186 as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
187 as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
188 as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
189 if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
190
191 else
192 exitcode=1; echo positional parameters were not saved.
193 fi
194 test x\$exitcode = x0 || exit 1
195 test -x / || exit 1"
196 as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
197 as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
198 eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
199 test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
200
201 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || (
202 ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
203 ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
204 ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
205 PATH=/empty FPATH=/empty; export PATH FPATH
206 test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\
207 || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1
208 test \$(( 1 + 1 )) = 2 || exit 1"
209 if (eval "$as_required") 2>/dev/null; then :
210 as_have_required=yes
211 else
212 as_have_required=no
213 fi
214 if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
215
216 else
217 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
218 as_found=false
219 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
220 do
221 IFS=$as_save_IFS
222 test -z "$as_dir" && as_dir=.
223 as_found=:
224 case $as_dir in #(
225 /*)
226 for as_base in sh bash ksh sh5; do
227 # Try only shells that exist, to save several forks.
228 as_shell=$as_dir/$as_base
229 if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
230 { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
231 CONFIG_SHELL=$as_shell as_have_required=yes
232 if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
233 break 2
234 fi
235 fi
236 done;;
237 esac
238 as_found=false
239 done
240 $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
241 { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
242 CONFIG_SHELL=$SHELL as_have_required=yes
243 fi; }
244 IFS=$as_save_IFS
245
246
247 if test "x$CONFIG_SHELL" != x; then :
248 export CONFIG_SHELL
249 # We cannot yet assume a decent shell, so we have to provide a
250 # neutralization value for shells without unset; and this also
251 # works around shells that cannot unset nonexistent variables.
252 # Preserve -v and -x to the replacement shell.
253 BASH_ENV=/dev/null
254 ENV=/dev/null
255 (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
256 case $- in # ((((
257 *v*x* | *x*v* ) as_opts=-vx ;;
258 *v* ) as_opts=-v ;;
259 *x* ) as_opts=-x ;;
260 * ) as_opts= ;;
261 esac
262 exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
263 # Admittedly, this is quite paranoid, since all the known shells bail
264 # out after a failed `exec'.
265 $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
266 exit 255
267 fi
268
269 if test x$as_have_required = xno; then :
270 $as_echo "$0: This script requires a shell more modern than all"
271 $as_echo "$0: the shells that I found on your system."
272 if test x${ZSH_VERSION+set} = xset ; then
273 $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
274 $as_echo "$0: be upgraded to zsh 4.3.4 or later."
275 else
276 $as_echo "$0: Please tell bug-autoconf@gnu.org and
277 $0: stub-resolver@verisignlabs.com about your system,
278 $0: including any error possibly output before this
279 $0: message. Then install a modern shell, or manually run
280 $0: the script under such a shell if you do have one."
281 fi
282 exit 1
283 fi
284 fi
285 fi
286 SHELL=${CONFIG_SHELL-/bin/sh}
287 export SHELL
288 # Unset more variables known to interfere with behavior of common tools.
289 CLICOLOR_FORCE= GREP_OPTIONS=
290 unset CLICOLOR_FORCE GREP_OPTIONS
291
292 ## --------------------- ##
293 ## M4sh Shell Functions. ##
294 ## --------------------- ##
295 # as_fn_unset VAR
296 # ---------------
297 # Portably unset VAR.
298 as_fn_unset ()
299 {
300 { eval $1=; unset $1;}
301 }
302 as_unset=as_fn_unset
303
304 # as_fn_set_status STATUS
305 # -----------------------
306 # Set $? to STATUS, without forking.
307 as_fn_set_status ()
308 {
309 return $1
310 } # as_fn_set_status
311
312 # as_fn_exit STATUS
313 # -----------------
314 # Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
315 as_fn_exit ()
316 {
317 set +e
318 as_fn_set_status $1
319 exit $1
320 } # as_fn_exit
321
322 # as_fn_mkdir_p
323 # -------------
324 # Create "$as_dir" as a directory, including parents if necessary.
325 as_fn_mkdir_p ()
326 {
327
328 case $as_dir in #(
329 -*) as_dir=./$as_dir;;
330 esac
331 test -d "$as_dir" || eval $as_mkdir_p || {
332 as_dirs=
333 while :; do
334 case $as_dir in #(
335 *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
336 *) as_qdir=$as_dir;;
337 esac
338 as_dirs="'$as_qdir' $as_dirs"
339 as_dir=`$as_dirname -- "$as_dir" ||
340 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
341 X"$as_dir" : 'X\(//\)[^/]' \| \
342 X"$as_dir" : 'X\(//\)$' \| \
343 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
344 $as_echo X"$as_dir" |
345 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
346 s//\1/
347 q
348 }
349 /^X\(\/\/\)[^/].*/{
350 s//\1/
351 q
352 }
353 /^X\(\/\/\)$/{
354 s//\1/
355 q
356 }
357 /^X\(\/\).*/{
358 s//\1/
359 q
360 }
361 s/.*/./; q'`
362 test -d "$as_dir" && break
363 done
364 test -z "$as_dirs" || eval "mkdir $as_dirs"
365 } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
366
367
368 } # as_fn_mkdir_p
369
370 # as_fn_executable_p FILE
371 # -----------------------
372 # Test if FILE is an executable regular file.
373 as_fn_executable_p ()
374 {
375 test -f "$1" && test -x "$1"
376 } # as_fn_executable_p
377 # as_fn_append VAR VALUE
378 # ----------------------
379 # Append the text in VALUE to the end of the definition contained in VAR. Take
380 # advantage of any shell optimizations that allow amortized linear growth over
381 # repeated appends, instead of the typical quadratic growth present in naive
382 # implementations.
383 if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
384 eval 'as_fn_append ()
385 {
386 eval $1+=\$2
387 }'
388 else
389 as_fn_append ()
390 {
391 eval $1=\$$1\$2
392 }
393 fi # as_fn_append
394
395 # as_fn_arith ARG...
396 # ------------------
397 # Perform arithmetic evaluation on the ARGs, and store the result in the
398 # global $as_val. Take advantage of shells that can avoid forks. The arguments
399 # must be portable across $(()) and expr.
400 if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
401 eval 'as_fn_arith ()
402 {
403 as_val=$(( $* ))
404 }'
405 else
406 as_fn_arith ()
407 {
408 as_val=`expr "$@" || test $? -eq 1`
409 }
410 fi # as_fn_arith
411
412
413 # as_fn_error STATUS ERROR [LINENO LOG_FD]
414 # ----------------------------------------
415 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
416 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
417 # script with STATUS, using 1 if that was 0.
418 as_fn_error ()
419 {
420 as_status=$1; test $as_status -eq 0 && as_status=1
421 if test "$4"; then
422 as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
423 $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
424 fi
425 $as_echo "$as_me: error: $2" >&2
426 as_fn_exit $as_status
427 } # as_fn_error
428
429 if expr a : '\(a\)' >/dev/null 2>&1 &&
430 test "X`expr 00001 : '.*\(...\)'`" = X001; then
431 as_expr=expr
432 else
433 as_expr=false
434 fi
435
436 if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
437 as_basename=basename
438 else
439 as_basename=false
440 fi
441
442 if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
443 as_dirname=dirname
444 else
445 as_dirname=false
446 fi
447
448 as_me=`$as_basename -- "$0" ||
449 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
450 X"$0" : 'X\(//\)$' \| \
451 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
452 $as_echo X/"$0" |
453 sed '/^.*\/\([^/][^/]*\)\/*$/{
454 s//\1/
455 q
456 }
457 /^X\/\(\/\/\)$/{
458 s//\1/
459 q
460 }
461 /^X\/\(\/\).*/{
462 s//\1/
463 q
464 }
465 s/.*/./; q'`
466
467 # Avoid depending upon Character Ranges.
468 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
469 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
470 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
471 as_cr_digits='0123456789'
472 as_cr_alnum=$as_cr_Letters$as_cr_digits
473
474
475 as_lineno_1=$LINENO as_lineno_1a=$LINENO
476 as_lineno_2=$LINENO as_lineno_2a=$LINENO
477 eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
478 test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
479 # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
480 sed -n '
481 p
482 /[$]LINENO/=
483 ' <$as_myself |
484 sed '
485 s/[$]LINENO.*/&-/
486 t lineno
487 b
488 :lineno
489 N
490 :loop
491 s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
492 t loop
493 s/-\n.*//
494 ' >$as_me.lineno &&
495 chmod +x "$as_me.lineno" ||
496 { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
497
498 # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
499 # already done that, so ensure we don't try to do so again and fall
500 # in an infinite loop. This has already happened in practice.
501 _as_can_reexec=no; export _as_can_reexec
502 # Don't try to exec as it changes $[0], causing all sort of problems
503 # (the dirname of $[0] is not the place where we might find the
504 # original and so on. Autoconf is especially sensitive to this).
505 . "./$as_me.lineno"
506 # Exit status is that of the last command.
507 exit
508 }
509
510 ECHO_C= ECHO_N= ECHO_T=
511 case `echo -n x` in #(((((
512 -n*)
513 case `echo 'xy\c'` in
514 *c*) ECHO_T=' ';; # ECHO_T is single tab character.
515 xy) ECHO_C='\c';;
516 *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
517 ECHO_T=' ';;
518 esac;;
519 *)
520 ECHO_N='-n';;
521 esac
522
523 rm -f conf$$ conf$$.exe conf$$.file
524 if test -d conf$$.dir; then
525 rm -f conf$$.dir/conf$$.file
526 else
527 rm -f conf$$.dir
528 mkdir conf$$.dir 2>/dev/null
529 fi
530 if (echo >conf$$.file) 2>/dev/null; then
531 if ln -s conf$$.file conf$$ 2>/dev/null; then
532 as_ln_s='ln -s'
533 # ... but there are two gotchas:
534 # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
535 # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
536 # In both cases, we have to default to `cp -pR'.
537 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
538 as_ln_s='cp -pR'
539 elif ln conf$$.file conf$$ 2>/dev/null; then
540 as_ln_s=ln
541 else
542 as_ln_s='cp -pR'
543 fi
544 else
545 as_ln_s='cp -pR'
546 fi
547 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
548 rmdir conf$$.dir 2>/dev/null
549
550 if mkdir -p . 2>/dev/null; then
551 as_mkdir_p='mkdir -p "$as_dir"'
552 else
553 test -d ./-p && rmdir ./-p
554 as_mkdir_p=false
555 fi
556
557 as_test_x='test -x'
558 as_executable_p=as_fn_executable_p
559
560 # Sed expression to map a string onto a valid CPP name.
561 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
562
563 # Sed expression to map a string onto a valid variable name.
564 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
565
566 SHELL=${CONFIG_SHELL-/bin/sh}
567
568
569 test -n "$DJDIR" || exec 7<&0 </dev/null
570 exec 6>&1
571
572 # Name of the host.
573 # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
574 # so uname gets run too.
575 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
576
577 #
578 # Initializations.
579 #
580 ac_default_prefix=/usr/local
581 ac_clean_files=
582 ac_config_libobj_dir=.
583 LIBOBJS=
584 cross_compiling=no
585 subdirs=
586 MFLAGS=
587 MAKEFLAGS=
588
589 # Identity of this package.
590 PACKAGE_NAME='getdns'
591 PACKAGE_TARNAME='getdns'
592 PACKAGE_VERSION='0.1.0'
593 PACKAGE_STRING='getdns 0.1.0'
594 PACKAGE_BUGREPORT='stub-resolver@verisignlabs.com'
595 PACKAGE_URL='http://www.getdnsapi.net'
596
597 ac_unique_file="src/getdns/getdns.h.in"
598 # Factoring default headers for most tests.
599 ac_includes_default="\
600 #include <stdio.h>
601 #ifdef HAVE_SYS_TYPES_H
602 # include <sys/types.h>
603 #endif
604 #ifdef HAVE_SYS_STAT_H
605 # include <sys/stat.h>
606 #endif
607 #ifdef STDC_HEADERS
608 # include <stdlib.h>
609 # include <stddef.h>
610 #else
611 # ifdef HAVE_STDLIB_H
612 # include <stdlib.h>
613 # endif
614 #endif
615 #ifdef HAVE_STRING_H
616 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
617 # include <memory.h>
618 # endif
619 # include <string.h>
620 #endif
621 #ifdef HAVE_STRINGS_H
622 # include <strings.h>
623 #endif
624 #ifdef HAVE_INTTYPES_H
625 # include <inttypes.h>
626 #endif
627 #ifdef HAVE_STDINT_H
628 # include <stdint.h>
629 #endif
630 #ifdef HAVE_UNISTD_H
631 # include <unistd.h>
632 #endif"
633
634 ac_subst_vars='LTLIBOBJS
635 LIBOBJS
636 TRUST_ANCHOR_FILE
637 EXTENSION_LDFLAGS
638 CHECK_EV_PROG
639 EXTENSION_LIBEV_EXT_LIBS
640 EXTENSION_LIBEV_LIB
641 have_libev
642 CHECK_UV_PROG
643 EXTENSION_LIBUV_EXT_LIBS
644 EXTENSION_LIBUV_LIB
645 have_libuv
646 CHECK_EVENT_PROG
647 EXTENSION_LIBEVENT_EXT_LIBS
648 EXTENSION_LIBEVENT_LIB
649 have_libevent
650 DOXYGEN
651 INSTALL_DATA
652 INSTALL_SCRIPT
653 INSTALL_PROGRAM
654 OTOOL64
655 OTOOL
656 LIPO
657 NMEDIT
658 DSYMUTIL
659 MANIFEST_TOOL
660 AWK
661 RANLIB
662 STRIP
663 ac_ct_AR
664 AR
665 DLLTOOL
666 OBJDUMP
667 LN_S
668 NM
669 ac_ct_DUMPBIN
670 DUMPBIN
671 LD
672 FGREP
673 EGREP
674 GREP
675 SED
676 LIBTOOL
677 libtool
678 host_os
679 host_vendor
680 host_cpu
681 host
682 build_os
683 build_vendor
684 build_cpu
685 build
686 CPP
687 OBJEXT
688 EXEEXT
689 ac_ct_CC
690 CPPFLAGS
691 LDFLAGS
692 CFLAGS
693 CC
694 GETDNS_COMPILATION_COMMENT
695 target_alias
696 host_alias
697 build_alias
698 LIBS
699 ECHO_T
700 ECHO_N
701 ECHO_C
702 DEFS
703 mandir
704 localedir
705 libdir
706 psdir
707 pdfdir
708 dvidir
709 htmldir
710 infodir
711 docdir
712 oldincludedir
713 includedir
714 localstatedir
715 sharedstatedir
716 sysconfdir
717 datadir
718 datarootdir
719 libexecdir
720 sbindir
721 bindir
722 program_transform_name
723 prefix
724 exec_prefix
725 PACKAGE_URL
726 PACKAGE_BUGREPORT
727 PACKAGE_STRING
728 PACKAGE_VERSION
729 PACKAGE_TARNAME
730 PACKAGE_NAME
731 PATH_SEPARATOR
732 SHELL'
733 ac_subst_files=''
734 ac_user_opts='
735 enable_option_checking
736 enable_shared
737 enable_static
738 with_pic
739 enable_fast_install
740 with_gnu_ld
741 with_sysroot
742 enable_libtool_lock
743 enable_rpath
744 with_libidn
745 with_libldns
746 with_libunbound
747 with_trust_anchor
748 '
749 ac_precious_vars='build_alias
750 host_alias
751 target_alias
752 CC
753 CFLAGS
754 LDFLAGS
755 LIBS
756 CPPFLAGS
757 CPP'
758
759
760 # Initialize some variables set by options.
761 ac_init_help=
762 ac_init_version=false
763 ac_unrecognized_opts=
764 ac_unrecognized_sep=
765 # The variables have the same names as the options, with
766 # dashes changed to underlines.
767 cache_file=/dev/null
768 exec_prefix=NONE
769 no_create=
770 no_recursion=
771 prefix=NONE
772 program_prefix=NONE
773 program_suffix=NONE
774 program_transform_name=s,x,x,
775 silent=
776 site=
777 srcdir=
778 verbose=
779 x_includes=NONE
780 x_libraries=NONE
781
782 # Installation directory options.
783 # These are left unexpanded so users can "make install exec_prefix=/foo"
784 # and all the variables that are supposed to be based on exec_prefix
785 # by default will actually change.
786 # Use braces instead of parens because sh, perl, etc. also accept them.
787 # (The list follows the same order as the GNU Coding Standards.)
788 bindir='${exec_prefix}/bin'
789 sbindir='${exec_prefix}/sbin'
790 libexecdir='${exec_prefix}/libexec'
791 datarootdir='${prefix}/share'
792 datadir='${datarootdir}'
793 sysconfdir='${prefix}/etc'
794 sharedstatedir='${prefix}/com'
795 localstatedir='${prefix}/var'
796 includedir='${prefix}/include'
797 oldincludedir='/usr/include'
798 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
799 infodir='${datarootdir}/info'
800 htmldir='${docdir}'
801 dvidir='${docdir}'
802 pdfdir='${docdir}'
803 psdir='${docdir}'
804 libdir='${exec_prefix}/lib'
805 localedir='${datarootdir}/locale'
806 mandir='${datarootdir}/man'
807
808 ac_prev=
809 ac_dashdash=
810 for ac_option
811 do
812 # If the previous option needs an argument, assign it.
813 if test -n "$ac_prev"; then
814 eval $ac_prev=\$ac_option
815 ac_prev=
816 continue
817 fi
818
819 case $ac_option in
820 *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
821 *=) ac_optarg= ;;
822 *) ac_optarg=yes ;;
823 esac
824
825 # Accept the important Cygnus configure options, so we can diagnose typos.
826
827 case $ac_dashdash$ac_option in
828 --)
829 ac_dashdash=yes ;;
830
831 -bindir | --bindir | --bindi | --bind | --bin | --bi)
832 ac_prev=bindir ;;
833 -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
834 bindir=$ac_optarg ;;
835
836 -build | --build | --buil | --bui | --bu)
837 ac_prev=build_alias ;;
838 -build=* | --build=* | --buil=* | --bui=* | --bu=*)
839 build_alias=$ac_optarg ;;
840
841 -cache-file | --cache-file | --cache-fil | --cache-fi \
842 | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
843 ac_prev=cache_file ;;
844 -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
845 | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
846 cache_file=$ac_optarg ;;
847
848 --config-cache | -C)
849 cache_file=config.cache ;;
850
851 -datadir | --datadir | --datadi | --datad)
852 ac_prev=datadir ;;
853 -datadir=* | --datadir=* | --datadi=* | --datad=*)
854 datadir=$ac_optarg ;;
855
856 -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
857 | --dataroo | --dataro | --datar)
858 ac_prev=datarootdir ;;
859 -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
860 | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
861 datarootdir=$ac_optarg ;;
862
863 -disable-* | --disable-*)
864 ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
865 # Reject names that are not valid shell variable names.
866 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
867 as_fn_error $? "invalid feature name: $ac_useropt"
868 ac_useropt_orig=$ac_useropt
869 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
870 case $ac_user_opts in
871 *"
872 "enable_$ac_useropt"
873 "*) ;;
874 *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
875 ac_unrecognized_sep=', ';;
876 esac
877 eval enable_$ac_useropt=no ;;
878
879 -docdir | --docdir | --docdi | --doc | --do)
880 ac_prev=docdir ;;
881 -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
882 docdir=$ac_optarg ;;
883
884 -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
885 ac_prev=dvidir ;;
886 -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
887 dvidir=$ac_optarg ;;
888
889 -enable-* | --enable-*)
890 ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
891 # Reject names that are not valid shell variable names.
892 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
893 as_fn_error $? "invalid feature name: $ac_useropt"
894 ac_useropt_orig=$ac_useropt
895 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
896 case $ac_user_opts in
897 *"
898 "enable_$ac_useropt"
899 "*) ;;
900 *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
901 ac_unrecognized_sep=', ';;
902 esac
903 eval enable_$ac_useropt=\$ac_optarg ;;
904
905 -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
906 | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
907 | --exec | --exe | --ex)
908 ac_prev=exec_prefix ;;
909 -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
910 | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
911 | --exec=* | --exe=* | --ex=*)
912 exec_prefix=$ac_optarg ;;
913
914 -gas | --gas | --ga | --g)
915 # Obsolete; use --with-gas.
916 with_gas=yes ;;
917
918 -help | --help | --hel | --he | -h)
919 ac_init_help=long ;;
920 -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
921 ac_init_help=recursive ;;
922 -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
923 ac_init_help=short ;;
924
925 -host | --host | --hos | --ho)
926 ac_prev=host_alias ;;
927 -host=* | --host=* | --hos=* | --ho=*)
928 host_alias=$ac_optarg ;;
929
930 -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
931 ac_prev=htmldir ;;
932 -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
933 | --ht=*)
934 htmldir=$ac_optarg ;;
935
936 -includedir | --includedir | --includedi | --included | --include \
937 | --includ | --inclu | --incl | --inc)
938 ac_prev=includedir ;;
939 -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
940 | --includ=* | --inclu=* | --incl=* | --inc=*)
941 includedir=$ac_optarg ;;
942
943 -infodir | --infodir | --infodi | --infod | --info | --inf)
944 ac_prev=infodir ;;
945 -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
946 infodir=$ac_optarg ;;
947
948 -libdir | --libdir | --libdi | --libd)
949 ac_prev=libdir ;;
950 -libdir=* | --libdir=* | --libdi=* | --libd=*)
951 libdir=$ac_optarg ;;
952
953 -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
954 | --libexe | --libex | --libe)
955 ac_prev=libexecdir ;;
956 -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
957 | --libexe=* | --libex=* | --libe=*)
958 libexecdir=$ac_optarg ;;
959
960 -localedir | --localedir | --localedi | --localed | --locale)
961 ac_prev=localedir ;;
962 -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
963 localedir=$ac_optarg ;;
964
965 -localstatedir | --localstatedir | --localstatedi | --localstated \
966 | --localstate | --localstat | --localsta | --localst | --locals)
967 ac_prev=localstatedir ;;
968 -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
969 | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
970 localstatedir=$ac_optarg ;;
971
972 -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
973 ac_prev=mandir ;;
974 -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
975 mandir=$ac_optarg ;;
976
977 -nfp | --nfp | --nf)
978 # Obsolete; use --without-fp.
979 with_fp=no ;;
980
981 -no-create | --no-create | --no-creat | --no-crea | --no-cre \
982 | --no-cr | --no-c | -n)
983 no_create=yes ;;
984
985 -no-recursion | --no-recursion | --no-recursio | --no-recursi \
986 | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
987 no_recursion=yes ;;
988
989 -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
990 | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
991 | --oldin | --oldi | --old | --ol | --o)
992 ac_prev=oldincludedir ;;
993 -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
994 | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
995 | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
996 oldincludedir=$ac_optarg ;;
997
998 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
999 ac_prev=prefix ;;
1000 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
1001 prefix=$ac_optarg ;;
1002
1003 -program-prefix | --program-prefix | --program-prefi | --program-pref \
1004 | --program-pre | --program-pr | --program-p)
1005 ac_prev=program_prefix ;;
1006 -program-prefix=* | --program-prefix=* | --program-prefi=* \
1007 | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
1008 program_prefix=$ac_optarg ;;
1009
1010 -program-suffix | --program-suffix | --program-suffi | --program-suff \
1011 | --program-suf | --program-su | --program-s)
1012 ac_prev=program_suffix ;;
1013 -program-suffix=* | --program-suffix=* | --program-suffi=* \
1014 | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
1015 program_suffix=$ac_optarg ;;
1016
1017 -program-transform-name | --program-transform-name \
1018 | --program-transform-nam | --program-transform-na \
1019 | --program-transform-n | --program-transform- \
1020 | --program-transform | --program-transfor \
1021 | --program-transfo | --program-transf \
1022 | --program-trans | --program-tran \
1023 | --progr-tra | --program-tr | --program-t)
1024 ac_prev=program_transform_name ;;
1025 -program-transform-name=* | --program-transform-name=* \
1026 | --program-transform-nam=* | --program-transform-na=* \
1027 | --program-transform-n=* | --program-transform-=* \
1028 | --program-transform=* | --program-transfor=* \
1029 | --program-transfo=* | --program-transf=* \
1030 | --program-trans=* | --program-tran=* \
1031 | --progr-tra=* | --program-tr=* | --program-t=*)
1032 program_transform_name=$ac_optarg ;;
1033
1034 -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
1035 ac_prev=pdfdir ;;
1036 -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
1037 pdfdir=$ac_optarg ;;
1038
1039 -psdir | --psdir | --psdi | --psd | --ps)
1040 ac_prev=psdir ;;
1041 -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
1042 psdir=$ac_optarg ;;
1043
1044 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
1045 | -silent | --silent | --silen | --sile | --sil)
1046 silent=yes ;;
1047
1048 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
1049 ac_prev=sbindir ;;
1050 -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
1051 | --sbi=* | --sb=*)
1052 sbindir=$ac_optarg ;;
1053
1054 -sharedstatedir | --sharedstatedir | --sharedstatedi \
1055 | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
1056 | --sharedst | --shareds | --shared | --share | --shar \
1057 | --sha | --sh)
1058 ac_prev=sharedstatedir ;;
1059 -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
1060 | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
1061 | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
1062 | --sha=* | --sh=*)
1063 sharedstatedir=$ac_optarg ;;
1064
1065 -site | --site | --sit)
1066 ac_prev=site ;;
1067 -site=* | --site=* | --sit=*)
1068 site=$ac_optarg ;;
1069
1070 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
1071 ac_prev=srcdir ;;
1072 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
1073 srcdir=$ac_optarg ;;
1074
1075 -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
1076 | --syscon | --sysco | --sysc | --sys | --sy)
1077 ac_prev=sysconfdir ;;
1078 -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
1079 | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
1080 sysconfdir=$ac_optarg ;;
1081
1082 -target | --target | --targe | --targ | --tar | --ta | --t)
1083 ac_prev=target_alias ;;
1084 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
1085 target_alias=$ac_optarg ;;
1086
1087 -v | -verbose | --verbose | --verbos | --verbo | --verb)
1088 verbose=yes ;;
1089
1090 -version | --version | --versio | --versi | --vers | -V)
1091 ac_init_version=: ;;
1092
1093 -with-* | --with-*)
1094 ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
1095 # Reject names that are not valid shell variable names.
1096 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
1097 as_fn_error $? "invalid package name: $ac_useropt"
1098 ac_useropt_orig=$ac_useropt
1099 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
1100 case $ac_user_opts in
1101 *"
1102 "with_$ac_useropt"
1103 "*) ;;
1104 *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
1105 ac_unrecognized_sep=', ';;
1106 esac
1107 eval with_$ac_useropt=\$ac_optarg ;;
1108
1109 -without-* | --without-*)
1110 ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
1111 # Reject names that are not valid shell variable names.
1112 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
1113 as_fn_error $? "invalid package name: $ac_useropt"
1114 ac_useropt_orig=$ac_useropt
1115 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
1116 case $ac_user_opts in
1117 *"
1118 "with_$ac_useropt"
1119 "*) ;;
1120 *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
1121 ac_unrecognized_sep=', ';;
1122 esac
1123 eval with_$ac_useropt=no ;;
1124
1125 --x)
1126 # Obsolete; use --with-x.
1127 with_x=yes ;;
1128
1129 -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
1130 | --x-incl | --x-inc | --x-in | --x-i)
1131 ac_prev=x_includes ;;
1132 -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
1133 | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
1134 x_includes=$ac_optarg ;;
1135
1136 -x-libraries | --x-libraries | --x-librarie | --x-librari \
1137 | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
1138 ac_prev=x_libraries ;;
1139 -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
1140 | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
1141 x_libraries=$ac_optarg ;;
1142
1143 -*) as_fn_error $? "unrecognized option: \`$ac_option'
1144 Try \`$0 --help' for more information"
1145 ;;
1146
1147 *=*)
1148 ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
1149 # Reject names that are not valid shell variable names.
1150 case $ac_envvar in #(
1151 '' | [0-9]* | *[!_$as_cr_alnum]* )
1152 as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
1153 esac
1154 eval $ac_envvar=\$ac_optarg
1155 export $ac_envvar ;;
1156
1157 *)
1158 # FIXME: should be removed in autoconf 3.0.
1159 $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
1160 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
1161 $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
1162 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
1163 ;;
1164
1165 esac
1166 done
1167
1168 if test -n "$ac_prev"; then
1169 ac_option=--`echo $ac_prev | sed 's/_/-/g'`
1170 as_fn_error $? "missing argument to $ac_option"
1171 fi
1172
1173 if test -n "$ac_unrecognized_opts"; then
1174 case $enable_option_checking in
1175 no) ;;
1176 fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
1177 *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
1178 esac
1179 fi
1180
1181 # Check all directory arguments for consistency.
1182 for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
1183 datadir sysconfdir sharedstatedir localstatedir includedir \
1184 oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
1185 libdir localedir mandir
1186 do
1187 eval ac_val=\$$ac_var
1188 # Remove trailing slashes.
1189 case $ac_val in
1190 */ )
1191 ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
1192 eval $ac_var=\$ac_val;;
1193 esac
1194 # Be sure to have absolute directory names.
1195 case $ac_val in
1196 [\\/$]* | ?:[\\/]* ) continue;;
1197 NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
1198 esac
1199 as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
1200 done
1201
1202 # There might be people who depend on the old broken behavior: `$host'
1203 # used to hold the argument of --host etc.
1204 # FIXME: To remove some day.
1205 build=$build_alias
1206 host=$host_alias
1207 target=$target_alias
1208
1209 # FIXME: To remove some day.
1210 if test "x$host_alias" != x; then
1211 if test "x$build_alias" = x; then
1212 cross_compiling=maybe
1213 elif test "x$build_alias" != "x$host_alias"; then
1214 cross_compiling=yes
1215 fi
1216 fi
1217
1218 ac_tool_prefix=
1219 test -n "$host_alias" && ac_tool_prefix=$host_alias-
1220
1221 test "$silent" = yes && exec 6>/dev/null
1222
1223
1224 ac_pwd=`pwd` && test -n "$ac_pwd" &&
1225 ac_ls_di=`ls -di .` &&
1226 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
1227 as_fn_error $? "working directory cannot be determined"
1228 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
1229 as_fn_error $? "pwd does not report name of working directory"
1230
1231
1232 # Find the source files, if location was not specified.
1233 if test -z "$srcdir"; then
1234 ac_srcdir_defaulted=yes
1235 # Try the directory containing this script, then the parent directory.
1236 ac_confdir=`$as_dirname -- "$as_myself" ||
1237 $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
1238 X"$as_myself" : 'X\(//\)[^/]' \| \
1239 X"$as_myself" : 'X\(//\)$' \| \
1240 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
1241 $as_echo X"$as_myself" |
1242 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
1243 s//\1/
1244 q
1245 }
1246 /^X\(\/\/\)[^/].*/{
1247 s//\1/
1248 q
1249 }
1250 /^X\(\/\/\)$/{
1251 s//\1/
1252 q
1253 }
1254 /^X\(\/\).*/{
1255 s//\1/
1256 q
1257 }
1258 s/.*/./; q'`
1259 srcdir=$ac_confdir
1260 if test ! -r "$srcdir/$ac_unique_file"; then
1261 srcdir=..
1262 fi
1263 else
1264 ac_srcdir_defaulted=no
1265 fi
1266 if test ! -r "$srcdir/$ac_unique_file"; then
1267 test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
1268 as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
1269 fi
1270 ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
1271 ac_abs_confdir=`(
1272 cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
1273 pwd)`
1274 # When building in place, set srcdir=.
1275 if test "$ac_abs_confdir" = "$ac_pwd"; then
1276 srcdir=.
1277 fi
1278 # Remove unnecessary trailing slashes from srcdir.
1279 # Double slashes in file names in object file debugging info
1280 # mess up M-x gdb in Emacs.
1281 case $srcdir in
1282 */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
1283 esac
1284 for ac_var in $ac_precious_vars; do
1285 eval ac_env_${ac_var}_set=\${${ac_var}+set}
1286 eval ac_env_${ac_var}_value=\$${ac_var}
1287 eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
1288 eval ac_cv_env_${ac_var}_value=\$${ac_var}
1289 done
1290
1291 #
1292 # Report the --help message.
1293 #
1294 if test "$ac_init_help" = "long"; then
1295 # Omit some internal or obsolete options to make the list less imposing.
1296 # This message is too long to be a string in the A/UX 3.1 sh.
1297 cat <<_ACEOF
1298 \`configure' configures getdns 0.1.0 to adapt to many kinds of systems.
1299
1300 Usage: $0 [OPTION]... [VAR=VALUE]...
1301
1302 To assign environment variables (e.g., CC, CFLAGS...), specify them as
1303 VAR=VALUE. See below for descriptions of some of the useful variables.
1304
1305 Defaults for the options are specified in brackets.
1306
1307 Configuration:
1308 -h, --help display this help and exit
1309 --help=short display options specific to this package
1310 --help=recursive display the short help of all the included packages
1311 -V, --version display version information and exit
1312 -q, --quiet, --silent do not print \`checking ...' messages
1313 --cache-file=FILE cache test results in FILE [disabled]
1314 -C, --config-cache alias for \`--cache-file=config.cache'
1315 -n, --no-create do not create output files
1316 --srcdir=DIR find the sources in DIR [configure dir or \`..']
1317
1318 Installation directories:
1319 --prefix=PREFIX install architecture-independent files in PREFIX
1320 [$ac_default_prefix]
1321 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
1322 [PREFIX]
1323
1324 By default, \`make install' will install all the files in
1325 \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
1326 an installation prefix other than \`$ac_default_prefix' using \`--prefix',
1327 for instance \`--prefix=\$HOME'.
1328
1329 For better control, use the options below.
1330
1331 Fine tuning of the installation directories:
1332 --bindir=DIR user executables [EPREFIX/bin]
1333 --sbindir=DIR system admin executables [EPREFIX/sbin]
1334 --libexecdir=DIR program executables [EPREFIX/libexec]
1335 --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
1336 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
1337 --localstatedir=DIR modifiable single-machine data [PREFIX/var]
1338 --libdir=DIR object code libraries [EPREFIX/lib]
1339 --includedir=DIR C header files [PREFIX/include]
1340 --oldincludedir=DIR C header files for non-gcc [/usr/include]
1341 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
1342 --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
1343 --infodir=DIR info documentation [DATAROOTDIR/info]
1344 --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
1345 --mandir=DIR man documentation [DATAROOTDIR/man]
1346 --docdir=DIR documentation root [DATAROOTDIR/doc/getdns]
1347 --htmldir=DIR html documentation [DOCDIR]
1348 --dvidir=DIR dvi documentation [DOCDIR]
1349 --pdfdir=DIR pdf documentation [DOCDIR]
1350 --psdir=DIR ps documentation [DOCDIR]
1351 _ACEOF
1352
1353 cat <<\_ACEOF
1354
1355 System types:
1356 --build=BUILD configure for building on BUILD [guessed]
1357 --host=HOST cross-compile to build programs to run on HOST [BUILD]
1358 _ACEOF
1359 fi
1360
1361 if test -n "$ac_init_help"; then
1362 case $ac_init_help in
1363 short | recursive ) echo "Configuration of getdns 0.1.0:";;
1364 esac
1365 cat <<\_ACEOF
1366
1367 Optional Features:
1368 --disable-option-checking ignore unrecognized --enable/--with options
1369 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
1370 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
1371 --enable-shared[=PKGS] build shared libraries [default=yes]
1372 --enable-static[=PKGS] build static libraries [default=yes]
1373 --enable-fast-install[=PKGS]
1374 optimize for fast installation [default=yes]
1375 --disable-libtool-lock avoid locking (might break parallel builds)
1376 --disable-rpath disable hardcoded rpath (default=enabled)
1377
1378 Optional Packages:
1379 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
1380 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
1381 --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
1382 both]
1383 --with-gnu-ld assume the C compiler uses GNU ld [default=no]
1384 --with-sysroot=DIR Search for dependent libraries within DIR
1385 (or the compiler's sysroot if not specified).
1386 --with-libidn=pathname path to libidn (default: search /usr/local ..)
1387 --with-libldns=pathname path to libldns (default: search /usr/local ..)
1388 --with-libunbound=pathname
1389 path to libunbound (default: search /usr/local ..)
1390 --with-trust-anchor=KEYFILE
1391 Default location of the trust anchor file.
1392 [default=SYSCONFDIR/unbound/getdns-root.key]
1393
1394 Some influential environment variables:
1395 CC C compiler command
1396 CFLAGS C compiler flags
1397 LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
1398 nonstandard directory <lib dir>
1399 LIBS libraries to pass to the linker, e.g. -l<library>
1400 CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
1401 you have headers in a nonstandard directory <include dir>
1402 CPP C preprocessor
1403
1404 Use these variables to override the choices made by `configure' or to help
1405 it to find libraries and programs with nonstandard names/locations.
1406
1407 Report bugs to <stub-resolver@verisignlabs.com>.
1408 getdns home page: <http://www.getdnsapi.net>.
1409 _ACEOF
1410 ac_status=$?
1411 fi
1412
1413 if test "$ac_init_help" = "recursive"; then
1414 # If there are subdirs, report their specific --help.
1415 for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
1416 test -d "$ac_dir" ||
1417 { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
1418 continue
1419 ac_builddir=.
1420
1421 case "$ac_dir" in
1422 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
1423 *)
1424 ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
1425 # A ".." for each directory in $ac_dir_suffix.
1426 ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
1427 case $ac_top_builddir_sub in
1428 "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
1429 *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
1430 esac ;;
1431 esac
1432 ac_abs_top_builddir=$ac_pwd
1433 ac_abs_builddir=$ac_pwd$ac_dir_suffix
1434 # for backward compatibility:
1435 ac_top_builddir=$ac_top_build_prefix
1436
1437 case $srcdir in
1438 .) # We are building in place.
1439 ac_srcdir=.
1440 ac_top_srcdir=$ac_top_builddir_sub
1441 ac_abs_top_srcdir=$ac_pwd ;;
1442 [\\/]* | ?:[\\/]* ) # Absolute name.
1443 ac_srcdir=$srcdir$ac_dir_suffix;
1444 ac_top_srcdir=$srcdir
1445 ac_abs_top_srcdir=$srcdir ;;
1446 *) # Relative name.
1447 ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
1448 ac_top_srcdir=$ac_top_build_prefix$srcdir
1449 ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
1450 esac
1451 ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
1452
1453 cd "$ac_dir" || { ac_status=$?; continue; }
1454 # Check for guested configure.
1455 if test -f "$ac_srcdir/configure.gnu"; then
1456 echo &&
1457 $SHELL "$ac_srcdir/configure.gnu" --help=recursive
1458 elif test -f "$ac_srcdir/configure"; then
1459 echo &&
1460 $SHELL "$ac_srcdir/configure" --help=recursive
1461 else
1462 $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
1463 fi || ac_status=$?
1464 cd "$ac_pwd" || { ac_status=$?; break; }
1465 done
1466 fi
1467
1468 test -n "$ac_init_help" && exit $ac_status
1469 if $ac_init_version; then
1470 cat <<\_ACEOF
1471 getdns configure 0.1.0
1472 generated by GNU Autoconf 2.69
1473
1474 Copyright (C) 2012 Free Software Foundation, Inc.
1475 This configure script is free software; the Free Software Foundation
1476 gives unlimited permission to copy, distribute and modify it.
1477 _ACEOF
1478 exit
1479 fi
1480
1481 ## ------------------------ ##
1482 ## Autoconf initialization. ##
1483 ## ------------------------ ##
1484
1485 # ac_fn_c_try_compile LINENO
1486 # --------------------------
1487 # Try to compile conftest.$ac_ext, and return whether this succeeded.
1488 ac_fn_c_try_compile ()
1489 {
1490 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1491 rm -f conftest.$ac_objext
1492 if { { ac_try="$ac_compile"
1493 case "(($ac_try" in
1494 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1495 *) ac_try_echo=$ac_try;;
1496 esac
1497 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1498 $as_echo "$ac_try_echo"; } >&5
1499 (eval "$ac_compile") 2>conftest.err
1500 ac_status=$?
1501 if test -s conftest.err; then
1502 grep -v '^ *+' conftest.err >conftest.er1
1503 cat conftest.er1 >&5
1504 mv -f conftest.er1 conftest.err
1505 fi
1506 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1507 test $ac_status = 0; } && {
1508 test -z "$ac_c_werror_flag" ||
1509 test ! -s conftest.err
1510 } && test -s conftest.$ac_objext; then :
1511 ac_retval=0
1512 else
1513 $as_echo "$as_me: failed program was:" >&5
1514 sed 's/^/| /' conftest.$ac_ext >&5
1515
1516 ac_retval=1
1517 fi
1518 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1519 as_fn_set_status $ac_retval
1520
1521 } # ac_fn_c_try_compile
1522
1523 # ac_fn_c_try_cpp LINENO
1524 # ----------------------
1525 # Try to preprocess conftest.$ac_ext, and return whether this succeeded.
1526 ac_fn_c_try_cpp ()
1527 {
1528 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1529 if { { ac_try="$ac_cpp conftest.$ac_ext"
1530 case "(($ac_try" in
1531 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1532 *) ac_try_echo=$ac_try;;
1533 esac
1534 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1535 $as_echo "$ac_try_echo"; } >&5
1536 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
1537 ac_status=$?
1538 if test -s conftest.err; then
1539 grep -v '^ *+' conftest.err >conftest.er1
1540 cat conftest.er1 >&5
1541 mv -f conftest.er1 conftest.err
1542 fi
1543 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1544 test $ac_status = 0; } > conftest.i && {
1545 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
1546 test ! -s conftest.err
1547 }; then :
1548 ac_retval=0
1549 else
1550 $as_echo "$as_me: failed program was:" >&5
1551 sed 's/^/| /' conftest.$ac_ext >&5
1552
1553 ac_retval=1
1554 fi
1555 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1556 as_fn_set_status $ac_retval
1557
1558 } # ac_fn_c_try_cpp
1559
1560 # ac_fn_c_try_link LINENO
1561 # -----------------------
1562 # Try to link conftest.$ac_ext, and return whether this succeeded.
1563 ac_fn_c_try_link ()
1564 {
1565 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1566 rm -f conftest.$ac_objext conftest$ac_exeext
1567 if { { ac_try="$ac_link"
1568 case "(($ac_try" in
1569 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1570 *) ac_try_echo=$ac_try;;
1571 esac
1572 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1573 $as_echo "$ac_try_echo"; } >&5
1574 (eval "$ac_link") 2>conftest.err
1575 ac_status=$?
1576 if test -s conftest.err; then
1577 grep -v '^ *+' conftest.err >conftest.er1
1578 cat conftest.er1 >&5
1579 mv -f conftest.er1 conftest.err
1580 fi
1581 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1582 test $ac_status = 0; } && {
1583 test -z "$ac_c_werror_flag" ||
1584 test ! -s conftest.err
1585 } && test -s conftest$ac_exeext && {
1586 test "$cross_compiling" = yes ||
1587 test -x conftest$ac_exeext
1588 }; then :
1589 ac_retval=0
1590 else
1591 $as_echo "$as_me: failed program was:" >&5
1592 sed 's/^/| /' conftest.$ac_ext >&5
1593
1594 ac_retval=1
1595 fi
1596 # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
1597 # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
1598 # interfere with the next link command; also delete a directory that is
1599 # left behind by Apple's compiler. We do this before executing the actions.
1600 rm -rf conftest.dSYM conftest_ipa8_conftest.oo
1601 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1602 as_fn_set_status $ac_retval
1603
1604 } # ac_fn_c_try_link
1605
1606 # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
1607 # -------------------------------------------------------
1608 # Tests whether HEADER exists and can be compiled using the include files in
1609 # INCLUDES, setting the cache variable VAR accordingly.
1610 ac_fn_c_check_header_compile ()
1611 {
1612 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1613 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
1614 $as_echo_n "checking for $2... " >&6; }
1615 if eval \${$3+:} false; then :
1616 $as_echo_n "(cached) " >&6
1617 else
1618 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1619 /* end confdefs.h. */
1620 $4
1621 #include <$2>
1622 _ACEOF
1623 if ac_fn_c_try_compile "$LINENO"; then :
1624 eval "$3=yes"
1625 else
1626 eval "$3=no"
1627 fi
1628 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1629 fi
1630 eval ac_res=\$$3
1631 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1632 $as_echo "$ac_res" >&6; }
1633 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1634
1635 } # ac_fn_c_check_header_compile
1636
1637 # ac_fn_c_try_run LINENO
1638 # ----------------------
1639 # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
1640 # that executables *can* be run.
1641 ac_fn_c_try_run ()
1642 {
1643 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1644 if { { ac_try="$ac_link"
1645 case "(($ac_try" in
1646 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1647 *) ac_try_echo=$ac_try;;
1648 esac
1649 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1650 $as_echo "$ac_try_echo"; } >&5
1651 (eval "$ac_link") 2>&5
1652 ac_status=$?
1653 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1654 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
1655 { { case "(($ac_try" in
1656 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1657 *) ac_try_echo=$ac_try;;
1658 esac
1659 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1660 $as_echo "$ac_try_echo"; } >&5
1661 (eval "$ac_try") 2>&5
1662 ac_status=$?
1663 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1664 test $ac_status = 0; }; }; then :
1665 ac_retval=0
1666 else
1667 $as_echo "$as_me: program exited with status $ac_status" >&5
1668 $as_echo "$as_me: failed program was:" >&5
1669 sed 's/^/| /' conftest.$ac_ext >&5
1670
1671 ac_retval=$ac_status
1672 fi
1673 rm -rf conftest.dSYM conftest_ipa8_conftest.oo
1674 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1675 as_fn_set_status $ac_retval
1676
1677 } # ac_fn_c_try_run
1678
1679 # ac_fn_c_check_func LINENO FUNC VAR
1680 # ----------------------------------
1681 # Tests whether FUNC exists, setting the cache variable VAR accordingly
1682 ac_fn_c_check_func ()
1683 {
1684 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1685 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
1686 $as_echo_n "checking for $2... " >&6; }
1687 if eval \${$3+:} false; then :
1688 $as_echo_n "(cached) " >&6
1689 else
1690 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1691 /* end confdefs.h. */
1692 /* Define $2 to an innocuous variant, in case <limits.h> declares $2.
1693 For example, HP-UX 11i <limits.h> declares gettimeofday. */
1694 #define $2 innocuous_$2
1695
1696 /* System header to define __stub macros and hopefully few prototypes,
1697 which can conflict with char $2 (); below.
1698 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
1699 <limits.h> exists even on freestanding compilers. */
1700
1701 #ifdef __STDC__
1702 # include <limits.h>
1703 #else
1704 # include <assert.h>
1705 #endif
1706
1707 #undef $2
1708
1709 /* Override any GCC internal prototype to avoid an error.
1710 Use char because int might match the return type of a GCC
1711 builtin and then its argument prototype would still apply. */
1712 #ifdef __cplusplus
1713 extern "C"
1714 #endif
1715 char $2 ();
1716 /* The GNU C library defines this for functions which it implements
1717 to always fail with ENOSYS. Some functions are actually named
1718 something starting with __ and the normal name is an alias. */
1719 #if defined __stub_$2 || defined __stub___$2
1720 choke me
1721 #endif
1722
1723 int
1724 main ()
1725 {
1726 return $2 ();
1727 ;
1728 return 0;
1729 }
1730 _ACEOF
1731 if ac_fn_c_try_link "$LINENO"; then :
1732 eval "$3=yes"
1733 else
1734 eval "$3=no"
1735 fi
1736 rm -f core conftest.err conftest.$ac_objext \
1737 conftest$ac_exeext conftest.$ac_ext
1738 fi
1739 eval ac_res=\$$3
1740 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1741 $as_echo "$ac_res" >&6; }
1742 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1743
1744 } # ac_fn_c_check_func
1745
1746 # ac_fn_c_check_type LINENO TYPE VAR INCLUDES
1747 # -------------------------------------------
1748 # Tests whether TYPE exists after having included INCLUDES, setting cache
1749 # variable VAR accordingly.
1750 ac_fn_c_check_type ()
1751 {
1752 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1753 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
1754 $as_echo_n "checking for $2... " >&6; }
1755 if eval \${$3+:} false; then :
1756 $as_echo_n "(cached) " >&6
1757 else
1758 eval "$3=no"
1759 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1760 /* end confdefs.h. */
1761 $4
1762 int
1763 main ()
1764 {
1765 if (sizeof ($2))
1766 return 0;
1767 ;
1768 return 0;
1769 }
1770 _ACEOF
1771 if ac_fn_c_try_compile "$LINENO"; then :
1772 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1773 /* end confdefs.h. */
1774 $4
1775 int
1776 main ()
1777 {
1778 if (sizeof (($2)))
1779 return 0;
1780 ;
1781 return 0;
1782 }
1783 _ACEOF
1784 if ac_fn_c_try_compile "$LINENO"; then :
1785
1786 else
1787 eval "$3=yes"
1788 fi
1789 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1790 fi
1791 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1792 fi
1793 eval ac_res=\$$3
1794 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1795 $as_echo "$ac_res" >&6; }
1796 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1797
1798 } # ac_fn_c_check_type
1799
1800 # ac_fn_c_find_uintX_t LINENO BITS VAR
1801 # ------------------------------------
1802 # Finds an unsigned integer type with width BITS, setting cache variable VAR
1803 # accordingly.
1804 ac_fn_c_find_uintX_t ()
1805 {
1806 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1807 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5
1808 $as_echo_n "checking for uint$2_t... " >&6; }
1809 if eval \${$3+:} false; then :
1810 $as_echo_n "(cached) " >&6
1811 else
1812 eval "$3=no"
1813 # Order is important - never check a type that is potentially smaller
1814 # than half of the expected target width.
1815 for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \
1816 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
1817 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1818 /* end confdefs.h. */
1819 $ac_includes_default
1820 int
1821 main ()
1822 {
1823 static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)];
1824 test_array [0] = 0;
1825 return test_array [0];
1826
1827 ;
1828 return 0;
1829 }
1830 _ACEOF
1831 if ac_fn_c_try_compile "$LINENO"; then :
1832 case $ac_type in #(
1833 uint$2_t) :
1834 eval "$3=yes" ;; #(
1835 *) :
1836 eval "$3=\$ac_type" ;;
1837 esac
1838 fi
1839 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1840 if eval test \"x\$"$3"\" = x"no"; then :
1841
1842 else
1843 break
1844 fi
1845 done
1846 fi
1847 eval ac_res=\$$3
1848 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1849 $as_echo "$ac_res" >&6; }
1850 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1851
1852 } # ac_fn_c_find_uintX_t
1853 cat >config.log <<_ACEOF
1854 This file contains any messages produced by compilers while
1855 running configure, to aid debugging if configure makes a mistake.
1856
1857 It was created by getdns $as_me 0.1.0, which was
1858 generated by GNU Autoconf 2.69. Invocation command line was
1859
1860 $ $0 $@
1861
1862 _ACEOF
1863 exec 5>>config.log
1864 {
1865 cat <<_ASUNAME
1866 ## --------- ##
1867 ## Platform. ##
1868 ## --------- ##
1869
1870 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
1871 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1872 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1873 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1874 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1875
1876 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
1877 /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
1878
1879 /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
1880 /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
1881 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
1882 /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
1883 /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
1884 /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
1885 /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
1886
1887 _ASUNAME
1888
1889 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1890 for as_dir in $PATH
1891 do
1892 IFS=$as_save_IFS
1893 test -z "$as_dir" && as_dir=.
1894 $as_echo "PATH: $as_dir"
1895 done
1896 IFS=$as_save_IFS
1897
1898 } >&5
1899
1900 cat >&5 <<_ACEOF
1901
1902
1903 ## ----------- ##
1904 ## Core tests. ##
1905 ## ----------- ##
1906
1907 _ACEOF
1908
1909
1910 # Keep a trace of the command line.
1911 # Strip out --no-create and --no-recursion so they do not pile up.
1912 # Strip out --silent because we don't want to record it for future runs.
1913 # Also quote any args containing shell meta-characters.
1914 # Make two passes to allow for proper duplicate-argument suppression.
1915 ac_configure_args=
1916 ac_configure_args0=
1917 ac_configure_args1=
1918 ac_must_keep_next=false
1919 for ac_pass in 1 2
1920 do
1921 for ac_arg
1922 do
1923 case $ac_arg in
1924 -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
1925 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
1926 | -silent | --silent | --silen | --sile | --sil)
1927 continue ;;
1928 *\'*)
1929 ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
1930 esac
1931 case $ac_pass in
1932 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
1933 2)
1934 as_fn_append ac_configure_args1 " '$ac_arg'"
1935 if test $ac_must_keep_next = true; then
1936 ac_must_keep_next=false # Got value, back to normal.
1937 else
1938 case $ac_arg in
1939 *=* | --config-cache | -C | -disable-* | --disable-* \
1940 | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
1941 | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
1942 | -with-* | --with-* | -without-* | --without-* | --x)
1943 case "$ac_configure_args0 " in
1944 "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
1945 esac
1946 ;;
1947 -* ) ac_must_keep_next=true ;;
1948 esac
1949 fi
1950 as_fn_append ac_configure_args " '$ac_arg'"
1951 ;;
1952 esac
1953 done
1954 done
1955 { ac_configure_args0=; unset ac_configure_args0;}
1956 { ac_configure_args1=; unset ac_configure_args1;}
1957
1958 # When interrupted or exit'd, cleanup temporary files, and complete
1959 # config.log. We remove comments because anyway the quotes in there
1960 # would cause problems or look ugly.
1961 # WARNING: Use '\'' to represent an apostrophe within the trap.
1962 # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
1963 trap 'exit_status=$?
1964 # Save into config.log some information that might help in debugging.
1965 {
1966 echo
1967
1968 $as_echo "## ---------------- ##
1969 ## Cache variables. ##
1970 ## ---------------- ##"
1971 echo
1972 # The following way of writing the cache mishandles newlines in values,
1973 (
1974 for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
1975 eval ac_val=\$$ac_var
1976 case $ac_val in #(
1977 *${as_nl}*)
1978 case $ac_var in #(
1979 *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
1980 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
1981 esac
1982 case $ac_var in #(
1983 _ | IFS | as_nl) ;; #(
1984 BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
1985 *) { eval $ac_var=; unset $ac_var;} ;;
1986 esac ;;
1987 esac
1988 done
1989 (set) 2>&1 |
1990 case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
1991 *${as_nl}ac_space=\ *)
1992 sed -n \
1993 "s/'\''/'\''\\\\'\'''\''/g;
1994 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
1995 ;; #(
1996 *)
1997 sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
1998 ;;
1999 esac |
2000 sort
2001 )
2002 echo
2003
2004 $as_echo "## ----------------- ##
2005 ## Output variables. ##
2006 ## ----------------- ##"
2007 echo
2008 for ac_var in $ac_subst_vars
2009 do
2010 eval ac_val=\$$ac_var
2011 case $ac_val in
2012 *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
2013 esac
2014 $as_echo "$ac_var='\''$ac_val'\''"
2015 done | sort
2016 echo
2017
2018 if test -n "$ac_subst_files"; then
2019 $as_echo "## ------------------- ##
2020 ## File substitutions. ##
2021 ## ------------------- ##"
2022 echo
2023 for ac_var in $ac_subst_files
2024 do
2025 eval ac_val=\$$ac_var
2026 case $ac_val in
2027 *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
2028 esac
2029 $as_echo "$ac_var='\''$ac_val'\''"
2030 done | sort
2031 echo
2032 fi
2033
2034 if test -s confdefs.h; then
2035 $as_echo "## ----------- ##
2036 ## confdefs.h. ##
2037 ## ----------- ##"
2038 echo
2039 cat confdefs.h
2040 echo
2041 fi
2042 test "$ac_signal" != 0 &&
2043 $as_echo "$as_me: caught signal $ac_signal"
2044 $as_echo "$as_me: exit $exit_status"
2045 } >&5
2046 rm -f core *.core core.conftest.* &&
2047 rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
2048 exit $exit_status
2049 ' 0
2050 for ac_signal in 1 2 13 15; do
2051 trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
2052 done
2053 ac_signal=0
2054
2055 # confdefs.h avoids OS command line length limits that DEFS can exceed.
2056 rm -f -r conftest* confdefs.h
2057
2058 $as_echo "/* confdefs.h */" > confdefs.h
2059
2060 # Predefined preprocessor variables.
2061
2062 cat >>confdefs.h <<_ACEOF
2063 #define PACKAGE_NAME "$PACKAGE_NAME"
2064 _ACEOF
2065
2066 cat >>confdefs.h <<_ACEOF
2067 #define PACKAGE_TARNAME "$PACKAGE_TARNAME"
2068 _ACEOF
2069
2070 cat >>confdefs.h <<_ACEOF
2071 #define PACKAGE_VERSION "$PACKAGE_VERSION"
2072 _ACEOF
2073
2074 cat >>confdefs.h <<_ACEOF
2075 #define PACKAGE_STRING "$PACKAGE_STRING"
2076 _ACEOF
2077
2078 cat >>confdefs.h <<_ACEOF
2079 #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
2080 _ACEOF
2081
2082 cat >>confdefs.h <<_ACEOF
2083 #define PACKAGE_URL "$PACKAGE_URL"
2084 _ACEOF
2085
2086
2087 # Let the site file select an alternate cache file if it wants to.
2088 # Prefer an explicitly selected file to automatically selected ones.
2089 ac_site_file1=NONE
2090 ac_site_file2=NONE
2091 if test -n "$CONFIG_SITE"; then
2092 # We do not want a PATH search for config.site.
2093 case $CONFIG_SITE in #((
2094 -*) ac_site_file1=./$CONFIG_SITE;;
2095 */*) ac_site_file1=$CONFIG_SITE;;
2096 *) ac_site_file1=./$CONFIG_SITE;;
2097 esac
2098 elif test "x$prefix" != xNONE; then
2099 ac_site_file1=$prefix/share/config.site
2100 ac_site_file2=$prefix/etc/config.site
2101 else
2102 ac_site_file1=$ac_default_prefix/share/config.site
2103 ac_site_file2=$ac_default_prefix/etc/config.site
2104 fi
2105 for ac_site_file in "$ac_site_file1" "$ac_site_file2"
2106 do
2107 test "x$ac_site_file" = xNONE && continue
2108 if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
2109 { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
2110 $as_echo "$as_me: loading site script $ac_site_file" >&6;}
2111 sed 's/^/| /' "$ac_site_file" >&5
2112 . "$ac_site_file" \
2113 || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2114 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2115 as_fn_error $? "failed to load site script $ac_site_file
2116 See \`config.log' for more details" "$LINENO" 5; }
2117 fi
2118 done
2119
2120 if test -r "$cache_file"; then
2121 # Some versions of bash will fail to source /dev/null (special files
2122 # actually), so we avoid doing that. DJGPP emulates it as a regular file.
2123 if test /dev/null != "$cache_file" && test -f "$cache_file"; then
2124 { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
2125 $as_echo "$as_me: loading cache $cache_file" >&6;}
2126 case $cache_file in
2127 [\\/]* | ?:[\\/]* ) . "$cache_file";;
2128 *) . "./$cache_file";;
2129 esac
2130 fi
2131 else
2132 { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
2133 $as_echo "$as_me: creating cache $cache_file" >&6;}
2134 >$cache_file
2135 fi
2136
2137 # Check that the precious variables saved in the cache have kept the same
2138 # value.
2139 ac_cache_corrupted=false
2140 for ac_var in $ac_precious_vars; do
2141 eval ac_old_set=\$ac_cv_env_${ac_var}_set
2142 eval ac_new_set=\$ac_env_${ac_var}_set
2143 eval ac_old_val=\$ac_cv_env_${ac_var}_value
2144 eval ac_new_val=\$ac_env_${ac_var}_value
2145 case $ac_old_set,$ac_new_set in
2146 set,)
2147 { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
2148 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
2149 ac_cache_corrupted=: ;;
2150 ,set)
2151 { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
2152 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
2153 ac_cache_corrupted=: ;;
2154 ,);;
2155 *)
2156 if test "x$ac_old_val" != "x$ac_new_val"; then
2157 # differences in whitespace do not lead to failure.
2158 ac_old_val_w=`echo x $ac_old_val`
2159 ac_new_val_w=`echo x $ac_new_val`
2160 if test "$ac_old_val_w" != "$ac_new_val_w"; then
2161 { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
2162 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
2163 ac_cache_corrupted=:
2164 else
2165 { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
2166 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
2167 eval $ac_var=\$ac_old_val
2168 fi
2169 { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
2170 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
2171 { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
2172 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
2173 fi;;
2174 esac
2175 # Pass precious variables to config.status.
2176 if test "$ac_new_set" = set; then
2177 case $ac_new_val in
2178 *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
2179 *) ac_arg=$ac_var=$ac_new_val ;;
2180 esac
2181 case " $ac_configure_args " in
2182 *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
2183 *) as_fn_append ac_configure_args " '$ac_arg'" ;;
2184 esac
2185 fi
2186 done
2187 if $ac_cache_corrupted; then
2188 { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2189 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2190 { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
2191 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
2192 as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
2193 fi
2194 ## -------------------- ##
2195 ## Main body of script. ##
2196 ## -------------------- ##
2197
2198 ac_ext=c
2199 ac_cpp='$CPP $CPPFLAGS'
2200 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
2201 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
2202 ac_compiler_gnu=$ac_cv_c_compiler_gnu
2203
2204
2205 CURRENT_DATE=`LC_ALL=C date`
2206 GETDNS_COMPILATION_COMMENT="getdns 0.1.0 configured on $CURRENT_DATE for the February 2014 version of the API"
2207
2208
2209 # AM_INIT_AUTOMAKE
2210 # LT_INIT
2211
2212
2213 ac_ext=c
2214 ac_cpp='$CPP $CPPFLAGS'
2215 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
2216 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
2217 ac_compiler_gnu=$ac_cv_c_compiler_gnu
2218 if test -n "$ac_tool_prefix"; then
2219 # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
2220 set dummy ${ac_tool_prefix}gcc; ac_word=$2
2221 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2222 $as_echo_n "checking for $ac_word... " >&6; }
2223 if ${ac_cv_prog_CC+:} false; then :
2224 $as_echo_n "(cached) " >&6
2225 else
2226 if test -n "$CC"; then
2227 ac_cv_prog_CC="$CC" # Let the user override the test.
2228 else
2229 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2230 for as_dir in $PATH
2231 do
2232 IFS=$as_save_IFS
2233 test -z "$as_dir" && as_dir=.
2234 for ac_exec_ext in '' $ac_executable_extensions; do
2235 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2236 ac_cv_prog_CC="${ac_tool_prefix}gcc"
2237 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2238 break 2
2239 fi
2240 done
2241 done
2242 IFS=$as_save_IFS
2243
2244 fi
2245 fi
2246 CC=$ac_cv_prog_CC
2247 if test -n "$CC"; then
2248 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
2249 $as_echo "$CC" >&6; }
2250 else
2251 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2252 $as_echo "no" >&6; }
2253 fi
2254
2255
2256 fi
2257 if test -z "$ac_cv_prog_CC"; then
2258 ac_ct_CC=$CC
2259 # Extract the first word of "gcc", so it can be a program name with args.
2260 set dummy gcc; ac_word=$2
2261 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2262 $as_echo_n "checking for $ac_word... " >&6; }
2263 if ${ac_cv_prog_ac_ct_CC+:} false; then :
2264 $as_echo_n "(cached) " >&6
2265 else
2266 if test -n "$ac_ct_CC"; then
2267 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
2268 else
2269 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2270 for as_dir in $PATH
2271 do
2272 IFS=$as_save_IFS
2273 test -z "$as_dir" && as_dir=.
2274 for ac_exec_ext in '' $ac_executable_extensions; do
2275 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2276 ac_cv_prog_ac_ct_CC="gcc"
2277 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2278 break 2
2279 fi
2280 done
2281 done
2282 IFS=$as_save_IFS
2283
2284 fi
2285 fi
2286 ac_ct_CC=$ac_cv_prog_ac_ct_CC
2287 if test -n "$ac_ct_CC"; then
2288 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
2289 $as_echo "$ac_ct_CC" >&6; }
2290 else
2291 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2292 $as_echo "no" >&6; }
2293 fi
2294
2295 if test "x$ac_ct_CC" = x; then
2296 CC=""
2297 else
2298 case $cross_compiling:$ac_tool_warned in
2299 yes:)
2300 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
2301 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
2302 ac_tool_warned=yes ;;
2303 esac
2304 CC=$ac_ct_CC
2305 fi
2306 else
2307 CC="$ac_cv_prog_CC"
2308 fi
2309
2310 if test -z "$CC"; then
2311 if test -n "$ac_tool_prefix"; then
2312 # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
2313 set dummy ${ac_tool_prefix}cc; ac_word=$2
2314 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2315 $as_echo_n "checking for $ac_word... " >&6; }
2316 if ${ac_cv_prog_CC+:} false; then :
2317 $as_echo_n "(cached) " >&6
2318 else
2319 if test -n "$CC"; then
2320 ac_cv_prog_CC="$CC" # Let the user override the test.
2321 else
2322 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2323 for as_dir in $PATH
2324 do
2325 IFS=$as_save_IFS
2326 test -z "$as_dir" && as_dir=.
2327 for ac_exec_ext in '' $ac_executable_extensions; do
2328 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2329 ac_cv_prog_CC="${ac_tool_prefix}cc"
2330 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2331 break 2
2332 fi
2333 done
2334 done
2335 IFS=$as_save_IFS
2336
2337 fi
2338 fi
2339 CC=$ac_cv_prog_CC
2340 if test -n "$CC"; then
2341 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
2342 $as_echo "$CC" >&6; }
2343 else
2344 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2345 $as_echo "no" >&6; }
2346 fi
2347
2348
2349 fi
2350 fi
2351 if test -z "$CC"; then
2352 # Extract the first word of "cc", so it can be a program name with args.
2353 set dummy cc; ac_word=$2
2354 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2355 $as_echo_n "checking for $ac_word... " >&6; }
2356 if ${ac_cv_prog_CC+:} false; then :
2357 $as_echo_n "(cached) " >&6
2358 else
2359 if test -n "$CC"; then
2360 ac_cv_prog_CC="$CC" # Let the user override the test.
2361 else
2362 ac_prog_rejected=no
2363 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2364 for as_dir in $PATH
2365 do
2366 IFS=$as_save_IFS
2367 test -z "$as_dir" && as_dir=.
2368 for ac_exec_ext in '' $ac_executable_extensions; do
2369 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2370 if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
2371 ac_prog_rejected=yes
2372 continue
2373 fi
2374 ac_cv_prog_CC="cc"
2375 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2376 break 2
2377 fi
2378 done
2379 done
2380 IFS=$as_save_IFS
2381
2382 if test $ac_prog_rejected = yes; then
2383 # We found a bogon in the path, so make sure we never use it.
2384 set dummy $ac_cv_prog_CC
2385 shift
2386 if test $# != 0; then
2387 # We chose a different compiler from the bogus one.
2388 # However, it has the same basename, so the bogon will be chosen
2389 # first if we set CC to just the basename; use the full file name.
2390 shift
2391 ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
2392 fi
2393 fi
2394 fi
2395 fi
2396 CC=$ac_cv_prog_CC
2397 if test -n "$CC"; then
2398 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
2399 $as_echo "$CC" >&6; }
2400 else
2401 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2402 $as_echo "no" >&6; }
2403 fi
2404
2405
2406 fi
2407 if test -z "$CC"; then
2408 if test -n "$ac_tool_prefix"; then
2409 for ac_prog in cl.exe
2410 do
2411 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
2412 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
2413 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2414 $as_echo_n "checking for $ac_word... " >&6; }
2415 if ${ac_cv_prog_CC+:} false; then :
2416 $as_echo_n "(cached) " >&6
2417 else
2418 if test -n "$CC"; then
2419 ac_cv_prog_CC="$CC" # Let the user override the test.
2420 else
2421 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2422 for as_dir in $PATH
2423 do
2424 IFS=$as_save_IFS
2425 test -z "$as_dir" && as_dir=.
2426 for ac_exec_ext in '' $ac_executable_extensions; do
2427 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2428 ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
2429 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2430 break 2
2431 fi
2432 done
2433 done
2434 IFS=$as_save_IFS
2435
2436 fi
2437 fi
2438 CC=$ac_cv_prog_CC
2439 if test -n "$CC"; then
2440 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
2441 $as_echo "$CC" >&6; }
2442 else
2443 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2444 $as_echo "no" >&6; }
2445 fi
2446
2447
2448 test -n "$CC" && break
2449 done
2450 fi
2451 if test -z "$CC"; then
2452 ac_ct_CC=$CC
2453 for ac_prog in cl.exe
2454 do
2455 # Extract the first word of "$ac_prog", so it can be a program name with args.
2456 set dummy $ac_prog; ac_word=$2
2457 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2458 $as_echo_n "checking for $ac_word... " >&6; }
2459 if ${ac_cv_prog_ac_ct_CC+:} false; then :
2460 $as_echo_n "(cached) " >&6
2461 else
2462 if test -n "$ac_ct_CC"; then
2463 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
2464 else
2465 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2466 for as_dir in $PATH
2467 do
2468 IFS=$as_save_IFS
2469 test -z "$as_dir" && as_dir=.
2470 for ac_exec_ext in '' $ac_executable_extensions; do
2471 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2472 ac_cv_prog_ac_ct_CC="$ac_prog"
2473 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2474 break 2
2475 fi
2476 done
2477 done
2478 IFS=$as_save_IFS
2479
2480 fi
2481 fi
2482 ac_ct_CC=$ac_cv_prog_ac_ct_CC
2483 if test -n "$ac_ct_CC"; then
2484 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
2485 $as_echo "$ac_ct_CC" >&6; }
2486 else
2487 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2488 $as_echo "no" >&6; }
2489 fi
2490
2491
2492 test -n "$ac_ct_CC" && break
2493 done
2494
2495 if test "x$ac_ct_CC" = x; then
2496 CC=""
2497 else
2498 case $cross_compiling:$ac_tool_warned in
2499 yes:)
2500 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
2501 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
2502 ac_tool_warned=yes ;;
2503 esac
2504 CC=$ac_ct_CC
2505 fi
2506 fi
2507
2508 fi
2509
2510
2511 test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2512 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2513 as_fn_error $? "no acceptable C compiler found in \$PATH
2514 See \`config.log' for more details" "$LINENO" 5; }
2515
2516 # Provide some information about the compiler.
2517 $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
2518 set X $ac_compile
2519 ac_compiler=$2
2520 for ac_option in --version -v -V -qversion; do
2521 { { ac_try="$ac_compiler $ac_option >&5"
2522 case "(($ac_try" in
2523 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2524 *) ac_try_echo=$ac_try;;
2525 esac
2526 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
2527 $as_echo "$ac_try_echo"; } >&5
2528 (eval "$ac_compiler $ac_option >&5") 2>conftest.err
2529 ac_status=$?
2530 if test -s conftest.err; then
2531 sed '10a\
2532 ... rest of stderr output deleted ...
2533 10q' conftest.err >conftest.er1
2534 cat conftest.er1 >&5
2535 fi
2536 rm -f conftest.er1 conftest.err
2537 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2538 test $ac_status = 0; }
2539 done
2540
2541 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2542 /* end confdefs.h. */
2543
2544 int
2545 main ()
2546 {
2547
2548 ;
2549 return 0;
2550 }
2551 _ACEOF
2552 ac_clean_files_save=$ac_clean_files
2553 ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
2554 # Try to create an executable without -o first, disregard a.out.
2555 # It will help us diagnose broken compilers, and finding out an intuition
2556 # of exeext.
2557 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
2558 $as_echo_n "checking whether the C compiler works... " >&6; }
2559 ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
2560
2561 # The possible output files:
2562 ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
2563
2564 ac_rmfiles=
2565 for ac_file in $ac_files
2566 do
2567 case $ac_file in
2568 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
2569 * ) ac_rmfiles="$ac_rmfiles $ac_file";;
2570 esac
2571 done
2572 rm -f $ac_rmfiles
2573
2574 if { { ac_try="$ac_link_default"
2575 case "(($ac_try" in
2576 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2577 *) ac_try_echo=$ac_try;;
2578 esac
2579 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
2580 $as_echo "$ac_try_echo"; } >&5
2581 (eval "$ac_link_default") 2>&5
2582 ac_status=$?
2583 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2584 test $ac_status = 0; }; then :
2585 # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
2586 # So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
2587 # in a Makefile. We should not override ac_cv_exeext if it was cached,
2588 # so that the user can short-circuit this test for compilers unknown to
2589 # Autoconf.
2590 for ac_file in $ac_files ''
2591 do
2592 test -f "$ac_file" || continue
2593 case $ac_file in
2594 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
2595 ;;
2596 [ab].out )
2597 # We found the default executable, but exeext='' is most
2598 # certainly right.
2599 break;;
2600 *.* )
2601 if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
2602 then :; else
2603 ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
2604 fi
2605 # We set ac_cv_exeext here because the later test for it is not
2606 # safe: cross compilers may not add the suffix if given an `-o'
2607 # argument, so we may need to know it at that point already.
2608 # Even if this section looks crufty: it has the advantage of
2609 # actually working.
2610 break;;
2611 * )
2612 break;;
2613 esac
2614 done
2615 test "$ac_cv_exeext" = no && ac_cv_exeext=
2616
2617 else
2618 ac_file=''
2619 fi
2620 if test -z "$ac_file"; then :
2621 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2622 $as_echo "no" >&6; }
2623 $as_echo "$as_me: failed program was:" >&5
2624 sed 's/^/| /' conftest.$ac_ext >&5
2625
2626 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2627 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2628 as_fn_error 77 "C compiler cannot create executables
2629 See \`config.log' for more details" "$LINENO" 5; }
2630 else
2631 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
2632 $as_echo "yes" >&6; }
2633 fi
2634 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
2635 $as_echo_n "checking for C compiler default output file name... " >&6; }
2636 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
2637 $as_echo "$ac_file" >&6; }
2638 ac_exeext=$ac_cv_exeext
2639
2640 rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
2641 ac_clean_files=$ac_clean_files_save
2642 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
2643 $as_echo_n "checking for suffix of executables... " >&6; }
2644 if { { ac_try="$ac_link"
2645 case "(($ac_try" in
2646 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2647 *) ac_try_echo=$ac_try;;
2648 esac
2649 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
2650 $as_echo "$ac_try_echo"; } >&5
2651 (eval "$ac_link") 2>&5
2652 ac_status=$?
2653 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2654 test $ac_status = 0; }; then :
2655 # If both `conftest.exe' and `conftest' are `present' (well, observable)
2656 # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
2657 # work properly (i.e., refer to `conftest.exe'), while it won't with
2658 # `rm'.
2659 for ac_file in conftest.exe conftest conftest.*; do
2660 test -f "$ac_file" || continue
2661 case $ac_file in
2662 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
2663 *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
2664 break;;
2665 * ) break;;
2666 esac
2667 done
2668 else
2669 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2670 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2671 as_fn_error $? "cannot compute suffix of executables: cannot compile and link
2672 See \`config.log' for more details" "$LINENO" 5; }
2673 fi
2674 rm -f conftest conftest$ac_cv_exeext
2675 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
2676 $as_echo "$ac_cv_exeext" >&6; }
2677
2678 rm -f conftest.$ac_ext
2679 EXEEXT=$ac_cv_exeext
2680 ac_exeext=$EXEEXT
2681 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2682 /* end confdefs.h. */
2683 #include <stdio.h>
2684 int
2685 main ()
2686 {
2687 FILE *f = fopen ("conftest.out", "w");
2688 return ferror (f) || fclose (f) != 0;
2689
2690 ;
2691 return 0;
2692 }
2693 _ACEOF
2694 ac_clean_files="$ac_clean_files conftest.out"
2695 # Check that the compiler produces executables we can run. If not, either
2696 # the compiler is broken, or we cross compile.
2697 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
2698 $as_echo_n "checking whether we are cross compiling... " >&6; }
2699 if test "$cross_compiling" != yes; then
2700 { { ac_try="$ac_link"
2701 case "(($ac_try" in
2702 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2703 *) ac_try_echo=$ac_try;;
2704 esac
2705 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
2706 $as_echo "$ac_try_echo"; } >&5
2707 (eval "$ac_link") 2>&5
2708 ac_status=$?
2709 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2710 test $ac_status = 0; }
2711 if { ac_try='./conftest$ac_cv_exeext'
2712 { { case "(($ac_try" in
2713 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2714 *) ac_try_echo=$ac_try;;
2715 esac
2716 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
2717 $as_echo "$ac_try_echo"; } >&5
2718 (eval "$ac_try") 2>&5
2719 ac_status=$?
2720 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2721 test $ac_status = 0; }; }; then
2722 cross_compiling=no
2723 else
2724 if test "$cross_compiling" = maybe; then
2725 cross_compiling=yes
2726 else
2727 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2728 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2729 as_fn_error $? "cannot run C compiled programs.
2730 If you meant to cross compile, use \`--host'.
2731 See \`config.log' for more details" "$LINENO" 5; }
2732 fi
2733 fi
2734 fi
2735 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
2736 $as_echo "$cross_compiling" >&6; }
2737
2738 rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
2739 ac_clean_files=$ac_clean_files_save
2740 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
2741 $as_echo_n "checking for suffix of object files... " >&6; }
2742 if ${ac_cv_objext+:} false; then :
2743 $as_echo_n "(cached) " >&6
2744 else
2745 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2746 /* end confdefs.h. */
2747
2748 int
2749 main ()
2750 {
2751
2752 ;
2753 return 0;
2754 }
2755 _ACEOF
2756 rm -f conftest.o conftest.obj
2757 if { { ac_try="$ac_compile"
2758 case "(($ac_try" in
2759 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2760 *) ac_try_echo=$ac_try;;
2761 esac
2762 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
2763 $as_echo "$ac_try_echo"; } >&5
2764 (eval "$ac_compile") 2>&5
2765 ac_status=$?
2766 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
2767 test $ac_status = 0; }; then :
2768 for ac_file in conftest.o conftest.obj conftest.*; do
2769 test -f "$ac_file" || continue;
2770 case $ac_file in
2771 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
2772 *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
2773 break;;
2774 esac
2775 done
2776 else
2777 $as_echo "$as_me: failed program was:" >&5
2778 sed 's/^/| /' conftest.$ac_ext >&5
2779
2780 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2781 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2782 as_fn_error $? "cannot compute suffix of object files: cannot compile
2783 See \`config.log' for more details" "$LINENO" 5; }
2784 fi
2785 rm -f conftest.$ac_cv_objext conftest.$ac_ext
2786 fi
2787 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
2788 $as_echo "$ac_cv_objext" >&6; }
2789 OBJEXT=$ac_cv_objext
2790 ac_objext=$OBJEXT
2791 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
2792 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
2793 if ${ac_cv_c_compiler_gnu+:} false; then :
2794 $as_echo_n "(cached) " >&6
2795 else
2796 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2797 /* end confdefs.h. */
2798
2799 int
2800 main ()
2801 {
2802 #ifndef __GNUC__
2803 choke me
2804 #endif
2805
2806 ;
2807 return 0;
2808 }
2809 _ACEOF
2810 if ac_fn_c_try_compile "$LINENO"; then :
2811 ac_compiler_gnu=yes
2812 else
2813 ac_compiler_gnu=no
2814 fi
2815 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
2816 ac_cv_c_compiler_gnu=$ac_compiler_gnu
2817
2818 fi
2819 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
2820 $as_echo "$ac_cv_c_compiler_gnu" >&6; }
2821 if test $ac_compiler_gnu = yes; then
2822 GCC=yes
2823 else
2824 GCC=
2825 fi
2826 ac_test_CFLAGS=${CFLAGS+set}
2827 ac_save_CFLAGS=$CFLAGS
2828 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
2829 $as_echo_n "checking whether $CC accepts -g... " >&6; }
2830 if ${ac_cv_prog_cc_g+:} false; then :
2831 $as_echo_n "(cached) " >&6
2832 else
2833 ac_save_c_werror_flag=$ac_c_werror_flag
2834 ac_c_werror_flag=yes
2835 ac_cv_prog_cc_g=no
2836 CFLAGS="-g"
2837 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2838 /* end confdefs.h. */
2839
2840 int
2841 main ()
2842 {
2843
2844 ;
2845 return 0;
2846 }
2847 _ACEOF
2848 if ac_fn_c_try_compile "$LINENO"; then :
2849 ac_cv_prog_cc_g=yes
2850 else
2851 CFLAGS=""
2852 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2853 /* end confdefs.h. */
2854
2855 int
2856 main ()
2857 {
2858
2859 ;
2860 return 0;
2861 }
2862 _ACEOF
2863 if ac_fn_c_try_compile "$LINENO"; then :
2864
2865 else
2866 ac_c_werror_flag=$ac_save_c_werror_flag
2867 CFLAGS="-g"
2868 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2869 /* end confdefs.h. */
2870
2871 int
2872 main ()
2873 {
2874
2875 ;
2876 return 0;
2877 }
2878 _ACEOF
2879 if ac_fn_c_try_compile "$LINENO"; then :
2880 ac_cv_prog_cc_g=yes
2881 fi
2882 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
2883 fi
2884 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
2885 fi
2886 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
2887 ac_c_werror_flag=$ac_save_c_werror_flag
2888 fi
2889 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
2890 $as_echo "$ac_cv_prog_cc_g" >&6; }
2891 if test "$ac_test_CFLAGS" = set; then
2892 CFLAGS=$ac_save_CFLAGS
2893 elif test $ac_cv_prog_cc_g = yes; then
2894 if test "$GCC" = yes; then
2895 CFLAGS="-g -O2"
2896 else
2897 CFLAGS="-g"
2898 fi
2899 else
2900 if test "$GCC" = yes; then
2901 CFLAGS="-O2"
2902 else
2903 CFLAGS=
2904 fi
2905 fi
2906 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
2907 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
2908 if ${ac_cv_prog_cc_c89+:} false; then :
2909 $as_echo_n "(cached) " >&6
2910 else
2911 ac_cv_prog_cc_c89=no
2912 ac_save_CC=$CC
2913 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
2914 /* end confdefs.h. */
2915 #include <stdarg.h>
2916 #include <stdio.h>
2917 struct stat;
2918 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
2919 struct buf { int x; };
2920 FILE * (*rcsopen) (struct buf *, struct stat *, int);
2921 static char *e (p, i)
2922 char **p;
2923 int i;
2924 {
2925 return p[i];
2926 }
2927 static char *f (char * (*g) (char **, int), char **p, ...)
2928 {
2929 char *s;
2930 va_list v;
2931 va_start (v,p);
2932 s = g (p, va_arg (v,int));
2933 va_end (v);
2934 return s;
2935 }
2936
2937 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
2938 function prototypes and stuff, but not '\xHH' hex character constants.
2939 These don't provoke an error unfortunately, instead are silently treated
2940 as 'x'. The following induces an error, until -std is added to get
2941 proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
2942 array size at least. It's necessary to write '\x00'==0 to get something
2943 that's true only with -std. */
2944 int osf4_cc_array ['\x00' == 0 ? 1 : -1];
2945
2946 /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
2947 inside strings and character constants. */
2948 #define FOO(x) 'x'
2949 int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
2950
2951 int test (int i, double x);
2952 struct s1 {int (*f) (int a);};
2953 struct s2 {int (*f) (double a);};
2954 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
2955 int argc;
2956 char **argv;
2957 int
2958 main ()
2959 {
2960 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
2961 ;
2962 return 0;
2963 }
2964 _ACEOF
2965 for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
2966 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
2967 do
2968 CC="$ac_save_CC $ac_arg"
2969 if ac_fn_c_try_compile "$LINENO"; then :
2970 ac_cv_prog_cc_c89=$ac_arg
2971 fi
2972 rm -f core conftest.err conftest.$ac_objext
2973 test "x$ac_cv_prog_cc_c89" != "xno" && break
2974 done
2975 rm -f conftest.$ac_ext
2976 CC=$ac_save_CC
2977
2978 fi
2979 # AC_CACHE_VAL
2980 case "x$ac_cv_prog_cc_c89" in
2981 x)
2982 { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
2983 $as_echo "none needed" >&6; } ;;
2984 xno)
2985 { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
2986 $as_echo "unsupported" >&6; } ;;
2987 *)
2988 CC="$CC $ac_cv_prog_cc_c89"
2989 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
2990 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
2991 esac
2992 if test "x$ac_cv_prog_cc_c89" != xno; then :
2993
2994 fi
2995
2996 ac_ext=c
2997 ac_cpp='$CPP $CPPFLAGS'
2998 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
2999 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3000 ac_compiler_gnu=$ac_cv_c_compiler_gnu
3001
3002 ac_ext=c
3003 ac_cpp='$CPP $CPPFLAGS'
3004 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
3005 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3006 ac_compiler_gnu=$ac_cv_c_compiler_gnu
3007 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
3008 $as_echo_n "checking how to run the C preprocessor... " >&6; }
3009 # On Suns, sometimes $CPP names a directory.
3010 if test -n "$CPP" && test -d "$CPP"; then
3011 CPP=
3012 fi
3013 if test -z "$CPP"; then
3014 if ${ac_cv_prog_CPP+:} false; then :
3015 $as_echo_n "(cached) " >&6
3016 else
3017 # Double quotes because CPP needs to be expanded
3018 for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
3019 do
3020 ac_preproc_ok=false
3021 for ac_c_preproc_warn_flag in '' yes
3022 do
3023 # Use a header file that comes with gcc, so configuring glibc
3024 # with a fresh cross-compiler works.
3025 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
3026 # <limits.h> exists even on freestanding compilers.
3027 # On the NeXT, cc -E runs the code through the compiler's parser,
3028 # not just through cpp. "Syntax error" is here to catch this case.
3029 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3030 /* end confdefs.h. */
3031 #ifdef __STDC__
3032 # include <limits.h>
3033 #else
3034 # include <assert.h>
3035 #endif
3036 Syntax error
3037 _ACEOF
3038 if ac_fn_c_try_cpp "$LINENO"; then :
3039
3040 else
3041 # Broken: fails on valid input.
3042 continue
3043 fi
3044 rm -f conftest.err conftest.i conftest.$ac_ext
3045
3046 # OK, works on sane cases. Now check whether nonexistent headers
3047 # can be detected and how.
3048 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3049 /* end confdefs.h. */
3050 #include <ac_nonexistent.h>
3051 _ACEOF
3052 if ac_fn_c_try_cpp "$LINENO"; then :
3053 # Broken: success on invalid input.
3054 continue
3055 else
3056 # Passes both tests.
3057 ac_preproc_ok=:
3058 break
3059 fi
3060 rm -f conftest.err conftest.i conftest.$ac_ext
3061
3062 done
3063 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
3064 rm -f conftest.i conftest.err conftest.$ac_ext
3065 if $ac_preproc_ok; then :
3066 break
3067 fi
3068
3069 done
3070 ac_cv_prog_CPP=$CPP
3071
3072 fi
3073 CPP=$ac_cv_prog_CPP
3074 else
3075 ac_cv_prog_CPP=$CPP
3076 fi
3077 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
3078 $as_echo "$CPP" >&6; }
3079 ac_preproc_ok=false
3080 for ac_c_preproc_warn_flag in '' yes
3081 do
3082 # Use a header file that comes with gcc, so configuring glibc
3083 # with a fresh cross-compiler works.
3084 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
3085 # <limits.h> exists even on freestanding compilers.
3086 # On the NeXT, cc -E runs the code through the compiler's parser,
3087 # not just through cpp. "Syntax error" is here to catch this case.
3088 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3089 /* end confdefs.h. */
3090 #ifdef __STDC__
3091 # include <limits.h>
3092 #else
3093 # include <assert.h>
3094 #endif
3095 Syntax error
3096 _ACEOF
3097 if ac_fn_c_try_cpp "$LINENO"; then :
3098
3099 else
3100 # Broken: fails on valid input.
3101 continue
3102 fi
3103 rm -f conftest.err conftest.i conftest.$ac_ext
3104
3105 # OK, works on sane cases. Now check whether nonexistent headers
3106 # can be detected and how.
3107 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3108 /* end confdefs.h. */
3109 #include <ac_nonexistent.h>
3110 _ACEOF
3111 if ac_fn_c_try_cpp "$LINENO"; then :
3112 # Broken: success on invalid input.
3113 continue
3114 else
3115 # Passes both tests.
3116 ac_preproc_ok=:
3117 break
3118 fi
3119 rm -f conftest.err conftest.i conftest.$ac_ext
3120
3121 done
3122 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
3123 rm -f conftest.i conftest.err conftest.$ac_ext
3124 if $ac_preproc_ok; then :
3125
3126 else
3127 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
3128 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3129 as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
3130 See \`config.log' for more details" "$LINENO" 5; }
3131 fi
3132
3133 ac_ext=c
3134 ac_cpp='$CPP $CPPFLAGS'
3135 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
3136 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3137 ac_compiler_gnu=$ac_cv_c_compiler_gnu
3138
3139
3140 # Checks for programs.
3141 ac_aux_dir=
3142 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
3143 if test -f "$ac_dir/install-sh"; then
3144 ac_aux_dir=$ac_dir
3145 ac_install_sh="$ac_aux_dir/install-sh -c"
3146 break
3147 elif test -f "$ac_dir/install.sh"; then
3148 ac_aux_dir=$ac_dir
3149 ac_install_sh="$ac_aux_dir/install.sh -c"
3150 break
3151 elif test -f "$ac_dir/shtool"; then
3152 ac_aux_dir=$ac_dir
3153 ac_install_sh="$ac_aux_dir/shtool install -c"
3154 break
3155 fi
3156 done
3157 if test -z "$ac_aux_dir"; then
3158 as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
3159 fi
3160
3161 # These three variables are undocumented and unsupported,
3162 # and are intended to be withdrawn in a future Autoconf release.
3163 # They can cause serious problems if a builder's source tree is in a directory
3164 # whose full name contains unusual characters.
3165 ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
3166 ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
3167 ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
3168
3169
3170 # Make sure we can run config.sub.
3171 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
3172 as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
3173
3174 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
3175 $as_echo_n "checking build system type... " >&6; }
3176 if ${ac_cv_build+:} false; then :
3177 $as_echo_n "(cached) " >&6
3178 else
3179 ac_build_alias=$build_alias
3180 test "x$ac_build_alias" = x &&
3181 ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
3182 test "x$ac_build_alias" = x &&
3183 as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
3184 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
3185 as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
3186
3187 fi
3188 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
3189 $as_echo "$ac_cv_build" >&6; }
3190 case $ac_cv_build in
3191 *-*-*) ;;
3192 *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
3193 esac
3194 build=$ac_cv_build
3195 ac_save_IFS=$IFS; IFS='-'
3196 set x $ac_cv_build
3197 shift
3198 build_cpu=$1
3199 build_vendor=$2
3200 shift; shift
3201 # Remember, the first character of IFS is used to create $*,
3202 # except with old shells:
3203 build_os=$*
3204 IFS=$ac_save_IFS
3205 case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
3206
3207
3208 { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
3209 $as_echo_n "checking host system type... " >&6; }
3210 if ${ac_cv_host+:} false; then :
3211 $as_echo_n "(cached) " >&6
3212 else
3213 if test "x$host_alias" = x; then
3214 ac_cv_host=$ac_cv_build
3215 else
3216 ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
3217 as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
3218 fi
3219
3220 fi
3221 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
3222 $as_echo "$ac_cv_host" >&6; }
3223 case $ac_cv_host in
3224 *-*-*) ;;
3225 *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
3226 esac
3227 host=$ac_cv_host
3228 ac_save_IFS=$IFS; IFS='-'
3229 set x $ac_cv_host
3230 shift
3231 host_cpu=$1
3232 host_vendor=$2
3233 shift; shift
3234 # Remember, the first character of IFS is used to create $*,
3235 # except with old shells:
3236 host_os=$*
3237 IFS=$ac_save_IFS
3238 case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
3239
3240
3241 case "$host_os" in
3242 linux* ) CFLAGS="$CFLAGS -D_XOPEN_SOURCE=501" # unfortunate, but needed to
3243 # pick up strdup() declaration
3244 # in <string.h>
3245 ;;
3246 solaris* ) CFLAGS="$CFLAGS -D__EXTENSIONS__" # for strdup() from <string.h>
3247 ;;
3248 esac
3249
3250 # always use ./libtool unless override from commandline (libtool=mylibtool)
3251 if test -z "$libtool"; then
3252 libtool="`pwd`/libtool"
3253 fi
3254
3255 case `pwd` in
3256 *\ * | *\ *)
3257 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
3258 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
3259 esac
3260
3261
3262
3263 macro_version='2.4.2'
3264 macro_revision='1.3337'
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278 ltmain="$ac_aux_dir/ltmain.sh"
3279
3280 # Backslashify metacharacters that are still active within
3281 # double-quoted strings.
3282 sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
3283
3284 # Same as above, but do not quote variable references.
3285 double_quote_subst='s/\(["`\\]\)/\\\1/g'
3286
3287 # Sed substitution to delay expansion of an escaped shell variable in a
3288 # double_quote_subst'ed string.
3289 delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
3290
3291 # Sed substitution to delay expansion of an escaped single quote.
3292 delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
3293
3294 # Sed substitution to avoid accidental globbing in evaled expressions
3295 no_glob_subst='s/\*/\\\*/g'
3296
3297 ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
3298 ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
3299 ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
3300
3301 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
3302 $as_echo_n "checking how to print strings... " >&6; }
3303 # Test print first, because it will be a builtin if present.
3304 if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
3305 test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
3306 ECHO='print -r --'
3307 elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
3308 ECHO='printf %s\n'
3309 else
3310 # Use this function as a fallback that always works.
3311 func_fallback_echo ()
3312 {
3313 eval 'cat <<_LTECHO_EOF
3314 $1
3315 _LTECHO_EOF'
3316 }
3317 ECHO='func_fallback_echo'
3318 fi
3319
3320 # func_echo_all arg...
3321 # Invoke $ECHO with all args, space-separated.
3322 func_echo_all ()
3323 {
3324 $ECHO ""
3325 }
3326
3327 case "$ECHO" in
3328 printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
3329 $as_echo "printf" >&6; } ;;
3330 print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
3331 $as_echo "print -r" >&6; } ;;
3332 *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
3333 $as_echo "cat" >&6; } ;;
3334 esac
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
3350 $as_echo_n "checking for a sed that does not truncate output... " >&6; }
3351 if ${ac_cv_path_SED+:} false; then :
3352 $as_echo_n "(cached) " >&6
3353 else
3354 ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
3355 for ac_i in 1 2 3 4 5 6 7; do
3356 ac_script="$ac_script$as_nl$ac_script"
3357 done
3358 echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
3359 { ac_script=; unset ac_script;}
3360 if test -z "$SED"; then
3361 ac_path_SED_found=false
3362 # Loop through the user's path and test for each of PROGNAME-LIST
3363 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3364 for as_dir in $PATH
3365 do
3366 IFS=$as_save_IFS
3367 test -z "$as_dir" && as_dir=.
3368 for ac_prog in sed gsed; do
3369 for ac_exec_ext in '' $ac_executable_extensions; do
3370 ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
3371 as_fn_executable_p "$ac_path_SED" || continue
3372 # Check for GNU ac_path_SED and select it if it is found.
3373 # Check for GNU $ac_path_SED
3374 case `"$ac_path_SED" --version 2>&1` in
3375 *GNU*)
3376 ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
3377 *)
3378 ac_count=0
3379 $as_echo_n 0123456789 >"conftest.in"
3380 while :
3381 do
3382 cat "conftest.in" "conftest.in" >"conftest.tmp"
3383 mv "conftest.tmp" "conftest.in"
3384 cp "conftest.in" "conftest.nl"
3385 $as_echo '' >> "conftest.nl"
3386 "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
3387 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
3388 as_fn_arith $ac_count + 1 && ac_count=$as_val
3389 if test $ac_count -gt ${ac_path_SED_max-0}; then
3390 # Best one so far, save it but keep looking for a better one
3391 ac_cv_path_SED="$ac_path_SED"
3392 ac_path_SED_max=$ac_count
3393 fi
3394 # 10*(2^10) chars as input seems more than enough
3395 test $ac_count -gt 10 && break
3396 done
3397 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
3398 esac
3399
3400 $ac_path_SED_found && break 3
3401 done
3402 done
3403 done
3404 IFS=$as_save_IFS
3405 if test -z "$ac_cv_path_SED"; then
3406 as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
3407 fi
3408 else
3409 ac_cv_path_SED=$SED
3410 fi
3411
3412 fi
3413 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
3414 $as_echo "$ac_cv_path_SED" >&6; }
3415 SED="$ac_cv_path_SED"
3416 rm -f conftest.sed
3417
3418 test -z "$SED" && SED=sed
3419 Xsed="$SED -e 1s/^X//"
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
3432 $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
3433 if ${ac_cv_path_GREP+:} false; then :
3434 $as_echo_n "(cached) " >&6
3435 else
3436 if test -z "$GREP"; then
3437 ac_path_GREP_found=false
3438 # Loop through the user's path and test for each of PROGNAME-LIST
3439 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3440 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
3441 do
3442 IFS=$as_save_IFS
3443 test -z "$as_dir" && as_dir=.
3444 for ac_prog in grep ggrep; do
3445 for ac_exec_ext in '' $ac_executable_extensions; do
3446 ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
3447 as_fn_executable_p "$ac_path_GREP" || continue
3448 # Check for GNU ac_path_GREP and select it if it is found.
3449 # Check for GNU $ac_path_GREP
3450 case `"$ac_path_GREP" --version 2>&1` in
3451 *GNU*)
3452 ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
3453 *)
3454 ac_count=0
3455 $as_echo_n 0123456789 >"conftest.in"
3456 while :
3457 do
3458 cat "conftest.in" "conftest.in" >"conftest.tmp"
3459 mv "conftest.tmp" "conftest.in"
3460 cp "conftest.in" "conftest.nl"
3461 $as_echo 'GREP' >> "conftest.nl"
3462 "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
3463 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
3464 as_fn_arith $ac_count + 1 && ac_count=$as_val
3465 if test $ac_count -gt ${ac_path_GREP_max-0}; then
3466 # Best one so far, save it but keep looking for a better one
3467 ac_cv_path_GREP="$ac_path_GREP"
3468 ac_path_GREP_max=$ac_count
3469 fi
3470 # 10*(2^10) chars as input seems more than enough
3471 test $ac_count -gt 10 && break
3472 done
3473 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
3474 esac
3475
3476 $ac_path_GREP_found && break 3
3477 done
3478 done
3479 done
3480 IFS=$as_save_IFS
3481 if test -z "$ac_cv_path_GREP"; then
3482 as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
3483 fi
3484 else
3485 ac_cv_path_GREP=$GREP
3486 fi
3487
3488 fi
3489 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
3490 $as_echo "$ac_cv_path_GREP" >&6; }
3491 GREP="$ac_cv_path_GREP"
3492
3493
3494 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
3495 $as_echo_n "checking for egrep... " >&6; }
3496 if ${ac_cv_path_EGREP+:} false; then :
3497 $as_echo_n "(cached) " >&6
3498 else
3499 if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
3500 then ac_cv_path_EGREP="$GREP -E"
3501 else
3502 if test -z "$EGREP"; then
3503 ac_path_EGREP_found=false
3504 # Loop through the user's path and test for each of PROGNAME-LIST
3505 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3506 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
3507 do
3508 IFS=$as_save_IFS
3509 test -z "$as_dir" && as_dir=.
3510 for ac_prog in egrep; do
3511 for ac_exec_ext in '' $ac_executable_extensions; do
3512 ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
3513 as_fn_executable_p "$ac_path_EGREP" || continue
3514 # Check for GNU ac_path_EGREP and select it if it is found.
3515 # Check for GNU $ac_path_EGREP
3516 case `"$ac_path_EGREP" --version 2>&1` in
3517 *GNU*)
3518 ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
3519 *)
3520 ac_count=0
3521 $as_echo_n 0123456789 >"conftest.in"
3522 while :
3523 do
3524 cat "conftest.in" "conftest.in" >"conftest.tmp"
3525 mv "conftest.tmp" "conftest.in"
3526 cp "conftest.in" "conftest.nl"
3527 $as_echo 'EGREP' >> "conftest.nl"
3528 "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
3529 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
3530 as_fn_arith $ac_count + 1 && ac_count=$as_val
3531 if test $ac_count -gt ${ac_path_EGREP_max-0}; then
3532 # Best one so far, save it but keep looking for a better one
3533 ac_cv_path_EGREP="$ac_path_EGREP"
3534 ac_path_EGREP_max=$ac_count
3535 fi
3536 # 10*(2^10) chars as input seems more than enough
3537 test $ac_count -gt 10 && break
3538 done
3539 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
3540 esac
3541
3542 $ac_path_EGREP_found && break 3
3543 done
3544 done
3545 done
3546 IFS=$as_save_IFS
3547 if test -z "$ac_cv_path_EGREP"; then
3548 as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
3549 fi
3550 else
3551 ac_cv_path_EGREP=$EGREP
3552 fi
3553
3554 fi
3555 fi
3556 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
3557 $as_echo "$ac_cv_path_EGREP" >&6; }
3558 EGREP="$ac_cv_path_EGREP"
3559
3560
3561 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
3562 $as_echo_n "checking for fgrep... " >&6; }
3563 if ${ac_cv_path_FGREP+:} false; then :
3564 $as_echo_n "(cached) " >&6
3565 else
3566 if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
3567 then ac_cv_path_FGREP="$GREP -F"
3568 else
3569 if test -z "$FGREP"; then
3570 ac_path_FGREP_found=false
3571 # Loop through the user's path and test for each of PROGNAME-LIST
3572 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3573 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
3574 do
3575 IFS=$as_save_IFS
3576 test -z "$as_dir" && as_dir=.
3577 for ac_prog in fgrep; do
3578 for ac_exec_ext in '' $ac_executable_extensions; do
3579 ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
3580 as_fn_executable_p "$ac_path_FGREP" || continue
3581 # Check for GNU ac_path_FGREP and select it if it is found.
3582 # Check for GNU $ac_path_FGREP
3583 case `"$ac_path_FGREP" --version 2>&1` in
3584 *GNU*)
3585 ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
3586 *)
3587 ac_count=0
3588 $as_echo_n 0123456789 >"conftest.in"
3589 while :
3590 do
3591 cat "conftest.in" "conftest.in" >"conftest.tmp"
3592 mv "conftest.tmp" "conftest.in"
3593 cp "conftest.in" "conftest.nl"
3594 $as_echo 'FGREP' >> "conftest.nl"
3595 "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
3596 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
3597 as_fn_arith $ac_count + 1 && ac_count=$as_val
3598 if test $ac_count -gt ${ac_path_FGREP_max-0}; then
3599 # Best one so far, save it but keep looking for a better one
3600 ac_cv_path_FGREP="$ac_path_FGREP"
3601 ac_path_FGREP_max=$ac_count
3602 fi
3603 # 10*(2^10) chars as input seems more than enough
3604 test $ac_count -gt 10 && break
3605 done
3606 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
3607 esac
3608
3609 $ac_path_FGREP_found && break 3
3610 done
3611 done
3612 done
3613 IFS=$as_save_IFS
3614 if test -z "$ac_cv_path_FGREP"; then
3615 as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
3616 fi
3617 else
3618 ac_cv_path_FGREP=$FGREP
3619 fi
3620
3621 fi
3622 fi
3623 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
3624 $as_echo "$ac_cv_path_FGREP" >&6; }
3625 FGREP="$ac_cv_path_FGREP"
3626
3627
3628 test -z "$GREP" && GREP=grep
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648 # Check whether --with-gnu-ld was given.
3649 if test "${with_gnu_ld+set}" = set; then :
3650 withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
3651 else
3652 with_gnu_ld=no
3653 fi
3654
3655 ac_prog=ld
3656 if test "$GCC" = yes; then
3657 # Check if gcc -print-prog-name=ld gives a path.
3658 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
3659 $as_echo_n "checking for ld used by $CC... " >&6; }
3660 case $host in
3661 *-*-mingw*)
3662 # gcc leaves a trailing carriage return which upsets mingw
3663 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
3664 *)
3665 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
3666 esac
3667 case $ac_prog in
3668 # Accept absolute paths.
3669 [\\/]* | ?:[\\/]*)
3670 re_direlt='/[^/][^/]*/\.\./'
3671 # Canonicalize the pathname of ld
3672 ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
3673 while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
3674 ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
3675 done
3676 test -z "$LD" && LD="$ac_prog"
3677 ;;
3678 "")
3679 # If it fails, then pretend we aren't using GCC.
3680 ac_prog=ld
3681 ;;
3682 *)
3683 # If it is relative, then search for the first ld in PATH.
3684 with_gnu_ld=unknown
3685 ;;
3686 esac
3687 elif test "$with_gnu_ld" = yes; then
3688 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
3689 $as_echo_n "checking for GNU ld... " >&6; }
3690 else
3691 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
3692 $as_echo_n "checking for non-GNU ld... " >&6; }
3693 fi
3694 if ${lt_cv_path_LD+:} false; then :
3695 $as_echo_n "(cached) " >&6
3696 else
3697 if test -z "$LD"; then
3698 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
3699 for ac_dir in $PATH; do
3700 IFS="$lt_save_ifs"
3701 test -z "$ac_dir" && ac_dir=.
3702 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
3703 lt_cv_path_LD="$ac_dir/$ac_prog"
3704 # Check to see if the program is GNU ld. I'd rather use --version,
3705 # but apparently some variants of GNU ld only accept -v.
3706 # Break only if it was the GNU/non-GNU ld that we prefer.
3707 case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
3708 *GNU* | *'with BFD'*)
3709 test "$with_gnu_ld" != no && break
3710 ;;
3711 *)
3712 test "$with_gnu_ld" != yes && break
3713 ;;
3714 esac
3715 fi
3716 done
3717 IFS="$lt_save_ifs"
3718 else
3719 lt_cv_path_LD="$LD" # Let the user override the test with a path.
3720 fi
3721 fi
3722
3723 LD="$lt_cv_path_LD"
3724 if test -n "$LD"; then
3725 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
3726 $as_echo "$LD" >&6; }
3727 else
3728 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3729 $as_echo "no" >&6; }
3730 fi
3731 test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
3732 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
3733 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
3734 if ${lt_cv_prog_gnu_ld+:} false; then :
3735 $as_echo_n "(cached) " >&6
3736 else
3737 # I'd rather use --version here, but apparently some GNU lds only accept -v.
3738 case `$LD -v 2>&1 </dev/null` in
3739 *GNU* | *'with BFD'*)
3740 lt_cv_prog_gnu_ld=yes
3741 ;;
3742 *)
3743 lt_cv_prog_gnu_ld=no
3744 ;;
3745 esac
3746 fi
3747 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
3748 $as_echo "$lt_cv_prog_gnu_ld" >&6; }
3749 with_gnu_ld=$lt_cv_prog_gnu_ld
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
3760 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
3761 if ${lt_cv_path_NM+:} false; then :
3762 $as_echo_n "(cached) " >&6
3763 else
3764 if test -n "$NM"; then
3765 # Let the user override the test.
3766 lt_cv_path_NM="$NM"
3767 else
3768 lt_nm_to_check="${ac_tool_prefix}nm"
3769 if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
3770 lt_nm_to_check="$lt_nm_to_check nm"
3771 fi
3772 for lt_tmp_nm in $lt_nm_to_check; do
3773 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
3774 for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
3775 IFS="$lt_save_ifs"
3776 test -z "$ac_dir" && ac_dir=.
3777 tmp_nm="$ac_dir/$lt_tmp_nm"
3778 if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
3779 # Check to see if the nm accepts a BSD-compat flag.
3780 # Adding the `sed 1q' prevents false positives on HP-UX, which says:
3781 # nm: unknown option "B" ignored
3782 # Tru64's nm complains that /dev/null is an invalid object file
3783 case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
3784 */dev/null* | *'Invalid file or object type'*)
3785 lt_cv_path_NM="$tmp_nm -B"
3786 break
3787 ;;
3788 *)
3789 case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
3790 */dev/null*)
3791 lt_cv_path_NM="$tmp_nm -p"
3792 break
3793 ;;
3794 *)
3795 lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
3796 continue # so that we can try to find one that supports BSD flags
3797 ;;
3798 esac
3799 ;;
3800 esac
3801 fi
3802 done
3803 IFS="$lt_save_ifs"
3804 done
3805 : ${lt_cv_path_NM=no}
3806 fi
3807 fi
3808 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
3809 $as_echo "$lt_cv_path_NM" >&6; }
3810 if test "$lt_cv_path_NM" != "no"; then
3811 NM="$lt_cv_path_NM"
3812 else
3813 # Didn't find any BSD compatible name lister, look for dumpbin.
3814 if test -n "$DUMPBIN"; then :
3815 # Let the user override the test.
3816 else
3817 if test -n "$ac_tool_prefix"; then
3818 for ac_prog in dumpbin "link -dump"
3819 do
3820 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
3821 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
3822 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
3823 $as_echo_n "checking for $ac_word... " >&6; }
3824 if ${ac_cv_prog_DUMPBIN+:} false; then :
3825 $as_echo_n "(cached) " >&6
3826 else
3827 if test -n "$DUMPBIN"; then
3828 ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
3829 else
3830 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3831 for as_dir in $PATH
3832 do
3833 IFS=$as_save_IFS
3834 test -z "$as_dir" && as_dir=.
3835 for ac_exec_ext in '' $ac_executable_extensions; do
3836 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
3837 ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
3838 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3839 break 2
3840 fi
3841 done
3842 done
3843 IFS=$as_save_IFS
3844
3845 fi
3846 fi
3847 DUMPBIN=$ac_cv_prog_DUMPBIN
3848 if test -n "$DUMPBIN"; then
3849 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
3850 $as_echo "$DUMPBIN" >&6; }
3851 else
3852 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3853 $as_echo "no" >&6; }
3854 fi
3855
3856
3857 test -n "$DUMPBIN" && break
3858 done
3859 fi
3860 if test -z "$DUMPBIN"; then
3861 ac_ct_DUMPBIN=$DUMPBIN
3862 for ac_prog in dumpbin "link -dump"
3863 do
3864 # Extract the first word of "$ac_prog", so it can be a program name with args.
3865 set dummy $ac_prog; ac_word=$2
3866 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
3867 $as_echo_n "checking for $ac_word... " >&6; }
3868 if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
3869 $as_echo_n "(cached) " >&6
3870 else
3871 if test -n "$ac_ct_DUMPBIN"; then
3872 ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
3873 else
3874 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3875 for as_dir in $PATH
3876 do
3877 IFS=$as_save_IFS
3878 test -z "$as_dir" && as_dir=.
3879 for ac_exec_ext in '' $ac_executable_extensions; do
3880 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
3881 ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
3882 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3883 break 2
3884 fi
3885 done
3886 done
3887 IFS=$as_save_IFS
3888
3889 fi
3890 fi
3891 ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
3892 if test -n "$ac_ct_DUMPBIN"; then
3893 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
3894 $as_echo "$ac_ct_DUMPBIN" >&6; }
3895 else
3896 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3897 $as_echo "no" >&6; }
3898 fi
3899
3900
3901 test -n "$ac_ct_DUMPBIN" && break
3902 done
3903
3904 if test "x$ac_ct_DUMPBIN" = x; then
3905 DUMPBIN=":"
3906 else
3907 case $cross_compiling:$ac_tool_warned in
3908 yes:)
3909 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
3910 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
3911 ac_tool_warned=yes ;;
3912 esac
3913 DUMPBIN=$ac_ct_DUMPBIN
3914 fi
3915 fi
3916
3917 case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
3918 *COFF*)
3919 DUMPBIN="$DUMPBIN -symbols"
3920 ;;
3921 *)
3922 DUMPBIN=:
3923 ;;
3924 esac
3925 fi
3926
3927 if test "$DUMPBIN" != ":"; then
3928 NM="$DUMPBIN"
3929 fi
3930 fi
3931 test -z "$NM" && NM=nm
3932
3933
3934
3935
3936
3937
3938 { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
3939 $as_echo_n "checking the name lister ($NM) interface... " >&6; }
3940 if ${lt_cv_nm_interface+:} false; then :
3941 $as_echo_n "(cached) " >&6
3942 else
3943 lt_cv_nm_interface="BSD nm"
3944 echo "int some_variable = 0;" > conftest.$ac_ext
3945 (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
3946 (eval "$ac_compile" 2>conftest.err)
3947 cat conftest.err >&5
3948 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
3949 (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
3950 cat conftest.err >&5
3951 (eval echo "\"\$as_me:$LINENO: output\"" >&5)
3952 cat conftest.out >&5
3953 if $GREP 'External.*some_variable' conftest.out > /dev/null; then
3954 lt_cv_nm_interface="MS dumpbin"
3955 fi
3956 rm -f conftest*
3957 fi
3958 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
3959 $as_echo "$lt_cv_nm_interface" >&6; }
3960
3961 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
3962 $as_echo_n "checking whether ln -s works... " >&6; }
3963 LN_S=$as_ln_s
3964 if test "$LN_S" = "ln -s"; then
3965 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
3966 $as_echo "yes" >&6; }
3967 else
3968 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
3969 $as_echo "no, using $LN_S" >&6; }
3970 fi
3971
3972 # find the maximum length of command line arguments
3973 { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
3974 $as_echo_n "checking the maximum length of command line arguments... " >&6; }
3975 if ${lt_cv_sys_max_cmd_len+:} false; then :
3976 $as_echo_n "(cached) " >&6
3977 else
3978 i=0
3979 teststring="ABCD"
3980
3981 case $build_os in
3982 msdosdjgpp*)
3983 # On DJGPP, this test can blow up pretty badly due to problems in libc
3984 # (any single argument exceeding 2000 bytes causes a buffer overrun
3985 # during glob expansion). Even if it were fixed, the result of this
3986 # check would be larger than it should be.
3987 lt_cv_sys_max_cmd_len=12288; # 12K is about right
3988 ;;
3989
3990 gnu*)
3991 # Under GNU Hurd, this test is not required because there is
3992 # no limit to the length of command line arguments.
3993 # Libtool will interpret -1 as no limit whatsoever
3994 lt_cv_sys_max_cmd_len=-1;
3995 ;;
3996
3997 cygwin* | mingw* | cegcc*)
3998 # On Win9x/ME, this test blows up -- it succeeds, but takes
3999 # about 5 minutes as the teststring grows exponentially.
4000 # Worse, since 9x/ME are not pre-emptively multitasking,
4001 # you end up with a "frozen" computer, even though with patience
4002 # the test eventually succeeds (with a max line length of 256k).
4003 # Instead, let's just punt: use the minimum linelength reported by
4004 # all of the supported platforms: 8192 (on NT/2K/XP).
4005 lt_cv_sys_max_cmd_len=8192;
4006 ;;
4007
4008 mint*)
4009 # On MiNT this can take a long time and run out of memory.
4010 lt_cv_sys_max_cmd_len=8192;
4011 ;;
4012
4013 amigaos*)
4014 # On AmigaOS with pdksh, this test takes hours, literally.
4015 # So we just punt and use a minimum line length of 8192.
4016 lt_cv_sys_max_cmd_len=8192;
4017 ;;
4018
4019 netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
4020 # This has been around since 386BSD, at least. Likely further.
4021 if test -x /sbin/sysctl; then
4022 lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
4023 elif test -x /usr/sbin/sysctl; then
4024 lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
4025 else
4026 lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
4027 fi
4028 # And add a safety zone
4029 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
4030 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
4031 ;;
4032
4033 interix*)
4034 # We know the value 262144 and hardcode it with a safety zone (like BSD)
4035 lt_cv_sys_max_cmd_len=196608
4036 ;;
4037
4038 os2*)
4039 # The test takes a long time on OS/2.
4040 lt_cv_sys_max_cmd_len=8192
4041 ;;
4042
4043 osf*)
4044 # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
4045 # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
4046 # nice to cause kernel panics so lets avoid the loop below.
4047 # First set a reasonable default.
4048 lt_cv_sys_max_cmd_len=16384
4049 #
4050 if test -x /sbin/sysconfig; then
4051 case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
4052 *1*) lt_cv_sys_max_cmd_len=-1 ;;
4053 esac
4054 fi
4055 ;;
4056 sco3.2v5*)
4057 lt_cv_sys_max_cmd_len=102400
4058 ;;
4059 sysv5* | sco5v6* | sysv4.2uw2*)
4060 kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
4061 if test -n "$kargmax"; then
4062 lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'`
4063 else
4064 lt_cv_sys_max_cmd_len=32768
4065 fi
4066 ;;
4067 *)
4068 lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
4069 if test -n "$lt_cv_sys_max_cmd_len"; then
4070 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
4071 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
4072 else
4073 # Make teststring a little bigger before we do anything with it.
4074 # a 1K string should be a reasonable start.
4075 for i in 1 2 3 4 5 6 7 8 ; do
4076 teststring=$teststring$teststring
4077 done
4078 SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
4079 # If test is not a shell built-in, we'll probably end up computing a
4080 # maximum length that is only half of the actual maximum length, but
4081 # we can't tell.
4082 while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
4083 = "X$teststring$teststring"; } >/dev/null 2>&1 &&
4084 test $i != 17 # 1/2 MB should be enough
4085 do
4086 i=`expr $i + 1`
4087 teststring=$teststring$teststring
4088 done
4089 # Only check the string length outside the loop.
4090 lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
4091 teststring=
4092 # Add a significant safety factor because C++ compilers can tack on
4093 # massive amounts of additional arguments before passing them to the
4094 # linker. It appears as though 1/2 is a usable value.
4095 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
4096 fi
4097 ;;
4098 esac
4099
4100 fi
4101
4102 if test -n $lt_cv_sys_max_cmd_len ; then
4103 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
4104 $as_echo "$lt_cv_sys_max_cmd_len" >&6; }
4105 else
4106 { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
4107 $as_echo "none" >&6; }
4108 fi
4109 max_cmd_len=$lt_cv_sys_max_cmd_len
4110
4111
4112
4113
4114
4115
4116 : ${CP="cp -f"}
4117 : ${MV="mv -f"}
4118 : ${RM="rm -f"}
4119
4120 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
4121 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
4122 # Try some XSI features
4123 xsi_shell=no
4124 ( _lt_dummy="a/b/c"
4125 test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
4126 = c,a/b,b/c, \
4127 && eval 'test $(( 1 + 1 )) -eq 2 \
4128 && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
4129 && xsi_shell=yes
4130 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
4131 $as_echo "$xsi_shell" >&6; }
4132
4133
4134 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
4135 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
4136 lt_shell_append=no
4137 ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
4138 >/dev/null 2>&1 \
4139 && lt_shell_append=yes
4140 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
4141 $as_echo "$lt_shell_append" >&6; }
4142
4143
4144 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
4145 lt_unset=unset
4146 else
4147 lt_unset=false
4148 fi
4149
4150
4151
4152
4153
4154 # test EBCDIC or ASCII
4155 case `echo X|tr X '\101'` in
4156 A) # ASCII based system
4157 # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
4158 lt_SP2NL='tr \040 \012'
4159 lt_NL2SP='tr \015\012 \040\040'
4160 ;;
4161 *) # EBCDIC based system
4162 lt_SP2NL='tr \100 \n'
4163 lt_NL2SP='tr \r\n \100\100'
4164 ;;
4165 esac
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5
4176 $as_echo_n "checking how to convert $build file names to $host format... " >&6; }
4177 if ${lt_cv_to_host_file_cmd+:} false; then :
4178 $as_echo_n "(cached) " >&6
4179 else
4180 case $host in
4181 *-*-mingw* )
4182 case $build in
4183 *-*-mingw* ) # actually msys
4184 lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
4185 ;;
4186 *-*-cygwin* )
4187 lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
4188 ;;
4189 * ) # otherwise, assume *nix
4190 lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
4191 ;;
4192 esac
4193 ;;
4194 *-*-cygwin* )
4195 case $build in
4196 *-*-mingw* ) # actually msys
4197 lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
4198 ;;
4199 *-*-cygwin* )
4200 lt_cv_to_host_file_cmd=func_convert_file_noop
4201 ;;
4202 * ) # otherwise, assume *nix
4203 lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
4204 ;;
4205 esac
4206 ;;
4207 * ) # unhandled hosts (and "normal" native builds)
4208 lt_cv_to_host_file_cmd=func_convert_file_noop
4209 ;;
4210 esac
4211
4212 fi
4213
4214 to_host_file_cmd=$lt_cv_to_host_file_cmd
4215 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5
4216 $as_echo "$lt_cv_to_host_file_cmd" >&6; }
4217
4218
4219
4220
4221
4222 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5
4223 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; }
4224 if ${lt_cv_to_tool_file_cmd+:} false; then :
4225 $as_echo_n "(cached) " >&6
4226 else
4227 #assume ordinary cross tools, or native build.
4228 lt_cv_to_tool_file_cmd=func_convert_file_noop
4229 case $host in
4230 *-*-mingw* )
4231 case $build in
4232 *-*-mingw* ) # actually msys
4233 lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
4234 ;;
4235 esac
4236 ;;
4237 esac
4238
4239 fi
4240
4241 to_tool_file_cmd=$lt_cv_to_tool_file_cmd
4242 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5
4243 $as_echo "$lt_cv_to_tool_file_cmd" >&6; }
4244
4245
4246
4247
4248
4249 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
4250 $as_echo_n "checking for $LD option to reload object files... " >&6; }
4251 if ${lt_cv_ld_reload_flag+:} false; then :
4252 $as_echo_n "(cached) " >&6
4253 else
4254 lt_cv_ld_reload_flag='-r'
4255 fi
4256 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
4257 $as_echo "$lt_cv_ld_reload_flag" >&6; }
4258 reload_flag=$lt_cv_ld_reload_flag
4259 case $reload_flag in
4260 "" | " "*) ;;
4261 *) reload_flag=" $reload_flag" ;;
4262 esac
4263 reload_cmds='$LD$reload_flag -o $output$reload_objs'
4264 case $host_os in
4265 cygwin* | mingw* | pw32* | cegcc*)
4266 if test "$GCC" != yes; then
4267 reload_cmds=false
4268 fi
4269 ;;
4270 darwin*)
4271 if test "$GCC" = yes; then
4272 reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
4273 else
4274 reload_cmds='$LD$reload_flag -o $output$reload_objs'
4275 fi
4276 ;;
4277 esac
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287 if test -n "$ac_tool_prefix"; then
4288 # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
4289 set dummy ${ac_tool_prefix}objdump; ac_word=$2
4290 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4291 $as_echo_n "checking for $ac_word... " >&6; }
4292 if ${ac_cv_prog_OBJDUMP+:} false; then :
4293 $as_echo_n "(cached) " >&6
4294 else
4295 if test -n "$OBJDUMP"; then
4296 ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
4297 else
4298 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4299 for as_dir in $PATH
4300 do
4301 IFS=$as_save_IFS
4302 test -z "$as_dir" && as_dir=.
4303 for ac_exec_ext in '' $ac_executable_extensions; do
4304 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4305 ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
4306 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4307 break 2
4308 fi
4309 done
4310 done
4311 IFS=$as_save_IFS
4312
4313 fi
4314 fi
4315 OBJDUMP=$ac_cv_prog_OBJDUMP
4316 if test -n "$OBJDUMP"; then
4317 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
4318 $as_echo "$OBJDUMP" >&6; }
4319 else
4320 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4321 $as_echo "no" >&6; }
4322 fi
4323
4324
4325 fi
4326 if test -z "$ac_cv_prog_OBJDUMP"; then
4327 ac_ct_OBJDUMP=$OBJDUMP
4328 # Extract the first word of "objdump", so it can be a program name with args.
4329 set dummy objdump; ac_word=$2
4330 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4331 $as_echo_n "checking for $ac_word... " >&6; }
4332 if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
4333 $as_echo_n "(cached) " >&6
4334 else
4335 if test -n "$ac_ct_OBJDUMP"; then
4336 ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
4337 else
4338 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4339 for as_dir in $PATH
4340 do
4341 IFS=$as_save_IFS
4342 test -z "$as_dir" && as_dir=.
4343 for ac_exec_ext in '' $ac_executable_extensions; do
4344 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4345 ac_cv_prog_ac_ct_OBJDUMP="objdump"
4346 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4347 break 2
4348 fi
4349 done
4350 done
4351 IFS=$as_save_IFS
4352
4353 fi
4354 fi
4355 ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
4356 if test -n "$ac_ct_OBJDUMP"; then
4357 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
4358 $as_echo "$ac_ct_OBJDUMP" >&6; }
4359 else
4360 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4361 $as_echo "no" >&6; }
4362 fi
4363
4364 if test "x$ac_ct_OBJDUMP" = x; then
4365 OBJDUMP="false"
4366 else
4367 case $cross_compiling:$ac_tool_warned in
4368 yes:)
4369 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
4370 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
4371 ac_tool_warned=yes ;;
4372 esac
4373 OBJDUMP=$ac_ct_OBJDUMP
4374 fi
4375 else
4376 OBJDUMP="$ac_cv_prog_OBJDUMP"
4377 fi
4378
4379 test -z "$OBJDUMP" && OBJDUMP=objdump
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
4390 $as_echo_n "checking how to recognize dependent libraries... " >&6; }
4391 if ${lt_cv_deplibs_check_method+:} false; then :
4392 $as_echo_n "(cached) " >&6
4393 else
4394 lt_cv_file_magic_cmd='$MAGIC_CMD'
4395 lt_cv_file_magic_test_file=
4396 lt_cv_deplibs_check_method='unknown'
4397 # Need to set the preceding variable on all platforms that support
4398 # interlibrary dependencies.
4399 # 'none' -- dependencies not supported.
4400 # `unknown' -- same as none, but documents that we really don't know.
4401 # 'pass_all' -- all dependencies passed with no checks.
4402 # 'test_compile' -- check by making test program.
4403 # 'file_magic [[regex]]' -- check by looking for files in library path
4404 # which responds to the $file_magic_cmd with a given extended regex.
4405 # If you have `file' or equivalent on your system and you're not sure
4406 # whether `pass_all' will *always* work, you probably want this one.
4407
4408 case $host_os in
4409 aix[4-9]*)
4410 lt_cv_deplibs_check_method=pass_all
4411 ;;
4412
4413 beos*)
4414 lt_cv_deplibs_check_method=pass_all
4415 ;;
4416
4417 bsdi[45]*)
4418 lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
4419 lt_cv_file_magic_cmd='/usr/bin/file -L'
4420 lt_cv_file_magic_test_file=/shlib/libc.so
4421 ;;
4422
4423 cygwin*)
4424 # func_win32_libid is a shell function defined in ltmain.sh
4425 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
4426 lt_cv_file_magic_cmd='func_win32_libid'
4427 ;;
4428
4429 mingw* | pw32*)
4430 # Base MSYS/MinGW do not provide the 'file' command needed by
4431 # func_win32_libid shell function, so use a weaker test based on 'objdump',
4432 # unless we find 'file', for example because we are cross-compiling.
4433 # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
4434 if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
4435 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
4436 lt_cv_file_magic_cmd='func_win32_libid'
4437 else
4438 # Keep this pattern in sync with the one in func_win32_libid.
4439 lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
4440 lt_cv_file_magic_cmd='$OBJDUMP -f'
4441 fi
4442 ;;
4443
4444 cegcc*)
4445 # use the weaker test based on 'objdump'. See mingw*.
4446 lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
4447 lt_cv_file_magic_cmd='$OBJDUMP -f'
4448 ;;
4449
4450 darwin* | rhapsody*)
4451 lt_cv_deplibs_check_method=pass_all
4452 ;;
4453
4454 freebsd* | dragonfly*)
4455 if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
4456 case $host_cpu in
4457 i*86 )
4458 # Not sure whether the presence of OpenBSD here was a mistake.
4459 # Let's accept both of them until this is cleared up.
4460 lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
4461 lt_cv_file_magic_cmd=/usr/bin/file
4462 lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
4463 ;;
4464 esac
4465 else
4466 lt_cv_deplibs_check_method=pass_all
4467 fi
4468 ;;
4469
4470 gnu*)
4471 lt_cv_deplibs_check_method=pass_all
4472 ;;
4473
4474 haiku*)
4475 lt_cv_deplibs_check_method=pass_all
4476 ;;
4477
4478 hpux10.20* | hpux11*)
4479 lt_cv_file_magic_cmd=/usr/bin/file
4480 case $host_cpu in
4481 ia64*)
4482 lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
4483 lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
4484 ;;
4485 hppa*64*)
4486 lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
4487 lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
4488 ;;
4489 *)
4490 lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'
4491 lt_cv_file_magic_test_file=/usr/lib/libc.sl
4492 ;;
4493 esac
4494 ;;
4495
4496 interix[3-9]*)
4497 # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
4498 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
4499 ;;
4500
4501 irix5* | irix6* | nonstopux*)
4502 case $LD in
4503 *-32|*"-32 ") libmagic=32-bit;;
4504 *-n32|*"-n32 ") libmagic=N32;;
4505 *-64|*"-64 ") libmagic=64-bit;;
4506 *) libmagic=never-match;;
4507 esac
4508 lt_cv_deplibs_check_method=pass_all
4509 ;;
4510
4511 # This must be glibc/ELF.
4512 linux* | k*bsd*-gnu | kopensolaris*-gnu)
4513 lt_cv_deplibs_check_method=pass_all
4514 ;;
4515
4516 netbsd*)
4517 if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
4518 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
4519 else
4520 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
4521 fi
4522 ;;
4523
4524 newos6*)
4525 lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
4526 lt_cv_file_magic_cmd=/usr/bin/file
4527 lt_cv_file_magic_test_file=/usr/lib/libnls.so
4528 ;;
4529
4530 *nto* | *qnx*)
4531 lt_cv_deplibs_check_method=pass_all
4532 ;;
4533
4534 openbsd*)
4535 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
4536 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
4537 else
4538 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
4539 fi
4540 ;;
4541
4542 osf3* | osf4* | osf5*)
4543 lt_cv_deplibs_check_method=pass_all
4544 ;;
4545
4546 rdos*)
4547 lt_cv_deplibs_check_method=pass_all
4548 ;;
4549
4550 solaris*)
4551 lt_cv_deplibs_check_method=pass_all
4552 ;;
4553
4554 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
4555 lt_cv_deplibs_check_method=pass_all
4556 ;;
4557
4558 sysv4 | sysv4.3*)
4559 case $host_vendor in
4560 motorola)
4561 lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
4562 lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
4563 ;;
4564 ncr)
4565 lt_cv_deplibs_check_method=pass_all
4566 ;;
4567 sequent)
4568 lt_cv_file_magic_cmd='/bin/file'
4569 lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
4570 ;;
4571 sni)
4572 lt_cv_file_magic_cmd='/bin/file'
4573 lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
4574 lt_cv_file_magic_test_file=/lib/libc.so
4575 ;;
4576 siemens)
4577 lt_cv_deplibs_check_method=pass_all
4578 ;;
4579 pc)
4580 lt_cv_deplibs_check_method=pass_all
4581 ;;
4582 esac
4583 ;;
4584
4585 tpf*)
4586 lt_cv_deplibs_check_method=pass_all
4587 ;;
4588 esac
4589
4590 fi
4591 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
4592 $as_echo "$lt_cv_deplibs_check_method" >&6; }
4593
4594 file_magic_glob=
4595 want_nocaseglob=no
4596 if test "$build" = "$host"; then
4597 case $host_os in
4598 mingw* | pw32*)
4599 if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
4600 want_nocaseglob=yes
4601 else
4602 file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"`
4603 fi
4604 ;;
4605 esac
4606 fi
4607
4608 file_magic_cmd=$lt_cv_file_magic_cmd
4609 deplibs_check_method=$lt_cv_deplibs_check_method
4610 test -z "$deplibs_check_method" && deplibs_check_method=unknown
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633 if test -n "$ac_tool_prefix"; then
4634 # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
4635 set dummy ${ac_tool_prefix}dlltool; ac_word=$2
4636 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4637 $as_echo_n "checking for $ac_word... " >&6; }
4638 if ${ac_cv_prog_DLLTOOL+:} false; then :
4639 $as_echo_n "(cached) " >&6
4640 else
4641 if test -n "$DLLTOOL"; then
4642 ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
4643 else
4644 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4645 for as_dir in $PATH
4646 do
4647 IFS=$as_save_IFS
4648 test -z "$as_dir" && as_dir=.
4649 for ac_exec_ext in '' $ac_executable_extensions; do
4650 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4651 ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
4652 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4653 break 2
4654 fi
4655 done
4656 done
4657 IFS=$as_save_IFS
4658
4659 fi
4660 fi
4661 DLLTOOL=$ac_cv_prog_DLLTOOL
4662 if test -n "$DLLTOOL"; then
4663 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
4664 $as_echo "$DLLTOOL" >&6; }
4665 else
4666 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4667 $as_echo "no" >&6; }
4668 fi
4669
4670
4671 fi
4672 if test -z "$ac_cv_prog_DLLTOOL"; then
4673 ac_ct_DLLTOOL=$DLLTOOL
4674 # Extract the first word of "dlltool", so it can be a program name with args.
4675 set dummy dlltool; ac_word=$2
4676 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4677 $as_echo_n "checking for $ac_word... " >&6; }
4678 if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
4679 $as_echo_n "(cached) " >&6
4680 else
4681 if test -n "$ac_ct_DLLTOOL"; then
4682 ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
4683 else
4684 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4685 for as_dir in $PATH
4686 do
4687 IFS=$as_save_IFS
4688 test -z "$as_dir" && as_dir=.
4689 for ac_exec_ext in '' $ac_executable_extensions; do
4690 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4691 ac_cv_prog_ac_ct_DLLTOOL="dlltool"
4692 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4693 break 2
4694 fi
4695 done
4696 done
4697 IFS=$as_save_IFS
4698
4699 fi
4700 fi
4701 ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
4702 if test -n "$ac_ct_DLLTOOL"; then
4703 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
4704 $as_echo "$ac_ct_DLLTOOL" >&6; }
4705 else
4706 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4707 $as_echo "no" >&6; }
4708 fi
4709
4710 if test "x$ac_ct_DLLTOOL" = x; then
4711 DLLTOOL="false"
4712 else
4713 case $cross_compiling:$ac_tool_warned in
4714 yes:)
4715 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
4716 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
4717 ac_tool_warned=yes ;;
4718 esac
4719 DLLTOOL=$ac_ct_DLLTOOL
4720 fi
4721 else
4722 DLLTOOL="$ac_cv_prog_DLLTOOL"
4723 fi
4724
4725 test -z "$DLLTOOL" && DLLTOOL=dlltool
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
4737 $as_echo_n "checking how to associate runtime and link libraries... " >&6; }
4738 if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then :
4739 $as_echo_n "(cached) " >&6
4740 else
4741 lt_cv_sharedlib_from_linklib_cmd='unknown'
4742
4743 case $host_os in
4744 cygwin* | mingw* | pw32* | cegcc*)
4745 # two different shell functions defined in ltmain.sh
4746 # decide which to use based on capabilities of $DLLTOOL
4747 case `$DLLTOOL --help 2>&1` in
4748 *--identify-strict*)
4749 lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
4750 ;;
4751 *)
4752 lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
4753 ;;
4754 esac
4755 ;;
4756 *)
4757 # fallback: assume linklib IS sharedlib
4758 lt_cv_sharedlib_from_linklib_cmd="$ECHO"
4759 ;;
4760 esac
4761
4762 fi
4763 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
4764 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
4765 sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
4766 test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
4767
4768
4769
4770
4771
4772
4773
4774
4775 if test -n "$ac_tool_prefix"; then
4776 for ac_prog in ar
4777 do
4778 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
4779 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
4780 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4781 $as_echo_n "checking for $ac_word... " >&6; }
4782 if ${ac_cv_prog_AR+:} false; then :
4783 $as_echo_n "(cached) " >&6
4784 else
4785 if test -n "$AR"; then
4786 ac_cv_prog_AR="$AR" # Let the user override the test.
4787 else
4788 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4789 for as_dir in $PATH
4790 do
4791 IFS=$as_save_IFS
4792 test -z "$as_dir" && as_dir=.
4793 for ac_exec_ext in '' $ac_executable_extensions; do
4794 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4795 ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
4796 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4797 break 2
4798 fi
4799 done
4800 done
4801 IFS=$as_save_IFS
4802
4803 fi
4804 fi
4805 AR=$ac_cv_prog_AR
4806 if test -n "$AR"; then
4807 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
4808 $as_echo "$AR" >&6; }
4809 else
4810 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4811 $as_echo "no" >&6; }
4812 fi
4813
4814
4815 test -n "$AR" && break
4816 done
4817 fi
4818 if test -z "$AR"; then
4819 ac_ct_AR=$AR
4820 for ac_prog in ar
4821 do
4822 # Extract the first word of "$ac_prog", so it can be a program name with args.
4823 set dummy $ac_prog; ac_word=$2
4824 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4825 $as_echo_n "checking for $ac_word... " >&6; }
4826 if ${ac_cv_prog_ac_ct_AR+:} false; then :
4827 $as_echo_n "(cached) " >&6
4828 else
4829 if test -n "$ac_ct_AR"; then
4830 ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
4831 else
4832 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4833 for as_dir in $PATH
4834 do
4835 IFS=$as_save_IFS
4836 test -z "$as_dir" && as_dir=.
4837 for ac_exec_ext in '' $ac_executable_extensions; do
4838 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4839 ac_cv_prog_ac_ct_AR="$ac_prog"
4840 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4841 break 2
4842 fi
4843 done
4844 done
4845 IFS=$as_save_IFS
4846
4847 fi
4848 fi
4849 ac_ct_AR=$ac_cv_prog_ac_ct_AR
4850 if test -n "$ac_ct_AR"; then
4851 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
4852 $as_echo "$ac_ct_AR" >&6; }
4853 else
4854 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4855 $as_echo "no" >&6; }
4856 fi
4857
4858
4859 test -n "$ac_ct_AR" && break
4860 done
4861
4862 if test "x$ac_ct_AR" = x; then
4863 AR="false"
4864 else
4865 case $cross_compiling:$ac_tool_warned in
4866 yes:)
4867 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
4868 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
4869 ac_tool_warned=yes ;;
4870 esac
4871 AR=$ac_ct_AR
4872 fi
4873 fi
4874
4875 : ${AR=ar}
4876 : ${AR_FLAGS=cru}
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5
4889 $as_echo_n "checking for archiver @FILE support... " >&6; }
4890 if ${lt_cv_ar_at_file+:} false; then :
4891 $as_echo_n "(cached) " >&6
4892 else
4893 lt_cv_ar_at_file=no
4894 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4895 /* end confdefs.h. */
4896
4897 int
4898 main ()
4899 {
4900
4901 ;
4902 return 0;
4903 }
4904 _ACEOF
4905 if ac_fn_c_try_compile "$LINENO"; then :
4906 echo conftest.$ac_objext > conftest.lst
4907 lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'
4908 { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
4909 (eval $lt_ar_try) 2>&5
4910 ac_status=$?
4911 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
4912 test $ac_status = 0; }
4913 if test "$ac_status" -eq 0; then
4914 # Ensure the archiver fails upon bogus file names.
4915 rm -f conftest.$ac_objext libconftest.a
4916 { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
4917 (eval $lt_ar_try) 2>&5
4918 ac_status=$?
4919 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
4920 test $ac_status = 0; }
4921 if test "$ac_status" -ne 0; then
4922 lt_cv_ar_at_file=@
4923 fi
4924 fi
4925 rm -f conftest.* libconftest.a
4926
4927 fi
4928 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4929
4930 fi
4931 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
4932 $as_echo "$lt_cv_ar_at_file" >&6; }
4933
4934 if test "x$lt_cv_ar_at_file" = xno; then
4935 archiver_list_spec=
4936 else
4937 archiver_list_spec=$lt_cv_ar_at_file
4938 fi
4939
4940
4941
4942
4943
4944
4945
4946 if test -n "$ac_tool_prefix"; then
4947 # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
4948 set dummy ${ac_tool_prefix}strip; ac_word=$2
4949 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4950 $as_echo_n "checking for $ac_word... " >&6; }
4951 if ${ac_cv_prog_STRIP+:} false; then :
4952 $as_echo_n "(cached) " >&6
4953 else
4954 if test -n "$STRIP"; then
4955 ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
4956 else
4957 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4958 for as_dir in $PATH
4959 do
4960 IFS=$as_save_IFS
4961 test -z "$as_dir" && as_dir=.
4962 for ac_exec_ext in '' $ac_executable_extensions; do
4963 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
4964 ac_cv_prog_STRIP="${ac_tool_prefix}strip"
4965 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
4966 break 2
4967 fi
4968 done
4969 done
4970 IFS=$as_save_IFS
4971
4972 fi
4973 fi
4974 STRIP=$ac_cv_prog_STRIP
4975 if test -n "$STRIP"; then
4976 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
4977 $as_echo "$STRIP" >&6; }
4978 else
4979 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
4980 $as_echo "no" >&6; }
4981 fi
4982
4983
4984 fi
4985 if test -z "$ac_cv_prog_STRIP"; then
4986 ac_ct_STRIP=$STRIP
4987 # Extract the first word of "strip", so it can be a program name with args.
4988 set dummy strip; ac_word=$2
4989 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
4990 $as_echo_n "checking for $ac_word... " >&6; }
4991 if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
4992 $as_echo_n "(cached) " >&6
4993 else
4994 if test -n "$ac_ct_STRIP"; then
4995 ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
4996 else
4997 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4998 for as_dir in $PATH
4999 do
5000 IFS=$as_save_IFS
5001 test -z "$as_dir" && as_dir=.
5002 for ac_exec_ext in '' $ac_executable_extensions; do
5003 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5004 ac_cv_prog_ac_ct_STRIP="strip"
5005 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5006 break 2
5007 fi
5008 done
5009 done
5010 IFS=$as_save_IFS
5011
5012 fi
5013 fi
5014 ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
5015 if test -n "$ac_ct_STRIP"; then
5016 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
5017 $as_echo "$ac_ct_STRIP" >&6; }
5018 else
5019 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5020 $as_echo "no" >&6; }
5021 fi
5022
5023 if test "x$ac_ct_STRIP" = x; then
5024 STRIP=":"
5025 else
5026 case $cross_compiling:$ac_tool_warned in
5027 yes:)
5028 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
5029 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
5030 ac_tool_warned=yes ;;
5031 esac
5032 STRIP=$ac_ct_STRIP
5033 fi
5034 else
5035 STRIP="$ac_cv_prog_STRIP"
5036 fi
5037
5038 test -z "$STRIP" && STRIP=:
5039
5040
5041
5042
5043
5044
5045 if test -n "$ac_tool_prefix"; then
5046 # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
5047 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
5048 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5049 $as_echo_n "checking for $ac_word... " >&6; }
5050 if ${ac_cv_prog_RANLIB+:} false; then :
5051 $as_echo_n "(cached) " >&6
5052 else
5053 if test -n "$RANLIB"; then
5054 ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
5055 else
5056 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5057 for as_dir in $PATH
5058 do
5059 IFS=$as_save_IFS
5060 test -z "$as_dir" && as_dir=.
5061 for ac_exec_ext in '' $ac_executable_extensions; do
5062 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5063 ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
5064 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5065 break 2
5066 fi
5067 done
5068 done
5069 IFS=$as_save_IFS
5070
5071 fi
5072 fi
5073 RANLIB=$ac_cv_prog_RANLIB
5074 if test -n "$RANLIB"; then
5075 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
5076 $as_echo "$RANLIB" >&6; }
5077 else
5078 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5079 $as_echo "no" >&6; }
5080 fi
5081
5082
5083 fi
5084 if test -z "$ac_cv_prog_RANLIB"; then
5085 ac_ct_RANLIB=$RANLIB
5086 # Extract the first word of "ranlib", so it can be a program name with args.
5087 set dummy ranlib; ac_word=$2
5088 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5089 $as_echo_n "checking for $ac_word... " >&6; }
5090 if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
5091 $as_echo_n "(cached) " >&6
5092 else
5093 if test -n "$ac_ct_RANLIB"; then
5094 ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
5095 else
5096 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5097 for as_dir in $PATH
5098 do
5099 IFS=$as_save_IFS
5100 test -z "$as_dir" && as_dir=.
5101 for ac_exec_ext in '' $ac_executable_extensions; do
5102 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5103 ac_cv_prog_ac_ct_RANLIB="ranlib"
5104 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5105 break 2
5106 fi
5107 done
5108 done
5109 IFS=$as_save_IFS
5110
5111 fi
5112 fi
5113 ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
5114 if test -n "$ac_ct_RANLIB"; then
5115 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
5116 $as_echo "$ac_ct_RANLIB" >&6; }
5117 else
5118 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5119 $as_echo "no" >&6; }
5120 fi
5121
5122 if test "x$ac_ct_RANLIB" = x; then
5123 RANLIB=":"
5124 else
5125 case $cross_compiling:$ac_tool_warned in
5126 yes:)
5127 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
5128 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
5129 ac_tool_warned=yes ;;
5130 esac
5131 RANLIB=$ac_ct_RANLIB
5132 fi
5133 else
5134 RANLIB="$ac_cv_prog_RANLIB"
5135 fi
5136
5137 test -z "$RANLIB" && RANLIB=:
5138
5139
5140
5141
5142
5143
5144 # Determine commands to create old-style static archives.
5145 old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
5146 old_postinstall_cmds='chmod 644 $oldlib'
5147 old_postuninstall_cmds=
5148
5149 if test -n "$RANLIB"; then
5150 case $host_os in
5151 openbsd*)
5152 old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
5153 ;;
5154 *)
5155 old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
5156 ;;
5157 esac
5158 old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
5159 fi
5160
5161 case $host_os in
5162 darwin*)
5163 lock_old_archive_extraction=yes ;;
5164 *)
5165 lock_old_archive_extraction=no ;;
5166 esac
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188 for ac_prog in gawk mawk nawk awk
5189 do
5190 # Extract the first word of "$ac_prog", so it can be a program name with args.
5191 set dummy $ac_prog; ac_word=$2
5192 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5193 $as_echo_n "checking for $ac_word... " >&6; }
5194 if ${ac_cv_prog_AWK+:} false; then :
5195 $as_echo_n "(cached) " >&6
5196 else
5197 if test -n "$AWK"; then
5198 ac_cv_prog_AWK="$AWK" # Let the user override the test.
5199 else
5200 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5201 for as_dir in $PATH
5202 do
5203 IFS=$as_save_IFS
5204 test -z "$as_dir" && as_dir=.
5205 for ac_exec_ext in '' $ac_executable_extensions; do
5206 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5207 ac_cv_prog_AWK="$ac_prog"
5208 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5209 break 2
5210 fi
5211 done
5212 done
5213 IFS=$as_save_IFS
5214
5215 fi
5216 fi
5217 AWK=$ac_cv_prog_AWK
5218 if test -n "$AWK"; then
5219 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
5220 $as_echo "$AWK" >&6; }
5221 else
5222 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5223 $as_echo "no" >&6; }
5224 fi
5225
5226
5227 test -n "$AWK" && break
5228 done
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248 # If no C compiler was specified, use CC.
5249 LTCC=${LTCC-"$CC"}
5250
5251 # If no C compiler flags were specified, use CFLAGS.
5252 LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
5253
5254 # Allow CC to be a program name with arguments.
5255 compiler=$CC
5256
5257
5258 # Check for command to grab the raw symbol name followed by C symbol from nm.
5259 { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
5260 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
5261 if ${lt_cv_sys_global_symbol_pipe+:} false; then :
5262 $as_echo_n "(cached) " >&6
5263 else
5264
5265 # These are sane defaults that work on at least a few old systems.
5266 # [They come from Ultrix. What could be older than Ultrix?!! ;)]
5267
5268 # Character class describing NM global symbol codes.
5269 symcode='[BCDEGRST]'
5270
5271 # Regexp to match symbols that can be accessed directly from C.
5272 sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
5273
5274 # Define system-specific variables.
5275 case $host_os in
5276 aix*)
5277 symcode='[BCDT]'
5278 ;;
5279 cygwin* | mingw* | pw32* | cegcc*)
5280 symcode='[ABCDGISTW]'
5281 ;;
5282 hpux*)
5283 if test "$host_cpu" = ia64; then
5284 symcode='[ABCDEGRST]'
5285 fi
5286 ;;
5287 irix* | nonstopux*)
5288 symcode='[BCDEGRST]'
5289 ;;
5290 osf*)
5291 symcode='[BCDEGQRST]'
5292 ;;
5293 solaris*)
5294 symcode='[BDRT]'
5295 ;;
5296 sco3.2v5*)
5297 symcode='[DT]'
5298 ;;
5299 sysv4.2uw2*)
5300 symcode='[DT]'
5301 ;;
5302 sysv5* | sco5v6* | unixware* | OpenUNIX*)
5303 symcode='[ABDT]'
5304 ;;
5305 sysv4)
5306 symcode='[DFNSTU]'
5307 ;;
5308 esac
5309
5310 # If we're using GNU nm, then use its standard symbol codes.
5311 case `$NM -V 2>&1` in
5312 *GNU* | *'with BFD'*)
5313 symcode='[ABCDGIRSTW]' ;;
5314 esac
5315
5316 # Transform an extracted symbol line into a proper C declaration.
5317 # Some systems (esp. on ia64) link data and code symbols differently,
5318 # so use this general approach.
5319 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
5320
5321 # Transform an extracted symbol line into symbol name and symbol address
5322 lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'"
5323 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
5324
5325 # Handle CRLF in mingw tool chain
5326 opt_cr=
5327 case $build_os in
5328 mingw*)
5329 opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
5330 ;;
5331 esac
5332
5333 # Try without a prefix underscore, then with it.
5334 for ac_symprfx in "" "_"; do
5335
5336 # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
5337 symxfrm="\\1 $ac_symprfx\\2 \\2"
5338
5339 # Write the raw and C identifiers.
5340 if test "$lt_cv_nm_interface" = "MS dumpbin"; then
5341 # Fake it for dumpbin and say T for any non-static function
5342 # and D for any global variable.
5343 # Also find C++ and __fastcall symbols from MSVC++,
5344 # which start with @ or ?.
5345 lt_cv_sys_global_symbol_pipe="$AWK '"\
5346 " {last_section=section; section=\$ 3};"\
5347 " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
5348 " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
5349 " \$ 0!~/External *\|/{next};"\
5350 " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
5351 " {if(hide[section]) next};"\
5352 " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
5353 " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
5354 " s[1]~/^[@?]/{print s[1], s[1]; next};"\
5355 " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
5356 " ' prfx=^$ac_symprfx"
5357 else
5358 lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
5359 fi
5360 lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
5361
5362 # Check to see that the pipe works correctly.
5363 pipe_works=no
5364
5365 rm -f conftest*
5366 cat > conftest.$ac_ext <<_LT_EOF
5367 #ifdef __cplusplus
5368 extern "C" {
5369 #endif
5370 char nm_test_var;
5371 void nm_test_func(void);
5372 void nm_test_func(void){}
5373 #ifdef __cplusplus
5374 }
5375 #endif
5376 int main(){nm_test_var='a';nm_test_func();return(0);}
5377 _LT_EOF
5378
5379 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
5380 (eval $ac_compile) 2>&5
5381 ac_status=$?
5382 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5383 test $ac_status = 0; }; then
5384 # Now try to grab the symbols.
5385 nlist=conftest.nm
5386 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
5387 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
5388 ac_status=$?
5389 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5390 test $ac_status = 0; } && test -s "$nlist"; then
5391 # Try sorting and uniquifying the output.
5392 if sort "$nlist" | uniq > "$nlist"T; then
5393 mv -f "$nlist"T "$nlist"
5394 else
5395 rm -f "$nlist"T
5396 fi
5397
5398 # Make sure that we snagged all the symbols we need.
5399 if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
5400 if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
5401 cat <<_LT_EOF > conftest.$ac_ext
5402 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
5403 #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
5404 /* DATA imports from DLLs on WIN32 con't be const, because runtime
5405 relocations are performed -- see ld's documentation on pseudo-relocs. */
5406 # define LT_DLSYM_CONST
5407 #elif defined(__osf__)
5408 /* This system does not cope well with relocations in const data. */
5409 # define LT_DLSYM_CONST
5410 #else
5411 # define LT_DLSYM_CONST const
5412 #endif
5413
5414 #ifdef __cplusplus
5415 extern "C" {
5416 #endif
5417
5418 _LT_EOF
5419 # Now generate the symbol file.
5420 eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
5421
5422 cat <<_LT_EOF >> conftest.$ac_ext
5423
5424 /* The mapping between symbol names and symbols. */
5425 LT_DLSYM_CONST struct {
5426 const char *name;
5427 void *address;
5428 }
5429 lt__PROGRAM__LTX_preloaded_symbols[] =
5430 {
5431 { "@PROGRAM@", (void *) 0 },
5432 _LT_EOF
5433 $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
5434 cat <<\_LT_EOF >> conftest.$ac_ext
5435 {0, (void *) 0}
5436 };
5437
5438 /* This works around a problem in FreeBSD linker */
5439 #ifdef FREEBSD_WORKAROUND
5440 static const void *lt_preloaded_setup() {
5441 return lt__PROGRAM__LTX_preloaded_symbols;
5442 }
5443 #endif
5444
5445 #ifdef __cplusplus
5446 }
5447 #endif
5448 _LT_EOF
5449 # Now try linking the two files.
5450 mv conftest.$ac_objext conftstm.$ac_objext
5451 lt_globsym_save_LIBS=$LIBS
5452 lt_globsym_save_CFLAGS=$CFLAGS
5453 LIBS="conftstm.$ac_objext"
5454 CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
5455 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
5456 (eval $ac_link) 2>&5
5457 ac_status=$?
5458 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5459 test $ac_status = 0; } && test -s conftest${ac_exeext}; then
5460 pipe_works=yes
5461 fi
5462 LIBS=$lt_globsym_save_LIBS
5463 CFLAGS=$lt_globsym_save_CFLAGS
5464 else
5465 echo "cannot find nm_test_func in $nlist" >&5
5466 fi
5467 else
5468 echo "cannot find nm_test_var in $nlist" >&5
5469 fi
5470 else
5471 echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
5472 fi
5473 else
5474 echo "$progname: failed program was:" >&5
5475 cat conftest.$ac_ext >&5
5476 fi
5477 rm -rf conftest* conftst*
5478
5479 # Do not use the global_symbol_pipe unless it works.
5480 if test "$pipe_works" = yes; then
5481 break
5482 else
5483 lt_cv_sys_global_symbol_pipe=
5484 fi
5485 done
5486
5487 fi
5488
5489 if test -z "$lt_cv_sys_global_symbol_pipe"; then
5490 lt_cv_sys_global_symbol_to_cdecl=
5491 fi
5492 if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
5493 { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
5494 $as_echo "failed" >&6; }
5495 else
5496 { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
5497 $as_echo "ok" >&6; }
5498 fi
5499
5500 # Response file support.
5501 if test "$lt_cv_nm_interface" = "MS dumpbin"; then
5502 nm_file_list_spec='@'
5503 elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then
5504 nm_file_list_spec='@'
5505 fi
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
5534 $as_echo_n "checking for sysroot... " >&6; }
5535
5536 # Check whether --with-sysroot was given.
5537 if test "${with_sysroot+set}" = set; then :
5538 withval=$with_sysroot;
5539 else
5540 with_sysroot=no
5541 fi
5542
5543
5544 lt_sysroot=
5545 case ${with_sysroot} in #(
5546 yes)
5547 if test "$GCC" = yes; then
5548 lt_sysroot=`$CC --print-sysroot 2>/dev/null`
5549 fi
5550 ;; #(
5551 /*)
5552 lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
5553 ;; #(
5554 no|'')
5555 ;; #(
5556 *)
5557 { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
5558 $as_echo "${with_sysroot}" >&6; }
5559 as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
5560 ;;
5561 esac
5562
5563 { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5
5564 $as_echo "${lt_sysroot:-no}" >&6; }
5565
5566
5567
5568
5569
5570 # Check whether --enable-libtool-lock was given.
5571 if test "${enable_libtool_lock+set}" = set; then :
5572 enableval=$enable_libtool_lock;
5573 fi
5574
5575 test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
5576
5577 # Some flags need to be propagated to the compiler or linker for good
5578 # libtool support.
5579 case $host in
5580 ia64-*-hpux*)
5581 # Find out which ABI we are using.
5582 echo 'int i;' > conftest.$ac_ext
5583 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
5584 (eval $ac_compile) 2>&5
5585 ac_status=$?
5586 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5587 test $ac_status = 0; }; then
5588 case `/usr/bin/file conftest.$ac_objext` in
5589 *ELF-32*)
5590 HPUX_IA64_MODE="32"
5591 ;;
5592 *ELF-64*)
5593 HPUX_IA64_MODE="64"
5594 ;;
5595 esac
5596 fi
5597 rm -rf conftest*
5598 ;;
5599 *-*-irix6*)
5600 # Find out which ABI we are using.
5601 echo '#line '$LINENO' "configure"' > conftest.$ac_ext
5602 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
5603 (eval $ac_compile) 2>&5
5604 ac_status=$?
5605 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5606 test $ac_status = 0; }; then
5607 if test "$lt_cv_prog_gnu_ld" = yes; then
5608 case `/usr/bin/file conftest.$ac_objext` in
5609 *32-bit*)
5610 LD="${LD-ld} -melf32bsmip"
5611 ;;
5612 *N32*)
5613 LD="${LD-ld} -melf32bmipn32"
5614 ;;
5615 *64-bit*)
5616 LD="${LD-ld} -melf64bmip"
5617 ;;
5618 esac
5619 else
5620 case `/usr/bin/file conftest.$ac_objext` in
5621 *32-bit*)
5622 LD="${LD-ld} -32"
5623 ;;
5624 *N32*)
5625 LD="${LD-ld} -n32"
5626 ;;
5627 *64-bit*)
5628 LD="${LD-ld} -64"
5629 ;;
5630 esac
5631 fi
5632 fi
5633 rm -rf conftest*
5634 ;;
5635
5636 x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
5637 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
5638 # Find out which ABI we are using.
5639 echo 'int i;' > conftest.$ac_ext
5640 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
5641 (eval $ac_compile) 2>&5
5642 ac_status=$?
5643 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5644 test $ac_status = 0; }; then
5645 case `/usr/bin/file conftest.o` in
5646 *32-bit*)
5647 case $host in
5648 x86_64-*kfreebsd*-gnu)
5649 LD="${LD-ld} -m elf_i386_fbsd"
5650 ;;
5651 x86_64-*linux*)
5652 LD="${LD-ld} -m elf_i386"
5653 ;;
5654 ppc64-*linux*|powerpc64-*linux*)
5655 LD="${LD-ld} -m elf32ppclinux"
5656 ;;
5657 s390x-*linux*)
5658 LD="${LD-ld} -m elf_s390"
5659 ;;
5660 sparc64-*linux*)
5661 LD="${LD-ld} -m elf32_sparc"
5662 ;;
5663 esac
5664 ;;
5665 *64-bit*)
5666 case $host in
5667 x86_64-*kfreebsd*-gnu)
5668 LD="${LD-ld} -m elf_x86_64_fbsd"
5669 ;;
5670 x86_64-*linux*)
5671 LD="${LD-ld} -m elf_x86_64"
5672 ;;
5673 ppc*-*linux*|powerpc*-*linux*)
5674 LD="${LD-ld} -m elf64ppc"
5675 ;;
5676 s390*-*linux*|s390*-*tpf*)
5677 LD="${LD-ld} -m elf64_s390"
5678 ;;
5679 sparc*-*linux*)
5680 LD="${LD-ld} -m elf64_sparc"
5681 ;;
5682 esac
5683 ;;
5684 esac
5685 fi
5686 rm -rf conftest*
5687 ;;
5688
5689 *-*-sco3.2v5*)
5690 # On SCO OpenServer 5, we need -belf to get full-featured binaries.
5691 SAVE_CFLAGS="$CFLAGS"
5692 CFLAGS="$CFLAGS -belf"
5693 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
5694 $as_echo_n "checking whether the C compiler needs -belf... " >&6; }
5695 if ${lt_cv_cc_needs_belf+:} false; then :
5696 $as_echo_n "(cached) " >&6
5697 else
5698 ac_ext=c
5699 ac_cpp='$CPP $CPPFLAGS'
5700 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5701 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5702 ac_compiler_gnu=$ac_cv_c_compiler_gnu
5703
5704 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5705 /* end confdefs.h. */
5706
5707 int
5708 main ()
5709 {
5710
5711 ;
5712 return 0;
5713 }
5714 _ACEOF
5715 if ac_fn_c_try_link "$LINENO"; then :
5716 lt_cv_cc_needs_belf=yes
5717 else
5718 lt_cv_cc_needs_belf=no
5719 fi
5720 rm -f core conftest.err conftest.$ac_objext \
5721 conftest$ac_exeext conftest.$ac_ext
5722 ac_ext=c
5723 ac_cpp='$CPP $CPPFLAGS'
5724 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5725 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5726 ac_compiler_gnu=$ac_cv_c_compiler_gnu
5727
5728 fi
5729 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
5730 $as_echo "$lt_cv_cc_needs_belf" >&6; }
5731 if test x"$lt_cv_cc_needs_belf" != x"yes"; then
5732 # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
5733 CFLAGS="$SAVE_CFLAGS"
5734 fi
5735 ;;
5736 *-*solaris*)
5737 # Find out which ABI we are using.
5738 echo 'int i;' > conftest.$ac_ext
5739 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
5740 (eval $ac_compile) 2>&5
5741 ac_status=$?
5742 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
5743 test $ac_status = 0; }; then
5744 case `/usr/bin/file conftest.o` in
5745 *64-bit*)
5746 case $lt_cv_prog_gnu_ld in
5747 yes*)
5748 case $host in
5749 i?86-*-solaris*)
5750 LD="${LD-ld} -m elf_x86_64"
5751 ;;
5752 sparc*-*-solaris*)
5753 LD="${LD-ld} -m elf64_sparc"
5754 ;;
5755 esac
5756 # GNU ld 2.21 introduced _sol2 emulations. Use them if available.
5757 if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
5758 LD="${LD-ld}_sol2"
5759 fi
5760 ;;
5761 *)
5762 if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
5763 LD="${LD-ld} -64"
5764 fi
5765 ;;
5766 esac
5767 ;;
5768 esac
5769 fi
5770 rm -rf conftest*
5771 ;;
5772 esac
5773
5774 need_locks="$enable_libtool_lock"
5775
5776 if test -n "$ac_tool_prefix"; then
5777 # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
5778 set dummy ${ac_tool_prefix}mt; ac_word=$2
5779 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5780 $as_echo_n "checking for $ac_word... " >&6; }
5781 if ${ac_cv_prog_MANIFEST_TOOL+:} false; then :
5782 $as_echo_n "(cached) " >&6
5783 else
5784 if test -n "$MANIFEST_TOOL"; then
5785 ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test.
5786 else
5787 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5788 for as_dir in $PATH
5789 do
5790 IFS=$as_save_IFS
5791 test -z "$as_dir" && as_dir=.
5792 for ac_exec_ext in '' $ac_executable_extensions; do
5793 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5794 ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
5795 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5796 break 2
5797 fi
5798 done
5799 done
5800 IFS=$as_save_IFS
5801
5802 fi
5803 fi
5804 MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL
5805 if test -n "$MANIFEST_TOOL"; then
5806 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5
5807 $as_echo "$MANIFEST_TOOL" >&6; }
5808 else
5809 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5810 $as_echo "no" >&6; }
5811 fi
5812
5813
5814 fi
5815 if test -z "$ac_cv_prog_MANIFEST_TOOL"; then
5816 ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL
5817 # Extract the first word of "mt", so it can be a program name with args.
5818 set dummy mt; ac_word=$2
5819 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5820 $as_echo_n "checking for $ac_word... " >&6; }
5821 if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then :
5822 $as_echo_n "(cached) " >&6
5823 else
5824 if test -n "$ac_ct_MANIFEST_TOOL"; then
5825 ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test.
5826 else
5827 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5828 for as_dir in $PATH
5829 do
5830 IFS=$as_save_IFS
5831 test -z "$as_dir" && as_dir=.
5832 for ac_exec_ext in '' $ac_executable_extensions; do
5833 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5834 ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
5835 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5836 break 2
5837 fi
5838 done
5839 done
5840 IFS=$as_save_IFS
5841
5842 fi
5843 fi
5844 ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL
5845 if test -n "$ac_ct_MANIFEST_TOOL"; then
5846 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5
5847 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; }
5848 else
5849 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5850 $as_echo "no" >&6; }
5851 fi
5852
5853 if test "x$ac_ct_MANIFEST_TOOL" = x; then
5854 MANIFEST_TOOL=":"
5855 else
5856 case $cross_compiling:$ac_tool_warned in
5857 yes:)
5858 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
5859 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
5860 ac_tool_warned=yes ;;
5861 esac
5862 MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL
5863 fi
5864 else
5865 MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL"
5866 fi
5867
5868 test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
5869 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5
5870 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }
5871 if ${lt_cv_path_mainfest_tool+:} false; then :
5872 $as_echo_n "(cached) " >&6
5873 else
5874 lt_cv_path_mainfest_tool=no
5875 echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5
5876 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
5877 cat conftest.err >&5
5878 if $GREP 'Manifest Tool' conftest.out > /dev/null; then
5879 lt_cv_path_mainfest_tool=yes
5880 fi
5881 rm -f conftest*
5882 fi
5883 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
5884 $as_echo "$lt_cv_path_mainfest_tool" >&6; }
5885 if test "x$lt_cv_path_mainfest_tool" != xyes; then
5886 MANIFEST_TOOL=:
5887 fi
5888
5889
5890
5891
5892
5893
5894 case $host_os in
5895 rhapsody* | darwin*)
5896 if test -n "$ac_tool_prefix"; then
5897 # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
5898 set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
5899 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5900 $as_echo_n "checking for $ac_word... " >&6; }
5901 if ${ac_cv_prog_DSYMUTIL+:} false; then :
5902 $as_echo_n "(cached) " >&6
5903 else
5904 if test -n "$DSYMUTIL"; then
5905 ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
5906 else
5907 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5908 for as_dir in $PATH
5909 do
5910 IFS=$as_save_IFS
5911 test -z "$as_dir" && as_dir=.
5912 for ac_exec_ext in '' $ac_executable_extensions; do
5913 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5914 ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
5915 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5916 break 2
5917 fi
5918 done
5919 done
5920 IFS=$as_save_IFS
5921
5922 fi
5923 fi
5924 DSYMUTIL=$ac_cv_prog_DSYMUTIL
5925 if test -n "$DSYMUTIL"; then
5926 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
5927 $as_echo "$DSYMUTIL" >&6; }
5928 else
5929 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5930 $as_echo "no" >&6; }
5931 fi
5932
5933
5934 fi
5935 if test -z "$ac_cv_prog_DSYMUTIL"; then
5936 ac_ct_DSYMUTIL=$DSYMUTIL
5937 # Extract the first word of "dsymutil", so it can be a program name with args.
5938 set dummy dsymutil; ac_word=$2
5939 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5940 $as_echo_n "checking for $ac_word... " >&6; }
5941 if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
5942 $as_echo_n "(cached) " >&6
5943 else
5944 if test -n "$ac_ct_DSYMUTIL"; then
5945 ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
5946 else
5947 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5948 for as_dir in $PATH
5949 do
5950 IFS=$as_save_IFS
5951 test -z "$as_dir" && as_dir=.
5952 for ac_exec_ext in '' $ac_executable_extensions; do
5953 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
5954 ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
5955 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
5956 break 2
5957 fi
5958 done
5959 done
5960 IFS=$as_save_IFS
5961
5962 fi
5963 fi
5964 ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
5965 if test -n "$ac_ct_DSYMUTIL"; then
5966 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
5967 $as_echo "$ac_ct_DSYMUTIL" >&6; }
5968 else
5969 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
5970 $as_echo "no" >&6; }
5971 fi
5972
5973 if test "x$ac_ct_DSYMUTIL" = x; then
5974 DSYMUTIL=":"
5975 else
5976 case $cross_compiling:$ac_tool_warned in
5977 yes:)
5978 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
5979 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
5980 ac_tool_warned=yes ;;
5981 esac
5982 DSYMUTIL=$ac_ct_DSYMUTIL
5983 fi
5984 else
5985 DSYMUTIL="$ac_cv_prog_DSYMUTIL"
5986 fi
5987
5988 if test -n "$ac_tool_prefix"; then
5989 # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
5990 set dummy ${ac_tool_prefix}nmedit; ac_word=$2
5991 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
5992 $as_echo_n "checking for $ac_word... " >&6; }
5993 if ${ac_cv_prog_NMEDIT+:} false; then :
5994 $as_echo_n "(cached) " >&6
5995 else
5996 if test -n "$NMEDIT"; then
5997 ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
5998 else
5999 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6000 for as_dir in $PATH
6001 do
6002 IFS=$as_save_IFS
6003 test -z "$as_dir" && as_dir=.
6004 for ac_exec_ext in '' $ac_executable_extensions; do
6005 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6006 ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
6007 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6008 break 2
6009 fi
6010 done
6011 done
6012 IFS=$as_save_IFS
6013
6014 fi
6015 fi
6016 NMEDIT=$ac_cv_prog_NMEDIT
6017 if test -n "$NMEDIT"; then
6018 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
6019 $as_echo "$NMEDIT" >&6; }
6020 else
6021 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6022 $as_echo "no" >&6; }
6023 fi
6024
6025
6026 fi
6027 if test -z "$ac_cv_prog_NMEDIT"; then
6028 ac_ct_NMEDIT=$NMEDIT
6029 # Extract the first word of "nmedit", so it can be a program name with args.
6030 set dummy nmedit; ac_word=$2
6031 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6032 $as_echo_n "checking for $ac_word... " >&6; }
6033 if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
6034 $as_echo_n "(cached) " >&6
6035 else
6036 if test -n "$ac_ct_NMEDIT"; then
6037 ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
6038 else
6039 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6040 for as_dir in $PATH
6041 do
6042 IFS=$as_save_IFS
6043 test -z "$as_dir" && as_dir=.
6044 for ac_exec_ext in '' $ac_executable_extensions; do
6045 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6046 ac_cv_prog_ac_ct_NMEDIT="nmedit"
6047 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6048 break 2
6049 fi
6050 done
6051 done
6052 IFS=$as_save_IFS
6053
6054 fi
6055 fi
6056 ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
6057 if test -n "$ac_ct_NMEDIT"; then
6058 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
6059 $as_echo "$ac_ct_NMEDIT" >&6; }
6060 else
6061 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6062 $as_echo "no" >&6; }
6063 fi
6064
6065 if test "x$ac_ct_NMEDIT" = x; then
6066 NMEDIT=":"
6067 else
6068 case $cross_compiling:$ac_tool_warned in
6069 yes:)
6070 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
6071 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
6072 ac_tool_warned=yes ;;
6073 esac
6074 NMEDIT=$ac_ct_NMEDIT
6075 fi
6076 else
6077 NMEDIT="$ac_cv_prog_NMEDIT"
6078 fi
6079
6080 if test -n "$ac_tool_prefix"; then
6081 # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
6082 set dummy ${ac_tool_prefix}lipo; ac_word=$2
6083 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6084 $as_echo_n "checking for $ac_word... " >&6; }
6085 if ${ac_cv_prog_LIPO+:} false; then :
6086 $as_echo_n "(cached) " >&6
6087 else
6088 if test -n "$LIPO"; then
6089 ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
6090 else
6091 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6092 for as_dir in $PATH
6093 do
6094 IFS=$as_save_IFS
6095 test -z "$as_dir" && as_dir=.
6096 for ac_exec_ext in '' $ac_executable_extensions; do
6097 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6098 ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
6099 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6100 break 2
6101 fi
6102 done
6103 done
6104 IFS=$as_save_IFS
6105
6106 fi
6107 fi
6108 LIPO=$ac_cv_prog_LIPO
6109 if test -n "$LIPO"; then
6110 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
6111 $as_echo "$LIPO" >&6; }
6112 else
6113 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6114 $as_echo "no" >&6; }
6115 fi
6116
6117
6118 fi
6119 if test -z "$ac_cv_prog_LIPO"; then
6120 ac_ct_LIPO=$LIPO
6121 # Extract the first word of "lipo", so it can be a program name with args.
6122 set dummy lipo; ac_word=$2
6123 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6124 $as_echo_n "checking for $ac_word... " >&6; }
6125 if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
6126 $as_echo_n "(cached) " >&6
6127 else
6128 if test -n "$ac_ct_LIPO"; then
6129 ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
6130 else
6131 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6132 for as_dir in $PATH
6133 do
6134 IFS=$as_save_IFS
6135 test -z "$as_dir" && as_dir=.
6136 for ac_exec_ext in '' $ac_executable_extensions; do
6137 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6138 ac_cv_prog_ac_ct_LIPO="lipo"
6139 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6140 break 2
6141 fi
6142 done
6143 done
6144 IFS=$as_save_IFS
6145
6146 fi
6147 fi
6148 ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
6149 if test -n "$ac_ct_LIPO"; then
6150 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
6151 $as_echo "$ac_ct_LIPO" >&6; }
6152 else
6153 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6154 $as_echo "no" >&6; }
6155 fi
6156
6157 if test "x$ac_ct_LIPO" = x; then
6158 LIPO=":"
6159 else
6160 case $cross_compiling:$ac_tool_warned in
6161 yes:)
6162 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
6163 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
6164 ac_tool_warned=yes ;;
6165 esac
6166 LIPO=$ac_ct_LIPO
6167 fi
6168 else
6169 LIPO="$ac_cv_prog_LIPO"
6170 fi
6171
6172 if test -n "$ac_tool_prefix"; then
6173 # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
6174 set dummy ${ac_tool_prefix}otool; ac_word=$2
6175 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6176 $as_echo_n "checking for $ac_word... " >&6; }
6177 if ${ac_cv_prog_OTOOL+:} false; then :
6178 $as_echo_n "(cached) " >&6
6179 else
6180 if test -n "$OTOOL"; then
6181 ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
6182 else
6183 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6184 for as_dir in $PATH
6185 do
6186 IFS=$as_save_IFS
6187 test -z "$as_dir" && as_dir=.
6188 for ac_exec_ext in '' $ac_executable_extensions; do
6189 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6190 ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
6191 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6192 break 2
6193 fi
6194 done
6195 done
6196 IFS=$as_save_IFS
6197
6198 fi
6199 fi
6200 OTOOL=$ac_cv_prog_OTOOL
6201 if test -n "$OTOOL"; then
6202 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
6203 $as_echo "$OTOOL" >&6; }
6204 else
6205 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6206 $as_echo "no" >&6; }
6207 fi
6208
6209
6210 fi
6211 if test -z "$ac_cv_prog_OTOOL"; then
6212 ac_ct_OTOOL=$OTOOL
6213 # Extract the first word of "otool", so it can be a program name with args.
6214 set dummy otool; ac_word=$2
6215 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6216 $as_echo_n "checking for $ac_word... " >&6; }
6217 if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
6218 $as_echo_n "(cached) " >&6
6219 else
6220 if test -n "$ac_ct_OTOOL"; then
6221 ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
6222 else
6223 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6224 for as_dir in $PATH
6225 do
6226 IFS=$as_save_IFS
6227 test -z "$as_dir" && as_dir=.
6228 for ac_exec_ext in '' $ac_executable_extensions; do
6229 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6230 ac_cv_prog_ac_ct_OTOOL="otool"
6231 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6232 break 2
6233 fi
6234 done
6235 done
6236 IFS=$as_save_IFS
6237
6238 fi
6239 fi
6240 ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
6241 if test -n "$ac_ct_OTOOL"; then
6242 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
6243 $as_echo "$ac_ct_OTOOL" >&6; }
6244 else
6245 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6246 $as_echo "no" >&6; }
6247 fi
6248
6249 if test "x$ac_ct_OTOOL" = x; then
6250 OTOOL=":"
6251 else
6252 case $cross_compiling:$ac_tool_warned in
6253 yes:)
6254 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
6255 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
6256 ac_tool_warned=yes ;;
6257 esac
6258 OTOOL=$ac_ct_OTOOL
6259 fi
6260 else
6261 OTOOL="$ac_cv_prog_OTOOL"
6262 fi
6263
6264 if test -n "$ac_tool_prefix"; then
6265 # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
6266 set dummy ${ac_tool_prefix}otool64; ac_word=$2
6267 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6268 $as_echo_n "checking for $ac_word... " >&6; }
6269 if ${ac_cv_prog_OTOOL64+:} false; then :
6270 $as_echo_n "(cached) " >&6
6271 else
6272 if test -n "$OTOOL64"; then
6273 ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
6274 else
6275 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6276 for as_dir in $PATH
6277 do
6278 IFS=$as_save_IFS
6279 test -z "$as_dir" && as_dir=.
6280 for ac_exec_ext in '' $ac_executable_extensions; do
6281 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6282 ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
6283 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6284 break 2
6285 fi
6286 done
6287 done
6288 IFS=$as_save_IFS
6289
6290 fi
6291 fi
6292 OTOOL64=$ac_cv_prog_OTOOL64
6293 if test -n "$OTOOL64"; then
6294 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
6295 $as_echo "$OTOOL64" >&6; }
6296 else
6297 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6298 $as_echo "no" >&6; }
6299 fi
6300
6301
6302 fi
6303 if test -z "$ac_cv_prog_OTOOL64"; then
6304 ac_ct_OTOOL64=$OTOOL64
6305 # Extract the first word of "otool64", so it can be a program name with args.
6306 set dummy otool64; ac_word=$2
6307 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
6308 $as_echo_n "checking for $ac_word... " >&6; }
6309 if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
6310 $as_echo_n "(cached) " >&6
6311 else
6312 if test -n "$ac_ct_OTOOL64"; then
6313 ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
6314 else
6315 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6316 for as_dir in $PATH
6317 do
6318 IFS=$as_save_IFS
6319 test -z "$as_dir" && as_dir=.
6320 for ac_exec_ext in '' $ac_executable_extensions; do
6321 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
6322 ac_cv_prog_ac_ct_OTOOL64="otool64"
6323 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
6324 break 2
6325 fi
6326 done
6327 done
6328 IFS=$as_save_IFS
6329
6330 fi
6331 fi
6332 ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
6333 if test -n "$ac_ct_OTOOL64"; then
6334 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
6335 $as_echo "$ac_ct_OTOOL64" >&6; }
6336 else
6337 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6338 $as_echo "no" >&6; }
6339 fi
6340
6341 if test "x$ac_ct_OTOOL64" = x; then
6342 OTOOL64=":"
6343 else
6344 case $cross_compiling:$ac_tool_warned in
6345 yes:)
6346 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
6347 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
6348 ac_tool_warned=yes ;;
6349 esac
6350 OTOOL64=$ac_ct_OTOOL64
6351 fi
6352 else
6353 OTOOL64="$ac_cv_prog_OTOOL64"
6354 fi
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
6383 $as_echo_n "checking for -single_module linker flag... " >&6; }
6384 if ${lt_cv_apple_cc_single_mod+:} false; then :
6385 $as_echo_n "(cached) " >&6
6386 else
6387 lt_cv_apple_cc_single_mod=no
6388 if test -z "${LT_MULTI_MODULE}"; then
6389 # By default we will add the -single_module flag. You can override
6390 # by either setting the environment variable LT_MULTI_MODULE
6391 # non-empty at configure time, or by adding -multi_module to the
6392 # link flags.
6393 rm -rf libconftest.dylib*
6394 echo "int foo(void){return 1;}" > conftest.c
6395 echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
6396 -dynamiclib -Wl,-single_module conftest.c" >&5
6397 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
6398 -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
6399 _lt_result=$?
6400 # If there is a non-empty error log, and "single_module"
6401 # appears in it, assume the flag caused a linker warning
6402 if test -s conftest.err && $GREP single_module conftest.err; then
6403 cat conftest.err >&5
6404 # Otherwise, if the output was created with a 0 exit code from
6405 # the compiler, it worked.
6406 elif test -f libconftest.dylib && test $_lt_result -eq 0; then
6407 lt_cv_apple_cc_single_mod=yes
6408 else
6409 cat conftest.err >&5
6410 fi
6411 rm -rf libconftest.dylib*
6412 rm -f conftest.*
6413 fi
6414 fi
6415 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
6416 $as_echo "$lt_cv_apple_cc_single_mod" >&6; }
6417
6418 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
6419 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
6420 if ${lt_cv_ld_exported_symbols_list+:} false; then :
6421 $as_echo_n "(cached) " >&6
6422 else
6423 lt_cv_ld_exported_symbols_list=no
6424 save_LDFLAGS=$LDFLAGS
6425 echo "_main" > conftest.sym
6426 LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
6427 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6428 /* end confdefs.h. */
6429
6430 int
6431 main ()
6432 {
6433
6434 ;
6435 return 0;
6436 }
6437 _ACEOF
6438 if ac_fn_c_try_link "$LINENO"; then :
6439 lt_cv_ld_exported_symbols_list=yes
6440 else
6441 lt_cv_ld_exported_symbols_list=no
6442 fi
6443 rm -f core conftest.err conftest.$ac_objext \
6444 conftest$ac_exeext conftest.$ac_ext
6445 LDFLAGS="$save_LDFLAGS"
6446
6447 fi
6448 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
6449 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
6450
6451 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
6452 $as_echo_n "checking for -force_load linker flag... " >&6; }
6453 if ${lt_cv_ld_force_load+:} false; then :
6454 $as_echo_n "(cached) " >&6
6455 else
6456 lt_cv_ld_force_load=no
6457 cat > conftest.c << _LT_EOF
6458 int forced_loaded() { return 2;}
6459 _LT_EOF
6460 echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
6461 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
6462 echo "$AR cru libconftest.a conftest.o" >&5
6463 $AR cru libconftest.a conftest.o 2>&5
6464 echo "$RANLIB libconftest.a" >&5
6465 $RANLIB libconftest.a 2>&5
6466 cat > conftest.c << _LT_EOF
6467 int main() { return 0;}
6468 _LT_EOF
6469 echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
6470 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
6471 _lt_result=$?
6472 if test -s conftest.err && $GREP force_load conftest.err; then
6473 cat conftest.err >&5
6474 elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
6475 lt_cv_ld_force_load=yes
6476 else
6477 cat conftest.err >&5
6478 fi
6479 rm -f conftest.err libconftest.a conftest conftest.c
6480 rm -rf conftest.dSYM
6481
6482 fi
6483 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
6484 $as_echo "$lt_cv_ld_force_load" >&6; }
6485 case $host_os in
6486 rhapsody* | darwin1.[012])
6487 _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
6488 darwin1.*)
6489 _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
6490 darwin*) # darwin 5.x on
6491 # if running on 10.5 or later, the deployment target defaults
6492 # to the OS version, if on x86, and 10.4, the deployment
6493 # target defaults to 10.4. Don't you love it?
6494 case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
6495 10.0,*86*-darwin8*|10.0,*-darwin[91]*)
6496 _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
6497 10.[012]*)
6498 _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
6499 10.*)
6500 _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
6501 esac
6502 ;;
6503 esac
6504 if test "$lt_cv_apple_cc_single_mod" = "yes"; then
6505 _lt_dar_single_mod='$single_module'
6506 fi
6507 if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
6508 _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
6509 else
6510 _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
6511 fi
6512 if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
6513 _lt_dsymutil='~$DSYMUTIL $lib || :'
6514 else
6515 _lt_dsymutil=
6516 fi
6517 ;;
6518 esac
6519
6520
6521 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
6522 $as_echo_n "checking for ANSI C header files... " >&6; }
6523 if ${ac_cv_header_stdc+:} false; then :
6524 $as_echo_n "(cached) " >&6
6525 else
6526 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6527 /* end confdefs.h. */
6528 #include <stdlib.h>
6529 #include <stdarg.h>
6530 #include <string.h>
6531 #include <float.h>
6532
6533 int
6534 main ()
6535 {
6536
6537 ;
6538 return 0;
6539 }
6540 _ACEOF
6541 if ac_fn_c_try_compile "$LINENO"; then :
6542 ac_cv_header_stdc=yes
6543 else
6544 ac_cv_header_stdc=no
6545 fi
6546 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6547
6548 if test $ac_cv_header_stdc = yes; then
6549 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
6550 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6551 /* end confdefs.h. */
6552 #include <string.h>
6553
6554 _ACEOF
6555 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
6556 $EGREP "memchr" >/dev/null 2>&1; then :
6557
6558 else
6559 ac_cv_header_stdc=no
6560 fi
6561 rm -f conftest*
6562
6563 fi
6564
6565 if test $ac_cv_header_stdc = yes; then
6566 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
6567 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6568 /* end confdefs.h. */
6569 #include <stdlib.h>
6570
6571 _ACEOF
6572 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
6573 $EGREP "free" >/dev/null 2>&1; then :
6574
6575 else
6576 ac_cv_header_stdc=no
6577 fi
6578 rm -f conftest*
6579
6580 fi
6581
6582 if test $ac_cv_header_stdc = yes; then
6583 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
6584 if test "$cross_compiling" = yes; then :
6585 :
6586 else
6587 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
6588 /* end confdefs.h. */
6589 #include <ctype.h>
6590 #include <stdlib.h>
6591 #if ((' ' & 0x0FF) == 0x020)
6592 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
6593 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
6594 #else
6595 # define ISLOWER(c) \
6596 (('a' <= (c) && (c) <= 'i') \
6597 || ('j' <= (c) && (c) <= 'r') \
6598 || ('s' <= (c) && (c) <= 'z'))
6599 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
6600 #endif
6601
6602 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
6603 int
6604 main ()
6605 {
6606 int i;
6607 for (i = 0; i < 256; i++)
6608 if (XOR (islower (i), ISLOWER (i))
6609 || toupper (i) != TOUPPER (i))
6610 return 2;
6611 return 0;
6612 }
6613 _ACEOF
6614 if ac_fn_c_try_run "$LINENO"; then :
6615
6616 else
6617 ac_cv_header_stdc=no
6618 fi
6619 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
6620 conftest.$ac_objext conftest.beam conftest.$ac_ext
6621 fi
6622
6623 fi
6624 fi
6625 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
6626 $as_echo "$ac_cv_header_stdc" >&6; }
6627 if test $ac_cv_header_stdc = yes; then
6628
6629 $as_echo "#define STDC_HEADERS 1" >>confdefs.h
6630
6631 fi
6632
6633 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
6634 for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
6635 inttypes.h stdint.h unistd.h
6636 do :
6637 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
6638 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
6639 "
6640 if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
6641 cat >>confdefs.h <<_ACEOF
6642 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
6643 _ACEOF
6644
6645 fi
6646
6647 done
6648
6649
6650 for ac_header in dlfcn.h
6651 do :
6652 ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
6653 "
6654 if test "x$ac_cv_header_dlfcn_h" = xyes; then :
6655 cat >>confdefs.h <<_ACEOF
6656 #define HAVE_DLFCN_H 1
6657 _ACEOF
6658
6659 fi
6660
6661 done
6662
6663
6664
6665
6666
6667 # Set options
6668
6669
6670
6671 enable_dlopen=no
6672
6673
6674 enable_win32_dll=no
6675
6676
6677 # Check whether --enable-shared was given.
6678 if test "${enable_shared+set}" = set; then :
6679 enableval=$enable_shared; p=${PACKAGE-default}
6680 case $enableval in
6681 yes) enable_shared=yes ;;
6682 no) enable_shared=no ;;
6683 *)
6684 enable_shared=no
6685 # Look at the argument we got. We use all the common list separators.
6686 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
6687 for pkg in $enableval; do
6688 IFS="$lt_save_ifs"
6689 if test "X$pkg" = "X$p"; then
6690 enable_shared=yes
6691 fi
6692 done
6693 IFS="$lt_save_ifs"
6694 ;;
6695 esac
6696 else
6697 enable_shared=yes
6698 fi
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708 # Check whether --enable-static was given.
6709 if test "${enable_static+set}" = set; then :
6710 enableval=$enable_static; p=${PACKAGE-default}
6711 case $enableval in
6712 yes) enable_static=yes ;;
6713 no) enable_static=no ;;
6714 *)
6715 enable_static=no
6716 # Look at the argument we got. We use all the common list separators.
6717 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
6718 for pkg in $enableval; do
6719 IFS="$lt_save_ifs"
6720 if test "X$pkg" = "X$p"; then
6721 enable_static=yes
6722 fi
6723 done
6724 IFS="$lt_save_ifs"
6725 ;;
6726 esac
6727 else
6728 enable_static=yes
6729 fi
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740 # Check whether --with-pic was given.
6741 if test "${with_pic+set}" = set; then :
6742 withval=$with_pic; lt_p=${PACKAGE-default}
6743 case $withval in
6744 yes|no) pic_mode=$withval ;;
6745 *)
6746 pic_mode=default
6747 # Look at the argument we got. We use all the common list separators.
6748 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
6749 for lt_pkg in $withval; do
6750 IFS="$lt_save_ifs"
6751 if test "X$lt_pkg" = "X$lt_p"; then
6752 pic_mode=yes
6753 fi
6754 done
6755 IFS="$lt_save_ifs"
6756 ;;
6757 esac
6758 else
6759 pic_mode=default
6760 fi
6761
6762
6763 test -z "$pic_mode" && pic_mode=default
6764
6765
6766
6767
6768
6769
6770
6771 # Check whether --enable-fast-install was given.
6772 if test "${enable_fast_install+set}" = set; then :
6773 enableval=$enable_fast_install; p=${PACKAGE-default}
6774 case $enableval in
6775 yes) enable_fast_install=yes ;;
6776 no) enable_fast_install=no ;;
6777 *)
6778 enable_fast_install=no
6779 # Look at the argument we got. We use all the common list separators.
6780 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
6781 for pkg in $enableval; do
6782 IFS="$lt_save_ifs"
6783 if test "X$pkg" = "X$p"; then
6784 enable_fast_install=yes
6785 fi
6786 done
6787 IFS="$lt_save_ifs"
6788 ;;
6789 esac
6790 else
6791 enable_fast_install=yes
6792 fi
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804 # This can be used to rebuild libtool when needed
6805 LIBTOOL_DEPS="$ltmain"
6806
6807 # Always use our own libtool.
6808 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839 test -z "$LN_S" && LN_S="ln -s"
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854 if test -n "${ZSH_VERSION+set}" ; then
6855 setopt NO_GLOB_SUBST
6856 fi
6857
6858 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
6859 $as_echo_n "checking for objdir... " >&6; }
6860 if ${lt_cv_objdir+:} false; then :
6861 $as_echo_n "(cached) " >&6
6862 else
6863 rm -f .libs 2>/dev/null
6864 mkdir .libs 2>/dev/null
6865 if test -d .libs; then
6866 lt_cv_objdir=.libs
6867 else
6868 # MS-DOS does not allow filenames that begin with a dot.
6869 lt_cv_objdir=_libs
6870 fi
6871 rmdir .libs 2>/dev/null
6872 fi
6873 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
6874 $as_echo "$lt_cv_objdir" >&6; }
6875 objdir=$lt_cv_objdir
6876
6877
6878
6879
6880
6881 cat >>confdefs.h <<_ACEOF
6882 #define LT_OBJDIR "$lt_cv_objdir/"
6883 _ACEOF
6884
6885
6886
6887
6888 case $host_os in
6889 aix3*)
6890 # AIX sometimes has problems with the GCC collect2 program. For some
6891 # reason, if we set the COLLECT_NAMES environment variable, the problems
6892 # vanish in a puff of smoke.
6893 if test "X${COLLECT_NAMES+set}" != Xset; then
6894 COLLECT_NAMES=
6895 export COLLECT_NAMES
6896 fi
6897 ;;
6898 esac
6899
6900 # Global variables:
6901 ofile=libtool
6902 can_build_shared=yes
6903
6904 # All known linkers require a `.a' archive for static linking (except MSVC,
6905 # which needs '.lib').
6906 libext=a
6907
6908 with_gnu_ld="$lt_cv_prog_gnu_ld"
6909
6910 old_CC="$CC"
6911 old_CFLAGS="$CFLAGS"
6912
6913 # Set sane defaults for various variables
6914 test -z "$CC" && CC=cc
6915 test -z "$LTCC" && LTCC=$CC
6916 test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
6917 test -z "$LD" && LD=ld
6918 test -z "$ac_objext" && ac_objext=o
6919
6920 for cc_temp in $compiler""; do
6921 case $cc_temp in
6922 compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
6923 distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
6924 \-*) ;;
6925 *) break;;
6926 esac
6927 done
6928 cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
6929
6930
6931 # Only perform the check for file, if the check method requires it
6932 test -z "$MAGIC_CMD" && MAGIC_CMD=file
6933 case $deplibs_check_method in
6934 file_magic*)
6935 if test "$file_magic_cmd" = '$MAGIC_CMD'; then
6936 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
6937 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
6938 if ${lt_cv_path_MAGIC_CMD+:} false; then :
6939 $as_echo_n "(cached) " >&6
6940 else
6941 case $MAGIC_CMD in
6942 [\\/*] | ?:[\\/]*)
6943 lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
6944 ;;
6945 *)
6946 lt_save_MAGIC_CMD="$MAGIC_CMD"
6947 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
6948 ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
6949 for ac_dir in $ac_dummy; do
6950 IFS="$lt_save_ifs"
6951 test -z "$ac_dir" && ac_dir=.
6952 if test -f $ac_dir/${ac_tool_prefix}file; then
6953 lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
6954 if test -n "$file_magic_test_file"; then
6955 case $deplibs_check_method in
6956 "file_magic "*)
6957 file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
6958 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
6959 if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
6960 $EGREP "$file_magic_regex" > /dev/null; then
6961 :
6962 else
6963 cat <<_LT_EOF 1>&2
6964
6965 *** Warning: the command libtool uses to detect shared libraries,
6966 *** $file_magic_cmd, produces output that libtool cannot recognize.
6967 *** The result is that libtool may fail to recognize shared libraries
6968 *** as such. This will affect the creation of libtool libraries that
6969 *** depend on shared libraries, but programs linked with such libtool
6970 *** libraries will work regardless of this problem. Nevertheless, you
6971 *** may want to report the problem to your system manager and/or to
6972 *** bug-libtool@gnu.org
6973
6974 _LT_EOF
6975 fi ;;
6976 esac
6977 fi
6978 break
6979 fi
6980 done
6981 IFS="$lt_save_ifs"
6982 MAGIC_CMD="$lt_save_MAGIC_CMD"
6983 ;;
6984 esac
6985 fi
6986
6987 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
6988 if test -n "$MAGIC_CMD"; then
6989 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
6990 $as_echo "$MAGIC_CMD" >&6; }
6991 else
6992 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
6993 $as_echo "no" >&6; }
6994 fi
6995
6996
6997
6998
6999
7000 if test -z "$lt_cv_path_MAGIC_CMD"; then
7001 if test -n "$ac_tool_prefix"; then
7002 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
7003 $as_echo_n "checking for file... " >&6; }
7004 if ${lt_cv_path_MAGIC_CMD+:} false; then :
7005 $as_echo_n "(cached) " >&6
7006 else
7007 case $MAGIC_CMD in
7008 [\\/*] | ?:[\\/]*)
7009 lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
7010 ;;
7011 *)
7012 lt_save_MAGIC_CMD="$MAGIC_CMD"
7013 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
7014 ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
7015 for ac_dir in $ac_dummy; do
7016 IFS="$lt_save_ifs"
7017 test -z "$ac_dir" && ac_dir=.
7018 if test -f $ac_dir/file; then
7019 lt_cv_path_MAGIC_CMD="$ac_dir/file"
7020 if test -n "$file_magic_test_file"; then
7021 case $deplibs_check_method in
7022 "file_magic "*)
7023 file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
7024 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
7025 if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
7026 $EGREP "$file_magic_regex" > /dev/null; then
7027 :
7028 else
7029 cat <<_LT_EOF 1>&2
7030
7031 *** Warning: the command libtool uses to detect shared libraries,
7032 *** $file_magic_cmd, produces output that libtool cannot recognize.
7033 *** The result is that libtool may fail to recognize shared libraries
7034 *** as such. This will affect the creation of libtool libraries that
7035 *** depend on shared libraries, but programs linked with such libtool
7036 *** libraries will work regardless of this problem. Nevertheless, you
7037 *** may want to report the problem to your system manager and/or to
7038 *** bug-libtool@gnu.org
7039
7040 _LT_EOF
7041 fi ;;
7042 esac
7043 fi
7044 break
7045 fi
7046 done
7047 IFS="$lt_save_ifs"
7048 MAGIC_CMD="$lt_save_MAGIC_CMD"
7049 ;;
7050 esac
7051 fi
7052
7053 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
7054 if test -n "$MAGIC_CMD"; then
7055 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
7056 $as_echo "$MAGIC_CMD" >&6; }
7057 else
7058 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
7059 $as_echo "no" >&6; }
7060 fi
7061
7062
7063 else
7064 MAGIC_CMD=:
7065 fi
7066 fi
7067
7068 fi
7069 ;;
7070 esac
7071
7072 # Use C for the default configuration in the libtool script
7073
7074 lt_save_CC="$CC"
7075 ac_ext=c
7076 ac_cpp='$CPP $CPPFLAGS'
7077 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
7078 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
7079 ac_compiler_gnu=$ac_cv_c_compiler_gnu
7080
7081
7082 # Source file extension for C test sources.
7083 ac_ext=c
7084
7085 # Object file extension for compiled C test sources.
7086 objext=o
7087 objext=$objext
7088
7089 # Code to be used in simple compile tests
7090 lt_simple_compile_test_code="int some_variable = 0;"
7091
7092 # Code to be used in simple link tests
7093 lt_simple_link_test_code='int main(){return(0);}'
7094
7095
7096
7097
7098
7099
7100
7101 # If no C compiler was specified, use CC.
7102 LTCC=${LTCC-"$CC"}
7103
7104 # If no C compiler flags were specified, use CFLAGS.
7105 LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
7106
7107 # Allow CC to be a program name with arguments.
7108 compiler=$CC
7109
7110 # Save the default compiler, since it gets overwritten when the other
7111 # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
7112 compiler_DEFAULT=$CC
7113
7114 # save warnings/boilerplate of simple test code
7115 ac_outfile=conftest.$ac_objext
7116 echo "$lt_simple_compile_test_code" >conftest.$ac_ext
7117 eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
7118 _lt_compiler_boilerplate=`cat conftest.err`
7119 $RM conftest*
7120
7121 ac_outfile=conftest.$ac_objext
7122 echo "$lt_simple_link_test_code" >conftest.$ac_ext
7123 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
7124 _lt_linker_boilerplate=`cat conftest.err`
7125 $RM -r conftest*
7126
7127
7128 ## CAVEAT EMPTOR:
7129 ## There is no encapsulation within the following macros, do not change
7130 ## the running order or otherwise move them around unless you know exactly
7131 ## what you are doing...
7132 if test -n "$compiler"; then
7133
7134 lt_prog_compiler_no_builtin_flag=
7135
7136 if test "$GCC" = yes; then
7137 case $cc_basename in
7138 nvcc*)
7139 lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
7140 *)
7141 lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;
7142 esac
7143
7144 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
7145 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
7146 if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :
7147 $as_echo_n "(cached) " >&6
7148 else
7149 lt_cv_prog_compiler_rtti_exceptions=no
7150 ac_outfile=conftest.$ac_objext
7151 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
7152 lt_compiler_flag="-fno-rtti -fno-exceptions"
7153 # Insert the option either (1) after the last *FLAGS variable, or
7154 # (2) before a word containing "conftest.", or (3) at the end.
7155 # Note that $ac_compile itself does not contain backslashes and begins
7156 # with a dollar sign (not a hyphen), so the echo should work correctly.
7157 # The option is referenced via a variable to avoid confusing sed.
7158 lt_compile=`echo "$ac_compile" | $SED \
7159 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7160 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7161 -e 's:$: $lt_compiler_flag:'`
7162 (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
7163 (eval "$lt_compile" 2>conftest.err)
7164 ac_status=$?
7165 cat conftest.err >&5
7166 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7167 if (exit $ac_status) && test -s "$ac_outfile"; then
7168 # The compiler can only warn and ignore the option if not recognized
7169 # So say no if there are warnings other than the usual output.
7170 $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
7171 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
7172 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
7173 lt_cv_prog_compiler_rtti_exceptions=yes
7174 fi
7175 fi
7176 $RM conftest*
7177
7178 fi
7179 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
7180 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
7181
7182 if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
7183 lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
7184 else
7185 :
7186 fi
7187
7188 fi
7189
7190
7191
7192
7193
7194
7195 lt_prog_compiler_wl=
7196 lt_prog_compiler_pic=
7197 lt_prog_compiler_static=
7198
7199
7200 if test "$GCC" = yes; then
7201 lt_prog_compiler_wl='-Wl,'
7202 lt_prog_compiler_static='-static'
7203
7204 case $host_os in
7205 aix*)
7206 # All AIX code is PIC.
7207 if test "$host_cpu" = ia64; then
7208 # AIX 5 now supports IA64 processor
7209 lt_prog_compiler_static='-Bstatic'
7210 fi
7211 ;;
7212
7213 amigaos*)
7214 case $host_cpu in
7215 powerpc)
7216 # see comment about AmigaOS4 .so support
7217 lt_prog_compiler_pic='-fPIC'
7218 ;;
7219 m68k)
7220 # FIXME: we need at least 68020 code to build shared libraries, but
7221 # adding the `-m68020' flag to GCC prevents building anything better,
7222 # like `-m68040'.
7223 lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
7224 ;;
7225 esac
7226 ;;
7227
7228 beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
7229 # PIC is the default for these OSes.
7230 ;;
7231
7232 mingw* | cygwin* | pw32* | os2* | cegcc*)
7233 # This hack is so that the source file can tell whether it is being
7234 # built for inclusion in a dll (and should export symbols for example).
7235 # Although the cygwin gcc ignores -fPIC, still need this for old-style
7236 # (--disable-auto-import) libraries
7237 lt_prog_compiler_pic='-DDLL_EXPORT'
7238 ;;
7239
7240 darwin* | rhapsody*)
7241 # PIC is the default on this platform
7242 # Common symbols not allowed in MH_DYLIB files
7243 lt_prog_compiler_pic='-fno-common'
7244 ;;
7245
7246 haiku*)
7247 # PIC is the default for Haiku.
7248 # The "-static" flag exists, but is broken.
7249 lt_prog_compiler_static=
7250 ;;
7251
7252 hpux*)
7253 # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
7254 # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
7255 # sets the default TLS model and affects inlining.
7256 case $host_cpu in
7257 hppa*64*)
7258 # +Z the default
7259 ;;
7260 *)
7261 lt_prog_compiler_pic='-fPIC'
7262 ;;
7263 esac
7264 ;;
7265
7266 interix[3-9]*)
7267 # Interix 3.x gcc -fpic/-fPIC options generate broken code.
7268 # Instead, we relocate shared libraries at runtime.
7269 ;;
7270
7271 msdosdjgpp*)
7272 # Just because we use GCC doesn't mean we suddenly get shared libraries
7273 # on systems that don't support them.
7274 lt_prog_compiler_can_build_shared=no
7275 enable_shared=no
7276 ;;
7277
7278 *nto* | *qnx*)
7279 # QNX uses GNU C++, but need to define -shared option too, otherwise
7280 # it will coredump.
7281 lt_prog_compiler_pic='-fPIC -shared'
7282 ;;
7283
7284 sysv4*MP*)
7285 if test -d /usr/nec; then
7286 lt_prog_compiler_pic=-Kconform_pic
7287 fi
7288 ;;
7289
7290 *)
7291 lt_prog_compiler_pic='-fPIC'
7292 ;;
7293 esac
7294
7295 case $cc_basename in
7296 nvcc*) # Cuda Compiler Driver 2.2
7297 lt_prog_compiler_wl='-Xlinker '
7298 if test -n "$lt_prog_compiler_pic"; then
7299 lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic"
7300 fi
7301 ;;
7302 esac
7303 else
7304 # PORTME Check for flag to pass linker flags through the system compiler.
7305 case $host_os in
7306 aix*)
7307 lt_prog_compiler_wl='-Wl,'
7308 if test "$host_cpu" = ia64; then
7309 # AIX 5 now supports IA64 processor
7310 lt_prog_compiler_static='-Bstatic'
7311 else
7312 lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
7313 fi
7314 ;;
7315
7316 mingw* | cygwin* | pw32* | os2* | cegcc*)
7317 # This hack is so that the source file can tell whether it is being
7318 # built for inclusion in a dll (and should export symbols for example).
7319 lt_prog_compiler_pic='-DDLL_EXPORT'
7320 ;;
7321
7322 hpux9* | hpux10* | hpux11*)
7323 lt_prog_compiler_wl='-Wl,'
7324 # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
7325 # not for PA HP-UX.
7326 case $host_cpu in
7327 hppa*64*|ia64*)
7328 # +Z the default
7329 ;;
7330 *)
7331 lt_prog_compiler_pic='+Z'
7332 ;;
7333 esac
7334 # Is there a better lt_prog_compiler_static that works with the bundled CC?
7335 lt_prog_compiler_static='${wl}-a ${wl}archive'
7336 ;;
7337
7338 irix5* | irix6* | nonstopux*)
7339 lt_prog_compiler_wl='-Wl,'
7340 # PIC (with -KPIC) is the default.
7341 lt_prog_compiler_static='-non_shared'
7342 ;;
7343
7344 linux* | k*bsd*-gnu | kopensolaris*-gnu)
7345 case $cc_basename in
7346 # old Intel for x86_64 which still supported -KPIC.
7347 ecc*)
7348 lt_prog_compiler_wl='-Wl,'
7349 lt_prog_compiler_pic='-KPIC'
7350 lt_prog_compiler_static='-static'
7351 ;;
7352 # icc used to be incompatible with GCC.
7353 # ICC 10 doesn't accept -KPIC any more.
7354 icc* | ifort*)
7355 lt_prog_compiler_wl='-Wl,'
7356 lt_prog_compiler_pic='-fPIC'
7357 lt_prog_compiler_static='-static'
7358 ;;
7359 # Lahey Fortran 8.1.
7360 lf95*)
7361 lt_prog_compiler_wl='-Wl,'
7362 lt_prog_compiler_pic='--shared'
7363 lt_prog_compiler_static='--static'
7364 ;;
7365 nagfor*)
7366 # NAG Fortran compiler
7367 lt_prog_compiler_wl='-Wl,-Wl,,'
7368 lt_prog_compiler_pic='-PIC'
7369 lt_prog_compiler_static='-Bstatic'
7370 ;;
7371 pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
7372 # Portland Group compilers (*not* the Pentium gcc compiler,
7373 # which looks to be a dead project)
7374 lt_prog_compiler_wl='-Wl,'
7375 lt_prog_compiler_pic='-fpic'
7376 lt_prog_compiler_static='-Bstatic'
7377 ;;
7378 ccc*)
7379 lt_prog_compiler_wl='-Wl,'
7380 # All Alpha code is PIC.
7381 lt_prog_compiler_static='-non_shared'
7382 ;;
7383 xl* | bgxl* | bgf* | mpixl*)
7384 # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
7385 lt_prog_compiler_wl='-Wl,'
7386 lt_prog_compiler_pic='-qpic'
7387 lt_prog_compiler_static='-qstaticlink'
7388 ;;
7389 *)
7390 case `$CC -V 2>&1 | sed 5q` in
7391 *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
7392 # Sun Fortran 8.3 passes all unrecognized flags to the linker
7393 lt_prog_compiler_pic='-KPIC'
7394 lt_prog_compiler_static='-Bstatic'
7395 lt_prog_compiler_wl=''
7396 ;;
7397 *Sun\ F* | *Sun*Fortran*)
7398 lt_prog_compiler_pic='-KPIC'
7399 lt_prog_compiler_static='-Bstatic'
7400 lt_prog_compiler_wl='-Qoption ld '
7401 ;;
7402 *Sun\ C*)
7403 # Sun C 5.9
7404 lt_prog_compiler_pic='-KPIC'
7405 lt_prog_compiler_static='-Bstatic'
7406 lt_prog_compiler_wl='-Wl,'
7407 ;;
7408 *Intel*\ [CF]*Compiler*)
7409 lt_prog_compiler_wl='-Wl,'
7410 lt_prog_compiler_pic='-fPIC'
7411 lt_prog_compiler_static='-static'
7412 ;;
7413 *Portland\ Group*)
7414 lt_prog_compiler_wl='-Wl,'
7415 lt_prog_compiler_pic='-fpic'
7416 lt_prog_compiler_static='-Bstatic'
7417 ;;
7418 esac
7419 ;;
7420 esac
7421 ;;
7422
7423 newsos6)
7424 lt_prog_compiler_pic='-KPIC'
7425 lt_prog_compiler_static='-Bstatic'
7426 ;;
7427
7428 *nto* | *qnx*)
7429 # QNX uses GNU C++, but need to define -shared option too, otherwise
7430 # it will coredump.
7431 lt_prog_compiler_pic='-fPIC -shared'
7432 ;;
7433
7434 osf3* | osf4* | osf5*)
7435 lt_prog_compiler_wl='-Wl,'
7436 # All OSF/1 code is PIC.
7437 lt_prog_compiler_static='-non_shared'
7438 ;;
7439
7440 rdos*)
7441 lt_prog_compiler_static='-non_shared'
7442 ;;
7443
7444 solaris*)
7445 lt_prog_compiler_pic='-KPIC'
7446 lt_prog_compiler_static='-Bstatic'
7447 case $cc_basename in
7448 f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
7449 lt_prog_compiler_wl='-Qoption ld ';;
7450 *)
7451 lt_prog_compiler_wl='-Wl,';;
7452 esac
7453 ;;
7454
7455 sunos4*)
7456 lt_prog_compiler_wl='-Qoption ld '
7457 lt_prog_compiler_pic='-PIC'
7458 lt_prog_compiler_static='-Bstatic'
7459 ;;
7460
7461 sysv4 | sysv4.2uw2* | sysv4.3*)
7462 lt_prog_compiler_wl='-Wl,'
7463 lt_prog_compiler_pic='-KPIC'
7464 lt_prog_compiler_static='-Bstatic'
7465 ;;
7466
7467 sysv4*MP*)
7468 if test -d /usr/nec ;then
7469 lt_prog_compiler_pic='-Kconform_pic'
7470 lt_prog_compiler_static='-Bstatic'
7471 fi
7472 ;;
7473
7474 sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
7475 lt_prog_compiler_wl='-Wl,'
7476 lt_prog_compiler_pic='-KPIC'
7477 lt_prog_compiler_static='-Bstatic'
7478 ;;
7479
7480 unicos*)
7481 lt_prog_compiler_wl='-Wl,'
7482 lt_prog_compiler_can_build_shared=no
7483 ;;
7484
7485 uts4*)
7486 lt_prog_compiler_pic='-pic'
7487 lt_prog_compiler_static='-Bstatic'
7488 ;;
7489
7490 *)
7491 lt_prog_compiler_can_build_shared=no
7492 ;;
7493 esac
7494 fi
7495
7496 case $host_os in
7497 # For platforms which do not support PIC, -DPIC is meaningless:
7498 *djgpp*)
7499 lt_prog_compiler_pic=
7500 ;;
7501 *)
7502 lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
7503 ;;
7504 esac
7505
7506 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
7507 $as_echo_n "checking for $compiler option to produce PIC... " >&6; }
7508 if ${lt_cv_prog_compiler_pic+:} false; then :
7509 $as_echo_n "(cached) " >&6
7510 else
7511 lt_cv_prog_compiler_pic=$lt_prog_compiler_pic
7512 fi
7513 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5
7514 $as_echo "$lt_cv_prog_compiler_pic" >&6; }
7515 lt_prog_compiler_pic=$lt_cv_prog_compiler_pic
7516
7517 #
7518 # Check to make sure the PIC flag actually works.
7519 #
7520 if test -n "$lt_prog_compiler_pic"; then
7521 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
7522 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
7523 if ${lt_cv_prog_compiler_pic_works+:} false; then :
7524 $as_echo_n "(cached) " >&6
7525 else
7526 lt_cv_prog_compiler_pic_works=no
7527 ac_outfile=conftest.$ac_objext
7528 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
7529 lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
7530 # Insert the option either (1) after the last *FLAGS variable, or
7531 # (2) before a word containing "conftest.", or (3) at the end.
7532 # Note that $ac_compile itself does not contain backslashes and begins
7533 # with a dollar sign (not a hyphen), so the echo should work correctly.
7534 # The option is referenced via a variable to avoid confusing sed.
7535 lt_compile=`echo "$ac_compile" | $SED \
7536 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7537 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7538 -e 's:$: $lt_compiler_flag:'`
7539 (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
7540 (eval "$lt_compile" 2>conftest.err)
7541 ac_status=$?
7542 cat conftest.err >&5
7543 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7544 if (exit $ac_status) && test -s "$ac_outfile"; then
7545 # The compiler can only warn and ignore the option if not recognized
7546 # So say no if there are warnings other than the usual output.
7547 $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
7548 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
7549 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
7550 lt_cv_prog_compiler_pic_works=yes
7551 fi
7552 fi
7553 $RM conftest*
7554
7555 fi
7556 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
7557 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
7558
7559 if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
7560 case $lt_prog_compiler_pic in
7561 "" | " "*) ;;
7562 *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
7563 esac
7564 else
7565 lt_prog_compiler_pic=
7566 lt_prog_compiler_can_build_shared=no
7567 fi
7568
7569 fi
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581 #
7582 # Check to make sure the static flag actually works.
7583 #
7584 wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
7585 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
7586 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
7587 if ${lt_cv_prog_compiler_static_works+:} false; then :
7588 $as_echo_n "(cached) " >&6
7589 else
7590 lt_cv_prog_compiler_static_works=no
7591 save_LDFLAGS="$LDFLAGS"
7592 LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
7593 echo "$lt_simple_link_test_code" > conftest.$ac_ext
7594 if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
7595 # The linker can only warn and ignore the option if not recognized
7596 # So say no if there are warnings
7597 if test -s conftest.err; then
7598 # Append any errors to the config.log.
7599 cat conftest.err 1>&5
7600 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
7601 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
7602 if diff conftest.exp conftest.er2 >/dev/null; then
7603 lt_cv_prog_compiler_static_works=yes
7604 fi
7605 else
7606 lt_cv_prog_compiler_static_works=yes
7607 fi
7608 fi
7609 $RM -r conftest*
7610 LDFLAGS="$save_LDFLAGS"
7611
7612 fi
7613 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
7614 $as_echo "$lt_cv_prog_compiler_static_works" >&6; }
7615
7616 if test x"$lt_cv_prog_compiler_static_works" = xyes; then
7617 :
7618 else
7619 lt_prog_compiler_static=
7620 fi
7621
7622
7623
7624
7625
7626
7627
7628 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
7629 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
7630 if ${lt_cv_prog_compiler_c_o+:} false; then :
7631 $as_echo_n "(cached) " >&6
7632 else
7633 lt_cv_prog_compiler_c_o=no
7634 $RM -r conftest 2>/dev/null
7635 mkdir conftest
7636 cd conftest
7637 mkdir out
7638 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
7639
7640 lt_compiler_flag="-o out/conftest2.$ac_objext"
7641 # Insert the option either (1) after the last *FLAGS variable, or
7642 # (2) before a word containing "conftest.", or (3) at the end.
7643 # Note that $ac_compile itself does not contain backslashes and begins
7644 # with a dollar sign (not a hyphen), so the echo should work correctly.
7645 lt_compile=`echo "$ac_compile" | $SED \
7646 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7647 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7648 -e 's:$: $lt_compiler_flag:'`
7649 (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
7650 (eval "$lt_compile" 2>out/conftest.err)
7651 ac_status=$?
7652 cat out/conftest.err >&5
7653 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7654 if (exit $ac_status) && test -s out/conftest2.$ac_objext
7655 then
7656 # The compiler can only warn and ignore the option if not recognized
7657 # So say no if there are warnings
7658 $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
7659 $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
7660 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
7661 lt_cv_prog_compiler_c_o=yes
7662 fi
7663 fi
7664 chmod u+w . 2>&5
7665 $RM conftest*
7666 # SGI C++ compiler will create directory out/ii_files/ for
7667 # template instantiation
7668 test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
7669 $RM out/* && rmdir out
7670 cd ..
7671 $RM -r conftest
7672 $RM conftest*
7673
7674 fi
7675 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
7676 $as_echo "$lt_cv_prog_compiler_c_o" >&6; }
7677
7678
7679
7680
7681
7682
7683 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
7684 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
7685 if ${lt_cv_prog_compiler_c_o+:} false; then :
7686 $as_echo_n "(cached) " >&6
7687 else
7688 lt_cv_prog_compiler_c_o=no
7689 $RM -r conftest 2>/dev/null
7690 mkdir conftest
7691 cd conftest
7692 mkdir out
7693 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
7694
7695 lt_compiler_flag="-o out/conftest2.$ac_objext"
7696 # Insert the option either (1) after the last *FLAGS variable, or
7697 # (2) before a word containing "conftest.", or (3) at the end.
7698 # Note that $ac_compile itself does not contain backslashes and begins
7699 # with a dollar sign (not a hyphen), so the echo should work correctly.
7700 lt_compile=`echo "$ac_compile" | $SED \
7701 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7702 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7703 -e 's:$: $lt_compiler_flag:'`
7704 (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
7705 (eval "$lt_compile" 2>out/conftest.err)
7706 ac_status=$?
7707 cat out/conftest.err >&5
7708 echo "$as_me:$LINENO: \$? = $ac_status" >&5
7709 if (exit $ac_status) && test -s out/conftest2.$ac_objext
7710 then
7711 # The compiler can only warn and ignore the option if not recognized
7712 # So say no if there are warnings
7713 $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
7714 $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
7715 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
7716 lt_cv_prog_compiler_c_o=yes
7717 fi
7718 fi
7719 chmod u+w . 2>&5
7720 $RM conftest*
7721 # SGI C++ compiler will create directory out/ii_files/ for
7722 # template instantiation
7723 test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
7724 $RM out/* && rmdir out
7725 cd ..
7726 $RM -r conftest
7727 $RM conftest*
7728
7729 fi
7730 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
7731 $as_echo "$lt_cv_prog_compiler_c_o" >&6; }
7732
7733
7734
7735
7736 hard_links="nottested"
7737 if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
7738 # do not overwrite the value of need_locks provided by the user
7739 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
7740 $as_echo_n "checking if we can lock with hard links... " >&6; }
7741 hard_links=yes
7742 $RM conftest*
7743 ln conftest.a conftest.b 2>/dev/null && hard_links=no
7744 touch conftest.a
7745 ln conftest.a conftest.b 2>&5 || hard_links=no
7746 ln conftest.a conftest.b 2>/dev/null && hard_links=no
7747 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
7748 $as_echo "$hard_links" >&6; }
7749 if test "$hard_links" = no; then
7750 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
7751 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
7752 need_locks=warn
7753 fi
7754 else
7755 need_locks=no
7756 fi
7757
7758
7759
7760
7761
7762
7763 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
7764 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
7765
7766 runpath_var=
7767 allow_undefined_flag=
7768 always_export_symbols=no
7769 archive_cmds=
7770 archive_expsym_cmds=
7771 compiler_needs_object=no
7772 enable_shared_with_static_runtimes=no
7773 export_dynamic_flag_spec=
7774 export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
7775 hardcode_automatic=no
7776 hardcode_direct=no
7777 hardcode_direct_absolute=no
7778 hardcode_libdir_flag_spec=
7779 hardcode_libdir_separator=
7780 hardcode_minus_L=no
7781 hardcode_shlibpath_var=unsupported
7782 inherit_rpath=no
7783 link_all_deplibs=unknown
7784 module_cmds=
7785 module_expsym_cmds=
7786 old_archive_from_new_cmds=
7787 old_archive_from_expsyms_cmds=
7788 thread_safe_flag_spec=
7789 whole_archive_flag_spec=
7790 # include_expsyms should be a list of space-separated symbols to be *always*
7791 # included in the symbol list
7792 include_expsyms=
7793 # exclude_expsyms can be an extended regexp of symbols to exclude
7794 # it will be wrapped by ` (' and `)$', so one must not match beginning or
7795 # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
7796 # as well as any symbol that contains `d'.
7797 exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
7798 # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
7799 # platforms (ab)use it in PIC code, but their linkers get confused if
7800 # the symbol is explicitly referenced. Since portable code cannot
7801 # rely on this symbol name, it's probably fine to never include it in
7802 # preloaded symbol tables.
7803 # Exclude shared library initialization/finalization symbols.
7804 extract_expsyms_cmds=
7805
7806 case $host_os in
7807 cygwin* | mingw* | pw32* | cegcc*)
7808 # FIXME: the MSVC++ port hasn't been tested in a loooong time
7809 # When not using gcc, we currently assume that we are using
7810 # Microsoft Visual C++.
7811 if test "$GCC" != yes; then
7812 with_gnu_ld=no
7813 fi
7814 ;;
7815 interix*)
7816 # we just hope/assume this is gcc and not c89 (= MSVC++)
7817 with_gnu_ld=yes
7818 ;;
7819 openbsd*)
7820 with_gnu_ld=no
7821 ;;
7822 esac
7823
7824 ld_shlibs=yes
7825
7826 # On some targets, GNU ld is compatible enough with the native linker
7827 # that we're better off using the native interface for both.
7828 lt_use_gnu_ld_interface=no
7829 if test "$with_gnu_ld" = yes; then
7830 case $host_os in
7831 aix*)
7832 # The AIX port of GNU ld has always aspired to compatibility
7833 # with the native linker. However, as the warning in the GNU ld
7834 # block says, versions before 2.19.5* couldn't really create working
7835 # shared libraries, regardless of the interface used.
7836 case `$LD -v 2>&1` in
7837 *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
7838 *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
7839 *\ \(GNU\ Binutils\)\ [3-9]*) ;;
7840 *)
7841 lt_use_gnu_ld_interface=yes
7842 ;;
7843 esac
7844 ;;
7845 *)
7846 lt_use_gnu_ld_interface=yes
7847 ;;
7848 esac
7849 fi
7850
7851 if test "$lt_use_gnu_ld_interface" = yes; then
7852 # If archive_cmds runs LD, not CC, wlarc should be empty
7853 wlarc='${wl}'
7854
7855 # Set some defaults for GNU ld with shared library support. These
7856 # are reset later if shared libraries are not supported. Putting them
7857 # here allows them to be overridden if necessary.
7858 runpath_var=LD_RUN_PATH
7859 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
7860 export_dynamic_flag_spec='${wl}--export-dynamic'
7861 # ancient GNU ld didn't support --whole-archive et. al.
7862 if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
7863 whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
7864 else
7865 whole_archive_flag_spec=
7866 fi
7867 supports_anon_versioning=no
7868 case `$LD -v 2>&1` in
7869 *GNU\ gold*) supports_anon_versioning=yes ;;
7870 *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
7871 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
7872 *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
7873 *\ 2.11.*) ;; # other 2.11 versions
7874 *) supports_anon_versioning=yes ;;
7875 esac
7876
7877 # See if GNU ld supports shared libraries.
7878 case $host_os in
7879 aix[3-9]*)
7880 # On AIX/PPC, the GNU linker is very broken
7881 if test "$host_cpu" != ia64; then
7882 ld_shlibs=no
7883 cat <<_LT_EOF 1>&2
7884
7885 *** Warning: the GNU linker, at least up to release 2.19, is reported
7886 *** to be unable to reliably create shared libraries on AIX.
7887 *** Therefore, libtool is disabling shared libraries support. If you
7888 *** really care for shared libraries, you may want to install binutils
7889 *** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
7890 *** You will then need to restart the configuration process.
7891
7892 _LT_EOF
7893 fi
7894 ;;
7895
7896 amigaos*)
7897 case $host_cpu in
7898 powerpc)
7899 # see comment about AmigaOS4 .so support
7900 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
7901 archive_expsym_cmds=''
7902 ;;
7903 m68k)
7904 archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
7905 hardcode_libdir_flag_spec='-L$libdir'
7906 hardcode_minus_L=yes
7907 ;;
7908 esac
7909 ;;
7910
7911 beos*)
7912 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
7913 allow_undefined_flag=unsupported
7914 # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
7915 # support --undefined. This deserves some investigation. FIXME
7916 archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
7917 else
7918 ld_shlibs=no
7919 fi
7920 ;;
7921
7922 cygwin* | mingw* | pw32* | cegcc*)
7923 # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
7924 # as there is no search path for DLLs.
7925 hardcode_libdir_flag_spec='-L$libdir'
7926 export_dynamic_flag_spec='${wl}--export-all-symbols'
7927 allow_undefined_flag=unsupported
7928 always_export_symbols=no
7929 enable_shared_with_static_runtimes=yes
7930 export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
7931 exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
7932
7933 if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
7934 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
7935 # If the export-symbols file already is a .def file (1st line
7936 # is EXPORTS), use it as is; otherwise, prepend...
7937 archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
7938 cp $export_symbols $output_objdir/$soname.def;
7939 else
7940 echo EXPORTS > $output_objdir/$soname.def;
7941 cat $export_symbols >> $output_objdir/$soname.def;
7942 fi~
7943 $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
7944 else
7945 ld_shlibs=no
7946 fi
7947 ;;
7948
7949 haiku*)
7950 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
7951 link_all_deplibs=yes
7952 ;;
7953
7954 interix[3-9]*)
7955 hardcode_direct=no
7956 hardcode_shlibpath_var=no
7957 hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
7958 export_dynamic_flag_spec='${wl}-E'
7959 # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
7960 # Instead, shared libraries are loaded at an image base (0x10000000 by
7961 # default) and relocated if they conflict, which is a slow very memory
7962 # consuming and fragmenting process. To avoid this, we pick a random,
7963 # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
7964 # time. Moving up from 0x10000000 also allows more sbrk(2) space.
7965 archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
7966 archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
7967 ;;
7968
7969 gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
7970 tmp_diet=no
7971 if test "$host_os" = linux-dietlibc; then
7972 case $cc_basename in
7973 diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
7974 esac
7975 fi
7976 if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
7977 && test "$tmp_diet" = no
7978 then
7979 tmp_addflag=' $pic_flag'
7980 tmp_sharedflag='-shared'
7981 case $cc_basename,$host_cpu in
7982 pgcc*) # Portland Group C compiler
7983 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
7984 tmp_addflag=' $pic_flag'
7985 ;;
7986 pgf77* | pgf90* | pgf95* | pgfortran*)
7987 # Portland Group f77 and f90 compilers
7988 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
7989 tmp_addflag=' $pic_flag -Mnomain' ;;
7990 ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
7991 tmp_addflag=' -i_dynamic' ;;
7992 efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
7993 tmp_addflag=' -i_dynamic -nofor_main' ;;
7994 ifc* | ifort*) # Intel Fortran compiler
7995 tmp_addflag=' -nofor_main' ;;
7996 lf95*) # Lahey Fortran 8.1
7997 whole_archive_flag_spec=
7998 tmp_sharedflag='--shared' ;;
7999 xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
8000 tmp_sharedflag='-qmkshrobj'
8001 tmp_addflag= ;;
8002 nvcc*) # Cuda Compiler Driver 2.2
8003 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
8004 compiler_needs_object=yes
8005 ;;
8006 esac
8007 case `$CC -V 2>&1 | sed 5q` in
8008 *Sun\ C*) # Sun C 5.9
8009 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
8010 compiler_needs_object=yes
8011 tmp_sharedflag='-G' ;;
8012 *Sun\ F*) # Sun Fortran 8.3
8013 tmp_sharedflag='-G' ;;
8014 esac
8015 archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8016
8017 if test "x$supports_anon_versioning" = xyes; then
8018 archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
8019 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
8020 echo "local: *; };" >> $output_objdir/$libname.ver~
8021 $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
8022 fi
8023
8024 case $cc_basename in
8025 xlf* | bgf* | bgxlf* | mpixlf*)
8026 # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
8027 whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
8028 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8029 archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
8030 if test "x$supports_anon_versioning" = xyes; then
8031 archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
8032 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
8033 echo "local: *; };" >> $output_objdir/$libname.ver~
8034 $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
8035 fi
8036 ;;
8037 esac
8038 else
8039 ld_shlibs=no
8040 fi
8041 ;;
8042
8043 netbsd*)
8044 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
8045 archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
8046 wlarc=
8047 else
8048 archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8049 archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
8050 fi
8051 ;;
8052
8053 solaris*)
8054 if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
8055 ld_shlibs=no
8056 cat <<_LT_EOF 1>&2
8057
8058 *** Warning: The releases 2.8.* of the GNU linker cannot reliably
8059 *** create shared libraries on Solaris systems. Therefore, libtool
8060 *** is disabling shared libraries support. We urge you to upgrade GNU
8061 *** binutils to release 2.9.1 or newer. Another option is to modify
8062 *** your PATH or compiler configuration so that the native linker is
8063 *** used, and then restart.
8064
8065 _LT_EOF
8066 elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
8067 archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8068 archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
8069 else
8070 ld_shlibs=no
8071 fi
8072 ;;
8073
8074 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
8075 case `$LD -v 2>&1` in
8076 *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
8077 ld_shlibs=no
8078 cat <<_LT_EOF 1>&2
8079
8080 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
8081 *** reliably create shared libraries on SCO systems. Therefore, libtool
8082 *** is disabling shared libraries support. We urge you to upgrade GNU
8083 *** binutils to release 2.16.91.0.3 or newer. Another option is to modify
8084 *** your PATH or compiler configuration so that the native linker is
8085 *** used, and then restart.
8086
8087 _LT_EOF
8088 ;;
8089 *)
8090 # For security reasons, it is highly recommended that you always
8091 # use absolute paths for naming shared libraries, and exclude the
8092 # DT_RUNPATH tag from executables and libraries. But doing so
8093 # requires that you compile everything twice, which is a pain.
8094 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
8095 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8096 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8097 archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
8098 else
8099 ld_shlibs=no
8100 fi
8101 ;;
8102 esac
8103 ;;
8104
8105 sunos4*)
8106 archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
8107 wlarc=
8108 hardcode_direct=yes
8109 hardcode_shlibpath_var=no
8110 ;;
8111
8112 *)
8113 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
8114 archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8115 archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
8116 else
8117 ld_shlibs=no
8118 fi
8119 ;;
8120 esac
8121
8122 if test "$ld_shlibs" = no; then
8123 runpath_var=
8124 hardcode_libdir_flag_spec=
8125 export_dynamic_flag_spec=
8126 whole_archive_flag_spec=
8127 fi
8128 else
8129 # PORTME fill in a description of your system's linker (not GNU ld)
8130 case $host_os in
8131 aix3*)
8132 allow_undefined_flag=unsupported
8133 always_export_symbols=yes
8134 archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
8135 # Note: this linker hardcodes the directories in LIBPATH if there
8136 # are no directories specified by -L.
8137 hardcode_minus_L=yes
8138 if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
8139 # Neither direct hardcoding nor static linking is supported with a
8140 # broken collect2.
8141 hardcode_direct=unsupported
8142 fi
8143 ;;
8144
8145 aix[4-9]*)
8146 if test "$host_cpu" = ia64; then
8147 # On IA64, the linker does run time linking by default, so we don't
8148 # have to do anything special.
8149 aix_use_runtimelinking=no
8150 exp_sym_flag='-Bexport'
8151 no_entry_flag=""
8152 else
8153 # If we're using GNU nm, then we don't want the "-C" option.
8154 # -C means demangle to AIX nm, but means don't demangle with GNU nm
8155 # Also, AIX nm treats weak defined symbols like other global
8156 # defined symbols, whereas GNU nm marks them as "W".
8157 if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
8158 export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
8159 else
8160 export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
8161 fi
8162 aix_use_runtimelinking=no
8163
8164 # Test if we are trying to use run time linking or normal
8165 # AIX style linking. If -brtl is somewhere in LDFLAGS, we
8166 # need to do runtime linking.
8167 case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
8168 for ld_flag in $LDFLAGS; do
8169 if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
8170 aix_use_runtimelinking=yes
8171 break
8172 fi
8173 done
8174 ;;
8175 esac
8176
8177 exp_sym_flag='-bexport'
8178 no_entry_flag='-bnoentry'
8179 fi
8180
8181 # When large executables or shared objects are built, AIX ld can
8182 # have problems creating the table of contents. If linking a library
8183 # or program results in "error TOC overflow" add -mminimal-toc to
8184 # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
8185 # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
8186
8187 archive_cmds=''
8188 hardcode_direct=yes
8189 hardcode_direct_absolute=yes
8190 hardcode_libdir_separator=':'
8191 link_all_deplibs=yes
8192 file_list_spec='${wl}-f,'
8193
8194 if test "$GCC" = yes; then
8195 case $host_os in aix4.[012]|aix4.[012].*)
8196 # We only want to do this on AIX 4.2 and lower, the check
8197 # below for broken collect2 doesn't work under 4.3+
8198 collect2name=`${CC} -print-prog-name=collect2`
8199 if test -f "$collect2name" &&
8200 strings "$collect2name" | $GREP resolve_lib_name >/dev/null
8201 then
8202 # We have reworked collect2
8203 :
8204 else
8205 # We have old collect2
8206 hardcode_direct=unsupported
8207 # It fails to find uninstalled libraries when the uninstalled
8208 # path is not listed in the libpath. Setting hardcode_minus_L
8209 # to unsupported forces relinking
8210 hardcode_minus_L=yes
8211 hardcode_libdir_flag_spec='-L$libdir'
8212 hardcode_libdir_separator=
8213 fi
8214 ;;
8215 esac
8216 shared_flag='-shared'
8217 if test "$aix_use_runtimelinking" = yes; then
8218 shared_flag="$shared_flag "'${wl}-G'
8219 fi
8220 else
8221 # not using gcc
8222 if test "$host_cpu" = ia64; then
8223 # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
8224 # chokes on -Wl,-G. The following line is correct:
8225 shared_flag='-G'
8226 else
8227 if test "$aix_use_runtimelinking" = yes; then
8228 shared_flag='${wl}-G'
8229 else
8230 shared_flag='${wl}-bM:SRE'
8231 fi
8232 fi
8233 fi
8234
8235 export_dynamic_flag_spec='${wl}-bexpall'
8236 # It seems that -bexpall does not export symbols beginning with
8237 # underscore (_), so it is better to generate a list of symbols to export.
8238 always_export_symbols=yes
8239 if test "$aix_use_runtimelinking" = yes; then
8240 # Warning - without using the other runtime loading flags (-brtl),
8241 # -berok will link without error, but may produce a broken library.
8242 allow_undefined_flag='-berok'
8243 # Determine the default libpath from the value encoded in an
8244 # empty executable.
8245 if test "${lt_cv_aix_libpath+set}" = set; then
8246 aix_libpath=$lt_cv_aix_libpath
8247 else
8248 if ${lt_cv_aix_libpath_+:} false; then :
8249 $as_echo_n "(cached) " >&6
8250 else
8251 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
8252 /* end confdefs.h. */
8253
8254 int
8255 main ()
8256 {
8257
8258 ;
8259 return 0;
8260 }
8261 _ACEOF
8262 if ac_fn_c_try_link "$LINENO"; then :
8263
8264 lt_aix_libpath_sed='
8265 /Import File Strings/,/^$/ {
8266 /^0/ {
8267 s/^0 *\([^ ]*\) *$/\1/
8268 p
8269 }
8270 }'
8271 lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
8272 # Check for a 64-bit object if we didn't find anything.
8273 if test -z "$lt_cv_aix_libpath_"; then
8274 lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
8275 fi
8276 fi
8277 rm -f core conftest.err conftest.$ac_objext \
8278 conftest$ac_exeext conftest.$ac_ext
8279 if test -z "$lt_cv_aix_libpath_"; then
8280 lt_cv_aix_libpath_="/usr/lib:/lib"
8281 fi
8282
8283 fi
8284
8285 aix_libpath=$lt_cv_aix_libpath_
8286 fi
8287
8288 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
8289 archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
8290 else
8291 if test "$host_cpu" = ia64; then
8292 hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
8293 allow_undefined_flag="-z nodefs"
8294 archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
8295 else
8296 # Determine the default libpath from the value encoded in an
8297 # empty executable.
8298 if test "${lt_cv_aix_libpath+set}" = set; then
8299 aix_libpath=$lt_cv_aix_libpath
8300 else
8301 if ${lt_cv_aix_libpath_+:} false; then :
8302 $as_echo_n "(cached) " >&6
8303 else
8304 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
8305 /* end confdefs.h. */
8306
8307 int
8308 main ()
8309 {
8310
8311 ;
8312 return 0;
8313 }
8314 _ACEOF
8315 if ac_fn_c_try_link "$LINENO"; then :
8316
8317 lt_aix_libpath_sed='
8318 /Import File Strings/,/^$/ {
8319 /^0/ {
8320 s/^0 *\([^ ]*\) *$/\1/
8321 p
8322 }
8323 }'
8324 lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
8325 # Check for a 64-bit object if we didn't find anything.
8326 if test -z "$lt_cv_aix_libpath_"; then
8327 lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
8328 fi
8329 fi
8330 rm -f core conftest.err conftest.$ac_objext \
8331 conftest$ac_exeext conftest.$ac_ext
8332 if test -z "$lt_cv_aix_libpath_"; then
8333 lt_cv_aix_libpath_="/usr/lib:/lib"
8334 fi
8335
8336 fi
8337
8338 aix_libpath=$lt_cv_aix_libpath_
8339 fi
8340
8341 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
8342 # Warning - without using the other run time loading flags,
8343 # -berok will link without error, but may produce a broken library.
8344 no_undefined_flag=' ${wl}-bernotok'
8345 allow_undefined_flag=' ${wl}-berok'
8346 if test "$with_gnu_ld" = yes; then
8347 # We only use this code for GNU lds that support --whole-archive.
8348 whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
8349 else
8350 # Exported symbols can be pulled into shared objects from archives
8351 whole_archive_flag_spec='$convenience'
8352 fi
8353 archive_cmds_need_lc=yes
8354 # This is similar to how AIX traditionally builds its shared libraries.
8355 archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
8356 fi
8357 fi
8358 ;;
8359
8360 amigaos*)
8361 case $host_cpu in
8362 powerpc)
8363 # see comment about AmigaOS4 .so support
8364 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8365 archive_expsym_cmds=''
8366 ;;
8367 m68k)
8368 archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
8369 hardcode_libdir_flag_spec='-L$libdir'
8370 hardcode_minus_L=yes
8371 ;;
8372 esac
8373 ;;
8374
8375 bsdi[45]*)
8376 export_dynamic_flag_spec=-rdynamic
8377 ;;
8378
8379 cygwin* | mingw* | pw32* | cegcc*)
8380 # When not using gcc, we currently assume that we are using
8381 # Microsoft Visual C++.
8382 # hardcode_libdir_flag_spec is actually meaningless, as there is
8383 # no search path for DLLs.
8384 case $cc_basename in
8385 cl*)
8386 # Native MSVC
8387 hardcode_libdir_flag_spec=' '
8388 allow_undefined_flag=unsupported
8389 always_export_symbols=yes
8390 file_list_spec='@'
8391 # Tell ltmain to make .lib files, not .a files.
8392 libext=lib
8393 # Tell ltmain to make .dll files, not .so files.
8394 shrext_cmds=".dll"
8395 # FIXME: Setting linknames here is a bad hack.
8396 archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
8397 archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
8398 sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
8399 else
8400 sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
8401 fi~
8402 $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
8403 linknames='
8404 # The linker will not automatically build a static lib if we build a DLL.
8405 # _LT_TAGVAR(old_archive_from_new_cmds, )='true'
8406 enable_shared_with_static_runtimes=yes
8407 exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
8408 export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
8409 # Don't use ranlib
8410 old_postinstall_cmds='chmod 644 $oldlib'
8411 postlink_cmds='lt_outputfile="@OUTPUT@"~
8412 lt_tool_outputfile="@TOOL_OUTPUT@"~
8413 case $lt_outputfile in
8414 *.exe|*.EXE) ;;
8415 *)
8416 lt_outputfile="$lt_outputfile.exe"
8417 lt_tool_outputfile="$lt_tool_outputfile.exe"
8418 ;;
8419 esac~
8420 if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
8421 $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
8422 $RM "$lt_outputfile.manifest";
8423 fi'
8424 ;;
8425 *)
8426 # Assume MSVC wrapper
8427 hardcode_libdir_flag_spec=' '
8428 allow_undefined_flag=unsupported
8429 # Tell ltmain to make .lib files, not .a files.
8430 libext=lib
8431 # Tell ltmain to make .dll files, not .so files.
8432 shrext_cmds=".dll"
8433 # FIXME: Setting linknames here is a bad hack.
8434 archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
8435 # The linker will automatically build a .lib file if we build a DLL.
8436 old_archive_from_new_cmds='true'
8437 # FIXME: Should let the user specify the lib program.
8438 old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
8439 enable_shared_with_static_runtimes=yes
8440 ;;
8441 esac
8442 ;;
8443
8444 darwin* | rhapsody*)
8445
8446
8447 archive_cmds_need_lc=no
8448 hardcode_direct=no
8449 hardcode_automatic=yes
8450 hardcode_shlibpath_var=unsupported
8451 if test "$lt_cv_ld_force_load" = "yes"; then
8452 whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
8453
8454 else
8455 whole_archive_flag_spec=''
8456 fi
8457 link_all_deplibs=yes
8458 allow_undefined_flag="$_lt_dar_allow_undefined"
8459 case $cc_basename in
8460 ifort*) _lt_dar_can_shared=yes ;;
8461 *) _lt_dar_can_shared=$GCC ;;
8462 esac
8463 if test "$_lt_dar_can_shared" = "yes"; then
8464 output_verbose_link_cmd=func_echo_all
8465 archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
8466 module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
8467 archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
8468 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
8469
8470 else
8471 ld_shlibs=no
8472 fi
8473
8474 ;;
8475
8476 dgux*)
8477 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8478 hardcode_libdir_flag_spec='-L$libdir'
8479 hardcode_shlibpath_var=no
8480 ;;
8481
8482 # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
8483 # support. Future versions do this automatically, but an explicit c++rt0.o
8484 # does not break anything, and helps significantly (at the cost of a little
8485 # extra space).
8486 freebsd2.2*)
8487 archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
8488 hardcode_libdir_flag_spec='-R$libdir'
8489 hardcode_direct=yes
8490 hardcode_shlibpath_var=no
8491 ;;
8492
8493 # Unfortunately, older versions of FreeBSD 2 do not have this feature.
8494 freebsd2.*)
8495 archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
8496 hardcode_direct=yes
8497 hardcode_minus_L=yes
8498 hardcode_shlibpath_var=no
8499 ;;
8500
8501 # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
8502 freebsd* | dragonfly*)
8503 archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
8504 hardcode_libdir_flag_spec='-R$libdir'
8505 hardcode_direct=yes
8506 hardcode_shlibpath_var=no
8507 ;;
8508
8509 hpux9*)
8510 if test "$GCC" = yes; then
8511 archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
8512 else
8513 archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
8514 fi
8515 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
8516 hardcode_libdir_separator=:
8517 hardcode_direct=yes
8518
8519 # hardcode_minus_L: Not really in the search PATH,
8520 # but as the default location of the library.
8521 hardcode_minus_L=yes
8522 export_dynamic_flag_spec='${wl}-E'
8523 ;;
8524
8525 hpux10*)
8526 if test "$GCC" = yes && test "$with_gnu_ld" = no; then
8527 archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
8528 else
8529 archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
8530 fi
8531 if test "$with_gnu_ld" = no; then
8532 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
8533 hardcode_libdir_separator=:
8534 hardcode_direct=yes
8535 hardcode_direct_absolute=yes
8536 export_dynamic_flag_spec='${wl}-E'
8537 # hardcode_minus_L: Not really in the search PATH,
8538 # but as the default location of the library.
8539 hardcode_minus_L=yes
8540 fi
8541 ;;
8542
8543 hpux11*)
8544 if test "$GCC" = yes && test "$with_gnu_ld" = no; then
8545 case $host_cpu in
8546 hppa*64*)
8547 archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
8548 ;;
8549 ia64*)
8550 archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
8551 ;;
8552 *)
8553 archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
8554 ;;
8555 esac
8556 else
8557 case $host_cpu in
8558 hppa*64*)
8559 archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
8560 ;;
8561 ia64*)
8562 archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
8563 ;;
8564 *)
8565
8566 # Older versions of the 11.00 compiler do not understand -b yet
8567 # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
8568 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
8569 $as_echo_n "checking if $CC understands -b... " >&6; }
8570 if ${lt_cv_prog_compiler__b+:} false; then :
8571 $as_echo_n "(cached) " >&6
8572 else
8573 lt_cv_prog_compiler__b=no
8574 save_LDFLAGS="$LDFLAGS"
8575 LDFLAGS="$LDFLAGS -b"
8576 echo "$lt_simple_link_test_code" > conftest.$ac_ext
8577 if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
8578 # The linker can only warn and ignore the option if not recognized
8579 # So say no if there are warnings
8580 if test -s conftest.err; then
8581 # Append any errors to the config.log.
8582 cat conftest.err 1>&5
8583 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
8584 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
8585 if diff conftest.exp conftest.er2 >/dev/null; then
8586 lt_cv_prog_compiler__b=yes
8587 fi
8588 else
8589 lt_cv_prog_compiler__b=yes
8590 fi
8591 fi
8592 $RM -r conftest*
8593 LDFLAGS="$save_LDFLAGS"
8594
8595 fi
8596 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
8597 $as_echo "$lt_cv_prog_compiler__b" >&6; }
8598
8599 if test x"$lt_cv_prog_compiler__b" = xyes; then
8600 archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
8601 else
8602 archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
8603 fi
8604
8605 ;;
8606 esac
8607 fi
8608 if test "$with_gnu_ld" = no; then
8609 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
8610 hardcode_libdir_separator=:
8611
8612 case $host_cpu in
8613 hppa*64*|ia64*)
8614 hardcode_direct=no
8615 hardcode_shlibpath_var=no
8616 ;;
8617 *)
8618 hardcode_direct=yes
8619 hardcode_direct_absolute=yes
8620 export_dynamic_flag_spec='${wl}-E'
8621
8622 # hardcode_minus_L: Not really in the search PATH,
8623 # but as the default location of the library.
8624 hardcode_minus_L=yes
8625 ;;
8626 esac
8627 fi
8628 ;;
8629
8630 irix5* | irix6* | nonstopux*)
8631 if test "$GCC" = yes; then
8632 archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
8633 # Try to use the -exported_symbol ld option, if it does not
8634 # work, assume that -exports_file does not work either and
8635 # implicitly export all symbols.
8636 # This should be the same for all languages, so no per-tag cache variable.
8637 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
8638 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
8639 if ${lt_cv_irix_exported_symbol+:} false; then :
8640 $as_echo_n "(cached) " >&6
8641 else
8642 save_LDFLAGS="$LDFLAGS"
8643 LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
8644 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
8645 /* end confdefs.h. */
8646 int foo (void) { return 0; }
8647 _ACEOF
8648 if ac_fn_c_try_link "$LINENO"; then :
8649 lt_cv_irix_exported_symbol=yes
8650 else
8651 lt_cv_irix_exported_symbol=no
8652 fi
8653 rm -f core conftest.err conftest.$ac_objext \
8654 conftest$ac_exeext conftest.$ac_ext
8655 LDFLAGS="$save_LDFLAGS"
8656 fi
8657 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
8658 $as_echo "$lt_cv_irix_exported_symbol" >&6; }
8659 if test "$lt_cv_irix_exported_symbol" = yes; then
8660 archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
8661 fi
8662 else
8663 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
8664 archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
8665 fi
8666 archive_cmds_need_lc='no'
8667 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8668 hardcode_libdir_separator=:
8669 inherit_rpath=yes
8670 link_all_deplibs=yes
8671 ;;
8672
8673 netbsd*)
8674 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
8675 archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
8676 else
8677 archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
8678 fi
8679 hardcode_libdir_flag_spec='-R$libdir'
8680 hardcode_direct=yes
8681 hardcode_shlibpath_var=no
8682 ;;
8683
8684 newsos6)
8685 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8686 hardcode_direct=yes
8687 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8688 hardcode_libdir_separator=:
8689 hardcode_shlibpath_var=no
8690 ;;
8691
8692 *nto* | *qnx*)
8693 ;;
8694
8695 openbsd*)
8696 if test -f /usr/libexec/ld.so; then
8697 hardcode_direct=yes
8698 hardcode_shlibpath_var=no
8699 hardcode_direct_absolute=yes
8700 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
8701 archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
8702 archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
8703 hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
8704 export_dynamic_flag_spec='${wl}-E'
8705 else
8706 case $host_os in
8707 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
8708 archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
8709 hardcode_libdir_flag_spec='-R$libdir'
8710 ;;
8711 *)
8712 archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
8713 hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
8714 ;;
8715 esac
8716 fi
8717 else
8718 ld_shlibs=no
8719 fi
8720 ;;
8721
8722 os2*)
8723 hardcode_libdir_flag_spec='-L$libdir'
8724 hardcode_minus_L=yes
8725 allow_undefined_flag=unsupported
8726 archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
8727 old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
8728 ;;
8729
8730 osf3*)
8731 if test "$GCC" = yes; then
8732 allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
8733 archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
8734 else
8735 allow_undefined_flag=' -expect_unresolved \*'
8736 archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
8737 fi
8738 archive_cmds_need_lc='no'
8739 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8740 hardcode_libdir_separator=:
8741 ;;
8742
8743 osf4* | osf5*) # as osf3* with the addition of -msym flag
8744 if test "$GCC" = yes; then
8745 allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
8746 archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
8747 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8748 else
8749 allow_undefined_flag=' -expect_unresolved \*'
8750 archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
8751 archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
8752 $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
8753
8754 # Both c and cxx compiler support -rpath directly
8755 hardcode_libdir_flag_spec='-rpath $libdir'
8756 fi
8757 archive_cmds_need_lc='no'
8758 hardcode_libdir_separator=:
8759 ;;
8760
8761 solaris*)
8762 no_undefined_flag=' -z defs'
8763 if test "$GCC" = yes; then
8764 wlarc='${wl}'
8765 archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
8766 archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
8767 $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
8768 else
8769 case `$CC -V 2>&1` in
8770 *"Compilers 5.0"*)
8771 wlarc=''
8772 archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
8773 archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
8774 $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
8775 ;;
8776 *)
8777 wlarc='${wl}'
8778 archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
8779 archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
8780 $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
8781 ;;
8782 esac
8783 fi
8784 hardcode_libdir_flag_spec='-R$libdir'
8785 hardcode_shlibpath_var=no
8786 case $host_os in
8787 solaris2.[0-5] | solaris2.[0-5].*) ;;
8788 *)
8789 # The compiler driver will combine and reorder linker options,
8790 # but understands `-z linker_flag'. GCC discards it without `$wl',
8791 # but is careful enough not to reorder.
8792 # Supported since Solaris 2.6 (maybe 2.5.1?)
8793 if test "$GCC" = yes; then
8794 whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
8795 else
8796 whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
8797 fi
8798 ;;
8799 esac
8800 link_all_deplibs=yes
8801 ;;
8802
8803 sunos4*)
8804 if test "x$host_vendor" = xsequent; then
8805 # Use $CC to link under sequent, because it throws in some extra .o
8806 # files that make .init and .fini sections work.
8807 archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
8808 else
8809 archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
8810 fi
8811 hardcode_libdir_flag_spec='-L$libdir'
8812 hardcode_direct=yes
8813 hardcode_minus_L=yes
8814 hardcode_shlibpath_var=no
8815 ;;
8816
8817 sysv4)
8818 case $host_vendor in
8819 sni)
8820 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8821 hardcode_direct=yes # is this really true???
8822 ;;
8823 siemens)
8824 ## LD is ld it makes a PLAMLIB
8825 ## CC just makes a GrossModule.
8826 archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
8827 reload_cmds='$CC -r -o $output$reload_objs'
8828 hardcode_direct=no
8829 ;;
8830 motorola)
8831 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8832 hardcode_direct=no #Motorola manual says yes, but my tests say they lie
8833 ;;
8834 esac
8835 runpath_var='LD_RUN_PATH'
8836 hardcode_shlibpath_var=no
8837 ;;
8838
8839 sysv4.3*)
8840 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8841 hardcode_shlibpath_var=no
8842 export_dynamic_flag_spec='-Bexport'
8843 ;;
8844
8845 sysv4*MP*)
8846 if test -d /usr/nec; then
8847 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8848 hardcode_shlibpath_var=no
8849 runpath_var=LD_RUN_PATH
8850 hardcode_runpath_var=yes
8851 ld_shlibs=yes
8852 fi
8853 ;;
8854
8855 sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
8856 no_undefined_flag='${wl}-z,text'
8857 archive_cmds_need_lc=no
8858 hardcode_shlibpath_var=no
8859 runpath_var='LD_RUN_PATH'
8860
8861 if test "$GCC" = yes; then
8862 archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8863 archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8864 else
8865 archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8866 archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8867 fi
8868 ;;
8869
8870 sysv5* | sco3.2v5* | sco5v6*)
8871 # Note: We can NOT use -z defs as we might desire, because we do not
8872 # link with -lc, and that would cause any symbols used from libc to
8873 # always be unresolved, which means just about no library would
8874 # ever link correctly. If we're not using GNU ld we use -z text
8875 # though, which does catch some bad symbols but isn't as heavy-handed
8876 # as -z defs.
8877 no_undefined_flag='${wl}-z,text'
8878 allow_undefined_flag='${wl}-z,nodefs'
8879 archive_cmds_need_lc=no
8880 hardcode_shlibpath_var=no
8881 hardcode_libdir_flag_spec='${wl}-R,$libdir'
8882 hardcode_libdir_separator=':'
8883 link_all_deplibs=yes
8884 export_dynamic_flag_spec='${wl}-Bexport'
8885 runpath_var='LD_RUN_PATH'
8886
8887 if test "$GCC" = yes; then
8888 archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8889 archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8890 else
8891 archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8892 archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
8893 fi
8894 ;;
8895
8896 uts4*)
8897 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8898 hardcode_libdir_flag_spec='-L$libdir'
8899 hardcode_shlibpath_var=no
8900 ;;
8901
8902 *)
8903 ld_shlibs=no
8904 ;;
8905 esac
8906
8907 if test x$host_vendor = xsni; then
8908 case $host in
8909 sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
8910 export_dynamic_flag_spec='${wl}-Blargedynsym'
8911 ;;
8912 esac
8913 fi
8914 fi
8915
8916 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
8917 $as_echo "$ld_shlibs" >&6; }
8918 test "$ld_shlibs" = no && can_build_shared=no
8919
8920 with_gnu_ld=$with_gnu_ld
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936 #
8937 # Do we need to explicitly link libc?
8938 #
8939 case "x$archive_cmds_need_lc" in
8940 x|xyes)
8941 # Assume -lc should be added
8942 archive_cmds_need_lc=yes
8943
8944 if test "$enable_shared" = yes && test "$GCC" = yes; then
8945 case $archive_cmds in
8946 *'~'*)
8947 # FIXME: we may have to deal with multi-command sequences.
8948 ;;
8949 '$CC '*)
8950 # Test whether the compiler implicitly links with -lc since on some
8951 # systems, -lgcc has to come before -lc. If gcc already passes -lc
8952 # to ld, don't add -lc before -lgcc.
8953 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
8954 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
8955 if ${lt_cv_archive_cmds_need_lc+:} false; then :
8956 $as_echo_n "(cached) " >&6
8957 else
8958 $RM conftest*
8959 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
8960
8961 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
8962 (eval $ac_compile) 2>&5
8963 ac_status=$?
8964 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
8965 test $ac_status = 0; } 2>conftest.err; then
8966 soname=conftest
8967 lib=conftest
8968 libobjs=conftest.$ac_objext
8969 deplibs=
8970 wl=$lt_prog_compiler_wl
8971 pic_flag=$lt_prog_compiler_pic
8972 compiler_flags=-v
8973 linker_flags=-v
8974 verstring=
8975 output_objdir=.
8976 libname=conftest
8977 lt_save_allow_undefined_flag=$allow_undefined_flag
8978 allow_undefined_flag=
8979 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
8980 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
8981 ac_status=$?
8982 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
8983 test $ac_status = 0; }
8984 then
8985 lt_cv_archive_cmds_need_lc=no
8986 else
8987 lt_cv_archive_cmds_need_lc=yes
8988 fi
8989 allow_undefined_flag=$lt_save_allow_undefined_flag
8990 else
8991 cat conftest.err 1>&5
8992 fi
8993 $RM conftest*
8994
8995 fi
8996 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
8997 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; }
8998 archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc
8999 ;;
9000 esac
9001 fi
9002 ;;
9003 esac
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156 { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
9157 $as_echo_n "checking dynamic linker characteristics... " >&6; }
9158
9159 if test "$GCC" = yes; then
9160 case $host_os in
9161 darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
9162 *) lt_awk_arg="/^libraries:/" ;;
9163 esac
9164 case $host_os in
9165 mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
9166 *) lt_sed_strip_eq="s,=/,/,g" ;;
9167 esac
9168 lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
9169 case $lt_search_path_spec in
9170 *\;*)
9171 # if the path contains ";" then we assume it to be the separator
9172 # otherwise default to the standard path separator (i.e. ":") - it is
9173 # assumed that no part of a normal pathname contains ";" but that should
9174 # okay in the real world where ";" in dirpaths is itself problematic.
9175 lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
9176 ;;
9177 *)
9178 lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
9179 ;;
9180 esac
9181 # Ok, now we have the path, separated by spaces, we can step through it
9182 # and add multilib dir if necessary.
9183 lt_tmp_lt_search_path_spec=
9184 lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
9185 for lt_sys_path in $lt_search_path_spec; do
9186 if test -d "$lt_sys_path/$lt_multi_os_dir"; then
9187 lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
9188 else
9189 test -d "$lt_sys_path" && \
9190 lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
9191 fi
9192 done
9193 lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
9194 BEGIN {RS=" "; FS="/|\n";} {
9195 lt_foo="";
9196 lt_count=0;
9197 for (lt_i = NF; lt_i > 0; lt_i--) {
9198 if ($lt_i != "" && $lt_i != ".") {
9199 if ($lt_i == "..") {
9200 lt_count++;
9201 } else {
9202 if (lt_count == 0) {
9203 lt_foo="/" $lt_i lt_foo;
9204 } else {
9205 lt_count--;
9206 }
9207 }
9208 }
9209 }
9210 if (lt_foo != "") { lt_freq[lt_foo]++; }
9211 if (lt_freq[lt_foo] == 1) { print lt_foo; }
9212 }'`
9213 # AWK program above erroneously prepends '/' to C:/dos/paths
9214 # for these hosts.
9215 case $host_os in
9216 mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
9217 $SED 's,/\([A-Za-z]:\),\1,g'` ;;
9218 esac
9219 sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
9220 else
9221 sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
9222 fi
9223 library_names_spec=
9224 libname_spec='lib$name'
9225 soname_spec=
9226 shrext_cmds=".so"
9227 postinstall_cmds=
9228 postuninstall_cmds=
9229 finish_cmds=
9230 finish_eval=
9231 shlibpath_var=
9232 shlibpath_overrides_runpath=unknown
9233 version_type=none
9234 dynamic_linker="$host_os ld.so"
9235 sys_lib_dlsearch_path_spec="/lib /usr/lib"
9236 need_lib_prefix=unknown
9237 hardcode_into_libs=no
9238
9239 # when you set need_version to no, make sure it does not cause -set_version
9240 # flags to be left without arguments
9241 need_version=unknown
9242
9243 case $host_os in
9244 aix3*)
9245 version_type=linux # correct to gnu/linux during the next big refactor
9246 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
9247 shlibpath_var=LIBPATH
9248
9249 # AIX 3 has no versioning support, so we append a major version to the name.
9250 soname_spec='${libname}${release}${shared_ext}$major'
9251 ;;
9252
9253 aix[4-9]*)
9254 version_type=linux # correct to gnu/linux during the next big refactor
9255 need_lib_prefix=no
9256 need_version=no
9257 hardcode_into_libs=yes
9258 if test "$host_cpu" = ia64; then
9259 # AIX 5 supports IA64
9260 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
9261 shlibpath_var=LD_LIBRARY_PATH
9262 else
9263 # With GCC up to 2.95.x, collect2 would create an import file
9264 # for dependence libraries. The import file would start with
9265 # the line `#! .'. This would cause the generated library to
9266 # depend on `.', always an invalid library. This was fixed in
9267 # development snapshots of GCC prior to 3.0.
9268 case $host_os in
9269 aix4 | aix4.[01] | aix4.[01].*)
9270 if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
9271 echo ' yes '
9272 echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
9273 :
9274 else
9275 can_build_shared=no
9276 fi
9277 ;;
9278 esac
9279 # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
9280 # soname into executable. Probably we can add versioning support to
9281 # collect2, so additional links can be useful in future.
9282 if test "$aix_use_runtimelinking" = yes; then
9283 # If using run time linking (on AIX 4.2 or later) use lib<name>.so
9284 # instead of lib<name>.a to let people know that these are not
9285 # typical AIX shared libraries.
9286 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9287 else
9288 # We preserve .a as extension for shared libraries through AIX4.2
9289 # and later when we are not doing run time linking.
9290 library_names_spec='${libname}${release}.a $libname.a'
9291 soname_spec='${libname}${release}${shared_ext}$major'
9292 fi
9293 shlibpath_var=LIBPATH
9294 fi
9295 ;;
9296
9297 amigaos*)
9298 case $host_cpu in
9299 powerpc)
9300 # Since July 2007 AmigaOS4 officially supports .so libraries.
9301 # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
9302 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9303 ;;
9304 m68k)
9305 library_names_spec='$libname.ixlibrary $libname.a'
9306 # Create ${libname}_ixlibrary.a entries in /sys/libs.
9307 finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
9308 ;;
9309 esac
9310 ;;
9311
9312 beos*)
9313 library_names_spec='${libname}${shared_ext}'
9314 dynamic_linker="$host_os ld.so"
9315 shlibpath_var=LIBRARY_PATH
9316 ;;
9317
9318 bsdi[45]*)
9319 version_type=linux # correct to gnu/linux during the next big refactor
9320 need_version=no
9321 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9322 soname_spec='${libname}${release}${shared_ext}$major'
9323 finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
9324 shlibpath_var=LD_LIBRARY_PATH
9325 sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
9326 sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
9327 # the default ld.so.conf also contains /usr/contrib/lib and
9328 # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
9329 # libtool to hard-code these into programs
9330 ;;
9331
9332 cygwin* | mingw* | pw32* | cegcc*)
9333 version_type=windows
9334 shrext_cmds=".dll"
9335 need_version=no
9336 need_lib_prefix=no
9337
9338 case $GCC,$cc_basename in
9339 yes,*)
9340 # gcc
9341 library_names_spec='$libname.dll.a'
9342 # DLL is installed to $(libdir)/../bin by postinstall_cmds
9343 postinstall_cmds='base_file=`basename \${file}`~
9344 dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
9345 dldir=$destdir/`dirname \$dlpath`~
9346 test -d \$dldir || mkdir -p \$dldir~
9347 $install_prog $dir/$dlname \$dldir/$dlname~
9348 chmod a+x \$dldir/$dlname~
9349 if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
9350 eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
9351 fi'
9352 postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
9353 dlpath=$dir/\$dldll~
9354 $RM \$dlpath'
9355 shlibpath_overrides_runpath=yes
9356
9357 case $host_os in
9358 cygwin*)
9359 # Cygwin DLLs use 'cyg' prefix rather than 'lib'
9360 soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
9361
9362 sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
9363 ;;
9364 mingw* | cegcc*)
9365 # MinGW DLLs use traditional 'lib' prefix
9366 soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
9367 ;;
9368 pw32*)
9369 # pw32 DLLs use 'pw' prefix rather than 'lib'
9370 library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
9371 ;;
9372 esac
9373 dynamic_linker='Win32 ld.exe'
9374 ;;
9375
9376 *,cl*)
9377 # Native MSVC
9378 libname_spec='$name'
9379 soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
9380 library_names_spec='${libname}.dll.lib'
9381
9382 case $build_os in
9383 mingw*)
9384 sys_lib_search_path_spec=
9385 lt_save_ifs=$IFS
9386 IFS=';'
9387 for lt_path in $LIB
9388 do
9389 IFS=$lt_save_ifs
9390 # Let DOS variable expansion print the short 8.3 style file name.
9391 lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
9392 sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
9393 done
9394 IFS=$lt_save_ifs
9395 # Convert to MSYS style.
9396 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
9397 ;;
9398 cygwin*)
9399 # Convert to unix form, then to dos form, then back to unix form
9400 # but this time dos style (no spaces!) so that the unix form looks
9401 # like /cygdrive/c/PROGRA~1:/cygdr...
9402 sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
9403 sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
9404 sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
9405 ;;
9406 *)
9407 sys_lib_search_path_spec="$LIB"
9408 if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
9409 # It is most probably a Windows format PATH.
9410 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
9411 else
9412 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
9413 fi
9414 # FIXME: find the short name or the path components, as spaces are
9415 # common. (e.g. "Program Files" -> "PROGRA~1")
9416 ;;
9417 esac
9418
9419 # DLL is installed to $(libdir)/../bin by postinstall_cmds
9420 postinstall_cmds='base_file=`basename \${file}`~
9421 dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
9422 dldir=$destdir/`dirname \$dlpath`~
9423 test -d \$dldir || mkdir -p \$dldir~
9424 $install_prog $dir/$dlname \$dldir/$dlname'
9425 postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
9426 dlpath=$dir/\$dldll~
9427 $RM \$dlpath'
9428 shlibpath_overrides_runpath=yes
9429 dynamic_linker='Win32 link.exe'
9430 ;;
9431
9432 *)
9433 # Assume MSVC wrapper
9434 library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
9435 dynamic_linker='Win32 ld.exe'
9436 ;;
9437 esac
9438 # FIXME: first we should search . and the directory the executable is in
9439 shlibpath_var=PATH
9440 ;;
9441
9442 darwin* | rhapsody*)
9443 dynamic_linker="$host_os dyld"
9444 version_type=darwin
9445 need_lib_prefix=no
9446 need_version=no
9447 library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
9448 soname_spec='${libname}${release}${major}$shared_ext'
9449 shlibpath_overrides_runpath=yes
9450 shlibpath_var=DYLD_LIBRARY_PATH
9451 shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
9452
9453 sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
9454 sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
9455 ;;
9456
9457 dgux*)
9458 version_type=linux # correct to gnu/linux during the next big refactor
9459 need_lib_prefix=no
9460 need_version=no
9461 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
9462 soname_spec='${libname}${release}${shared_ext}$major'
9463 shlibpath_var=LD_LIBRARY_PATH
9464 ;;
9465
9466 freebsd* | dragonfly*)
9467 # DragonFly does not have aout. When/if they implement a new
9468 # versioning mechanism, adjust this.
9469 if test -x /usr/bin/objformat; then
9470 objformat=`/usr/bin/objformat`
9471 else
9472 case $host_os in
9473 freebsd[23].*) objformat=aout ;;
9474 *) objformat=elf ;;
9475 esac
9476 fi
9477 version_type=freebsd-$objformat
9478 case $version_type in
9479 freebsd-elf*)
9480 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
9481 need_version=no
9482 need_lib_prefix=no
9483 ;;
9484 freebsd-*)
9485 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
9486 need_version=yes
9487 ;;
9488 esac
9489 shlibpath_var=LD_LIBRARY_PATH
9490 case $host_os in
9491 freebsd2.*)
9492 shlibpath_overrides_runpath=yes
9493 ;;
9494 freebsd3.[01]* | freebsdelf3.[01]*)
9495 shlibpath_overrides_runpath=yes
9496 hardcode_into_libs=yes
9497 ;;
9498 freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
9499 freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
9500 shlibpath_overrides_runpath=no
9501 hardcode_into_libs=yes
9502 ;;
9503 *) # from 4.6 on, and DragonFly
9504 shlibpath_overrides_runpath=yes
9505 hardcode_into_libs=yes
9506 ;;
9507 esac
9508 ;;
9509
9510 gnu*)
9511 version_type=linux # correct to gnu/linux during the next big refactor
9512 need_lib_prefix=no
9513 need_version=no
9514 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
9515 soname_spec='${libname}${release}${shared_ext}$major'
9516 shlibpath_var=LD_LIBRARY_PATH
9517 shlibpath_overrides_runpath=no
9518 hardcode_into_libs=yes
9519 ;;
9520
9521 haiku*)
9522 version_type=linux # correct to gnu/linux during the next big refactor
9523 need_lib_prefix=no
9524 need_version=no
9525 dynamic_linker="$host_os runtime_loader"
9526 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
9527 soname_spec='${libname}${release}${shared_ext}$major'
9528 shlibpath_var=LIBRARY_PATH
9529 shlibpath_overrides_runpath=yes
9530 sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
9531 hardcode_into_libs=yes
9532 ;;
9533
9534 hpux9* | hpux10* | hpux11*)
9535 # Give a soname corresponding to the major version so that dld.sl refuses to
9536 # link against other versions.
9537 version_type=sunos
9538 need_lib_prefix=no
9539 need_version=no
9540 case $host_cpu in
9541 ia64*)
9542 shrext_cmds='.so'
9543 hardcode_into_libs=yes
9544 dynamic_linker="$host_os dld.so"
9545 shlibpath_var=LD_LIBRARY_PATH
9546 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
9547 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9548 soname_spec='${libname}${release}${shared_ext}$major'
9549 if test "X$HPUX_IA64_MODE" = X32; then
9550 sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
9551 else
9552 sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
9553 fi
9554 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
9555 ;;
9556 hppa*64*)
9557 shrext_cmds='.sl'
9558 hardcode_into_libs=yes
9559 dynamic_linker="$host_os dld.sl"
9560 shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
9561 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
9562 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9563 soname_spec='${libname}${release}${shared_ext}$major'
9564 sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
9565 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
9566 ;;
9567 *)
9568 shrext_cmds='.sl'
9569 dynamic_linker="$host_os dld.sl"
9570 shlibpath_var=SHLIB_PATH
9571 shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
9572 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9573 soname_spec='${libname}${release}${shared_ext}$major'
9574 ;;
9575 esac
9576 # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
9577 postinstall_cmds='chmod 555 $lib'
9578 # or fails outright, so override atomically:
9579 install_override_mode=555
9580 ;;
9581
9582 interix[3-9]*)
9583 version_type=linux # correct to gnu/linux during the next big refactor
9584 need_lib_prefix=no
9585 need_version=no
9586 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
9587 soname_spec='${libname}${release}${shared_ext}$major'
9588 dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
9589 shlibpath_var=LD_LIBRARY_PATH
9590 shlibpath_overrides_runpath=no
9591 hardcode_into_libs=yes
9592 ;;
9593
9594 irix5* | irix6* | nonstopux*)
9595 case $host_os in
9596 nonstopux*) version_type=nonstopux ;;
9597 *)
9598 if test "$lt_cv_prog_gnu_ld" = yes; then
9599 version_type=linux # correct to gnu/linux during the next big refactor
9600 else
9601 version_type=irix
9602 fi ;;
9603 esac
9604 need_lib_prefix=no
9605 need_version=no
9606 soname_spec='${libname}${release}${shared_ext}$major'
9607 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
9608 case $host_os in
9609 irix5* | nonstopux*)
9610 libsuff= shlibsuff=
9611 ;;
9612 *)
9613 case $LD in # libtool.m4 will add one of these switches to LD
9614 *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
9615 libsuff= shlibsuff= libmagic=32-bit;;
9616 *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
9617 libsuff=32 shlibsuff=N32 libmagic=N32;;
9618 *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
9619 libsuff=64 shlibsuff=64 libmagic=64-bit;;
9620 *) libsuff= shlibsuff= libmagic=never-match;;
9621 esac
9622 ;;
9623 esac
9624 shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
9625 shlibpath_overrides_runpath=no
9626 sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
9627 sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
9628 hardcode_into_libs=yes
9629 ;;
9630
9631 # No shared lib support for Linux oldld, aout, or coff.
9632 linux*oldld* | linux*aout* | linux*coff*)
9633 dynamic_linker=no
9634 ;;
9635
9636 # This must be glibc/ELF.
9637 linux* | k*bsd*-gnu | kopensolaris*-gnu)
9638 version_type=linux # correct to gnu/linux during the next big refactor
9639 need_lib_prefix=no
9640 need_version=no
9641 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9642 soname_spec='${libname}${release}${shared_ext}$major'
9643 finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
9644 shlibpath_var=LD_LIBRARY_PATH
9645 shlibpath_overrides_runpath=no
9646
9647 # Some binutils ld are patched to set DT_RUNPATH
9648 if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
9649 $as_echo_n "(cached) " >&6
9650 else
9651 lt_cv_shlibpath_overrides_runpath=no
9652 save_LDFLAGS=$LDFLAGS
9653 save_libdir=$libdir
9654 eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
9655 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
9656 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
9657 /* end confdefs.h. */
9658
9659 int
9660 main ()
9661 {
9662
9663 ;
9664 return 0;
9665 }
9666 _ACEOF
9667 if ac_fn_c_try_link "$LINENO"; then :
9668 if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
9669 lt_cv_shlibpath_overrides_runpath=yes
9670 fi
9671 fi
9672 rm -f core conftest.err conftest.$ac_objext \
9673 conftest$ac_exeext conftest.$ac_ext
9674 LDFLAGS=$save_LDFLAGS
9675 libdir=$save_libdir
9676
9677 fi
9678
9679 shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
9680
9681 # This implies no fast_install, which is unacceptable.
9682 # Some rework will be needed to allow for fast_install
9683 # before this can be enabled.
9684 hardcode_into_libs=yes
9685
9686 # Add ABI-specific directories to the system library path.
9687 sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
9688
9689 # Append ld.so.conf contents to the search path
9690 if test -f /etc/ld.so.conf; then
9691 lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
9692 sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
9693
9694 fi
9695
9696 # We used to test for /lib/ld.so.1 and disable shared libraries on
9697 # powerpc, because MkLinux only supported shared libraries with the
9698 # GNU dynamic linker. Since this was broken with cross compilers,
9699 # most powerpc-linux boxes support dynamic linking these days and
9700 # people can always --disable-shared, the test was removed, and we
9701 # assume the GNU/Linux dynamic linker is in use.
9702 dynamic_linker='GNU/Linux ld.so'
9703 ;;
9704
9705 netbsd*)
9706 version_type=sunos
9707 need_lib_prefix=no
9708 need_version=no
9709 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
9710 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
9711 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
9712 dynamic_linker='NetBSD (a.out) ld.so'
9713 else
9714 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
9715 soname_spec='${libname}${release}${shared_ext}$major'
9716 dynamic_linker='NetBSD ld.elf_so'
9717 fi
9718 shlibpath_var=LD_LIBRARY_PATH
9719 shlibpath_overrides_runpath=yes
9720 hardcode_into_libs=yes
9721 ;;
9722
9723 newsos6)
9724 version_type=linux # correct to gnu/linux during the next big refactor
9725 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9726 shlibpath_var=LD_LIBRARY_PATH
9727 shlibpath_overrides_runpath=yes
9728 ;;
9729
9730 *nto* | *qnx*)
9731 version_type=qnx
9732 need_lib_prefix=no
9733 need_version=no
9734 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9735 soname_spec='${libname}${release}${shared_ext}$major'
9736 shlibpath_var=LD_LIBRARY_PATH
9737 shlibpath_overrides_runpath=no
9738 hardcode_into_libs=yes
9739 dynamic_linker='ldqnx.so'
9740 ;;
9741
9742 openbsd*)
9743 version_type=sunos
9744 sys_lib_dlsearch_path_spec="/usr/lib"
9745 need_lib_prefix=no
9746 # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
9747 case $host_os in
9748 openbsd3.3 | openbsd3.3.*) need_version=yes ;;
9749 *) need_version=no ;;
9750 esac
9751 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
9752 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
9753 shlibpath_var=LD_LIBRARY_PATH
9754 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
9755 case $host_os in
9756 openbsd2.[89] | openbsd2.[89].*)
9757 shlibpath_overrides_runpath=no
9758 ;;
9759 *)
9760 shlibpath_overrides_runpath=yes
9761 ;;
9762 esac
9763 else
9764 shlibpath_overrides_runpath=yes
9765 fi
9766 ;;
9767
9768 os2*)
9769 libname_spec='$name'
9770 shrext_cmds=".dll"
9771 need_lib_prefix=no
9772 library_names_spec='$libname${shared_ext} $libname.a'
9773 dynamic_linker='OS/2 ld.exe'
9774 shlibpath_var=LIBPATH
9775 ;;
9776
9777 osf3* | osf4* | osf5*)
9778 version_type=osf
9779 need_lib_prefix=no
9780 need_version=no
9781 soname_spec='${libname}${release}${shared_ext}$major'
9782 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9783 shlibpath_var=LD_LIBRARY_PATH
9784 sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
9785 sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
9786 ;;
9787
9788 rdos*)
9789 dynamic_linker=no
9790 ;;
9791
9792 solaris*)
9793 version_type=linux # correct to gnu/linux during the next big refactor
9794 need_lib_prefix=no
9795 need_version=no
9796 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9797 soname_spec='${libname}${release}${shared_ext}$major'
9798 shlibpath_var=LD_LIBRARY_PATH
9799 shlibpath_overrides_runpath=yes
9800 hardcode_into_libs=yes
9801 # ldd complains unless libraries are executable
9802 postinstall_cmds='chmod +x $lib'
9803 ;;
9804
9805 sunos4*)
9806 version_type=sunos
9807 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
9808 finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
9809 shlibpath_var=LD_LIBRARY_PATH
9810 shlibpath_overrides_runpath=yes
9811 if test "$with_gnu_ld" = yes; then
9812 need_lib_prefix=no
9813 fi
9814 need_version=yes
9815 ;;
9816
9817 sysv4 | sysv4.3*)
9818 version_type=linux # correct to gnu/linux during the next big refactor
9819 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9820 soname_spec='${libname}${release}${shared_ext}$major'
9821 shlibpath_var=LD_LIBRARY_PATH
9822 case $host_vendor in
9823 sni)
9824 shlibpath_overrides_runpath=no
9825 need_lib_prefix=no
9826 runpath_var=LD_RUN_PATH
9827 ;;
9828 siemens)
9829 need_lib_prefix=no
9830 ;;
9831 motorola)
9832 need_lib_prefix=no
9833 need_version=no
9834 shlibpath_overrides_runpath=no
9835 sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
9836 ;;
9837 esac
9838 ;;
9839
9840 sysv4*MP*)
9841 if test -d /usr/nec ;then
9842 version_type=linux # correct to gnu/linux during the next big refactor
9843 library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
9844 soname_spec='$libname${shared_ext}.$major'
9845 shlibpath_var=LD_LIBRARY_PATH
9846 fi
9847 ;;
9848
9849 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
9850 version_type=freebsd-elf
9851 need_lib_prefix=no
9852 need_version=no
9853 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
9854 soname_spec='${libname}${release}${shared_ext}$major'
9855 shlibpath_var=LD_LIBRARY_PATH
9856 shlibpath_overrides_runpath=yes
9857 hardcode_into_libs=yes
9858 if test "$with_gnu_ld" = yes; then
9859 sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
9860 else
9861 sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
9862 case $host_os in
9863 sco3.2v5*)
9864 sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
9865 ;;
9866 esac
9867 fi
9868 sys_lib_dlsearch_path_spec='/usr/lib'
9869 ;;
9870
9871 tpf*)
9872 # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
9873 version_type=linux # correct to gnu/linux during the next big refactor
9874 need_lib_prefix=no
9875 need_version=no
9876 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9877 shlibpath_var=LD_LIBRARY_PATH
9878 shlibpath_overrides_runpath=no
9879 hardcode_into_libs=yes
9880 ;;
9881
9882 uts4*)
9883 version_type=linux # correct to gnu/linux during the next big refactor
9884 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9885 soname_spec='${libname}${release}${shared_ext}$major'
9886 shlibpath_var=LD_LIBRARY_PATH
9887 ;;
9888
9889 *)
9890 dynamic_linker=no
9891 ;;
9892 esac
9893 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
9894 $as_echo "$dynamic_linker" >&6; }
9895 test "$dynamic_linker" = no && can_build_shared=no
9896
9897 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
9898 if test "$GCC" = yes; then
9899 variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
9900 fi
9901
9902 if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
9903 sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
9904 fi
9905 if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
9906 sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
9907 fi
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
10001 $as_echo_n "checking how to hardcode library paths into programs... " >&6; }
10002 hardcode_action=
10003 if test -n "$hardcode_libdir_flag_spec" ||
10004 test -n "$runpath_var" ||
10005 test "X$hardcode_automatic" = "Xyes" ; then
10006
10007 # We can hardcode non-existent directories.
10008 if test "$hardcode_direct" != no &&
10009 # If the only mechanism to avoid hardcoding is shlibpath_var, we
10010 # have to relink, otherwise we might link with an installed library
10011 # when we should be linking with a yet-to-be-installed one
10012 ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
10013 test "$hardcode_minus_L" != no; then
10014 # Linking always hardcodes the temporary library directory.
10015 hardcode_action=relink
10016 else
10017 # We can link without hardcoding, and we can hardcode nonexisting dirs.
10018 hardcode_action=immediate
10019 fi
10020 else
10021 # We cannot hardcode anything, or else we can only hardcode existing
10022 # directories.
10023 hardcode_action=unsupported
10024 fi
10025 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
10026 $as_echo "$hardcode_action" >&6; }
10027
10028 if test "$hardcode_action" = relink ||
10029 test "$inherit_rpath" = yes; then
10030 # Fast installation is not supported
10031 enable_fast_install=no
10032 elif test "$shlibpath_overrides_runpath" = yes ||
10033 test "$enable_shared" = no; then
10034 # Fast installation is not necessary
10035 enable_fast_install=needless
10036 fi
10037
10038
10039
10040
10041
10042
10043 if test "x$enable_dlopen" != xyes; then
10044 enable_dlopen=unknown
10045 enable_dlopen_self=unknown
10046 enable_dlopen_self_static=unknown
10047 else
10048 lt_cv_dlopen=no
10049 lt_cv_dlopen_libs=
10050
10051 case $host_os in
10052 beos*)
10053 lt_cv_dlopen="load_add_on"
10054 lt_cv_dlopen_libs=
10055 lt_cv_dlopen_self=yes
10056 ;;
10057
10058 mingw* | pw32* | cegcc*)
10059 lt_cv_dlopen="LoadLibrary"
10060 lt_cv_dlopen_libs=
10061 ;;
10062
10063 cygwin*)
10064 lt_cv_dlopen="dlopen"
10065 lt_cv_dlopen_libs=
10066 ;;
10067
10068 darwin*)
10069 # if libdl is installed we need to link against it
10070 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
10071 $as_echo_n "checking for dlopen in -ldl... " >&6; }
10072 if ${ac_cv_lib_dl_dlopen+:} false; then :
10073 $as_echo_n "(cached) " >&6
10074 else
10075 ac_check_lib_save_LIBS=$LIBS
10076 LIBS="-ldl $LIBS"
10077 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10078 /* end confdefs.h. */
10079
10080 /* Override any GCC internal prototype to avoid an error.
10081 Use char because int might match the return type of a GCC
10082 builtin and then its argument prototype would still apply. */
10083 #ifdef __cplusplus
10084 extern "C"
10085 #endif
10086 char dlopen ();
10087 int
10088 main ()
10089 {
10090 return dlopen ();
10091 ;
10092 return 0;
10093 }
10094 _ACEOF
10095 if ac_fn_c_try_link "$LINENO"; then :
10096 ac_cv_lib_dl_dlopen=yes
10097 else
10098 ac_cv_lib_dl_dlopen=no
10099 fi
10100 rm -f core conftest.err conftest.$ac_objext \
10101 conftest$ac_exeext conftest.$ac_ext
10102 LIBS=$ac_check_lib_save_LIBS
10103 fi
10104 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
10105 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
10106 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
10107 lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
10108 else
10109
10110 lt_cv_dlopen="dyld"
10111 lt_cv_dlopen_libs=
10112 lt_cv_dlopen_self=yes
10113
10114 fi
10115
10116 ;;
10117
10118 *)
10119 ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
10120 if test "x$ac_cv_func_shl_load" = xyes; then :
10121 lt_cv_dlopen="shl_load"
10122 else
10123 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
10124 $as_echo_n "checking for shl_load in -ldld... " >&6; }
10125 if ${ac_cv_lib_dld_shl_load+:} false; then :
10126 $as_echo_n "(cached) " >&6
10127 else
10128 ac_check_lib_save_LIBS=$LIBS
10129 LIBS="-ldld $LIBS"
10130 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10131 /* end confdefs.h. */
10132
10133 /* Override any GCC internal prototype to avoid an error.
10134 Use char because int might match the return type of a GCC
10135 builtin and then its argument prototype would still apply. */
10136 #ifdef __cplusplus
10137 extern "C"
10138 #endif
10139 char shl_load ();
10140 int
10141 main ()
10142 {
10143 return shl_load ();
10144 ;
10145 return 0;
10146 }
10147 _ACEOF
10148 if ac_fn_c_try_link "$LINENO"; then :
10149 ac_cv_lib_dld_shl_load=yes
10150 else
10151 ac_cv_lib_dld_shl_load=no
10152 fi
10153 rm -f core conftest.err conftest.$ac_objext \
10154 conftest$ac_exeext conftest.$ac_ext
10155 LIBS=$ac_check_lib_save_LIBS
10156 fi
10157 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
10158 $as_echo "$ac_cv_lib_dld_shl_load" >&6; }
10159 if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
10160 lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
10161 else
10162 ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
10163 if test "x$ac_cv_func_dlopen" = xyes; then :
10164 lt_cv_dlopen="dlopen"
10165 else
10166 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
10167 $as_echo_n "checking for dlopen in -ldl... " >&6; }
10168 if ${ac_cv_lib_dl_dlopen+:} false; then :
10169 $as_echo_n "(cached) " >&6
10170 else
10171 ac_check_lib_save_LIBS=$LIBS
10172 LIBS="-ldl $LIBS"
10173 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10174 /* end confdefs.h. */
10175
10176 /* Override any GCC internal prototype to avoid an error.
10177 Use char because int might match the return type of a GCC
10178 builtin and then its argument prototype would still apply. */
10179 #ifdef __cplusplus
10180 extern "C"
10181 #endif
10182 char dlopen ();
10183 int
10184 main ()
10185 {
10186 return dlopen ();
10187 ;
10188 return 0;
10189 }
10190 _ACEOF
10191 if ac_fn_c_try_link "$LINENO"; then :
10192 ac_cv_lib_dl_dlopen=yes
10193 else
10194 ac_cv_lib_dl_dlopen=no
10195 fi
10196 rm -f core conftest.err conftest.$ac_objext \
10197 conftest$ac_exeext conftest.$ac_ext
10198 LIBS=$ac_check_lib_save_LIBS
10199 fi
10200 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
10201 $as_echo "$ac_cv_lib_dl_dlopen" >&6; }
10202 if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
10203 lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
10204 else
10205 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
10206 $as_echo_n "checking for dlopen in -lsvld... " >&6; }
10207 if ${ac_cv_lib_svld_dlopen+:} false; then :
10208 $as_echo_n "(cached) " >&6
10209 else
10210 ac_check_lib_save_LIBS=$LIBS
10211 LIBS="-lsvld $LIBS"
10212 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10213 /* end confdefs.h. */
10214
10215 /* Override any GCC internal prototype to avoid an error.
10216 Use char because int might match the return type of a GCC
10217 builtin and then its argument prototype would still apply. */
10218 #ifdef __cplusplus
10219 extern "C"
10220 #endif
10221 char dlopen ();
10222 int
10223 main ()
10224 {
10225 return dlopen ();
10226 ;
10227 return 0;
10228 }
10229 _ACEOF
10230 if ac_fn_c_try_link "$LINENO"; then :
10231 ac_cv_lib_svld_dlopen=yes
10232 else
10233 ac_cv_lib_svld_dlopen=no
10234 fi
10235 rm -f core conftest.err conftest.$ac_objext \
10236 conftest$ac_exeext conftest.$ac_ext
10237 LIBS=$ac_check_lib_save_LIBS
10238 fi
10239 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
10240 $as_echo "$ac_cv_lib_svld_dlopen" >&6; }
10241 if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
10242 lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
10243 else
10244 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
10245 $as_echo_n "checking for dld_link in -ldld... " >&6; }
10246 if ${ac_cv_lib_dld_dld_link+:} false; then :
10247 $as_echo_n "(cached) " >&6
10248 else
10249 ac_check_lib_save_LIBS=$LIBS
10250 LIBS="-ldld $LIBS"
10251 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10252 /* end confdefs.h. */
10253
10254 /* Override any GCC internal prototype to avoid an error.
10255 Use char because int might match the return type of a GCC
10256 builtin and then its argument prototype would still apply. */
10257 #ifdef __cplusplus
10258 extern "C"
10259 #endif
10260 char dld_link ();
10261 int
10262 main ()
10263 {
10264 return dld_link ();
10265 ;
10266 return 0;
10267 }
10268 _ACEOF
10269 if ac_fn_c_try_link "$LINENO"; then :
10270 ac_cv_lib_dld_dld_link=yes
10271 else
10272 ac_cv_lib_dld_dld_link=no
10273 fi
10274 rm -f core conftest.err conftest.$ac_objext \
10275 conftest$ac_exeext conftest.$ac_ext
10276 LIBS=$ac_check_lib_save_LIBS
10277 fi
10278 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
10279 $as_echo "$ac_cv_lib_dld_dld_link" >&6; }
10280 if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
10281 lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
10282 fi
10283
10284
10285 fi
10286
10287
10288 fi
10289
10290
10291 fi
10292
10293
10294 fi
10295
10296
10297 fi
10298
10299 ;;
10300 esac
10301
10302 if test "x$lt_cv_dlopen" != xno; then
10303 enable_dlopen=yes
10304 else
10305 enable_dlopen=no
10306 fi
10307
10308 case $lt_cv_dlopen in
10309 dlopen)
10310 save_CPPFLAGS="$CPPFLAGS"
10311 test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
10312
10313 save_LDFLAGS="$LDFLAGS"
10314 wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
10315
10316 save_LIBS="$LIBS"
10317 LIBS="$lt_cv_dlopen_libs $LIBS"
10318
10319 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
10320 $as_echo_n "checking whether a program can dlopen itself... " >&6; }
10321 if ${lt_cv_dlopen_self+:} false; then :
10322 $as_echo_n "(cached) " >&6
10323 else
10324 if test "$cross_compiling" = yes; then :
10325 lt_cv_dlopen_self=cross
10326 else
10327 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
10328 lt_status=$lt_dlunknown
10329 cat > conftest.$ac_ext <<_LT_EOF
10330 #line $LINENO "configure"
10331 #include "confdefs.h"
10332
10333 #if HAVE_DLFCN_H
10334 #include <dlfcn.h>
10335 #endif
10336
10337 #include <stdio.h>
10338
10339 #ifdef RTLD_GLOBAL
10340 # define LT_DLGLOBAL RTLD_GLOBAL
10341 #else
10342 # ifdef DL_GLOBAL
10343 # define LT_DLGLOBAL DL_GLOBAL
10344 # else
10345 # define LT_DLGLOBAL 0
10346 # endif
10347 #endif
10348
10349 /* We may have to define LT_DLLAZY_OR_NOW in the command line if we
10350 find out it does not work in some platform. */
10351 #ifndef LT_DLLAZY_OR_NOW
10352 # ifdef RTLD_LAZY
10353 # define LT_DLLAZY_OR_NOW RTLD_LAZY
10354 # else
10355 # ifdef DL_LAZY
10356 # define LT_DLLAZY_OR_NOW DL_LAZY
10357 # else
10358 # ifdef RTLD_NOW
10359 # define LT_DLLAZY_OR_NOW RTLD_NOW
10360 # else
10361 # ifdef DL_NOW
10362 # define LT_DLLAZY_OR_NOW DL_NOW
10363 # else
10364 # define LT_DLLAZY_OR_NOW 0
10365 # endif
10366 # endif
10367 # endif
10368 # endif
10369 #endif
10370
10371 /* When -fvisbility=hidden is used, assume the code has been annotated
10372 correspondingly for the symbols needed. */
10373 #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
10374 int fnord () __attribute__((visibility("default")));
10375 #endif
10376
10377 int fnord () { return 42; }
10378 int main ()
10379 {
10380 void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
10381 int status = $lt_dlunknown;
10382
10383 if (self)
10384 {
10385 if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
10386 else
10387 {
10388 if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
10389 else puts (dlerror ());
10390 }
10391 /* dlclose (self); */
10392 }
10393 else
10394 puts (dlerror ());
10395
10396 return status;
10397 }
10398 _LT_EOF
10399 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
10400 (eval $ac_link) 2>&5
10401 ac_status=$?
10402 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
10403 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
10404 (./conftest; exit; ) >&5 2>/dev/null
10405 lt_status=$?
10406 case x$lt_status in
10407 x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
10408 x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
10409 x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
10410 esac
10411 else :
10412 # compilation failed
10413 lt_cv_dlopen_self=no
10414 fi
10415 fi
10416 rm -fr conftest*
10417
10418
10419 fi
10420 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
10421 $as_echo "$lt_cv_dlopen_self" >&6; }
10422
10423 if test "x$lt_cv_dlopen_self" = xyes; then
10424 wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
10425 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
10426 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
10427 if ${lt_cv_dlopen_self_static+:} false; then :
10428 $as_echo_n "(cached) " >&6
10429 else
10430 if test "$cross_compiling" = yes; then :
10431 lt_cv_dlopen_self_static=cross
10432 else
10433 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
10434 lt_status=$lt_dlunknown
10435 cat > conftest.$ac_ext <<_LT_EOF
10436 #line $LINENO "configure"
10437 #include "confdefs.h"
10438
10439 #if HAVE_DLFCN_H
10440 #include <dlfcn.h>
10441 #endif
10442
10443 #include <stdio.h>
10444
10445 #ifdef RTLD_GLOBAL
10446 # define LT_DLGLOBAL RTLD_GLOBAL
10447 #else
10448 # ifdef DL_GLOBAL
10449 # define LT_DLGLOBAL DL_GLOBAL
10450 # else
10451 # define LT_DLGLOBAL 0
10452 # endif
10453 #endif
10454
10455 /* We may have to define LT_DLLAZY_OR_NOW in the command line if we
10456 find out it does not work in some platform. */
10457 #ifndef LT_DLLAZY_OR_NOW
10458 # ifdef RTLD_LAZY
10459 # define LT_DLLAZY_OR_NOW RTLD_LAZY
10460 # else
10461 # ifdef DL_LAZY
10462 # define LT_DLLAZY_OR_NOW DL_LAZY
10463 # else
10464 # ifdef RTLD_NOW
10465 # define LT_DLLAZY_OR_NOW RTLD_NOW
10466 # else
10467 # ifdef DL_NOW
10468 # define LT_DLLAZY_OR_NOW DL_NOW
10469 # else
10470 # define LT_DLLAZY_OR_NOW 0
10471 # endif
10472 # endif
10473 # endif
10474 # endif
10475 #endif
10476
10477 /* When -fvisbility=hidden is used, assume the code has been annotated
10478 correspondingly for the symbols needed. */
10479 #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
10480 int fnord () __attribute__((visibility("default")));
10481 #endif
10482
10483 int fnord () { return 42; }
10484 int main ()
10485 {
10486 void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
10487 int status = $lt_dlunknown;
10488
10489 if (self)
10490 {
10491 if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
10492 else
10493 {
10494 if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
10495 else puts (dlerror ());
10496 }
10497 /* dlclose (self); */
10498 }
10499 else
10500 puts (dlerror ());
10501
10502 return status;
10503 }
10504 _LT_EOF
10505 if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
10506 (eval $ac_link) 2>&5
10507 ac_status=$?
10508 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
10509 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
10510 (./conftest; exit; ) >&5 2>/dev/null
10511 lt_status=$?
10512 case x$lt_status in
10513 x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
10514 x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
10515 x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
10516 esac
10517 else :
10518 # compilation failed
10519 lt_cv_dlopen_self_static=no
10520 fi
10521 fi
10522 rm -fr conftest*
10523
10524
10525 fi
10526 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
10527 $as_echo "$lt_cv_dlopen_self_static" >&6; }
10528 fi
10529
10530 CPPFLAGS="$save_CPPFLAGS"
10531 LDFLAGS="$save_LDFLAGS"
10532 LIBS="$save_LIBS"
10533 ;;
10534 esac
10535
10536 case $lt_cv_dlopen_self in
10537 yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
10538 *) enable_dlopen_self=unknown ;;
10539 esac
10540
10541 case $lt_cv_dlopen_self_static in
10542 yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
10543 *) enable_dlopen_self_static=unknown ;;
10544 esac
10545 fi
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563 striplib=
10564 old_striplib=
10565 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
10566 $as_echo_n "checking whether stripping libraries is possible... " >&6; }
10567 if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
10568 test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
10569 test -z "$striplib" && striplib="$STRIP --strip-unneeded"
10570 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10571 $as_echo "yes" >&6; }
10572 else
10573 # FIXME - insert some real tests, host_os isn't really good enough
10574 case $host_os in
10575 darwin*)
10576 if test -n "$STRIP" ; then
10577 striplib="$STRIP -x"
10578 old_striplib="$STRIP -S"
10579 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
10580 $as_echo "yes" >&6; }
10581 else
10582 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10583 $as_echo "no" >&6; }
10584 fi
10585 ;;
10586 *)
10587 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
10588 $as_echo "no" >&6; }
10589 ;;
10590 esac
10591 fi
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604 # Report which library types will actually be built
10605 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
10606 $as_echo_n "checking if libtool supports shared libraries... " >&6; }
10607 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
10608 $as_echo "$can_build_shared" >&6; }
10609
10610 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
10611 $as_echo_n "checking whether to build shared libraries... " >&6; }
10612 test "$can_build_shared" = "no" && enable_shared=no
10613
10614 # On AIX, shared libraries and static libraries use the same namespace, and
10615 # are all built from PIC.
10616 case $host_os in
10617 aix3*)
10618 test "$enable_shared" = yes && enable_static=no
10619 if test -n "$RANLIB"; then
10620 archive_cmds="$archive_cmds~\$RANLIB \$lib"
10621 postinstall_cmds='$RANLIB $lib'
10622 fi
10623 ;;
10624
10625 aix[4-9]*)
10626 if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
10627 test "$enable_shared" = yes && enable_static=no
10628 fi
10629 ;;
10630 esac
10631 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
10632 $as_echo "$enable_shared" >&6; }
10633
10634 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
10635 $as_echo_n "checking whether to build static libraries... " >&6; }
10636 # Make sure either enable_shared or enable_static is yes.
10637 test "$enable_shared" = yes || enable_static=yes
10638 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
10639 $as_echo "$enable_static" >&6; }
10640
10641
10642
10643
10644 fi
10645 ac_ext=c
10646 ac_cpp='$CPP $CPPFLAGS'
10647 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
10648 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
10649 ac_compiler_gnu=$ac_cv_c_compiler_gnu
10650
10651 CC="$lt_save_CC"
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667 ac_config_commands="$ac_config_commands libtool"
10668
10669
10670
10671
10672 # Only expand once:
10673
10674
10675 # Find a good install program. We prefer a C program (faster),
10676 # so one script is as good as another. But avoid the broken or
10677 # incompatible versions:
10678 # SysV /etc/install, /usr/sbin/install
10679 # SunOS /usr/etc/install
10680 # IRIX /sbin/install
10681 # AIX /bin/install
10682 # AmigaOS /C/install, which installs bootblocks on floppy discs
10683 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
10684 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
10685 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
10686 # OS/2's system install, which has a completely different semantic
10687 # ./install, which can be erroneously created by make from ./install.sh.
10688 # Reject install programs that cannot install multiple files.
10689 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
10690 $as_echo_n "checking for a BSD-compatible install... " >&6; }
10691 if test -z "$INSTALL"; then
10692 if ${ac_cv_path_install+:} false; then :
10693 $as_echo_n "(cached) " >&6
10694 else
10695 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
10696 for as_dir in $PATH
10697 do
10698 IFS=$as_save_IFS
10699 test -z "$as_dir" && as_dir=.
10700 # Account for people who put trailing slashes in PATH elements.
10701 case $as_dir/ in #((
10702 ./ | .// | /[cC]/* | \
10703 /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
10704 ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
10705 /usr/ucb/* ) ;;
10706 *)
10707 # OSF1 and SCO ODT 3.0 have their own names for install.
10708 # Don't use installbsd from OSF since it installs stuff as root
10709 # by default.
10710 for ac_prog in ginstall scoinst install; do
10711 for ac_exec_ext in '' $ac_executable_extensions; do
10712 if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
10713 if test $ac_prog = install &&
10714 grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
10715 # AIX install. It has an incompatible calling convention.
10716 :
10717 elif test $ac_prog = install &&
10718 grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
10719 # program-specific install script used by HP pwplus--don't use.
10720 :
10721 else
10722 rm -rf conftest.one conftest.two conftest.dir
10723 echo one > conftest.one
10724 echo two > conftest.two
10725 mkdir conftest.dir
10726 if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
10727 test -s conftest.one && test -s conftest.two &&
10728 test -s conftest.dir/conftest.one &&
10729 test -s conftest.dir/conftest.two
10730 then
10731 ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
10732 break 3
10733 fi
10734 fi
10735 fi
10736 done
10737 done
10738 ;;
10739 esac
10740
10741 done
10742 IFS=$as_save_IFS
10743
10744 rm -rf conftest.one conftest.two conftest.dir
10745
10746 fi
10747 if test "${ac_cv_path_install+set}" = set; then
10748 INSTALL=$ac_cv_path_install
10749 else
10750 # As a last resort, use the slow shell script. Don't cache a
10751 # value for INSTALL within a source directory, because that will
10752 # break other packages using the cache if that directory is
10753 # removed, or if the value is a relative name.
10754 INSTALL=$ac_install_sh
10755 fi
10756 fi
10757 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
10758 $as_echo "$INSTALL" >&6; }
10759
10760 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
10761 # It thinks the first close brace ends the variable substitution.
10762 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
10763
10764 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
10765
10766 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
10767
10768
10769
10770
10771 # Check whether --enable-rpath was given.
10772 if test "${enable_rpath+set}" = set; then :
10773 enableval=$enable_rpath; enable_rpath=$enableval
10774 else
10775 enable_rpath=yes
10776 fi
10777
10778 if test "x$enable_rpath" = xno; then
10779 ac_config_commands="$ac_config_commands disable-rpath"
10780
10781 fi
10782
10783
10784 # search to set include and library paths right
10785 # find libidn
10786
10787 # Check whether --with-libidn was given.
10788 if test "${with_libidn+set}" = set; then :
10789 withval=$with_libidn;
10790 else
10791 withval="yes"
10792 fi
10793
10794 if test x_$withval = x_yes; then
10795 for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do
10796 if test -f "$dir/include/idna.h"; then
10797 CFLAGS="$CFLAGS -I$dir/include"
10798 LDFLAGS="$LDFLAGS -L$dir/lib"
10799 { $as_echo "$as_me:${as_lineno-$LINENO}: Found libidn in $dir" >&5
10800 $as_echo "$as_me: Found libidn in $dir" >&6;}
10801 break
10802 fi
10803 if test -f "$dir/include/idn/idna.h"; then
10804 CFLAGS="$CFLAGS -I$dir/include/idn"
10805 LDFLAGS="$LDFLAGS -L$dir/lib"
10806 { $as_echo "$as_me:${as_lineno-$LINENO}: Found libidn in $dir" >&5
10807 $as_echo "$as_me: Found libidn in $dir" >&6;}
10808 break
10809 fi
10810 done
10811 if test -f "/usr/include/idn/idna.h"; then
10812 CFLAGS="$CFLAGS -I/usr/include/idn"
10813 #LDFLAGS="$LDFLAGS -L/usr/lib"
10814 { $as_echo "$as_me:${as_lineno-$LINENO}: Found libidn in /usr" >&5
10815 $as_echo "$as_me: Found libidn in /usr" >&6;}
10816 fi
10817 else
10818 if test x_$withval != x_no; then
10819 CFLAGS="$CFLAGS -I$withval/include"
10820 LDFLAGS="$LDFLAGS -L$withval/lib"
10821 fi
10822 fi
10823
10824 # find libldns
10825
10826 # Check whether --with-libldns was given.
10827 if test "${with_libldns+set}" = set; then :
10828 withval=$with_libldns;
10829 else
10830 withval="yes"
10831 fi
10832
10833 if test x_$withval = x_yes; then
10834 for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do
10835 if test -f "$dir/include/ldns/ldns.h"; then
10836 CFLAGS="$CFLAGS -I$dir/include"
10837 LDFLAGS="$LDFLAGS -L$dir/lib"
10838 { $as_echo "$as_me:${as_lineno-$LINENO}: Found libldns in $dir" >&5
10839 $as_echo "$as_me: Found libldns in $dir" >&6;}
10840 break
10841 fi
10842 done
10843 else
10844 if test x_$withval != x_no; then
10845 CFLAGS="$CFLAGS -I$withval/include"
10846 LDFLAGS="$LDFLAGS -L$withval/lib"
10847 fi
10848 fi
10849
10850 # find libunbound
10851
10852 # Check whether --with-libunbound was given.
10853 if test "${with_libunbound+set}" = set; then :
10854 withval=$with_libunbound;
10855 else
10856 withval="yes"
10857 fi
10858
10859 if test x_$withval = x_yes; then
10860 for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do
10861 if test -f "$dir/include/unbound.h"; then
10862 CFLAGS="$CFLAGS -I$dir/include"
10863 LDFLAGS="$LDFLAGS -L$dir/lib"
10864 { $as_echo "$as_me:${as_lineno-$LINENO}: Found libunbound in $dir" >&5
10865 $as_echo "$as_me: Found libunbound in $dir" >&6;}
10866 break
10867 fi
10868 done
10869 else
10870 if test x_$withval != x_no; then
10871 CFLAGS="$CFLAGS -I$withval/include"
10872 LDFLAGS="$LDFLAGS -L$withval/lib"
10873 fi
10874 fi
10875
10876 # Checks for libraries.
10877 found_all_libs=1
10878 { $as_echo "$as_me:${as_lineno-$LINENO}: Checking for dependency ldns" >&5
10879 $as_echo "$as_me: Checking for dependency ldns" >&6;}
10880 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ldns_dname_new_frm_str in -lldns" >&5
10881 $as_echo_n "checking for ldns_dname_new_frm_str in -lldns... " >&6; }
10882 if ${ac_cv_lib_ldns_ldns_dname_new_frm_str+:} false; then :
10883 $as_echo_n "(cached) " >&6
10884 else
10885 ac_check_lib_save_LIBS=$LIBS
10886 LIBS="-lldns $LIBS"
10887 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10888 /* end confdefs.h. */
10889
10890 /* Override any GCC internal prototype to avoid an error.
10891 Use char because int might match the return type of a GCC
10892 builtin and then its argument prototype would still apply. */
10893 #ifdef __cplusplus
10894 extern "C"
10895 #endif
10896 char ldns_dname_new_frm_str ();
10897 int
10898 main ()
10899 {
10900 return ldns_dname_new_frm_str ();
10901 ;
10902 return 0;
10903 }
10904 _ACEOF
10905 if ac_fn_c_try_link "$LINENO"; then :
10906 ac_cv_lib_ldns_ldns_dname_new_frm_str=yes
10907 else
10908 ac_cv_lib_ldns_ldns_dname_new_frm_str=no
10909 fi
10910 rm -f core conftest.err conftest.$ac_objext \
10911 conftest$ac_exeext conftest.$ac_ext
10912 LIBS=$ac_check_lib_save_LIBS
10913 fi
10914 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ldns_ldns_dname_new_frm_str" >&5
10915 $as_echo "$ac_cv_lib_ldns_ldns_dname_new_frm_str" >&6; }
10916 if test "x$ac_cv_lib_ldns_ldns_dname_new_frm_str" = xyes; then :
10917 cat >>confdefs.h <<_ACEOF
10918 #define HAVE_LIBLDNS 1
10919 _ACEOF
10920
10921 LIBS="-lldns $LIBS"
10922
10923 else
10924 found_all_libs=0
10925 fi
10926
10927 { $as_echo "$as_me:${as_lineno-$LINENO}: Checking for dependency libidn" >&5
10928 $as_echo "$as_me: Checking for dependency libidn" >&6;}
10929 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for idna_to_ascii_8z in -lidn" >&5
10930 $as_echo_n "checking for idna_to_ascii_8z in -lidn... " >&6; }
10931 if ${ac_cv_lib_idn_idna_to_ascii_8z+:} false; then :
10932 $as_echo_n "(cached) " >&6
10933 else
10934 ac_check_lib_save_LIBS=$LIBS
10935 LIBS="-lidn $LIBS"
10936 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10937 /* end confdefs.h. */
10938
10939 /* Override any GCC internal prototype to avoid an error.
10940 Use char because int might match the return type of a GCC
10941 builtin and then its argument prototype would still apply. */
10942 #ifdef __cplusplus
10943 extern "C"
10944 #endif
10945 char idna_to_ascii_8z ();
10946 int
10947 main ()
10948 {
10949 return idna_to_ascii_8z ();
10950 ;
10951 return 0;
10952 }
10953 _ACEOF
10954 if ac_fn_c_try_link "$LINENO"; then :
10955 ac_cv_lib_idn_idna_to_ascii_8z=yes
10956 else
10957 ac_cv_lib_idn_idna_to_ascii_8z=no
10958 fi
10959 rm -f core conftest.err conftest.$ac_objext \
10960 conftest$ac_exeext conftest.$ac_ext
10961 LIBS=$ac_check_lib_save_LIBS
10962 fi
10963 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_idn_idna_to_ascii_8z" >&5
10964 $as_echo "$ac_cv_lib_idn_idna_to_ascii_8z" >&6; }
10965 if test "x$ac_cv_lib_idn_idna_to_ascii_8z" = xyes; then :
10966 cat >>confdefs.h <<_ACEOF
10967 #define HAVE_LIBIDN 1
10968 _ACEOF
10969
10970 LIBS="-lidn $LIBS"
10971
10972 else
10973 found_all_libs=0
10974 fi
10975
10976
10977 if test $found_all_libs == 0
10978 then
10979 as_fn_error $? "One more dependencies is missing" "$LINENO" 5
10980 fi
10981
10982 # break out libunbound from other libraries since we are currently using a
10983 # patch to the sources
10984 found_libunbound=1
10985 { $as_echo "$as_me:${as_lineno-$LINENO}: Checking for dependency libunbound" >&5
10986 $as_echo "$as_me: Checking for dependency libunbound" >&6;}
10987 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ub_fd in -lunbound" >&5
10988 $as_echo_n "checking for ub_fd in -lunbound... " >&6; }
10989 if ${ac_cv_lib_unbound_ub_fd+:} false; then :
10990 $as_echo_n "(cached) " >&6
10991 else
10992 ac_check_lib_save_LIBS=$LIBS
10993 LIBS="-lunbound $LIBS"
10994 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
10995 /* end confdefs.h. */
10996
10997 /* Override any GCC internal prototype to avoid an error.
10998 Use char because int might match the return type of a GCC
10999 builtin and then its argument prototype would still apply. */
11000 #ifdef __cplusplus
11001 extern "C"
11002 #endif
11003 char ub_fd ();
11004 int
11005 main ()
11006 {
11007 return ub_fd ();
11008 ;
11009 return 0;
11010 }
11011 _ACEOF
11012 if ac_fn_c_try_link "$LINENO"; then :
11013 ac_cv_lib_unbound_ub_fd=yes
11014 else
11015 ac_cv_lib_unbound_ub_fd=no
11016 fi
11017 rm -f core conftest.err conftest.$ac_objext \
11018 conftest$ac_exeext conftest.$ac_ext
11019 LIBS=$ac_check_lib_save_LIBS
11020 fi
11021 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_unbound_ub_fd" >&5
11022 $as_echo "$ac_cv_lib_unbound_ub_fd" >&6; }
11023 if test "x$ac_cv_lib_unbound_ub_fd" = xyes; then :
11024 cat >>confdefs.h <<_ACEOF
11025 #define HAVE_LIBUNBOUND 1
11026 _ACEOF
11027
11028 LIBS="-lunbound $LIBS"
11029
11030 else
11031 found_libunbound=0
11032 fi
11033
11034 if test $found_libunbound == 0
11035 then
11036 as_fn_error $? "libunbound is missing." "$LINENO" 5
11037 fi
11038
11039 for ac_prog in doxygen
11040 do
11041 # Extract the first word of "$ac_prog", so it can be a program name with args.
11042 set dummy $ac_prog; ac_word=$2
11043 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
11044 $as_echo_n "checking for $ac_word... " >&6; }
11045 if ${ac_cv_prog_DOXYGEN+:} false; then :
11046 $as_echo_n "(cached) " >&6
11047 else
11048 if test -n "$DOXYGEN"; then
11049 ac_cv_prog_DOXYGEN="$DOXYGEN" # Let the user override the test.
11050 else
11051 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
11052 for as_dir in $PATH
11053 do
11054 IFS=$as_save_IFS
11055 test -z "$as_dir" && as_dir=.
11056 for ac_exec_ext in '' $ac_executable_extensions; do
11057 if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
11058 ac_cv_prog_DOXYGEN="$ac_prog"
11059 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
11060 break 2
11061 fi
11062 done
11063 done
11064 IFS=$as_save_IFS
11065
11066 fi
11067 fi
11068 DOXYGEN=$ac_cv_prog_DOXYGEN
11069 if test -n "$DOXYGEN"; then
11070 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DOXYGEN" >&5
11071 $as_echo "$DOXYGEN" >&6; }
11072 else
11073 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11074 $as_echo "no" >&6; }
11075 fi
11076
11077
11078 test -n "$DOXYGEN" && break
11079 done
11080
11081 if test -z "$DOXYGEN";
11082 then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Doxygen not found, continuing without" >&5
11083 $as_echo "$as_me: WARNING: Doxygen not found, continuing without" >&2;}
11084 fi
11085
11086 # Checks for header files.
11087 for ac_header in inttypes.h netinet/in.h stdint.h stdlib.h string.h
11088 do :
11089 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
11090 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
11091 "
11092 if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
11093 cat >>confdefs.h <<_ACEOF
11094 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
11095 _ACEOF
11096
11097 fi
11098
11099 done
11100
11101
11102 # Checks for typedefs, structures, and compiler characteristics.
11103 ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
11104 if test "x$ac_cv_type_size_t" = xyes; then :
11105
11106 else
11107
11108 cat >>confdefs.h <<_ACEOF
11109 #define size_t unsigned int
11110 _ACEOF
11111
11112 fi
11113
11114 ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t"
11115 case $ac_cv_c_uint16_t in #(
11116 no|yes) ;; #(
11117 *)
11118
11119
11120 cat >>confdefs.h <<_ACEOF
11121 #define uint16_t $ac_cv_c_uint16_t
11122 _ACEOF
11123 ;;
11124 esac
11125
11126 ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t"
11127 case $ac_cv_c_uint32_t in #(
11128 no|yes) ;; #(
11129 *)
11130
11131 $as_echo "#define _UINT32_T 1" >>confdefs.h
11132
11133
11134 cat >>confdefs.h <<_ACEOF
11135 #define uint32_t $ac_cv_c_uint32_t
11136 _ACEOF
11137 ;;
11138 esac
11139
11140 ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t"
11141 case $ac_cv_c_uint64_t in #(
11142 no|yes) ;; #(
11143 *)
11144
11145 $as_echo "#define _UINT64_T 1" >>confdefs.h
11146
11147
11148 cat >>confdefs.h <<_ACEOF
11149 #define uint64_t $ac_cv_c_uint64_t
11150 _ACEOF
11151 ;;
11152 esac
11153
11154 ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t"
11155 case $ac_cv_c_uint8_t in #(
11156 no|yes) ;; #(
11157 *)
11158
11159 $as_echo "#define _UINT8_T 1" >>confdefs.h
11160
11161
11162 cat >>confdefs.h <<_ACEOF
11163 #define uint8_t $ac_cv_c_uint8_t
11164 _ACEOF
11165 ;;
11166 esac
11167
11168
11169 getdns_LIBS=$LIBS
11170 getdns_LDFLAGS=$LDFLAGS
11171
11172 EXTENSION_LDFLAGS=$LDFLAGS
11173
11174 # libevent extension
11175 have_libevent=0
11176 EXTENSION_LIBEVENT_LIB="libgetdns_ext_event.la"
11177 EXTENSION_LIBEVENT_EXT_LIBS=""
11178 CHECK_EVENT_PROG=""
11179 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing event_loop" >&5
11180 $as_echo_n "checking for library containing event_loop... " >&6; }
11181 if ${ac_cv_search_event_loop+:} false; then :
11182 $as_echo_n "(cached) " >&6
11183 else
11184 ac_func_search_save_LIBS=$LIBS
11185 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11186 /* end confdefs.h. */
11187
11188 /* Override any GCC internal prototype to avoid an error.
11189 Use char because int might match the return type of a GCC
11190 builtin and then its argument prototype would still apply. */
11191 #ifdef __cplusplus
11192 extern "C"
11193 #endif
11194 char event_loop ();
11195 int
11196 main ()
11197 {
11198 return event_loop ();
11199 ;
11200 return 0;
11201 }
11202 _ACEOF
11203 for ac_lib in '' event_core event; do
11204 if test -z "$ac_lib"; then
11205 ac_res="none required"
11206 else
11207 ac_res=-l$ac_lib
11208 LIBS="-l$ac_lib $ac_func_search_save_LIBS"
11209 fi
11210 if ac_fn_c_try_link "$LINENO"; then :
11211 ac_cv_search_event_loop=$ac_res
11212 fi
11213 rm -f core conftest.err conftest.$ac_objext \
11214 conftest$ac_exeext
11215 if ${ac_cv_search_event_loop+:} false; then :
11216 break
11217 fi
11218 done
11219 if ${ac_cv_search_event_loop+:} false; then :
11220
11221 else
11222 ac_cv_search_event_loop=no
11223 fi
11224 rm conftest.$ac_ext
11225 LIBS=$ac_func_search_save_LIBS
11226 fi
11227 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_event_loop" >&5
11228 $as_echo "$ac_cv_search_event_loop" >&6; }
11229 ac_res=$ac_cv_search_event_loop
11230 if test "$ac_res" != no; then :
11231 test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
11232 for ac_func in event_base_new event_base_free
11233 do :
11234 as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
11235 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
11236 if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
11237 cat >>confdefs.h <<_ACEOF
11238 #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
11239 _ACEOF
11240
11241 fi
11242 done
11243
11244 for ac_header in event2/event.h
11245 do :
11246 ac_fn_c_check_header_compile "$LINENO" "event2/event.h" "ac_cv_header_event2_event_h" "$ac_includes_default
11247 "
11248 if test "x$ac_cv_header_event2_event_h" = xyes; then :
11249 cat >>confdefs.h <<_ACEOF
11250 #define HAVE_EVENT2_EVENT_H 1
11251 _ACEOF
11252 # event2/event.h found
11253 have_libevent=1
11254 EXTENSION_LIBEVENT_EXT_LIBS="$ac_cv_search_event_loop"
11255 CHECK_EVENT_PROG=check_getdns_event
11256 else
11257 # not found - look for event.h
11258 ac_fn_c_check_type "$LINENO" "u_char" "ac_cv_type_u_char" "$ac_includes_default"
11259 if test "x$ac_cv_type_u_char" = xyes; then :
11260
11261 else
11262
11263 cat >>confdefs.h <<_ACEOF
11264 #define u_char unsigned char
11265 _ACEOF
11266
11267 fi
11268
11269 for ac_header in event.h
11270 do :
11271 ac_fn_c_check_header_compile "$LINENO" "event.h" "ac_cv_header_event_h" "$ac_includes_default
11272 "
11273 if test "x$ac_cv_header_event_h" = xyes; then :
11274 cat >>confdefs.h <<_ACEOF
11275 #define HAVE_EVENT_H 1
11276 _ACEOF
11277 # found
11278 have_libevent=1
11279 EXTENSION_LIBEVENT_EXT_LIBS="$ac_cv_search_event_loop"
11280 CHECK_EVENT_PROG=check_getdns_event
11281 else
11282 # not found - give up
11283 EXTENSION_LIBEVENT_LIB=""
11284 fi
11285
11286 done
11287
11288
11289 fi
11290
11291 done
11292
11293 else
11294 # libs not found
11295 have_libevent=0
11296 EXTENSION_LIBEVENT_LIB=""
11297 fi
11298
11299
11300
11301
11302
11303
11304
11305 # libuv extension
11306 have_libuv=1
11307 EXTENSION_LIBUV_LIB="libgetdns_ext_uv.la"
11308 EXTENSION_LIBUV_EXT_LIBS=""
11309 CHECK_UV_PROG=""
11310 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing uv_run" >&5
11311 $as_echo_n "checking for library containing uv_run... " >&6; }
11312 if ${ac_cv_search_uv_run+:} false; then :
11313 $as_echo_n "(cached) " >&6
11314 else
11315 ac_func_search_save_LIBS=$LIBS
11316 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11317 /* end confdefs.h. */
11318
11319 /* Override any GCC internal prototype to avoid an error.
11320 Use char because int might match the return type of a GCC
11321 builtin and then its argument prototype would still apply. */
11322 #ifdef __cplusplus
11323 extern "C"
11324 #endif
11325 char uv_run ();
11326 int
11327 main ()
11328 {
11329 return uv_run ();
11330 ;
11331 return 0;
11332 }
11333 _ACEOF
11334 for ac_lib in '' uv; do
11335 if test -z "$ac_lib"; then
11336 ac_res="none required"
11337 else
11338 ac_res=-l$ac_lib
11339 LIBS="-l$ac_lib $ac_func_search_save_LIBS"
11340 fi
11341 if ac_fn_c_try_link "$LINENO"; then :
11342 ac_cv_search_uv_run=$ac_res
11343 fi
11344 rm -f core conftest.err conftest.$ac_objext \
11345 conftest$ac_exeext
11346 if ${ac_cv_search_uv_run+:} false; then :
11347 break
11348 fi
11349 done
11350 if ${ac_cv_search_uv_run+:} false; then :
11351
11352 else
11353 ac_cv_search_uv_run=no
11354 fi
11355 rm conftest.$ac_ext
11356 LIBS=$ac_func_search_save_LIBS
11357 fi
11358 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_uv_run" >&5
11359 $as_echo "$ac_cv_search_uv_run" >&6; }
11360 ac_res=$ac_cv_search_uv_run
11361 if test "$ac_res" != no; then :
11362 test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
11363 for ac_header in uv.h
11364 do :
11365 ac_fn_c_check_header_compile "$LINENO" "uv.h" "ac_cv_header_uv_h" "$ac_includes_default
11366 "
11367 if test "x$ac_cv_header_uv_h" = xyes; then :
11368 cat >>confdefs.h <<_ACEOF
11369 #define HAVE_UV_H 1
11370 _ACEOF
11371 EXTENSION_LIBUV_EXT_LIBS="$ac_cv_search_uv_run"
11372 CHECK_UV_PROG=check_getdns_uv
11373 else
11374 have_libuv=0
11375 EXTENSION_LIBUV_LIB=""
11376 fi
11377
11378 done
11379
11380 else
11381 have_libuv=0
11382 EXTENSION_LIBUV_LIB=""
11383 fi
11384
11385
11386
11387
11388
11389
11390
11391 # libev extension
11392 have_libev=1
11393 EXTENSION_LIBEV_LIB="libgetdns_ext_ev.la"
11394 EXTENSION_LIBEV_EXT_LIBS=""
11395
11396 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing ev_run" >&5
11397 $as_echo_n "checking for library containing ev_run... " >&6; }
11398 if ${ac_cv_search_ev_run+:} false; then :
11399 $as_echo_n "(cached) " >&6
11400 else
11401 ac_func_search_save_LIBS=$LIBS
11402 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11403 /* end confdefs.h. */
11404
11405 /* Override any GCC internal prototype to avoid an error.
11406 Use char because int might match the return type of a GCC
11407 builtin and then its argument prototype would still apply. */
11408 #ifdef __cplusplus
11409 extern "C"
11410 #endif
11411 char ev_run ();
11412 int
11413 main ()
11414 {
11415 return ev_run ();
11416 ;
11417 return 0;
11418 }
11419 _ACEOF
11420 for ac_lib in '' ev; do
11421 if test -z "$ac_lib"; then
11422 ac_res="none required"
11423 else
11424 ac_res=-l$ac_lib
11425 LIBS="-l$ac_lib $ac_func_search_save_LIBS"
11426 fi
11427 if ac_fn_c_try_link "$LINENO"; then :
11428 ac_cv_search_ev_run=$ac_res
11429 fi
11430 rm -f core conftest.err conftest.$ac_objext \
11431 conftest$ac_exeext
11432 if ${ac_cv_search_ev_run+:} false; then :
11433 break
11434 fi
11435 done
11436 if ${ac_cv_search_ev_run+:} false; then :
11437
11438 else
11439 ac_cv_search_ev_run=no
11440 fi
11441 rm conftest.$ac_ext
11442 LIBS=$ac_func_search_save_LIBS
11443 fi
11444 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_ev_run" >&5
11445 $as_echo "$ac_cv_search_ev_run" >&6; }
11446 ac_res=$ac_cv_search_ev_run
11447 if test "$ac_res" != no; then :
11448 test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
11449 for ac_header in ev.h
11450 do :
11451 ac_fn_c_check_header_compile "$LINENO" "ev.h" "ac_cv_header_ev_h" "$ac_includes_default
11452 "
11453 if test "x$ac_cv_header_ev_h" = xyes; then :
11454 cat >>confdefs.h <<_ACEOF
11455 #define HAVE_EV_H 1
11456 _ACEOF
11457 EXTENSION_LIBEV_EXT_LIBS="$ac_cv_search_ev_run"
11458 CHECK_EV_PROG=check_getdns_ev
11459 else
11460 have_libev=0
11461 EXTENSION_LIBUV_LIB=""
11462 fi
11463
11464 done
11465
11466 else
11467 have_libev=0
11468 EXTENSION_LIBEV_LIB=""
11469 fi
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479 LIBS=$getdns_LIBS
11480 LDFLAGS=$getdns_LDFLAGS
11481
11482 # --with-trust-anchor=
11483
11484 $as_echo "#define SYSCONFDIR sysconfdir" >>confdefs.h
11485
11486
11487 # Check whether --with-trust-anchor was given.
11488 if test "${with_trust_anchor+set}" = set; then :
11489 withval=$with_trust_anchor;
11490 TRUST_ANCHOR_FILE="$withval"
11491
11492 else
11493
11494 if test "x$TRUST_ANCHOR_FILE" = "x"; then
11495 if test "x$sysconfdir" = 'x${prefix}/etc' ; then
11496 if test "x$prefix" = 'xNONE' ; then
11497 TRUST_ANCHOR_FILE="/etc/unbound/getdns-root.key"
11498 else
11499 TRUST_ANCHOR_FILE="${prefix}/etc/unbound/getdns-root.key"
11500 fi
11501 else
11502 TRUST_ANCHOR_FILE="${sysconfdir}/unbound/getdns-root.key"
11503 fi
11504 fi
11505
11506 fi
11507
11508
11509 cat >>confdefs.h <<_ACEOF
11510 #define TRUST_ANCHOR_FILE "$TRUST_ANCHOR_FILE"
11511 _ACEOF
11512
11513
11514 { $as_echo "$as_me:${as_lineno-$LINENO}: Default trust anchor: $TRUST_ANCHOR_FILE" >&5
11515 $as_echo "$as_me: Default trust anchor: $TRUST_ANCHOR_FILE" >&6;}
11516
11517 ac_config_files="$ac_config_files Makefile src/Makefile src/getdns/Makefile src/getdns/getdns.h src/example/Makefile src/test/Makefile doc/Makefile"
11518
11519 if test -n "$DOXYGEN"
11520 then ac_config_files="$ac_config_files src/Doxyfile"
11521
11522 fi
11523 ac_config_headers="$ac_config_headers src/config.h"
11524
11525 cat >confcache <<\_ACEOF
11526 # This file is a shell script that caches the results of configure
11527 # tests run on this system so they can be shared between configure
11528 # scripts and configure runs, see configure's option --config-cache.
11529 # It is not useful on other systems. If it contains results you don't
11530 # want to keep, you may remove or edit it.
11531 #
11532 # config.status only pays attention to the cache file if you give it
11533 # the --recheck option to rerun configure.
11534 #
11535 # `ac_cv_env_foo' variables (set or unset) will be overridden when
11536 # loading this file, other *unset* `ac_cv_foo' will be assigned the
11537 # following values.
11538
11539 _ACEOF
11540
11541 # The following way of writing the cache mishandles newlines in values,
11542 # but we know of no workaround that is simple, portable, and efficient.
11543 # So, we kill variables containing newlines.
11544 # Ultrix sh set writes to stderr and can't be redirected directly,
11545 # and sets the high bit in the cache file unless we assign to the vars.
11546 (
11547 for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
11548 eval ac_val=\$$ac_var
11549 case $ac_val in #(
11550 *${as_nl}*)
11551 case $ac_var in #(
11552 *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
11553 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
11554 esac
11555 case $ac_var in #(
11556 _ | IFS | as_nl) ;; #(
11557 BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
11558 *) { eval $ac_var=; unset $ac_var;} ;;
11559 esac ;;
11560 esac
11561 done
11562
11563 (set) 2>&1 |
11564 case $as_nl`(ac_space=' '; set) 2>&1` in #(
11565 *${as_nl}ac_space=\ *)
11566 # `set' does not quote correctly, so add quotes: double-quote
11567 # substitution turns \\\\ into \\, and sed turns \\ into \.
11568 sed -n \
11569 "s/'/'\\\\''/g;
11570 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
11571 ;; #(
11572 *)
11573 # `set' quotes correctly as required by POSIX, so do not add quotes.
11574 sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
11575 ;;
11576 esac |
11577 sort
11578 ) |
11579 sed '
11580 /^ac_cv_env_/b end
11581 t clear
11582 :clear
11583 s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
11584 t end
11585 s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
11586 :end' >>confcache
11587 if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
11588 if test -w "$cache_file"; then
11589 if test "x$cache_file" != "x/dev/null"; then
11590 { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
11591 $as_echo "$as_me: updating cache $cache_file" >&6;}
11592 if test ! -f "$cache_file" || test -h "$cache_file"; then
11593 cat confcache >"$cache_file"
11594 else
11595 case $cache_file in #(
11596 */* | ?:*)
11597 mv -f confcache "$cache_file"$$ &&
11598 mv -f "$cache_file"$$ "$cache_file" ;; #(
11599 *)
11600 mv -f confcache "$cache_file" ;;
11601 esac
11602 fi
11603 fi
11604 else
11605 { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
11606 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
11607 fi
11608 fi
11609 rm -f confcache
11610
11611 test "x$prefix" = xNONE && prefix=$ac_default_prefix
11612 # Let make expand exec_prefix.
11613 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
11614
11615 DEFS=-DHAVE_CONFIG_H
11616
11617 ac_libobjs=
11618 ac_ltlibobjs=
11619 U=
11620 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
11621 # 1. Remove the extension, and $U if already installed.
11622 ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
11623 ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
11624 # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
11625 # will be set to the directory where LIBOBJS objects are built.
11626 as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
11627 as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
11628 done
11629 LIBOBJS=$ac_libobjs
11630
11631 LTLIBOBJS=$ac_ltlibobjs
11632
11633
11634
11635 : "${CONFIG_STATUS=./config.status}"
11636 ac_write_fail=0
11637 ac_clean_files_save=$ac_clean_files
11638 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
11639 { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
11640 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
11641 as_write_fail=0
11642 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
11643 #! $SHELL
11644 # Generated by $as_me.
11645 # Run this file to recreate the current configuration.
11646 # Compiler output produced by configure, useful for debugging
11647 # configure, is in config.log if it exists.
11648
11649 debug=false
11650 ac_cs_recheck=false
11651 ac_cs_silent=false
11652
11653 SHELL=\${CONFIG_SHELL-$SHELL}
11654 export SHELL
11655 _ASEOF
11656 cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
11657 ## -------------------- ##
11658 ## M4sh Initialization. ##
11659 ## -------------------- ##
11660
11661 # Be more Bourne compatible
11662 DUALCASE=1; export DUALCASE # for MKS sh
11663 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
11664 emulate sh
11665 NULLCMD=:
11666 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
11667 # is contrary to our usage. Disable this feature.
11668 alias -g '${1+"$@"}'='"$@"'
11669 setopt NO_GLOB_SUBST
11670 else
11671 case `(set -o) 2>/dev/null` in #(
11672 *posix*) :
11673 set -o posix ;; #(
11674 *) :
11675 ;;
11676 esac
11677 fi
11678
11679
11680 as_nl='
11681 '
11682 export as_nl
11683 # Printing a long string crashes Solaris 7 /usr/bin/printf.
11684 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
11685 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
11686 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
11687 # Prefer a ksh shell builtin over an external printf program on Solaris,
11688 # but without wasting forks for bash or zsh.
11689 if test -z "$BASH_VERSION$ZSH_VERSION" \
11690 && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
11691 as_echo='print -r --'
11692 as_echo_n='print -rn --'
11693 elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
11694 as_echo='printf %s\n'
11695 as_echo_n='printf %s'
11696 else
11697 if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
11698 as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
11699 as_echo_n='/usr/ucb/echo -n'
11700 else
11701 as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
11702 as_echo_n_body='eval
11703 arg=$1;
11704 case $arg in #(
11705 *"$as_nl"*)
11706 expr "X$arg" : "X\\(.*\\)$as_nl";
11707 arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
11708 esac;
11709 expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
11710 '
11711 export as_echo_n_body
11712 as_echo_n='sh -c $as_echo_n_body as_echo'
11713 fi
11714 export as_echo_body
11715 as_echo='sh -c $as_echo_body as_echo'
11716 fi
11717
11718 # The user is always right.
11719 if test "${PATH_SEPARATOR+set}" != set; then
11720 PATH_SEPARATOR=:
11721 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
11722 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
11723 PATH_SEPARATOR=';'
11724 }
11725 fi
11726
11727
11728 # IFS
11729 # We need space, tab and new line, in precisely that order. Quoting is
11730 # there to prevent editors from complaining about space-tab.
11731 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
11732 # splitting by setting IFS to empty value.)
11733 IFS=" "" $as_nl"
11734
11735 # Find who we are. Look in the path if we contain no directory separator.
11736 as_myself=
11737 case $0 in #((
11738 *[\\/]* ) as_myself=$0 ;;
11739 *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
11740 for as_dir in $PATH
11741 do
11742 IFS=$as_save_IFS
11743 test -z "$as_dir" && as_dir=.
11744 test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
11745 done
11746 IFS=$as_save_IFS
11747
11748 ;;
11749 esac
11750 # We did not find ourselves, most probably we were run as `sh COMMAND'
11751 # in which case we are not to be found in the path.
11752 if test "x$as_myself" = x; then
11753 as_myself=$0
11754 fi
11755 if test ! -f "$as_myself"; then
11756 $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
11757 exit 1
11758 fi
11759
11760 # Unset variables that we do not need and which cause bugs (e.g. in
11761 # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
11762 # suppresses any "Segmentation fault" message there. '((' could
11763 # trigger a bug in pdksh 5.2.14.
11764 for as_var in BASH_ENV ENV MAIL MAILPATH
11765 do eval test x\${$as_var+set} = xset \
11766 && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
11767 done
11768 PS1='$ '
11769 PS2='> '
11770 PS4='+ '
11771
11772 # NLS nuisances.
11773 LC_ALL=C
11774 export LC_ALL
11775 LANGUAGE=C
11776 export LANGUAGE
11777
11778 # CDPATH.
11779 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
11780
11781
11782 # as_fn_error STATUS ERROR [LINENO LOG_FD]
11783 # ----------------------------------------
11784 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
11785 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
11786 # script with STATUS, using 1 if that was 0.
11787 as_fn_error ()
11788 {
11789 as_status=$1; test $as_status -eq 0 && as_status=1
11790 if test "$4"; then
11791 as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
11792 $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
11793 fi
11794 $as_echo "$as_me: error: $2" >&2
11795 as_fn_exit $as_status
11796 } # as_fn_error
11797
11798
11799 # as_fn_set_status STATUS
11800 # -----------------------
11801 # Set $? to STATUS, without forking.
11802 as_fn_set_status ()
11803 {
11804 return $1
11805 } # as_fn_set_status
11806
11807 # as_fn_exit STATUS
11808 # -----------------
11809 # Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
11810 as_fn_exit ()
11811 {
11812 set +e
11813 as_fn_set_status $1
11814 exit $1
11815 } # as_fn_exit
11816
11817 # as_fn_unset VAR
11818 # ---------------
11819 # Portably unset VAR.
11820 as_fn_unset ()
11821 {
11822 { eval $1=; unset $1;}
11823 }
11824 as_unset=as_fn_unset
11825 # as_fn_append VAR VALUE
11826 # ----------------------
11827 # Append the text in VALUE to the end of the definition contained in VAR. Take
11828 # advantage of any shell optimizations that allow amortized linear growth over
11829 # repeated appends, instead of the typical quadratic growth present in naive
11830 # implementations.
11831 if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
11832 eval 'as_fn_append ()
11833 {
11834 eval $1+=\$2
11835 }'
11836 else
11837 as_fn_append ()
11838 {
11839 eval $1=\$$1\$2
11840 }
11841 fi # as_fn_append
11842
11843 # as_fn_arith ARG...
11844 # ------------------
11845 # Perform arithmetic evaluation on the ARGs, and store the result in the
11846 # global $as_val. Take advantage of shells that can avoid forks. The arguments
11847 # must be portable across $(()) and expr.
11848 if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
11849 eval 'as_fn_arith ()
11850 {
11851 as_val=$(( $* ))
11852 }'
11853 else
11854 as_fn_arith ()
11855 {
11856 as_val=`expr "$@" || test $? -eq 1`
11857 }
11858 fi # as_fn_arith
11859
11860
11861 if expr a : '\(a\)' >/dev/null 2>&1 &&
11862 test "X`expr 00001 : '.*\(...\)'`" = X001; then
11863 as_expr=expr
11864 else
11865 as_expr=false
11866 fi
11867
11868 if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
11869 as_basename=basename
11870 else
11871 as_basename=false
11872 fi
11873
11874 if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
11875 as_dirname=dirname
11876 else
11877 as_dirname=false
11878 fi
11879
11880 as_me=`$as_basename -- "$0" ||
11881 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
11882 X"$0" : 'X\(//\)$' \| \
11883 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
11884 $as_echo X/"$0" |
11885 sed '/^.*\/\([^/][^/]*\)\/*$/{
11886 s//\1/
11887 q
11888 }
11889 /^X\/\(\/\/\)$/{
11890 s//\1/
11891 q
11892 }
11893 /^X\/\(\/\).*/{
11894 s//\1/
11895 q
11896 }
11897 s/.*/./; q'`
11898
11899 # Avoid depending upon Character Ranges.
11900 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
11901 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
11902 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
11903 as_cr_digits='0123456789'
11904 as_cr_alnum=$as_cr_Letters$as_cr_digits
11905
11906 ECHO_C= ECHO_N= ECHO_T=
11907 case `echo -n x` in #(((((
11908 -n*)
11909 case `echo 'xy\c'` in
11910 *c*) ECHO_T=' ';; # ECHO_T is single tab character.
11911 xy) ECHO_C='\c';;
11912 *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
11913 ECHO_T=' ';;
11914 esac;;
11915 *)
11916 ECHO_N='-n';;
11917 esac
11918
11919 rm -f conf$$ conf$$.exe conf$$.file
11920 if test -d conf$$.dir; then
11921 rm -f conf$$.dir/conf$$.file
11922 else
11923 rm -f conf$$.dir
11924 mkdir conf$$.dir 2>/dev/null
11925 fi
11926 if (echo >conf$$.file) 2>/dev/null; then
11927 if ln -s conf$$.file conf$$ 2>/dev/null; then
11928 as_ln_s='ln -s'
11929 # ... but there are two gotchas:
11930 # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
11931 # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
11932 # In both cases, we have to default to `cp -pR'.
11933 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
11934 as_ln_s='cp -pR'
11935 elif ln conf$$.file conf$$ 2>/dev/null; then
11936 as_ln_s=ln
11937 else
11938 as_ln_s='cp -pR'
11939 fi
11940 else
11941 as_ln_s='cp -pR'
11942 fi
11943 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
11944 rmdir conf$$.dir 2>/dev/null
11945
11946
11947 # as_fn_mkdir_p
11948 # -------------
11949 # Create "$as_dir" as a directory, including parents if necessary.
11950 as_fn_mkdir_p ()
11951 {
11952
11953 case $as_dir in #(
11954 -*) as_dir=./$as_dir;;
11955 esac
11956 test -d "$as_dir" || eval $as_mkdir_p || {
11957 as_dirs=
11958 while :; do
11959 case $as_dir in #(
11960 *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
11961 *) as_qdir=$as_dir;;
11962 esac
11963 as_dirs="'$as_qdir' $as_dirs"
11964 as_dir=`$as_dirname -- "$as_dir" ||
11965 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
11966 X"$as_dir" : 'X\(//\)[^/]' \| \
11967 X"$as_dir" : 'X\(//\)$' \| \
11968 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
11969 $as_echo X"$as_dir" |
11970 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
11971 s//\1/
11972 q
11973 }
11974 /^X\(\/\/\)[^/].*/{
11975 s//\1/
11976 q
11977 }
11978 /^X\(\/\/\)$/{
11979 s//\1/
11980 q
11981 }
11982 /^X\(\/\).*/{
11983 s//\1/
11984 q
11985 }
11986 s/.*/./; q'`
11987 test -d "$as_dir" && break
11988 done
11989 test -z "$as_dirs" || eval "mkdir $as_dirs"
11990 } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
11991
11992
11993 } # as_fn_mkdir_p
11994 if mkdir -p . 2>/dev/null; then
11995 as_mkdir_p='mkdir -p "$as_dir"'
11996 else
11997 test -d ./-p && rmdir ./-p
11998 as_mkdir_p=false
11999 fi
12000
12001
12002 # as_fn_executable_p FILE
12003 # -----------------------
12004 # Test if FILE is an executable regular file.
12005 as_fn_executable_p ()
12006 {
12007 test -f "$1" && test -x "$1"
12008 } # as_fn_executable_p
12009 as_test_x='test -x'
12010 as_executable_p=as_fn_executable_p
12011
12012 # Sed expression to map a string onto a valid CPP name.
12013 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
12014
12015 # Sed expression to map a string onto a valid variable name.
12016 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
12017
12018
12019 exec 6>&1
12020 ## ----------------------------------- ##
12021 ## Main body of $CONFIG_STATUS script. ##
12022 ## ----------------------------------- ##
12023 _ASEOF
12024 test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
12025
12026 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
12027 # Save the log message, to keep $0 and so on meaningful, and to
12028 # report actual input values of CONFIG_FILES etc. instead of their
12029 # values after options handling.
12030 ac_log="
12031 This file was extended by getdns $as_me 0.1.0, which was
12032 generated by GNU Autoconf 2.69. Invocation command line was
12033
12034 CONFIG_FILES = $CONFIG_FILES
12035 CONFIG_HEADERS = $CONFIG_HEADERS
12036 CONFIG_LINKS = $CONFIG_LINKS
12037 CONFIG_COMMANDS = $CONFIG_COMMANDS
12038 $ $0 $@
12039
12040 on `(hostname || uname -n) 2>/dev/null | sed 1q`
12041 "
12042
12043 _ACEOF
12044
12045 case $ac_config_files in *"
12046 "*) set x $ac_config_files; shift; ac_config_files=$*;;
12047 esac
12048
12049 case $ac_config_headers in *"
12050 "*) set x $ac_config_headers; shift; ac_config_headers=$*;;
12051 esac
12052
12053
12054 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
12055 # Files that config.status was made for.
12056 config_files="$ac_config_files"
12057 config_headers="$ac_config_headers"
12058 config_commands="$ac_config_commands"
12059
12060 _ACEOF
12061
12062 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
12063 ac_cs_usage="\
12064 \`$as_me' instantiates files and other configuration actions
12065 from templates according to the current configuration. Unless the files
12066 and actions are specified as TAGs, all are instantiated by default.
12067
12068 Usage: $0 [OPTION]... [TAG]...
12069
12070 -h, --help print this help, then exit
12071 -V, --version print version number and configuration settings, then exit
12072 --config print configuration, then exit
12073 -q, --quiet, --silent
12074 do not print progress messages
12075 -d, --debug don't remove temporary files
12076 --recheck update $as_me by reconfiguring in the same conditions
12077 --file=FILE[:TEMPLATE]
12078 instantiate the configuration file FILE
12079 --header=FILE[:TEMPLATE]
12080 instantiate the configuration header FILE
12081
12082 Configuration files:
12083 $config_files
12084
12085 Configuration headers:
12086 $config_headers
12087
12088 Configuration commands:
12089 $config_commands
12090
12091 Report bugs to <stub-resolver@verisignlabs.com>.
12092 getdns home page: <http://www.getdnsapi.net>."
12093
12094 _ACEOF
12095 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
12096 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
12097 ac_cs_version="\\
12098 getdns config.status 0.1.0
12099 configured by $0, generated by GNU Autoconf 2.69,
12100 with options \\"\$ac_cs_config\\"
12101
12102 Copyright (C) 2012 Free Software Foundation, Inc.
12103 This config.status script is free software; the Free Software Foundation
12104 gives unlimited permission to copy, distribute and modify it."
12105
12106 ac_pwd='$ac_pwd'
12107 srcdir='$srcdir'
12108 INSTALL='$INSTALL'
12109 AWK='$AWK'
12110 test -n "\$AWK" || AWK=awk
12111 _ACEOF
12112
12113 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
12114 # The default lists apply if the user does not specify any file.
12115 ac_need_defaults=:
12116 while test $# != 0
12117 do
12118 case $1 in
12119 --*=?*)
12120 ac_option=`expr "X$1" : 'X\([^=]*\)='`
12121 ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
12122 ac_shift=:
12123 ;;
12124 --*=)
12125 ac_option=`expr "X$1" : 'X\([^=]*\)='`
12126 ac_optarg=
12127 ac_shift=:
12128 ;;
12129 *)
12130 ac_option=$1
12131 ac_optarg=$2
12132 ac_shift=shift
12133 ;;
12134 esac
12135
12136 case $ac_option in
12137 # Handling of the options.
12138 -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
12139 ac_cs_recheck=: ;;
12140 --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
12141 $as_echo "$ac_cs_version"; exit ;;
12142 --config | --confi | --conf | --con | --co | --c )
12143 $as_echo "$ac_cs_config"; exit ;;
12144 --debug | --debu | --deb | --de | --d | -d )
12145 debug=: ;;
12146 --file | --fil | --fi | --f )
12147 $ac_shift
12148 case $ac_optarg in
12149 *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
12150 '') as_fn_error $? "missing file argument" ;;
12151 esac
12152 as_fn_append CONFIG_FILES " '$ac_optarg'"
12153 ac_need_defaults=false;;
12154 --header | --heade | --head | --hea )
12155 $ac_shift
12156 case $ac_optarg in
12157 *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
12158 esac
12159 as_fn_append CONFIG_HEADERS " '$ac_optarg'"
12160 ac_need_defaults=false;;
12161 --he | --h)
12162 # Conflict between --help and --header
12163 as_fn_error $? "ambiguous option: \`$1'
12164 Try \`$0 --help' for more information.";;
12165 --help | --hel | -h )
12166 $as_echo "$ac_cs_usage"; exit ;;
12167 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
12168 | -silent | --silent | --silen | --sile | --sil | --si | --s)
12169 ac_cs_silent=: ;;
12170
12171 # This is an error.
12172 -*) as_fn_error $? "unrecognized option: \`$1'
12173 Try \`$0 --help' for more information." ;;
12174
12175 *) as_fn_append ac_config_targets " $1"
12176 ac_need_defaults=false ;;
12177
12178 esac
12179 shift
12180 done
12181
12182 ac_configure_extra_args=
12183
12184 if $ac_cs_silent; then
12185 exec 6>/dev/null
12186 ac_configure_extra_args="$ac_configure_extra_args --silent"
12187 fi
12188
12189 _ACEOF
12190 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
12191 if \$ac_cs_recheck; then
12192 set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
12193 shift
12194 \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
12195 CONFIG_SHELL='$SHELL'
12196 export CONFIG_SHELL
12197 exec "\$@"
12198 fi
12199
12200 _ACEOF
12201 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
12202 exec 5>>config.log
12203 {
12204 echo
12205 sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
12206 ## Running $as_me. ##
12207 _ASBOX
12208 $as_echo "$ac_log"
12209 } >&5
12210
12211 _ACEOF
12212 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
12213 #
12214 # INIT-COMMANDS
12215 #
12216
12217
12218 # The HP-UX ksh and POSIX shell print the target directory to stdout
12219 # if CDPATH is set.
12220 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
12221
12222 sed_quote_subst='$sed_quote_subst'
12223 double_quote_subst='$double_quote_subst'
12224 delay_variable_subst='$delay_variable_subst'
12225 macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'
12226 macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'
12227 enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
12228 enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
12229 pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
12230 enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
12231 SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
12232 ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
12233 PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'
12234 host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`'
12235 host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`'
12236 host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`'
12237 build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`'
12238 build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`'
12239 build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`'
12240 SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`'
12241 Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`'
12242 GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`'
12243 EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`'
12244 FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`'
12245 LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`'
12246 NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`'
12247 LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`'
12248 max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`'
12249 ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`'
12250 exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`'
12251 lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`'
12252 lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`'
12253 lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`'
12254 lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`'
12255 lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`'
12256 reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`'
12257 reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`'
12258 OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`'
12259 deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`'
12260 file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`'
12261 file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`'
12262 want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`'
12263 DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`'
12264 sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`'
12265 AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`'
12266 AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`'
12267 archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`'
12268 STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`'
12269 RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`'
12270 old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`'
12271 old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
12272 old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`'
12273 lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`'
12274 CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`'
12275 CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`'
12276 compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
12277 GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
12278 lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
12279 lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
12280 lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
12281 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
12282 nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'
12283 lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'
12284 objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
12285 MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
12286 lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
12287 lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`'
12288 lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`'
12289 lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`'
12290 lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`'
12291 need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`'
12292 MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`'
12293 DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`'
12294 NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`'
12295 LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`'
12296 OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`'
12297 OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`'
12298 libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`'
12299 shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`'
12300 extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
12301 archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`'
12302 enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`'
12303 export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`'
12304 whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`'
12305 compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`'
12306 old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`'
12307 old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
12308 archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`'
12309 archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`'
12310 module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`'
12311 module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`'
12312 with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`'
12313 allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`'
12314 no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`'
12315 hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`'
12316 hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`'
12317 hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`'
12318 hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`'
12319 hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`'
12320 hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`'
12321 hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`'
12322 inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`'
12323 link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`'
12324 always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`'
12325 export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`'
12326 exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`'
12327 include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`'
12328 prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`'
12329 postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`'
12330 file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`'
12331 variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`'
12332 need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`'
12333 need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`'
12334 version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`'
12335 runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`'
12336 shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`'
12337 shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`'
12338 libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`'
12339 library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`'
12340 soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`'
12341 install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`'
12342 postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`'
12343 postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
12344 finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
12345 finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
12346 hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
12347 sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
12348 sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
12349 hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
12350 enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
12351 enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
12352 enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`'
12353 old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`'
12354 striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`'
12355
12356 LTCC='$LTCC'
12357 LTCFLAGS='$LTCFLAGS'
12358 compiler='$compiler_DEFAULT'
12359
12360 # A function that is used when there is no print builtin or printf.
12361 func_fallback_echo ()
12362 {
12363 eval 'cat <<_LTECHO_EOF
12364 \$1
12365 _LTECHO_EOF'
12366 }
12367
12368 # Quote evaled strings.
12369 for var in SHELL \
12370 ECHO \
12371 PATH_SEPARATOR \
12372 SED \
12373 GREP \
12374 EGREP \
12375 FGREP \
12376 LD \
12377 NM \
12378 LN_S \
12379 lt_SP2NL \
12380 lt_NL2SP \
12381 reload_flag \
12382 OBJDUMP \
12383 deplibs_check_method \
12384 file_magic_cmd \
12385 file_magic_glob \
12386 want_nocaseglob \
12387 DLLTOOL \
12388 sharedlib_from_linklib_cmd \
12389 AR \
12390 AR_FLAGS \
12391 archiver_list_spec \
12392 STRIP \
12393 RANLIB \
12394 CC \
12395 CFLAGS \
12396 compiler \
12397 lt_cv_sys_global_symbol_pipe \
12398 lt_cv_sys_global_symbol_to_cdecl \
12399 lt_cv_sys_global_symbol_to_c_name_address \
12400 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
12401 nm_file_list_spec \
12402 lt_prog_compiler_no_builtin_flag \
12403 lt_prog_compiler_pic \
12404 lt_prog_compiler_wl \
12405 lt_prog_compiler_static \
12406 lt_cv_prog_compiler_c_o \
12407 need_locks \
12408 MANIFEST_TOOL \
12409 DSYMUTIL \
12410 NMEDIT \
12411 LIPO \
12412 OTOOL \
12413 OTOOL64 \
12414 shrext_cmds \
12415 export_dynamic_flag_spec \
12416 whole_archive_flag_spec \
12417 compiler_needs_object \
12418 with_gnu_ld \
12419 allow_undefined_flag \
12420 no_undefined_flag \
12421 hardcode_libdir_flag_spec \
12422 hardcode_libdir_separator \
12423 exclude_expsyms \
12424 include_expsyms \
12425 file_list_spec \
12426 variables_saved_for_relink \
12427 libname_spec \
12428 library_names_spec \
12429 soname_spec \
12430 install_override_mode \
12431 finish_eval \
12432 old_striplib \
12433 striplib; do
12434 case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
12435 *[\\\\\\\`\\"\\\$]*)
12436 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
12437 ;;
12438 *)
12439 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
12440 ;;
12441 esac
12442 done
12443
12444 # Double-quote double-evaled strings.
12445 for var in reload_cmds \
12446 old_postinstall_cmds \
12447 old_postuninstall_cmds \
12448 old_archive_cmds \
12449 extract_expsyms_cmds \
12450 old_archive_from_new_cmds \
12451 old_archive_from_expsyms_cmds \
12452 archive_cmds \
12453 archive_expsym_cmds \
12454 module_cmds \
12455 module_expsym_cmds \
12456 export_symbols_cmds \
12457 prelink_cmds \
12458 postlink_cmds \
12459 postinstall_cmds \
12460 postuninstall_cmds \
12461 finish_cmds \
12462 sys_lib_search_path_spec \
12463 sys_lib_dlsearch_path_spec; do
12464 case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
12465 *[\\\\\\\`\\"\\\$]*)
12466 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
12467 ;;
12468 *)
12469 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
12470 ;;
12471 esac
12472 done
12473
12474 ac_aux_dir='$ac_aux_dir'
12475 xsi_shell='$xsi_shell'
12476 lt_shell_append='$lt_shell_append'
12477
12478 # See if we are running on zsh, and set the options which allow our
12479 # commands through without removal of \ escapes INIT.
12480 if test -n "\${ZSH_VERSION+set}" ; then
12481 setopt NO_GLOB_SUBST
12482 fi
12483
12484
12485 PACKAGE='$PACKAGE'
12486 VERSION='$VERSION'
12487 TIMESTAMP='$TIMESTAMP'
12488 RM='$RM'
12489 ofile='$ofile'
12490
12491
12492
12493
12494 _ACEOF
12495
12496 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
12497
12498 # Handling of arguments.
12499 for ac_config_target in $ac_config_targets
12500 do
12501 case $ac_config_target in
12502 "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
12503 "disable-rpath") CONFIG_COMMANDS="$CONFIG_COMMANDS disable-rpath" ;;
12504 "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
12505 "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
12506 "src/getdns/Makefile") CONFIG_FILES="$CONFIG_FILES src/getdns/Makefile" ;;
12507 "src/getdns/getdns.h") CONFIG_FILES="$CONFIG_FILES src/getdns/getdns.h" ;;
12508 "src/example/Makefile") CONFIG_FILES="$CONFIG_FILES src/example/Makefile" ;;
12509 "src/test/Makefile") CONFIG_FILES="$CONFIG_FILES src/test/Makefile" ;;
12510 "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
12511 "src/Doxyfile") CONFIG_FILES="$CONFIG_FILES src/Doxyfile" ;;
12512 "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;;
12513
12514 *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
12515 esac
12516 done
12517
12518
12519 # If the user did not use the arguments to specify the items to instantiate,
12520 # then the envvar interface is used. Set only those that are not.
12521 # We use the long form for the default assignment because of an extremely
12522 # bizarre bug on SunOS 4.1.3.
12523 if $ac_need_defaults; then
12524 test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
12525 test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
12526 test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
12527 fi
12528
12529 # Have a temporary directory for convenience. Make it in the build tree
12530 # simply because there is no reason against having it here, and in addition,
12531 # creating and moving files from /tmp can sometimes cause problems.
12532 # Hook for its removal unless debugging.
12533 # Note that there is a small window in which the directory will not be cleaned:
12534 # after its creation but before its name has been assigned to `$tmp'.
12535 $debug ||
12536 {
12537 tmp= ac_tmp=
12538 trap 'exit_status=$?
12539 : "${ac_tmp:=$tmp}"
12540 { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
12541 ' 0
12542 trap 'as_fn_exit 1' 1 2 13 15
12543 }
12544 # Create a (secure) tmp directory for tmp files.
12545
12546 {
12547 tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
12548 test -d "$tmp"
12549 } ||
12550 {
12551 tmp=./conf$$-$RANDOM
12552 (umask 077 && mkdir "$tmp")
12553 } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
12554 ac_tmp=$tmp
12555
12556 # Set up the scripts for CONFIG_FILES section.
12557 # No need to generate them if there are no CONFIG_FILES.
12558 # This happens for instance with `./config.status config.h'.
12559 if test -n "$CONFIG_FILES"; then
12560
12561
12562 ac_cr=`echo X | tr X '\015'`
12563 # On cygwin, bash can eat \r inside `` if the user requested igncr.
12564 # But we know of no other shell where ac_cr would be empty at this
12565 # point, so we can use a bashism as a fallback.
12566 if test "x$ac_cr" = x; then
12567 eval ac_cr=\$\'\\r\'
12568 fi
12569 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
12570 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
12571 ac_cs_awk_cr='\\r'
12572 else
12573 ac_cs_awk_cr=$ac_cr
12574 fi
12575
12576 echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
12577 _ACEOF
12578
12579
12580 {
12581 echo "cat >conf$$subs.awk <<_ACEOF" &&
12582 echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
12583 echo "_ACEOF"
12584 } >conf$$subs.sh ||
12585 as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
12586 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
12587 ac_delim='%!_!# '
12588 for ac_last_try in false false false false false :; do
12589 . ./conf$$subs.sh ||
12590 as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
12591
12592 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
12593 if test $ac_delim_n = $ac_delim_num; then
12594 break
12595 elif $ac_last_try; then
12596 as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
12597 else
12598 ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
12599 fi
12600 done
12601 rm -f conf$$subs.sh
12602
12603 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
12604 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
12605 _ACEOF
12606 sed -n '
12607 h
12608 s/^/S["/; s/!.*/"]=/
12609 p
12610 g
12611 s/^[^!]*!//
12612 :repl
12613 t repl
12614 s/'"$ac_delim"'$//
12615 t delim
12616 :nl
12617 h
12618 s/\(.\{148\}\)..*/\1/
12619 t more1
12620 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
12621 p
12622 n
12623 b repl
12624 :more1
12625 s/["\\]/\\&/g; s/^/"/; s/$/"\\/
12626 p
12627 g
12628 s/.\{148\}//
12629 t nl
12630 :delim
12631 h
12632 s/\(.\{148\}\)..*/\1/
12633 t more2
12634 s/["\\]/\\&/g; s/^/"/; s/$/"/
12635 p
12636 b
12637 :more2
12638 s/["\\]/\\&/g; s/^/"/; s/$/"\\/
12639 p
12640 g
12641 s/.\{148\}//
12642 t delim
12643 ' <conf$$subs.awk | sed '
12644 /^[^""]/{
12645 N
12646 s/\n//
12647 }
12648 ' >>$CONFIG_STATUS || ac_write_fail=1
12649 rm -f conf$$subs.awk
12650 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
12651 _ACAWK
12652 cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
12653 for (key in S) S_is_set[key] = 1
12654 FS = ""
12655
12656 }
12657 {
12658 line = $ 0
12659 nfields = split(line, field, "@")
12660 substed = 0
12661 len = length(field[1])
12662 for (i = 2; i < nfields; i++) {
12663 key = field[i]
12664 keylen = length(key)
12665 if (S_is_set[key]) {
12666 value = S[key]
12667 line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
12668 len += length(value) + length(field[++i])
12669 substed = 1
12670 } else
12671 len += 1 + keylen
12672 }
12673
12674 print line
12675 }
12676
12677 _ACAWK
12678 _ACEOF
12679 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
12680 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
12681 sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
12682 else
12683 cat
12684 fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
12685 || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
12686 _ACEOF
12687
12688 # VPATH may cause trouble with some makes, so we remove sole $(srcdir),
12689 # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
12690 # trailing colons and then remove the whole line if VPATH becomes empty
12691 # (actually we leave an empty line to preserve line numbers).
12692 if test "x$srcdir" = x.; then
12693 ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
12694 h
12695 s///
12696 s/^/:/
12697 s/[ ]*$/:/
12698 s/:\$(srcdir):/:/g
12699 s/:\${srcdir}:/:/g
12700 s/:@srcdir@:/:/g
12701 s/^:*//
12702 s/:*$//
12703 x
12704 s/\(=[ ]*\).*/\1/
12705 G
12706 s/\n//
12707 s/^[^=]*=[ ]*$//
12708 }'
12709 fi
12710
12711 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
12712 fi # test -n "$CONFIG_FILES"
12713
12714 # Set up the scripts for CONFIG_HEADERS section.
12715 # No need to generate them if there are no CONFIG_HEADERS.
12716 # This happens for instance with `./config.status Makefile'.
12717 if test -n "$CONFIG_HEADERS"; then
12718 cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
12719 BEGIN {
12720 _ACEOF
12721
12722 # Transform confdefs.h into an awk script `defines.awk', embedded as
12723 # here-document in config.status, that substitutes the proper values into
12724 # config.h.in to produce config.h.
12725
12726 # Create a delimiter string that does not exist in confdefs.h, to ease
12727 # handling of long lines.
12728 ac_delim='%!_!# '
12729 for ac_last_try in false false :; do
12730 ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
12731 if test -z "$ac_tt"; then
12732 break
12733 elif $ac_last_try; then
12734 as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
12735 else
12736 ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
12737 fi
12738 done
12739
12740 # For the awk script, D is an array of macro values keyed by name,
12741 # likewise P contains macro parameters if any. Preserve backslash
12742 # newline sequences.
12743
12744 ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
12745 sed -n '
12746 s/.\{148\}/&'"$ac_delim"'/g
12747 t rset
12748 :rset
12749 s/^[ ]*#[ ]*define[ ][ ]*/ /
12750 t def
12751 d
12752 :def
12753 s/\\$//
12754 t bsnl
12755 s/["\\]/\\&/g
12756 s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
12757 D["\1"]=" \3"/p
12758 s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
12759 d
12760 :bsnl
12761 s/["\\]/\\&/g
12762 s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
12763 D["\1"]=" \3\\\\\\n"\\/p
12764 t cont
12765 s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
12766 t cont
12767 d
12768 :cont
12769 n
12770 s/.\{148\}/&'"$ac_delim"'/g
12771 t clear
12772 :clear
12773 s/\\$//
12774 t bsnlc
12775 s/["\\]/\\&/g; s/^/"/; s/$/"/p
12776 d
12777 :bsnlc
12778 s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
12779 b cont
12780 ' <confdefs.h | sed '
12781 s/'"$ac_delim"'/"\\\
12782 "/g' >>$CONFIG_STATUS || ac_write_fail=1
12783
12784 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
12785 for (key in D) D_is_set[key] = 1
12786 FS = ""
12787 }
12788 /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
12789 line = \$ 0
12790 split(line, arg, " ")
12791 if (arg[1] == "#") {
12792 defundef = arg[2]
12793 mac1 = arg[3]
12794 } else {
12795 defundef = substr(arg[1], 2)
12796 mac1 = arg[2]
12797 }
12798 split(mac1, mac2, "(") #)
12799 macro = mac2[1]
12800 prefix = substr(line, 1, index(line, defundef) - 1)
12801 if (D_is_set[macro]) {
12802 # Preserve the white space surrounding the "#".
12803 print prefix "define", macro P[macro] D[macro]
12804 next
12805 } else {
12806 # Replace #undef with comments. This is necessary, for example,
12807 # in the case of _POSIX_SOURCE, which is predefined and required
12808 # on some systems where configure will not decide to define it.
12809 if (defundef == "undef") {
12810 print "/*", prefix defundef, macro, "*/"
12811 next
12812 }
12813 }
12814 }
12815 { print }
12816 _ACAWK
12817 _ACEOF
12818 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
12819 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
12820 fi # test -n "$CONFIG_HEADERS"
12821
12822
12823 eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS"
12824 shift
12825 for ac_tag
12826 do
12827 case $ac_tag in
12828 :[FHLC]) ac_mode=$ac_tag; continue;;
12829 esac
12830 case $ac_mode$ac_tag in
12831 :[FHL]*:*);;
12832 :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
12833 :[FH]-) ac_tag=-:-;;
12834 :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
12835 esac
12836 ac_save_IFS=$IFS
12837 IFS=:
12838 set x $ac_tag
12839 IFS=$ac_save_IFS
12840 shift
12841 ac_file=$1
12842 shift
12843
12844 case $ac_mode in
12845 :L) ac_source=$1;;
12846 :[FH])
12847 ac_file_inputs=
12848 for ac_f
12849 do
12850 case $ac_f in
12851 -) ac_f="$ac_tmp/stdin";;
12852 *) # Look for the file first in the build tree, then in the source tree
12853 # (if the path is not absolute). The absolute path cannot be DOS-style,
12854 # because $ac_f cannot contain `:'.
12855 test -f "$ac_f" ||
12856 case $ac_f in
12857 [\\/$]*) false;;
12858 *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
12859 esac ||
12860 as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
12861 esac
12862 case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
12863 as_fn_append ac_file_inputs " '$ac_f'"
12864 done
12865
12866 # Let's still pretend it is `configure' which instantiates (i.e., don't
12867 # use $as_me), people would be surprised to read:
12868 # /* config.h. Generated by config.status. */
12869 configure_input='Generated from '`
12870 $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
12871 `' by configure.'
12872 if test x"$ac_file" != x-; then
12873 configure_input="$ac_file. $configure_input"
12874 { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
12875 $as_echo "$as_me: creating $ac_file" >&6;}
12876 fi
12877 # Neutralize special characters interpreted by sed in replacement strings.
12878 case $configure_input in #(
12879 *\&* | *\|* | *\\* )
12880 ac_sed_conf_input=`$as_echo "$configure_input" |
12881 sed 's/[\\\\&|]/\\\\&/g'`;; #(
12882 *) ac_sed_conf_input=$configure_input;;
12883 esac
12884
12885 case $ac_tag in
12886 *:-:* | *:-) cat >"$ac_tmp/stdin" \
12887 || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
12888 esac
12889 ;;
12890 esac
12891
12892 ac_dir=`$as_dirname -- "$ac_file" ||
12893 $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
12894 X"$ac_file" : 'X\(//\)[^/]' \| \
12895 X"$ac_file" : 'X\(//\)$' \| \
12896 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
12897 $as_echo X"$ac_file" |
12898 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
12899 s//\1/
12900 q
12901 }
12902 /^X\(\/\/\)[^/].*/{
12903 s//\1/
12904 q
12905 }
12906 /^X\(\/\/\)$/{
12907 s//\1/
12908 q
12909 }
12910 /^X\(\/\).*/{
12911 s//\1/
12912 q
12913 }
12914 s/.*/./; q'`
12915 as_dir="$ac_dir"; as_fn_mkdir_p
12916 ac_builddir=.
12917
12918 case "$ac_dir" in
12919 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
12920 *)
12921 ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
12922 # A ".." for each directory in $ac_dir_suffix.
12923 ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
12924 case $ac_top_builddir_sub in
12925 "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
12926 *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
12927 esac ;;
12928 esac
12929 ac_abs_top_builddir=$ac_pwd
12930 ac_abs_builddir=$ac_pwd$ac_dir_suffix
12931 # for backward compatibility:
12932 ac_top_builddir=$ac_top_build_prefix
12933
12934 case $srcdir in
12935 .) # We are building in place.
12936 ac_srcdir=.
12937 ac_top_srcdir=$ac_top_builddir_sub
12938 ac_abs_top_srcdir=$ac_pwd ;;
12939 [\\/]* | ?:[\\/]* ) # Absolute name.
12940 ac_srcdir=$srcdir$ac_dir_suffix;
12941 ac_top_srcdir=$srcdir
12942 ac_abs_top_srcdir=$srcdir ;;
12943 *) # Relative name.
12944 ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
12945 ac_top_srcdir=$ac_top_build_prefix$srcdir
12946 ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
12947 esac
12948 ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
12949
12950
12951 case $ac_mode in
12952 :F)
12953 #
12954 # CONFIG_FILE
12955 #
12956
12957 case $INSTALL in
12958 [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
12959 *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
12960 esac
12961 _ACEOF
12962
12963 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
12964 # If the template does not know about datarootdir, expand it.
12965 # FIXME: This hack should be removed a few years after 2.60.
12966 ac_datarootdir_hack=; ac_datarootdir_seen=
12967 ac_sed_dataroot='
12968 /datarootdir/ {
12969 p
12970 q
12971 }
12972 /@datadir@/p
12973 /@docdir@/p
12974 /@infodir@/p
12975 /@localedir@/p
12976 /@mandir@/p'
12977 case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
12978 *datarootdir*) ac_datarootdir_seen=yes;;
12979 *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
12980 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
12981 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
12982 _ACEOF
12983 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
12984 ac_datarootdir_hack='
12985 s&@datadir@&$datadir&g
12986 s&@docdir@&$docdir&g
12987 s&@infodir@&$infodir&g
12988 s&@localedir@&$localedir&g
12989 s&@mandir@&$mandir&g
12990 s&\\\${datarootdir}&$datarootdir&g' ;;
12991 esac
12992 _ACEOF
12993
12994 # Neutralize VPATH when `$srcdir' = `.'.
12995 # Shell code in configure.ac might set extrasub.
12996 # FIXME: do we really want to maintain this feature?
12997 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
12998 ac_sed_extra="$ac_vpsub
12999 $extrasub
13000 _ACEOF
13001 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
13002 :t
13003 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
13004 s|@configure_input@|$ac_sed_conf_input|;t t
13005 s&@top_builddir@&$ac_top_builddir_sub&;t t
13006 s&@top_build_prefix@&$ac_top_build_prefix&;t t
13007 s&@srcdir@&$ac_srcdir&;t t
13008 s&@abs_srcdir@&$ac_abs_srcdir&;t t
13009 s&@top_srcdir@&$ac_top_srcdir&;t t
13010 s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
13011 s&@builddir@&$ac_builddir&;t t
13012 s&@abs_builddir@&$ac_abs_builddir&;t t
13013 s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
13014 s&@INSTALL@&$ac_INSTALL&;t t
13015 $ac_datarootdir_hack
13016 "
13017 eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
13018 >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
13019
13020 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
13021 { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
13022 { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
13023 "$ac_tmp/out"`; test -z "$ac_out"; } &&
13024 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
13025 which seems to be undefined. Please make sure it is defined" >&5
13026 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
13027 which seems to be undefined. Please make sure it is defined" >&2;}
13028
13029 rm -f "$ac_tmp/stdin"
13030 case $ac_file in
13031 -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
13032 *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
13033 esac \
13034 || as_fn_error $? "could not create $ac_file" "$LINENO" 5
13035 ;;
13036 :H)
13037 #
13038 # CONFIG_HEADER
13039 #
13040 if test x"$ac_file" != x-; then
13041 {
13042 $as_echo "/* $configure_input */" \
13043 && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
13044 } >"$ac_tmp/config.h" \
13045 || as_fn_error $? "could not create $ac_file" "$LINENO" 5
13046 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
13047 { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
13048 $as_echo "$as_me: $ac_file is unchanged" >&6;}
13049 else
13050 rm -f "$ac_file"
13051 mv "$ac_tmp/config.h" "$ac_file" \
13052 || as_fn_error $? "could not create $ac_file" "$LINENO" 5
13053 fi
13054 else
13055 $as_echo "/* $configure_input */" \
13056 && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
13057 || as_fn_error $? "could not create -" "$LINENO" 5
13058 fi
13059 ;;
13060
13061 :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
13062 $as_echo "$as_me: executing $ac_file commands" >&6;}
13063 ;;
13064 esac
13065
13066
13067 case $ac_file$ac_mode in
13068 "libtool":C)
13069
13070 # See if we are running on zsh, and set the options which allow our
13071 # commands through without removal of \ escapes.
13072 if test -n "${ZSH_VERSION+set}" ; then
13073 setopt NO_GLOB_SUBST
13074 fi
13075
13076 cfgfile="${ofile}T"
13077 trap "$RM \"$cfgfile\"; exit 1" 1 2 15
13078 $RM "$cfgfile"
13079
13080 cat <<_LT_EOF >> "$cfgfile"
13081 #! $SHELL
13082
13083 # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
13084 # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
13085 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
13086 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
13087 #
13088 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
13089 # 2006, 2007, 2008, 2009, 2010, 2011 Free Software
13090 # Foundation, Inc.
13091 # Written by Gordon Matzigkeit, 1996
13092 #
13093 # This file is part of GNU Libtool.
13094 #
13095 # GNU Libtool is free software; you can redistribute it and/or
13096 # modify it under the terms of the GNU General Public License as
13097 # published by the Free Software Foundation; either version 2 of
13098 # the License, or (at your option) any later version.
13099 #
13100 # As a special exception to the GNU General Public License,
13101 # if you distribute this file as part of a program or library that
13102 # is built using GNU Libtool, you may include this file under the
13103 # same distribution terms that you use for the rest of that program.
13104 #
13105 # GNU Libtool is distributed in the hope that it will be useful,
13106 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13107 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13108 # GNU General Public License for more details.
13109 #
13110 # You should have received a copy of the GNU General Public License
13111 # along with GNU Libtool; see the file COPYING. If not, a copy
13112 # can be downloaded from http://www.gnu.org/licenses/gpl.html, or
13113 # obtained by writing to the Free Software Foundation, Inc.,
13114 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
13115
13116
13117 # The names of the tagged configurations supported by this script.
13118 available_tags=""
13119
13120 # ### BEGIN LIBTOOL CONFIG
13121
13122 # Which release of libtool.m4 was used?
13123 macro_version=$macro_version
13124 macro_revision=$macro_revision
13125
13126 # Whether or not to build shared libraries.
13127 build_libtool_libs=$enable_shared
13128
13129 # Whether or not to build static libraries.
13130 build_old_libs=$enable_static
13131
13132 # What type of objects to build.
13133 pic_mode=$pic_mode
13134
13135 # Whether or not to optimize for fast installation.
13136 fast_install=$enable_fast_install
13137
13138 # Shell to use when invoking shell scripts.
13139 SHELL=$lt_SHELL
13140
13141 # An echo program that protects backslashes.
13142 ECHO=$lt_ECHO
13143
13144 # The PATH separator for the build system.
13145 PATH_SEPARATOR=$lt_PATH_SEPARATOR
13146
13147 # The host system.
13148 host_alias=$host_alias
13149 host=$host
13150 host_os=$host_os
13151
13152 # The build system.
13153 build_alias=$build_alias
13154 build=$build
13155 build_os=$build_os
13156
13157 # A sed program that does not truncate output.
13158 SED=$lt_SED
13159
13160 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
13161 Xsed="\$SED -e 1s/^X//"
13162
13163 # A grep program that handles long lines.
13164 GREP=$lt_GREP
13165
13166 # An ERE matcher.
13167 EGREP=$lt_EGREP
13168
13169 # A literal string matcher.
13170 FGREP=$lt_FGREP
13171
13172 # A BSD- or MS-compatible name lister.
13173 NM=$lt_NM
13174
13175 # Whether we need soft or hard links.
13176 LN_S=$lt_LN_S
13177
13178 # What is the maximum length of a command?
13179 max_cmd_len=$max_cmd_len
13180
13181 # Object file suffix (normally "o").
13182 objext=$ac_objext
13183
13184 # Executable file suffix (normally "").
13185 exeext=$exeext
13186
13187 # whether the shell understands "unset".
13188 lt_unset=$lt_unset
13189
13190 # turn spaces into newlines.
13191 SP2NL=$lt_lt_SP2NL
13192
13193 # turn newlines into spaces.
13194 NL2SP=$lt_lt_NL2SP
13195
13196 # convert \$build file names to \$host format.
13197 to_host_file_cmd=$lt_cv_to_host_file_cmd
13198
13199 # convert \$build files to toolchain format.
13200 to_tool_file_cmd=$lt_cv_to_tool_file_cmd
13201
13202 # An object symbol dumper.
13203 OBJDUMP=$lt_OBJDUMP
13204
13205 # Method to check whether dependent libraries are shared objects.
13206 deplibs_check_method=$lt_deplibs_check_method
13207
13208 # Command to use when deplibs_check_method = "file_magic".
13209 file_magic_cmd=$lt_file_magic_cmd
13210
13211 # How to find potential files when deplibs_check_method = "file_magic".
13212 file_magic_glob=$lt_file_magic_glob
13213
13214 # Find potential files using nocaseglob when deplibs_check_method = "file_magic".
13215 want_nocaseglob=$lt_want_nocaseglob
13216
13217 # DLL creation program.
13218 DLLTOOL=$lt_DLLTOOL
13219
13220 # Command to associate shared and link libraries.
13221 sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd
13222
13223 # The archiver.
13224 AR=$lt_AR
13225
13226 # Flags to create an archive.
13227 AR_FLAGS=$lt_AR_FLAGS
13228
13229 # How to feed a file listing to the archiver.
13230 archiver_list_spec=$lt_archiver_list_spec
13231
13232 # A symbol stripping program.
13233 STRIP=$lt_STRIP
13234
13235 # Commands used to install an old-style archive.
13236 RANLIB=$lt_RANLIB
13237 old_postinstall_cmds=$lt_old_postinstall_cmds
13238 old_postuninstall_cmds=$lt_old_postuninstall_cmds
13239
13240 # Whether to use a lock for old archive extraction.
13241 lock_old_archive_extraction=$lock_old_archive_extraction
13242
13243 # A C compiler.
13244 LTCC=$lt_CC
13245
13246 # LTCC compiler flags.
13247 LTCFLAGS=$lt_CFLAGS
13248
13249 # Take the output of nm and produce a listing of raw symbols and C names.
13250 global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
13251
13252 # Transform the output of nm in a proper C declaration.
13253 global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
13254
13255 # Transform the output of nm in a C name address pair.
13256 global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
13257
13258 # Transform the output of nm in a C name address pair when lib prefix is needed.
13259 global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
13260
13261 # Specify filename containing input files for \$NM.
13262 nm_file_list_spec=$lt_nm_file_list_spec
13263
13264 # The root where to search for dependent libraries,and in which our libraries should be installed.
13265 lt_sysroot=$lt_sysroot
13266
13267 # The name of the directory that contains temporary libtool files.
13268 objdir=$objdir
13269
13270 # Used to examine libraries when file_magic_cmd begins with "file".
13271 MAGIC_CMD=$MAGIC_CMD
13272
13273 # Must we lock files when doing compilation?
13274 need_locks=$lt_need_locks
13275
13276 # Manifest tool.
13277 MANIFEST_TOOL=$lt_MANIFEST_TOOL
13278
13279 # Tool to manipulate archived DWARF debug symbol files on Mac OS X.
13280 DSYMUTIL=$lt_DSYMUTIL
13281
13282 # Tool to change global to local symbols on Mac OS X.
13283 NMEDIT=$lt_NMEDIT
13284
13285 # Tool to manipulate fat objects and archives on Mac OS X.
13286 LIPO=$lt_LIPO
13287
13288 # ldd/readelf like tool for Mach-O binaries on Mac OS X.
13289 OTOOL=$lt_OTOOL
13290
13291 # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
13292 OTOOL64=$lt_OTOOL64
13293
13294 # Old archive suffix (normally "a").
13295 libext=$libext
13296
13297 # Shared library suffix (normally ".so").
13298 shrext_cmds=$lt_shrext_cmds
13299
13300 # The commands to extract the exported symbol list from a shared archive.
13301 extract_expsyms_cmds=$lt_extract_expsyms_cmds
13302
13303 # Variables whose values should be saved in libtool wrapper scripts and
13304 # restored at link time.
13305 variables_saved_for_relink=$lt_variables_saved_for_relink
13306
13307 # Do we need the "lib" prefix for modules?
13308 need_lib_prefix=$need_lib_prefix
13309
13310 # Do we need a version for libraries?
13311 need_version=$need_version
13312
13313 # Library versioning type.
13314 version_type=$version_type
13315
13316 # Shared library runtime path variable.
13317 runpath_var=$runpath_var
13318
13319 # Shared library path variable.
13320 shlibpath_var=$shlibpath_var
13321
13322 # Is shlibpath searched before the hard-coded library search path?
13323 shlibpath_overrides_runpath=$shlibpath_overrides_runpath
13324
13325 # Format of library name prefix.
13326 libname_spec=$lt_libname_spec
13327
13328 # List of archive names. First name is the real one, the rest are links.
13329 # The last name is the one that the linker finds with -lNAME
13330 library_names_spec=$lt_library_names_spec
13331
13332 # The coded name of the library, if different from the real name.
13333 soname_spec=$lt_soname_spec
13334
13335 # Permission mode override for installation of shared libraries.
13336 install_override_mode=$lt_install_override_mode
13337
13338 # Command to use after installation of a shared archive.
13339 postinstall_cmds=$lt_postinstall_cmds
13340
13341 # Command to use after uninstallation of a shared archive.
13342 postuninstall_cmds=$lt_postuninstall_cmds
13343
13344 # Commands used to finish a libtool library installation in a directory.
13345 finish_cmds=$lt_finish_cmds
13346
13347 # As "finish_cmds", except a single script fragment to be evaled but
13348 # not shown.
13349 finish_eval=$lt_finish_eval
13350
13351 # Whether we should hardcode library paths into libraries.
13352 hardcode_into_libs=$hardcode_into_libs
13353
13354 # Compile-time system search path for libraries.
13355 sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
13356
13357 # Run-time system search path for libraries.
13358 sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
13359
13360 # Whether dlopen is supported.
13361 dlopen_support=$enable_dlopen
13362
13363 # Whether dlopen of programs is supported.
13364 dlopen_self=$enable_dlopen_self
13365
13366 # Whether dlopen of statically linked programs is supported.
13367 dlopen_self_static=$enable_dlopen_self_static
13368
13369 # Commands to strip libraries.
13370 old_striplib=$lt_old_striplib
13371 striplib=$lt_striplib
13372
13373
13374 # The linker used to build libraries.
13375 LD=$lt_LD
13376
13377 # How to create reloadable object files.
13378 reload_flag=$lt_reload_flag
13379 reload_cmds=$lt_reload_cmds
13380
13381 # Commands used to build an old-style archive.
13382 old_archive_cmds=$lt_old_archive_cmds
13383
13384 # A language specific compiler.
13385 CC=$lt_compiler
13386
13387 # Is the compiler the GNU compiler?
13388 with_gcc=$GCC
13389
13390 # Compiler flag to turn off builtin functions.
13391 no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
13392
13393 # Additional compiler flags for building library objects.
13394 pic_flag=$lt_lt_prog_compiler_pic
13395
13396 # How to pass a linker flag through the compiler.
13397 wl=$lt_lt_prog_compiler_wl
13398
13399 # Compiler flag to prevent dynamic linking.
13400 link_static_flag=$lt_lt_prog_compiler_static
13401
13402 # Does compiler simultaneously support -c and -o options?
13403 compiler_c_o=$lt_lt_cv_prog_compiler_c_o
13404
13405 # Whether or not to add -lc for building shared libraries.
13406 build_libtool_need_lc=$archive_cmds_need_lc
13407
13408 # Whether or not to disallow shared libs when runtime libs are static.
13409 allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
13410
13411 # Compiler flag to allow reflexive dlopens.
13412 export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
13413
13414 # Compiler flag to generate shared objects directly from archives.
13415 whole_archive_flag_spec=$lt_whole_archive_flag_spec
13416
13417 # Whether the compiler copes with passing no objects directly.
13418 compiler_needs_object=$lt_compiler_needs_object
13419
13420 # Create an old-style archive from a shared archive.
13421 old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
13422
13423 # Create a temporary old-style archive to link instead of a shared archive.
13424 old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
13425
13426 # Commands used to build a shared archive.
13427 archive_cmds=$lt_archive_cmds
13428 archive_expsym_cmds=$lt_archive_expsym_cmds
13429
13430 # Commands used to build a loadable module if different from building
13431 # a shared archive.
13432 module_cmds=$lt_module_cmds
13433 module_expsym_cmds=$lt_module_expsym_cmds
13434
13435 # Whether we are building with GNU ld or not.
13436 with_gnu_ld=$lt_with_gnu_ld
13437
13438 # Flag that allows shared libraries with undefined symbols to be built.
13439 allow_undefined_flag=$lt_allow_undefined_flag
13440
13441 # Flag that enforces no undefined symbols.
13442 no_undefined_flag=$lt_no_undefined_flag
13443
13444 # Flag to hardcode \$libdir into a binary during linking.
13445 # This must work even if \$libdir does not exist
13446 hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
13447
13448 # Whether we need a single "-rpath" flag with a separated argument.
13449 hardcode_libdir_separator=$lt_hardcode_libdir_separator
13450
13451 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
13452 # DIR into the resulting binary.
13453 hardcode_direct=$hardcode_direct
13454
13455 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
13456 # DIR into the resulting binary and the resulting library dependency is
13457 # "absolute",i.e impossible to change by setting \${shlibpath_var} if the
13458 # library is relocated.
13459 hardcode_direct_absolute=$hardcode_direct_absolute
13460
13461 # Set to "yes" if using the -LDIR flag during linking hardcodes DIR
13462 # into the resulting binary.
13463 hardcode_minus_L=$hardcode_minus_L
13464
13465 # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
13466 # into the resulting binary.
13467 hardcode_shlibpath_var=$hardcode_shlibpath_var
13468
13469 # Set to "yes" if building a shared library automatically hardcodes DIR
13470 # into the library and all subsequent libraries and executables linked
13471 # against it.
13472 hardcode_automatic=$hardcode_automatic
13473
13474 # Set to yes if linker adds runtime paths of dependent libraries
13475 # to runtime path list.
13476 inherit_rpath=$inherit_rpath
13477
13478 # Whether libtool must link a program against all its dependency libraries.
13479 link_all_deplibs=$link_all_deplibs
13480
13481 # Set to "yes" if exported symbols are required.
13482 always_export_symbols=$always_export_symbols
13483
13484 # The commands to list exported symbols.
13485 export_symbols_cmds=$lt_export_symbols_cmds
13486
13487 # Symbols that should not be listed in the preloaded symbols.
13488 exclude_expsyms=$lt_exclude_expsyms
13489
13490 # Symbols that must always be exported.
13491 include_expsyms=$lt_include_expsyms
13492
13493 # Commands necessary for linking programs (against libraries) with templates.
13494 prelink_cmds=$lt_prelink_cmds
13495
13496 # Commands necessary for finishing linking programs.
13497 postlink_cmds=$lt_postlink_cmds
13498
13499 # Specify filename containing input files.
13500 file_list_spec=$lt_file_list_spec
13501
13502 # How to hardcode a shared library path into an executable.
13503 hardcode_action=$hardcode_action
13504
13505 # ### END LIBTOOL CONFIG
13506
13507 _LT_EOF
13508
13509 case $host_os in
13510 aix3*)
13511 cat <<\_LT_EOF >> "$cfgfile"
13512 # AIX sometimes has problems with the GCC collect2 program. For some
13513 # reason, if we set the COLLECT_NAMES environment variable, the problems
13514 # vanish in a puff of smoke.
13515 if test "X${COLLECT_NAMES+set}" != Xset; then
13516 COLLECT_NAMES=
13517 export COLLECT_NAMES
13518 fi
13519 _LT_EOF
13520 ;;
13521 esac
13522
13523
13524 ltmain="$ac_aux_dir/ltmain.sh"
13525
13526
13527 # We use sed instead of cat because bash on DJGPP gets confused if
13528 # if finds mixed CR/LF and LF-only lines. Since sed operates in
13529 # text mode, it properly converts lines to CR/LF. This bash problem
13530 # is reportedly fixed, but why not run on old versions too?
13531 sed '$q' "$ltmain" >> "$cfgfile" \
13532 || (rm -f "$cfgfile"; exit 1)
13533
13534 if test x"$xsi_shell" = xyes; then
13535 sed -e '/^func_dirname ()$/,/^} # func_dirname /c\
13536 func_dirname ()\
13537 {\
13538 \ case ${1} in\
13539 \ */*) func_dirname_result="${1%/*}${2}" ;;\
13540 \ * ) func_dirname_result="${3}" ;;\
13541 \ esac\
13542 } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \
13543 && mv -f "$cfgfile.tmp" "$cfgfile" \
13544 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13545 test 0 -eq $? || _lt_function_replace_fail=:
13546
13547
13548 sed -e '/^func_basename ()$/,/^} # func_basename /c\
13549 func_basename ()\
13550 {\
13551 \ func_basename_result="${1##*/}"\
13552 } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \
13553 && mv -f "$cfgfile.tmp" "$cfgfile" \
13554 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13555 test 0 -eq $? || _lt_function_replace_fail=:
13556
13557
13558 sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\
13559 func_dirname_and_basename ()\
13560 {\
13561 \ case ${1} in\
13562 \ */*) func_dirname_result="${1%/*}${2}" ;;\
13563 \ * ) func_dirname_result="${3}" ;;\
13564 \ esac\
13565 \ func_basename_result="${1##*/}"\
13566 } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \
13567 && mv -f "$cfgfile.tmp" "$cfgfile" \
13568 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13569 test 0 -eq $? || _lt_function_replace_fail=:
13570
13571
13572 sed -e '/^func_stripname ()$/,/^} # func_stripname /c\
13573 func_stripname ()\
13574 {\
13575 \ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\
13576 \ # positional parameters, so assign one to ordinary parameter first.\
13577 \ func_stripname_result=${3}\
13578 \ func_stripname_result=${func_stripname_result#"${1}"}\
13579 \ func_stripname_result=${func_stripname_result%"${2}"}\
13580 } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \
13581 && mv -f "$cfgfile.tmp" "$cfgfile" \
13582 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13583 test 0 -eq $? || _lt_function_replace_fail=:
13584
13585
13586 sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\
13587 func_split_long_opt ()\
13588 {\
13589 \ func_split_long_opt_name=${1%%=*}\
13590 \ func_split_long_opt_arg=${1#*=}\
13591 } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \
13592 && mv -f "$cfgfile.tmp" "$cfgfile" \
13593 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13594 test 0 -eq $? || _lt_function_replace_fail=:
13595
13596
13597 sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\
13598 func_split_short_opt ()\
13599 {\
13600 \ func_split_short_opt_arg=${1#??}\
13601 \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\
13602 } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \
13603 && mv -f "$cfgfile.tmp" "$cfgfile" \
13604 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13605 test 0 -eq $? || _lt_function_replace_fail=:
13606
13607
13608 sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\
13609 func_lo2o ()\
13610 {\
13611 \ case ${1} in\
13612 \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\
13613 \ *) func_lo2o_result=${1} ;;\
13614 \ esac\
13615 } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \
13616 && mv -f "$cfgfile.tmp" "$cfgfile" \
13617 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13618 test 0 -eq $? || _lt_function_replace_fail=:
13619
13620
13621 sed -e '/^func_xform ()$/,/^} # func_xform /c\
13622 func_xform ()\
13623 {\
13624 func_xform_result=${1%.*}.lo\
13625 } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \
13626 && mv -f "$cfgfile.tmp" "$cfgfile" \
13627 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13628 test 0 -eq $? || _lt_function_replace_fail=:
13629
13630
13631 sed -e '/^func_arith ()$/,/^} # func_arith /c\
13632 func_arith ()\
13633 {\
13634 func_arith_result=$(( $* ))\
13635 } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \
13636 && mv -f "$cfgfile.tmp" "$cfgfile" \
13637 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13638 test 0 -eq $? || _lt_function_replace_fail=:
13639
13640
13641 sed -e '/^func_len ()$/,/^} # func_len /c\
13642 func_len ()\
13643 {\
13644 func_len_result=${#1}\
13645 } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \
13646 && mv -f "$cfgfile.tmp" "$cfgfile" \
13647 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13648 test 0 -eq $? || _lt_function_replace_fail=:
13649
13650 fi
13651
13652 if test x"$lt_shell_append" = xyes; then
13653 sed -e '/^func_append ()$/,/^} # func_append /c\
13654 func_append ()\
13655 {\
13656 eval "${1}+=\\${2}"\
13657 } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \
13658 && mv -f "$cfgfile.tmp" "$cfgfile" \
13659 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13660 test 0 -eq $? || _lt_function_replace_fail=:
13661
13662
13663 sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\
13664 func_append_quoted ()\
13665 {\
13666 \ func_quote_for_eval "${2}"\
13667 \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\
13668 } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \
13669 && mv -f "$cfgfile.tmp" "$cfgfile" \
13670 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13671 test 0 -eq $? || _lt_function_replace_fail=:
13672
13673
13674 # Save a `func_append' function call where possible by direct use of '+='
13675 sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
13676 && mv -f "$cfgfile.tmp" "$cfgfile" \
13677 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13678 test 0 -eq $? || _lt_function_replace_fail=:
13679 else
13680 # Save a `func_append' function call even when '+=' is not available
13681 sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
13682 && mv -f "$cfgfile.tmp" "$cfgfile" \
13683 || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
13684 test 0 -eq $? || _lt_function_replace_fail=:
13685 fi
13686
13687 if test x"$_lt_function_replace_fail" = x":"; then
13688 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5
13689 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;}
13690 fi
13691
13692
13693 mv -f "$cfgfile" "$ofile" ||
13694 (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
13695 chmod +x "$ofile"
13696
13697 ;;
13698 "disable-rpath":C)
13699 sed < libtool > libtool-2 \
13700 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_RPATH_SED__ "/'
13701 mv libtool-2 libtool
13702 chmod 755 libtool
13703 libtool="./libtool"
13704 ;;
13705
13706 esac
13707 done # for ac_tag
13708
13709
13710 as_fn_exit 0
13711 _ACEOF
13712 ac_clean_files=$ac_clean_files_save
13713
13714 test $ac_write_fail = 0 ||
13715 as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
13716
13717
13718 # configure is writing to config.log, and then calls config.status.
13719 # config.status does its own redirection, appending to config.log.
13720 # Unfortunately, on DOS this fails, as config.log is still kept open
13721 # by configure, so config.status won't be able to write to it; its
13722 # output is simply discarded. So we exec the FD to /dev/null,
13723 # effectively closing config.log, so it can be properly (re)opened and
13724 # appended to by config.status. When coming back to configure, we
13725 # need to make the FD available again.
13726 if test "$no_create" != yes; then
13727 ac_cs_success=:
13728 ac_config_status_args=
13729 test "$silent" = yes &&
13730 ac_config_status_args="$ac_config_status_args --quiet"
13731 exec 5>/dev/null
13732 $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
13733 exec 5>>config.log
13734 # Use ||, not &&, to avoid exiting from the if with $? = 1, which
13735 # would make configure fail if this is the last instruction.
13736 $ac_cs_success || as_fn_exit 1
13737 fi
13738 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
13739 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
13740 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
13741 fi
13742
0 # -*- Autoconf -*-
1 # Process this file with autoconf to produce a configure script.
2 # known to work with autconf version: autoconf (GNU Autoconf) 2.69
3 #
4 # @configure_input@
5 #
6 # Copyright (c) 2013, Verisign, Inc., NLnet Labs
7 # All rights reserved.
8 #
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions are met:
11 # * Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # * Neither the names of the copyright holders nor the
17 # names of its contributors may be used to endorse or promote products
18 # derived from this software without specific prior written permission.
19 #
20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
24 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 AC_PREREQ([2.56])
32 AC_INIT([getdns], [0.1.0], [stub-resolver@verisignlabs.com], [], [http://www.getdnsapi.net])
33 CURRENT_DATE=`LC_ALL=C date`
34 GETDNS_COMPILATION_COMMENT="AC_PACKAGE_STRING configured on $CURRENT_DATE for the February 2014 version of the API"
35 AC_SUBST(GETDNS_COMPILATION_COMMENT)
36 AC_CONFIG_SRCDIR([src/getdns/getdns.h.in])
37 # AM_INIT_AUTOMAKE
38 # LT_INIT
39 AC_CONFIG_MACRO_DIR([m4])
40
41 AC_PROG_CC
42 AC_PROG_CPP
43
44 # Checks for programs.
45 AC_CANONICAL_HOST
46 case "$host_os" in
47 linux* ) CFLAGS="$CFLAGS -D_XOPEN_SOURCE=501" # unfortunate, but needed to
48 # pick up strdup() declaration
49 # in <string.h>
50 ;;
51 solaris* ) CFLAGS="$CFLAGS -D__EXTENSIONS__" # for strdup() from <string.h>
52 ;;
53 esac
54
55 # always use ./libtool unless override from commandline (libtool=mylibtool)
56 if test -z "$libtool"; then
57 libtool="`pwd`/libtool"
58 fi
59 AC_SUBST(libtool)
60 AC_PROG_LIBTOOL
61 AC_PROG_INSTALL
62
63 dnl Add option to disable the evil rpath. Check whether to use rpath or not.
64 dnl Adds the --disable-rpath option. Uses trick to edit the ./libtool.
65 AC_DEFUN([ACX_ARG_RPATH],
66 [
67 AC_ARG_ENABLE(rpath,
68 [ --disable-rpath disable hardcoded rpath (default=enabled)],
69 enable_rpath=$enableval, enable_rpath=yes)
70 if test "x$enable_rpath" = xno; then
71 dnl AC_MSG_RESULT([Fixing libtool for -rpath problems.])
72 AC_CONFIG_COMMANDS([disable-rpath], [
73 sed < libtool > libtool-2 \
74 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_RPATH_SED__ "/'
75 mv libtool-2 libtool
76 chmod 755 libtool
77 libtool="./libtool"
78 ])
79 fi
80 ])
81 ACX_ARG_RPATH
82
83 # search to set include and library paths right
84 # find libidn
85 AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=pathname],
86 [path to libidn (default: search /usr/local ..)]),
87 [], [withval="yes"])
88 if test x_$withval = x_yes; then
89 for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do
90 if test -f "$dir/include/idna.h"; then
91 CFLAGS="$CFLAGS -I$dir/include"
92 LDFLAGS="$LDFLAGS -L$dir/lib"
93 AC_MSG_NOTICE([Found libidn in $dir])
94 break
95 fi
96 if test -f "$dir/include/idn/idna.h"; then
97 CFLAGS="$CFLAGS -I$dir/include/idn"
98 LDFLAGS="$LDFLAGS -L$dir/lib"
99 AC_MSG_NOTICE([Found libidn in $dir])
100 break
101 fi
102 done
103 if test -f "/usr/include/idn/idna.h"; then
104 CFLAGS="$CFLAGS -I/usr/include/idn"
105 #LDFLAGS="$LDFLAGS -L/usr/lib"
106 AC_MSG_NOTICE([Found libidn in /usr])
107 fi
108 else
109 if test x_$withval != x_no; then
110 CFLAGS="$CFLAGS -I$withval/include"
111 LDFLAGS="$LDFLAGS -L$withval/lib"
112 fi
113 fi
114
115 # find libldns
116 AC_ARG_WITH(libldns, AC_HELP_STRING([--with-libldns=pathname],
117 [path to libldns (default: search /usr/local ..)]),
118 [], [withval="yes"])
119 if test x_$withval = x_yes; then
120 for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do
121 if test -f "$dir/include/ldns/ldns.h"; then
122 CFLAGS="$CFLAGS -I$dir/include"
123 LDFLAGS="$LDFLAGS -L$dir/lib"
124 AC_MSG_NOTICE([Found libldns in $dir])
125 break
126 fi
127 done
128 else
129 if test x_$withval != x_no; then
130 CFLAGS="$CFLAGS -I$withval/include"
131 LDFLAGS="$LDFLAGS -L$withval/lib"
132 fi
133 fi
134
135 # find libunbound
136 AC_ARG_WITH(libunbound, AC_HELP_STRING([--with-libunbound=pathname],
137 [path to libunbound (default: search /usr/local ..)]),
138 [], [withval="yes"])
139 if test x_$withval = x_yes; then
140 for dir in /usr/local /opt/local /usr/pkg /usr/sfw; do
141 if test -f "$dir/include/unbound.h"; then
142 CFLAGS="$CFLAGS -I$dir/include"
143 LDFLAGS="$LDFLAGS -L$dir/lib"
144 AC_MSG_NOTICE([Found libunbound in $dir])
145 break
146 fi
147 done
148 else
149 if test x_$withval != x_no; then
150 CFLAGS="$CFLAGS -I$withval/include"
151 LDFLAGS="$LDFLAGS -L$withval/lib"
152 fi
153 fi
154
155 # Checks for libraries.
156 found_all_libs=1
157 AC_MSG_NOTICE([Checking for dependency ldns])
158 AC_CHECK_LIB([ldns], [ldns_dname_new_frm_str], [], [found_all_libs=0])
159 AC_MSG_NOTICE([Checking for dependency libidn])
160 AC_CHECK_LIB([idn], [idna_to_ascii_8z], [], [found_all_libs=0])
161
162 if test $found_all_libs == 0
163 then
164 AC_MSG_ERROR([One more dependencies is missing])
165 fi
166
167 # break out libunbound from other libraries since we are currently using a
168 # patch to the sources
169 found_libunbound=1
170 AC_MSG_NOTICE([Checking for dependency libunbound])
171 AC_CHECK_LIB([unbound], [ub_fd], [], [found_libunbound=0])
172 if test $found_libunbound == 0
173 then
174 AC_MSG_ERROR([libunbound is missing.])
175 fi
176
177 AC_CHECK_PROGS([DOXYGEN], [doxygen])
178 if test -z "$DOXYGEN";
179 then AC_MSG_WARN([Doxygen not found, continuing without])
180 fi
181
182 # Checks for header files.
183 AC_CHECK_HEADERS([inttypes.h netinet/in.h stdint.h stdlib.h string.h],,, [AC_INCLUDES_DEFAULT])
184
185 # Checks for typedefs, structures, and compiler characteristics.
186 AC_TYPE_SIZE_T
187 AC_TYPE_UINT16_T
188 AC_TYPE_UINT32_T
189 AC_TYPE_UINT64_T
190 AC_TYPE_UINT8_T
191
192 getdns_LIBS=$LIBS
193 getdns_LDFLAGS=$LDFLAGS
194
195 EXTENSION_LDFLAGS=$LDFLAGS
196
197 # libevent extension
198 have_libevent=0
199 EXTENSION_LIBEVENT_LIB="libgetdns_ext_event.la"
200 EXTENSION_LIBEVENT_EXT_LIBS=""
201 CHECK_EVENT_PROG=""
202 AC_SEARCH_LIBS([event_loop],
203 [event_core event],
204 [AC_CHECK_FUNCS([event_base_new event_base_free])]
205 [AC_CHECK_HEADERS([event2/event.h],
206 # event2/event.h found
207 [have_libevent=1]
208 [EXTENSION_LIBEVENT_EXT_LIBS="$ac_cv_search_event_loop"]
209 [CHECK_EVENT_PROG=check_getdns_event],
210 # not found - look for event.h
211 [AC_CHECK_TYPE(u_char, unsigned char)]
212 [AC_CHECK_HEADERS([event.h],
213 # found
214 [have_libevent=1]
215 [EXTENSION_LIBEVENT_EXT_LIBS="$ac_cv_search_event_loop"]
216 [CHECK_EVENT_PROG=check_getdns_event],
217 # not found - give up
218 [EXTENSION_LIBEVENT_LIB=""],
219 [AC_INCLUDES_DEFAULT])]
220 ,[AC_INCLUDES_DEFAULT])],
221 # libs not found
222 [have_libevent=0]
223 [EXTENSION_LIBEVENT_LIB=""])
224
225 AC_SUBST(have_libevent)
226 AC_SUBST(EXTENSION_LIBEVENT_LIB)
227 AC_SUBST(EXTENSION_LIBEVENT_EXT_LIBS)
228 AC_SUBST(CHECK_EVENT_PROG)
229
230 # libuv extension
231 have_libuv=1
232 EXTENSION_LIBUV_LIB="libgetdns_ext_uv.la"
233 EXTENSION_LIBUV_EXT_LIBS=""
234 CHECK_UV_PROG=""
235 AC_SEARCH_LIBS([uv_run],
236 [uv],
237 [AC_CHECK_HEADERS([uv.h],
238 [EXTENSION_LIBUV_EXT_LIBS="$ac_cv_search_uv_run"]
239 [CHECK_UV_PROG=check_getdns_uv],
240 [have_libuv=0]
241 [EXTENSION_LIBUV_LIB=""],
242 [AC_INCLUDES_DEFAULT])],
243 [have_libuv=0]
244 [EXTENSION_LIBUV_LIB=""])
245
246 AC_SUBST(have_libuv)
247 AC_SUBST(EXTENSION_LIBUV_LIB)
248 AC_SUBST(EXTENSION_LIBUV_EXT_LIBS)
249 AC_SUBST(CHECK_UV_PROG)
250
251 # libev extension
252 have_libev=1
253 EXTENSION_LIBEV_LIB="libgetdns_ext_ev.la"
254 EXTENSION_LIBEV_EXT_LIBS=""
255
256 AC_SEARCH_LIBS([ev_run],
257 [ev],
258 [AC_CHECK_HEADERS([ev.h],
259 [EXTENSION_LIBEV_EXT_LIBS="$ac_cv_search_ev_run"]
260 [CHECK_EV_PROG=check_getdns_ev],
261 [have_libev=0]
262 [EXTENSION_LIBUV_LIB=""],
263 [AC_INCLUDES_DEFAULT])],
264 [have_libev=0]
265 [EXTENSION_LIBEV_LIB=""])
266
267 AC_SUBST(have_libev)
268 AC_SUBST(EXTENSION_LIBEV_LIB)
269 AC_SUBST(EXTENSION_LIBEV_EXT_LIBS)
270 AC_SUBST(CHECK_EV_PROG)
271
272 AC_SUBST(EXTENSION_LDFLAGS)
273
274 LIBS=$getdns_LIBS
275 LDFLAGS=$getdns_LDFLAGS
276
277 # --with-trust-anchor=
278 AC_DEFINE([SYSCONFDIR], [sysconfdir], [System configuration dir])
279 AC_ARG_WITH(trust-anchor, AC_HELP_STRING([--with-trust-anchor=KEYFILE], [Default location of the trust anchor file. [default=SYSCONFDIR/unbound/getdns-root.key]]), [
280 TRUST_ANCHOR_FILE="$withval"
281 ],[
282 if test "x$TRUST_ANCHOR_FILE" = "x"; then
283 if test "x$sysconfdir" = 'x${prefix}/etc' ; then
284 if test "x$prefix" = 'xNONE' ; then
285 TRUST_ANCHOR_FILE="/etc/unbound/getdns-root.key"
286 else
287 TRUST_ANCHOR_FILE="${prefix}/etc/unbound/getdns-root.key"
288 fi
289 else
290 TRUST_ANCHOR_FILE="${sysconfdir}/unbound/getdns-root.key"
291 fi
292 fi
293 ])
294 AC_DEFINE_UNQUOTED([TRUST_ANCHOR_FILE], ["$TRUST_ANCHOR_FILE"], [Default trust anchor file])
295 AC_SUBST(TRUST_ANCHOR_FILE)
296 AC_MSG_NOTICE([Default trust anchor: $TRUST_ANCHOR_FILE])
297
298 AC_CONFIG_FILES([Makefile src/Makefile src/getdns/Makefile src/getdns/getdns.h src/example/Makefile src/test/Makefile doc/Makefile])
299 if [ test -n "$DOXYGEN" ]
300 then AC_CONFIG_FILES([src/Doxyfile])
301 fi
302 AC_CONFIG_HEADER([src/config.h])
303 AC_OUTPUT
0 #
1 # @configure_input@
2 #
3 #
4 # Copyright (c) 2013, Verisign, Inc., NLNet Labs
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * 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 # * Neither the names of the copyright holders nor the
15 # names of its contributors may be used to endorse or promote products
16 # derived from this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 package = @PACKAGE_NAME@
30 version = @PACKAGE_VERSION@
31 tarname = @PACKAGE_TARNAME@
32 distdir = $(tarname)-$(version)
33
34 prefix = @prefix@
35 exec_prefix = @exec_prefix@
36 bindir = @bindir@
37 # datarootdir is here to please some checkers
38 datarootdir=@datarootdir@
39 mandir = @mandir@
40 INSTALL = @INSTALL@
41
42 srcdir = @srcdir@
43 VPATH = @srcdir@
44
45 EDITS=-e 's/@''version@/$(version)/g'
46
47 DOCDIRS = html latex man
48 MANPAGES3 = libgetdns.3 getdns_address.3 getdns_cancel_callback.3 getdns_context.3 getdns_context_create.3 getdns_context_set.3 getdns_convert.3 getdns_dict.3 getdns_dict_get.3 getdns_dict_set.3 getdns_free_sync_request_memory.3 getdns_general.3 getdns_hostname.3 getdns_list.3 getdns_list_get.3 getdns_list_set.3 getdns_service.3
49
50 default: all
51
52 all: doc
53
54 doc: $(MANPAGES3)
55 cd ../src && doxygen
56
57 .SUFFIXES: .3.in .3
58 .3.in.3:
59 sed $(EDITS) -e "s/@date@/`date +'%B %Y'`/g" $< > $@
60
61 # we assume that we want a separate file for each "name" specified for each man page
62 # and consider these "alternate names" simple copies of the main man page
63 install: $(MANPAGES3)
64 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)
65 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man3
66 for x in $(MANPAGES3); do echo $(INSTALL) -m 644 $$x $(DESTDIR)$(mandir)/man3; $(INSTALL) -m 644 $$x $(DESTDIR)$(mandir)/man3; for altpg in $$(./manpgaltnames $$x); do cp $$x $$altpg; echo $(INSTALL) -m 644 $$altpg $(DESTDIR)$(mandir)/man3; $(INSTALL) -m 644 $$altpg $(DESTDIR)$(mandir)/man3; done; done
67
68 uninstall:
69 for x in $(MANPAGES3); do echo rm -f $(DESTDIR)$(mandir)/man3/$$x; rm -f $(DESTDIR)$(mandir)/man3/$$x; for altpg in $$(./manpgaltnames $$x); do echo rm -f $(DESTDIR)$(mandir)/man3/$$altpg; rm -f $(DESTDIR)$(mandir)/man3/$$altpg; done; done
70
71 clean:
72 for x in $(MANPAGES3); do rm -f $$(./manpgaltnames $$x); done
73 rm -rf $(DOCDIRS) $(MANPAGES3)
74
75 distclean : clean
76 rm -f Makefile config.status config.log
77 rm -Rf autom4te.cache
78
79 Makefile: Makefile.in ../config.status
80 cd .. && ./config.status $@
81
82 configure.status: configure
83 cd .. && ./config.status --recheck
84
85 .PHONY: clean $(DOC)
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_address 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_address,
31 .B getdns_address_sync
32
33 .SH LIBRARY
34 DNS Resolver library (libgetdns, -lgetdns)
35
36 .SH SYNOPSIS
37 #include <getdns.h>
38
39 getdns_return_t
40 .br
41 .B getdns_address
42 (getdns_context *context,
43 .RS 3
44 const char *name,
45 .br
46 getdns_dict *extensions,
47 .br
48 void *userarg,
49 .br
50 getdns_transaction_t *transaction_id,
51 .br
52 getdns_callback_t callbackfn)
53 .RE
54
55 getdns_return_t
56 .br
57 .B getdns_address_sync
58 (getdns_context *context,
59 .RS 3
60 const char *name,
61 .br
62 getdns_dict *extensions,
63 .br
64 getdns_dict **response)
65 .RE
66
67 .SH DESCRIPTION
68
69 .LP
70 The getdns_address(3) and getdns_address_sync functions provide public entry points into the getdns API library to retrieve the address given a host name. It always returns both IPv4 and IPv6 addresses.
71
72 .HP 3
73 .I context
74 .RP
75 see getdns_context (3)
76
77 .HP 3
78 .I name
79 .RP
80 the host name to resolve to an address (note that an IP address is considered invalid)
81
82 .HP 3
83 .I extensions
84 .RP
85 extensions for this request, NULL if no extensions, see libgetdns (3) for a detailed description of extensions
86
87 .HP 3
88 .I userarg
89 .RP
90 returned to the callback function untouched, can be NULL
91
92 .HP 3
93 .I transaction_id
94 .RP
95 populated by the API and used to identify the callback (for example to getdns_cancel_callback), can be NULL, set to 0 if the function fails
96
97 .HP 3
98 .I callbackfn
99 .RP
100 pointer to a callback function defined by the application, typically used to process the response, may not be NULL. Only the asynchronous signature accepts a callback function, the synchronous signature does not include a callback.
101
102 .HP 3
103 .I response
104 .RP
105 A getdns_dict type is returned in response and always contains at least three names: replies_full (a list containing the DNS response as binary data), replies_tree (a list containing the parsed DNS response data) and status (an int). The storage associated with this must be freed by a call to getdns_free_sync_request_memory (3).
106
107 .HP
108 .SH "RETURN VALUES"
109
110 Upon successful completion the functions return
111 .B GETDNS_RETURN_GOOD
112 , otherwise the following error values are returned:
113
114 .LP
115 .B GETDNS_RETURN_BAD_CONTEXT
116 if the context pointer is invalid
117 .LP
118 .B GETDNS_RETURN_INVALID PARAMETER
119 one or more parameters has an invalid value
120 .LP
121 .B GETDNS_RETURN_BAD_DOMAIN_NAME
122 if the domain name passed to the function is invalid
123 .LP
124 .B GETDNS_RETURN_EXTENSION_MISFORMAT
125 if the data type specified in one or more of the extensions does not match the specifications
126 .LP
127 .B GETDNS_RETURN_NO_SUCH_EXTENSION
128 if one or more of the strings specified in the extensions are not valid
129 .LP
130 .B GETDNS_RETURN_GENERIC_ERROR
131 some problem was encountered in the function not addressed by one of the more
132 specific return codes
133
134 The values of status in the response include:
135
136 .LP
137 .B GETDNS_RESPSTATUS_GOOD
138 At least one response was returned
139 .LP
140 .B GETDNS_RESPSTATUS_NO_NAME
141 Queries for the name yielded all negative responses
142 .LP
143 .B GETDNS_RESPSTATUS_ALL_TIMEOUT
144 All queries for the name timed out
145 .LP
146 .B GETDNS_RESPSTATUS_NO_SECURE_ANSWERS
147 only secure replies accepted (per context), at least one response was received but no DNS responses were secure through DNSSEC
148
149 .LP
150 For a more detailed explanation of the response object see
151 .I libgetdns
152 (3)
153
154 .SH EXAMPLES
155
156 TBD
157
158 .SH FILES
159 .br
160 /etc/hosts
161 .br
162 /etc/resolv.conf
163
164 .SH SEE ALSO
165 .BR libgetdns (3),
166 .BR getdns_context (3),
167 .BR getdns_free_sync_request_memory (3),
168 .BR getdns_general (3),
169 .BR getdns_general_sync (3),
170 .BR getdns_hostname (3),
171 .BR getdns_hostname_sync (3),
172 .BR getdns_service (3),
173 .BR getdns_service_sync (3)
174
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_cancel_callback 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_cancel_callback
31
32 .SH LIBRARY
33 DNS Resolver library (libgetdns, -lgetdns)
34
35 .SH SYNOPSIS
36 #include <getdns.h>
37
38 getdns_return_t
39 .br
40 .B getdns_cancel_callback
41 (getdns_context_t context,
42 .RS 3
43 .br
44 getdns_transaction_t *transaction_id)
45 .RE
46
47 .SH DESCRIPTION
48
49 .LP
50 To cancel an outstanding callback, use getdns_cancel_callback. This causes the
51 API to call the callback with a callback_type of GETDNS_CALLBACK_CANCEL if the
52 callback for this transaction_id has not already been called. The callback code
53 for cancellation should clean up any memory related to the identified call,
54 such as to deallocate the memory for the userarg. getdns_cancel_callback() may
55 return immediately, even before the callback finishes its work and returns.
56
57 .HP 3
58 .I context
59 .RP
60 see getdns_context (3)
61
62 .HP 3
63 .I transaction_id
64 .RP
65 populated by the API and used to identify the callback (for example to getdns_cancel_callback), can be NULL, set to 0 if the function fails
66
67 .HP
68 .SH "RETURN VALUES"
69
70 Upon successful completion the functions return
71 .B GETDNS_RETURN_GOOD
72 , otherwise the following error values are returned:
73
74 .LP
75 .B GETDNS_RETURN_UNKNOWN_TRANSACTION
76 when calling getdns_cancel_callback() with a transaction_id of a callback that has already been called or an unknown transaction_id
77
78 .SH EXAMPLES
79
80 TBD
81
82 .SH FILES
83 .br
84 /etc/hosts
85 .br
86 /etc/resolv.conf
87
88 .SH SEE ALSO
89 .BR libgetdns (3),
90 .BR getdns_context (3),
91 .BR getdns_general (3),
92 .BR getdns_hostname (3),
93 .BR getdns_service (3),
94
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_context 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_context_create,
31 .B getdns_context_create_with_memory_functions,
32 .B getdns_context_create_with_extended_memory_functions,
33 .B getdns_context_destroy
34 -- getdns context create and destroy routines
35
36 .SH LIBRARY
37 DNS Resolver library (libgetdns, -lgetdns)
38
39 .SH SYNOPSIS
40 #include <getdns.h>
41
42 getdns_return_t
43 .br
44 .B getdns_context_create
45 (getdns_context ** context,
46 .RS 3
47 .br
48 int set_from_os)
49 .RE
50
51 getdns_return_t
52 .br
53 .B getdns_context_create_with_memory_functions
54 (getdns_context ** context,
55 .RS 3
56 .br
57 int set_from_os,
58 .br
59 void *(*malloc) (size_t),
60 .br
61 void *(*realloc) (void *, size_t),
62 .br
63 void (*free) (void *))
64 .RE
65
66 getdns_return_t
67 .br
68 .B getdns_context_create_with_extended_memory_functions
69 (getdns_context **context,
70 .RS 3
71 .br
72 int set_from_os,
73 .br
74 void *userarg,
75 .br
76 void *(*malloc) (void *userarg, size_t),
77 .br
78 void *(*realloc) (void *userarg, void *, size_t),
79 .br
80 void (*free) (void *userarg, void *))
81 .RE
82
83 void
84 .br
85 .B getdns_context_destroy
86 (getdns_context *context)
87
88 .SH DESCRIPTION
89
90 .LP
91 Calls to getdns functions require a DNS context, which is a group of API
92 settings that affect how DNS calls are made. For most applications, a default
93 context is sufficient.
94
95 .LP
96 To create a new DNS context, use the function:
97 .RS 3
98 .br
99 getdns_return_t
100 .B getdns_context_create
101 (getdns_context_t *context, bool set_from_os)
102 .RE
103
104 .LP
105 The call to getdns_context_create immediately returns a context that can be
106 used with other API calls; that context contains the API's default values. Most
107 applications will want set_from_os set to true.
108
109 .LP
110 To clean up the context, including cleaning up all outstanding transactions
111 that were called using this context, use the function:
112 .RS 3
113 .br
114 void
115 .B getdns_context_destroy
116 (getdns_context_t context)
117 .RE
118
119 .LP
120 When getdns_context_destroy() returns, the application knows that all
121 outstanding transactions associated with this context will have been called;
122 callbacks that had not been called before getdns_context_destroy() was called
123 will be called with a callback_type of GETDNS_CALLBACK_CANCEL.
124 getdns_context_destroy() returns after all of the needed cleanup is done and
125 callbacks are made.
126
127 .SH DESCRIPTION (LONG)
128
129 .LP
130 Many calls in the DNS API require a DNS context. A DNS context contains the information that the API needs in order to process DNS calls, such as the locations of upstream DNS servers, DNSSEC trust anchors, and so on. The internal structure of the DNS context is opaque, and might be different on each OS. When a context is passed to any function, it must be an allocated context; the context must not be NULL.
131
132 .LP
133 A typical application using this API doesn't need to know anything about contexts. Basically, the application creates a default context, uses it in the functions that require a context, and then deallocates it when done. Context manipulation is available for more DNS-aware programs, but is unlikely to be of interest to applications that just want the results of lookups for A, AAAA, SRV, and PTR records.
134
135 .LP
136 It is expected that contexts in implementations of the API will not necessarily be thread-safe, but they will not be thread-hostile. A context should not be used by multiple threads: create a new context for use on a different thread. It is just fine for an application to have many contexts, and some DNS-heavy applications will certainly want to have many even if the application uses a single thread.
137
138 .LP
139 When the context is used in the API for the first time and set_from_os is 1, the API starts replacing some of the values with values from the OS, such as those that would be found in res_query(3), /etc/resolv.conf, and so on, then proceeds with the new function. Some advanced users will not want the API to change the values to the OS's defaults; if set_from_os is 0, the API will not do any updates to the initial values based on changes in the OS. For example, this might be useful if the API is acting as a stub resolver that is using a specific upstream recursive resolver chosen by the application, not the one that might come back from DHCP.
140
141 .HP 3
142 .I context
143 .RP
144 In calls to the getdns_create_context functions this parameter is used to return a newly allocated and initialized context (if there are no errors). In the getdns_destroy_context function this is the context whose associated memory will be released.
145
146 .HP 3
147 .I set_from_os
148 .RP
149 If set_from_os is 0 then the caller must provide forwarding name servers if running in stub mode. If set_from_os is 1 then the system files are used to initialize the context. /etc/resolv.conf is used to populate forwarders when running as a stub resolver (only "nameserver" lines are recognized). If set_from_os is 1 /etc/hosts entries are preferred before resorting to a DNS query. Errors in the system files will not prevent the context form being constructed.
150
151 .HP 3
152 .I userarg
153 .RP
154 In the extended use case this argument is passed unchanged to each of the memory management functions each time they are called.
155
156 .HP 3
157 .I malloc
158 .RP
159 The function that will be used for creating response dicts (and the members within the response dicts). By default the system malloc is used.
160
161 .HP 3
162 .I realloc
163 .RP
164 The function that will be used for creating response dicts (and the members within the response dicts). By default the system realloc is used.
165
166 .HP 3
167 .I free
168 .RP
169 The function that will be used for releasing storage for response dicts (and the members within the response dicts). By default the system free is used.
170
171 .HP
172 .SH "RETURN VALUES"
173
174 Upon successful completion each of these functions return
175 .B GETDNS_RETURN_GOOD
176 , otherwise the following error values are returned:
177
178 .LP
179 .B GETDNS_RETURN_GENERIC_ERROR
180 memory allocation failed or some other untoward thing happened while initializing the context
181
182 .LP
183 .B GETDNS_RETURN_BAD_CONTEXT
184 if the context pointer is invalid (getdns_context_destroy)
185
186 .SH EXAMPLES
187
188 TBD
189
190 .SH FILES
191 .br
192 /etc/hosts
193 .br
194 /etc/resolv.conf
195
196 .SH SEE ALSO
197 .BR libgetdns (3),
198 .BR getdns_address (3),
199 .BR getdns_address_sync (3),
200 .BR getdns_context_set (3),
201 .BR getdns_general (3),
202 .BR getdns_general_sync (3),
203 .BR getdns_hostname (3),
204 .BR getdns_hostname_sync (3),
205 .BR getdns_service (3),
206 .BR getdns_service_sync (3).
207
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_context 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_context_create,
31 .B getdns_context_create_with_memory_functions,
32 .B getdns_context_create_with_extended_memory_functions,
33 .B getdns_context_destroy
34 -- getdns context create and destroy routines
35
36 .SH LIBRARY
37 DNS Resolver library (libgetdns, -lgetdns)
38
39 .SH SYNOPSIS
40 #include <getdns.h>
41
42 getdns_return_t
43 .br
44 .B getdns_context_create
45 (getdns_context ** context,
46 .RS 3
47 .br
48 int set_from_os)
49 .RE
50
51 getdns_return_t
52 .br
53 .B getdns_context_create_with_memory_functions
54 (getdns_context ** context,
55 .RS 3
56 .br
57 int set_from_os,
58 .br
59 void *(*malloc) (size_t),
60 .br
61 void *(*realloc) (void *, size_t),
62 .br
63 void (*free) (void *))
64 .RE
65
66 getdns_return_t
67 .br
68 .B getdns_context_create_with_extended_memory_functions
69 (getdns_context **context,
70 .RS 3
71 .br
72 int set_from_os,
73 .br
74 void *userarg,
75 .br
76 void *(*malloc) (void *userarg, size_t),
77 .br
78 void *(*realloc) (void *userarg, void *, size_t),
79 .br
80 void (*free) (void *userarg, void *))
81 .RE
82
83 void
84 .br
85 .B getdns_context_destroy
86 (getdns_context *context)
87
88 .SH DESCRIPTION
89
90 .LP
91 Calls to getdns functions require a DNS context, which is a group of API
92 settings that affect how DNS calls are made. For most applications, a default
93 context is sufficient.
94
95 .LP
96 To create a new DNS context, use the function:
97 .RS 3
98 .br
99 getdns_return_t
100 .B getdns_context_create
101 (getdns_context_t *context, bool set_from_os)
102 .RE
103
104 .LP
105 The call to getdns_context_create immediately returns a context that can be
106 used with other API calls; that context contains the API's default values. Most
107 applications will want set_from_os set to true.
108
109 .LP
110 To clean up the context, including cleaning up all outstanding transactions
111 that were called using this context, use the function:
112 .RS 3
113 .br
114 void
115 .B getdns_context_destroy
116 (getdns_context_t context)
117 .RE
118
119 .LP
120 When getdns_context_destroy() returns, the application knows that all
121 outstanding transactions associated with this context will have been called;
122 callbacks that had not been called before getdns_context_destroy() was called
123 will be called with a callback_type of GETDNS_CALLBACK_CANCEL.
124 getdns_context_destroy() returns after all of the needed cleanup is done and
125 callbacks are made.
126
127 .SH DESCRIPTION (LONG)
128
129 .LP
130 Many calls in the DNS API require a DNS context. A DNS context contains the information that the API needs in order to process DNS calls, such as the locations of upstream DNS servers, DNSSEC trust anchors, and so on. The internal structure of the DNS context is opaque, and might be different on each OS. When a context is passed to any function, it must be an allocated context; the context must not be NULL.
131
132 .LP
133 A typical application using this API doesn't need to know anything about contexts. Basically, the application creates a default context, uses it in the functions that require a context, and then deallocates it when done. Context manipulation is available for more DNS-aware programs, but is unlikely to be of interest to applications that just want the results of lookups for A, AAAA, SRV, and PTR records.
134
135 .LP
136 It is expected that contexts in implementations of the API will not necessarily be thread-safe, but they will not be thread-hostile. A context should not be used by multiple threads: create a new context for use on a different thread. It is just fine for an application to have many contexts, and some DNS-heavy applications will certainly want to have many even if the application uses a single thread.
137
138 .LP
139 When the context is used in the API for the first time and set_from_os is 1, the API starts replacing some of the values with values from the OS, such as those that would be found in res_query(3), /etc/resolv.conf, and so on, then proceeds with the new function. Some advanced users will not want the API to change the values to the OS's defaults; if set_from_os is 0, the API will not do any updates to the initial values based on changes in the OS. For example, this might be useful if the API is acting as a stub resolver that is using a specific upstream recursive resolver chosen by the application, not the one that might come back from DHCP.
140
141 .HP 3
142 .I context
143 .RP
144 In calls to the getdns_create_context functions this parameter is used to return a newly allocated and initialized context (if there are no errors). In the getdns_destroy_context function this is the context whose associated memory will be released.
145
146 .HP 3
147 .I set_from_os
148 .RP
149 If set_from_os is 0 then the caller must provide forwarding name servers if running in stub mode. If set_from_os is 1 then the system files are used to initialize the context. /etc/resolv.conf is used to populate forwarders when running as a stub resolver (only "nameserver" lines are recognized). If set_from_os is 1 /etc/hosts entries are preferred before resorting to a DNS query. Errors in the system files will not prevent the context form being constructed.
150
151 .HP 3
152 .I userarg
153 .RP
154 In the extended use case this argument is passed unchanged to each of the memory management functions each time they are called.
155
156 .HP 3
157 .I malloc
158 .RP
159 The function that will be used for creating response dicts (and the members within the response dicts). By default the system malloc is used.
160
161 .HP 3
162 .I realloc
163 .RP
164 The function that will be used for creating response dicts (and the members within the response dicts). By default the system realloc is used.
165
166 .HP 3
167 .I free
168 .RP
169 The function that will be used for releasing storage for response dicts (and the members within the response dicts). By default the system free is used.
170
171 .HP
172 .SH "RETURN VALUES"
173
174 Upon successful completion each of these functions return
175 .B GETDNS_RETURN_GOOD
176 , otherwise the following error values are returned:
177
178 .LP
179 .B GETDNS_RETURN_GENERIC_ERROR
180 memory allocation failed or some other untoward thing happened while initializing the context
181
182 .LP
183 .B GETDNS_RETURN_BAD_CONTEXT
184 if the context pointer is invalid (getdns_context_destroy)
185
186 .SH EXAMPLES
187
188 TBD
189
190 .SH FILES
191 .br
192 /etc/hosts
193 .br
194 /etc/resolv.conf
195
196 .SH SEE ALSO
197 .BR libgetdns (3),
198 .BR getdns_address (3),
199 .BR getdns_address_sync (3),
200 .BR getdns_context_set (3),
201 .BR getdns_general (3),
202 .BR getdns_general_sync (3),
203 .BR getdns_hostname (3),
204 .BR getdns_hostname_sync (3),
205 .BR getdns_service (3),
206 .BR getdns_service_sync (3).
207
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_context_set 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_context_set_append_name,
31 .B getdns_context_set_context_update_callback,
32 .B getdns_context_set_dns_root_servers,
33 .B getdns_context_set_dns_transport,
34 .B getdns_context_set_follow_redirects,
35 .B getdns_context_set_limit_outstanding_queries,
36 .B getdns_context_set_namespaces,
37 .B getdns_context_set_resolution_type,
38 .B getdns_context_set_timeout
39 -- getdns context manipulation routines
40
41 .SH LIBRARY
42 DNS Resolver library (libgetdns, -lgetdns)
43
44 .SH SYNOPSIS
45 #include <getdns.h>
46
47 getdns_return_t
48 .br
49 .B getdns_context_set_context_update_callback
50 (getdns_context_t context,
51 .RS 3
52 .br
53 (*callback)(struct getdns_context *context, uint16_t changed_item))
54 .RE
55
56 getdns_return_t
57 .br
58 .B getdns_context_set_dns_root_servers
59 (getdns_context_t context,
60 .RS 3
61 .br
62 getdns_list *root_addresses)
63 .RE
64
65 getdns_return_t
66 .br
67 .B getdns_context_set_dns_transport
68 (getdns_context_t context,
69 .RS 3
70 .br
71 uint16_t transport)
72 .RE
73
74 getdns_return_t
75 .br
76 .B getdns_context_set_follow_redirects
77 (getdns_context_t context,
78 .RS 3
79 .br
80 getdns_redirects_t followredir)
81 .RE
82
83 getdns_return_t
84 .br
85 .B getdns_context_set_limit_outstanding_queries
86 (getdns_context_t context,
87 .RS 3
88 .br
89 uint16_t limit)
90 .RE
91
92 getdns_return_t
93 .br
94 .B getdns_context_set_namespaces
95 (getdns_context_t context,
96 .RS 3
97 .br
98 size_t namespace_count,
99 .br
100 uint16_t *namespaces)
101 .RE
102
103 getdns_return_t
104 .br
105 .B getdns_context_set_resolution_type
106 (getdns_context_t context,
107 .RS 3
108 uint16_t restype)
109 .RE
110
111 getdns_return_t
112 .br
113 .B getdns_context_set_timeout
114 (getdns_context_t context,
115 .RS 3
116 uint16_t timeout)
117 .RE
118
119 .SH DESCRIPTION
120
121 .LP
122 These functions are used to manipulate a previously allocated and initialized context, see getdns_context (3) for more details on the functions used to allocate, initialized and destroy contexts and for a more detailed discussion of the getdns_context in general.
123
124 .LP
125 .B getdns_context_set_context_update_callback
126 sets a function that will be called if changes to the system files (for example /etc/resolv.conf and /etc/hosts).
127
128 .LP
129 .B getdns_context_set_dns_transport
130 specifies the transport used for DNS lookups, the default is to use UDP and fall back to
131 TCP as needed.
132
133 .LP
134 .B getdns_context_set_limit_outstanding_queries
135 specifies the maximum number of outstanding DNS queries, the API will queue queries
136 over this limit until current queries are answers and will then automatically issue
137 the queries on the queue.
138
139 .LP
140 .B
141 getdns_context_set_dns_root_servers
142 provides an alternate set of addresses to use
143 to look up the top level domains. The default (if this function is not called) is the
144 list of IANA root servers (think of this as the root hints).
145
146 .LP
147 .B
148 getdns_context_set_follow_redirects
149 specifies whether or not DNS queries follow redirects (CNAME and DNAME), the default
150 behavior is to follow redirects and return the eventual target.
151
152 .LP
153 .B getdns_context_set_namespaces
154 sets the namespaces to be used by the resolver, the default is DNS and then local
155 files. Future implementations will support netbios, mdns, and nis.
156
157 .LP
158 .B getdns_context_set_resolution_type
159 specifies whether DNS queries are performed with non-recursive lookups or as a stub resolver.
160
161 .LP
162 .B getdns_context_set_timeout
163 specifies the number of milliseconds the API will wait for a response.
164
165 .HP 3
166 .I context
167 .RP
168 a previously allocated and initialized getdns_context
169
170 .HP 3
171 .I callback
172 .RP
173 a callback function that will be called when changes are made to the system files (/etc/resolv.conf and /etc/hosts) for contexts created with set_from_os = 1. When this function is called the changed_item parameter indicates which item in the context has changed.
174
175 .HP 3
176 .I root_addresses
177 .RP
178 This is a list of getdns_dict types that each identify a single root server to
179 use to look up top level domains. Each dictionary includes two names,
180 .I address_type
181 , a bindata containing the string "IPv4" or "IPv6" and
182 .I address_data
183 a bindata containing the IP address.
184
185 .HP 3
186 .I transport
187 .RP
188 may be one of GETDNS_CONTEXT_UDP_FIRST_AND_FALL_BACK_TO_TCP, GETDNS_CONTEXT_UDP_ONLY, GETDNS_CONTEXT_TCP_ONLY, GETDNS_CONTEXT_TCP_ONLY_KEEP_CONNECTIONS_OPEN. If you need more information on what each of these means reread the mnemonic and take a guess ;)
189
190 .HP 3
191 .I followredir
192 .RP
193 If set to GETDNS_REDIRECTS_FOLLOW (the default) then the eventual target of the redirect is returned. If set to GETDNS_REDIRECTS_DO_NOT_FOLLOW then the CNAME or DNAME is returned and NOT the eventual target.
194
195 .HP 3
196 .I limit
197 .RP
198 the maximum number of concurrent outstanding (unanswered) DNS queries, if exceeded the API will queue queries and issue them as the number of outstanding queries drops. A value of 0 indicates that there is no limit.
199
200 .HP 3
201 .I namespaces
202 .RP
203 The namespaces array contains an ordered list of namespaces that will be queried. Important: this context setting is ignored for the getdns_general and getdns_general_sync functions; it is used for the other functions. The values are GETDNS_CONTEXT_NAMESPACE_DNS, GETDNS_CONTEXT_NAMESPACE_LOCALNAMES, GETDNS_CONTEXT_NAMESPACE_NETBIOS, GETDNS_CONTEXT_NAMESPACE_MDNS, and GETDNS_CONTEXT_NAMESPACE_NIS. When a normal lookup is done, the API does the lookups in the order given and stops when it gets the first result; a different method with the same result would be to run the queries in parallel and return when it gets the first result. Because lookups might be done over different mechanisms because of the different namespaces, there can be information leakage that is similar to that seen with getaddrinfo(). The default is determined by the OS.
204
205 .HP 3
206 .I restype
207 .RP
208 can be set to either GETDNS_CONTEXT_RECURSIVE (the default) or GETDNS_CONTEXT_STUB (requires that forwarders be specified by the caller).
209
210 .HP 3
211 .I timeout
212 .RP
213 the number of milliseconds the API will wait for a response, after which the callback will be invoked (or the synchronous function will return) with a timeout error.
214
215 .HP
216 .SH "RETURN VALUES"
217
218 Upon successful completion the functions return
219 .B GETDNS_RETURN_GOOD
220 , otherwise the following error values are returned:
221
222 .LP
223 .B GETDNS_RETURN_BAD_CONTEXT
224 if the context pointer is invalid
225 .LP
226 .B GETDNS_RETURN_CONTEXT_UPDATE_FAIL
227 if there was a problem updating the context
228
229 .SH EXAMPLES
230
231 TBD
232
233 .SH FILES
234 .br
235 /etc/hosts
236 .br
237 /etc/resolv.conf
238
239 .SH SEE ALSO
240 .BR libgetdns (3),
241 .BR getdns_address (3),
242 .BR getdns_address_sync (3),
243 .BR getdns_context (3),
244 .BR getdns_general (3),
245 .BR getdns_general_sync (3),
246 .BR getdns_hostname (3),
247 .BR getdns_hostname_sync (3),
248 .BR getdns_service (3),
249 .BR getdns_service_sync (3).
250
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_convert 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_convert,
31 .B getdns_convert_dns_name_to_fqdn,
32 .B getdns_convert_fqdn_to_dns_name
33
34 .SH LIBRARY
35 DNS Resolver library (libgetdns, -lgetdns)
36
37 .SH SYNOPSIS
38 #include <getdns.h>
39
40 getdns_return_t
41 .br
42 .B getdns_convert_dns_name_to_fqdn
43 (const getdns_bindata *dns_name_wire_fmt,
44 .br
45 .RS 3
46 char **fqdn_as_string)
47 .RE
48
49 getdns_return_t
50 .br
51 .B getdns_convert_fqdn_to_dns_name
52 (char *fqdn_as_string,
53 .br
54 .RS 3
55 const getdns_bindata **dns_name_wire_fmt)
56 .RE
57
58 .SH DESCRIPTION
59
60 .LP
61 Names in DNS fields are stored in a fashion very different from the normal
62 presentation format normally used in applications. The DNS format is described
63 in the first paragraph in Section 3.1 of RFC 1035; the presentation format here
64 is a null-terminated string with interior dots. These helper functions only
65 work with names in the DNS format that are not compressed. They are useful for
66 converting domain names in the replies_tree to and from the FQDN presentation
67 format.
68
69 getdns_convert_dns_name_to_fqdn() converts a domain name in DNS format to the
70 presentation format. For example, the hex sequence 03 77 77 77 07 65 78 61 6d
71 70 6c 65 03 63 6f 6d 00 would be converted to "www.example.com".
72 getdns_convert_fqdn_to_dns_name() does the reverse: it converts a
73 null-terminated string in FQDN format to bytes in DNS format.
74
75 .HP 3
76 .I dns_name_wire_fmt
77 .RP
78 The non-compressed DNS wire format name (per RFC 1035) in a bindata structure that
79 will be converted to/from an fqdn. In getdns_convert_fqdn_to_dns_name storage is
80 allocated using the system allocator (malloc) and must be freed by the caller.
81
82 .HP 3
83 .I fqdn_as_string
84 .RP
85 a null terminated string to be converted to/from non-compressed DNS wire format name (per RFC 1035).
86 In getdns_convert_dns_name_to_fqdn storage is
87 allocated using the system allocator (malloc) and must be freed by the caller.
88
89 .HP
90 .SH "RETURN VALUES"
91
92 Upon successful completion the function returns
93 .B GETDNS_RETURN_GOOD
94
95 .SH EXAMPLES
96
97 TBD
98
99 .SH SEE ALSO
100 .BR libgetdns (3)
101
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_dict 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_dict,
31 .B getdns_dict_create,
32 .B getdns_dict_destroy
33
34 .SH LIBRARY
35 DNS Resolver library (libgetdns, -lgetdns)
36
37 .SH SYNOPSIS
38 #include <getdns.h>
39
40 getdns_dict *
41 .br
42 .B getdns_dict_create
43 ()
44
45 void
46 .br
47 .B getdns_dict_destroy
48 (getdns_dict *this_dict)
49
50 .SH DESCRIPTION
51
52 .LP
53 The getdns_dict type is used to manage name/value pairs in which the names are strings and the data types of the values are heterogeneous and include
54 .RS 3
55 .br
56 getdns_bindata
57 .br
58 getdns_dict
59 .br
60 getdns_list
61 .br
62 uint32_t
63 .RE
64
65 .LP
66 The destroy function performs a "deep" destroy, freeing storage for all of the members
67 of the dictionary before destroying the dictionary. There are a number of helper
68 functions that provide access to the dictionary object, see their respective man pages.
69
70 .LP
71 .I this_dict
72 the dictionary to destroy
73 .LP
74
75 .SH "RETURN VALUES"
76
77 Upon successful completion the getdns_dict_create function returns a valid (empty)
78 dictionary structure that should be freed via a call to getdns_dict_destroy.
79
80 .SH EXAMPLES
81
82 TBD
83
84 .SH SEE ALSO
85 .BR libgetdns (3),
86 .BR getdns_dict_get (3),
87 .BR getdns_dict_set (3),
88 .BR getdns_list (3).
89
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_dict_get 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_dict_get,
31 .B getdns_dict_get_bindata,
32 .B getdns_dict_get_data_type,
33 .B getdns_dict_get_dict,
34 .B getdns_dict_get_int,
35 .B getdns_dict_get_list,
36 .B getdns_dict_get_names
37
38 .SH LIBRARY
39 DNS Resolver library (libgetdns, -lgetdns)
40
41 .SH SYNOPSIS
42 #include <getdns.h>
43
44 getdns_return_t
45 .br
46 .B getdns_dict_get_bindata
47 (getdns_dict *this_dict,
48 .RS 3
49 char *name,
50 .br
51 getdns_bindata **answer)
52 .RE
53
54 getdns_return_t
55 .br
56 .B getdns_dict_get_data_type
57 (getdns_dict *this_dict,
58 .RS 3
59 char *name,
60 .br
61 getdns_data_type *answer)
62 .RE
63
64 getdns_return_t
65 .br
66 .B getdns_dict_get_dict
67 (getdns_dict *this_dict,
68 .RS 3
69 char *name,
70 .br
71 getdns_dict **answer)
72 .RE
73
74 getdns_return_t
75 .br
76 .B getdns_dict_get_int
77 (getdns_dict *this_dict,
78 .RS 3
79 char *name,
80 .br
81 uint32_t *answer)
82 .RE
83
84 getdns_return_t
85 .br
86 .B getdns_dict_get_list
87 (getdns_dict *this_dict,
88 .RS 3
89 char *name,
90 .br
91 getdns_list **answer)
92 .RE
93
94 getdns_return_t
95 .br
96 .B getdns_dict_get_names
97 (getdns_dict *this_dict,
98 .RS 3
99 getdns_list **answer)
100 .RE
101
102 .SH DESCRIPTION
103
104 .LP
105 The getdns_dict type is used to manage name/value pairs in which the names are strings and the data types of the values are heterogeneous and include
106 .RS 3
107 .br
108 getdns_bindata
109 .br
110 getdns_dict
111 .br
112 getdns_list
113 .br
114 uint32_t
115 .RE
116
117 .LP
118 .I this_dict
119 the dictionary from which to retrieve the list of names
120 .LP
121 .I name
122 the name whose associated value is to be returned in answer
123 .LP
124 .I answer
125 the list of all names in the dictionary, note that the caller must free storage allocated to the list via a call to
126 .B getdns_list_destroy(3)
127
128 .SH "RETURN VALUES"
129
130 Upon successful completion the functions return
131 .B GETDNS_RETURN_GOOD
132 , otherwise the following error values are returned:
133 .LP
134 .B GETDNS_RETURN_GENERIC_ERROR
135 if this_dict is not a valid dictionary
136 .LP
137 .B GETDNS_RETURN_NO_SUCH_DICT_NAME
138 if the name argument doesn't exist in the dictionary
139 .LP
140 .B GETDNS_RETURN_WRONG_TYPE_REQUESTED
141 if the requested data type doesn't match the contents of the indexed argument or name
142
143 .SH EXAMPLES
144
145 TBD
146
147 .SH SEE ALSO
148 .BR libgetdns (3),
149 .BR getdns_address (3),
150 .BR getdns_dict (3),
151 .BR getdns_dict_set (3),
152 .BR getdns_general (3),
153 .BR getdns_hostname (3),
154 .BR getdns_list (3),
155 .BR getdns_service (3),
156
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_dict_set 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_dict_set,
31 .B getdns_dict_set_bindata,
32 .B getdns_dict_set_dict,
33 .B getdns_dict_set_int,
34 .B getdns_dict_set_list,
35
36 .SH LIBRARY
37 DNS Resolver library (libgetdns, -lgetdns)
38
39 .SH SYNOPSIS
40 #include <getdns.h>
41
42 getdns_return_t
43 .br
44 .B getdns_dict_set_bindata
45 (getdns_dict *this_dict,
46 .RS 3
47 char *name,
48 .br
49 getdns_bindata *child_bindata)
50 .RE
51
52 getdns_return_t
53 .br
54 .B getdns_dict_set_dict
55 (getdns_dict *this_dict,
56 .RS 3
57 char *name,
58 .br
59 getdns_dict *child_dict)
60 .RE
61
62 getdns_return_t
63 .br
64 .B getdns_dict_set_int
65 (getdns_dict *this_dict,
66 .RS 3
67 char *name,
68 .br
69 uint32_t child_uint32_t)
70 .RE
71
72 getdns_return_t
73 .br
74 .B getdns_dict_set_list
75 (getdns_dict *this_dict,
76 .RS 3
77 char *name,
78 .br
79 getdns_list *child_list)
80 .RE
81
82 .SH DESCRIPTION
83
84 .LP
85 The getdns_dict type is used to manage name/value pairs in which the names are strings and the data types of the values are heterogeneous and include
86 .RS 3
87 .br
88 getdns_bindata
89 .br
90 getdns_dict
91 .br
92 getdns_list
93 .br
94 uint32_t
95 .RE
96
97 .LP
98 .I this_dict
99 the dictionary in which to add/update the name/value pair
100 .LP
101 .I name
102 the name whose associated value is to be set. If the name exists in the dictionary
103 the value associated with that name is replaced, if the name does not exist in the
104 dictionary a new item is added to the dictionary.
105 .LP
106 .I child_bindata
107 .I child_dict
108 .I child_list
109 .I child_uint32
110 value to assign the name
111
112 .SH "RETURN VALUES"
113
114 Upon successful completion the functions return
115 .B GETDNS_RETURN_GOOD
116 , otherwise the following error values are returned:
117 .LP
118 .B GETDNS_RETURN_GENERIC_ERROR
119 if this_dict is not a valid dictionary
120
121 .SH EXAMPLES
122
123 TBD
124
125 .SH SEE ALSO
126 .BR libgetdns (3),
127 .BR getdns_address (3),
128 .BR getdns_dict (3),
129 .BR getdns_dict_get (3),
130 .BR getdns_general (3),
131 .BR getdns_hostname (3),
132 .BR getdns_service (3)
133
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_free_sync_request_memory 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_free_sync_request_memory
31
32 .SH LIBRARY
33 DNS Resolver library (libgetdns, -lgetdns)
34
35 .SH SYNOPSIS
36 #include <getdns.h>
37
38 getdns_return_t
39 .br
40 .B getdns_free_sync_request_memory
41 (getdns_dict *response)
42
43 .SH DESCRIPTION
44
45 .LP
46 This function is used to free memory allocated within one of the synchronous functions.
47
48 .HP 3
49 .I response
50 .RP
51 A previously allocated response object.
52
53 .HP
54 .SH "RETURN VALUES"
55
56 Upon successful completion the function returns
57 .B GETDNS_RETURN_GOOD
58
59 .SH EXAMPLES
60
61 TBD
62
63 .SH FILES
64 .br
65 /etc/hosts
66 .br
67 /etc/resolv.conf
68
69 .SH SEE ALSO
70 .BR libgetdns (3),
71 .BR getdns_address_sync (3),
72 .BR getdns_general_sync (3),
73 .BR getdns_hostname_sync (3),
74 .BR getdns_service_sync (3)
75
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_general 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_general,
31 .B getdns_general_sync
32
33 .SH LIBRARY
34 DNS Resolver library (libgetdns, -lgetdns)
35
36 .SH SYNOPSIS
37 #include <getdns.h>
38
39 getdns_return_t
40 .br
41 .B getdns_general
42 (getdns_context *context,
43 .RS 3
44 const char *name,
45 .br
46 uint16_t request_type
47 .br
48 getdns_dict *extensions,
49 .br
50 void *userarg,
51 .br
52 getdns_transaction_t *transaction_id,
53 .br
54 getdns_callback_t callbackfn)
55 .RE
56
57 getdns_return_t
58 .br
59 .B getdns_general_sync
60 (getdns_context *context,
61 .RS 3
62 const char *name,
63 .br
64 uint16_t request_type
65 .br
66 getdns_dict *extensions,
67 .br
68 getdns_dict **response)
69 .RE
70
71 .SH DESCRIPTION
72
73 .LP
74 The getdns_general(3) and getdns_general_sync functions provide public entry points into the getdns API library to retrieve any valid responses to a query from the DNS.
75
76 .HP 3
77 .I context
78 .RP
79 see getdns_context (3)
80
81 .HP 3
82 .I name
83 .RP
84 The ASCII-based domain name looked up as a string. This can also be an
85 IPv4 or IPv6 address for request types that take addresses instead of domain
86 names, such as PTR. The values here follow the rules in section 2.1 of RFC 4343
87 to allow non-ASCII octets and special characters in labels.
88
89 .HP 3
90 .I request_type
91 .RP
92 Specifies the RRtype for the query; the RRtype numbers are listed in the IANA registry. For example, to get the NS records, request_type would be 2. The API also has defined macros for most of the RRtypes by name; the definition names all start with "GETDNS_RRTYPE_". For example, to get the NS records, you can also set the request_type to GETDNS_RRTYPE_NS.
93
94 .HP 3
95 .I extensions
96 extensions for this request, NULL if no extensions, see libgetnds (3) for a detailed description of extensions
97
98 .HP 3
99 .I userarg
100 .RP
101 returned to the callback function untouched, can be NULL
102
103 .HP 3
104 .I transaction_id
105 .RP
106 populated by the API and used to identify the callback (for example to getdns_cancel_callback), can be NULL, set to 0 if the function fails
107
108 .HP 3
109 .I callbackfn
110 .RP
111 pointer to a callback function defined by the application, typically used to process the response, may not be NULL. Only the asynchronous signature accepts a callback function, the synchronous signature does not include a callback.
112
113 .HP 3
114 .I response
115 .RP
116 A getdns_dict type is returned in response and always contains at least three names: replies_full (a list containing the DNS response as binary data), replies_tree (a list containing the parsed DNS response data) and status (an int). The storage associated with this must be freed by a call to getdns_free_sync_request_memory (3).
117
118 .HP
119 .SH "RETURN VALUES"
120
121 Upon successful completion the functions return
122 .B GETDNS_RETURN_GOOD
123 , otherwise the following error values are returned:
124
125 .LP
126 .B GETDNS_RETURN_BAD_CONTEXT
127 if the context pointer is invalid
128 .LP
129 .B GETDNS_RETURN_INVALID PARAMETER
130 one or more parameters has an invalid value
131 .LP
132 .B GETDNS_RETURN_BAD_DOMAIN_NAME
133 if the domain name passed to the function is invalid
134 .LP
135 .B GETDNS_RETURN_EXTENSION_MISFORMAT
136 if the data type specified in one or more of the extensions does not match the specifications
137 .LP
138 .B GETDNS_RETURN_NO_SUCH_EXTENSION
139 if one or more of the strings specified in the extensions are not valid
140 .LP
141 .B GETDNS_RETURN_GENERIC_ERROR
142 some problem was encountered in the function not addressed by one of the more
143 specific return codes
144
145 The values of status included in the response parameter are:
146
147 .LP
148 .B GETDNS_RESPSTATUS_GOOD
149 At least one response was returned
150 .LP
151 .B GETDNS_RESPSTATUS_NO_NAME
152 Queries for the name yielded all negative responses
153 .LP
154 .B GETDNS_RESPSTATUS_ALL_TIMEOUT
155 All queries for the name timed out
156 .LP
157 .B GETDNS_RESPSTATUS_NO_SECURE_ANSWERS
158 only secure replies accepted (per context), at least one response was received but no DNS responses were secure through DNSSEC
159
160 .LP
161 For a more detailed explanation of the response object see
162 .I libgetdns
163 (3)
164
165 .SH REQUEST TYPES
166
167 This is a list of the most common request types, a full list of request types in more detail is available at http://www.iana.org/assignments/dns-parameters/dns-parameters.xml
168
169 .RS 3
170 .TP 11
171 .B A
172 Host address
173 .TP
174 .B AAAA
175 IPv6 address
176 .TP
177 .B CAA
178 Certificate Authority Authorization
179 .TP
180 .B CNAME
181 Canonical name for an alias
182 .TP
183 .B DLV
184 DNSSEC lookaside validation
185 .TP
186 .B DNAME
187 DNAME
188 .TP
189 .B DS
190 Delegation signer
191 .TP
192 .B HINFO
193 Host information
194 .TP
195 .B KEY
196 Security key
197 .TP
198 .B MINFO
199 Mailbox or mail list information
200 .TP
201 .B MX
202 Mail exchange
203 .TP
204 .B NS
205 Authoritative name server
206 .TP
207 .B NSEC
208 Next secure record
209 .TP
210 .B NSEC3
211 Next secure record (hashed)
212 .TP
213 .B NSEC3PARAM
214 NSEC3PARAM
215 .TP
216 .B PTR
217 Domain name pointer
218 .TP
219 .B RRSIG
220 Signature for a record set
221 .TP
222 .B SIG
223 Security signature
224 .TP
225 .B SOA
226 Marks the start of a zone of authority
227 .TP
228 .B SRV
229 Server selection
230 .TP
231 .B TA
232 DNSSEC trust authorities
233 .TP
234 .B TKEY
235 Transaction key
236 .TP
237 .B TLSA
238 TLSA
239 .TP
240 .B TSIG
241 Transaction signature
242 .TP
243 .B TXT
244 Text strings
245 .RE
246
247 .SH EXAMPLES
248
249 TBD
250
251 .SH FILES
252 .br
253 /etc/hosts
254 .br
255 /etc/resolv.conf
256
257 .SH SEE ALSO
258 .BR libgetdns (3),
259 .BR getdns_address (3),
260 .BR getdns_address_sync (3),
261 .BR getdns_context (3),
262 .BR getdns_free_sync_request_memory (3),
263 .BR getdns_hostname (3),
264 .BR getdns_hostname_sync (3),
265 .BR getdns_service (3),
266 .BR getdns_service_sync (3)
267
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_hostname 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_hostname,
31 .B getdns_hostname_sync
32
33 .SH LIBRARY
34 DNS Resolver library (libgetdns, -lgetdns)
35
36 .SH SYNOPSIS
37 #include <getdns.h>
38
39 getdns_return_t
40 .br
41 .B getdns_hostname
42 (getdns_context *context,
43 .RS 3
44 getdns_dict *address,
45 .br
46 getdns_dict *extensions,
47 .br
48 void *userarg,
49 .br
50 getdns_transaction_t *transaction_id,
51 .br
52 getdns_callback_t callbackfn)
53 .RE
54
55 getdns_return_t
56 .br
57 .B getdns_hostname_sync
58 (getdns_context *context,
59 .RS 3
60 getdns_dict *address,
61 .br
62 getdns_dict *extensions,
63 .br
64 getdns_dict **response)
65 .RE
66
67 .SH DESCRIPTION
68
69 .LP
70 The getdns_hostname(3) and getdns_hostname_sync functions provide public entry points into the getdns API library to retrieve the host name given an address.
71
72 .HP 3
73 .I context
74
75 see getdns_context (3)
76
77 .HP 3
78 .I address
79
80 a getdns_dict structure containing two names: address_type (whose value is bindata and is either "IPv4" or "IPv6") and address_data whose value is bindata
81
82 .HP 3
83 .I extensions
84 .RP
85 extensions for this request, NULL if no extensions, see libgetdns (3) for a detailed description of extensions
86
87 .HP 3
88 .I userarg
89 .RP
90 returned to the callback function untouched, can be NULL
91
92 .HP 3
93 .I transaction_id
94 .RP
95 populated by the API and used to identify the callback (for example to getdns_cancel_callback), can be NULL, set to 0 if the function fails
96
97 .HP 3
98 .I callbackfn
99 .RP
100 pointer to a callback function defined by the application, typically used to process the response, may not be NULL. Only the asynchronous signature accepts a callback function, the synchronous signature does not include a callback.
101
102 .HP 3
103 .I response
104 .RP
105 A getdns_dict type is returned in response and always contains at least three names: replies_full (a list containing the DNS response as binary data), replies_tree (a list containing the parsed DNS response data) and status (an int). The storage associated with this must be freed by a call to getdns_free_sync_request_memory (3).
106
107 .HP
108 .SH "RETURN VALUES"
109
110 Upon successful completion the functions return
111 .B GETDNS_RETURN_GOOD
112 , otherwise the following error values are returned:
113
114 .LP
115 .B GETDNS_RETURN_BAD_CONTEXT
116 if the context pointer is invalid
117 .LP
118 .B GETDNS_RETURN_INVALID PARAMETER
119 one or more parameters has an invalid value
120 .LP
121 .B GETDNS_RETURN_BAD_DOMAIN_NAME
122 if the domain name passed to the function is invalid
123 .LP
124 .B GETDNS_RETURN_EXTENSION_MISFORMAT
125 if the data type specified in one or more of the extensions does not match the specifications
126 .LP
127 .B GETDNS_RETURN_NO_SUCH_EXTENSION
128 if one or more of the strings specified in the extensions are not valid
129 .LP
130 .B GETDNS_RETURN_GENERIC_ERROR
131 some problem was encountered in the function not addressed by one of the more
132 specific return codes
133
134 The values of status in the response include:
135
136 .LP
137 .B GETDNS_RESPSTATUS_GOOD
138 At least one response was returned
139 .LP
140 .B GETDNS_RESPSTATUS_NO_NAME
141 Queries for the name yielded all negative responses
142 .LP
143 .B GETDNS_RESPSTATUS_ALL_TIMEOUT
144 All queries for the name timed out
145 .LP
146 .B GETDNS_RESPSTATUS_NO_SECURE_ANSWERS
147 only secure replies accepted (per context), at least one response was received but no DNS responses were secure through DNSSEC
148
149 .LP
150 For a more detailed explanation of the response object see
151 .I libgetdns
152 (3)
153
154 .SH EXAMPLES
155
156 TBD
157
158 .SH FILES
159 .br
160 /etc/hosts
161 .br
162 /etc/resolv.conf
163
164 .SH SEE ALSO
165 .BR libgetdns (3),
166 .BR getdns_context (3),
167 .BR getdns_free_sync_request_memory (3),
168 .BR getdns_general (3),
169 .BR getdns_general_sync (3),
170 .BR getdns_address (3),
171 .BR getdns_address_sync (3),
172 .BR getdns_service (3),
173 .BR getdns_service_sync (3)
174
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_list 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_list,
31 .B getdns_list_create,
32 .B getdns_list_destroy
33
34 .SH LIBRARY
35 DNS Resolver library (libgetdns, -lgetdns)
36
37 .SH SYNOPSIS
38 #include <getdns.h>
39
40 getdns_list *
41 .br
42 .B getdns_list_create
43 ()
44
45 void
46 .br
47 .B getdns_list_destroy
48 (getdns_list *this_dict)
49
50 .SH DESCRIPTION
51
52 .LP
53 The getdns_list type is used to manage heterogeneous indexed lists name/value pairs in which the data types of the values include
54 .RS 3
55 .br
56 getdns_bindata
57 .br
58 getdns_dict
59 .br
60 getdns_list
61 .br
62 uint32_t
63 .RE
64
65 .LP
66 The destroy function performs a "deep" destroy, freeing storage for all of the members
67 of the list before destroying the list. There are a number of helper
68 functions that provide access to the list object, see their respective man pages.
69
70 .LP
71 .I this_list
72 the list to destroy
73 .LP
74
75 .SH "RETURN VALUES"
76
77 Upon successful completion the getdns_list_create function returns a valid (empty)
78 list structure that should be freed via a call to getdns_list_destroy.
79
80 .SH EXAMPLES
81
82 TBD
83
84 .SH SEE ALSO
85 .BR libgetdns (3),
86 .BR getdns_dict (3),
87 .BR getdns_list_get (3),
88 .BR getdns_list_set (3)
89
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_list 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_list,
31 .B getdns_list_get_bindata,
32 .B getdns_list_get_data_type,
33 .B getdns_list_get_dict,
34 .B getdns_list_get_length,
35 .B getdns_list_get_list,
36 .B getdns_list_get_int
37
38 .SH LIBRARY
39 DNS Resolver library (libgetdns, -lgetdns)
40
41 .SH SYNOPSIS
42 #include <getdns.h>
43
44 getdns_return_t
45 .br
46 .B getdns_list_get_bindata
47 (getdns_list *this_list,
48 .RS 3
49 size_t index,
50 .br
51 getdns_bindata **answer)
52 .RE
53
54 getdns_return_t
55 .br
56 .B getdns_list_get_data_type
57 (getdns_list *this_list,
58 .RS 3
59 size_t index,
60 .br
61 getdns_data_type *answer)
62 .RE
63
64 getdns_return_t
65 .br
66 .B getdns_list_get_dict
67 (getdns_list *this_list,
68 .RS 3
69 size_t index,
70 .br
71 getdns_dict **answer)
72 .RE
73
74 getdns_return_t
75 .br
76 .B getdns_list_get_length
77 (getdns_list *this_list,
78 .RS 3
79 size_t *answer)
80 .RE
81
82 getdns_return_t
83 .br
84 .B getdns_list_get_list
85 (getdns_list *this_list,
86 .RS 3
87 size_t index,
88 .br
89 getdns_list **answer)
90 .RE
91
92 getdns_return_t
93 .br
94 .B getdns_list_get_int
95 (getdns_list *this_list,
96 .RS 3
97 size_t index,
98 .br
99 uint32_t *answer)
100 .RE
101
102 .SH DESCRIPTION
103
104 .LP
105 The getdns_list type is used to manage heterogeneous lists in which the objects are each one of the data types:
106 .RS 3
107 .br
108 getdns_bindata
109 .br
110 getdns_dict
111 .br
112 getdns_list
113 .br
114 uint32_t
115 .RE
116
117 .LP
118 .I this_list
119 the list from which to retrieve the object
120 .LP
121 .I index
122 the numeric index (0 based) of the item in the list you would like copied to answer
123 .LP
124 .I answer
125 a copy of the object in the list is placed in answer, the caller is responsible
126 for freeing the storage associated with that object by calling the appropriate
127 destroy function.
128
129 .SH "RETURN VALUES"
130
131 Upon successful completion the functions return
132 .B GETDNS_RETURN_GOOD
133 , otherwise the following error values are returned:
134 .LP
135 .B GETDNS_RETURN_GENERIC_ERROR
136 if this_list is not a valid list
137 .LP
138 .B GETDNS_RETURN_NO_SUCH_LIST_ITEM
139 if index is out of range
140 .LP
141 .B GETDNS_RETURN_WRONG_TYPE_REQUESTED
142 if the requested data type doesn't match the contents of the indexed argument
143
144 .SH EXAMPLES
145
146 TBD
147
148 .SH SEE ALSO
149 .BR libgetdns (3),
150 .BR getdns_address (3),
151 .BR getdns_dict (3),
152 .BR getdns_general (3),
153 .BR getdns_hostname (3),
154 .BR getdns_service (3),
155
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_list_set 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_list_set,
31 .B getdns_list_set_bindata,
32 .B getdns_list_set_dict,
33 .B getdns_list_set_int,
34 .B getdns_list_set_list,
35
36 .SH LIBRARY
37 DNS Resolver library (libgetdns, -lgetdns)
38
39 .SH SYNOPSIS
40 #include <getdns.h>
41
42 getdns_return_t
43 .br
44 .B getdns_list_set_bindata
45 (getdns_list *this_list,
46 .RS 3
47 char *name,
48 .br
49 getdns_bindata *child_bindata)
50 .RE
51
52 getdns_return_t
53 .br
54 .B getdns_list_set_dict
55 (getdns_list *this_list,
56 .RS 3
57 char *name,
58 .br
59 getdns_dict *child_dict)
60 .RE
61
62 getdns_return_t
63 .br
64 .B getdns_list_set_int
65 (getdns_list *this_list,
66 .RS 3
67 char *name,
68 .br
69 uint32_t child_uint32_t)
70 .RE
71
72 getdns_return_t
73 .br
74 .B getdns_list_set_list
75 (getdns_list *this_list,
76 .RS 3
77 char *name,
78 .br
79 getdns_list *child_list)
80 .RE
81
82 .SH DESCRIPTION
83
84 .LP
85 The getdns_list type is used to manage a heterogeneous indexed list of values that include:
86 .RS 3
87 .br
88 getdns_bindata
89 .br
90 getdns_dict
91 .br
92 getdns_list
93 .br
94 uint32_t
95 .RE
96
97 .LP
98 .I this_list
99 the list in which to add/update the indexed item
100 .LP
101 .I index
102 the index whose associated value is to be set. If the index exists in the list
103 the value associated with that index is replaced, if the index does not exist in the
104 list a new item is added to the list at the specified index.
105 .LP
106 .I child_bindata
107 .I child_dict
108 .I child_list
109 .I child_uint32
110 value to assign the indexed element
111
112 .SH "RETURN VALUES"
113
114 Upon successful completion the functions return
115 .B GETDNS_RETURN_GOOD
116 , otherwise the following error values are returned:
117 .LP
118 .B GETDNS_RETURN_NO_SUCH_LIST_ITEM
119 if the index is out of range
120 .LP
121 .B GETDNS_RETURN_GENERIC_ERROR
122 if this_list is not a valid list
123
124 .SH EXAMPLES
125
126 TBD
127
128 .SH SEE ALSO
129 .BR libgetdns (3),
130 .BR getdns_address (3),
131 .BR getdns_list (3),
132 .BR getdns_list_get (3),
133 .BR getdns_general (3),
134 .BR getdns_hostname (3),
135 .BR getdns_service (3),
136
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH getdns_service 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 .B getdns_service,
31 .B getdns_service_sync
32
33 .SH LIBRARY
34 DNS Resolver library (libgetdns, -lgetdns)
35
36 .SH SYNOPSIS
37 #include <getdns.h>
38
39 getdns_return_t
40 .br
41 .B getdns_service
42 (getdns_context *context,
43 .RS 3
44 const char *name,
45 .br
46 getdns_dict *extensions,
47 .br
48 void *userarg,
49 .br
50 getdns_transaction_t *transaction_id,
51 .br
52 getdns_callback_t callbackfn)
53 .RE
54
55 getdns_return_t
56 .br
57 .B getdns_service_sync
58 (getdns_context *context,
59 .RS 3
60 const char *name,
61 .br
62 getdns_dict *extensions,
63 .br
64 getdns_dict **response)
65 .RE
66
67 .SH DESCRIPTION
68
69 .LP
70 The getdns_service (3) and getdns_service_sync functions provide public entry points into the getdns API library to retrieve the SRV information given a name.
71
72 .HP 3
73 .I context
74 .RP
75 see getdns_context (3)
76
77 .HP 3
78 .I name
79 .RP
80 the service name to resolve
81
82 .HP 3
83 .I extensions
84 .RP
85 extensions for this request, NULL if no extensions, see libgetdns (3) for a detailed description of extensions
86
87 .HP 3
88 .I userarg
89 .RP
90 returned to the callback function untouched, can be NULL
91
92 .HP 3
93 .I transaction_id
94 .RP
95 populated by the API and used to identify the callback (for example to getdns_cancel_callback), can be NULL, set to 0 if the function fails
96
97 .HP 3
98 .I callbackfn
99 .RP
100 pointer to a callback function defined by the application, typically used to process the response, may not be NULL. Only the asynchronous signature accepts a callback function, the synchronous signature does not include a callback.
101
102 .HP 3
103 .I response
104 .RP
105 A getdns_dict type is returned in response and always contains at least three names: replies_full (a list containing the DNS response as binary data), replies_tree (a list containing the parsed DNS response data) and status (an int). The storage associated with this must be freed by a call to getdns_free_sync_request_memory (3).
106
107 .HP
108 .SH "RETURN VALUES"
109
110 Upon successful completion the functions return
111 .B GETDNS_RETURN_GOOD
112 , otherwise the following error values are returned:
113
114 .LP
115 .B GETDNS_RETURN_BAD_CONTEXT
116 if the context pointer is invalid
117 .LP
118 .B GETDNS_RETURN_INVALID PARAMETER
119 one or more parameters has an invalid value
120 .LP
121 .B GETDNS_RETURN_BAD_DOMAIN_NAME
122 if the domain name passed to the function is invalid
123 .LP
124 .B GETDNS_RETURN_EXTENSION_MISFORMAT
125 if the data type specified in one or more of the extensions does not match the specifications
126 .LP
127 .B GETDNS_RETURN_NO_SUCH_EXTENSION
128 if one or more of the strings specified in the extensions are not valid
129 .LP
130 .B GETDNS_RETURN_GENERIC_ERROR
131 some problem was encountered in the function not addressed by one of the more
132 specific return codes
133
134 The values of status in the response include:
135
136 .LP
137 .B GETDNS_RESPSTATUS_GOOD
138 At least one response was returned
139 .LP
140 .B GETDNS_RESPSTATUS_NO_NAME
141 Queries for the name yielded all negative responses
142 .LP
143 .B GETDNS_RESPSTATUS_ALL_TIMEOUT
144 All queries for the name timed out
145 .LP
146 .B GETDNS_RESPSTATUS_NO_SECURE_ANSWERS
147 only secure replies accepted (per context), at least one response was received but no DNS responses were secure through DNSSEC
148
149 .LP
150 For a more detailed explanation of the response object see
151 .I libgetdns
152 (3)
153
154 .SH EXAMPLES
155
156 TBD
157
158 .SH FILES
159 .br
160 /etc/hosts
161 .br
162 /etc/resolv.conf
163
164 .SH SEE ALSO
165 .BR libgetdns (3),
166 .BR getdns_context (3),
167 .BR getdns_free_sync_request_memory (3),
168 .BR getdns_general (3),
169 .BR getdns_general_sync (3),
170 .BR getdns_hostname (3),
171 .BR getdns_hostname_sync (3),
172 .BR getdns_address (3),
173 .BR getdns_address_sync (3)
174
0 .\" The "BSD-New" License
1 .\"
2 .\" Copyright (c) 2013, NLNet Labs, Verisign, Inc.
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions are met:
7 .\" * Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" * Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" * Neither the names of the copyright holders nor the
13 .\" names of its contributors may be used to endorse or promote products
14 .\" derived from this software without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 .\" DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 .\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 .\" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27
28 .TH libgetdns 3 "@date@" "getdns @version@" getdns
29 .SH NAME
30 libgetdns
31 .SH LIBRARY
32 DNS Resolver library (libgetdns, -lgetdns)
33
34 .SH SYNOPSIS
35 .Lb libgetdns
36
37 This man page describes the getdns library, the general concepts behind the API and some of the common elements of the public interface to the library. Each of the public entry points and more complex data types are captured in separate man pages.
38
39 .SH DESCRIPTION
40
41 .LP
42 getdns is modern asynchronous DNS API intended to be useful to application developers and operating system distributors as a way of making all types of DNS information easily available in many types of programs. The major features of this new API are:
43
44 .RS 3
45 Full support for event-driven programming
46 Supports DNSSEC in multiple ways
47 Mirroring of the resolution in getaddrinfo()
48 Easily supports all RRtypes, even those yet to be defined
49 .RE
50
51 .LP
52 Each of the entry points is offered with both asynchronous and synchronous signatures. The asynchronous functions rely on event handling and callback via libevent.
53 Functions are thread safe.
54
55 .LP
56 A context structure maintains DNS query and response data and is used to maintain state during calls to the public entry points.
57
58 .LP
59 The project page for this implementation is at
60 .IP
61 http://www.getdnsapi.net
62
63 .LP
64 The specification is maintained at
65 .IP
66 http://www.vpnc.org/getdns-api
67
68 .LP
69 The git repository for this implementation is at
70 .IP
71 http://github.com/getdnsapi/getdns
72
73 .SH DATA STRUCTURES
74
75 .LP
76 The API uses a few data structures to pass data into and return data from the public
77 entry points.
78
79 .IP list
80 an ordered list, the members of the list can be any of the four data types.
81 .IP dict
82 a name-value pair. The name is a string literal, and the value can be any of the four data types. The order of the name-value pairs in a dict is not important.
83 .IP int
84 an integer compatible with uint32_t.
85 .IP bindata
86 a struct used to hold binary data defined as { size_t size; uint8_t *binary_stuff; }.
87
88 .SH ASYNCHRONOUS USE
89
90 .LP
91 TBD
92
93 .SH SYNCHRONOUS USE
94
95 .LP
96 There are four synchronous functions parallel to the four getdns async
97 functions, except that there is no callback parameter. When an application
98 calls one of these synchronous functions, the API gathers all the required
99 information and then returns the result. The value returned is exactly the same
100 as the response returned in the callback if you had used the async version of
101 the function.
102
103 .LP
104 When you are done with the data in the response, call getdns_free_sync_request_memory so
105 that the API can free the memory from its internal pool.
106
107 .SH EXTENSIONS
108
109 Applications may populate an extension dictionary when making a call to the public entry points. To use an extension add it to the extension dictionary prior to making the call to the public entry point and set the value depending on the behavior you expect. These extensions include:
110
111 .HP 3
112 dnssec_return_status (int)
113
114 Set to GETDNS_EXTENSION_TRUE to include the DNSSEC status for each DNS record in the replies_tree
115
116 .HP 3
117 dnssec_return_only_secure (int)
118
119 Set to GETDNS_EXTENSION_TRUE to cause only records that the API can validate as secure withe DNSSEC to be returned in the
120 .I replies_tree
121 and
122 .I replies_full lists
123
124 .HP 3
125 dnssec_return_supporting_responses (int)
126
127 Set to GETDNS_EXTENSION_TRUE to cause the set of additional DNSSEC-related records needed for validation to be returned in the response object as the list named
128 .I additional_dnssec
129 at the top level of the response object
130
131 .HP 3
132 return_both_v4_and_v6 (int)
133
134 Set to GETDNS_EXTENSION_TRUE to cause the results of both A and AAAA records for the queried name to be included in the response object.
135
136 .HP 3
137 add_opt_parameters (dict)
138
139 TBD (complicated)
140
141 .HP 3
142 add_warning_for_bad_dns
143
144 Set to GETDNS_EXTENSION_TRUE to cause each reply in the
145 .I replies_tree
146 to contain an additional name whose data type is a list,
147 .I bad_dns
148 which contains zero or more ints that indicate the types of bad DNS found in the reply.
149 .RS 6
150 .br
151 GETDNS_BAD_DNS_CNAME_IN_TARGET: query type does not allow a CNAME pointed to a CNAME
152 .br
153 GETDNS_BAD_DNS_ALL_NUMERIC_LABEL: one or more labels is all numeric
154 .br
155 GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE: query type for other than CNAME returned a CNAME
156 .RE
157
158 .HP 3
159 specify_class (int)
160
161 Set to the DNS class number (other than Internet (IN) class desired in query.
162
163 .HP 3
164 return_api_information (int)
165
166 Set to GETDNS_EXTENSION_TRUE to add the following to the top level of the response object:
167 .RS 6
168 .br
169 .I version_string
170 (bindata) : the version string for this version of the getdns API
171 .br
172 .I implementation_string
173 (bindata) : string set by this library's implementer as a build or version indicator
174 .br
175 .I resolver_type
176 (int) : GETDNS_CONTEXT_RECURSING or GETDNS_CONTEXT_STUB depending on how the context is configured
177 .br
178 .I all_context
179 (dict) : includes names from the context, use with
180 .I getdns_pretty_print_dict
181 (3) for debugging
182 .RE
183
184 .HP 3
185 return_call_debugging (int)
186
187 Set to GETDNS_EXTENSION_TRUE to add the name
188 .I call_debugging
189 (list) to the top level of the response object that includes a dict for each call made to the API. TBD: more detail
190
191 .LP
192 This implementation of the getdns API is licensed under the BSD license.
193
194 .SH RESPONSE DATA
195
196 .LP
197 The callback function contains a pointer to a response object. A response
198 object is always a dict. The response object always contains at least three
199 names: replies_full (a list) and replies_tree (a list), and status (an int).
200 replies_full is a list of DNS replies (each is bindata) as they appear on the
201 wire. replies_tree is a list of DNS replies (each is a dict) with the various
202 part of the reply parsed out. status is a status code for the query.
203
204 .LP
205 Because the API might be extended in the future, a response object might also
206 contain names other than replies_full, replies_tree, and status. Similarly, any
207 of the dicts described here might be extended in later versions of the API.
208 Thus, an application using the API must not assume that it knows all possible
209 names in a dict.
210
211 .LP
212 The following lists the status codes for response objects. Note that, if the
213 status is that there are no responses for the query, the lists in replies_full
214 and replies_tree will have zero length.
215
216 .HP 3
217 .B GETDNS_RESPSTATUS_GOOD
218 At least one response was returned
219 .HP 3
220 .B GETDNS_RESPSTATUS_NO_NAME
221 Queries for the name yielded all negative responses
222 .HP 3
223 .B GETDNS_RESPSTATUS_ALL_TIMEOUT
224 All queries for the name timed out
225 .HP 3
226 .B GETDNS_RESPSTATUS_NO_SECURE_ANSWERS
227 The context setting for getting only secure responses was specified, and at least one DNS response was received, but no DNS response was determined to be secure through DNSSEC.
228
229 .LP
230 The top level of replies_tree can optionally have the following names: canonical_name (a bindata), intermediate_aliases (a list), answer_ipv4_address (a bindata), answer_ipv6_address (a bindata), and answer_type (an int).
231
232 .LP
233 The value of canonical_name is the name that the API used for its lookup. It is
234 in FQDN presentation format. The values in the intermediate_aliases list are
235 domain names from any CNAME or unsynthesized DNAME found when resolving the
236 original query. The list might have zero entries if there were no CNAMEs in the
237 path. These may be useful, for example, for name comparisons when following the
238 rules in RFC 6125. The value of answer_ipv4_address and answer_ipv6_address
239 are the addresses of the server from which the answer was received. The value
240 of answer_type is the type of name service that generated the response. The
241 values are:
242
243 .RS 3
244 GETDNS_NAMETYPE_DNS
245 Normal DNS (RFC 1035)
246 GETDNS_NAMETYPE_WINS
247 The WINS name service (some reference needed)
248 .RE
249
250 .LP
251 If the call was getdns_address or getdns_address_sync, the top level of
252 replies_tree has an additional name, just_address_answers (a list). The value
253 of just_address_answers is a list that contains all of the A and AAAA records
254 from the answer sections of any of the replies, in the order they appear in the
255 replies. Each item in the list is a dict with at least two names: address_type
256 (whose value is a bindata; it is currently either "IPv4" or "IPv6") and
257 address_data (whose value is a bindata). Note that the
258 dnssec_return_only_secure extension affects what will appear in the
259 just_address_answers list. If the DNS returns other
260 address types, those types will appear in this list as well.
261
262 .LP
263 The API can make service discovery through SRV records easier. If the call was
264 getdns_service or getdns_service_sync, the top level of replies_tree has an
265 additional name, srv_addresses (a list). The list is ordered by priority and
266 weight based on the weighting algorithm in RFC 2782, lowest priority value
267 first. Each element of the list is dict has at least two names: port and
268 domain_name. If the API was able to determine the address of the target domain
269 name (such as from its cache or from the Additional section of responses), the
270 dict for an element will also contain address_type (whose value is a bindata;
271 it is currently either "IPv4" or "IPv6") and address_data (whose value is a
272 bindata). Note that the dnssec_return_only_secure extension affects what will
273 appear in the srv_addresses list.
274
275 .SH STRUCTURE OF DNS REPLIES_TREE
276
277 .LP
278 The names in each entry in the the replies_tree list for DNS responses include
279 header (a dict), question (a dict), answer (a list), authority (a list), and
280 additional (a list), corresponding to the sections in the DNS message format.
281 The answer, authority, and additional lists each contain zero or more dicts,
282 with each dict in each list representing a resource record.
283
284 .LP
285 The names in the header dict are all the fields from Section 4.1.1. of RFC
286 1035. They are: id, qr, opcode, aa, tc, rd, ra, z, rcode, qdcount, ancount,
287 nscount, and arcount. All are ints.
288
289 .LP
290 The names in the question dict are the three fields from Section 4.1.2. of RFC
291 1035: qname (a bindata), qtype (an int), and qclass (an int).
292
293 .LP
294 Resource records are a bit different than headers and question sections in that
295 the RDATA portion often has its own structure. The other names in the resource
296 record dicts are name (a bindata), type (an int), class (an int), ttl (an int)
297 and rdata (a dict); there is no name equivalent to the RDLENGTH field.
298
299 .LP
300 The rdata dict has different names for each response type. There is a complete
301 list of the types defined in the API. For names that end in "-obsolete" or
302 "-unknown", the bindata is the entire RDATA field. For example, the rdata for
303 an A record has a name ipv4_address (a bindata); the rdata for an SRV record
304 has the names priority (an int), weight (an int), port (an int), and target (a
305 bindata).
306
307 .LP
308 Each rdata dict also has a rdata_raw field (a bindata). This is useful for
309 types not defined in this version of the API. It also might be of value if a
310 later version of the API allows for additional parsers. Thus, doing a query for
311 types not known by the API still will return a result: an rdata with just a
312 rdata_raw.
313
314 .LP
315 It is expected that later extensions to the API will give some DNS types
316 different names. It is also possible that later extensions will change the
317 names for some of the DNS types listed above.
318
319 .SH CALLBACK FUNCTIONS
320
321 .LP
322 A call to the async getdns functions typically returns before any network or
323 file I/O occurs. After the API marshalls all the needed information, it calls
324 the callback function that was passed by the application. The callback function
325 might be called at any time, even before the calling function has returned. The
326 API guarantees that the callback will be called exactly once unless the calling
327 function returned an error, in which case the callback function is never
328 called.
329
330 The getdns calling function calls the callback with the parameters defined as
331 follows:
332
333 .br
334 typedef void (*getdns_callback_t)(
335 .RS 3
336 getdns_context_t context,
337 .br
338 uint16_t callback_type,
339 .br
340 getdns_dict *response,
341 .br
342 void *userarg,
343 .br
344 getdns_transaction_t transaction_id)
345 .RE
346
347 .HP 3
348 .I context
349 .RP
350 see getdns_context (3)
351
352 .HP 3
353 .I callback_type
354 .RP
355 Supplies the reason for the callback.
356 .RS 3
357 .LP
358 .B GETDNS_CALLBACK_COMPLETE
359 The response has the requested data in it
360 .LP
361 .B GETDNS_CALLBACK_CANCEL
362 The calling program canceled the callback; response is NULL
363 .LP
364 .B GETDNS_CALLBACK_TIMEOUT
365 The requested action timed out; response is NULL
366 .LP
367 .B GETDNS_CALLBACK_ERROR
368 The requested action had an error; response is NULL
369 .RE
370
371 .HP 3
372 .I response
373 .RP
374 A response object with the response data. This is described below. The response object is part of the API's memory space, and will be freed by the API with the callback returns.
375
376 .HP 3
377 .I userarg
378 .RP
379 Identical to the userarg passed to the calling function.
380
381 .HP 3
382 .I transaction_id
383 .RP
384 The transaction identified assigned by the calling function, used to associate a DNS response to a specific DNS request.
385
386 .LP
387 To cancel an outstanding callback, use the following function.
388
389 .RS 3
390 .br
391 getdns_return_t
392 .br
393 .B
394 getdns_cancel_callback
395 (getdns_context_t context, getdns_transaction_t transaction_id)
396 .RE
397
398 .LP
399 This causes the API to call the callback with a callback_type of
400 GETDNS_CALLBACK_CANCEL if the callback for this transaction_id has not already
401 been called. The callback code for cancellation should clean up any memory
402 related to the identified call, such as to deallocate the memory for the
403 userarg. getdns_cancel_callback() may return immediately, even before the
404 callback finishes its work and returns. Calling getdns_cancel_callback() with a
405 transaction_id of a callback that has already been called or an unknown
406 transaction_id returns GETDNS_RETURN_UNKNOWN_TRANSACTION; otherwise,
407 getdns_cancel_callback() returns GETDNS_RETURN_GOOD.
408
409 .SH FILES
410 .br /etc/hosts
411 .br /etc/resolv.conf
412
413 .SH EXAMPLES
414 TBD
415
416 .SH DIAGNOSTICS
417 TBD
418
419 .SH "SEE ALSO"
420 .BR getdns_address (3),
421 .BR getdns_bindata (3),
422 .BR getdns_context (3),
423 .BR getdns_convert (3),
424 .BR getdns_dict (3),
425 .BR getdns_general (3),
426 .BR getdns_hostname (3),
427 .BR getdns_list (3),
428 .BR getdns_service (3)
429
430 .SH REPORTING PROBLEMS
431 Bug reports should be sent to the getdns-bugs@getdns.net
432
433 .SH AUTHORS
434
435 The getdns API was documented by Paul Hoffman. This implementation of the getdns API was written by:
436 .LP
437 .RS 3
438 .br
439 Neel Goyal, Verisign Inc.
440 .br
441 Melinda Shore, No Mountain Software, LLC
442 .br
443 Willem Toorop, NLNet Labs
444 .br
445 Wouter Wijngaards, NLNet Labs
446 .br
447 Glen Wiley, Verisign Inc.
448 .RE
449
0 #!/bin/sh
1 # generate list of alternate names for the specified man page
2 # used to generate alternative man pages
3 #
4 # Copyright (c) 2013, Verisign, Inc., NLNet Labs
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are met:
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * 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 # * Neither the names of the copyright holders nor the
15 # names of its contributors may be used to endorse or promote products
16 # derived from this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
22 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 [ ! -f $1 ] && exit 0
29
30 main=${1%.[0-9]}
31 sect=${1#*.}
32 sed -n '/.SH NAME/,/.SH LIBRARY/p' $1 |grep "^.B " | sed 's/.B //g' | sed 's/ *$//g' | sed 's/,//g' | grep -v "^$main\$" | sed "s/\$/.$sect/"
0 #!/bin/sh
1 # install - install a program, script, or datafile
2
3 scriptversion=2011-11-20.07; # UTC
4
5 # This originates from X11R5 (mit/util/scripts/install.sh), which was
6 # later released in X11R6 (xc/config/util/install.sh) with the
7 # following copyright and license.
8 #
9 # Copyright (C) 1994 X Consortium
10 #
11 # Permission is hereby granted, free of charge, to any person obtaining a copy
12 # of this software and associated documentation files (the "Software"), to
13 # deal in the Software without restriction, including without limitation the
14 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15 # sell copies of the Software, and to permit persons to whom the Software is
16 # furnished to do so, subject to the following conditions:
17 #
18 # The above copyright notice and this permission notice shall be included in
19 # all copies or substantial portions of the Software.
20 #
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
26 # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #
28 # Except as contained in this notice, the name of the X Consortium shall not
29 # be used in advertising or otherwise to promote the sale, use or other deal-
30 # ings in this Software without prior written authorization from the X Consor-
31 # tium.
32 #
33 #
34 # FSF changes to this file are in the public domain.
35 #
36 # Calling this script install-sh is preferred over install.sh, to prevent
37 # 'make' implicit rules from creating a file called install from it
38 # when there is no Makefile.
39 #
40 # This script is compatible with the BSD install script, but was written
41 # from scratch.
42
43 nl='
44 '
45 IFS=" "" $nl"
46
47 # set DOITPROG to echo to test this script
48
49 # Don't use :- since 4.3BSD and earlier shells don't like it.
50 doit=${DOITPROG-}
51 if test -z "$doit"; then
52 doit_exec=exec
53 else
54 doit_exec=$doit
55 fi
56
57 # Put in absolute file names if you don't have them in your path;
58 # or use environment vars.
59
60 chgrpprog=${CHGRPPROG-chgrp}
61 chmodprog=${CHMODPROG-chmod}
62 chownprog=${CHOWNPROG-chown}
63 cmpprog=${CMPPROG-cmp}
64 cpprog=${CPPROG-cp}
65 mkdirprog=${MKDIRPROG-mkdir}
66 mvprog=${MVPROG-mv}
67 rmprog=${RMPROG-rm}
68 stripprog=${STRIPPROG-strip}
69
70 posix_glob='?'
71 initialize_posix_glob='
72 test "$posix_glob" != "?" || {
73 if (set -f) 2>/dev/null; then
74 posix_glob=
75 else
76 posix_glob=:
77 fi
78 }
79 '
80
81 posix_mkdir=
82
83 # Desired mode of installed file.
84 mode=0755
85
86 chgrpcmd=
87 chmodcmd=$chmodprog
88 chowncmd=
89 mvcmd=$mvprog
90 rmcmd="$rmprog -f"
91 stripcmd=
92
93 src=
94 dst=
95 dir_arg=
96 dst_arg=
97
98 copy_on_change=false
99 no_target_directory=
100
101 usage="\
102 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
103 or: $0 [OPTION]... SRCFILES... DIRECTORY
104 or: $0 [OPTION]... -t DIRECTORY SRCFILES...
105 or: $0 [OPTION]... -d DIRECTORIES...
106
107 In the 1st form, copy SRCFILE to DSTFILE.
108 In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
109 In the 4th, create DIRECTORIES.
110
111 Options:
112 --help display this help and exit.
113 --version display version info and exit.
114
115 -c (ignored)
116 -C install only if different (preserve the last data modification time)
117 -d create directories instead of installing files.
118 -g GROUP $chgrpprog installed files to GROUP.
119 -m MODE $chmodprog installed files to MODE.
120 -o USER $chownprog installed files to USER.
121 -s $stripprog installed files.
122 -t DIRECTORY install into DIRECTORY.
123 -T report an error if DSTFILE is a directory.
124
125 Environment variables override the default commands:
126 CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
127 RMPROG STRIPPROG
128 "
129
130 while test $# -ne 0; do
131 case $1 in
132 -c) ;;
133
134 -C) copy_on_change=true;;
135
136 -d) dir_arg=true;;
137
138 -g) chgrpcmd="$chgrpprog $2"
139 shift;;
140
141 --help) echo "$usage"; exit $?;;
142
143 -m) mode=$2
144 case $mode in
145 *' '* | *' '* | *'
146 '* | *'*'* | *'?'* | *'['*)
147 echo "$0: invalid mode: $mode" >&2
148 exit 1;;
149 esac
150 shift;;
151
152 -o) chowncmd="$chownprog $2"
153 shift;;
154
155 -s) stripcmd=$stripprog;;
156
157 -t) dst_arg=$2
158 # Protect names problematic for 'test' and other utilities.
159 case $dst_arg in
160 -* | [=\(\)!]) dst_arg=./$dst_arg;;
161 esac
162 shift;;
163
164 -T) no_target_directory=true;;
165
166 --version) echo "$0 $scriptversion"; exit $?;;
167
168 --) shift
169 break;;
170
171 -*) echo "$0: invalid option: $1" >&2
172 exit 1;;
173
174 *) break;;
175 esac
176 shift
177 done
178
179 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
180 # When -d is used, all remaining arguments are directories to create.
181 # When -t is used, the destination is already specified.
182 # Otherwise, the last argument is the destination. Remove it from $@.
183 for arg
184 do
185 if test -n "$dst_arg"; then
186 # $@ is not empty: it contains at least $arg.
187 set fnord "$@" "$dst_arg"
188 shift # fnord
189 fi
190 shift # arg
191 dst_arg=$arg
192 # Protect names problematic for 'test' and other utilities.
193 case $dst_arg in
194 -* | [=\(\)!]) dst_arg=./$dst_arg;;
195 esac
196 done
197 fi
198
199 if test $# -eq 0; then
200 if test -z "$dir_arg"; then
201 echo "$0: no input file specified." >&2
202 exit 1
203 fi
204 # It's OK to call 'install-sh -d' without argument.
205 # This can happen when creating conditional directories.
206 exit 0
207 fi
208
209 if test -z "$dir_arg"; then
210 do_exit='(exit $ret); exit $ret'
211 trap "ret=129; $do_exit" 1
212 trap "ret=130; $do_exit" 2
213 trap "ret=141; $do_exit" 13
214 trap "ret=143; $do_exit" 15
215
216 # Set umask so as not to create temps with too-generous modes.
217 # However, 'strip' requires both read and write access to temps.
218 case $mode in
219 # Optimize common cases.
220 *644) cp_umask=133;;
221 *755) cp_umask=22;;
222
223 *[0-7])
224 if test -z "$stripcmd"; then
225 u_plus_rw=
226 else
227 u_plus_rw='% 200'
228 fi
229 cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
230 *)
231 if test -z "$stripcmd"; then
232 u_plus_rw=
233 else
234 u_plus_rw=,u+rw
235 fi
236 cp_umask=$mode$u_plus_rw;;
237 esac
238 fi
239
240 for src
241 do
242 # Protect names problematic for 'test' and other utilities.
243 case $src in
244 -* | [=\(\)!]) src=./$src;;
245 esac
246
247 if test -n "$dir_arg"; then
248 dst=$src
249 dstdir=$dst
250 test -d "$dstdir"
251 dstdir_status=$?
252 else
253
254 # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
255 # might cause directories to be created, which would be especially bad
256 # if $src (and thus $dsttmp) contains '*'.
257 if test ! -f "$src" && test ! -d "$src"; then
258 echo "$0: $src does not exist." >&2
259 exit 1
260 fi
261
262 if test -z "$dst_arg"; then
263 echo "$0: no destination specified." >&2
264 exit 1
265 fi
266 dst=$dst_arg
267
268 # If destination is a directory, append the input filename; won't work
269 # if double slashes aren't ignored.
270 if test -d "$dst"; then
271 if test -n "$no_target_directory"; then
272 echo "$0: $dst_arg: Is a directory" >&2
273 exit 1
274 fi
275 dstdir=$dst
276 dst=$dstdir/`basename "$src"`
277 dstdir_status=0
278 else
279 # Prefer dirname, but fall back on a substitute if dirname fails.
280 dstdir=`
281 (dirname "$dst") 2>/dev/null ||
282 expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
283 X"$dst" : 'X\(//\)[^/]' \| \
284 X"$dst" : 'X\(//\)$' \| \
285 X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
286 echo X"$dst" |
287 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
288 s//\1/
289 q
290 }
291 /^X\(\/\/\)[^/].*/{
292 s//\1/
293 q
294 }
295 /^X\(\/\/\)$/{
296 s//\1/
297 q
298 }
299 /^X\(\/\).*/{
300 s//\1/
301 q
302 }
303 s/.*/./; q'
304 `
305
306 test -d "$dstdir"
307 dstdir_status=$?
308 fi
309 fi
310
311 obsolete_mkdir_used=false
312
313 if test $dstdir_status != 0; then
314 case $posix_mkdir in
315 '')
316 # Create intermediate dirs using mode 755 as modified by the umask.
317 # This is like FreeBSD 'install' as of 1997-10-28.
318 umask=`umask`
319 case $stripcmd.$umask in
320 # Optimize common cases.
321 *[2367][2367]) mkdir_umask=$umask;;
322 .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
323
324 *[0-7])
325 mkdir_umask=`expr $umask + 22 \
326 - $umask % 100 % 40 + $umask % 20 \
327 - $umask % 10 % 4 + $umask % 2
328 `;;
329 *) mkdir_umask=$umask,go-w;;
330 esac
331
332 # With -d, create the new directory with the user-specified mode.
333 # Otherwise, rely on $mkdir_umask.
334 if test -n "$dir_arg"; then
335 mkdir_mode=-m$mode
336 else
337 mkdir_mode=
338 fi
339
340 posix_mkdir=false
341 case $umask in
342 *[123567][0-7][0-7])
343 # POSIX mkdir -p sets u+wx bits regardless of umask, which
344 # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
345 ;;
346 *)
347 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
348 trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
349
350 if (umask $mkdir_umask &&
351 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
352 then
353 if test -z "$dir_arg" || {
354 # Check for POSIX incompatibilities with -m.
355 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
356 # other-writable bit of parent directory when it shouldn't.
357 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
358 ls_ld_tmpdir=`ls -ld "$tmpdir"`
359 case $ls_ld_tmpdir in
360 d????-?r-*) different_mode=700;;
361 d????-?--*) different_mode=755;;
362 *) false;;
363 esac &&
364 $mkdirprog -m$different_mode -p -- "$tmpdir" && {
365 ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
366 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
367 }
368 }
369 then posix_mkdir=:
370 fi
371 rmdir "$tmpdir/d" "$tmpdir"
372 else
373 # Remove any dirs left behind by ancient mkdir implementations.
374 rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
375 fi
376 trap '' 0;;
377 esac;;
378 esac
379
380 if
381 $posix_mkdir && (
382 umask $mkdir_umask &&
383 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
384 )
385 then :
386 else
387
388 # The umask is ridiculous, or mkdir does not conform to POSIX,
389 # or it failed possibly due to a race condition. Create the
390 # directory the slow way, step by step, checking for races as we go.
391
392 case $dstdir in
393 /*) prefix='/';;
394 [-=\(\)!]*) prefix='./';;
395 *) prefix='';;
396 esac
397
398 eval "$initialize_posix_glob"
399
400 oIFS=$IFS
401 IFS=/
402 $posix_glob set -f
403 set fnord $dstdir
404 shift
405 $posix_glob set +f
406 IFS=$oIFS
407
408 prefixes=
409
410 for d
411 do
412 test X"$d" = X && continue
413
414 prefix=$prefix$d
415 if test -d "$prefix"; then
416 prefixes=
417 else
418 if $posix_mkdir; then
419 (umask=$mkdir_umask &&
420 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
421 # Don't fail if two instances are running concurrently.
422 test -d "$prefix" || exit 1
423 else
424 case $prefix in
425 *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
426 *) qprefix=$prefix;;
427 esac
428 prefixes="$prefixes '$qprefix'"
429 fi
430 fi
431 prefix=$prefix/
432 done
433
434 if test -n "$prefixes"; then
435 # Don't fail if two instances are running concurrently.
436 (umask $mkdir_umask &&
437 eval "\$doit_exec \$mkdirprog $prefixes") ||
438 test -d "$dstdir" || exit 1
439 obsolete_mkdir_used=true
440 fi
441 fi
442 fi
443
444 if test -n "$dir_arg"; then
445 { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
446 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
447 { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
448 test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
449 else
450
451 # Make a couple of temp file names in the proper directory.
452 dsttmp=$dstdir/_inst.$$_
453 rmtmp=$dstdir/_rm.$$_
454
455 # Trap to clean up those temp files at exit.
456 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
457
458 # Copy the file name to the temp name.
459 (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
460
461 # and set any options; do chmod last to preserve setuid bits.
462 #
463 # If any of these fail, we abort the whole thing. If we want to
464 # ignore errors from any of these, just make sure not to ignore
465 # errors from the above "$doit $cpprog $src $dsttmp" command.
466 #
467 { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
468 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
469 { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
470 { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
471
472 # If -C, don't bother to copy if it wouldn't change the file.
473 if $copy_on_change &&
474 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
475 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
476
477 eval "$initialize_posix_glob" &&
478 $posix_glob set -f &&
479 set X $old && old=:$2:$4:$5:$6 &&
480 set X $new && new=:$2:$4:$5:$6 &&
481 $posix_glob set +f &&
482
483 test "$old" = "$new" &&
484 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
485 then
486 rm -f "$dsttmp"
487 else
488 # Rename the file to the real destination.
489 $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
490
491 # The rename failed, perhaps because mv can't rename something else
492 # to itself, or perhaps because mv is so ancient that it does not
493 # support -f.
494 {
495 # Now remove or move aside any old file at destination location.
496 # We try this two ways since rm can't unlink itself on some
497 # systems and the destination file might be busy for other
498 # reasons. In this case, the final cleanup might fail but the new
499 # file should still install successfully.
500 {
501 test ! -f "$dst" ||
502 $doit $rmcmd -f "$dst" 2>/dev/null ||
503 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
504 { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
505 } ||
506 { echo "$0: cannot unlink or rename $dst" >&2
507 (exit 1); exit 1
508 }
509 } &&
510
511 # Now rename the file to the real destination.
512 $doit $mvcmd "$dsttmp" "$dst"
513 }
514 fi || exit 1
515
516 trap '' 0
517 fi
518 done
519
520 # Local variables:
521 # eval: (add-hook 'write-file-hooks 'time-stamp)
522 # time-stamp-start: "scriptversion="
523 # time-stamp-format: "%:y-%02m-%02d.%02H"
524 # time-stamp-time-zone: "UTC"
525 # time-stamp-end: "; # UTC"
526 # End:
+10074
-0
libtool less more
0 #! /bin/sh
1
2 # libtool - Provide generalized library-building support services.
3 # Generated automatically by config.status ()
4 # Libtool was configured on host DUL1GWILEY-M2:
5 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
6 #
7 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
8 # 2006, 2007, 2008, 2009, 2010, 2011 Free Software
9 # Foundation, Inc.
10 # Written by Gordon Matzigkeit, 1996
11 #
12 # This file is part of GNU Libtool.
13 #
14 # GNU Libtool is free software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License as
16 # published by the Free Software Foundation; either version 2 of
17 # the License, or (at your option) any later version.
18 #
19 # As a special exception to the GNU General Public License,
20 # if you distribute this file as part of a program or library that
21 # is built using GNU Libtool, you may include this file under the
22 # same distribution terms that you use for the rest of that program.
23 #
24 # GNU Libtool is distributed in the hope that it will be useful,
25 # but WITHOUT ANY WARRANTY; without even the implied warranty of
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 # GNU General Public License for more details.
28 #
29 # You should have received a copy of the GNU General Public License
30 # along with GNU Libtool; see the file COPYING. If not, a copy
31 # can be downloaded from http://www.gnu.org/licenses/gpl.html, or
32 # obtained by writing to the Free Software Foundation, Inc.,
33 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
34
35
36 # The names of the tagged configurations supported by this script.
37 available_tags=""
38
39 # ### BEGIN LIBTOOL CONFIG
40
41 # Which release of libtool.m4 was used?
42 macro_version=2.4.2
43 macro_revision=1.3337
44
45 # Whether or not to build shared libraries.
46 build_libtool_libs=yes
47
48 # Whether or not to build static libraries.
49 build_old_libs=yes
50
51 # What type of objects to build.
52 pic_mode=default
53
54 # Whether or not to optimize for fast installation.
55 fast_install=needless
56
57 # Shell to use when invoking shell scripts.
58 SHELL="/bin/sh"
59
60 # An echo program that protects backslashes.
61 ECHO="printf %s\\n"
62
63 # The PATH separator for the build system.
64 PATH_SEPARATOR=":"
65
66 # The host system.
67 host_alias=
68 host=x86_64-apple-darwin12.5.0
69 host_os=darwin12.5.0
70
71 # The build system.
72 build_alias=
73 build=x86_64-apple-darwin12.5.0
74 build_os=darwin12.5.0
75
76 # A sed program that does not truncate output.
77 SED="/usr/bin/sed"
78
79 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
80 Xsed="$SED -e 1s/^X//"
81
82 # A grep program that handles long lines.
83 GREP="/usr/bin/grep"
84
85 # An ERE matcher.
86 EGREP="/usr/bin/grep -E"
87
88 # A literal string matcher.
89 FGREP="/usr/bin/grep -F"
90
91 # A BSD- or MS-compatible name lister.
92 NM="/usr/bin/nm"
93
94 # Whether we need soft or hard links.
95 LN_S="ln -s"
96
97 # What is the maximum length of a command?
98 max_cmd_len=196608
99
100 # Object file suffix (normally "o").
101 objext=o
102
103 # Executable file suffix (normally "").
104 exeext=
105
106 # whether the shell understands "unset".
107 lt_unset=unset
108
109 # turn spaces into newlines.
110 SP2NL="tr \\040 \\012"
111
112 # turn newlines into spaces.
113 NL2SP="tr \\015\\012 \\040\\040"
114
115 # convert $build file names to $host format.
116 to_host_file_cmd=func_convert_file_noop
117
118 # convert $build files to toolchain format.
119 to_tool_file_cmd=func_convert_file_noop
120
121 # An object symbol dumper.
122 OBJDUMP="false"
123
124 # Method to check whether dependent libraries are shared objects.
125 deplibs_check_method="pass_all"
126
127 # Command to use when deplibs_check_method = "file_magic".
128 file_magic_cmd="\$MAGIC_CMD"
129
130 # How to find potential files when deplibs_check_method = "file_magic".
131 file_magic_glob=""
132
133 # Find potential files using nocaseglob when deplibs_check_method = "file_magic".
134 want_nocaseglob="no"
135
136 # DLL creation program.
137 DLLTOOL="false"
138
139 # Command to associate shared and link libraries.
140 sharedlib_from_linklib_cmd="printf %s\\n"
141
142 # The archiver.
143 AR="ar"
144
145 # Flags to create an archive.
146 AR_FLAGS="cru"
147
148 # How to feed a file listing to the archiver.
149 archiver_list_spec=""
150
151 # A symbol stripping program.
152 STRIP="strip"
153
154 # Commands used to install an old-style archive.
155 RANLIB="ranlib"
156 old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$tool_oldlib"
157 old_postuninstall_cmds=""
158
159 # Whether to use a lock for old archive extraction.
160 lock_old_archive_extraction=yes
161
162 # A C compiler.
163 LTCC="gcc"
164
165 # LTCC compiler flags.
166 LTCFLAGS="-g -O2 -I/opt/local/include -I/usr/local/include -I/usr/local/include"
167
168 # Take the output of nm and produce a listing of raw symbols and C names.
169 global_symbol_pipe="sed -n -e 's/^.*[ ]\\([BCDEGRST][BCDEGRST]*\\)[ ][ ]*_\\([_A-Za-z][_A-Za-z0-9]*\\)\$/\\1 _\\2 \\2/p' | sed '/ __gnu_lto/d'"
170
171 # Transform the output of nm in a proper C declaration.
172 global_symbol_to_cdecl="sed -n -e 's/^T .* \\(.*\\)\$/extern int \\1();/p' -e 's/^[BCDEGRST]* .* \\(.*\\)\$/extern char \\1;/p'"
173
174 # Transform the output of nm in a C name address pair.
175 global_symbol_to_c_name_address="sed -n -e 's/^: \\([^ ]*\\)[ ]*\$/ {\\\"\\1\\\", (void *) 0},/p' -e 's/^[BCDEGRST]* \\([^ ]*\\) \\([^ ]*\\)\$/ {\"\\2\", (void *) \\&\\2},/p'"
176
177 # Transform the output of nm in a C name address pair when lib prefix is needed.
178 global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \\([^ ]*\\)[ ]*\$/ {\\\"\\1\\\", (void *) 0},/p' -e 's/^[BCDEGRST]* \\([^ ]*\\) \\(lib[^ ]*\\)\$/ {\"\\2\", (void *) \\&\\2},/p' -e 's/^[BCDEGRST]* \\([^ ]*\\) \\([^ ]*\\)\$/ {\"lib\\2\", (void *) \\&\\2},/p'"
179
180 # Specify filename containing input files for $NM.
181 nm_file_list_spec=""
182
183 # The root where to search for dependent libraries,and in which our libraries should be installed.
184 lt_sysroot=
185
186 # The name of the directory that contains temporary libtool files.
187 objdir=.libs
188
189 # Used to examine libraries when file_magic_cmd begins with "file".
190 MAGIC_CMD=file
191
192 # Must we lock files when doing compilation?
193 need_locks="no"
194
195 # Manifest tool.
196 MANIFEST_TOOL=":"
197
198 # Tool to manipulate archived DWARF debug symbol files on Mac OS X.
199 DSYMUTIL="dsymutil"
200
201 # Tool to change global to local symbols on Mac OS X.
202 NMEDIT="nmedit"
203
204 # Tool to manipulate fat objects and archives on Mac OS X.
205 LIPO="lipo"
206
207 # ldd/readelf like tool for Mach-O binaries on Mac OS X.
208 OTOOL="otool"
209
210 # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
211 OTOOL64=":"
212
213 # Old archive suffix (normally "a").
214 libext=a
215
216 # Shared library suffix (normally ".so").
217 shrext_cmds="\`test .\$module = .yes && echo .so || echo .dylib\`"
218
219 # The commands to extract the exported symbol list from a shared archive.
220 extract_expsyms_cmds=""
221
222 # Variables whose values should be saved in libtool wrapper scripts and
223 # restored at link time.
224 variables_saved_for_relink="PATH DYLD_LIBRARY_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
225
226 # Do we need the "lib" prefix for modules?
227 need_lib_prefix=no
228
229 # Do we need a version for libraries?
230 need_version=no
231
232 # Library versioning type.
233 version_type=darwin
234
235 # Shared library runtime path variable.
236 runpath_var=
237
238 # Shared library path variable.
239 shlibpath_var=DYLD_LIBRARY_PATH
240
241 # Is shlibpath searched before the hard-coded library search path?
242 shlibpath_overrides_runpath=yes
243
244 # Format of library name prefix.
245 libname_spec="lib\$name"
246
247 # List of archive names. First name is the real one, the rest are links.
248 # The last name is the one that the linker finds with -lNAME
249 library_names_spec="\${libname}\${release}\${major}\$shared_ext \${libname}\$shared_ext"
250
251 # The coded name of the library, if different from the real name.
252 soname_spec="\${libname}\${release}\${major}\$shared_ext"
253
254 # Permission mode override for installation of shared libraries.
255 install_override_mode=""
256
257 # Command to use after installation of a shared archive.
258 postinstall_cmds=""
259
260 # Command to use after uninstallation of a shared archive.
261 postuninstall_cmds=""
262
263 # Commands used to finish a libtool library installation in a directory.
264 finish_cmds=""
265
266 # As "finish_cmds", except a single script fragment to be evaled but
267 # not shown.
268 finish_eval=""
269
270 # Whether we should hardcode library paths into libraries.
271 hardcode_into_libs=no
272
273 # Compile-time system search path for libraries.
274 sys_lib_search_path_spec="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/5.0 /usr/local/lib"
275
276 # Run-time system search path for libraries.
277 sys_lib_dlsearch_path_spec="/usr/local/lib /lib /usr/lib"
278
279 # Whether dlopen is supported.
280 dlopen_support=unknown
281
282 # Whether dlopen of programs is supported.
283 dlopen_self=unknown
284
285 # Whether dlopen of statically linked programs is supported.
286 dlopen_self_static=unknown
287
288 # Commands to strip libraries.
289 old_striplib="strip -S"
290 striplib="strip -x"
291
292
293 # The linker used to build libraries.
294 LD="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
295
296 # How to create reloadable object files.
297 reload_flag=" -r"
298 reload_cmds="\$LTCC \$LTCFLAGS -nostdlib \${wl}-r -o \$output\$reload_objs"
299
300 # Commands used to build an old-style archive.
301 old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$tool_oldlib"
302
303 # A language specific compiler.
304 CC="gcc"
305
306 # Is the compiler the GNU compiler?
307 with_gcc=yes
308
309 # Compiler flag to turn off builtin functions.
310 no_builtin_flag=" -fno-builtin -fno-rtti -fno-exceptions"
311
312 # Additional compiler flags for building library objects.
313 pic_flag=" -fno-common -DPIC"
314
315 # How to pass a linker flag through the compiler.
316 wl="-Wl,"
317
318 # Compiler flag to prevent dynamic linking.
319 link_static_flag=""
320
321 # Does compiler simultaneously support -c and -o options?
322 compiler_c_o="yes"
323
324 # Whether or not to add -lc for building shared libraries.
325 build_libtool_need_lc=no
326
327 # Whether or not to disallow shared libs when runtime libs are static.
328 allow_libtool_libs_with_static_runtimes=no
329
330 # Compiler flag to allow reflexive dlopens.
331 export_dynamic_flag_spec=""
332
333 # Compiler flag to generate shared objects directly from archives.
334 whole_archive_flag_spec="\`for conv in \$convenience\\\"\\\"; do test -n \\\"\$conv\\\" && new_convenience=\\\"\$new_convenience \${wl}-force_load,\$conv\\\"; done; func_echo_all \\\"\$new_convenience\\\"\`"
335
336 # Whether the compiler copes with passing no objects directly.
337 compiler_needs_object="no"
338
339 # Create an old-style archive from a shared archive.
340 old_archive_from_new_cmds=""
341
342 # Create a temporary old-style archive to link instead of a shared archive.
343 old_archive_from_expsyms_cmds=""
344
345 # Commands used to build a shared archive.
346 archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring \$single_module"
347 archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring \$single_module \${wl}-exported_symbols_list,\$output_objdir/\${libname}-symbols.expsym"
348
349 # Commands used to build a loadable module if different from building
350 # a shared archive.
351 module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags"
352 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags \${wl}-exported_symbols_list,\$output_objdir/\${libname}-symbols.expsym"
353
354 # Whether we are building with GNU ld or not.
355 with_gnu_ld="no"
356
357 # Flag that allows shared libraries with undefined symbols to be built.
358 allow_undefined_flag="\${wl}-undefined \${wl}dynamic_lookup"
359
360 # Flag that enforces no undefined symbols.
361 no_undefined_flag=""
362
363 # Flag to hardcode $libdir into a binary during linking.
364 # This must work even if $libdir does not exist
365 hardcode_libdir_flag_spec=""
366
367 # Whether we need a single "-rpath" flag with a separated argument.
368 hardcode_libdir_separator=""
369
370 # Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
371 # DIR into the resulting binary.
372 hardcode_direct=no
373
374 # Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
375 # DIR into the resulting binary and the resulting library dependency is
376 # "absolute",i.e impossible to change by setting ${shlibpath_var} if the
377 # library is relocated.
378 hardcode_direct_absolute=no
379
380 # Set to "yes" if using the -LDIR flag during linking hardcodes DIR
381 # into the resulting binary.
382 hardcode_minus_L=no
383
384 # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
385 # into the resulting binary.
386 hardcode_shlibpath_var=unsupported
387
388 # Set to "yes" if building a shared library automatically hardcodes DIR
389 # into the library and all subsequent libraries and executables linked
390 # against it.
391 hardcode_automatic=yes
392
393 # Set to yes if linker adds runtime paths of dependent libraries
394 # to runtime path list.
395 inherit_rpath=no
396
397 # Whether libtool must link a program against all its dependency libraries.
398 link_all_deplibs=yes
399
400 # Set to "yes" if exported symbols are required.
401 always_export_symbols=no
402
403 # The commands to list exported symbols.
404 export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED 's/.* //' | sort | uniq > \$export_symbols"
405
406 # Symbols that should not be listed in the preloaded symbols.
407 exclude_expsyms="_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*"
408
409 # Symbols that must always be exported.
410 include_expsyms=""
411
412 # Commands necessary for linking programs (against libraries) with templates.
413 prelink_cmds=""
414
415 # Commands necessary for finishing linking programs.
416 postlink_cmds=""
417
418 # Specify filename containing input files.
419 file_list_spec=""
420
421 # How to hardcode a shared library path into an executable.
422 hardcode_action=immediate
423
424 # ### END LIBTOOL CONFIG
425
426
427 # libtool (GNU libtool) 2.4.2
428 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
429
430 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
431 # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
432 # This is free software; see the source for copying conditions. There is NO
433 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
434
435 # GNU Libtool is free software; you can redistribute it and/or modify
436 # it under the terms of the GNU General Public License as published by
437 # the Free Software Foundation; either version 2 of the License, or
438 # (at your option) any later version.
439 #
440 # As a special exception to the GNU General Public License,
441 # if you distribute this file as part of a program or library that
442 # is built using GNU Libtool, you may include this file under the
443 # same distribution terms that you use for the rest of that program.
444 #
445 # GNU Libtool is distributed in the hope that it will be useful, but
446 # WITHOUT ANY WARRANTY; without even the implied warranty of
447 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
448 # General Public License for more details.
449 #
450 # You should have received a copy of the GNU General Public License
451 # along with GNU Libtool; see the file COPYING. If not, a copy
452 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
453 # or obtained by writing to the Free Software Foundation, Inc.,
454 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
455
456 # Usage: $progname [OPTION]... [MODE-ARG]...
457 #
458 # Provide generalized library-building support services.
459 #
460 # --config show all configuration variables
461 # --debug enable verbose shell tracing
462 # -n, --dry-run display commands without modifying any files
463 # --features display basic configuration information and exit
464 # --mode=MODE use operation mode MODE
465 # --preserve-dup-deps don't remove duplicate dependency libraries
466 # --quiet, --silent don't print informational messages
467 # --no-quiet, --no-silent
468 # print informational messages (default)
469 # --no-warn don't display warning messages
470 # --tag=TAG use configuration variables from tag TAG
471 # -v, --verbose print more informational messages than default
472 # --no-verbose don't print the extra informational messages
473 # --version print version information
474 # -h, --help, --help-all print short, long, or detailed help message
475 #
476 # MODE must be one of the following:
477 #
478 # clean remove files from the build directory
479 # compile compile a source file into a libtool object
480 # execute automatically set library path, then run a program
481 # finish complete the installation of libtool libraries
482 # install install libraries or executables
483 # link create a library or an executable
484 # uninstall remove libraries from an installed directory
485 #
486 # MODE-ARGS vary depending on the MODE. When passed as first option,
487 # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
488 # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
489 #
490 # When reporting a bug, please describe a test case to reproduce it and
491 # include the following information:
492 #
493 # host-triplet: $host
494 # shell: $SHELL
495 # compiler: $LTCC
496 # compiler flags: $LTCFLAGS
497 # linker: $LD (gnu? $with_gnu_ld)
498 # $progname: (GNU libtool) 2.4.2
499 # automake: $automake_version
500 # autoconf: $autoconf_version
501 #
502 # Report bugs to <bug-libtool@gnu.org>.
503 # GNU libtool home page: <http://www.gnu.org/software/libtool/>.
504 # General help using GNU software: <http://www.gnu.org/gethelp/>.
505
506 PROGRAM=libtool
507 PACKAGE=libtool
508 VERSION=2.4.2
509 TIMESTAMP=""
510 package_revision=1.3337
511
512 # Be Bourne compatible
513 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
514 emulate sh
515 NULLCMD=:
516 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
517 # is contrary to our usage. Disable this feature.
518 alias -g '${1+"$@"}'='"$@"'
519 setopt NO_GLOB_SUBST
520 else
521 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
522 fi
523 BIN_SH=xpg4; export BIN_SH # for Tru64
524 DUALCASE=1; export DUALCASE # for MKS sh
525
526 # A function that is used when there is no print builtin or printf.
527 func_fallback_echo ()
528 {
529 eval 'cat <<_LTECHO_EOF
530 $1
531 _LTECHO_EOF'
532 }
533
534 # NLS nuisances: We save the old values to restore during execute mode.
535 lt_user_locale=
536 lt_safe_locale=
537 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
538 do
539 eval "if test \"\${$lt_var+set}\" = set; then
540 save_$lt_var=\$$lt_var
541 $lt_var=C
542 export $lt_var
543 lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
544 lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
545 fi"
546 done
547 LC_ALL=C
548 LANGUAGE=C
549 export LANGUAGE LC_ALL
550
551 $lt_unset CDPATH
552
553
554 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
555 # is ksh but when the shell is invoked as "sh" and the current value of
556 # the _XPG environment variable is not equal to 1 (one), the special
557 # positional parameter $0, within a function call, is the name of the
558 # function.
559 progpath="$0"
560
561
562
563 : ${CP="cp -f"}
564 test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
565 : ${MAKE="make"}
566 : ${MKDIR="mkdir"}
567 : ${MV="mv -f"}
568 : ${RM="rm -f"}
569 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
570 : ${Xsed="$SED -e 1s/^X//"}
571
572 # Global variables:
573 EXIT_SUCCESS=0
574 EXIT_FAILURE=1
575 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
576 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
577
578 exit_status=$EXIT_SUCCESS
579
580 # Make sure IFS has a sensible default
581 lt_nl='
582 '
583 IFS=" $lt_nl"
584
585 dirname="s,/[^/]*$,,"
586 basename="s,^.*/,,"
587
588 # func_dirname file append nondir_replacement
589 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
590 # otherwise set result to NONDIR_REPLACEMENT.
591 func_dirname ()
592 {
593 case ${1} in
594 */*) func_dirname_result="${1%/*}${2}" ;;
595 * ) func_dirname_result="${3}" ;;
596 esac
597 } # Extended-shell func_dirname implementation
598
599
600 # func_basename file
601 func_basename ()
602 {
603 func_basename_result="${1##*/}"
604 } # Extended-shell func_basename implementation
605
606
607 # func_dirname_and_basename file append nondir_replacement
608 # perform func_basename and func_dirname in a single function
609 # call:
610 # dirname: Compute the dirname of FILE. If nonempty,
611 # add APPEND to the result, otherwise set result
612 # to NONDIR_REPLACEMENT.
613 # value returned in "$func_dirname_result"
614 # basename: Compute filename of FILE.
615 # value retuned in "$func_basename_result"
616 # Implementation must be kept synchronized with func_dirname
617 # and func_basename. For efficiency, we do not delegate to
618 # those functions but instead duplicate the functionality here.
619 func_dirname_and_basename ()
620 {
621 case ${1} in
622 */*) func_dirname_result="${1%/*}${2}" ;;
623 * ) func_dirname_result="${3}" ;;
624 esac
625 func_basename_result="${1##*/}"
626 } # Extended-shell func_dirname_and_basename implementation
627
628
629 # func_stripname prefix suffix name
630 # strip PREFIX and SUFFIX off of NAME.
631 # PREFIX and SUFFIX must not contain globbing or regex special
632 # characters, hashes, percent signs, but SUFFIX may contain a leading
633 # dot (in which case that matches only a dot).
634 # func_strip_suffix prefix name
635 func_stripname ()
636 {
637 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
638 # positional parameters, so assign one to ordinary parameter first.
639 func_stripname_result=${3}
640 func_stripname_result=${func_stripname_result#"${1}"}
641 func_stripname_result=${func_stripname_result%"${2}"}
642 } # Extended-shell func_stripname implementation
643
644
645 # These SED scripts presuppose an absolute path with a trailing slash.
646 pathcar='s,^/\([^/]*\).*$,\1,'
647 pathcdr='s,^/[^/]*,,'
648 removedotparts=':dotsl
649 s@/\./@/@g
650 t dotsl
651 s,/\.$,/,'
652 collapseslashes='s@/\{1,\}@/@g'
653 finalslash='s,/*$,/,'
654
655 # func_normal_abspath PATH
656 # Remove doubled-up and trailing slashes, "." path components,
657 # and cancel out any ".." path components in PATH after making
658 # it an absolute path.
659 # value returned in "$func_normal_abspath_result"
660 func_normal_abspath ()
661 {
662 # Start from root dir and reassemble the path.
663 func_normal_abspath_result=
664 func_normal_abspath_tpath=$1
665 func_normal_abspath_altnamespace=
666 case $func_normal_abspath_tpath in
667 "")
668 # Empty path, that just means $cwd.
669 func_stripname '' '/' "`pwd`"
670 func_normal_abspath_result=$func_stripname_result
671 return
672 ;;
673 # The next three entries are used to spot a run of precisely
674 # two leading slashes without using negated character classes;
675 # we take advantage of case's first-match behaviour.
676 ///*)
677 # Unusual form of absolute path, do nothing.
678 ;;
679 //*)
680 # Not necessarily an ordinary path; POSIX reserves leading '//'
681 # and for example Cygwin uses it to access remote file shares
682 # over CIFS/SMB, so we conserve a leading double slash if found.
683 func_normal_abspath_altnamespace=/
684 ;;
685 /*)
686 # Absolute path, do nothing.
687 ;;
688 *)
689 # Relative path, prepend $cwd.
690 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
691 ;;
692 esac
693 # Cancel out all the simple stuff to save iterations. We also want
694 # the path to end with a slash for ease of parsing, so make sure
695 # there is one (and only one) here.
696 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
697 -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
698 while :; do
699 # Processed it all yet?
700 if test "$func_normal_abspath_tpath" = / ; then
701 # If we ascended to the root using ".." the result may be empty now.
702 if test -z "$func_normal_abspath_result" ; then
703 func_normal_abspath_result=/
704 fi
705 break
706 fi
707 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
708 -e "$pathcar"`
709 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
710 -e "$pathcdr"`
711 # Figure out what to do with it
712 case $func_normal_abspath_tcomponent in
713 "")
714 # Trailing empty path component, ignore it.
715 ;;
716 ..)
717 # Parent dir; strip last assembled component from result.
718 func_dirname "$func_normal_abspath_result"
719 func_normal_abspath_result=$func_dirname_result
720 ;;
721 *)
722 # Actual path component, append it.
723 func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
724 ;;
725 esac
726 done
727 # Restore leading double-slash if one was found on entry.
728 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
729 }
730
731 # func_relative_path SRCDIR DSTDIR
732 # generates a relative path from SRCDIR to DSTDIR, with a trailing
733 # slash if non-empty, suitable for immediately appending a filename
734 # without needing to append a separator.
735 # value returned in "$func_relative_path_result"
736 func_relative_path ()
737 {
738 func_relative_path_result=
739 func_normal_abspath "$1"
740 func_relative_path_tlibdir=$func_normal_abspath_result
741 func_normal_abspath "$2"
742 func_relative_path_tbindir=$func_normal_abspath_result
743
744 # Ascend the tree starting from libdir
745 while :; do
746 # check if we have found a prefix of bindir
747 case $func_relative_path_tbindir in
748 $func_relative_path_tlibdir)
749 # found an exact match
750 func_relative_path_tcancelled=
751 break
752 ;;
753 $func_relative_path_tlibdir*)
754 # found a matching prefix
755 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
756 func_relative_path_tcancelled=$func_stripname_result
757 if test -z "$func_relative_path_result"; then
758 func_relative_path_result=.
759 fi
760 break
761 ;;
762 *)
763 func_dirname $func_relative_path_tlibdir
764 func_relative_path_tlibdir=${func_dirname_result}
765 if test "x$func_relative_path_tlibdir" = x ; then
766 # Have to descend all the way to the root!
767 func_relative_path_result=../$func_relative_path_result
768 func_relative_path_tcancelled=$func_relative_path_tbindir
769 break
770 fi
771 func_relative_path_result=../$func_relative_path_result
772 ;;
773 esac
774 done
775
776 # Now calculate path; take care to avoid doubling-up slashes.
777 func_stripname '' '/' "$func_relative_path_result"
778 func_relative_path_result=$func_stripname_result
779 func_stripname '/' '/' "$func_relative_path_tcancelled"
780 if test "x$func_stripname_result" != x ; then
781 func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
782 fi
783
784 # Normalisation. If bindir is libdir, return empty string,
785 # else relative path ending with a slash; either way, target
786 # file name can be directly appended.
787 if test ! -z "$func_relative_path_result"; then
788 func_stripname './' '' "$func_relative_path_result/"
789 func_relative_path_result=$func_stripname_result
790 fi
791 }
792
793 # The name of this program:
794 func_dirname_and_basename "$progpath"
795 progname=$func_basename_result
796
797 # Make sure we have an absolute path for reexecution:
798 case $progpath in
799 [\\/]*|[A-Za-z]:\\*) ;;
800 *[\\/]*)
801 progdir=$func_dirname_result
802 progdir=`cd "$progdir" && pwd`
803 progpath="$progdir/$progname"
804 ;;
805 *)
806 save_IFS="$IFS"
807 IFS=${PATH_SEPARATOR-:}
808 for progdir in $PATH; do
809 IFS="$save_IFS"
810 test -x "$progdir/$progname" && break
811 done
812 IFS="$save_IFS"
813 test -n "$progdir" || progdir=`pwd`
814 progpath="$progdir/$progname"
815 ;;
816 esac
817
818 # Sed substitution that helps us do robust quoting. It backslashifies
819 # metacharacters that are still active within double-quoted strings.
820 Xsed="${SED}"' -e 1s/^X//'
821 sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
822
823 # Same as above, but do not quote variable references.
824 double_quote_subst='s/\(["`\\]\)/\\\1/g'
825
826 # Sed substitution that turns a string into a regex matching for the
827 # string literally.
828 sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
829
830 # Sed substitution that converts a w32 file name or path
831 # which contains forward slashes, into one that contains
832 # (escaped) backslashes. A very naive implementation.
833 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
834
835 # Re-`\' parameter expansions in output of double_quote_subst that were
836 # `\'-ed in input to the same. If an odd number of `\' preceded a '$'
837 # in input to double_quote_subst, that '$' was protected from expansion.
838 # Since each input `\' is now two `\'s, look for any number of runs of
839 # four `\'s followed by two `\'s and then a '$'. `\' that '$'.
840 bs='\\'
841 bs2='\\\\'
842 bs4='\\\\\\\\'
843 dollar='\$'
844 sed_double_backslash="\
845 s/$bs4/&\\
846 /g
847 s/^$bs2$dollar/$bs&/
848 s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
849 s/\n//g"
850
851 # Standard options:
852 opt_dry_run=false
853 opt_help=false
854 opt_quiet=false
855 opt_verbose=false
856 opt_warning=:
857
858 # func_echo arg...
859 # Echo program name prefixed message, along with the current mode
860 # name if it has been set yet.
861 func_echo ()
862 {
863 $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
864 }
865
866 # func_verbose arg...
867 # Echo program name prefixed message in verbose mode only.
868 func_verbose ()
869 {
870 $opt_verbose && func_echo ${1+"$@"}
871
872 # A bug in bash halts the script if the last line of a function
873 # fails when set -e is in force, so we need another command to
874 # work around that:
875 :
876 }
877
878 # func_echo_all arg...
879 # Invoke $ECHO with all args, space-separated.
880 func_echo_all ()
881 {
882 $ECHO "$*"
883 }
884
885 # func_error arg...
886 # Echo program name prefixed message to standard error.
887 func_error ()
888 {
889 $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
890 }
891
892 # func_warning arg...
893 # Echo program name prefixed warning message to standard error.
894 func_warning ()
895 {
896 $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
897
898 # bash bug again:
899 :
900 }
901
902 # func_fatal_error arg...
903 # Echo program name prefixed message to standard error, and exit.
904 func_fatal_error ()
905 {
906 func_error ${1+"$@"}
907 exit $EXIT_FAILURE
908 }
909
910 # func_fatal_help arg...
911 # Echo program name prefixed message to standard error, followed by
912 # a help hint, and exit.
913 func_fatal_help ()
914 {
915 func_error ${1+"$@"}
916 func_fatal_error "$help"
917 }
918 help="Try \`$progname --help' for more information." ## default
919
920
921 # func_grep expression filename
922 # Check whether EXPRESSION matches any line of FILENAME, without output.
923 func_grep ()
924 {
925 $GREP "$1" "$2" >/dev/null 2>&1
926 }
927
928
929 # func_mkdir_p directory-path
930 # Make sure the entire path to DIRECTORY-PATH is available.
931 func_mkdir_p ()
932 {
933 my_directory_path="$1"
934 my_dir_list=
935
936 if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
937
938 # Protect directory names starting with `-'
939 case $my_directory_path in
940 -*) my_directory_path="./$my_directory_path" ;;
941 esac
942
943 # While some portion of DIR does not yet exist...
944 while test ! -d "$my_directory_path"; do
945 # ...make a list in topmost first order. Use a colon delimited
946 # list incase some portion of path contains whitespace.
947 my_dir_list="$my_directory_path:$my_dir_list"
948
949 # If the last portion added has no slash in it, the list is done
950 case $my_directory_path in */*) ;; *) break ;; esac
951
952 # ...otherwise throw away the child directory and loop
953 my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
954 done
955 my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
956
957 save_mkdir_p_IFS="$IFS"; IFS=':'
958 for my_dir in $my_dir_list; do
959 IFS="$save_mkdir_p_IFS"
960 # mkdir can fail with a `File exist' error if two processes
961 # try to create one of the directories concurrently. Don't
962 # stop in that case!
963 $MKDIR "$my_dir" 2>/dev/null || :
964 done
965 IFS="$save_mkdir_p_IFS"
966
967 # Bail out if we (or some other process) failed to create a directory.
968 test -d "$my_directory_path" || \
969 func_fatal_error "Failed to create \`$1'"
970 fi
971 }
972
973
974 # func_mktempdir [string]
975 # Make a temporary directory that won't clash with other running
976 # libtool processes, and avoids race conditions if possible. If
977 # given, STRING is the basename for that directory.
978 func_mktempdir ()
979 {
980 my_template="${TMPDIR-/tmp}/${1-$progname}"
981
982 if test "$opt_dry_run" = ":"; then
983 # Return a directory name, but don't create it in dry-run mode
984 my_tmpdir="${my_template}-$$"
985 else
986
987 # If mktemp works, use that first and foremost
988 my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
989
990 if test ! -d "$my_tmpdir"; then
991 # Failing that, at least try and use $RANDOM to avoid a race
992 my_tmpdir="${my_template}-${RANDOM-0}$$"
993
994 save_mktempdir_umask=`umask`
995 umask 0077
996 $MKDIR "$my_tmpdir"
997 umask $save_mktempdir_umask
998 fi
999
1000 # If we're not in dry-run mode, bomb out on failure
1001 test -d "$my_tmpdir" || \
1002 func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
1003 fi
1004
1005 $ECHO "$my_tmpdir"
1006 }
1007
1008
1009 # func_quote_for_eval arg
1010 # Aesthetically quote ARG to be evaled later.
1011 # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
1012 # is double-quoted, suitable for a subsequent eval, whereas
1013 # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
1014 # which are still active within double quotes backslashified.
1015 func_quote_for_eval ()
1016 {
1017 case $1 in
1018 *[\\\`\"\$]*)
1019 func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
1020 *)
1021 func_quote_for_eval_unquoted_result="$1" ;;
1022 esac
1023
1024 case $func_quote_for_eval_unquoted_result in
1025 # Double-quote args containing shell metacharacters to delay
1026 # word splitting, command substitution and and variable
1027 # expansion for a subsequent eval.
1028 # Many Bourne shells cannot handle close brackets correctly
1029 # in scan sets, so we specify it separately.
1030 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1031 func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
1032 ;;
1033 *)
1034 func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
1035 esac
1036 }
1037
1038
1039 # func_quote_for_expand arg
1040 # Aesthetically quote ARG to be evaled later; same as above,
1041 # but do not quote variable references.
1042 func_quote_for_expand ()
1043 {
1044 case $1 in
1045 *[\\\`\"]*)
1046 my_arg=`$ECHO "$1" | $SED \
1047 -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
1048 *)
1049 my_arg="$1" ;;
1050 esac
1051
1052 case $my_arg in
1053 # Double-quote args containing shell metacharacters to delay
1054 # word splitting and command substitution for a subsequent eval.
1055 # Many Bourne shells cannot handle close brackets correctly
1056 # in scan sets, so we specify it separately.
1057 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1058 my_arg="\"$my_arg\""
1059 ;;
1060 esac
1061
1062 func_quote_for_expand_result="$my_arg"
1063 }
1064
1065
1066 # func_show_eval cmd [fail_exp]
1067 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
1068 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1069 # is given, then evaluate it.
1070 func_show_eval ()
1071 {
1072 my_cmd="$1"
1073 my_fail_exp="${2-:}"
1074
1075 ${opt_silent-false} || {
1076 func_quote_for_expand "$my_cmd"
1077 eval "func_echo $func_quote_for_expand_result"
1078 }
1079
1080 if ${opt_dry_run-false}; then :; else
1081 eval "$my_cmd"
1082 my_status=$?
1083 if test "$my_status" -eq 0; then :; else
1084 eval "(exit $my_status); $my_fail_exp"
1085 fi
1086 fi
1087 }
1088
1089
1090 # func_show_eval_locale cmd [fail_exp]
1091 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
1092 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
1093 # is given, then evaluate it. Use the saved locale for evaluation.
1094 func_show_eval_locale ()
1095 {
1096 my_cmd="$1"
1097 my_fail_exp="${2-:}"
1098
1099 ${opt_silent-false} || {
1100 func_quote_for_expand "$my_cmd"
1101 eval "func_echo $func_quote_for_expand_result"
1102 }
1103
1104 if ${opt_dry_run-false}; then :; else
1105 eval "$lt_user_locale
1106 $my_cmd"
1107 my_status=$?
1108 eval "$lt_safe_locale"
1109 if test "$my_status" -eq 0; then :; else
1110 eval "(exit $my_status); $my_fail_exp"
1111 fi
1112 fi
1113 }
1114
1115 # func_tr_sh
1116 # Turn $1 into a string suitable for a shell variable name.
1117 # Result is stored in $func_tr_sh_result. All characters
1118 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
1119 # if $1 begins with a digit, a '_' is prepended as well.
1120 func_tr_sh ()
1121 {
1122 case $1 in
1123 [0-9]* | *[!a-zA-Z0-9_]*)
1124 func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
1125 ;;
1126 * )
1127 func_tr_sh_result=$1
1128 ;;
1129 esac
1130 }
1131
1132
1133 # func_version
1134 # Echo version message to standard output and exit.
1135 func_version ()
1136 {
1137 $opt_debug
1138
1139 $SED -n '/(C)/!b go
1140 :more
1141 /\./!{
1142 N
1143 s/\n# / /
1144 b more
1145 }
1146 :go
1147 /^# '$PROGRAM' (GNU /,/# warranty; / {
1148 s/^# //
1149 s/^# *$//
1150 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
1151 p
1152 }' < "$progpath"
1153 exit $?
1154 }
1155
1156 # func_usage
1157 # Echo short help message to standard output and exit.
1158 func_usage ()
1159 {
1160 $opt_debug
1161
1162 $SED -n '/^# Usage:/,/^# *.*--help/ {
1163 s/^# //
1164 s/^# *$//
1165 s/\$progname/'$progname'/
1166 p
1167 }' < "$progpath"
1168 echo
1169 $ECHO "run \`$progname --help | more' for full usage"
1170 exit $?
1171 }
1172
1173 # func_help [NOEXIT]
1174 # Echo long help message to standard output and exit,
1175 # unless 'noexit' is passed as argument.
1176 func_help ()
1177 {
1178 $opt_debug
1179
1180 $SED -n '/^# Usage:/,/# Report bugs to/ {
1181 :print
1182 s/^# //
1183 s/^# *$//
1184 s*\$progname*'$progname'*
1185 s*\$host*'"$host"'*
1186 s*\$SHELL*'"$SHELL"'*
1187 s*\$LTCC*'"$LTCC"'*
1188 s*\$LTCFLAGS*'"$LTCFLAGS"'*
1189 s*\$LD*'"$LD"'*
1190 s/\$with_gnu_ld/'"$with_gnu_ld"'/
1191 s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
1192 s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
1193 p
1194 d
1195 }
1196 /^# .* home page:/b print
1197 /^# General help using/b print
1198 ' < "$progpath"
1199 ret=$?
1200 if test -z "$1"; then
1201 exit $ret
1202 fi
1203 }
1204
1205 # func_missing_arg argname
1206 # Echo program name prefixed message to standard error and set global
1207 # exit_cmd.
1208 func_missing_arg ()
1209 {
1210 $opt_debug
1211
1212 func_error "missing argument for $1."
1213 exit_cmd=exit
1214 }
1215
1216
1217 # func_split_short_opt shortopt
1218 # Set func_split_short_opt_name and func_split_short_opt_arg shell
1219 # variables after splitting SHORTOPT after the 2nd character.
1220 func_split_short_opt ()
1221 {
1222 func_split_short_opt_arg=${1#??}
1223 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
1224 } # Extended-shell func_split_short_opt implementation
1225
1226
1227 # func_split_long_opt longopt
1228 # Set func_split_long_opt_name and func_split_long_opt_arg shell
1229 # variables after splitting LONGOPT at the `=' sign.
1230 func_split_long_opt ()
1231 {
1232 func_split_long_opt_name=${1%%=*}
1233 func_split_long_opt_arg=${1#*=}
1234 } # Extended-shell func_split_long_opt implementation
1235
1236 exit_cmd=:
1237
1238
1239
1240
1241
1242 magic="%%%MAGIC variable%%%"
1243 magic_exe="%%%MAGIC EXE variable%%%"
1244
1245 # Global variables.
1246 nonopt=
1247 preserve_args=
1248 lo2o="s/\\.lo\$/.${objext}/"
1249 o2lo="s/\\.${objext}\$/.lo/"
1250 extracted_archives=
1251 extracted_serial=0
1252
1253 # If this variable is set in any of the actions, the command in it
1254 # will be execed at the end. This prevents here-documents from being
1255 # left over by shells.
1256 exec_cmd=
1257
1258 # func_append var value
1259 # Append VALUE to the end of shell variable VAR.
1260 func_append ()
1261 {
1262 eval "${1}+=\${2}"
1263 } # Extended-shell func_append implementation
1264
1265 # func_append_quoted var value
1266 # Quote VALUE and append to the end of shell variable VAR, separated
1267 # by a space.
1268 func_append_quoted ()
1269 {
1270 func_quote_for_eval "${2}"
1271 eval "${1}+=\\ \$func_quote_for_eval_result"
1272 } # Extended-shell func_append_quoted implementation
1273
1274
1275 # func_arith arithmetic-term...
1276 func_arith ()
1277 {
1278 func_arith_result=$(( $* ))
1279 } # Extended-shell func_arith implementation
1280
1281
1282 # func_len string
1283 # STRING may not start with a hyphen.
1284 func_len ()
1285 {
1286 func_len_result=${#1}
1287 } # Extended-shell func_len implementation
1288
1289
1290 # func_lo2o object
1291 func_lo2o ()
1292 {
1293 case ${1} in
1294 *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
1295 *) func_lo2o_result=${1} ;;
1296 esac
1297 } # Extended-shell func_lo2o implementation
1298
1299
1300 # func_xform libobj-or-source
1301 func_xform ()
1302 {
1303 func_xform_result=${1%.*}.lo
1304 } # Extended-shell func_xform implementation
1305
1306
1307 # func_fatal_configuration arg...
1308 # Echo program name prefixed message to standard error, followed by
1309 # a configuration failure hint, and exit.
1310 func_fatal_configuration ()
1311 {
1312 func_error ${1+"$@"}
1313 func_error "See the $PACKAGE documentation for more information."
1314 func_fatal_error "Fatal configuration error."
1315 }
1316
1317
1318 # func_config
1319 # Display the configuration for all the tags in this script.
1320 func_config ()
1321 {
1322 re_begincf='^# ### BEGIN LIBTOOL'
1323 re_endcf='^# ### END LIBTOOL'
1324
1325 # Default configuration.
1326 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
1327
1328 # Now print the configurations for the tags.
1329 for tagname in $taglist; do
1330 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
1331 done
1332
1333 exit $?
1334 }
1335
1336 # func_features
1337 # Display the features supported by this script.
1338 func_features ()
1339 {
1340 echo "host: $host"
1341 if test "$build_libtool_libs" = yes; then
1342 echo "enable shared libraries"
1343 else
1344 echo "disable shared libraries"
1345 fi
1346 if test "$build_old_libs" = yes; then
1347 echo "enable static libraries"
1348 else
1349 echo "disable static libraries"
1350 fi
1351
1352 exit $?
1353 }
1354
1355 # func_enable_tag tagname
1356 # Verify that TAGNAME is valid, and either flag an error and exit, or
1357 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
1358 # variable here.
1359 func_enable_tag ()
1360 {
1361 # Global variable:
1362 tagname="$1"
1363
1364 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
1365 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
1366 sed_extractcf="/$re_begincf/,/$re_endcf/p"
1367
1368 # Validate tagname.
1369 case $tagname in
1370 *[!-_A-Za-z0-9,/]*)
1371 func_fatal_error "invalid tag name: $tagname"
1372 ;;
1373 esac
1374
1375 # Don't test for the "default" C tag, as we know it's
1376 # there but not specially marked.
1377 case $tagname in
1378 CC) ;;
1379 *)
1380 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
1381 taglist="$taglist $tagname"
1382
1383 # Evaluate the configuration. Be careful to quote the path
1384 # and the sed script, to avoid splitting on whitespace, but
1385 # also don't use non-portable quotes within backquotes within
1386 # quotes we have to do it in 2 steps:
1387 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
1388 eval "$extractedcf"
1389 else
1390 func_error "ignoring unknown tag $tagname"
1391 fi
1392 ;;
1393 esac
1394 }
1395
1396 # func_check_version_match
1397 # Ensure that we are using m4 macros, and libtool script from the same
1398 # release of libtool.
1399 func_check_version_match ()
1400 {
1401 if test "$package_revision" != "$macro_revision"; then
1402 if test "$VERSION" != "$macro_version"; then
1403 if test -z "$macro_version"; then
1404 cat >&2 <<_LT_EOF
1405 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
1406 $progname: definition of this LT_INIT comes from an older release.
1407 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
1408 $progname: and run autoconf again.
1409 _LT_EOF
1410 else
1411 cat >&2 <<_LT_EOF
1412 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
1413 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
1414 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
1415 $progname: and run autoconf again.
1416 _LT_EOF
1417 fi
1418 else
1419 cat >&2 <<_LT_EOF
1420 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
1421 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
1422 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
1423 $progname: of $PACKAGE $VERSION and run autoconf again.
1424 _LT_EOF
1425 fi
1426
1427 exit $EXIT_MISMATCH
1428 fi
1429 }
1430
1431
1432 # Shorthand for --mode=foo, only valid as the first argument
1433 case $1 in
1434 clean|clea|cle|cl)
1435 shift; set dummy --mode clean ${1+"$@"}; shift
1436 ;;
1437 compile|compil|compi|comp|com|co|c)
1438 shift; set dummy --mode compile ${1+"$@"}; shift
1439 ;;
1440 execute|execut|execu|exec|exe|ex|e)
1441 shift; set dummy --mode execute ${1+"$@"}; shift
1442 ;;
1443 finish|finis|fini|fin|fi|f)
1444 shift; set dummy --mode finish ${1+"$@"}; shift
1445 ;;
1446 install|instal|insta|inst|ins|in|i)
1447 shift; set dummy --mode install ${1+"$@"}; shift
1448 ;;
1449 link|lin|li|l)
1450 shift; set dummy --mode link ${1+"$@"}; shift
1451 ;;
1452 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1453 shift; set dummy --mode uninstall ${1+"$@"}; shift
1454 ;;
1455 esac
1456
1457
1458
1459 # Option defaults:
1460 opt_debug=:
1461 opt_dry_run=false
1462 opt_config=false
1463 opt_preserve_dup_deps=false
1464 opt_features=false
1465 opt_finish=false
1466 opt_help=false
1467 opt_help_all=false
1468 opt_silent=:
1469 opt_warning=:
1470 opt_verbose=:
1471 opt_silent=false
1472 opt_verbose=false
1473
1474
1475 # Parse options once, thoroughly. This comes as soon as possible in the
1476 # script to make things like `--version' happen as quickly as we can.
1477 {
1478 # this just eases exit handling
1479 while test $# -gt 0; do
1480 opt="$1"
1481 shift
1482 case $opt in
1483 --debug|-x) opt_debug='set -x'
1484 func_echo "enabling shell trace mode"
1485 $opt_debug
1486 ;;
1487 --dry-run|--dryrun|-n)
1488 opt_dry_run=:
1489 ;;
1490 --config)
1491 opt_config=:
1492 func_config
1493 ;;
1494 --dlopen|-dlopen)
1495 optarg="$1"
1496 opt_dlopen="${opt_dlopen+$opt_dlopen
1497 }$optarg"
1498 shift
1499 ;;
1500 --preserve-dup-deps)
1501 opt_preserve_dup_deps=:
1502 ;;
1503 --features)
1504 opt_features=:
1505 func_features
1506 ;;
1507 --finish)
1508 opt_finish=:
1509 set dummy --mode finish ${1+"$@"}; shift
1510 ;;
1511 --help)
1512 opt_help=:
1513 ;;
1514 --help-all)
1515 opt_help_all=:
1516 opt_help=': help-all'
1517 ;;
1518 --mode)
1519 test $# = 0 && func_missing_arg $opt && break
1520 optarg="$1"
1521 opt_mode="$optarg"
1522 case $optarg in
1523 # Valid mode arguments:
1524 clean|compile|execute|finish|install|link|relink|uninstall) ;;
1525
1526 # Catch anything else as an error
1527 *) func_error "invalid argument for $opt"
1528 exit_cmd=exit
1529 break
1530 ;;
1531 esac
1532 shift
1533 ;;
1534 --no-silent|--no-quiet)
1535 opt_silent=false
1536 preserve_args+=" $opt"
1537 ;;
1538 --no-warning|--no-warn)
1539 opt_warning=false
1540 preserve_args+=" $opt"
1541 ;;
1542 --no-verbose)
1543 opt_verbose=false
1544 preserve_args+=" $opt"
1545 ;;
1546 --silent|--quiet)
1547 opt_silent=:
1548 preserve_args+=" $opt"
1549 opt_verbose=false
1550 ;;
1551 --verbose|-v)
1552 opt_verbose=:
1553 preserve_args+=" $opt"
1554 opt_silent=false
1555 ;;
1556 --tag)
1557 test $# = 0 && func_missing_arg $opt && break
1558 optarg="$1"
1559 opt_tag="$optarg"
1560 preserve_args+=" $opt $optarg"
1561 func_enable_tag "$optarg"
1562 shift
1563 ;;
1564
1565 -\?|-h) func_usage ;;
1566 --help) func_help ;;
1567 --version) func_version ;;
1568
1569 # Separate optargs to long options:
1570 --*=*)
1571 func_split_long_opt "$opt"
1572 set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1573 shift
1574 ;;
1575
1576 # Separate non-argument short options:
1577 -\?*|-h*|-n*|-v*)
1578 func_split_short_opt "$opt"
1579 set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1580 shift
1581 ;;
1582
1583 --) break ;;
1584 -*) func_fatal_help "unrecognized option \`$opt'" ;;
1585 *) set dummy "$opt" ${1+"$@"}; shift; break ;;
1586 esac
1587 done
1588
1589 # Validate options:
1590
1591 # save first non-option argument
1592 if test "$#" -gt 0; then
1593 nonopt="$opt"
1594 shift
1595 fi
1596
1597 # preserve --debug
1598 test "$opt_debug" = : || preserve_args+=" --debug"
1599
1600 case $host in
1601 *cygwin* | *mingw* | *pw32* | *cegcc*)
1602 # don't eliminate duplications in $postdeps and $predeps
1603 opt_duplicate_compiler_generated_deps=:
1604 ;;
1605 *)
1606 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1607 ;;
1608 esac
1609
1610 $opt_help || {
1611 # Sanity checks first:
1612 func_check_version_match
1613
1614 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1615 func_fatal_configuration "not configured to build any kind of library"
1616 fi
1617
1618 # Darwin sucks
1619 eval std_shrext=\"$shrext_cmds\"
1620
1621 # Only execute mode is allowed to have -dlopen flags.
1622 if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1623 func_error "unrecognized option \`-dlopen'"
1624 $ECHO "$help" 1>&2
1625 exit $EXIT_FAILURE
1626 fi
1627
1628 # Change the help message to a mode-specific one.
1629 generic_help="$help"
1630 help="Try \`$progname --help --mode=$opt_mode' for more information."
1631 }
1632
1633
1634 # Bail if the options were screwed
1635 $exit_cmd $EXIT_FAILURE
1636 }
1637
1638
1639
1640
1641 ## ----------- ##
1642 ## Main. ##
1643 ## ----------- ##
1644
1645 # func_lalib_p file
1646 # True iff FILE is a libtool `.la' library or `.lo' object file.
1647 # This function is only a basic sanity check; it will hardly flush out
1648 # determined imposters.
1649 func_lalib_p ()
1650 {
1651 test -f "$1" &&
1652 $SED -e 4q "$1" 2>/dev/null \
1653 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1654 }
1655
1656 # func_lalib_unsafe_p file
1657 # True iff FILE is a libtool `.la' library or `.lo' object file.
1658 # This function implements the same check as func_lalib_p without
1659 # resorting to external programs. To this end, it redirects stdin and
1660 # closes it afterwards, without saving the original file descriptor.
1661 # As a safety measure, use it only where a negative result would be
1662 # fatal anyway. Works if `file' does not exist.
1663 func_lalib_unsafe_p ()
1664 {
1665 lalib_p=no
1666 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1667 for lalib_p_l in 1 2 3 4
1668 do
1669 read lalib_p_line
1670 case "$lalib_p_line" in
1671 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1672 esac
1673 done
1674 exec 0<&5 5<&-
1675 fi
1676 test "$lalib_p" = yes
1677 }
1678
1679 # func_ltwrapper_script_p file
1680 # True iff FILE is a libtool wrapper script
1681 # This function is only a basic sanity check; it will hardly flush out
1682 # determined imposters.
1683 func_ltwrapper_script_p ()
1684 {
1685 func_lalib_p "$1"
1686 }
1687
1688 # func_ltwrapper_executable_p file
1689 # True iff FILE is a libtool wrapper executable
1690 # This function is only a basic sanity check; it will hardly flush out
1691 # determined imposters.
1692 func_ltwrapper_executable_p ()
1693 {
1694 func_ltwrapper_exec_suffix=
1695 case $1 in
1696 *.exe) ;;
1697 *) func_ltwrapper_exec_suffix=.exe ;;
1698 esac
1699 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1700 }
1701
1702 # func_ltwrapper_scriptname file
1703 # Assumes file is an ltwrapper_executable
1704 # uses $file to determine the appropriate filename for a
1705 # temporary ltwrapper_script.
1706 func_ltwrapper_scriptname ()
1707 {
1708 func_dirname_and_basename "$1" "" "."
1709 func_stripname '' '.exe' "$func_basename_result"
1710 func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1711 }
1712
1713 # func_ltwrapper_p file
1714 # True iff FILE is a libtool wrapper script or wrapper executable
1715 # This function is only a basic sanity check; it will hardly flush out
1716 # determined imposters.
1717 func_ltwrapper_p ()
1718 {
1719 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1720 }
1721
1722
1723 # func_execute_cmds commands fail_cmd
1724 # Execute tilde-delimited COMMANDS.
1725 # If FAIL_CMD is given, eval that upon failure.
1726 # FAIL_CMD may read-access the current command in variable CMD!
1727 func_execute_cmds ()
1728 {
1729 $opt_debug
1730 save_ifs=$IFS; IFS='~'
1731 for cmd in $1; do
1732 IFS=$save_ifs
1733 eval cmd=\"$cmd\"
1734 func_show_eval "$cmd" "${2-:}"
1735 done
1736 IFS=$save_ifs
1737 }
1738
1739
1740 # func_source file
1741 # Source FILE, adding directory component if necessary.
1742 # Note that it is not necessary on cygwin/mingw to append a dot to
1743 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1744 # behavior happens only for exec(3), not for open(2)! Also, sourcing
1745 # `FILE.' does not work on cygwin managed mounts.
1746 func_source ()
1747 {
1748 $opt_debug
1749 case $1 in
1750 */* | *\\*) . "$1" ;;
1751 *) . "./$1" ;;
1752 esac
1753 }
1754
1755
1756 # func_resolve_sysroot PATH
1757 # Replace a leading = in PATH with a sysroot. Store the result into
1758 # func_resolve_sysroot_result
1759 func_resolve_sysroot ()
1760 {
1761 func_resolve_sysroot_result=$1
1762 case $func_resolve_sysroot_result in
1763 =*)
1764 func_stripname '=' '' "$func_resolve_sysroot_result"
1765 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1766 ;;
1767 esac
1768 }
1769
1770 # func_replace_sysroot PATH
1771 # If PATH begins with the sysroot, replace it with = and
1772 # store the result into func_replace_sysroot_result.
1773 func_replace_sysroot ()
1774 {
1775 case "$lt_sysroot:$1" in
1776 ?*:"$lt_sysroot"*)
1777 func_stripname "$lt_sysroot" '' "$1"
1778 func_replace_sysroot_result="=$func_stripname_result"
1779 ;;
1780 *)
1781 # Including no sysroot.
1782 func_replace_sysroot_result=$1
1783 ;;
1784 esac
1785 }
1786
1787 # func_infer_tag arg
1788 # Infer tagged configuration to use if any are available and
1789 # if one wasn't chosen via the "--tag" command line option.
1790 # Only attempt this if the compiler in the base compile
1791 # command doesn't match the default compiler.
1792 # arg is usually of the form 'gcc ...'
1793 func_infer_tag ()
1794 {
1795 $opt_debug
1796 if test -n "$available_tags" && test -z "$tagname"; then
1797 CC_quoted=
1798 for arg in $CC; do
1799 func_append_quoted CC_quoted "$arg"
1800 done
1801 CC_expanded=`func_echo_all $CC`
1802 CC_quoted_expanded=`func_echo_all $CC_quoted`
1803 case $@ in
1804 # Blanks in the command may have been stripped by the calling shell,
1805 # but not from the CC environment variable when configure was run.
1806 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1807 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1808 # Blanks at the start of $base_compile will cause this to fail
1809 # if we don't check for them as well.
1810 *)
1811 for z in $available_tags; do
1812 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1813 # Evaluate the configuration.
1814 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1815 CC_quoted=
1816 for arg in $CC; do
1817 # Double-quote args containing other shell metacharacters.
1818 func_append_quoted CC_quoted "$arg"
1819 done
1820 CC_expanded=`func_echo_all $CC`
1821 CC_quoted_expanded=`func_echo_all $CC_quoted`
1822 case "$@ " in
1823 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1824 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1825 # The compiler in the base compile command matches
1826 # the one in the tagged configuration.
1827 # Assume this is the tagged configuration we want.
1828 tagname=$z
1829 break
1830 ;;
1831 esac
1832 fi
1833 done
1834 # If $tagname still isn't set, then no tagged configuration
1835 # was found and let the user know that the "--tag" command
1836 # line option must be used.
1837 if test -z "$tagname"; then
1838 func_echo "unable to infer tagged configuration"
1839 func_fatal_error "specify a tag with \`--tag'"
1840 # else
1841 # func_verbose "using $tagname tagged configuration"
1842 fi
1843 ;;
1844 esac
1845 fi
1846 }
1847
1848
1849
1850 # func_write_libtool_object output_name pic_name nonpic_name
1851 # Create a libtool object file (analogous to a ".la" file),
1852 # but don't create it if we're doing a dry run.
1853 func_write_libtool_object ()
1854 {
1855 write_libobj=${1}
1856 if test "$build_libtool_libs" = yes; then
1857 write_lobj=\'${2}\'
1858 else
1859 write_lobj=none
1860 fi
1861
1862 if test "$build_old_libs" = yes; then
1863 write_oldobj=\'${3}\'
1864 else
1865 write_oldobj=none
1866 fi
1867
1868 $opt_dry_run || {
1869 cat >${write_libobj}T <<EOF
1870 # $write_libobj - a libtool object file
1871 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1872 #
1873 # Please DO NOT delete this file!
1874 # It is necessary for linking the library.
1875
1876 # Name of the PIC object.
1877 pic_object=$write_lobj
1878
1879 # Name of the non-PIC object
1880 non_pic_object=$write_oldobj
1881
1882 EOF
1883 $MV "${write_libobj}T" "${write_libobj}"
1884 }
1885 }
1886
1887
1888 ##################################################
1889 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1890 ##################################################
1891
1892 # func_convert_core_file_wine_to_w32 ARG
1893 # Helper function used by file name conversion functions when $build is *nix,
1894 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
1895 # correctly configured wine environment available, with the winepath program
1896 # in $build's $PATH.
1897 #
1898 # ARG is the $build file name to be converted to w32 format.
1899 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
1900 # be empty on error (or when ARG is empty)
1901 func_convert_core_file_wine_to_w32 ()
1902 {
1903 $opt_debug
1904 func_convert_core_file_wine_to_w32_result="$1"
1905 if test -n "$1"; then
1906 # Unfortunately, winepath does not exit with a non-zero error code, so we
1907 # are forced to check the contents of stdout. On the other hand, if the
1908 # command is not found, the shell will set an exit code of 127 and print
1909 # *an error message* to stdout. So we must check for both error code of
1910 # zero AND non-empty stdout, which explains the odd construction:
1911 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1912 if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1913 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1914 $SED -e "$lt_sed_naive_backslashify"`
1915 else
1916 func_convert_core_file_wine_to_w32_result=
1917 fi
1918 fi
1919 }
1920 # end: func_convert_core_file_wine_to_w32
1921
1922
1923 # func_convert_core_path_wine_to_w32 ARG
1924 # Helper function used by path conversion functions when $build is *nix, and
1925 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1926 # configured wine environment available, with the winepath program in $build's
1927 # $PATH. Assumes ARG has no leading or trailing path separator characters.
1928 #
1929 # ARG is path to be converted from $build format to win32.
1930 # Result is available in $func_convert_core_path_wine_to_w32_result.
1931 # Unconvertible file (directory) names in ARG are skipped; if no directory names
1932 # are convertible, then the result may be empty.
1933 func_convert_core_path_wine_to_w32 ()
1934 {
1935 $opt_debug
1936 # unfortunately, winepath doesn't convert paths, only file names
1937 func_convert_core_path_wine_to_w32_result=""
1938 if test -n "$1"; then
1939 oldIFS=$IFS
1940 IFS=:
1941 for func_convert_core_path_wine_to_w32_f in $1; do
1942 IFS=$oldIFS
1943 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1944 if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1945 if test -z "$func_convert_core_path_wine_to_w32_result"; then
1946 func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1947 else
1948 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1949 fi
1950 fi
1951 done
1952 IFS=$oldIFS
1953 fi
1954 }
1955 # end: func_convert_core_path_wine_to_w32
1956
1957
1958 # func_cygpath ARGS...
1959 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1960 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1961 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1962 # (2), returns the Cygwin file name or path in func_cygpath_result (input
1963 # file name or path is assumed to be in w32 format, as previously converted
1964 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
1965 # or path in func_cygpath_result (input file name or path is assumed to be in
1966 # Cygwin format). Returns an empty string on error.
1967 #
1968 # ARGS are passed to cygpath, with the last one being the file name or path to
1969 # be converted.
1970 #
1971 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1972 # environment variable; do not put it in $PATH.
1973 func_cygpath ()
1974 {
1975 $opt_debug
1976 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1977 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1978 if test "$?" -ne 0; then
1979 # on failure, ensure result is empty
1980 func_cygpath_result=
1981 fi
1982 else
1983 func_cygpath_result=
1984 func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1985 fi
1986 }
1987 #end: func_cygpath
1988
1989
1990 # func_convert_core_msys_to_w32 ARG
1991 # Convert file name or path ARG from MSYS format to w32 format. Return
1992 # result in func_convert_core_msys_to_w32_result.
1993 func_convert_core_msys_to_w32 ()
1994 {
1995 $opt_debug
1996 # awkward: cmd appends spaces to result
1997 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1998 $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1999 }
2000 #end: func_convert_core_msys_to_w32
2001
2002
2003 # func_convert_file_check ARG1 ARG2
2004 # Verify that ARG1 (a file name in $build format) was converted to $host
2005 # format in ARG2. Otherwise, emit an error message, but continue (resetting
2006 # func_to_host_file_result to ARG1).
2007 func_convert_file_check ()
2008 {
2009 $opt_debug
2010 if test -z "$2" && test -n "$1" ; then
2011 func_error "Could not determine host file name corresponding to"
2012 func_error " \`$1'"
2013 func_error "Continuing, but uninstalled executables may not work."
2014 # Fallback:
2015 func_to_host_file_result="$1"
2016 fi
2017 }
2018 # end func_convert_file_check
2019
2020
2021 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
2022 # Verify that FROM_PATH (a path in $build format) was converted to $host
2023 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
2024 # func_to_host_file_result to a simplistic fallback value (see below).
2025 func_convert_path_check ()
2026 {
2027 $opt_debug
2028 if test -z "$4" && test -n "$3"; then
2029 func_error "Could not determine the host path corresponding to"
2030 func_error " \`$3'"
2031 func_error "Continuing, but uninstalled executables may not work."
2032 # Fallback. This is a deliberately simplistic "conversion" and
2033 # should not be "improved". See libtool.info.
2034 if test "x$1" != "x$2"; then
2035 lt_replace_pathsep_chars="s|$1|$2|g"
2036 func_to_host_path_result=`echo "$3" |
2037 $SED -e "$lt_replace_pathsep_chars"`
2038 else
2039 func_to_host_path_result="$3"
2040 fi
2041 fi
2042 }
2043 # end func_convert_path_check
2044
2045
2046 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
2047 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
2048 # and appending REPL if ORIG matches BACKPAT.
2049 func_convert_path_front_back_pathsep ()
2050 {
2051 $opt_debug
2052 case $4 in
2053 $1 ) func_to_host_path_result="$3$func_to_host_path_result"
2054 ;;
2055 esac
2056 case $4 in
2057 $2 ) func_to_host_path_result+="$3"
2058 ;;
2059 esac
2060 }
2061 # end func_convert_path_front_back_pathsep
2062
2063
2064 ##################################################
2065 # $build to $host FILE NAME CONVERSION FUNCTIONS #
2066 ##################################################
2067 # invoked via `$to_host_file_cmd ARG'
2068 #
2069 # In each case, ARG is the path to be converted from $build to $host format.
2070 # Result will be available in $func_to_host_file_result.
2071
2072
2073 # func_to_host_file ARG
2074 # Converts the file name ARG from $build format to $host format. Return result
2075 # in func_to_host_file_result.
2076 func_to_host_file ()
2077 {
2078 $opt_debug
2079 $to_host_file_cmd "$1"
2080 }
2081 # end func_to_host_file
2082
2083
2084 # func_to_tool_file ARG LAZY
2085 # converts the file name ARG from $build format to toolchain format. Return
2086 # result in func_to_tool_file_result. If the conversion in use is listed
2087 # in (the comma separated) LAZY, no conversion takes place.
2088 func_to_tool_file ()
2089 {
2090 $opt_debug
2091 case ,$2, in
2092 *,"$to_tool_file_cmd",*)
2093 func_to_tool_file_result=$1
2094 ;;
2095 *)
2096 $to_tool_file_cmd "$1"
2097 func_to_tool_file_result=$func_to_host_file_result
2098 ;;
2099 esac
2100 }
2101 # end func_to_tool_file
2102
2103
2104 # func_convert_file_noop ARG
2105 # Copy ARG to func_to_host_file_result.
2106 func_convert_file_noop ()
2107 {
2108 func_to_host_file_result="$1"
2109 }
2110 # end func_convert_file_noop
2111
2112
2113 # func_convert_file_msys_to_w32 ARG
2114 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
2115 # conversion to w32 is not available inside the cwrapper. Returns result in
2116 # func_to_host_file_result.
2117 func_convert_file_msys_to_w32 ()
2118 {
2119 $opt_debug
2120 func_to_host_file_result="$1"
2121 if test -n "$1"; then
2122 func_convert_core_msys_to_w32 "$1"
2123 func_to_host_file_result="$func_convert_core_msys_to_w32_result"
2124 fi
2125 func_convert_file_check "$1" "$func_to_host_file_result"
2126 }
2127 # end func_convert_file_msys_to_w32
2128
2129
2130 # func_convert_file_cygwin_to_w32 ARG
2131 # Convert file name ARG from Cygwin to w32 format. Returns result in
2132 # func_to_host_file_result.
2133 func_convert_file_cygwin_to_w32 ()
2134 {
2135 $opt_debug
2136 func_to_host_file_result="$1"
2137 if test -n "$1"; then
2138 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
2139 # LT_CYGPATH in this case.
2140 func_to_host_file_result=`cygpath -m "$1"`
2141 fi
2142 func_convert_file_check "$1" "$func_to_host_file_result"
2143 }
2144 # end func_convert_file_cygwin_to_w32
2145
2146
2147 # func_convert_file_nix_to_w32 ARG
2148 # Convert file name ARG from *nix to w32 format. Requires a wine environment
2149 # and a working winepath. Returns result in func_to_host_file_result.
2150 func_convert_file_nix_to_w32 ()
2151 {
2152 $opt_debug
2153 func_to_host_file_result="$1"
2154 if test -n "$1"; then
2155 func_convert_core_file_wine_to_w32 "$1"
2156 func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
2157 fi
2158 func_convert_file_check "$1" "$func_to_host_file_result"
2159 }
2160 # end func_convert_file_nix_to_w32
2161
2162
2163 # func_convert_file_msys_to_cygwin ARG
2164 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
2165 # Returns result in func_to_host_file_result.
2166 func_convert_file_msys_to_cygwin ()
2167 {
2168 $opt_debug
2169 func_to_host_file_result="$1"
2170 if test -n "$1"; then
2171 func_convert_core_msys_to_w32 "$1"
2172 func_cygpath -u "$func_convert_core_msys_to_w32_result"
2173 func_to_host_file_result="$func_cygpath_result"
2174 fi
2175 func_convert_file_check "$1" "$func_to_host_file_result"
2176 }
2177 # end func_convert_file_msys_to_cygwin
2178
2179
2180 # func_convert_file_nix_to_cygwin ARG
2181 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
2182 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
2183 # in func_to_host_file_result.
2184 func_convert_file_nix_to_cygwin ()
2185 {
2186 $opt_debug
2187 func_to_host_file_result="$1"
2188 if test -n "$1"; then
2189 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
2190 func_convert_core_file_wine_to_w32 "$1"
2191 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
2192 func_to_host_file_result="$func_cygpath_result"
2193 fi
2194 func_convert_file_check "$1" "$func_to_host_file_result"
2195 }
2196 # end func_convert_file_nix_to_cygwin
2197
2198
2199 #############################################
2200 # $build to $host PATH CONVERSION FUNCTIONS #
2201 #############################################
2202 # invoked via `$to_host_path_cmd ARG'
2203 #
2204 # In each case, ARG is the path to be converted from $build to $host format.
2205 # The result will be available in $func_to_host_path_result.
2206 #
2207 # Path separators are also converted from $build format to $host format. If
2208 # ARG begins or ends with a path separator character, it is preserved (but
2209 # converted to $host format) on output.
2210 #
2211 # All path conversion functions are named using the following convention:
2212 # file name conversion function : func_convert_file_X_to_Y ()
2213 # path conversion function : func_convert_path_X_to_Y ()
2214 # where, for any given $build/$host combination the 'X_to_Y' value is the
2215 # same. If conversion functions are added for new $build/$host combinations,
2216 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
2217 # will break.
2218
2219
2220 # func_init_to_host_path_cmd
2221 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
2222 # appropriate value, based on the value of $to_host_file_cmd.
2223 to_host_path_cmd=
2224 func_init_to_host_path_cmd ()
2225 {
2226 $opt_debug
2227 if test -z "$to_host_path_cmd"; then
2228 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
2229 to_host_path_cmd="func_convert_path_${func_stripname_result}"
2230 fi
2231 }
2232
2233
2234 # func_to_host_path ARG
2235 # Converts the path ARG from $build format to $host format. Return result
2236 # in func_to_host_path_result.
2237 func_to_host_path ()
2238 {
2239 $opt_debug
2240 func_init_to_host_path_cmd
2241 $to_host_path_cmd "$1"
2242 }
2243 # end func_to_host_path
2244
2245
2246 # func_convert_path_noop ARG
2247 # Copy ARG to func_to_host_path_result.
2248 func_convert_path_noop ()
2249 {
2250 func_to_host_path_result="$1"
2251 }
2252 # end func_convert_path_noop
2253
2254
2255 # func_convert_path_msys_to_w32 ARG
2256 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
2257 # conversion to w32 is not available inside the cwrapper. Returns result in
2258 # func_to_host_path_result.
2259 func_convert_path_msys_to_w32 ()
2260 {
2261 $opt_debug
2262 func_to_host_path_result="$1"
2263 if test -n "$1"; then
2264 # Remove leading and trailing path separator characters from ARG. MSYS
2265 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
2266 # and winepath ignores them completely.
2267 func_stripname : : "$1"
2268 func_to_host_path_tmp1=$func_stripname_result
2269 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
2270 func_to_host_path_result="$func_convert_core_msys_to_w32_result"
2271 func_convert_path_check : ";" \
2272 "$func_to_host_path_tmp1" "$func_to_host_path_result"
2273 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
2274 fi
2275 }
2276 # end func_convert_path_msys_to_w32
2277
2278
2279 # func_convert_path_cygwin_to_w32 ARG
2280 # Convert path ARG from Cygwin to w32 format. Returns result in
2281 # func_to_host_file_result.
2282 func_convert_path_cygwin_to_w32 ()
2283 {
2284 $opt_debug
2285 func_to_host_path_result="$1"
2286 if test -n "$1"; then
2287 # See func_convert_path_msys_to_w32:
2288 func_stripname : : "$1"
2289 func_to_host_path_tmp1=$func_stripname_result
2290 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
2291 func_convert_path_check : ";" \
2292 "$func_to_host_path_tmp1" "$func_to_host_path_result"
2293 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
2294 fi
2295 }
2296 # end func_convert_path_cygwin_to_w32
2297
2298
2299 # func_convert_path_nix_to_w32 ARG
2300 # Convert path ARG from *nix to w32 format. Requires a wine environment and
2301 # a working winepath. Returns result in func_to_host_file_result.
2302 func_convert_path_nix_to_w32 ()
2303 {
2304 $opt_debug
2305 func_to_host_path_result="$1"
2306 if test -n "$1"; then
2307 # See func_convert_path_msys_to_w32:
2308 func_stripname : : "$1"
2309 func_to_host_path_tmp1=$func_stripname_result
2310 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
2311 func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
2312 func_convert_path_check : ";" \
2313 "$func_to_host_path_tmp1" "$func_to_host_path_result"
2314 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
2315 fi
2316 }
2317 # end func_convert_path_nix_to_w32
2318
2319
2320 # func_convert_path_msys_to_cygwin ARG
2321 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
2322 # Returns result in func_to_host_file_result.
2323 func_convert_path_msys_to_cygwin ()
2324 {
2325 $opt_debug
2326 func_to_host_path_result="$1"
2327 if test -n "$1"; then
2328 # See func_convert_path_msys_to_w32:
2329 func_stripname : : "$1"
2330 func_to_host_path_tmp1=$func_stripname_result
2331 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
2332 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
2333 func_to_host_path_result="$func_cygpath_result"
2334 func_convert_path_check : : \
2335 "$func_to_host_path_tmp1" "$func_to_host_path_result"
2336 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
2337 fi
2338 }
2339 # end func_convert_path_msys_to_cygwin
2340
2341
2342 # func_convert_path_nix_to_cygwin ARG
2343 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
2344 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
2345 # func_to_host_file_result.
2346 func_convert_path_nix_to_cygwin ()
2347 {
2348 $opt_debug
2349 func_to_host_path_result="$1"
2350 if test -n "$1"; then
2351 # Remove leading and trailing path separator characters from
2352 # ARG. msys behavior is inconsistent here, cygpath turns them
2353 # into '.;' and ';.', and winepath ignores them completely.
2354 func_stripname : : "$1"
2355 func_to_host_path_tmp1=$func_stripname_result
2356 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
2357 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
2358 func_to_host_path_result="$func_cygpath_result"
2359 func_convert_path_check : : \
2360 "$func_to_host_path_tmp1" "$func_to_host_path_result"
2361 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
2362 fi
2363 }
2364 # end func_convert_path_nix_to_cygwin
2365
2366
2367 # func_mode_compile arg...
2368 func_mode_compile ()
2369 {
2370 $opt_debug
2371 # Get the compilation command and the source file.
2372 base_compile=
2373 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
2374 suppress_opt=yes
2375 suppress_output=
2376 arg_mode=normal
2377 libobj=
2378 later=
2379 pie_flag=
2380
2381 for arg
2382 do
2383 case $arg_mode in
2384 arg )
2385 # do not "continue". Instead, add this to base_compile
2386 lastarg="$arg"
2387 arg_mode=normal
2388 ;;
2389
2390 target )
2391 libobj="$arg"
2392 arg_mode=normal
2393 continue
2394 ;;
2395
2396 normal )
2397 # Accept any command-line options.
2398 case $arg in
2399 -o)
2400 test -n "$libobj" && \
2401 func_fatal_error "you cannot specify \`-o' more than once"
2402 arg_mode=target
2403 continue
2404 ;;
2405
2406 -pie | -fpie | -fPIE)
2407 pie_flag+=" $arg"
2408 continue
2409 ;;
2410
2411 -shared | -static | -prefer-pic | -prefer-non-pic)
2412 later+=" $arg"
2413 continue
2414 ;;
2415
2416 -no-suppress)
2417 suppress_opt=no
2418 continue
2419 ;;
2420
2421 -Xcompiler)
2422 arg_mode=arg # the next one goes into the "base_compile" arg list
2423 continue # The current "srcfile" will either be retained or
2424 ;; # replaced later. I would guess that would be a bug.
2425
2426 -Wc,*)
2427 func_stripname '-Wc,' '' "$arg"
2428 args=$func_stripname_result
2429 lastarg=
2430 save_ifs="$IFS"; IFS=','
2431 for arg in $args; do
2432 IFS="$save_ifs"
2433 func_append_quoted lastarg "$arg"
2434 done
2435 IFS="$save_ifs"
2436 func_stripname ' ' '' "$lastarg"
2437 lastarg=$func_stripname_result
2438
2439 # Add the arguments to base_compile.
2440 base_compile+=" $lastarg"
2441 continue
2442 ;;
2443
2444 *)
2445 # Accept the current argument as the source file.
2446 # The previous "srcfile" becomes the current argument.
2447 #
2448 lastarg="$srcfile"
2449 srcfile="$arg"
2450 ;;
2451 esac # case $arg
2452 ;;
2453 esac # case $arg_mode
2454
2455 # Aesthetically quote the previous argument.
2456 func_append_quoted base_compile "$lastarg"
2457 done # for arg
2458
2459 case $arg_mode in
2460 arg)
2461 func_fatal_error "you must specify an argument for -Xcompile"
2462 ;;
2463 target)
2464 func_fatal_error "you must specify a target with \`-o'"
2465 ;;
2466 *)
2467 # Get the name of the library object.
2468 test -z "$libobj" && {
2469 func_basename "$srcfile"
2470 libobj="$func_basename_result"
2471 }
2472 ;;
2473 esac
2474
2475 # Recognize several different file suffixes.
2476 # If the user specifies -o file.o, it is replaced with file.lo
2477 case $libobj in
2478 *.[cCFSifmso] | \
2479 *.ada | *.adb | *.ads | *.asm | \
2480 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2481 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2482 func_xform "$libobj"
2483 libobj=$func_xform_result
2484 ;;
2485 esac
2486
2487 case $libobj in
2488 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2489 *)
2490 func_fatal_error "cannot determine name of library object from \`$libobj'"
2491 ;;
2492 esac
2493
2494 func_infer_tag $base_compile
2495
2496 for arg in $later; do
2497 case $arg in
2498 -shared)
2499 test "$build_libtool_libs" != yes && \
2500 func_fatal_configuration "can not build a shared library"
2501 build_old_libs=no
2502 continue
2503 ;;
2504
2505 -static)
2506 build_libtool_libs=no
2507 build_old_libs=yes
2508 continue
2509 ;;
2510
2511 -prefer-pic)
2512 pic_mode=yes
2513 continue
2514 ;;
2515
2516 -prefer-non-pic)
2517 pic_mode=no
2518 continue
2519 ;;
2520 esac
2521 done
2522
2523 func_quote_for_eval "$libobj"
2524 test "X$libobj" != "X$func_quote_for_eval_result" \
2525 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
2526 && func_warning "libobj name \`$libobj' may not contain shell special characters."
2527 func_dirname_and_basename "$obj" "/" ""
2528 objname="$func_basename_result"
2529 xdir="$func_dirname_result"
2530 lobj=${xdir}$objdir/$objname
2531
2532 test -z "$base_compile" && \
2533 func_fatal_help "you must specify a compilation command"
2534
2535 # Delete any leftover library objects.
2536 if test "$build_old_libs" = yes; then
2537 removelist="$obj $lobj $libobj ${libobj}T"
2538 else
2539 removelist="$lobj $libobj ${libobj}T"
2540 fi
2541
2542 # On Cygwin there's no "real" PIC flag so we must build both object types
2543 case $host_os in
2544 cygwin* | mingw* | pw32* | os2* | cegcc*)
2545 pic_mode=default
2546 ;;
2547 esac
2548 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2549 # non-PIC code in shared libraries is not supported
2550 pic_mode=default
2551 fi
2552
2553 # Calculate the filename of the output object if compiler does
2554 # not support -o with -c
2555 if test "$compiler_c_o" = no; then
2556 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2557 lockfile="$output_obj.lock"
2558 else
2559 output_obj=
2560 need_locks=no
2561 lockfile=
2562 fi
2563
2564 # Lock this critical section if it is needed
2565 # We use this script file to make the link, it avoids creating a new file
2566 if test "$need_locks" = yes; then
2567 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2568 func_echo "Waiting for $lockfile to be removed"
2569 sleep 2
2570 done
2571 elif test "$need_locks" = warn; then
2572 if test -f "$lockfile"; then
2573 $ECHO "\
2574 *** ERROR, $lockfile exists and contains:
2575 `cat $lockfile 2>/dev/null`
2576
2577 This indicates that another process is trying to use the same
2578 temporary object file, and libtool could not work around it because
2579 your compiler does not support \`-c' and \`-o' together. If you
2580 repeat this compilation, it may succeed, by chance, but you had better
2581 avoid parallel builds (make -j) in this platform, or get a better
2582 compiler."
2583
2584 $opt_dry_run || $RM $removelist
2585 exit $EXIT_FAILURE
2586 fi
2587 removelist+=" $output_obj"
2588 $ECHO "$srcfile" > "$lockfile"
2589 fi
2590
2591 $opt_dry_run || $RM $removelist
2592 removelist+=" $lockfile"
2593 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2594
2595 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2596 srcfile=$func_to_tool_file_result
2597 func_quote_for_eval "$srcfile"
2598 qsrcfile=$func_quote_for_eval_result
2599
2600 # Only build a PIC object if we are building libtool libraries.
2601 if test "$build_libtool_libs" = yes; then
2602 # Without this assignment, base_compile gets emptied.
2603 fbsd_hideous_sh_bug=$base_compile
2604
2605 if test "$pic_mode" != no; then
2606 command="$base_compile $qsrcfile $pic_flag"
2607 else
2608 # Don't build PIC code
2609 command="$base_compile $qsrcfile"
2610 fi
2611
2612 func_mkdir_p "$xdir$objdir"
2613
2614 if test -z "$output_obj"; then
2615 # Place PIC objects in $objdir
2616 command+=" -o $lobj"
2617 fi
2618
2619 func_show_eval_locale "$command" \
2620 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2621
2622 if test "$need_locks" = warn &&
2623 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2624 $ECHO "\
2625 *** ERROR, $lockfile contains:
2626 `cat $lockfile 2>/dev/null`
2627
2628 but it should contain:
2629 $srcfile
2630
2631 This indicates that another process is trying to use the same
2632 temporary object file, and libtool could not work around it because
2633 your compiler does not support \`-c' and \`-o' together. If you
2634 repeat this compilation, it may succeed, by chance, but you had better
2635 avoid parallel builds (make -j) in this platform, or get a better
2636 compiler."
2637
2638 $opt_dry_run || $RM $removelist
2639 exit $EXIT_FAILURE
2640 fi
2641
2642 # Just move the object if needed, then go on to compile the next one
2643 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2644 func_show_eval '$MV "$output_obj" "$lobj"' \
2645 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2646 fi
2647
2648 # Allow error messages only from the first compilation.
2649 if test "$suppress_opt" = yes; then
2650 suppress_output=' >/dev/null 2>&1'
2651 fi
2652 fi
2653
2654 # Only build a position-dependent object if we build old libraries.
2655 if test "$build_old_libs" = yes; then
2656 if test "$pic_mode" != yes; then
2657 # Don't build PIC code
2658 command="$base_compile $qsrcfile$pie_flag"
2659 else
2660 command="$base_compile $qsrcfile $pic_flag"
2661 fi
2662 if test "$compiler_c_o" = yes; then
2663 command+=" -o $obj"
2664 fi
2665
2666 # Suppress compiler output if we already did a PIC compilation.
2667 command+="$suppress_output"
2668 func_show_eval_locale "$command" \
2669 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2670
2671 if test "$need_locks" = warn &&
2672 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2673 $ECHO "\
2674 *** ERROR, $lockfile contains:
2675 `cat $lockfile 2>/dev/null`
2676
2677 but it should contain:
2678 $srcfile
2679
2680 This indicates that another process is trying to use the same
2681 temporary object file, and libtool could not work around it because
2682 your compiler does not support \`-c' and \`-o' together. If you
2683 repeat this compilation, it may succeed, by chance, but you had better
2684 avoid parallel builds (make -j) in this platform, or get a better
2685 compiler."
2686
2687 $opt_dry_run || $RM $removelist
2688 exit $EXIT_FAILURE
2689 fi
2690
2691 # Just move the object if needed
2692 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2693 func_show_eval '$MV "$output_obj" "$obj"' \
2694 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2695 fi
2696 fi
2697
2698 $opt_dry_run || {
2699 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2700
2701 # Unlock the critical section if it was locked
2702 if test "$need_locks" != no; then
2703 removelist=$lockfile
2704 $RM "$lockfile"
2705 fi
2706 }
2707
2708 exit $EXIT_SUCCESS
2709 }
2710
2711 $opt_help || {
2712 test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2713 }
2714
2715 func_mode_help ()
2716 {
2717 # We need to display help for each of the modes.
2718 case $opt_mode in
2719 "")
2720 # Generic help is extracted from the usage comments
2721 # at the start of this file.
2722 func_help
2723 ;;
2724
2725 clean)
2726 $ECHO \
2727 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2728
2729 Remove files from the build directory.
2730
2731 RM is the name of the program to use to delete files associated with each FILE
2732 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
2733 to RM.
2734
2735 If FILE is a libtool library, object or program, all the files associated
2736 with it are deleted. Otherwise, only FILE itself is deleted using RM."
2737 ;;
2738
2739 compile)
2740 $ECHO \
2741 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2742
2743 Compile a source file into a libtool library object.
2744
2745 This mode accepts the following additional options:
2746
2747 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
2748 -no-suppress do not suppress compiler output for multiple passes
2749 -prefer-pic try to build PIC objects only
2750 -prefer-non-pic try to build non-PIC objects only
2751 -shared do not build a \`.o' file suitable for static linking
2752 -static only build a \`.o' file suitable for static linking
2753 -Wc,FLAG pass FLAG directly to the compiler
2754
2755 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
2756 from the given SOURCEFILE.
2757
2758 The output file name is determined by removing the directory component from
2759 SOURCEFILE, then substituting the C source code suffix \`.c' with the
2760 library object suffix, \`.lo'."
2761 ;;
2762
2763 execute)
2764 $ECHO \
2765 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2766
2767 Automatically set library path, then run a program.
2768
2769 This mode accepts the following additional options:
2770
2771 -dlopen FILE add the directory containing FILE to the library path
2772
2773 This mode sets the library path environment variable according to \`-dlopen'
2774 flags.
2775
2776 If any of the ARGS are libtool executable wrappers, then they are translated
2777 into their corresponding uninstalled binary, and any of their required library
2778 directories are added to the library path.
2779
2780 Then, COMMAND is executed, with ARGS as arguments."
2781 ;;
2782
2783 finish)
2784 $ECHO \
2785 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2786
2787 Complete the installation of libtool libraries.
2788
2789 Each LIBDIR is a directory that contains libtool libraries.
2790
2791 The commands that this mode executes may require superuser privileges. Use
2792 the \`--dry-run' option if you just want to see what would be executed."
2793 ;;
2794
2795 install)
2796 $ECHO \
2797 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2798
2799 Install executables or libraries.
2800
2801 INSTALL-COMMAND is the installation command. The first component should be
2802 either the \`install' or \`cp' program.
2803
2804 The following components of INSTALL-COMMAND are treated specially:
2805
2806 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
2807
2808 The rest of the components are interpreted as arguments to that command (only
2809 BSD-compatible install options are recognized)."
2810 ;;
2811
2812 link)
2813 $ECHO \
2814 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2815
2816 Link object files or libraries together to form another library, or to
2817 create an executable program.
2818
2819 LINK-COMMAND is a command using the C compiler that you would use to create
2820 a program from several object files.
2821
2822 The following components of LINK-COMMAND are treated specially:
2823
2824 -all-static do not do any dynamic linking at all
2825 -avoid-version do not add a version suffix if possible
2826 -bindir BINDIR specify path to binaries directory (for systems where
2827 libraries must be found in the PATH setting at runtime)
2828 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
2829 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
2830 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2831 -export-symbols SYMFILE
2832 try to export only the symbols listed in SYMFILE
2833 -export-symbols-regex REGEX
2834 try to export only the symbols matching REGEX
2835 -LLIBDIR search LIBDIR for required installed libraries
2836 -lNAME OUTPUT-FILE requires the installed library libNAME
2837 -module build a library that can dlopened
2838 -no-fast-install disable the fast-install mode
2839 -no-install link a not-installable executable
2840 -no-undefined declare that a library does not refer to external symbols
2841 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
2842 -objectlist FILE Use a list of object files found in FILE to specify objects
2843 -precious-files-regex REGEX
2844 don't remove output files matching REGEX
2845 -release RELEASE specify package release information
2846 -rpath LIBDIR the created library will eventually be installed in LIBDIR
2847 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
2848 -shared only do dynamic linking of libtool libraries
2849 -shrext SUFFIX override the standard shared library file extension
2850 -static do not do any dynamic linking of uninstalled libtool libraries
2851 -static-libtool-libs
2852 do not do any dynamic linking of libtool libraries
2853 -version-info CURRENT[:REVISION[:AGE]]
2854 specify library version info [each variable defaults to 0]
2855 -weak LIBNAME declare that the target provides the LIBNAME interface
2856 -Wc,FLAG
2857 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
2858 -Wl,FLAG
2859 -Xlinker FLAG pass linker-specific FLAG directly to the linker
2860 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
2861
2862 All other options (arguments beginning with \`-') are ignored.
2863
2864 Every other argument is treated as a filename. Files ending in \`.la' are
2865 treated as uninstalled libtool libraries, other files are standard or library
2866 object files.
2867
2868 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2869 only library objects (\`.lo' files) may be specified, and \`-rpath' is
2870 required, except when creating a convenience library.
2871
2872 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2873 using \`ar' and \`ranlib', or on Windows using \`lib'.
2874
2875 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2876 is created, otherwise an executable program is created."
2877 ;;
2878
2879 uninstall)
2880 $ECHO \
2881 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2882
2883 Remove libraries from an installation directory.
2884
2885 RM is the name of the program to use to delete files associated with each FILE
2886 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
2887 to RM.
2888
2889 If FILE is a libtool library, all the files associated with it are deleted.
2890 Otherwise, only FILE itself is deleted using RM."
2891 ;;
2892
2893 *)
2894 func_fatal_help "invalid operation mode \`$opt_mode'"
2895 ;;
2896 esac
2897
2898 echo
2899 $ECHO "Try \`$progname --help' for more information about other modes."
2900 }
2901
2902 # Now that we've collected a possible --mode arg, show help if necessary
2903 if $opt_help; then
2904 if test "$opt_help" = :; then
2905 func_mode_help
2906 else
2907 {
2908 func_help noexit
2909 for opt_mode in compile link execute install finish uninstall clean; do
2910 func_mode_help
2911 done
2912 } | sed -n '1p; 2,$s/^Usage:/ or: /p'
2913 {
2914 func_help noexit
2915 for opt_mode in compile link execute install finish uninstall clean; do
2916 echo
2917 func_mode_help
2918 done
2919 } |
2920 sed '1d
2921 /^When reporting/,/^Report/{
2922 H
2923 d
2924 }
2925 $x
2926 /information about other modes/d
2927 /more detailed .*MODE/d
2928 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2929 fi
2930 exit $?
2931 fi
2932
2933
2934 # func_mode_execute arg...
2935 func_mode_execute ()
2936 {
2937 $opt_debug
2938 # The first argument is the command name.
2939 cmd="$nonopt"
2940 test -z "$cmd" && \
2941 func_fatal_help "you must specify a COMMAND"
2942
2943 # Handle -dlopen flags immediately.
2944 for file in $opt_dlopen; do
2945 test -f "$file" \
2946 || func_fatal_help "\`$file' is not a file"
2947
2948 dir=
2949 case $file in
2950 *.la)
2951 func_resolve_sysroot "$file"
2952 file=$func_resolve_sysroot_result
2953
2954 # Check to see that this really is a libtool archive.
2955 func_lalib_unsafe_p "$file" \
2956 || func_fatal_help "\`$lib' is not a valid libtool archive"
2957
2958 # Read the libtool library.
2959 dlname=
2960 library_names=
2961 func_source "$file"
2962
2963 # Skip this library if it cannot be dlopened.
2964 if test -z "$dlname"; then
2965 # Warn if it was a shared library.
2966 test -n "$library_names" && \
2967 func_warning "\`$file' was not linked with \`-export-dynamic'"
2968 continue
2969 fi
2970
2971 func_dirname "$file" "" "."
2972 dir="$func_dirname_result"
2973
2974 if test -f "$dir/$objdir/$dlname"; then
2975 dir+="/$objdir"
2976 else
2977 if test ! -f "$dir/$dlname"; then
2978 func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2979 fi
2980 fi
2981 ;;
2982
2983 *.lo)
2984 # Just add the directory containing the .lo file.
2985 func_dirname "$file" "" "."
2986 dir="$func_dirname_result"
2987 ;;
2988
2989 *)
2990 func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2991 continue
2992 ;;
2993 esac
2994
2995 # Get the absolute pathname.
2996 absdir=`cd "$dir" && pwd`
2997 test -n "$absdir" && dir="$absdir"
2998
2999 # Now add the directory to shlibpath_var.
3000 if eval "test -z \"\$$shlibpath_var\""; then
3001 eval "$shlibpath_var=\"\$dir\""
3002 else
3003 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
3004 fi
3005 done
3006
3007 # This variable tells wrapper scripts just to set shlibpath_var
3008 # rather than running their programs.
3009 libtool_execute_magic="$magic"
3010
3011 # Check if any of the arguments is a wrapper script.
3012 args=
3013 for file
3014 do
3015 case $file in
3016 -* | *.la | *.lo ) ;;
3017 *)
3018 # Do a test to see if this is really a libtool program.
3019 if func_ltwrapper_script_p "$file"; then
3020 func_source "$file"
3021 # Transform arg to wrapped name.
3022 file="$progdir/$program"
3023 elif func_ltwrapper_executable_p "$file"; then
3024 func_ltwrapper_scriptname "$file"
3025 func_source "$func_ltwrapper_scriptname_result"
3026 # Transform arg to wrapped name.
3027 file="$progdir/$program"
3028 fi
3029 ;;
3030 esac
3031 # Quote arguments (to preserve shell metacharacters).
3032 func_append_quoted args "$file"
3033 done
3034
3035 if test "X$opt_dry_run" = Xfalse; then
3036 if test -n "$shlibpath_var"; then
3037 # Export the shlibpath_var.
3038 eval "export $shlibpath_var"
3039 fi
3040
3041 # Restore saved environment variables
3042 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
3043 do
3044 eval "if test \"\${save_$lt_var+set}\" = set; then
3045 $lt_var=\$save_$lt_var; export $lt_var
3046 else
3047 $lt_unset $lt_var
3048 fi"
3049 done
3050
3051 # Now prepare to actually exec the command.
3052 exec_cmd="\$cmd$args"
3053 else
3054 # Display what would be done.
3055 if test -n "$shlibpath_var"; then
3056 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
3057 echo "export $shlibpath_var"
3058 fi
3059 $ECHO "$cmd$args"
3060 exit $EXIT_SUCCESS
3061 fi
3062 }
3063
3064 test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
3065
3066
3067 # func_mode_finish arg...
3068 func_mode_finish ()
3069 {
3070 $opt_debug
3071 libs=
3072 libdirs=
3073 admincmds=
3074
3075 for opt in "$nonopt" ${1+"$@"}
3076 do
3077 if test -d "$opt"; then
3078 libdirs+=" $opt"
3079
3080 elif test -f "$opt"; then
3081 if func_lalib_unsafe_p "$opt"; then
3082 libs+=" $opt"
3083 else
3084 func_warning "\`$opt' is not a valid libtool archive"
3085 fi
3086
3087 else
3088 func_fatal_error "invalid argument \`$opt'"
3089 fi
3090 done
3091
3092 if test -n "$libs"; then
3093 if test -n "$lt_sysroot"; then
3094 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
3095 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
3096 else
3097 sysroot_cmd=
3098 fi
3099
3100 # Remove sysroot references
3101 if $opt_dry_run; then
3102 for lib in $libs; do
3103 echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
3104 done
3105 else
3106 tmpdir=`func_mktempdir`
3107 for lib in $libs; do
3108 sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
3109 > $tmpdir/tmp-la
3110 mv -f $tmpdir/tmp-la $lib
3111 done
3112 ${RM}r "$tmpdir"
3113 fi
3114 fi
3115
3116 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
3117 for libdir in $libdirs; do
3118 if test -n "$finish_cmds"; then
3119 # Do each command in the finish commands.
3120 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
3121 '"$cmd"'"'
3122 fi
3123 if test -n "$finish_eval"; then
3124 # Do the single finish_eval.
3125 eval cmds=\"$finish_eval\"
3126 $opt_dry_run || eval "$cmds" || admincmds+="
3127 $cmds"
3128 fi
3129 done
3130 fi
3131
3132 # Exit here if they wanted silent mode.
3133 $opt_silent && exit $EXIT_SUCCESS
3134
3135 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
3136 echo "----------------------------------------------------------------------"
3137 echo "Libraries have been installed in:"
3138 for libdir in $libdirs; do
3139 $ECHO " $libdir"
3140 done
3141 echo
3142 echo "If you ever happen to want to link against installed libraries"
3143 echo "in a given directory, LIBDIR, you must either use libtool, and"
3144 echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
3145 echo "flag during linking and do at least one of the following:"
3146 if test -n "$shlibpath_var"; then
3147 echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
3148 echo " during execution"
3149 fi
3150 if test -n "$runpath_var"; then
3151 echo " - add LIBDIR to the \`$runpath_var' environment variable"
3152 echo " during linking"
3153 fi
3154 if test -n "$hardcode_libdir_flag_spec"; then
3155 libdir=LIBDIR
3156 eval flag=\"$hardcode_libdir_flag_spec\"
3157
3158 $ECHO " - use the \`$flag' linker flag"
3159 fi
3160 if test -n "$admincmds"; then
3161 $ECHO " - have your system administrator run these commands:$admincmds"
3162 fi
3163 if test -f /etc/ld.so.conf; then
3164 echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
3165 fi
3166 echo
3167
3168 echo "See any operating system documentation about shared libraries for"
3169 case $host in
3170 solaris2.[6789]|solaris2.1[0-9])
3171 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
3172 echo "pages."
3173 ;;
3174 *)
3175 echo "more information, such as the ld(1) and ld.so(8) manual pages."
3176 ;;
3177 esac
3178 echo "----------------------------------------------------------------------"
3179 fi
3180 exit $EXIT_SUCCESS
3181 }
3182
3183 test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
3184
3185
3186 # func_mode_install arg...
3187 func_mode_install ()
3188 {
3189 $opt_debug
3190 # There may be an optional sh(1) argument at the beginning of
3191 # install_prog (especially on Windows NT).
3192 if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
3193 # Allow the use of GNU shtool's install command.
3194 case $nonopt in *shtool*) :;; *) false;; esac; then
3195 # Aesthetically quote it.
3196 func_quote_for_eval "$nonopt"
3197 install_prog="$func_quote_for_eval_result "
3198 arg=$1
3199 shift
3200 else
3201 install_prog=
3202 arg=$nonopt
3203 fi
3204
3205 # The real first argument should be the name of the installation program.
3206 # Aesthetically quote it.
3207 func_quote_for_eval "$arg"
3208 install_prog+="$func_quote_for_eval_result"
3209 install_shared_prog=$install_prog
3210 case " $install_prog " in
3211 *[\\\ /]cp\ *) install_cp=: ;;
3212 *) install_cp=false ;;
3213 esac
3214
3215 # We need to accept at least all the BSD install flags.
3216 dest=
3217 files=
3218 opts=
3219 prev=
3220 install_type=
3221 isdir=no
3222 stripme=
3223 no_mode=:
3224 for arg
3225 do
3226 arg2=
3227 if test -n "$dest"; then
3228 files+=" $dest"
3229 dest=$arg
3230 continue
3231 fi
3232
3233 case $arg in
3234 -d) isdir=yes ;;
3235 -f)
3236 if $install_cp; then :; else
3237 prev=$arg
3238 fi
3239 ;;
3240 -g | -m | -o)
3241 prev=$arg
3242 ;;
3243 -s)
3244 stripme=" -s"
3245 continue
3246 ;;
3247 -*)
3248 ;;
3249 *)
3250 # If the previous option needed an argument, then skip it.
3251 if test -n "$prev"; then
3252 if test "x$prev" = x-m && test -n "$install_override_mode"; then
3253 arg2=$install_override_mode
3254 no_mode=false
3255 fi
3256 prev=
3257 else
3258 dest=$arg
3259 continue
3260 fi
3261 ;;
3262 esac
3263
3264 # Aesthetically quote the argument.
3265 func_quote_for_eval "$arg"
3266 install_prog+=" $func_quote_for_eval_result"
3267 if test -n "$arg2"; then
3268 func_quote_for_eval "$arg2"
3269 fi
3270 install_shared_prog+=" $func_quote_for_eval_result"
3271 done
3272
3273 test -z "$install_prog" && \
3274 func_fatal_help "you must specify an install program"
3275
3276 test -n "$prev" && \
3277 func_fatal_help "the \`$prev' option requires an argument"
3278
3279 if test -n "$install_override_mode" && $no_mode; then
3280 if $install_cp; then :; else
3281 func_quote_for_eval "$install_override_mode"
3282 install_shared_prog+=" -m $func_quote_for_eval_result"
3283 fi
3284 fi
3285
3286 if test -z "$files"; then
3287 if test -z "$dest"; then
3288 func_fatal_help "no file or destination specified"
3289 else
3290 func_fatal_help "you must specify a destination"
3291 fi
3292 fi
3293
3294 # Strip any trailing slash from the destination.
3295 func_stripname '' '/' "$dest"
3296 dest=$func_stripname_result
3297
3298 # Check to see that the destination is a directory.
3299 test -d "$dest" && isdir=yes
3300 if test "$isdir" = yes; then
3301 destdir="$dest"
3302 destname=
3303 else
3304 func_dirname_and_basename "$dest" "" "."
3305 destdir="$func_dirname_result"
3306 destname="$func_basename_result"
3307
3308 # Not a directory, so check to see that there is only one file specified.
3309 set dummy $files; shift
3310 test "$#" -gt 1 && \
3311 func_fatal_help "\`$dest' is not a directory"
3312 fi
3313 case $destdir in
3314 [\\/]* | [A-Za-z]:[\\/]*) ;;
3315 *)
3316 for file in $files; do
3317 case $file in
3318 *.lo) ;;
3319 *)
3320 func_fatal_help "\`$destdir' must be an absolute directory name"
3321 ;;
3322 esac
3323 done
3324 ;;
3325 esac
3326
3327 # This variable tells wrapper scripts just to set variables rather
3328 # than running their programs.
3329 libtool_install_magic="$magic"
3330
3331 staticlibs=
3332 future_libdirs=
3333 current_libdirs=
3334 for file in $files; do
3335
3336 # Do each installation.
3337 case $file in
3338 *.$libext)
3339 # Do the static libraries later.
3340 staticlibs+=" $file"
3341 ;;
3342
3343 *.la)
3344 func_resolve_sysroot "$file"
3345 file=$func_resolve_sysroot_result
3346
3347 # Check to see that this really is a libtool archive.
3348 func_lalib_unsafe_p "$file" \
3349 || func_fatal_help "\`$file' is not a valid libtool archive"
3350
3351 library_names=
3352 old_library=
3353 relink_command=
3354 func_source "$file"
3355
3356 # Add the libdir to current_libdirs if it is the destination.
3357 if test "X$destdir" = "X$libdir"; then
3358 case "$current_libdirs " in
3359 *" $libdir "*) ;;
3360 *) current_libdirs+=" $libdir" ;;
3361 esac
3362 else
3363 # Note the libdir as a future libdir.
3364 case "$future_libdirs " in
3365 *" $libdir "*) ;;
3366 *) future_libdirs+=" $libdir" ;;
3367 esac
3368 fi
3369
3370 func_dirname "$file" "/" ""
3371 dir="$func_dirname_result"
3372 dir+="$objdir"
3373
3374 if test -n "$relink_command"; then
3375 # Determine the prefix the user has applied to our future dir.
3376 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
3377
3378 # Don't allow the user to place us outside of our expected
3379 # location b/c this prevents finding dependent libraries that
3380 # are installed to the same prefix.
3381 # At present, this check doesn't affect windows .dll's that
3382 # are installed into $libdir/../bin (currently, that works fine)
3383 # but it's something to keep an eye on.
3384 test "$inst_prefix_dir" = "$destdir" && \
3385 func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
3386
3387 if test -n "$inst_prefix_dir"; then
3388 # Stick the inst_prefix_dir data into the link command.
3389 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
3390 else
3391 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
3392 fi
3393
3394 func_warning "relinking \`$file'"
3395 func_show_eval "$relink_command" \
3396 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
3397 fi
3398
3399 # See the names of the shared library.
3400 set dummy $library_names; shift
3401 if test -n "$1"; then
3402 realname="$1"
3403 shift
3404
3405 srcname="$realname"
3406 test -n "$relink_command" && srcname="$realname"T
3407
3408 # Install the shared library and build the symlinks.
3409 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
3410 'exit $?'
3411 tstripme="$stripme"
3412 case $host_os in
3413 cygwin* | mingw* | pw32* | cegcc*)
3414 case $realname in
3415 *.dll.a)
3416 tstripme=""
3417 ;;
3418 esac
3419 ;;
3420 esac
3421 if test -n "$tstripme" && test -n "$striplib"; then
3422 func_show_eval "$striplib $destdir/$realname" 'exit $?'
3423 fi
3424
3425 if test "$#" -gt 0; then
3426 # Delete the old symlinks, and create new ones.
3427 # Try `ln -sf' first, because the `ln' binary might depend on
3428 # the symlink we replace! Solaris /bin/ln does not understand -f,
3429 # so we also need to try rm && ln -s.
3430 for linkname
3431 do
3432 test "$linkname" != "$realname" \
3433 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3434 done
3435 fi
3436
3437 # Do each command in the postinstall commands.
3438 lib="$destdir/$realname"
3439 func_execute_cmds "$postinstall_cmds" 'exit $?'
3440 fi
3441
3442 # Install the pseudo-library for information purposes.
3443 func_basename "$file"
3444 name="$func_basename_result"
3445 instname="$dir/$name"i
3446 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3447
3448 # Maybe install the static library, too.
3449 test -n "$old_library" && staticlibs+=" $dir/$old_library"
3450 ;;
3451
3452 *.lo)
3453 # Install (i.e. copy) a libtool object.
3454
3455 # Figure out destination file name, if it wasn't already specified.
3456 if test -n "$destname"; then
3457 destfile="$destdir/$destname"
3458 else
3459 func_basename "$file"
3460 destfile="$func_basename_result"
3461 destfile="$destdir/$destfile"
3462 fi
3463
3464 # Deduce the name of the destination old-style object file.
3465 case $destfile in
3466 *.lo)
3467 func_lo2o "$destfile"
3468 staticdest=$func_lo2o_result
3469 ;;
3470 *.$objext)
3471 staticdest="$destfile"
3472 destfile=
3473 ;;
3474 *)
3475 func_fatal_help "cannot copy a libtool object to \`$destfile'"
3476 ;;
3477 esac
3478
3479 # Install the libtool object if requested.
3480 test -n "$destfile" && \
3481 func_show_eval "$install_prog $file $destfile" 'exit $?'
3482
3483 # Install the old object if enabled.
3484 if test "$build_old_libs" = yes; then
3485 # Deduce the name of the old-style object file.
3486 func_lo2o "$file"
3487 staticobj=$func_lo2o_result
3488 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3489 fi
3490 exit $EXIT_SUCCESS
3491 ;;
3492
3493 *)
3494 # Figure out destination file name, if it wasn't already specified.
3495 if test -n "$destname"; then
3496 destfile="$destdir/$destname"
3497 else
3498 func_basename "$file"
3499 destfile="$func_basename_result"
3500 destfile="$destdir/$destfile"
3501 fi
3502
3503 # If the file is missing, and there is a .exe on the end, strip it
3504 # because it is most likely a libtool script we actually want to
3505 # install
3506 stripped_ext=""
3507 case $file in
3508 *.exe)
3509 if test ! -f "$file"; then
3510 func_stripname '' '.exe' "$file"
3511 file=$func_stripname_result
3512 stripped_ext=".exe"
3513 fi
3514 ;;
3515 esac
3516
3517 # Do a test to see if this is really a libtool program.
3518 case $host in
3519 *cygwin* | *mingw*)
3520 if func_ltwrapper_executable_p "$file"; then
3521 func_ltwrapper_scriptname "$file"
3522 wrapper=$func_ltwrapper_scriptname_result
3523 else
3524 func_stripname '' '.exe' "$file"
3525 wrapper=$func_stripname_result
3526 fi
3527 ;;
3528 *)
3529 wrapper=$file
3530 ;;
3531 esac
3532 if func_ltwrapper_script_p "$wrapper"; then
3533 notinst_deplibs=
3534 relink_command=
3535
3536 func_source "$wrapper"
3537
3538 # Check the variables that should have been set.
3539 test -z "$generated_by_libtool_version" && \
3540 func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3541
3542 finalize=yes
3543 for lib in $notinst_deplibs; do
3544 # Check to see that each library is installed.
3545 libdir=
3546 if test -f "$lib"; then
3547 func_source "$lib"
3548 fi
3549 libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3550 if test -n "$libdir" && test ! -f "$libfile"; then
3551 func_warning "\`$lib' has not been installed in \`$libdir'"
3552 finalize=no
3553 fi
3554 done
3555
3556 relink_command=
3557 func_source "$wrapper"
3558
3559 outputname=
3560 if test "$fast_install" = no && test -n "$relink_command"; then
3561 $opt_dry_run || {
3562 if test "$finalize" = yes; then
3563 tmpdir=`func_mktempdir`
3564 func_basename "$file$stripped_ext"
3565 file="$func_basename_result"
3566 outputname="$tmpdir/$file"
3567 # Replace the output file specification.
3568 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3569
3570 $opt_silent || {
3571 func_quote_for_expand "$relink_command"
3572 eval "func_echo $func_quote_for_expand_result"
3573 }
3574 if eval "$relink_command"; then :
3575 else
3576 func_error "error: relink \`$file' with the above command before installing it"
3577 $opt_dry_run || ${RM}r "$tmpdir"
3578 continue
3579 fi
3580 file="$outputname"
3581 else
3582 func_warning "cannot relink \`$file'"
3583 fi
3584 }
3585 else
3586 # Install the binary that we compiled earlier.
3587 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3588 fi
3589 fi
3590
3591 # remove .exe since cygwin /usr/bin/install will append another
3592 # one anyway
3593 case $install_prog,$host in
3594 */usr/bin/install*,*cygwin*)
3595 case $file:$destfile in
3596 *.exe:*.exe)
3597 # this is ok
3598 ;;
3599 *.exe:*)
3600 destfile=$destfile.exe
3601 ;;
3602 *:*.exe)
3603 func_stripname '' '.exe' "$destfile"
3604 destfile=$func_stripname_result
3605 ;;
3606 esac
3607 ;;
3608 esac
3609 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3610 $opt_dry_run || if test -n "$outputname"; then
3611 ${RM}r "$tmpdir"
3612 fi
3613 ;;
3614 esac
3615 done
3616
3617 for file in $staticlibs; do
3618 func_basename "$file"
3619 name="$func_basename_result"
3620
3621 # Set up the ranlib parameters.
3622 oldlib="$destdir/$name"
3623 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3624 tool_oldlib=$func_to_tool_file_result
3625
3626 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3627
3628 if test -n "$stripme" && test -n "$old_striplib"; then
3629 func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3630 fi
3631
3632 # Do each command in the postinstall commands.
3633 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3634 done
3635
3636 test -n "$future_libdirs" && \
3637 func_warning "remember to run \`$progname --finish$future_libdirs'"
3638
3639 if test -n "$current_libdirs"; then
3640 # Maybe just do a dry run.
3641 $opt_dry_run && current_libdirs=" -n$current_libdirs"
3642 exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3643 else
3644 exit $EXIT_SUCCESS
3645 fi
3646 }
3647
3648 test "$opt_mode" = install && func_mode_install ${1+"$@"}
3649
3650
3651 # func_generate_dlsyms outputname originator pic_p
3652 # Extract symbols from dlprefiles and create ${outputname}S.o with
3653 # a dlpreopen symbol table.
3654 func_generate_dlsyms ()
3655 {
3656 $opt_debug
3657 my_outputname="$1"
3658 my_originator="$2"
3659 my_pic_p="${3-no}"
3660 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3661 my_dlsyms=
3662
3663 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3664 if test -n "$NM" && test -n "$global_symbol_pipe"; then
3665 my_dlsyms="${my_outputname}S.c"
3666 else
3667 func_error "not configured to extract global symbols from dlpreopened files"
3668 fi
3669 fi
3670
3671 if test -n "$my_dlsyms"; then
3672 case $my_dlsyms in
3673 "") ;;
3674 *.c)
3675 # Discover the nlist of each of the dlfiles.
3676 nlist="$output_objdir/${my_outputname}.nm"
3677
3678 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3679
3680 # Parse the name list into a source file.
3681 func_verbose "creating $output_objdir/$my_dlsyms"
3682
3683 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3684 /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3685 /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3686
3687 #ifdef __cplusplus
3688 extern \"C\" {
3689 #endif
3690
3691 #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3692 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3693 #endif
3694
3695 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
3696 #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3697 /* DATA imports from DLLs on WIN32 con't be const, because runtime
3698 relocations are performed -- see ld's documentation on pseudo-relocs. */
3699 # define LT_DLSYM_CONST
3700 #elif defined(__osf__)
3701 /* This system does not cope well with relocations in const data. */
3702 # define LT_DLSYM_CONST
3703 #else
3704 # define LT_DLSYM_CONST const
3705 #endif
3706
3707 /* External symbol declarations for the compiler. */\
3708 "
3709
3710 if test "$dlself" = yes; then
3711 func_verbose "generating symbol list for \`$output'"
3712
3713 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3714
3715 # Add our own program objects to the symbol list.
3716 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3717 for progfile in $progfiles; do
3718 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3719 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3720 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3721 done
3722
3723 if test -n "$exclude_expsyms"; then
3724 $opt_dry_run || {
3725 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3726 eval '$MV "$nlist"T "$nlist"'
3727 }
3728 fi
3729
3730 if test -n "$export_symbols_regex"; then
3731 $opt_dry_run || {
3732 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3733 eval '$MV "$nlist"T "$nlist"'
3734 }
3735 fi
3736
3737 # Prepare the list of exported symbols
3738 if test -z "$export_symbols"; then
3739 export_symbols="$output_objdir/$outputname.exp"
3740 $opt_dry_run || {
3741 $RM $export_symbols
3742 eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3743 case $host in
3744 *cygwin* | *mingw* | *cegcc* )
3745 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3746 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3747 ;;
3748 esac
3749 }
3750 else
3751 $opt_dry_run || {
3752 eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3753 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3754 eval '$MV "$nlist"T "$nlist"'
3755 case $host in
3756 *cygwin* | *mingw* | *cegcc* )
3757 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3758 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3759 ;;
3760 esac
3761 }
3762 fi
3763 fi
3764
3765 for dlprefile in $dlprefiles; do
3766 func_verbose "extracting global C symbols from \`$dlprefile'"
3767 func_basename "$dlprefile"
3768 name="$func_basename_result"
3769 case $host in
3770 *cygwin* | *mingw* | *cegcc* )
3771 # if an import library, we need to obtain dlname
3772 if func_win32_import_lib_p "$dlprefile"; then
3773 func_tr_sh "$dlprefile"
3774 eval "curr_lafile=\$libfile_$func_tr_sh_result"
3775 dlprefile_dlbasename=""
3776 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3777 # Use subshell, to avoid clobbering current variable values
3778 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3779 if test -n "$dlprefile_dlname" ; then
3780 func_basename "$dlprefile_dlname"
3781 dlprefile_dlbasename="$func_basename_result"
3782 else
3783 # no lafile. user explicitly requested -dlpreopen <import library>.
3784 $sharedlib_from_linklib_cmd "$dlprefile"
3785 dlprefile_dlbasename=$sharedlib_from_linklib_result
3786 fi
3787 fi
3788 $opt_dry_run || {
3789 if test -n "$dlprefile_dlbasename" ; then
3790 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3791 else
3792 func_warning "Could not compute DLL name from $name"
3793 eval '$ECHO ": $name " >> "$nlist"'
3794 fi
3795 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3796 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3797 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3798 }
3799 else # not an import lib
3800 $opt_dry_run || {
3801 eval '$ECHO ": $name " >> "$nlist"'
3802 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3803 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3804 }
3805 fi
3806 ;;
3807 *)
3808 $opt_dry_run || {
3809 eval '$ECHO ": $name " >> "$nlist"'
3810 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3811 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3812 }
3813 ;;
3814 esac
3815 done
3816
3817 $opt_dry_run || {
3818 # Make sure we have at least an empty file.
3819 test -f "$nlist" || : > "$nlist"
3820
3821 if test -n "$exclude_expsyms"; then
3822 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3823 $MV "$nlist"T "$nlist"
3824 fi
3825
3826 # Try sorting and uniquifying the output.
3827 if $GREP -v "^: " < "$nlist" |
3828 if sort -k 3 </dev/null >/dev/null 2>&1; then
3829 sort -k 3
3830 else
3831 sort +2
3832 fi |
3833 uniq > "$nlist"S; then
3834 :
3835 else
3836 $GREP -v "^: " < "$nlist" > "$nlist"S
3837 fi
3838
3839 if test -f "$nlist"S; then
3840 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3841 else
3842 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3843 fi
3844
3845 echo >> "$output_objdir/$my_dlsyms" "\
3846
3847 /* The mapping between symbol names and symbols. */
3848 typedef struct {
3849 const char *name;
3850 void *address;
3851 } lt_dlsymlist;
3852 extern LT_DLSYM_CONST lt_dlsymlist
3853 lt_${my_prefix}_LTX_preloaded_symbols[];
3854 LT_DLSYM_CONST lt_dlsymlist
3855 lt_${my_prefix}_LTX_preloaded_symbols[] =
3856 {\
3857 { \"$my_originator\", (void *) 0 },"
3858
3859 case $need_lib_prefix in
3860 no)
3861 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3862 ;;
3863 *)
3864 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3865 ;;
3866 esac
3867 echo >> "$output_objdir/$my_dlsyms" "\
3868 {0, (void *) 0}
3869 };
3870
3871 /* This works around a problem in FreeBSD linker */
3872 #ifdef FREEBSD_WORKAROUND
3873 static const void *lt_preloaded_setup() {
3874 return lt_${my_prefix}_LTX_preloaded_symbols;
3875 }
3876 #endif
3877
3878 #ifdef __cplusplus
3879 }
3880 #endif\
3881 "
3882 } # !$opt_dry_run
3883
3884 pic_flag_for_symtable=
3885 case "$compile_command " in
3886 *" -static "*) ;;
3887 *)
3888 case $host in
3889 # compiling the symbol table file with pic_flag works around
3890 # a FreeBSD bug that causes programs to crash when -lm is
3891 # linked before any other PIC object. But we must not use
3892 # pic_flag when linking with -static. The problem exists in
3893 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3894 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3895 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3896 *-*-hpux*)
3897 pic_flag_for_symtable=" $pic_flag" ;;
3898 *)
3899 if test "X$my_pic_p" != Xno; then
3900 pic_flag_for_symtable=" $pic_flag"
3901 fi
3902 ;;
3903 esac
3904 ;;
3905 esac
3906 symtab_cflags=
3907 for arg in $LTCFLAGS; do
3908 case $arg in
3909 -pie | -fpie | -fPIE) ;;
3910 *) symtab_cflags+=" $arg" ;;
3911 esac
3912 done
3913
3914 # Now compile the dynamic symbol file.
3915 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3916
3917 # Clean up the generated files.
3918 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3919
3920 # Transform the symbol file into the correct name.
3921 symfileobj="$output_objdir/${my_outputname}S.$objext"
3922 case $host in
3923 *cygwin* | *mingw* | *cegcc* )
3924 if test -f "$output_objdir/$my_outputname.def"; then
3925 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3926 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3927 else
3928 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3929 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3930 fi
3931 ;;
3932 *)
3933 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3934 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3935 ;;
3936 esac
3937 ;;
3938 *)
3939 func_fatal_error "unknown suffix for \`$my_dlsyms'"
3940 ;;
3941 esac
3942 else
3943 # We keep going just in case the user didn't refer to
3944 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
3945 # really was required.
3946
3947 # Nullify the symbol file.
3948 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3949 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3950 fi
3951 }
3952
3953 # func_win32_libid arg
3954 # return the library type of file 'arg'
3955 #
3956 # Need a lot of goo to handle *both* DLLs and import libs
3957 # Has to be a shell function in order to 'eat' the argument
3958 # that is supplied when $file_magic_command is called.
3959 # Despite the name, also deal with 64 bit binaries.
3960 func_win32_libid ()
3961 {
3962 $opt_debug
3963 win32_libid_type="unknown"
3964 win32_fileres=`file -L $1 2>/dev/null`
3965 case $win32_fileres in
3966 *ar\ archive\ import\ library*) # definitely import
3967 win32_libid_type="x86 archive import"
3968 ;;
3969 *ar\ archive*) # could be an import, or static
3970 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3971 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3972 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3973 func_to_tool_file "$1" func_convert_file_msys_to_w32
3974 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3975 $SED -n -e '
3976 1,100{
3977 / I /{
3978 s,.*,import,
3979 p
3980 q
3981 }
3982 }'`
3983 case $win32_nmres in
3984 import*) win32_libid_type="x86 archive import";;
3985 *) win32_libid_type="x86 archive static";;
3986 esac
3987 fi
3988 ;;
3989 *DLL*)
3990 win32_libid_type="x86 DLL"
3991 ;;
3992 *executable*) # but shell scripts are "executable" too...
3993 case $win32_fileres in
3994 *MS\ Windows\ PE\ Intel*)
3995 win32_libid_type="x86 DLL"
3996 ;;
3997 esac
3998 ;;
3999 esac
4000 $ECHO "$win32_libid_type"
4001 }
4002
4003 # func_cygming_dll_for_implib ARG
4004 #
4005 # Platform-specific function to extract the
4006 # name of the DLL associated with the specified
4007 # import library ARG.
4008 # Invoked by eval'ing the libtool variable
4009 # $sharedlib_from_linklib_cmd
4010 # Result is available in the variable
4011 # $sharedlib_from_linklib_result
4012 func_cygming_dll_for_implib ()
4013 {
4014 $opt_debug
4015 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
4016 }
4017
4018 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
4019 #
4020 # The is the core of a fallback implementation of a
4021 # platform-specific function to extract the name of the
4022 # DLL associated with the specified import library LIBNAME.
4023 #
4024 # SECTION_NAME is either .idata$6 or .idata$7, depending
4025 # on the platform and compiler that created the implib.
4026 #
4027 # Echos the name of the DLL associated with the
4028 # specified import library.
4029 func_cygming_dll_for_implib_fallback_core ()
4030 {
4031 $opt_debug
4032 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
4033 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
4034 $SED '/^Contents of section '"$match_literal"':/{
4035 # Place marker at beginning of archive member dllname section
4036 s/.*/====MARK====/
4037 p
4038 d
4039 }
4040 # These lines can sometimes be longer than 43 characters, but
4041 # are always uninteresting
4042 /:[ ]*file format pe[i]\{,1\}-/d
4043 /^In archive [^:]*:/d
4044 # Ensure marker is printed
4045 /^====MARK====/p
4046 # Remove all lines with less than 43 characters
4047 /^.\{43\}/!d
4048 # From remaining lines, remove first 43 characters
4049 s/^.\{43\}//' |
4050 $SED -n '
4051 # Join marker and all lines until next marker into a single line
4052 /^====MARK====/ b para
4053 H
4054 $ b para
4055 b
4056 :para
4057 x
4058 s/\n//g
4059 # Remove the marker
4060 s/^====MARK====//
4061 # Remove trailing dots and whitespace
4062 s/[\. \t]*$//
4063 # Print
4064 /./p' |
4065 # we now have a list, one entry per line, of the stringified
4066 # contents of the appropriate section of all members of the
4067 # archive which possess that section. Heuristic: eliminate
4068 # all those which have a first or second character that is
4069 # a '.' (that is, objdump's representation of an unprintable
4070 # character.) This should work for all archives with less than
4071 # 0x302f exports -- but will fail for DLLs whose name actually
4072 # begins with a literal '.' or a single character followed by
4073 # a '.'.
4074 #
4075 # Of those that remain, print the first one.
4076 $SED -e '/^\./d;/^.\./d;q'
4077 }
4078
4079 # func_cygming_gnu_implib_p ARG
4080 # This predicate returns with zero status (TRUE) if
4081 # ARG is a GNU/binutils-style import library. Returns
4082 # with nonzero status (FALSE) otherwise.
4083 func_cygming_gnu_implib_p ()
4084 {
4085 $opt_debug
4086 func_to_tool_file "$1" func_convert_file_msys_to_w32
4087 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
4088 test -n "$func_cygming_gnu_implib_tmp"
4089 }
4090
4091 # func_cygming_ms_implib_p ARG
4092 # This predicate returns with zero status (TRUE) if
4093 # ARG is an MS-style import library. Returns
4094 # with nonzero status (FALSE) otherwise.
4095 func_cygming_ms_implib_p ()
4096 {
4097 $opt_debug
4098 func_to_tool_file "$1" func_convert_file_msys_to_w32
4099 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
4100 test -n "$func_cygming_ms_implib_tmp"
4101 }
4102
4103 # func_cygming_dll_for_implib_fallback ARG
4104 # Platform-specific function to extract the
4105 # name of the DLL associated with the specified
4106 # import library ARG.
4107 #
4108 # This fallback implementation is for use when $DLLTOOL
4109 # does not support the --identify-strict option.
4110 # Invoked by eval'ing the libtool variable
4111 # $sharedlib_from_linklib_cmd
4112 # Result is available in the variable
4113 # $sharedlib_from_linklib_result
4114 func_cygming_dll_for_implib_fallback ()
4115 {
4116 $opt_debug
4117 if func_cygming_gnu_implib_p "$1" ; then
4118 # binutils import library
4119 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
4120 elif func_cygming_ms_implib_p "$1" ; then
4121 # ms-generated import library
4122 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
4123 else
4124 # unknown
4125 sharedlib_from_linklib_result=""
4126 fi
4127 }
4128
4129
4130 # func_extract_an_archive dir oldlib
4131 func_extract_an_archive ()
4132 {
4133 $opt_debug
4134 f_ex_an_ar_dir="$1"; shift
4135 f_ex_an_ar_oldlib="$1"
4136 if test "$lock_old_archive_extraction" = yes; then
4137 lockfile=$f_ex_an_ar_oldlib.lock
4138 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
4139 func_echo "Waiting for $lockfile to be removed"
4140 sleep 2
4141 done
4142 fi
4143 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
4144 'stat=$?; rm -f "$lockfile"; exit $stat'
4145 if test "$lock_old_archive_extraction" = yes; then
4146 $opt_dry_run || rm -f "$lockfile"
4147 fi
4148 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
4149 :
4150 else
4151 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
4152 fi
4153 }
4154
4155
4156 # func_extract_archives gentop oldlib ...
4157 func_extract_archives ()
4158 {
4159 $opt_debug
4160 my_gentop="$1"; shift
4161 my_oldlibs=${1+"$@"}
4162 my_oldobjs=""
4163 my_xlib=""
4164 my_xabs=""
4165 my_xdir=""
4166
4167 for my_xlib in $my_oldlibs; do
4168 # Extract the objects.
4169 case $my_xlib in
4170 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
4171 *) my_xabs=`pwd`"/$my_xlib" ;;
4172 esac
4173 func_basename "$my_xlib"
4174 my_xlib="$func_basename_result"
4175 my_xlib_u=$my_xlib
4176 while :; do
4177 case " $extracted_archives " in
4178 *" $my_xlib_u "*)
4179 func_arith $extracted_serial + 1
4180 extracted_serial=$func_arith_result
4181 my_xlib_u=lt$extracted_serial-$my_xlib ;;
4182 *) break ;;
4183 esac
4184 done
4185 extracted_archives="$extracted_archives $my_xlib_u"
4186 my_xdir="$my_gentop/$my_xlib_u"
4187
4188 func_mkdir_p "$my_xdir"
4189
4190 case $host in
4191 *-darwin*)
4192 func_verbose "Extracting $my_xabs"
4193 # Do not bother doing anything if just a dry run
4194 $opt_dry_run || {
4195 darwin_orig_dir=`pwd`
4196 cd $my_xdir || exit $?
4197 darwin_archive=$my_xabs
4198 darwin_curdir=`pwd`
4199 darwin_base_archive=`basename "$darwin_archive"`
4200 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
4201 if test -n "$darwin_arches"; then
4202 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
4203 darwin_arch=
4204 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
4205 for darwin_arch in $darwin_arches ; do
4206 func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
4207 $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
4208 cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
4209 func_extract_an_archive "`pwd`" "${darwin_base_archive}"
4210 cd "$darwin_curdir"
4211 $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
4212 done # $darwin_arches
4213 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
4214 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
4215 darwin_file=
4216 darwin_files=
4217 for darwin_file in $darwin_filelist; do
4218 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
4219 $LIPO -create -output "$darwin_file" $darwin_files
4220 done # $darwin_filelist
4221 $RM -rf unfat-$$
4222 cd "$darwin_orig_dir"
4223 else
4224 cd $darwin_orig_dir
4225 func_extract_an_archive "$my_xdir" "$my_xabs"
4226 fi # $darwin_arches
4227 } # !$opt_dry_run
4228 ;;
4229 *)
4230 func_extract_an_archive "$my_xdir" "$my_xabs"
4231 ;;
4232 esac
4233 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
4234 done
4235
4236 func_extract_archives_result="$my_oldobjs"
4237 }
4238
4239
4240 # func_emit_wrapper [arg=no]
4241 #
4242 # Emit a libtool wrapper script on stdout.
4243 # Don't directly open a file because we may want to
4244 # incorporate the script contents within a cygwin/mingw
4245 # wrapper executable. Must ONLY be called from within
4246 # func_mode_link because it depends on a number of variables
4247 # set therein.
4248 #
4249 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
4250 # variable will take. If 'yes', then the emitted script
4251 # will assume that the directory in which it is stored is
4252 # the $objdir directory. This is a cygwin/mingw-specific
4253 # behavior.
4254 func_emit_wrapper ()
4255 {
4256 func_emit_wrapper_arg1=${1-no}
4257
4258 $ECHO "\
4259 #! $SHELL
4260
4261 # $output - temporary wrapper script for $objdir/$outputname
4262 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4263 #
4264 # The $output program cannot be directly executed until all the libtool
4265 # libraries that it depends on are installed.
4266 #
4267 # This wrapper script should never be moved out of the build directory.
4268 # If it is, it will not operate correctly.
4269
4270 # Sed substitution that helps us do robust quoting. It backslashifies
4271 # metacharacters that are still active within double-quoted strings.
4272 sed_quote_subst='$sed_quote_subst'
4273
4274 # Be Bourne compatible
4275 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
4276 emulate sh
4277 NULLCMD=:
4278 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
4279 # is contrary to our usage. Disable this feature.
4280 alias -g '\${1+\"\$@\"}'='\"\$@\"'
4281 setopt NO_GLOB_SUBST
4282 else
4283 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
4284 fi
4285 BIN_SH=xpg4; export BIN_SH # for Tru64
4286 DUALCASE=1; export DUALCASE # for MKS sh
4287
4288 # The HP-UX ksh and POSIX shell print the target directory to stdout
4289 # if CDPATH is set.
4290 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
4291
4292 relink_command=\"$relink_command\"
4293
4294 # This environment variable determines our operation mode.
4295 if test \"\$libtool_install_magic\" = \"$magic\"; then
4296 # install mode needs the following variables:
4297 generated_by_libtool_version='$macro_version'
4298 notinst_deplibs='$notinst_deplibs'
4299 else
4300 # When we are sourced in execute mode, \$file and \$ECHO are already set.
4301 if test \"\$libtool_execute_magic\" != \"$magic\"; then
4302 file=\"\$0\""
4303
4304 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
4305 $ECHO "\
4306
4307 # A function that is used when there is no print builtin or printf.
4308 func_fallback_echo ()
4309 {
4310 eval 'cat <<_LTECHO_EOF
4311 \$1
4312 _LTECHO_EOF'
4313 }
4314 ECHO=\"$qECHO\"
4315 fi
4316
4317 # Very basic option parsing. These options are (a) specific to
4318 # the libtool wrapper, (b) are identical between the wrapper
4319 # /script/ and the wrapper /executable/ which is used only on
4320 # windows platforms, and (c) all begin with the string "--lt-"
4321 # (application programs are unlikely to have options which match
4322 # this pattern).
4323 #
4324 # There are only two supported options: --lt-debug and
4325 # --lt-dump-script. There is, deliberately, no --lt-help.
4326 #
4327 # The first argument to this parsing function should be the
4328 # script's $0 value, followed by "$@".
4329 lt_option_debug=
4330 func_parse_lt_options ()
4331 {
4332 lt_script_arg0=\$0
4333 shift
4334 for lt_opt
4335 do
4336 case \"\$lt_opt\" in
4337 --lt-debug) lt_option_debug=1 ;;
4338 --lt-dump-script)
4339 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
4340 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
4341 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
4342 cat \"\$lt_dump_D/\$lt_dump_F\"
4343 exit 0
4344 ;;
4345 --lt-*)
4346 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
4347 exit 1
4348 ;;
4349 esac
4350 done
4351
4352 # Print the debug banner immediately:
4353 if test -n \"\$lt_option_debug\"; then
4354 echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
4355 fi
4356 }
4357
4358 # Used when --lt-debug. Prints its arguments to stdout
4359 # (redirection is the responsibility of the caller)
4360 func_lt_dump_args ()
4361 {
4362 lt_dump_args_N=1;
4363 for lt_arg
4364 do
4365 \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
4366 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
4367 done
4368 }
4369
4370 # Core function for launching the target application
4371 func_exec_program_core ()
4372 {
4373 "
4374 case $host in
4375 # Backslashes separate directories on plain windows
4376 *-*-mingw | *-*-os2* | *-cegcc*)
4377 $ECHO "\
4378 if test -n \"\$lt_option_debug\"; then
4379 \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
4380 func_lt_dump_args \${1+\"\$@\"} 1>&2
4381 fi
4382 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
4383 "
4384 ;;
4385
4386 *)
4387 $ECHO "\
4388 if test -n \"\$lt_option_debug\"; then
4389 \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
4390 func_lt_dump_args \${1+\"\$@\"} 1>&2
4391 fi
4392 exec \"\$progdir/\$program\" \${1+\"\$@\"}
4393 "
4394 ;;
4395 esac
4396 $ECHO "\
4397 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
4398 exit 1
4399 }
4400
4401 # A function to encapsulate launching the target application
4402 # Strips options in the --lt-* namespace from \$@ and
4403 # launches target application with the remaining arguments.
4404 func_exec_program ()
4405 {
4406 case \" \$* \" in
4407 *\\ --lt-*)
4408 for lt_wr_arg
4409 do
4410 case \$lt_wr_arg in
4411 --lt-*) ;;
4412 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
4413 esac
4414 shift
4415 done ;;
4416 esac
4417 func_exec_program_core \${1+\"\$@\"}
4418 }
4419
4420 # Parse options
4421 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4422
4423 # Find the directory that this script lives in.
4424 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4425 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4426
4427 # Follow symbolic links until we get to the real thisdir.
4428 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4429 while test -n \"\$file\"; do
4430 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4431
4432 # If there was a directory component, then change thisdir.
4433 if test \"x\$destdir\" != \"x\$file\"; then
4434 case \"\$destdir\" in
4435 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4436 *) thisdir=\"\$thisdir/\$destdir\" ;;
4437 esac
4438 fi
4439
4440 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4441 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4442 done
4443
4444 # Usually 'no', except on cygwin/mingw when embedded into
4445 # the cwrapper.
4446 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4447 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4448 # special case for '.'
4449 if test \"\$thisdir\" = \".\"; then
4450 thisdir=\`pwd\`
4451 fi
4452 # remove .libs from thisdir
4453 case \"\$thisdir\" in
4454 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4455 $objdir ) thisdir=. ;;
4456 esac
4457 fi
4458
4459 # Try to get the absolute directory name.
4460 absdir=\`cd \"\$thisdir\" && pwd\`
4461 test -n \"\$absdir\" && thisdir=\"\$absdir\"
4462 "
4463
4464 if test "$fast_install" = yes; then
4465 $ECHO "\
4466 program=lt-'$outputname'$exeext
4467 progdir=\"\$thisdir/$objdir\"
4468
4469 if test ! -f \"\$progdir/\$program\" ||
4470 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4471 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4472
4473 file=\"\$\$-\$program\"
4474
4475 if test ! -d \"\$progdir\"; then
4476 $MKDIR \"\$progdir\"
4477 else
4478 $RM \"\$progdir/\$file\"
4479 fi"
4480
4481 $ECHO "\
4482
4483 # relink executable if necessary
4484 if test -n \"\$relink_command\"; then
4485 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4486 else
4487 $ECHO \"\$relink_command_output\" >&2
4488 $RM \"\$progdir/\$file\"
4489 exit 1
4490 fi
4491 fi
4492
4493 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4494 { $RM \"\$progdir/\$program\";
4495 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4496 $RM \"\$progdir/\$file\"
4497 fi"
4498 else
4499 $ECHO "\
4500 program='$outputname'
4501 progdir=\"\$thisdir/$objdir\"
4502 "
4503 fi
4504
4505 $ECHO "\
4506
4507 if test -f \"\$progdir/\$program\"; then"
4508
4509 # fixup the dll searchpath if we need to.
4510 #
4511 # Fix the DLL searchpath if we need to. Do this before prepending
4512 # to shlibpath, because on Windows, both are PATH and uninstalled
4513 # libraries must come first.
4514 if test -n "$dllsearchpath"; then
4515 $ECHO "\
4516 # Add the dll search path components to the executable PATH
4517 PATH=$dllsearchpath:\$PATH
4518 "
4519 fi
4520
4521 # Export our shlibpath_var if we have one.
4522 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4523 $ECHO "\
4524 # Add our own library path to $shlibpath_var
4525 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4526
4527 # Some systems cannot cope with colon-terminated $shlibpath_var
4528 # The second colon is a workaround for a bug in BeOS R4 sed
4529 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4530
4531 export $shlibpath_var
4532 "
4533 fi
4534
4535 $ECHO "\
4536 if test \"\$libtool_execute_magic\" != \"$magic\"; then
4537 # Run the actual program with our arguments.
4538 func_exec_program \${1+\"\$@\"}
4539 fi
4540 else
4541 # The program doesn't exist.
4542 \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4543 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4544 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4545 exit 1
4546 fi
4547 fi\
4548 "
4549 }
4550
4551
4552 # func_emit_cwrapperexe_src
4553 # emit the source code for a wrapper executable on stdout
4554 # Must ONLY be called from within func_mode_link because
4555 # it depends on a number of variable set therein.
4556 func_emit_cwrapperexe_src ()
4557 {
4558 cat <<EOF
4559
4560 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4561 Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4562
4563 The $output program cannot be directly executed until all the libtool
4564 libraries that it depends on are installed.
4565
4566 This wrapper executable should never be moved out of the build directory.
4567 If it is, it will not operate correctly.
4568 */
4569 EOF
4570 cat <<"EOF"
4571 #ifdef _MSC_VER
4572 # define _CRT_SECURE_NO_DEPRECATE 1
4573 #endif
4574 #include <stdio.h>
4575 #include <stdlib.h>
4576 #ifdef _MSC_VER
4577 # include <direct.h>
4578 # include <process.h>
4579 # include <io.h>
4580 #else
4581 # include <unistd.h>
4582 # include <stdint.h>
4583 # ifdef __CYGWIN__
4584 # include <io.h>
4585 # endif
4586 #endif
4587 #include <malloc.h>
4588 #include <stdarg.h>
4589 #include <assert.h>
4590 #include <string.h>
4591 #include <ctype.h>
4592 #include <errno.h>
4593 #include <fcntl.h>
4594 #include <sys/stat.h>
4595
4596 /* declarations of non-ANSI functions */
4597 #if defined(__MINGW32__)
4598 # ifdef __STRICT_ANSI__
4599 int _putenv (const char *);
4600 # endif
4601 #elif defined(__CYGWIN__)
4602 # ifdef __STRICT_ANSI__
4603 char *realpath (const char *, char *);
4604 int putenv (char *);
4605 int setenv (const char *, const char *, int);
4606 # endif
4607 /* #elif defined (other platforms) ... */
4608 #endif
4609
4610 /* portability defines, excluding path handling macros */
4611 #if defined(_MSC_VER)
4612 # define setmode _setmode
4613 # define stat _stat
4614 # define chmod _chmod
4615 # define getcwd _getcwd
4616 # define putenv _putenv
4617 # define S_IXUSR _S_IEXEC
4618 # ifndef _INTPTR_T_DEFINED
4619 # define _INTPTR_T_DEFINED
4620 # define intptr_t int
4621 # endif
4622 #elif defined(__MINGW32__)
4623 # define setmode _setmode
4624 # define stat _stat
4625 # define chmod _chmod
4626 # define getcwd _getcwd
4627 # define putenv _putenv
4628 #elif defined(__CYGWIN__)
4629 # define HAVE_SETENV
4630 # define FOPEN_WB "wb"
4631 /* #elif defined (other platforms) ... */
4632 #endif
4633
4634 #if defined(PATH_MAX)
4635 # define LT_PATHMAX PATH_MAX
4636 #elif defined(MAXPATHLEN)
4637 # define LT_PATHMAX MAXPATHLEN
4638 #else
4639 # define LT_PATHMAX 1024
4640 #endif
4641
4642 #ifndef S_IXOTH
4643 # define S_IXOTH 0
4644 #endif
4645 #ifndef S_IXGRP
4646 # define S_IXGRP 0
4647 #endif
4648
4649 /* path handling portability macros */
4650 #ifndef DIR_SEPARATOR
4651 # define DIR_SEPARATOR '/'
4652 # define PATH_SEPARATOR ':'
4653 #endif
4654
4655 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4656 defined (__OS2__)
4657 # define HAVE_DOS_BASED_FILE_SYSTEM
4658 # define FOPEN_WB "wb"
4659 # ifndef DIR_SEPARATOR_2
4660 # define DIR_SEPARATOR_2 '\\'
4661 # endif
4662 # ifndef PATH_SEPARATOR_2
4663 # define PATH_SEPARATOR_2 ';'
4664 # endif
4665 #endif
4666
4667 #ifndef DIR_SEPARATOR_2
4668 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4669 #else /* DIR_SEPARATOR_2 */
4670 # define IS_DIR_SEPARATOR(ch) \
4671 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4672 #endif /* DIR_SEPARATOR_2 */
4673
4674 #ifndef PATH_SEPARATOR_2
4675 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4676 #else /* PATH_SEPARATOR_2 */
4677 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4678 #endif /* PATH_SEPARATOR_2 */
4679
4680 #ifndef FOPEN_WB
4681 # define FOPEN_WB "w"
4682 #endif
4683 #ifndef _O_BINARY
4684 # define _O_BINARY 0
4685 #endif
4686
4687 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4688 #define XFREE(stale) do { \
4689 if (stale) { free ((void *) stale); stale = 0; } \
4690 } while (0)
4691
4692 #if defined(LT_DEBUGWRAPPER)
4693 static int lt_debug = 1;
4694 #else
4695 static int lt_debug = 0;
4696 #endif
4697
4698 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4699
4700 void *xmalloc (size_t num);
4701 char *xstrdup (const char *string);
4702 const char *base_name (const char *name);
4703 char *find_executable (const char *wrapper);
4704 char *chase_symlinks (const char *pathspec);
4705 int make_executable (const char *path);
4706 int check_executable (const char *path);
4707 char *strendzap (char *str, const char *pat);
4708 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
4709 void lt_fatal (const char *file, int line, const char *message, ...);
4710 static const char *nonnull (const char *s);
4711 static const char *nonempty (const char *s);
4712 void lt_setenv (const char *name, const char *value);
4713 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
4714 void lt_update_exe_path (const char *name, const char *value);
4715 void lt_update_lib_path (const char *name, const char *value);
4716 char **prepare_spawn (char **argv);
4717 void lt_dump_script (FILE *f);
4718 EOF
4719
4720 cat <<EOF
4721 volatile const char * MAGIC_EXE = "$magic_exe";
4722 const char * LIB_PATH_VARNAME = "$shlibpath_var";
4723 EOF
4724
4725 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4726 func_to_host_path "$temp_rpath"
4727 cat <<EOF
4728 const char * LIB_PATH_VALUE = "$func_to_host_path_result";
4729 EOF
4730 else
4731 cat <<"EOF"
4732 const char * LIB_PATH_VALUE = "";
4733 EOF
4734 fi
4735
4736 if test -n "$dllsearchpath"; then
4737 func_to_host_path "$dllsearchpath:"
4738 cat <<EOF
4739 const char * EXE_PATH_VARNAME = "PATH";
4740 const char * EXE_PATH_VALUE = "$func_to_host_path_result";
4741 EOF
4742 else
4743 cat <<"EOF"
4744 const char * EXE_PATH_VARNAME = "";
4745 const char * EXE_PATH_VALUE = "";
4746 EOF
4747 fi
4748
4749 if test "$fast_install" = yes; then
4750 cat <<EOF
4751 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4752 EOF
4753 else
4754 cat <<EOF
4755 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4756 EOF
4757 fi
4758
4759
4760 cat <<"EOF"
4761
4762 #define LTWRAPPER_OPTION_PREFIX "--lt-"
4763
4764 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4765 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
4766 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
4767
4768 int
4769 main (int argc, char *argv[])
4770 {
4771 char **newargz;
4772 int newargc;
4773 char *tmp_pathspec;
4774 char *actual_cwrapper_path;
4775 char *actual_cwrapper_name;
4776 char *target_name;
4777 char *lt_argv_zero;
4778 intptr_t rval = 127;
4779
4780 int i;
4781
4782 program_name = (char *) xstrdup (base_name (argv[0]));
4783 newargz = XMALLOC (char *, argc + 1);
4784
4785 /* very simple arg parsing; don't want to rely on getopt
4786 * also, copy all non cwrapper options to newargz, except
4787 * argz[0], which is handled differently
4788 */
4789 newargc=0;
4790 for (i = 1; i < argc; i++)
4791 {
4792 if (strcmp (argv[i], dumpscript_opt) == 0)
4793 {
4794 EOF
4795 case "$host" in
4796 *mingw* | *cygwin* )
4797 # make stdout use "unix" line endings
4798 echo " setmode(1,_O_BINARY);"
4799 ;;
4800 esac
4801
4802 cat <<"EOF"
4803 lt_dump_script (stdout);
4804 return 0;
4805 }
4806 if (strcmp (argv[i], debug_opt) == 0)
4807 {
4808 lt_debug = 1;
4809 continue;
4810 }
4811 if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4812 {
4813 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4814 namespace, but it is not one of the ones we know about and
4815 have already dealt with, above (inluding dump-script), then
4816 report an error. Otherwise, targets might begin to believe
4817 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4818 namespace. The first time any user complains about this, we'll
4819 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4820 or a configure.ac-settable value.
4821 */
4822 lt_fatal (__FILE__, __LINE__,
4823 "unrecognized %s option: '%s'",
4824 ltwrapper_option_prefix, argv[i]);
4825 }
4826 /* otherwise ... */
4827 newargz[++newargc] = xstrdup (argv[i]);
4828 }
4829 newargz[++newargc] = NULL;
4830
4831 EOF
4832 cat <<EOF
4833 /* The GNU banner must be the first non-error debug message */
4834 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4835 EOF
4836 cat <<"EOF"
4837 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4838 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4839
4840 tmp_pathspec = find_executable (argv[0]);
4841 if (tmp_pathspec == NULL)
4842 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4843 lt_debugprintf (__FILE__, __LINE__,
4844 "(main) found exe (before symlink chase) at: %s\n",
4845 tmp_pathspec);
4846
4847 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4848 lt_debugprintf (__FILE__, __LINE__,
4849 "(main) found exe (after symlink chase) at: %s\n",
4850 actual_cwrapper_path);
4851 XFREE (tmp_pathspec);
4852
4853 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4854 strendzap (actual_cwrapper_path, actual_cwrapper_name);
4855
4856 /* wrapper name transforms */
4857 strendzap (actual_cwrapper_name, ".exe");
4858 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4859 XFREE (actual_cwrapper_name);
4860 actual_cwrapper_name = tmp_pathspec;
4861 tmp_pathspec = 0;
4862
4863 /* target_name transforms -- use actual target program name; might have lt- prefix */
4864 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4865 strendzap (target_name, ".exe");
4866 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4867 XFREE (target_name);
4868 target_name = tmp_pathspec;
4869 tmp_pathspec = 0;
4870
4871 lt_debugprintf (__FILE__, __LINE__,
4872 "(main) libtool target name: %s\n",
4873 target_name);
4874 EOF
4875
4876 cat <<EOF
4877 newargz[0] =
4878 XMALLOC (char, (strlen (actual_cwrapper_path) +
4879 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4880 strcpy (newargz[0], actual_cwrapper_path);
4881 strcat (newargz[0], "$objdir");
4882 strcat (newargz[0], "/");
4883 EOF
4884
4885 cat <<"EOF"
4886 /* stop here, and copy so we don't have to do this twice */
4887 tmp_pathspec = xstrdup (newargz[0]);
4888
4889 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4890 strcat (newargz[0], actual_cwrapper_name);
4891
4892 /* DO want the lt- prefix here if it exists, so use target_name */
4893 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4894 XFREE (tmp_pathspec);
4895 tmp_pathspec = NULL;
4896 EOF
4897
4898 case $host_os in
4899 mingw*)
4900 cat <<"EOF"
4901 {
4902 char* p;
4903 while ((p = strchr (newargz[0], '\\')) != NULL)
4904 {
4905 *p = '/';
4906 }
4907 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4908 {
4909 *p = '/';
4910 }
4911 }
4912 EOF
4913 ;;
4914 esac
4915
4916 cat <<"EOF"
4917 XFREE (target_name);
4918 XFREE (actual_cwrapper_path);
4919 XFREE (actual_cwrapper_name);
4920
4921 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4922 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
4923 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
4924 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4925 because on Windows, both *_VARNAMEs are PATH but uninstalled
4926 libraries must come first. */
4927 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4928 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4929
4930 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4931 nonnull (lt_argv_zero));
4932 for (i = 0; i < newargc; i++)
4933 {
4934 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4935 i, nonnull (newargz[i]));
4936 }
4937
4938 EOF
4939
4940 case $host_os in
4941 mingw*)
4942 cat <<"EOF"
4943 /* execv doesn't actually work on mingw as expected on unix */
4944 newargz = prepare_spawn (newargz);
4945 rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4946 if (rval == -1)
4947 {
4948 /* failed to start process */
4949 lt_debugprintf (__FILE__, __LINE__,
4950 "(main) failed to launch target \"%s\": %s\n",
4951 lt_argv_zero, nonnull (strerror (errno)));
4952 return 127;
4953 }
4954 return rval;
4955 EOF
4956 ;;
4957 *)
4958 cat <<"EOF"
4959 execv (lt_argv_zero, newargz);
4960 return rval; /* =127, but avoids unused variable warning */
4961 EOF
4962 ;;
4963 esac
4964
4965 cat <<"EOF"
4966 }
4967
4968 void *
4969 xmalloc (size_t num)
4970 {
4971 void *p = (void *) malloc (num);
4972 if (!p)
4973 lt_fatal (__FILE__, __LINE__, "memory exhausted");
4974
4975 return p;
4976 }
4977
4978 char *
4979 xstrdup (const char *string)
4980 {
4981 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4982 string) : NULL;
4983 }
4984
4985 const char *
4986 base_name (const char *name)
4987 {
4988 const char *base;
4989
4990 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4991 /* Skip over the disk name in MSDOS pathnames. */
4992 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4993 name += 2;
4994 #endif
4995
4996 for (base = name; *name; name++)
4997 if (IS_DIR_SEPARATOR (*name))
4998 base = name + 1;
4999 return base;
5000 }
5001
5002 int
5003 check_executable (const char *path)
5004 {
5005 struct stat st;
5006
5007 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
5008 nonempty (path));
5009 if ((!path) || (!*path))
5010 return 0;
5011
5012 if ((stat (path, &st) >= 0)
5013 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
5014 return 1;
5015 else
5016 return 0;
5017 }
5018
5019 int
5020 make_executable (const char *path)
5021 {
5022 int rval = 0;
5023 struct stat st;
5024
5025 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
5026 nonempty (path));
5027 if ((!path) || (!*path))
5028 return 0;
5029
5030 if (stat (path, &st) >= 0)
5031 {
5032 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
5033 }
5034 return rval;
5035 }
5036
5037 /* Searches for the full path of the wrapper. Returns
5038 newly allocated full path name if found, NULL otherwise
5039 Does not chase symlinks, even on platforms that support them.
5040 */
5041 char *
5042 find_executable (const char *wrapper)
5043 {
5044 int has_slash = 0;
5045 const char *p;
5046 const char *p_next;
5047 /* static buffer for getcwd */
5048 char tmp[LT_PATHMAX + 1];
5049 int tmp_len;
5050 char *concat_name;
5051
5052 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
5053 nonempty (wrapper));
5054
5055 if ((wrapper == NULL) || (*wrapper == '\0'))
5056 return NULL;
5057
5058 /* Absolute path? */
5059 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5060 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
5061 {
5062 concat_name = xstrdup (wrapper);
5063 if (check_executable (concat_name))
5064 return concat_name;
5065 XFREE (concat_name);
5066 }
5067 else
5068 {
5069 #endif
5070 if (IS_DIR_SEPARATOR (wrapper[0]))
5071 {
5072 concat_name = xstrdup (wrapper);
5073 if (check_executable (concat_name))
5074 return concat_name;
5075 XFREE (concat_name);
5076 }
5077 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
5078 }
5079 #endif
5080
5081 for (p = wrapper; *p; p++)
5082 if (*p == '/')
5083 {
5084 has_slash = 1;
5085 break;
5086 }
5087 if (!has_slash)
5088 {
5089 /* no slashes; search PATH */
5090 const char *path = getenv ("PATH");
5091 if (path != NULL)
5092 {
5093 for (p = path; *p; p = p_next)
5094 {
5095 const char *q;
5096 size_t p_len;
5097 for (q = p; *q; q++)
5098 if (IS_PATH_SEPARATOR (*q))
5099 break;
5100 p_len = q - p;
5101 p_next = (*q == '\0' ? q : q + 1);
5102 if (p_len == 0)
5103 {
5104 /* empty path: current directory */
5105 if (getcwd (tmp, LT_PATHMAX) == NULL)
5106 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
5107 nonnull (strerror (errno)));
5108 tmp_len = strlen (tmp);
5109 concat_name =
5110 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
5111 memcpy (concat_name, tmp, tmp_len);
5112 concat_name[tmp_len] = '/';
5113 strcpy (concat_name + tmp_len + 1, wrapper);
5114 }
5115 else
5116 {
5117 concat_name =
5118 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
5119 memcpy (concat_name, p, p_len);
5120 concat_name[p_len] = '/';
5121 strcpy (concat_name + p_len + 1, wrapper);
5122 }
5123 if (check_executable (concat_name))
5124 return concat_name;
5125 XFREE (concat_name);
5126 }
5127 }
5128 /* not found in PATH; assume curdir */
5129 }
5130 /* Relative path | not found in path: prepend cwd */
5131 if (getcwd (tmp, LT_PATHMAX) == NULL)
5132 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
5133 nonnull (strerror (errno)));
5134 tmp_len = strlen (tmp);
5135 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
5136 memcpy (concat_name, tmp, tmp_len);
5137 concat_name[tmp_len] = '/';
5138 strcpy (concat_name + tmp_len + 1, wrapper);
5139
5140 if (check_executable (concat_name))
5141 return concat_name;
5142 XFREE (concat_name);
5143 return NULL;
5144 }
5145
5146 char *
5147 chase_symlinks (const char *pathspec)
5148 {
5149 #ifndef S_ISLNK
5150 return xstrdup (pathspec);
5151 #else
5152 char buf[LT_PATHMAX];
5153 struct stat s;
5154 char *tmp_pathspec = xstrdup (pathspec);
5155 char *p;
5156 int has_symlinks = 0;
5157 while (strlen (tmp_pathspec) && !has_symlinks)
5158 {
5159 lt_debugprintf (__FILE__, __LINE__,
5160 "checking path component for symlinks: %s\n",
5161 tmp_pathspec);
5162 if (lstat (tmp_pathspec, &s) == 0)
5163 {
5164 if (S_ISLNK (s.st_mode) != 0)
5165 {
5166 has_symlinks = 1;
5167 break;
5168 }
5169
5170 /* search backwards for last DIR_SEPARATOR */
5171 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
5172 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
5173 p--;
5174 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
5175 {
5176 /* no more DIR_SEPARATORS left */
5177 break;
5178 }
5179 *p = '\0';
5180 }
5181 else
5182 {
5183 lt_fatal (__FILE__, __LINE__,
5184 "error accessing file \"%s\": %s",
5185 tmp_pathspec, nonnull (strerror (errno)));
5186 }
5187 }
5188 XFREE (tmp_pathspec);
5189
5190 if (!has_symlinks)
5191 {
5192 return xstrdup (pathspec);
5193 }
5194
5195 tmp_pathspec = realpath (pathspec, buf);
5196 if (tmp_pathspec == 0)
5197 {
5198 lt_fatal (__FILE__, __LINE__,
5199 "could not follow symlinks for %s", pathspec);
5200 }
5201 return xstrdup (tmp_pathspec);
5202 #endif
5203 }
5204
5205 char *
5206 strendzap (char *str, const char *pat)
5207 {
5208 size_t len, patlen;
5209
5210 assert (str != NULL);
5211 assert (pat != NULL);
5212
5213 len = strlen (str);
5214 patlen = strlen (pat);
5215
5216 if (patlen <= len)
5217 {
5218 str += len - patlen;
5219 if (strcmp (str, pat) == 0)
5220 *str = '\0';
5221 }
5222 return str;
5223 }
5224
5225 void
5226 lt_debugprintf (const char *file, int line, const char *fmt, ...)
5227 {
5228 va_list args;
5229 if (lt_debug)
5230 {
5231 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
5232 va_start (args, fmt);
5233 (void) vfprintf (stderr, fmt, args);
5234 va_end (args);
5235 }
5236 }
5237
5238 static void
5239 lt_error_core (int exit_status, const char *file,
5240 int line, const char *mode,
5241 const char *message, va_list ap)
5242 {
5243 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
5244 vfprintf (stderr, message, ap);
5245 fprintf (stderr, ".\n");
5246
5247 if (exit_status >= 0)
5248 exit (exit_status);
5249 }
5250
5251 void
5252 lt_fatal (const char *file, int line, const char *message, ...)
5253 {
5254 va_list ap;
5255 va_start (ap, message);
5256 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
5257 va_end (ap);
5258 }
5259
5260 static const char *
5261 nonnull (const char *s)
5262 {
5263 return s ? s : "(null)";
5264 }
5265
5266 static const char *
5267 nonempty (const char *s)
5268 {
5269 return (s && !*s) ? "(empty)" : nonnull (s);
5270 }
5271
5272 void
5273 lt_setenv (const char *name, const char *value)
5274 {
5275 lt_debugprintf (__FILE__, __LINE__,
5276 "(lt_setenv) setting '%s' to '%s'\n",
5277 nonnull (name), nonnull (value));
5278 {
5279 #ifdef HAVE_SETENV
5280 /* always make a copy, for consistency with !HAVE_SETENV */
5281 char *str = xstrdup (value);
5282 setenv (name, str, 1);
5283 #else
5284 int len = strlen (name) + 1 + strlen (value) + 1;
5285 char *str = XMALLOC (char, len);
5286 sprintf (str, "%s=%s", name, value);
5287 if (putenv (str) != EXIT_SUCCESS)
5288 {
5289 XFREE (str);
5290 }
5291 #endif
5292 }
5293 }
5294
5295 char *
5296 lt_extend_str (const char *orig_value, const char *add, int to_end)
5297 {
5298 char *new_value;
5299 if (orig_value && *orig_value)
5300 {
5301 int orig_value_len = strlen (orig_value);
5302 int add_len = strlen (add);
5303 new_value = XMALLOC (char, add_len + orig_value_len + 1);
5304 if (to_end)
5305 {
5306 strcpy (new_value, orig_value);
5307 strcpy (new_value + orig_value_len, add);
5308 }
5309 else
5310 {
5311 strcpy (new_value, add);
5312 strcpy (new_value + add_len, orig_value);
5313 }
5314 }
5315 else
5316 {
5317 new_value = xstrdup (add);
5318 }
5319 return new_value;
5320 }
5321
5322 void
5323 lt_update_exe_path (const char *name, const char *value)
5324 {
5325 lt_debugprintf (__FILE__, __LINE__,
5326 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
5327 nonnull (name), nonnull (value));
5328
5329 if (name && *name && value && *value)
5330 {
5331 char *new_value = lt_extend_str (getenv (name), value, 0);
5332 /* some systems can't cope with a ':'-terminated path #' */
5333 int len = strlen (new_value);
5334 while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
5335 {
5336 new_value[len-1] = '\0';
5337 }
5338 lt_setenv (name, new_value);
5339 XFREE (new_value);
5340 }
5341 }
5342
5343 void
5344 lt_update_lib_path (const char *name, const char *value)
5345 {
5346 lt_debugprintf (__FILE__, __LINE__,
5347 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
5348 nonnull (name), nonnull (value));
5349
5350 if (name && *name && value && *value)
5351 {
5352 char *new_value = lt_extend_str (getenv (name), value, 0);
5353 lt_setenv (name, new_value);
5354 XFREE (new_value);
5355 }
5356 }
5357
5358 EOF
5359 case $host_os in
5360 mingw*)
5361 cat <<"EOF"
5362
5363 /* Prepares an argument vector before calling spawn().
5364 Note that spawn() does not by itself call the command interpreter
5365 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
5366 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
5367 GetVersionEx(&v);
5368 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
5369 }) ? "cmd.exe" : "command.com").
5370 Instead it simply concatenates the arguments, separated by ' ', and calls
5371 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
5372 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
5373 special way:
5374 - Space and tab are interpreted as delimiters. They are not treated as
5375 delimiters if they are surrounded by double quotes: "...".
5376 - Unescaped double quotes are removed from the input. Their only effect is
5377 that within double quotes, space and tab are treated like normal
5378 characters.
5379 - Backslashes not followed by double quotes are not special.
5380 - But 2*n+1 backslashes followed by a double quote become
5381 n backslashes followed by a double quote (n >= 0):
5382 \" -> "
5383 \\\" -> \"
5384 \\\\\" -> \\"
5385 */
5386 #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
5387 #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
5388 char **
5389 prepare_spawn (char **argv)
5390 {
5391 size_t argc;
5392 char **new_argv;
5393 size_t i;
5394
5395 /* Count number of arguments. */
5396 for (argc = 0; argv[argc] != NULL; argc++)
5397 ;
5398
5399 /* Allocate new argument vector. */
5400 new_argv = XMALLOC (char *, argc + 1);
5401
5402 /* Put quoted arguments into the new argument vector. */
5403 for (i = 0; i < argc; i++)
5404 {
5405 const char *string = argv[i];
5406
5407 if (string[0] == '\0')
5408 new_argv[i] = xstrdup ("\"\"");
5409 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
5410 {
5411 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
5412 size_t length;
5413 unsigned int backslashes;
5414 const char *s;
5415 char *quoted_string;
5416 char *p;
5417
5418 length = 0;
5419 backslashes = 0;
5420 if (quote_around)
5421 length++;
5422 for (s = string; *s != '\0'; s++)
5423 {
5424 char c = *s;
5425 if (c == '"')
5426 length += backslashes + 1;
5427 length++;
5428 if (c == '\\')
5429 backslashes++;
5430 else
5431 backslashes = 0;
5432 }
5433 if (quote_around)
5434 length += backslashes + 1;
5435
5436 quoted_string = XMALLOC (char, length + 1);
5437
5438 p = quoted_string;
5439 backslashes = 0;
5440 if (quote_around)
5441 *p++ = '"';
5442 for (s = string; *s != '\0'; s++)
5443 {
5444 char c = *s;
5445 if (c == '"')
5446 {
5447 unsigned int j;
5448 for (j = backslashes + 1; j > 0; j--)
5449 *p++ = '\\';
5450 }
5451 *p++ = c;
5452 if (c == '\\')
5453 backslashes++;
5454 else
5455 backslashes = 0;
5456 }
5457 if (quote_around)
5458 {
5459 unsigned int j;
5460 for (j = backslashes; j > 0; j--)
5461 *p++ = '\\';
5462 *p++ = '"';
5463 }
5464 *p = '\0';
5465
5466 new_argv[i] = quoted_string;
5467 }
5468 else
5469 new_argv[i] = (char *) string;
5470 }
5471 new_argv[argc] = NULL;
5472
5473 return new_argv;
5474 }
5475 EOF
5476 ;;
5477 esac
5478
5479 cat <<"EOF"
5480 void lt_dump_script (FILE* f)
5481 {
5482 EOF
5483 func_emit_wrapper yes |
5484 $SED -n -e '
5485 s/^\(.\{79\}\)\(..*\)/\1\
5486 \2/
5487 h
5488 s/\([\\"]\)/\\\1/g
5489 s/$/\\n/
5490 s/\([^\n]*\).*/ fputs ("\1", f);/p
5491 g
5492 D'
5493 cat <<"EOF"
5494 }
5495 EOF
5496 }
5497 # end: func_emit_cwrapperexe_src
5498
5499 # func_win32_import_lib_p ARG
5500 # True if ARG is an import lib, as indicated by $file_magic_cmd
5501 func_win32_import_lib_p ()
5502 {
5503 $opt_debug
5504 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5505 *import*) : ;;
5506 *) false ;;
5507 esac
5508 }
5509
5510 # func_mode_link arg...
5511 func_mode_link ()
5512 {
5513 $opt_debug
5514 case $host in
5515 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5516 # It is impossible to link a dll without this setting, and
5517 # we shouldn't force the makefile maintainer to figure out
5518 # which system we are compiling for in order to pass an extra
5519 # flag for every libtool invocation.
5520 # allow_undefined=no
5521
5522 # FIXME: Unfortunately, there are problems with the above when trying
5523 # to make a dll which has undefined symbols, in which case not
5524 # even a static library is built. For now, we need to specify
5525 # -no-undefined on the libtool link line when we can be certain
5526 # that all symbols are satisfied, otherwise we get a static library.
5527 allow_undefined=yes
5528 ;;
5529 *)
5530 allow_undefined=yes
5531 ;;
5532 esac
5533 libtool_args=$nonopt
5534 base_compile="$nonopt $@"
5535 compile_command=$nonopt
5536 finalize_command=$nonopt
5537
5538 compile_rpath=
5539 finalize_rpath=
5540 compile_shlibpath=
5541 finalize_shlibpath=
5542 convenience=
5543 old_convenience=
5544 deplibs=
5545 old_deplibs=
5546 compiler_flags=
5547 linker_flags=
5548 dllsearchpath=
5549 lib_search_path=`pwd`
5550 inst_prefix_dir=
5551 new_inherited_linker_flags=
5552
5553 avoid_version=no
5554 bindir=
5555 dlfiles=
5556 dlprefiles=
5557 dlself=no
5558 export_dynamic=no
5559 export_symbols=
5560 export_symbols_regex=
5561 generated=
5562 libobjs=
5563 ltlibs=
5564 module=no
5565 no_install=no
5566 objs=
5567 non_pic_objects=
5568 precious_files_regex=
5569 prefer_static_libs=no
5570 preload=no
5571 prev=
5572 prevarg=
5573 release=
5574 rpath=
5575 xrpath=
5576 perm_rpath=
5577 temp_rpath=
5578 thread_safe=no
5579 vinfo=
5580 vinfo_number=no
5581 weak_libs=
5582 single_module="${wl}-single_module"
5583 func_infer_tag $base_compile
5584
5585 # We need to know -static, to get the right output filenames.
5586 for arg
5587 do
5588 case $arg in
5589 -shared)
5590 test "$build_libtool_libs" != yes && \
5591 func_fatal_configuration "can not build a shared library"
5592 build_old_libs=no
5593 break
5594 ;;
5595 -all-static | -static | -static-libtool-libs)
5596 case $arg in
5597 -all-static)
5598 if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5599 func_warning "complete static linking is impossible in this configuration"
5600 fi
5601 if test -n "$link_static_flag"; then
5602 dlopen_self=$dlopen_self_static
5603 fi
5604 prefer_static_libs=yes
5605 ;;
5606 -static)
5607 if test -z "$pic_flag" && test -n "$link_static_flag"; then
5608 dlopen_self=$dlopen_self_static
5609 fi
5610 prefer_static_libs=built
5611 ;;
5612 -static-libtool-libs)
5613 if test -z "$pic_flag" && test -n "$link_static_flag"; then
5614 dlopen_self=$dlopen_self_static
5615 fi
5616 prefer_static_libs=yes
5617 ;;
5618 esac
5619 build_libtool_libs=no
5620 build_old_libs=yes
5621 break
5622 ;;
5623 esac
5624 done
5625
5626 # See if our shared archives depend on static archives.
5627 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5628
5629 # Go through the arguments, transforming them on the way.
5630 while test "$#" -gt 0; do
5631 arg="$1"
5632 shift
5633 func_quote_for_eval "$arg"
5634 qarg=$func_quote_for_eval_unquoted_result
5635 libtool_args+=" $func_quote_for_eval_result"
5636
5637 # If the previous option needs an argument, assign it.
5638 if test -n "$prev"; then
5639 case $prev in
5640 output)
5641 compile_command+=" @OUTPUT@"
5642 finalize_command+=" @OUTPUT@"
5643 ;;
5644 esac
5645
5646 case $prev in
5647 bindir)
5648 bindir="$arg"
5649 prev=
5650 continue
5651 ;;
5652 dlfiles|dlprefiles)
5653 if test "$preload" = no; then
5654 # Add the symbol object into the linking commands.
5655 compile_command+=" @SYMFILE@"
5656 finalize_command+=" @SYMFILE@"
5657 preload=yes
5658 fi
5659 case $arg in
5660 *.la | *.lo) ;; # We handle these cases below.
5661 force)
5662 if test "$dlself" = no; then
5663 dlself=needless
5664 export_dynamic=yes
5665 fi
5666 prev=
5667 continue
5668 ;;
5669 self)
5670 if test "$prev" = dlprefiles; then
5671 dlself=yes
5672 elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5673 dlself=yes
5674 else
5675 dlself=needless
5676 export_dynamic=yes
5677 fi
5678 prev=
5679 continue
5680 ;;
5681 *)
5682 if test "$prev" = dlfiles; then
5683 dlfiles+=" $arg"
5684 else
5685 dlprefiles+=" $arg"
5686 fi
5687 prev=
5688 continue
5689 ;;
5690 esac
5691 ;;
5692 expsyms)
5693 export_symbols="$arg"
5694 test -f "$arg" \
5695 || func_fatal_error "symbol file \`$arg' does not exist"
5696 prev=
5697 continue
5698 ;;
5699 expsyms_regex)
5700 export_symbols_regex="$arg"
5701 prev=
5702 continue
5703 ;;
5704 framework)
5705 case $host in
5706 *-*-darwin*)
5707 case "$deplibs " in
5708 *" $qarg.ltframework "*) ;;
5709 *) deplibs+=" $qarg.ltframework" # this is fixed later
5710 ;;
5711 esac
5712 ;;
5713 esac
5714 prev=
5715 continue
5716 ;;
5717 inst_prefix)
5718 inst_prefix_dir="$arg"
5719 prev=
5720 continue
5721 ;;
5722 objectlist)
5723 if test -f "$arg"; then
5724 save_arg=$arg
5725 moreargs=
5726 for fil in `cat "$save_arg"`
5727 do
5728 # moreargs+=" $fil"
5729 arg=$fil
5730 # A libtool-controlled object.
5731
5732 # Check to see that this really is a libtool object.
5733 if func_lalib_unsafe_p "$arg"; then
5734 pic_object=
5735 non_pic_object=
5736
5737 # Read the .lo file
5738 func_source "$arg"
5739
5740 if test -z "$pic_object" ||
5741 test -z "$non_pic_object" ||
5742 test "$pic_object" = none &&
5743 test "$non_pic_object" = none; then
5744 func_fatal_error "cannot find name of object for \`$arg'"
5745 fi
5746
5747 # Extract subdirectory from the argument.
5748 func_dirname "$arg" "/" ""
5749 xdir="$func_dirname_result"
5750
5751 if test "$pic_object" != none; then
5752 # Prepend the subdirectory the object is found in.
5753 pic_object="$xdir$pic_object"
5754
5755 if test "$prev" = dlfiles; then
5756 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5757 dlfiles+=" $pic_object"
5758 prev=
5759 continue
5760 else
5761 # If libtool objects are unsupported, then we need to preload.
5762 prev=dlprefiles
5763 fi
5764 fi
5765
5766 # CHECK ME: I think I busted this. -Ossama
5767 if test "$prev" = dlprefiles; then
5768 # Preload the old-style object.
5769 dlprefiles+=" $pic_object"
5770 prev=
5771 fi
5772
5773 # A PIC object.
5774 libobjs+=" $pic_object"
5775 arg="$pic_object"
5776 fi
5777
5778 # Non-PIC object.
5779 if test "$non_pic_object" != none; then
5780 # Prepend the subdirectory the object is found in.
5781 non_pic_object="$xdir$non_pic_object"
5782
5783 # A standard non-PIC object
5784 non_pic_objects+=" $non_pic_object"
5785 if test -z "$pic_object" || test "$pic_object" = none ; then
5786 arg="$non_pic_object"
5787 fi
5788 else
5789 # If the PIC object exists, use it instead.
5790 # $xdir was prepended to $pic_object above.
5791 non_pic_object="$pic_object"
5792 non_pic_objects+=" $non_pic_object"
5793 fi
5794 else
5795 # Only an error if not doing a dry-run.
5796 if $opt_dry_run; then
5797 # Extract subdirectory from the argument.
5798 func_dirname "$arg" "/" ""
5799 xdir="$func_dirname_result"
5800
5801 func_lo2o "$arg"
5802 pic_object=$xdir$objdir/$func_lo2o_result
5803 non_pic_object=$xdir$func_lo2o_result
5804 libobjs+=" $pic_object"
5805 non_pic_objects+=" $non_pic_object"
5806 else
5807 func_fatal_error "\`$arg' is not a valid libtool object"
5808 fi
5809 fi
5810 done
5811 else
5812 func_fatal_error "link input file \`$arg' does not exist"
5813 fi
5814 arg=$save_arg
5815 prev=
5816 continue
5817 ;;
5818 precious_regex)
5819 precious_files_regex="$arg"
5820 prev=
5821 continue
5822 ;;
5823 release)
5824 release="-$arg"
5825 prev=
5826 continue
5827 ;;
5828 rpath | xrpath)
5829 # We need an absolute path.
5830 case $arg in
5831 [\\/]* | [A-Za-z]:[\\/]*) ;;
5832 *)
5833 func_fatal_error "only absolute run-paths are allowed"
5834 ;;
5835 esac
5836 if test "$prev" = rpath; then
5837 case "$rpath " in
5838 *" $arg "*) ;;
5839 *) rpath+=" $arg" ;;
5840 esac
5841 else
5842 case "$xrpath " in
5843 *" $arg "*) ;;
5844 *) xrpath+=" $arg" ;;
5845 esac
5846 fi
5847 prev=
5848 continue
5849 ;;
5850 shrext)
5851 shrext_cmds="$arg"
5852 prev=
5853 continue
5854 ;;
5855 weak)
5856 weak_libs+=" $arg"
5857 prev=
5858 continue
5859 ;;
5860 xcclinker)
5861 linker_flags+=" $qarg"
5862 compiler_flags+=" $qarg"
5863 prev=
5864 compile_command+=" $qarg"
5865 finalize_command+=" $qarg"
5866 continue
5867 ;;
5868 xcompiler)
5869 compiler_flags+=" $qarg"
5870 prev=
5871 compile_command+=" $qarg"
5872 finalize_command+=" $qarg"
5873 continue
5874 ;;
5875 xlinker)
5876 linker_flags+=" $qarg"
5877 compiler_flags+=" $wl$qarg"
5878 prev=
5879 compile_command+=" $wl$qarg"
5880 finalize_command+=" $wl$qarg"
5881 continue
5882 ;;
5883 *)
5884 eval "$prev=\"\$arg\""
5885 prev=
5886 continue
5887 ;;
5888 esac
5889 fi # test -n "$prev"
5890
5891 prevarg="$arg"
5892
5893 case $arg in
5894 -all-static)
5895 if test -n "$link_static_flag"; then
5896 # See comment for -static flag below, for more details.
5897 compile_command+=" $link_static_flag"
5898 finalize_command+=" $link_static_flag"
5899 fi
5900 continue
5901 ;;
5902
5903 -allow-undefined)
5904 # FIXME: remove this flag sometime in the future.
5905 func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5906 ;;
5907
5908 -avoid-version)
5909 avoid_version=yes
5910 continue
5911 ;;
5912
5913 -bindir)
5914 prev=bindir
5915 continue
5916 ;;
5917
5918 -dlopen)
5919 prev=dlfiles
5920 continue
5921 ;;
5922
5923 -dlpreopen)
5924 prev=dlprefiles
5925 continue
5926 ;;
5927
5928 -export-dynamic)
5929 export_dynamic=yes
5930 continue
5931 ;;
5932
5933 -export-symbols | -export-symbols-regex)
5934 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5935 func_fatal_error "more than one -exported-symbols argument is not allowed"
5936 fi
5937 if test "X$arg" = "X-export-symbols"; then
5938 prev=expsyms
5939 else
5940 prev=expsyms_regex
5941 fi
5942 continue
5943 ;;
5944
5945 -framework)
5946 prev=framework
5947 continue
5948 ;;
5949
5950 -inst-prefix-dir)
5951 prev=inst_prefix
5952 continue
5953 ;;
5954
5955 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5956 # so, if we see these flags be careful not to treat them like -L
5957 -L[A-Z][A-Z]*:*)
5958 case $with_gcc/$host in
5959 no/*-*-irix* | /*-*-irix*)
5960 compile_command+=" $arg"
5961 finalize_command+=" $arg"
5962 ;;
5963 esac
5964 continue
5965 ;;
5966
5967 -L*)
5968 func_stripname "-L" '' "$arg"
5969 if test -z "$func_stripname_result"; then
5970 if test "$#" -gt 0; then
5971 func_fatal_error "require no space between \`-L' and \`$1'"
5972 else
5973 func_fatal_error "need path for \`-L' option"
5974 fi
5975 fi
5976 func_resolve_sysroot "$func_stripname_result"
5977 dir=$func_resolve_sysroot_result
5978 # We need an absolute path.
5979 case $dir in
5980 [\\/]* | [A-Za-z]:[\\/]*) ;;
5981 *)
5982 absdir=`cd "$dir" && pwd`
5983 test -z "$absdir" && \
5984 func_fatal_error "cannot determine absolute directory name of \`$dir'"
5985 dir="$absdir"
5986 ;;
5987 esac
5988 case "$deplibs " in
5989 *" -L$dir "* | *" $arg "*)
5990 # Will only happen for absolute or sysroot arguments
5991 ;;
5992 *)
5993 # Preserve sysroot, but never include relative directories
5994 case $dir in
5995 [\\/]* | [A-Za-z]:[\\/]* | =*) deplibs+=" $arg" ;;
5996 *) deplibs+=" -L$dir" ;;
5997 esac
5998 lib_search_path+=" $dir"
5999 ;;
6000 esac
6001 case $host in
6002 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
6003 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
6004 case :$dllsearchpath: in
6005 *":$dir:"*) ;;
6006 ::) dllsearchpath=$dir;;
6007 *) dllsearchpath+=":$dir";;
6008 esac
6009 case :$dllsearchpath: in
6010 *":$testbindir:"*) ;;
6011 ::) dllsearchpath=$testbindir;;
6012 *) dllsearchpath+=":$testbindir";;
6013 esac
6014 ;;
6015 esac
6016 continue
6017 ;;
6018
6019 -l*)
6020 if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
6021 case $host in
6022 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
6023 # These systems don't actually have a C or math library (as such)
6024 continue
6025 ;;
6026 *-*-os2*)
6027 # These systems don't actually have a C library (as such)
6028 test "X$arg" = "X-lc" && continue
6029 ;;
6030 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
6031 # Do not include libc due to us having libc/libc_r.
6032 test "X$arg" = "X-lc" && continue
6033 ;;
6034 *-*-rhapsody* | *-*-darwin1.[012])
6035 # Rhapsody C and math libraries are in the System framework
6036 deplibs+=" System.ltframework"
6037 continue
6038 ;;
6039 *-*-sco3.2v5* | *-*-sco5v6*)
6040 # Causes problems with __ctype
6041 test "X$arg" = "X-lc" && continue
6042 ;;
6043 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
6044 # Compiler inserts libc in the correct place for threads to work
6045 test "X$arg" = "X-lc" && continue
6046 ;;
6047 esac
6048 elif test "X$arg" = "X-lc_r"; then
6049 case $host in
6050 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
6051 # Do not include libc_r directly, use -pthread flag.
6052 continue
6053 ;;
6054 esac
6055 fi
6056 deplibs+=" $arg"
6057 continue
6058 ;;
6059
6060 -module)
6061 module=yes
6062 continue
6063 ;;
6064
6065 # Tru64 UNIX uses -model [arg] to determine the layout of C++
6066 # classes, name mangling, and exception handling.
6067 # Darwin uses the -arch flag to determine output architecture.
6068 -model|-arch|-isysroot|--sysroot)
6069 compiler_flags+=" $arg"
6070 compile_command+=" $arg"
6071 finalize_command+=" $arg"
6072 prev=xcompiler
6073 continue
6074 ;;
6075
6076 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6077 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6078 compiler_flags+=" $arg"
6079 compile_command+=" $arg"
6080 finalize_command+=" $arg"
6081 case "$new_inherited_linker_flags " in
6082 *" $arg "*) ;;
6083 * ) new_inherited_linker_flags+=" $arg" ;;
6084 esac
6085 continue
6086 ;;
6087
6088 -multi_module)
6089 single_module="${wl}-multi_module"
6090 continue
6091 ;;
6092
6093 -no-fast-install)
6094 fast_install=no
6095 continue
6096 ;;
6097
6098 -no-install)
6099 case $host in
6100 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
6101 # The PATH hackery in wrapper scripts is required on Windows
6102 # and Darwin in order for the loader to find any dlls it needs.
6103 func_warning "\`-no-install' is ignored for $host"
6104 func_warning "assuming \`-no-fast-install' instead"
6105 fast_install=no
6106 ;;
6107 *) no_install=yes ;;
6108 esac
6109 continue
6110 ;;
6111
6112 -no-undefined)
6113 allow_undefined=no
6114 continue
6115 ;;
6116
6117 -objectlist)
6118 prev=objectlist
6119 continue
6120 ;;
6121
6122 -o) prev=output ;;
6123
6124 -precious-files-regex)
6125 prev=precious_regex
6126 continue
6127 ;;
6128
6129 -release)
6130 prev=release
6131 continue
6132 ;;
6133
6134 -rpath)
6135 prev=rpath
6136 continue
6137 ;;
6138
6139 -R)
6140 prev=xrpath
6141 continue
6142 ;;
6143
6144 -R*)
6145 func_stripname '-R' '' "$arg"
6146 dir=$func_stripname_result
6147 # We need an absolute path.
6148 case $dir in
6149 [\\/]* | [A-Za-z]:[\\/]*) ;;
6150 =*)
6151 func_stripname '=' '' "$dir"
6152 dir=$lt_sysroot$func_stripname_result
6153 ;;
6154 *)
6155 func_fatal_error "only absolute run-paths are allowed"
6156 ;;
6157 esac
6158 case "$xrpath " in
6159 *" $dir "*) ;;
6160 *) xrpath+=" $dir" ;;
6161 esac
6162 continue
6163 ;;
6164
6165 -shared)
6166 # The effects of -shared are defined in a previous loop.
6167 continue
6168 ;;
6169
6170 -shrext)
6171 prev=shrext
6172 continue
6173 ;;
6174
6175 -static | -static-libtool-libs)
6176 # The effects of -static are defined in a previous loop.
6177 # We used to do the same as -all-static on platforms that
6178 # didn't have a PIC flag, but the assumption that the effects
6179 # would be equivalent was wrong. It would break on at least
6180 # Digital Unix and AIX.
6181 continue
6182 ;;
6183
6184 -thread-safe)
6185 thread_safe=yes
6186 continue
6187 ;;
6188
6189 -version-info)
6190 prev=vinfo
6191 continue
6192 ;;
6193
6194 -version-number)
6195 prev=vinfo
6196 vinfo_number=yes
6197 continue
6198 ;;
6199
6200 -weak)
6201 prev=weak
6202 continue
6203 ;;
6204
6205 -Wc,*)
6206 func_stripname '-Wc,' '' "$arg"
6207 args=$func_stripname_result
6208 arg=
6209 save_ifs="$IFS"; IFS=','
6210 for flag in $args; do
6211 IFS="$save_ifs"
6212 func_quote_for_eval "$flag"
6213 arg+=" $func_quote_for_eval_result"
6214 compiler_flags+=" $func_quote_for_eval_result"
6215 done
6216 IFS="$save_ifs"
6217 func_stripname ' ' '' "$arg"
6218 arg=$func_stripname_result
6219 ;;
6220
6221 -Wl,*)
6222 func_stripname '-Wl,' '' "$arg"
6223 args=$func_stripname_result
6224 arg=
6225 save_ifs="$IFS"; IFS=','
6226 for flag in $args; do
6227 IFS="$save_ifs"
6228 func_quote_for_eval "$flag"
6229 arg+=" $wl$func_quote_for_eval_result"
6230 compiler_flags+=" $wl$func_quote_for_eval_result"
6231 linker_flags+=" $func_quote_for_eval_result"
6232 done
6233 IFS="$save_ifs"
6234 func_stripname ' ' '' "$arg"
6235 arg=$func_stripname_result
6236 ;;
6237
6238 -Xcompiler)
6239 prev=xcompiler
6240 continue
6241 ;;
6242
6243 -Xlinker)
6244 prev=xlinker
6245 continue
6246 ;;
6247
6248 -XCClinker)
6249 prev=xcclinker
6250 continue
6251 ;;
6252
6253 # -msg_* for osf cc
6254 -msg_*)
6255 func_quote_for_eval "$arg"
6256 arg="$func_quote_for_eval_result"
6257 ;;
6258
6259 # Flags to be passed through unchanged, with rationale:
6260 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
6261 # -r[0-9][0-9]* specify processor for the SGI compiler
6262 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
6263 # +DA*, +DD* enable 64-bit mode for the HP compiler
6264 # -q* compiler args for the IBM compiler
6265 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
6266 # -F/path path to uninstalled frameworks, gcc on darwin
6267 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
6268 # @file GCC response files
6269 # -tp=* Portland pgcc target processor selection
6270 # --sysroot=* for sysroot support
6271 # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
6272 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
6273 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
6274 -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
6275 func_quote_for_eval "$arg"
6276 arg="$func_quote_for_eval_result"
6277 compile_command+=" $arg"
6278 finalize_command+=" $arg"
6279 compiler_flags+=" $arg"
6280 continue
6281 ;;
6282
6283 # Some other compiler flag.
6284 -* | +*)
6285 func_quote_for_eval "$arg"
6286 arg="$func_quote_for_eval_result"
6287 ;;
6288
6289 *.$objext)
6290 # A standard object.
6291 objs+=" $arg"
6292 ;;
6293
6294 *.lo)
6295 # A libtool-controlled object.
6296
6297 # Check to see that this really is a libtool object.
6298 if func_lalib_unsafe_p "$arg"; then
6299 pic_object=
6300 non_pic_object=
6301
6302 # Read the .lo file
6303 func_source "$arg"
6304
6305 if test -z "$pic_object" ||
6306 test -z "$non_pic_object" ||
6307 test "$pic_object" = none &&
6308 test "$non_pic_object" = none; then
6309 func_fatal_error "cannot find name of object for \`$arg'"
6310 fi
6311
6312 # Extract subdirectory from the argument.
6313 func_dirname "$arg" "/" ""
6314 xdir="$func_dirname_result"
6315
6316 if test "$pic_object" != none; then
6317 # Prepend the subdirectory the object is found in.
6318 pic_object="$xdir$pic_object"
6319
6320 if test "$prev" = dlfiles; then
6321 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
6322 dlfiles+=" $pic_object"
6323 prev=
6324 continue
6325 else
6326 # If libtool objects are unsupported, then we need to preload.
6327 prev=dlprefiles
6328 fi
6329 fi
6330
6331 # CHECK ME: I think I busted this. -Ossama
6332 if test "$prev" = dlprefiles; then
6333 # Preload the old-style object.
6334 dlprefiles+=" $pic_object"
6335 prev=
6336 fi
6337
6338 # A PIC object.
6339 libobjs+=" $pic_object"
6340 arg="$pic_object"
6341 fi
6342
6343 # Non-PIC object.
6344 if test "$non_pic_object" != none; then
6345 # Prepend the subdirectory the object is found in.
6346 non_pic_object="$xdir$non_pic_object"
6347
6348 # A standard non-PIC object
6349 non_pic_objects+=" $non_pic_object"
6350 if test -z "$pic_object" || test "$pic_object" = none ; then
6351 arg="$non_pic_object"
6352 fi
6353 else
6354 # If the PIC object exists, use it instead.
6355 # $xdir was prepended to $pic_object above.
6356 non_pic_object="$pic_object"
6357 non_pic_objects+=" $non_pic_object"
6358 fi
6359 else
6360 # Only an error if not doing a dry-run.
6361 if $opt_dry_run; then
6362 # Extract subdirectory from the argument.
6363 func_dirname "$arg" "/" ""
6364 xdir="$func_dirname_result"
6365
6366 func_lo2o "$arg"
6367 pic_object=$xdir$objdir/$func_lo2o_result
6368 non_pic_object=$xdir$func_lo2o_result
6369 libobjs+=" $pic_object"
6370 non_pic_objects+=" $non_pic_object"
6371 else
6372 func_fatal_error "\`$arg' is not a valid libtool object"
6373 fi
6374 fi
6375 ;;
6376
6377 *.$libext)
6378 # An archive.
6379 deplibs+=" $arg"
6380 old_deplibs+=" $arg"
6381 continue
6382 ;;
6383
6384 *.la)
6385 # A libtool-controlled library.
6386
6387 func_resolve_sysroot "$arg"
6388 if test "$prev" = dlfiles; then
6389 # This library was specified with -dlopen.
6390 dlfiles+=" $func_resolve_sysroot_result"
6391 prev=
6392 elif test "$prev" = dlprefiles; then
6393 # The library was specified with -dlpreopen.
6394 dlprefiles+=" $func_resolve_sysroot_result"
6395 prev=
6396 else
6397 deplibs+=" $func_resolve_sysroot_result"
6398 fi
6399 continue
6400 ;;
6401
6402 # Some other compiler argument.
6403 *)
6404 # Unknown arguments in both finalize_command and compile_command need
6405 # to be aesthetically quoted because they are evaled later.
6406 func_quote_for_eval "$arg"
6407 arg="$func_quote_for_eval_result"
6408 ;;
6409 esac # arg
6410
6411 # Now actually substitute the argument into the commands.
6412 if test -n "$arg"; then
6413 compile_command+=" $arg"
6414 finalize_command+=" $arg"
6415 fi
6416 done # argument parsing loop
6417
6418 test -n "$prev" && \
6419 func_fatal_help "the \`$prevarg' option requires an argument"
6420
6421 if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6422 eval arg=\"$export_dynamic_flag_spec\"
6423 compile_command+=" $arg"
6424 finalize_command+=" $arg"
6425 fi
6426
6427 oldlibs=
6428 # calculate the name of the file, without its directory
6429 func_basename "$output"
6430 outputname="$func_basename_result"
6431 libobjs_save="$libobjs"
6432
6433 if test -n "$shlibpath_var"; then
6434 # get the directories listed in $shlibpath_var
6435 eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6436 else
6437 shlib_search_path=
6438 fi
6439 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6440 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6441
6442 func_dirname "$output" "/" ""
6443 output_objdir="$func_dirname_result$objdir"
6444 func_to_tool_file "$output_objdir/"
6445 tool_output_objdir=$func_to_tool_file_result
6446 # Create the object directory.
6447 func_mkdir_p "$output_objdir"
6448
6449 # Determine the type of output
6450 case $output in
6451 "")
6452 func_fatal_help "you must specify an output file"
6453 ;;
6454 *.$libext) linkmode=oldlib ;;
6455 *.lo | *.$objext) linkmode=obj ;;
6456 *.la) linkmode=lib ;;
6457 *) linkmode=prog ;; # Anything else should be a program.
6458 esac
6459
6460 specialdeplibs=
6461
6462 libs=
6463 # Find all interdependent deplibs by searching for libraries
6464 # that are linked more than once (e.g. -la -lb -la)
6465 for deplib in $deplibs; do
6466 if $opt_preserve_dup_deps ; then
6467 case "$libs " in
6468 *" $deplib "*) specialdeplibs+=" $deplib" ;;
6469 esac
6470 fi
6471 libs+=" $deplib"
6472 done
6473
6474 if test "$linkmode" = lib; then
6475 libs="$predeps $libs $compiler_lib_search_path $postdeps"
6476
6477 # Compute libraries that are listed more than once in $predeps
6478 # $postdeps and mark them as special (i.e., whose duplicates are
6479 # not to be eliminated).
6480 pre_post_deps=
6481 if $opt_duplicate_compiler_generated_deps; then
6482 for pre_post_dep in $predeps $postdeps; do
6483 case "$pre_post_deps " in
6484 *" $pre_post_dep "*) specialdeplibs+=" $pre_post_deps" ;;
6485 esac
6486 pre_post_deps+=" $pre_post_dep"
6487 done
6488 fi
6489 pre_post_deps=
6490 fi
6491
6492 deplibs=
6493 newdependency_libs=
6494 newlib_search_path=
6495 need_relink=no # whether we're linking any uninstalled libtool libraries
6496 notinst_deplibs= # not-installed libtool libraries
6497 notinst_path= # paths that contain not-installed libtool libraries
6498
6499 case $linkmode in
6500 lib)
6501 passes="conv dlpreopen link"
6502 for file in $dlfiles $dlprefiles; do
6503 case $file in
6504 *.la) ;;
6505 *)
6506 func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6507 ;;
6508 esac
6509 done
6510 ;;
6511 prog)
6512 compile_deplibs=
6513 finalize_deplibs=
6514 alldeplibs=no
6515 newdlfiles=
6516 newdlprefiles=
6517 passes="conv scan dlopen dlpreopen link"
6518 ;;
6519 *) passes="conv"
6520 ;;
6521 esac
6522
6523 for pass in $passes; do
6524 # The preopen pass in lib mode reverses $deplibs; put it back here
6525 # so that -L comes before libs that need it for instance...
6526 if test "$linkmode,$pass" = "lib,link"; then
6527 ## FIXME: Find the place where the list is rebuilt in the wrong
6528 ## order, and fix it there properly
6529 tmp_deplibs=
6530 for deplib in $deplibs; do
6531 tmp_deplibs="$deplib $tmp_deplibs"
6532 done
6533 deplibs="$tmp_deplibs"
6534 fi
6535
6536 if test "$linkmode,$pass" = "lib,link" ||
6537 test "$linkmode,$pass" = "prog,scan"; then
6538 libs="$deplibs"
6539 deplibs=
6540 fi
6541 if test "$linkmode" = prog; then
6542 case $pass in
6543 dlopen) libs="$dlfiles" ;;
6544 dlpreopen) libs="$dlprefiles" ;;
6545 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6546 esac
6547 fi
6548 if test "$linkmode,$pass" = "lib,dlpreopen"; then
6549 # Collect and forward deplibs of preopened libtool libs
6550 for lib in $dlprefiles; do
6551 # Ignore non-libtool-libs
6552 dependency_libs=
6553 func_resolve_sysroot "$lib"
6554 case $lib in
6555 *.la) func_source "$func_resolve_sysroot_result" ;;
6556 esac
6557
6558 # Collect preopened libtool deplibs, except any this library
6559 # has declared as weak libs
6560 for deplib in $dependency_libs; do
6561 func_basename "$deplib"
6562 deplib_base=$func_basename_result
6563 case " $weak_libs " in
6564 *" $deplib_base "*) ;;
6565 *) deplibs+=" $deplib" ;;
6566 esac
6567 done
6568 done
6569 libs="$dlprefiles"
6570 fi
6571 if test "$pass" = dlopen; then
6572 # Collect dlpreopened libraries
6573 save_deplibs="$deplibs"
6574 deplibs=
6575 fi
6576
6577 for deplib in $libs; do
6578 lib=
6579 found=no
6580 case $deplib in
6581 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6582 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6583 if test "$linkmode,$pass" = "prog,link"; then
6584 compile_deplibs="$deplib $compile_deplibs"
6585 finalize_deplibs="$deplib $finalize_deplibs"
6586 else
6587 compiler_flags+=" $deplib"
6588 if test "$linkmode" = lib ; then
6589 case "$new_inherited_linker_flags " in
6590 *" $deplib "*) ;;
6591 * ) new_inherited_linker_flags+=" $deplib" ;;
6592 esac
6593 fi
6594 fi
6595 continue
6596 ;;
6597 -l*)
6598 if test "$linkmode" != lib && test "$linkmode" != prog; then
6599 func_warning "\`-l' is ignored for archives/objects"
6600 continue
6601 fi
6602 func_stripname '-l' '' "$deplib"
6603 name=$func_stripname_result
6604 if test "$linkmode" = lib; then
6605 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6606 else
6607 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6608 fi
6609 for searchdir in $searchdirs; do
6610 for search_ext in .la $std_shrext .so .a; do
6611 # Search the libtool library
6612 lib="$searchdir/lib${name}${search_ext}"
6613 if test -f "$lib"; then
6614 if test "$search_ext" = ".la"; then
6615 found=yes
6616 else
6617 found=no
6618 fi
6619 break 2
6620 fi
6621 done
6622 done
6623 if test "$found" != yes; then
6624 # deplib doesn't seem to be a libtool library
6625 if test "$linkmode,$pass" = "prog,link"; then
6626 compile_deplibs="$deplib $compile_deplibs"
6627 finalize_deplibs="$deplib $finalize_deplibs"
6628 else
6629 deplibs="$deplib $deplibs"
6630 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6631 fi
6632 continue
6633 else # deplib is a libtool library
6634 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6635 # We need to do some special things here, and not later.
6636 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6637 case " $predeps $postdeps " in
6638 *" $deplib "*)
6639 if func_lalib_p "$lib"; then
6640 library_names=
6641 old_library=
6642 func_source "$lib"
6643 for l in $old_library $library_names; do
6644 ll="$l"
6645 done
6646 if test "X$ll" = "X$old_library" ; then # only static version available
6647 found=no
6648 func_dirname "$lib" "" "."
6649 ladir="$func_dirname_result"
6650 lib=$ladir/$old_library
6651 if test "$linkmode,$pass" = "prog,link"; then
6652 compile_deplibs="$deplib $compile_deplibs"
6653 finalize_deplibs="$deplib $finalize_deplibs"
6654 else
6655 deplibs="$deplib $deplibs"
6656 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6657 fi
6658 continue
6659 fi
6660 fi
6661 ;;
6662 *) ;;
6663 esac
6664 fi
6665 fi
6666 ;; # -l
6667 *.ltframework)
6668 if test "$linkmode,$pass" = "prog,link"; then
6669 compile_deplibs="$deplib $compile_deplibs"
6670 finalize_deplibs="$deplib $finalize_deplibs"
6671 else
6672 deplibs="$deplib $deplibs"
6673 if test "$linkmode" = lib ; then
6674 case "$new_inherited_linker_flags " in
6675 *" $deplib "*) ;;
6676 * ) new_inherited_linker_flags+=" $deplib" ;;
6677 esac
6678 fi
6679 fi
6680 continue
6681 ;;
6682 -L*)
6683 case $linkmode in
6684 lib)
6685 deplibs="$deplib $deplibs"
6686 test "$pass" = conv && continue
6687 newdependency_libs="$deplib $newdependency_libs"
6688 func_stripname '-L' '' "$deplib"
6689 func_resolve_sysroot "$func_stripname_result"
6690 newlib_search_path+=" $func_resolve_sysroot_result"
6691 ;;
6692 prog)
6693 if test "$pass" = conv; then
6694 deplibs="$deplib $deplibs"
6695 continue
6696 fi
6697 if test "$pass" = scan; then
6698 deplibs="$deplib $deplibs"
6699 else
6700 compile_deplibs="$deplib $compile_deplibs"
6701 finalize_deplibs="$deplib $finalize_deplibs"
6702 fi
6703 func_stripname '-L' '' "$deplib"
6704 func_resolve_sysroot "$func_stripname_result"
6705 newlib_search_path+=" $func_resolve_sysroot_result"
6706 ;;
6707 *)
6708 func_warning "\`-L' is ignored for archives/objects"
6709 ;;
6710 esac # linkmode
6711 continue
6712 ;; # -L
6713 -R*)
6714 if test "$pass" = link; then
6715 func_stripname '-R' '' "$deplib"
6716 func_resolve_sysroot "$func_stripname_result"
6717 dir=$func_resolve_sysroot_result
6718 # Make sure the xrpath contains only unique directories.
6719 case "$xrpath " in
6720 *" $dir "*) ;;
6721 *) xrpath+=" $dir" ;;
6722 esac
6723 fi
6724 deplibs="$deplib $deplibs"
6725 continue
6726 ;;
6727 *.la)
6728 func_resolve_sysroot "$deplib"
6729 lib=$func_resolve_sysroot_result
6730 ;;
6731 *.$libext)
6732 if test "$pass" = conv; then
6733 deplibs="$deplib $deplibs"
6734 continue
6735 fi
6736 case $linkmode in
6737 lib)
6738 # Linking convenience modules into shared libraries is allowed,
6739 # but linking other static libraries is non-portable.
6740 case " $dlpreconveniencelibs " in
6741 *" $deplib "*) ;;
6742 *)
6743 valid_a_lib=no
6744 case $deplibs_check_method in
6745 match_pattern*)
6746 set dummy $deplibs_check_method; shift
6747 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6748 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6749 | $EGREP "$match_pattern_regex" > /dev/null; then
6750 valid_a_lib=yes
6751 fi
6752 ;;
6753 pass_all)
6754 valid_a_lib=yes
6755 ;;
6756 esac
6757 if test "$valid_a_lib" != yes; then
6758 echo
6759 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
6760 echo "*** I have the capability to make that library automatically link in when"
6761 echo "*** you link to this library. But I can only do this if you have a"
6762 echo "*** shared version of the library, which you do not appear to have"
6763 echo "*** because the file extensions .$libext of this argument makes me believe"
6764 echo "*** that it is just a static archive that I should not use here."
6765 else
6766 echo
6767 $ECHO "*** Warning: Linking the shared library $output against the"
6768 $ECHO "*** static library $deplib is not portable!"
6769 deplibs="$deplib $deplibs"
6770 fi
6771 ;;
6772 esac
6773 continue
6774 ;;
6775 prog)
6776 if test "$pass" != link; then
6777 deplibs="$deplib $deplibs"
6778 else
6779 compile_deplibs="$deplib $compile_deplibs"
6780 finalize_deplibs="$deplib $finalize_deplibs"
6781 fi
6782 continue
6783 ;;
6784 esac # linkmode
6785 ;; # *.$libext
6786 *.lo | *.$objext)
6787 if test "$pass" = conv; then
6788 deplibs="$deplib $deplibs"
6789 elif test "$linkmode" = prog; then
6790 if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6791 # If there is no dlopen support or we're linking statically,
6792 # we need to preload.
6793 newdlprefiles+=" $deplib"
6794 compile_deplibs="$deplib $compile_deplibs"
6795 finalize_deplibs="$deplib $finalize_deplibs"
6796 else
6797 newdlfiles+=" $deplib"
6798 fi
6799 fi
6800 continue
6801 ;;
6802 %DEPLIBS%)
6803 alldeplibs=yes
6804 continue
6805 ;;
6806 esac # case $deplib
6807
6808 if test "$found" = yes || test -f "$lib"; then :
6809 else
6810 func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6811 fi
6812
6813 # Check to see that this really is a libtool archive.
6814 func_lalib_unsafe_p "$lib" \
6815 || func_fatal_error "\`$lib' is not a valid libtool archive"
6816
6817 func_dirname "$lib" "" "."
6818 ladir="$func_dirname_result"
6819
6820 dlname=
6821 dlopen=
6822 dlpreopen=
6823 libdir=
6824 library_names=
6825 old_library=
6826 inherited_linker_flags=
6827 # If the library was installed with an old release of libtool,
6828 # it will not redefine variables installed, or shouldnotlink
6829 installed=yes
6830 shouldnotlink=no
6831 avoidtemprpath=
6832
6833
6834 # Read the .la file
6835 func_source "$lib"
6836
6837 # Convert "-framework foo" to "foo.ltframework"
6838 if test -n "$inherited_linker_flags"; then
6839 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6840 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6841 case " $new_inherited_linker_flags " in
6842 *" $tmp_inherited_linker_flag "*) ;;
6843 *) new_inherited_linker_flags+=" $tmp_inherited_linker_flag";;
6844 esac
6845 done
6846 fi
6847 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6848 if test "$linkmode,$pass" = "lib,link" ||
6849 test "$linkmode,$pass" = "prog,scan" ||
6850 { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6851 test -n "$dlopen" && dlfiles+=" $dlopen"
6852 test -n "$dlpreopen" && dlprefiles+=" $dlpreopen"
6853 fi
6854
6855 if test "$pass" = conv; then
6856 # Only check for convenience libraries
6857 deplibs="$lib $deplibs"
6858 if test -z "$libdir"; then
6859 if test -z "$old_library"; then
6860 func_fatal_error "cannot find name of link library for \`$lib'"
6861 fi
6862 # It is a libtool convenience library, so add in its objects.
6863 convenience+=" $ladir/$objdir/$old_library"
6864 old_convenience+=" $ladir/$objdir/$old_library"
6865 elif test "$linkmode" != prog && test "$linkmode" != lib; then
6866 func_fatal_error "\`$lib' is not a convenience library"
6867 fi
6868 tmp_libs=
6869 for deplib in $dependency_libs; do
6870 deplibs="$deplib $deplibs"
6871 if $opt_preserve_dup_deps ; then
6872 case "$tmp_libs " in
6873 *" $deplib "*) specialdeplibs+=" $deplib" ;;
6874 esac
6875 fi
6876 tmp_libs+=" $deplib"
6877 done
6878 continue
6879 fi # $pass = conv
6880
6881
6882 # Get the name of the library we link against.
6883 linklib=
6884 if test -n "$old_library" &&
6885 { test "$prefer_static_libs" = yes ||
6886 test "$prefer_static_libs,$installed" = "built,no"; }; then
6887 linklib=$old_library
6888 else
6889 for l in $old_library $library_names; do
6890 linklib="$l"
6891 done
6892 fi
6893 if test -z "$linklib"; then
6894 func_fatal_error "cannot find name of link library for \`$lib'"
6895 fi
6896
6897 # This library was specified with -dlopen.
6898 if test "$pass" = dlopen; then
6899 if test -z "$libdir"; then
6900 func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6901 fi
6902 if test -z "$dlname" ||
6903 test "$dlopen_support" != yes ||
6904 test "$build_libtool_libs" = no; then
6905 # If there is no dlname, no dlopen support or we're linking
6906 # statically, we need to preload. We also need to preload any
6907 # dependent libraries so libltdl's deplib preloader doesn't
6908 # bomb out in the load deplibs phase.
6909 dlprefiles+=" $lib $dependency_libs"
6910 else
6911 newdlfiles+=" $lib"
6912 fi
6913 continue
6914 fi # $pass = dlopen
6915
6916 # We need an absolute path.
6917 case $ladir in
6918 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6919 *)
6920 abs_ladir=`cd "$ladir" && pwd`
6921 if test -z "$abs_ladir"; then
6922 func_warning "cannot determine absolute directory name of \`$ladir'"
6923 func_warning "passing it literally to the linker, although it might fail"
6924 abs_ladir="$ladir"
6925 fi
6926 ;;
6927 esac
6928 func_basename "$lib"
6929 laname="$func_basename_result"
6930
6931 # Find the relevant object directory and library name.
6932 if test "X$installed" = Xyes; then
6933 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6934 func_warning "library \`$lib' was moved."
6935 dir="$ladir"
6936 absdir="$abs_ladir"
6937 libdir="$abs_ladir"
6938 else
6939 dir="$lt_sysroot$libdir"
6940 absdir="$lt_sysroot$libdir"
6941 fi
6942 test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6943 else
6944 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6945 dir="$ladir"
6946 absdir="$abs_ladir"
6947 # Remove this search path later
6948 notinst_path+=" $abs_ladir"
6949 else
6950 dir="$ladir/$objdir"
6951 absdir="$abs_ladir/$objdir"
6952 # Remove this search path later
6953 notinst_path+=" $abs_ladir"
6954 fi
6955 fi # $installed = yes
6956 func_stripname 'lib' '.la' "$laname"
6957 name=$func_stripname_result
6958
6959 # This library was specified with -dlpreopen.
6960 if test "$pass" = dlpreopen; then
6961 if test -z "$libdir" && test "$linkmode" = prog; then
6962 func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6963 fi
6964 case "$host" in
6965 # special handling for platforms with PE-DLLs.
6966 *cygwin* | *mingw* | *cegcc* )
6967 # Linker will automatically link against shared library if both
6968 # static and shared are present. Therefore, ensure we extract
6969 # symbols from the import library if a shared library is present
6970 # (otherwise, the dlopen module name will be incorrect). We do
6971 # this by putting the import library name into $newdlprefiles.
6972 # We recover the dlopen module name by 'saving' the la file
6973 # name in a special purpose variable, and (later) extracting the
6974 # dlname from the la file.
6975 if test -n "$dlname"; then
6976 func_tr_sh "$dir/$linklib"
6977 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6978 newdlprefiles+=" $dir/$linklib"
6979 else
6980 newdlprefiles+=" $dir/$old_library"
6981 # Keep a list of preopened convenience libraries to check
6982 # that they are being used correctly in the link pass.
6983 test -z "$libdir" && \
6984 dlpreconveniencelibs+=" $dir/$old_library"
6985 fi
6986 ;;
6987 * )
6988 # Prefer using a static library (so that no silly _DYNAMIC symbols
6989 # are required to link).
6990 if test -n "$old_library"; then
6991 newdlprefiles+=" $dir/$old_library"
6992 # Keep a list of preopened convenience libraries to check
6993 # that they are being used correctly in the link pass.
6994 test -z "$libdir" && \
6995 dlpreconveniencelibs+=" $dir/$old_library"
6996 # Otherwise, use the dlname, so that lt_dlopen finds it.
6997 elif test -n "$dlname"; then
6998 newdlprefiles+=" $dir/$dlname"
6999 else
7000 newdlprefiles+=" $dir/$linklib"
7001 fi
7002 ;;
7003 esac
7004 fi # $pass = dlpreopen
7005
7006 if test -z "$libdir"; then
7007 # Link the convenience library
7008 if test "$linkmode" = lib; then
7009 deplibs="$dir/$old_library $deplibs"
7010 elif test "$linkmode,$pass" = "prog,link"; then
7011 compile_deplibs="$dir/$old_library $compile_deplibs"
7012 finalize_deplibs="$dir/$old_library $finalize_deplibs"
7013 else
7014 deplibs="$lib $deplibs" # used for prog,scan pass
7015 fi
7016 continue
7017 fi
7018
7019
7020 if test "$linkmode" = prog && test "$pass" != link; then
7021 newlib_search_path+=" $ladir"
7022 deplibs="$lib $deplibs"
7023
7024 linkalldeplibs=no
7025 if test "$link_all_deplibs" != no || test -z "$library_names" ||
7026 test "$build_libtool_libs" = no; then
7027 linkalldeplibs=yes
7028 fi
7029
7030 tmp_libs=
7031 for deplib in $dependency_libs; do
7032 case $deplib in
7033 -L*) func_stripname '-L' '' "$deplib"
7034 func_resolve_sysroot "$func_stripname_result"
7035 newlib_search_path+=" $func_resolve_sysroot_result"
7036 ;;
7037 esac
7038 # Need to link against all dependency_libs?
7039 if test "$linkalldeplibs" = yes; then
7040 deplibs="$deplib $deplibs"
7041 else
7042 # Need to hardcode shared library paths
7043 # or/and link against static libraries
7044 newdependency_libs="$deplib $newdependency_libs"
7045 fi
7046 if $opt_preserve_dup_deps ; then
7047 case "$tmp_libs " in
7048 *" $deplib "*) specialdeplibs+=" $deplib" ;;
7049 esac
7050 fi
7051 tmp_libs+=" $deplib"
7052 done # for deplib
7053 continue
7054 fi # $linkmode = prog...
7055
7056 if test "$linkmode,$pass" = "prog,link"; then
7057 if test -n "$library_names" &&
7058 { { test "$prefer_static_libs" = no ||
7059 test "$prefer_static_libs,$installed" = "built,yes"; } ||
7060 test -z "$old_library"; }; then
7061 # We need to hardcode the library path
7062 if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
7063 # Make sure the rpath contains only unique directories.
7064 case "$temp_rpath:" in
7065 *"$absdir:"*) ;;
7066 *) temp_rpath+="$absdir:" ;;
7067 esac
7068 fi
7069
7070 # Hardcode the library path.
7071 # Skip directories that are in the system default run-time
7072 # search path.
7073 case " $sys_lib_dlsearch_path " in
7074 *" $absdir "*) ;;
7075 *)
7076 case "$compile_rpath " in
7077 *" $absdir "*) ;;
7078 *) compile_rpath+=" $absdir" ;;
7079 esac
7080 ;;
7081 esac
7082 case " $sys_lib_dlsearch_path " in
7083 *" $libdir "*) ;;
7084 *)
7085 case "$finalize_rpath " in
7086 *" $libdir "*) ;;
7087 *) finalize_rpath+=" $libdir" ;;
7088 esac
7089 ;;
7090 esac
7091 fi # $linkmode,$pass = prog,link...
7092
7093 if test "$alldeplibs" = yes &&
7094 { test "$deplibs_check_method" = pass_all ||
7095 { test "$build_libtool_libs" = yes &&
7096 test -n "$library_names"; }; }; then
7097 # We only need to search for static libraries
7098 continue
7099 fi
7100 fi
7101
7102 link_static=no # Whether the deplib will be linked statically
7103 use_static_libs=$prefer_static_libs
7104 if test "$use_static_libs" = built && test "$installed" = yes; then
7105 use_static_libs=no
7106 fi
7107 if test -n "$library_names" &&
7108 { test "$use_static_libs" = no || test -z "$old_library"; }; then
7109 case $host in
7110 *cygwin* | *mingw* | *cegcc*)
7111 # No point in relinking DLLs because paths are not encoded
7112 notinst_deplibs+=" $lib"
7113 need_relink=no
7114 ;;
7115 *)
7116 if test "$installed" = no; then
7117 notinst_deplibs+=" $lib"
7118 need_relink=yes
7119 fi
7120 ;;
7121 esac
7122 # This is a shared library
7123
7124 # Warn about portability, can't link against -module's on some
7125 # systems (darwin). Don't bleat about dlopened modules though!
7126 dlopenmodule=""
7127 for dlpremoduletest in $dlprefiles; do
7128 if test "X$dlpremoduletest" = "X$lib"; then
7129 dlopenmodule="$dlpremoduletest"
7130 break
7131 fi
7132 done
7133 if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
7134 echo
7135 if test "$linkmode" = prog; then
7136 $ECHO "*** Warning: Linking the executable $output against the loadable module"
7137 else
7138 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
7139 fi
7140 $ECHO "*** $linklib is not portable!"
7141 fi
7142 if test "$linkmode" = lib &&
7143 test "$hardcode_into_libs" = yes; then
7144 # Hardcode the library path.
7145 # Skip directories that are in the system default run-time
7146 # search path.
7147 case " $sys_lib_dlsearch_path " in
7148 *" $absdir "*) ;;
7149 *)
7150 case "$compile_rpath " in
7151 *" $absdir "*) ;;
7152 *) compile_rpath+=" $absdir" ;;
7153 esac
7154 ;;
7155 esac
7156 case " $sys_lib_dlsearch_path " in
7157 *" $libdir "*) ;;
7158 *)
7159 case "$finalize_rpath " in
7160 *" $libdir "*) ;;
7161 *) finalize_rpath+=" $libdir" ;;
7162 esac
7163 ;;
7164 esac
7165 fi
7166
7167 if test -n "$old_archive_from_expsyms_cmds"; then
7168 # figure out the soname
7169 set dummy $library_names
7170 shift
7171 realname="$1"
7172 shift
7173 libname=`eval "\\$ECHO \"$libname_spec\""`
7174 # use dlname if we got it. it's perfectly good, no?
7175 if test -n "$dlname"; then
7176 soname="$dlname"
7177 elif test -n "$soname_spec"; then
7178 # bleh windows
7179 case $host in
7180 *cygwin* | mingw* | *cegcc*)
7181 func_arith $current - $age
7182 major=$func_arith_result
7183 versuffix="-$major"
7184 ;;
7185 esac
7186 eval soname=\"$soname_spec\"
7187 else
7188 soname="$realname"
7189 fi
7190
7191 # Make a new name for the extract_expsyms_cmds to use
7192 soroot="$soname"
7193 func_basename "$soroot"
7194 soname="$func_basename_result"
7195 func_stripname 'lib' '.dll' "$soname"
7196 newlib=libimp-$func_stripname_result.a
7197
7198 # If the library has no export list, then create one now
7199 if test -f "$output_objdir/$soname-def"; then :
7200 else
7201 func_verbose "extracting exported symbol list from \`$soname'"
7202 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
7203 fi
7204
7205 # Create $newlib
7206 if test -f "$output_objdir/$newlib"; then :; else
7207 func_verbose "generating import library for \`$soname'"
7208 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
7209 fi
7210 # make sure the library variables are pointing to the new library
7211 dir=$output_objdir
7212 linklib=$newlib
7213 fi # test -n "$old_archive_from_expsyms_cmds"
7214
7215 if test "$linkmode" = prog || test "$opt_mode" != relink; then
7216 add_shlibpath=
7217 add_dir=
7218 add=
7219 lib_linked=yes
7220 case $hardcode_action in
7221 immediate | unsupported)
7222 if test "$hardcode_direct" = no; then
7223 add="$dir/$linklib"
7224 case $host in
7225 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
7226 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
7227 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
7228 *-*-unixware7*) add_dir="-L$dir" ;;
7229 *-*-darwin* )
7230 # if the lib is a (non-dlopened) module then we can not
7231 # link against it, someone is ignoring the earlier warnings
7232 if /usr/bin/file -L $add 2> /dev/null |
7233 $GREP ": [^:]* bundle" >/dev/null ; then
7234 if test "X$dlopenmodule" != "X$lib"; then
7235 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
7236 if test -z "$old_library" ; then
7237 echo
7238 echo "*** And there doesn't seem to be a static archive available"
7239 echo "*** The link will probably fail, sorry"
7240 else
7241 add="$dir/$old_library"
7242 fi
7243 elif test -n "$old_library"; then
7244 add="$dir/$old_library"
7245 fi
7246 fi
7247 esac
7248 elif test "$hardcode_minus_L" = no; then
7249 case $host in
7250 *-*-sunos*) add_shlibpath="$dir" ;;
7251 esac
7252 add_dir="-L$dir"
7253 add="-l$name"
7254 elif test "$hardcode_shlibpath_var" = no; then
7255 add_shlibpath="$dir"
7256 add="-l$name"
7257 else
7258 lib_linked=no
7259 fi
7260 ;;
7261 relink)
7262 if test "$hardcode_direct" = yes &&
7263 test "$hardcode_direct_absolute" = no; then
7264 add="$dir/$linklib"
7265 elif test "$hardcode_minus_L" = yes; then
7266 add_dir="-L$absdir"
7267 # Try looking first in the location we're being installed to.
7268 if test -n "$inst_prefix_dir"; then
7269 case $libdir in
7270 [\\/]*)
7271 add_dir+=" -L$inst_prefix_dir$libdir"
7272 ;;
7273 esac
7274 fi
7275 add="-l$name"
7276 elif test "$hardcode_shlibpath_var" = yes; then
7277 add_shlibpath="$dir"
7278 add="-l$name"
7279 else
7280 lib_linked=no
7281 fi
7282 ;;
7283 *) lib_linked=no ;;
7284 esac
7285
7286 if test "$lib_linked" != yes; then
7287 func_fatal_configuration "unsupported hardcode properties"
7288 fi
7289
7290 if test -n "$add_shlibpath"; then
7291 case :$compile_shlibpath: in
7292 *":$add_shlibpath:"*) ;;
7293 *) compile_shlibpath+="$add_shlibpath:" ;;
7294 esac
7295 fi
7296 if test "$linkmode" = prog; then
7297 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
7298 test -n "$add" && compile_deplibs="$add $compile_deplibs"
7299 else
7300 test -n "$add_dir" && deplibs="$add_dir $deplibs"
7301 test -n "$add" && deplibs="$add $deplibs"
7302 if test "$hardcode_direct" != yes &&
7303 test "$hardcode_minus_L" != yes &&
7304 test "$hardcode_shlibpath_var" = yes; then
7305 case :$finalize_shlibpath: in
7306 *":$libdir:"*) ;;
7307 *) finalize_shlibpath+="$libdir:" ;;
7308 esac
7309 fi
7310 fi
7311 fi
7312
7313 if test "$linkmode" = prog || test "$opt_mode" = relink; then
7314 add_shlibpath=
7315 add_dir=
7316 add=
7317 # Finalize command for both is simple: just hardcode it.
7318 if test "$hardcode_direct" = yes &&
7319 test "$hardcode_direct_absolute" = no; then
7320 add="$libdir/$linklib"
7321 elif test "$hardcode_minus_L" = yes; then
7322 add_dir="-L$libdir"
7323 add="-l$name"
7324 elif test "$hardcode_shlibpath_var" = yes; then
7325 case :$finalize_shlibpath: in
7326 *":$libdir:"*) ;;
7327 *) finalize_shlibpath+="$libdir:" ;;
7328 esac
7329 add="-l$name"
7330 elif test "$hardcode_automatic" = yes; then
7331 if test -n "$inst_prefix_dir" &&
7332 test -f "$inst_prefix_dir$libdir/$linklib" ; then
7333 add="$inst_prefix_dir$libdir/$linklib"
7334 else
7335 add="$libdir/$linklib"
7336 fi
7337 else
7338 # We cannot seem to hardcode it, guess we'll fake it.
7339 add_dir="-L$libdir"
7340 # Try looking first in the location we're being installed to.
7341 if test -n "$inst_prefix_dir"; then
7342 case $libdir in
7343 [\\/]*)
7344 add_dir+=" -L$inst_prefix_dir$libdir"
7345 ;;
7346 esac
7347 fi
7348 add="-l$name"
7349 fi
7350
7351 if test "$linkmode" = prog; then
7352 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
7353 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
7354 else
7355 test -n "$add_dir" && deplibs="$add_dir $deplibs"
7356 test -n "$add" && deplibs="$add $deplibs"
7357 fi
7358 fi
7359 elif test "$linkmode" = prog; then
7360 # Here we assume that one of hardcode_direct or hardcode_minus_L
7361 # is not unsupported. This is valid on all known static and
7362 # shared platforms.
7363 if test "$hardcode_direct" != unsupported; then
7364 test -n "$old_library" && linklib="$old_library"
7365 compile_deplibs="$dir/$linklib $compile_deplibs"
7366 finalize_deplibs="$dir/$linklib $finalize_deplibs"
7367 else
7368 compile_deplibs="-l$name -L$dir $compile_deplibs"
7369 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
7370 fi
7371 elif test "$build_libtool_libs" = yes; then
7372 # Not a shared library
7373 if test "$deplibs_check_method" != pass_all; then
7374 # We're trying link a shared library against a static one
7375 # but the system doesn't support it.
7376
7377 # Just print a warning and add the library to dependency_libs so
7378 # that the program can be linked against the static library.
7379 echo
7380 $ECHO "*** Warning: This system can not link to static lib archive $lib."
7381 echo "*** I have the capability to make that library automatically link in when"
7382 echo "*** you link to this library. But I can only do this if you have a"
7383 echo "*** shared version of the library, which you do not appear to have."
7384 if test "$module" = yes; then
7385 echo "*** But as you try to build a module library, libtool will still create "
7386 echo "*** a static module, that should work as long as the dlopening application"
7387 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
7388 if test -z "$global_symbol_pipe"; then
7389 echo
7390 echo "*** However, this would only work if libtool was able to extract symbol"
7391 echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7392 echo "*** not find such a program. So, this module is probably useless."
7393 echo "*** \`nm' from GNU binutils and a full rebuild may help."
7394 fi
7395 if test "$build_old_libs" = no; then
7396 build_libtool_libs=module
7397 build_old_libs=yes
7398 else
7399 build_libtool_libs=no
7400 fi
7401 fi
7402 else
7403 deplibs="$dir/$old_library $deplibs"
7404 link_static=yes
7405 fi
7406 fi # link shared/static library?
7407
7408 if test "$linkmode" = lib; then
7409 if test -n "$dependency_libs" &&
7410 { test "$hardcode_into_libs" != yes ||
7411 test "$build_old_libs" = yes ||
7412 test "$link_static" = yes; }; then
7413 # Extract -R from dependency_libs
7414 temp_deplibs=
7415 for libdir in $dependency_libs; do
7416 case $libdir in
7417 -R*) func_stripname '-R' '' "$libdir"
7418 temp_xrpath=$func_stripname_result
7419 case " $xrpath " in
7420 *" $temp_xrpath "*) ;;
7421 *) xrpath+=" $temp_xrpath";;
7422 esac;;
7423 *) temp_deplibs+=" $libdir";;
7424 esac
7425 done
7426 dependency_libs="$temp_deplibs"
7427 fi
7428
7429 newlib_search_path+=" $absdir"
7430 # Link against this library
7431 test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7432 # ... and its dependency_libs
7433 tmp_libs=
7434 for deplib in $dependency_libs; do
7435 newdependency_libs="$deplib $newdependency_libs"
7436 case $deplib in
7437 -L*) func_stripname '-L' '' "$deplib"
7438 func_resolve_sysroot "$func_stripname_result";;
7439 *) func_resolve_sysroot "$deplib" ;;
7440 esac
7441 if $opt_preserve_dup_deps ; then
7442 case "$tmp_libs " in
7443 *" $func_resolve_sysroot_result "*)
7444 specialdeplibs+=" $func_resolve_sysroot_result" ;;
7445 esac
7446 fi
7447 tmp_libs+=" $func_resolve_sysroot_result"
7448 done
7449
7450 if test "$link_all_deplibs" != no; then
7451 # Add the search paths of all dependency libraries
7452 for deplib in $dependency_libs; do
7453 path=
7454 case $deplib in
7455 -L*) path="$deplib" ;;
7456 *.la)
7457 func_resolve_sysroot "$deplib"
7458 deplib=$func_resolve_sysroot_result
7459 func_dirname "$deplib" "" "."
7460 dir=$func_dirname_result
7461 # We need an absolute path.
7462 case $dir in
7463 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7464 *)
7465 absdir=`cd "$dir" && pwd`
7466 if test -z "$absdir"; then
7467 func_warning "cannot determine absolute directory name of \`$dir'"
7468 absdir="$dir"
7469 fi
7470 ;;
7471 esac
7472 if $GREP "^installed=no" $deplib > /dev/null; then
7473 case $host in
7474 *-*-darwin*)
7475 depdepl=
7476 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7477 if test -n "$deplibrary_names" ; then
7478 for tmp in $deplibrary_names ; do
7479 depdepl=$tmp
7480 done
7481 if test -f "$absdir/$objdir/$depdepl" ; then
7482 depdepl="$absdir/$objdir/$depdepl"
7483 darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7484 if test -z "$darwin_install_name"; then
7485 darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7486 fi
7487 compiler_flags+=" ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7488 linker_flags+=" -dylib_file ${darwin_install_name}:${depdepl}"
7489 path=
7490 fi
7491 fi
7492 ;;
7493 *)
7494 path="-L$absdir/$objdir"
7495 ;;
7496 esac
7497 else
7498 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7499 test -z "$libdir" && \
7500 func_fatal_error "\`$deplib' is not a valid libtool archive"
7501 test "$absdir" != "$libdir" && \
7502 func_warning "\`$deplib' seems to be moved"
7503
7504 path="-L$absdir"
7505 fi
7506 ;;
7507 esac
7508 case " $deplibs " in
7509 *" $path "*) ;;
7510 *) deplibs="$path $deplibs" ;;
7511 esac
7512 done
7513 fi # link_all_deplibs != no
7514 fi # linkmode = lib
7515 done # for deplib in $libs
7516 if test "$pass" = link; then
7517 if test "$linkmode" = "prog"; then
7518 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7519 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7520 else
7521 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7522 fi
7523 fi
7524 dependency_libs="$newdependency_libs"
7525 if test "$pass" = dlpreopen; then
7526 # Link the dlpreopened libraries before other libraries
7527 for deplib in $save_deplibs; do
7528 deplibs="$deplib $deplibs"
7529 done
7530 fi
7531 if test "$pass" != dlopen; then
7532 if test "$pass" != conv; then
7533 # Make sure lib_search_path contains only unique directories.
7534 lib_search_path=
7535 for dir in $newlib_search_path; do
7536 case "$lib_search_path " in
7537 *" $dir "*) ;;
7538 *) lib_search_path+=" $dir" ;;
7539 esac
7540 done
7541 newlib_search_path=
7542 fi
7543
7544 if test "$linkmode,$pass" != "prog,link"; then
7545 vars="deplibs"
7546 else
7547 vars="compile_deplibs finalize_deplibs"
7548 fi
7549 for var in $vars dependency_libs; do
7550 # Add libraries to $var in reverse order
7551 eval tmp_libs=\"\$$var\"
7552 new_libs=
7553 for deplib in $tmp_libs; do
7554 # FIXME: Pedantically, this is the right thing to do, so
7555 # that some nasty dependency loop isn't accidentally
7556 # broken:
7557 #new_libs="$deplib $new_libs"
7558 # Pragmatically, this seems to cause very few problems in
7559 # practice:
7560 case $deplib in
7561 -L*) new_libs="$deplib $new_libs" ;;
7562 -R*) ;;
7563 *)
7564 # And here is the reason: when a library appears more
7565 # than once as an explicit dependence of a library, or
7566 # is implicitly linked in more than once by the
7567 # compiler, it is considered special, and multiple
7568 # occurrences thereof are not removed. Compare this
7569 # with having the same library being listed as a
7570 # dependency of multiple other libraries: in this case,
7571 # we know (pedantically, we assume) the library does not
7572 # need to be listed more than once, so we keep only the
7573 # last copy. This is not always right, but it is rare
7574 # enough that we require users that really mean to play
7575 # such unportable linking tricks to link the library
7576 # using -Wl,-lname, so that libtool does not consider it
7577 # for duplicate removal.
7578 case " $specialdeplibs " in
7579 *" $deplib "*) new_libs="$deplib $new_libs" ;;
7580 *)
7581 case " $new_libs " in
7582 *" $deplib "*) ;;
7583 *) new_libs="$deplib $new_libs" ;;
7584 esac
7585 ;;
7586 esac
7587 ;;
7588 esac
7589 done
7590 tmp_libs=
7591 for deplib in $new_libs; do
7592 case $deplib in
7593 -L*)
7594 case " $tmp_libs " in
7595 *" $deplib "*) ;;
7596 *) tmp_libs+=" $deplib" ;;
7597 esac
7598 ;;
7599 *) tmp_libs+=" $deplib" ;;
7600 esac
7601 done
7602 eval $var=\"$tmp_libs\"
7603 done # for var
7604 fi
7605 # Last step: remove runtime libs from dependency_libs
7606 # (they stay in deplibs)
7607 tmp_libs=
7608 for i in $dependency_libs ; do
7609 case " $predeps $postdeps $compiler_lib_search_path " in
7610 *" $i "*)
7611 i=""
7612 ;;
7613 esac
7614 if test -n "$i" ; then
7615 tmp_libs+=" $i"
7616 fi
7617 done
7618 dependency_libs=$tmp_libs
7619 done # for pass
7620 if test "$linkmode" = prog; then
7621 dlfiles="$newdlfiles"
7622 fi
7623 if test "$linkmode" = prog || test "$linkmode" = lib; then
7624 dlprefiles="$newdlprefiles"
7625 fi
7626
7627 case $linkmode in
7628 oldlib)
7629 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7630 func_warning "\`-dlopen' is ignored for archives"
7631 fi
7632
7633 case " $deplibs" in
7634 *\ -l* | *\ -L*)
7635 func_warning "\`-l' and \`-L' are ignored for archives" ;;
7636 esac
7637
7638 test -n "$rpath" && \
7639 func_warning "\`-rpath' is ignored for archives"
7640
7641 test -n "$xrpath" && \
7642 func_warning "\`-R' is ignored for archives"
7643
7644 test -n "$vinfo" && \
7645 func_warning "\`-version-info/-version-number' is ignored for archives"
7646
7647 test -n "$release" && \
7648 func_warning "\`-release' is ignored for archives"
7649
7650 test -n "$export_symbols$export_symbols_regex" && \
7651 func_warning "\`-export-symbols' is ignored for archives"
7652
7653 # Now set the variables for building old libraries.
7654 build_libtool_libs=no
7655 oldlibs="$output"
7656 objs+="$old_deplibs"
7657 ;;
7658
7659 lib)
7660 # Make sure we only generate libraries of the form `libNAME.la'.
7661 case $outputname in
7662 lib*)
7663 func_stripname 'lib' '.la' "$outputname"
7664 name=$func_stripname_result
7665 eval shared_ext=\"$shrext_cmds\"
7666 eval libname=\"$libname_spec\"
7667 ;;
7668 *)
7669 test "$module" = no && \
7670 func_fatal_help "libtool library \`$output' must begin with \`lib'"
7671
7672 if test "$need_lib_prefix" != no; then
7673 # Add the "lib" prefix for modules if required
7674 func_stripname '' '.la' "$outputname"
7675 name=$func_stripname_result
7676 eval shared_ext=\"$shrext_cmds\"
7677 eval libname=\"$libname_spec\"
7678 else
7679 func_stripname '' '.la' "$outputname"
7680 libname=$func_stripname_result
7681 fi
7682 ;;
7683 esac
7684
7685 if test -n "$objs"; then
7686 if test "$deplibs_check_method" != pass_all; then
7687 func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7688 else
7689 echo
7690 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7691 $ECHO "*** objects $objs is not portable!"
7692 libobjs+=" $objs"
7693 fi
7694 fi
7695
7696 test "$dlself" != no && \
7697 func_warning "\`-dlopen self' is ignored for libtool libraries"
7698
7699 set dummy $rpath
7700 shift
7701 test "$#" -gt 1 && \
7702 func_warning "ignoring multiple \`-rpath's for a libtool library"
7703
7704 install_libdir="$1"
7705
7706 oldlibs=
7707 if test -z "$rpath"; then
7708 if test "$build_libtool_libs" = yes; then
7709 # Building a libtool convenience library.
7710 # Some compilers have problems with a `.al' extension so
7711 # convenience libraries should have the same extension an
7712 # archive normally would.
7713 oldlibs="$output_objdir/$libname.$libext $oldlibs"
7714 build_libtool_libs=convenience
7715 build_old_libs=yes
7716 fi
7717
7718 test -n "$vinfo" && \
7719 func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7720
7721 test -n "$release" && \
7722 func_warning "\`-release' is ignored for convenience libraries"
7723 else
7724
7725 # Parse the version information argument.
7726 save_ifs="$IFS"; IFS=':'
7727 set dummy $vinfo 0 0 0
7728 shift
7729 IFS="$save_ifs"
7730
7731 test -n "$7" && \
7732 func_fatal_help "too many parameters to \`-version-info'"
7733
7734 # convert absolute version numbers to libtool ages
7735 # this retains compatibility with .la files and attempts
7736 # to make the code below a bit more comprehensible
7737
7738 case $vinfo_number in
7739 yes)
7740 number_major="$1"
7741 number_minor="$2"
7742 number_revision="$3"
7743 #
7744 # There are really only two kinds -- those that
7745 # use the current revision as the major version
7746 # and those that subtract age and use age as
7747 # a minor version. But, then there is irix
7748 # which has an extra 1 added just for fun
7749 #
7750 case $version_type in
7751 # correct linux to gnu/linux during the next big refactor
7752 darwin|linux|osf|windows|none)
7753 func_arith $number_major + $number_minor
7754 current=$func_arith_result
7755 age="$number_minor"
7756 revision="$number_revision"
7757 ;;
7758 freebsd-aout|freebsd-elf|qnx|sunos)
7759 current="$number_major"
7760 revision="$number_minor"
7761 age="0"
7762 ;;
7763 irix|nonstopux)
7764 func_arith $number_major + $number_minor
7765 current=$func_arith_result
7766 age="$number_minor"
7767 revision="$number_minor"
7768 lt_irix_increment=no
7769 ;;
7770 esac
7771 ;;
7772 no)
7773 current="$1"
7774 revision="$2"
7775 age="$3"
7776 ;;
7777 esac
7778
7779 # Check that each of the things are valid numbers.
7780 case $current in
7781 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
7782 *)
7783 func_error "CURRENT \`$current' must be a nonnegative integer"
7784 func_fatal_error "\`$vinfo' is not valid version information"
7785 ;;
7786 esac
7787
7788 case $revision in
7789 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
7790 *)
7791 func_error "REVISION \`$revision' must be a nonnegative integer"
7792 func_fatal_error "\`$vinfo' is not valid version information"
7793 ;;
7794 esac
7795
7796 case $age in
7797 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
7798 *)
7799 func_error "AGE \`$age' must be a nonnegative integer"
7800 func_fatal_error "\`$vinfo' is not valid version information"
7801 ;;
7802 esac
7803
7804 if test "$age" -gt "$current"; then
7805 func_error "AGE \`$age' is greater than the current interface number \`$current'"
7806 func_fatal_error "\`$vinfo' is not valid version information"
7807 fi
7808
7809 # Calculate the version variables.
7810 major=
7811 versuffix=
7812 verstring=
7813 case $version_type in
7814 none) ;;
7815
7816 darwin)
7817 # Like Linux, but with the current version available in
7818 # verstring for coding it into the library header
7819 func_arith $current - $age
7820 major=.$func_arith_result
7821 versuffix="$major.$age.$revision"
7822 # Darwin ld doesn't like 0 for these options...
7823 func_arith $current + 1
7824 minor_current=$func_arith_result
7825 xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7826 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7827 ;;
7828
7829 freebsd-aout)
7830 major=".$current"
7831 versuffix=".$current.$revision";
7832 ;;
7833
7834 freebsd-elf)
7835 major=".$current"
7836 versuffix=".$current"
7837 ;;
7838
7839 irix | nonstopux)
7840 if test "X$lt_irix_increment" = "Xno"; then
7841 func_arith $current - $age
7842 else
7843 func_arith $current - $age + 1
7844 fi
7845 major=$func_arith_result
7846
7847 case $version_type in
7848 nonstopux) verstring_prefix=nonstopux ;;
7849 *) verstring_prefix=sgi ;;
7850 esac
7851 verstring="$verstring_prefix$major.$revision"
7852
7853 # Add in all the interfaces that we are compatible with.
7854 loop=$revision
7855 while test "$loop" -ne 0; do
7856 func_arith $revision - $loop
7857 iface=$func_arith_result
7858 func_arith $loop - 1
7859 loop=$func_arith_result
7860 verstring="$verstring_prefix$major.$iface:$verstring"
7861 done
7862
7863 # Before this point, $major must not contain `.'.
7864 major=.$major
7865 versuffix="$major.$revision"
7866 ;;
7867
7868 linux) # correct to gnu/linux during the next big refactor
7869 func_arith $current - $age
7870 major=.$func_arith_result
7871 versuffix="$major.$age.$revision"
7872 ;;
7873
7874 osf)
7875 func_arith $current - $age
7876 major=.$func_arith_result
7877 versuffix=".$current.$age.$revision"
7878 verstring="$current.$age.$revision"
7879
7880 # Add in all the interfaces that we are compatible with.
7881 loop=$age
7882 while test "$loop" -ne 0; do
7883 func_arith $current - $loop
7884 iface=$func_arith_result
7885 func_arith $loop - 1
7886 loop=$func_arith_result
7887 verstring="$verstring:${iface}.0"
7888 done
7889
7890 # Make executables depend on our current version.
7891 verstring+=":${current}.0"
7892 ;;
7893
7894 qnx)
7895 major=".$current"
7896 versuffix=".$current"
7897 ;;
7898
7899 sunos)
7900 major=".$current"
7901 versuffix=".$current.$revision"
7902 ;;
7903
7904 windows)
7905 # Use '-' rather than '.', since we only want one
7906 # extension on DOS 8.3 filesystems.
7907 func_arith $current - $age
7908 major=$func_arith_result
7909 versuffix="-$major"
7910 ;;
7911
7912 *)
7913 func_fatal_configuration "unknown library version type \`$version_type'"
7914 ;;
7915 esac
7916
7917 # Clear the version info if we defaulted, and they specified a release.
7918 if test -z "$vinfo" && test -n "$release"; then
7919 major=
7920 case $version_type in
7921 darwin)
7922 # we can't check for "0.0" in archive_cmds due to quoting
7923 # problems, so we reset it completely
7924 verstring=
7925 ;;
7926 *)
7927 verstring="0.0"
7928 ;;
7929 esac
7930 if test "$need_version" = no; then
7931 versuffix=
7932 else
7933 versuffix=".0.0"
7934 fi
7935 fi
7936
7937 # Remove version info from name if versioning should be avoided
7938 if test "$avoid_version" = yes && test "$need_version" = no; then
7939 major=
7940 versuffix=
7941 verstring=""
7942 fi
7943
7944 # Check to see if the archive will have undefined symbols.
7945 if test "$allow_undefined" = yes; then
7946 if test "$allow_undefined_flag" = unsupported; then
7947 func_warning "undefined symbols not allowed in $host shared libraries"
7948 build_libtool_libs=no
7949 build_old_libs=yes
7950 fi
7951 else
7952 # Don't allow undefined symbols.
7953 allow_undefined_flag="$no_undefined_flag"
7954 fi
7955
7956 fi
7957
7958 func_generate_dlsyms "$libname" "$libname" "yes"
7959 libobjs+=" $symfileobj"
7960 test "X$libobjs" = "X " && libobjs=
7961
7962 if test "$opt_mode" != relink; then
7963 # Remove our outputs, but don't remove object files since they
7964 # may have been created when compiling PIC objects.
7965 removelist=
7966 tempremovelist=`$ECHO "$output_objdir/*"`
7967 for p in $tempremovelist; do
7968 case $p in
7969 *.$objext | *.gcno)
7970 ;;
7971 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7972 if test "X$precious_files_regex" != "X"; then
7973 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7974 then
7975 continue
7976 fi
7977 fi
7978 removelist+=" $p"
7979 ;;
7980 *) ;;
7981 esac
7982 done
7983 test -n "$removelist" && \
7984 func_show_eval "${RM}r \$removelist"
7985 fi
7986
7987 # Now set the variables for building old libraries.
7988 if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7989 oldlibs+=" $output_objdir/$libname.$libext"
7990
7991 # Transform .lo files to .o files.
7992 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7993 fi
7994
7995 # Eliminate all temporary directories.
7996 #for path in $notinst_path; do
7997 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7998 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7999 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
8000 #done
8001
8002 if test -n "$xrpath"; then
8003 # If the user specified any rpath flags, then add them.
8004 temp_xrpath=
8005 for libdir in $xrpath; do
8006 func_replace_sysroot "$libdir"
8007 temp_xrpath+=" -R$func_replace_sysroot_result"
8008 case "$finalize_rpath " in
8009 *" $libdir "*) ;;
8010 *) finalize_rpath+=" $libdir" ;;
8011 esac
8012 done
8013 if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
8014 dependency_libs="$temp_xrpath $dependency_libs"
8015 fi
8016 fi
8017
8018 # Make sure dlfiles contains only unique files that won't be dlpreopened
8019 old_dlfiles="$dlfiles"
8020 dlfiles=
8021 for lib in $old_dlfiles; do
8022 case " $dlprefiles $dlfiles " in
8023 *" $lib "*) ;;
8024 *) dlfiles+=" $lib" ;;
8025 esac
8026 done
8027
8028 # Make sure dlprefiles contains only unique files
8029 old_dlprefiles="$dlprefiles"
8030 dlprefiles=
8031 for lib in $old_dlprefiles; do
8032 case "$dlprefiles " in
8033 *" $lib "*) ;;
8034 *) dlprefiles+=" $lib" ;;
8035 esac
8036 done
8037
8038 if test "$build_libtool_libs" = yes; then
8039 if test -n "$rpath"; then
8040 case $host in
8041 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
8042 # these systems don't actually have a c library (as such)!
8043 ;;
8044 *-*-rhapsody* | *-*-darwin1.[012])
8045 # Rhapsody C library is in the System framework
8046 deplibs+=" System.ltframework"
8047 ;;
8048 *-*-netbsd*)
8049 # Don't link with libc until the a.out ld.so is fixed.
8050 ;;
8051 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
8052 # Do not include libc due to us having libc/libc_r.
8053 ;;
8054 *-*-sco3.2v5* | *-*-sco5v6*)
8055 # Causes problems with __ctype
8056 ;;
8057 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
8058 # Compiler inserts libc in the correct place for threads to work
8059 ;;
8060 *)
8061 # Add libc to deplibs on all other systems if necessary.
8062 if test "$build_libtool_need_lc" = "yes"; then
8063 deplibs+=" -lc"
8064 fi
8065 ;;
8066 esac
8067 fi
8068
8069 # Transform deplibs into only deplibs that can be linked in shared.
8070 name_save=$name
8071 libname_save=$libname
8072 release_save=$release
8073 versuffix_save=$versuffix
8074 major_save=$major
8075 # I'm not sure if I'm treating the release correctly. I think
8076 # release should show up in the -l (ie -lgmp5) so we don't want to
8077 # add it in twice. Is that correct?
8078 release=""
8079 versuffix=""
8080 major=""
8081 newdeplibs=
8082 droppeddeps=no
8083 case $deplibs_check_method in
8084 pass_all)
8085 # Don't check for shared/static. Everything works.
8086 # This might be a little naive. We might want to check
8087 # whether the library exists or not. But this is on
8088 # osf3 & osf4 and I'm not really sure... Just
8089 # implementing what was already the behavior.
8090 newdeplibs=$deplibs
8091 ;;
8092 test_compile)
8093 # This code stresses the "libraries are programs" paradigm to its
8094 # limits. Maybe even breaks it. We compile a program, linking it
8095 # against the deplibs as a proxy for the library. Then we can check
8096 # whether they linked in statically or dynamically with ldd.
8097 $opt_dry_run || $RM conftest.c
8098 cat > conftest.c <<EOF
8099 int main() { return 0; }
8100 EOF
8101 $opt_dry_run || $RM conftest
8102 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
8103 ldd_output=`ldd conftest`
8104 for i in $deplibs; do
8105 case $i in
8106 -l*)
8107 func_stripname -l '' "$i"
8108 name=$func_stripname_result
8109 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
8110 case " $predeps $postdeps " in
8111 *" $i "*)
8112 newdeplibs+=" $i"
8113 i=""
8114 ;;
8115 esac
8116 fi
8117 if test -n "$i" ; then
8118 libname=`eval "\\$ECHO \"$libname_spec\""`
8119 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
8120 set dummy $deplib_matches; shift
8121 deplib_match=$1
8122 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
8123 newdeplibs+=" $i"
8124 else
8125 droppeddeps=yes
8126 echo
8127 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
8128 echo "*** I have the capability to make that library automatically link in when"
8129 echo "*** you link to this library. But I can only do this if you have a"
8130 echo "*** shared version of the library, which I believe you do not have"
8131 echo "*** because a test_compile did reveal that the linker did not use it for"
8132 echo "*** its dynamic dependency list that programs get resolved with at runtime."
8133 fi
8134 fi
8135 ;;
8136 *)
8137 newdeplibs+=" $i"
8138 ;;
8139 esac
8140 done
8141 else
8142 # Error occurred in the first compile. Let's try to salvage
8143 # the situation: Compile a separate program for each library.
8144 for i in $deplibs; do
8145 case $i in
8146 -l*)
8147 func_stripname -l '' "$i"
8148 name=$func_stripname_result
8149 $opt_dry_run || $RM conftest
8150 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
8151 ldd_output=`ldd conftest`
8152 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
8153 case " $predeps $postdeps " in
8154 *" $i "*)
8155 newdeplibs+=" $i"
8156 i=""
8157 ;;
8158 esac
8159 fi
8160 if test -n "$i" ; then
8161 libname=`eval "\\$ECHO \"$libname_spec\""`
8162 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
8163 set dummy $deplib_matches; shift
8164 deplib_match=$1
8165 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
8166 newdeplibs+=" $i"
8167 else
8168 droppeddeps=yes
8169 echo
8170 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
8171 echo "*** I have the capability to make that library automatically link in when"
8172 echo "*** you link to this library. But I can only do this if you have a"
8173 echo "*** shared version of the library, which you do not appear to have"
8174 echo "*** because a test_compile did reveal that the linker did not use this one"
8175 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
8176 fi
8177 fi
8178 else
8179 droppeddeps=yes
8180 echo
8181 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
8182 echo "*** make it link in! You will probably need to install it or some"
8183 echo "*** library that it depends on before this library will be fully"
8184 echo "*** functional. Installing it before continuing would be even better."
8185 fi
8186 ;;
8187 *)
8188 newdeplibs+=" $i"
8189 ;;
8190 esac
8191 done
8192 fi
8193 ;;
8194 file_magic*)
8195 set dummy $deplibs_check_method; shift
8196 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
8197 for a_deplib in $deplibs; do
8198 case $a_deplib in
8199 -l*)
8200 func_stripname -l '' "$a_deplib"
8201 name=$func_stripname_result
8202 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
8203 case " $predeps $postdeps " in
8204 *" $a_deplib "*)
8205 newdeplibs+=" $a_deplib"
8206 a_deplib=""
8207 ;;
8208 esac
8209 fi
8210 if test -n "$a_deplib" ; then
8211 libname=`eval "\\$ECHO \"$libname_spec\""`
8212 if test -n "$file_magic_glob"; then
8213 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
8214 else
8215 libnameglob=$libname
8216 fi
8217 test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
8218 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
8219 if test "$want_nocaseglob" = yes; then
8220 shopt -s nocaseglob
8221 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
8222 $nocaseglob
8223 else
8224 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
8225 fi
8226 for potent_lib in $potential_libs; do
8227 # Follow soft links.
8228 if ls -lLd "$potent_lib" 2>/dev/null |
8229 $GREP " -> " >/dev/null; then
8230 continue
8231 fi
8232 # The statement above tries to avoid entering an
8233 # endless loop below, in case of cyclic links.
8234 # We might still enter an endless loop, since a link
8235 # loop can be closed while we follow links,
8236 # but so what?
8237 potlib="$potent_lib"
8238 while test -h "$potlib" 2>/dev/null; do
8239 potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
8240 case $potliblink in
8241 [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
8242 *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
8243 esac
8244 done
8245 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
8246 $SED -e 10q |
8247 $EGREP "$file_magic_regex" > /dev/null; then
8248 newdeplibs+=" $a_deplib"
8249 a_deplib=""
8250 break 2
8251 fi
8252 done
8253 done
8254 fi
8255 if test -n "$a_deplib" ; then
8256 droppeddeps=yes
8257 echo
8258 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
8259 echo "*** I have the capability to make that library automatically link in when"
8260 echo "*** you link to this library. But I can only do this if you have a"
8261 echo "*** shared version of the library, which you do not appear to have"
8262 echo "*** because I did check the linker path looking for a file starting"
8263 if test -z "$potlib" ; then
8264 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
8265 else
8266 $ECHO "*** with $libname and none of the candidates passed a file format test"
8267 $ECHO "*** using a file magic. Last file checked: $potlib"
8268 fi
8269 fi
8270 ;;
8271 *)
8272 # Add a -L argument.
8273 newdeplibs+=" $a_deplib"
8274 ;;
8275 esac
8276 done # Gone through all deplibs.
8277 ;;
8278 match_pattern*)
8279 set dummy $deplibs_check_method; shift
8280 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
8281 for a_deplib in $deplibs; do
8282 case $a_deplib in
8283 -l*)
8284 func_stripname -l '' "$a_deplib"
8285 name=$func_stripname_result
8286 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
8287 case " $predeps $postdeps " in
8288 *" $a_deplib "*)
8289 newdeplibs+=" $a_deplib"
8290 a_deplib=""
8291 ;;
8292 esac
8293 fi
8294 if test -n "$a_deplib" ; then
8295 libname=`eval "\\$ECHO \"$libname_spec\""`
8296 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
8297 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
8298 for potent_lib in $potential_libs; do
8299 potlib="$potent_lib" # see symlink-check above in file_magic test
8300 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
8301 $EGREP "$match_pattern_regex" > /dev/null; then
8302 newdeplibs+=" $a_deplib"
8303 a_deplib=""
8304 break 2
8305 fi
8306 done
8307 done
8308 fi
8309 if test -n "$a_deplib" ; then
8310 droppeddeps=yes
8311 echo
8312 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
8313 echo "*** I have the capability to make that library automatically link in when"
8314 echo "*** you link to this library. But I can only do this if you have a"
8315 echo "*** shared version of the library, which you do not appear to have"
8316 echo "*** because I did check the linker path looking for a file starting"
8317 if test -z "$potlib" ; then
8318 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
8319 else
8320 $ECHO "*** with $libname and none of the candidates passed a file format test"
8321 $ECHO "*** using a regex pattern. Last file checked: $potlib"
8322 fi
8323 fi
8324 ;;
8325 *)
8326 # Add a -L argument.
8327 newdeplibs+=" $a_deplib"
8328 ;;
8329 esac
8330 done # Gone through all deplibs.
8331 ;;
8332 none | unknown | *)
8333 newdeplibs=""
8334 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
8335 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
8336 for i in $predeps $postdeps ; do
8337 # can't use Xsed below, because $i might contain '/'
8338 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
8339 done
8340 fi
8341 case $tmp_deplibs in
8342 *[!\ \ ]*)
8343 echo
8344 if test "X$deplibs_check_method" = "Xnone"; then
8345 echo "*** Warning: inter-library dependencies are not supported in this platform."
8346 else
8347 echo "*** Warning: inter-library dependencies are not known to be supported."
8348 fi
8349 echo "*** All declared inter-library dependencies are being dropped."
8350 droppeddeps=yes
8351 ;;
8352 esac
8353 ;;
8354 esac
8355 versuffix=$versuffix_save
8356 major=$major_save
8357 release=$release_save
8358 libname=$libname_save
8359 name=$name_save
8360
8361 case $host in
8362 *-*-rhapsody* | *-*-darwin1.[012])
8363 # On Rhapsody replace the C library with the System framework
8364 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
8365 ;;
8366 esac
8367
8368 if test "$droppeddeps" = yes; then
8369 if test "$module" = yes; then
8370 echo
8371 echo "*** Warning: libtool could not satisfy all declared inter-library"
8372 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
8373 echo "*** a static module, that should work as long as the dlopening"
8374 echo "*** application is linked with the -dlopen flag."
8375 if test -z "$global_symbol_pipe"; then
8376 echo
8377 echo "*** However, this would only work if libtool was able to extract symbol"
8378 echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
8379 echo "*** not find such a program. So, this module is probably useless."
8380 echo "*** \`nm' from GNU binutils and a full rebuild may help."
8381 fi
8382 if test "$build_old_libs" = no; then
8383 oldlibs="$output_objdir/$libname.$libext"
8384 build_libtool_libs=module
8385 build_old_libs=yes
8386 else
8387 build_libtool_libs=no
8388 fi
8389 else
8390 echo "*** The inter-library dependencies that have been dropped here will be"
8391 echo "*** automatically added whenever a program is linked with this library"
8392 echo "*** or is declared to -dlopen it."
8393
8394 if test "$allow_undefined" = no; then
8395 echo
8396 echo "*** Since this library must not contain undefined symbols,"
8397 echo "*** because either the platform does not support them or"
8398 echo "*** it was explicitly requested with -no-undefined,"
8399 echo "*** libtool will only create a static version of it."
8400 if test "$build_old_libs" = no; then
8401 oldlibs="$output_objdir/$libname.$libext"
8402 build_libtool_libs=module
8403 build_old_libs=yes
8404 else
8405 build_libtool_libs=no
8406 fi
8407 fi
8408 fi
8409 fi
8410 # Done checking deplibs!
8411 deplibs=$newdeplibs
8412 fi
8413 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
8414 case $host in
8415 *-*-darwin*)
8416 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8417 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8418 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8419 ;;
8420 esac
8421
8422 # move library search paths that coincide with paths to not yet
8423 # installed libraries to the beginning of the library search list
8424 new_libs=
8425 for path in $notinst_path; do
8426 case " $new_libs " in
8427 *" -L$path/$objdir "*) ;;
8428 *)
8429 case " $deplibs " in
8430 *" -L$path/$objdir "*)
8431 new_libs+=" -L$path/$objdir" ;;
8432 esac
8433 ;;
8434 esac
8435 done
8436 for deplib in $deplibs; do
8437 case $deplib in
8438 -L*)
8439 case " $new_libs " in
8440 *" $deplib "*) ;;
8441 *) new_libs+=" $deplib" ;;
8442 esac
8443 ;;
8444 *) new_libs+=" $deplib" ;;
8445 esac
8446 done
8447 deplibs="$new_libs"
8448
8449 # All the library-specific variables (install_libdir is set above).
8450 library_names=
8451 old_library=
8452 dlname=
8453
8454 # Test again, we may have decided not to build it any more
8455 if test "$build_libtool_libs" = yes; then
8456 # Remove ${wl} instances when linking with ld.
8457 # FIXME: should test the right _cmds variable.
8458 case $archive_cmds in
8459 *\$LD\ *) wl= ;;
8460 esac
8461 if test "$hardcode_into_libs" = yes; then
8462 # Hardcode the library paths
8463 hardcode_libdirs=
8464 dep_rpath=
8465 rpath="$finalize_rpath"
8466 test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8467 for libdir in $rpath; do
8468 if test -n "$hardcode_libdir_flag_spec"; then
8469 if test -n "$hardcode_libdir_separator"; then
8470 func_replace_sysroot "$libdir"
8471 libdir=$func_replace_sysroot_result
8472 if test -z "$hardcode_libdirs"; then
8473 hardcode_libdirs="$libdir"
8474 else
8475 # Just accumulate the unique libdirs.
8476 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8477 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8478 ;;
8479 *)
8480 hardcode_libdirs+="$hardcode_libdir_separator$libdir"
8481 ;;
8482 esac
8483 fi
8484 else
8485 eval flag=\"$hardcode_libdir_flag_spec\"
8486 dep_rpath+=" $flag"
8487 fi
8488 elif test -n "$runpath_var"; then
8489 case "$perm_rpath " in
8490 *" $libdir "*) ;;
8491 *) perm_rpath+=" $libdir" ;;
8492 esac
8493 fi
8494 done
8495 # Substitute the hardcoded libdirs into the rpath.
8496 if test -n "$hardcode_libdir_separator" &&
8497 test -n "$hardcode_libdirs"; then
8498 libdir="$hardcode_libdirs"
8499 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8500 fi
8501 if test -n "$runpath_var" && test -n "$perm_rpath"; then
8502 # We should set the runpath_var.
8503 rpath=
8504 for dir in $perm_rpath; do
8505 rpath+="$dir:"
8506 done
8507 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8508 fi
8509 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8510 fi
8511
8512 shlibpath="$finalize_shlibpath"
8513 test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8514 if test -n "$shlibpath"; then
8515 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8516 fi
8517
8518 # Get the real and link names of the library.
8519 eval shared_ext=\"$shrext_cmds\"
8520 eval library_names=\"$library_names_spec\"
8521 set dummy $library_names
8522 shift
8523 realname="$1"
8524 shift
8525
8526 if test -n "$soname_spec"; then
8527 eval soname=\"$soname_spec\"
8528 else
8529 soname="$realname"
8530 fi
8531 if test -z "$dlname"; then
8532 dlname=$soname
8533 fi
8534
8535 lib="$output_objdir/$realname"
8536 linknames=
8537 for link
8538 do
8539 linknames+=" $link"
8540 done
8541
8542 # Use standard objects if they are pic
8543 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8544 test "X$libobjs" = "X " && libobjs=
8545
8546 delfiles=
8547 if test -n "$export_symbols" && test -n "$include_expsyms"; then
8548 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8549 export_symbols="$output_objdir/$libname.uexp"
8550 delfiles+=" $export_symbols"
8551 fi
8552
8553 orig_export_symbols=
8554 case $host_os in
8555 cygwin* | mingw* | cegcc*)
8556 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8557 # exporting using user supplied symfile
8558 if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8559 # and it's NOT already a .def file. Must figure out
8560 # which of the given symbols are data symbols and tag
8561 # them as such. So, trigger use of export_symbols_cmds.
8562 # export_symbols gets reassigned inside the "prepare
8563 # the list of exported symbols" if statement, so the
8564 # include_expsyms logic still works.
8565 orig_export_symbols="$export_symbols"
8566 export_symbols=
8567 always_export_symbols=yes
8568 fi
8569 fi
8570 ;;
8571 esac
8572
8573 # Prepare the list of exported symbols
8574 if test -z "$export_symbols"; then
8575 if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8576 func_verbose "generating symbol list for \`$libname.la'"
8577 export_symbols="$output_objdir/$libname.exp"
8578 $opt_dry_run || $RM $export_symbols
8579 cmds=$export_symbols_cmds
8580 save_ifs="$IFS"; IFS='~'
8581 for cmd1 in $cmds; do
8582 IFS="$save_ifs"
8583 # Take the normal branch if the nm_file_list_spec branch
8584 # doesn't work or if tool conversion is not needed.
8585 case $nm_file_list_spec~$to_tool_file_cmd in
8586 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8587 try_normal_branch=yes
8588 eval cmd=\"$cmd1\"
8589 func_len " $cmd"
8590 len=$func_len_result
8591 ;;
8592 *)
8593 try_normal_branch=no
8594 ;;
8595 esac
8596 if test "$try_normal_branch" = yes \
8597 && { test "$len" -lt "$max_cmd_len" \
8598 || test "$max_cmd_len" -le -1; }
8599 then
8600 func_show_eval "$cmd" 'exit $?'
8601 skipped_export=false
8602 elif test -n "$nm_file_list_spec"; then
8603 func_basename "$output"
8604 output_la=$func_basename_result
8605 save_libobjs=$libobjs
8606 save_output=$output
8607 output=${output_objdir}/${output_la}.nm
8608 func_to_tool_file "$output"
8609 libobjs=$nm_file_list_spec$func_to_tool_file_result
8610 delfiles+=" $output"
8611 func_verbose "creating $NM input file list: $output"
8612 for obj in $save_libobjs; do
8613 func_to_tool_file "$obj"
8614 $ECHO "$func_to_tool_file_result"
8615 done > "$output"
8616 eval cmd=\"$cmd1\"
8617 func_show_eval "$cmd" 'exit $?'
8618 output=$save_output
8619 libobjs=$save_libobjs
8620 skipped_export=false
8621 else
8622 # The command line is too long to execute in one step.
8623 func_verbose "using reloadable object file for export list..."
8624 skipped_export=:
8625 # Break out early, otherwise skipped_export may be
8626 # set to false by a later but shorter cmd.
8627 break
8628 fi
8629 done
8630 IFS="$save_ifs"
8631 if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8632 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8633 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8634 fi
8635 fi
8636 fi
8637
8638 if test -n "$export_symbols" && test -n "$include_expsyms"; then
8639 tmp_export_symbols="$export_symbols"
8640 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8641 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8642 fi
8643
8644 if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8645 # The given exports_symbols file has to be filtered, so filter it.
8646 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8647 # FIXME: $output_objdir/$libname.filter potentially contains lots of
8648 # 's' commands which not all seds can handle. GNU sed should be fine
8649 # though. Also, the filter scales superlinearly with the number of
8650 # global variables. join(1) would be nice here, but unfortunately
8651 # isn't a blessed tool.
8652 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8653 delfiles+=" $export_symbols $output_objdir/$libname.filter"
8654 export_symbols=$output_objdir/$libname.def
8655 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8656 fi
8657
8658 tmp_deplibs=
8659 for test_deplib in $deplibs; do
8660 case " $convenience " in
8661 *" $test_deplib "*) ;;
8662 *)
8663 tmp_deplibs+=" $test_deplib"
8664 ;;
8665 esac
8666 done
8667 deplibs="$tmp_deplibs"
8668
8669 if test -n "$convenience"; then
8670 if test -n "$whole_archive_flag_spec" &&
8671 test "$compiler_needs_object" = yes &&
8672 test -z "$libobjs"; then
8673 # extract the archives, so we have objects to list.
8674 # TODO: could optimize this to just extract one archive.
8675 whole_archive_flag_spec=
8676 fi
8677 if test -n "$whole_archive_flag_spec"; then
8678 save_libobjs=$libobjs
8679 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8680 test "X$libobjs" = "X " && libobjs=
8681 else
8682 gentop="$output_objdir/${outputname}x"
8683 generated+=" $gentop"
8684
8685 func_extract_archives $gentop $convenience
8686 libobjs+=" $func_extract_archives_result"
8687 test "X$libobjs" = "X " && libobjs=
8688 fi
8689 fi
8690
8691 if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8692 eval flag=\"$thread_safe_flag_spec\"
8693 linker_flags+=" $flag"
8694 fi
8695
8696 # Make a backup of the uninstalled library when relinking
8697 if test "$opt_mode" = relink; then
8698 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8699 fi
8700
8701 # Do each of the archive commands.
8702 if test "$module" = yes && test -n "$module_cmds" ; then
8703 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8704 eval test_cmds=\"$module_expsym_cmds\"
8705 cmds=$module_expsym_cmds
8706 else
8707 eval test_cmds=\"$module_cmds\"
8708 cmds=$module_cmds
8709 fi
8710 else
8711 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8712 eval test_cmds=\"$archive_expsym_cmds\"
8713 cmds=$archive_expsym_cmds
8714 else
8715 eval test_cmds=\"$archive_cmds\"
8716 cmds=$archive_cmds
8717 fi
8718 fi
8719
8720 if test "X$skipped_export" != "X:" &&
8721 func_len " $test_cmds" &&
8722 len=$func_len_result &&
8723 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8724 :
8725 else
8726 # The command line is too long to link in one step, link piecewise
8727 # or, if using GNU ld and skipped_export is not :, use a linker
8728 # script.
8729
8730 # Save the value of $output and $libobjs because we want to
8731 # use them later. If we have whole_archive_flag_spec, we
8732 # want to use save_libobjs as it was before
8733 # whole_archive_flag_spec was expanded, because we can't
8734 # assume the linker understands whole_archive_flag_spec.
8735 # This may have to be revisited, in case too many
8736 # convenience libraries get linked in and end up exceeding
8737 # the spec.
8738 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8739 save_libobjs=$libobjs
8740 fi
8741 save_output=$output
8742 func_basename "$output"
8743 output_la=$func_basename_result
8744
8745 # Clear the reloadable object creation command queue and
8746 # initialize k to one.
8747 test_cmds=
8748 concat_cmds=
8749 objlist=
8750 last_robj=
8751 k=1
8752
8753 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8754 output=${output_objdir}/${output_la}.lnkscript
8755 func_verbose "creating GNU ld script: $output"
8756 echo 'INPUT (' > $output
8757 for obj in $save_libobjs
8758 do
8759 func_to_tool_file "$obj"
8760 $ECHO "$func_to_tool_file_result" >> $output
8761 done
8762 echo ')' >> $output
8763 delfiles+=" $output"
8764 func_to_tool_file "$output"
8765 output=$func_to_tool_file_result
8766 elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8767 output=${output_objdir}/${output_la}.lnk
8768 func_verbose "creating linker input file list: $output"
8769 : > $output
8770 set x $save_libobjs
8771 shift
8772 firstobj=
8773 if test "$compiler_needs_object" = yes; then
8774 firstobj="$1 "
8775 shift
8776 fi
8777 for obj
8778 do
8779 func_to_tool_file "$obj"
8780 $ECHO "$func_to_tool_file_result" >> $output
8781 done
8782 delfiles+=" $output"
8783 func_to_tool_file "$output"
8784 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8785 else
8786 if test -n "$save_libobjs"; then
8787 func_verbose "creating reloadable object files..."
8788 output=$output_objdir/$output_la-${k}.$objext
8789 eval test_cmds=\"$reload_cmds\"
8790 func_len " $test_cmds"
8791 len0=$func_len_result
8792 len=$len0
8793
8794 # Loop over the list of objects to be linked.
8795 for obj in $save_libobjs
8796 do
8797 func_len " $obj"
8798 func_arith $len + $func_len_result
8799 len=$func_arith_result
8800 if test "X$objlist" = X ||
8801 test "$len" -lt "$max_cmd_len"; then
8802 objlist+=" $obj"
8803 else
8804 # The command $test_cmds is almost too long, add a
8805 # command to the queue.
8806 if test "$k" -eq 1 ; then
8807 # The first file doesn't have a previous command to add.
8808 reload_objs=$objlist
8809 eval concat_cmds=\"$reload_cmds\"
8810 else
8811 # All subsequent reloadable object files will link in
8812 # the last one created.
8813 reload_objs="$objlist $last_robj"
8814 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8815 fi
8816 last_robj=$output_objdir/$output_la-${k}.$objext
8817 func_arith $k + 1
8818 k=$func_arith_result
8819 output=$output_objdir/$output_la-${k}.$objext
8820 objlist=" $obj"
8821 func_len " $last_robj"
8822 func_arith $len0 + $func_len_result
8823 len=$func_arith_result
8824 fi
8825 done
8826 # Handle the remaining objects by creating one last
8827 # reloadable object file. All subsequent reloadable object
8828 # files will link in the last one created.
8829 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8830 reload_objs="$objlist $last_robj"
8831 eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8832 if test -n "$last_robj"; then
8833 eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8834 fi
8835 delfiles+=" $output"
8836
8837 else
8838 output=
8839 fi
8840
8841 if ${skipped_export-false}; then
8842 func_verbose "generating symbol list for \`$libname.la'"
8843 export_symbols="$output_objdir/$libname.exp"
8844 $opt_dry_run || $RM $export_symbols
8845 libobjs=$output
8846 # Append the command to create the export file.
8847 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8848 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8849 if test -n "$last_robj"; then
8850 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8851 fi
8852 fi
8853
8854 test -n "$save_libobjs" &&
8855 func_verbose "creating a temporary reloadable object file: $output"
8856
8857 # Loop through the commands generated above and execute them.
8858 save_ifs="$IFS"; IFS='~'
8859 for cmd in $concat_cmds; do
8860 IFS="$save_ifs"
8861 $opt_silent || {
8862 func_quote_for_expand "$cmd"
8863 eval "func_echo $func_quote_for_expand_result"
8864 }
8865 $opt_dry_run || eval "$cmd" || {
8866 lt_exit=$?
8867
8868 # Restore the uninstalled library and exit
8869 if test "$opt_mode" = relink; then
8870 ( cd "$output_objdir" && \
8871 $RM "${realname}T" && \
8872 $MV "${realname}U" "$realname" )
8873 fi
8874
8875 exit $lt_exit
8876 }
8877 done
8878 IFS="$save_ifs"
8879
8880 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8881 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8882 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8883 fi
8884 fi
8885
8886 if ${skipped_export-false}; then
8887 if test -n "$export_symbols" && test -n "$include_expsyms"; then
8888 tmp_export_symbols="$export_symbols"
8889 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8890 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8891 fi
8892
8893 if test -n "$orig_export_symbols"; then
8894 # The given exports_symbols file has to be filtered, so filter it.
8895 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8896 # FIXME: $output_objdir/$libname.filter potentially contains lots of
8897 # 's' commands which not all seds can handle. GNU sed should be fine
8898 # though. Also, the filter scales superlinearly with the number of
8899 # global variables. join(1) would be nice here, but unfortunately
8900 # isn't a blessed tool.
8901 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8902 delfiles+=" $export_symbols $output_objdir/$libname.filter"
8903 export_symbols=$output_objdir/$libname.def
8904 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8905 fi
8906 fi
8907
8908 libobjs=$output
8909 # Restore the value of output.
8910 output=$save_output
8911
8912 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8913 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8914 test "X$libobjs" = "X " && libobjs=
8915 fi
8916 # Expand the library linking commands again to reset the
8917 # value of $libobjs for piecewise linking.
8918
8919 # Do each of the archive commands.
8920 if test "$module" = yes && test -n "$module_cmds" ; then
8921 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8922 cmds=$module_expsym_cmds
8923 else
8924 cmds=$module_cmds
8925 fi
8926 else
8927 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8928 cmds=$archive_expsym_cmds
8929 else
8930 cmds=$archive_cmds
8931 fi
8932 fi
8933 fi
8934
8935 if test -n "$delfiles"; then
8936 # Append the command to remove temporary files to $cmds.
8937 eval cmds=\"\$cmds~\$RM $delfiles\"
8938 fi
8939
8940 # Add any objects from preloaded convenience libraries
8941 if test -n "$dlprefiles"; then
8942 gentop="$output_objdir/${outputname}x"
8943 generated+=" $gentop"
8944
8945 func_extract_archives $gentop $dlprefiles
8946 libobjs+=" $func_extract_archives_result"
8947 test "X$libobjs" = "X " && libobjs=
8948 fi
8949
8950 save_ifs="$IFS"; IFS='~'
8951 for cmd in $cmds; do
8952 IFS="$save_ifs"
8953 eval cmd=\"$cmd\"
8954 $opt_silent || {
8955 func_quote_for_expand "$cmd"
8956 eval "func_echo $func_quote_for_expand_result"
8957 }
8958 $opt_dry_run || eval "$cmd" || {
8959 lt_exit=$?
8960
8961 # Restore the uninstalled library and exit
8962 if test "$opt_mode" = relink; then
8963 ( cd "$output_objdir" && \
8964 $RM "${realname}T" && \
8965 $MV "${realname}U" "$realname" )
8966 fi
8967
8968 exit $lt_exit
8969 }
8970 done
8971 IFS="$save_ifs"
8972
8973 # Restore the uninstalled library and exit
8974 if test "$opt_mode" = relink; then
8975 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8976
8977 if test -n "$convenience"; then
8978 if test -z "$whole_archive_flag_spec"; then
8979 func_show_eval '${RM}r "$gentop"'
8980 fi
8981 fi
8982
8983 exit $EXIT_SUCCESS
8984 fi
8985
8986 # Create links to the real library.
8987 for linkname in $linknames; do
8988 if test "$realname" != "$linkname"; then
8989 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8990 fi
8991 done
8992
8993 # If -module or -export-dynamic was specified, set the dlname.
8994 if test "$module" = yes || test "$export_dynamic" = yes; then
8995 # On all known operating systems, these are identical.
8996 dlname="$soname"
8997 fi
8998 fi
8999 ;;
9000
9001 obj)
9002 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
9003 func_warning "\`-dlopen' is ignored for objects"
9004 fi
9005
9006 case " $deplibs" in
9007 *\ -l* | *\ -L*)
9008 func_warning "\`-l' and \`-L' are ignored for objects" ;;
9009 esac
9010
9011 test -n "$rpath" && \
9012 func_warning "\`-rpath' is ignored for objects"
9013
9014 test -n "$xrpath" && \
9015 func_warning "\`-R' is ignored for objects"
9016
9017 test -n "$vinfo" && \
9018 func_warning "\`-version-info' is ignored for objects"
9019
9020 test -n "$release" && \
9021 func_warning "\`-release' is ignored for objects"
9022
9023 case $output in
9024 *.lo)
9025 test -n "$objs$old_deplibs" && \
9026 func_fatal_error "cannot build library object \`$output' from non-libtool objects"
9027
9028 libobj=$output
9029 func_lo2o "$libobj"
9030 obj=$func_lo2o_result
9031 ;;
9032 *)
9033 libobj=
9034 obj="$output"
9035 ;;
9036 esac
9037
9038 # Delete the old objects.
9039 $opt_dry_run || $RM $obj $libobj
9040
9041 # Objects from convenience libraries. This assumes
9042 # single-version convenience libraries. Whenever we create
9043 # different ones for PIC/non-PIC, this we'll have to duplicate
9044 # the extraction.
9045 reload_conv_objs=
9046 gentop=
9047 # reload_cmds runs $LD directly, so let us get rid of
9048 # -Wl from whole_archive_flag_spec and hope we can get by with
9049 # turning comma into space..
9050 wl=
9051
9052 if test -n "$convenience"; then
9053 if test -n "$whole_archive_flag_spec"; then
9054 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
9055 reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
9056 else
9057 gentop="$output_objdir/${obj}x"
9058 generated+=" $gentop"
9059
9060 func_extract_archives $gentop $convenience
9061 reload_conv_objs="$reload_objs $func_extract_archives_result"
9062 fi
9063 fi
9064
9065 # If we're not building shared, we need to use non_pic_objs
9066 test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
9067
9068 # Create the old-style object.
9069 reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
9070
9071 output="$obj"
9072 func_execute_cmds "$reload_cmds" 'exit $?'
9073
9074 # Exit if we aren't doing a library object file.
9075 if test -z "$libobj"; then
9076 if test -n "$gentop"; then
9077 func_show_eval '${RM}r "$gentop"'
9078 fi
9079
9080 exit $EXIT_SUCCESS
9081 fi
9082
9083 if test "$build_libtool_libs" != yes; then
9084 if test -n "$gentop"; then
9085 func_show_eval '${RM}r "$gentop"'
9086 fi
9087
9088 # Create an invalid libtool object if no PIC, so that we don't
9089 # accidentally link it into a program.
9090 # $show "echo timestamp > $libobj"
9091 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
9092 exit $EXIT_SUCCESS
9093 fi
9094
9095 if test -n "$pic_flag" || test "$pic_mode" != default; then
9096 # Only do commands if we really have different PIC objects.
9097 reload_objs="$libobjs $reload_conv_objs"
9098 output="$libobj"
9099 func_execute_cmds "$reload_cmds" 'exit $?'
9100 fi
9101
9102 if test -n "$gentop"; then
9103 func_show_eval '${RM}r "$gentop"'
9104 fi
9105
9106 exit $EXIT_SUCCESS
9107 ;;
9108
9109 prog)
9110 case $host in
9111 *cygwin*) func_stripname '' '.exe' "$output"
9112 output=$func_stripname_result.exe;;
9113 esac
9114 test -n "$vinfo" && \
9115 func_warning "\`-version-info' is ignored for programs"
9116
9117 test -n "$release" && \
9118 func_warning "\`-release' is ignored for programs"
9119
9120 test "$preload" = yes \
9121 && test "$dlopen_support" = unknown \
9122 && test "$dlopen_self" = unknown \
9123 && test "$dlopen_self_static" = unknown && \
9124 func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
9125
9126 case $host in
9127 *-*-rhapsody* | *-*-darwin1.[012])
9128 # On Rhapsody replace the C library is the System framework
9129 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
9130 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
9131 ;;
9132 esac
9133
9134 case $host in
9135 *-*-darwin*)
9136 # Don't allow lazy linking, it breaks C++ global constructors
9137 # But is supposedly fixed on 10.4 or later (yay!).
9138 if test "$tagname" = CXX ; then
9139 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
9140 10.[0123])
9141 compile_command+=" ${wl}-bind_at_load"
9142 finalize_command+=" ${wl}-bind_at_load"
9143 ;;
9144 esac
9145 fi
9146 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
9147 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9148 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
9149 ;;
9150 esac
9151
9152
9153 # move library search paths that coincide with paths to not yet
9154 # installed libraries to the beginning of the library search list
9155 new_libs=
9156 for path in $notinst_path; do
9157 case " $new_libs " in
9158 *" -L$path/$objdir "*) ;;
9159 *)
9160 case " $compile_deplibs " in
9161 *" -L$path/$objdir "*)
9162 new_libs+=" -L$path/$objdir" ;;
9163 esac
9164 ;;
9165 esac
9166 done
9167 for deplib in $compile_deplibs; do
9168 case $deplib in
9169 -L*)
9170 case " $new_libs " in
9171 *" $deplib "*) ;;
9172 *) new_libs+=" $deplib" ;;
9173 esac
9174 ;;
9175 *) new_libs+=" $deplib" ;;
9176 esac
9177 done
9178 compile_deplibs="$new_libs"
9179
9180
9181 compile_command+=" $compile_deplibs"
9182 finalize_command+=" $finalize_deplibs"
9183
9184 if test -n "$rpath$xrpath"; then
9185 # If the user specified any rpath flags, then add them.
9186 for libdir in $rpath $xrpath; do
9187 # This is the magic to use -rpath.
9188 case "$finalize_rpath " in
9189 *" $libdir "*) ;;
9190 *) finalize_rpath+=" $libdir" ;;
9191 esac
9192 done
9193 fi
9194
9195 # Now hardcode the library paths
9196 rpath=
9197 hardcode_libdirs=
9198 for libdir in $compile_rpath $finalize_rpath; do
9199 if test -n "$hardcode_libdir_flag_spec"; then
9200 if test -n "$hardcode_libdir_separator"; then
9201 if test -z "$hardcode_libdirs"; then
9202 hardcode_libdirs="$libdir"
9203 else
9204 # Just accumulate the unique libdirs.
9205 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9206 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9207 ;;
9208 *)
9209 hardcode_libdirs+="$hardcode_libdir_separator$libdir"
9210 ;;
9211 esac
9212 fi
9213 else
9214 eval flag=\"$hardcode_libdir_flag_spec\"
9215 rpath+=" $flag"
9216 fi
9217 elif test -n "$runpath_var"; then
9218 case "$perm_rpath " in
9219 *" $libdir "*) ;;
9220 *) perm_rpath+=" $libdir" ;;
9221 esac
9222 fi
9223 case $host in
9224 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
9225 testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
9226 case :$dllsearchpath: in
9227 *":$libdir:"*) ;;
9228 ::) dllsearchpath=$libdir;;
9229 *) dllsearchpath+=":$libdir";;
9230 esac
9231 case :$dllsearchpath: in
9232 *":$testbindir:"*) ;;
9233 ::) dllsearchpath=$testbindir;;
9234 *) dllsearchpath+=":$testbindir";;
9235 esac
9236 ;;
9237 esac
9238 done
9239 # Substitute the hardcoded libdirs into the rpath.
9240 if test -n "$hardcode_libdir_separator" &&
9241 test -n "$hardcode_libdirs"; then
9242 libdir="$hardcode_libdirs"
9243 eval rpath=\" $hardcode_libdir_flag_spec\"
9244 fi
9245 compile_rpath="$rpath"
9246
9247 rpath=
9248 hardcode_libdirs=
9249 for libdir in $finalize_rpath; do
9250 if test -n "$hardcode_libdir_flag_spec"; then
9251 if test -n "$hardcode_libdir_separator"; then
9252 if test -z "$hardcode_libdirs"; then
9253 hardcode_libdirs="$libdir"
9254 else
9255 # Just accumulate the unique libdirs.
9256 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
9257 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
9258 ;;
9259 *)
9260 hardcode_libdirs+="$hardcode_libdir_separator$libdir"
9261 ;;
9262 esac
9263 fi
9264 else
9265 eval flag=\"$hardcode_libdir_flag_spec\"
9266 rpath+=" $flag"
9267 fi
9268 elif test -n "$runpath_var"; then
9269 case "$finalize_perm_rpath " in
9270 *" $libdir "*) ;;
9271 *) finalize_perm_rpath+=" $libdir" ;;
9272 esac
9273 fi
9274 done
9275 # Substitute the hardcoded libdirs into the rpath.
9276 if test -n "$hardcode_libdir_separator" &&
9277 test -n "$hardcode_libdirs"; then
9278 libdir="$hardcode_libdirs"
9279 eval rpath=\" $hardcode_libdir_flag_spec\"
9280 fi
9281 finalize_rpath="$rpath"
9282
9283 if test -n "$libobjs" && test "$build_old_libs" = yes; then
9284 # Transform all the library objects into standard objects.
9285 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
9286 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
9287 fi
9288
9289 func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
9290
9291 # template prelinking step
9292 if test -n "$prelink_cmds"; then
9293 func_execute_cmds "$prelink_cmds" 'exit $?'
9294 fi
9295
9296 wrappers_required=yes
9297 case $host in
9298 *cegcc* | *mingw32ce*)
9299 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
9300 wrappers_required=no
9301 ;;
9302 *cygwin* | *mingw* )
9303 if test "$build_libtool_libs" != yes; then
9304 wrappers_required=no
9305 fi
9306 ;;
9307 *)
9308 if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
9309 wrappers_required=no
9310 fi
9311 ;;
9312 esac
9313 if test "$wrappers_required" = no; then
9314 # Replace the output file specification.
9315 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
9316 link_command="$compile_command$compile_rpath"
9317
9318 # We have no uninstalled library dependencies, so finalize right now.
9319 exit_status=0
9320 func_show_eval "$link_command" 'exit_status=$?'
9321
9322 if test -n "$postlink_cmds"; then
9323 func_to_tool_file "$output"
9324 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
9325 func_execute_cmds "$postlink_cmds" 'exit $?'
9326 fi
9327
9328 # Delete the generated files.
9329 if test -f "$output_objdir/${outputname}S.${objext}"; then
9330 func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
9331 fi
9332
9333 exit $exit_status
9334 fi
9335
9336 if test -n "$compile_shlibpath$finalize_shlibpath"; then
9337 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
9338 fi
9339 if test -n "$finalize_shlibpath"; then
9340 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
9341 fi
9342
9343 compile_var=
9344 finalize_var=
9345 if test -n "$runpath_var"; then
9346 if test -n "$perm_rpath"; then
9347 # We should set the runpath_var.
9348 rpath=
9349 for dir in $perm_rpath; do
9350 rpath+="$dir:"
9351 done
9352 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
9353 fi
9354 if test -n "$finalize_perm_rpath"; then
9355 # We should set the runpath_var.
9356 rpath=
9357 for dir in $finalize_perm_rpath; do
9358 rpath+="$dir:"
9359 done
9360 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
9361 fi
9362 fi
9363
9364 if test "$no_install" = yes; then
9365 # We don't need to create a wrapper script.
9366 link_command="$compile_var$compile_command$compile_rpath"
9367 # Replace the output file specification.
9368 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
9369 # Delete the old output file.
9370 $opt_dry_run || $RM $output
9371 # Link the executable and exit
9372 func_show_eval "$link_command" 'exit $?'
9373
9374 if test -n "$postlink_cmds"; then
9375 func_to_tool_file "$output"
9376 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
9377 func_execute_cmds "$postlink_cmds" 'exit $?'
9378 fi
9379
9380 exit $EXIT_SUCCESS
9381 fi
9382
9383 if test "$hardcode_action" = relink; then
9384 # Fast installation is not supported
9385 link_command="$compile_var$compile_command$compile_rpath"
9386 relink_command="$finalize_var$finalize_command$finalize_rpath"
9387
9388 func_warning "this platform does not like uninstalled shared libraries"
9389 func_warning "\`$output' will be relinked during installation"
9390 else
9391 if test "$fast_install" != no; then
9392 link_command="$finalize_var$compile_command$finalize_rpath"
9393 if test "$fast_install" = yes; then
9394 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
9395 else
9396 # fast_install is set to needless
9397 relink_command=
9398 fi
9399 else
9400 link_command="$compile_var$compile_command$compile_rpath"
9401 relink_command="$finalize_var$finalize_command$finalize_rpath"
9402 fi
9403 fi
9404
9405 # Replace the output file specification.
9406 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
9407
9408 # Delete the old output files.
9409 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
9410
9411 func_show_eval "$link_command" 'exit $?'
9412
9413 if test -n "$postlink_cmds"; then
9414 func_to_tool_file "$output_objdir/$outputname"
9415 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
9416 func_execute_cmds "$postlink_cmds" 'exit $?'
9417 fi
9418
9419 # Now create the wrapper script.
9420 func_verbose "creating $output"
9421
9422 # Quote the relink command for shipping.
9423 if test -n "$relink_command"; then
9424 # Preserve any variables that may affect compiler behavior
9425 for var in $variables_saved_for_relink; do
9426 if eval test -z \"\${$var+set}\"; then
9427 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9428 elif eval var_value=\$$var; test -z "$var_value"; then
9429 relink_command="$var=; export $var; $relink_command"
9430 else
9431 func_quote_for_eval "$var_value"
9432 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9433 fi
9434 done
9435 relink_command="(cd `pwd`; $relink_command)"
9436 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9437 fi
9438
9439 # Only actually do things if not in dry run mode.
9440 $opt_dry_run || {
9441 # win32 will think the script is a binary if it has
9442 # a .exe suffix, so we strip it off here.
9443 case $output in
9444 *.exe) func_stripname '' '.exe' "$output"
9445 output=$func_stripname_result ;;
9446 esac
9447 # test for cygwin because mv fails w/o .exe extensions
9448 case $host in
9449 *cygwin*)
9450 exeext=.exe
9451 func_stripname '' '.exe' "$outputname"
9452 outputname=$func_stripname_result ;;
9453 *) exeext= ;;
9454 esac
9455 case $host in
9456 *cygwin* | *mingw* )
9457 func_dirname_and_basename "$output" "" "."
9458 output_name=$func_basename_result
9459 output_path=$func_dirname_result
9460 cwrappersource="$output_path/$objdir/lt-$output_name.c"
9461 cwrapper="$output_path/$output_name.exe"
9462 $RM $cwrappersource $cwrapper
9463 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9464
9465 func_emit_cwrapperexe_src > $cwrappersource
9466
9467 # The wrapper executable is built using the $host compiler,
9468 # because it contains $host paths and files. If cross-
9469 # compiling, it, like the target executable, must be
9470 # executed on the $host or under an emulation environment.
9471 $opt_dry_run || {
9472 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9473 $STRIP $cwrapper
9474 }
9475
9476 # Now, create the wrapper script for func_source use:
9477 func_ltwrapper_scriptname $cwrapper
9478 $RM $func_ltwrapper_scriptname_result
9479 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9480 $opt_dry_run || {
9481 # note: this script will not be executed, so do not chmod.
9482 if test "x$build" = "x$host" ; then
9483 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9484 else
9485 func_emit_wrapper no > $func_ltwrapper_scriptname_result
9486 fi
9487 }
9488 ;;
9489 * )
9490 $RM $output
9491 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9492
9493 func_emit_wrapper no > $output
9494 chmod +x $output
9495 ;;
9496 esac
9497 }
9498 exit $EXIT_SUCCESS
9499 ;;
9500 esac
9501
9502 # See if we need to build an old-fashioned archive.
9503 for oldlib in $oldlibs; do
9504
9505 if test "$build_libtool_libs" = convenience; then
9506 oldobjs="$libobjs_save $symfileobj"
9507 addlibs="$convenience"
9508 build_libtool_libs=no
9509 else
9510 if test "$build_libtool_libs" = module; then
9511 oldobjs="$libobjs_save"
9512 build_libtool_libs=no
9513 else
9514 oldobjs="$old_deplibs $non_pic_objects"
9515 if test "$preload" = yes && test -f "$symfileobj"; then
9516 oldobjs+=" $symfileobj"
9517 fi
9518 fi
9519 addlibs="$old_convenience"
9520 fi
9521
9522 if test -n "$addlibs"; then
9523 gentop="$output_objdir/${outputname}x"
9524 generated+=" $gentop"
9525
9526 func_extract_archives $gentop $addlibs
9527 oldobjs+=" $func_extract_archives_result"
9528 fi
9529
9530 # Do each command in the archive commands.
9531 if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9532 cmds=$old_archive_from_new_cmds
9533 else
9534
9535 # Add any objects from preloaded convenience libraries
9536 if test -n "$dlprefiles"; then
9537 gentop="$output_objdir/${outputname}x"
9538 generated+=" $gentop"
9539
9540 func_extract_archives $gentop $dlprefiles
9541 oldobjs+=" $func_extract_archives_result"
9542 fi
9543
9544 # POSIX demands no paths to be encoded in archives. We have
9545 # to avoid creating archives with duplicate basenames if we
9546 # might have to extract them afterwards, e.g., when creating a
9547 # static archive out of a convenience library, or when linking
9548 # the entirety of a libtool archive into another (currently
9549 # not supported by libtool).
9550 if (for obj in $oldobjs
9551 do
9552 func_basename "$obj"
9553 $ECHO "$func_basename_result"
9554 done | sort | sort -uc >/dev/null 2>&1); then
9555 :
9556 else
9557 echo "copying selected object files to avoid basename conflicts..."
9558 gentop="$output_objdir/${outputname}x"
9559 generated+=" $gentop"
9560 func_mkdir_p "$gentop"
9561 save_oldobjs=$oldobjs
9562 oldobjs=
9563 counter=1
9564 for obj in $save_oldobjs
9565 do
9566 func_basename "$obj"
9567 objbase="$func_basename_result"
9568 case " $oldobjs " in
9569 " ") oldobjs=$obj ;;
9570 *[\ /]"$objbase "*)
9571 while :; do
9572 # Make sure we don't pick an alternate name that also
9573 # overlaps.
9574 newobj=lt$counter-$objbase
9575 func_arith $counter + 1
9576 counter=$func_arith_result
9577 case " $oldobjs " in
9578 *[\ /]"$newobj "*) ;;
9579 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
9580 esac
9581 done
9582 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9583 oldobjs+=" $gentop/$newobj"
9584 ;;
9585 *) oldobjs+=" $obj" ;;
9586 esac
9587 done
9588 fi
9589 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9590 tool_oldlib=$func_to_tool_file_result
9591 eval cmds=\"$old_archive_cmds\"
9592
9593 func_len " $cmds"
9594 len=$func_len_result
9595 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9596 cmds=$old_archive_cmds
9597 elif test -n "$archiver_list_spec"; then
9598 func_verbose "using command file archive linking..."
9599 for obj in $oldobjs
9600 do
9601 func_to_tool_file "$obj"
9602 $ECHO "$func_to_tool_file_result"
9603 done > $output_objdir/$libname.libcmd
9604 func_to_tool_file "$output_objdir/$libname.libcmd"
9605 oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9606 cmds=$old_archive_cmds
9607 else
9608 # the command line is too long to link in one step, link in parts
9609 func_verbose "using piecewise archive linking..."
9610 save_RANLIB=$RANLIB
9611 RANLIB=:
9612 objlist=
9613 concat_cmds=
9614 save_oldobjs=$oldobjs
9615 oldobjs=
9616 # Is there a better way of finding the last object in the list?
9617 for obj in $save_oldobjs
9618 do
9619 last_oldobj=$obj
9620 done
9621 eval test_cmds=\"$old_archive_cmds\"
9622 func_len " $test_cmds"
9623 len0=$func_len_result
9624 len=$len0
9625 for obj in $save_oldobjs
9626 do
9627 func_len " $obj"
9628 func_arith $len + $func_len_result
9629 len=$func_arith_result
9630 objlist+=" $obj"
9631 if test "$len" -lt "$max_cmd_len"; then
9632 :
9633 else
9634 # the above command should be used before it gets too long
9635 oldobjs=$objlist
9636 if test "$obj" = "$last_oldobj" ; then
9637 RANLIB=$save_RANLIB
9638 fi
9639 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9640 eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9641 objlist=
9642 len=$len0
9643 fi
9644 done
9645 RANLIB=$save_RANLIB
9646 oldobjs=$objlist
9647 if test "X$oldobjs" = "X" ; then
9648 eval cmds=\"\$concat_cmds\"
9649 else
9650 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9651 fi
9652 fi
9653 fi
9654 func_execute_cmds "$cmds" 'exit $?'
9655 done
9656
9657 test -n "$generated" && \
9658 func_show_eval "${RM}r$generated"
9659
9660 # Now create the libtool archive.
9661 case $output in
9662 *.la)
9663 old_library=
9664 test "$build_old_libs" = yes && old_library="$libname.$libext"
9665 func_verbose "creating $output"
9666
9667 # Preserve any variables that may affect compiler behavior
9668 for var in $variables_saved_for_relink; do
9669 if eval test -z \"\${$var+set}\"; then
9670 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9671 elif eval var_value=\$$var; test -z "$var_value"; then
9672 relink_command="$var=; export $var; $relink_command"
9673 else
9674 func_quote_for_eval "$var_value"
9675 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9676 fi
9677 done
9678 # Quote the link command for shipping.
9679 relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9680 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9681 if test "$hardcode_automatic" = yes ; then
9682 relink_command=
9683 fi
9684
9685 # Only create the output if not a dry run.
9686 $opt_dry_run || {
9687 for installed in no yes; do
9688 if test "$installed" = yes; then
9689 if test -z "$install_libdir"; then
9690 break
9691 fi
9692 output="$output_objdir/$outputname"i
9693 # Replace all uninstalled libtool libraries with the installed ones
9694 newdependency_libs=
9695 for deplib in $dependency_libs; do
9696 case $deplib in
9697 *.la)
9698 func_basename "$deplib"
9699 name="$func_basename_result"
9700 func_resolve_sysroot "$deplib"
9701 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9702 test -z "$libdir" && \
9703 func_fatal_error "\`$deplib' is not a valid libtool archive"
9704 newdependency_libs+=" ${lt_sysroot:+=}$libdir/$name"
9705 ;;
9706 -L*)
9707 func_stripname -L '' "$deplib"
9708 func_replace_sysroot "$func_stripname_result"
9709 newdependency_libs+=" -L$func_replace_sysroot_result"
9710 ;;
9711 -R*)
9712 func_stripname -R '' "$deplib"
9713 func_replace_sysroot "$func_stripname_result"
9714 newdependency_libs+=" -R$func_replace_sysroot_result"
9715 ;;
9716 *) newdependency_libs+=" $deplib" ;;
9717 esac
9718 done
9719 dependency_libs="$newdependency_libs"
9720 newdlfiles=
9721
9722 for lib in $dlfiles; do
9723 case $lib in
9724 *.la)
9725 func_basename "$lib"
9726 name="$func_basename_result"
9727 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9728 test -z "$libdir" && \
9729 func_fatal_error "\`$lib' is not a valid libtool archive"
9730 newdlfiles+=" ${lt_sysroot:+=}$libdir/$name"
9731 ;;
9732 *) newdlfiles+=" $lib" ;;
9733 esac
9734 done
9735 dlfiles="$newdlfiles"
9736 newdlprefiles=
9737 for lib in $dlprefiles; do
9738 case $lib in
9739 *.la)
9740 # Only pass preopened files to the pseudo-archive (for
9741 # eventual linking with the app. that links it) if we
9742 # didn't already link the preopened objects directly into
9743 # the library:
9744 func_basename "$lib"
9745 name="$func_basename_result"
9746 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9747 test -z "$libdir" && \
9748 func_fatal_error "\`$lib' is not a valid libtool archive"
9749 newdlprefiles+=" ${lt_sysroot:+=}$libdir/$name"
9750 ;;
9751 esac
9752 done
9753 dlprefiles="$newdlprefiles"
9754 else
9755 newdlfiles=
9756 for lib in $dlfiles; do
9757 case $lib in
9758 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9759 *) abs=`pwd`"/$lib" ;;
9760 esac
9761 newdlfiles+=" $abs"
9762 done
9763 dlfiles="$newdlfiles"
9764 newdlprefiles=
9765 for lib in $dlprefiles; do
9766 case $lib in
9767 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9768 *) abs=`pwd`"/$lib" ;;
9769 esac
9770 newdlprefiles+=" $abs"
9771 done
9772 dlprefiles="$newdlprefiles"
9773 fi
9774 $RM $output
9775 # place dlname in correct position for cygwin
9776 # In fact, it would be nice if we could use this code for all target
9777 # systems that can't hard-code library paths into their executables
9778 # and that have no shared library path variable independent of PATH,
9779 # but it turns out we can't easily determine that from inspecting
9780 # libtool variables, so we have to hard-code the OSs to which it
9781 # applies here; at the moment, that means platforms that use the PE
9782 # object format with DLL files. See the long comment at the top of
9783 # tests/bindir.at for full details.
9784 tdlname=$dlname
9785 case $host,$output,$installed,$module,$dlname in
9786 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9787 # If a -bindir argument was supplied, place the dll there.
9788 if test "x$bindir" != x ;
9789 then
9790 func_relative_path "$install_libdir" "$bindir"
9791 tdlname=$func_relative_path_result$dlname
9792 else
9793 # Otherwise fall back on heuristic.
9794 tdlname=../bin/$dlname
9795 fi
9796 ;;
9797 esac
9798 $ECHO > $output "\
9799 # $outputname - a libtool library file
9800 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9801 #
9802 # Please DO NOT delete this file!
9803 # It is necessary for linking the library.
9804
9805 # The name that we can dlopen(3).
9806 dlname='$tdlname'
9807
9808 # Names of this library.
9809 library_names='$library_names'
9810
9811 # The name of the static archive.
9812 old_library='$old_library'
9813
9814 # Linker flags that can not go in dependency_libs.
9815 inherited_linker_flags='$new_inherited_linker_flags'
9816
9817 # Libraries that this one depends upon.
9818 dependency_libs='$dependency_libs'
9819
9820 # Names of additional weak libraries provided by this library
9821 weak_library_names='$weak_libs'
9822
9823 # Version information for $libname.
9824 current=$current
9825 age=$age
9826 revision=$revision
9827
9828 # Is this an already installed library?
9829 installed=$installed
9830
9831 # Should we warn about portability when linking against -modules?
9832 shouldnotlink=$module
9833
9834 # Files to dlopen/dlpreopen
9835 dlopen='$dlfiles'
9836 dlpreopen='$dlprefiles'
9837
9838 # Directory that this library needs to be installed in:
9839 libdir='$install_libdir'"
9840 if test "$installed" = no && test "$need_relink" = yes; then
9841 $ECHO >> $output "\
9842 relink_command=\"$relink_command\""
9843 fi
9844 done
9845 }
9846
9847 # Do a symbolic link so that the libtool archive can be found in
9848 # LD_LIBRARY_PATH before the program is installed.
9849 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9850 ;;
9851 esac
9852 exit $EXIT_SUCCESS
9853 }
9854
9855 { test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9856 func_mode_link ${1+"$@"}
9857
9858
9859 # func_mode_uninstall arg...
9860 func_mode_uninstall ()
9861 {
9862 $opt_debug
9863 RM="$nonopt"
9864 files=
9865 rmforce=
9866 exit_status=0
9867
9868 # This variable tells wrapper scripts just to set variables rather
9869 # than running their programs.
9870 libtool_install_magic="$magic"
9871
9872 for arg
9873 do
9874 case $arg in
9875 -f) RM+=" $arg"; rmforce=yes ;;
9876 -*) RM+=" $arg" ;;
9877 *) files+=" $arg" ;;
9878 esac
9879 done
9880
9881 test -z "$RM" && \
9882 func_fatal_help "you must specify an RM program"
9883
9884 rmdirs=
9885
9886 for file in $files; do
9887 func_dirname "$file" "" "."
9888 dir="$func_dirname_result"
9889 if test "X$dir" = X.; then
9890 odir="$objdir"
9891 else
9892 odir="$dir/$objdir"
9893 fi
9894 func_basename "$file"
9895 name="$func_basename_result"
9896 test "$opt_mode" = uninstall && odir="$dir"
9897
9898 # Remember odir for removal later, being careful to avoid duplicates
9899 if test "$opt_mode" = clean; then
9900 case " $rmdirs " in
9901 *" $odir "*) ;;
9902 *) rmdirs+=" $odir" ;;
9903 esac
9904 fi
9905
9906 # Don't error if the file doesn't exist and rm -f was used.
9907 if { test -L "$file"; } >/dev/null 2>&1 ||
9908 { test -h "$file"; } >/dev/null 2>&1 ||
9909 test -f "$file"; then
9910 :
9911 elif test -d "$file"; then
9912 exit_status=1
9913 continue
9914 elif test "$rmforce" = yes; then
9915 continue
9916 fi
9917
9918 rmfiles="$file"
9919
9920 case $name in
9921 *.la)
9922 # Possibly a libtool archive, so verify it.
9923 if func_lalib_p "$file"; then
9924 func_source $dir/$name
9925
9926 # Delete the libtool libraries and symlinks.
9927 for n in $library_names; do
9928 rmfiles+=" $odir/$n"
9929 done
9930 test -n "$old_library" && rmfiles+=" $odir/$old_library"
9931
9932 case "$opt_mode" in
9933 clean)
9934 case " $library_names " in
9935 *" $dlname "*) ;;
9936 *) test -n "$dlname" && rmfiles+=" $odir/$dlname" ;;
9937 esac
9938 test -n "$libdir" && rmfiles+=" $odir/$name $odir/${name}i"
9939 ;;
9940 uninstall)
9941 if test -n "$library_names"; then
9942 # Do each command in the postuninstall commands.
9943 func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9944 fi
9945
9946 if test -n "$old_library"; then
9947 # Do each command in the old_postuninstall commands.
9948 func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9949 fi
9950 # FIXME: should reinstall the best remaining shared library.
9951 ;;
9952 esac
9953 fi
9954 ;;
9955
9956 *.lo)
9957 # Possibly a libtool object, so verify it.
9958 if func_lalib_p "$file"; then
9959
9960 # Read the .lo file
9961 func_source $dir/$name
9962
9963 # Add PIC object to the list of files to remove.
9964 if test -n "$pic_object" &&
9965 test "$pic_object" != none; then
9966 rmfiles+=" $dir/$pic_object"
9967 fi
9968
9969 # Add non-PIC object to the list of files to remove.
9970 if test -n "$non_pic_object" &&
9971 test "$non_pic_object" != none; then
9972 rmfiles+=" $dir/$non_pic_object"
9973 fi
9974 fi
9975 ;;
9976
9977 *)
9978 if test "$opt_mode" = clean ; then
9979 noexename=$name
9980 case $file in
9981 *.exe)
9982 func_stripname '' '.exe' "$file"
9983 file=$func_stripname_result
9984 func_stripname '' '.exe' "$name"
9985 noexename=$func_stripname_result
9986 # $file with .exe has already been added to rmfiles,
9987 # add $file without .exe
9988 rmfiles+=" $file"
9989 ;;
9990 esac
9991 # Do a test to see if this is a libtool program.
9992 if func_ltwrapper_p "$file"; then
9993 if func_ltwrapper_executable_p "$file"; then
9994 func_ltwrapper_scriptname "$file"
9995 relink_command=
9996 func_source $func_ltwrapper_scriptname_result
9997 rmfiles+=" $func_ltwrapper_scriptname_result"
9998 else
9999 relink_command=
10000 func_source $dir/$noexename
10001 fi
10002
10003 # note $name still contains .exe if it was in $file originally
10004 # as does the version of $file that was added into $rmfiles
10005 rmfiles+=" $odir/$name $odir/${name}S.${objext}"
10006 if test "$fast_install" = yes && test -n "$relink_command"; then
10007 rmfiles+=" $odir/lt-$name"
10008 fi
10009 if test "X$noexename" != "X$name" ; then
10010 rmfiles+=" $odir/lt-${noexename}.c"
10011 fi
10012 fi
10013 fi
10014 ;;
10015 esac
10016 func_show_eval "$RM $rmfiles" 'exit_status=1'
10017 done
10018
10019 # Try to remove the ${objdir}s in the directories where we deleted files
10020 for dir in $rmdirs; do
10021 if test -d "$dir"; then
10022 func_show_eval "rmdir $dir >/dev/null 2>&1"
10023 fi
10024 done
10025
10026 exit $exit_status
10027 }
10028
10029 { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
10030 func_mode_uninstall ${1+"$@"}
10031
10032 test -z "$opt_mode" && {
10033 help="$generic_help"
10034 func_fatal_help "you must specify a MODE"
10035 }
10036
10037 test -z "$exec_cmd" && \
10038 func_fatal_help "invalid operation mode \`$opt_mode'"
10039
10040 if test -n "$exec_cmd"; then
10041 eval exec "$exec_cmd"
10042 exit $EXIT_FAILURE
10043 fi
10044
10045 exit $exit_status
10046
10047
10048 # The TAGs below are defined such that we never get into a situation
10049 # in which we disable both kinds of libraries. Given conflicting
10050 # choices, we go for a static library, that is the most portable,
10051 # since we can't tell whether shared libraries were disabled because
10052 # the user asked for that or because the platform doesn't support
10053 # them. This is particularly important on AIX, because we don't
10054 # support having both static and shared libraries enabled at the same
10055 # time on that platform, so we default to a shared-only configuration.
10056 # If a disable-shared tag is given, we'll fallback to a static-only
10057 # configuration. But we'll never go from static-only to shared-only.
10058
10059 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
10060 build_libtool_libs=no
10061 build_old_libs=yes
10062 # ### END LIBTOOL TAG CONFIG: disable-shared
10063
10064 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
10065 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
10066 # ### END LIBTOOL TAG CONFIG: disable-static
10067
10068 # Local Variables:
10069 # mode:shell-script
10070 # sh-indentation:2
10071 # End:
10072 # vi:sw=2
10073
0
1 # libtool (GNU libtool) 2.4.2
2 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
3
4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
5 # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
6 # This is free software; see the source for copying conditions. There is NO
7 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8
9 # GNU Libtool is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13 #
14 # As a special exception to the GNU General Public License,
15 # if you distribute this file as part of a program or library that
16 # is built using GNU Libtool, you may include this file under the
17 # same distribution terms that you use for the rest of that program.
18 #
19 # GNU Libtool is distributed in the hope that it will be useful, but
20 # WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 # General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with GNU Libtool; see the file COPYING. If not, a copy
26 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
27 # or obtained by writing to the Free Software Foundation, Inc.,
28 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
30 # Usage: $progname [OPTION]... [MODE-ARG]...
31 #
32 # Provide generalized library-building support services.
33 #
34 # --config show all configuration variables
35 # --debug enable verbose shell tracing
36 # -n, --dry-run display commands without modifying any files
37 # --features display basic configuration information and exit
38 # --mode=MODE use operation mode MODE
39 # --preserve-dup-deps don't remove duplicate dependency libraries
40 # --quiet, --silent don't print informational messages
41 # --no-quiet, --no-silent
42 # print informational messages (default)
43 # --no-warn don't display warning messages
44 # --tag=TAG use configuration variables from tag TAG
45 # -v, --verbose print more informational messages than default
46 # --no-verbose don't print the extra informational messages
47 # --version print version information
48 # -h, --help, --help-all print short, long, or detailed help message
49 #
50 # MODE must be one of the following:
51 #
52 # clean remove files from the build directory
53 # compile compile a source file into a libtool object
54 # execute automatically set library path, then run a program
55 # finish complete the installation of libtool libraries
56 # install install libraries or executables
57 # link create a library or an executable
58 # uninstall remove libraries from an installed directory
59 #
60 # MODE-ARGS vary depending on the MODE. When passed as first option,
61 # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
62 # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
63 #
64 # When reporting a bug, please describe a test case to reproduce it and
65 # include the following information:
66 #
67 # host-triplet: $host
68 # shell: $SHELL
69 # compiler: $LTCC
70 # compiler flags: $LTCFLAGS
71 # linker: $LD (gnu? $with_gnu_ld)
72 # $progname: (GNU libtool) 2.4.2
73 # automake: $automake_version
74 # autoconf: $autoconf_version
75 #
76 # Report bugs to <bug-libtool@gnu.org>.
77 # GNU libtool home page: <http://www.gnu.org/software/libtool/>.
78 # General help using GNU software: <http://www.gnu.org/gethelp/>.
79
80 PROGRAM=libtool
81 PACKAGE=libtool
82 VERSION=2.4.2
83 TIMESTAMP=""
84 package_revision=1.3337
85
86 # Be Bourne compatible
87 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
88 emulate sh
89 NULLCMD=:
90 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
91 # is contrary to our usage. Disable this feature.
92 alias -g '${1+"$@"}'='"$@"'
93 setopt NO_GLOB_SUBST
94 else
95 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
96 fi
97 BIN_SH=xpg4; export BIN_SH # for Tru64
98 DUALCASE=1; export DUALCASE # for MKS sh
99
100 # A function that is used when there is no print builtin or printf.
101 func_fallback_echo ()
102 {
103 eval 'cat <<_LTECHO_EOF
104 $1
105 _LTECHO_EOF'
106 }
107
108 # NLS nuisances: We save the old values to restore during execute mode.
109 lt_user_locale=
110 lt_safe_locale=
111 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
112 do
113 eval "if test \"\${$lt_var+set}\" = set; then
114 save_$lt_var=\$$lt_var
115 $lt_var=C
116 export $lt_var
117 lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
118 lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
119 fi"
120 done
121 LC_ALL=C
122 LANGUAGE=C
123 export LANGUAGE LC_ALL
124
125 $lt_unset CDPATH
126
127
128 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
129 # is ksh but when the shell is invoked as "sh" and the current value of
130 # the _XPG environment variable is not equal to 1 (one), the special
131 # positional parameter $0, within a function call, is the name of the
132 # function.
133 progpath="$0"
134
135
136
137 : ${CP="cp -f"}
138 test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
139 : ${MAKE="make"}
140 : ${MKDIR="mkdir"}
141 : ${MV="mv -f"}
142 : ${RM="rm -f"}
143 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
144 : ${Xsed="$SED -e 1s/^X//"}
145
146 # Global variables:
147 EXIT_SUCCESS=0
148 EXIT_FAILURE=1
149 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
150 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
151
152 exit_status=$EXIT_SUCCESS
153
154 # Make sure IFS has a sensible default
155 lt_nl='
156 '
157 IFS=" $lt_nl"
158
159 dirname="s,/[^/]*$,,"
160 basename="s,^.*/,,"
161
162 # func_dirname file append nondir_replacement
163 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
164 # otherwise set result to NONDIR_REPLACEMENT.
165 func_dirname ()
166 {
167 func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
168 if test "X$func_dirname_result" = "X${1}"; then
169 func_dirname_result="${3}"
170 else
171 func_dirname_result="$func_dirname_result${2}"
172 fi
173 } # func_dirname may be replaced by extended shell implementation
174
175
176 # func_basename file
177 func_basename ()
178 {
179 func_basename_result=`$ECHO "${1}" | $SED "$basename"`
180 } # func_basename may be replaced by extended shell implementation
181
182
183 # func_dirname_and_basename file append nondir_replacement
184 # perform func_basename and func_dirname in a single function
185 # call:
186 # dirname: Compute the dirname of FILE. If nonempty,
187 # add APPEND to the result, otherwise set result
188 # to NONDIR_REPLACEMENT.
189 # value returned in "$func_dirname_result"
190 # basename: Compute filename of FILE.
191 # value retuned in "$func_basename_result"
192 # Implementation must be kept synchronized with func_dirname
193 # and func_basename. For efficiency, we do not delegate to
194 # those functions but instead duplicate the functionality here.
195 func_dirname_and_basename ()
196 {
197 # Extract subdirectory from the argument.
198 func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
199 if test "X$func_dirname_result" = "X${1}"; then
200 func_dirname_result="${3}"
201 else
202 func_dirname_result="$func_dirname_result${2}"
203 fi
204 func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
205 } # func_dirname_and_basename may be replaced by extended shell implementation
206
207
208 # func_stripname prefix suffix name
209 # strip PREFIX and SUFFIX off of NAME.
210 # PREFIX and SUFFIX must not contain globbing or regex special
211 # characters, hashes, percent signs, but SUFFIX may contain a leading
212 # dot (in which case that matches only a dot).
213 # func_strip_suffix prefix name
214 func_stripname ()
215 {
216 case ${2} in
217 .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
218 *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
219 esac
220 } # func_stripname may be replaced by extended shell implementation
221
222
223 # These SED scripts presuppose an absolute path with a trailing slash.
224 pathcar='s,^/\([^/]*\).*$,\1,'
225 pathcdr='s,^/[^/]*,,'
226 removedotparts=':dotsl
227 s@/\./@/@g
228 t dotsl
229 s,/\.$,/,'
230 collapseslashes='s@/\{1,\}@/@g'
231 finalslash='s,/*$,/,'
232
233 # func_normal_abspath PATH
234 # Remove doubled-up and trailing slashes, "." path components,
235 # and cancel out any ".." path components in PATH after making
236 # it an absolute path.
237 # value returned in "$func_normal_abspath_result"
238 func_normal_abspath ()
239 {
240 # Start from root dir and reassemble the path.
241 func_normal_abspath_result=
242 func_normal_abspath_tpath=$1
243 func_normal_abspath_altnamespace=
244 case $func_normal_abspath_tpath in
245 "")
246 # Empty path, that just means $cwd.
247 func_stripname '' '/' "`pwd`"
248 func_normal_abspath_result=$func_stripname_result
249 return
250 ;;
251 # The next three entries are used to spot a run of precisely
252 # two leading slashes without using negated character classes;
253 # we take advantage of case's first-match behaviour.
254 ///*)
255 # Unusual form of absolute path, do nothing.
256 ;;
257 //*)
258 # Not necessarily an ordinary path; POSIX reserves leading '//'
259 # and for example Cygwin uses it to access remote file shares
260 # over CIFS/SMB, so we conserve a leading double slash if found.
261 func_normal_abspath_altnamespace=/
262 ;;
263 /*)
264 # Absolute path, do nothing.
265 ;;
266 *)
267 # Relative path, prepend $cwd.
268 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
269 ;;
270 esac
271 # Cancel out all the simple stuff to save iterations. We also want
272 # the path to end with a slash for ease of parsing, so make sure
273 # there is one (and only one) here.
274 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
275 -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
276 while :; do
277 # Processed it all yet?
278 if test "$func_normal_abspath_tpath" = / ; then
279 # If we ascended to the root using ".." the result may be empty now.
280 if test -z "$func_normal_abspath_result" ; then
281 func_normal_abspath_result=/
282 fi
283 break
284 fi
285 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
286 -e "$pathcar"`
287 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
288 -e "$pathcdr"`
289 # Figure out what to do with it
290 case $func_normal_abspath_tcomponent in
291 "")
292 # Trailing empty path component, ignore it.
293 ;;
294 ..)
295 # Parent dir; strip last assembled component from result.
296 func_dirname "$func_normal_abspath_result"
297 func_normal_abspath_result=$func_dirname_result
298 ;;
299 *)
300 # Actual path component, append it.
301 func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
302 ;;
303 esac
304 done
305 # Restore leading double-slash if one was found on entry.
306 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
307 }
308
309 # func_relative_path SRCDIR DSTDIR
310 # generates a relative path from SRCDIR to DSTDIR, with a trailing
311 # slash if non-empty, suitable for immediately appending a filename
312 # without needing to append a separator.
313 # value returned in "$func_relative_path_result"
314 func_relative_path ()
315 {
316 func_relative_path_result=
317 func_normal_abspath "$1"
318 func_relative_path_tlibdir=$func_normal_abspath_result
319 func_normal_abspath "$2"
320 func_relative_path_tbindir=$func_normal_abspath_result
321
322 # Ascend the tree starting from libdir
323 while :; do
324 # check if we have found a prefix of bindir
325 case $func_relative_path_tbindir in
326 $func_relative_path_tlibdir)
327 # found an exact match
328 func_relative_path_tcancelled=
329 break
330 ;;
331 $func_relative_path_tlibdir*)
332 # found a matching prefix
333 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
334 func_relative_path_tcancelled=$func_stripname_result
335 if test -z "$func_relative_path_result"; then
336 func_relative_path_result=.
337 fi
338 break
339 ;;
340 *)
341 func_dirname $func_relative_path_tlibdir
342 func_relative_path_tlibdir=${func_dirname_result}
343 if test "x$func_relative_path_tlibdir" = x ; then
344 # Have to descend all the way to the root!
345 func_relative_path_result=../$func_relative_path_result
346 func_relative_path_tcancelled=$func_relative_path_tbindir
347 break
348 fi
349 func_relative_path_result=../$func_relative_path_result
350 ;;
351 esac
352 done
353
354 # Now calculate path; take care to avoid doubling-up slashes.
355 func_stripname '' '/' "$func_relative_path_result"
356 func_relative_path_result=$func_stripname_result
357 func_stripname '/' '/' "$func_relative_path_tcancelled"
358 if test "x$func_stripname_result" != x ; then
359 func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
360 fi
361
362 # Normalisation. If bindir is libdir, return empty string,
363 # else relative path ending with a slash; either way, target
364 # file name can be directly appended.
365 if test ! -z "$func_relative_path_result"; then
366 func_stripname './' '' "$func_relative_path_result/"
367 func_relative_path_result=$func_stripname_result
368 fi
369 }
370
371 # The name of this program:
372 func_dirname_and_basename "$progpath"
373 progname=$func_basename_result
374
375 # Make sure we have an absolute path for reexecution:
376 case $progpath in
377 [\\/]*|[A-Za-z]:\\*) ;;
378 *[\\/]*)
379 progdir=$func_dirname_result
380 progdir=`cd "$progdir" && pwd`
381 progpath="$progdir/$progname"
382 ;;
383 *)
384 save_IFS="$IFS"
385 IFS=${PATH_SEPARATOR-:}
386 for progdir in $PATH; do
387 IFS="$save_IFS"
388 test -x "$progdir/$progname" && break
389 done
390 IFS="$save_IFS"
391 test -n "$progdir" || progdir=`pwd`
392 progpath="$progdir/$progname"
393 ;;
394 esac
395
396 # Sed substitution that helps us do robust quoting. It backslashifies
397 # metacharacters that are still active within double-quoted strings.
398 Xsed="${SED}"' -e 1s/^X//'
399 sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
400
401 # Same as above, but do not quote variable references.
402 double_quote_subst='s/\(["`\\]\)/\\\1/g'
403
404 # Sed substitution that turns a string into a regex matching for the
405 # string literally.
406 sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
407
408 # Sed substitution that converts a w32 file name or path
409 # which contains forward slashes, into one that contains
410 # (escaped) backslashes. A very naive implementation.
411 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
412
413 # Re-`\' parameter expansions in output of double_quote_subst that were
414 # `\'-ed in input to the same. If an odd number of `\' preceded a '$'
415 # in input to double_quote_subst, that '$' was protected from expansion.
416 # Since each input `\' is now two `\'s, look for any number of runs of
417 # four `\'s followed by two `\'s and then a '$'. `\' that '$'.
418 bs='\\'
419 bs2='\\\\'
420 bs4='\\\\\\\\'
421 dollar='\$'
422 sed_double_backslash="\
423 s/$bs4/&\\
424 /g
425 s/^$bs2$dollar/$bs&/
426 s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
427 s/\n//g"
428
429 # Standard options:
430 opt_dry_run=false
431 opt_help=false
432 opt_quiet=false
433 opt_verbose=false
434 opt_warning=:
435
436 # func_echo arg...
437 # Echo program name prefixed message, along with the current mode
438 # name if it has been set yet.
439 func_echo ()
440 {
441 $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
442 }
443
444 # func_verbose arg...
445 # Echo program name prefixed message in verbose mode only.
446 func_verbose ()
447 {
448 $opt_verbose && func_echo ${1+"$@"}
449
450 # A bug in bash halts the script if the last line of a function
451 # fails when set -e is in force, so we need another command to
452 # work around that:
453 :
454 }
455
456 # func_echo_all arg...
457 # Invoke $ECHO with all args, space-separated.
458 func_echo_all ()
459 {
460 $ECHO "$*"
461 }
462
463 # func_error arg...
464 # Echo program name prefixed message to standard error.
465 func_error ()
466 {
467 $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
468 }
469
470 # func_warning arg...
471 # Echo program name prefixed warning message to standard error.
472 func_warning ()
473 {
474 $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
475
476 # bash bug again:
477 :
478 }
479
480 # func_fatal_error arg...
481 # Echo program name prefixed message to standard error, and exit.
482 func_fatal_error ()
483 {
484 func_error ${1+"$@"}
485 exit $EXIT_FAILURE
486 }
487
488 # func_fatal_help arg...
489 # Echo program name prefixed message to standard error, followed by
490 # a help hint, and exit.
491 func_fatal_help ()
492 {
493 func_error ${1+"$@"}
494 func_fatal_error "$help"
495 }
496 help="Try \`$progname --help' for more information." ## default
497
498
499 # func_grep expression filename
500 # Check whether EXPRESSION matches any line of FILENAME, without output.
501 func_grep ()
502 {
503 $GREP "$1" "$2" >/dev/null 2>&1
504 }
505
506
507 # func_mkdir_p directory-path
508 # Make sure the entire path to DIRECTORY-PATH is available.
509 func_mkdir_p ()
510 {
511 my_directory_path="$1"
512 my_dir_list=
513
514 if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
515
516 # Protect directory names starting with `-'
517 case $my_directory_path in
518 -*) my_directory_path="./$my_directory_path" ;;
519 esac
520
521 # While some portion of DIR does not yet exist...
522 while test ! -d "$my_directory_path"; do
523 # ...make a list in topmost first order. Use a colon delimited
524 # list incase some portion of path contains whitespace.
525 my_dir_list="$my_directory_path:$my_dir_list"
526
527 # If the last portion added has no slash in it, the list is done
528 case $my_directory_path in */*) ;; *) break ;; esac
529
530 # ...otherwise throw away the child directory and loop
531 my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
532 done
533 my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
534
535 save_mkdir_p_IFS="$IFS"; IFS=':'
536 for my_dir in $my_dir_list; do
537 IFS="$save_mkdir_p_IFS"
538 # mkdir can fail with a `File exist' error if two processes
539 # try to create one of the directories concurrently. Don't
540 # stop in that case!
541 $MKDIR "$my_dir" 2>/dev/null || :
542 done
543 IFS="$save_mkdir_p_IFS"
544
545 # Bail out if we (or some other process) failed to create a directory.
546 test -d "$my_directory_path" || \
547 func_fatal_error "Failed to create \`$1'"
548 fi
549 }
550
551
552 # func_mktempdir [string]
553 # Make a temporary directory that won't clash with other running
554 # libtool processes, and avoids race conditions if possible. If
555 # given, STRING is the basename for that directory.
556 func_mktempdir ()
557 {
558 my_template="${TMPDIR-/tmp}/${1-$progname}"
559
560 if test "$opt_dry_run" = ":"; then
561 # Return a directory name, but don't create it in dry-run mode
562 my_tmpdir="${my_template}-$$"
563 else
564
565 # If mktemp works, use that first and foremost
566 my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
567
568 if test ! -d "$my_tmpdir"; then
569 # Failing that, at least try and use $RANDOM to avoid a race
570 my_tmpdir="${my_template}-${RANDOM-0}$$"
571
572 save_mktempdir_umask=`umask`
573 umask 0077
574 $MKDIR "$my_tmpdir"
575 umask $save_mktempdir_umask
576 fi
577
578 # If we're not in dry-run mode, bomb out on failure
579 test -d "$my_tmpdir" || \
580 func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
581 fi
582
583 $ECHO "$my_tmpdir"
584 }
585
586
587 # func_quote_for_eval arg
588 # Aesthetically quote ARG to be evaled later.
589 # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
590 # is double-quoted, suitable for a subsequent eval, whereas
591 # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
592 # which are still active within double quotes backslashified.
593 func_quote_for_eval ()
594 {
595 case $1 in
596 *[\\\`\"\$]*)
597 func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
598 *)
599 func_quote_for_eval_unquoted_result="$1" ;;
600 esac
601
602 case $func_quote_for_eval_unquoted_result in
603 # Double-quote args containing shell metacharacters to delay
604 # word splitting, command substitution and and variable
605 # expansion for a subsequent eval.
606 # Many Bourne shells cannot handle close brackets correctly
607 # in scan sets, so we specify it separately.
608 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
609 func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
610 ;;
611 *)
612 func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
613 esac
614 }
615
616
617 # func_quote_for_expand arg
618 # Aesthetically quote ARG to be evaled later; same as above,
619 # but do not quote variable references.
620 func_quote_for_expand ()
621 {
622 case $1 in
623 *[\\\`\"]*)
624 my_arg=`$ECHO "$1" | $SED \
625 -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
626 *)
627 my_arg="$1" ;;
628 esac
629
630 case $my_arg in
631 # Double-quote args containing shell metacharacters to delay
632 # word splitting and command substitution for a subsequent eval.
633 # Many Bourne shells cannot handle close brackets correctly
634 # in scan sets, so we specify it separately.
635 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
636 my_arg="\"$my_arg\""
637 ;;
638 esac
639
640 func_quote_for_expand_result="$my_arg"
641 }
642
643
644 # func_show_eval cmd [fail_exp]
645 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
646 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
647 # is given, then evaluate it.
648 func_show_eval ()
649 {
650 my_cmd="$1"
651 my_fail_exp="${2-:}"
652
653 ${opt_silent-false} || {
654 func_quote_for_expand "$my_cmd"
655 eval "func_echo $func_quote_for_expand_result"
656 }
657
658 if ${opt_dry_run-false}; then :; else
659 eval "$my_cmd"
660 my_status=$?
661 if test "$my_status" -eq 0; then :; else
662 eval "(exit $my_status); $my_fail_exp"
663 fi
664 fi
665 }
666
667
668 # func_show_eval_locale cmd [fail_exp]
669 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
670 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
671 # is given, then evaluate it. Use the saved locale for evaluation.
672 func_show_eval_locale ()
673 {
674 my_cmd="$1"
675 my_fail_exp="${2-:}"
676
677 ${opt_silent-false} || {
678 func_quote_for_expand "$my_cmd"
679 eval "func_echo $func_quote_for_expand_result"
680 }
681
682 if ${opt_dry_run-false}; then :; else
683 eval "$lt_user_locale
684 $my_cmd"
685 my_status=$?
686 eval "$lt_safe_locale"
687 if test "$my_status" -eq 0; then :; else
688 eval "(exit $my_status); $my_fail_exp"
689 fi
690 fi
691 }
692
693 # func_tr_sh
694 # Turn $1 into a string suitable for a shell variable name.
695 # Result is stored in $func_tr_sh_result. All characters
696 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
697 # if $1 begins with a digit, a '_' is prepended as well.
698 func_tr_sh ()
699 {
700 case $1 in
701 [0-9]* | *[!a-zA-Z0-9_]*)
702 func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
703 ;;
704 * )
705 func_tr_sh_result=$1
706 ;;
707 esac
708 }
709
710
711 # func_version
712 # Echo version message to standard output and exit.
713 func_version ()
714 {
715 $opt_debug
716
717 $SED -n '/(C)/!b go
718 :more
719 /\./!{
720 N
721 s/\n# / /
722 b more
723 }
724 :go
725 /^# '$PROGRAM' (GNU /,/# warranty; / {
726 s/^# //
727 s/^# *$//
728 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
729 p
730 }' < "$progpath"
731 exit $?
732 }
733
734 # func_usage
735 # Echo short help message to standard output and exit.
736 func_usage ()
737 {
738 $opt_debug
739
740 $SED -n '/^# Usage:/,/^# *.*--help/ {
741 s/^# //
742 s/^# *$//
743 s/\$progname/'$progname'/
744 p
745 }' < "$progpath"
746 echo
747 $ECHO "run \`$progname --help | more' for full usage"
748 exit $?
749 }
750
751 # func_help [NOEXIT]
752 # Echo long help message to standard output and exit,
753 # unless 'noexit' is passed as argument.
754 func_help ()
755 {
756 $opt_debug
757
758 $SED -n '/^# Usage:/,/# Report bugs to/ {
759 :print
760 s/^# //
761 s/^# *$//
762 s*\$progname*'$progname'*
763 s*\$host*'"$host"'*
764 s*\$SHELL*'"$SHELL"'*
765 s*\$LTCC*'"$LTCC"'*
766 s*\$LTCFLAGS*'"$LTCFLAGS"'*
767 s*\$LD*'"$LD"'*
768 s/\$with_gnu_ld/'"$with_gnu_ld"'/
769 s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
770 s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
771 p
772 d
773 }
774 /^# .* home page:/b print
775 /^# General help using/b print
776 ' < "$progpath"
777 ret=$?
778 if test -z "$1"; then
779 exit $ret
780 fi
781 }
782
783 # func_missing_arg argname
784 # Echo program name prefixed message to standard error and set global
785 # exit_cmd.
786 func_missing_arg ()
787 {
788 $opt_debug
789
790 func_error "missing argument for $1."
791 exit_cmd=exit
792 }
793
794
795 # func_split_short_opt shortopt
796 # Set func_split_short_opt_name and func_split_short_opt_arg shell
797 # variables after splitting SHORTOPT after the 2nd character.
798 func_split_short_opt ()
799 {
800 my_sed_short_opt='1s/^\(..\).*$/\1/;q'
801 my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
802
803 func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
804 func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
805 } # func_split_short_opt may be replaced by extended shell implementation
806
807
808 # func_split_long_opt longopt
809 # Set func_split_long_opt_name and func_split_long_opt_arg shell
810 # variables after splitting LONGOPT at the `=' sign.
811 func_split_long_opt ()
812 {
813 my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
814 my_sed_long_arg='1s/^--[^=]*=//'
815
816 func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
817 func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
818 } # func_split_long_opt may be replaced by extended shell implementation
819
820 exit_cmd=:
821
822
823
824
825
826 magic="%%%MAGIC variable%%%"
827 magic_exe="%%%MAGIC EXE variable%%%"
828
829 # Global variables.
830 nonopt=
831 preserve_args=
832 lo2o="s/\\.lo\$/.${objext}/"
833 o2lo="s/\\.${objext}\$/.lo/"
834 extracted_archives=
835 extracted_serial=0
836
837 # If this variable is set in any of the actions, the command in it
838 # will be execed at the end. This prevents here-documents from being
839 # left over by shells.
840 exec_cmd=
841
842 # func_append var value
843 # Append VALUE to the end of shell variable VAR.
844 func_append ()
845 {
846 eval "${1}=\$${1}\${2}"
847 } # func_append may be replaced by extended shell implementation
848
849 # func_append_quoted var value
850 # Quote VALUE and append to the end of shell variable VAR, separated
851 # by a space.
852 func_append_quoted ()
853 {
854 func_quote_for_eval "${2}"
855 eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
856 } # func_append_quoted may be replaced by extended shell implementation
857
858
859 # func_arith arithmetic-term...
860 func_arith ()
861 {
862 func_arith_result=`expr "${@}"`
863 } # func_arith may be replaced by extended shell implementation
864
865
866 # func_len string
867 # STRING may not start with a hyphen.
868 func_len ()
869 {
870 func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
871 } # func_len may be replaced by extended shell implementation
872
873
874 # func_lo2o object
875 func_lo2o ()
876 {
877 func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
878 } # func_lo2o may be replaced by extended shell implementation
879
880
881 # func_xform libobj-or-source
882 func_xform ()
883 {
884 func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
885 } # func_xform may be replaced by extended shell implementation
886
887
888 # func_fatal_configuration arg...
889 # Echo program name prefixed message to standard error, followed by
890 # a configuration failure hint, and exit.
891 func_fatal_configuration ()
892 {
893 func_error ${1+"$@"}
894 func_error "See the $PACKAGE documentation for more information."
895 func_fatal_error "Fatal configuration error."
896 }
897
898
899 # func_config
900 # Display the configuration for all the tags in this script.
901 func_config ()
902 {
903 re_begincf='^# ### BEGIN LIBTOOL'
904 re_endcf='^# ### END LIBTOOL'
905
906 # Default configuration.
907 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
908
909 # Now print the configurations for the tags.
910 for tagname in $taglist; do
911 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
912 done
913
914 exit $?
915 }
916
917 # func_features
918 # Display the features supported by this script.
919 func_features ()
920 {
921 echo "host: $host"
922 if test "$build_libtool_libs" = yes; then
923 echo "enable shared libraries"
924 else
925 echo "disable shared libraries"
926 fi
927 if test "$build_old_libs" = yes; then
928 echo "enable static libraries"
929 else
930 echo "disable static libraries"
931 fi
932
933 exit $?
934 }
935
936 # func_enable_tag tagname
937 # Verify that TAGNAME is valid, and either flag an error and exit, or
938 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
939 # variable here.
940 func_enable_tag ()
941 {
942 # Global variable:
943 tagname="$1"
944
945 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
946 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
947 sed_extractcf="/$re_begincf/,/$re_endcf/p"
948
949 # Validate tagname.
950 case $tagname in
951 *[!-_A-Za-z0-9,/]*)
952 func_fatal_error "invalid tag name: $tagname"
953 ;;
954 esac
955
956 # Don't test for the "default" C tag, as we know it's
957 # there but not specially marked.
958 case $tagname in
959 CC) ;;
960 *)
961 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
962 taglist="$taglist $tagname"
963
964 # Evaluate the configuration. Be careful to quote the path
965 # and the sed script, to avoid splitting on whitespace, but
966 # also don't use non-portable quotes within backquotes within
967 # quotes we have to do it in 2 steps:
968 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
969 eval "$extractedcf"
970 else
971 func_error "ignoring unknown tag $tagname"
972 fi
973 ;;
974 esac
975 }
976
977 # func_check_version_match
978 # Ensure that we are using m4 macros, and libtool script from the same
979 # release of libtool.
980 func_check_version_match ()
981 {
982 if test "$package_revision" != "$macro_revision"; then
983 if test "$VERSION" != "$macro_version"; then
984 if test -z "$macro_version"; then
985 cat >&2 <<_LT_EOF
986 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
987 $progname: definition of this LT_INIT comes from an older release.
988 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
989 $progname: and run autoconf again.
990 _LT_EOF
991 else
992 cat >&2 <<_LT_EOF
993 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
994 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
995 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
996 $progname: and run autoconf again.
997 _LT_EOF
998 fi
999 else
1000 cat >&2 <<_LT_EOF
1001 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
1002 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
1003 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
1004 $progname: of $PACKAGE $VERSION and run autoconf again.
1005 _LT_EOF
1006 fi
1007
1008 exit $EXIT_MISMATCH
1009 fi
1010 }
1011
1012
1013 # Shorthand for --mode=foo, only valid as the first argument
1014 case $1 in
1015 clean|clea|cle|cl)
1016 shift; set dummy --mode clean ${1+"$@"}; shift
1017 ;;
1018 compile|compil|compi|comp|com|co|c)
1019 shift; set dummy --mode compile ${1+"$@"}; shift
1020 ;;
1021 execute|execut|execu|exec|exe|ex|e)
1022 shift; set dummy --mode execute ${1+"$@"}; shift
1023 ;;
1024 finish|finis|fini|fin|fi|f)
1025 shift; set dummy --mode finish ${1+"$@"}; shift
1026 ;;
1027 install|instal|insta|inst|ins|in|i)
1028 shift; set dummy --mode install ${1+"$@"}; shift
1029 ;;
1030 link|lin|li|l)
1031 shift; set dummy --mode link ${1+"$@"}; shift
1032 ;;
1033 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
1034 shift; set dummy --mode uninstall ${1+"$@"}; shift
1035 ;;
1036 esac
1037
1038
1039
1040 # Option defaults:
1041 opt_debug=:
1042 opt_dry_run=false
1043 opt_config=false
1044 opt_preserve_dup_deps=false
1045 opt_features=false
1046 opt_finish=false
1047 opt_help=false
1048 opt_help_all=false
1049 opt_silent=:
1050 opt_warning=:
1051 opt_verbose=:
1052 opt_silent=false
1053 opt_verbose=false
1054
1055
1056 # Parse options once, thoroughly. This comes as soon as possible in the
1057 # script to make things like `--version' happen as quickly as we can.
1058 {
1059 # this just eases exit handling
1060 while test $# -gt 0; do
1061 opt="$1"
1062 shift
1063 case $opt in
1064 --debug|-x) opt_debug='set -x'
1065 func_echo "enabling shell trace mode"
1066 $opt_debug
1067 ;;
1068 --dry-run|--dryrun|-n)
1069 opt_dry_run=:
1070 ;;
1071 --config)
1072 opt_config=:
1073 func_config
1074 ;;
1075 --dlopen|-dlopen)
1076 optarg="$1"
1077 opt_dlopen="${opt_dlopen+$opt_dlopen
1078 }$optarg"
1079 shift
1080 ;;
1081 --preserve-dup-deps)
1082 opt_preserve_dup_deps=:
1083 ;;
1084 --features)
1085 opt_features=:
1086 func_features
1087 ;;
1088 --finish)
1089 opt_finish=:
1090 set dummy --mode finish ${1+"$@"}; shift
1091 ;;
1092 --help)
1093 opt_help=:
1094 ;;
1095 --help-all)
1096 opt_help_all=:
1097 opt_help=': help-all'
1098 ;;
1099 --mode)
1100 test $# = 0 && func_missing_arg $opt && break
1101 optarg="$1"
1102 opt_mode="$optarg"
1103 case $optarg in
1104 # Valid mode arguments:
1105 clean|compile|execute|finish|install|link|relink|uninstall) ;;
1106
1107 # Catch anything else as an error
1108 *) func_error "invalid argument for $opt"
1109 exit_cmd=exit
1110 break
1111 ;;
1112 esac
1113 shift
1114 ;;
1115 --no-silent|--no-quiet)
1116 opt_silent=false
1117 func_append preserve_args " $opt"
1118 ;;
1119 --no-warning|--no-warn)
1120 opt_warning=false
1121 func_append preserve_args " $opt"
1122 ;;
1123 --no-verbose)
1124 opt_verbose=false
1125 func_append preserve_args " $opt"
1126 ;;
1127 --silent|--quiet)
1128 opt_silent=:
1129 func_append preserve_args " $opt"
1130 opt_verbose=false
1131 ;;
1132 --verbose|-v)
1133 opt_verbose=:
1134 func_append preserve_args " $opt"
1135 opt_silent=false
1136 ;;
1137 --tag)
1138 test $# = 0 && func_missing_arg $opt && break
1139 optarg="$1"
1140 opt_tag="$optarg"
1141 func_append preserve_args " $opt $optarg"
1142 func_enable_tag "$optarg"
1143 shift
1144 ;;
1145
1146 -\?|-h) func_usage ;;
1147 --help) func_help ;;
1148 --version) func_version ;;
1149
1150 # Separate optargs to long options:
1151 --*=*)
1152 func_split_long_opt "$opt"
1153 set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
1154 shift
1155 ;;
1156
1157 # Separate non-argument short options:
1158 -\?*|-h*|-n*|-v*)
1159 func_split_short_opt "$opt"
1160 set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
1161 shift
1162 ;;
1163
1164 --) break ;;
1165 -*) func_fatal_help "unrecognized option \`$opt'" ;;
1166 *) set dummy "$opt" ${1+"$@"}; shift; break ;;
1167 esac
1168 done
1169
1170 # Validate options:
1171
1172 # save first non-option argument
1173 if test "$#" -gt 0; then
1174 nonopt="$opt"
1175 shift
1176 fi
1177
1178 # preserve --debug
1179 test "$opt_debug" = : || func_append preserve_args " --debug"
1180
1181 case $host in
1182 *cygwin* | *mingw* | *pw32* | *cegcc*)
1183 # don't eliminate duplications in $postdeps and $predeps
1184 opt_duplicate_compiler_generated_deps=:
1185 ;;
1186 *)
1187 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
1188 ;;
1189 esac
1190
1191 $opt_help || {
1192 # Sanity checks first:
1193 func_check_version_match
1194
1195 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
1196 func_fatal_configuration "not configured to build any kind of library"
1197 fi
1198
1199 # Darwin sucks
1200 eval std_shrext=\"$shrext_cmds\"
1201
1202 # Only execute mode is allowed to have -dlopen flags.
1203 if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
1204 func_error "unrecognized option \`-dlopen'"
1205 $ECHO "$help" 1>&2
1206 exit $EXIT_FAILURE
1207 fi
1208
1209 # Change the help message to a mode-specific one.
1210 generic_help="$help"
1211 help="Try \`$progname --help --mode=$opt_mode' for more information."
1212 }
1213
1214
1215 # Bail if the options were screwed
1216 $exit_cmd $EXIT_FAILURE
1217 }
1218
1219
1220
1221
1222 ## ----------- ##
1223 ## Main. ##
1224 ## ----------- ##
1225
1226 # func_lalib_p file
1227 # True iff FILE is a libtool `.la' library or `.lo' object file.
1228 # This function is only a basic sanity check; it will hardly flush out
1229 # determined imposters.
1230 func_lalib_p ()
1231 {
1232 test -f "$1" &&
1233 $SED -e 4q "$1" 2>/dev/null \
1234 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1235 }
1236
1237 # func_lalib_unsafe_p file
1238 # True iff FILE is a libtool `.la' library or `.lo' object file.
1239 # This function implements the same check as func_lalib_p without
1240 # resorting to external programs. To this end, it redirects stdin and
1241 # closes it afterwards, without saving the original file descriptor.
1242 # As a safety measure, use it only where a negative result would be
1243 # fatal anyway. Works if `file' does not exist.
1244 func_lalib_unsafe_p ()
1245 {
1246 lalib_p=no
1247 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1248 for lalib_p_l in 1 2 3 4
1249 do
1250 read lalib_p_line
1251 case "$lalib_p_line" in
1252 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
1253 esac
1254 done
1255 exec 0<&5 5<&-
1256 fi
1257 test "$lalib_p" = yes
1258 }
1259
1260 # func_ltwrapper_script_p file
1261 # True iff FILE is a libtool wrapper script
1262 # This function is only a basic sanity check; it will hardly flush out
1263 # determined imposters.
1264 func_ltwrapper_script_p ()
1265 {
1266 func_lalib_p "$1"
1267 }
1268
1269 # func_ltwrapper_executable_p file
1270 # True iff FILE is a libtool wrapper executable
1271 # This function is only a basic sanity check; it will hardly flush out
1272 # determined imposters.
1273 func_ltwrapper_executable_p ()
1274 {
1275 func_ltwrapper_exec_suffix=
1276 case $1 in
1277 *.exe) ;;
1278 *) func_ltwrapper_exec_suffix=.exe ;;
1279 esac
1280 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
1281 }
1282
1283 # func_ltwrapper_scriptname file
1284 # Assumes file is an ltwrapper_executable
1285 # uses $file to determine the appropriate filename for a
1286 # temporary ltwrapper_script.
1287 func_ltwrapper_scriptname ()
1288 {
1289 func_dirname_and_basename "$1" "" "."
1290 func_stripname '' '.exe' "$func_basename_result"
1291 func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
1292 }
1293
1294 # func_ltwrapper_p file
1295 # True iff FILE is a libtool wrapper script or wrapper executable
1296 # This function is only a basic sanity check; it will hardly flush out
1297 # determined imposters.
1298 func_ltwrapper_p ()
1299 {
1300 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1301 }
1302
1303
1304 # func_execute_cmds commands fail_cmd
1305 # Execute tilde-delimited COMMANDS.
1306 # If FAIL_CMD is given, eval that upon failure.
1307 # FAIL_CMD may read-access the current command in variable CMD!
1308 func_execute_cmds ()
1309 {
1310 $opt_debug
1311 save_ifs=$IFS; IFS='~'
1312 for cmd in $1; do
1313 IFS=$save_ifs
1314 eval cmd=\"$cmd\"
1315 func_show_eval "$cmd" "${2-:}"
1316 done
1317 IFS=$save_ifs
1318 }
1319
1320
1321 # func_source file
1322 # Source FILE, adding directory component if necessary.
1323 # Note that it is not necessary on cygwin/mingw to append a dot to
1324 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
1325 # behavior happens only for exec(3), not for open(2)! Also, sourcing
1326 # `FILE.' does not work on cygwin managed mounts.
1327 func_source ()
1328 {
1329 $opt_debug
1330 case $1 in
1331 */* | *\\*) . "$1" ;;
1332 *) . "./$1" ;;
1333 esac
1334 }
1335
1336
1337 # func_resolve_sysroot PATH
1338 # Replace a leading = in PATH with a sysroot. Store the result into
1339 # func_resolve_sysroot_result
1340 func_resolve_sysroot ()
1341 {
1342 func_resolve_sysroot_result=$1
1343 case $func_resolve_sysroot_result in
1344 =*)
1345 func_stripname '=' '' "$func_resolve_sysroot_result"
1346 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
1347 ;;
1348 esac
1349 }
1350
1351 # func_replace_sysroot PATH
1352 # If PATH begins with the sysroot, replace it with = and
1353 # store the result into func_replace_sysroot_result.
1354 func_replace_sysroot ()
1355 {
1356 case "$lt_sysroot:$1" in
1357 ?*:"$lt_sysroot"*)
1358 func_stripname "$lt_sysroot" '' "$1"
1359 func_replace_sysroot_result="=$func_stripname_result"
1360 ;;
1361 *)
1362 # Including no sysroot.
1363 func_replace_sysroot_result=$1
1364 ;;
1365 esac
1366 }
1367
1368 # func_infer_tag arg
1369 # Infer tagged configuration to use if any are available and
1370 # if one wasn't chosen via the "--tag" command line option.
1371 # Only attempt this if the compiler in the base compile
1372 # command doesn't match the default compiler.
1373 # arg is usually of the form 'gcc ...'
1374 func_infer_tag ()
1375 {
1376 $opt_debug
1377 if test -n "$available_tags" && test -z "$tagname"; then
1378 CC_quoted=
1379 for arg in $CC; do
1380 func_append_quoted CC_quoted "$arg"
1381 done
1382 CC_expanded=`func_echo_all $CC`
1383 CC_quoted_expanded=`func_echo_all $CC_quoted`
1384 case $@ in
1385 # Blanks in the command may have been stripped by the calling shell,
1386 # but not from the CC environment variable when configure was run.
1387 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1388 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1389 # Blanks at the start of $base_compile will cause this to fail
1390 # if we don't check for them as well.
1391 *)
1392 for z in $available_tags; do
1393 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1394 # Evaluate the configuration.
1395 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1396 CC_quoted=
1397 for arg in $CC; do
1398 # Double-quote args containing other shell metacharacters.
1399 func_append_quoted CC_quoted "$arg"
1400 done
1401 CC_expanded=`func_echo_all $CC`
1402 CC_quoted_expanded=`func_echo_all $CC_quoted`
1403 case "$@ " in
1404 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
1405 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1406 # The compiler in the base compile command matches
1407 # the one in the tagged configuration.
1408 # Assume this is the tagged configuration we want.
1409 tagname=$z
1410 break
1411 ;;
1412 esac
1413 fi
1414 done
1415 # If $tagname still isn't set, then no tagged configuration
1416 # was found and let the user know that the "--tag" command
1417 # line option must be used.
1418 if test -z "$tagname"; then
1419 func_echo "unable to infer tagged configuration"
1420 func_fatal_error "specify a tag with \`--tag'"
1421 # else
1422 # func_verbose "using $tagname tagged configuration"
1423 fi
1424 ;;
1425 esac
1426 fi
1427 }
1428
1429
1430
1431 # func_write_libtool_object output_name pic_name nonpic_name
1432 # Create a libtool object file (analogous to a ".la" file),
1433 # but don't create it if we're doing a dry run.
1434 func_write_libtool_object ()
1435 {
1436 write_libobj=${1}
1437 if test "$build_libtool_libs" = yes; then
1438 write_lobj=\'${2}\'
1439 else
1440 write_lobj=none
1441 fi
1442
1443 if test "$build_old_libs" = yes; then
1444 write_oldobj=\'${3}\'
1445 else
1446 write_oldobj=none
1447 fi
1448
1449 $opt_dry_run || {
1450 cat >${write_libobj}T <<EOF
1451 # $write_libobj - a libtool object file
1452 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1453 #
1454 # Please DO NOT delete this file!
1455 # It is necessary for linking the library.
1456
1457 # Name of the PIC object.
1458 pic_object=$write_lobj
1459
1460 # Name of the non-PIC object
1461 non_pic_object=$write_oldobj
1462
1463 EOF
1464 $MV "${write_libobj}T" "${write_libobj}"
1465 }
1466 }
1467
1468
1469 ##################################################
1470 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
1471 ##################################################
1472
1473 # func_convert_core_file_wine_to_w32 ARG
1474 # Helper function used by file name conversion functions when $build is *nix,
1475 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
1476 # correctly configured wine environment available, with the winepath program
1477 # in $build's $PATH.
1478 #
1479 # ARG is the $build file name to be converted to w32 format.
1480 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
1481 # be empty on error (or when ARG is empty)
1482 func_convert_core_file_wine_to_w32 ()
1483 {
1484 $opt_debug
1485 func_convert_core_file_wine_to_w32_result="$1"
1486 if test -n "$1"; then
1487 # Unfortunately, winepath does not exit with a non-zero error code, so we
1488 # are forced to check the contents of stdout. On the other hand, if the
1489 # command is not found, the shell will set an exit code of 127 and print
1490 # *an error message* to stdout. So we must check for both error code of
1491 # zero AND non-empty stdout, which explains the odd construction:
1492 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1493 if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
1494 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1495 $SED -e "$lt_sed_naive_backslashify"`
1496 else
1497 func_convert_core_file_wine_to_w32_result=
1498 fi
1499 fi
1500 }
1501 # end: func_convert_core_file_wine_to_w32
1502
1503
1504 # func_convert_core_path_wine_to_w32 ARG
1505 # Helper function used by path conversion functions when $build is *nix, and
1506 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
1507 # configured wine environment available, with the winepath program in $build's
1508 # $PATH. Assumes ARG has no leading or trailing path separator characters.
1509 #
1510 # ARG is path to be converted from $build format to win32.
1511 # Result is available in $func_convert_core_path_wine_to_w32_result.
1512 # Unconvertible file (directory) names in ARG are skipped; if no directory names
1513 # are convertible, then the result may be empty.
1514 func_convert_core_path_wine_to_w32 ()
1515 {
1516 $opt_debug
1517 # unfortunately, winepath doesn't convert paths, only file names
1518 func_convert_core_path_wine_to_w32_result=""
1519 if test -n "$1"; then
1520 oldIFS=$IFS
1521 IFS=:
1522 for func_convert_core_path_wine_to_w32_f in $1; do
1523 IFS=$oldIFS
1524 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1525 if test -n "$func_convert_core_file_wine_to_w32_result" ; then
1526 if test -z "$func_convert_core_path_wine_to_w32_result"; then
1527 func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
1528 else
1529 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
1530 fi
1531 fi
1532 done
1533 IFS=$oldIFS
1534 fi
1535 }
1536 # end: func_convert_core_path_wine_to_w32
1537
1538
1539 # func_cygpath ARGS...
1540 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
1541 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
1542 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
1543 # (2), returns the Cygwin file name or path in func_cygpath_result (input
1544 # file name or path is assumed to be in w32 format, as previously converted
1545 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
1546 # or path in func_cygpath_result (input file name or path is assumed to be in
1547 # Cygwin format). Returns an empty string on error.
1548 #
1549 # ARGS are passed to cygpath, with the last one being the file name or path to
1550 # be converted.
1551 #
1552 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
1553 # environment variable; do not put it in $PATH.
1554 func_cygpath ()
1555 {
1556 $opt_debug
1557 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
1558 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
1559 if test "$?" -ne 0; then
1560 # on failure, ensure result is empty
1561 func_cygpath_result=
1562 fi
1563 else
1564 func_cygpath_result=
1565 func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
1566 fi
1567 }
1568 #end: func_cygpath
1569
1570
1571 # func_convert_core_msys_to_w32 ARG
1572 # Convert file name or path ARG from MSYS format to w32 format. Return
1573 # result in func_convert_core_msys_to_w32_result.
1574 func_convert_core_msys_to_w32 ()
1575 {
1576 $opt_debug
1577 # awkward: cmd appends spaces to result
1578 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1579 $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
1580 }
1581 #end: func_convert_core_msys_to_w32
1582
1583
1584 # func_convert_file_check ARG1 ARG2
1585 # Verify that ARG1 (a file name in $build format) was converted to $host
1586 # format in ARG2. Otherwise, emit an error message, but continue (resetting
1587 # func_to_host_file_result to ARG1).
1588 func_convert_file_check ()
1589 {
1590 $opt_debug
1591 if test -z "$2" && test -n "$1" ; then
1592 func_error "Could not determine host file name corresponding to"
1593 func_error " \`$1'"
1594 func_error "Continuing, but uninstalled executables may not work."
1595 # Fallback:
1596 func_to_host_file_result="$1"
1597 fi
1598 }
1599 # end func_convert_file_check
1600
1601
1602 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
1603 # Verify that FROM_PATH (a path in $build format) was converted to $host
1604 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
1605 # func_to_host_file_result to a simplistic fallback value (see below).
1606 func_convert_path_check ()
1607 {
1608 $opt_debug
1609 if test -z "$4" && test -n "$3"; then
1610 func_error "Could not determine the host path corresponding to"
1611 func_error " \`$3'"
1612 func_error "Continuing, but uninstalled executables may not work."
1613 # Fallback. This is a deliberately simplistic "conversion" and
1614 # should not be "improved". See libtool.info.
1615 if test "x$1" != "x$2"; then
1616 lt_replace_pathsep_chars="s|$1|$2|g"
1617 func_to_host_path_result=`echo "$3" |
1618 $SED -e "$lt_replace_pathsep_chars"`
1619 else
1620 func_to_host_path_result="$3"
1621 fi
1622 fi
1623 }
1624 # end func_convert_path_check
1625
1626
1627 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
1628 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
1629 # and appending REPL if ORIG matches BACKPAT.
1630 func_convert_path_front_back_pathsep ()
1631 {
1632 $opt_debug
1633 case $4 in
1634 $1 ) func_to_host_path_result="$3$func_to_host_path_result"
1635 ;;
1636 esac
1637 case $4 in
1638 $2 ) func_append func_to_host_path_result "$3"
1639 ;;
1640 esac
1641 }
1642 # end func_convert_path_front_back_pathsep
1643
1644
1645 ##################################################
1646 # $build to $host FILE NAME CONVERSION FUNCTIONS #
1647 ##################################################
1648 # invoked via `$to_host_file_cmd ARG'
1649 #
1650 # In each case, ARG is the path to be converted from $build to $host format.
1651 # Result will be available in $func_to_host_file_result.
1652
1653
1654 # func_to_host_file ARG
1655 # Converts the file name ARG from $build format to $host format. Return result
1656 # in func_to_host_file_result.
1657 func_to_host_file ()
1658 {
1659 $opt_debug
1660 $to_host_file_cmd "$1"
1661 }
1662 # end func_to_host_file
1663
1664
1665 # func_to_tool_file ARG LAZY
1666 # converts the file name ARG from $build format to toolchain format. Return
1667 # result in func_to_tool_file_result. If the conversion in use is listed
1668 # in (the comma separated) LAZY, no conversion takes place.
1669 func_to_tool_file ()
1670 {
1671 $opt_debug
1672 case ,$2, in
1673 *,"$to_tool_file_cmd",*)
1674 func_to_tool_file_result=$1
1675 ;;
1676 *)
1677 $to_tool_file_cmd "$1"
1678 func_to_tool_file_result=$func_to_host_file_result
1679 ;;
1680 esac
1681 }
1682 # end func_to_tool_file
1683
1684
1685 # func_convert_file_noop ARG
1686 # Copy ARG to func_to_host_file_result.
1687 func_convert_file_noop ()
1688 {
1689 func_to_host_file_result="$1"
1690 }
1691 # end func_convert_file_noop
1692
1693
1694 # func_convert_file_msys_to_w32 ARG
1695 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
1696 # conversion to w32 is not available inside the cwrapper. Returns result in
1697 # func_to_host_file_result.
1698 func_convert_file_msys_to_w32 ()
1699 {
1700 $opt_debug
1701 func_to_host_file_result="$1"
1702 if test -n "$1"; then
1703 func_convert_core_msys_to_w32 "$1"
1704 func_to_host_file_result="$func_convert_core_msys_to_w32_result"
1705 fi
1706 func_convert_file_check "$1" "$func_to_host_file_result"
1707 }
1708 # end func_convert_file_msys_to_w32
1709
1710
1711 # func_convert_file_cygwin_to_w32 ARG
1712 # Convert file name ARG from Cygwin to w32 format. Returns result in
1713 # func_to_host_file_result.
1714 func_convert_file_cygwin_to_w32 ()
1715 {
1716 $opt_debug
1717 func_to_host_file_result="$1"
1718 if test -n "$1"; then
1719 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
1720 # LT_CYGPATH in this case.
1721 func_to_host_file_result=`cygpath -m "$1"`
1722 fi
1723 func_convert_file_check "$1" "$func_to_host_file_result"
1724 }
1725 # end func_convert_file_cygwin_to_w32
1726
1727
1728 # func_convert_file_nix_to_w32 ARG
1729 # Convert file name ARG from *nix to w32 format. Requires a wine environment
1730 # and a working winepath. Returns result in func_to_host_file_result.
1731 func_convert_file_nix_to_w32 ()
1732 {
1733 $opt_debug
1734 func_to_host_file_result="$1"
1735 if test -n "$1"; then
1736 func_convert_core_file_wine_to_w32 "$1"
1737 func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
1738 fi
1739 func_convert_file_check "$1" "$func_to_host_file_result"
1740 }
1741 # end func_convert_file_nix_to_w32
1742
1743
1744 # func_convert_file_msys_to_cygwin ARG
1745 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
1746 # Returns result in func_to_host_file_result.
1747 func_convert_file_msys_to_cygwin ()
1748 {
1749 $opt_debug
1750 func_to_host_file_result="$1"
1751 if test -n "$1"; then
1752 func_convert_core_msys_to_w32 "$1"
1753 func_cygpath -u "$func_convert_core_msys_to_w32_result"
1754 func_to_host_file_result="$func_cygpath_result"
1755 fi
1756 func_convert_file_check "$1" "$func_to_host_file_result"
1757 }
1758 # end func_convert_file_msys_to_cygwin
1759
1760
1761 # func_convert_file_nix_to_cygwin ARG
1762 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
1763 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
1764 # in func_to_host_file_result.
1765 func_convert_file_nix_to_cygwin ()
1766 {
1767 $opt_debug
1768 func_to_host_file_result="$1"
1769 if test -n "$1"; then
1770 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
1771 func_convert_core_file_wine_to_w32 "$1"
1772 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1773 func_to_host_file_result="$func_cygpath_result"
1774 fi
1775 func_convert_file_check "$1" "$func_to_host_file_result"
1776 }
1777 # end func_convert_file_nix_to_cygwin
1778
1779
1780 #############################################
1781 # $build to $host PATH CONVERSION FUNCTIONS #
1782 #############################################
1783 # invoked via `$to_host_path_cmd ARG'
1784 #
1785 # In each case, ARG is the path to be converted from $build to $host format.
1786 # The result will be available in $func_to_host_path_result.
1787 #
1788 # Path separators are also converted from $build format to $host format. If
1789 # ARG begins or ends with a path separator character, it is preserved (but
1790 # converted to $host format) on output.
1791 #
1792 # All path conversion functions are named using the following convention:
1793 # file name conversion function : func_convert_file_X_to_Y ()
1794 # path conversion function : func_convert_path_X_to_Y ()
1795 # where, for any given $build/$host combination the 'X_to_Y' value is the
1796 # same. If conversion functions are added for new $build/$host combinations,
1797 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
1798 # will break.
1799
1800
1801 # func_init_to_host_path_cmd
1802 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
1803 # appropriate value, based on the value of $to_host_file_cmd.
1804 to_host_path_cmd=
1805 func_init_to_host_path_cmd ()
1806 {
1807 $opt_debug
1808 if test -z "$to_host_path_cmd"; then
1809 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1810 to_host_path_cmd="func_convert_path_${func_stripname_result}"
1811 fi
1812 }
1813
1814
1815 # func_to_host_path ARG
1816 # Converts the path ARG from $build format to $host format. Return result
1817 # in func_to_host_path_result.
1818 func_to_host_path ()
1819 {
1820 $opt_debug
1821 func_init_to_host_path_cmd
1822 $to_host_path_cmd "$1"
1823 }
1824 # end func_to_host_path
1825
1826
1827 # func_convert_path_noop ARG
1828 # Copy ARG to func_to_host_path_result.
1829 func_convert_path_noop ()
1830 {
1831 func_to_host_path_result="$1"
1832 }
1833 # end func_convert_path_noop
1834
1835
1836 # func_convert_path_msys_to_w32 ARG
1837 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
1838 # conversion to w32 is not available inside the cwrapper. Returns result in
1839 # func_to_host_path_result.
1840 func_convert_path_msys_to_w32 ()
1841 {
1842 $opt_debug
1843 func_to_host_path_result="$1"
1844 if test -n "$1"; then
1845 # Remove leading and trailing path separator characters from ARG. MSYS
1846 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
1847 # and winepath ignores them completely.
1848 func_stripname : : "$1"
1849 func_to_host_path_tmp1=$func_stripname_result
1850 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1851 func_to_host_path_result="$func_convert_core_msys_to_w32_result"
1852 func_convert_path_check : ";" \
1853 "$func_to_host_path_tmp1" "$func_to_host_path_result"
1854 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1855 fi
1856 }
1857 # end func_convert_path_msys_to_w32
1858
1859
1860 # func_convert_path_cygwin_to_w32 ARG
1861 # Convert path ARG from Cygwin to w32 format. Returns result in
1862 # func_to_host_file_result.
1863 func_convert_path_cygwin_to_w32 ()
1864 {
1865 $opt_debug
1866 func_to_host_path_result="$1"
1867 if test -n "$1"; then
1868 # See func_convert_path_msys_to_w32:
1869 func_stripname : : "$1"
1870 func_to_host_path_tmp1=$func_stripname_result
1871 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
1872 func_convert_path_check : ";" \
1873 "$func_to_host_path_tmp1" "$func_to_host_path_result"
1874 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1875 fi
1876 }
1877 # end func_convert_path_cygwin_to_w32
1878
1879
1880 # func_convert_path_nix_to_w32 ARG
1881 # Convert path ARG from *nix to w32 format. Requires a wine environment and
1882 # a working winepath. Returns result in func_to_host_file_result.
1883 func_convert_path_nix_to_w32 ()
1884 {
1885 $opt_debug
1886 func_to_host_path_result="$1"
1887 if test -n "$1"; then
1888 # See func_convert_path_msys_to_w32:
1889 func_stripname : : "$1"
1890 func_to_host_path_tmp1=$func_stripname_result
1891 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1892 func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
1893 func_convert_path_check : ";" \
1894 "$func_to_host_path_tmp1" "$func_to_host_path_result"
1895 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
1896 fi
1897 }
1898 # end func_convert_path_nix_to_w32
1899
1900
1901 # func_convert_path_msys_to_cygwin ARG
1902 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
1903 # Returns result in func_to_host_file_result.
1904 func_convert_path_msys_to_cygwin ()
1905 {
1906 $opt_debug
1907 func_to_host_path_result="$1"
1908 if test -n "$1"; then
1909 # See func_convert_path_msys_to_w32:
1910 func_stripname : : "$1"
1911 func_to_host_path_tmp1=$func_stripname_result
1912 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1913 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1914 func_to_host_path_result="$func_cygpath_result"
1915 func_convert_path_check : : \
1916 "$func_to_host_path_tmp1" "$func_to_host_path_result"
1917 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1918 fi
1919 }
1920 # end func_convert_path_msys_to_cygwin
1921
1922
1923 # func_convert_path_nix_to_cygwin ARG
1924 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
1925 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
1926 # func_to_host_file_result.
1927 func_convert_path_nix_to_cygwin ()
1928 {
1929 $opt_debug
1930 func_to_host_path_result="$1"
1931 if test -n "$1"; then
1932 # Remove leading and trailing path separator characters from
1933 # ARG. msys behavior is inconsistent here, cygpath turns them
1934 # into '.;' and ';.', and winepath ignores them completely.
1935 func_stripname : : "$1"
1936 func_to_host_path_tmp1=$func_stripname_result
1937 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1938 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1939 func_to_host_path_result="$func_cygpath_result"
1940 func_convert_path_check : : \
1941 "$func_to_host_path_tmp1" "$func_to_host_path_result"
1942 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
1943 fi
1944 }
1945 # end func_convert_path_nix_to_cygwin
1946
1947
1948 # func_mode_compile arg...
1949 func_mode_compile ()
1950 {
1951 $opt_debug
1952 # Get the compilation command and the source file.
1953 base_compile=
1954 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
1955 suppress_opt=yes
1956 suppress_output=
1957 arg_mode=normal
1958 libobj=
1959 later=
1960 pie_flag=
1961
1962 for arg
1963 do
1964 case $arg_mode in
1965 arg )
1966 # do not "continue". Instead, add this to base_compile
1967 lastarg="$arg"
1968 arg_mode=normal
1969 ;;
1970
1971 target )
1972 libobj="$arg"
1973 arg_mode=normal
1974 continue
1975 ;;
1976
1977 normal )
1978 # Accept any command-line options.
1979 case $arg in
1980 -o)
1981 test -n "$libobj" && \
1982 func_fatal_error "you cannot specify \`-o' more than once"
1983 arg_mode=target
1984 continue
1985 ;;
1986
1987 -pie | -fpie | -fPIE)
1988 func_append pie_flag " $arg"
1989 continue
1990 ;;
1991
1992 -shared | -static | -prefer-pic | -prefer-non-pic)
1993 func_append later " $arg"
1994 continue
1995 ;;
1996
1997 -no-suppress)
1998 suppress_opt=no
1999 continue
2000 ;;
2001
2002 -Xcompiler)
2003 arg_mode=arg # the next one goes into the "base_compile" arg list
2004 continue # The current "srcfile" will either be retained or
2005 ;; # replaced later. I would guess that would be a bug.
2006
2007 -Wc,*)
2008 func_stripname '-Wc,' '' "$arg"
2009 args=$func_stripname_result
2010 lastarg=
2011 save_ifs="$IFS"; IFS=','
2012 for arg in $args; do
2013 IFS="$save_ifs"
2014 func_append_quoted lastarg "$arg"
2015 done
2016 IFS="$save_ifs"
2017 func_stripname ' ' '' "$lastarg"
2018 lastarg=$func_stripname_result
2019
2020 # Add the arguments to base_compile.
2021 func_append base_compile " $lastarg"
2022 continue
2023 ;;
2024
2025 *)
2026 # Accept the current argument as the source file.
2027 # The previous "srcfile" becomes the current argument.
2028 #
2029 lastarg="$srcfile"
2030 srcfile="$arg"
2031 ;;
2032 esac # case $arg
2033 ;;
2034 esac # case $arg_mode
2035
2036 # Aesthetically quote the previous argument.
2037 func_append_quoted base_compile "$lastarg"
2038 done # for arg
2039
2040 case $arg_mode in
2041 arg)
2042 func_fatal_error "you must specify an argument for -Xcompile"
2043 ;;
2044 target)
2045 func_fatal_error "you must specify a target with \`-o'"
2046 ;;
2047 *)
2048 # Get the name of the library object.
2049 test -z "$libobj" && {
2050 func_basename "$srcfile"
2051 libobj="$func_basename_result"
2052 }
2053 ;;
2054 esac
2055
2056 # Recognize several different file suffixes.
2057 # If the user specifies -o file.o, it is replaced with file.lo
2058 case $libobj in
2059 *.[cCFSifmso] | \
2060 *.ada | *.adb | *.ads | *.asm | \
2061 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
2062 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2063 func_xform "$libobj"
2064 libobj=$func_xform_result
2065 ;;
2066 esac
2067
2068 case $libobj in
2069 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
2070 *)
2071 func_fatal_error "cannot determine name of library object from \`$libobj'"
2072 ;;
2073 esac
2074
2075 func_infer_tag $base_compile
2076
2077 for arg in $later; do
2078 case $arg in
2079 -shared)
2080 test "$build_libtool_libs" != yes && \
2081 func_fatal_configuration "can not build a shared library"
2082 build_old_libs=no
2083 continue
2084 ;;
2085
2086 -static)
2087 build_libtool_libs=no
2088 build_old_libs=yes
2089 continue
2090 ;;
2091
2092 -prefer-pic)
2093 pic_mode=yes
2094 continue
2095 ;;
2096
2097 -prefer-non-pic)
2098 pic_mode=no
2099 continue
2100 ;;
2101 esac
2102 done
2103
2104 func_quote_for_eval "$libobj"
2105 test "X$libobj" != "X$func_quote_for_eval_result" \
2106 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
2107 && func_warning "libobj name \`$libobj' may not contain shell special characters."
2108 func_dirname_and_basename "$obj" "/" ""
2109 objname="$func_basename_result"
2110 xdir="$func_dirname_result"
2111 lobj=${xdir}$objdir/$objname
2112
2113 test -z "$base_compile" && \
2114 func_fatal_help "you must specify a compilation command"
2115
2116 # Delete any leftover library objects.
2117 if test "$build_old_libs" = yes; then
2118 removelist="$obj $lobj $libobj ${libobj}T"
2119 else
2120 removelist="$lobj $libobj ${libobj}T"
2121 fi
2122
2123 # On Cygwin there's no "real" PIC flag so we must build both object types
2124 case $host_os in
2125 cygwin* | mingw* | pw32* | os2* | cegcc*)
2126 pic_mode=default
2127 ;;
2128 esac
2129 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
2130 # non-PIC code in shared libraries is not supported
2131 pic_mode=default
2132 fi
2133
2134 # Calculate the filename of the output object if compiler does
2135 # not support -o with -c
2136 if test "$compiler_c_o" = no; then
2137 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
2138 lockfile="$output_obj.lock"
2139 else
2140 output_obj=
2141 need_locks=no
2142 lockfile=
2143 fi
2144
2145 # Lock this critical section if it is needed
2146 # We use this script file to make the link, it avoids creating a new file
2147 if test "$need_locks" = yes; then
2148 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
2149 func_echo "Waiting for $lockfile to be removed"
2150 sleep 2
2151 done
2152 elif test "$need_locks" = warn; then
2153 if test -f "$lockfile"; then
2154 $ECHO "\
2155 *** ERROR, $lockfile exists and contains:
2156 `cat $lockfile 2>/dev/null`
2157
2158 This indicates that another process is trying to use the same
2159 temporary object file, and libtool could not work around it because
2160 your compiler does not support \`-c' and \`-o' together. If you
2161 repeat this compilation, it may succeed, by chance, but you had better
2162 avoid parallel builds (make -j) in this platform, or get a better
2163 compiler."
2164
2165 $opt_dry_run || $RM $removelist
2166 exit $EXIT_FAILURE
2167 fi
2168 func_append removelist " $output_obj"
2169 $ECHO "$srcfile" > "$lockfile"
2170 fi
2171
2172 $opt_dry_run || $RM $removelist
2173 func_append removelist " $lockfile"
2174 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
2175
2176 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
2177 srcfile=$func_to_tool_file_result
2178 func_quote_for_eval "$srcfile"
2179 qsrcfile=$func_quote_for_eval_result
2180
2181 # Only build a PIC object if we are building libtool libraries.
2182 if test "$build_libtool_libs" = yes; then
2183 # Without this assignment, base_compile gets emptied.
2184 fbsd_hideous_sh_bug=$base_compile
2185
2186 if test "$pic_mode" != no; then
2187 command="$base_compile $qsrcfile $pic_flag"
2188 else
2189 # Don't build PIC code
2190 command="$base_compile $qsrcfile"
2191 fi
2192
2193 func_mkdir_p "$xdir$objdir"
2194
2195 if test -z "$output_obj"; then
2196 # Place PIC objects in $objdir
2197 func_append command " -o $lobj"
2198 fi
2199
2200 func_show_eval_locale "$command" \
2201 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
2202
2203 if test "$need_locks" = warn &&
2204 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2205 $ECHO "\
2206 *** ERROR, $lockfile contains:
2207 `cat $lockfile 2>/dev/null`
2208
2209 but it should contain:
2210 $srcfile
2211
2212 This indicates that another process is trying to use the same
2213 temporary object file, and libtool could not work around it because
2214 your compiler does not support \`-c' and \`-o' together. If you
2215 repeat this compilation, it may succeed, by chance, but you had better
2216 avoid parallel builds (make -j) in this platform, or get a better
2217 compiler."
2218
2219 $opt_dry_run || $RM $removelist
2220 exit $EXIT_FAILURE
2221 fi
2222
2223 # Just move the object if needed, then go on to compile the next one
2224 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
2225 func_show_eval '$MV "$output_obj" "$lobj"' \
2226 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2227 fi
2228
2229 # Allow error messages only from the first compilation.
2230 if test "$suppress_opt" = yes; then
2231 suppress_output=' >/dev/null 2>&1'
2232 fi
2233 fi
2234
2235 # Only build a position-dependent object if we build old libraries.
2236 if test "$build_old_libs" = yes; then
2237 if test "$pic_mode" != yes; then
2238 # Don't build PIC code
2239 command="$base_compile $qsrcfile$pie_flag"
2240 else
2241 command="$base_compile $qsrcfile $pic_flag"
2242 fi
2243 if test "$compiler_c_o" = yes; then
2244 func_append command " -o $obj"
2245 fi
2246
2247 # Suppress compiler output if we already did a PIC compilation.
2248 func_append command "$suppress_output"
2249 func_show_eval_locale "$command" \
2250 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
2251
2252 if test "$need_locks" = warn &&
2253 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
2254 $ECHO "\
2255 *** ERROR, $lockfile contains:
2256 `cat $lockfile 2>/dev/null`
2257
2258 but it should contain:
2259 $srcfile
2260
2261 This indicates that another process is trying to use the same
2262 temporary object file, and libtool could not work around it because
2263 your compiler does not support \`-c' and \`-o' together. If you
2264 repeat this compilation, it may succeed, by chance, but you had better
2265 avoid parallel builds (make -j) in this platform, or get a better
2266 compiler."
2267
2268 $opt_dry_run || $RM $removelist
2269 exit $EXIT_FAILURE
2270 fi
2271
2272 # Just move the object if needed
2273 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
2274 func_show_eval '$MV "$output_obj" "$obj"' \
2275 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
2276 fi
2277 fi
2278
2279 $opt_dry_run || {
2280 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
2281
2282 # Unlock the critical section if it was locked
2283 if test "$need_locks" != no; then
2284 removelist=$lockfile
2285 $RM "$lockfile"
2286 fi
2287 }
2288
2289 exit $EXIT_SUCCESS
2290 }
2291
2292 $opt_help || {
2293 test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
2294 }
2295
2296 func_mode_help ()
2297 {
2298 # We need to display help for each of the modes.
2299 case $opt_mode in
2300 "")
2301 # Generic help is extracted from the usage comments
2302 # at the start of this file.
2303 func_help
2304 ;;
2305
2306 clean)
2307 $ECHO \
2308 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
2309
2310 Remove files from the build directory.
2311
2312 RM is the name of the program to use to delete files associated with each FILE
2313 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
2314 to RM.
2315
2316 If FILE is a libtool library, object or program, all the files associated
2317 with it are deleted. Otherwise, only FILE itself is deleted using RM."
2318 ;;
2319
2320 compile)
2321 $ECHO \
2322 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
2323
2324 Compile a source file into a libtool library object.
2325
2326 This mode accepts the following additional options:
2327
2328 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
2329 -no-suppress do not suppress compiler output for multiple passes
2330 -prefer-pic try to build PIC objects only
2331 -prefer-non-pic try to build non-PIC objects only
2332 -shared do not build a \`.o' file suitable for static linking
2333 -static only build a \`.o' file suitable for static linking
2334 -Wc,FLAG pass FLAG directly to the compiler
2335
2336 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
2337 from the given SOURCEFILE.
2338
2339 The output file name is determined by removing the directory component from
2340 SOURCEFILE, then substituting the C source code suffix \`.c' with the
2341 library object suffix, \`.lo'."
2342 ;;
2343
2344 execute)
2345 $ECHO \
2346 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
2347
2348 Automatically set library path, then run a program.
2349
2350 This mode accepts the following additional options:
2351
2352 -dlopen FILE add the directory containing FILE to the library path
2353
2354 This mode sets the library path environment variable according to \`-dlopen'
2355 flags.
2356
2357 If any of the ARGS are libtool executable wrappers, then they are translated
2358 into their corresponding uninstalled binary, and any of their required library
2359 directories are added to the library path.
2360
2361 Then, COMMAND is executed, with ARGS as arguments."
2362 ;;
2363
2364 finish)
2365 $ECHO \
2366 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
2367
2368 Complete the installation of libtool libraries.
2369
2370 Each LIBDIR is a directory that contains libtool libraries.
2371
2372 The commands that this mode executes may require superuser privileges. Use
2373 the \`--dry-run' option if you just want to see what would be executed."
2374 ;;
2375
2376 install)
2377 $ECHO \
2378 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
2379
2380 Install executables or libraries.
2381
2382 INSTALL-COMMAND is the installation command. The first component should be
2383 either the \`install' or \`cp' program.
2384
2385 The following components of INSTALL-COMMAND are treated specially:
2386
2387 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
2388
2389 The rest of the components are interpreted as arguments to that command (only
2390 BSD-compatible install options are recognized)."
2391 ;;
2392
2393 link)
2394 $ECHO \
2395 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
2396
2397 Link object files or libraries together to form another library, or to
2398 create an executable program.
2399
2400 LINK-COMMAND is a command using the C compiler that you would use to create
2401 a program from several object files.
2402
2403 The following components of LINK-COMMAND are treated specially:
2404
2405 -all-static do not do any dynamic linking at all
2406 -avoid-version do not add a version suffix if possible
2407 -bindir BINDIR specify path to binaries directory (for systems where
2408 libraries must be found in the PATH setting at runtime)
2409 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
2410 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
2411 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
2412 -export-symbols SYMFILE
2413 try to export only the symbols listed in SYMFILE
2414 -export-symbols-regex REGEX
2415 try to export only the symbols matching REGEX
2416 -LLIBDIR search LIBDIR for required installed libraries
2417 -lNAME OUTPUT-FILE requires the installed library libNAME
2418 -module build a library that can dlopened
2419 -no-fast-install disable the fast-install mode
2420 -no-install link a not-installable executable
2421 -no-undefined declare that a library does not refer to external symbols
2422 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
2423 -objectlist FILE Use a list of object files found in FILE to specify objects
2424 -precious-files-regex REGEX
2425 don't remove output files matching REGEX
2426 -release RELEASE specify package release information
2427 -rpath LIBDIR the created library will eventually be installed in LIBDIR
2428 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
2429 -shared only do dynamic linking of libtool libraries
2430 -shrext SUFFIX override the standard shared library file extension
2431 -static do not do any dynamic linking of uninstalled libtool libraries
2432 -static-libtool-libs
2433 do not do any dynamic linking of libtool libraries
2434 -version-info CURRENT[:REVISION[:AGE]]
2435 specify library version info [each variable defaults to 0]
2436 -weak LIBNAME declare that the target provides the LIBNAME interface
2437 -Wc,FLAG
2438 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
2439 -Wl,FLAG
2440 -Xlinker FLAG pass linker-specific FLAG directly to the linker
2441 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
2442
2443 All other options (arguments beginning with \`-') are ignored.
2444
2445 Every other argument is treated as a filename. Files ending in \`.la' are
2446 treated as uninstalled libtool libraries, other files are standard or library
2447 object files.
2448
2449 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
2450 only library objects (\`.lo' files) may be specified, and \`-rpath' is
2451 required, except when creating a convenience library.
2452
2453 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
2454 using \`ar' and \`ranlib', or on Windows using \`lib'.
2455
2456 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
2457 is created, otherwise an executable program is created."
2458 ;;
2459
2460 uninstall)
2461 $ECHO \
2462 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
2463
2464 Remove libraries from an installation directory.
2465
2466 RM is the name of the program to use to delete files associated with each FILE
2467 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
2468 to RM.
2469
2470 If FILE is a libtool library, all the files associated with it are deleted.
2471 Otherwise, only FILE itself is deleted using RM."
2472 ;;
2473
2474 *)
2475 func_fatal_help "invalid operation mode \`$opt_mode'"
2476 ;;
2477 esac
2478
2479 echo
2480 $ECHO "Try \`$progname --help' for more information about other modes."
2481 }
2482
2483 # Now that we've collected a possible --mode arg, show help if necessary
2484 if $opt_help; then
2485 if test "$opt_help" = :; then
2486 func_mode_help
2487 else
2488 {
2489 func_help noexit
2490 for opt_mode in compile link execute install finish uninstall clean; do
2491 func_mode_help
2492 done
2493 } | sed -n '1p; 2,$s/^Usage:/ or: /p'
2494 {
2495 func_help noexit
2496 for opt_mode in compile link execute install finish uninstall clean; do
2497 echo
2498 func_mode_help
2499 done
2500 } |
2501 sed '1d
2502 /^When reporting/,/^Report/{
2503 H
2504 d
2505 }
2506 $x
2507 /information about other modes/d
2508 /more detailed .*MODE/d
2509 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
2510 fi
2511 exit $?
2512 fi
2513
2514
2515 # func_mode_execute arg...
2516 func_mode_execute ()
2517 {
2518 $opt_debug
2519 # The first argument is the command name.
2520 cmd="$nonopt"
2521 test -z "$cmd" && \
2522 func_fatal_help "you must specify a COMMAND"
2523
2524 # Handle -dlopen flags immediately.
2525 for file in $opt_dlopen; do
2526 test -f "$file" \
2527 || func_fatal_help "\`$file' is not a file"
2528
2529 dir=
2530 case $file in
2531 *.la)
2532 func_resolve_sysroot "$file"
2533 file=$func_resolve_sysroot_result
2534
2535 # Check to see that this really is a libtool archive.
2536 func_lalib_unsafe_p "$file" \
2537 || func_fatal_help "\`$lib' is not a valid libtool archive"
2538
2539 # Read the libtool library.
2540 dlname=
2541 library_names=
2542 func_source "$file"
2543
2544 # Skip this library if it cannot be dlopened.
2545 if test -z "$dlname"; then
2546 # Warn if it was a shared library.
2547 test -n "$library_names" && \
2548 func_warning "\`$file' was not linked with \`-export-dynamic'"
2549 continue
2550 fi
2551
2552 func_dirname "$file" "" "."
2553 dir="$func_dirname_result"
2554
2555 if test -f "$dir/$objdir/$dlname"; then
2556 func_append dir "/$objdir"
2557 else
2558 if test ! -f "$dir/$dlname"; then
2559 func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
2560 fi
2561 fi
2562 ;;
2563
2564 *.lo)
2565 # Just add the directory containing the .lo file.
2566 func_dirname "$file" "" "."
2567 dir="$func_dirname_result"
2568 ;;
2569
2570 *)
2571 func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
2572 continue
2573 ;;
2574 esac
2575
2576 # Get the absolute pathname.
2577 absdir=`cd "$dir" && pwd`
2578 test -n "$absdir" && dir="$absdir"
2579
2580 # Now add the directory to shlibpath_var.
2581 if eval "test -z \"\$$shlibpath_var\""; then
2582 eval "$shlibpath_var=\"\$dir\""
2583 else
2584 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
2585 fi
2586 done
2587
2588 # This variable tells wrapper scripts just to set shlibpath_var
2589 # rather than running their programs.
2590 libtool_execute_magic="$magic"
2591
2592 # Check if any of the arguments is a wrapper script.
2593 args=
2594 for file
2595 do
2596 case $file in
2597 -* | *.la | *.lo ) ;;
2598 *)
2599 # Do a test to see if this is really a libtool program.
2600 if func_ltwrapper_script_p "$file"; then
2601 func_source "$file"
2602 # Transform arg to wrapped name.
2603 file="$progdir/$program"
2604 elif func_ltwrapper_executable_p "$file"; then
2605 func_ltwrapper_scriptname "$file"
2606 func_source "$func_ltwrapper_scriptname_result"
2607 # Transform arg to wrapped name.
2608 file="$progdir/$program"
2609 fi
2610 ;;
2611 esac
2612 # Quote arguments (to preserve shell metacharacters).
2613 func_append_quoted args "$file"
2614 done
2615
2616 if test "X$opt_dry_run" = Xfalse; then
2617 if test -n "$shlibpath_var"; then
2618 # Export the shlibpath_var.
2619 eval "export $shlibpath_var"
2620 fi
2621
2622 # Restore saved environment variables
2623 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
2624 do
2625 eval "if test \"\${save_$lt_var+set}\" = set; then
2626 $lt_var=\$save_$lt_var; export $lt_var
2627 else
2628 $lt_unset $lt_var
2629 fi"
2630 done
2631
2632 # Now prepare to actually exec the command.
2633 exec_cmd="\$cmd$args"
2634 else
2635 # Display what would be done.
2636 if test -n "$shlibpath_var"; then
2637 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
2638 echo "export $shlibpath_var"
2639 fi
2640 $ECHO "$cmd$args"
2641 exit $EXIT_SUCCESS
2642 fi
2643 }
2644
2645 test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
2646
2647
2648 # func_mode_finish arg...
2649 func_mode_finish ()
2650 {
2651 $opt_debug
2652 libs=
2653 libdirs=
2654 admincmds=
2655
2656 for opt in "$nonopt" ${1+"$@"}
2657 do
2658 if test -d "$opt"; then
2659 func_append libdirs " $opt"
2660
2661 elif test -f "$opt"; then
2662 if func_lalib_unsafe_p "$opt"; then
2663 func_append libs " $opt"
2664 else
2665 func_warning "\`$opt' is not a valid libtool archive"
2666 fi
2667
2668 else
2669 func_fatal_error "invalid argument \`$opt'"
2670 fi
2671 done
2672
2673 if test -n "$libs"; then
2674 if test -n "$lt_sysroot"; then
2675 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
2676 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
2677 else
2678 sysroot_cmd=
2679 fi
2680
2681 # Remove sysroot references
2682 if $opt_dry_run; then
2683 for lib in $libs; do
2684 echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
2685 done
2686 else
2687 tmpdir=`func_mktempdir`
2688 for lib in $libs; do
2689 sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
2690 > $tmpdir/tmp-la
2691 mv -f $tmpdir/tmp-la $lib
2692 done
2693 ${RM}r "$tmpdir"
2694 fi
2695 fi
2696
2697 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2698 for libdir in $libdirs; do
2699 if test -n "$finish_cmds"; then
2700 # Do each command in the finish commands.
2701 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
2702 '"$cmd"'"'
2703 fi
2704 if test -n "$finish_eval"; then
2705 # Do the single finish_eval.
2706 eval cmds=\"$finish_eval\"
2707 $opt_dry_run || eval "$cmds" || func_append admincmds "
2708 $cmds"
2709 fi
2710 done
2711 fi
2712
2713 # Exit here if they wanted silent mode.
2714 $opt_silent && exit $EXIT_SUCCESS
2715
2716 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
2717 echo "----------------------------------------------------------------------"
2718 echo "Libraries have been installed in:"
2719 for libdir in $libdirs; do
2720 $ECHO " $libdir"
2721 done
2722 echo
2723 echo "If you ever happen to want to link against installed libraries"
2724 echo "in a given directory, LIBDIR, you must either use libtool, and"
2725 echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
2726 echo "flag during linking and do at least one of the following:"
2727 if test -n "$shlibpath_var"; then
2728 echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
2729 echo " during execution"
2730 fi
2731 if test -n "$runpath_var"; then
2732 echo " - add LIBDIR to the \`$runpath_var' environment variable"
2733 echo " during linking"
2734 fi
2735 if test -n "$hardcode_libdir_flag_spec"; then
2736 libdir=LIBDIR
2737 eval flag=\"$hardcode_libdir_flag_spec\"
2738
2739 $ECHO " - use the \`$flag' linker flag"
2740 fi
2741 if test -n "$admincmds"; then
2742 $ECHO " - have your system administrator run these commands:$admincmds"
2743 fi
2744 if test -f /etc/ld.so.conf; then
2745 echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
2746 fi
2747 echo
2748
2749 echo "See any operating system documentation about shared libraries for"
2750 case $host in
2751 solaris2.[6789]|solaris2.1[0-9])
2752 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
2753 echo "pages."
2754 ;;
2755 *)
2756 echo "more information, such as the ld(1) and ld.so(8) manual pages."
2757 ;;
2758 esac
2759 echo "----------------------------------------------------------------------"
2760 fi
2761 exit $EXIT_SUCCESS
2762 }
2763
2764 test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
2765
2766
2767 # func_mode_install arg...
2768 func_mode_install ()
2769 {
2770 $opt_debug
2771 # There may be an optional sh(1) argument at the beginning of
2772 # install_prog (especially on Windows NT).
2773 if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
2774 # Allow the use of GNU shtool's install command.
2775 case $nonopt in *shtool*) :;; *) false;; esac; then
2776 # Aesthetically quote it.
2777 func_quote_for_eval "$nonopt"
2778 install_prog="$func_quote_for_eval_result "
2779 arg=$1
2780 shift
2781 else
2782 install_prog=
2783 arg=$nonopt
2784 fi
2785
2786 # The real first argument should be the name of the installation program.
2787 # Aesthetically quote it.
2788 func_quote_for_eval "$arg"
2789 func_append install_prog "$func_quote_for_eval_result"
2790 install_shared_prog=$install_prog
2791 case " $install_prog " in
2792 *[\\\ /]cp\ *) install_cp=: ;;
2793 *) install_cp=false ;;
2794 esac
2795
2796 # We need to accept at least all the BSD install flags.
2797 dest=
2798 files=
2799 opts=
2800 prev=
2801 install_type=
2802 isdir=no
2803 stripme=
2804 no_mode=:
2805 for arg
2806 do
2807 arg2=
2808 if test -n "$dest"; then
2809 func_append files " $dest"
2810 dest=$arg
2811 continue
2812 fi
2813
2814 case $arg in
2815 -d) isdir=yes ;;
2816 -f)
2817 if $install_cp; then :; else
2818 prev=$arg
2819 fi
2820 ;;
2821 -g | -m | -o)
2822 prev=$arg
2823 ;;
2824 -s)
2825 stripme=" -s"
2826 continue
2827 ;;
2828 -*)
2829 ;;
2830 *)
2831 # If the previous option needed an argument, then skip it.
2832 if test -n "$prev"; then
2833 if test "x$prev" = x-m && test -n "$install_override_mode"; then
2834 arg2=$install_override_mode
2835 no_mode=false
2836 fi
2837 prev=
2838 else
2839 dest=$arg
2840 continue
2841 fi
2842 ;;
2843 esac
2844
2845 # Aesthetically quote the argument.
2846 func_quote_for_eval "$arg"
2847 func_append install_prog " $func_quote_for_eval_result"
2848 if test -n "$arg2"; then
2849 func_quote_for_eval "$arg2"
2850 fi
2851 func_append install_shared_prog " $func_quote_for_eval_result"
2852 done
2853
2854 test -z "$install_prog" && \
2855 func_fatal_help "you must specify an install program"
2856
2857 test -n "$prev" && \
2858 func_fatal_help "the \`$prev' option requires an argument"
2859
2860 if test -n "$install_override_mode" && $no_mode; then
2861 if $install_cp; then :; else
2862 func_quote_for_eval "$install_override_mode"
2863 func_append install_shared_prog " -m $func_quote_for_eval_result"
2864 fi
2865 fi
2866
2867 if test -z "$files"; then
2868 if test -z "$dest"; then
2869 func_fatal_help "no file or destination specified"
2870 else
2871 func_fatal_help "you must specify a destination"
2872 fi
2873 fi
2874
2875 # Strip any trailing slash from the destination.
2876 func_stripname '' '/' "$dest"
2877 dest=$func_stripname_result
2878
2879 # Check to see that the destination is a directory.
2880 test -d "$dest" && isdir=yes
2881 if test "$isdir" = yes; then
2882 destdir="$dest"
2883 destname=
2884 else
2885 func_dirname_and_basename "$dest" "" "."
2886 destdir="$func_dirname_result"
2887 destname="$func_basename_result"
2888
2889 # Not a directory, so check to see that there is only one file specified.
2890 set dummy $files; shift
2891 test "$#" -gt 1 && \
2892 func_fatal_help "\`$dest' is not a directory"
2893 fi
2894 case $destdir in
2895 [\\/]* | [A-Za-z]:[\\/]*) ;;
2896 *)
2897 for file in $files; do
2898 case $file in
2899 *.lo) ;;
2900 *)
2901 func_fatal_help "\`$destdir' must be an absolute directory name"
2902 ;;
2903 esac
2904 done
2905 ;;
2906 esac
2907
2908 # This variable tells wrapper scripts just to set variables rather
2909 # than running their programs.
2910 libtool_install_magic="$magic"
2911
2912 staticlibs=
2913 future_libdirs=
2914 current_libdirs=
2915 for file in $files; do
2916
2917 # Do each installation.
2918 case $file in
2919 *.$libext)
2920 # Do the static libraries later.
2921 func_append staticlibs " $file"
2922 ;;
2923
2924 *.la)
2925 func_resolve_sysroot "$file"
2926 file=$func_resolve_sysroot_result
2927
2928 # Check to see that this really is a libtool archive.
2929 func_lalib_unsafe_p "$file" \
2930 || func_fatal_help "\`$file' is not a valid libtool archive"
2931
2932 library_names=
2933 old_library=
2934 relink_command=
2935 func_source "$file"
2936
2937 # Add the libdir to current_libdirs if it is the destination.
2938 if test "X$destdir" = "X$libdir"; then
2939 case "$current_libdirs " in
2940 *" $libdir "*) ;;
2941 *) func_append current_libdirs " $libdir" ;;
2942 esac
2943 else
2944 # Note the libdir as a future libdir.
2945 case "$future_libdirs " in
2946 *" $libdir "*) ;;
2947 *) func_append future_libdirs " $libdir" ;;
2948 esac
2949 fi
2950
2951 func_dirname "$file" "/" ""
2952 dir="$func_dirname_result"
2953 func_append dir "$objdir"
2954
2955 if test -n "$relink_command"; then
2956 # Determine the prefix the user has applied to our future dir.
2957 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
2958
2959 # Don't allow the user to place us outside of our expected
2960 # location b/c this prevents finding dependent libraries that
2961 # are installed to the same prefix.
2962 # At present, this check doesn't affect windows .dll's that
2963 # are installed into $libdir/../bin (currently, that works fine)
2964 # but it's something to keep an eye on.
2965 test "$inst_prefix_dir" = "$destdir" && \
2966 func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2967
2968 if test -n "$inst_prefix_dir"; then
2969 # Stick the inst_prefix_dir data into the link command.
2970 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2971 else
2972 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
2973 fi
2974
2975 func_warning "relinking \`$file'"
2976 func_show_eval "$relink_command" \
2977 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2978 fi
2979
2980 # See the names of the shared library.
2981 set dummy $library_names; shift
2982 if test -n "$1"; then
2983 realname="$1"
2984 shift
2985
2986 srcname="$realname"
2987 test -n "$relink_command" && srcname="$realname"T
2988
2989 # Install the shared library and build the symlinks.
2990 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
2991 'exit $?'
2992 tstripme="$stripme"
2993 case $host_os in
2994 cygwin* | mingw* | pw32* | cegcc*)
2995 case $realname in
2996 *.dll.a)
2997 tstripme=""
2998 ;;
2999 esac
3000 ;;
3001 esac
3002 if test -n "$tstripme" && test -n "$striplib"; then
3003 func_show_eval "$striplib $destdir/$realname" 'exit $?'
3004 fi
3005
3006 if test "$#" -gt 0; then
3007 # Delete the old symlinks, and create new ones.
3008 # Try `ln -sf' first, because the `ln' binary might depend on
3009 # the symlink we replace! Solaris /bin/ln does not understand -f,
3010 # so we also need to try rm && ln -s.
3011 for linkname
3012 do
3013 test "$linkname" != "$realname" \
3014 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
3015 done
3016 fi
3017
3018 # Do each command in the postinstall commands.
3019 lib="$destdir/$realname"
3020 func_execute_cmds "$postinstall_cmds" 'exit $?'
3021 fi
3022
3023 # Install the pseudo-library for information purposes.
3024 func_basename "$file"
3025 name="$func_basename_result"
3026 instname="$dir/$name"i
3027 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
3028
3029 # Maybe install the static library, too.
3030 test -n "$old_library" && func_append staticlibs " $dir/$old_library"
3031 ;;
3032
3033 *.lo)
3034 # Install (i.e. copy) a libtool object.
3035
3036 # Figure out destination file name, if it wasn't already specified.
3037 if test -n "$destname"; then
3038 destfile="$destdir/$destname"
3039 else
3040 func_basename "$file"
3041 destfile="$func_basename_result"
3042 destfile="$destdir/$destfile"
3043 fi
3044
3045 # Deduce the name of the destination old-style object file.
3046 case $destfile in
3047 *.lo)
3048 func_lo2o "$destfile"
3049 staticdest=$func_lo2o_result
3050 ;;
3051 *.$objext)
3052 staticdest="$destfile"
3053 destfile=
3054 ;;
3055 *)
3056 func_fatal_help "cannot copy a libtool object to \`$destfile'"
3057 ;;
3058 esac
3059
3060 # Install the libtool object if requested.
3061 test -n "$destfile" && \
3062 func_show_eval "$install_prog $file $destfile" 'exit $?'
3063
3064 # Install the old object if enabled.
3065 if test "$build_old_libs" = yes; then
3066 # Deduce the name of the old-style object file.
3067 func_lo2o "$file"
3068 staticobj=$func_lo2o_result
3069 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
3070 fi
3071 exit $EXIT_SUCCESS
3072 ;;
3073
3074 *)
3075 # Figure out destination file name, if it wasn't already specified.
3076 if test -n "$destname"; then
3077 destfile="$destdir/$destname"
3078 else
3079 func_basename "$file"
3080 destfile="$func_basename_result"
3081 destfile="$destdir/$destfile"
3082 fi
3083
3084 # If the file is missing, and there is a .exe on the end, strip it
3085 # because it is most likely a libtool script we actually want to
3086 # install
3087 stripped_ext=""
3088 case $file in
3089 *.exe)
3090 if test ! -f "$file"; then
3091 func_stripname '' '.exe' "$file"
3092 file=$func_stripname_result
3093 stripped_ext=".exe"
3094 fi
3095 ;;
3096 esac
3097
3098 # Do a test to see if this is really a libtool program.
3099 case $host in
3100 *cygwin* | *mingw*)
3101 if func_ltwrapper_executable_p "$file"; then
3102 func_ltwrapper_scriptname "$file"
3103 wrapper=$func_ltwrapper_scriptname_result
3104 else
3105 func_stripname '' '.exe' "$file"
3106 wrapper=$func_stripname_result
3107 fi
3108 ;;
3109 *)
3110 wrapper=$file
3111 ;;
3112 esac
3113 if func_ltwrapper_script_p "$wrapper"; then
3114 notinst_deplibs=
3115 relink_command=
3116
3117 func_source "$wrapper"
3118
3119 # Check the variables that should have been set.
3120 test -z "$generated_by_libtool_version" && \
3121 func_fatal_error "invalid libtool wrapper script \`$wrapper'"
3122
3123 finalize=yes
3124 for lib in $notinst_deplibs; do
3125 # Check to see that each library is installed.
3126 libdir=
3127 if test -f "$lib"; then
3128 func_source "$lib"
3129 fi
3130 libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
3131 if test -n "$libdir" && test ! -f "$libfile"; then
3132 func_warning "\`$lib' has not been installed in \`$libdir'"
3133 finalize=no
3134 fi
3135 done
3136
3137 relink_command=
3138 func_source "$wrapper"
3139
3140 outputname=
3141 if test "$fast_install" = no && test -n "$relink_command"; then
3142 $opt_dry_run || {
3143 if test "$finalize" = yes; then
3144 tmpdir=`func_mktempdir`
3145 func_basename "$file$stripped_ext"
3146 file="$func_basename_result"
3147 outputname="$tmpdir/$file"
3148 # Replace the output file specification.
3149 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
3150
3151 $opt_silent || {
3152 func_quote_for_expand "$relink_command"
3153 eval "func_echo $func_quote_for_expand_result"
3154 }
3155 if eval "$relink_command"; then :
3156 else
3157 func_error "error: relink \`$file' with the above command before installing it"
3158 $opt_dry_run || ${RM}r "$tmpdir"
3159 continue
3160 fi
3161 file="$outputname"
3162 else
3163 func_warning "cannot relink \`$file'"
3164 fi
3165 }
3166 else
3167 # Install the binary that we compiled earlier.
3168 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
3169 fi
3170 fi
3171
3172 # remove .exe since cygwin /usr/bin/install will append another
3173 # one anyway
3174 case $install_prog,$host in
3175 */usr/bin/install*,*cygwin*)
3176 case $file:$destfile in
3177 *.exe:*.exe)
3178 # this is ok
3179 ;;
3180 *.exe:*)
3181 destfile=$destfile.exe
3182 ;;
3183 *:*.exe)
3184 func_stripname '' '.exe' "$destfile"
3185 destfile=$func_stripname_result
3186 ;;
3187 esac
3188 ;;
3189 esac
3190 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
3191 $opt_dry_run || if test -n "$outputname"; then
3192 ${RM}r "$tmpdir"
3193 fi
3194 ;;
3195 esac
3196 done
3197
3198 for file in $staticlibs; do
3199 func_basename "$file"
3200 name="$func_basename_result"
3201
3202 # Set up the ranlib parameters.
3203 oldlib="$destdir/$name"
3204 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
3205 tool_oldlib=$func_to_tool_file_result
3206
3207 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
3208
3209 if test -n "$stripme" && test -n "$old_striplib"; then
3210 func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
3211 fi
3212
3213 # Do each command in the postinstall commands.
3214 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
3215 done
3216
3217 test -n "$future_libdirs" && \
3218 func_warning "remember to run \`$progname --finish$future_libdirs'"
3219
3220 if test -n "$current_libdirs"; then
3221 # Maybe just do a dry run.
3222 $opt_dry_run && current_libdirs=" -n$current_libdirs"
3223 exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
3224 else
3225 exit $EXIT_SUCCESS
3226 fi
3227 }
3228
3229 test "$opt_mode" = install && func_mode_install ${1+"$@"}
3230
3231
3232 # func_generate_dlsyms outputname originator pic_p
3233 # Extract symbols from dlprefiles and create ${outputname}S.o with
3234 # a dlpreopen symbol table.
3235 func_generate_dlsyms ()
3236 {
3237 $opt_debug
3238 my_outputname="$1"
3239 my_originator="$2"
3240 my_pic_p="${3-no}"
3241 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
3242 my_dlsyms=
3243
3244 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
3245 if test -n "$NM" && test -n "$global_symbol_pipe"; then
3246 my_dlsyms="${my_outputname}S.c"
3247 else
3248 func_error "not configured to extract global symbols from dlpreopened files"
3249 fi
3250 fi
3251
3252 if test -n "$my_dlsyms"; then
3253 case $my_dlsyms in
3254 "") ;;
3255 *.c)
3256 # Discover the nlist of each of the dlfiles.
3257 nlist="$output_objdir/${my_outputname}.nm"
3258
3259 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
3260
3261 # Parse the name list into a source file.
3262 func_verbose "creating $output_objdir/$my_dlsyms"
3263
3264 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
3265 /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
3266 /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
3267
3268 #ifdef __cplusplus
3269 extern \"C\" {
3270 #endif
3271
3272 #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
3273 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
3274 #endif
3275
3276 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
3277 #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
3278 /* DATA imports from DLLs on WIN32 con't be const, because runtime
3279 relocations are performed -- see ld's documentation on pseudo-relocs. */
3280 # define LT_DLSYM_CONST
3281 #elif defined(__osf__)
3282 /* This system does not cope well with relocations in const data. */
3283 # define LT_DLSYM_CONST
3284 #else
3285 # define LT_DLSYM_CONST const
3286 #endif
3287
3288 /* External symbol declarations for the compiler. */\
3289 "
3290
3291 if test "$dlself" = yes; then
3292 func_verbose "generating symbol list for \`$output'"
3293
3294 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
3295
3296 # Add our own program objects to the symbol list.
3297 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
3298 for progfile in $progfiles; do
3299 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
3300 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
3301 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
3302 done
3303
3304 if test -n "$exclude_expsyms"; then
3305 $opt_dry_run || {
3306 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
3307 eval '$MV "$nlist"T "$nlist"'
3308 }
3309 fi
3310
3311 if test -n "$export_symbols_regex"; then
3312 $opt_dry_run || {
3313 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
3314 eval '$MV "$nlist"T "$nlist"'
3315 }
3316 fi
3317
3318 # Prepare the list of exported symbols
3319 if test -z "$export_symbols"; then
3320 export_symbols="$output_objdir/$outputname.exp"
3321 $opt_dry_run || {
3322 $RM $export_symbols
3323 eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
3324 case $host in
3325 *cygwin* | *mingw* | *cegcc* )
3326 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3327 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
3328 ;;
3329 esac
3330 }
3331 else
3332 $opt_dry_run || {
3333 eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
3334 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
3335 eval '$MV "$nlist"T "$nlist"'
3336 case $host in
3337 *cygwin* | *mingw* | *cegcc* )
3338 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
3339 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
3340 ;;
3341 esac
3342 }
3343 fi
3344 fi
3345
3346 for dlprefile in $dlprefiles; do
3347 func_verbose "extracting global C symbols from \`$dlprefile'"
3348 func_basename "$dlprefile"
3349 name="$func_basename_result"
3350 case $host in
3351 *cygwin* | *mingw* | *cegcc* )
3352 # if an import library, we need to obtain dlname
3353 if func_win32_import_lib_p "$dlprefile"; then
3354 func_tr_sh "$dlprefile"
3355 eval "curr_lafile=\$libfile_$func_tr_sh_result"
3356 dlprefile_dlbasename=""
3357 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
3358 # Use subshell, to avoid clobbering current variable values
3359 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
3360 if test -n "$dlprefile_dlname" ; then
3361 func_basename "$dlprefile_dlname"
3362 dlprefile_dlbasename="$func_basename_result"
3363 else
3364 # no lafile. user explicitly requested -dlpreopen <import library>.
3365 $sharedlib_from_linklib_cmd "$dlprefile"
3366 dlprefile_dlbasename=$sharedlib_from_linklib_result
3367 fi
3368 fi
3369 $opt_dry_run || {
3370 if test -n "$dlprefile_dlbasename" ; then
3371 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
3372 else
3373 func_warning "Could not compute DLL name from $name"
3374 eval '$ECHO ": $name " >> "$nlist"'
3375 fi
3376 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3377 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
3378 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
3379 }
3380 else # not an import lib
3381 $opt_dry_run || {
3382 eval '$ECHO ": $name " >> "$nlist"'
3383 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3384 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3385 }
3386 fi
3387 ;;
3388 *)
3389 $opt_dry_run || {
3390 eval '$ECHO ": $name " >> "$nlist"'
3391 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
3392 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
3393 }
3394 ;;
3395 esac
3396 done
3397
3398 $opt_dry_run || {
3399 # Make sure we have at least an empty file.
3400 test -f "$nlist" || : > "$nlist"
3401
3402 if test -n "$exclude_expsyms"; then
3403 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
3404 $MV "$nlist"T "$nlist"
3405 fi
3406
3407 # Try sorting and uniquifying the output.
3408 if $GREP -v "^: " < "$nlist" |
3409 if sort -k 3 </dev/null >/dev/null 2>&1; then
3410 sort -k 3
3411 else
3412 sort +2
3413 fi |
3414 uniq > "$nlist"S; then
3415 :
3416 else
3417 $GREP -v "^: " < "$nlist" > "$nlist"S
3418 fi
3419
3420 if test -f "$nlist"S; then
3421 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
3422 else
3423 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
3424 fi
3425
3426 echo >> "$output_objdir/$my_dlsyms" "\
3427
3428 /* The mapping between symbol names and symbols. */
3429 typedef struct {
3430 const char *name;
3431 void *address;
3432 } lt_dlsymlist;
3433 extern LT_DLSYM_CONST lt_dlsymlist
3434 lt_${my_prefix}_LTX_preloaded_symbols[];
3435 LT_DLSYM_CONST lt_dlsymlist
3436 lt_${my_prefix}_LTX_preloaded_symbols[] =
3437 {\
3438 { \"$my_originator\", (void *) 0 },"
3439
3440 case $need_lib_prefix in
3441 no)
3442 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
3443 ;;
3444 *)
3445 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
3446 ;;
3447 esac
3448 echo >> "$output_objdir/$my_dlsyms" "\
3449 {0, (void *) 0}
3450 };
3451
3452 /* This works around a problem in FreeBSD linker */
3453 #ifdef FREEBSD_WORKAROUND
3454 static const void *lt_preloaded_setup() {
3455 return lt_${my_prefix}_LTX_preloaded_symbols;
3456 }
3457 #endif
3458
3459 #ifdef __cplusplus
3460 }
3461 #endif\
3462 "
3463 } # !$opt_dry_run
3464
3465 pic_flag_for_symtable=
3466 case "$compile_command " in
3467 *" -static "*) ;;
3468 *)
3469 case $host in
3470 # compiling the symbol table file with pic_flag works around
3471 # a FreeBSD bug that causes programs to crash when -lm is
3472 # linked before any other PIC object. But we must not use
3473 # pic_flag when linking with -static. The problem exists in
3474 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
3475 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
3476 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
3477 *-*-hpux*)
3478 pic_flag_for_symtable=" $pic_flag" ;;
3479 *)
3480 if test "X$my_pic_p" != Xno; then
3481 pic_flag_for_symtable=" $pic_flag"
3482 fi
3483 ;;
3484 esac
3485 ;;
3486 esac
3487 symtab_cflags=
3488 for arg in $LTCFLAGS; do
3489 case $arg in
3490 -pie | -fpie | -fPIE) ;;
3491 *) func_append symtab_cflags " $arg" ;;
3492 esac
3493 done
3494
3495 # Now compile the dynamic symbol file.
3496 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
3497
3498 # Clean up the generated files.
3499 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
3500
3501 # Transform the symbol file into the correct name.
3502 symfileobj="$output_objdir/${my_outputname}S.$objext"
3503 case $host in
3504 *cygwin* | *mingw* | *cegcc* )
3505 if test -f "$output_objdir/$my_outputname.def"; then
3506 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3507 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
3508 else
3509 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3510 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3511 fi
3512 ;;
3513 *)
3514 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3515 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
3516 ;;
3517 esac
3518 ;;
3519 *)
3520 func_fatal_error "unknown suffix for \`$my_dlsyms'"
3521 ;;
3522 esac
3523 else
3524 # We keep going just in case the user didn't refer to
3525 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
3526 # really was required.
3527
3528 # Nullify the symbol file.
3529 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
3530 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
3531 fi
3532 }
3533
3534 # func_win32_libid arg
3535 # return the library type of file 'arg'
3536 #
3537 # Need a lot of goo to handle *both* DLLs and import libs
3538 # Has to be a shell function in order to 'eat' the argument
3539 # that is supplied when $file_magic_command is called.
3540 # Despite the name, also deal with 64 bit binaries.
3541 func_win32_libid ()
3542 {
3543 $opt_debug
3544 win32_libid_type="unknown"
3545 win32_fileres=`file -L $1 2>/dev/null`
3546 case $win32_fileres in
3547 *ar\ archive\ import\ library*) # definitely import
3548 win32_libid_type="x86 archive import"
3549 ;;
3550 *ar\ archive*) # could be an import, or static
3551 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
3552 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
3553 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
3554 func_to_tool_file "$1" func_convert_file_msys_to_w32
3555 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
3556 $SED -n -e '
3557 1,100{
3558 / I /{
3559 s,.*,import,
3560 p
3561 q
3562 }
3563 }'`
3564 case $win32_nmres in
3565 import*) win32_libid_type="x86 archive import";;
3566 *) win32_libid_type="x86 archive static";;
3567 esac
3568 fi
3569 ;;
3570 *DLL*)
3571 win32_libid_type="x86 DLL"
3572 ;;
3573 *executable*) # but shell scripts are "executable" too...
3574 case $win32_fileres in
3575 *MS\ Windows\ PE\ Intel*)
3576 win32_libid_type="x86 DLL"
3577 ;;
3578 esac
3579 ;;
3580 esac
3581 $ECHO "$win32_libid_type"
3582 }
3583
3584 # func_cygming_dll_for_implib ARG
3585 #
3586 # Platform-specific function to extract the
3587 # name of the DLL associated with the specified
3588 # import library ARG.
3589 # Invoked by eval'ing the libtool variable
3590 # $sharedlib_from_linklib_cmd
3591 # Result is available in the variable
3592 # $sharedlib_from_linklib_result
3593 func_cygming_dll_for_implib ()
3594 {
3595 $opt_debug
3596 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
3597 }
3598
3599 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
3600 #
3601 # The is the core of a fallback implementation of a
3602 # platform-specific function to extract the name of the
3603 # DLL associated with the specified import library LIBNAME.
3604 #
3605 # SECTION_NAME is either .idata$6 or .idata$7, depending
3606 # on the platform and compiler that created the implib.
3607 #
3608 # Echos the name of the DLL associated with the
3609 # specified import library.
3610 func_cygming_dll_for_implib_fallback_core ()
3611 {
3612 $opt_debug
3613 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
3614 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
3615 $SED '/^Contents of section '"$match_literal"':/{
3616 # Place marker at beginning of archive member dllname section
3617 s/.*/====MARK====/
3618 p
3619 d
3620 }
3621 # These lines can sometimes be longer than 43 characters, but
3622 # are always uninteresting
3623 /:[ ]*file format pe[i]\{,1\}-/d
3624 /^In archive [^:]*:/d
3625 # Ensure marker is printed
3626 /^====MARK====/p
3627 # Remove all lines with less than 43 characters
3628 /^.\{43\}/!d
3629 # From remaining lines, remove first 43 characters
3630 s/^.\{43\}//' |
3631 $SED -n '
3632 # Join marker and all lines until next marker into a single line
3633 /^====MARK====/ b para
3634 H
3635 $ b para
3636 b
3637 :para
3638 x
3639 s/\n//g
3640 # Remove the marker
3641 s/^====MARK====//
3642 # Remove trailing dots and whitespace
3643 s/[\. \t]*$//
3644 # Print
3645 /./p' |
3646 # we now have a list, one entry per line, of the stringified
3647 # contents of the appropriate section of all members of the
3648 # archive which possess that section. Heuristic: eliminate
3649 # all those which have a first or second character that is
3650 # a '.' (that is, objdump's representation of an unprintable
3651 # character.) This should work for all archives with less than
3652 # 0x302f exports -- but will fail for DLLs whose name actually
3653 # begins with a literal '.' or a single character followed by
3654 # a '.'.
3655 #
3656 # Of those that remain, print the first one.
3657 $SED -e '/^\./d;/^.\./d;q'
3658 }
3659
3660 # func_cygming_gnu_implib_p ARG
3661 # This predicate returns with zero status (TRUE) if
3662 # ARG is a GNU/binutils-style import library. Returns
3663 # with nonzero status (FALSE) otherwise.
3664 func_cygming_gnu_implib_p ()
3665 {
3666 $opt_debug
3667 func_to_tool_file "$1" func_convert_file_msys_to_w32
3668 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
3669 test -n "$func_cygming_gnu_implib_tmp"
3670 }
3671
3672 # func_cygming_ms_implib_p ARG
3673 # This predicate returns with zero status (TRUE) if
3674 # ARG is an MS-style import library. Returns
3675 # with nonzero status (FALSE) otherwise.
3676 func_cygming_ms_implib_p ()
3677 {
3678 $opt_debug
3679 func_to_tool_file "$1" func_convert_file_msys_to_w32
3680 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
3681 test -n "$func_cygming_ms_implib_tmp"
3682 }
3683
3684 # func_cygming_dll_for_implib_fallback ARG
3685 # Platform-specific function to extract the
3686 # name of the DLL associated with the specified
3687 # import library ARG.
3688 #
3689 # This fallback implementation is for use when $DLLTOOL
3690 # does not support the --identify-strict option.
3691 # Invoked by eval'ing the libtool variable
3692 # $sharedlib_from_linklib_cmd
3693 # Result is available in the variable
3694 # $sharedlib_from_linklib_result
3695 func_cygming_dll_for_implib_fallback ()
3696 {
3697 $opt_debug
3698 if func_cygming_gnu_implib_p "$1" ; then
3699 # binutils import library
3700 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
3701 elif func_cygming_ms_implib_p "$1" ; then
3702 # ms-generated import library
3703 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
3704 else
3705 # unknown
3706 sharedlib_from_linklib_result=""
3707 fi
3708 }
3709
3710
3711 # func_extract_an_archive dir oldlib
3712 func_extract_an_archive ()
3713 {
3714 $opt_debug
3715 f_ex_an_ar_dir="$1"; shift
3716 f_ex_an_ar_oldlib="$1"
3717 if test "$lock_old_archive_extraction" = yes; then
3718 lockfile=$f_ex_an_ar_oldlib.lock
3719 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
3720 func_echo "Waiting for $lockfile to be removed"
3721 sleep 2
3722 done
3723 fi
3724 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
3725 'stat=$?; rm -f "$lockfile"; exit $stat'
3726 if test "$lock_old_archive_extraction" = yes; then
3727 $opt_dry_run || rm -f "$lockfile"
3728 fi
3729 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
3730 :
3731 else
3732 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
3733 fi
3734 }
3735
3736
3737 # func_extract_archives gentop oldlib ...
3738 func_extract_archives ()
3739 {
3740 $opt_debug
3741 my_gentop="$1"; shift
3742 my_oldlibs=${1+"$@"}
3743 my_oldobjs=""
3744 my_xlib=""
3745 my_xabs=""
3746 my_xdir=""
3747
3748 for my_xlib in $my_oldlibs; do
3749 # Extract the objects.
3750 case $my_xlib in
3751 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
3752 *) my_xabs=`pwd`"/$my_xlib" ;;
3753 esac
3754 func_basename "$my_xlib"
3755 my_xlib="$func_basename_result"
3756 my_xlib_u=$my_xlib
3757 while :; do
3758 case " $extracted_archives " in
3759 *" $my_xlib_u "*)
3760 func_arith $extracted_serial + 1
3761 extracted_serial=$func_arith_result
3762 my_xlib_u=lt$extracted_serial-$my_xlib ;;
3763 *) break ;;
3764 esac
3765 done
3766 extracted_archives="$extracted_archives $my_xlib_u"
3767 my_xdir="$my_gentop/$my_xlib_u"
3768
3769 func_mkdir_p "$my_xdir"
3770
3771 case $host in
3772 *-darwin*)
3773 func_verbose "Extracting $my_xabs"
3774 # Do not bother doing anything if just a dry run
3775 $opt_dry_run || {
3776 darwin_orig_dir=`pwd`
3777 cd $my_xdir || exit $?
3778 darwin_archive=$my_xabs
3779 darwin_curdir=`pwd`
3780 darwin_base_archive=`basename "$darwin_archive"`
3781 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
3782 if test -n "$darwin_arches"; then
3783 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
3784 darwin_arch=
3785 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
3786 for darwin_arch in $darwin_arches ; do
3787 func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3788 $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
3789 cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
3790 func_extract_an_archive "`pwd`" "${darwin_base_archive}"
3791 cd "$darwin_curdir"
3792 $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
3793 done # $darwin_arches
3794 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
3795 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
3796 darwin_file=
3797 darwin_files=
3798 for darwin_file in $darwin_filelist; do
3799 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
3800 $LIPO -create -output "$darwin_file" $darwin_files
3801 done # $darwin_filelist
3802 $RM -rf unfat-$$
3803 cd "$darwin_orig_dir"
3804 else
3805 cd $darwin_orig_dir
3806 func_extract_an_archive "$my_xdir" "$my_xabs"
3807 fi # $darwin_arches
3808 } # !$opt_dry_run
3809 ;;
3810 *)
3811 func_extract_an_archive "$my_xdir" "$my_xabs"
3812 ;;
3813 esac
3814 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
3815 done
3816
3817 func_extract_archives_result="$my_oldobjs"
3818 }
3819
3820
3821 # func_emit_wrapper [arg=no]
3822 #
3823 # Emit a libtool wrapper script on stdout.
3824 # Don't directly open a file because we may want to
3825 # incorporate the script contents within a cygwin/mingw
3826 # wrapper executable. Must ONLY be called from within
3827 # func_mode_link because it depends on a number of variables
3828 # set therein.
3829 #
3830 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
3831 # variable will take. If 'yes', then the emitted script
3832 # will assume that the directory in which it is stored is
3833 # the $objdir directory. This is a cygwin/mingw-specific
3834 # behavior.
3835 func_emit_wrapper ()
3836 {
3837 func_emit_wrapper_arg1=${1-no}
3838
3839 $ECHO "\
3840 #! $SHELL
3841
3842 # $output - temporary wrapper script for $objdir/$outputname
3843 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3844 #
3845 # The $output program cannot be directly executed until all the libtool
3846 # libraries that it depends on are installed.
3847 #
3848 # This wrapper script should never be moved out of the build directory.
3849 # If it is, it will not operate correctly.
3850
3851 # Sed substitution that helps us do robust quoting. It backslashifies
3852 # metacharacters that are still active within double-quoted strings.
3853 sed_quote_subst='$sed_quote_subst'
3854
3855 # Be Bourne compatible
3856 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
3857 emulate sh
3858 NULLCMD=:
3859 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
3860 # is contrary to our usage. Disable this feature.
3861 alias -g '\${1+\"\$@\"}'='\"\$@\"'
3862 setopt NO_GLOB_SUBST
3863 else
3864 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
3865 fi
3866 BIN_SH=xpg4; export BIN_SH # for Tru64
3867 DUALCASE=1; export DUALCASE # for MKS sh
3868
3869 # The HP-UX ksh and POSIX shell print the target directory to stdout
3870 # if CDPATH is set.
3871 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
3872
3873 relink_command=\"$relink_command\"
3874
3875 # This environment variable determines our operation mode.
3876 if test \"\$libtool_install_magic\" = \"$magic\"; then
3877 # install mode needs the following variables:
3878 generated_by_libtool_version='$macro_version'
3879 notinst_deplibs='$notinst_deplibs'
3880 else
3881 # When we are sourced in execute mode, \$file and \$ECHO are already set.
3882 if test \"\$libtool_execute_magic\" != \"$magic\"; then
3883 file=\"\$0\""
3884
3885 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
3886 $ECHO "\
3887
3888 # A function that is used when there is no print builtin or printf.
3889 func_fallback_echo ()
3890 {
3891 eval 'cat <<_LTECHO_EOF
3892 \$1
3893 _LTECHO_EOF'
3894 }
3895 ECHO=\"$qECHO\"
3896 fi
3897
3898 # Very basic option parsing. These options are (a) specific to
3899 # the libtool wrapper, (b) are identical between the wrapper
3900 # /script/ and the wrapper /executable/ which is used only on
3901 # windows platforms, and (c) all begin with the string "--lt-"
3902 # (application programs are unlikely to have options which match
3903 # this pattern).
3904 #
3905 # There are only two supported options: --lt-debug and
3906 # --lt-dump-script. There is, deliberately, no --lt-help.
3907 #
3908 # The first argument to this parsing function should be the
3909 # script's $0 value, followed by "$@".
3910 lt_option_debug=
3911 func_parse_lt_options ()
3912 {
3913 lt_script_arg0=\$0
3914 shift
3915 for lt_opt
3916 do
3917 case \"\$lt_opt\" in
3918 --lt-debug) lt_option_debug=1 ;;
3919 --lt-dump-script)
3920 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
3921 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
3922 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
3923 cat \"\$lt_dump_D/\$lt_dump_F\"
3924 exit 0
3925 ;;
3926 --lt-*)
3927 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
3928 exit 1
3929 ;;
3930 esac
3931 done
3932
3933 # Print the debug banner immediately:
3934 if test -n \"\$lt_option_debug\"; then
3935 echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
3936 fi
3937 }
3938
3939 # Used when --lt-debug. Prints its arguments to stdout
3940 # (redirection is the responsibility of the caller)
3941 func_lt_dump_args ()
3942 {
3943 lt_dump_args_N=1;
3944 for lt_arg
3945 do
3946 \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
3947 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
3948 done
3949 }
3950
3951 # Core function for launching the target application
3952 func_exec_program_core ()
3953 {
3954 "
3955 case $host in
3956 # Backslashes separate directories on plain windows
3957 *-*-mingw | *-*-os2* | *-cegcc*)
3958 $ECHO "\
3959 if test -n \"\$lt_option_debug\"; then
3960 \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
3961 func_lt_dump_args \${1+\"\$@\"} 1>&2
3962 fi
3963 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
3964 "
3965 ;;
3966
3967 *)
3968 $ECHO "\
3969 if test -n \"\$lt_option_debug\"; then
3970 \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
3971 func_lt_dump_args \${1+\"\$@\"} 1>&2
3972 fi
3973 exec \"\$progdir/\$program\" \${1+\"\$@\"}
3974 "
3975 ;;
3976 esac
3977 $ECHO "\
3978 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
3979 exit 1
3980 }
3981
3982 # A function to encapsulate launching the target application
3983 # Strips options in the --lt-* namespace from \$@ and
3984 # launches target application with the remaining arguments.
3985 func_exec_program ()
3986 {
3987 case \" \$* \" in
3988 *\\ --lt-*)
3989 for lt_wr_arg
3990 do
3991 case \$lt_wr_arg in
3992 --lt-*) ;;
3993 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
3994 esac
3995 shift
3996 done ;;
3997 esac
3998 func_exec_program_core \${1+\"\$@\"}
3999 }
4000
4001 # Parse options
4002 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
4003
4004 # Find the directory that this script lives in.
4005 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
4006 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4007
4008 # Follow symbolic links until we get to the real thisdir.
4009 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
4010 while test -n \"\$file\"; do
4011 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
4012
4013 # If there was a directory component, then change thisdir.
4014 if test \"x\$destdir\" != \"x\$file\"; then
4015 case \"\$destdir\" in
4016 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4017 *) thisdir=\"\$thisdir/\$destdir\" ;;
4018 esac
4019 fi
4020
4021 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
4022 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
4023 done
4024
4025 # Usually 'no', except on cygwin/mingw when embedded into
4026 # the cwrapper.
4027 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
4028 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
4029 # special case for '.'
4030 if test \"\$thisdir\" = \".\"; then
4031 thisdir=\`pwd\`
4032 fi
4033 # remove .libs from thisdir
4034 case \"\$thisdir\" in
4035 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
4036 $objdir ) thisdir=. ;;
4037 esac
4038 fi
4039
4040 # Try to get the absolute directory name.
4041 absdir=\`cd \"\$thisdir\" && pwd\`
4042 test -n \"\$absdir\" && thisdir=\"\$absdir\"
4043 "
4044
4045 if test "$fast_install" = yes; then
4046 $ECHO "\
4047 program=lt-'$outputname'$exeext
4048 progdir=\"\$thisdir/$objdir\"
4049
4050 if test ! -f \"\$progdir/\$program\" ||
4051 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4052 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4053
4054 file=\"\$\$-\$program\"
4055
4056 if test ! -d \"\$progdir\"; then
4057 $MKDIR \"\$progdir\"
4058 else
4059 $RM \"\$progdir/\$file\"
4060 fi"
4061
4062 $ECHO "\
4063
4064 # relink executable if necessary
4065 if test -n \"\$relink_command\"; then
4066 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4067 else
4068 $ECHO \"\$relink_command_output\" >&2
4069 $RM \"\$progdir/\$file\"
4070 exit 1
4071 fi
4072 fi
4073
4074 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4075 { $RM \"\$progdir/\$program\";
4076 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4077 $RM \"\$progdir/\$file\"
4078 fi"
4079 else
4080 $ECHO "\
4081 program='$outputname'
4082 progdir=\"\$thisdir/$objdir\"
4083 "
4084 fi
4085
4086 $ECHO "\
4087
4088 if test -f \"\$progdir/\$program\"; then"
4089
4090 # fixup the dll searchpath if we need to.
4091 #
4092 # Fix the DLL searchpath if we need to. Do this before prepending
4093 # to shlibpath, because on Windows, both are PATH and uninstalled
4094 # libraries must come first.
4095 if test -n "$dllsearchpath"; then
4096 $ECHO "\
4097 # Add the dll search path components to the executable PATH
4098 PATH=$dllsearchpath:\$PATH
4099 "
4100 fi
4101
4102 # Export our shlibpath_var if we have one.
4103 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4104 $ECHO "\
4105 # Add our own library path to $shlibpath_var
4106 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4107
4108 # Some systems cannot cope with colon-terminated $shlibpath_var
4109 # The second colon is a workaround for a bug in BeOS R4 sed
4110 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
4111
4112 export $shlibpath_var
4113 "
4114 fi
4115
4116 $ECHO "\
4117 if test \"\$libtool_execute_magic\" != \"$magic\"; then
4118 # Run the actual program with our arguments.
4119 func_exec_program \${1+\"\$@\"}
4120 fi
4121 else
4122 # The program doesn't exist.
4123 \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
4124 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
4125 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
4126 exit 1
4127 fi
4128 fi\
4129 "
4130 }
4131
4132
4133 # func_emit_cwrapperexe_src
4134 # emit the source code for a wrapper executable on stdout
4135 # Must ONLY be called from within func_mode_link because
4136 # it depends on a number of variable set therein.
4137 func_emit_cwrapperexe_src ()
4138 {
4139 cat <<EOF
4140
4141 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4142 Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
4143
4144 The $output program cannot be directly executed until all the libtool
4145 libraries that it depends on are installed.
4146
4147 This wrapper executable should never be moved out of the build directory.
4148 If it is, it will not operate correctly.
4149 */
4150 EOF
4151 cat <<"EOF"
4152 #ifdef _MSC_VER
4153 # define _CRT_SECURE_NO_DEPRECATE 1
4154 #endif
4155 #include <stdio.h>
4156 #include <stdlib.h>
4157 #ifdef _MSC_VER
4158 # include <direct.h>
4159 # include <process.h>
4160 # include <io.h>
4161 #else
4162 # include <unistd.h>
4163 # include <stdint.h>
4164 # ifdef __CYGWIN__
4165 # include <io.h>
4166 # endif
4167 #endif
4168 #include <malloc.h>
4169 #include <stdarg.h>
4170 #include <assert.h>
4171 #include <string.h>
4172 #include <ctype.h>
4173 #include <errno.h>
4174 #include <fcntl.h>
4175 #include <sys/stat.h>
4176
4177 /* declarations of non-ANSI functions */
4178 #if defined(__MINGW32__)
4179 # ifdef __STRICT_ANSI__
4180 int _putenv (const char *);
4181 # endif
4182 #elif defined(__CYGWIN__)
4183 # ifdef __STRICT_ANSI__
4184 char *realpath (const char *, char *);
4185 int putenv (char *);
4186 int setenv (const char *, const char *, int);
4187 # endif
4188 /* #elif defined (other platforms) ... */
4189 #endif
4190
4191 /* portability defines, excluding path handling macros */
4192 #if defined(_MSC_VER)
4193 # define setmode _setmode
4194 # define stat _stat
4195 # define chmod _chmod
4196 # define getcwd _getcwd
4197 # define putenv _putenv
4198 # define S_IXUSR _S_IEXEC
4199 # ifndef _INTPTR_T_DEFINED
4200 # define _INTPTR_T_DEFINED
4201 # define intptr_t int
4202 # endif
4203 #elif defined(__MINGW32__)
4204 # define setmode _setmode
4205 # define stat _stat
4206 # define chmod _chmod
4207 # define getcwd _getcwd
4208 # define putenv _putenv
4209 #elif defined(__CYGWIN__)
4210 # define HAVE_SETENV
4211 # define FOPEN_WB "wb"
4212 /* #elif defined (other platforms) ... */
4213 #endif
4214
4215 #if defined(PATH_MAX)
4216 # define LT_PATHMAX PATH_MAX
4217 #elif defined(MAXPATHLEN)
4218 # define LT_PATHMAX MAXPATHLEN
4219 #else
4220 # define LT_PATHMAX 1024
4221 #endif
4222
4223 #ifndef S_IXOTH
4224 # define S_IXOTH 0
4225 #endif
4226 #ifndef S_IXGRP
4227 # define S_IXGRP 0
4228 #endif
4229
4230 /* path handling portability macros */
4231 #ifndef DIR_SEPARATOR
4232 # define DIR_SEPARATOR '/'
4233 # define PATH_SEPARATOR ':'
4234 #endif
4235
4236 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4237 defined (__OS2__)
4238 # define HAVE_DOS_BASED_FILE_SYSTEM
4239 # define FOPEN_WB "wb"
4240 # ifndef DIR_SEPARATOR_2
4241 # define DIR_SEPARATOR_2 '\\'
4242 # endif
4243 # ifndef PATH_SEPARATOR_2
4244 # define PATH_SEPARATOR_2 ';'
4245 # endif
4246 #endif
4247
4248 #ifndef DIR_SEPARATOR_2
4249 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4250 #else /* DIR_SEPARATOR_2 */
4251 # define IS_DIR_SEPARATOR(ch) \
4252 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4253 #endif /* DIR_SEPARATOR_2 */
4254
4255 #ifndef PATH_SEPARATOR_2
4256 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
4257 #else /* PATH_SEPARATOR_2 */
4258 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
4259 #endif /* PATH_SEPARATOR_2 */
4260
4261 #ifndef FOPEN_WB
4262 # define FOPEN_WB "w"
4263 #endif
4264 #ifndef _O_BINARY
4265 # define _O_BINARY 0
4266 #endif
4267
4268 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
4269 #define XFREE(stale) do { \
4270 if (stale) { free ((void *) stale); stale = 0; } \
4271 } while (0)
4272
4273 #if defined(LT_DEBUGWRAPPER)
4274 static int lt_debug = 1;
4275 #else
4276 static int lt_debug = 0;
4277 #endif
4278
4279 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
4280
4281 void *xmalloc (size_t num);
4282 char *xstrdup (const char *string);
4283 const char *base_name (const char *name);
4284 char *find_executable (const char *wrapper);
4285 char *chase_symlinks (const char *pathspec);
4286 int make_executable (const char *path);
4287 int check_executable (const char *path);
4288 char *strendzap (char *str, const char *pat);
4289 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
4290 void lt_fatal (const char *file, int line, const char *message, ...);
4291 static const char *nonnull (const char *s);
4292 static const char *nonempty (const char *s);
4293 void lt_setenv (const char *name, const char *value);
4294 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
4295 void lt_update_exe_path (const char *name, const char *value);
4296 void lt_update_lib_path (const char *name, const char *value);
4297 char **prepare_spawn (char **argv);
4298 void lt_dump_script (FILE *f);
4299 EOF
4300
4301 cat <<EOF
4302 volatile const char * MAGIC_EXE = "$magic_exe";
4303 const char * LIB_PATH_VARNAME = "$shlibpath_var";
4304 EOF
4305
4306 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4307 func_to_host_path "$temp_rpath"
4308 cat <<EOF
4309 const char * LIB_PATH_VALUE = "$func_to_host_path_result";
4310 EOF
4311 else
4312 cat <<"EOF"
4313 const char * LIB_PATH_VALUE = "";
4314 EOF
4315 fi
4316
4317 if test -n "$dllsearchpath"; then
4318 func_to_host_path "$dllsearchpath:"
4319 cat <<EOF
4320 const char * EXE_PATH_VARNAME = "PATH";
4321 const char * EXE_PATH_VALUE = "$func_to_host_path_result";
4322 EOF
4323 else
4324 cat <<"EOF"
4325 const char * EXE_PATH_VARNAME = "";
4326 const char * EXE_PATH_VALUE = "";
4327 EOF
4328 fi
4329
4330 if test "$fast_install" = yes; then
4331 cat <<EOF
4332 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
4333 EOF
4334 else
4335 cat <<EOF
4336 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
4337 EOF
4338 fi
4339
4340
4341 cat <<"EOF"
4342
4343 #define LTWRAPPER_OPTION_PREFIX "--lt-"
4344
4345 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
4346 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
4347 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
4348
4349 int
4350 main (int argc, char *argv[])
4351 {
4352 char **newargz;
4353 int newargc;
4354 char *tmp_pathspec;
4355 char *actual_cwrapper_path;
4356 char *actual_cwrapper_name;
4357 char *target_name;
4358 char *lt_argv_zero;
4359 intptr_t rval = 127;
4360
4361 int i;
4362
4363 program_name = (char *) xstrdup (base_name (argv[0]));
4364 newargz = XMALLOC (char *, argc + 1);
4365
4366 /* very simple arg parsing; don't want to rely on getopt
4367 * also, copy all non cwrapper options to newargz, except
4368 * argz[0], which is handled differently
4369 */
4370 newargc=0;
4371 for (i = 1; i < argc; i++)
4372 {
4373 if (strcmp (argv[i], dumpscript_opt) == 0)
4374 {
4375 EOF
4376 case "$host" in
4377 *mingw* | *cygwin* )
4378 # make stdout use "unix" line endings
4379 echo " setmode(1,_O_BINARY);"
4380 ;;
4381 esac
4382
4383 cat <<"EOF"
4384 lt_dump_script (stdout);
4385 return 0;
4386 }
4387 if (strcmp (argv[i], debug_opt) == 0)
4388 {
4389 lt_debug = 1;
4390 continue;
4391 }
4392 if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
4393 {
4394 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
4395 namespace, but it is not one of the ones we know about and
4396 have already dealt with, above (inluding dump-script), then
4397 report an error. Otherwise, targets might begin to believe
4398 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
4399 namespace. The first time any user complains about this, we'll
4400 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
4401 or a configure.ac-settable value.
4402 */
4403 lt_fatal (__FILE__, __LINE__,
4404 "unrecognized %s option: '%s'",
4405 ltwrapper_option_prefix, argv[i]);
4406 }
4407 /* otherwise ... */
4408 newargz[++newargc] = xstrdup (argv[i]);
4409 }
4410 newargz[++newargc] = NULL;
4411
4412 EOF
4413 cat <<EOF
4414 /* The GNU banner must be the first non-error debug message */
4415 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
4416 EOF
4417 cat <<"EOF"
4418 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
4419 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
4420
4421 tmp_pathspec = find_executable (argv[0]);
4422 if (tmp_pathspec == NULL)
4423 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
4424 lt_debugprintf (__FILE__, __LINE__,
4425 "(main) found exe (before symlink chase) at: %s\n",
4426 tmp_pathspec);
4427
4428 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
4429 lt_debugprintf (__FILE__, __LINE__,
4430 "(main) found exe (after symlink chase) at: %s\n",
4431 actual_cwrapper_path);
4432 XFREE (tmp_pathspec);
4433
4434 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
4435 strendzap (actual_cwrapper_path, actual_cwrapper_name);
4436
4437 /* wrapper name transforms */
4438 strendzap (actual_cwrapper_name, ".exe");
4439 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
4440 XFREE (actual_cwrapper_name);
4441 actual_cwrapper_name = tmp_pathspec;
4442 tmp_pathspec = 0;
4443
4444 /* target_name transforms -- use actual target program name; might have lt- prefix */
4445 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
4446 strendzap (target_name, ".exe");
4447 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
4448 XFREE (target_name);
4449 target_name = tmp_pathspec;
4450 tmp_pathspec = 0;
4451
4452 lt_debugprintf (__FILE__, __LINE__,
4453 "(main) libtool target name: %s\n",
4454 target_name);
4455 EOF
4456
4457 cat <<EOF
4458 newargz[0] =
4459 XMALLOC (char, (strlen (actual_cwrapper_path) +
4460 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
4461 strcpy (newargz[0], actual_cwrapper_path);
4462 strcat (newargz[0], "$objdir");
4463 strcat (newargz[0], "/");
4464 EOF
4465
4466 cat <<"EOF"
4467 /* stop here, and copy so we don't have to do this twice */
4468 tmp_pathspec = xstrdup (newargz[0]);
4469
4470 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
4471 strcat (newargz[0], actual_cwrapper_name);
4472
4473 /* DO want the lt- prefix here if it exists, so use target_name */
4474 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
4475 XFREE (tmp_pathspec);
4476 tmp_pathspec = NULL;
4477 EOF
4478
4479 case $host_os in
4480 mingw*)
4481 cat <<"EOF"
4482 {
4483 char* p;
4484 while ((p = strchr (newargz[0], '\\')) != NULL)
4485 {
4486 *p = '/';
4487 }
4488 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
4489 {
4490 *p = '/';
4491 }
4492 }
4493 EOF
4494 ;;
4495 esac
4496
4497 cat <<"EOF"
4498 XFREE (target_name);
4499 XFREE (actual_cwrapper_path);
4500 XFREE (actual_cwrapper_name);
4501
4502 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
4503 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
4504 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
4505 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
4506 because on Windows, both *_VARNAMEs are PATH but uninstalled
4507 libraries must come first. */
4508 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
4509 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
4510
4511 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
4512 nonnull (lt_argv_zero));
4513 for (i = 0; i < newargc; i++)
4514 {
4515 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
4516 i, nonnull (newargz[i]));
4517 }
4518
4519 EOF
4520
4521 case $host_os in
4522 mingw*)
4523 cat <<"EOF"
4524 /* execv doesn't actually work on mingw as expected on unix */
4525 newargz = prepare_spawn (newargz);
4526 rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
4527 if (rval == -1)
4528 {
4529 /* failed to start process */
4530 lt_debugprintf (__FILE__, __LINE__,
4531 "(main) failed to launch target \"%s\": %s\n",
4532 lt_argv_zero, nonnull (strerror (errno)));
4533 return 127;
4534 }
4535 return rval;
4536 EOF
4537 ;;
4538 *)
4539 cat <<"EOF"
4540 execv (lt_argv_zero, newargz);
4541 return rval; /* =127, but avoids unused variable warning */
4542 EOF
4543 ;;
4544 esac
4545
4546 cat <<"EOF"
4547 }
4548
4549 void *
4550 xmalloc (size_t num)
4551 {
4552 void *p = (void *) malloc (num);
4553 if (!p)
4554 lt_fatal (__FILE__, __LINE__, "memory exhausted");
4555
4556 return p;
4557 }
4558
4559 char *
4560 xstrdup (const char *string)
4561 {
4562 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
4563 string) : NULL;
4564 }
4565
4566 const char *
4567 base_name (const char *name)
4568 {
4569 const char *base;
4570
4571 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4572 /* Skip over the disk name in MSDOS pathnames. */
4573 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
4574 name += 2;
4575 #endif
4576
4577 for (base = name; *name; name++)
4578 if (IS_DIR_SEPARATOR (*name))
4579 base = name + 1;
4580 return base;
4581 }
4582
4583 int
4584 check_executable (const char *path)
4585 {
4586 struct stat st;
4587
4588 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
4589 nonempty (path));
4590 if ((!path) || (!*path))
4591 return 0;
4592
4593 if ((stat (path, &st) >= 0)
4594 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
4595 return 1;
4596 else
4597 return 0;
4598 }
4599
4600 int
4601 make_executable (const char *path)
4602 {
4603 int rval = 0;
4604 struct stat st;
4605
4606 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
4607 nonempty (path));
4608 if ((!path) || (!*path))
4609 return 0;
4610
4611 if (stat (path, &st) >= 0)
4612 {
4613 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
4614 }
4615 return rval;
4616 }
4617
4618 /* Searches for the full path of the wrapper. Returns
4619 newly allocated full path name if found, NULL otherwise
4620 Does not chase symlinks, even on platforms that support them.
4621 */
4622 char *
4623 find_executable (const char *wrapper)
4624 {
4625 int has_slash = 0;
4626 const char *p;
4627 const char *p_next;
4628 /* static buffer for getcwd */
4629 char tmp[LT_PATHMAX + 1];
4630 int tmp_len;
4631 char *concat_name;
4632
4633 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
4634 nonempty (wrapper));
4635
4636 if ((wrapper == NULL) || (*wrapper == '\0'))
4637 return NULL;
4638
4639 /* Absolute path? */
4640 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4641 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
4642 {
4643 concat_name = xstrdup (wrapper);
4644 if (check_executable (concat_name))
4645 return concat_name;
4646 XFREE (concat_name);
4647 }
4648 else
4649 {
4650 #endif
4651 if (IS_DIR_SEPARATOR (wrapper[0]))
4652 {
4653 concat_name = xstrdup (wrapper);
4654 if (check_executable (concat_name))
4655 return concat_name;
4656 XFREE (concat_name);
4657 }
4658 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4659 }
4660 #endif
4661
4662 for (p = wrapper; *p; p++)
4663 if (*p == '/')
4664 {
4665 has_slash = 1;
4666 break;
4667 }
4668 if (!has_slash)
4669 {
4670 /* no slashes; search PATH */
4671 const char *path = getenv ("PATH");
4672 if (path != NULL)
4673 {
4674 for (p = path; *p; p = p_next)
4675 {
4676 const char *q;
4677 size_t p_len;
4678 for (q = p; *q; q++)
4679 if (IS_PATH_SEPARATOR (*q))
4680 break;
4681 p_len = q - p;
4682 p_next = (*q == '\0' ? q : q + 1);
4683 if (p_len == 0)
4684 {
4685 /* empty path: current directory */
4686 if (getcwd (tmp, LT_PATHMAX) == NULL)
4687 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4688 nonnull (strerror (errno)));
4689 tmp_len = strlen (tmp);
4690 concat_name =
4691 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4692 memcpy (concat_name, tmp, tmp_len);
4693 concat_name[tmp_len] = '/';
4694 strcpy (concat_name + tmp_len + 1, wrapper);
4695 }
4696 else
4697 {
4698 concat_name =
4699 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
4700 memcpy (concat_name, p, p_len);
4701 concat_name[p_len] = '/';
4702 strcpy (concat_name + p_len + 1, wrapper);
4703 }
4704 if (check_executable (concat_name))
4705 return concat_name;
4706 XFREE (concat_name);
4707 }
4708 }
4709 /* not found in PATH; assume curdir */
4710 }
4711 /* Relative path | not found in path: prepend cwd */
4712 if (getcwd (tmp, LT_PATHMAX) == NULL)
4713 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
4714 nonnull (strerror (errno)));
4715 tmp_len = strlen (tmp);
4716 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
4717 memcpy (concat_name, tmp, tmp_len);
4718 concat_name[tmp_len] = '/';
4719 strcpy (concat_name + tmp_len + 1, wrapper);
4720
4721 if (check_executable (concat_name))
4722 return concat_name;
4723 XFREE (concat_name);
4724 return NULL;
4725 }
4726
4727 char *
4728 chase_symlinks (const char *pathspec)
4729 {
4730 #ifndef S_ISLNK
4731 return xstrdup (pathspec);
4732 #else
4733 char buf[LT_PATHMAX];
4734 struct stat s;
4735 char *tmp_pathspec = xstrdup (pathspec);
4736 char *p;
4737 int has_symlinks = 0;
4738 while (strlen (tmp_pathspec) && !has_symlinks)
4739 {
4740 lt_debugprintf (__FILE__, __LINE__,
4741 "checking path component for symlinks: %s\n",
4742 tmp_pathspec);
4743 if (lstat (tmp_pathspec, &s) == 0)
4744 {
4745 if (S_ISLNK (s.st_mode) != 0)
4746 {
4747 has_symlinks = 1;
4748 break;
4749 }
4750
4751 /* search backwards for last DIR_SEPARATOR */
4752 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
4753 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4754 p--;
4755 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
4756 {
4757 /* no more DIR_SEPARATORS left */
4758 break;
4759 }
4760 *p = '\0';
4761 }
4762 else
4763 {
4764 lt_fatal (__FILE__, __LINE__,
4765 "error accessing file \"%s\": %s",
4766 tmp_pathspec, nonnull (strerror (errno)));
4767 }
4768 }
4769 XFREE (tmp_pathspec);
4770
4771 if (!has_symlinks)
4772 {
4773 return xstrdup (pathspec);
4774 }
4775
4776 tmp_pathspec = realpath (pathspec, buf);
4777 if (tmp_pathspec == 0)
4778 {
4779 lt_fatal (__FILE__, __LINE__,
4780 "could not follow symlinks for %s", pathspec);
4781 }
4782 return xstrdup (tmp_pathspec);
4783 #endif
4784 }
4785
4786 char *
4787 strendzap (char *str, const char *pat)
4788 {
4789 size_t len, patlen;
4790
4791 assert (str != NULL);
4792 assert (pat != NULL);
4793
4794 len = strlen (str);
4795 patlen = strlen (pat);
4796
4797 if (patlen <= len)
4798 {
4799 str += len - patlen;
4800 if (strcmp (str, pat) == 0)
4801 *str = '\0';
4802 }
4803 return str;
4804 }
4805
4806 void
4807 lt_debugprintf (const char *file, int line, const char *fmt, ...)
4808 {
4809 va_list args;
4810 if (lt_debug)
4811 {
4812 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
4813 va_start (args, fmt);
4814 (void) vfprintf (stderr, fmt, args);
4815 va_end (args);
4816 }
4817 }
4818
4819 static void
4820 lt_error_core (int exit_status, const char *file,
4821 int line, const char *mode,
4822 const char *message, va_list ap)
4823 {
4824 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
4825 vfprintf (stderr, message, ap);
4826 fprintf (stderr, ".\n");
4827
4828 if (exit_status >= 0)
4829 exit (exit_status);
4830 }
4831
4832 void
4833 lt_fatal (const char *file, int line, const char *message, ...)
4834 {
4835 va_list ap;
4836 va_start (ap, message);
4837 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
4838 va_end (ap);
4839 }
4840
4841 static const char *
4842 nonnull (const char *s)
4843 {
4844 return s ? s : "(null)";
4845 }
4846
4847 static const char *
4848 nonempty (const char *s)
4849 {
4850 return (s && !*s) ? "(empty)" : nonnull (s);
4851 }
4852
4853 void
4854 lt_setenv (const char *name, const char *value)
4855 {
4856 lt_debugprintf (__FILE__, __LINE__,
4857 "(lt_setenv) setting '%s' to '%s'\n",
4858 nonnull (name), nonnull (value));
4859 {
4860 #ifdef HAVE_SETENV
4861 /* always make a copy, for consistency with !HAVE_SETENV */
4862 char *str = xstrdup (value);
4863 setenv (name, str, 1);
4864 #else
4865 int len = strlen (name) + 1 + strlen (value) + 1;
4866 char *str = XMALLOC (char, len);
4867 sprintf (str, "%s=%s", name, value);
4868 if (putenv (str) != EXIT_SUCCESS)
4869 {
4870 XFREE (str);
4871 }
4872 #endif
4873 }
4874 }
4875
4876 char *
4877 lt_extend_str (const char *orig_value, const char *add, int to_end)
4878 {
4879 char *new_value;
4880 if (orig_value && *orig_value)
4881 {
4882 int orig_value_len = strlen (orig_value);
4883 int add_len = strlen (add);
4884 new_value = XMALLOC (char, add_len + orig_value_len + 1);
4885 if (to_end)
4886 {
4887 strcpy (new_value, orig_value);
4888 strcpy (new_value + orig_value_len, add);
4889 }
4890 else
4891 {
4892 strcpy (new_value, add);
4893 strcpy (new_value + add_len, orig_value);
4894 }
4895 }
4896 else
4897 {
4898 new_value = xstrdup (add);
4899 }
4900 return new_value;
4901 }
4902
4903 void
4904 lt_update_exe_path (const char *name, const char *value)
4905 {
4906 lt_debugprintf (__FILE__, __LINE__,
4907 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4908 nonnull (name), nonnull (value));
4909
4910 if (name && *name && value && *value)
4911 {
4912 char *new_value = lt_extend_str (getenv (name), value, 0);
4913 /* some systems can't cope with a ':'-terminated path #' */
4914 int len = strlen (new_value);
4915 while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4916 {
4917 new_value[len-1] = '\0';
4918 }
4919 lt_setenv (name, new_value);
4920 XFREE (new_value);
4921 }
4922 }
4923
4924 void
4925 lt_update_lib_path (const char *name, const char *value)
4926 {
4927 lt_debugprintf (__FILE__, __LINE__,
4928 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4929 nonnull (name), nonnull (value));
4930
4931 if (name && *name && value && *value)
4932 {
4933 char *new_value = lt_extend_str (getenv (name), value, 0);
4934 lt_setenv (name, new_value);
4935 XFREE (new_value);
4936 }
4937 }
4938
4939 EOF
4940 case $host_os in
4941 mingw*)
4942 cat <<"EOF"
4943
4944 /* Prepares an argument vector before calling spawn().
4945 Note that spawn() does not by itself call the command interpreter
4946 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
4947 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
4948 GetVersionEx(&v);
4949 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
4950 }) ? "cmd.exe" : "command.com").
4951 Instead it simply concatenates the arguments, separated by ' ', and calls
4952 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
4953 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
4954 special way:
4955 - Space and tab are interpreted as delimiters. They are not treated as
4956 delimiters if they are surrounded by double quotes: "...".
4957 - Unescaped double quotes are removed from the input. Their only effect is
4958 that within double quotes, space and tab are treated like normal
4959 characters.
4960 - Backslashes not followed by double quotes are not special.
4961 - But 2*n+1 backslashes followed by a double quote become
4962 n backslashes followed by a double quote (n >= 0):
4963 \" -> "
4964 \\\" -> \"
4965 \\\\\" -> \\"
4966 */
4967 #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
4968 #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
4969 char **
4970 prepare_spawn (char **argv)
4971 {
4972 size_t argc;
4973 char **new_argv;
4974 size_t i;
4975
4976 /* Count number of arguments. */
4977 for (argc = 0; argv[argc] != NULL; argc++)
4978 ;
4979
4980 /* Allocate new argument vector. */
4981 new_argv = XMALLOC (char *, argc + 1);
4982
4983 /* Put quoted arguments into the new argument vector. */
4984 for (i = 0; i < argc; i++)
4985 {
4986 const char *string = argv[i];
4987
4988 if (string[0] == '\0')
4989 new_argv[i] = xstrdup ("\"\"");
4990 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
4991 {
4992 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
4993 size_t length;
4994 unsigned int backslashes;
4995 const char *s;
4996 char *quoted_string;
4997 char *p;
4998
4999 length = 0;
5000 backslashes = 0;
5001 if (quote_around)
5002 length++;
5003 for (s = string; *s != '\0'; s++)
5004 {
5005 char c = *s;
5006 if (c == '"')
5007 length += backslashes + 1;
5008 length++;
5009 if (c == '\\')
5010 backslashes++;
5011 else
5012 backslashes = 0;
5013 }
5014 if (quote_around)
5015 length += backslashes + 1;
5016
5017 quoted_string = XMALLOC (char, length + 1);
5018
5019 p = quoted_string;
5020 backslashes = 0;
5021 if (quote_around)
5022 *p++ = '"';
5023 for (s = string; *s != '\0'; s++)
5024 {
5025 char c = *s;
5026 if (c == '"')
5027 {
5028 unsigned int j;
5029 for (j = backslashes + 1; j > 0; j--)
5030 *p++ = '\\';
5031 }
5032 *p++ = c;
5033 if (c == '\\')
5034 backslashes++;
5035 else
5036 backslashes = 0;
5037 }
5038 if (quote_around)
5039 {
5040 unsigned int j;
5041 for (j = backslashes; j > 0; j--)
5042 *p++ = '\\';
5043 *p++ = '"';
5044 }
5045 *p = '\0';
5046
5047 new_argv[i] = quoted_string;
5048 }
5049 else
5050 new_argv[i] = (char *) string;
5051 }
5052 new_argv[argc] = NULL;
5053
5054 return new_argv;
5055 }
5056 EOF
5057 ;;
5058 esac
5059
5060 cat <<"EOF"
5061 void lt_dump_script (FILE* f)
5062 {
5063 EOF
5064 func_emit_wrapper yes |
5065 $SED -n -e '
5066 s/^\(.\{79\}\)\(..*\)/\1\
5067 \2/
5068 h
5069 s/\([\\"]\)/\\\1/g
5070 s/$/\\n/
5071 s/\([^\n]*\).*/ fputs ("\1", f);/p
5072 g
5073 D'
5074 cat <<"EOF"
5075 }
5076 EOF
5077 }
5078 # end: func_emit_cwrapperexe_src
5079
5080 # func_win32_import_lib_p ARG
5081 # True if ARG is an import lib, as indicated by $file_magic_cmd
5082 func_win32_import_lib_p ()
5083 {
5084 $opt_debug
5085 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
5086 *import*) : ;;
5087 *) false ;;
5088 esac
5089 }
5090
5091 # func_mode_link arg...
5092 func_mode_link ()
5093 {
5094 $opt_debug
5095 case $host in
5096 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5097 # It is impossible to link a dll without this setting, and
5098 # we shouldn't force the makefile maintainer to figure out
5099 # which system we are compiling for in order to pass an extra
5100 # flag for every libtool invocation.
5101 # allow_undefined=no
5102
5103 # FIXME: Unfortunately, there are problems with the above when trying
5104 # to make a dll which has undefined symbols, in which case not
5105 # even a static library is built. For now, we need to specify
5106 # -no-undefined on the libtool link line when we can be certain
5107 # that all symbols are satisfied, otherwise we get a static library.
5108 allow_undefined=yes
5109 ;;
5110 *)
5111 allow_undefined=yes
5112 ;;
5113 esac
5114 libtool_args=$nonopt
5115 base_compile="$nonopt $@"
5116 compile_command=$nonopt
5117 finalize_command=$nonopt
5118
5119 compile_rpath=
5120 finalize_rpath=
5121 compile_shlibpath=
5122 finalize_shlibpath=
5123 convenience=
5124 old_convenience=
5125 deplibs=
5126 old_deplibs=
5127 compiler_flags=
5128 linker_flags=
5129 dllsearchpath=
5130 lib_search_path=`pwd`
5131 inst_prefix_dir=
5132 new_inherited_linker_flags=
5133
5134 avoid_version=no
5135 bindir=
5136 dlfiles=
5137 dlprefiles=
5138 dlself=no
5139 export_dynamic=no
5140 export_symbols=
5141 export_symbols_regex=
5142 generated=
5143 libobjs=
5144 ltlibs=
5145 module=no
5146 no_install=no
5147 objs=
5148 non_pic_objects=
5149 precious_files_regex=
5150 prefer_static_libs=no
5151 preload=no
5152 prev=
5153 prevarg=
5154 release=
5155 rpath=
5156 xrpath=
5157 perm_rpath=
5158 temp_rpath=
5159 thread_safe=no
5160 vinfo=
5161 vinfo_number=no
5162 weak_libs=
5163 single_module="${wl}-single_module"
5164 func_infer_tag $base_compile
5165
5166 # We need to know -static, to get the right output filenames.
5167 for arg
5168 do
5169 case $arg in
5170 -shared)
5171 test "$build_libtool_libs" != yes && \
5172 func_fatal_configuration "can not build a shared library"
5173 build_old_libs=no
5174 break
5175 ;;
5176 -all-static | -static | -static-libtool-libs)
5177 case $arg in
5178 -all-static)
5179 if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
5180 func_warning "complete static linking is impossible in this configuration"
5181 fi
5182 if test -n "$link_static_flag"; then
5183 dlopen_self=$dlopen_self_static
5184 fi
5185 prefer_static_libs=yes
5186 ;;
5187 -static)
5188 if test -z "$pic_flag" && test -n "$link_static_flag"; then
5189 dlopen_self=$dlopen_self_static
5190 fi
5191 prefer_static_libs=built
5192 ;;
5193 -static-libtool-libs)
5194 if test -z "$pic_flag" && test -n "$link_static_flag"; then
5195 dlopen_self=$dlopen_self_static
5196 fi
5197 prefer_static_libs=yes
5198 ;;
5199 esac
5200 build_libtool_libs=no
5201 build_old_libs=yes
5202 break
5203 ;;
5204 esac
5205 done
5206
5207 # See if our shared archives depend on static archives.
5208 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
5209
5210 # Go through the arguments, transforming them on the way.
5211 while test "$#" -gt 0; do
5212 arg="$1"
5213 shift
5214 func_quote_for_eval "$arg"
5215 qarg=$func_quote_for_eval_unquoted_result
5216 func_append libtool_args " $func_quote_for_eval_result"
5217
5218 # If the previous option needs an argument, assign it.
5219 if test -n "$prev"; then
5220 case $prev in
5221 output)
5222 func_append compile_command " @OUTPUT@"
5223 func_append finalize_command " @OUTPUT@"
5224 ;;
5225 esac
5226
5227 case $prev in
5228 bindir)
5229 bindir="$arg"
5230 prev=
5231 continue
5232 ;;
5233 dlfiles|dlprefiles)
5234 if test "$preload" = no; then
5235 # Add the symbol object into the linking commands.
5236 func_append compile_command " @SYMFILE@"
5237 func_append finalize_command " @SYMFILE@"
5238 preload=yes
5239 fi
5240 case $arg in
5241 *.la | *.lo) ;; # We handle these cases below.
5242 force)
5243 if test "$dlself" = no; then
5244 dlself=needless
5245 export_dynamic=yes
5246 fi
5247 prev=
5248 continue
5249 ;;
5250 self)
5251 if test "$prev" = dlprefiles; then
5252 dlself=yes
5253 elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
5254 dlself=yes
5255 else
5256 dlself=needless
5257 export_dynamic=yes
5258 fi
5259 prev=
5260 continue
5261 ;;
5262 *)
5263 if test "$prev" = dlfiles; then
5264 func_append dlfiles " $arg"
5265 else
5266 func_append dlprefiles " $arg"
5267 fi
5268 prev=
5269 continue
5270 ;;
5271 esac
5272 ;;
5273 expsyms)
5274 export_symbols="$arg"
5275 test -f "$arg" \
5276 || func_fatal_error "symbol file \`$arg' does not exist"
5277 prev=
5278 continue
5279 ;;
5280 expsyms_regex)
5281 export_symbols_regex="$arg"
5282 prev=
5283 continue
5284 ;;
5285 framework)
5286 case $host in
5287 *-*-darwin*)
5288 case "$deplibs " in
5289 *" $qarg.ltframework "*) ;;
5290 *) func_append deplibs " $qarg.ltframework" # this is fixed later
5291 ;;
5292 esac
5293 ;;
5294 esac
5295 prev=
5296 continue
5297 ;;
5298 inst_prefix)
5299 inst_prefix_dir="$arg"
5300 prev=
5301 continue
5302 ;;
5303 objectlist)
5304 if test -f "$arg"; then
5305 save_arg=$arg
5306 moreargs=
5307 for fil in `cat "$save_arg"`
5308 do
5309 # func_append moreargs " $fil"
5310 arg=$fil
5311 # A libtool-controlled object.
5312
5313 # Check to see that this really is a libtool object.
5314 if func_lalib_unsafe_p "$arg"; then
5315 pic_object=
5316 non_pic_object=
5317
5318 # Read the .lo file
5319 func_source "$arg"
5320
5321 if test -z "$pic_object" ||
5322 test -z "$non_pic_object" ||
5323 test "$pic_object" = none &&
5324 test "$non_pic_object" = none; then
5325 func_fatal_error "cannot find name of object for \`$arg'"
5326 fi
5327
5328 # Extract subdirectory from the argument.
5329 func_dirname "$arg" "/" ""
5330 xdir="$func_dirname_result"
5331
5332 if test "$pic_object" != none; then
5333 # Prepend the subdirectory the object is found in.
5334 pic_object="$xdir$pic_object"
5335
5336 if test "$prev" = dlfiles; then
5337 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5338 func_append dlfiles " $pic_object"
5339 prev=
5340 continue
5341 else
5342 # If libtool objects are unsupported, then we need to preload.
5343 prev=dlprefiles
5344 fi
5345 fi
5346
5347 # CHECK ME: I think I busted this. -Ossama
5348 if test "$prev" = dlprefiles; then
5349 # Preload the old-style object.
5350 func_append dlprefiles " $pic_object"
5351 prev=
5352 fi
5353
5354 # A PIC object.
5355 func_append libobjs " $pic_object"
5356 arg="$pic_object"
5357 fi
5358
5359 # Non-PIC object.
5360 if test "$non_pic_object" != none; then
5361 # Prepend the subdirectory the object is found in.
5362 non_pic_object="$xdir$non_pic_object"
5363
5364 # A standard non-PIC object
5365 func_append non_pic_objects " $non_pic_object"
5366 if test -z "$pic_object" || test "$pic_object" = none ; then
5367 arg="$non_pic_object"
5368 fi
5369 else
5370 # If the PIC object exists, use it instead.
5371 # $xdir was prepended to $pic_object above.
5372 non_pic_object="$pic_object"
5373 func_append non_pic_objects " $non_pic_object"
5374 fi
5375 else
5376 # Only an error if not doing a dry-run.
5377 if $opt_dry_run; then
5378 # Extract subdirectory from the argument.
5379 func_dirname "$arg" "/" ""
5380 xdir="$func_dirname_result"
5381
5382 func_lo2o "$arg"
5383 pic_object=$xdir$objdir/$func_lo2o_result
5384 non_pic_object=$xdir$func_lo2o_result
5385 func_append libobjs " $pic_object"
5386 func_append non_pic_objects " $non_pic_object"
5387 else
5388 func_fatal_error "\`$arg' is not a valid libtool object"
5389 fi
5390 fi
5391 done
5392 else
5393 func_fatal_error "link input file \`$arg' does not exist"
5394 fi
5395 arg=$save_arg
5396 prev=
5397 continue
5398 ;;
5399 precious_regex)
5400 precious_files_regex="$arg"
5401 prev=
5402 continue
5403 ;;
5404 release)
5405 release="-$arg"
5406 prev=
5407 continue
5408 ;;
5409 rpath | xrpath)
5410 # We need an absolute path.
5411 case $arg in
5412 [\\/]* | [A-Za-z]:[\\/]*) ;;
5413 *)
5414 func_fatal_error "only absolute run-paths are allowed"
5415 ;;
5416 esac
5417 if test "$prev" = rpath; then
5418 case "$rpath " in
5419 *" $arg "*) ;;
5420 *) func_append rpath " $arg" ;;
5421 esac
5422 else
5423 case "$xrpath " in
5424 *" $arg "*) ;;
5425 *) func_append xrpath " $arg" ;;
5426 esac
5427 fi
5428 prev=
5429 continue
5430 ;;
5431 shrext)
5432 shrext_cmds="$arg"
5433 prev=
5434 continue
5435 ;;
5436 weak)
5437 func_append weak_libs " $arg"
5438 prev=
5439 continue
5440 ;;
5441 xcclinker)
5442 func_append linker_flags " $qarg"
5443 func_append compiler_flags " $qarg"
5444 prev=
5445 func_append compile_command " $qarg"
5446 func_append finalize_command " $qarg"
5447 continue
5448 ;;
5449 xcompiler)
5450 func_append compiler_flags " $qarg"
5451 prev=
5452 func_append compile_command " $qarg"
5453 func_append finalize_command " $qarg"
5454 continue
5455 ;;
5456 xlinker)
5457 func_append linker_flags " $qarg"
5458 func_append compiler_flags " $wl$qarg"
5459 prev=
5460 func_append compile_command " $wl$qarg"
5461 func_append finalize_command " $wl$qarg"
5462 continue
5463 ;;
5464 *)
5465 eval "$prev=\"\$arg\""
5466 prev=
5467 continue
5468 ;;
5469 esac
5470 fi # test -n "$prev"
5471
5472 prevarg="$arg"
5473
5474 case $arg in
5475 -all-static)
5476 if test -n "$link_static_flag"; then
5477 # See comment for -static flag below, for more details.
5478 func_append compile_command " $link_static_flag"
5479 func_append finalize_command " $link_static_flag"
5480 fi
5481 continue
5482 ;;
5483
5484 -allow-undefined)
5485 # FIXME: remove this flag sometime in the future.
5486 func_fatal_error "\`-allow-undefined' must not be used because it is the default"
5487 ;;
5488
5489 -avoid-version)
5490 avoid_version=yes
5491 continue
5492 ;;
5493
5494 -bindir)
5495 prev=bindir
5496 continue
5497 ;;
5498
5499 -dlopen)
5500 prev=dlfiles
5501 continue
5502 ;;
5503
5504 -dlpreopen)
5505 prev=dlprefiles
5506 continue
5507 ;;
5508
5509 -export-dynamic)
5510 export_dynamic=yes
5511 continue
5512 ;;
5513
5514 -export-symbols | -export-symbols-regex)
5515 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
5516 func_fatal_error "more than one -exported-symbols argument is not allowed"
5517 fi
5518 if test "X$arg" = "X-export-symbols"; then
5519 prev=expsyms
5520 else
5521 prev=expsyms_regex
5522 fi
5523 continue
5524 ;;
5525
5526 -framework)
5527 prev=framework
5528 continue
5529 ;;
5530
5531 -inst-prefix-dir)
5532 prev=inst_prefix
5533 continue
5534 ;;
5535
5536 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
5537 # so, if we see these flags be careful not to treat them like -L
5538 -L[A-Z][A-Z]*:*)
5539 case $with_gcc/$host in
5540 no/*-*-irix* | /*-*-irix*)
5541 func_append compile_command " $arg"
5542 func_append finalize_command " $arg"
5543 ;;
5544 esac
5545 continue
5546 ;;
5547
5548 -L*)
5549 func_stripname "-L" '' "$arg"
5550 if test -z "$func_stripname_result"; then
5551 if test "$#" -gt 0; then
5552 func_fatal_error "require no space between \`-L' and \`$1'"
5553 else
5554 func_fatal_error "need path for \`-L' option"
5555 fi
5556 fi
5557 func_resolve_sysroot "$func_stripname_result"
5558 dir=$func_resolve_sysroot_result
5559 # We need an absolute path.
5560 case $dir in
5561 [\\/]* | [A-Za-z]:[\\/]*) ;;
5562 *)
5563 absdir=`cd "$dir" && pwd`
5564 test -z "$absdir" && \
5565 func_fatal_error "cannot determine absolute directory name of \`$dir'"
5566 dir="$absdir"
5567 ;;
5568 esac
5569 case "$deplibs " in
5570 *" -L$dir "* | *" $arg "*)
5571 # Will only happen for absolute or sysroot arguments
5572 ;;
5573 *)
5574 # Preserve sysroot, but never include relative directories
5575 case $dir in
5576 [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
5577 *) func_append deplibs " -L$dir" ;;
5578 esac
5579 func_append lib_search_path " $dir"
5580 ;;
5581 esac
5582 case $host in
5583 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
5584 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
5585 case :$dllsearchpath: in
5586 *":$dir:"*) ;;
5587 ::) dllsearchpath=$dir;;
5588 *) func_append dllsearchpath ":$dir";;
5589 esac
5590 case :$dllsearchpath: in
5591 *":$testbindir:"*) ;;
5592 ::) dllsearchpath=$testbindir;;
5593 *) func_append dllsearchpath ":$testbindir";;
5594 esac
5595 ;;
5596 esac
5597 continue
5598 ;;
5599
5600 -l*)
5601 if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
5602 case $host in
5603 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
5604 # These systems don't actually have a C or math library (as such)
5605 continue
5606 ;;
5607 *-*-os2*)
5608 # These systems don't actually have a C library (as such)
5609 test "X$arg" = "X-lc" && continue
5610 ;;
5611 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5612 # Do not include libc due to us having libc/libc_r.
5613 test "X$arg" = "X-lc" && continue
5614 ;;
5615 *-*-rhapsody* | *-*-darwin1.[012])
5616 # Rhapsody C and math libraries are in the System framework
5617 func_append deplibs " System.ltframework"
5618 continue
5619 ;;
5620 *-*-sco3.2v5* | *-*-sco5v6*)
5621 # Causes problems with __ctype
5622 test "X$arg" = "X-lc" && continue
5623 ;;
5624 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5625 # Compiler inserts libc in the correct place for threads to work
5626 test "X$arg" = "X-lc" && continue
5627 ;;
5628 esac
5629 elif test "X$arg" = "X-lc_r"; then
5630 case $host in
5631 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5632 # Do not include libc_r directly, use -pthread flag.
5633 continue
5634 ;;
5635 esac
5636 fi
5637 func_append deplibs " $arg"
5638 continue
5639 ;;
5640
5641 -module)
5642 module=yes
5643 continue
5644 ;;
5645
5646 # Tru64 UNIX uses -model [arg] to determine the layout of C++
5647 # classes, name mangling, and exception handling.
5648 # Darwin uses the -arch flag to determine output architecture.
5649 -model|-arch|-isysroot|--sysroot)
5650 func_append compiler_flags " $arg"
5651 func_append compile_command " $arg"
5652 func_append finalize_command " $arg"
5653 prev=xcompiler
5654 continue
5655 ;;
5656
5657 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
5658 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
5659 func_append compiler_flags " $arg"
5660 func_append compile_command " $arg"
5661 func_append finalize_command " $arg"
5662 case "$new_inherited_linker_flags " in
5663 *" $arg "*) ;;
5664 * ) func_append new_inherited_linker_flags " $arg" ;;
5665 esac
5666 continue
5667 ;;
5668
5669 -multi_module)
5670 single_module="${wl}-multi_module"
5671 continue
5672 ;;
5673
5674 -no-fast-install)
5675 fast_install=no
5676 continue
5677 ;;
5678
5679 -no-install)
5680 case $host in
5681 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
5682 # The PATH hackery in wrapper scripts is required on Windows
5683 # and Darwin in order for the loader to find any dlls it needs.
5684 func_warning "\`-no-install' is ignored for $host"
5685 func_warning "assuming \`-no-fast-install' instead"
5686 fast_install=no
5687 ;;
5688 *) no_install=yes ;;
5689 esac
5690 continue
5691 ;;
5692
5693 -no-undefined)
5694 allow_undefined=no
5695 continue
5696 ;;
5697
5698 -objectlist)
5699 prev=objectlist
5700 continue
5701 ;;
5702
5703 -o) prev=output ;;
5704
5705 -precious-files-regex)
5706 prev=precious_regex
5707 continue
5708 ;;
5709
5710 -release)
5711 prev=release
5712 continue
5713 ;;
5714
5715 -rpath)
5716 prev=rpath
5717 continue
5718 ;;
5719
5720 -R)
5721 prev=xrpath
5722 continue
5723 ;;
5724
5725 -R*)
5726 func_stripname '-R' '' "$arg"
5727 dir=$func_stripname_result
5728 # We need an absolute path.
5729 case $dir in
5730 [\\/]* | [A-Za-z]:[\\/]*) ;;
5731 =*)
5732 func_stripname '=' '' "$dir"
5733 dir=$lt_sysroot$func_stripname_result
5734 ;;
5735 *)
5736 func_fatal_error "only absolute run-paths are allowed"
5737 ;;
5738 esac
5739 case "$xrpath " in
5740 *" $dir "*) ;;
5741 *) func_append xrpath " $dir" ;;
5742 esac
5743 continue
5744 ;;
5745
5746 -shared)
5747 # The effects of -shared are defined in a previous loop.
5748 continue
5749 ;;
5750
5751 -shrext)
5752 prev=shrext
5753 continue
5754 ;;
5755
5756 -static | -static-libtool-libs)
5757 # The effects of -static are defined in a previous loop.
5758 # We used to do the same as -all-static on platforms that
5759 # didn't have a PIC flag, but the assumption that the effects
5760 # would be equivalent was wrong. It would break on at least
5761 # Digital Unix and AIX.
5762 continue
5763 ;;
5764
5765 -thread-safe)
5766 thread_safe=yes
5767 continue
5768 ;;
5769
5770 -version-info)
5771 prev=vinfo
5772 continue
5773 ;;
5774
5775 -version-number)
5776 prev=vinfo
5777 vinfo_number=yes
5778 continue
5779 ;;
5780
5781 -weak)
5782 prev=weak
5783 continue
5784 ;;
5785
5786 -Wc,*)
5787 func_stripname '-Wc,' '' "$arg"
5788 args=$func_stripname_result
5789 arg=
5790 save_ifs="$IFS"; IFS=','
5791 for flag in $args; do
5792 IFS="$save_ifs"
5793 func_quote_for_eval "$flag"
5794 func_append arg " $func_quote_for_eval_result"
5795 func_append compiler_flags " $func_quote_for_eval_result"
5796 done
5797 IFS="$save_ifs"
5798 func_stripname ' ' '' "$arg"
5799 arg=$func_stripname_result
5800 ;;
5801
5802 -Wl,*)
5803 func_stripname '-Wl,' '' "$arg"
5804 args=$func_stripname_result
5805 arg=
5806 save_ifs="$IFS"; IFS=','
5807 for flag in $args; do
5808 IFS="$save_ifs"
5809 func_quote_for_eval "$flag"
5810 func_append arg " $wl$func_quote_for_eval_result"
5811 func_append compiler_flags " $wl$func_quote_for_eval_result"
5812 func_append linker_flags " $func_quote_for_eval_result"
5813 done
5814 IFS="$save_ifs"
5815 func_stripname ' ' '' "$arg"
5816 arg=$func_stripname_result
5817 ;;
5818
5819 -Xcompiler)
5820 prev=xcompiler
5821 continue
5822 ;;
5823
5824 -Xlinker)
5825 prev=xlinker
5826 continue
5827 ;;
5828
5829 -XCClinker)
5830 prev=xcclinker
5831 continue
5832 ;;
5833
5834 # -msg_* for osf cc
5835 -msg_*)
5836 func_quote_for_eval "$arg"
5837 arg="$func_quote_for_eval_result"
5838 ;;
5839
5840 # Flags to be passed through unchanged, with rationale:
5841 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
5842 # -r[0-9][0-9]* specify processor for the SGI compiler
5843 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
5844 # +DA*, +DD* enable 64-bit mode for the HP compiler
5845 # -q* compiler args for the IBM compiler
5846 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
5847 # -F/path path to uninstalled frameworks, gcc on darwin
5848 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
5849 # @file GCC response files
5850 # -tp=* Portland pgcc target processor selection
5851 # --sysroot=* for sysroot support
5852 # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
5853 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
5854 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
5855 -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
5856 func_quote_for_eval "$arg"
5857 arg="$func_quote_for_eval_result"
5858 func_append compile_command " $arg"
5859 func_append finalize_command " $arg"
5860 func_append compiler_flags " $arg"
5861 continue
5862 ;;
5863
5864 # Some other compiler flag.
5865 -* | +*)
5866 func_quote_for_eval "$arg"
5867 arg="$func_quote_for_eval_result"
5868 ;;
5869
5870 *.$objext)
5871 # A standard object.
5872 func_append objs " $arg"
5873 ;;
5874
5875 *.lo)
5876 # A libtool-controlled object.
5877
5878 # Check to see that this really is a libtool object.
5879 if func_lalib_unsafe_p "$arg"; then
5880 pic_object=
5881 non_pic_object=
5882
5883 # Read the .lo file
5884 func_source "$arg"
5885
5886 if test -z "$pic_object" ||
5887 test -z "$non_pic_object" ||
5888 test "$pic_object" = none &&
5889 test "$non_pic_object" = none; then
5890 func_fatal_error "cannot find name of object for \`$arg'"
5891 fi
5892
5893 # Extract subdirectory from the argument.
5894 func_dirname "$arg" "/" ""
5895 xdir="$func_dirname_result"
5896
5897 if test "$pic_object" != none; then
5898 # Prepend the subdirectory the object is found in.
5899 pic_object="$xdir$pic_object"
5900
5901 if test "$prev" = dlfiles; then
5902 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
5903 func_append dlfiles " $pic_object"
5904 prev=
5905 continue
5906 else
5907 # If libtool objects are unsupported, then we need to preload.
5908 prev=dlprefiles
5909 fi
5910 fi
5911
5912 # CHECK ME: I think I busted this. -Ossama
5913 if test "$prev" = dlprefiles; then
5914 # Preload the old-style object.
5915 func_append dlprefiles " $pic_object"
5916 prev=
5917 fi
5918
5919 # A PIC object.
5920 func_append libobjs " $pic_object"
5921 arg="$pic_object"
5922 fi
5923
5924 # Non-PIC object.
5925 if test "$non_pic_object" != none; then
5926 # Prepend the subdirectory the object is found in.
5927 non_pic_object="$xdir$non_pic_object"
5928
5929 # A standard non-PIC object
5930 func_append non_pic_objects " $non_pic_object"
5931 if test -z "$pic_object" || test "$pic_object" = none ; then
5932 arg="$non_pic_object"
5933 fi
5934 else
5935 # If the PIC object exists, use it instead.
5936 # $xdir was prepended to $pic_object above.
5937 non_pic_object="$pic_object"
5938 func_append non_pic_objects " $non_pic_object"
5939 fi
5940 else
5941 # Only an error if not doing a dry-run.
5942 if $opt_dry_run; then
5943 # Extract subdirectory from the argument.
5944 func_dirname "$arg" "/" ""
5945 xdir="$func_dirname_result"
5946
5947 func_lo2o "$arg"
5948 pic_object=$xdir$objdir/$func_lo2o_result
5949 non_pic_object=$xdir$func_lo2o_result
5950 func_append libobjs " $pic_object"
5951 func_append non_pic_objects " $non_pic_object"
5952 else
5953 func_fatal_error "\`$arg' is not a valid libtool object"
5954 fi
5955 fi
5956 ;;
5957
5958 *.$libext)
5959 # An archive.
5960 func_append deplibs " $arg"
5961 func_append old_deplibs " $arg"
5962 continue
5963 ;;
5964
5965 *.la)
5966 # A libtool-controlled library.
5967
5968 func_resolve_sysroot "$arg"
5969 if test "$prev" = dlfiles; then
5970 # This library was specified with -dlopen.
5971 func_append dlfiles " $func_resolve_sysroot_result"
5972 prev=
5973 elif test "$prev" = dlprefiles; then
5974 # The library was specified with -dlpreopen.
5975 func_append dlprefiles " $func_resolve_sysroot_result"
5976 prev=
5977 else
5978 func_append deplibs " $func_resolve_sysroot_result"
5979 fi
5980 continue
5981 ;;
5982
5983 # Some other compiler argument.
5984 *)
5985 # Unknown arguments in both finalize_command and compile_command need
5986 # to be aesthetically quoted because they are evaled later.
5987 func_quote_for_eval "$arg"
5988 arg="$func_quote_for_eval_result"
5989 ;;
5990 esac # arg
5991
5992 # Now actually substitute the argument into the commands.
5993 if test -n "$arg"; then
5994 func_append compile_command " $arg"
5995 func_append finalize_command " $arg"
5996 fi
5997 done # argument parsing loop
5998
5999 test -n "$prev" && \
6000 func_fatal_help "the \`$prevarg' option requires an argument"
6001
6002 if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
6003 eval arg=\"$export_dynamic_flag_spec\"
6004 func_append compile_command " $arg"
6005 func_append finalize_command " $arg"
6006 fi
6007
6008 oldlibs=
6009 # calculate the name of the file, without its directory
6010 func_basename "$output"
6011 outputname="$func_basename_result"
6012 libobjs_save="$libobjs"
6013
6014 if test -n "$shlibpath_var"; then
6015 # get the directories listed in $shlibpath_var
6016 eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
6017 else
6018 shlib_search_path=
6019 fi
6020 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
6021 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
6022
6023 func_dirname "$output" "/" ""
6024 output_objdir="$func_dirname_result$objdir"
6025 func_to_tool_file "$output_objdir/"
6026 tool_output_objdir=$func_to_tool_file_result
6027 # Create the object directory.
6028 func_mkdir_p "$output_objdir"
6029
6030 # Determine the type of output
6031 case $output in
6032 "")
6033 func_fatal_help "you must specify an output file"
6034 ;;
6035 *.$libext) linkmode=oldlib ;;
6036 *.lo | *.$objext) linkmode=obj ;;
6037 *.la) linkmode=lib ;;
6038 *) linkmode=prog ;; # Anything else should be a program.
6039 esac
6040
6041 specialdeplibs=
6042
6043 libs=
6044 # Find all interdependent deplibs by searching for libraries
6045 # that are linked more than once (e.g. -la -lb -la)
6046 for deplib in $deplibs; do
6047 if $opt_preserve_dup_deps ; then
6048 case "$libs " in
6049 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6050 esac
6051 fi
6052 func_append libs " $deplib"
6053 done
6054
6055 if test "$linkmode" = lib; then
6056 libs="$predeps $libs $compiler_lib_search_path $postdeps"
6057
6058 # Compute libraries that are listed more than once in $predeps
6059 # $postdeps and mark them as special (i.e., whose duplicates are
6060 # not to be eliminated).
6061 pre_post_deps=
6062 if $opt_duplicate_compiler_generated_deps; then
6063 for pre_post_dep in $predeps $postdeps; do
6064 case "$pre_post_deps " in
6065 *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
6066 esac
6067 func_append pre_post_deps " $pre_post_dep"
6068 done
6069 fi
6070 pre_post_deps=
6071 fi
6072
6073 deplibs=
6074 newdependency_libs=
6075 newlib_search_path=
6076 need_relink=no # whether we're linking any uninstalled libtool libraries
6077 notinst_deplibs= # not-installed libtool libraries
6078 notinst_path= # paths that contain not-installed libtool libraries
6079
6080 case $linkmode in
6081 lib)
6082 passes="conv dlpreopen link"
6083 for file in $dlfiles $dlprefiles; do
6084 case $file in
6085 *.la) ;;
6086 *)
6087 func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
6088 ;;
6089 esac
6090 done
6091 ;;
6092 prog)
6093 compile_deplibs=
6094 finalize_deplibs=
6095 alldeplibs=no
6096 newdlfiles=
6097 newdlprefiles=
6098 passes="conv scan dlopen dlpreopen link"
6099 ;;
6100 *) passes="conv"
6101 ;;
6102 esac
6103
6104 for pass in $passes; do
6105 # The preopen pass in lib mode reverses $deplibs; put it back here
6106 # so that -L comes before libs that need it for instance...
6107 if test "$linkmode,$pass" = "lib,link"; then
6108 ## FIXME: Find the place where the list is rebuilt in the wrong
6109 ## order, and fix it there properly
6110 tmp_deplibs=
6111 for deplib in $deplibs; do
6112 tmp_deplibs="$deplib $tmp_deplibs"
6113 done
6114 deplibs="$tmp_deplibs"
6115 fi
6116
6117 if test "$linkmode,$pass" = "lib,link" ||
6118 test "$linkmode,$pass" = "prog,scan"; then
6119 libs="$deplibs"
6120 deplibs=
6121 fi
6122 if test "$linkmode" = prog; then
6123 case $pass in
6124 dlopen) libs="$dlfiles" ;;
6125 dlpreopen) libs="$dlprefiles" ;;
6126 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
6127 esac
6128 fi
6129 if test "$linkmode,$pass" = "lib,dlpreopen"; then
6130 # Collect and forward deplibs of preopened libtool libs
6131 for lib in $dlprefiles; do
6132 # Ignore non-libtool-libs
6133 dependency_libs=
6134 func_resolve_sysroot "$lib"
6135 case $lib in
6136 *.la) func_source "$func_resolve_sysroot_result" ;;
6137 esac
6138
6139 # Collect preopened libtool deplibs, except any this library
6140 # has declared as weak libs
6141 for deplib in $dependency_libs; do
6142 func_basename "$deplib"
6143 deplib_base=$func_basename_result
6144 case " $weak_libs " in
6145 *" $deplib_base "*) ;;
6146 *) func_append deplibs " $deplib" ;;
6147 esac
6148 done
6149 done
6150 libs="$dlprefiles"
6151 fi
6152 if test "$pass" = dlopen; then
6153 # Collect dlpreopened libraries
6154 save_deplibs="$deplibs"
6155 deplibs=
6156 fi
6157
6158 for deplib in $libs; do
6159 lib=
6160 found=no
6161 case $deplib in
6162 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
6163 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
6164 if test "$linkmode,$pass" = "prog,link"; then
6165 compile_deplibs="$deplib $compile_deplibs"
6166 finalize_deplibs="$deplib $finalize_deplibs"
6167 else
6168 func_append compiler_flags " $deplib"
6169 if test "$linkmode" = lib ; then
6170 case "$new_inherited_linker_flags " in
6171 *" $deplib "*) ;;
6172 * ) func_append new_inherited_linker_flags " $deplib" ;;
6173 esac
6174 fi
6175 fi
6176 continue
6177 ;;
6178 -l*)
6179 if test "$linkmode" != lib && test "$linkmode" != prog; then
6180 func_warning "\`-l' is ignored for archives/objects"
6181 continue
6182 fi
6183 func_stripname '-l' '' "$deplib"
6184 name=$func_stripname_result
6185 if test "$linkmode" = lib; then
6186 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
6187 else
6188 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
6189 fi
6190 for searchdir in $searchdirs; do
6191 for search_ext in .la $std_shrext .so .a; do
6192 # Search the libtool library
6193 lib="$searchdir/lib${name}${search_ext}"
6194 if test -f "$lib"; then
6195 if test "$search_ext" = ".la"; then
6196 found=yes
6197 else
6198 found=no
6199 fi
6200 break 2
6201 fi
6202 done
6203 done
6204 if test "$found" != yes; then
6205 # deplib doesn't seem to be a libtool library
6206 if test "$linkmode,$pass" = "prog,link"; then
6207 compile_deplibs="$deplib $compile_deplibs"
6208 finalize_deplibs="$deplib $finalize_deplibs"
6209 else
6210 deplibs="$deplib $deplibs"
6211 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6212 fi
6213 continue
6214 else # deplib is a libtool library
6215 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
6216 # We need to do some special things here, and not later.
6217 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6218 case " $predeps $postdeps " in
6219 *" $deplib "*)
6220 if func_lalib_p "$lib"; then
6221 library_names=
6222 old_library=
6223 func_source "$lib"
6224 for l in $old_library $library_names; do
6225 ll="$l"
6226 done
6227 if test "X$ll" = "X$old_library" ; then # only static version available
6228 found=no
6229 func_dirname "$lib" "" "."
6230 ladir="$func_dirname_result"
6231 lib=$ladir/$old_library
6232 if test "$linkmode,$pass" = "prog,link"; then
6233 compile_deplibs="$deplib $compile_deplibs"
6234 finalize_deplibs="$deplib $finalize_deplibs"
6235 else
6236 deplibs="$deplib $deplibs"
6237 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
6238 fi
6239 continue
6240 fi
6241 fi
6242 ;;
6243 *) ;;
6244 esac
6245 fi
6246 fi
6247 ;; # -l
6248 *.ltframework)
6249 if test "$linkmode,$pass" = "prog,link"; then
6250 compile_deplibs="$deplib $compile_deplibs"
6251 finalize_deplibs="$deplib $finalize_deplibs"
6252 else
6253 deplibs="$deplib $deplibs"
6254 if test "$linkmode" = lib ; then
6255 case "$new_inherited_linker_flags " in
6256 *" $deplib "*) ;;
6257 * ) func_append new_inherited_linker_flags " $deplib" ;;
6258 esac
6259 fi
6260 fi
6261 continue
6262 ;;
6263 -L*)
6264 case $linkmode in
6265 lib)
6266 deplibs="$deplib $deplibs"
6267 test "$pass" = conv && continue
6268 newdependency_libs="$deplib $newdependency_libs"
6269 func_stripname '-L' '' "$deplib"
6270 func_resolve_sysroot "$func_stripname_result"
6271 func_append newlib_search_path " $func_resolve_sysroot_result"
6272 ;;
6273 prog)
6274 if test "$pass" = conv; then
6275 deplibs="$deplib $deplibs"
6276 continue
6277 fi
6278 if test "$pass" = scan; then
6279 deplibs="$deplib $deplibs"
6280 else
6281 compile_deplibs="$deplib $compile_deplibs"
6282 finalize_deplibs="$deplib $finalize_deplibs"
6283 fi
6284 func_stripname '-L' '' "$deplib"
6285 func_resolve_sysroot "$func_stripname_result"
6286 func_append newlib_search_path " $func_resolve_sysroot_result"
6287 ;;
6288 *)
6289 func_warning "\`-L' is ignored for archives/objects"
6290 ;;
6291 esac # linkmode
6292 continue
6293 ;; # -L
6294 -R*)
6295 if test "$pass" = link; then
6296 func_stripname '-R' '' "$deplib"
6297 func_resolve_sysroot "$func_stripname_result"
6298 dir=$func_resolve_sysroot_result
6299 # Make sure the xrpath contains only unique directories.
6300 case "$xrpath " in
6301 *" $dir "*) ;;
6302 *) func_append xrpath " $dir" ;;
6303 esac
6304 fi
6305 deplibs="$deplib $deplibs"
6306 continue
6307 ;;
6308 *.la)
6309 func_resolve_sysroot "$deplib"
6310 lib=$func_resolve_sysroot_result
6311 ;;
6312 *.$libext)
6313 if test "$pass" = conv; then
6314 deplibs="$deplib $deplibs"
6315 continue
6316 fi
6317 case $linkmode in
6318 lib)
6319 # Linking convenience modules into shared libraries is allowed,
6320 # but linking other static libraries is non-portable.
6321 case " $dlpreconveniencelibs " in
6322 *" $deplib "*) ;;
6323 *)
6324 valid_a_lib=no
6325 case $deplibs_check_method in
6326 match_pattern*)
6327 set dummy $deplibs_check_method; shift
6328 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6329 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
6330 | $EGREP "$match_pattern_regex" > /dev/null; then
6331 valid_a_lib=yes
6332 fi
6333 ;;
6334 pass_all)
6335 valid_a_lib=yes
6336 ;;
6337 esac
6338 if test "$valid_a_lib" != yes; then
6339 echo
6340 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
6341 echo "*** I have the capability to make that library automatically link in when"
6342 echo "*** you link to this library. But I can only do this if you have a"
6343 echo "*** shared version of the library, which you do not appear to have"
6344 echo "*** because the file extensions .$libext of this argument makes me believe"
6345 echo "*** that it is just a static archive that I should not use here."
6346 else
6347 echo
6348 $ECHO "*** Warning: Linking the shared library $output against the"
6349 $ECHO "*** static library $deplib is not portable!"
6350 deplibs="$deplib $deplibs"
6351 fi
6352 ;;
6353 esac
6354 continue
6355 ;;
6356 prog)
6357 if test "$pass" != link; then
6358 deplibs="$deplib $deplibs"
6359 else
6360 compile_deplibs="$deplib $compile_deplibs"
6361 finalize_deplibs="$deplib $finalize_deplibs"
6362 fi
6363 continue
6364 ;;
6365 esac # linkmode
6366 ;; # *.$libext
6367 *.lo | *.$objext)
6368 if test "$pass" = conv; then
6369 deplibs="$deplib $deplibs"
6370 elif test "$linkmode" = prog; then
6371 if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
6372 # If there is no dlopen support or we're linking statically,
6373 # we need to preload.
6374 func_append newdlprefiles " $deplib"
6375 compile_deplibs="$deplib $compile_deplibs"
6376 finalize_deplibs="$deplib $finalize_deplibs"
6377 else
6378 func_append newdlfiles " $deplib"
6379 fi
6380 fi
6381 continue
6382 ;;
6383 %DEPLIBS%)
6384 alldeplibs=yes
6385 continue
6386 ;;
6387 esac # case $deplib
6388
6389 if test "$found" = yes || test -f "$lib"; then :
6390 else
6391 func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
6392 fi
6393
6394 # Check to see that this really is a libtool archive.
6395 func_lalib_unsafe_p "$lib" \
6396 || func_fatal_error "\`$lib' is not a valid libtool archive"
6397
6398 func_dirname "$lib" "" "."
6399 ladir="$func_dirname_result"
6400
6401 dlname=
6402 dlopen=
6403 dlpreopen=
6404 libdir=
6405 library_names=
6406 old_library=
6407 inherited_linker_flags=
6408 # If the library was installed with an old release of libtool,
6409 # it will not redefine variables installed, or shouldnotlink
6410 installed=yes
6411 shouldnotlink=no
6412 avoidtemprpath=
6413
6414
6415 # Read the .la file
6416 func_source "$lib"
6417
6418 # Convert "-framework foo" to "foo.ltframework"
6419 if test -n "$inherited_linker_flags"; then
6420 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
6421 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
6422 case " $new_inherited_linker_flags " in
6423 *" $tmp_inherited_linker_flag "*) ;;
6424 *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
6425 esac
6426 done
6427 fi
6428 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
6429 if test "$linkmode,$pass" = "lib,link" ||
6430 test "$linkmode,$pass" = "prog,scan" ||
6431 { test "$linkmode" != prog && test "$linkmode" != lib; }; then
6432 test -n "$dlopen" && func_append dlfiles " $dlopen"
6433 test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
6434 fi
6435
6436 if test "$pass" = conv; then
6437 # Only check for convenience libraries
6438 deplibs="$lib $deplibs"
6439 if test -z "$libdir"; then
6440 if test -z "$old_library"; then
6441 func_fatal_error "cannot find name of link library for \`$lib'"
6442 fi
6443 # It is a libtool convenience library, so add in its objects.
6444 func_append convenience " $ladir/$objdir/$old_library"
6445 func_append old_convenience " $ladir/$objdir/$old_library"
6446 elif test "$linkmode" != prog && test "$linkmode" != lib; then
6447 func_fatal_error "\`$lib' is not a convenience library"
6448 fi
6449 tmp_libs=
6450 for deplib in $dependency_libs; do
6451 deplibs="$deplib $deplibs"
6452 if $opt_preserve_dup_deps ; then
6453 case "$tmp_libs " in
6454 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6455 esac
6456 fi
6457 func_append tmp_libs " $deplib"
6458 done
6459 continue
6460 fi # $pass = conv
6461
6462
6463 # Get the name of the library we link against.
6464 linklib=
6465 if test -n "$old_library" &&
6466 { test "$prefer_static_libs" = yes ||
6467 test "$prefer_static_libs,$installed" = "built,no"; }; then
6468 linklib=$old_library
6469 else
6470 for l in $old_library $library_names; do
6471 linklib="$l"
6472 done
6473 fi
6474 if test -z "$linklib"; then
6475 func_fatal_error "cannot find name of link library for \`$lib'"
6476 fi
6477
6478 # This library was specified with -dlopen.
6479 if test "$pass" = dlopen; then
6480 if test -z "$libdir"; then
6481 func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
6482 fi
6483 if test -z "$dlname" ||
6484 test "$dlopen_support" != yes ||
6485 test "$build_libtool_libs" = no; then
6486 # If there is no dlname, no dlopen support or we're linking
6487 # statically, we need to preload. We also need to preload any
6488 # dependent libraries so libltdl's deplib preloader doesn't
6489 # bomb out in the load deplibs phase.
6490 func_append dlprefiles " $lib $dependency_libs"
6491 else
6492 func_append newdlfiles " $lib"
6493 fi
6494 continue
6495 fi # $pass = dlopen
6496
6497 # We need an absolute path.
6498 case $ladir in
6499 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
6500 *)
6501 abs_ladir=`cd "$ladir" && pwd`
6502 if test -z "$abs_ladir"; then
6503 func_warning "cannot determine absolute directory name of \`$ladir'"
6504 func_warning "passing it literally to the linker, although it might fail"
6505 abs_ladir="$ladir"
6506 fi
6507 ;;
6508 esac
6509 func_basename "$lib"
6510 laname="$func_basename_result"
6511
6512 # Find the relevant object directory and library name.
6513 if test "X$installed" = Xyes; then
6514 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6515 func_warning "library \`$lib' was moved."
6516 dir="$ladir"
6517 absdir="$abs_ladir"
6518 libdir="$abs_ladir"
6519 else
6520 dir="$lt_sysroot$libdir"
6521 absdir="$lt_sysroot$libdir"
6522 fi
6523 test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
6524 else
6525 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
6526 dir="$ladir"
6527 absdir="$abs_ladir"
6528 # Remove this search path later
6529 func_append notinst_path " $abs_ladir"
6530 else
6531 dir="$ladir/$objdir"
6532 absdir="$abs_ladir/$objdir"
6533 # Remove this search path later
6534 func_append notinst_path " $abs_ladir"
6535 fi
6536 fi # $installed = yes
6537 func_stripname 'lib' '.la' "$laname"
6538 name=$func_stripname_result
6539
6540 # This library was specified with -dlpreopen.
6541 if test "$pass" = dlpreopen; then
6542 if test -z "$libdir" && test "$linkmode" = prog; then
6543 func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
6544 fi
6545 case "$host" in
6546 # special handling for platforms with PE-DLLs.
6547 *cygwin* | *mingw* | *cegcc* )
6548 # Linker will automatically link against shared library if both
6549 # static and shared are present. Therefore, ensure we extract
6550 # symbols from the import library if a shared library is present
6551 # (otherwise, the dlopen module name will be incorrect). We do
6552 # this by putting the import library name into $newdlprefiles.
6553 # We recover the dlopen module name by 'saving' the la file
6554 # name in a special purpose variable, and (later) extracting the
6555 # dlname from the la file.
6556 if test -n "$dlname"; then
6557 func_tr_sh "$dir/$linklib"
6558 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
6559 func_append newdlprefiles " $dir/$linklib"
6560 else
6561 func_append newdlprefiles " $dir/$old_library"
6562 # Keep a list of preopened convenience libraries to check
6563 # that they are being used correctly in the link pass.
6564 test -z "$libdir" && \
6565 func_append dlpreconveniencelibs " $dir/$old_library"
6566 fi
6567 ;;
6568 * )
6569 # Prefer using a static library (so that no silly _DYNAMIC symbols
6570 # are required to link).
6571 if test -n "$old_library"; then
6572 func_append newdlprefiles " $dir/$old_library"
6573 # Keep a list of preopened convenience libraries to check
6574 # that they are being used correctly in the link pass.
6575 test -z "$libdir" && \
6576 func_append dlpreconveniencelibs " $dir/$old_library"
6577 # Otherwise, use the dlname, so that lt_dlopen finds it.
6578 elif test -n "$dlname"; then
6579 func_append newdlprefiles " $dir/$dlname"
6580 else
6581 func_append newdlprefiles " $dir/$linklib"
6582 fi
6583 ;;
6584 esac
6585 fi # $pass = dlpreopen
6586
6587 if test -z "$libdir"; then
6588 # Link the convenience library
6589 if test "$linkmode" = lib; then
6590 deplibs="$dir/$old_library $deplibs"
6591 elif test "$linkmode,$pass" = "prog,link"; then
6592 compile_deplibs="$dir/$old_library $compile_deplibs"
6593 finalize_deplibs="$dir/$old_library $finalize_deplibs"
6594 else
6595 deplibs="$lib $deplibs" # used for prog,scan pass
6596 fi
6597 continue
6598 fi
6599
6600
6601 if test "$linkmode" = prog && test "$pass" != link; then
6602 func_append newlib_search_path " $ladir"
6603 deplibs="$lib $deplibs"
6604
6605 linkalldeplibs=no
6606 if test "$link_all_deplibs" != no || test -z "$library_names" ||
6607 test "$build_libtool_libs" = no; then
6608 linkalldeplibs=yes
6609 fi
6610
6611 tmp_libs=
6612 for deplib in $dependency_libs; do
6613 case $deplib in
6614 -L*) func_stripname '-L' '' "$deplib"
6615 func_resolve_sysroot "$func_stripname_result"
6616 func_append newlib_search_path " $func_resolve_sysroot_result"
6617 ;;
6618 esac
6619 # Need to link against all dependency_libs?
6620 if test "$linkalldeplibs" = yes; then
6621 deplibs="$deplib $deplibs"
6622 else
6623 # Need to hardcode shared library paths
6624 # or/and link against static libraries
6625 newdependency_libs="$deplib $newdependency_libs"
6626 fi
6627 if $opt_preserve_dup_deps ; then
6628 case "$tmp_libs " in
6629 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
6630 esac
6631 fi
6632 func_append tmp_libs " $deplib"
6633 done # for deplib
6634 continue
6635 fi # $linkmode = prog...
6636
6637 if test "$linkmode,$pass" = "prog,link"; then
6638 if test -n "$library_names" &&
6639 { { test "$prefer_static_libs" = no ||
6640 test "$prefer_static_libs,$installed" = "built,yes"; } ||
6641 test -z "$old_library"; }; then
6642 # We need to hardcode the library path
6643 if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
6644 # Make sure the rpath contains only unique directories.
6645 case "$temp_rpath:" in
6646 *"$absdir:"*) ;;
6647 *) func_append temp_rpath "$absdir:" ;;
6648 esac
6649 fi
6650
6651 # Hardcode the library path.
6652 # Skip directories that are in the system default run-time
6653 # search path.
6654 case " $sys_lib_dlsearch_path " in
6655 *" $absdir "*) ;;
6656 *)
6657 case "$compile_rpath " in
6658 *" $absdir "*) ;;
6659 *) func_append compile_rpath " $absdir" ;;
6660 esac
6661 ;;
6662 esac
6663 case " $sys_lib_dlsearch_path " in
6664 *" $libdir "*) ;;
6665 *)
6666 case "$finalize_rpath " in
6667 *" $libdir "*) ;;
6668 *) func_append finalize_rpath " $libdir" ;;
6669 esac
6670 ;;
6671 esac
6672 fi # $linkmode,$pass = prog,link...
6673
6674 if test "$alldeplibs" = yes &&
6675 { test "$deplibs_check_method" = pass_all ||
6676 { test "$build_libtool_libs" = yes &&
6677 test -n "$library_names"; }; }; then
6678 # We only need to search for static libraries
6679 continue
6680 fi
6681 fi
6682
6683 link_static=no # Whether the deplib will be linked statically
6684 use_static_libs=$prefer_static_libs
6685 if test "$use_static_libs" = built && test "$installed" = yes; then
6686 use_static_libs=no
6687 fi
6688 if test -n "$library_names" &&
6689 { test "$use_static_libs" = no || test -z "$old_library"; }; then
6690 case $host in
6691 *cygwin* | *mingw* | *cegcc*)
6692 # No point in relinking DLLs because paths are not encoded
6693 func_append notinst_deplibs " $lib"
6694 need_relink=no
6695 ;;
6696 *)
6697 if test "$installed" = no; then
6698 func_append notinst_deplibs " $lib"
6699 need_relink=yes
6700 fi
6701 ;;
6702 esac
6703 # This is a shared library
6704
6705 # Warn about portability, can't link against -module's on some
6706 # systems (darwin). Don't bleat about dlopened modules though!
6707 dlopenmodule=""
6708 for dlpremoduletest in $dlprefiles; do
6709 if test "X$dlpremoduletest" = "X$lib"; then
6710 dlopenmodule="$dlpremoduletest"
6711 break
6712 fi
6713 done
6714 if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
6715 echo
6716 if test "$linkmode" = prog; then
6717 $ECHO "*** Warning: Linking the executable $output against the loadable module"
6718 else
6719 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
6720 fi
6721 $ECHO "*** $linklib is not portable!"
6722 fi
6723 if test "$linkmode" = lib &&
6724 test "$hardcode_into_libs" = yes; then
6725 # Hardcode the library path.
6726 # Skip directories that are in the system default run-time
6727 # search path.
6728 case " $sys_lib_dlsearch_path " in
6729 *" $absdir "*) ;;
6730 *)
6731 case "$compile_rpath " in
6732 *" $absdir "*) ;;
6733 *) func_append compile_rpath " $absdir" ;;
6734 esac
6735 ;;
6736 esac
6737 case " $sys_lib_dlsearch_path " in
6738 *" $libdir "*) ;;
6739 *)
6740 case "$finalize_rpath " in
6741 *" $libdir "*) ;;
6742 *) func_append finalize_rpath " $libdir" ;;
6743 esac
6744 ;;
6745 esac
6746 fi
6747
6748 if test -n "$old_archive_from_expsyms_cmds"; then
6749 # figure out the soname
6750 set dummy $library_names
6751 shift
6752 realname="$1"
6753 shift
6754 libname=`eval "\\$ECHO \"$libname_spec\""`
6755 # use dlname if we got it. it's perfectly good, no?
6756 if test -n "$dlname"; then
6757 soname="$dlname"
6758 elif test -n "$soname_spec"; then
6759 # bleh windows
6760 case $host in
6761 *cygwin* | mingw* | *cegcc*)
6762 func_arith $current - $age
6763 major=$func_arith_result
6764 versuffix="-$major"
6765 ;;
6766 esac
6767 eval soname=\"$soname_spec\"
6768 else
6769 soname="$realname"
6770 fi
6771
6772 # Make a new name for the extract_expsyms_cmds to use
6773 soroot="$soname"
6774 func_basename "$soroot"
6775 soname="$func_basename_result"
6776 func_stripname 'lib' '.dll' "$soname"
6777 newlib=libimp-$func_stripname_result.a
6778
6779 # If the library has no export list, then create one now
6780 if test -f "$output_objdir/$soname-def"; then :
6781 else
6782 func_verbose "extracting exported symbol list from \`$soname'"
6783 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
6784 fi
6785
6786 # Create $newlib
6787 if test -f "$output_objdir/$newlib"; then :; else
6788 func_verbose "generating import library for \`$soname'"
6789 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
6790 fi
6791 # make sure the library variables are pointing to the new library
6792 dir=$output_objdir
6793 linklib=$newlib
6794 fi # test -n "$old_archive_from_expsyms_cmds"
6795
6796 if test "$linkmode" = prog || test "$opt_mode" != relink; then
6797 add_shlibpath=
6798 add_dir=
6799 add=
6800 lib_linked=yes
6801 case $hardcode_action in
6802 immediate | unsupported)
6803 if test "$hardcode_direct" = no; then
6804 add="$dir/$linklib"
6805 case $host in
6806 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
6807 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
6808 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
6809 *-*-unixware7*) add_dir="-L$dir" ;;
6810 *-*-darwin* )
6811 # if the lib is a (non-dlopened) module then we can not
6812 # link against it, someone is ignoring the earlier warnings
6813 if /usr/bin/file -L $add 2> /dev/null |
6814 $GREP ": [^:]* bundle" >/dev/null ; then
6815 if test "X$dlopenmodule" != "X$lib"; then
6816 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
6817 if test -z "$old_library" ; then
6818 echo
6819 echo "*** And there doesn't seem to be a static archive available"
6820 echo "*** The link will probably fail, sorry"
6821 else
6822 add="$dir/$old_library"
6823 fi
6824 elif test -n "$old_library"; then
6825 add="$dir/$old_library"
6826 fi
6827 fi
6828 esac
6829 elif test "$hardcode_minus_L" = no; then
6830 case $host in
6831 *-*-sunos*) add_shlibpath="$dir" ;;
6832 esac
6833 add_dir="-L$dir"
6834 add="-l$name"
6835 elif test "$hardcode_shlibpath_var" = no; then
6836 add_shlibpath="$dir"
6837 add="-l$name"
6838 else
6839 lib_linked=no
6840 fi
6841 ;;
6842 relink)
6843 if test "$hardcode_direct" = yes &&
6844 test "$hardcode_direct_absolute" = no; then
6845 add="$dir/$linklib"
6846 elif test "$hardcode_minus_L" = yes; then
6847 add_dir="-L$absdir"
6848 # Try looking first in the location we're being installed to.
6849 if test -n "$inst_prefix_dir"; then
6850 case $libdir in
6851 [\\/]*)
6852 func_append add_dir " -L$inst_prefix_dir$libdir"
6853 ;;
6854 esac
6855 fi
6856 add="-l$name"
6857 elif test "$hardcode_shlibpath_var" = yes; then
6858 add_shlibpath="$dir"
6859 add="-l$name"
6860 else
6861 lib_linked=no
6862 fi
6863 ;;
6864 *) lib_linked=no ;;
6865 esac
6866
6867 if test "$lib_linked" != yes; then
6868 func_fatal_configuration "unsupported hardcode properties"
6869 fi
6870
6871 if test -n "$add_shlibpath"; then
6872 case :$compile_shlibpath: in
6873 *":$add_shlibpath:"*) ;;
6874 *) func_append compile_shlibpath "$add_shlibpath:" ;;
6875 esac
6876 fi
6877 if test "$linkmode" = prog; then
6878 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
6879 test -n "$add" && compile_deplibs="$add $compile_deplibs"
6880 else
6881 test -n "$add_dir" && deplibs="$add_dir $deplibs"
6882 test -n "$add" && deplibs="$add $deplibs"
6883 if test "$hardcode_direct" != yes &&
6884 test "$hardcode_minus_L" != yes &&
6885 test "$hardcode_shlibpath_var" = yes; then
6886 case :$finalize_shlibpath: in
6887 *":$libdir:"*) ;;
6888 *) func_append finalize_shlibpath "$libdir:" ;;
6889 esac
6890 fi
6891 fi
6892 fi
6893
6894 if test "$linkmode" = prog || test "$opt_mode" = relink; then
6895 add_shlibpath=
6896 add_dir=
6897 add=
6898 # Finalize command for both is simple: just hardcode it.
6899 if test "$hardcode_direct" = yes &&
6900 test "$hardcode_direct_absolute" = no; then
6901 add="$libdir/$linklib"
6902 elif test "$hardcode_minus_L" = yes; then
6903 add_dir="-L$libdir"
6904 add="-l$name"
6905 elif test "$hardcode_shlibpath_var" = yes; then
6906 case :$finalize_shlibpath: in
6907 *":$libdir:"*) ;;
6908 *) func_append finalize_shlibpath "$libdir:" ;;
6909 esac
6910 add="-l$name"
6911 elif test "$hardcode_automatic" = yes; then
6912 if test -n "$inst_prefix_dir" &&
6913 test -f "$inst_prefix_dir$libdir/$linklib" ; then
6914 add="$inst_prefix_dir$libdir/$linklib"
6915 else
6916 add="$libdir/$linklib"
6917 fi
6918 else
6919 # We cannot seem to hardcode it, guess we'll fake it.
6920 add_dir="-L$libdir"
6921 # Try looking first in the location we're being installed to.
6922 if test -n "$inst_prefix_dir"; then
6923 case $libdir in
6924 [\\/]*)
6925 func_append add_dir " -L$inst_prefix_dir$libdir"
6926 ;;
6927 esac
6928 fi
6929 add="-l$name"
6930 fi
6931
6932 if test "$linkmode" = prog; then
6933 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
6934 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
6935 else
6936 test -n "$add_dir" && deplibs="$add_dir $deplibs"
6937 test -n "$add" && deplibs="$add $deplibs"
6938 fi
6939 fi
6940 elif test "$linkmode" = prog; then
6941 # Here we assume that one of hardcode_direct or hardcode_minus_L
6942 # is not unsupported. This is valid on all known static and
6943 # shared platforms.
6944 if test "$hardcode_direct" != unsupported; then
6945 test -n "$old_library" && linklib="$old_library"
6946 compile_deplibs="$dir/$linklib $compile_deplibs"
6947 finalize_deplibs="$dir/$linklib $finalize_deplibs"
6948 else
6949 compile_deplibs="-l$name -L$dir $compile_deplibs"
6950 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
6951 fi
6952 elif test "$build_libtool_libs" = yes; then
6953 # Not a shared library
6954 if test "$deplibs_check_method" != pass_all; then
6955 # We're trying link a shared library against a static one
6956 # but the system doesn't support it.
6957
6958 # Just print a warning and add the library to dependency_libs so
6959 # that the program can be linked against the static library.
6960 echo
6961 $ECHO "*** Warning: This system can not link to static lib archive $lib."
6962 echo "*** I have the capability to make that library automatically link in when"
6963 echo "*** you link to this library. But I can only do this if you have a"
6964 echo "*** shared version of the library, which you do not appear to have."
6965 if test "$module" = yes; then
6966 echo "*** But as you try to build a module library, libtool will still create "
6967 echo "*** a static module, that should work as long as the dlopening application"
6968 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
6969 if test -z "$global_symbol_pipe"; then
6970 echo
6971 echo "*** However, this would only work if libtool was able to extract symbol"
6972 echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
6973 echo "*** not find such a program. So, this module is probably useless."
6974 echo "*** \`nm' from GNU binutils and a full rebuild may help."
6975 fi
6976 if test "$build_old_libs" = no; then
6977 build_libtool_libs=module
6978 build_old_libs=yes
6979 else
6980 build_libtool_libs=no
6981 fi
6982 fi
6983 else
6984 deplibs="$dir/$old_library $deplibs"
6985 link_static=yes
6986 fi
6987 fi # link shared/static library?
6988
6989 if test "$linkmode" = lib; then
6990 if test -n "$dependency_libs" &&
6991 { test "$hardcode_into_libs" != yes ||
6992 test "$build_old_libs" = yes ||
6993 test "$link_static" = yes; }; then
6994 # Extract -R from dependency_libs
6995 temp_deplibs=
6996 for libdir in $dependency_libs; do
6997 case $libdir in
6998 -R*) func_stripname '-R' '' "$libdir"
6999 temp_xrpath=$func_stripname_result
7000 case " $xrpath " in
7001 *" $temp_xrpath "*) ;;
7002 *) func_append xrpath " $temp_xrpath";;
7003 esac;;
7004 *) func_append temp_deplibs " $libdir";;
7005 esac
7006 done
7007 dependency_libs="$temp_deplibs"
7008 fi
7009
7010 func_append newlib_search_path " $absdir"
7011 # Link against this library
7012 test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
7013 # ... and its dependency_libs
7014 tmp_libs=
7015 for deplib in $dependency_libs; do
7016 newdependency_libs="$deplib $newdependency_libs"
7017 case $deplib in
7018 -L*) func_stripname '-L' '' "$deplib"
7019 func_resolve_sysroot "$func_stripname_result";;
7020 *) func_resolve_sysroot "$deplib" ;;
7021 esac
7022 if $opt_preserve_dup_deps ; then
7023 case "$tmp_libs " in
7024 *" $func_resolve_sysroot_result "*)
7025 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
7026 esac
7027 fi
7028 func_append tmp_libs " $func_resolve_sysroot_result"
7029 done
7030
7031 if test "$link_all_deplibs" != no; then
7032 # Add the search paths of all dependency libraries
7033 for deplib in $dependency_libs; do
7034 path=
7035 case $deplib in
7036 -L*) path="$deplib" ;;
7037 *.la)
7038 func_resolve_sysroot "$deplib"
7039 deplib=$func_resolve_sysroot_result
7040 func_dirname "$deplib" "" "."
7041 dir=$func_dirname_result
7042 # We need an absolute path.
7043 case $dir in
7044 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
7045 *)
7046 absdir=`cd "$dir" && pwd`
7047 if test -z "$absdir"; then
7048 func_warning "cannot determine absolute directory name of \`$dir'"
7049 absdir="$dir"
7050 fi
7051 ;;
7052 esac
7053 if $GREP "^installed=no" $deplib > /dev/null; then
7054 case $host in
7055 *-*-darwin*)
7056 depdepl=
7057 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
7058 if test -n "$deplibrary_names" ; then
7059 for tmp in $deplibrary_names ; do
7060 depdepl=$tmp
7061 done
7062 if test -f "$absdir/$objdir/$depdepl" ; then
7063 depdepl="$absdir/$objdir/$depdepl"
7064 darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7065 if test -z "$darwin_install_name"; then
7066 darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
7067 fi
7068 func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
7069 func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
7070 path=
7071 fi
7072 fi
7073 ;;
7074 *)
7075 path="-L$absdir/$objdir"
7076 ;;
7077 esac
7078 else
7079 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7080 test -z "$libdir" && \
7081 func_fatal_error "\`$deplib' is not a valid libtool archive"
7082 test "$absdir" != "$libdir" && \
7083 func_warning "\`$deplib' seems to be moved"
7084
7085 path="-L$absdir"
7086 fi
7087 ;;
7088 esac
7089 case " $deplibs " in
7090 *" $path "*) ;;
7091 *) deplibs="$path $deplibs" ;;
7092 esac
7093 done
7094 fi # link_all_deplibs != no
7095 fi # linkmode = lib
7096 done # for deplib in $libs
7097 if test "$pass" = link; then
7098 if test "$linkmode" = "prog"; then
7099 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
7100 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
7101 else
7102 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7103 fi
7104 fi
7105 dependency_libs="$newdependency_libs"
7106 if test "$pass" = dlpreopen; then
7107 # Link the dlpreopened libraries before other libraries
7108 for deplib in $save_deplibs; do
7109 deplibs="$deplib $deplibs"
7110 done
7111 fi
7112 if test "$pass" != dlopen; then
7113 if test "$pass" != conv; then
7114 # Make sure lib_search_path contains only unique directories.
7115 lib_search_path=
7116 for dir in $newlib_search_path; do
7117 case "$lib_search_path " in
7118 *" $dir "*) ;;
7119 *) func_append lib_search_path " $dir" ;;
7120 esac
7121 done
7122 newlib_search_path=
7123 fi
7124
7125 if test "$linkmode,$pass" != "prog,link"; then
7126 vars="deplibs"
7127 else
7128 vars="compile_deplibs finalize_deplibs"
7129 fi
7130 for var in $vars dependency_libs; do
7131 # Add libraries to $var in reverse order
7132 eval tmp_libs=\"\$$var\"
7133 new_libs=
7134 for deplib in $tmp_libs; do
7135 # FIXME: Pedantically, this is the right thing to do, so
7136 # that some nasty dependency loop isn't accidentally
7137 # broken:
7138 #new_libs="$deplib $new_libs"
7139 # Pragmatically, this seems to cause very few problems in
7140 # practice:
7141 case $deplib in
7142 -L*) new_libs="$deplib $new_libs" ;;
7143 -R*) ;;
7144 *)
7145 # And here is the reason: when a library appears more
7146 # than once as an explicit dependence of a library, or
7147 # is implicitly linked in more than once by the
7148 # compiler, it is considered special, and multiple
7149 # occurrences thereof are not removed. Compare this
7150 # with having the same library being listed as a
7151 # dependency of multiple other libraries: in this case,
7152 # we know (pedantically, we assume) the library does not
7153 # need to be listed more than once, so we keep only the
7154 # last copy. This is not always right, but it is rare
7155 # enough that we require users that really mean to play
7156 # such unportable linking tricks to link the library
7157 # using -Wl,-lname, so that libtool does not consider it
7158 # for duplicate removal.
7159 case " $specialdeplibs " in
7160 *" $deplib "*) new_libs="$deplib $new_libs" ;;
7161 *)
7162 case " $new_libs " in
7163 *" $deplib "*) ;;
7164 *) new_libs="$deplib $new_libs" ;;
7165 esac
7166 ;;
7167 esac
7168 ;;
7169 esac
7170 done
7171 tmp_libs=
7172 for deplib in $new_libs; do
7173 case $deplib in
7174 -L*)
7175 case " $tmp_libs " in
7176 *" $deplib "*) ;;
7177 *) func_append tmp_libs " $deplib" ;;
7178 esac
7179 ;;
7180 *) func_append tmp_libs " $deplib" ;;
7181 esac
7182 done
7183 eval $var=\"$tmp_libs\"
7184 done # for var
7185 fi
7186 # Last step: remove runtime libs from dependency_libs
7187 # (they stay in deplibs)
7188 tmp_libs=
7189 for i in $dependency_libs ; do
7190 case " $predeps $postdeps $compiler_lib_search_path " in
7191 *" $i "*)
7192 i=""
7193 ;;
7194 esac
7195 if test -n "$i" ; then
7196 func_append tmp_libs " $i"
7197 fi
7198 done
7199 dependency_libs=$tmp_libs
7200 done # for pass
7201 if test "$linkmode" = prog; then
7202 dlfiles="$newdlfiles"
7203 fi
7204 if test "$linkmode" = prog || test "$linkmode" = lib; then
7205 dlprefiles="$newdlprefiles"
7206 fi
7207
7208 case $linkmode in
7209 oldlib)
7210 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7211 func_warning "\`-dlopen' is ignored for archives"
7212 fi
7213
7214 case " $deplibs" in
7215 *\ -l* | *\ -L*)
7216 func_warning "\`-l' and \`-L' are ignored for archives" ;;
7217 esac
7218
7219 test -n "$rpath" && \
7220 func_warning "\`-rpath' is ignored for archives"
7221
7222 test -n "$xrpath" && \
7223 func_warning "\`-R' is ignored for archives"
7224
7225 test -n "$vinfo" && \
7226 func_warning "\`-version-info/-version-number' is ignored for archives"
7227
7228 test -n "$release" && \
7229 func_warning "\`-release' is ignored for archives"
7230
7231 test -n "$export_symbols$export_symbols_regex" && \
7232 func_warning "\`-export-symbols' is ignored for archives"
7233
7234 # Now set the variables for building old libraries.
7235 build_libtool_libs=no
7236 oldlibs="$output"
7237 func_append objs "$old_deplibs"
7238 ;;
7239
7240 lib)
7241 # Make sure we only generate libraries of the form `libNAME.la'.
7242 case $outputname in
7243 lib*)
7244 func_stripname 'lib' '.la' "$outputname"
7245 name=$func_stripname_result
7246 eval shared_ext=\"$shrext_cmds\"
7247 eval libname=\"$libname_spec\"
7248 ;;
7249 *)
7250 test "$module" = no && \
7251 func_fatal_help "libtool library \`$output' must begin with \`lib'"
7252
7253 if test "$need_lib_prefix" != no; then
7254 # Add the "lib" prefix for modules if required
7255 func_stripname '' '.la' "$outputname"
7256 name=$func_stripname_result
7257 eval shared_ext=\"$shrext_cmds\"
7258 eval libname=\"$libname_spec\"
7259 else
7260 func_stripname '' '.la' "$outputname"
7261 libname=$func_stripname_result
7262 fi
7263 ;;
7264 esac
7265
7266 if test -n "$objs"; then
7267 if test "$deplibs_check_method" != pass_all; then
7268 func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
7269 else
7270 echo
7271 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
7272 $ECHO "*** objects $objs is not portable!"
7273 func_append libobjs " $objs"
7274 fi
7275 fi
7276
7277 test "$dlself" != no && \
7278 func_warning "\`-dlopen self' is ignored for libtool libraries"
7279
7280 set dummy $rpath
7281 shift
7282 test "$#" -gt 1 && \
7283 func_warning "ignoring multiple \`-rpath's for a libtool library"
7284
7285 install_libdir="$1"
7286
7287 oldlibs=
7288 if test -z "$rpath"; then
7289 if test "$build_libtool_libs" = yes; then
7290 # Building a libtool convenience library.
7291 # Some compilers have problems with a `.al' extension so
7292 # convenience libraries should have the same extension an
7293 # archive normally would.
7294 oldlibs="$output_objdir/$libname.$libext $oldlibs"
7295 build_libtool_libs=convenience
7296 build_old_libs=yes
7297 fi
7298
7299 test -n "$vinfo" && \
7300 func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
7301
7302 test -n "$release" && \
7303 func_warning "\`-release' is ignored for convenience libraries"
7304 else
7305
7306 # Parse the version information argument.
7307 save_ifs="$IFS"; IFS=':'
7308 set dummy $vinfo 0 0 0
7309 shift
7310 IFS="$save_ifs"
7311
7312 test -n "$7" && \
7313 func_fatal_help "too many parameters to \`-version-info'"
7314
7315 # convert absolute version numbers to libtool ages
7316 # this retains compatibility with .la files and attempts
7317 # to make the code below a bit more comprehensible
7318
7319 case $vinfo_number in
7320 yes)
7321 number_major="$1"
7322 number_minor="$2"
7323 number_revision="$3"
7324 #
7325 # There are really only two kinds -- those that
7326 # use the current revision as the major version
7327 # and those that subtract age and use age as
7328 # a minor version. But, then there is irix
7329 # which has an extra 1 added just for fun
7330 #
7331 case $version_type in
7332 # correct linux to gnu/linux during the next big refactor
7333 darwin|linux|osf|windows|none)
7334 func_arith $number_major + $number_minor
7335 current=$func_arith_result
7336 age="$number_minor"
7337 revision="$number_revision"
7338 ;;
7339 freebsd-aout|freebsd-elf|qnx|sunos)
7340 current="$number_major"
7341 revision="$number_minor"
7342 age="0"
7343 ;;
7344 irix|nonstopux)
7345 func_arith $number_major + $number_minor
7346 current=$func_arith_result
7347 age="$number_minor"
7348 revision="$number_minor"
7349 lt_irix_increment=no
7350 ;;
7351 esac
7352 ;;
7353 no)
7354 current="$1"
7355 revision="$2"
7356 age="$3"
7357 ;;
7358 esac
7359
7360 # Check that each of the things are valid numbers.
7361 case $current in
7362 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
7363 *)
7364 func_error "CURRENT \`$current' must be a nonnegative integer"
7365 func_fatal_error "\`$vinfo' is not valid version information"
7366 ;;
7367 esac
7368
7369 case $revision in
7370 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
7371 *)
7372 func_error "REVISION \`$revision' must be a nonnegative integer"
7373 func_fatal_error "\`$vinfo' is not valid version information"
7374 ;;
7375 esac
7376
7377 case $age in
7378 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
7379 *)
7380 func_error "AGE \`$age' must be a nonnegative integer"
7381 func_fatal_error "\`$vinfo' is not valid version information"
7382 ;;
7383 esac
7384
7385 if test "$age" -gt "$current"; then
7386 func_error "AGE \`$age' is greater than the current interface number \`$current'"
7387 func_fatal_error "\`$vinfo' is not valid version information"
7388 fi
7389
7390 # Calculate the version variables.
7391 major=
7392 versuffix=
7393 verstring=
7394 case $version_type in
7395 none) ;;
7396
7397 darwin)
7398 # Like Linux, but with the current version available in
7399 # verstring for coding it into the library header
7400 func_arith $current - $age
7401 major=.$func_arith_result
7402 versuffix="$major.$age.$revision"
7403 # Darwin ld doesn't like 0 for these options...
7404 func_arith $current + 1
7405 minor_current=$func_arith_result
7406 xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
7407 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
7408 ;;
7409
7410 freebsd-aout)
7411 major=".$current"
7412 versuffix=".$current.$revision";
7413 ;;
7414
7415 freebsd-elf)
7416 major=".$current"
7417 versuffix=".$current"
7418 ;;
7419
7420 irix | nonstopux)
7421 if test "X$lt_irix_increment" = "Xno"; then
7422 func_arith $current - $age
7423 else
7424 func_arith $current - $age + 1
7425 fi
7426 major=$func_arith_result
7427
7428 case $version_type in
7429 nonstopux) verstring_prefix=nonstopux ;;
7430 *) verstring_prefix=sgi ;;
7431 esac
7432 verstring="$verstring_prefix$major.$revision"
7433
7434 # Add in all the interfaces that we are compatible with.
7435 loop=$revision
7436 while test "$loop" -ne 0; do
7437 func_arith $revision - $loop
7438 iface=$func_arith_result
7439 func_arith $loop - 1
7440 loop=$func_arith_result
7441 verstring="$verstring_prefix$major.$iface:$verstring"
7442 done
7443
7444 # Before this point, $major must not contain `.'.
7445 major=.$major
7446 versuffix="$major.$revision"
7447 ;;
7448
7449 linux) # correct to gnu/linux during the next big refactor
7450 func_arith $current - $age
7451 major=.$func_arith_result
7452 versuffix="$major.$age.$revision"
7453 ;;
7454
7455 osf)
7456 func_arith $current - $age
7457 major=.$func_arith_result
7458 versuffix=".$current.$age.$revision"
7459 verstring="$current.$age.$revision"
7460
7461 # Add in all the interfaces that we are compatible with.
7462 loop=$age
7463 while test "$loop" -ne 0; do
7464 func_arith $current - $loop
7465 iface=$func_arith_result
7466 func_arith $loop - 1
7467 loop=$func_arith_result
7468 verstring="$verstring:${iface}.0"
7469 done
7470
7471 # Make executables depend on our current version.
7472 func_append verstring ":${current}.0"
7473 ;;
7474
7475 qnx)
7476 major=".$current"
7477 versuffix=".$current"
7478 ;;
7479
7480 sunos)
7481 major=".$current"
7482 versuffix=".$current.$revision"
7483 ;;
7484
7485 windows)
7486 # Use '-' rather than '.', since we only want one
7487 # extension on DOS 8.3 filesystems.
7488 func_arith $current - $age
7489 major=$func_arith_result
7490 versuffix="-$major"
7491 ;;
7492
7493 *)
7494 func_fatal_configuration "unknown library version type \`$version_type'"
7495 ;;
7496 esac
7497
7498 # Clear the version info if we defaulted, and they specified a release.
7499 if test -z "$vinfo" && test -n "$release"; then
7500 major=
7501 case $version_type in
7502 darwin)
7503 # we can't check for "0.0" in archive_cmds due to quoting
7504 # problems, so we reset it completely
7505 verstring=
7506 ;;
7507 *)
7508 verstring="0.0"
7509 ;;
7510 esac
7511 if test "$need_version" = no; then
7512 versuffix=
7513 else
7514 versuffix=".0.0"
7515 fi
7516 fi
7517
7518 # Remove version info from name if versioning should be avoided
7519 if test "$avoid_version" = yes && test "$need_version" = no; then
7520 major=
7521 versuffix=
7522 verstring=""
7523 fi
7524
7525 # Check to see if the archive will have undefined symbols.
7526 if test "$allow_undefined" = yes; then
7527 if test "$allow_undefined_flag" = unsupported; then
7528 func_warning "undefined symbols not allowed in $host shared libraries"
7529 build_libtool_libs=no
7530 build_old_libs=yes
7531 fi
7532 else
7533 # Don't allow undefined symbols.
7534 allow_undefined_flag="$no_undefined_flag"
7535 fi
7536
7537 fi
7538
7539 func_generate_dlsyms "$libname" "$libname" "yes"
7540 func_append libobjs " $symfileobj"
7541 test "X$libobjs" = "X " && libobjs=
7542
7543 if test "$opt_mode" != relink; then
7544 # Remove our outputs, but don't remove object files since they
7545 # may have been created when compiling PIC objects.
7546 removelist=
7547 tempremovelist=`$ECHO "$output_objdir/*"`
7548 for p in $tempremovelist; do
7549 case $p in
7550 *.$objext | *.gcno)
7551 ;;
7552 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
7553 if test "X$precious_files_regex" != "X"; then
7554 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
7555 then
7556 continue
7557 fi
7558 fi
7559 func_append removelist " $p"
7560 ;;
7561 *) ;;
7562 esac
7563 done
7564 test -n "$removelist" && \
7565 func_show_eval "${RM}r \$removelist"
7566 fi
7567
7568 # Now set the variables for building old libraries.
7569 if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
7570 func_append oldlibs " $output_objdir/$libname.$libext"
7571
7572 # Transform .lo files to .o files.
7573 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
7574 fi
7575
7576 # Eliminate all temporary directories.
7577 #for path in $notinst_path; do
7578 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
7579 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
7580 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
7581 #done
7582
7583 if test -n "$xrpath"; then
7584 # If the user specified any rpath flags, then add them.
7585 temp_xrpath=
7586 for libdir in $xrpath; do
7587 func_replace_sysroot "$libdir"
7588 func_append temp_xrpath " -R$func_replace_sysroot_result"
7589 case "$finalize_rpath " in
7590 *" $libdir "*) ;;
7591 *) func_append finalize_rpath " $libdir" ;;
7592 esac
7593 done
7594 if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
7595 dependency_libs="$temp_xrpath $dependency_libs"
7596 fi
7597 fi
7598
7599 # Make sure dlfiles contains only unique files that won't be dlpreopened
7600 old_dlfiles="$dlfiles"
7601 dlfiles=
7602 for lib in $old_dlfiles; do
7603 case " $dlprefiles $dlfiles " in
7604 *" $lib "*) ;;
7605 *) func_append dlfiles " $lib" ;;
7606 esac
7607 done
7608
7609 # Make sure dlprefiles contains only unique files
7610 old_dlprefiles="$dlprefiles"
7611 dlprefiles=
7612 for lib in $old_dlprefiles; do
7613 case "$dlprefiles " in
7614 *" $lib "*) ;;
7615 *) func_append dlprefiles " $lib" ;;
7616 esac
7617 done
7618
7619 if test "$build_libtool_libs" = yes; then
7620 if test -n "$rpath"; then
7621 case $host in
7622 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
7623 # these systems don't actually have a c library (as such)!
7624 ;;
7625 *-*-rhapsody* | *-*-darwin1.[012])
7626 # Rhapsody C library is in the System framework
7627 func_append deplibs " System.ltframework"
7628 ;;
7629 *-*-netbsd*)
7630 # Don't link with libc until the a.out ld.so is fixed.
7631 ;;
7632 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
7633 # Do not include libc due to us having libc/libc_r.
7634 ;;
7635 *-*-sco3.2v5* | *-*-sco5v6*)
7636 # Causes problems with __ctype
7637 ;;
7638 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
7639 # Compiler inserts libc in the correct place for threads to work
7640 ;;
7641 *)
7642 # Add libc to deplibs on all other systems if necessary.
7643 if test "$build_libtool_need_lc" = "yes"; then
7644 func_append deplibs " -lc"
7645 fi
7646 ;;
7647 esac
7648 fi
7649
7650 # Transform deplibs into only deplibs that can be linked in shared.
7651 name_save=$name
7652 libname_save=$libname
7653 release_save=$release
7654 versuffix_save=$versuffix
7655 major_save=$major
7656 # I'm not sure if I'm treating the release correctly. I think
7657 # release should show up in the -l (ie -lgmp5) so we don't want to
7658 # add it in twice. Is that correct?
7659 release=""
7660 versuffix=""
7661 major=""
7662 newdeplibs=
7663 droppeddeps=no
7664 case $deplibs_check_method in
7665 pass_all)
7666 # Don't check for shared/static. Everything works.
7667 # This might be a little naive. We might want to check
7668 # whether the library exists or not. But this is on
7669 # osf3 & osf4 and I'm not really sure... Just
7670 # implementing what was already the behavior.
7671 newdeplibs=$deplibs
7672 ;;
7673 test_compile)
7674 # This code stresses the "libraries are programs" paradigm to its
7675 # limits. Maybe even breaks it. We compile a program, linking it
7676 # against the deplibs as a proxy for the library. Then we can check
7677 # whether they linked in statically or dynamically with ldd.
7678 $opt_dry_run || $RM conftest.c
7679 cat > conftest.c <<EOF
7680 int main() { return 0; }
7681 EOF
7682 $opt_dry_run || $RM conftest
7683 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
7684 ldd_output=`ldd conftest`
7685 for i in $deplibs; do
7686 case $i in
7687 -l*)
7688 func_stripname -l '' "$i"
7689 name=$func_stripname_result
7690 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7691 case " $predeps $postdeps " in
7692 *" $i "*)
7693 func_append newdeplibs " $i"
7694 i=""
7695 ;;
7696 esac
7697 fi
7698 if test -n "$i" ; then
7699 libname=`eval "\\$ECHO \"$libname_spec\""`
7700 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7701 set dummy $deplib_matches; shift
7702 deplib_match=$1
7703 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7704 func_append newdeplibs " $i"
7705 else
7706 droppeddeps=yes
7707 echo
7708 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7709 echo "*** I have the capability to make that library automatically link in when"
7710 echo "*** you link to this library. But I can only do this if you have a"
7711 echo "*** shared version of the library, which I believe you do not have"
7712 echo "*** because a test_compile did reveal that the linker did not use it for"
7713 echo "*** its dynamic dependency list that programs get resolved with at runtime."
7714 fi
7715 fi
7716 ;;
7717 *)
7718 func_append newdeplibs " $i"
7719 ;;
7720 esac
7721 done
7722 else
7723 # Error occurred in the first compile. Let's try to salvage
7724 # the situation: Compile a separate program for each library.
7725 for i in $deplibs; do
7726 case $i in
7727 -l*)
7728 func_stripname -l '' "$i"
7729 name=$func_stripname_result
7730 $opt_dry_run || $RM conftest
7731 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
7732 ldd_output=`ldd conftest`
7733 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7734 case " $predeps $postdeps " in
7735 *" $i "*)
7736 func_append newdeplibs " $i"
7737 i=""
7738 ;;
7739 esac
7740 fi
7741 if test -n "$i" ; then
7742 libname=`eval "\\$ECHO \"$libname_spec\""`
7743 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
7744 set dummy $deplib_matches; shift
7745 deplib_match=$1
7746 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
7747 func_append newdeplibs " $i"
7748 else
7749 droppeddeps=yes
7750 echo
7751 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
7752 echo "*** I have the capability to make that library automatically link in when"
7753 echo "*** you link to this library. But I can only do this if you have a"
7754 echo "*** shared version of the library, which you do not appear to have"
7755 echo "*** because a test_compile did reveal that the linker did not use this one"
7756 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
7757 fi
7758 fi
7759 else
7760 droppeddeps=yes
7761 echo
7762 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
7763 echo "*** make it link in! You will probably need to install it or some"
7764 echo "*** library that it depends on before this library will be fully"
7765 echo "*** functional. Installing it before continuing would be even better."
7766 fi
7767 ;;
7768 *)
7769 func_append newdeplibs " $i"
7770 ;;
7771 esac
7772 done
7773 fi
7774 ;;
7775 file_magic*)
7776 set dummy $deplibs_check_method; shift
7777 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7778 for a_deplib in $deplibs; do
7779 case $a_deplib in
7780 -l*)
7781 func_stripname -l '' "$a_deplib"
7782 name=$func_stripname_result
7783 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7784 case " $predeps $postdeps " in
7785 *" $a_deplib "*)
7786 func_append newdeplibs " $a_deplib"
7787 a_deplib=""
7788 ;;
7789 esac
7790 fi
7791 if test -n "$a_deplib" ; then
7792 libname=`eval "\\$ECHO \"$libname_spec\""`
7793 if test -n "$file_magic_glob"; then
7794 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
7795 else
7796 libnameglob=$libname
7797 fi
7798 test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
7799 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7800 if test "$want_nocaseglob" = yes; then
7801 shopt -s nocaseglob
7802 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7803 $nocaseglob
7804 else
7805 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
7806 fi
7807 for potent_lib in $potential_libs; do
7808 # Follow soft links.
7809 if ls -lLd "$potent_lib" 2>/dev/null |
7810 $GREP " -> " >/dev/null; then
7811 continue
7812 fi
7813 # The statement above tries to avoid entering an
7814 # endless loop below, in case of cyclic links.
7815 # We might still enter an endless loop, since a link
7816 # loop can be closed while we follow links,
7817 # but so what?
7818 potlib="$potent_lib"
7819 while test -h "$potlib" 2>/dev/null; do
7820 potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
7821 case $potliblink in
7822 [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
7823 *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
7824 esac
7825 done
7826 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
7827 $SED -e 10q |
7828 $EGREP "$file_magic_regex" > /dev/null; then
7829 func_append newdeplibs " $a_deplib"
7830 a_deplib=""
7831 break 2
7832 fi
7833 done
7834 done
7835 fi
7836 if test -n "$a_deplib" ; then
7837 droppeddeps=yes
7838 echo
7839 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7840 echo "*** I have the capability to make that library automatically link in when"
7841 echo "*** you link to this library. But I can only do this if you have a"
7842 echo "*** shared version of the library, which you do not appear to have"
7843 echo "*** because I did check the linker path looking for a file starting"
7844 if test -z "$potlib" ; then
7845 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
7846 else
7847 $ECHO "*** with $libname and none of the candidates passed a file format test"
7848 $ECHO "*** using a file magic. Last file checked: $potlib"
7849 fi
7850 fi
7851 ;;
7852 *)
7853 # Add a -L argument.
7854 func_append newdeplibs " $a_deplib"
7855 ;;
7856 esac
7857 done # Gone through all deplibs.
7858 ;;
7859 match_pattern*)
7860 set dummy $deplibs_check_method; shift
7861 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
7862 for a_deplib in $deplibs; do
7863 case $a_deplib in
7864 -l*)
7865 func_stripname -l '' "$a_deplib"
7866 name=$func_stripname_result
7867 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7868 case " $predeps $postdeps " in
7869 *" $a_deplib "*)
7870 func_append newdeplibs " $a_deplib"
7871 a_deplib=""
7872 ;;
7873 esac
7874 fi
7875 if test -n "$a_deplib" ; then
7876 libname=`eval "\\$ECHO \"$libname_spec\""`
7877 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
7878 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
7879 for potent_lib in $potential_libs; do
7880 potlib="$potent_lib" # see symlink-check above in file_magic test
7881 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
7882 $EGREP "$match_pattern_regex" > /dev/null; then
7883 func_append newdeplibs " $a_deplib"
7884 a_deplib=""
7885 break 2
7886 fi
7887 done
7888 done
7889 fi
7890 if test -n "$a_deplib" ; then
7891 droppeddeps=yes
7892 echo
7893 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
7894 echo "*** I have the capability to make that library automatically link in when"
7895 echo "*** you link to this library. But I can only do this if you have a"
7896 echo "*** shared version of the library, which you do not appear to have"
7897 echo "*** because I did check the linker path looking for a file starting"
7898 if test -z "$potlib" ; then
7899 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
7900 else
7901 $ECHO "*** with $libname and none of the candidates passed a file format test"
7902 $ECHO "*** using a regex pattern. Last file checked: $potlib"
7903 fi
7904 fi
7905 ;;
7906 *)
7907 # Add a -L argument.
7908 func_append newdeplibs " $a_deplib"
7909 ;;
7910 esac
7911 done # Gone through all deplibs.
7912 ;;
7913 none | unknown | *)
7914 newdeplibs=""
7915 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
7916 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
7917 for i in $predeps $postdeps ; do
7918 # can't use Xsed below, because $i might contain '/'
7919 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
7920 done
7921 fi
7922 case $tmp_deplibs in
7923 *[!\ \ ]*)
7924 echo
7925 if test "X$deplibs_check_method" = "Xnone"; then
7926 echo "*** Warning: inter-library dependencies are not supported in this platform."
7927 else
7928 echo "*** Warning: inter-library dependencies are not known to be supported."
7929 fi
7930 echo "*** All declared inter-library dependencies are being dropped."
7931 droppeddeps=yes
7932 ;;
7933 esac
7934 ;;
7935 esac
7936 versuffix=$versuffix_save
7937 major=$major_save
7938 release=$release_save
7939 libname=$libname_save
7940 name=$name_save
7941
7942 case $host in
7943 *-*-rhapsody* | *-*-darwin1.[012])
7944 # On Rhapsody replace the C library with the System framework
7945 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
7946 ;;
7947 esac
7948
7949 if test "$droppeddeps" = yes; then
7950 if test "$module" = yes; then
7951 echo
7952 echo "*** Warning: libtool could not satisfy all declared inter-library"
7953 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
7954 echo "*** a static module, that should work as long as the dlopening"
7955 echo "*** application is linked with the -dlopen flag."
7956 if test -z "$global_symbol_pipe"; then
7957 echo
7958 echo "*** However, this would only work if libtool was able to extract symbol"
7959 echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
7960 echo "*** not find such a program. So, this module is probably useless."
7961 echo "*** \`nm' from GNU binutils and a full rebuild may help."
7962 fi
7963 if test "$build_old_libs" = no; then
7964 oldlibs="$output_objdir/$libname.$libext"
7965 build_libtool_libs=module
7966 build_old_libs=yes
7967 else
7968 build_libtool_libs=no
7969 fi
7970 else
7971 echo "*** The inter-library dependencies that have been dropped here will be"
7972 echo "*** automatically added whenever a program is linked with this library"
7973 echo "*** or is declared to -dlopen it."
7974
7975 if test "$allow_undefined" = no; then
7976 echo
7977 echo "*** Since this library must not contain undefined symbols,"
7978 echo "*** because either the platform does not support them or"
7979 echo "*** it was explicitly requested with -no-undefined,"
7980 echo "*** libtool will only create a static version of it."
7981 if test "$build_old_libs" = no; then
7982 oldlibs="$output_objdir/$libname.$libext"
7983 build_libtool_libs=module
7984 build_old_libs=yes
7985 else
7986 build_libtool_libs=no
7987 fi
7988 fi
7989 fi
7990 fi
7991 # Done checking deplibs!
7992 deplibs=$newdeplibs
7993 fi
7994 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7995 case $host in
7996 *-*-darwin*)
7997 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7998 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
7999 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8000 ;;
8001 esac
8002
8003 # move library search paths that coincide with paths to not yet
8004 # installed libraries to the beginning of the library search list
8005 new_libs=
8006 for path in $notinst_path; do
8007 case " $new_libs " in
8008 *" -L$path/$objdir "*) ;;
8009 *)
8010 case " $deplibs " in
8011 *" -L$path/$objdir "*)
8012 func_append new_libs " -L$path/$objdir" ;;
8013 esac
8014 ;;
8015 esac
8016 done
8017 for deplib in $deplibs; do
8018 case $deplib in
8019 -L*)
8020 case " $new_libs " in
8021 *" $deplib "*) ;;
8022 *) func_append new_libs " $deplib" ;;
8023 esac
8024 ;;
8025 *) func_append new_libs " $deplib" ;;
8026 esac
8027 done
8028 deplibs="$new_libs"
8029
8030 # All the library-specific variables (install_libdir is set above).
8031 library_names=
8032 old_library=
8033 dlname=
8034
8035 # Test again, we may have decided not to build it any more
8036 if test "$build_libtool_libs" = yes; then
8037 # Remove ${wl} instances when linking with ld.
8038 # FIXME: should test the right _cmds variable.
8039 case $archive_cmds in
8040 *\$LD\ *) wl= ;;
8041 esac
8042 if test "$hardcode_into_libs" = yes; then
8043 # Hardcode the library paths
8044 hardcode_libdirs=
8045 dep_rpath=
8046 rpath="$finalize_rpath"
8047 test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
8048 for libdir in $rpath; do
8049 if test -n "$hardcode_libdir_flag_spec"; then
8050 if test -n "$hardcode_libdir_separator"; then
8051 func_replace_sysroot "$libdir"
8052 libdir=$func_replace_sysroot_result
8053 if test -z "$hardcode_libdirs"; then
8054 hardcode_libdirs="$libdir"
8055 else
8056 # Just accumulate the unique libdirs.
8057 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8058 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8059 ;;
8060 *)
8061 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8062 ;;
8063 esac
8064 fi
8065 else
8066 eval flag=\"$hardcode_libdir_flag_spec\"
8067 func_append dep_rpath " $flag"
8068 fi
8069 elif test -n "$runpath_var"; then
8070 case "$perm_rpath " in
8071 *" $libdir "*) ;;
8072 *) func_append perm_rpath " $libdir" ;;
8073 esac
8074 fi
8075 done
8076 # Substitute the hardcoded libdirs into the rpath.
8077 if test -n "$hardcode_libdir_separator" &&
8078 test -n "$hardcode_libdirs"; then
8079 libdir="$hardcode_libdirs"
8080 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
8081 fi
8082 if test -n "$runpath_var" && test -n "$perm_rpath"; then
8083 # We should set the runpath_var.
8084 rpath=
8085 for dir in $perm_rpath; do
8086 func_append rpath "$dir:"
8087 done
8088 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
8089 fi
8090 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
8091 fi
8092
8093 shlibpath="$finalize_shlibpath"
8094 test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
8095 if test -n "$shlibpath"; then
8096 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
8097 fi
8098
8099 # Get the real and link names of the library.
8100 eval shared_ext=\"$shrext_cmds\"
8101 eval library_names=\"$library_names_spec\"
8102 set dummy $library_names
8103 shift
8104 realname="$1"
8105 shift
8106
8107 if test -n "$soname_spec"; then
8108 eval soname=\"$soname_spec\"
8109 else
8110 soname="$realname"
8111 fi
8112 if test -z "$dlname"; then
8113 dlname=$soname
8114 fi
8115
8116 lib="$output_objdir/$realname"
8117 linknames=
8118 for link
8119 do
8120 func_append linknames " $link"
8121 done
8122
8123 # Use standard objects if they are pic
8124 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
8125 test "X$libobjs" = "X " && libobjs=
8126
8127 delfiles=
8128 if test -n "$export_symbols" && test -n "$include_expsyms"; then
8129 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
8130 export_symbols="$output_objdir/$libname.uexp"
8131 func_append delfiles " $export_symbols"
8132 fi
8133
8134 orig_export_symbols=
8135 case $host_os in
8136 cygwin* | mingw* | cegcc*)
8137 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
8138 # exporting using user supplied symfile
8139 if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
8140 # and it's NOT already a .def file. Must figure out
8141 # which of the given symbols are data symbols and tag
8142 # them as such. So, trigger use of export_symbols_cmds.
8143 # export_symbols gets reassigned inside the "prepare
8144 # the list of exported symbols" if statement, so the
8145 # include_expsyms logic still works.
8146 orig_export_symbols="$export_symbols"
8147 export_symbols=
8148 always_export_symbols=yes
8149 fi
8150 fi
8151 ;;
8152 esac
8153
8154 # Prepare the list of exported symbols
8155 if test -z "$export_symbols"; then
8156 if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
8157 func_verbose "generating symbol list for \`$libname.la'"
8158 export_symbols="$output_objdir/$libname.exp"
8159 $opt_dry_run || $RM $export_symbols
8160 cmds=$export_symbols_cmds
8161 save_ifs="$IFS"; IFS='~'
8162 for cmd1 in $cmds; do
8163 IFS="$save_ifs"
8164 # Take the normal branch if the nm_file_list_spec branch
8165 # doesn't work or if tool conversion is not needed.
8166 case $nm_file_list_spec~$to_tool_file_cmd in
8167 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
8168 try_normal_branch=yes
8169 eval cmd=\"$cmd1\"
8170 func_len " $cmd"
8171 len=$func_len_result
8172 ;;
8173 *)
8174 try_normal_branch=no
8175 ;;
8176 esac
8177 if test "$try_normal_branch" = yes \
8178 && { test "$len" -lt "$max_cmd_len" \
8179 || test "$max_cmd_len" -le -1; }
8180 then
8181 func_show_eval "$cmd" 'exit $?'
8182 skipped_export=false
8183 elif test -n "$nm_file_list_spec"; then
8184 func_basename "$output"
8185 output_la=$func_basename_result
8186 save_libobjs=$libobjs
8187 save_output=$output
8188 output=${output_objdir}/${output_la}.nm
8189 func_to_tool_file "$output"
8190 libobjs=$nm_file_list_spec$func_to_tool_file_result
8191 func_append delfiles " $output"
8192 func_verbose "creating $NM input file list: $output"
8193 for obj in $save_libobjs; do
8194 func_to_tool_file "$obj"
8195 $ECHO "$func_to_tool_file_result"
8196 done > "$output"
8197 eval cmd=\"$cmd1\"
8198 func_show_eval "$cmd" 'exit $?'
8199 output=$save_output
8200 libobjs=$save_libobjs
8201 skipped_export=false
8202 else
8203 # The command line is too long to execute in one step.
8204 func_verbose "using reloadable object file for export list..."
8205 skipped_export=:
8206 # Break out early, otherwise skipped_export may be
8207 # set to false by a later but shorter cmd.
8208 break
8209 fi
8210 done
8211 IFS="$save_ifs"
8212 if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
8213 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8214 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8215 fi
8216 fi
8217 fi
8218
8219 if test -n "$export_symbols" && test -n "$include_expsyms"; then
8220 tmp_export_symbols="$export_symbols"
8221 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8222 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8223 fi
8224
8225 if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
8226 # The given exports_symbols file has to be filtered, so filter it.
8227 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8228 # FIXME: $output_objdir/$libname.filter potentially contains lots of
8229 # 's' commands which not all seds can handle. GNU sed should be fine
8230 # though. Also, the filter scales superlinearly with the number of
8231 # global variables. join(1) would be nice here, but unfortunately
8232 # isn't a blessed tool.
8233 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8234 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8235 export_symbols=$output_objdir/$libname.def
8236 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8237 fi
8238
8239 tmp_deplibs=
8240 for test_deplib in $deplibs; do
8241 case " $convenience " in
8242 *" $test_deplib "*) ;;
8243 *)
8244 func_append tmp_deplibs " $test_deplib"
8245 ;;
8246 esac
8247 done
8248 deplibs="$tmp_deplibs"
8249
8250 if test -n "$convenience"; then
8251 if test -n "$whole_archive_flag_spec" &&
8252 test "$compiler_needs_object" = yes &&
8253 test -z "$libobjs"; then
8254 # extract the archives, so we have objects to list.
8255 # TODO: could optimize this to just extract one archive.
8256 whole_archive_flag_spec=
8257 fi
8258 if test -n "$whole_archive_flag_spec"; then
8259 save_libobjs=$libobjs
8260 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8261 test "X$libobjs" = "X " && libobjs=
8262 else
8263 gentop="$output_objdir/${outputname}x"
8264 func_append generated " $gentop"
8265
8266 func_extract_archives $gentop $convenience
8267 func_append libobjs " $func_extract_archives_result"
8268 test "X$libobjs" = "X " && libobjs=
8269 fi
8270 fi
8271
8272 if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
8273 eval flag=\"$thread_safe_flag_spec\"
8274 func_append linker_flags " $flag"
8275 fi
8276
8277 # Make a backup of the uninstalled library when relinking
8278 if test "$opt_mode" = relink; then
8279 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
8280 fi
8281
8282 # Do each of the archive commands.
8283 if test "$module" = yes && test -n "$module_cmds" ; then
8284 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8285 eval test_cmds=\"$module_expsym_cmds\"
8286 cmds=$module_expsym_cmds
8287 else
8288 eval test_cmds=\"$module_cmds\"
8289 cmds=$module_cmds
8290 fi
8291 else
8292 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8293 eval test_cmds=\"$archive_expsym_cmds\"
8294 cmds=$archive_expsym_cmds
8295 else
8296 eval test_cmds=\"$archive_cmds\"
8297 cmds=$archive_cmds
8298 fi
8299 fi
8300
8301 if test "X$skipped_export" != "X:" &&
8302 func_len " $test_cmds" &&
8303 len=$func_len_result &&
8304 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8305 :
8306 else
8307 # The command line is too long to link in one step, link piecewise
8308 # or, if using GNU ld and skipped_export is not :, use a linker
8309 # script.
8310
8311 # Save the value of $output and $libobjs because we want to
8312 # use them later. If we have whole_archive_flag_spec, we
8313 # want to use save_libobjs as it was before
8314 # whole_archive_flag_spec was expanded, because we can't
8315 # assume the linker understands whole_archive_flag_spec.
8316 # This may have to be revisited, in case too many
8317 # convenience libraries get linked in and end up exceeding
8318 # the spec.
8319 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
8320 save_libobjs=$libobjs
8321 fi
8322 save_output=$output
8323 func_basename "$output"
8324 output_la=$func_basename_result
8325
8326 # Clear the reloadable object creation command queue and
8327 # initialize k to one.
8328 test_cmds=
8329 concat_cmds=
8330 objlist=
8331 last_robj=
8332 k=1
8333
8334 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
8335 output=${output_objdir}/${output_la}.lnkscript
8336 func_verbose "creating GNU ld script: $output"
8337 echo 'INPUT (' > $output
8338 for obj in $save_libobjs
8339 do
8340 func_to_tool_file "$obj"
8341 $ECHO "$func_to_tool_file_result" >> $output
8342 done
8343 echo ')' >> $output
8344 func_append delfiles " $output"
8345 func_to_tool_file "$output"
8346 output=$func_to_tool_file_result
8347 elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
8348 output=${output_objdir}/${output_la}.lnk
8349 func_verbose "creating linker input file list: $output"
8350 : > $output
8351 set x $save_libobjs
8352 shift
8353 firstobj=
8354 if test "$compiler_needs_object" = yes; then
8355 firstobj="$1 "
8356 shift
8357 fi
8358 for obj
8359 do
8360 func_to_tool_file "$obj"
8361 $ECHO "$func_to_tool_file_result" >> $output
8362 done
8363 func_append delfiles " $output"
8364 func_to_tool_file "$output"
8365 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
8366 else
8367 if test -n "$save_libobjs"; then
8368 func_verbose "creating reloadable object files..."
8369 output=$output_objdir/$output_la-${k}.$objext
8370 eval test_cmds=\"$reload_cmds\"
8371 func_len " $test_cmds"
8372 len0=$func_len_result
8373 len=$len0
8374
8375 # Loop over the list of objects to be linked.
8376 for obj in $save_libobjs
8377 do
8378 func_len " $obj"
8379 func_arith $len + $func_len_result
8380 len=$func_arith_result
8381 if test "X$objlist" = X ||
8382 test "$len" -lt "$max_cmd_len"; then
8383 func_append objlist " $obj"
8384 else
8385 # The command $test_cmds is almost too long, add a
8386 # command to the queue.
8387 if test "$k" -eq 1 ; then
8388 # The first file doesn't have a previous command to add.
8389 reload_objs=$objlist
8390 eval concat_cmds=\"$reload_cmds\"
8391 else
8392 # All subsequent reloadable object files will link in
8393 # the last one created.
8394 reload_objs="$objlist $last_robj"
8395 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
8396 fi
8397 last_robj=$output_objdir/$output_la-${k}.$objext
8398 func_arith $k + 1
8399 k=$func_arith_result
8400 output=$output_objdir/$output_la-${k}.$objext
8401 objlist=" $obj"
8402 func_len " $last_robj"
8403 func_arith $len0 + $func_len_result
8404 len=$func_arith_result
8405 fi
8406 done
8407 # Handle the remaining objects by creating one last
8408 # reloadable object file. All subsequent reloadable object
8409 # files will link in the last one created.
8410 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8411 reload_objs="$objlist $last_robj"
8412 eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
8413 if test -n "$last_robj"; then
8414 eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
8415 fi
8416 func_append delfiles " $output"
8417
8418 else
8419 output=
8420 fi
8421
8422 if ${skipped_export-false}; then
8423 func_verbose "generating symbol list for \`$libname.la'"
8424 export_symbols="$output_objdir/$libname.exp"
8425 $opt_dry_run || $RM $export_symbols
8426 libobjs=$output
8427 # Append the command to create the export file.
8428 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8429 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
8430 if test -n "$last_robj"; then
8431 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
8432 fi
8433 fi
8434
8435 test -n "$save_libobjs" &&
8436 func_verbose "creating a temporary reloadable object file: $output"
8437
8438 # Loop through the commands generated above and execute them.
8439 save_ifs="$IFS"; IFS='~'
8440 for cmd in $concat_cmds; do
8441 IFS="$save_ifs"
8442 $opt_silent || {
8443 func_quote_for_expand "$cmd"
8444 eval "func_echo $func_quote_for_expand_result"
8445 }
8446 $opt_dry_run || eval "$cmd" || {
8447 lt_exit=$?
8448
8449 # Restore the uninstalled library and exit
8450 if test "$opt_mode" = relink; then
8451 ( cd "$output_objdir" && \
8452 $RM "${realname}T" && \
8453 $MV "${realname}U" "$realname" )
8454 fi
8455
8456 exit $lt_exit
8457 }
8458 done
8459 IFS="$save_ifs"
8460
8461 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
8462 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
8463 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
8464 fi
8465 fi
8466
8467 if ${skipped_export-false}; then
8468 if test -n "$export_symbols" && test -n "$include_expsyms"; then
8469 tmp_export_symbols="$export_symbols"
8470 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
8471 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
8472 fi
8473
8474 if test -n "$orig_export_symbols"; then
8475 # The given exports_symbols file has to be filtered, so filter it.
8476 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
8477 # FIXME: $output_objdir/$libname.filter potentially contains lots of
8478 # 's' commands which not all seds can handle. GNU sed should be fine
8479 # though. Also, the filter scales superlinearly with the number of
8480 # global variables. join(1) would be nice here, but unfortunately
8481 # isn't a blessed tool.
8482 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
8483 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
8484 export_symbols=$output_objdir/$libname.def
8485 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
8486 fi
8487 fi
8488
8489 libobjs=$output
8490 # Restore the value of output.
8491 output=$save_output
8492
8493 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
8494 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
8495 test "X$libobjs" = "X " && libobjs=
8496 fi
8497 # Expand the library linking commands again to reset the
8498 # value of $libobjs for piecewise linking.
8499
8500 # Do each of the archive commands.
8501 if test "$module" = yes && test -n "$module_cmds" ; then
8502 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
8503 cmds=$module_expsym_cmds
8504 else
8505 cmds=$module_cmds
8506 fi
8507 else
8508 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
8509 cmds=$archive_expsym_cmds
8510 else
8511 cmds=$archive_cmds
8512 fi
8513 fi
8514 fi
8515
8516 if test -n "$delfiles"; then
8517 # Append the command to remove temporary files to $cmds.
8518 eval cmds=\"\$cmds~\$RM $delfiles\"
8519 fi
8520
8521 # Add any objects from preloaded convenience libraries
8522 if test -n "$dlprefiles"; then
8523 gentop="$output_objdir/${outputname}x"
8524 func_append generated " $gentop"
8525
8526 func_extract_archives $gentop $dlprefiles
8527 func_append libobjs " $func_extract_archives_result"
8528 test "X$libobjs" = "X " && libobjs=
8529 fi
8530
8531 save_ifs="$IFS"; IFS='~'
8532 for cmd in $cmds; do
8533 IFS="$save_ifs"
8534 eval cmd=\"$cmd\"
8535 $opt_silent || {
8536 func_quote_for_expand "$cmd"
8537 eval "func_echo $func_quote_for_expand_result"
8538 }
8539 $opt_dry_run || eval "$cmd" || {
8540 lt_exit=$?
8541
8542 # Restore the uninstalled library and exit
8543 if test "$opt_mode" = relink; then
8544 ( cd "$output_objdir" && \
8545 $RM "${realname}T" && \
8546 $MV "${realname}U" "$realname" )
8547 fi
8548
8549 exit $lt_exit
8550 }
8551 done
8552 IFS="$save_ifs"
8553
8554 # Restore the uninstalled library and exit
8555 if test "$opt_mode" = relink; then
8556 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
8557
8558 if test -n "$convenience"; then
8559 if test -z "$whole_archive_flag_spec"; then
8560 func_show_eval '${RM}r "$gentop"'
8561 fi
8562 fi
8563
8564 exit $EXIT_SUCCESS
8565 fi
8566
8567 # Create links to the real library.
8568 for linkname in $linknames; do
8569 if test "$realname" != "$linkname"; then
8570 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
8571 fi
8572 done
8573
8574 # If -module or -export-dynamic was specified, set the dlname.
8575 if test "$module" = yes || test "$export_dynamic" = yes; then
8576 # On all known operating systems, these are identical.
8577 dlname="$soname"
8578 fi
8579 fi
8580 ;;
8581
8582 obj)
8583 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
8584 func_warning "\`-dlopen' is ignored for objects"
8585 fi
8586
8587 case " $deplibs" in
8588 *\ -l* | *\ -L*)
8589 func_warning "\`-l' and \`-L' are ignored for objects" ;;
8590 esac
8591
8592 test -n "$rpath" && \
8593 func_warning "\`-rpath' is ignored for objects"
8594
8595 test -n "$xrpath" && \
8596 func_warning "\`-R' is ignored for objects"
8597
8598 test -n "$vinfo" && \
8599 func_warning "\`-version-info' is ignored for objects"
8600
8601 test -n "$release" && \
8602 func_warning "\`-release' is ignored for objects"
8603
8604 case $output in
8605 *.lo)
8606 test -n "$objs$old_deplibs" && \
8607 func_fatal_error "cannot build library object \`$output' from non-libtool objects"
8608
8609 libobj=$output
8610 func_lo2o "$libobj"
8611 obj=$func_lo2o_result
8612 ;;
8613 *)
8614 libobj=
8615 obj="$output"
8616 ;;
8617 esac
8618
8619 # Delete the old objects.
8620 $opt_dry_run || $RM $obj $libobj
8621
8622 # Objects from convenience libraries. This assumes
8623 # single-version convenience libraries. Whenever we create
8624 # different ones for PIC/non-PIC, this we'll have to duplicate
8625 # the extraction.
8626 reload_conv_objs=
8627 gentop=
8628 # reload_cmds runs $LD directly, so let us get rid of
8629 # -Wl from whole_archive_flag_spec and hope we can get by with
8630 # turning comma into space..
8631 wl=
8632
8633 if test -n "$convenience"; then
8634 if test -n "$whole_archive_flag_spec"; then
8635 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
8636 reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
8637 else
8638 gentop="$output_objdir/${obj}x"
8639 func_append generated " $gentop"
8640
8641 func_extract_archives $gentop $convenience
8642 reload_conv_objs="$reload_objs $func_extract_archives_result"
8643 fi
8644 fi
8645
8646 # If we're not building shared, we need to use non_pic_objs
8647 test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
8648
8649 # Create the old-style object.
8650 reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
8651
8652 output="$obj"
8653 func_execute_cmds "$reload_cmds" 'exit $?'
8654
8655 # Exit if we aren't doing a library object file.
8656 if test -z "$libobj"; then
8657 if test -n "$gentop"; then
8658 func_show_eval '${RM}r "$gentop"'
8659 fi
8660
8661 exit $EXIT_SUCCESS
8662 fi
8663
8664 if test "$build_libtool_libs" != yes; then
8665 if test -n "$gentop"; then
8666 func_show_eval '${RM}r "$gentop"'
8667 fi
8668
8669 # Create an invalid libtool object if no PIC, so that we don't
8670 # accidentally link it into a program.
8671 # $show "echo timestamp > $libobj"
8672 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
8673 exit $EXIT_SUCCESS
8674 fi
8675
8676 if test -n "$pic_flag" || test "$pic_mode" != default; then
8677 # Only do commands if we really have different PIC objects.
8678 reload_objs="$libobjs $reload_conv_objs"
8679 output="$libobj"
8680 func_execute_cmds "$reload_cmds" 'exit $?'
8681 fi
8682
8683 if test -n "$gentop"; then
8684 func_show_eval '${RM}r "$gentop"'
8685 fi
8686
8687 exit $EXIT_SUCCESS
8688 ;;
8689
8690 prog)
8691 case $host in
8692 *cygwin*) func_stripname '' '.exe' "$output"
8693 output=$func_stripname_result.exe;;
8694 esac
8695 test -n "$vinfo" && \
8696 func_warning "\`-version-info' is ignored for programs"
8697
8698 test -n "$release" && \
8699 func_warning "\`-release' is ignored for programs"
8700
8701 test "$preload" = yes \
8702 && test "$dlopen_support" = unknown \
8703 && test "$dlopen_self" = unknown \
8704 && test "$dlopen_self_static" = unknown && \
8705 func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
8706
8707 case $host in
8708 *-*-rhapsody* | *-*-darwin1.[012])
8709 # On Rhapsody replace the C library is the System framework
8710 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
8711 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
8712 ;;
8713 esac
8714
8715 case $host in
8716 *-*-darwin*)
8717 # Don't allow lazy linking, it breaks C++ global constructors
8718 # But is supposedly fixed on 10.4 or later (yay!).
8719 if test "$tagname" = CXX ; then
8720 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
8721 10.[0123])
8722 func_append compile_command " ${wl}-bind_at_load"
8723 func_append finalize_command " ${wl}-bind_at_load"
8724 ;;
8725 esac
8726 fi
8727 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
8728 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8729 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
8730 ;;
8731 esac
8732
8733
8734 # move library search paths that coincide with paths to not yet
8735 # installed libraries to the beginning of the library search list
8736 new_libs=
8737 for path in $notinst_path; do
8738 case " $new_libs " in
8739 *" -L$path/$objdir "*) ;;
8740 *)
8741 case " $compile_deplibs " in
8742 *" -L$path/$objdir "*)
8743 func_append new_libs " -L$path/$objdir" ;;
8744 esac
8745 ;;
8746 esac
8747 done
8748 for deplib in $compile_deplibs; do
8749 case $deplib in
8750 -L*)
8751 case " $new_libs " in
8752 *" $deplib "*) ;;
8753 *) func_append new_libs " $deplib" ;;
8754 esac
8755 ;;
8756 *) func_append new_libs " $deplib" ;;
8757 esac
8758 done
8759 compile_deplibs="$new_libs"
8760
8761
8762 func_append compile_command " $compile_deplibs"
8763 func_append finalize_command " $finalize_deplibs"
8764
8765 if test -n "$rpath$xrpath"; then
8766 # If the user specified any rpath flags, then add them.
8767 for libdir in $rpath $xrpath; do
8768 # This is the magic to use -rpath.
8769 case "$finalize_rpath " in
8770 *" $libdir "*) ;;
8771 *) func_append finalize_rpath " $libdir" ;;
8772 esac
8773 done
8774 fi
8775
8776 # Now hardcode the library paths
8777 rpath=
8778 hardcode_libdirs=
8779 for libdir in $compile_rpath $finalize_rpath; do
8780 if test -n "$hardcode_libdir_flag_spec"; then
8781 if test -n "$hardcode_libdir_separator"; then
8782 if test -z "$hardcode_libdirs"; then
8783 hardcode_libdirs="$libdir"
8784 else
8785 # Just accumulate the unique libdirs.
8786 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8787 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8788 ;;
8789 *)
8790 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8791 ;;
8792 esac
8793 fi
8794 else
8795 eval flag=\"$hardcode_libdir_flag_spec\"
8796 func_append rpath " $flag"
8797 fi
8798 elif test -n "$runpath_var"; then
8799 case "$perm_rpath " in
8800 *" $libdir "*) ;;
8801 *) func_append perm_rpath " $libdir" ;;
8802 esac
8803 fi
8804 case $host in
8805 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
8806 testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
8807 case :$dllsearchpath: in
8808 *":$libdir:"*) ;;
8809 ::) dllsearchpath=$libdir;;
8810 *) func_append dllsearchpath ":$libdir";;
8811 esac
8812 case :$dllsearchpath: in
8813 *":$testbindir:"*) ;;
8814 ::) dllsearchpath=$testbindir;;
8815 *) func_append dllsearchpath ":$testbindir";;
8816 esac
8817 ;;
8818 esac
8819 done
8820 # Substitute the hardcoded libdirs into the rpath.
8821 if test -n "$hardcode_libdir_separator" &&
8822 test -n "$hardcode_libdirs"; then
8823 libdir="$hardcode_libdirs"
8824 eval rpath=\" $hardcode_libdir_flag_spec\"
8825 fi
8826 compile_rpath="$rpath"
8827
8828 rpath=
8829 hardcode_libdirs=
8830 for libdir in $finalize_rpath; do
8831 if test -n "$hardcode_libdir_flag_spec"; then
8832 if test -n "$hardcode_libdir_separator"; then
8833 if test -z "$hardcode_libdirs"; then
8834 hardcode_libdirs="$libdir"
8835 else
8836 # Just accumulate the unique libdirs.
8837 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
8838 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
8839 ;;
8840 *)
8841 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
8842 ;;
8843 esac
8844 fi
8845 else
8846 eval flag=\"$hardcode_libdir_flag_spec\"
8847 func_append rpath " $flag"
8848 fi
8849 elif test -n "$runpath_var"; then
8850 case "$finalize_perm_rpath " in
8851 *" $libdir "*) ;;
8852 *) func_append finalize_perm_rpath " $libdir" ;;
8853 esac
8854 fi
8855 done
8856 # Substitute the hardcoded libdirs into the rpath.
8857 if test -n "$hardcode_libdir_separator" &&
8858 test -n "$hardcode_libdirs"; then
8859 libdir="$hardcode_libdirs"
8860 eval rpath=\" $hardcode_libdir_flag_spec\"
8861 fi
8862 finalize_rpath="$rpath"
8863
8864 if test -n "$libobjs" && test "$build_old_libs" = yes; then
8865 # Transform all the library objects into standard objects.
8866 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8867 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
8868 fi
8869
8870 func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
8871
8872 # template prelinking step
8873 if test -n "$prelink_cmds"; then
8874 func_execute_cmds "$prelink_cmds" 'exit $?'
8875 fi
8876
8877 wrappers_required=yes
8878 case $host in
8879 *cegcc* | *mingw32ce*)
8880 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
8881 wrappers_required=no
8882 ;;
8883 *cygwin* | *mingw* )
8884 if test "$build_libtool_libs" != yes; then
8885 wrappers_required=no
8886 fi
8887 ;;
8888 *)
8889 if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
8890 wrappers_required=no
8891 fi
8892 ;;
8893 esac
8894 if test "$wrappers_required" = no; then
8895 # Replace the output file specification.
8896 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8897 link_command="$compile_command$compile_rpath"
8898
8899 # We have no uninstalled library dependencies, so finalize right now.
8900 exit_status=0
8901 func_show_eval "$link_command" 'exit_status=$?'
8902
8903 if test -n "$postlink_cmds"; then
8904 func_to_tool_file "$output"
8905 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8906 func_execute_cmds "$postlink_cmds" 'exit $?'
8907 fi
8908
8909 # Delete the generated files.
8910 if test -f "$output_objdir/${outputname}S.${objext}"; then
8911 func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
8912 fi
8913
8914 exit $exit_status
8915 fi
8916
8917 if test -n "$compile_shlibpath$finalize_shlibpath"; then
8918 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
8919 fi
8920 if test -n "$finalize_shlibpath"; then
8921 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
8922 fi
8923
8924 compile_var=
8925 finalize_var=
8926 if test -n "$runpath_var"; then
8927 if test -n "$perm_rpath"; then
8928 # We should set the runpath_var.
8929 rpath=
8930 for dir in $perm_rpath; do
8931 func_append rpath "$dir:"
8932 done
8933 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
8934 fi
8935 if test -n "$finalize_perm_rpath"; then
8936 # We should set the runpath_var.
8937 rpath=
8938 for dir in $finalize_perm_rpath; do
8939 func_append rpath "$dir:"
8940 done
8941 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
8942 fi
8943 fi
8944
8945 if test "$no_install" = yes; then
8946 # We don't need to create a wrapper script.
8947 link_command="$compile_var$compile_command$compile_rpath"
8948 # Replace the output file specification.
8949 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
8950 # Delete the old output file.
8951 $opt_dry_run || $RM $output
8952 # Link the executable and exit
8953 func_show_eval "$link_command" 'exit $?'
8954
8955 if test -n "$postlink_cmds"; then
8956 func_to_tool_file "$output"
8957 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8958 func_execute_cmds "$postlink_cmds" 'exit $?'
8959 fi
8960
8961 exit $EXIT_SUCCESS
8962 fi
8963
8964 if test "$hardcode_action" = relink; then
8965 # Fast installation is not supported
8966 link_command="$compile_var$compile_command$compile_rpath"
8967 relink_command="$finalize_var$finalize_command$finalize_rpath"
8968
8969 func_warning "this platform does not like uninstalled shared libraries"
8970 func_warning "\`$output' will be relinked during installation"
8971 else
8972 if test "$fast_install" != no; then
8973 link_command="$finalize_var$compile_command$finalize_rpath"
8974 if test "$fast_install" = yes; then
8975 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
8976 else
8977 # fast_install is set to needless
8978 relink_command=
8979 fi
8980 else
8981 link_command="$compile_var$compile_command$compile_rpath"
8982 relink_command="$finalize_var$finalize_command$finalize_rpath"
8983 fi
8984 fi
8985
8986 # Replace the output file specification.
8987 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
8988
8989 # Delete the old output files.
8990 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
8991
8992 func_show_eval "$link_command" 'exit $?'
8993
8994 if test -n "$postlink_cmds"; then
8995 func_to_tool_file "$output_objdir/$outputname"
8996 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
8997 func_execute_cmds "$postlink_cmds" 'exit $?'
8998 fi
8999
9000 # Now create the wrapper script.
9001 func_verbose "creating $output"
9002
9003 # Quote the relink command for shipping.
9004 if test -n "$relink_command"; then
9005 # Preserve any variables that may affect compiler behavior
9006 for var in $variables_saved_for_relink; do
9007 if eval test -z \"\${$var+set}\"; then
9008 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9009 elif eval var_value=\$$var; test -z "$var_value"; then
9010 relink_command="$var=; export $var; $relink_command"
9011 else
9012 func_quote_for_eval "$var_value"
9013 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9014 fi
9015 done
9016 relink_command="(cd `pwd`; $relink_command)"
9017 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9018 fi
9019
9020 # Only actually do things if not in dry run mode.
9021 $opt_dry_run || {
9022 # win32 will think the script is a binary if it has
9023 # a .exe suffix, so we strip it off here.
9024 case $output in
9025 *.exe) func_stripname '' '.exe' "$output"
9026 output=$func_stripname_result ;;
9027 esac
9028 # test for cygwin because mv fails w/o .exe extensions
9029 case $host in
9030 *cygwin*)
9031 exeext=.exe
9032 func_stripname '' '.exe' "$outputname"
9033 outputname=$func_stripname_result ;;
9034 *) exeext= ;;
9035 esac
9036 case $host in
9037 *cygwin* | *mingw* )
9038 func_dirname_and_basename "$output" "" "."
9039 output_name=$func_basename_result
9040 output_path=$func_dirname_result
9041 cwrappersource="$output_path/$objdir/lt-$output_name.c"
9042 cwrapper="$output_path/$output_name.exe"
9043 $RM $cwrappersource $cwrapper
9044 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
9045
9046 func_emit_cwrapperexe_src > $cwrappersource
9047
9048 # The wrapper executable is built using the $host compiler,
9049 # because it contains $host paths and files. If cross-
9050 # compiling, it, like the target executable, must be
9051 # executed on the $host or under an emulation environment.
9052 $opt_dry_run || {
9053 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
9054 $STRIP $cwrapper
9055 }
9056
9057 # Now, create the wrapper script for func_source use:
9058 func_ltwrapper_scriptname $cwrapper
9059 $RM $func_ltwrapper_scriptname_result
9060 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
9061 $opt_dry_run || {
9062 # note: this script will not be executed, so do not chmod.
9063 if test "x$build" = "x$host" ; then
9064 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
9065 else
9066 func_emit_wrapper no > $func_ltwrapper_scriptname_result
9067 fi
9068 }
9069 ;;
9070 * )
9071 $RM $output
9072 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
9073
9074 func_emit_wrapper no > $output
9075 chmod +x $output
9076 ;;
9077 esac
9078 }
9079 exit $EXIT_SUCCESS
9080 ;;
9081 esac
9082
9083 # See if we need to build an old-fashioned archive.
9084 for oldlib in $oldlibs; do
9085
9086 if test "$build_libtool_libs" = convenience; then
9087 oldobjs="$libobjs_save $symfileobj"
9088 addlibs="$convenience"
9089 build_libtool_libs=no
9090 else
9091 if test "$build_libtool_libs" = module; then
9092 oldobjs="$libobjs_save"
9093 build_libtool_libs=no
9094 else
9095 oldobjs="$old_deplibs $non_pic_objects"
9096 if test "$preload" = yes && test -f "$symfileobj"; then
9097 func_append oldobjs " $symfileobj"
9098 fi
9099 fi
9100 addlibs="$old_convenience"
9101 fi
9102
9103 if test -n "$addlibs"; then
9104 gentop="$output_objdir/${outputname}x"
9105 func_append generated " $gentop"
9106
9107 func_extract_archives $gentop $addlibs
9108 func_append oldobjs " $func_extract_archives_result"
9109 fi
9110
9111 # Do each command in the archive commands.
9112 if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
9113 cmds=$old_archive_from_new_cmds
9114 else
9115
9116 # Add any objects from preloaded convenience libraries
9117 if test -n "$dlprefiles"; then
9118 gentop="$output_objdir/${outputname}x"
9119 func_append generated " $gentop"
9120
9121 func_extract_archives $gentop $dlprefiles
9122 func_append oldobjs " $func_extract_archives_result"
9123 fi
9124
9125 # POSIX demands no paths to be encoded in archives. We have
9126 # to avoid creating archives with duplicate basenames if we
9127 # might have to extract them afterwards, e.g., when creating a
9128 # static archive out of a convenience library, or when linking
9129 # the entirety of a libtool archive into another (currently
9130 # not supported by libtool).
9131 if (for obj in $oldobjs
9132 do
9133 func_basename "$obj"
9134 $ECHO "$func_basename_result"
9135 done | sort | sort -uc >/dev/null 2>&1); then
9136 :
9137 else
9138 echo "copying selected object files to avoid basename conflicts..."
9139 gentop="$output_objdir/${outputname}x"
9140 func_append generated " $gentop"
9141 func_mkdir_p "$gentop"
9142 save_oldobjs=$oldobjs
9143 oldobjs=
9144 counter=1
9145 for obj in $save_oldobjs
9146 do
9147 func_basename "$obj"
9148 objbase="$func_basename_result"
9149 case " $oldobjs " in
9150 " ") oldobjs=$obj ;;
9151 *[\ /]"$objbase "*)
9152 while :; do
9153 # Make sure we don't pick an alternate name that also
9154 # overlaps.
9155 newobj=lt$counter-$objbase
9156 func_arith $counter + 1
9157 counter=$func_arith_result
9158 case " $oldobjs " in
9159 *[\ /]"$newobj "*) ;;
9160 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
9161 esac
9162 done
9163 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
9164 func_append oldobjs " $gentop/$newobj"
9165 ;;
9166 *) func_append oldobjs " $obj" ;;
9167 esac
9168 done
9169 fi
9170 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
9171 tool_oldlib=$func_to_tool_file_result
9172 eval cmds=\"$old_archive_cmds\"
9173
9174 func_len " $cmds"
9175 len=$func_len_result
9176 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
9177 cmds=$old_archive_cmds
9178 elif test -n "$archiver_list_spec"; then
9179 func_verbose "using command file archive linking..."
9180 for obj in $oldobjs
9181 do
9182 func_to_tool_file "$obj"
9183 $ECHO "$func_to_tool_file_result"
9184 done > $output_objdir/$libname.libcmd
9185 func_to_tool_file "$output_objdir/$libname.libcmd"
9186 oldobjs=" $archiver_list_spec$func_to_tool_file_result"
9187 cmds=$old_archive_cmds
9188 else
9189 # the command line is too long to link in one step, link in parts
9190 func_verbose "using piecewise archive linking..."
9191 save_RANLIB=$RANLIB
9192 RANLIB=:
9193 objlist=
9194 concat_cmds=
9195 save_oldobjs=$oldobjs
9196 oldobjs=
9197 # Is there a better way of finding the last object in the list?
9198 for obj in $save_oldobjs
9199 do
9200 last_oldobj=$obj
9201 done
9202 eval test_cmds=\"$old_archive_cmds\"
9203 func_len " $test_cmds"
9204 len0=$func_len_result
9205 len=$len0
9206 for obj in $save_oldobjs
9207 do
9208 func_len " $obj"
9209 func_arith $len + $func_len_result
9210 len=$func_arith_result
9211 func_append objlist " $obj"
9212 if test "$len" -lt "$max_cmd_len"; then
9213 :
9214 else
9215 # the above command should be used before it gets too long
9216 oldobjs=$objlist
9217 if test "$obj" = "$last_oldobj" ; then
9218 RANLIB=$save_RANLIB
9219 fi
9220 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
9221 eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
9222 objlist=
9223 len=$len0
9224 fi
9225 done
9226 RANLIB=$save_RANLIB
9227 oldobjs=$objlist
9228 if test "X$oldobjs" = "X" ; then
9229 eval cmds=\"\$concat_cmds\"
9230 else
9231 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
9232 fi
9233 fi
9234 fi
9235 func_execute_cmds "$cmds" 'exit $?'
9236 done
9237
9238 test -n "$generated" && \
9239 func_show_eval "${RM}r$generated"
9240
9241 # Now create the libtool archive.
9242 case $output in
9243 *.la)
9244 old_library=
9245 test "$build_old_libs" = yes && old_library="$libname.$libext"
9246 func_verbose "creating $output"
9247
9248 # Preserve any variables that may affect compiler behavior
9249 for var in $variables_saved_for_relink; do
9250 if eval test -z \"\${$var+set}\"; then
9251 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
9252 elif eval var_value=\$$var; test -z "$var_value"; then
9253 relink_command="$var=; export $var; $relink_command"
9254 else
9255 func_quote_for_eval "$var_value"
9256 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
9257 fi
9258 done
9259 # Quote the link command for shipping.
9260 relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
9261 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
9262 if test "$hardcode_automatic" = yes ; then
9263 relink_command=
9264 fi
9265
9266 # Only create the output if not a dry run.
9267 $opt_dry_run || {
9268 for installed in no yes; do
9269 if test "$installed" = yes; then
9270 if test -z "$install_libdir"; then
9271 break
9272 fi
9273 output="$output_objdir/$outputname"i
9274 # Replace all uninstalled libtool libraries with the installed ones
9275 newdependency_libs=
9276 for deplib in $dependency_libs; do
9277 case $deplib in
9278 *.la)
9279 func_basename "$deplib"
9280 name="$func_basename_result"
9281 func_resolve_sysroot "$deplib"
9282 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
9283 test -z "$libdir" && \
9284 func_fatal_error "\`$deplib' is not a valid libtool archive"
9285 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
9286 ;;
9287 -L*)
9288 func_stripname -L '' "$deplib"
9289 func_replace_sysroot "$func_stripname_result"
9290 func_append newdependency_libs " -L$func_replace_sysroot_result"
9291 ;;
9292 -R*)
9293 func_stripname -R '' "$deplib"
9294 func_replace_sysroot "$func_stripname_result"
9295 func_append newdependency_libs " -R$func_replace_sysroot_result"
9296 ;;
9297 *) func_append newdependency_libs " $deplib" ;;
9298 esac
9299 done
9300 dependency_libs="$newdependency_libs"
9301 newdlfiles=
9302
9303 for lib in $dlfiles; do
9304 case $lib in
9305 *.la)
9306 func_basename "$lib"
9307 name="$func_basename_result"
9308 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9309 test -z "$libdir" && \
9310 func_fatal_error "\`$lib' is not a valid libtool archive"
9311 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
9312 ;;
9313 *) func_append newdlfiles " $lib" ;;
9314 esac
9315 done
9316 dlfiles="$newdlfiles"
9317 newdlprefiles=
9318 for lib in $dlprefiles; do
9319 case $lib in
9320 *.la)
9321 # Only pass preopened files to the pseudo-archive (for
9322 # eventual linking with the app. that links it) if we
9323 # didn't already link the preopened objects directly into
9324 # the library:
9325 func_basename "$lib"
9326 name="$func_basename_result"
9327 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
9328 test -z "$libdir" && \
9329 func_fatal_error "\`$lib' is not a valid libtool archive"
9330 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
9331 ;;
9332 esac
9333 done
9334 dlprefiles="$newdlprefiles"
9335 else
9336 newdlfiles=
9337 for lib in $dlfiles; do
9338 case $lib in
9339 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9340 *) abs=`pwd`"/$lib" ;;
9341 esac
9342 func_append newdlfiles " $abs"
9343 done
9344 dlfiles="$newdlfiles"
9345 newdlprefiles=
9346 for lib in $dlprefiles; do
9347 case $lib in
9348 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
9349 *) abs=`pwd`"/$lib" ;;
9350 esac
9351 func_append newdlprefiles " $abs"
9352 done
9353 dlprefiles="$newdlprefiles"
9354 fi
9355 $RM $output
9356 # place dlname in correct position for cygwin
9357 # In fact, it would be nice if we could use this code for all target
9358 # systems that can't hard-code library paths into their executables
9359 # and that have no shared library path variable independent of PATH,
9360 # but it turns out we can't easily determine that from inspecting
9361 # libtool variables, so we have to hard-code the OSs to which it
9362 # applies here; at the moment, that means platforms that use the PE
9363 # object format with DLL files. See the long comment at the top of
9364 # tests/bindir.at for full details.
9365 tdlname=$dlname
9366 case $host,$output,$installed,$module,$dlname in
9367 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
9368 # If a -bindir argument was supplied, place the dll there.
9369 if test "x$bindir" != x ;
9370 then
9371 func_relative_path "$install_libdir" "$bindir"
9372 tdlname=$func_relative_path_result$dlname
9373 else
9374 # Otherwise fall back on heuristic.
9375 tdlname=../bin/$dlname
9376 fi
9377 ;;
9378 esac
9379 $ECHO > $output "\
9380 # $outputname - a libtool library file
9381 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
9382 #
9383 # Please DO NOT delete this file!
9384 # It is necessary for linking the library.
9385
9386 # The name that we can dlopen(3).
9387 dlname='$tdlname'
9388
9389 # Names of this library.
9390 library_names='$library_names'
9391
9392 # The name of the static archive.
9393 old_library='$old_library'
9394
9395 # Linker flags that can not go in dependency_libs.
9396 inherited_linker_flags='$new_inherited_linker_flags'
9397
9398 # Libraries that this one depends upon.
9399 dependency_libs='$dependency_libs'
9400
9401 # Names of additional weak libraries provided by this library
9402 weak_library_names='$weak_libs'
9403
9404 # Version information for $libname.
9405 current=$current
9406 age=$age
9407 revision=$revision
9408
9409 # Is this an already installed library?
9410 installed=$installed
9411
9412 # Should we warn about portability when linking against -modules?
9413 shouldnotlink=$module
9414
9415 # Files to dlopen/dlpreopen
9416 dlopen='$dlfiles'
9417 dlpreopen='$dlprefiles'
9418
9419 # Directory that this library needs to be installed in:
9420 libdir='$install_libdir'"
9421 if test "$installed" = no && test "$need_relink" = yes; then
9422 $ECHO >> $output "\
9423 relink_command=\"$relink_command\""
9424 fi
9425 done
9426 }
9427
9428 # Do a symbolic link so that the libtool archive can be found in
9429 # LD_LIBRARY_PATH before the program is installed.
9430 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
9431 ;;
9432 esac
9433 exit $EXIT_SUCCESS
9434 }
9435
9436 { test "$opt_mode" = link || test "$opt_mode" = relink; } &&
9437 func_mode_link ${1+"$@"}
9438
9439
9440 # func_mode_uninstall arg...
9441 func_mode_uninstall ()
9442 {
9443 $opt_debug
9444 RM="$nonopt"
9445 files=
9446 rmforce=
9447 exit_status=0
9448
9449 # This variable tells wrapper scripts just to set variables rather
9450 # than running their programs.
9451 libtool_install_magic="$magic"
9452
9453 for arg
9454 do
9455 case $arg in
9456 -f) func_append RM " $arg"; rmforce=yes ;;
9457 -*) func_append RM " $arg" ;;
9458 *) func_append files " $arg" ;;
9459 esac
9460 done
9461
9462 test -z "$RM" && \
9463 func_fatal_help "you must specify an RM program"
9464
9465 rmdirs=
9466
9467 for file in $files; do
9468 func_dirname "$file" "" "."
9469 dir="$func_dirname_result"
9470 if test "X$dir" = X.; then
9471 odir="$objdir"
9472 else
9473 odir="$dir/$objdir"
9474 fi
9475 func_basename "$file"
9476 name="$func_basename_result"
9477 test "$opt_mode" = uninstall && odir="$dir"
9478
9479 # Remember odir for removal later, being careful to avoid duplicates
9480 if test "$opt_mode" = clean; then
9481 case " $rmdirs " in
9482 *" $odir "*) ;;
9483 *) func_append rmdirs " $odir" ;;
9484 esac
9485 fi
9486
9487 # Don't error if the file doesn't exist and rm -f was used.
9488 if { test -L "$file"; } >/dev/null 2>&1 ||
9489 { test -h "$file"; } >/dev/null 2>&1 ||
9490 test -f "$file"; then
9491 :
9492 elif test -d "$file"; then
9493 exit_status=1
9494 continue
9495 elif test "$rmforce" = yes; then
9496 continue
9497 fi
9498
9499 rmfiles="$file"
9500
9501 case $name in
9502 *.la)
9503 # Possibly a libtool archive, so verify it.
9504 if func_lalib_p "$file"; then
9505 func_source $dir/$name
9506
9507 # Delete the libtool libraries and symlinks.
9508 for n in $library_names; do
9509 func_append rmfiles " $odir/$n"
9510 done
9511 test -n "$old_library" && func_append rmfiles " $odir/$old_library"
9512
9513 case "$opt_mode" in
9514 clean)
9515 case " $library_names " in
9516 *" $dlname "*) ;;
9517 *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
9518 esac
9519 test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
9520 ;;
9521 uninstall)
9522 if test -n "$library_names"; then
9523 # Do each command in the postuninstall commands.
9524 func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9525 fi
9526
9527 if test -n "$old_library"; then
9528 # Do each command in the old_postuninstall commands.
9529 func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
9530 fi
9531 # FIXME: should reinstall the best remaining shared library.
9532 ;;
9533 esac
9534 fi
9535 ;;
9536
9537 *.lo)
9538 # Possibly a libtool object, so verify it.
9539 if func_lalib_p "$file"; then
9540
9541 # Read the .lo file
9542 func_source $dir/$name
9543
9544 # Add PIC object to the list of files to remove.
9545 if test -n "$pic_object" &&
9546 test "$pic_object" != none; then
9547 func_append rmfiles " $dir/$pic_object"
9548 fi
9549
9550 # Add non-PIC object to the list of files to remove.
9551 if test -n "$non_pic_object" &&
9552 test "$non_pic_object" != none; then
9553 func_append rmfiles " $dir/$non_pic_object"
9554 fi
9555 fi
9556 ;;
9557
9558 *)
9559 if test "$opt_mode" = clean ; then
9560 noexename=$name
9561 case $file in
9562 *.exe)
9563 func_stripname '' '.exe' "$file"
9564 file=$func_stripname_result
9565 func_stripname '' '.exe' "$name"
9566 noexename=$func_stripname_result
9567 # $file with .exe has already been added to rmfiles,
9568 # add $file without .exe
9569 func_append rmfiles " $file"
9570 ;;
9571 esac
9572 # Do a test to see if this is a libtool program.
9573 if func_ltwrapper_p "$file"; then
9574 if func_ltwrapper_executable_p "$file"; then
9575 func_ltwrapper_scriptname "$file"
9576 relink_command=
9577 func_source $func_ltwrapper_scriptname_result
9578 func_append rmfiles " $func_ltwrapper_scriptname_result"
9579 else
9580 relink_command=
9581 func_source $dir/$noexename
9582 fi
9583
9584 # note $name still contains .exe if it was in $file originally
9585 # as does the version of $file that was added into $rmfiles
9586 func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
9587 if test "$fast_install" = yes && test -n "$relink_command"; then
9588 func_append rmfiles " $odir/lt-$name"
9589 fi
9590 if test "X$noexename" != "X$name" ; then
9591 func_append rmfiles " $odir/lt-${noexename}.c"
9592 fi
9593 fi
9594 fi
9595 ;;
9596 esac
9597 func_show_eval "$RM $rmfiles" 'exit_status=1'
9598 done
9599
9600 # Try to remove the ${objdir}s in the directories where we deleted files
9601 for dir in $rmdirs; do
9602 if test -d "$dir"; then
9603 func_show_eval "rmdir $dir >/dev/null 2>&1"
9604 fi
9605 done
9606
9607 exit $exit_status
9608 }
9609
9610 { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
9611 func_mode_uninstall ${1+"$@"}
9612
9613 test -z "$opt_mode" && {
9614 help="$generic_help"
9615 func_fatal_help "you must specify a MODE"
9616 }
9617
9618 test -z "$exec_cmd" && \
9619 func_fatal_help "invalid operation mode \`$opt_mode'"
9620
9621 if test -n "$exec_cmd"; then
9622 eval exec "$exec_cmd"
9623 exit $EXIT_FAILURE
9624 fi
9625
9626 exit $exit_status
9627
9628
9629 # The TAGs below are defined such that we never get into a situation
9630 # in which we disable both kinds of libraries. Given conflicting
9631 # choices, we go for a static library, that is the most portable,
9632 # since we can't tell whether shared libraries were disabled because
9633 # the user asked for that or because the platform doesn't support
9634 # them. This is particularly important on AIX, because we don't
9635 # support having both static and shared libraries enabled at the same
9636 # time on that platform, so we default to a shared-only configuration.
9637 # If a disable-shared tag is given, we'll fallback to a static-only
9638 # configuration. But we'll never go from static-only to shared-only.
9639
9640 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
9641 build_libtool_libs=no
9642 build_old_libs=yes
9643 # ### END LIBTOOL TAG CONFIG: disable-shared
9644
9645 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
9646 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
9647 # ### END LIBTOOL TAG CONFIG: disable-static
9648
9649 # Local Variables:
9650 # mode:shell-script
9651 # sh-indentation:2
9652 # End:
9653 # vi:sw=2
9654
Binary diff not shown
0 <!DOCTYPE html SYSTEM 'about:legacy-compat'>
1 <html><head><title>DNS API Description</title>
2 <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
3
4 <style type="text/css">
5 <!--
6 div.forh { white-space: pre; font-family: monospace; margin-top: 0; margin-bottom: 0 }
7 h1 { font-size: 18pt; }
8 h2 { font-size: 14pt; }
9 p { margin-bottom: 0 }
10 p.title { font-size: 24pt; font-weight: bold; margin-top: 0; margin-bottom: 0; text-align: center; }
11 p.title2 { font-size: 12pt; margin-top: 0; text-align: center; }
12 p.define { font-family: monospace; font-weight: bold; margin-bottom: 0; margin-left: 2em; }
13 p.descrip { margin-left: 4em; margin-top: 0; }
14 p.cont { margin-top: 0 }
15 p.bull { margin-top: 0; margin-bottom: 0 }
16 p.bull:before { content: "• " }
17 pre { margin-bottom: 0 }
18 table { border-spacing: 8pt }
19 td, th { vertical-align: top; text-align: left }
20 td.num { font-weight: bold; width: 2em }
21 tr.code { font-family: monospace }
22 .done { background: lightgreen }
23 .wontdo { background: lightpink }
24 .moved { background: lightskyblue }
25 .default { font-weight: bold }
26 /* The following is for Pygments-highlighted code */
27 .highlight .hll { background-color: #ffffcc }
28 .highlight { background: #ffffff; }
29 .highlight .c { color: #408080; font-style: italic } /* Comment */
30 .highlight .err { border: 1px solid #FF0000 } /* Error */
31 .highlight .k { color: #008000; font-weight: bold } /* Keyword */
32 .highlight .o { color: #666666 } /* Operator */
33 .highlight .cm { color: #408080; font-style: italic } /* Comment.Multiline */
34 .highlight .cp { color: #BC7A00 } /* Comment.Preproc */
35 .highlight .c1 { color: #408080; font-style: italic } /* Comment.Single */
36 .highlight .cs { color: #408080; font-style: italic } /* Comment.Special */
37 .highlight .gd { color: #A00000 } /* Generic.Deleted */
38 .highlight .ge { font-style: italic } /* Generic.Emph */
39 .highlight .gr { color: #FF0000 } /* Generic.Error */
40 .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
41 .highlight .gi { color: #00A000 } /* Generic.Inserted */
42 .highlight .go { color: #808080 } /* Generic.Output */
43 .highlight .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
44 .highlight .gs { font-weight: bold } /* Generic.Strong */
45 .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
46 .highlight .gt { color: #0040D0 } /* Generic.Traceback */
47 .highlight .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
48 .highlight .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
49 .highlight .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
50 .highlight .kp { color: #008000 } /* Keyword.Pseudo */
51 .highlight .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
52 .highlight .kt { color: #B00040 } /* Keyword.Type */
53 .highlight .m { color: #666666 } /* Literal.Number */
54 .highlight .s { color: #BA2121 } /* Literal.String */
55 .highlight .na { color: #7D9029 } /* Name.Attribute */
56 .highlight .nb { color: #008000 } /* Name.Builtin */
57 .highlight .nc { color: #0000FF; font-weight: bold } /* Name.Class */
58 .highlight .no { color: #880000 } /* Name.Constant */
59 .highlight .nd { color: #AA22FF } /* Name.Decorator */
60 .highlight .ni { color: #999999; font-weight: bold } /* Name.Entity */
61 .highlight .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
62 .highlight .nf { color: #0000FF } /* Name.Function */
63 .highlight .nl { color: #A0A000 } /* Name.Label */
64 .highlight .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
65 .highlight .nt { color: #008000; font-weight: bold } /* Name.Tag */
66 .highlight .nv { color: #19177C } /* Name.Variable */
67 .highlight .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
68 .highlight .w { color: #bbbbbb } /* Text.Whitespace */
69 .highlight .mf { color: #666666 } /* Literal.Number.Float */
70 .highlight .mh { color: #666666 } /* Literal.Number.Hex */
71 .highlight .mi { color: #666666 } /* Literal.Number.Integer */
72 .highlight .mo { color: #666666 } /* Literal.Number.Oct */
73 .highlight .sb { color: #BA2121 } /* Literal.String.Backtick */
74 .highlight .sc { color: #BA2121 } /* Literal.String.Char */
75 .highlight .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
76 .highlight .s2 { color: #BA2121 } /* Literal.String.Double */
77 .highlight .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
78 .highlight .sh { color: #BA2121 } /* Literal.String.Heredoc */
79 .highlight .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
80 .highlight .sx { color: #008000 } /* Literal.String.Other */
81 .highlight .sr { color: #BB6688 } /* Literal.String.Regex */
82 .highlight .s1 { color: #BA2121 } /* Literal.String.Single */
83 .highlight .ss { color: #19177C } /* Literal.String.Symbol */
84 .highlight .bp { color: #008000 } /* Name.Builtin.Pseudo */
85 .highlight .vc { color: #19177C } /* Name.Variable.Class */
86 .highlight .vg { color: #19177C } /* Name.Variable.Global */
87 .highlight .vi { color: #19177C } /* Name.Variable.Instance */
88 .highlight .il { color: #666666 } /* Literal.Number.Integer.Long */-->
89 </style>
90 </head><body>
91
92 <p class=title>Description of the <code>getdns</code> API</p>
93 <p class=title2>Paul Hoffman, Editor</p>
94 <p class=title2>Document version: "getdns February 2014"</p>
95
96 <p>This document describes a modern asynchronous DNS API. This new API is intended to be useful to
97 application developers and operating system distributors as a way of making
98 all types of DNS information easily available in many types of programs. The major features
99 of this new API are:</p>
100
101 <ul>
102 <li>Full support for event-driven programming</li>
103 <li>Supports DNSSEC in multiple ways</li>
104 <li>Mirroring of the resolution in <code>getaddrinfo()</code></li>
105 <li>Easily supports all RRtypes, even those yet to be defined</li>
106 </ul>
107
108 <p>There is more background into the design and future goals of this API
109 <a href="#Commentary">later in this document</a>.</p>
110
111 <p>This document was discussed on the <a href="http://www.vpnc.org/mailman/listinfo/getdns-api">
112 getdns-api mailing list</a>; future versions of the API might be discussed there as well.
113 (If you
114 want to contact the editor off-list, please send mail to <a
115 href="mailto:paul.hoffman@vpnc.org">paul.hoffman@vpnc.org</a>.)</p>
116
117 <h1>1. The <code>getdns</code> Async Functions</h1>
118
119 <p>The API has four async functions:</p>
120
121 <ul>
122
123 <li><code>getdns_address</code> for doing <code>getaddrinfo()</code>-like address lookups</li>
124
125 <li><code>getdns_hostname</code> for doing <code>getnameinfo()</code>-like name lookups</li>
126
127 <li><code>getdns_service</code> for getting results from SRV lookups</li>
128
129 <li><code>getdns_general</code> for looking up any type of DNS record</li>
130
131 </ul>
132
133 <h2>1.1 <code>getdns_general()</code></h2>
134
135 <div class=forh id="getdnsfuncgeneral">getdns_return_t
136 getdns_general(
137 getdns_context *context,
138 const char *name,
139 uint16_t request_type,
140 getdns_dict *extensions,
141 void *userarg,
142 getdns_transaction_t *transaction_id,
143 getdns_callback_t callbackfn
144 );
145 </div>
146
147 <p class=define><code><b>context</b></code></p>
148 <p class=descrip>A pointer to the DNS context that is to be used with this call. DNS contexts are
149 described <a href="#Contexts">later in this document</a>. Note that a context <i>must</i> be created
150 before calling the function.</p>
151
152 <p class=define><code><b>*name</b></code></p>
153 <p class=descrip>This is a null-terminted string consisting of either an
154 ASCII-based domain name to be looked up, or a null-terminted text string that is an IPv4 or IPv6 address.
155 The values here follow the rules in section 2.1 of RFC 4343
156 to allow non-ASCII octets and special characters in labels.</p>
157
158 <p class=define><code><b>request_type</b></code></p>
159 <p class=descrip>Specifies the RRtype for the query; the RRtype numbers are listed in the IANA
160 registry. For example, to get the NS records, <code>request_type</code> would be 2. The API also has
161 defined macros for most of the RRtypes by name; the definition names all start with
162 "<code>GETDNS_RRTYPE_</code>". For example, to get the NS records, you can also set the
163 <code>request_type</code> to <code>GETDNS_RRTYPE_NS</code>.
164 (The full list of request types is always
165 <a href="http://www.iana.org/assignments/dns-parameters/dns-parameters.xml">here</a>.)</p>
166
167 <p class=define><code><b>*extensions</b></code></p>
168 <p class=descrip>Specifies the extensions for this request; the value may be NULL if there are no
169 extensions. See <a href="#Extensions">the section below</a> for information on how to specify
170 the extensions used for a request.</p>
171
172 <p class=define><code><b>*userarg</b></code></p>
173 <p class=descrip>A void* that is passed to the function, which the funciton
174 returns to the callback function untouched. <code>userarg</code> can be used by the callback
175 function for any user-specific data needed. This can be NULL.</p>
176
177 <p class=define><code><b>*transaction_id</b></code></p>
178 <p class=descrip>A pointer to a value that is filled in by the
179 function to identify the callback being made.
180 This pointer can be NULL, in which case it is ignored and no value is assigned.
181 The <code>getdns_cancel_callback()</code> function uses the
182 <code>transaction_id</code> to determine which callback is to be cancelled.
183 If the function fails,
184 <code>transaction_id</code> is set to 0.</p>
185
186 <p class=define><code><b>*callbackfn</b></code></p>
187 <p class=descrip>A pointer to a callback function that is defined by the application.
188 Typically, the callback function will do all the processing on the results from
189 the API. The parameters of the callback are defined below. This really needs
190 to be a pointer to a function (and not something like NULL); otherwise, the
191 results are unpredictable.</p>
192
193 <p>The async <code>getdns</code> functions return <code>GETDNS_RETURN_GOOD</code> if the call was properly formatted.
194 It returns <code>GETDNS_RETURN_BAD_DOMAIN_NAME</code> if the API determines that the name passed to
195 the function was bad, <code>GETDNS_RETURN_BAD_CONTEXT</code> if the context has internal deficiencies,
196 <code>GETDNS_RETURN_NO_SUCH_EXTENSION</code> if one or more extensions do not exist, or
197 <code>GETDNS_RETURN_EXTENSION_MISFORMAT</code> if the contents of one or more of the
198 extensions is incorrect. All of the return values are given <a
199 href="#ReturnCodes">later in this document</a>.</p>
200
201 <h2>1.2 <code>getdns_address()</code></h2>
202
203 <div class=forh id="getdnsfuncaddress">getdns_return_t
204 getdns_address(
205 getdns_context *context,
206 const char *name,
207 getdns_dict *extensions,
208 void *userarg,
209 getdns_transaction_t *transaction_id,
210 getdns_callback_t callbackfn
211 );
212 </div>
213
214 <p>There are three critical differences between <code>getdns_address()</code> and
215 <code>getdns_general()</code> beyond the missing <code>request_type</code> argument:</p>
216
217 <ul>
218
219 <li>In <code>getdns_address()</code>, the <code>name</code> argument can only take a host name.</li>
220
221 <li>You do not need to include a <code>return_both_v4_and_v6</code> extension with the call in
222 <code>getdns_address()</code>: it will always return both IPv4 and IPv6 addresses.</li>
223
224 <li><code>getdns_address()</code> always uses all of namespaces from the context (to better emulate
225 <code>getaddrinfo()</code>), while <code>getdns_general()</code> only uses the DNS namespace.</li>
226
227 </ul>
228
229 <h2>1.3 <code>getdns_hostname()</code></h2>
230
231 <div class=forh id="getdnsfunchostname">getdns_return_t
232 getdns_hostname(
233 getdns_context *context,
234 getdns_dict *address,
235 getdns_dict *extensions,
236 void *userarg,
237 getdns_transaction_t *transaction_id,
238 getdns_callback_t callbackfn
239 );
240 </div>
241
242 <p>The address is given as a <code>getdns_dict</code> data structure (defined below). The list must
243 have two names: <code>address_type</code> (whose value is a bindata; it is currently either "IPv4"
244 or "IPv6" (which are case-sensitive)) and <code>address_data</code> (whose value is a bindata).</p>
245
246 <h2>1.4 <code>getdns_service()</code></h2>
247
248 <div class=forh id="getdnsfuncservice">getdns_return_t
249 getdns_service(
250 getdns_context *context,
251 const char *name,
252 getdns_dict *extensions,
253 void *userarg,
254 getdns_transaction_t *transaction_id,
255 getdns_callback_t callbackfn
256 );
257 </div>
258
259 <p><code>name</code> must be a domain name for an SRV lookup; the call returns the
260 relevant SRV information for the name.</p>
261
262 <h2>1.5 Callback Functions for <code>getdns</code></h2>
263
264 <p>A call to the async <code>getdns</code> functions typically returns before any network or file I/O occurs. After
265 the API marshalls all the needed information, it calls the callback function that was passed by the
266 application. The callback function might be called at any time, even before the calling function
267 has returned. The API guarantees that the callback will be called exactly once unless the calling function
268 returned an error, in which case the callback function is never called.<p>
269
270 <p>The <code>getdns</code> calling function calls the callback with the parameters defined
271 as follows:</p>
272 <div class=forh id="getdns_callback_t">
273 typedef void (*getdns_callback_t)(
274 getdns_context *context,
275 getdns_callback_type_t callback_type,
276 getdns_dict *response,
277 void *userarg,
278 getdns_transaction_t transaction_id);
279 </div>
280
281 <p class=define><code><b>context</b></code></p>
282 <p class=descrip>The DNS context that was used in the calling function. See <a
283 href="#ContextInitial">below</a> for a description of the basic use of contexts, and <a
284 href="#Contexts">later</a> for more advanced use.</p>
285
286 <p class=define><code><b>callback_type</b></code></p>
287 <p class=descrip>Supplies the reason for the callback. See below for the codes and reasons.</p>
288
289 <p class=define><code><b>*response</b></code></p>
290 <p class=descrip>A response object with the response data.
291 This is described below.
292 The application is responsible for cleaning up the response object with getdns_dict_destroy.</p>
293
294 <p class=define><code><b>*userarg</b></code></p>
295 <p class=descrip>Identical to the <code>*userarg</code> passed to the calling function.</p>
296
297 <p class=define><code><b>transaction_id</b></code></p>
298 <p class=descrip>The transaction identifier that was assigned by the calling function.</p>
299
300 <p>The following are the values for callback_type.</p>
301
302 <p class=define>GETDNS_CALLBACK_COMPLETE</p>
303 <p class=descrip>The response has the requested data in it</p>
304 <p class=define>GETDNS_CALLBACK_CANCEL</p>
305 <p class=descrip>The calling program cancelled the callback; response is NULL</p>
306 <p class=define>GETDNS_CALLBACK_TIMEOUT</p>
307 <p class=descrip>The requested action timed out; response is NULL</p>
308 <p class=define>GETDNS_CALLBACK_ERROR</p>
309 <p class=descrip>The requested action had an error; response is NULL</p>
310
311
312 <h2>1.6 <a id="ContextInitial">Setting Up The DNS Context</a></h2>
313
314 <p>Calls to <code>getdns</code> functions require a DNS context, which is a group of API settings
315 that affect how DNS calls are made. For most applications, a default context is sufficient.</p>
316
317 <p>To create a new DNS context, use the function:</p>
318
319 <div class=forh>getdns_return_t
320 getdns_context_create(
321 getdns_context **context,
322 int set_from_os
323 );
324 </div>
325
326 <p class=cont>The call to <code>getdns_context_create</code> immediately returns a context that can
327 be used with other API calls; that context contains the API's default values. Most applications will
328 want <code>set_from_os</code> set to <code>1</code>.</p>
329
330 <div class=forh>getdns_return_t
331 getdns_context_create_with_memory_functions(
332 getdns_context **context,
333 int set_from_os,
334 void *(*malloc)(size_t),
335 void *(*realloc)(void *, size_t),
336 void (*free)(void *)
337 );
338 getdns_return_t
339 getdns_context_create_with_extended_memory_functions(
340 getdns_context **context,
341 int set_from_os,
342 void *userarg,
343 void *(*malloc)(void *userarg, size_t),
344 void *(*realloc)(void *userarg, void *, size_t),
345 void (*free)(void *userarg, void *)
346 );
347 </div>
348
349 <p>To clean up the context, including cleaning up all outstanding transactions that were called
350 using this context, use the function:</p>
351
352 <div class=forh>void
353 getdns_context_destroy(
354 getdns_context *context
355 );
356 </div>
357
358 <p class=cont>When <code>getdns_context_destroy()</code> returns, the
359 application knows that all outstanding transactions associated with this
360 context will have been called; callbacks that had not been called before
361 <code>getdns_context_destroy()</code> was called will be called with a callback_type of
362 <code>GETDNS_CALLBACK_CANCEL</code>. <code>getdns_context_destroy()</code> returns after
363 all of the needed cleanup is done and callbacks are made.</p>
364
365 <h2>1.7 Canceling a Callback</h2>
366
367 <p>To cancel an outstanding callback, use the following function.</p>
368
369 <div class=forh>getdns_return_t
370 getdns_cancel_callback(
371 getdns_context *context,
372 getdns_transaction_t transaction_id
373 );
374 </div>
375
376 <p class=cont>This causes the API to call the callback with a <code>callback_type</code> of
377 <code>GETDNS_CALLBACK_CANCEL</code> if the callback for this <code>transaction_id</code> has not
378 already been called. This will cancel the callback regardless of what the original call was
379 doing (such as in the middle of a DNS request, while DNSSEC validation is happening, and so on).
380 The callback code for cancellation should clean up any memory related to the
381 identified call, such as to deallocate the memory for the userarg.
382 <code>getdns_cancel_callback()</code> may return immediately, even before the callback finishes its
383 work and returns. Calling <code>getdns_cancel_callback()</code> with a <code>transaction_id</code>
384 of a callback that has already been called or an unknown <code>transaction_id</code> returns
385 <code>GETDNS_RETURN_UNKNOWN_TRANSACTION</code>; otherwise, <code>getdns_cancel_callback()</code>
386 returns <code>GETDNS_RETURN_GOOD</code>.</p>
387
388 <h2>1.8 Event-driven Programs</h2>
389
390 <p>Event-driven programs (sometimes called "async programs") require an event
391 base and event loop (among other things). Different event libraries have
392 different structures or the event base. Because of this, there is no standard
393 method to set the event base in the DNS API: those are all added as
394 extensions. The API is distributed as a core package and one or more sets of
395 extensions to align with event libraries. It is mandatory to use one of the extension
396 functions to set the event base in the DNS context; this is required before
397 calling any event-driven calls like the <code>getdns</code> functions.</p>
398
399 <p>Each implementation of the DNS API will specify an extension function that
400 tells the DNS context which event base is being used. For example, one
401 implementation of this API that uses the libevent event library might name
402 this function "<code>getdns_extension_set_libevent_base()</code>" while
403 another might name it
404 "<code>getdns_extension_set_eventbase_for_libevent()</code>"; the two
405 extension functions could have very different calling patterns and return
406 values. Thus, the application developer <i>must</i> read the API documentation
407 (not just this design document) in order to determine what extension function
408 to use to tell the API the event base to use.</p>
409
410 <p>The structure of a typical event-driven application might look like the following pseudocode.
411 The code in italics is specific to the event mechanism.</p>
412
413 <pre>
414 Includes for one or more regular C libraries
415 <i>An include for the getdns library specific to the event library you use</i>
416 Definition of your callback function
417 Get the DNS data from the allocated pointer
418 Process that data
419 Check for errors
420 Definition of main()
421 Create context
422 <i>Set up your event base</i>
423 <i>Point the context to your event base</i>
424 Set up the getdns call arguments
425 Make the getdns call
426 Check if the getdns return is good
427 Destroy the context
428 Exit
429 </pre>
430
431 <p>The API does not have direct support for a polling interface. Instead, the callback interface is
432 specifically designed to allow an application that wants to process results in polling instead of in
433 callbacks to be able to create its own polling interface fairly trivially. Such a program would
434 create a data structure for the calls, including their <code>transaction_id</code> and
435 <code>userarg</code>. The <code>userarg</code> could be the polling data structure or have a pointer to it.
436 The application would have just
437 one callback function for all requests, and that function would copy the <code>response</code> into
438 application memory, update the data structure based on the <code>transaction_id</code> index,
439 and return from the callback. The polling code could then check the data structure for any updates
440 at its leisure.</p>
441
442 <h2>1.9 Calling the API Synchronously (Without Events)</h2>
443
444 <p>Thare are functions parallel to the four <code>getdns</code> async functions,
445 except that there is no callback. That is, when an application calls one of these
446 synchronous functions, the
447 API gathers all the required information and then returns the result. The value returned is exactly the
448 same as the response returned in the callback if you had used the async version of the function.</p>
449
450 <div class=forh>getdns_return_t
451 getdns_general_sync(
452 getdns_context *context,
453 const char *name,
454 uint16_t request_type,
455 getdns_dict *extensions,
456 getdns_dict **response
457 );
458 </div>
459
460 <div class=forh>getdns_return_t
461 getdns_address_sync(
462 getdns_context *context,
463 const char *name,
464 getdns_dict *extensions,
465 getdns_dict **response
466 );
467 </div>
468
469 <div class=forh>getdns_return_t
470 getdns_hostname_sync(
471 getdns_context *context,
472 getdns_dict *address,
473 getdns_dict *extensions,
474 getdns_dict **response
475 );
476 </div>
477
478 <div class=forh>getdns_return_t
479 getdns_service_sync(
480 getdns_context *context,
481 const char *name,
482 getdns_dict *extensions,
483 getdns_dict **response
484 );
485 </div>
486
487 <p>When you are done with the data in the response, use the following function so that the API can
488 free the memory from its internal pool.</p>
489
490 <div class=forh>void
491 getdns_dict_destroy(
492 getdns_dict *response
493 );
494 </div>
495
496 <h1>2. Data structures in the API</h1>
497
498 <p>The API returns data structures. The data structure is not a representational language like JSON:
499 it is really just a data structure. Data structures can have four types of members:</p>
500
501 <ul>
502
503 <li><span class=default>list</span> is an ordered list, like JSON and Python lists.
504 The members of the list can be any of the four data types.</li>
505
506 <li><span class=default>dict</span> is a name-value pair, like a JSON object or Python dict. The
507 name is a string literal, and the value can be any of the four data types. The order of the
508 name-value pairs in a dict is not important.</li>
509
510 <li><span class=default>int</span> is an integer compatible with uint32_t.</li>
511
512 <li><span class=default>bindata</span> is a struct to hold binary data. It is defined as
513 <code>{ size_t size; uint8_t *binary_stuff; }</code>.</li>
514
515 </ul>
516
517 <p>The API comes with helper functions to get data from the list and dict data types:</p>
518
519 <div class=forh id="datagetters">
520 /* Lists: get the length, get the data_type of the value at a given
521 position, and get the data at a given position */
522 getdns_return_t getdns_list_get_length(const getdns_list *this_list, size_t *answer);
523 getdns_return_t getdns_list_get_data_type(const getdns_list *this_list, size_t index, getdns_data_type *answer);
524 getdns_return_t getdns_list_get_dict(const getdns_list *this_list, size_t index, getdns_dict **answer);
525 getdns_return_t getdns_list_get_list(const getdns_list *this_list, size_t index, getdns_list **answer);
526 getdns_return_t getdns_list_get_bindata(const getdns_list *this_list, size_t index, getdns_bindata **answer);
527 getdns_return_t getdns_list_get_int(const getdns_list *this_list, size_t index, uint32_t *answer);
528
529 /* Dicts: get the list of names, get the data_type of the
530 value at a given name, and get the data at a given name */
531 getdns_return_t getdns_dict_get_names(const getdns_dict *this_dict, getdns_list **answer);
532 getdns_return_t getdns_dict_get_data_type(const getdns_dict *this_dict, const char *name, getdns_data_type *answer);
533 getdns_return_t getdns_dict_get_dict(const getdns_dict *this_dict, const char *name, getdns_dict **answer);
534 getdns_return_t getdns_dict_get_list(const getdns_dict *this_dict, const char *name, getdns_list **answer);
535 getdns_return_t getdns_dict_get_bindata(const getdns_dict *this_dict, const char *name, getdns_bindata **answer);
536 getdns_return_t getdns_dict_get_int(const getdns_dict *this_dict, const char *name, uint32_t *answer);
537 </div>
538
539 <p>All of these helper getter functions return <code>GETDNS_RETURN_GOOD</code> if the call is successful.
540 The list functions will return <code>GETDNS_RETURN_NO_SUCH_LIST_ITEM</code> if the index argument is
541 out of range; the dict functions will return <code>GETDNS_RETURN_NO_SUCH_DICT_NAME</code> if the name
542 argument doesn't exist in the dict. The functions also return <code>GETDNS_RETURN_WRONG_TYPE_REQUESTED</code>
543 if the requested data type doesn't match the contents of the indexed argument or name.</p>
544
545 <p>This document uses graphical representations of data structures. It is important to note that
546 this is only a graphical representation; the brackets, commas, quotation marks, comments, and so on
547 are not part of the data. Also, this document uses macro names instead of some of the int
548 arguments; of course, the data structures have the actual int in them.</p>
549
550 <p>The helper getter functions return references to <code>getdns_dict</code>, <code>getdns_list</code> and <code>getdns_bindata</code> data structures.
551 The user must not directly destroy these retrieved "child" data structures; instead,
552 they will automatically be destroyed when the containing "parent" data structure is destroyed.
553 Because of this, retrieved "child" data structures cannot be used any more after the containing "parent" data structure has been destroyed.</p>
554
555 <h2>2.1 Creating Data Structures</h2>
556
557 <p>Some of the features of the API require that you create your own data structures to be used in
558 arguments passed to the API. For example, if you want to use any extensions for the calling functions,
559 you need to create a dict. The requisite functions are:</p>
560
561 <div class=forh id="datasetters">
562 /* Lists: create, destroy, and set the data at a given position */
563 getdns_list * getdns_list_create();
564 getdns_list * getdns_list_create_with_context(
565 getdns_context *context
566 );
567 getdns_list * getdns_list_create_with_memory_functions(
568 void *(*malloc)(size_t),
569 void *(*realloc)(void *, size_t),
570 void (*free)(void *)
571 );
572 getdns_list * getdns_list_create_with_extended_memory_functions(
573 void *userarg,
574 void *(*malloc)(void *userarg, size_t),
575 void *(*realloc)(void *userarg, void *, size_t),
576 void (*free)(void *userarg, void *)
577 );
578 void getdns_list_destroy(getdns_list *this_list);
579 getdns_return_t getdns_list_set_dict(getdns_list *this_list, size_t index, const getdns_dict *child_dict);
580 getdns_return_t getdns_list_set_list(getdns_list *this_list, size_t index, const getdns_list *child_list);
581 getdns_return_t getdns_list_set_bindata(getdns_list *this_list, size_t index, const getdns_bindata *child_bindata);
582 getdns_return_t getdns_list_set_int(getdns_list *this_list, size_t index, uint32_t child_uint32);
583
584 /* Dicts: create, destroy, and set the data at a given name */
585 getdns_dict * getdns_dict_create();
586 getdns_dict * getdns_dict_create_with_context(
587 getdns_context *context
588 );
589 getdns_dict * getdns_dict_create_with_memory_functions(
590 void *(*malloc)(size_t),
591 void *(*realloc)(void *, size_t),
592 void (*free)(void *)
593 );
594 getdns_dict * getdns_dict_create_with_extended_memory_functions(
595 void *userarg,
596 void *(*malloc)(void *userarg, size_t),
597 void *(*realloc)(void *userarg, void *, size_t),
598 void (*free)(void *userarg, void *)
599 );
600 void getdns_dict_destroy(getdns_dict *this_dict);
601 getdns_return_t getdns_dict_set_dict(getdns_dict *this_dict, const char *name, const getdns_dict *child_dict);
602 getdns_return_t getdns_dict_set_list(getdns_dict *this_dict, const char *name, const getdns_list *child_list);
603 getdns_return_t getdns_dict_set_bindata(getdns_dict *this_dict, const char *name, const getdns_bindata *child_bindata);
604 getdns_return_t getdns_dict_set_int(getdns_dict *this_dict, const char *name, uint32_t child_uint32);
605 getdns_return_t getdns_dict_remove_name(getdns_dict *this_dict, const char *name);
606 </div>
607
608 <p>Lists are extended with the <code>getdns_list_set_</code> calls with the <code>index</code> set to the
609 size of the list (such as 0 for an empty list). Dicts are extended with the <code>getdns_dict_set_</code> calls
610 with the <code>name</code> set to a name that does not yet exist. Name-value pairs are removed with
611 <code>getdns_dict_remove_name()</code>.</p>
612
613 <p>These helper setter functions return <code>GETDNS_RETURN_GOOD</code> if the call is successful.
614 The functions return <code>GETDNS_RETURN_WRONG_TYPE_REQUESTED</code> if the requested data type
615 doesn't match the contents of the indexed argument or name. The list functions will return
616 <code>GETDNS_RETURN_NO_SUCH_LIST_ITEM</code> if the index argument is higher than the length of the
617 list. <code>getdns_dict_remove_name()</code> will return
618 <code>GETDNS_RETURN_NO_SUCH_DICT_NAME</code> if the name argument doesn't exist in the dict. </p>
619
620 <p>The helper setter functions store copies of the given "child" values.
621 It is the responsibility of the caller to dispose of the original values.</p>
622
623 <h1>3. <a id="Extensions">Extensions</a></h1>
624
625 <p>Extensions are dict data structures. The names in the dict are the names of the extensions.
626 The definition of each extension describes the value associated with the name. For most extensions,
627 it is an on-off boolean, and the value is <code>GETDNS_EXTENSION_TRUE</code>. (There is
628 not currently a good reason to specify an extension name and give it a value of <code>GETDNS_EXTENSION_FALSE</code>,
629 but that is allowed by the API.)</p>
630
631 <p>For example, to create a dict for extensions and specify the extension to only return
632 results that have been validated with DNSSEC, you might use:</p>
633
634 <pre>
635 /* . . . */
636 getdns_dict * this_extensions = getdns_dict_create();
637 this_ret = getdns_dict_set_int(this_extensions, "dnssec_return_only_secure", GETDNS_EXTENSION_TRUE);
638 /* . . . Do some processing with the extensions and results . . . */
639 /* Remember to clean up memory*/
640 getdns_dict_destroy(this_extensions);
641 </pre>
642
643 <p>The extensions described in this section are are:
644
645 <ul>
646
647 <li><code>dnssec_return_status</code></li>
648
649 <li><code>dnssec_return_only_secure</code></li>
650
651 <li><code>dnssec_return_validation_chain</code></li>
652
653 <li><code>return_both_v4_and_v6</code></li>
654
655 <li><code>add_opt_parameters</code></li>
656
657 <li><code>add_warning_for_bad_dns</code></li>
658
659 <li><code>specify_class</code></li>
660
661 <li><code>return_call_debugging</code></li>
662
663 </ul>
664
665 <h2>3.1 Extensions for DNSSEC</h2>
666
667 <p>If an application wants the API to do DNSSEC validation for a request, it must set one or more DNSSEC-related extensions.
668 Note that the default is for none of these extensions to be set and the API will not perform DNSSEC.
669 Note that getting DNSSEC results can take longer in a few circumstances.</p>
670
671 <p>To return the DNSSEC status for each DNS record in the <code>replies_tree</code> list, use the
672 <code>dnssec_return_status</code> extension. The extension's value (an int) is set to
673 <code>GETDNS_EXTENSION_TRUE</code> to cause the returned status to have the name
674 <code>dnssec_status</code> (an int) added to the other names in the record's dict ("header",
675 "question", and so on). The values for that name are <code>GETDNS_DNSSEC_SECURE</code>,
676 <code>GETDNS_DNSSEC_BOGUS</code>, <code>GETDNS_DNSSEC_INDETERMINATE</code>, and
677 <code>GETDNS_DNSSEC_INSECURE</code>. Thus, a reply might look like:</p>
678
679 <pre>
680 { # This is the first reply
681 "dnssec_status": GETDNS_DNSSEC_INDETERMINATE,
682 "header": { "id": 23456, "qr": 1, "opcode": 0, ... },
683 . . .
684 </pre>
685
686 <p>If instead of returning the status, you want to only see secure results, use the
687 <code>dnssec_return_only_secure</code> extension. The extension's value (an int) is set to
688 <code>GETDNS_EXTENSION_TRUE</code> to cause only records that the API can validate as secure with
689 DNSSEC to be returned in the <code>replies_tree</code> and <code>replies_full</code> lists. No
690 additional names are added to the dict of the record; the change is that some records might not
691 appear in the results. When this context option is set, if the API receives DNS replies but none
692 are determined to be secure, the error code at the top level of the response object is
693 <code>GETDNS_RESPSTATUS_NO_SECURE_ANSWERS</code>.</p>
694
695 <p>Applications that want to do their own validation will want to have the DNSSEC-related records
696 for a particular response. Use the <code>dnssec_return_validation_chain</code> extension. The
697 extension's value (an int) is set to <code>GETDNS_EXTENSION_TRUE</code> to cause a set
698 of additional DNSSEC-related records needed for validation to be returned in the response object.
699 This set comes as <code>validation_chain</code> (a list) at the top level of the response object.
700 This list includes all resource record dicts for all the resource records (DS, DNSKEY and their RRSIGs) that are needed to perform the validation from the root up. Thus, a reply might look like:</p>
701
702 <pre>
703 { # This is the response object
704 "validation_chain":
705 [ { "name": &lt;bindata for .&gt;,
706 "type": GETDNS_RRTYPE_DNSKEY,
707 "rdata": { "flags": 256, . . . },
708 . . .
709 },
710 { "name": &lt;bindata for .&gt;,
711 "type": GETDNS_RRTYPE_DNSKEY,
712 "rdata": { "flags": 257, . . . },
713 . . .
714 },
715 { "name": &lt;bindata for .&gt;,
716 "type": GETDNS_RRTYPE_RRSIG,
717 "rdata": { "signers_name": &lt;bindata for .&gt;,
718 "type_covered": GETDNS_RRTYPE_DNSKEY,
719 . . .
720 },
721 },
722 { "name": &lt;bindata for com.&gt;,
723 "type": GETDNS_RRTYPE_DS,
724 . . .
725 },
726 { "name": &lt;bindata for com.&gt;,
727 "type": GETDNS_RRTYPE_RRSIG
728 "rdata": { "signers_name": &lt;bindata for .&gt;,
729 "type_covered": GETDNS_RRTYPE_DS,
730 . . .
731 },
732 . . .
733 },
734 { "name": &lt;bindata for com.&gt;,
735 "type": GETDNS_RRTYPE_DNSKEY
736 "rdata": { "flags": 256, . . . },
737 . . .
738 },
739 { "name": &lt;bindata for com.&gt;,
740 "type": GETDNS_RRTYPE_DNSKEY
741 "rdata": { "flags": 257, . . . },
742 . . .
743 },
744 { "name": &lt;bindata for com.&gt;,
745 "type": GETDNS_RRTYPE_RRSIG
746 "rdata": { "signers_name": &lt;bindata for com.&gt;,
747 "type_covered": GETDNS_RRTYPE_DNSKEY,
748 . . .
749 },
750 . . .
751 },
752 { "name": &lt;bindata for example.com.&gt;,
753 "type": GETDNS_RRTYPE_DS,
754 . . .
755 },
756 { "name": &lt;bindata for example.com.&gt;,
757 "type": GETDNS_RRTYPE_RRSIG
758 "rdata": { "signers_name": &lt;bindata for com.&gt;,
759 "type_covered": GETDNS_RRTYPE_DS,
760 . . .
761 },
762 . . .
763 },
764 { "name": &lt;bindata for example.com.&gt;,
765 "type": GETDNS_RRTYPE_DNSKEY
766 "rdata": { "flags": 257, ... },
767 . . .
768 },
769 . . .
770 ]
771 "replies_tree":
772 [
773 . . .
774 </pre>
775
776 <p>If a request is using a context in which stub resolution is set, and that request also has
777 any of the <code>dnssec_return_status</code>, <code>dnssec_return_only_secure</code>, or
778 <code>dnssec_return_validation_chain</code> extensions specified, the API will not perform
779 the request and will instead return an error of <code>GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED</code>.</p>
780
781 <h2>3.2 Returning Both IPv4 and IPv6 Responses</h2>
782
783 <p>Many applications want to get both IPv4 and IPv6 addresses in a single call so that the results
784 can be processed together. The <code>getdns_address</code> and <code>getdns_address_sync</code>
785 functions are able to do this automatically. If you are using the <code>getdns_general</code> or
786 <code>getdns_general_sync</code> function, you can enable this with the
787 <code>return_both_v4_and_v6</code> extension. The extension's value (an int) is set to
788 <code>GETDNS_EXTENSION_TRUE</code> to cause the results to be the lookup of either A or AAAA records
789 to include any A and AAAA records for the queried name (otherwise, the extension does nothing).
790 These results are expected to be used with Happy Eyeballs systems that will find the best socket for
791 an application.</p>
792
793 <h2>3.3 Setting Up OPT Resource Records</h2>
794
795 <p>For lookups that need an OPT resource record in the Additional Data section, use the
796 <code>add_opt_parameters</code> extension. The extension's value (a dict) contains the
797 parameters; these are described in more detail in RFC 2671. They are:</p>
798
799 <ul>
800
801 <li><code>maximum_udp_payload_size</code> (an int), a value between 512 and 65535; if not specified,
802 this defaults to those from the DNS context</li>
803
804 <li><code>extended_rcode</code> (an int), a value between 0 and 255; if not specified,
805 this defaults to those from the DNS context</li>
806
807 <li><code>version</code> (an int), a value between 0 and 255; if not specified, this
808 defaults to 0</li>
809
810 <li><code>do_bit</code> (an int), a value between 0 and 1; if not specified, this defaults
811 to those from the DNS context</li>
812
813 <li><code>options</code> (a list) contains dicts for each option to be specified.
814 Each list time contains two names: <code>option_code</code> (an int) and <code>option_data</code>
815 (a bindata). The API marshalls the entire set of options into a properly-formatted RDATA
816 for the resource record.</li>
817
818 </ul>
819
820 <p>It is very important to note that the OPT resource record specified in the
821 <code>add_opt_parameters</code> extension might not be the same the one that the API sends in the
822 query. For example, if the application also includes any of the DNSSEC extensions, the API will make
823 sure that the OPT resource record sets the resource record appropriately, making the needed changes
824 to the settings from the <code>add_opt_parameters</code> extension.</p>
825
826 <p>The use of this extension can conflict with the values in the DNS context. For example,
827 the default for an OS might be a maximum payload size of 65535, but the extension might specify
828 1550. In such a case, the API will honor the values stated in the extension, but will honor the
829 values from the DNS context if values are not given in the extension.</p>
830
831 <h2>3.4 Getting Warnings for Responses that Violate the DNS Standard</h2>
832
833 <p>To receive a warning if a particular response violates some parts of the DNS standard, use
834 the <code>add_warning_for_bad_dns</code> extension. The extension's value (an int) is set to
835 <code>GETDNS_EXTENSION_TRUE</code> to cause each reply in the <code>replies_tree</code>
836 to contain an additional name, <code>bad_dns</code> (a list). The list is zero or more
837 ints that indicate types of bad DNS found in that reply. The list of values is:
838
839 <p class=define>GETDNS_BAD_DNS_CNAME_IN_TARGET</p>
840 <p class=descrip>A DNS query type that does not allow a target to be a CNAME pointed to a CNAME</p>
841 <p class=define>GETDNS_BAD_DNS_ALL_NUMERIC_LABEL</p>
842 <p class=descrip>One or more labels in a returned domain name is all-numeric; this is not legal for a hostname</p>
843 <p class=define>GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE</p>
844 <p class=descrip>A DNS query for a type other than CNAME returned a CNAME response</p>
845
846
847 <h2>3.5 Using Other Class Types</h2>
848
849 <p>The vast majority of DNS requests are made with the Internet (IN) class. To make a request in a
850 different DNS class, use, the <code>specify_class</code> extension. The extension's value (an int)
851 contains the class number. Few applications will ever use this extension.</p>
852
853 <h2>3.6 Extensions Relating to the API</h2>
854
855 <p>An application might want to see debugging information for queries such as the length of time it
856 takes for each query to return to the API. Use the <code>return_call_debugging</code> extension. The
857 extension's value (an int) is set to <code>GETDNS_EXTENSION_TRUE</code> to add the name
858 <code>call_debugging</code> (a list) to the top level of the response object. Each member of the
859 list is a dict that represents one call made for the call to the API. Each member has the following
860 names:</p>
861
862 <ul>
863 <li><code>query_name</code> (a bindata) is the name that was sent</li>
864 <li><code>query_type</code> (an int) is the type that was queried for</li>
865 <li><code>query_to</code> (a bindata) is the address to which the query was sent</li>
866 <li><code>start_time</code> (a bindata) is the time the query started in milliseconds since the epoch,
867 represented as a uint64_t</li>
868 <li><code>end_time</code> (a bindata) is the time the query was received in milliseconds since the epoch,
869 represented as a uint64_t</li>
870 <li><code>entire_reply</code> (a bindata) is the entire response received</li>
871 <li><code>dnssec_result</code> (an int) is the DNSSEC status, or <code>GETDNS_DNSSEC_NOT_PERFORMED</code>
872 if DNSSEC validation was not performed</li>
873 </ul>
874
875 <h1>4. Response Data from Queries</h1>
876
877 <p>The callback function contains a pointer to a response object.
878 A response object is always a dict. The response
879 object always contains at least three names: <code>replies_full</code> (a list) and
880 <code>replies_tree</code> (a list), and <code>status</code> (an int).
881 <code>replies_full</code> is a list of DNS replies (each is bindata) as they appear on the wire.
882 <code>replies_tree</code> is a list of DNS replies (each is a dict) with the various part of the
883 reply parsed out. <code>status</code> is a status code for the query.</p>
884
885 <p>Because the API might be extended in the future, a response object might also contain names other
886 than <code>replies_full</code>, <code>replies_tree</code>, and <code>status</code>. Similarly, any
887 of the dicts described here might be extended in later versions of the API. Thus, an application
888 using the API must not assume that it knows all possible names in a dict.</p>
889
890 <p>The following lists the status codes for response objects. Note that, if the status is that there
891 are no responses for the query, the lists in <code>replies_full</code> and <code>replies_tree</code>
892 will have zero length.</p>
893
894 <p class=define>GETDNS_RESPSTATUS_GOOD</p>
895 <p class=descrip>At least one response was returned</p>
896 <p class=define>GETDNS_RESPSTATUS_NO_NAME</p>
897 <p class=descrip>Queries for the name yielded all negative responses</p>
898 <p class=define>GETDNS_RESPSTATUS_ALL_TIMEOUT</p>
899 <p class=descrip>All queries for the name timed out</p>
900 <p class=define>GETDNS_RESPSTATUS_NO_SECURE_ANSWERS</p>
901 <p class=descrip>The context setting for getting only secure responses was specified, and at least one DNS response was received, but no DNS response was determined to be secure through DNSSEC.</p>
902
903
904 <p>The top level of <code>replies_tree</code> can optionally have the following names: <code>canonical_name</code> (a
905 bindata), <code>intermediate_aliases</code> (a list), <code>answer_ipv4_address</code> (a bindata),
906 <code>answer_ipv6_address</code> (a bindata), and <code>answer_type</code> (an int).</p>
907
908 <ul>
909
910 <li>The value of <code>canonical_name</code> is the name that the API used for its lookup. It is in
911 FQDN presentation format.</li>
912
913 <li>The values in the <code>intermediate_aliases</code> list are domain names from any CNAME or
914 unsynthesized DNAME found when resolving the original query. The list might have zero entries
915 if there were no CNAMEs in the path. These may be useful, for example, for name comparisons
916 when following the rules in RFC 6125.</li>
917
918 <li>The value of <code>answer_ipv4_address</code> and <code>answer_ipv6_address</code> are
919 the addresses of the server from which the answer was received.</li>
920
921 <li>The value of <code>answer_type</code> is the type of name service that generated the response.
922 The values are:</li>
923
924 </ul>
925
926 <p class=define>GETDNS_NAMETYPE_DNS</p>
927 <p class=descrip>Normal DNS (RFC 1035)</p>
928 <p class=define>GETDNS_NAMETYPE_WINS</p>
929 <p class=descrip>The WINS name service (some reference needed)</p>
930
931
932 <p>If the call was <code>getdns_address</code> or <code>getdns_address_sync</code>, the top level
933 of <code>replies_tree</code> has an additional name, <code>just_address_answers</code> (a list).
934 The value of <code>just_address_answers</code> is a list that contains all of the A and AAAA
935 records from the answer sections of any of the replies, in the order they appear in the replies.
936 Each item in the list is a dict with at least two names: <code>address_type</code> (whose value is
937 a bindata; it is currently either "IPv4" or "IPv6") and <code>address_data</code> (whose value is a bindata).
938 Note that the <code>dnssec_return_only_secure</code> extension affects
939 what will appear in the <code>just_address_answers</code> list. Also note if later versions of the
940 DNS return other address types, those types will appear in this list as well.</p>
941
942 <p>The API can make service discovery through SRV records easier. If
943 the call was <code>getdns_service</code> or <code>getdns_service_sync</code>,
944 the top level of <code>replies_tree</code> has an additional name,
945 <code>srv_addresses</code> (a list).
946 The list is ordered by priority and weight based on the weighting
947 algorithm in RFC 2782, lowest priority value first. Each element
948 of the list is dict has at least two names: <code>port</code> and <code>domain_name</code>. If the
949 API was able to determine the address of the target domain name (such as from its cache or from the
950 Additional section of responses), the dict for an element will also contain
951 <code>address_type</code> (whose value is a bindata; it is currently either "IPv4" or "IPv6") and
952 <code>address_data</code> (whose value is a bindata). Note that the
953 <code>dnssec_return_only_secure</code> extension affects what will appear in the
954 <code>srv_addresses</code> list.</p>
955
956 <h2>4.1 Structure of DNS <code>replies_tree</code></h2>
957
958 <p>The names in each entry in the the <code>replies_tree</code> list for DNS responses include
959 <code>header</code> (a dict), <code>question</code> (a dict), <code>answer</code> (a list),
960 <code>authority</code> (a list), and <code>additional</code> (a list), corresponding to the sections
961 in the DNS message format. The answer, authority, and additional lists each contain zero or more
962 dicts, with each dict in each list representing a resource record.</p>
963
964 <p>The names in the <code>header</code> dict are all the fields from Section 4.1.1. of RFC 1035.
965 They are: <code>id</code>, <code>qr</code>, <code>opcode</code>, <code>aa</code>, <code>tc</code>,
966 <code>rd</code>, <code>ra</code>, <code>z</code>, <code>rcode</code>, <code>qdcount</code>,
967 <code>ancount</code>, <code>nscount</code>, and <code>arcount</code>. All are ints.</p>
968
969 <p>The names in the <code>question</code> dict are the three fields from Section 4.1.2. of RFC 1035:
970 <code>qname</code> (a bindata), <code>qtype</code> (an int), and <code>qclass</code> (an int).</p>
971
972 <p>Resource records are a bit different than headers and question sections in that the RDATA portion
973 often has its own structure. The other names in the resource record dicts are <code>name</code> (a
974 bindata), <code>type</code> (an int), <code>class</code> (an int), <code>ttl</code> (an int) and
975 <code>rdata</code> (a dict); there is no name equivalent to the RDLENGTH field.
976 The <code>OPT</code> resource record does not have the <code>class</code> and the <code>ttl</code> name, but in stead provides <code>udp_payload_size</code> (an int), <code>extended_rcode</code> (an int), <code>version</code> (an int), <code>do</code> (an int), and <code>z</code> (an int).</p>
977
978 <p>The <code>rdata</code> dict has different names for each response type. There is a <a
979 href="#TypeList">complete list of the types defined</a> in the API. For names that end in
980 "-obsolete" or "-unknown", the bindata is the entire RDATA field. For example, the
981 <code>rdata</code> for an A record has a name <code>ipv4_address</code> (a bindata); the
982 <code>rdata</code> for an SRV record has the names <code>priority</code> (an int),
983 <code>weight</code> (an int), <code>port</code> (an int), and <code>target</code> (a bindata).</p>
984
985 <p>Each <code>rdata</code> dict also has a <code>rdata_raw</code> field (a bindata). This is useful
986 for types not defined in this version of the API. It also might be of value if a later version of
987 the API allows for additional parsers. Thus, doing a query for types not known by the API still will
988 return a result: an <code>rdata</code> with just a <code>rdata_raw</code>.</p>
989
990 <p>It is expected that later extensions to the API will give some DNS types different names. It is
991 also possible that later extensions will change the names for some of the DNS types listed above.</p>
992
993 <p>For example, a response to a <code>getdns_address()</code> call for www.example.com would
994 look something like this:</p>
995
996 <pre>
997 { # This is the response object
998 "replies_full": [ &lt;bindata of the first response&gt;, &lt;bindata of the second response&gt; ],
999 "just_address_answers":
1000 [
1001 {
1002 "address_type": &lt;bindata of "IPv4"&gt;,
1003 "address_data": &lt;bindata of 0x0a0b0c01&gt;,
1004 },
1005 {
1006 "address_type": &lt;bindata of "IPv6"&gt;,
1007 "address_data": &lt;bindata of 0x33445566334455663344556633445566&gt;
1008 }
1009 ],
1010 "canonical_name": &lt;bindata of "www.example.com"&gt;,
1011 "answer_type": GETDNS_NAMETYPE_DNS,
1012 "intermediate_aliases": [],
1013 "replies_tree":
1014 [
1015 { # This is the first reply
1016 "header": { "id": 23456, "qr": 1, "opcode": 0, ... },
1017 "question": { "qname": &lt;bindata of "www.example.com"&gt;, "qtype": 1, "qclass": 1 },
1018 "answer":
1019 [
1020 {
1021 "name": &lt;bindata of "www.example.com"&gt;,
1022 "type": 1,
1023 "class": 1,
1024 "ttl": 33000,
1025 "rdata":
1026 {
1027 "ipv4_address": &lt;bindata of 0x0a0b0c01&gt;
1028 "rdata_raw": &lt;bindata of 0x0a0b0c01&gt;
1029 }
1030 }
1031 ],
1032 "authority":
1033 [
1034 {
1035 "name": &lt;bindata of "ns1.example.com"&gt;,
1036 "type": 1,
1037 "class": 1,
1038 "ttl": 600,
1039 "rdata":
1040 {
1041 "ipv4_address": &lt;bindata of 0x65439876&gt;
1042 "rdata_raw": &lt;bindata of 0x65439876&gt;
1043 }
1044 }
1045 ]
1046 "additional": [],
1047 "canonical_name": &lt;bindata of "www.example.com"&gt;,
1048 "answer_type": GETDNS_NAMETYPE_DNS
1049 },
1050 { # This is the second reply
1051 "header": { "id": 47809, "qr": 1, "opcode": 0, ... },
1052 "question": { "qname": &lt;bindata of "www.example.com"&gt;, "qtype": 28, "qclass": 1 },
1053 "answer":
1054 [
1055 {
1056 "name": &lt;bindata of "www.example.com"&gt;,
1057 "type": 28,
1058 "class": 1,
1059 "ttl": 1000,
1060 "rdata":
1061 {
1062 "ipv6_address": &lt;bindata of 0x33445566334455663344556633445566&gt;
1063 "rdata_raw": &lt;bindata of 0x33445566334455663344556633445566&gt;
1064 }
1065 }
1066 ],
1067 "authority": [ # Same as for other record... ]
1068 "additional": [],
1069 },
1070 ]
1071 }
1072 </pre>
1073
1074 <p>In DNS responses, domain names are treated special. RFC 1035 describes a form of name compression
1075 that requires that the entire record be available for analysis. The API deals with this by
1076 converting compressed names into full names when returning names in the <code>replies_tree</code>.
1077 This conversion happens for <code>qname</code> in <code>question</code>; <code>name</code> in the
1078 <code>answer</code>, <code>authority</code>, and <code>additional</code>; and in domain names in the
1079 data in names under <code>rdata</code> where the response type is AFSDB, CNAME, MX, NS, PTR, RP, RT, and SOA.</p>
1080
1081 <h2>4.2 Converting Domain Names</h2>
1082
1083 <p>Names in DNS fields are stored in a fashion very different from the normal presentation format
1084 normally used in applications. The DNS format is described in the first paragraph in Section 3.1 of
1085 RFC 1035; the presentation format here is a null-terminated string with interior dots. These helper
1086 functions only work with names in the DNS format that are not compressed. They are useful for
1087 converting domain names in the <code>replies_tree</code> to and from the FQDN presentation
1088 format.</p>
1089
1090 <p><code>getdns_convert_dns_name_to_fqdn()</code> converts a domain name in DNS format to the
1091 presentation format. For example, the hex sequence <code>03 77 77 77 07 65 78 61 6d 70 6c 65 03 63
1092 6f 6d 00</code> would be converted to "www.example.com".
1093 <code>getdns_convert_fqdn_to_dns_name()</code> does the reverse: it converts a null-terminated
1094 string in FQDN format to bytes in DNS format.</p>
1095
1096 <div class=forh>
1097 getdns_return_t
1098 getdns_convert_dns_name_to_fqdn(
1099 const getdns_bindata *dns_name_wire_fmt,
1100 char **fqdn_as_string
1101 );
1102
1103 getdns_return_t
1104 getdns_convert_fqdn_to_dns_name(
1105 const char *fqdn_as_string,
1106 getdns_bindata **dns_name_wire_fmt
1107 );
1108 </div>
1109
1110 <p>The returned values are allocated with the default system allocator, namely <code>malloc</code>.
1111 The caller is responsible of disposing these allocations with <code>free</code>. </p>
1112
1113 <h1>5. Additional Definitions and Descriptions</h1>
1114
1115 <h2>5.1 A Few Needed Definitions</h2>
1116
1117 <div class=forh id="Various">typedef struct getdns_context getdns_context;
1118 typedef uint64_t getdns_transaction_t;
1119 typedef enum getdns_data_type {
1120 t_dict, t_list, t_int, t_bindata
1121 } getdns_data_type;
1122 typedef struct getdns_bindata {
1123 size_t size;
1124 uint8_t *data;
1125 } getdns_bindata;
1126 typedef struct getdns_dict getdns_dict;
1127 typedef struct getdns_list getdns_list;
1128 </div>
1129
1130 <h2>5.2 <a id="ReturnCodes">Return Codes</a></h2>
1131
1132 <p>The return codes for all the functions are:</p>
1133
1134 <p class=define>GETDNS_RETURN_GOOD</p>
1135 <p class=descrip>Good</p>
1136 <p class=define>GETDNS_RETURN_GENERIC_ERROR</p>
1137 <p class=descrip>Generic error</p>
1138 <p class=define>GETDNS_RETURN_BAD_DOMAIN_NAME</p>
1139 <p class=descrip>Badly-formed domain name in first argument</p>
1140 <p class=define>GETDNS_RETURN_BAD_CONTEXT</p>
1141 <p class=descrip>The context has internal deficiencies</p>
1142 <p class=define>GETDNS_RETURN_CONTEXT_UPDATE_FAIL</p>
1143 <p class=descrip>Did not update the context</p>
1144 <p class=define>GETDNS_RETURN_UNKNOWN_TRANSACTION</p>
1145 <p class=descrip>An attempt was made to cancel a callback with a transaction_id that is not recognized</p>
1146 <p class=define>GETDNS_RETURN_NO_SUCH_LIST_ITEM</p>
1147 <p class=descrip>A helper function for lists had an index argument that was too high.</p>
1148 <p class=define>GETDNS_RETURN_NO_SUCH_DICT_NAME</p>
1149 <p class=descrip>A helper function for dicts had a name argument that for a name that is not in the dict.</p>
1150 <p class=define>GETDNS_RETURN_WRONG_TYPE_REQUESTED</p>
1151 <p class=descrip>A helper function was supposed to return a certain type for an item, but the wrong type was given.</p>
1152 <p class=define>GETDNS_RETURN_NO_SUCH_EXTENSION</p>
1153 <p class=descrip>A name in the extensions dict is not a valid extension.</p>
1154 <p class=define>GETDNS_RETURN_EXTENSION_MISFORMAT</p>
1155 <p class=descrip>One or more of the extensions have a bad format.</p>
1156 <p class=define>GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED</p>
1157 <p class=descrip>A query was made with a context that is using stub resolution and a DNSSEC extension specified.</p>
1158 <p class=define>GETDNS_RETURN_MEMORY_ERROR</p>
1159 <p class=descrip>Unable to allocate the memory required.</p>
1160 <p class=define>GETDNS_RETURN_INVALID_PARAMETER</p>
1161 <p class=descrip>A required parameter had an invalid value.</p>
1162
1163
1164 <h2>5.3 <a id="TypeList">Types of RDATA Returned in the API</a></h2>
1165
1166 <p>The names in the <code>rdata</code> dicts in replies are:</p>
1167
1168
1169 <p class=define>A (1)</p>
1170 <p class=descrip><code>ipv4_address</code> (a bindata)</p>
1171
1172 <p class=define>NS (2)</p>
1173 <p class=descrip><code>nsdname</code> (a bindata)</p>
1174
1175 <p class=define>MD (3)</p>
1176 <p class=descrip><code>madname</code> (a bindata)</p>
1177
1178 <p class=define>MF (4)</p>
1179 <p class=descrip><code>madname</code> (a bindata)</p>
1180
1181 <p class=define>CNAME (5)</p>
1182 <p class=descrip><code>cname</code> (a bindata)</p>
1183
1184 <p class=define>SOA (6)</p>
1185 <p class=descrip><code>mname</code> (a bindata), <code>rname</code> (a bindata),
1186 <code>serial</code> (an int), <code>refresh</code> (an int), <code>refresh</code> (an int),
1187 <code>retry</code> (an int), and <code>expire</code> (an int)</p>
1188
1189 <p class=define>MB (7)</p>
1190 <p class=descrip><code>madname</code> (a bindata)</p>
1191
1192 <p class=define>MG (8)</p>
1193 <p class=descrip><code>mgmname</code> (a bindata)</p>
1194
1195 <p class=define>MR (9)</p>
1196 <p class=descrip><code>newname</code> (a bindata)</p>
1197
1198 <p class=define>NULL (10)</p>
1199 <p class=descrip><code>anything</code> (a bindata)</p>
1200
1201 <p class=define>WKS (11)</p>
1202 <p class=descrip><code>address</code> (a bindata), <code>protocol</code> (an int),
1203 and <code>bitmap</code> (a bindata)</p>
1204
1205 <p class=define>PTR (12)</p>
1206 <p class=descrip><code>ptrdname</code> (a bindata)</p>
1207
1208 <p class=define>HINFO (13)</p>
1209 <p class=descrip><code>cpu</code> (a bindata) and <code>os</code> (a bindata)</p>
1210
1211 <p class=define>MINFO (14)</p>
1212 <p class=descrip><code>rmailbx</code> (a bindata) and <code>emailbx</code> (a bindata)</p>
1213
1214 <p class=define>MX (15)</p>
1215 <p class=descrip><code>preference</code> (an int) and <code>exchange</code> (a bindata)</p>
1216
1217 <p class=define>TXT (16)</p>
1218 <p class=descrip><code>txt_strings</code> (a list) which contains zero or more bindata elements
1219 that are text strings</p>
1220
1221 <p class=define>RP (17)</p>
1222 <p class=descrip><code>mbox_dname</code> (a bindata) and <code>txt_dname</code> (a bindata)</p>
1223
1224 <p class=define>AFSDB (18)</p>
1225 <p class=descrip><code>subtype</code> (an int) and <code>hostname</code> (a bindata)</p>
1226
1227 <p class=define>X25 (19)</p>
1228 <p class=descrip><code>psdn_address</code> (a bindata)</p>
1229
1230 <p class=define>ISDN (20)</p>
1231 <p class=descrip><code>isdn_address</code> (a bindata) and <code>sa</code> (a bindata)</p>
1232
1233 <p class=define>RT (21)</p>
1234 <p class=descrip><code>preference</code> (an int) and <code>intermediate_host</code> (a bindata)</p>
1235
1236 <p class=define>NSAP (22)</p>
1237 <p class=descrip><code>nsap</code> (a bindata)</p>
1238
1239 <p class=define>SIG (24)</p>
1240 <p class=descrip><code>sig_obsolete</code> (a bindata)</p>
1241
1242 <p class=define>KEY (25)</p>
1243 <p class=descrip><code>key_obsolete</code> (a bindata)</p>
1244
1245 <p class=define>PX (26)</p>
1246 <p class=descrip><code>preference</code> (an int), <code>map822</code> (a bindata), and <code>mapx400</code> (a bindata)</p>
1247
1248 <p class=define>GPOS (27)</p>
1249 <p class=descrip><code>longitude</code> (a bindata), <code>latitude</code> (a bindata), and <code>altitude</code> (a bindata)</p>
1250
1251 <p class=define>AAAA (28)</p>
1252 <p class=descrip><code>ipv6_address</code> (a bindata)</p>
1253
1254 <p class=define>LOC (29)</p>
1255 <p class=descrip><code>loc_obsolete</code> (a bindata)</p>
1256
1257 <p class=define>NXT (30)</p>
1258 <p class=descrip><code>nxt_obsolete</code> (a bindata)</p>
1259
1260 <p class=define>EID (31)</p>
1261 <p class=descrip><code>eid_unknown</code> (a bindata)</p>
1262
1263 <p class=define>NIMLOC (32)</p>
1264 <p class=descrip><code>nimloc_unknown</code> (a bindata)</p>
1265
1266 <p class=define>SRV (33)</p>
1267 <p class=descrip><code>priority</code> (an int), <code>weight</code> (an int),
1268 <code>port</code> (an int), and <code>target</code> (a bindata)</p>
1269
1270 <p class=define>ATMA (34)</p>
1271 <p class=descrip><code>format</code> (an int) and <code>address</code> (a bindata)</p>
1272
1273 <p class=define>NAPTR (35)</p>
1274 <p class=descrip><code>order</code> (an int), <code>preference</code> (an int), <code>flags</code>
1275 (a bindata), <code>service</code> (a bindata), <code>regexp</code> (a bindata), and
1276 <code>replacement</code> (a bindata).</p>
1277
1278 <p class=define>KX (36)</p>
1279 <p class=descrip><code>preference</code> (an int) and <code>exchanger</code> (a bindata)</p>
1280
1281 <p class=define>CERT (37)</p>
1282 <p class=descrip><code>type</code> (an int), <code>key_tag</code> (an int), <code>algorithm</code> (an int),
1283 and <code>certificate_or_crl</code> (a bindata)</p>
1284
1285 <p class=define>A6 (38)</p>
1286 <p class=descrip><code>a6_obsolete</code> (a bindata)</p>
1287
1288 <p class=define>DNAME (39)</p>
1289 <p class=descrip><code>target</code> (a bindata)</p>
1290
1291 <p class=define>SINK (40)</p>
1292 <p class=descrip><code>sink_unknown</code> (a bindata)</p>
1293
1294 <p class=define>OPT (41)</p>
1295 <p class=descrip><code>options</code> (a list). Each element of the <code>options</code> list is a
1296 dict with two names: <code>option_code</code> (an int) and <code>option_data</code> (a bindata).</p>
1297
1298 <p class=define>APL (42)</p>
1299 <p class=descrip><code>apitems</code> (a list).
1300 Each element of the <code>apitems</code> list is a dict with four names:
1301 <code>address_family</code> (an int), <code>prefix</code> (an int),
1302 <code>n</code> (an int), and <code>afdpart</code> (a bindata)</p>
1303
1304 <p class=define>DS (43)</p>
1305 <p class=descrip><code>key_tag</code> (an int), <code>algorithm</code> (an int), <code>digest_type</code> (an int),
1306 and <code>digest</code> (a bindata)</p>
1307
1308 <p class=define>SSHFP (44)</p>
1309 <p class=descrip><code>algorithm</code> (an int), <code>fp_type</code> (an int),
1310 and <code>fingerprint</code> (a bindata)</p>
1311
1312 <p class=define>IPSECKEY (45)</p>
1313 <p class=descrip><code>algorithm</code> (an int), <code>gateway_type</code> (an int), <code>precedence</code> (an int),
1314 <code>gateway</code>, and <code>public_key</code> (a bindata)</p>
1315
1316 <p class=define>RRSIG (46)</p>
1317 <p class=descrip> <code>type_covered</code> (an int), <code>algorithm</code> (an int),
1318 <code>labels</code> (an int), <code>original_ttl</code> (an int), <code>signature_expiration</code>
1319 (an int), <code>signature_inception</code> (an int), <code>key_tag</code> (an int),
1320 <code>signers_name</code> (a bindata), and <code>signature</code> (a bindata)</p>
1321
1322 <p class=define>NSEC (47)</p>
1323 <p class=descrip><code>next_domain_name</code> (a bindata) and <code>type_bit_maps</code> (a bindata)</p>
1324
1325 <p class=define>DNSKEY (48)</p>
1326 <p class=descrip><code>flags</code> (an int), <code>protocol</code> (an int), <code>algorithm</code> (an int),
1327 and <code>public_key</code> (a bindata)</p>
1328
1329 <p class=define>DHCID (49)</p>
1330 <p class=descrip><code>dhcid_opaque</code> (a bindata)</p>
1331
1332 <p class=define>NSEC3 (50)</p>
1333 <p class=descrip><code>hash_algorithm</code> (an int), <code>flags</code> (an int),
1334 <code>iterations</code> (an int), <code>salt</code> (a bindata),
1335 <code>next_hashed_owner_name</code> (a bindata), and
1336 <code>type_bit_maps</code> (a bindata)</p>
1337
1338 <p class=define>NSEC3PARAM (51)</p>
1339 <p class=descrip><code>hash_algorithm</code> (an int), <code>flags</code> (an int),
1340 <code>iterations</code> (an int), and
1341 <code>salt</code> (a bindata)</p>
1342
1343 <p class=define>TLSA (52)</p>
1344 <p class=descrip><code>certificate_usage</code> (an int), <code>selector</code> (an int),
1345 <code>matching_type</code> (an int), and <code>certificate_association_data</code> (a
1346 bindata).</p>
1347
1348 <p class=define>HIP (55)</p>
1349 <p class=descrip><code>pk_algorithm</code> (an int),
1350 <code>hit</code> (a bindata), <code>public_key</code>
1351 (a bindata), and <code>rendezvous_servers</code> (a list) with each element a bindata with the dname of the rendezvous_server.</p>
1352
1353 <p class=define>NINFO (56)</p>
1354 <p class=descrip><code>ninfo_unknown</code> (a bindata)</p>
1355
1356 <p class=define>RKEY (57)</p>
1357 <p class=descrip><code>rkey_unknown</code> (a bindata)</p>
1358
1359 <p class=define>TALINK (58)</p>
1360 <p class=descrip><code>talink_unknown</code> (a bindata)</p>
1361
1362 <p class=define>CDS (59)</p>
1363 <p class=descrip><code>cds_unknown</code> (a bindata)</p>
1364
1365 <p class=define>SPF (99)</p>
1366 <p class=descrip><code>text</code> (a bindata)</p>
1367
1368 <p class=define>UINFO (100)</p>
1369 <p class=descrip><code>uinfo_unknown</code> (a bindata)</p>
1370
1371 <p class=define>UID (101)</p>
1372 <p class=descrip><code>uid_unknown</code> (a bindata)</p>
1373
1374 <p class=define>GID (102)</p>
1375 <p class=descrip><code>gid_unknown</code> (a bindata)</p>
1376
1377 <p class=define>UNSPEC (103)</p>
1378 <p class=descrip><code>unspec_unknown</code> (a bindata)</p>
1379
1380 <p class=define>NID (104)</p>
1381 <p class=descrip><code>preference</code> (an int) and
1382 <code>node_id</code> (a bindata)</p>
1383
1384 <p class=define>L32 (105)</p>
1385 <p class=descrip><code>preference</code> (an int) and <code>locator32</code> (a bindata)</p>
1386
1387 <p class=define>L64 (106)</p>
1388 <p class=descrip><code>preference</code> (an int) and <code>locator64</code> (a bindata)</p>
1389
1390 <p class=define>LP (107)</p>
1391 <p class=descrip><code>preference</code> (an int) and <code>fqdn</code> (a bindata)</p>
1392
1393 <p class=define>EUI48 (108)</p>
1394 <p class=descrip><code>eui48_address</code> (a bindata)</p>
1395
1396 <p class=define>EUI64 (109)</p>
1397 <p class=descrip><code>eui64_address</code> (a bindata)</p>
1398
1399 <p class=define>TKEY (249)</p>
1400 <p class=descrip><code>algorithm</code> (a bindata), <code>inception</code> (an int),
1401 <code>expiration</code> (an int), <code>mode</code> (an int), <code>error</code> (an int),
1402 <code>key_data</code> (a bindata), and <code>other_data</code> (a bindata)</p>
1403
1404 <p class=define>TSIG (250)</p>
1405 <p class=descrip><code>algorithm</code> (a bindata), <code>time_signed</code> (a bindata),
1406 <code>fudge</code> (an int), <code>mac</code> (a bindata), <code>original_id</code> (an int),
1407 <code>error</code> (an int), and <code>other_data</code> (a bindata)</p>
1408
1409 <p class=define>MAILB (253)</p>
1410 <p class=descrip><code>mailb-unknown</code> (a bindata)</p>
1411
1412 <p class=define>MAILA (254)</p>
1413 <p class=descrip><code>maila-unknown</code> (a bindata)</p>
1414
1415 <p class=define>URI (256)</p>
1416 <p class=descrip><code>priority</code> (an int), <code>weight</code> (an int),
1417 and <code>target</code> (a bindata)</p>
1418
1419 <p class=define>CAA (257)</p>
1420 <p class=descrip><code>flags</code> (an int), <code>tag</code> (a bindata), and <code>value</code> (a bindata)</p>
1421
1422 <p class=define>TA (32768)</p>
1423 <p class=descrip><code>ta_unknown</code> (a bindata)</p>
1424
1425 <p class=define>DLV (32769)</p>
1426 <p class=descrip>Identical to DS (43)</p>
1427
1428
1429 <h1>6. Examples</h1>
1430
1431 <p>This section gives examples of code that calls the API to do many common tasks.
1432 The purpose of the code here is to give application developers a quick hands-on
1433 demo of using the API.</p>
1434
1435 <p>Note that the examples here all use getdns_libevent.h as the include that will call in the API
1436 code as well as calling in libevent as the event library. They also use
1437 <code>getdns_context_set_libevent_base()</code> as the name of the function to set the event base in
1438 the DNS context. If you are using a different event library, you will of course use a different
1439 <code>#include</code> at the beginning of your code, and a different name for the event base
1440 function.</p>
1441
1442 <h2>6.1 Get Both IPv4 and IPv6 Addresses for a Domain Name Using Quick Results</h2>
1443
1444 <p>This is an example of a common call to <code>getdns_address()</code>.</p>
1445
1446 <br><div class="highlight"><pre><span class="cp">#include &lt;stdio.h&gt;</span>
1447 <span class="cp">#include &lt;stdint.h&gt;</span>
1448 <span class="cp">#include &lt;stdlib.h&gt;</span>
1449 <span class="cp">#include &lt;string.h&gt;</span>
1450 <span class="cp">#include &lt;inttypes.h&gt;</span>
1451 <span class="cp">#include &lt;getdns_libevent.h&gt;</span>
1452
1453 <span class="cp">#define UNUSED_PARAM(x) ((void)(x))</span>
1454
1455 <span class="cm">/* Set up the callback function, which will also do the processing of the results */</span>
1456 <span class="kt">void</span> <span class="nf">this_callbackfn</span><span class="p">(</span><span class="n">getdns_context</span> <span class="o">*</span><span class="n">this_context</span><span class="p">,</span>
1457 <span class="n">getdns_callback_type_t</span> <span class="n">this_callback_type</span><span class="p">,</span>
1458 <span class="n">getdns_dict</span> <span class="o">*</span><span class="n">this_response</span><span class="p">,</span>
1459 <span class="kt">void</span> <span class="o">*</span><span class="n">this_userarg</span><span class="p">,</span>
1460 <span class="kt">getdns_transaction_t</span> <span class="n">this_transaction_id</span><span class="p">)</span>
1461 <span class="p">{</span>
1462 <span class="n">UNUSED_PARAM</span><span class="p">(</span><span class="n">this_userarg</span><span class="p">);</span> <span class="cm">/* Not looking at the userarg for this example */</span>
1463 <span class="n">UNUSED_PARAM</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span> <span class="cm">/* Not looking at the context for this example */</span>
1464 <span class="kt">getdns_return_t</span> <span class="n">this_ret</span><span class="p">;</span> <span class="cm">/* Holder for all function returns */</span>
1465 <span class="k">if</span> <span class="p">(</span><span class="n">this_callback_type</span> <span class="o">==</span> <span class="n">GETDNS_CALLBACK_COMPLETE</span><span class="p">)</span> <span class="cm">/* This is a callback with data */</span>
1466 <span class="p">{</span>
1467 <span class="cm">/* Be sure the search returned something */</span>
1468 <span class="kt">uint32_t</span> <span class="n">this_error</span><span class="p">;</span>
1469 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_int</span><span class="p">(</span><span class="n">this_response</span><span class="p">,</span> <span class="s">&quot;status&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_error</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1470 <span class="k">if</span> <span class="p">(</span><span class="n">this_error</span> <span class="o">!=</span> <span class="n">GETDNS_RESPSTATUS_GOOD</span><span class="p">)</span> <span class="c1">// If the search didn&#39;t return &quot;good&quot;</span>
1471 <span class="p">{</span>
1472 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;The search had no results, and a return value of %d. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_error</span><span class="p">);</span>
1473 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1474 <span class="k">return</span><span class="p">;</span>
1475 <span class="p">}</span>
1476 <span class="n">getdns_list</span> <span class="o">*</span> <span class="n">just_the_addresses_ptr</span><span class="p">;</span>
1477 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_list</span><span class="p">(</span><span class="n">this_response</span><span class="p">,</span> <span class="s">&quot;just_address_answers&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">just_the_addresses_ptr</span><span class="p">);</span>
1478 <span class="k">if</span> <span class="p">(</span><span class="n">this_ret</span> <span class="o">!=</span> <span class="n">GETDNS_RETURN_GOOD</span><span class="p">)</span> <span class="c1">// This check is really not needed, but prevents a compiler error under &quot;pedantic&quot;</span>
1479 <span class="p">{</span>
1480 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Trying to get the answers failed: %d</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_ret</span><span class="p">);</span>
1481 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1482 <span class="k">return</span><span class="p">;</span>
1483 <span class="p">}</span>
1484 <span class="kt">size_t</span> <span class="n">num_addresses</span><span class="p">;</span>
1485 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_list_get_length</span><span class="p">(</span><span class="n">just_the_addresses_ptr</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">num_addresses</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1486 <span class="cm">/* Go through each record */</span>
1487 <span class="k">for</span> <span class="p">(</span> <span class="kt">size_t</span> <span class="n">rec_count</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">rec_count</span> <span class="o">&lt;</span> <span class="n">num_addresses</span><span class="p">;</span> <span class="o">++</span><span class="n">rec_count</span> <span class="p">)</span>
1488 <span class="p">{</span>
1489 <span class="n">getdns_dict</span> <span class="o">*</span> <span class="n">this_address</span><span class="p">;</span>
1490 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_list_get_dict</span><span class="p">(</span><span class="n">just_the_addresses_ptr</span><span class="p">,</span> <span class="n">rec_count</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_address</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1491 <span class="cm">/* Just print the address */</span>
1492 <span class="n">getdns_bindata</span> <span class="o">*</span> <span class="n">this_address_data</span><span class="p">;</span>
1493 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_bindata</span><span class="p">(</span><span class="n">this_address</span><span class="p">,</span> <span class="s">&quot;address_data&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_address_data</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1494 <span class="kt">char</span> <span class="o">*</span><span class="n">this_address_str</span> <span class="o">=</span> <span class="n">getdns_display_ip_address</span><span class="p">(</span><span class="n">this_address_data</span><span class="p">);</span>
1495 <span class="n">printf</span><span class="p">(</span><span class="s">&quot;The address is %s</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_address_str</span><span class="p">);</span>
1496 <span class="n">free</span><span class="p">(</span><span class="n">this_address_str</span><span class="p">);</span>
1497 <span class="p">}</span>
1498 <span class="p">}</span>
1499 <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">this_callback_type</span> <span class="o">==</span> <span class="n">GETDNS_CALLBACK_CANCEL</span><span class="p">)</span>
1500 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;The callback with ID %&quot;</span><span class="n">PRIu64</span><span class="s">&quot; was cancelled. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_transaction_id</span><span class="p">);</span>
1501 <span class="k">else</span>
1502 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;The callback got a callback_type of %d. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_callback_type</span><span class="p">);</span>
1503 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1504 <span class="p">}</span>
1505
1506 <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span>
1507 <span class="p">{</span>
1508 <span class="cm">/* Create the DNS context for this call */</span>
1509 <span class="n">getdns_context</span> <span class="o">*</span><span class="n">this_context</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
1510 <span class="kt">getdns_return_t</span> <span class="n">context_create_return</span> <span class="o">=</span> <span class="n">getdns_context_create</span><span class="p">(</span><span class="o">&amp;</span><span class="n">this_context</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
1511 <span class="k">if</span> <span class="p">(</span><span class="n">context_create_return</span> <span class="o">!=</span> <span class="n">GETDNS_RETURN_GOOD</span><span class="p">)</span>
1512 <span class="p">{</span>
1513 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Trying to create the context failed: %d&quot;</span><span class="p">,</span> <span class="n">context_create_return</span><span class="p">);</span>
1514 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1515 <span class="p">}</span>
1516 <span class="cm">/* Create an event base and put it in the context using the unknown function name */</span>
1517 <span class="k">struct</span> <span class="n">event_base</span> <span class="o">*</span><span class="n">this_event_base</span><span class="p">;</span>
1518 <span class="n">this_event_base</span> <span class="o">=</span> <span class="n">event_base_new</span><span class="p">();</span>
1519 <span class="k">if</span> <span class="p">(</span><span class="n">this_event_base</span> <span class="o">==</span> <span class="nb">NULL</span><span class="p">)</span>
1520 <span class="p">{</span>
1521 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Trying to create the event base failed.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span>
1522 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1523 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1524 <span class="p">}</span>
1525 <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="n">getdns_extension_set_libevent_base</span><span class="p">(</span><span class="n">this_context</span><span class="p">,</span> <span class="n">this_event_base</span><span class="p">);</span>
1526 <span class="cm">/* Set up the getdns call */</span>
1527 <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">this_name</span> <span class="o">=</span> <span class="s">&quot;www.example.com&quot;</span><span class="p">;</span>
1528 <span class="kt">char</span><span class="o">*</span> <span class="n">this_userarg</span> <span class="o">=</span> <span class="s">&quot;somestring&quot;</span><span class="p">;</span> <span class="c1">// Could add things here to help identify this call</span>
1529 <span class="kt">getdns_transaction_t</span> <span class="n">this_transaction_id</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
1530
1531 <span class="cm">/* Make the call */</span>
1532 <span class="kt">getdns_return_t</span> <span class="n">dns_request_return</span> <span class="o">=</span> <span class="n">getdns_address</span><span class="p">(</span><span class="n">this_context</span><span class="p">,</span> <span class="n">this_name</span><span class="p">,</span>
1533 <span class="nb">NULL</span><span class="p">,</span> <span class="n">this_userarg</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_transaction_id</span><span class="p">,</span> <span class="n">this_callbackfn</span><span class="p">);</span>
1534 <span class="k">if</span> <span class="p">(</span><span class="n">dns_request_return</span> <span class="o">==</span> <span class="n">GETDNS_RETURN_BAD_DOMAIN_NAME</span><span class="p">)</span>
1535 <span class="p">{</span>
1536 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;A bad domain name was used: %s. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_name</span><span class="p">);</span>
1537 <span class="n">event_base_free</span><span class="p">(</span><span class="n">this_event_base</span><span class="p">);</span>
1538 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1539 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1540 <span class="p">}</span>
1541 <span class="k">else</span>
1542 <span class="p">{</span>
1543 <span class="cm">/* Call the event loop */</span>
1544 <span class="kt">int</span> <span class="n">dispatch_return</span> <span class="o">=</span> <span class="n">event_base_dispatch</span><span class="p">(</span><span class="n">this_event_base</span><span class="p">);</span>
1545 <span class="n">UNUSED_PARAM</span><span class="p">(</span><span class="n">dispatch_return</span><span class="p">);</span>
1546 <span class="c1">// TODO: check the return value above</span>
1547 <span class="p">}</span>
1548 <span class="cm">/* Clean up */</span>
1549 <span class="n">event_base_free</span><span class="p">(</span><span class="n">this_event_base</span><span class="p">);</span>
1550 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1551 <span class="cm">/* Assuming we get here, leave gracefully */</span>
1552 <span class="n">exit</span><span class="p">(</span><span class="n">EXIT_SUCCESS</span><span class="p">);</span>
1553 <span class="p">}</span>
1554 </pre></div>
1555
1556
1557
1558 <h2>6.2 Get IPv4 and IPv6 Addresses for a Domain Name</h2>
1559
1560 <p>This example is similar to the previous one, except that it retrieves more information than just
1561 the addresses, so it traverses the replies_tree. In this case, it gets both the addresses and
1562 their TTLs.</p>
1563
1564 <br><div class="highlight"><pre><span class="cp">#include &lt;stdio.h&gt;</span>
1565 <span class="cp">#include &lt;stdint.h&gt;</span>
1566 <span class="cp">#include &lt;stdlib.h&gt;</span>
1567 <span class="cp">#include &lt;string.h&gt;</span>
1568 <span class="cp">#include &lt;inttypes.h&gt;</span>
1569 <span class="cp">#include &lt;getdns_libevent.h&gt;</span>
1570
1571 <span class="cp">#define UNUSED_PARAM(x) ((void)(x))</span>
1572
1573 <span class="cm">/* Set up the callback function, which will also do the processing of the results */</span>
1574 <span class="kt">void</span> <span class="nf">this_callbackfn</span><span class="p">(</span><span class="n">getdns_context</span> <span class="o">*</span><span class="n">this_context</span><span class="p">,</span>
1575 <span class="n">getdns_callback_type_t</span> <span class="n">this_callback_type</span><span class="p">,</span>
1576 <span class="n">getdns_dict</span> <span class="o">*</span><span class="n">this_response</span><span class="p">,</span>
1577 <span class="kt">void</span> <span class="o">*</span><span class="n">this_userarg</span><span class="p">,</span>
1578 <span class="kt">getdns_transaction_t</span> <span class="n">this_transaction_id</span><span class="p">)</span>
1579 <span class="p">{</span>
1580 <span class="n">UNUSED_PARAM</span><span class="p">(</span><span class="n">this_userarg</span><span class="p">);</span> <span class="cm">/* Not looking at the userarg for this example */</span>
1581 <span class="n">UNUSED_PARAM</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span> <span class="cm">/* Not looking at the context for this example */</span>
1582 <span class="kt">getdns_return_t</span> <span class="n">this_ret</span><span class="p">;</span> <span class="cm">/* Holder for all function returns */</span>
1583 <span class="k">if</span> <span class="p">(</span><span class="n">this_callback_type</span> <span class="o">==</span> <span class="n">GETDNS_CALLBACK_COMPLETE</span><span class="p">)</span> <span class="cm">/* This is a callback with data */</span>
1584 <span class="p">{</span>
1585 <span class="cm">/* Be sure the search returned something */</span>
1586 <span class="kt">uint32_t</span> <span class="n">this_error</span><span class="p">;</span>
1587 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_int</span><span class="p">(</span><span class="n">this_response</span><span class="p">,</span> <span class="s">&quot;status&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_error</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1588 <span class="k">if</span> <span class="p">(</span><span class="n">this_error</span> <span class="o">!=</span> <span class="n">GETDNS_RESPSTATUS_GOOD</span><span class="p">)</span> <span class="c1">// If the search didn&#39;t return &quot;good&quot;</span>
1589 <span class="p">{</span>
1590 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;The search had no results, and a return value of %d. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_error</span><span class="p">);</span>
1591 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1592 <span class="k">return</span><span class="p">;</span>
1593 <span class="p">}</span>
1594 <span class="cm">/* Find all the answers returned */</span>
1595 <span class="n">getdns_list</span> <span class="o">*</span> <span class="n">these_answers</span><span class="p">;</span>
1596 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_list</span><span class="p">(</span><span class="n">this_response</span><span class="p">,</span> <span class="s">&quot;replies_tree&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">these_answers</span><span class="p">);</span>
1597 <span class="k">if</span> <span class="p">(</span><span class="n">this_ret</span> <span class="o">==</span> <span class="n">GETDNS_RETURN_NO_SUCH_DICT_NAME</span><span class="p">)</span>
1598 <span class="p">{</span>
1599 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Weird: the response had no error, but also no replies_tree. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span>
1600 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1601 <span class="k">return</span><span class="p">;</span>
1602 <span class="p">}</span>
1603 <span class="kt">size_t</span> <span class="n">num_answers</span><span class="p">;</span>
1604 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_list_get_length</span><span class="p">(</span><span class="n">these_answers</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">num_answers</span><span class="p">);</span>
1605 <span class="cm">/* Go through each answer */</span>
1606 <span class="k">for</span> <span class="p">(</span> <span class="kt">size_t</span> <span class="n">rec_count</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">rec_count</span> <span class="o">&lt;</span> <span class="n">num_answers</span><span class="p">;</span> <span class="o">++</span><span class="n">rec_count</span> <span class="p">)</span>
1607 <span class="p">{</span>
1608 <span class="n">getdns_dict</span> <span class="o">*</span> <span class="n">this_record</span><span class="p">;</span>
1609 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_list_get_dict</span><span class="p">(</span><span class="n">these_answers</span><span class="p">,</span> <span class="n">rec_count</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_record</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1610 <span class="cm">/* Get the answer section */</span>
1611 <span class="n">getdns_list</span> <span class="o">*</span> <span class="n">this_answer</span><span class="p">;</span>
1612 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_list</span><span class="p">(</span><span class="n">this_record</span><span class="p">,</span> <span class="s">&quot;answer&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_answer</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1613 <span class="cm">/* Get each RR in the answer section */</span>
1614 <span class="kt">size_t</span> <span class="n">num_rrs</span><span class="p">;</span>
1615 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_list_get_length</span><span class="p">(</span><span class="n">this_answer</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">num_rrs</span><span class="p">);</span>
1616 <span class="k">for</span> <span class="p">(</span> <span class="kt">size_t</span> <span class="n">rr_count</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">rr_count</span> <span class="o">&lt;</span> <span class="n">num_rrs</span><span class="p">;</span> <span class="o">++</span><span class="n">rr_count</span> <span class="p">)</span>
1617 <span class="p">{</span>
1618 <span class="n">getdns_dict</span> <span class="o">*</span><span class="n">this_rr</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
1619 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_list_get_dict</span><span class="p">(</span><span class="n">this_answer</span><span class="p">,</span> <span class="n">rr_count</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_rr</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1620 <span class="cm">/* Get the RDATA */</span>
1621 <span class="n">getdns_dict</span> <span class="o">*</span> <span class="n">this_rdata</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
1622 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_dict</span><span class="p">(</span><span class="n">this_rr</span><span class="p">,</span> <span class="s">&quot;rdata&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_rdata</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1623 <span class="cm">/* Get the RDATA type */</span>
1624 <span class="kt">uint32_t</span> <span class="n">this_type</span><span class="p">;</span>
1625 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_int</span><span class="p">(</span><span class="n">this_rr</span><span class="p">,</span> <span class="s">&quot;type&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_type</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1626 <span class="cm">/* If it is type A or AAAA, print the value */</span>
1627 <span class="k">if</span> <span class="p">(</span><span class="n">this_type</span> <span class="o">==</span> <span class="n">GETDNS_RRTYPE_A</span><span class="p">)</span>
1628 <span class="p">{</span>
1629 <span class="n">getdns_bindata</span> <span class="o">*</span> <span class="n">this_a_record</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
1630 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_bindata</span><span class="p">(</span><span class="n">this_rdata</span><span class="p">,</span> <span class="s">&quot;ipv4_address&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_a_record</span><span class="p">);</span>
1631 <span class="k">if</span> <span class="p">(</span><span class="n">this_ret</span> <span class="o">==</span> <span class="n">GETDNS_RETURN_NO_SUCH_DICT_NAME</span><span class="p">)</span>
1632 <span class="p">{</span>
1633 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Weird: the A record at %d in record at %d had no address. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span>
1634 <span class="p">(</span><span class="kt">int</span><span class="p">)</span> <span class="n">rr_count</span><span class="p">,</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span> <span class="n">rec_count</span><span class="p">);</span>
1635 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1636 <span class="k">return</span><span class="p">;</span>
1637 <span class="p">}</span>
1638 <span class="kt">char</span> <span class="o">*</span><span class="n">this_address_str</span> <span class="o">=</span> <span class="n">getdns_display_ip_address</span><span class="p">(</span><span class="n">this_a_record</span><span class="p">);</span>
1639 <span class="n">printf</span><span class="p">(</span><span class="s">&quot;The IPv4 address is %s</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_address_str</span><span class="p">);</span>
1640 <span class="n">free</span><span class="p">(</span><span class="n">this_address_str</span><span class="p">);</span>
1641 <span class="p">}</span>
1642 <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">this_type</span> <span class="o">==</span> <span class="n">GETDNS_RRTYPE_AAAA</span><span class="p">)</span>
1643 <span class="p">{</span>
1644 <span class="n">getdns_bindata</span> <span class="o">*</span> <span class="n">this_aaaa_record</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
1645 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_bindata</span><span class="p">(</span><span class="n">this_rdata</span><span class="p">,</span> <span class="s">&quot;ipv6_address&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_aaaa_record</span><span class="p">);</span>
1646 <span class="k">if</span> <span class="p">(</span><span class="n">this_ret</span> <span class="o">==</span> <span class="n">GETDNS_RETURN_NO_SUCH_DICT_NAME</span><span class="p">)</span>
1647 <span class="p">{</span>
1648 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Weird: the AAAA record at %d in record at %d had no address. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span>
1649 <span class="p">(</span><span class="kt">int</span><span class="p">)</span> <span class="n">rr_count</span><span class="p">,</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span> <span class="n">rec_count</span><span class="p">);</span>
1650 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1651 <span class="k">return</span><span class="p">;</span>
1652 <span class="p">}</span>
1653 <span class="kt">char</span> <span class="o">*</span><span class="n">this_address_str</span> <span class="o">=</span> <span class="n">getdns_display_ip_address</span><span class="p">(</span><span class="n">this_aaaa_record</span><span class="p">);</span>
1654 <span class="n">printf</span><span class="p">(</span><span class="s">&quot;The IPv6 address is %s</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_address_str</span><span class="p">);</span>
1655 <span class="n">free</span><span class="p">(</span><span class="n">this_address_str</span><span class="p">);</span>
1656 <span class="p">}</span>
1657 <span class="p">}</span>
1658 <span class="p">}</span>
1659 <span class="p">}</span>
1660 <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">this_callback_type</span> <span class="o">==</span> <span class="n">GETDNS_CALLBACK_CANCEL</span><span class="p">)</span>
1661 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;The callback with ID %&quot;</span><span class="n">PRIu64</span><span class="s">&quot; was cancelled. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_transaction_id</span><span class="p">);</span>
1662 <span class="k">else</span>
1663 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;The callback got a callback_type of %d. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_callback_type</span><span class="p">);</span>
1664 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1665 <span class="p">}</span>
1666
1667 <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span>
1668 <span class="p">{</span>
1669 <span class="cm">/* Create the DNS context for this call */</span>
1670 <span class="n">getdns_context</span> <span class="o">*</span><span class="n">this_context</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
1671 <span class="kt">getdns_return_t</span> <span class="n">context_create_return</span> <span class="o">=</span> <span class="n">getdns_context_create</span><span class="p">(</span><span class="o">&amp;</span><span class="n">this_context</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
1672 <span class="k">if</span> <span class="p">(</span><span class="n">context_create_return</span> <span class="o">!=</span> <span class="n">GETDNS_RETURN_GOOD</span><span class="p">)</span>
1673 <span class="p">{</span>
1674 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Trying to create the context failed: %d</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">context_create_return</span><span class="p">);</span>
1675 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1676 <span class="p">}</span>
1677 <span class="cm">/* Create an event base and put it in the context using the unknown function name */</span>
1678 <span class="k">struct</span> <span class="n">event_base</span> <span class="o">*</span><span class="n">this_event_base</span><span class="p">;</span>
1679 <span class="n">this_event_base</span> <span class="o">=</span> <span class="n">event_base_new</span><span class="p">();</span>
1680 <span class="k">if</span> <span class="p">(</span><span class="n">this_event_base</span> <span class="o">==</span> <span class="nb">NULL</span><span class="p">)</span>
1681 <span class="p">{</span>
1682 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Trying to create the event base failed.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">);</span>
1683 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1684 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1685 <span class="p">}</span>
1686 <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="n">getdns_extension_set_libevent_base</span><span class="p">(</span><span class="n">this_context</span><span class="p">,</span> <span class="n">this_event_base</span><span class="p">);</span>
1687 <span class="cm">/* Set up the getdns call */</span>
1688 <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">this_name</span> <span class="o">=</span> <span class="s">&quot;www.example.com&quot;</span><span class="p">;</span>
1689 <span class="kt">char</span><span class="o">*</span> <span class="n">this_userarg</span> <span class="o">=</span> <span class="s">&quot;somestring&quot;</span><span class="p">;</span> <span class="c1">// Could add things here to help identify this call</span>
1690 <span class="kt">getdns_transaction_t</span> <span class="n">this_transaction_id</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
1691
1692 <span class="cm">/* Make the call */</span>
1693 <span class="kt">getdns_return_t</span> <span class="n">dns_request_return</span> <span class="o">=</span> <span class="n">getdns_address</span><span class="p">(</span><span class="n">this_context</span><span class="p">,</span> <span class="n">this_name</span><span class="p">,</span>
1694 <span class="nb">NULL</span><span class="p">,</span> <span class="n">this_userarg</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_transaction_id</span><span class="p">,</span> <span class="n">this_callbackfn</span><span class="p">);</span>
1695 <span class="k">if</span> <span class="p">(</span><span class="n">dns_request_return</span> <span class="o">==</span> <span class="n">GETDNS_RETURN_BAD_DOMAIN_NAME</span><span class="p">)</span>
1696 <span class="p">{</span>
1697 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;A bad domain name was used: %s. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_name</span><span class="p">);</span>
1698 <span class="n">event_base_free</span><span class="p">(</span><span class="n">this_event_base</span><span class="p">);</span>
1699 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1700 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1701 <span class="p">}</span>
1702 <span class="k">else</span>
1703 <span class="p">{</span>
1704 <span class="cm">/* Call the event loop */</span>
1705 <span class="kt">int</span> <span class="n">dispatch_return</span> <span class="o">=</span> <span class="n">event_base_dispatch</span><span class="p">(</span><span class="n">this_event_base</span><span class="p">);</span>
1706 <span class="n">UNUSED_PARAM</span><span class="p">(</span><span class="n">dispatch_return</span><span class="p">);</span>
1707 <span class="c1">// TODO: check the return value above</span>
1708 <span class="p">}</span>
1709 <span class="cm">/* Clean up */</span>
1710 <span class="n">event_base_free</span><span class="p">(</span><span class="n">this_event_base</span><span class="p">);</span>
1711 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1712 <span class="cm">/* Assuming we get here, leave gracefully */</span>
1713 <span class="n">exit</span><span class="p">(</span><span class="n">EXIT_SUCCESS</span><span class="p">);</span>
1714 <span class="p">}</span>
1715 </pre></div>
1716
1717
1718
1719 <h2>6.3 Get Addresses for a Domain Name And Their Associated DNSSEC Validation Status</h2>
1720
1721 <p>This example shows how to check for secure DNSSEC results using the
1722 <code>dnssec_return_status</code> extension. In the innermost loop of the
1723 callback function, add a check for the DNSSEC status. It shows how to add two
1724 extensions to the <code>extensions</code> argument of the call.</p>
1725
1726 <pre>
1727 getdns_dict * this_extensions = getdns_dict_create();
1728 this_ret = getdns_dict_set_int(this_extensions, "return_both_v4_and_v6", GETDNS_EXTENSION_TRUE);
1729 this_ret = getdns_dict_set_int(this_extensions, "dnssec_return_status", GETDNS_EXTENSION_TRUE);
1730 . . .
1731 if (this_type == GETDNS_RRTYPE_A)
1732 {
1733 uint32_t * this_dnssec_status;
1734 this_ret = getdns_dict_get_int(this_rdata, "dnssec_status", &amp;this_dnssec_status);
1735 if (this_dnssec_status != GETDNS_DNSSEC_SECURE)
1736 {
1737 // Log the DNSSEC status somewhere
1738 }
1739 else
1740 {
1741 // Deal with the record however you were going to
1742 }
1743 }
1744 . . .
1745 </pre>
1746
1747 <p>You can put the DNSSEC status check outside the check for the particular type of record you care about, but
1748 you will then get log messages for bad status on records you might not care about as well.</p>
1749
1750 <h2>6.4 Using the API Synchronously with <code>getdns_general_sync()</code></h2>
1751
1752 <p>This example is the same as the earlier examples, but uses <code>getdns_general_sync()</code>
1753 and thus does not use the async code. Note that the processing of the answers is essentially the same
1754 as it is for the synchronous example, it is just done in <code>main()</code>.</p>
1755
1756 <br><div class="highlight"><pre><span class="cp">#include &lt;stdio.h&gt;</span>
1757 <span class="cp">#include &lt;stdint.h&gt;</span>
1758 <span class="cp">#include &lt;stdlib.h&gt;</span>
1759 <span class="cp">#include &lt;string.h&gt;</span>
1760 <span class="cp">#include &lt;inttypes.h&gt;</span>
1761 <span class="cp">#include &lt;getdns_core_only.h&gt;</span>
1762
1763 <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span>
1764 <span class="p">{</span>
1765 <span class="kt">getdns_return_t</span> <span class="n">this_ret</span><span class="p">;</span> <span class="cm">/* Holder for all function returns */</span>
1766 <span class="cm">/* Create the DNS context for this call */</span>
1767 <span class="n">getdns_context</span> <span class="o">*</span><span class="n">this_context</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
1768 <span class="kt">getdns_return_t</span> <span class="n">context_create_return</span> <span class="o">=</span> <span class="n">getdns_context_create</span><span class="p">(</span><span class="o">&amp;</span><span class="n">this_context</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
1769 <span class="k">if</span> <span class="p">(</span><span class="n">context_create_return</span> <span class="o">!=</span> <span class="n">GETDNS_RETURN_GOOD</span><span class="p">)</span>
1770 <span class="p">{</span>
1771 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Trying to create the context failed: %d</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">context_create_return</span><span class="p">);</span>
1772 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1773 <span class="p">}</span>
1774 <span class="cm">/* Set up the getdns_sync_request call */</span>
1775 <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">this_name</span> <span class="o">=</span> <span class="s">&quot;www.example.com&quot;</span><span class="p">;</span>
1776 <span class="kt">uint8_t</span> <span class="n">this_request_type</span> <span class="o">=</span> <span class="n">GETDNS_RRTYPE_A</span><span class="p">;</span>
1777 <span class="cm">/* Get the A and AAAA records */</span>
1778 <span class="n">getdns_dict</span> <span class="o">*</span> <span class="n">this_extensions</span> <span class="o">=</span> <span class="n">getdns_dict_create</span><span class="p">();</span>
1779 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_set_int</span><span class="p">(</span><span class="n">this_extensions</span><span class="p">,</span> <span class="s">&quot;return_both_v4_and_v6&quot;</span><span class="p">,</span> <span class="n">GETDNS_EXTENSION_TRUE</span><span class="p">);</span>
1780 <span class="k">if</span> <span class="p">(</span><span class="n">this_ret</span> <span class="o">!=</span> <span class="n">GETDNS_RETURN_GOOD</span><span class="p">)</span>
1781 <span class="p">{</span>
1782 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Trying to set an extension do both IPv4 and IPv6 failed: %d</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_ret</span><span class="p">);</span>
1783 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_extensions</span><span class="p">);</span>
1784 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1785 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1786 <span class="p">}</span>
1787 <span class="n">getdns_dict</span> <span class="o">*</span> <span class="n">this_response</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
1788
1789 <span class="cm">/* Make the call */</span>
1790 <span class="kt">getdns_return_t</span> <span class="n">dns_request_return</span> <span class="o">=</span> <span class="n">getdns_general_sync</span><span class="p">(</span><span class="n">this_context</span><span class="p">,</span> <span class="n">this_name</span><span class="p">,</span> <span class="n">this_request_type</span><span class="p">,</span>
1791 <span class="n">this_extensions</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_response</span><span class="p">);</span>
1792 <span class="k">if</span> <span class="p">(</span><span class="n">dns_request_return</span> <span class="o">==</span> <span class="n">GETDNS_RETURN_BAD_DOMAIN_NAME</span><span class="p">)</span>
1793 <span class="p">{</span>
1794 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;A bad domain name was used: %s. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_name</span><span class="p">);</span>
1795 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1796 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_extensions</span><span class="p">);</span>
1797 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1798 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1799 <span class="p">}</span>
1800 <span class="k">else</span>
1801 <span class="p">{</span>
1802 <span class="cm">/* Be sure the search returned something */</span>
1803 <span class="kt">uint32_t</span> <span class="n">this_error</span><span class="p">;</span>
1804 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_int</span><span class="p">(</span><span class="n">this_response</span><span class="p">,</span> <span class="s">&quot;status&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_error</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1805 <span class="k">if</span> <span class="p">(</span><span class="n">this_error</span> <span class="o">!=</span> <span class="n">GETDNS_RESPSTATUS_GOOD</span><span class="p">)</span> <span class="c1">// If the search didn&#39;t return &quot;good&quot;</span>
1806 <span class="p">{</span>
1807 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;The search had no results, and a return value of %d. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_error</span><span class="p">);</span>
1808 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1809 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_extensions</span><span class="p">);</span>
1810 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1811 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1812 <span class="p">}</span>
1813 <span class="n">getdns_list</span> <span class="o">*</span> <span class="n">just_the_addresses_ptr</span><span class="p">;</span>
1814 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_list</span><span class="p">(</span><span class="n">this_response</span><span class="p">,</span> <span class="s">&quot;just_address_answers&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">just_the_addresses_ptr</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1815 <span class="kt">size_t</span> <span class="n">num_addresses</span><span class="p">;</span>
1816 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_list_get_length</span><span class="p">(</span><span class="n">just_the_addresses_ptr</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">num_addresses</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1817 <span class="cm">/* Go through each record */</span>
1818 <span class="k">for</span> <span class="p">(</span> <span class="kt">size_t</span> <span class="n">rec_count</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">rec_count</span> <span class="o">&lt;</span> <span class="n">num_addresses</span><span class="p">;</span> <span class="o">++</span><span class="n">rec_count</span> <span class="p">)</span>
1819 <span class="p">{</span>
1820 <span class="n">getdns_dict</span> <span class="o">*</span> <span class="n">this_address</span><span class="p">;</span>
1821 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_list_get_dict</span><span class="p">(</span><span class="n">just_the_addresses_ptr</span><span class="p">,</span> <span class="n">rec_count</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_address</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1822 <span class="cm">/* Just print the address */</span>
1823 <span class="n">getdns_bindata</span> <span class="o">*</span> <span class="n">this_address_data</span><span class="p">;</span>
1824 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_bindata</span><span class="p">(</span><span class="n">this_address</span><span class="p">,</span> <span class="s">&quot;address_data&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_address_data</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1825 <span class="kt">char</span> <span class="o">*</span><span class="n">this_address_str</span> <span class="o">=</span> <span class="n">getdns_display_ip_address</span><span class="p">(</span><span class="n">this_address_data</span><span class="p">);</span>
1826 <span class="n">printf</span><span class="p">(</span><span class="s">&quot;The address is %s</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_address_str</span><span class="p">);</span>
1827 <span class="n">free</span><span class="p">(</span><span class="n">this_address_str</span><span class="p">);</span>
1828 <span class="p">}</span>
1829 <span class="p">}</span>
1830 <span class="cm">/* Clean up */</span>
1831 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1832 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_extensions</span><span class="p">);</span>
1833 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1834 <span class="cm">/* Assuming we get here, leave gracefully */</span>
1835 <span class="n">exit</span><span class="p">(</span><span class="n">EXIT_SUCCESS</span><span class="p">);</span>
1836 <span class="p">}</span>
1837 </pre></div>
1838
1839
1840
1841 <h2>6.5 Getting Names from the Reverse Tree with <code>getdns_hostname()</code></h2>
1842
1843 <p>This example shows how to use <code>getdns_hostname()</code> to get names from the DNS reverse tree.</p>
1844
1845 <br><div class="highlight"><pre><span class="cp">#include &lt;stdio.h&gt;</span>
1846 <span class="cp">#include &lt;stdint.h&gt;</span>
1847 <span class="cp">#include &lt;stdlib.h&gt;</span>
1848 <span class="cp">#include &lt;string.h&gt;</span>
1849 <span class="cp">#include &lt;inttypes.h&gt;</span>
1850 <span class="cp">#include &lt;getdns_libevent.h&gt;</span>
1851
1852 <span class="cp">#define UNUSED_PARAM(x) ((void)(x))</span>
1853
1854 <span class="cm">/* Set up the callback function, which will also do the processing of the results */</span>
1855 <span class="kt">void</span> <span class="nf">this_callbackfn</span><span class="p">(</span><span class="n">getdns_context</span> <span class="o">*</span><span class="n">this_context</span><span class="p">,</span>
1856 <span class="n">getdns_callback_type_t</span> <span class="n">this_callback_type</span><span class="p">,</span>
1857 <span class="n">getdns_dict</span> <span class="o">*</span><span class="n">this_response</span><span class="p">,</span>
1858 <span class="kt">void</span> <span class="o">*</span><span class="n">this_userarg</span><span class="p">,</span>
1859 <span class="kt">getdns_transaction_t</span> <span class="n">this_transaction_id</span><span class="p">)</span>
1860 <span class="p">{</span>
1861 <span class="kt">getdns_return_t</span> <span class="n">this_ret</span><span class="p">;</span> <span class="cm">/* Holder for all function returns */</span>
1862 <span class="n">UNUSED_PARAM</span><span class="p">(</span><span class="n">this_userarg</span><span class="p">);</span> <span class="cm">/* Not looking at the userarg for this example */</span>
1863 <span class="n">UNUSED_PARAM</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span> <span class="cm">/* Not looking at the context for this example */</span>
1864 <span class="n">UNUSED_PARAM</span><span class="p">(</span><span class="n">this_ret</span><span class="p">);</span> <span class="cm">/* Set, but not read */</span>
1865 <span class="k">if</span> <span class="p">(</span><span class="n">this_callback_type</span> <span class="o">==</span> <span class="n">GETDNS_CALLBACK_COMPLETE</span><span class="p">)</span> <span class="cm">/* This is a callback with data */</span>
1866 <span class="p">{</span>
1867 <span class="cm">/* Be sure the search returned something */</span>
1868 <span class="kt">uint32_t</span> <span class="n">this_error</span><span class="p">;</span>
1869 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_int</span><span class="p">(</span><span class="n">this_response</span><span class="p">,</span> <span class="s">&quot;status&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_error</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1870 <span class="k">if</span> <span class="p">(</span><span class="n">this_error</span> <span class="o">!=</span> <span class="n">GETDNS_RESPSTATUS_GOOD</span><span class="p">)</span> <span class="c1">// If the search didn&#39;t return &quot;good&quot;</span>
1871 <span class="p">{</span>
1872 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;The search had no results, and a return value of %d. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_error</span><span class="p">);</span>
1873 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1874 <span class="k">return</span><span class="p">;</span>
1875 <span class="p">}</span>
1876 <span class="n">getdns_list</span> <span class="o">*</span><span class="n">replies_tree</span><span class="p">;</span>
1877 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_list</span><span class="p">(</span><span class="n">this_response</span><span class="p">,</span> <span class="s">&quot;replies_tree&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">replies_tree</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1878 <span class="kt">size_t</span> <span class="n">num_replies</span><span class="p">;</span>
1879 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_list_get_length</span><span class="p">(</span><span class="n">replies_tree</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">num_replies</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1880 <span class="cm">/* Go through each reply */</span>
1881 <span class="k">for</span> <span class="p">(</span> <span class="kt">size_t</span> <span class="n">reply_count</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">reply_count</span> <span class="o">&lt;</span> <span class="n">num_replies</span><span class="p">;</span> <span class="o">++</span><span class="n">reply_count</span><span class="p">)</span>
1882 <span class="p">{</span>
1883 <span class="n">getdns_dict</span> <span class="o">*</span> <span class="n">this_reply</span><span class="p">;</span>
1884 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_list_get_dict</span><span class="p">(</span><span class="n">replies_tree</span><span class="p">,</span> <span class="n">reply_count</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_reply</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1885 <span class="cm">/* Just print the address */</span>
1886 <span class="n">getdns_list</span><span class="o">*</span> <span class="n">reply_answers</span><span class="p">;</span>
1887 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_list</span><span class="p">(</span><span class="n">this_reply</span><span class="p">,</span> <span class="s">&quot;answer&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">reply_answers</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1888 <span class="kt">size_t</span> <span class="n">num_answers</span><span class="p">;</span>
1889 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_list_get_length</span><span class="p">(</span><span class="n">reply_answers</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">num_answers</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1890 <span class="cm">/* Go through each answer */</span>
1891 <span class="k">for</span> <span class="p">(</span> <span class="kt">size_t</span> <span class="n">answer_count</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">answer_count</span> <span class="o">&lt;</span> <span class="n">num_answers</span><span class="p">;</span> <span class="o">++</span><span class="n">answer_count</span><span class="p">)</span>
1892 <span class="p">{</span>
1893 <span class="n">getdns_dict</span> <span class="o">*</span> <span class="n">this_rr</span><span class="p">;</span>
1894 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_list_get_dict</span><span class="p">(</span><span class="n">reply_answers</span><span class="p">,</span> <span class="n">answer_count</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_rr</span><span class="p">);</span>
1895 <span class="cm">/* Get the RDATA type */</span>
1896 <span class="kt">uint32_t</span> <span class="n">this_type</span><span class="p">;</span>
1897 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_int</span><span class="p">(</span><span class="n">this_rr</span><span class="p">,</span> <span class="s">&quot;type&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_type</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1898 <span class="k">if</span> <span class="p">(</span><span class="n">this_type</span> <span class="o">==</span> <span class="n">GETDNS_RRTYPE_PTR</span><span class="p">)</span>
1899 <span class="p">{</span>
1900 <span class="n">getdns_dict</span> <span class="o">*</span><span class="n">this_rdata</span><span class="p">;</span>
1901 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_dict</span><span class="p">(</span><span class="n">this_rr</span><span class="p">,</span> <span class="s">&quot;rdata&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_rdata</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1902
1903 <span class="n">getdns_bindata</span> <span class="o">*</span> <span class="n">this_dname</span><span class="p">;</span>
1904 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_get_bindata</span><span class="p">(</span><span class="n">this_rdata</span><span class="p">,</span> <span class="s">&quot;rdata_raw&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_dname</span><span class="p">);</span>
1905 <span class="kt">char</span> <span class="o">*</span><span class="n">this_dname_str</span><span class="p">;</span>
1906 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_convert_dns_name_to_fqdn</span><span class="p">(</span><span class="n">this_dname</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_dname_str</span><span class="p">);</span> <span class="c1">// Ignore any error</span>
1907 <span class="n">printf</span><span class="p">(</span><span class="s">&quot;The dname is %s</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">this_dname_str</span><span class="p">);</span>
1908 <span class="n">free</span><span class="p">(</span><span class="n">this_dname_str</span><span class="p">);</span>
1909 <span class="p">}</span>
1910 <span class="p">}</span>
1911
1912 <span class="p">}</span>
1913 <span class="p">}</span>
1914 <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="n">this_callback_type</span> <span class="o">==</span> <span class="n">GETDNS_CALLBACK_CANCEL</span><span class="p">)</span>
1915 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;The callback with ID %&quot;</span><span class="n">PRIu64</span><span class="s">&quot; was cancelled. Exiting.&quot;</span><span class="p">,</span> <span class="n">this_transaction_id</span><span class="p">);</span>
1916 <span class="k">else</span>
1917 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;The callback got a callback_type of %d. Exiting.&quot;</span><span class="p">,</span> <span class="n">this_callback_type</span><span class="p">);</span>
1918 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_response</span><span class="p">);</span>
1919 <span class="p">}</span>
1920
1921 <span class="kt">int</span> <span class="nf">main</span><span class="p">()</span>
1922 <span class="p">{</span>
1923 <span class="cm">/* Create the DNS context for this call */</span>
1924 <span class="n">getdns_context</span> <span class="o">*</span><span class="n">this_context</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
1925 <span class="kt">getdns_return_t</span> <span class="n">context_create_return</span> <span class="o">=</span> <span class="n">getdns_context_create</span><span class="p">(</span><span class="o">&amp;</span><span class="n">this_context</span><span class="p">,</span> <span class="mi">1</span><span class="p">);</span>
1926 <span class="k">if</span> <span class="p">(</span><span class="n">context_create_return</span> <span class="o">!=</span> <span class="n">GETDNS_RETURN_GOOD</span><span class="p">)</span>
1927 <span class="p">{</span>
1928 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Trying to create the context failed: %d&quot;</span><span class="p">,</span> <span class="n">context_create_return</span><span class="p">);</span>
1929 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1930 <span class="p">}</span>
1931 <span class="cm">/* Create an event base and put it in the context using the unknown function name */</span>
1932 <span class="k">struct</span> <span class="n">event_base</span> <span class="o">*</span><span class="n">this_event_base</span><span class="p">;</span>
1933 <span class="n">this_event_base</span> <span class="o">=</span> <span class="n">event_base_new</span><span class="p">();</span>
1934 <span class="k">if</span> <span class="p">(</span><span class="n">this_event_base</span> <span class="o">==</span> <span class="nb">NULL</span><span class="p">)</span>
1935 <span class="p">{</span>
1936 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;Trying to create the event base failed.&quot;</span><span class="p">);</span>
1937 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1938 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1939 <span class="p">}</span>
1940 <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="n">getdns_extension_set_libevent_base</span><span class="p">(</span><span class="n">this_context</span><span class="p">,</span> <span class="n">this_event_base</span><span class="p">);</span>
1941 <span class="cm">/* Set up the getdns call */</span>
1942 <span class="n">getdns_dict</span> <span class="o">*</span> <span class="n">this_addr_to_look_up</span> <span class="o">=</span> <span class="n">getdns_dict_create</span><span class="p">();</span>
1943 <span class="c1">// TODO: check the return value above</span>
1944 <span class="n">getdns_bindata</span> <span class="n">this_type</span> <span class="o">=</span> <span class="p">{</span> <span class="mi">4</span><span class="p">,</span> <span class="p">(</span><span class="kt">void</span> <span class="o">*</span><span class="p">)</span><span class="s">&quot;IPv4&quot;</span> <span class="p">};</span>
1945 <span class="kt">getdns_return_t</span> <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_set_bindata</span><span class="p">(</span><span class="n">this_addr_to_look_up</span><span class="p">,</span> <span class="s">&quot;address_type&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_type</span><span class="p">);</span>
1946 <span class="n">UNUSED_PARAM</span><span class="p">(</span><span class="n">this_ret</span><span class="p">);</span>
1947 <span class="n">getdns_bindata</span> <span class="n">this_ipv4_addr</span> <span class="o">=</span> <span class="p">{</span> <span class="mi">4</span><span class="p">,</span> <span class="p">(</span><span class="kt">void</span> <span class="o">*</span><span class="p">)</span><span class="s">&quot;</span><span class="se">\x08\x08\x08\x08</span><span class="s">&quot;</span> <span class="p">};</span>
1948 <span class="n">this_ret</span> <span class="o">=</span> <span class="n">getdns_dict_set_bindata</span><span class="p">(</span><span class="n">this_addr_to_look_up</span><span class="p">,</span> <span class="s">&quot;address_data&quot;</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_ipv4_addr</span><span class="p">);</span>
1949 <span class="kt">char</span><span class="o">*</span> <span class="n">this_userarg</span> <span class="o">=</span> <span class="s">&quot;somestring&quot;</span><span class="p">;</span> <span class="c1">// Could add things here to help identify this call</span>
1950 <span class="kt">getdns_transaction_t</span> <span class="n">this_transaction_id</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
1951
1952 <span class="cm">/* Make the call */</span>
1953 <span class="kt">getdns_return_t</span> <span class="n">dns_request_return</span> <span class="o">=</span> <span class="n">getdns_hostname</span><span class="p">(</span><span class="n">this_context</span><span class="p">,</span> <span class="n">this_addr_to_look_up</span><span class="p">,</span>
1954 <span class="nb">NULL</span><span class="p">,</span> <span class="n">this_userarg</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">this_transaction_id</span><span class="p">,</span> <span class="n">this_callbackfn</span><span class="p">);</span>
1955 <span class="k">if</span> <span class="p">(</span><span class="n">dns_request_return</span> <span class="o">==</span> <span class="n">GETDNS_RETURN_BAD_DOMAIN_NAME</span><span class="p">)</span>
1956 <span class="p">{</span>
1957 <span class="kt">char</span> <span class="o">*</span><span class="n">ip_address_str</span> <span class="o">=</span> <span class="n">getdns_display_ip_address</span><span class="p">(</span><span class="o">&amp;</span><span class="n">this_ipv4_addr</span><span class="p">);</span>
1958
1959 <span class="n">fprintf</span><span class="p">(</span><span class="n">stderr</span><span class="p">,</span> <span class="s">&quot;A bad IP address was used: %s. Exiting.</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">ip_address_str</span><span class="p">);</span>
1960 <span class="n">free</span><span class="p">(</span><span class="n">ip_address_str</span><span class="p">);</span>
1961 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_addr_to_look_up</span><span class="p">);</span>
1962 <span class="n">event_base_free</span><span class="p">(</span><span class="n">this_event_base</span><span class="p">);</span>
1963 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1964 <span class="k">return</span><span class="p">(</span><span class="n">GETDNS_RETURN_GENERIC_ERROR</span><span class="p">);</span>
1965 <span class="p">}</span>
1966 <span class="k">else</span>
1967 <span class="p">{</span>
1968 <span class="cm">/* Call the event loop */</span>
1969 <span class="kt">int</span> <span class="n">dispatch_return</span> <span class="o">=</span> <span class="n">event_base_dispatch</span><span class="p">(</span><span class="n">this_event_base</span><span class="p">);</span>
1970 <span class="n">UNUSED_PARAM</span><span class="p">(</span><span class="n">dispatch_return</span><span class="p">);</span>
1971 <span class="c1">// TODO: check the return value above</span>
1972 <span class="p">}</span>
1973 <span class="cm">/* Clean up */</span>
1974 <span class="n">getdns_dict_destroy</span><span class="p">(</span><span class="n">this_addr_to_look_up</span><span class="p">);</span>
1975 <span class="n">event_base_free</span><span class="p">(</span><span class="n">this_event_base</span><span class="p">);</span>
1976 <span class="n">getdns_context_destroy</span><span class="p">(</span><span class="n">this_context</span><span class="p">);</span>
1977 <span class="cm">/* Assuming we get here, leave gracefully */</span>
1978 <span class="n">exit</span><span class="p">(</span><span class="n">EXIT_SUCCESS</span><span class="p">);</span>
1979 <span class="p">}</span>
1980 </pre></div>
1981
1982
1983
1984 <h1>7. More Helper Functions</h1>
1985
1986 <p>The following two functions convert individual labels of IDNs between their Unicode
1987 encoding and their ASCII encoding. They follow the rules for IDNA 2008 described in
1988 RFC 5890-5892.</p>
1989 <div class=forh>char *
1990 getdns_convert_ulabel_to_alabel(
1991 const char *ulabel
1992 );
1993 </div>
1994 <div class=forh>char *
1995 getdns_convert_alabel_to_ulabel(
1996 const char *alabel
1997 );
1998 </div>
1999
2000 <p>If an application wants the API do perform DNSSEC validation without using the extensions, it
2001 can use the <code>getdns_validate_dnssec()</code> helper function.</p>
2002 <div class=forh>getdns_return_t
2003 getdns_validate_dnssec(
2004 getdns_list *record_to_validate,
2005 getdns_list *bundle_of_support_records,
2006 getdns_list *trust_anchor_records
2007 );
2008 </div>
2009 <p class=cont>
2010 The <code>record_to_validate</code> is the resource record being validated together with the associated signatures.
2011 The API will use the resource records in <code>bundle_of_support_records</code> to construct the validation chain and the DNSKEY or DS records in <code>trust_anchor_records</code> as trust anchors.
2012 The function returns one of <code>GETDNS_DNSSEC_SECURE</code>, <code>GETDNS_DNSSEC_BOGUS</code>, <code>GETDNS_DNSSEC_INDETERMINATE</code>, or <code>GETDNS_DNSSEC_INSECURE</code>.
2013 </p>
2014
2015 <p class=cont>
2016 The default list of trust anchor records that is used by the library to validate DNSSEC can
2017 be retrieved by using the <code>getdns_root_trust_anchor</code> helper function.</p>
2018 <div class=forh>getdns_list *
2019 getdns_root_trust_anchor(
2020 time_t *utc_date_of_anchor
2021 );
2022 </div>
2023 <p class=cont>
2024 When there are no default trust anchors <code>NULL</code> is returned.
2025 Upon successful return, the variable of type <code>time_t</code>, referenced by
2026 <code>utc_date_of_anchor</code> is set to the number of seconds since epoch
2027 the trust anchors were obtained.
2028 </p>
2029
2030 <p>There are two functions that help process data:</p>
2031
2032 <div class=forh>
2033 char *
2034 getdns_pretty_print_dict(
2035 const getdns_dict *some_dict
2036 );
2037 </div>
2038 <p class=cont>This returns a string that is the nicely-formatted version
2039 of the dict and all of the named elements in it.</p>
2040
2041 <div class=forh>
2042 char *
2043 getdns_display_ip_address(
2044 const getdns_bindata *bindata_of_ipv4_or_ipv6_address
2045 );
2046 </div>
2047 <p class=cont>This returns a string that is the nicely-formatted version
2048 of the IPv4 or IPv6 address in it. The API determines they type of address
2049 by the length given in the bindata.</p>
2050
2051 <p class=cont>All memory locations returned by these helper functions are allocated by the default system allocator, namely <code>malloc</code>.
2052 The caller is responsible of disposing these allocations with <code>free</code>.</p>
2053
2054 <h1>8. <a id="Contexts">DNS Contexts</a></h1>
2055
2056 <p>Many calls in the DNS API require a DNS context. A DNS
2057 context contains the information that the API needs in order to process DNS calls, such as the
2058 locations of upstream DNS servers, DNSSEC trust anchors, and so on. The internal structure of the
2059 DNS context is opaque, and might be different on each OS. When a context is passed to any function,
2060 it must be an allocated context; the context must not be NULL.</p>
2061
2062 <p>A typical application using this API doesn't need to know anything about contexts. Basically,
2063 the application creates a default context, uses it in the functions that require a context, and
2064 then deallocates it when done. Context manipulation is available for more DNS-aware programs,
2065 but is unlikely to be of interest to applications that just want the results of lookups for
2066 A, AAAA, SRV, and PTR records.</p>
2067
2068 <p>It is expected that contexts in implementations of the API will not necessarily be thread-safe,
2069 but they will not be thread-hostile. A context should not be used by multiple threads: create a new
2070 context for use on a different thread. It is just fine for an application to have many contexts,
2071 and some DNS-heavy applications will certainly want to have many even if the application uses
2072 a single thread.</p>
2073
2074 <p>See <a href="#ContextInitial">above</a> for the method for creating and destroying
2075 contexts. When the context is used in the API for the first time and <code>set_from_os</code> is
2076 <code>1</code>, the API starts replacing some of the values with values from the OS, such as
2077 those that would be found in res_query(3), /etc/resolv.conf, and so on, then proceeds with the new
2078 function. Some advanced users will not want the API to change the values to the OS's defaults; if
2079 <code>set_from_os</code> is <code>0</code>, the API will not do any updates to the initial
2080 values based on changes in the OS. For example, this might be useful if the API is acting
2081 as a stub resolver that is using a specific upstream recursive resolver chosen by the
2082 application, not the one that might come back from DHCP.</p>
2083
2084 <h2>8.1 Updating the Context Automatically</h2>
2085
2086 <p>The context returned by <code>getdns_context_create()</code> is updated by the API by default,
2087 such as when changes are made to /etc/resolv.conf. When there is a change, the callback function
2088 that is set in <code>getdns_context_set_context_update_callback()</code> (described below) is
2089 called.</p>
2090
2091 <p>Many of the defaults for a context come from the operating system under which the API is running.
2092 In specific, it is important that the implementation should try to replicate as best as possible the
2093 logic of a local <code>getaddrinfo()</code> when creating a new context. This includes making
2094 lookups in WINS for NetBIOS, mDNS lookups, nis names, and any other name lookup that
2095 <code>getaddrinfo()</code> normally does automatically. The API should look at nsswitch, the Windows
2096 resolver, and so on.</p>
2097
2098 <p>In the function definitions below, the choice listed <span class=default>in bold</span> is the one used
2099 for the API default context.</p>
2100
2101 <h2>8.2 Updating the Context Manually</h2>
2102
2103 <p>Setting specific values in a context are done with value-specific
2104 functions shown here. The setting functions all return either <code>GETDNS_RETURN_GOOD</code> for
2105 success or <code>GETDNS_RETURN_CONTEXT_UPDATE_FAIL</code> for a failure to update the context.</p>
2106
2107 <p>An application can be notified when the context is changed.</p>
2108
2109 <div class=forh>
2110 getdns_return_t
2111 getdns_context_set_context_update_callback(
2112 getdns_context *context,
2113 void (*value)(getdns_context *context, getdns_context_code_t changed_item)
2114 );</div>
2115 <p class=cont>The value is a pointer to the callback function that will be
2116 called when any context is changed. Such changes might be from automatic
2117 changes from the API (such as changes to /etc/resolv.conf), or might be from any of the
2118 API functions in this section being called. The second argument to the callback function
2119 specifies which of the context changed; the context codes are listed
2120 <a href="#ContextCodes">later in this document</a>.</p>
2121 <p class=cont>Calling getdns_context_set_context_update_callback with a second argument of NULL prevents updates to the context from causing callbacks.</p>
2122
2123 <h2>8.3 Contexts for Basic Resolution</h2>
2124
2125 <div class=forh>
2126 getdns_return_t
2127 getdns_context_set_resolution_type(
2128 getdns_context *context,
2129 getdns_resolution_t value
2130 );</div>
2131 <p class=cont>Specifies whether DNS queries are performed with nonrecurive lookups or
2132 as a stub resolver. The value is <span class=default><code>GETDNS_RESOLUTION_RECURSING</code></span> or
2133 <code>GETDNS_RESOLUTION_STUB</code>.</p>
2134
2135 <p>All implementations of this API can act as recursive resolvers, and that must be the
2136 default mode of the default context.
2137 Some implementations of this API are expected to also be able to act as stub resolvers.
2138 If an
2139 implementation of this API is only able to act as a recursive resolver, a call to
2140 <code>getdns_context_set_resolution_type(somecontext, GETDNS_RESOLUTION_STUB)</code> will
2141 return <code>GETDNS_RETURN_CONTEXT_UPDATE_FAIL</code>.</p>
2142
2143 <div class=forh>
2144 getdns_return_t
2145 getdns_context_set_namespaces(
2146 getdns_context *context,
2147 size_t namespace_count,
2148 getdns_namespace_t *namespaces
2149 );</div>
2150 <p class=cont>The <code>namespaces</code> array contains an ordered list
2151 of namespaces that will be queried.
2152 <b>Important:</b> this context setting is ignored for the <code>getdns_general</code> and
2153 <code>getdns_general_sync</code> functions; it is used for the other funtions.
2154 The values
2155 are <code>GETDNS_NAMESPACE_DNS</code>,
2156 <code>GETDNS_NAMESPACE_LOCALNAMES</code>,
2157 <code>GETDNS_NAMESPACE_NETBIOS</code>,
2158 <code>GETDNS_NAMESPACE_MDNS</code>, and
2159 <code>GETDNS_NAMESPACE_NIS</code>. When a normal lookup is done,
2160 the API does the lookups in the order given and stops when it gets the
2161 first result; a different method with the same result would be to run
2162 the queries in parallel and return when it gets the first result.
2163 Because lookups might be done over different mechanisms because of the
2164 different namespaces, there can be information leakage that is similar
2165 to that seen with <code>getaddrinfo()</code>. The
2166 default is <span class=default>determined by the OS</span>.</p>
2167
2168 <div class=forh>
2169 getdns_return_t
2170 getdns_context_set_dns_transport(
2171 getdns_context *context,
2172 getdns_transport_t value
2173 );</div>
2174 <p class=cont>Specifies what transport is used for DNS lookups.
2175 The value is <span class=default>
2176 <code>GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP</code></span>,
2177 <code>GETDNS_TRANSPORT_UDP_ONLY</code>,
2178 <code>GETDNS_TRANSPORT_TCP_ONLY</code>, or
2179 <code>GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN</code>.</p>
2180
2181 <div class=forh>
2182 getdns_return_t
2183 getdns_context_set_limit_outstanding_queries(
2184 getdns_context *context,
2185 uint16_t limit
2186 );</div>
2187 <p class=cont>Specifies limit the number of outstanding DNS queries.
2188 The API will block itself from sending more queries if it is about to exceed
2189 this value, and instead keep those queries in an internal queue.
2190 The a value of <span class=default>0</span> indicates that
2191 the number of outstanding DNS queries is unlimited.</p>
2192
2193 <div class=forh>
2194 getdns_return_t
2195 getdns_context_set_timeout(
2196 getdns_context *context,
2197 uint64_t timeout
2198 );</div>
2199 <p class=cont>Specifies number of milliseconds the API will wait for request to return.
2200 The default is <span class=default>not specified</span>.</p>
2201
2202 <h2>8.4 Context for Recursive Resolvers</h2>
2203
2204 <div class=forh>
2205 getdns_return_t
2206 getdns_context_set_follow_redirects(
2207 getdns_context *context,
2208 getdns_redirects_t value
2209 );</div>
2210 <p class=cont>Specifies whether or not DNS queries follow redirects.
2211 The value is <span class=default><code>GETDNS_REDIRECTS_FOLLOW</code></span> for normal
2212 following of redirects though CNAME and DNAME; or
2213 <code>GETDNS_REDIRECTS_DO_NOT_FOLLOW</code> to cause any lookups that would have gone
2214 through CNAME and DNAME to return the CNAME or DNAME, not the eventual target.</p>
2215
2216 <div class=forh>
2217 getdns_return_t
2218 getdns_context_set_dns_root_servers(
2219 getdns_context *context,
2220 getdns_list *addresses
2221 );</div>
2222 <p class=cont>The list contains dicts that are addresses to be used for looking up top-level
2223 domains; the default is the list of <b>"normal" IANA root servers</b>. Each dict in the list
2224 contains at least two names: <code>address_type</code> (whose value is a bindata; it is currently
2225 either "IPv4" or "IPv6") and <code>address_data</code> (whose value is a bindata).</p>
2226
2227 <h2>8.5 Context for Local Naming</h2>
2228
2229 <div class=forh>
2230 getdns_return_t
2231 getdns_context_set_append_name(
2232 getdns_context *context,
2233 getdns_append_name_t value
2234 );</div>
2235 <p class=cont>Specifies whether to append a suffix to the query string
2236 before the API starts resolving a name.
2237 The value is <span class=default>
2238 <code>GETDNS_APPEND_NAME_ALWAYS</code></span>,
2239 <code>GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE</code>,
2240 <code>GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE</code>,
2241 or <code>GETDNS_APPEND_NAME_NEVER</code>. This controls
2242 whether or not to append the suffix given by <code>getdns_context_set_suffix</code></p>
2243
2244 <div class=forh>
2245 getdns_return_t
2246 getdns_context_set_suffix(
2247 getdns_context *context,
2248 getdns_list *value
2249 );</div>
2250 <p class=cont>The value is a list of bindatas that are strings that are
2251 to be appended based on <code>getdns_context_set_append_name</code>; the default is an <span
2252 class=default>empty list</span>. The values here follow the rules in section 2.1 of RFC 4343
2253 to allow non-ASCII octets and special characters in labels.</p>
2254
2255 <h2>8.6 Context for DNSSEC</h2>
2256
2257 <p>These context settings affect queries that have extensions that specify the use of DNSSEC.</p>
2258
2259 <p>Applications that need to specify the DNSSEC trust anchors can use:</p>
2260 <div class=forh>
2261 getdns_return_t
2262 getdns_context_set_dnssec_trust_anchors(
2263 getdns_context *context,
2264 getdns_list *value
2265 );</div>
2266 <p class=cont>The value is a list of bindatas that are the DNSSEC trust anchors. The default
2267 is the trust anchors from the <span class=default>IANA root</span>. The trust anchors
2268 are expressed as RDATAs from DNSKEY resource records.</p>
2269
2270 <p>In the rare case that an application needs to set the DNSSEC skew, it can:</p>
2271 <div class=forh>
2272 getdns_return_t
2273 getdns_context_set_dnssec_allowed_skew(
2274 getdns_context *context,
2275 uint32_t value
2276 );</div>
2277 <p class=cont>The value is the number of seconds of skew that is allowed in either direction when
2278 checking an RRSIG's Expiration and Inception fields. The default
2279 is <span class=default>0</span>.</p>
2280
2281 <h2>8.7 Context Specific to Stub Resolvers</h2>
2282
2283 <p>An application can change the quering mechanism of a context to be to act as a stub
2284 resolver. Such an application might first get the default information to make this change
2285 from the operating system, probably through DHCP.</p>
2286
2287 <p>Note that if a context is changed to being a stub resolver, this automatically prevents the application
2288 from using the extenstions for DNSSEC. An application that wants to both do DNSSEC and stub resolution
2289 must do its own DNSSEC processing, possibly with the <code>getdns_validate_dnssec()</code> function.</p>
2290
2291 <div class=forh>
2292 getdns_return_t
2293 getdns_context_set_upstream_recursive_servers(
2294 getdns_context *context,
2295 getdns_list *upstream_list
2296 );</div>
2297 <p class=cont>The list of dicts define where a stub resolver will send queries. Each dict contains
2298 at least two names: <code>address_type</code> (whose value is a bindata; it is currently either
2299 "IPv4" or "IPv6") and <code>address_data</code> (whose value is a bindata). It might also contain
2300 <code>port</code> to specify which port to use to contact these DNS servers; the default is 53. If
2301 the stub and a recursive resolver both support TSIG (RFC 2845), the <code>upstream_list</code> entry
2302 can also contain <code>tsig_algorithm</code> (a bindata) that is the name of the TSIG hash
2303 algorithm, and <code>tsig_secret</code> (a bindata) that is the TSIG key.</p>
2304
2305 <h2>8.8 Context for EDNS</h2>
2306
2307 <p>These context settings affect queries that have extensions that specify the use of OPT resource records.
2308 These come from RFC 2671.</p>
2309
2310 <div class=forh>
2311 getdns_return_t
2312 getdns_context_set_edns_maximum_udp_payload_size(
2313 getdns_context *context,
2314 uint16_t value
2315 );</div>
2316 <p class=cont>The value is between 512 and 65535; the default
2317 is <span class=default>512</span>.</p>
2318
2319 <div class=forh>
2320 getdns_return_t
2321 getdns_context_set_edns_extended_rcode(
2322 getdns_context *context,
2323 uint8_t value
2324 );</div>
2325 <p class=cont>The value is between 0 and 255; the default
2326 is <span class=default>0</span>.</p>
2327
2328 <div class=forh>
2329 getdns_return_t
2330 getdns_context_set_edns_version(
2331 getdns_context *context,
2332 uint8_t value
2333 );</div>
2334 <p class=cont>The value is between 0 and 255; the default
2335 is <span class=default>0</span>.</p>
2336
2337 <div class=forh>
2338 getdns_return_t
2339 getdns_context_set_edns_do_bit(
2340 getdns_context *context,
2341 uint8_t value
2342 );</div>
2343 <p class=cont>The value is between 0 and 1; the default
2344 is <span class=default>0</span>.</p>
2345
2346 <h2>8.9 Context Use of Custom Memory Management Functions</h2>
2347
2348 <div class=forh>
2349 getdns_return_t
2350 getdns_context_set_memory_functions(
2351 getdns_context *context,
2352 void *(*malloc) (size_t),
2353 void *(*realloc) (void *, size_t),
2354 void (*free) (void *)
2355 );</div>
2356 <p class=cont>The given memory management functions will be used for creating the response dicts.
2357 The response dicts inherit the custom memory management functions from the context and will deallocate themselves (and their members) with the custom deallocator.
2358 By default, the system <span class=default>malloc</span>, <span class=default>realloc</span>, and <span>free</span> are used.</p>
2359
2360 <div class=forh>
2361 getdns_return_t
2362 getdns_context_set_extended_memory_functions(
2363 getdns_context *context,
2364 void *userarg,
2365 void *(*malloc)(void *userarg, size_t sz),
2366 void *(*realloc)(void *userarg, void *ptr, size_t sz),
2367 void (*free)(void *userarg, void *ptr)
2368 );</div>
2369 <p class=cont>The given extended memory management functions will be used for creating the response dicts.
2370 The value of <code>userarg</code> argument will be passed to the custom <code>malloc</code>, <code>realloc</code>, and <code>free</code>.
2371 The response dicts inherit the custom memory management functions and the value for <code>userarg</code> from the context and will deallocate themselves (and their members) with the custom deallocator.</p>
2372
2373 <h2>8.10 <a id="ContextCodes">Context Codes</a></h2>
2374
2375 <p>The context codes for <code>getdns_context_set_context_update_callback()</code> are:</p>
2376
2377 <p class=define>GETDNS_CONTEXT_CODE_NAMESPACES</p>
2378 <p class=descrip>Change related to <code>getdns_context_set_namespaces</code></p>
2379 <p class=define>GETDNS_CONTEXT_CODE_RESOLUTION_TYPE</p>
2380 <p class=descrip>Change related to <code>getdns_context_set_resolution_type</code></p>
2381 <p class=define>GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS</p>
2382 <p class=descrip>Change related to <code>getdns_context_set_follow_redirects</code></p>
2383 <p class=define>GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS</p>
2384 <p class=descrip>Change related to <code>getdns_context_set_upstream_recursive_servers</code></p>
2385 <p class=define>GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS</p>
2386 <p class=descrip>Change related to <code>getdns_context_set_dns_root_servers</code></p>
2387 <p class=define>GETDNS_CONTEXT_CODE_DNS_TRANSPORT</p>
2388 <p class=descrip>Change related to <code>getdns_context_set_dns_transport</code></p>
2389 <p class=define>GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES</p>
2390 <p class=descrip>Change related to <code>getdns_context_set_limit_outstanding_queries</code></p>
2391 <p class=define>GETDNS_CONTEXT_CODE_APPEND_NAME</p>
2392 <p class=descrip>Change related to <code>getdns_context_set_append_name</code></p>
2393 <p class=define>GETDNS_CONTEXT_CODE_SUFFIX</p>
2394 <p class=descrip>Change related to <code>getdns_context_set_suffix</code></p>
2395 <p class=define>GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS</p>
2396 <p class=descrip>Change related to <code>getdns_context_set_dnssec_trust_anchors</code></p>
2397 <p class=define>GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE</p>
2398 <p class=descrip>Change related to <code>getdns_context_set_edns_maximum_udp_payload_size</code></p>
2399 <p class=define>GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE</p>
2400 <p class=descrip>Change related to <code>getdns_context_set_edns_extended_rcode</code></p>
2401 <p class=define>GETDNS_CONTEXT_CODE_EDNS_VERSION</p>
2402 <p class=descrip>Change related to <code>getdns_context_set_edns_version</code></p>
2403 <p class=define>GETDNS_CONTEXT_CODE_EDNS_DO_BIT</p>
2404 <p class=descrip>Change related to <code>getdns_context_set_edns_do_bit</code></p>
2405 <p class=define>GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW</p>
2406 <p class=descrip>Change related to <code>getdns_context_set_dnssec_allowed_skew</code></p>
2407 <p class=define>GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS</p>
2408 <p class=descrip>Change related to <code>getdns_context_set_memory_functions</code></p>
2409 <p class=define>GETDNS_CONTEXT_CODE_TIMEOUT</p>
2410 <p class=descrip>Change related to <code>getdns_context_set_timeout</code></p>
2411
2412
2413 <h2>8.11 Getting API information and current Contexts</h2>
2414 <p>An application might want to see information about the API itself and inspect the current context.
2415 Use the <code>getdns_context_get_api_information</code> function.</p>
2416 <div class=forh>
2417 getdns_dict *
2418 getdns_context_get_api_information(
2419 getdns_context *context
2420 );
2421 </div>
2422 <p>The returned <code>getdns_dict</code> will contain the following name/value pairs:</p>
2423 <ul>
2424 <li><code>version_string</code> (a bindata) represents the version string for this version of the DNS
2425 API.</li>
2426
2427 <li><code>implementation_string</code> (a bindata) is a string set by the API implementer. It might
2428 be human-readable, and it might have information in it useful to an application developer (but it doesn't
2429 have to).</li>
2430
2431 <li><code>resolver_type</code> (an int) is the type of resolver that the API is acting as in this context:
2432 <code>GETDNS_RESOLUTION_RECURSING</code> or <code>GETDNS_RESOLUTION_STUB</code> (it will be
2433 a recursing resolver unless the application changed this in a context.</li>
2434
2435 <li><code>all_context</code> (a dict) with names for all the types of context. This can be used with
2436 getdns_pretty_print_dict() for debugging.</li>
2437
2438 </ul>
2439
2440 <h1>9. The Generated Files</h1>
2441
2442 <p>There is <a href="getdns-0.5.tgz">a tarball</a> that includes the .h files,
2443 the examples, and so on. The examples all make, even though there is no API implementation, based
2444 on a pseudo-implementation in the tarball; see make-examples-PLATFORM.sh. Note that this currently builds fine
2445 on the Macintosh and Ubuntu; help is definitely appreciated on making the build process
2446 work on more platforms if it fails there.</p>
2447
2448 <h1>10. <a id="Commentary">Commentary</a></h1>
2449
2450 <p>The following description of the API may be of value to those who might implement the design, and
2451 those who are using an implementation of the design.</p>
2452
2453 <h2>10.1 API Design Considerations</h2>
2454
2455 <p>The genesis of this DNS API design was seeing other DNS API designs flounder. There are other
2456 DNS APIs already available (such as draft-hayatnagarkar-dnsext-validator-api, as well
2457 as DNSSEC APIs in BIND and Unbound), but there has been very little uptake of them. In talking to
2458 application developers, there was a consistent story: that they felt that the APIs were developed by and
2459 for DNS people, not applications developers.</p>
2460
2461 <p>This API design comes from talking to a small handful of applications developers about what they
2462 would want to see in a modern DNS API. Now that the API is public, it would be great to hear from many
2463 more application developers about whether it would meet their needs if it was implemented. My goal
2464 is to create a design that is a natural follow-on to <code>getaddrinfo()</code> that has all the
2465 capabilities that most application developers might want now or in the next few years: access to all
2466 types of DNS records (including those which are yet to be defined), full DNSSEC awareness, IDN
2467 handling, and parity for IPv4 and IPv6 addresses.</p>
2468
2469 <p>Note that this is just a design for a new API: there is no implementation of the design yet, but
2470 at least one is being worked on. The process of designing the API without implementing it at the
2471 same time has the huge advantage that major design changes could be made without any worry about
2472 "but we already coded it the other way". In the early revisions of this document, many fundamental
2473 design choices changed over and over, and even bike-shedding-like changes were allowed because they
2474 didn't involve any programming effort.</p>
2475
2476 <p>This work was done independently, not through the IETF because the IETF generally doesn't take on
2477 API work, and has explicitly avoided DNS API work in the past.</p>
2478
2479 <p>This API design has a Creative Commons license so that it can be
2480 used widely by potential API implementers. This also allows other people who want to fork the design
2481 to do so cleanly. Of course, any implementation of this API can choose whatever kind of license the
2482 API implementer wishes, but it would be fabulous if one or more such implementations had Creative
2483 Commons or BSD-ish licenses.</p>
2484
2485 <p>The API relies heavily on C macros and hopefully has no magic numbers.</p>
2486
2487 <h2>10.2 API Implementation Considerations</h2>
2488
2489 <p>All implementations of this API must act as recursive resolvers, and some might choose not to be
2490 able to act as stub resolvers. Note that all implementations of this API must be DNSSEC validators.</p>
2491
2492 <p>Because there are many C event libraries available, and they have different calling routines,
2493 it is the implementation of an API that determines which event library is used. This is certainly
2494 not optimal for C programmers, but they appear to have gotten used to is so far. All implementations
2495 of this API must support synchronous calls with <code>getdns_general_sync()</code>.</p>
2496
2497 <p>Versions are differentiated by version strings instead of version numbers. The version string for
2498 this API is "getdns April 2013". Each implementation is free to set the implementation string as it
2499 feels fit.</p>
2500
2501 <p>The API's .h file contains a macro called <code>GETDNS_COMPILATION_COMMENT</code>. This can be useful
2502 to an application which will use the API because it can check the string without calling any
2503 functions. Each time the API implementation is compiled, this string should be updated with unique
2504 information about the implementation build.</p>
2505
2506 <p>The implementation of both the async and sync <code>getdns</code> functions will
2507 copy all the values of the parameters into local memory, in case the application changes or
2508 deallocates them.</p>
2509
2510 <hr width=90%>
2511
2512 <p><a rel="license" href="http://creativecommons.org/licenses/by/3.0/deed.en_US"><img alt="Creative
2513 Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by/3.0/80x15.png"
2514 /></a><br />This work is licensed under a <a rel="license"
2515 href="http://creativecommons.org/licenses/by/3.0/deed.en_US">Creative Commons Attribution 3.0
2516 Unported License</a>.</p>
2517
2518 </body></html>
0 # Doxyfile 1.8.3.1
1 # Copyright (c) 2013, Verisign, Inc., NLnet Labs
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution.
11 # * Neither the names of the copyright holders nor the
12 # names of its contributors may be used to endorse or promote products
13 # derived from this software without specific prior written permission.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26 # This file describes the settings to be used by the documentation system
27 # doxygen (www.doxygen.org) for a project.
28 #
29 # All text after a hash (#) is considered a comment and will be ignored.
30 # The format is:
31 # TAG = value [value, ...]
32 # For lists items can also be appended using:
33 # TAG += value [value, ...]
34 # Values that contain spaces should be placed between quotes (" ").
35
36 #---------------------------------------------------------------------------
37 # Project related configuration options
38 #---------------------------------------------------------------------------
39
40 # This tag specifies the encoding used for all characters in the config file
41 # that follow. The default is UTF-8 which is also the encoding used for all
42 # text before the first occurrence of this tag. Doxygen uses libiconv (or the
43 # iconv built into libc) for the transcoding. See
44 # http://www.gnu.org/software/libiconv for the list of possible encodings.
45
46 DOXYFILE_ENCODING = UTF-8
47
48 # The PROJECT_NAME tag is a single word (or sequence of words) that should
49 # identify the project. Note that if you do not use Doxywizard you need
50 # to put quotes around the project name if it contains spaces.
51
52 PROJECT_NAME = "getdns API"
53
54 # The PROJECT_NUMBER tag can be used to enter a project or revision number.
55 # This could be handy for archiving the generated documentation or
56 # if some version control system is used.
57
58 PROJECT_NUMBER = @PACKAGE_VERSION@
59
60 # Using the PROJECT_BRIEF tag one can provide an optional one line description
61 # for a project that appears at the top of each page and should give viewer
62 # a quick idea about the purpose of the project. Keep the description short.
63
64 PROJECT_BRIEF = "A modern asynchronous API for fetching DNS data"
65
66 # With the PROJECT_LOGO tag one can specify an logo or icon that is
67 # included in the documentation. The maximum height of the logo should not
68 # exceed 55 pixels and the maximum width should not exceed 200 pixels.
69 # Doxygen will copy the logo to the output directory.
70
71 PROJECT_LOGO =
72
73 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
74 # base path where the generated documentation will be put.
75 # If a relative path is entered, it will be relative to the location
76 # where doxygen was started. If left blank the current directory will be used.
77
78 OUTPUT_DIRECTORY = ../doc
79
80 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
81 # 4096 sub-directories (in 2 levels) under the output directory of each output
82 # format and will distribute the generated files over these directories.
83 # Enabling this option can be useful when feeding doxygen a huge amount of
84 # source files, where putting all generated files in the same directory would
85 # otherwise cause performance problems for the file system.
86
87 CREATE_SUBDIRS = NO
88
89 # The OUTPUT_LANGUAGE tag is used to specify the language in which all
90 # documentation generated by doxygen is written. Doxygen will use this
91 # information to generate all constant output in the proper language.
92 # The default language is English, other supported languages are:
93 # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
94 # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
95 # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
96 # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
97 # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
98 # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
99
100 OUTPUT_LANGUAGE = English
101
102 # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
103 # include brief member descriptions after the members that are listed in
104 # the file and class documentation (similar to JavaDoc).
105 # Set to NO to disable this.
106
107 BRIEF_MEMBER_DESC = YES
108
109 # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
110 # the brief description of a member or function before the detailed description.
111 # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
112 # brief descriptions will be completely suppressed.
113
114 REPEAT_BRIEF = YES
115
116 # This tag implements a quasi-intelligent brief description abbreviator
117 # that is used to form the text in various listings. Each string
118 # in this list, if found as the leading text of the brief description, will be
119 # stripped from the text and the result after processing the whole list, is
120 # used as the annotated text. Otherwise, the brief description is used as-is.
121 # If left blank, the following values are used ("$name" is automatically
122 # replaced with the name of the entity): "The $name class" "The $name widget"
123 # "The $name file" "is" "provides" "specifies" "contains"
124 # "represents" "a" "an" "the"
125
126 ABBREVIATE_BRIEF =
127
128 # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
129 # Doxygen will generate a detailed section even if there is only a brief
130 # description.
131
132 ALWAYS_DETAILED_SEC = YES
133
134 # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
135 # inherited members of a class in the documentation of that class as if those
136 # members were ordinary class members. Constructors, destructors and assignment
137 # operators of the base classes will not be shown.
138
139 INLINE_INHERITED_MEMB = NO
140
141 # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
142 # path before files name in the file list and in the header files. If set
143 # to NO the shortest path that makes the file name unique will be used.
144
145 FULL_PATH_NAMES = NO
146
147 # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
148 # can be used to strip a user-defined part of the path. Stripping is
149 # only done if one of the specified strings matches the left-hand part of
150 # the path. The tag can be used to show relative paths in the file list.
151 # If left blank the directory from which doxygen is run is used as the
152 # path to strip. Note that you specify absolute paths here, but also
153 # relative paths, which will be relative from the directory where doxygen is
154 # started.
155
156 STRIP_FROM_PATH =
157
158 # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
159 # the path mentioned in the documentation of a class, which tells
160 # the reader which header file to include in order to use a class.
161 # If left blank only the name of the header file containing the class
162 # definition is used. Otherwise one should specify the include paths that
163 # are normally passed to the compiler using the -I flag.
164
165 STRIP_FROM_INC_PATH =
166
167 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
168 # (but less readable) file names. This can be useful if your file system
169 # doesn't support long names like on DOS, Mac, or CD-ROM.
170
171 SHORT_NAMES = NO
172
173 # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
174 # will interpret the first line (until the first dot) of a JavaDoc-style
175 # comment as the brief description. If set to NO, the JavaDoc
176 # comments will behave just like regular Qt-style comments
177 # (thus requiring an explicit @brief command for a brief description.)
178
179 JAVADOC_AUTOBRIEF = NO
180
181 # If the QT_AUTOBRIEF tag is set to YES then Doxygen will
182 # interpret the first line (until the first dot) of a Qt-style
183 # comment as the brief description. If set to NO, the comments
184 # will behave just like regular Qt-style comments (thus requiring
185 # an explicit \brief command for a brief description.)
186
187 QT_AUTOBRIEF = NO
188
189 # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
190 # treat a multi-line C++ special comment block (i.e. a block of //! or ///
191 # comments) as a brief description. This used to be the default behaviour.
192 # The new default is to treat a multi-line C++ comment block as a detailed
193 # description. Set this tag to YES if you prefer the old behaviour instead.
194
195 MULTILINE_CPP_IS_BRIEF = NO
196
197 # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
198 # member inherits the documentation from any documented member that it
199 # re-implements.
200
201 INHERIT_DOCS = YES
202
203 # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
204 # a new page for each member. If set to NO, the documentation of a member will
205 # be part of the file/class/namespace that contains it.
206
207 SEPARATE_MEMBER_PAGES = NO
208
209 # The TAB_SIZE tag can be used to set the number of spaces in a tab.
210 # Doxygen uses this value to replace tabs by spaces in code fragments.
211
212 TAB_SIZE = 4
213
214 # This tag can be used to specify a number of aliases that acts
215 # as commands in the documentation. An alias has the form "name=value".
216 # For example adding "sideeffect=\par Side Effects:\n" will allow you to
217 # put the command \sideeffect (or @sideeffect) in the documentation, which
218 # will result in a user-defined paragraph with heading "Side Effects:".
219 # You can put \n's in the value part of an alias to insert newlines.
220
221 ALIASES =
222
223 # This tag can be used to specify a number of word-keyword mappings (TCL only).
224 # A mapping has the form "name=value". For example adding
225 # "class=itcl::class" will allow you to use the command class in the
226 # itcl::class meaning.
227
228 TCL_SUBST =
229
230 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
231 # sources only. Doxygen will then generate output that is more tailored for C.
232 # For instance, some of the names that are used will be different. The list
233 # of all members will be omitted, etc.
234
235 OPTIMIZE_OUTPUT_FOR_C = YES
236
237 # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
238 # sources only. Doxygen will then generate output that is more tailored for
239 # Java. For instance, namespaces will be presented as packages, qualified
240 # scopes will look different, etc.
241
242 OPTIMIZE_OUTPUT_JAVA = NO
243
244 # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
245 # sources only. Doxygen will then generate output that is more tailored for
246 # Fortran.
247
248 OPTIMIZE_FOR_FORTRAN = NO
249
250 # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
251 # sources. Doxygen will then generate output that is tailored for
252 # VHDL.
253
254 OPTIMIZE_OUTPUT_VHDL = NO
255
256 # Doxygen selects the parser to use depending on the extension of the files it
257 # parses. With this tag you can assign which parser to use for a given
258 # extension. Doxygen has a built-in mapping, but you can override or extend it
259 # using this tag. The format is ext=language, where ext is a file extension,
260 # and language is one of the parsers supported by doxygen: IDL, Java,
261 # Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C,
262 # C++. For instance to make doxygen treat .inc files as Fortran files (default
263 # is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note
264 # that for custom extensions you also need to set FILE_PATTERNS otherwise the
265 # files are not read by doxygen.
266
267 EXTENSION_MAPPING =
268
269 # If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all
270 # comments according to the Markdown format, which allows for more readable
271 # documentation. See http://daringfireball.net/projects/markdown/ for details.
272 # The output of markdown processing is further processed by doxygen, so you
273 # can mix doxygen, HTML, and XML commands with Markdown formatting.
274 # Disable only in case of backward compatibilities issues.
275
276 MARKDOWN_SUPPORT = YES
277
278 # When enabled doxygen tries to link words that correspond to documented classes,
279 # or namespaces to their corresponding documentation. Such a link can be
280 # prevented in individual cases by by putting a % sign in front of the word or
281 # globally by setting AUTOLINK_SUPPORT to NO.
282
283 AUTOLINK_SUPPORT = YES
284
285 # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
286 # to include (a tag file for) the STL sources as input, then you should
287 # set this tag to YES in order to let doxygen match functions declarations and
288 # definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
289 # func(std::string) {}). This also makes the inheritance and collaboration
290 # diagrams that involve STL classes more complete and accurate.
291
292 BUILTIN_STL_SUPPORT = NO
293
294 # If you use Microsoft's C++/CLI language, you should set this option to YES to
295 # enable parsing support.
296
297 CPP_CLI_SUPPORT = NO
298
299 # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
300 # Doxygen will parse them like normal C++ but will assume all classes use public
301 # instead of private inheritance when no explicit protection keyword is present.
302
303 SIP_SUPPORT = NO
304
305 # For Microsoft's IDL there are propget and propput attributes to indicate
306 # getter and setter methods for a property. Setting this option to YES (the
307 # default) will make doxygen replace the get and set methods by a property in
308 # the documentation. This will only work if the methods are indeed getting or
309 # setting a simple type. If this is not the case, or you want to show the
310 # methods anyway, you should set this option to NO.
311
312 IDL_PROPERTY_SUPPORT = YES
313
314 # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
315 # tag is set to YES, then doxygen will reuse the documentation of the first
316 # member in the group (if any) for the other members of the group. By default
317 # all members of a group must be documented explicitly.
318
319 DISTRIBUTE_GROUP_DOC = NO
320
321 # Set the SUBGROUPING tag to YES (the default) to allow class member groups of
322 # the same type (for instance a group of public functions) to be put as a
323 # subgroup of that type (e.g. under the Public Functions section). Set it to
324 # NO to prevent subgrouping. Alternatively, this can be done per class using
325 # the \nosubgrouping command.
326
327 SUBGROUPING = YES
328
329 # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
330 # unions are shown inside the group in which they are included (e.g. using
331 # @ingroup) instead of on a separate page (for HTML and Man pages) or
332 # section (for LaTeX and RTF).
333
334 INLINE_GROUPED_CLASSES = NO
335
336 # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
337 # unions with only public data fields will be shown inline in the documentation
338 # of the scope in which they are defined (i.e. file, namespace, or group
339 # documentation), provided this scope is documented. If set to NO (the default),
340 # structs, classes, and unions are shown on a separate page (for HTML and Man
341 # pages) or section (for LaTeX and RTF).
342
343 INLINE_SIMPLE_STRUCTS = NO
344
345 # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
346 # is documented as struct, union, or enum with the name of the typedef. So
347 # typedef struct TypeS {} TypeT, will appear in the documentation as a struct
348 # with name TypeT. When disabled the typedef will appear as a member of a file,
349 # namespace, or class. And the struct will be named TypeS. This can typically
350 # be useful for C code in case the coding convention dictates that all compound
351 # types are typedef'ed and only the typedef is referenced, never the tag name.
352
353 TYPEDEF_HIDES_STRUCT = NO
354
355 # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
356 # determine which symbols to keep in memory and which to flush to disk.
357 # When the cache is full, less often used symbols will be written to disk.
358 # For small to medium size projects (<1000 input files) the default value is
359 # probably good enough. For larger projects a too small cache size can cause
360 # doxygen to be busy swapping symbols to and from disk most of the time
361 # causing a significant performance penalty.
362 # If the system has enough physical memory increasing the cache will improve the
363 # performance by keeping more symbols in memory. Note that the value works on
364 # a logarithmic scale so increasing the size by one will roughly double the
365 # memory usage. The cache size is given by this formula:
366 # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
367 # corresponding to a cache size of 2^16 = 65536 symbols.
368
369 SYMBOL_CACHE_SIZE = 0
370
371 # Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
372 # set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
373 # their name and scope. Since this can be an expensive process and often the
374 # same symbol appear multiple times in the code, doxygen keeps a cache of
375 # pre-resolved symbols. If the cache is too small doxygen will become slower.
376 # If the cache is too large, memory is wasted. The cache size is given by this
377 # formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,
378 # corresponding to a cache size of 2^16 = 65536 symbols.
379
380 LOOKUP_CACHE_SIZE = 0
381
382 #---------------------------------------------------------------------------
383 # Build related configuration options
384 #---------------------------------------------------------------------------
385
386 # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
387 # documentation are documented, even if no documentation was available.
388 # Private class members and static file members will be hidden unless
389 # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
390
391 EXTRACT_ALL = YES
392
393 # If the EXTRACT_PRIVATE tag is set to YES all private members of a class
394 # will be included in the documentation.
395
396 EXTRACT_PRIVATE = NO
397
398 # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal
399 # scope will be included in the documentation.
400
401 EXTRACT_PACKAGE = NO
402
403 # If the EXTRACT_STATIC tag is set to YES all static members of a file
404 # will be included in the documentation.
405
406 EXTRACT_STATIC = YES
407
408 # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
409 # defined locally in source files will be included in the documentation.
410 # If set to NO only classes defined in header files are included.
411
412 EXTRACT_LOCAL_CLASSES = YES
413
414 # This flag is only useful for Objective-C code. When set to YES local
415 # methods, which are defined in the implementation section but not in
416 # the interface are included in the documentation.
417 # If set to NO (the default) only methods in the interface are included.
418
419 EXTRACT_LOCAL_METHODS = NO
420
421 # If this flag is set to YES, the members of anonymous namespaces will be
422 # extracted and appear in the documentation as a namespace called
423 # 'anonymous_namespace{file}', where file will be replaced with the base
424 # name of the file that contains the anonymous namespace. By default
425 # anonymous namespaces are hidden.
426
427 EXTRACT_ANON_NSPACES = NO
428
429 # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
430 # undocumented members of documented classes, files or namespaces.
431 # If set to NO (the default) these members will be included in the
432 # various overviews, but no documentation section is generated.
433 # This option has no effect if EXTRACT_ALL is enabled.
434
435 HIDE_UNDOC_MEMBERS = NO
436
437 # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
438 # undocumented classes that are normally visible in the class hierarchy.
439 # If set to NO (the default) these classes will be included in the various
440 # overviews. This option has no effect if EXTRACT_ALL is enabled.
441
442 HIDE_UNDOC_CLASSES = NO
443
444 # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
445 # friend (class|struct|union) declarations.
446 # If set to NO (the default) these declarations will be included in the
447 # documentation.
448
449 HIDE_FRIEND_COMPOUNDS = NO
450
451 # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
452 # documentation blocks found inside the body of a function.
453 # If set to NO (the default) these blocks will be appended to the
454 # function's detailed documentation block.
455
456 HIDE_IN_BODY_DOCS = NO
457
458 # The INTERNAL_DOCS tag determines if documentation
459 # that is typed after a \internal command is included. If the tag is set
460 # to NO (the default) then the documentation will be excluded.
461 # Set it to YES to include the internal documentation.
462
463 INTERNAL_DOCS = NO
464
465 # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
466 # file names in lower-case letters. If set to YES upper-case letters are also
467 # allowed. This is useful if you have classes or files whose names only differ
468 # in case and if your file system supports case sensitive file names. Windows
469 # and Mac users are advised to set this option to NO.
470
471 CASE_SENSE_NAMES = YES
472
473 # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
474 # will show members with their full class and namespace scopes in the
475 # documentation. If set to YES the scope will be hidden.
476
477 HIDE_SCOPE_NAMES = NO
478
479 # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
480 # will put a list of the files that are included by a file in the documentation
481 # of that file.
482
483 SHOW_INCLUDE_FILES = YES
484
485 # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
486 # will list include files with double quotes in the documentation
487 # rather than with sharp brackets.
488
489 FORCE_LOCAL_INCLUDES = NO
490
491 # If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
492 # is inserted in the documentation for inline members.
493
494 INLINE_INFO = YES
495
496 # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
497 # will sort the (detailed) documentation of file and class members
498 # alphabetically by member name. If set to NO the members will appear in
499 # declaration order.
500
501 SORT_MEMBER_DOCS = NO
502
503 # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
504 # brief documentation of file, namespace and class members alphabetically
505 # by member name. If set to NO (the default) the members will appear in
506 # declaration order.
507
508 SORT_BRIEF_DOCS = NO
509
510 # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
511 # will sort the (brief and detailed) documentation of class members so that
512 # constructors and destructors are listed first. If set to NO (the default)
513 # the constructors will appear in the respective orders defined by
514 # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
515 # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
516 # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
517
518 SORT_MEMBERS_CTORS_1ST = NO
519
520 # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
521 # hierarchy of group names into alphabetical order. If set to NO (the default)
522 # the group names will appear in their defined order.
523
524 SORT_GROUP_NAMES = NO
525
526 # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
527 # sorted by fully-qualified names, including namespaces. If set to
528 # NO (the default), the class list will be sorted only by class name,
529 # not including the namespace part.
530 # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
531 # Note: This option applies only to the class list, not to the
532 # alphabetical list.
533
534 SORT_BY_SCOPE_NAME = NO
535
536 # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
537 # do proper type resolution of all parameters of a function it will reject a
538 # match between the prototype and the implementation of a member function even
539 # if there is only one candidate or it is obvious which candidate to choose
540 # by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
541 # will still accept a match between prototype and implementation in such cases.
542
543 STRICT_PROTO_MATCHING = NO
544
545 # The GENERATE_TODOLIST tag can be used to enable (YES) or
546 # disable (NO) the todo list. This list is created by putting \todo
547 # commands in the documentation.
548
549 GENERATE_TODOLIST = YES
550
551 # The GENERATE_TESTLIST tag can be used to enable (YES) or
552 # disable (NO) the test list. This list is created by putting \test
553 # commands in the documentation.
554
555 GENERATE_TESTLIST = YES
556
557 # The GENERATE_BUGLIST tag can be used to enable (YES) or
558 # disable (NO) the bug list. This list is created by putting \bug
559 # commands in the documentation.
560
561 GENERATE_BUGLIST = YES
562
563 # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
564 # disable (NO) the deprecated list. This list is created by putting
565 # \deprecated commands in the documentation.
566
567 GENERATE_DEPRECATEDLIST= YES
568
569 # The ENABLED_SECTIONS tag can be used to enable conditional
570 # documentation sections, marked by \if section-label ... \endif
571 # and \cond section-label ... \endcond blocks.
572
573 ENABLED_SECTIONS =
574
575 # The MAX_INITIALIZER_LINES tag determines the maximum number of lines
576 # the initial value of a variable or macro consists of for it to appear in
577 # the documentation. If the initializer consists of more lines than specified
578 # here it will be hidden. Use a value of 0 to hide initializers completely.
579 # The appearance of the initializer of individual variables and macros in the
580 # documentation can be controlled using \showinitializer or \hideinitializer
581 # command in the documentation regardless of this setting.
582
583 MAX_INITIALIZER_LINES = 30
584
585 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated
586 # at the bottom of the documentation of classes and structs. If set to YES the
587 # list will mention the files that were used to generate the documentation.
588
589 SHOW_USED_FILES = YES
590
591 # Set the SHOW_FILES tag to NO to disable the generation of the Files page.
592 # This will remove the Files entry from the Quick Index and from the
593 # Folder Tree View (if specified). The default is YES.
594
595 SHOW_FILES = YES
596
597 # Set the SHOW_NAMESPACES tag to NO to disable the generation of the
598 # Namespaces page.
599 # This will remove the Namespaces entry from the Quick Index
600 # and from the Folder Tree View (if specified). The default is YES.
601
602 SHOW_NAMESPACES = YES
603
604 # The FILE_VERSION_FILTER tag can be used to specify a program or script that
605 # doxygen should invoke to get the current version for each file (typically from
606 # the version control system). Doxygen will invoke the program by executing (via
607 # popen()) the command <command> <input-file>, where <command> is the value of
608 # the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
609 # provided by doxygen. Whatever the program writes to standard output
610 # is used as the file version. See the manual for examples.
611
612 FILE_VERSION_FILTER =
613
614 # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
615 # by doxygen. The layout file controls the global structure of the generated
616 # output files in an output format independent way. To create the layout file
617 # that represents doxygen's defaults, run doxygen with the -l option.
618 # You can optionally specify a file name after the option, if omitted
619 # DoxygenLayout.xml will be used as the name of the layout file.
620
621 LAYOUT_FILE =
622
623 # The CITE_BIB_FILES tag can be used to specify one or more bib files
624 # containing the references data. This must be a list of .bib files. The
625 # .bib extension is automatically appended if omitted. Using this command
626 # requires the bibtex tool to be installed. See also
627 # http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
628 # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this
629 # feature you need bibtex and perl available in the search path. Do not use
630 # file names with spaces, bibtex cannot handle them.
631
632 CITE_BIB_FILES =
633
634 #---------------------------------------------------------------------------
635 # configuration options related to warning and progress messages
636 #---------------------------------------------------------------------------
637
638 # The QUIET tag can be used to turn on/off the messages that are generated
639 # by doxygen. Possible values are YES and NO. If left blank NO is used.
640
641 QUIET = NO
642
643 # The WARNINGS tag can be used to turn on/off the warning messages that are
644 # generated by doxygen. Possible values are YES and NO. If left blank
645 # NO is used.
646
647 WARNINGS = YES
648
649 # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
650 # for undocumented members. If EXTRACT_ALL is set to YES then this flag will
651 # automatically be disabled.
652
653 WARN_IF_UNDOCUMENTED = YES
654
655 # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
656 # potential errors in the documentation, such as not documenting some
657 # parameters in a documented function, or documenting parameters that
658 # don't exist or using markup commands wrongly.
659
660 WARN_IF_DOC_ERROR = YES
661
662 # The WARN_NO_PARAMDOC option can be enabled to get warnings for
663 # functions that are documented, but have no documentation for their parameters
664 # or return value. If set to NO (the default) doxygen will only warn about
665 # wrong or incomplete parameter documentation, but not about the absence of
666 # documentation.
667
668 WARN_NO_PARAMDOC = NO
669
670 # The WARN_FORMAT tag determines the format of the warning messages that
671 # doxygen can produce. The string should contain the $file, $line, and $text
672 # tags, which will be replaced by the file and line number from which the
673 # warning originated and the warning text. Optionally the format may contain
674 # $version, which will be replaced by the version of the file (if it could
675 # be obtained via FILE_VERSION_FILTER)
676
677 WARN_FORMAT = "$file:$line: $text"
678
679 # The WARN_LOGFILE tag can be used to specify a file to which warning
680 # and error messages should be written. If left blank the output is written
681 # to stderr.
682
683 WARN_LOGFILE =
684
685 #---------------------------------------------------------------------------
686 # configuration options related to the input files
687 #---------------------------------------------------------------------------
688
689 # The INPUT tag can be used to specify the files and/or directories that contain
690 # documented source files. You may enter file names like "myfile.cpp" or
691 # directories like "/usr/src/myproject". Separate the files or directories
692 # with spaces.
693
694 INPUT = . \
695 getdns/ \
696 example/ \
697 test/ \
698 ../README.md
699
700 # This tag can be used to specify the character encoding of the source files
701 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
702 # also the default input encoding. Doxygen uses libiconv (or the iconv built
703 # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
704 # the list of possible encodings.
705
706 INPUT_ENCODING = UTF-8
707
708 # If the value of the INPUT tag contains directories, you can use the
709 # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
710 # and *.h) to filter out the source-files in the directories. If left
711 # blank the following patterns are tested:
712 # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
713 # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
714 # *.f90 *.f *.for *.vhd *.vhdl
715
716 FILE_PATTERNS =
717
718 # The RECURSIVE tag can be used to turn specify whether or not subdirectories
719 # should be searched for input files as well. Possible values are YES and NO.
720 # If left blank NO is used.
721
722 RECURSIVE = NO
723
724 # The EXCLUDE tag can be used to specify files and/or directories that should be
725 # excluded from the INPUT source files. This way you can easily exclude a
726 # subdirectory from a directory tree whose root is specified with the INPUT tag.
727 # Note that relative paths are relative to the directory from which doxygen is
728 # run.
729
730 EXCLUDE = config.h
731
732 # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
733 # directories that are symbolic links (a Unix file system feature) are excluded
734 # from the input.
735
736 EXCLUDE_SYMLINKS = NO
737
738 # If the value of the INPUT tag contains directories, you can use the
739 # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
740 # certain files from those directories. Note that the wildcards are matched
741 # against the file with absolute path, so to exclude all test directories
742 # for example use the pattern */test/*
743
744 EXCLUDE_PATTERNS =
745
746 # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
747 # (namespaces, classes, functions, etc.) that should be excluded from the
748 # output. The symbol name can be a fully qualified name, a word, or if the
749 # wildcard * is used, a substring. Examples: ANamespace, AClass,
750 # AClass::ANamespace, ANamespace::*Test
751
752 EXCLUDE_SYMBOLS =
753
754 # The EXAMPLE_PATH tag can be used to specify one or more files or
755 # directories that contain example code fragments that are included (see
756 # the \include command).
757
758 EXAMPLE_PATH = example/
759
760 # If the value of the EXAMPLE_PATH tag contains directories, you can use the
761 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
762 # and *.h) to filter out the source-files in the directories. If left
763 # blank all files are included.
764
765 EXAMPLE_PATTERNS =
766
767 # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
768 # searched for input files to be used with the \include or \dontinclude
769 # commands irrespective of the value of the RECURSIVE tag.
770 # Possible values are YES and NO. If left blank NO is used.
771
772 EXAMPLE_RECURSIVE = NO
773
774 # The IMAGE_PATH tag can be used to specify one or more files or
775 # directories that contain image that are included in the documentation (see
776 # the \image command).
777
778 IMAGE_PATH =
779
780 # The INPUT_FILTER tag can be used to specify a program that doxygen should
781 # invoke to filter for each input file. Doxygen will invoke the filter program
782 # by executing (via popen()) the command <filter> <input-file>, where <filter>
783 # is the value of the INPUT_FILTER tag, and <input-file> is the name of an
784 # input file. Doxygen will then use the output that the filter program writes
785 # to standard output.
786 # If FILTER_PATTERNS is specified, this tag will be
787 # ignored.
788
789 INPUT_FILTER =
790
791 # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
792 # basis.
793 # Doxygen will compare the file name with each pattern and apply the
794 # filter if there is a match.
795 # The filters are a list of the form:
796 # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
797 # info on how filters are used. If FILTER_PATTERNS is empty or if
798 # non of the patterns match the file name, INPUT_FILTER is applied.
799
800 FILTER_PATTERNS =
801
802 # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
803 # INPUT_FILTER) will be used to filter the input files when producing source
804 # files to browse (i.e. when SOURCE_BROWSER is set to YES).
805
806 FILTER_SOURCE_FILES = NO
807
808 # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
809 # pattern. A pattern will override the setting for FILTER_PATTERN (if any)
810 # and it is also possible to disable source filtering for a specific pattern
811 # using *.ext= (so without naming a filter). This option only has effect when
812 # FILTER_SOURCE_FILES is enabled.
813
814 FILTER_SOURCE_PATTERNS =
815
816 # If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that
817 # is part of the input, its contents will be placed on the main page (index.html).
818 # This can be useful if you have a project on for instance GitHub and want reuse
819 # the introduction page also for the doxygen output.
820
821 USE_MDFILE_AS_MAINPAGE = ../README.md
822
823 #---------------------------------------------------------------------------
824 # configuration options related to source browsing
825 #---------------------------------------------------------------------------
826
827 # If the SOURCE_BROWSER tag is set to YES then a list of source files will
828 # be generated. Documented entities will be cross-referenced with these sources.
829 # Note: To get rid of all source code in the generated output, make sure also
830 # VERBATIM_HEADERS is set to NO.
831
832 SOURCE_BROWSER = YES
833
834 # Setting the INLINE_SOURCES tag to YES will include the body
835 # of functions and classes directly in the documentation.
836
837 INLINE_SOURCES = NO
838
839 # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
840 # doxygen to hide any special comment blocks from generated source code
841 # fragments. Normal C, C++ and Fortran comments will always remain visible.
842
843 STRIP_CODE_COMMENTS = YES
844
845 # If the REFERENCED_BY_RELATION tag is set to YES
846 # then for each documented function all documented
847 # functions referencing it will be listed.
848
849 REFERENCED_BY_RELATION = NO
850
851 # If the REFERENCES_RELATION tag is set to YES
852 # then for each documented function all documented entities
853 # called/used by that function will be listed.
854
855 REFERENCES_RELATION = NO
856
857 # If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
858 # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
859 # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
860 # link to the source code.
861 # Otherwise they will link to the documentation.
862
863 REFERENCES_LINK_SOURCE = YES
864
865 # If the USE_HTAGS tag is set to YES then the references to source code
866 # will point to the HTML generated by the htags(1) tool instead of doxygen
867 # built-in source browser. The htags tool is part of GNU's global source
868 # tagging system (see http://www.gnu.org/software/global/global.html). You
869 # will need version 4.8.6 or higher.
870
871 USE_HTAGS = NO
872
873 # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
874 # will generate a verbatim copy of the header file for each class for
875 # which an include is specified. Set to NO to disable this.
876
877 VERBATIM_HEADERS = YES
878
879 #---------------------------------------------------------------------------
880 # configuration options related to the alphabetical class index
881 #---------------------------------------------------------------------------
882
883 # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
884 # of all compounds will be generated. Enable this if the project
885 # contains a lot of classes, structs, unions or interfaces.
886
887 ALPHABETICAL_INDEX = YES
888
889 # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
890 # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
891 # in which this list will be split (can be a number in the range [1..20])
892
893 COLS_IN_ALPHA_INDEX = 5
894
895 # In case all classes in a project start with a common prefix, all
896 # classes will be put under the same header in the alphabetical index.
897 # The IGNORE_PREFIX tag can be used to specify one or more prefixes that
898 # should be ignored while generating the index headers.
899
900 IGNORE_PREFIX =
901
902 #---------------------------------------------------------------------------
903 # configuration options related to the HTML output
904 #---------------------------------------------------------------------------
905
906 # If the GENERATE_HTML tag is set to YES (the default) Doxygen will
907 # generate HTML output.
908
909 GENERATE_HTML = YES
910
911 # The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
912 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
913 # put in front of it. If left blank `html' will be used as the default path.
914
915 HTML_OUTPUT = html
916
917 # The HTML_FILE_EXTENSION tag can be used to specify the file extension for
918 # each generated HTML page (for example: .htm,.php,.asp). If it is left blank
919 # doxygen will generate files with .html extension.
920
921 HTML_FILE_EXTENSION = .html
922
923 # The HTML_HEADER tag can be used to specify a personal HTML header for
924 # each generated HTML page. If it is left blank doxygen will generate a
925 # standard header. Note that when using a custom header you are responsible
926 # for the proper inclusion of any scripts and style sheets that doxygen
927 # needs, which is dependent on the configuration options used.
928 # It is advised to generate a default header using "doxygen -w html
929 # header.html footer.html stylesheet.css YourConfigFile" and then modify
930 # that header. Note that the header is subject to change so you typically
931 # have to redo this when upgrading to a newer version of doxygen or when
932 # changing the value of configuration settings such as GENERATE_TREEVIEW!
933
934 HTML_HEADER =
935
936 # The HTML_FOOTER tag can be used to specify a personal HTML footer for
937 # each generated HTML page. If it is left blank doxygen will generate a
938 # standard footer.
939
940 HTML_FOOTER =
941
942 # The HTML_STYLESHEET tag can be used to specify a user-defined cascading
943 # style sheet that is used by each HTML page. It can be used to
944 # fine-tune the look of the HTML output. If left blank doxygen will
945 # generate a default style sheet. Note that it is recommended to use
946 # HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this
947 # tag will in the future become obsolete.
948
949 HTML_STYLESHEET =
950
951 # The HTML_EXTRA_STYLESHEET tag can be used to specify an additional
952 # user-defined cascading style sheet that is included after the standard
953 # style sheets created by doxygen. Using this option one can overrule
954 # certain style aspects. This is preferred over using HTML_STYLESHEET
955 # since it does not replace the standard style sheet and is therefor more
956 # robust against future updates. Doxygen will copy the style sheet file to
957 # the output directory.
958
959 HTML_EXTRA_STYLESHEET =
960
961 # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
962 # other source files which should be copied to the HTML output directory. Note
963 # that these files will be copied to the base HTML output directory. Use the
964 # $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
965 # files. In the HTML_STYLESHEET file, use the file name only. Also note that
966 # the files will be copied as-is; there are no commands or markers available.
967
968 HTML_EXTRA_FILES =
969
970 # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
971 # Doxygen will adjust the colors in the style sheet and background images
972 # according to this color. Hue is specified as an angle on a colorwheel,
973 # see http://en.wikipedia.org/wiki/Hue for more information.
974 # For instance the value 0 represents red, 60 is yellow, 120 is green,
975 # 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
976 # The allowed range is 0 to 359.
977
978 HTML_COLORSTYLE_HUE = 220
979
980 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
981 # the colors in the HTML output. For a value of 0 the output will use
982 # grayscales only. A value of 255 will produce the most vivid colors.
983
984 HTML_COLORSTYLE_SAT = 100
985
986 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
987 # the luminance component of the colors in the HTML output. Values below
988 # 100 gradually make the output lighter, whereas values above 100 make
989 # the output darker. The value divided by 100 is the actual gamma applied,
990 # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
991 # and 100 does not change the gamma.
992
993 HTML_COLORSTYLE_GAMMA = 80
994
995 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
996 # page will contain the date and time when the page was generated. Setting
997 # this to NO can help when comparing the output of multiple runs.
998
999 HTML_TIMESTAMP = YES
1000
1001 # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
1002 # documentation will contain sections that can be hidden and shown after the
1003 # page has loaded.
1004
1005 HTML_DYNAMIC_SECTIONS = NO
1006
1007 # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of
1008 # entries shown in the various tree structured indices initially; the user
1009 # can expand and collapse entries dynamically later on. Doxygen will expand
1010 # the tree to such a level that at most the specified number of entries are
1011 # visible (unless a fully collapsed tree already exceeds this amount).
1012 # So setting the number of entries 1 will produce a full collapsed tree by
1013 # default. 0 is a special value representing an infinite number of entries
1014 # and will result in a full expanded tree by default.
1015
1016 HTML_INDEX_NUM_ENTRIES = 100
1017
1018 # If the GENERATE_DOCSET tag is set to YES, additional index files
1019 # will be generated that can be used as input for Apple's Xcode 3
1020 # integrated development environment, introduced with OSX 10.5 (Leopard).
1021 # To create a documentation set, doxygen will generate a Makefile in the
1022 # HTML output directory. Running make will produce the docset in that
1023 # directory and running "make install" will install the docset in
1024 # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
1025 # it at startup.
1026 # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
1027 # for more information.
1028
1029 GENERATE_DOCSET = NO
1030
1031 # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
1032 # feed. A documentation feed provides an umbrella under which multiple
1033 # documentation sets from a single provider (such as a company or product suite)
1034 # can be grouped.
1035
1036 DOCSET_FEEDNAME = "Doxygen generated docs"
1037
1038 # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
1039 # should uniquely identify the documentation set bundle. This should be a
1040 # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
1041 # will append .docset to the name.
1042
1043 DOCSET_BUNDLE_ID = org.doxygen.Project
1044
1045 # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely
1046 # identify the documentation publisher. This should be a reverse domain-name
1047 # style string, e.g. com.mycompany.MyDocSet.documentation.
1048
1049 DOCSET_PUBLISHER_ID = org.doxygen.Publisher
1050
1051 # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
1052
1053 DOCSET_PUBLISHER_NAME = Publisher
1054
1055 # If the GENERATE_HTMLHELP tag is set to YES, additional index files
1056 # will be generated that can be used as input for tools like the
1057 # Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
1058 # of the generated HTML documentation.
1059
1060 GENERATE_HTMLHELP = NO
1061
1062 # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
1063 # be used to specify the file name of the resulting .chm file. You
1064 # can add a path in front of the file if the result should not be
1065 # written to the html output directory.
1066
1067 CHM_FILE =
1068
1069 # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
1070 # be used to specify the location (absolute path including file name) of
1071 # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
1072 # the HTML help compiler on the generated index.hhp.
1073
1074 HHC_LOCATION =
1075
1076 # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
1077 # controls if a separate .chi index file is generated (YES) or that
1078 # it should be included in the master .chm file (NO).
1079
1080 GENERATE_CHI = NO
1081
1082 # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
1083 # is used to encode HtmlHelp index (hhk), content (hhc) and project file
1084 # content.
1085
1086 CHM_INDEX_ENCODING =
1087
1088 # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
1089 # controls whether a binary table of contents is generated (YES) or a
1090 # normal table of contents (NO) in the .chm file.
1091
1092 BINARY_TOC = NO
1093
1094 # The TOC_EXPAND flag can be set to YES to add extra items for group members
1095 # to the contents of the HTML help documentation and to the tree view.
1096
1097 TOC_EXPAND = NO
1098
1099 # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
1100 # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
1101 # that can be used as input for Qt's qhelpgenerator to generate a
1102 # Qt Compressed Help (.qch) of the generated HTML documentation.
1103
1104 GENERATE_QHP = NO
1105
1106 # If the QHG_LOCATION tag is specified, the QCH_FILE tag can
1107 # be used to specify the file name of the resulting .qch file.
1108 # The path specified is relative to the HTML output folder.
1109
1110 QCH_FILE =
1111
1112 # The QHP_NAMESPACE tag specifies the namespace to use when generating
1113 # Qt Help Project output. For more information please see
1114 # http://doc.trolltech.com/qthelpproject.html#namespace
1115
1116 QHP_NAMESPACE = org.doxygen.Project
1117
1118 # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
1119 # Qt Help Project output. For more information please see
1120 # http://doc.trolltech.com/qthelpproject.html#virtual-folders
1121
1122 QHP_VIRTUAL_FOLDER = doc
1123
1124 # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
1125 # add. For more information please see
1126 # http://doc.trolltech.com/qthelpproject.html#custom-filters
1127
1128 QHP_CUST_FILTER_NAME =
1129
1130 # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
1131 # custom filter to add. For more information please see
1132 # <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">
1133 # Qt Help Project / Custom Filters</a>.
1134
1135 QHP_CUST_FILTER_ATTRS =
1136
1137 # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
1138 # project's
1139 # filter section matches.
1140 # <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">
1141 # Qt Help Project / Filter Attributes</a>.
1142
1143 QHP_SECT_FILTER_ATTRS =
1144
1145 # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
1146 # be used to specify the location of Qt's qhelpgenerator.
1147 # If non-empty doxygen will try to run qhelpgenerator on the generated
1148 # .qhp file.
1149
1150 QHG_LOCATION =
1151
1152 # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
1153 # will be generated, which together with the HTML files, form an Eclipse help
1154 # plugin. To install this plugin and make it available under the help contents
1155 # menu in Eclipse, the contents of the directory containing the HTML and XML
1156 # files needs to be copied into the plugins directory of eclipse. The name of
1157 # the directory within the plugins directory should be the same as
1158 # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
1159 # the help appears.
1160
1161 GENERATE_ECLIPSEHELP = NO
1162
1163 # A unique identifier for the eclipse help plugin. When installing the plugin
1164 # the directory name containing the HTML and XML files should also have
1165 # this name.
1166
1167 ECLIPSE_DOC_ID = org.doxygen.Project
1168
1169 # The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)
1170 # at top of each HTML page. The value NO (the default) enables the index and
1171 # the value YES disables it. Since the tabs have the same information as the
1172 # navigation tree you can set this option to NO if you already set
1173 # GENERATE_TREEVIEW to YES.
1174
1175 DISABLE_INDEX = NO
1176
1177 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
1178 # structure should be generated to display hierarchical information.
1179 # If the tag value is set to YES, a side panel will be generated
1180 # containing a tree-like index structure (just like the one that
1181 # is generated for HTML Help). For this to work a browser that supports
1182 # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
1183 # Windows users are probably better off using the HTML help feature.
1184 # Since the tree basically has the same information as the tab index you
1185 # could consider to set DISABLE_INDEX to NO when enabling this option.
1186
1187 GENERATE_TREEVIEW = NO
1188
1189 # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
1190 # (range [0,1..20]) that doxygen will group on one line in the generated HTML
1191 # documentation. Note that a value of 0 will completely suppress the enum
1192 # values from appearing in the overview section.
1193
1194 ENUM_VALUES_PER_LINE = 4
1195
1196 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
1197 # used to set the initial width (in pixels) of the frame in which the tree
1198 # is shown.
1199
1200 TREEVIEW_WIDTH = 250
1201
1202 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
1203 # links to external symbols imported via tag files in a separate window.
1204
1205 EXT_LINKS_IN_WINDOW = NO
1206
1207 # Use this tag to change the font size of Latex formulas included
1208 # as images in the HTML documentation. The default is 10. Note that
1209 # when you change the font size after a successful doxygen run you need
1210 # to manually remove any form_*.png images from the HTML output directory
1211 # to force them to be regenerated.
1212
1213 FORMULA_FONTSIZE = 10
1214
1215 # Use the FORMULA_TRANPARENT tag to determine whether or not the images
1216 # generated for formulas are transparent PNGs. Transparent PNGs are
1217 # not supported properly for IE 6.0, but are supported on all modern browsers.
1218 # Note that when changing this option you need to delete any form_*.png files
1219 # in the HTML output before the changes have effect.
1220
1221 FORMULA_TRANSPARENT = YES
1222
1223 # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
1224 # (see http://www.mathjax.org) which uses client side Javascript for the
1225 # rendering instead of using prerendered bitmaps. Use this if you do not
1226 # have LaTeX installed or if you want to formulas look prettier in the HTML
1227 # output. When enabled you may also need to install MathJax separately and
1228 # configure the path to it using the MATHJAX_RELPATH option.
1229
1230 USE_MATHJAX = NO
1231
1232 # When MathJax is enabled you can set the default output format to be used for
1233 # thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and
1234 # SVG. The default value is HTML-CSS, which is slower, but has the best
1235 # compatibility.
1236
1237 MATHJAX_FORMAT = HTML-CSS
1238
1239 # When MathJax is enabled you need to specify the location relative to the
1240 # HTML output directory using the MATHJAX_RELPATH option. The destination
1241 # directory should contain the MathJax.js script. For instance, if the mathjax
1242 # directory is located at the same level as the HTML output directory, then
1243 # MATHJAX_RELPATH should be ../mathjax. The default value points to
1244 # the MathJax Content Delivery Network so you can quickly see the result without
1245 # installing MathJax.
1246 # However, it is strongly recommended to install a local
1247 # copy of MathJax from http://www.mathjax.org before deployment.
1248
1249 MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
1250
1251 # The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension
1252 # names that should be enabled during MathJax rendering.
1253
1254 MATHJAX_EXTENSIONS =
1255
1256 # When the SEARCHENGINE tag is enabled doxygen will generate a search box
1257 # for the HTML output. The underlying search engine uses javascript
1258 # and DHTML and should work on any modern browser. Note that when using
1259 # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
1260 # (GENERATE_DOCSET) there is already a search function so this one should
1261 # typically be disabled. For large projects the javascript based search engine
1262 # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
1263
1264 SEARCHENGINE = YES
1265
1266 # When the SERVER_BASED_SEARCH tag is enabled the search engine will be
1267 # implemented using a web server instead of a web client using Javascript.
1268 # There are two flavours of web server based search depending on the
1269 # EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for
1270 # searching and an index file used by the script. When EXTERNAL_SEARCH is
1271 # enabled the indexing and searching needs to be provided by external tools.
1272 # See the manual for details.
1273
1274 SERVER_BASED_SEARCH = NO
1275
1276 # When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP
1277 # script for searching. Instead the search results are written to an XML file
1278 # which needs to be processed by an external indexer. Doxygen will invoke an
1279 # external search engine pointed to by the SEARCHENGINE_URL option to obtain
1280 # the search results. Doxygen ships with an example indexer (doxyindexer) and
1281 # search engine (doxysearch.cgi) which are based on the open source search engine
1282 # library Xapian. See the manual for configuration details.
1283
1284 EXTERNAL_SEARCH = NO
1285
1286 # The SEARCHENGINE_URL should point to a search engine hosted by a web server
1287 # which will returned the search results when EXTERNAL_SEARCH is enabled.
1288 # Doxygen ships with an example search engine (doxysearch) which is based on
1289 # the open source search engine library Xapian. See the manual for configuration
1290 # details.
1291
1292 SEARCHENGINE_URL =
1293
1294 # When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
1295 # search data is written to a file for indexing by an external tool. With the
1296 # SEARCHDATA_FILE tag the name of this file can be specified.
1297
1298 SEARCHDATA_FILE = searchdata.xml
1299
1300 # When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the
1301 # EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
1302 # useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
1303 # projects and redirect the results back to the right project.
1304
1305 EXTERNAL_SEARCH_ID =
1306
1307 # The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
1308 # projects other than the one defined by this configuration file, but that are
1309 # all added to the same external search index. Each project needs to have a
1310 # unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id
1311 # of to a relative location where the documentation can be found.
1312 # The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ...
1313
1314 EXTRA_SEARCH_MAPPINGS =
1315
1316 #---------------------------------------------------------------------------
1317 # configuration options related to the LaTeX output
1318 #---------------------------------------------------------------------------
1319
1320 # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
1321 # generate Latex output.
1322
1323 GENERATE_LATEX = YES
1324
1325 # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
1326 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
1327 # put in front of it. If left blank `latex' will be used as the default path.
1328
1329 LATEX_OUTPUT = latex
1330
1331 # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
1332 # invoked. If left blank `latex' will be used as the default command name.
1333 # Note that when enabling USE_PDFLATEX this option is only used for
1334 # generating bitmaps for formulas in the HTML output, but not in the
1335 # Makefile that is written to the output directory.
1336
1337 LATEX_CMD_NAME = latex
1338
1339 # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
1340 # generate index for LaTeX. If left blank `makeindex' will be used as the
1341 # default command name.
1342
1343 MAKEINDEX_CMD_NAME = makeindex
1344
1345 # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
1346 # LaTeX documents. This may be useful for small projects and may help to
1347 # save some trees in general.
1348
1349 COMPACT_LATEX = NO
1350
1351 # The PAPER_TYPE tag can be used to set the paper type that is used
1352 # by the printer. Possible values are: a4, letter, legal and
1353 # executive. If left blank a4wide will be used.
1354
1355 PAPER_TYPE = a4
1356
1357 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
1358 # packages that should be included in the LaTeX output.
1359
1360 EXTRA_PACKAGES =
1361
1362 # The LATEX_HEADER tag can be used to specify a personal LaTeX header for
1363 # the generated latex document. The header should contain everything until
1364 # the first chapter. If it is left blank doxygen will generate a
1365 # standard header. Notice: only use this tag if you know what you are doing!
1366
1367 LATEX_HEADER =
1368
1369 # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
1370 # the generated latex document. The footer should contain everything after
1371 # the last chapter. If it is left blank doxygen will generate a
1372 # standard footer. Notice: only use this tag if you know what you are doing!
1373
1374 LATEX_FOOTER =
1375
1376 # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
1377 # is prepared for conversion to pdf (using ps2pdf). The pdf file will
1378 # contain links (just like the HTML output) instead of page references
1379 # This makes the output suitable for online browsing using a pdf viewer.
1380
1381 PDF_HYPERLINKS = YES
1382
1383 # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
1384 # plain latex in the generated Makefile. Set this option to YES to get a
1385 # higher quality PDF documentation.
1386
1387 USE_PDFLATEX = YES
1388
1389 # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
1390 # command to the generated LaTeX files. This will instruct LaTeX to keep
1391 # running if errors occur, instead of asking the user for help.
1392 # This option is also used when generating formulas in HTML.
1393
1394 LATEX_BATCHMODE = NO
1395
1396 # If LATEX_HIDE_INDICES is set to YES then doxygen will not
1397 # include the index chapters (such as File Index, Compound Index, etc.)
1398 # in the output.
1399
1400 LATEX_HIDE_INDICES = NO
1401
1402 # If LATEX_SOURCE_CODE is set to YES then doxygen will include
1403 # source code with syntax highlighting in the LaTeX output.
1404 # Note that which sources are shown also depends on other settings
1405 # such as SOURCE_BROWSER.
1406
1407 LATEX_SOURCE_CODE = NO
1408
1409 # The LATEX_BIB_STYLE tag can be used to specify the style to use for the
1410 # bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
1411 # http://en.wikipedia.org/wiki/BibTeX for more info.
1412
1413 LATEX_BIB_STYLE = plain
1414
1415 #---------------------------------------------------------------------------
1416 # configuration options related to the RTF output
1417 #---------------------------------------------------------------------------
1418
1419 # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
1420 # The RTF output is optimized for Word 97 and may not look very pretty with
1421 # other RTF readers or editors.
1422
1423 GENERATE_RTF = NO
1424
1425 # The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
1426 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
1427 # put in front of it. If left blank `rtf' will be used as the default path.
1428
1429 RTF_OUTPUT = rtf
1430
1431 # If the COMPACT_RTF tag is set to YES Doxygen generates more compact
1432 # RTF documents. This may be useful for small projects and may help to
1433 # save some trees in general.
1434
1435 COMPACT_RTF = NO
1436
1437 # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
1438 # will contain hyperlink fields. The RTF file will
1439 # contain links (just like the HTML output) instead of page references.
1440 # This makes the output suitable for online browsing using WORD or other
1441 # programs which support those fields.
1442 # Note: wordpad (write) and others do not support links.
1443
1444 RTF_HYPERLINKS = NO
1445
1446 # Load style sheet definitions from file. Syntax is similar to doxygen's
1447 # config file, i.e. a series of assignments. You only have to provide
1448 # replacements, missing definitions are set to their default value.
1449
1450 RTF_STYLESHEET_FILE =
1451
1452 # Set optional variables used in the generation of an rtf document.
1453 # Syntax is similar to doxygen's config file.
1454
1455 RTF_EXTENSIONS_FILE =
1456
1457 #---------------------------------------------------------------------------
1458 # configuration options related to the man page output
1459 #---------------------------------------------------------------------------
1460
1461 # If the GENERATE_MAN tag is set to YES (the default) Doxygen will
1462 # generate man pages
1463
1464 GENERATE_MAN = YES
1465
1466 # The MAN_OUTPUT tag is used to specify where the man pages will be put.
1467 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
1468 # put in front of it. If left blank `man' will be used as the default path.
1469
1470 MAN_OUTPUT = man
1471
1472 # The MAN_EXTENSION tag determines the extension that is added to
1473 # the generated man pages (default is the subroutine's section .3)
1474
1475 MAN_EXTENSION = .3
1476
1477 # If the MAN_LINKS tag is set to YES and Doxygen generates man output,
1478 # then it will generate one additional man file for each entity
1479 # documented in the real man page(s). These additional files
1480 # only source the real man page, but without them the man command
1481 # would be unable to find the correct page. The default is NO.
1482
1483 MAN_LINKS = NO
1484
1485 #---------------------------------------------------------------------------
1486 # configuration options related to the XML output
1487 #---------------------------------------------------------------------------
1488
1489 # If the GENERATE_XML tag is set to YES Doxygen will
1490 # generate an XML file that captures the structure of
1491 # the code including all documentation.
1492
1493 GENERATE_XML = NO
1494
1495 # The XML_OUTPUT tag is used to specify where the XML pages will be put.
1496 # If a relative path is entered the value of OUTPUT_DIRECTORY will be
1497 # put in front of it. If left blank `xml' will be used as the default path.
1498
1499 XML_OUTPUT = xml
1500
1501 # The XML_SCHEMA tag can be used to specify an XML schema,
1502 # which can be used by a validating XML parser to check the
1503 # syntax of the XML files.
1504
1505 XML_SCHEMA =
1506
1507 # The XML_DTD tag can be used to specify an XML DTD,
1508 # which can be used by a validating XML parser to check the
1509 # syntax of the XML files.
1510
1511 XML_DTD =
1512
1513 # If the XML_PROGRAMLISTING tag is set to YES Doxygen will
1514 # dump the program listings (including syntax highlighting
1515 # and cross-referencing information) to the XML output. Note that
1516 # enabling this will significantly increase the size of the XML output.
1517
1518 XML_PROGRAMLISTING = YES
1519
1520 #---------------------------------------------------------------------------
1521 # configuration options for the AutoGen Definitions output
1522 #---------------------------------------------------------------------------
1523
1524 # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
1525 # generate an AutoGen Definitions (see autogen.sf.net) file
1526 # that captures the structure of the code including all
1527 # documentation. Note that this feature is still experimental
1528 # and incomplete at the moment.
1529
1530 GENERATE_AUTOGEN_DEF = NO
1531
1532 #---------------------------------------------------------------------------
1533 # configuration options related to the Perl module output
1534 #---------------------------------------------------------------------------
1535
1536 # If the GENERATE_PERLMOD tag is set to YES Doxygen will
1537 # generate a Perl module file that captures the structure of
1538 # the code including all documentation. Note that this
1539 # feature is still experimental and incomplete at the
1540 # moment.
1541
1542 GENERATE_PERLMOD = NO
1543
1544 # If the PERLMOD_LATEX tag is set to YES Doxygen will generate
1545 # the necessary Makefile rules, Perl scripts and LaTeX code to be able
1546 # to generate PDF and DVI output from the Perl module output.
1547
1548 PERLMOD_LATEX = NO
1549
1550 # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
1551 # nicely formatted so it can be parsed by a human reader.
1552 # This is useful
1553 # if you want to understand what is going on.
1554 # On the other hand, if this
1555 # tag is set to NO the size of the Perl module output will be much smaller
1556 # and Perl will parse it just the same.
1557
1558 PERLMOD_PRETTY = YES
1559
1560 # The names of the make variables in the generated doxyrules.make file
1561 # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
1562 # This is useful so different doxyrules.make files included by the same
1563 # Makefile don't overwrite each other's variables.
1564
1565 PERLMOD_MAKEVAR_PREFIX =
1566
1567 #---------------------------------------------------------------------------
1568 # Configuration options related to the preprocessor
1569 #---------------------------------------------------------------------------
1570
1571 # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
1572 # evaluate all C-preprocessor directives found in the sources and include
1573 # files.
1574
1575 ENABLE_PREPROCESSING = YES
1576
1577 # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
1578 # names in the source code. If set to NO (the default) only conditional
1579 # compilation will be performed. Macro expansion can be done in a controlled
1580 # way by setting EXPAND_ONLY_PREDEF to YES.
1581
1582 MACRO_EXPANSION = NO
1583
1584 # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
1585 # then the macro expansion is limited to the macros specified with the
1586 # PREDEFINED and EXPAND_AS_DEFINED tags.
1587
1588 EXPAND_ONLY_PREDEF = NO
1589
1590 # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
1591 # pointed to by INCLUDE_PATH will be searched when a #include is found.
1592
1593 SEARCH_INCLUDES = YES
1594
1595 # The INCLUDE_PATH tag can be used to specify one or more directories that
1596 # contain include files that are not input files but should be processed by
1597 # the preprocessor.
1598
1599 INCLUDE_PATH =
1600
1601 # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
1602 # patterns (like *.h and *.hpp) to filter out the header-files in the
1603 # directories. If left blank, the patterns specified with FILE_PATTERNS will
1604 # be used.
1605
1606 INCLUDE_FILE_PATTERNS =
1607
1608 # The PREDEFINED tag can be used to specify one or more macro names that
1609 # are defined before the preprocessor is started (similar to the -D option of
1610 # gcc). The argument of the tag is a list of macros of the form: name
1611 # or name=definition (no spaces). If the definition and the = are
1612 # omitted =1 is assumed. To prevent a macro definition from being
1613 # undefined via #undef or recursively expanded use the := operator
1614 # instead of the = operator.
1615
1616 PREDEFINED =
1617
1618 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
1619 # this tag can be used to specify a list of macro names that should be expanded.
1620 # The macro definition that is found in the sources will be used.
1621 # Use the PREDEFINED tag if you want to use a different macro definition that
1622 # overrules the definition found in the source code.
1623
1624 EXPAND_AS_DEFINED =
1625
1626 # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
1627 # doxygen's preprocessor will remove all references to function-like macros
1628 # that are alone on a line, have an all uppercase name, and do not end with a
1629 # semicolon, because these will confuse the parser if not removed.
1630
1631 SKIP_FUNCTION_MACROS = YES
1632
1633 #---------------------------------------------------------------------------
1634 # Configuration::additions related to external references
1635 #---------------------------------------------------------------------------
1636
1637 # The TAGFILES option can be used to specify one or more tagfiles. For each
1638 # tag file the location of the external documentation should be added. The
1639 # format of a tag file without this location is as follows:
1640 #
1641 # TAGFILES = file1 file2 ...
1642 # Adding location for the tag files is done as follows:
1643 #
1644 # TAGFILES = file1=loc1 "file2 = loc2" ...
1645 # where "loc1" and "loc2" can be relative or absolute paths
1646 # or URLs. Note that each tag file must have a unique name (where the name does
1647 # NOT include the path). If a tag file is not located in the directory in which
1648 # doxygen is run, you must also specify the path to the tagfile here.
1649
1650 TAGFILES =
1651
1652 # When a file name is specified after GENERATE_TAGFILE, doxygen will create
1653 # a tag file that is based on the input files it reads.
1654
1655 GENERATE_TAGFILE =
1656
1657 # If the ALLEXTERNALS tag is set to YES all external classes will be listed
1658 # in the class index. If set to NO only the inherited external classes
1659 # will be listed.
1660
1661 ALLEXTERNALS = NO
1662
1663 # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
1664 # in the modules index. If set to NO, only the current project's groups will
1665 # be listed.
1666
1667 EXTERNAL_GROUPS = YES
1668
1669 # The PERL_PATH should be the absolute path and name of the perl script
1670 # interpreter (i.e. the result of `which perl').
1671
1672 PERL_PATH = /usr/bin/perl
1673
1674 #---------------------------------------------------------------------------
1675 # Configuration options related to the dot tool
1676 #---------------------------------------------------------------------------
1677
1678 # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
1679 # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
1680 # or super classes. Setting the tag to NO turns the diagrams off. Note that
1681 # this option also works with HAVE_DOT disabled, but it is recommended to
1682 # install and use dot, since it yields more powerful graphs.
1683
1684 CLASS_DIAGRAMS = YES
1685
1686 # You can define message sequence charts within doxygen comments using the \msc
1687 # command. Doxygen will then run the mscgen tool (see
1688 # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
1689 # documentation. The MSCGEN_PATH tag allows you to specify the directory where
1690 # the mscgen tool resides. If left empty the tool is assumed to be found in the
1691 # default search path.
1692
1693 MSCGEN_PATH =
1694
1695 # If set to YES, the inheritance and collaboration graphs will hide
1696 # inheritance and usage relations if the target is undocumented
1697 # or is not a class.
1698
1699 HIDE_UNDOC_RELATIONS = YES
1700
1701 # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
1702 # available from the path. This tool is part of Graphviz, a graph visualization
1703 # toolkit from AT&T and Lucent Bell Labs. The other options in this section
1704 # have no effect if this option is set to NO (the default)
1705
1706 HAVE_DOT = NO
1707
1708 # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
1709 # allowed to run in parallel. When set to 0 (the default) doxygen will
1710 # base this on the number of processors available in the system. You can set it
1711 # explicitly to a value larger than 0 to get control over the balance
1712 # between CPU load and processing speed.
1713
1714 DOT_NUM_THREADS = 0
1715
1716 # By default doxygen will use the Helvetica font for all dot files that
1717 # doxygen generates. When you want a differently looking font you can specify
1718 # the font name using DOT_FONTNAME. You need to make sure dot is able to find
1719 # the font, which can be done by putting it in a standard location or by setting
1720 # the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
1721 # directory containing the font.
1722
1723 DOT_FONTNAME = Helvetica
1724
1725 # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
1726 # The default size is 10pt.
1727
1728 DOT_FONTSIZE = 10
1729
1730 # By default doxygen will tell dot to use the Helvetica font.
1731 # If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to
1732 # set the path where dot can find it.
1733
1734 DOT_FONTPATH =
1735
1736 # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
1737 # will generate a graph for each documented class showing the direct and
1738 # indirect inheritance relations. Setting this tag to YES will force the
1739 # CLASS_DIAGRAMS tag to NO.
1740
1741 CLASS_GRAPH = YES
1742
1743 # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
1744 # will generate a graph for each documented class showing the direct and
1745 # indirect implementation dependencies (inheritance, containment, and
1746 # class references variables) of the class with other documented classes.
1747
1748 COLLABORATION_GRAPH = YES
1749
1750 # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
1751 # will generate a graph for groups, showing the direct groups dependencies
1752
1753 GROUP_GRAPHS = YES
1754
1755 # If the UML_LOOK tag is set to YES doxygen will generate inheritance and
1756 # collaboration diagrams in a style similar to the OMG's Unified Modeling
1757 # Language.
1758
1759 UML_LOOK = NO
1760
1761 # If the UML_LOOK tag is enabled, the fields and methods are shown inside
1762 # the class node. If there are many fields or methods and many nodes the
1763 # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
1764 # threshold limits the number of items for each type to make the size more
1765 # managable. Set this to 0 for no limit. Note that the threshold may be
1766 # exceeded by 50% before the limit is enforced.
1767
1768 UML_LIMIT_NUM_FIELDS = 10
1769
1770 # If set to YES, the inheritance and collaboration graphs will show the
1771 # relations between templates and their instances.
1772
1773 TEMPLATE_RELATIONS = NO
1774
1775 # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
1776 # tags are set to YES then doxygen will generate a graph for each documented
1777 # file showing the direct and indirect include dependencies of the file with
1778 # other documented files.
1779
1780 INCLUDE_GRAPH = YES
1781
1782 # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
1783 # HAVE_DOT tags are set to YES then doxygen will generate a graph for each
1784 # documented header file showing the documented files that directly or
1785 # indirectly include this file.
1786
1787 INCLUDED_BY_GRAPH = YES
1788
1789 # If the CALL_GRAPH and HAVE_DOT options are set to YES then
1790 # doxygen will generate a call dependency graph for every global function
1791 # or class method. Note that enabling this option will significantly increase
1792 # the time of a run. So in most cases it will be better to enable call graphs
1793 # for selected functions only using the \callgraph command.
1794
1795 CALL_GRAPH = NO
1796
1797 # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
1798 # doxygen will generate a caller dependency graph for every global function
1799 # or class method. Note that enabling this option will significantly increase
1800 # the time of a run. So in most cases it will be better to enable caller
1801 # graphs for selected functions only using the \callergraph command.
1802
1803 CALLER_GRAPH = NO
1804
1805 # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
1806 # will generate a graphical hierarchy of all classes instead of a textual one.
1807
1808 GRAPHICAL_HIERARCHY = YES
1809
1810 # If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES
1811 # then doxygen will show the dependencies a directory has on other directories
1812 # in a graphical way. The dependency relations are determined by the #include
1813 # relations between the files in the directories.
1814
1815 DIRECTORY_GRAPH = YES
1816
1817 # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
1818 # generated by dot. Possible values are svg, png, jpg, or gif.
1819 # If left blank png will be used. If you choose svg you need to set
1820 # HTML_FILE_EXTENSION to xhtml in order to make the SVG files
1821 # visible in IE 9+ (other browsers do not have this requirement).
1822
1823 DOT_IMAGE_FORMAT = png
1824
1825 # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
1826 # enable generation of interactive SVG images that allow zooming and panning.
1827 # Note that this requires a modern browser other than Internet Explorer.
1828 # Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you
1829 # need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files
1830 # visible. Older versions of IE do not have SVG support.
1831
1832 INTERACTIVE_SVG = NO
1833
1834 # The tag DOT_PATH can be used to specify the path where the dot tool can be
1835 # found. If left blank, it is assumed the dot tool can be found in the path.
1836
1837 DOT_PATH =
1838
1839 # The DOTFILE_DIRS tag can be used to specify one or more directories that
1840 # contain dot files that are included in the documentation (see the
1841 # \dotfile command).
1842
1843 DOTFILE_DIRS =
1844
1845 # The MSCFILE_DIRS tag can be used to specify one or more directories that
1846 # contain msc files that are included in the documentation (see the
1847 # \mscfile command).
1848
1849 MSCFILE_DIRS =
1850
1851 # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
1852 # nodes that will be shown in the graph. If the number of nodes in a graph
1853 # becomes larger than this value, doxygen will truncate the graph, which is
1854 # visualized by representing a node as a red box. Note that doxygen if the
1855 # number of direct children of the root node in a graph is already larger than
1856 # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
1857 # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
1858
1859 DOT_GRAPH_MAX_NODES = 50
1860
1861 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
1862 # graphs generated by dot. A depth value of 3 means that only nodes reachable
1863 # from the root by following a path via at most 3 edges will be shown. Nodes
1864 # that lay further from the root node will be omitted. Note that setting this
1865 # option to 1 or 2 may greatly reduce the computation time needed for large
1866 # code bases. Also note that the size of a graph can be further restricted by
1867 # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
1868
1869 MAX_DOT_GRAPH_DEPTH = 0
1870
1871 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
1872 # background. This is disabled by default, because dot on Windows does not
1873 # seem to support this out of the box. Warning: Depending on the platform used,
1874 # enabling this option may lead to badly anti-aliased labels on the edges of
1875 # a graph (i.e. they become hard to read).
1876
1877 DOT_TRANSPARENT = NO
1878
1879 # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
1880 # files in one run (i.e. multiple -o and -T options on the command line). This
1881 # makes dot run faster, but since only newer versions of dot (>1.8.10)
1882 # support this, this feature is disabled by default.
1883
1884 DOT_MULTI_TARGETS = NO
1885
1886 # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
1887 # generate a legend page explaining the meaning of the various boxes and
1888 # arrows in the dot generated graphs.
1889
1890 GENERATE_LEGEND = YES
1891
1892 # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
1893 # remove the intermediate dot files that are used to generate
1894 # the various graphs.
1895
1896 DOT_CLEANUP = YES
0 #
1 # @configure_input@
2 #
3 # Copyright (c) 2013, Verisign, Inc., NLnet Labs
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 are met:
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # * Neither the names of the copyright holders nor the
14 # names of its contributors may be used to endorse or promote products
15 # derived from this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
21 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 package = @PACKAGE_NAME@
29 version = @PACKAGE_VERSION@
30 tarname = @PACKAGE_TARNAME@
31 distdir = $(tarname)-$(version)
32
33 # current:revision:age
34 # (binary-api-number):(which-binary-api-version):(how-many-nrs-backwardscompat)
35 # if api unchanged: no changes
36 # if api broken: current++ ; revision = 0; age = 0
37 # if programs compiled against existing library work and link with new
38 # version of library with new binary api: revision++; age++
39 libversion = 0:0:0
40
41 prefix = @prefix@
42 exec_prefix = @exec_prefix@
43 bindir = @bindir@
44 libdir = @libdir@
45 includedir = @includedir@
46 have_libevent = @have_libevent@
47 have_libuv = @have_libuv@
48 have_libev = @have_libev@
49 # datarootdir is here to please some checkers
50 datarootdir=@datarootdir@
51 INSTALL = @INSTALL@
52 LIBTOOL = ../libtool
53
54 srcdir = @srcdir@
55 VPATH = @srcdir@
56
57 CC=@CC@
58 CFLAGS=@CFLAGS@ -Wall -I$(srcdir)/ -I/usr/local/include -std=c99
59 LDFLAGS=@LDFLAGS@ @LIBS@
60
61 EXTENSION_LDFLAGS=@EXTENSION_LDFLAGS@
62 EXTENSION_LIBEVENT_LIB=@EXTENSION_LIBEVENT_LIB@
63 EXTENSION_LIBEVENT_EXT_LIBS=@EXTENSION_LIBEVENT_EXT_LIBS@
64 EXTENSION_LIBUV_LIB=@EXTENSION_LIBUV_LIB@
65 EXTENSION_LIBUV_EXT_LIBS=@EXTENSION_LIBUV_EXT_LIBS@
66 EXTENSION_LIBEV_LIB=@EXTENSION_LIBEV_LIB@
67 EXTENSION_LIBEV_EXT_LIBS=@EXTENSION_LIBEV_EXT_LIBS@
68
69 GETDNS_OBJ=sync.lo context.lo list.lo dict.lo convert.lo general.lo \
70 hostname.lo service.lo request-internal.lo util-internal.lo \
71 getdns_error.lo rr-dict.lo dnssec.lo const-info.lo
72
73 .SUFFIXES: .c .o .a .lo .h
74
75 .c.o:
76 $(CC) $(CFLAGS) -c $< -o $@
77
78 .c.lo:
79 $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $< -o $@
80
81 default: all
82
83 all: libgetdns.la $(EXTENSION_LIBEVENT_LIB) $(EXTENSION_LIBUV_LIB) $(EXTENSION_LIBEV_LIB)
84
85 install: libgetdns.la
86 $(INSTALL) -m 755 -d $(DESTDIR)$(includedir)
87 $(INSTALL) -m 755 -d $(DESTDIR)$(includedir)/getdns
88 $(INSTALL) -m 644 $(srcdir)/getdns/getdns.h $(DESTDIR)$(includedir)/getdns/getdns.h
89 $(INSTALL) -m 644 $(srcdir)/getdns/getdns.h $(DESTDIR)$(includedir)/getdns/getdns_extra.h
90 $(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
91 $(LIBTOOL) --mode=install cp libgetdns.la $(DESTDIR)$(libdir)
92 if test $(have_libevent) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libevent.h $(DESTDIR)$(includedir)/getdns/ ; $(LIBTOOL) --mode=install cp $(EXTENSION_LIBEVENT_LIB) $(DESTDIR)$(libdir) ; fi
93 if test $(have_libuv) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libuv.h $(DESTDIR)$(includedir)/getdns/ ; $(LIBTOOL) --mode=install cp $(EXTENSION_LIBUV_LIB) $(DESTDIR)$(libdir) ; fi
94 if test $(have_libev) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libev.h $(DESTDIR)$(includedir)/getdns/ ; $(LIBTOOL) --mode=install cp $(EXTENSION_LIBEV_LIB) $(DESTDIR)$(libdir) ; fi
95
96 $(LIBTOOL) --mode=finish $(DESTDIR)$(libdir)
97
98 uninstall:
99 rm -rf $(DESTDIR)$(includedir)/getdns
100 $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libgetdns.la $(DESTDIR)$(libdir)/$(EXTENSION_LIBEVENT_LIB) $(DESTDIR)$(libdir)/$(EXTENSION_LIBUV_LIB) $(DESTDIR)$(libdir)/$(EXTENSION_LIBEV_LIB)
101
102 libgetdns_ext_event.la: libgetdns.la extension/libevent.lo
103 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ extension/libevent.lo ./.libs/libgetdns.la $(EXTENSION_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -release $(version)
104
105 libgetdns_ext_uv.la: libgetdns.la extension/libuv.lo
106 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ extension/libuv.lo ./.libs/libgetdns.la $(EXTENSION_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -release $(version)
107
108 libgetdns_ext_ev.la: libgetdns.la extension/libev.lo
109 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ extension/libev.lo ./.libs/libgetdns.la $(EXTENSION_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -release $(version)
110
111 libgetdns.la: $(GETDNS_OBJ)
112 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ $(GETDNS_OBJ) $(LDFLAGS) -rpath $(libdir) -version-info $(libversion) -no-undefined -release $(version)
113
114 test: FORCE
115 cd test && $(MAKE) $@
116
117 example: FORCE
118 cd example && $(MAKE) $@
119
120 clean:
121 cd test && $(MAKE) $@
122 cd example && $(MAKE) $@
123 rm -f *.o *.lo extension/*.lo $(PROGRAMS) libgetdns.la
124 rm -rf .libs
125
126 distclean : clean
127 cd test && $(MAKE) $@
128 cd example && $(MAKE) $@
129 rm -f Makefile config.status config.log Doxyfile
130 rm -Rf autom4te.cache
131
132 $(distdir): FORCE
133 mkdir -p $(distdir)/src
134 cp configure.ac $(distdir)
135 cp configure $(distdir)
136 cp Makefile.in $(distdir)
137 cp src/Makefile.in $(distdir)/src
138
139 distcheck: $(distdir).tar.gz
140 gzip -cd $(distdir).tar.gz | tar xvf -
141 cd $(distdir) && ./configure
142 cd $(distdir) && $(MAKE) all
143 cd $(distdir) && $(MAKE) check
144 cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst install
145 cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst uninstall
146 @remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \
147 if test "$${remaining}" -ne 0; then
148 echo "@@@ $${remaining} file(s) remaining in stage directory!"; \
149 exit 1; \
150 fi
151 cd $(distdir) && $(MAKE) clean
152 rm -rf $(distdir)
153 @echo "*** Package $(distdir).tar.gz is ready for distribution"
154
155 Makefile: Makefile.in ../config.status
156 cd .. && ./config.status $@
157
158 configure.status: configure
159 cd .. && ./config.status --recheck
160
161 .PHONY: clean test example
162 FORCE:
0 /* src/config.h. Generated from config.h.in by configure. */
1 /* src/config.h.in. Generated from configure.ac by autoheader. */
2
3 /* Define to 1 if you have the <dlfcn.h> header file. */
4 #define HAVE_DLFCN_H 1
5
6 /* Define to 1 if you have the <event2/event.h> header file. */
7 #define HAVE_EVENT2_EVENT_H 1
8
9 /* Define to 1 if you have the `event_base_free' function. */
10 #define HAVE_EVENT_BASE_FREE 1
11
12 /* Define to 1 if you have the `event_base_new' function. */
13 #define HAVE_EVENT_BASE_NEW 1
14
15 /* Define to 1 if you have the <event.h> header file. */
16 /* #undef HAVE_EVENT_H */
17
18 /* Define to 1 if you have the <ev.h> header file. */
19 /* #undef HAVE_EV_H */
20
21 /* Define to 1 if you have the <inttypes.h> header file. */
22 #define HAVE_INTTYPES_H 1
23
24 /* Define to 1 if you have the `idn' library (-lidn). */
25 #define HAVE_LIBIDN 1
26
27 /* Define to 1 if you have the `ldns' library (-lldns). */
28 #define HAVE_LIBLDNS 1
29
30 /* Define to 1 if you have the `unbound' library (-lunbound). */
31 #define HAVE_LIBUNBOUND 1
32
33 /* Define to 1 if you have the <memory.h> header file. */
34 #define HAVE_MEMORY_H 1
35
36 /* Define to 1 if you have the <netinet/in.h> header file. */
37 #define HAVE_NETINET_IN_H 1
38
39 /* Define to 1 if you have the <stdint.h> header file. */
40 #define HAVE_STDINT_H 1
41
42 /* Define to 1 if you have the <stdlib.h> header file. */
43 #define HAVE_STDLIB_H 1
44
45 /* Define to 1 if you have the <strings.h> header file. */
46 #define HAVE_STRINGS_H 1
47
48 /* Define to 1 if you have the <string.h> header file. */
49 #define HAVE_STRING_H 1
50
51 /* Define to 1 if you have the <sys/stat.h> header file. */
52 #define HAVE_SYS_STAT_H 1
53
54 /* Define to 1 if you have the <sys/types.h> header file. */
55 #define HAVE_SYS_TYPES_H 1
56
57 /* Define to 1 if you have the <unistd.h> header file. */
58 #define HAVE_UNISTD_H 1
59
60 /* Define to 1 if you have the <uv.h> header file. */
61 /* #undef HAVE_UV_H */
62
63 /* Define to the sub-directory in which libtool stores uninstalled libraries.
64 */
65 #define LT_OBJDIR ".libs/"
66
67 /* Define to the address where bug reports for this package should be sent. */
68 #define PACKAGE_BUGREPORT "stub-resolver@verisignlabs.com"
69
70 /* Define to the full name of this package. */
71 #define PACKAGE_NAME "getdns"
72
73 /* Define to the full name and version of this package. */
74 #define PACKAGE_STRING "getdns 0.1.0"
75
76 /* Define to the one symbol short name of this package. */
77 #define PACKAGE_TARNAME "getdns"
78
79 /* Define to the home page for this package. */
80 #define PACKAGE_URL "http://www.getdnsapi.net"
81
82 /* Define to the version of this package. */
83 #define PACKAGE_VERSION "0.1.0"
84
85 /* Define to 1 if you have the ANSI C header files. */
86 #define STDC_HEADERS 1
87
88 /* System configuration dir */
89 #define SYSCONFDIR sysconfdir
90
91 /* Default trust anchor file */
92 #define TRUST_ANCHOR_FILE "/etc/unbound/getdns-root.key"
93
94 /* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
95 <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
96 #define below would cause a syntax error. */
97 /* #undef _UINT32_T */
98
99 /* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
100 <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
101 #define below would cause a syntax error. */
102 /* #undef _UINT64_T */
103
104 /* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
105 <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
106 #define below would cause a syntax error. */
107 /* #undef _UINT8_T */
108
109 /* Define to `unsigned int' if <sys/types.h> does not define. */
110 /* #undef size_t */
111
112 /* Define to `unsigned char' if <sys/types.h> does not define. */
113 /* #undef u_char */
114
115 /* Define to the type of an unsigned integer type of width exactly 16 bits if
116 such a type exists and the standard includes do not define it. */
117 /* #undef uint16_t */
118
119 /* Define to the type of an unsigned integer type of width exactly 32 bits if
120 such a type exists and the standard includes do not define it. */
121 /* #undef uint32_t */
122
123 /* Define to the type of an unsigned integer type of width exactly 64 bits if
124 such a type exists and the standard includes do not define it. */
125 /* #undef uint64_t */
126
127 /* Define to the type of an unsigned integer type of width exactly 8 bits if
128 such a type exists and the standard includes do not define it. */
129 /* #undef uint8_t */
0 /* src/config.h.in. Generated from configure.ac by autoheader. */
1
2 /* Define to 1 if you have the <dlfcn.h> header file. */
3 #undef HAVE_DLFCN_H
4
5 /* Define to 1 if you have the <event2/event.h> header file. */
6 #undef HAVE_EVENT2_EVENT_H
7
8 /* Define to 1 if you have the `event_base_free' function. */
9 #undef HAVE_EVENT_BASE_FREE
10
11 /* Define to 1 if you have the `event_base_new' function. */
12 #undef HAVE_EVENT_BASE_NEW
13
14 /* Define to 1 if you have the <event.h> header file. */
15 #undef HAVE_EVENT_H
16
17 /* Define to 1 if you have the <ev.h> header file. */
18 #undef HAVE_EV_H
19
20 /* Define to 1 if you have the <inttypes.h> header file. */
21 #undef HAVE_INTTYPES_H
22
23 /* Define to 1 if you have the `idn' library (-lidn). */
24 #undef HAVE_LIBIDN
25
26 /* Define to 1 if you have the `ldns' library (-lldns). */
27 #undef HAVE_LIBLDNS
28
29 /* Define to 1 if you have the `unbound' library (-lunbound). */
30 #undef HAVE_LIBUNBOUND
31
32 /* Define to 1 if you have the <memory.h> header file. */
33 #undef HAVE_MEMORY_H
34
35 /* Define to 1 if you have the <netinet/in.h> header file. */
36 #undef HAVE_NETINET_IN_H
37
38 /* Define to 1 if you have the <stdint.h> header file. */
39 #undef HAVE_STDINT_H
40
41 /* Define to 1 if you have the <stdlib.h> header file. */
42 #undef HAVE_STDLIB_H
43
44 /* Define to 1 if you have the <strings.h> header file. */
45 #undef HAVE_STRINGS_H
46
47 /* Define to 1 if you have the <string.h> header file. */
48 #undef HAVE_STRING_H
49
50 /* Define to 1 if you have the <sys/stat.h> header file. */
51 #undef HAVE_SYS_STAT_H
52
53 /* Define to 1 if you have the <sys/types.h> header file. */
54 #undef HAVE_SYS_TYPES_H
55
56 /* Define to 1 if you have the <unistd.h> header file. */
57 #undef HAVE_UNISTD_H
58
59 /* Define to 1 if you have the <uv.h> header file. */
60 #undef HAVE_UV_H
61
62 /* Define to the sub-directory in which libtool stores uninstalled libraries.
63 */
64 #undef LT_OBJDIR
65
66 /* Define to the address where bug reports for this package should be sent. */
67 #undef PACKAGE_BUGREPORT
68
69 /* Define to the full name of this package. */
70 #undef PACKAGE_NAME
71
72 /* Define to the full name and version of this package. */
73 #undef PACKAGE_STRING
74
75 /* Define to the one symbol short name of this package. */
76 #undef PACKAGE_TARNAME
77
78 /* Define to the home page for this package. */
79 #undef PACKAGE_URL
80
81 /* Define to the version of this package. */
82 #undef PACKAGE_VERSION
83
84 /* Define to 1 if you have the ANSI C header files. */
85 #undef STDC_HEADERS
86
87 /* System configuration dir */
88 #undef SYSCONFDIR
89
90 /* Default trust anchor file */
91 #undef TRUST_ANCHOR_FILE
92
93 /* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
94 <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
95 #define below would cause a syntax error. */
96 #undef _UINT32_T
97
98 /* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
99 <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
100 #define below would cause a syntax error. */
101 #undef _UINT64_T
102
103 /* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
104 <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
105 #define below would cause a syntax error. */
106 #undef _UINT8_T
107
108 /* Define to `unsigned int' if <sys/types.h> does not define. */
109 #undef size_t
110
111 /* Define to `unsigned char' if <sys/types.h> does not define. */
112 #undef u_char
113
114 /* Define to the type of an unsigned integer type of width exactly 16 bits if
115 such a type exists and the standard includes do not define it. */
116 #undef uint16_t
117
118 /* Define to the type of an unsigned integer type of width exactly 32 bits if
119 such a type exists and the standard includes do not define it. */
120 #undef uint32_t
121
122 /* Define to the type of an unsigned integer type of width exactly 64 bits if
123 such a type exists and the standard includes do not define it. */
124 #undef uint64_t
125
126 /* Define to the type of an unsigned integer type of width exactly 8 bits if
127 such a type exists and the standard includes do not define it. */
128 #undef uint8_t
0 /* WARNING! This file is generated by the mk-const-info.c.sh program.
1 * Do not edit manually!
2 */
3 #include <getdns/getdns.h>
4 #include <stdlib.h>
5 #include "const-info.h"
6
7 static struct const_info consts_info[] = {
8 { -1, NULL, "/* <unknown getdns value> */" },
9 { 0, "GETDNS_RETURN_GOOD", GETDNS_RETURN_GOOD_TEXT },
10 { 1, "GETDNS_RETURN_GENERIC_ERROR", GETDNS_RETURN_GENERIC_ERROR_TEXT },
11 { 300, "GETDNS_RETURN_BAD_DOMAIN_NAME", GETDNS_RETURN_BAD_DOMAIN_NAME_TEXT },
12 { 301, "GETDNS_RETURN_BAD_CONTEXT", GETDNS_RETURN_BAD_CONTEXT_TEXT },
13 { 302, "GETDNS_RETURN_CONTEXT_UPDATE_FAIL", GETDNS_RETURN_CONTEXT_UPDATE_FAIL_TEXT },
14 { 303, "GETDNS_RETURN_UNKNOWN_TRANSACTION", GETDNS_RETURN_UNKNOWN_TRANSACTION_TEXT },
15 { 304, "GETDNS_RETURN_NO_SUCH_LIST_ITEM", GETDNS_RETURN_NO_SUCH_LIST_ITEM_TEXT },
16 { 305, "GETDNS_RETURN_NO_SUCH_DICT_NAME", GETDNS_RETURN_NO_SUCH_DICT_NAME_TEXT },
17 { 306, "GETDNS_RETURN_WRONG_TYPE_REQUESTED", GETDNS_RETURN_WRONG_TYPE_REQUESTED_TEXT },
18 { 307, "GETDNS_RETURN_NO_SUCH_EXTENSION", GETDNS_RETURN_NO_SUCH_EXTENSION_TEXT },
19 { 308, "GETDNS_RETURN_EXTENSION_MISFORMAT", GETDNS_RETURN_EXTENSION_MISFORMAT_TEXT },
20 { 309, "GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED", GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED_TEXT },
21 { 310, "GETDNS_RETURN_MEMORY_ERROR", GETDNS_RETURN_MEMORY_ERROR_TEXT },
22 { 311, "GETDNS_RETURN_INVALID_PARAMETER", GETDNS_RETURN_INVALID_PARAMETER_TEXT },
23 { 400, "GETDNS_DNSSEC_SECURE", GETDNS_DNSSEC_SECURE_TEXT },
24 { 401, "GETDNS_DNSSEC_BOGUS", GETDNS_DNSSEC_BOGUS_TEXT },
25 { 402, "GETDNS_DNSSEC_INDETERMINATE", GETDNS_DNSSEC_INDETERMINATE_TEXT },
26 { 403, "GETDNS_DNSSEC_INSECURE", GETDNS_DNSSEC_INSECURE_TEXT },
27 { 404, "GETDNS_DNSSEC_NOT_PERFORMED", GETDNS_DNSSEC_NOT_PERFORMED_TEXT },
28 { 500, "GETDNS_NAMESPACE_DNS", GETDNS_NAMESPACE_DNS_TEXT },
29 { 501, "GETDNS_NAMESPACE_LOCALNAMES", GETDNS_NAMESPACE_LOCALNAMES_TEXT },
30 { 502, "GETDNS_NAMESPACE_NETBIOS", GETDNS_NAMESPACE_NETBIOS_TEXT },
31 { 503, "GETDNS_NAMESPACE_MDNS", GETDNS_NAMESPACE_MDNS_TEXT },
32 { 504, "GETDNS_NAMESPACE_NIS", GETDNS_NAMESPACE_NIS_TEXT },
33 { 520, "GETDNS_RESOLUTION_STUB", GETDNS_RESOLUTION_STUB_TEXT },
34 { 521, "GETDNS_RESOLUTION_RECURSING", GETDNS_RESOLUTION_RECURSING_TEXT },
35 { 530, "GETDNS_REDIRECTS_FOLLOW", GETDNS_REDIRECTS_FOLLOW_TEXT },
36 { 531, "GETDNS_REDIRECTS_DO_NOT_FOLLOW", GETDNS_REDIRECTS_DO_NOT_FOLLOW_TEXT },
37 { 540, "GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP", GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP_TEXT },
38 { 541, "GETDNS_TRANSPORT_UDP_ONLY", GETDNS_TRANSPORT_UDP_ONLY_TEXT },
39 { 542, "GETDNS_TRANSPORT_TCP_ONLY", GETDNS_TRANSPORT_TCP_ONLY_TEXT },
40 { 543, "GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN_TEXT },
41 { 550, "GETDNS_APPEND_NAME_ALWAYS", GETDNS_APPEND_NAME_ALWAYS_TEXT },
42 { 551, "GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE", GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE_TEXT },
43 { 552, "GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE", GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE_TEXT },
44 { 553, "GETDNS_APPEND_NAME_NEVER", GETDNS_APPEND_NAME_NEVER_TEXT },
45 { 600, "GETDNS_CONTEXT_CODE_NAMESPACES", GETDNS_CONTEXT_CODE_NAMESPACES_TEXT },
46 { 601, "GETDNS_CONTEXT_CODE_RESOLUTION_TYPE", GETDNS_CONTEXT_CODE_RESOLUTION_TYPE_TEXT },
47 { 602, "GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS", GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS_TEXT },
48 { 603, "GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS", GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS_TEXT },
49 { 604, "GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS", GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS_TEXT },
50 { 605, "GETDNS_CONTEXT_CODE_DNS_TRANSPORT", GETDNS_CONTEXT_CODE_DNS_TRANSPORT_TEXT },
51 { 606, "GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES", GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES_TEXT },
52 { 607, "GETDNS_CONTEXT_CODE_APPEND_NAME", GETDNS_CONTEXT_CODE_APPEND_NAME_TEXT },
53 { 608, "GETDNS_CONTEXT_CODE_SUFFIX", GETDNS_CONTEXT_CODE_SUFFIX_TEXT },
54 { 609, "GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS", GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS_TEXT },
55 { 610, "GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE", GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE_TEXT },
56 { 611, "GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE", GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE_TEXT },
57 { 612, "GETDNS_CONTEXT_CODE_EDNS_VERSION", GETDNS_CONTEXT_CODE_EDNS_VERSION_TEXT },
58 { 613, "GETDNS_CONTEXT_CODE_EDNS_DO_BIT", GETDNS_CONTEXT_CODE_EDNS_DO_BIT_TEXT },
59 { 614, "GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW", GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW_TEXT },
60 { 615, "GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS", GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS_TEXT },
61 { 616, "GETDNS_CONTEXT_CODE_TIMEOUT", GETDNS_CONTEXT_CODE_TIMEOUT_TEXT },
62 { 700, "GETDNS_CALLBACK_COMPLETE", GETDNS_CALLBACK_COMPLETE_TEXT },
63 { 701, "GETDNS_CALLBACK_CANCEL", GETDNS_CALLBACK_CANCEL_TEXT },
64 { 702, "GETDNS_CALLBACK_TIMEOUT", GETDNS_CALLBACK_TIMEOUT_TEXT },
65 { 703, "GETDNS_CALLBACK_ERROR", GETDNS_CALLBACK_ERROR_TEXT },
66 { 800, "GETDNS_NAMETYPE_DNS", GETDNS_NAMETYPE_DNS_TEXT },
67 { 801, "GETDNS_NAMETYPE_WINS", GETDNS_NAMETYPE_WINS_TEXT },
68 { 900, "GETDNS_RESPSTATUS_GOOD", GETDNS_RESPSTATUS_GOOD_TEXT },
69 { 901, "GETDNS_RESPSTATUS_NO_NAME", GETDNS_RESPSTATUS_NO_NAME_TEXT },
70 { 902, "GETDNS_RESPSTATUS_ALL_TIMEOUT", GETDNS_RESPSTATUS_ALL_TIMEOUT_TEXT },
71 { 903, "GETDNS_RESPSTATUS_NO_SECURE_ANSWERS", GETDNS_RESPSTATUS_NO_SECURE_ANSWERS_TEXT },
72 { 1000, "GETDNS_EXTENSION_TRUE", GETDNS_EXTENSION_TRUE_TEXT },
73 { 1001, "GETDNS_EXTENSION_FALSE", GETDNS_EXTENSION_FALSE_TEXT },
74 { 1100, "GETDNS_BAD_DNS_CNAME_IN_TARGET", GETDNS_BAD_DNS_CNAME_IN_TARGET_TEXT },
75 { 1101, "GETDNS_BAD_DNS_ALL_NUMERIC_LABEL", GETDNS_BAD_DNS_ALL_NUMERIC_LABEL_TEXT },
76 { 1102, "GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE", GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE_TEXT },
77 };
78
79 static int const_info_cmp(const void *a, const void *b)
80 {
81 return ((struct const_info *) a)->code - ((struct const_info *) b)->code;
82 }
83 struct const_info *
84 priv_getdns_get_const_info(int value)
85 {
86 struct const_info key = { value, "", "" };
87 struct const_info *i = bsearch(&key, consts_info,
88 sizeof(consts_info) / sizeof(struct const_info),
89 sizeof(struct const_info), const_info_cmp);
90 if (i)
91 return i;
92 return consts_info;
93 }
94
0 /**
1 *
2 * /brief priv_getdns_consts table with values, names and descriptions of the
3 * constants in getdns
4 *
5 * The priv_getdns_get_validation_chain function is called after an answer
6 * has been fetched when the dnssec_return_validation_chain extension is set.
7 * It fetches DNSKEYs, DSes and their signatures for all RRSIGs found in the
8 * answer.
9 */
10
11 /*
12 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
13 * All rights reserved.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are met:
17 * * Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * * Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * * Neither the names of the copyright holders nor the
23 * names of its contributors may be used to endorse or promote products
24 * derived from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
30 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38 #ifndef CONST_INFO_H_
39 #define CONST_INFO_H_
40
41 struct const_info {
42 int code;
43 const char *name;
44 const char *text;
45 };
46
47 struct const_info *priv_getdns_get_const_info(int value);
48
49 #endif
50
51 /* const-info.h */
0 /**
1 *
2 * \file context.c
3 * @brief getdns context management functions
4 *
5 * Declarations taken from the getdns API description pseudo implementation.
6 *
7 */
8
9 /*
10 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * * Neither the names of the copyright holders nor the
21 * names of its contributors may be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 #include "config.h"
37 #include <arpa/inet.h>
38 #include <ldns/ldns.h>
39 #include <string.h>
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <sys/stat.h>
43 #include <sys/time.h>
44 #include <unbound.h>
45
46 #include "context.h"
47 #include "types-internal.h"
48 #include "util-internal.h"
49 #include "dnssec.h"
50
51 void *plain_mem_funcs_user_arg = MF_PLAIN;
52
53 /* Private functions */
54 getdns_return_t create_default_namespaces(struct getdns_context *context);
55 static struct getdns_list *create_default_root_servers(void);
56 static getdns_return_t add_ip_str(struct getdns_dict *);
57 static struct getdns_dict *create_ipaddr_dict_from_rdf(struct getdns_context *,
58 ldns_rdf *);
59 static struct getdns_list *create_from_ldns_list(struct getdns_context *,
60 ldns_rdf **, size_t);
61 static getdns_return_t set_os_defaults(struct getdns_context *);
62 static int transaction_id_cmp(const void *, const void *);
63 static int timeout_cmp(const void *, const void *);
64 static void dispatch_updated(struct getdns_context *, uint16_t);
65 static void cancel_dns_req(getdns_dns_req *);
66 static void cancel_outstanding_requests(struct getdns_context*, int);
67
68 /* unbound helpers */
69 static getdns_return_t rebuild_ub_ctx(struct getdns_context* context);
70 static void set_ub_string_opt(struct getdns_context *, char *, char *);
71 static void set_ub_number_opt(struct getdns_context *, char *, uint16_t);
72 static getdns_return_t set_ub_dns_transport(struct getdns_context*, getdns_transport_t);
73 static void set_ub_limit_outstanding_queries(struct getdns_context*,
74 uint16_t);
75 static void set_ub_dnssec_allowed_skew(struct getdns_context*, uint32_t);
76 static void set_ub_edns_maximum_udp_payload_size(struct getdns_context*,
77 uint16_t);
78
79
80 /* Stuff to make it compile pedantically */
81 #define RETURN_IF_NULL(ptr, code) if(ptr == NULL) return code;
82
83 /**
84 * Helper to get default lookup namespaces.
85 * TODO: Determine from OS
86 */
87 getdns_return_t
88 create_default_namespaces(struct getdns_context *context)
89 {
90 context->namespaces = GETDNS_XMALLOC(context->my_mf, getdns_namespace_t, 2);
91 if(context->namespaces == NULL)
92 return GETDNS_RETURN_GENERIC_ERROR;
93
94 context->namespaces[0] = GETDNS_NAMESPACE_LOCALNAMES;
95 context->namespaces[1] = GETDNS_NAMESPACE_DNS;
96 context->namespace_count = 2;
97
98 return GETDNS_RETURN_GOOD;
99 }
100
101 /**
102 * Helper to get the default root servers.
103 * TODO: Implement
104 */
105 static struct getdns_list *
106 create_default_root_servers()
107 {
108 return NULL;
109 }
110
111 #define IP_STR_BUFF_LEN 512
112
113 static getdns_return_t
114 add_ip_str(struct getdns_dict * ip)
115 {
116 struct sockaddr_storage storage;
117 uint32_t port = 0;
118 char buff[IP_STR_BUFF_LEN];
119 memset(buff, 0, IP_STR_BUFF_LEN);
120 getdns_return_t r = dict_to_sockaddr(ip, &storage);
121 if (r != GETDNS_RETURN_GOOD) {
122 return r;
123 }
124 if (storage.ss_family == AF_INET) {
125 struct sockaddr_in *addr = (struct sockaddr_in *) &storage;
126 const char *ipStr =
127 inet_ntop(AF_INET, &(addr->sin_addr), buff, IP_STR_BUFF_LEN);
128 if (!ipStr) {
129 return GETDNS_RETURN_GENERIC_ERROR;
130 }
131 r = getdns_dict_get_int(ip, GETDNS_STR_PORT, &port);
132 if (r == GETDNS_RETURN_GOOD && port > 0) {
133 size_t addrLen = strlen(ipStr);
134 /* append @ and port */
135 buff[addrLen] = '@';
136 ++addrLen;
137 snprintf(buff + addrLen, IP_STR_BUFF_LEN - addrLen, "%d", port);
138 }
139 getdns_dict_util_set_string(ip, GETDNS_STR_ADDRESS_STRING,
140 ipStr);
141 } else if (storage.ss_family == AF_INET6) {
142 struct sockaddr_in6 *addr = (struct sockaddr_in6 *) &storage;
143 const char *ipStr =
144 inet_ntop(AF_INET6, &(addr->sin6_addr), buff, IP_STR_BUFF_LEN);
145 if (!ipStr) {
146 return GETDNS_RETURN_GENERIC_ERROR;
147 }
148 r = getdns_dict_get_int(ip, GETDNS_STR_PORT, &port);
149 if (r == GETDNS_RETURN_GOOD && port > 0) {
150 size_t addrLen = strlen(ipStr);
151 /* append @ and port */
152 buff[addrLen] = '@';
153 ++addrLen;
154 snprintf(buff + addrLen, IP_STR_BUFF_LEN - addrLen, "%d", port);
155 }
156
157 getdns_dict_util_set_string(ip, GETDNS_STR_ADDRESS_STRING,
158 ipStr);
159 } else {
160 /* unknown */
161 return GETDNS_RETURN_GENERIC_ERROR;
162 }
163 return GETDNS_RETURN_GOOD;
164 }
165
166 /**
167 * check a file for changes since the last check
168 * and refresh the current data if changes are detected
169 * @param file to check
170 * @returns changes as OR'd list of GETDNS_FCHG_* values
171 * @returns GETDNS_FCHG_NONE if no changes
172 * @returns GETDNS_FCHG_ERRORS if problems (see fchg->errors for details)
173 */
174 int
175 filechg_check(struct getdns_context *context, struct filechg *fchg)
176 {
177 struct stat *finfo;
178
179 if(fchg == NULL)
180 return 0;
181
182 fchg->errors = GETDNS_FCHG_NOERROR;
183 fchg->changes = GETDNS_FCHG_NOCHANGES;
184
185 finfo = GETDNS_MALLOC(context->my_mf, struct stat);
186 if(finfo == NULL)
187 {
188 fchg->errors = errno;
189 return GETDNS_FCHG_ERRORS;
190 }
191
192 if(stat(fchg->fn, finfo) != 0)
193 {
194 GETDNS_FREE(context->my_mf, finfo);
195 fchg->errors = errno;
196 return GETDNS_FCHG_ERRORS;
197 }
198
199 /* we want to consider a file that previously returned error for stat() as a
200 change */
201
202 if(fchg->prevstat == NULL)
203 fchg->changes = GETDNS_FCHG_MTIME | GETDNS_FCHG_CTIME;
204 else
205 {
206 if(fchg->prevstat->st_mtime != finfo->st_mtime)
207 fchg->changes |= GETDNS_FCHG_MTIME;
208 if(fchg->prevstat->st_ctime != finfo->st_ctime)
209 fchg->changes |= GETDNS_FCHG_CTIME;
210 GETDNS_FREE(context->my_mf, fchg->prevstat);
211 }
212 fchg->prevstat = finfo;
213
214 return fchg->changes;
215 } /* filechg */
216
217 static struct getdns_dict *
218 create_ipaddr_dict_from_rdf(struct getdns_context *context, ldns_rdf * rdf)
219 {
220 ldns_rdf_type rt = ldns_rdf_get_type(rdf);
221 size_t sz = ldns_rdf_size(rdf);
222 struct getdns_dict *result = getdns_dict_create_with_context(context);
223 /* set type */
224 if (rt == LDNS_RDF_TYPE_A) {
225 getdns_dict_util_set_string(result, GETDNS_STR_ADDRESS_TYPE,
226 GETDNS_STR_IPV4);
227 } else {
228 getdns_dict_util_set_string(result, GETDNS_STR_ADDRESS_TYPE,
229 GETDNS_STR_IPV6);
230 }
231 /* set data */
232 struct getdns_bindata data_bin = { sz, ldns_rdf_data(rdf) };
233 getdns_dict_set_bindata(result, GETDNS_STR_ADDRESS_DATA, &data_bin);
234 add_ip_str(result);
235 return result;
236 }
237
238 static struct getdns_list *
239 create_from_ldns_list(struct getdns_context *context, ldns_rdf ** ldns_list,
240 size_t count)
241 {
242 size_t i = 0;
243 size_t idx = 0;
244 struct getdns_list *result = getdns_list_create_with_context(context);
245 for (i = 0; i < count; ++i) {
246 ldns_rdf *rdf = ldns_list[i];
247 switch (ldns_rdf_get_type(rdf)) {
248 case LDNS_RDF_TYPE_A:
249 case LDNS_RDF_TYPE_AAAA:
250 {
251 struct getdns_dict *ipaddr =
252 create_ipaddr_dict_from_rdf(context, rdf);
253 getdns_list_add_item(result, &idx);
254 getdns_list_set_dict(result, idx, ipaddr);
255 getdns_dict_destroy(ipaddr);
256 }
257 break;
258
259 case LDNS_RDF_TYPE_DNAME:
260 {
261 struct getdns_bindata item;
262 char *srch = ldns_rdf2str(rdf);
263 item.size = strlen(srch) + 1;
264 item.data = (uint8_t *) srch;
265 getdns_list_add_item(result, &idx);
266 getdns_list_set_bindata(result, idx, &item);
267 free(srch);
268 }
269 break;
270
271 default:
272 break;
273 }
274 }
275 return result;
276 }
277
278 /*---------------------------------------- set_os_defaults
279 we use ldns to read the resolv.conf file - the ldns resolver is
280 destroyed once the file is read
281 */
282 static getdns_return_t
283 set_os_defaults(struct getdns_context *context)
284 {
285 ldns_resolver *lr = NULL;
286 ldns_rdf **rdf_list;
287 size_t rdf_list_sz;
288
289 if (ldns_resolver_new_frm_file(&lr, NULL) != LDNS_STATUS_OK)
290 return GETDNS_RETURN_GENERIC_ERROR;
291
292 if(context->fchg_resolvconf == NULL)
293 {
294 context->fchg_resolvconf = GETDNS_MALLOC(context->my_mf, struct filechg);
295 if(context->fchg_resolvconf == NULL)
296 return GETDNS_RETURN_MEMORY_ERROR;
297 context->fchg_resolvconf->fn = "/etc/resolv.conf";
298 context->fchg_resolvconf->prevstat = NULL;
299 context->fchg_resolvconf->changes = GETDNS_FCHG_NOCHANGES;
300 context->fchg_resolvconf->errors = GETDNS_FCHG_NOERROR;
301 }
302 filechg_check(context, context->fchg_resolvconf);
303
304 rdf_list = ldns_resolver_nameservers(lr);
305 rdf_list_sz = ldns_resolver_nameserver_count(lr);
306 if (rdf_list_sz > 0) {
307 context->upstream_list =
308 create_from_ldns_list(context, rdf_list, rdf_list_sz);
309 }
310
311 rdf_list = ldns_resolver_searchlist(lr);
312 rdf_list_sz = ldns_resolver_searchlist_count(lr);
313 if (rdf_list_sz > 0) {
314 context->suffix = create_from_ldns_list(context, rdf_list,
315 rdf_list_sz);
316 }
317 ldns_resolver_deep_free(lr);
318
319 return GETDNS_RETURN_GOOD;
320 } /* set_os_defaults */
321
322 /* compare of transaction ids in DESCENDING order
323 so that 0 comes last
324 */
325 static int
326 transaction_id_cmp(const void *id1, const void *id2)
327 {
328 if (id1 == NULL && id2 == NULL) {
329 return 0;
330 } else if (id1 == NULL && id2 != NULL) {
331 return 1;
332 } else if (id1 != NULL && id2 == NULL) {
333 return -1;
334 } else {
335 getdns_transaction_t t1 =
336 *((const getdns_transaction_t *) id1);
337 getdns_transaction_t t2 =
338 *((const getdns_transaction_t *) id2);
339 if (t1 == t2) {
340 return 0;
341 } else if (t1 > t2) {
342 return -1;
343 } else {
344 return 1;
345 }
346 }
347 }
348
349 static int
350 timeout_cmp(const void *to1, const void *to2)
351 {
352 if (to1 == NULL && to2 == NULL) {
353 return 0;
354 } else if (to1 == NULL && to2 != NULL) {
355 return 1;
356 } else if (to1 != NULL && to2 == NULL) {
357 return -1;
358 } else {
359 const getdns_timeout_data_t* t1 = (const getdns_timeout_data_t*) to1;
360 const getdns_timeout_data_t* t2 = (const getdns_timeout_data_t*) to2;
361 if (t1->timeout_time.tv_sec < t2->timeout_time.tv_sec) {
362 return -1;
363 } else if (t1->timeout_time.tv_sec > t2->timeout_time.tv_sec) {
364 return 1;
365 } else {
366 /* compare usec.. */
367 if (t1->timeout_time.tv_usec < t2->timeout_time.tv_usec) {
368 return -1;
369 } else if (t1->timeout_time.tv_usec > t2->timeout_time.tv_usec) {
370 return 1;
371 } else {
372 return transaction_id_cmp(&t1->transaction_id, &t2->transaction_id);
373 }
374 }
375 }
376 }
377
378 static ldns_rbtree_t*
379 create_ldns_rbtree(getdns_context * context,
380 int(*cmpf)(const void *, const void *)) {
381 ldns_rbtree_t* result = GETDNS_MALLOC(context->mf, ldns_rbtree_t);
382 if (!result) {
383 return NULL;
384 }
385 ldns_rbtree_init(result, cmpf);
386 return result;
387 }
388
389 /*
390 * getdns_context_create
391 *
392 * Call this to initialize the context that is used in other getdns calls.
393 */
394 getdns_return_t
395 getdns_context_create_with_extended_memory_functions(
396 struct getdns_context ** context,
397 int set_from_os,
398 void *userarg,
399 void *(*malloc)(void *userarg, size_t),
400 void *(*realloc)(void *userarg, void *, size_t),
401 void (*free)(void *userarg, void *)
402 )
403 {
404 struct getdns_context *result = NULL;
405 mf_union mf;
406
407 if (!context || !malloc || !realloc || !free)
408 return GETDNS_RETURN_INVALID_PARAMETER;
409
410 /** default init **/
411 mf.ext.malloc = malloc;
412 result = userarg == MF_PLAIN
413 ? (*mf.pln.malloc)( sizeof(struct getdns_context))
414 : (*mf.ext.malloc)(userarg, sizeof(struct getdns_context));
415 if (!result) {
416 return GETDNS_RETURN_GENERIC_ERROR;
417 }
418 result->destroying = 0;
419 result->my_mf.mf_arg = userarg;
420 result->my_mf.mf.ext.malloc = malloc;
421 result->my_mf.mf.ext.realloc = realloc;
422 result->my_mf.mf.ext.free = free;
423
424 result->update_callback = NULL;
425
426 result->mf.mf_arg = userarg;
427 result->mf.mf.ext.malloc = malloc;
428 result->mf.mf.ext.realloc = realloc;
429 result->mf.mf.ext.free = free;
430
431 result->resolution_type_set = 0;
432
433 result->outbound_requests = create_ldns_rbtree(result, transaction_id_cmp);
434 result->timeouts_by_time = create_ldns_rbtree(result, timeout_cmp);
435 result->timeouts_by_id = create_ldns_rbtree(result, transaction_id_cmp);
436
437
438 result->resolution_type = GETDNS_RESOLUTION_RECURSING;
439 if(create_default_namespaces(result) != GETDNS_RETURN_GOOD)
440 return GETDNS_RETURN_GENERIC_ERROR;
441
442 result->timeout = 5000;
443 result->follow_redirects = GETDNS_REDIRECTS_FOLLOW;
444 result->dns_root_servers = create_default_root_servers();
445 result->append_name = GETDNS_APPEND_NAME_ALWAYS;
446 result->suffix = NULL;
447
448 result->dnssec_trust_anchors = NULL;
449 result->upstream_list = NULL;
450
451 result->edns_extended_rcode = 0;
452 result->edns_version = 0;
453 result->edns_do_bit = 1;
454
455 result->extension = NULL;
456 result->extension_data = NULL;
457
458 result->fchg_resolvconf = NULL;
459 result->fchg_hosts = NULL;
460 if (set_from_os) {
461 if (GETDNS_RETURN_GOOD != set_os_defaults(result)) {
462 getdns_context_destroy(result);
463 return GETDNS_RETURN_GENERIC_ERROR;
464 }
465 }
466 result->dnssec_allowed_skew = 0;
467 result->edns_maximum_udp_payload_size = 512;
468 result->dns_transport = GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP;
469 result->limit_outstanding_queries = 0;
470 result->has_ta = priv_getdns_parse_ta_file(NULL, NULL);
471 if (!result->outbound_requests ||
472 !result->timeouts_by_id ||
473 !result->timeouts_by_time) {
474 getdns_context_destroy(result);
475 return GETDNS_RETURN_MEMORY_ERROR;
476 }
477 /* unbound context is initialized here */
478 result->unbound_ctx = NULL;
479 if (GETDNS_RETURN_GOOD != rebuild_ub_ctx(result)) {
480 getdns_context_destroy(result);
481 return GETDNS_RETURN_GENERIC_ERROR;
482 }
483
484 *context = result;
485
486 return GETDNS_RETURN_GOOD;
487 } /* getdns_context_create_with_extended_memory_functions */
488
489 /*
490 * getdns_context_create
491 *
492 * Call this to initialize the context that is used in other getdns calls.
493 */
494 getdns_return_t
495 getdns_context_create_with_memory_functions(struct getdns_context ** context,
496 int set_from_os,
497 void *(*malloc)(size_t),
498 void *(*realloc)(void *, size_t),
499 void (*free)(void *)
500 )
501 {
502 mf_union mf;
503 mf.pln.malloc = malloc;
504 mf.pln.realloc = realloc;
505 mf.pln.free = free;
506 return getdns_context_create_with_extended_memory_functions(
507 context, set_from_os, MF_PLAIN,
508 mf.ext.malloc, mf.ext.realloc, mf.ext.free);
509 } /* getdns_context_create */
510
511 /*
512 * getdns_context_create
513 *
514 * Call this to initialize the context that is used in other getdns calls.
515 */
516 getdns_return_t
517 getdns_context_create(struct getdns_context ** context, int set_from_os)
518 {
519 return getdns_context_create_with_memory_functions(context,
520 set_from_os, malloc, realloc, free);
521 } /* getdns_context_create */
522
523
524 /*
525 * getdns_context_destroy
526 *
527 * Call this to dispose of resources associated with a context once you
528 * are done with it.
529 */
530 void
531 getdns_context_destroy(struct getdns_context *context)
532 {
533 if (context == NULL) {
534 return;
535 }
536 context->destroying = 1;
537 cancel_outstanding_requests(context, 1);
538 getdns_extension_detach_eventloop(context);
539
540 if (context->namespaces)
541 GETDNS_FREE(context->my_mf, context->namespaces);
542 if(context->fchg_resolvconf)
543 {
544 if(context->fchg_resolvconf->prevstat)
545 GETDNS_FREE(context->my_mf, context->fchg_resolvconf->prevstat);
546 GETDNS_FREE(context->my_mf, context->fchg_resolvconf);
547 }
548 if(context->fchg_hosts)
549 {
550 if(context->fchg_hosts->prevstat)
551 GETDNS_FREE(context->my_mf, context->fchg_hosts->prevstat);
552 GETDNS_FREE(context->my_mf, context->fchg_hosts);
553 }
554
555 getdns_list_destroy(context->dns_root_servers);
556 getdns_list_destroy(context->suffix);
557 getdns_list_destroy(context->dnssec_trust_anchors);
558 getdns_list_destroy(context->upstream_list);
559
560 /* destroy the ub context */
561 if (context->unbound_ctx)
562 ub_ctx_delete(context->unbound_ctx);
563
564 if (context->outbound_requests)
565 GETDNS_FREE(context->my_mf, context->outbound_requests);
566 if (context->timeouts_by_id)
567 GETDNS_FREE(context->my_mf, context->timeouts_by_id);
568 if (context->timeouts_by_time)
569 GETDNS_FREE(context->my_mf, context->timeouts_by_time);
570
571 GETDNS_FREE(context->my_mf, context);
572 return;
573 } /* getdns_context_destroy */
574
575 /*
576 * getdns_context_set_context_update_callback
577 *
578 */
579 getdns_return_t
580 getdns_context_set_context_update_callback(struct getdns_context *context,
581 void (*value) (struct getdns_context *context,
582 getdns_context_code_t changed_item))
583 {
584 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
585 context->update_callback = value;
586 return GETDNS_RETURN_GOOD;
587 } /* getdns_context_set_context_update_callback */
588
589 /*
590 * Helpers to set options on the unbound ctx
591 */
592
593 static void
594 set_ub_string_opt(struct getdns_context *ctx, char *opt, char *value)
595 {
596 if (ctx->unbound_ctx)
597 ub_ctx_set_option(ctx->unbound_ctx, opt, value);
598 }
599
600 static void
601 set_ub_number_opt(struct getdns_context *ctx, char *opt, uint16_t value)
602 {
603 char buffer[64];
604 snprintf(buffer, 64, "%hu", value);
605 set_ub_string_opt(ctx, opt, buffer);
606 }
607
608 static getdns_return_t
609 rebuild_ub_ctx(struct getdns_context* context) {
610 if (context->unbound_ctx != NULL) {
611 /* cancel all requests and delete */
612 cancel_outstanding_requests(context, 1);
613 ub_ctx_delete(context->unbound_ctx);
614 context->unbound_ctx = NULL;
615 }
616 /* setup */
617 context->unbound_ctx = ub_ctx_create();
618 if (!context->unbound_ctx) {
619 return GETDNS_RETURN_MEMORY_ERROR;
620 }
621 set_ub_dnssec_allowed_skew(context,
622 context->dnssec_allowed_skew);
623 set_ub_edns_maximum_udp_payload_size(context,
624 context->edns_maximum_udp_payload_size);
625 set_ub_dns_transport(context,
626 context->dns_transport);
627
628 /* Set default trust anchor */
629 if (context->has_ta) {
630 (void) ub_ctx_add_ta_file(
631 context->unbound_ctx, TRUST_ANCHOR_FILE);
632 }
633 return GETDNS_RETURN_GOOD;
634 }
635
636 /**
637 * Helper to dispatch the updated callback
638 */
639 static void
640 dispatch_updated(struct getdns_context *context, uint16_t item)
641 {
642 if (context->update_callback) {
643 context->update_callback(context, item);
644 }
645 }
646
647 /*
648 * getdns_context_set_resolution_type
649 *
650 */
651 getdns_return_t
652 getdns_context_set_resolution_type(struct getdns_context *context,
653 getdns_resolution_t value)
654 {
655 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
656 if (value != GETDNS_RESOLUTION_STUB && value != GETDNS_RESOLUTION_RECURSING) {
657 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
658 }
659 if (context->resolution_type_set != 0) {
660 /* already setup */
661 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
662 }
663 context->resolution_type = value;
664
665 dispatch_updated(context, GETDNS_CONTEXT_CODE_RESOLUTION_TYPE);
666
667 return GETDNS_RETURN_GOOD;
668 } /* getdns_context_set_resolution_type */
669
670 /*
671 * getdns_context_set_namespaces
672 *
673 */
674 getdns_return_t
675 getdns_context_set_namespaces(struct getdns_context *context,
676 size_t namespace_count, getdns_namespace_t *namespaces)
677 {
678 size_t i;
679
680 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
681 if (namespace_count == 0 || namespaces == NULL) {
682 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
683 }
684 if (context->resolution_type_set != 0) {
685 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
686 }
687
688 for(i=0; i<namespace_count; i++)
689 {
690 if( namespaces[i] != GETDNS_NAMESPACE_DNS
691 && namespaces[i] != GETDNS_NAMESPACE_LOCALNAMES
692 && namespaces[i] != GETDNS_NAMESPACE_NETBIOS
693 && namespaces[i] != GETDNS_NAMESPACE_MDNS
694 && namespaces[i] != GETDNS_NAMESPACE_NIS)
695 return GETDNS_RETURN_INVALID_PARAMETER;
696 }
697
698 GETDNS_FREE(context->my_mf, context->namespaces);
699
700 /** duplicate **/
701 context->namespaces = GETDNS_XMALLOC(context->my_mf, getdns_namespace_t,
702 namespace_count);
703 memcpy(context->namespaces, namespaces,
704 namespace_count * sizeof(getdns_namespace_t));
705 context->namespace_count = namespace_count;
706 dispatch_updated(context, GETDNS_CONTEXT_CODE_NAMESPACES);
707
708 return GETDNS_RETURN_GOOD;
709 } /* getdns_context_set_namespaces */
710
711 static getdns_return_t
712 set_ub_dns_transport(struct getdns_context* context,
713 getdns_transport_t value) {
714 switch (value) {
715 case GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP:
716 set_ub_string_opt(context, "do-udp", "yes");
717 set_ub_string_opt(context, "do-tcp", "yes");
718 break;
719 case GETDNS_TRANSPORT_UDP_ONLY:
720 set_ub_string_opt(context, "do-udp", "yes");
721 set_ub_string_opt(context, "do-tcp", "no");
722 break;
723 case GETDNS_TRANSPORT_TCP_ONLY:
724 set_ub_string_opt(context, "do-udp", "no");
725 set_ub_string_opt(context, "do-tcp", "yes");
726 break;
727 default:
728 /* TODO GETDNS_CONTEXT_TCP_ONLY_KEEP_CONNECTIONS_OPEN */
729 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
730 }
731 return GETDNS_RETURN_GOOD;
732 }
733 /*
734 * getdns_context_set_dns_transport
735 *
736 */
737 getdns_return_t
738 getdns_context_set_dns_transport(struct getdns_context *context,
739 getdns_transport_t value)
740 {
741 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
742 if (set_ub_dns_transport(context, value) != GETDNS_RETURN_GOOD) {
743 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
744 }
745 if (value != context->dns_transport) {
746 context->dns_transport = value;
747 dispatch_updated(context, GETDNS_CONTEXT_CODE_DNS_TRANSPORT);
748 }
749
750 return GETDNS_RETURN_GOOD;
751 } /* getdns_context_set_dns_transport */
752
753 static void
754 set_ub_limit_outstanding_queries(struct getdns_context* context, uint16_t value) {
755 /* num-queries-per-thread */
756 set_ub_number_opt(context, "num-queries-per-thread", value);
757 }
758 /*
759 * getdns_context_set_limit_outstanding_queries
760 *
761 */
762 getdns_return_t
763 getdns_context_set_limit_outstanding_queries(struct getdns_context *context,
764 uint16_t limit)
765 {
766 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
767 set_ub_limit_outstanding_queries(context, limit);
768 if (limit != context->limit_outstanding_queries) {
769 context->limit_outstanding_queries = limit;
770 dispatch_updated(context,
771 GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES);
772 }
773
774 return GETDNS_RETURN_GOOD;
775 } /* getdns_context_set_limit_outstanding_queries */
776
777 /*
778 * getdns_context_set_timeout
779 *
780 */
781 getdns_return_t
782 getdns_context_set_timeout(struct getdns_context *context, uint64_t timeout)
783 {
784 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
785
786 if (timeout == 0) {
787 return GETDNS_RETURN_INVALID_PARAMETER;
788 }
789
790 context->timeout = timeout;
791
792 dispatch_updated(context, GETDNS_CONTEXT_CODE_TIMEOUT);
793
794 return GETDNS_RETURN_GOOD;
795 } /* getdns_context_set_timeout */
796
797 /*
798 * getdns_context_set_follow_redirects
799 *
800 */
801 getdns_return_t
802 getdns_context_set_follow_redirects(struct getdns_context *context,
803 getdns_redirects_t value)
804 {
805 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
806 context->follow_redirects = value;
807 if (context->resolution_type_set != 0) {
808 /* already setup */
809 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
810 }
811
812 dispatch_updated(context, GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS);
813 return GETDNS_RETURN_GOOD;
814 } /* getdns_context_set_follow_redirects */
815
816 /*
817 * getdns_context_set_dns_root_servers
818 *
819 */
820 getdns_return_t
821 getdns_context_set_dns_root_servers(struct getdns_context *context,
822 struct getdns_list * addresses)
823 {
824 struct getdns_list *copy = NULL;
825 size_t count = 0;
826 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
827 if (context->resolution_type_set != 0) {
828 /* already setup */
829 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
830 }
831 if (addresses != NULL) {
832 if (getdns_list_copy(addresses, &copy) != GETDNS_RETURN_GOOD) {
833 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
834 }
835 addresses = copy;
836 getdns_list_get_length(addresses, &count);
837 if (count == 0) {
838 getdns_list_destroy(addresses);
839 addresses = NULL;
840 } else {
841 size_t i = 0;
842 getdns_return_t r = GETDNS_RETURN_GOOD;
843 /* validate and add ip str */
844 for (i = 0; i < count; ++i) {
845 struct getdns_dict *dict = NULL;
846 getdns_list_get_dict(addresses, i, &dict);
847 r = add_ip_str(dict);
848 if (r != GETDNS_RETURN_GOOD) {
849 break;
850 }
851 }
852 if (r != GETDNS_RETURN_GOOD) {
853 getdns_list_destroy(addresses);
854 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
855 }
856 }
857 }
858
859 getdns_list_destroy(context->dns_root_servers);
860 context->dns_root_servers = addresses;
861
862 dispatch_updated(context, GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS);
863
864 return GETDNS_RETURN_GOOD;
865 } /* getdns_context_set_dns_root_servers */
866
867 /*
868 * getdns_context_set_append_name
869 *
870 */
871 getdns_return_t
872 getdns_context_set_append_name(struct getdns_context *context,
873 getdns_append_name_t value)
874 {
875 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
876 if (value != GETDNS_APPEND_NAME_ALWAYS &&
877 value != GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE &&
878 value != GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE
879 && value != GETDNS_APPEND_NAME_NEVER) {
880 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
881 }
882
883 context->append_name = value;
884
885 dispatch_updated(context, GETDNS_CONTEXT_CODE_APPEND_NAME);
886
887 return GETDNS_RETURN_GOOD;
888 } /* getdns_context_set_append_name */
889
890 /*
891 * getdns_context_set_suffix
892 *
893 */
894 getdns_return_t
895 getdns_context_set_suffix(struct getdns_context *context, struct getdns_list * value)
896 {
897 struct getdns_list *copy = NULL;
898 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
899 if (context->resolution_type_set != 0) {
900 /* already setup */
901 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
902 }
903 if (value != NULL) {
904 if (getdns_list_copy(value, &copy) != GETDNS_RETURN_GOOD) {
905 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
906 }
907 value = copy;
908 }
909 getdns_list_destroy(context->suffix);
910 context->suffix = value;
911
912 dispatch_updated(context, GETDNS_CONTEXT_CODE_SUFFIX);
913
914 return GETDNS_RETURN_GOOD;
915 } /* getdns_context_set_suffix */
916
917 /*
918 * getdns_context_set_dnssec_trust_anchors
919 *
920 */
921 getdns_return_t
922 getdns_context_set_dnssec_trust_anchors(struct getdns_context *context,
923 struct getdns_list * value)
924 {
925 struct getdns_list *copy = NULL;
926 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
927 if (value != NULL) {
928 if (getdns_list_copy(value, &copy) != GETDNS_RETURN_GOOD) {
929 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
930 }
931 value = copy;
932 }
933 getdns_list_destroy(context->dnssec_trust_anchors);
934 context->dnssec_trust_anchors = value;
935
936 dispatch_updated(context, GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS);
937
938 return GETDNS_RETURN_GOOD;
939 } /* getdns_context_set_dnssec_trust_anchors */
940
941 static void
942 set_ub_dnssec_allowed_skew(struct getdns_context* context, uint32_t value) {
943 set_ub_number_opt(context, "val-sig-skew-min", value);
944 set_ub_number_opt(context, "val-sig-skew-max", value);
945 }
946 /*
947 * getdns_context_set_dnssec_allowed_skew
948 *
949 */
950 getdns_return_t
951 getdns_context_set_dnssec_allowed_skew(struct getdns_context *context,
952 uint32_t value)
953 {
954 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
955 set_ub_dnssec_allowed_skew(context, value);
956 if (value != context->dnssec_allowed_skew) {
957 context->dnssec_allowed_skew = value;
958 dispatch_updated(context, GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW);
959 }
960
961 return GETDNS_RETURN_GOOD;
962 } /* getdns_context_set_dnssec_allowed_skew */
963
964 /*
965 * getdns_context_set_upstream_recursive_servers
966 *
967 */
968 getdns_return_t
969 getdns_context_set_upstream_recursive_servers(struct getdns_context *context,
970 struct getdns_list * upstream_list)
971 {
972 size_t count = 0;
973 size_t i = 0;
974 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
975 RETURN_IF_NULL(upstream_list, GETDNS_RETURN_INVALID_PARAMETER);
976 getdns_return_t r = getdns_list_get_length(upstream_list, &count);
977 if (count == 0 || r != GETDNS_RETURN_GOOD) {
978 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
979 }
980 if (context->resolution_type_set != 0) {
981 /* already setup */
982 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
983 }
984 struct getdns_list *copy = NULL;
985 if (getdns_list_copy(upstream_list, &copy) != GETDNS_RETURN_GOOD) {
986 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
987 }
988 upstream_list = copy;
989 /* validate and add ip str */
990 for (i = 0; i < count; ++i) {
991 struct getdns_dict *dict = NULL;
992 getdns_list_get_dict(upstream_list, i, &dict);
993 r = add_ip_str(dict);
994 if (r != GETDNS_RETURN_GOOD) {
995 break;
996 }
997 }
998
999 if (r != GETDNS_RETURN_GOOD) {
1000 getdns_list_destroy(upstream_list);
1001 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
1002 }
1003
1004 getdns_list_destroy(context->upstream_list);
1005 context->upstream_list = upstream_list;
1006
1007 dispatch_updated(context,
1008 GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS);
1009
1010 return GETDNS_RETURN_GOOD;
1011 } /* getdns_context_set_upstream_recursive_servers */
1012
1013
1014 static void
1015 set_ub_edns_maximum_udp_payload_size(struct getdns_context* context,
1016 uint16_t value) {
1017 /* max-udp-size */
1018 set_ub_number_opt(context, "max-udp-size", value);
1019 }
1020 /*
1021 * getdns_context_set_edns_maximum_udp_payload_size
1022 *
1023 */
1024 getdns_return_t
1025 getdns_context_set_edns_maximum_udp_payload_size(struct getdns_context *context,
1026 uint16_t value)
1027 {
1028 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1029 /* check for < 512. uint16_t won't let it go above max) */
1030 if (value < 512) {
1031 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
1032 }
1033 set_ub_edns_maximum_udp_payload_size(context, value);
1034 if (value != context->edns_maximum_udp_payload_size) {
1035 context->edns_maximum_udp_payload_size = value;
1036 dispatch_updated(context,
1037 GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE);
1038 }
1039
1040 return GETDNS_RETURN_GOOD;
1041 } /* getdns_context_set_edns_maximum_udp_payload_size */
1042
1043 /*
1044 * getdns_context_set_edns_extended_rcode
1045 *
1046 */
1047 getdns_return_t
1048 getdns_context_set_edns_extended_rcode(struct getdns_context *context, uint8_t value)
1049 {
1050 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1051 context->edns_extended_rcode = value;
1052
1053 dispatch_updated(context, GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE);
1054
1055 return GETDNS_RETURN_GOOD;
1056 } /* getdns_context_set_edns_extended_rcode */
1057
1058 /*
1059 * getdns_context_set_edns_version
1060 *
1061 */
1062 getdns_return_t
1063 getdns_context_set_edns_version(struct getdns_context *context, uint8_t value)
1064 {
1065 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1066 context->edns_version = value;
1067
1068 dispatch_updated(context, GETDNS_CONTEXT_CODE_EDNS_VERSION);
1069
1070 return GETDNS_RETURN_GOOD;
1071 } /* getdns_context_set_edns_version */
1072
1073 /*
1074 * getdns_context_set_edns_do_bit
1075 *
1076 */
1077 getdns_return_t
1078 getdns_context_set_edns_do_bit(struct getdns_context *context, uint8_t value)
1079 {
1080 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1081 /* only allow 1 */
1082 if (value != 1) {
1083 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
1084 }
1085
1086 context->edns_do_bit = value;
1087
1088 dispatch_updated(context, GETDNS_CONTEXT_CODE_EDNS_DO_BIT);
1089
1090 return GETDNS_RETURN_GOOD;
1091 } /* getdns_context_set_edns_do_bit */
1092
1093 /*
1094 * getdns_context_set_extended_memory_functions
1095 *
1096 */
1097 getdns_return_t
1098 getdns_context_set_extended_memory_functions(
1099 struct getdns_context *context,
1100 void *userarg,
1101 void *(*malloc) (void *userarg, size_t),
1102 void *(*realloc) (void *userarg, void *, size_t),
1103 void (*free) (void *userarg, void *)
1104 )
1105 {
1106 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1107 if (!malloc || !realloc || !free)
1108 return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
1109
1110 context->mf.mf_arg = userarg;
1111 context->mf.mf.ext.malloc = malloc;
1112 context->mf.mf.ext.realloc = realloc;
1113 context->mf.mf.ext.free = free;
1114
1115 dispatch_updated(context, GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS);
1116
1117 return GETDNS_RETURN_GOOD;
1118 } /* getdns_context_set_extended_memory_functions*/
1119
1120
1121 /*
1122 * getdns_context_set_memory_functions
1123 *
1124 */
1125 getdns_return_t
1126 getdns_context_set_memory_functions(struct getdns_context *context,
1127 void *(*malloc) (size_t),
1128 void *(*realloc) (void *, size_t),
1129 void (*free) (void *)
1130 )
1131 {
1132 mf_union mf;
1133 mf.pln.malloc = malloc;
1134 mf.pln.realloc = realloc;
1135 mf.pln.free = free;
1136 return getdns_context_set_extended_memory_functions(
1137 context, MF_PLAIN, mf.ext.malloc, mf.ext.realloc, mf.ext.free);
1138 } /* getdns_context_set_memory_functions*/
1139
1140 /* cancel the request */
1141 static void
1142 cancel_dns_req(getdns_dns_req * req)
1143 {
1144 getdns_network_req *netreq = req->first_req;
1145 while (netreq) {
1146 if (netreq->state == NET_REQ_IN_FLIGHT) {
1147 /* for ev based ub, this should always prevent
1148 * the callback from firing */
1149 ub_cancel(req->context->unbound_ctx, netreq->unbound_id);
1150 netreq->state = NET_REQ_CANCELED;
1151 } else if (netreq->state == NET_REQ_NOT_SENT) {
1152 netreq->state = NET_REQ_CANCELED;
1153 }
1154 netreq = netreq->next;
1155 }
1156 req->canceled = 1;
1157 }
1158
1159 getdns_return_t
1160 getdns_context_cancel_request(struct getdns_context *context,
1161 getdns_transaction_t transaction_id, int fire_callback)
1162 {
1163 getdns_dns_req *req = NULL;
1164 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1165
1166 /* delete the node from the tree */
1167 ldns_rbnode_t *node = ldns_rbtree_delete(context->outbound_requests,
1168 &transaction_id);
1169
1170 if (!node) {
1171 return GETDNS_RETURN_UNKNOWN_TRANSACTION;
1172 }
1173 req = (getdns_dns_req *) node->data;
1174 /* do the cancel */
1175
1176 cancel_dns_req(req);
1177
1178 if (fire_callback) {
1179 getdns_callback_t cb = NULL;
1180 void *user_pointer = NULL;
1181
1182 cb = req->user_callback;
1183 user_pointer = req->user_pointer;
1184
1185 /* fire callback */
1186 cb(context,
1187 GETDNS_CALLBACK_CANCEL,
1188 NULL, user_pointer, transaction_id);
1189 }
1190 /* clean up */
1191 GETDNS_FREE(context->my_mf, node);
1192 dns_req_free(req);
1193 return GETDNS_RETURN_GOOD;
1194 }
1195
1196 /*
1197 * getdns_cancel_callback
1198 *
1199 */
1200 getdns_return_t
1201 getdns_cancel_callback(struct getdns_context *context,
1202 getdns_transaction_t transaction_id)
1203 {
1204 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1205 getdns_return_t r = getdns_context_cancel_request(context, transaction_id, 1);
1206 if (context->extension) {
1207 context->extension->request_count_changed(context,
1208 context->outbound_requests->count, context->extension_data);
1209 }
1210 return r;
1211 } /* getdns_cancel_callback */
1212
1213 static getdns_return_t
1214 ub_setup_stub(struct ub_ctx *ctx, struct getdns_list * upstreams)
1215 {
1216 size_t i;
1217 size_t count;
1218 struct getdns_dict *dict;
1219 struct getdns_bindata *address_string;
1220 getdns_return_t r;
1221
1222 r = getdns_list_get_length(upstreams, &count);
1223 if (r != GETDNS_RETURN_GOOD)
1224 return r;
1225
1226 if (count == 0)
1227 return GETDNS_RETURN_BAD_CONTEXT;
1228
1229 /* reset forwarding servers */
1230 (void) ub_ctx_set_fwd(ctx, NULL);
1231 for (i = 0; i < count; ++i) {
1232 r = getdns_list_get_dict(upstreams, i, &dict);
1233 if (r != GETDNS_RETURN_GOOD)
1234 break;
1235
1236 r = getdns_dict_get_bindata(dict, GETDNS_STR_ADDRESS_STRING,
1237 &address_string);
1238 if (r != GETDNS_RETURN_GOOD)
1239 break;
1240
1241 (void) ub_ctx_set_fwd(ctx, (char *)address_string->data);
1242 }
1243 /* Allow lookups of:
1244 */
1245 /* - localhost */
1246 (void)ub_ctx_zone_remove(ctx, "localhost.");
1247
1248 /* - reverse IPv4 loopback */
1249 (void)ub_ctx_zone_remove(ctx, "127.in-addr.arpa.");
1250
1251 /* - reverse IPv6 loopback */
1252 (void)ub_ctx_zone_remove(ctx, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0."
1253 "0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.");
1254
1255 /* - reverse RFC1918 local use zones */
1256 (void)ub_ctx_zone_remove(ctx, "10.in-addr.arpa.");
1257 (void)ub_ctx_zone_remove(ctx, "16.172.in-addr.arpa.");
1258 (void)ub_ctx_zone_remove(ctx, "17.172.in-addr.arpa.");
1259 (void)ub_ctx_zone_remove(ctx, "18.172.in-addr.arpa.");
1260 (void)ub_ctx_zone_remove(ctx, "19.172.in-addr.arpa.");
1261 (void)ub_ctx_zone_remove(ctx, "20.172.in-addr.arpa.");
1262 (void)ub_ctx_zone_remove(ctx, "21.172.in-addr.arpa.");
1263 (void)ub_ctx_zone_remove(ctx, "22.172.in-addr.arpa.");
1264 (void)ub_ctx_zone_remove(ctx, "23.172.in-addr.arpa.");
1265 (void)ub_ctx_zone_remove(ctx, "24.172.in-addr.arpa.");
1266 (void)ub_ctx_zone_remove(ctx, "25.172.in-addr.arpa.");
1267 (void)ub_ctx_zone_remove(ctx, "26.172.in-addr.arpa.");
1268 (void)ub_ctx_zone_remove(ctx, "27.172.in-addr.arpa.");
1269 (void)ub_ctx_zone_remove(ctx, "28.172.in-addr.arpa.");
1270 (void)ub_ctx_zone_remove(ctx, "29.172.in-addr.arpa.");
1271 (void)ub_ctx_zone_remove(ctx, "30.172.in-addr.arpa.");
1272 (void)ub_ctx_zone_remove(ctx, "31.172.in-addr.arpa.");
1273 (void)ub_ctx_zone_remove(ctx, "168.192.in-addr.arpa.");
1274
1275 /* - reverse RFC3330 IP4 this, link-local, testnet and broadcast */
1276 (void)ub_ctx_zone_remove(ctx, "0.in-addr.arpa.");
1277 (void)ub_ctx_zone_remove(ctx, "254.169.in-addr.arpa.");
1278 (void)ub_ctx_zone_remove(ctx, "2.0.192.in-addr.arpa.");
1279 (void)ub_ctx_zone_remove(ctx, "100.51.198.in-addr.arpa.");
1280 (void)ub_ctx_zone_remove(ctx, "113.0.203.in-addr.arpa.");
1281 (void)ub_ctx_zone_remove(ctx, "255.255.255.255.in-addr.arpa.");
1282
1283 /* - reverse RFC4291 IP6 unspecified */
1284 (void)ub_ctx_zone_remove(ctx, "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0."
1285 "0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.");
1286
1287 /* - reverse RFC4193 IPv6 Locally Assigned Local Addresses */
1288 (void)ub_ctx_zone_remove(ctx, "D.F.ip6.arpa.");
1289
1290 /* - reverse RFC4291 IPv6 Link Local Addresses */
1291 (void)ub_ctx_zone_remove(ctx, "8.E.F.ip6.arpa.");
1292 (void)ub_ctx_zone_remove(ctx, "9.E.F.ip6.arpa.");
1293 (void)ub_ctx_zone_remove(ctx, "A.E.F.ip6.arpa.");
1294 (void)ub_ctx_zone_remove(ctx, "B.E.F.ip6.arpa.");
1295
1296 /* - reverse IPv6 Example Prefix */
1297 (void)ub_ctx_zone_remove(ctx, "8.B.D.0.1.0.0.2.ip6.arpa.");
1298
1299 return r;
1300 }
1301
1302 static getdns_return_t
1303 priv_getdns_ns_dns_setup(struct getdns_context *context)
1304 {
1305 assert(context);
1306
1307 switch (context->resolution_type) {
1308 case GETDNS_RESOLUTION_STUB:
1309 return ub_setup_stub(context->unbound_ctx,
1310 context->upstream_list);
1311
1312 case GETDNS_RESOLUTION_RECURSING:
1313 /* TODO: use the root servers via root hints file */
1314 (void) ub_ctx_set_fwd(context->unbound_ctx, NULL);
1315 return GETDNS_RETURN_GOOD;
1316 }
1317 return GETDNS_RETURN_BAD_CONTEXT;
1318 }
1319
1320 getdns_return_t
1321 getdns_context_prepare_for_resolution(struct getdns_context *context,
1322 int usenamespaces)
1323 {
1324 int i;
1325 getdns_return_t r;
1326
1327 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1328 if (context->destroying) {
1329 return GETDNS_RETURN_BAD_CONTEXT;
1330 }
1331 if (context->resolution_type_set == context->resolution_type)
1332 /* already set and no config changes
1333 * have caused this to be bad.
1334 */
1335 return GETDNS_RETURN_GOOD;
1336
1337 /* TODO: respect namespace order (unbound always uses local first if cfg
1338 * the spec calls for us to treat the namespace list as ordered
1339 * so we need to respect that order
1340 */
1341
1342
1343 if (! usenamespaces) {
1344 r = priv_getdns_ns_dns_setup(context);
1345 if (r == GETDNS_RETURN_GOOD)
1346 context->resolution_type_set = context->resolution_type;
1347 return r;
1348 }
1349
1350 r = GETDNS_RETURN_GOOD;
1351 for (i = 0; i < context->namespace_count; i++) {
1352 switch (context->namespaces[i]) {
1353 case GETDNS_NAMESPACE_LOCALNAMES:
1354 (void) ub_ctx_hosts(context->unbound_ctx, NULL);
1355 break;
1356
1357 case GETDNS_NAMESPACE_DNS:
1358 r = priv_getdns_ns_dns_setup(context);
1359 break;
1360
1361 default:
1362 r = GETDNS_RETURN_BAD_CONTEXT;
1363 break;
1364 }
1365 if (r != GETDNS_RETURN_GOOD)
1366 return r; /* try again later (resolution_type_set) */
1367 }
1368 context->resolution_type_set = context->resolution_type;
1369 return r;
1370 } /* getdns_context_prepare_for_resolution */
1371
1372 getdns_return_t
1373 getdns_context_track_outbound_request(getdns_dns_req * req)
1374 {
1375 if (!req) {
1376 return GETDNS_RETURN_GENERIC_ERROR;
1377 }
1378 struct getdns_context *context = req->context;
1379 ldns_rbnode_t *node = GETDNS_MALLOC(context->my_mf, ldns_rbnode_t);
1380 if (!node) {
1381 return GETDNS_RETURN_GENERIC_ERROR;
1382 }
1383 node->key = &(req->trans_id);
1384 node->data = req;
1385 if (!ldns_rbtree_insert(context->outbound_requests, node)) {
1386 /* free the node */
1387 GETDNS_FREE(context->my_mf, node);
1388 return GETDNS_RETURN_GENERIC_ERROR;
1389 }
1390 if (context->extension) {
1391 context->extension->request_count_changed(context,
1392 context->outbound_requests->count, context->extension_data);
1393 }
1394 return GETDNS_RETURN_GOOD;
1395 }
1396
1397 getdns_return_t
1398 getdns_context_clear_outbound_request(getdns_dns_req * req)
1399 {
1400 if (!req) {
1401 return GETDNS_RETURN_GENERIC_ERROR;
1402 }
1403 struct getdns_context *context = req->context;
1404 ldns_rbnode_t *node = ldns_rbtree_delete(context->outbound_requests,
1405 &(req->trans_id));
1406 if (node) {
1407 GETDNS_FREE(context->my_mf, node);
1408 }
1409 return GETDNS_RETURN_GOOD;
1410 }
1411
1412
1413
1414 char *
1415 getdns_strdup(const struct mem_funcs *mfs, const char *s)
1416 {
1417 size_t sz = strlen(s) + 1;
1418 char *r = GETDNS_XMALLOC(*mfs, char, sz);
1419 if (r)
1420 return memcpy(r, s, sz);
1421 else
1422 return NULL;
1423 }
1424
1425 struct getdns_bindata *
1426 getdns_bindata_copy(struct mem_funcs *mfs,
1427 const struct getdns_bindata *src)
1428 {
1429 struct getdns_bindata *dst;
1430
1431 if (!src)
1432 return NULL;
1433
1434 dst = GETDNS_MALLOC(*mfs, struct getdns_bindata);
1435 if (!dst)
1436 return NULL;
1437
1438 dst->size = src->size;
1439 dst->data = GETDNS_XMALLOC(*mfs, uint8_t, src->size);
1440 if (!dst->data) {
1441 GETDNS_FREE(*mfs, dst);
1442 return NULL;
1443 }
1444 (void) memcpy(dst->data, src->data, src->size);
1445 return dst;
1446 }
1447
1448 void
1449 getdns_bindata_destroy(struct mem_funcs *mfs,
1450 struct getdns_bindata *bindata)
1451 {
1452 if (!bindata)
1453 return;
1454 GETDNS_FREE(*mfs, bindata->data);
1455 GETDNS_FREE(*mfs, bindata);
1456 }
1457
1458 /* get the fd */
1459 int getdns_context_fd(struct getdns_context* context) {
1460 RETURN_IF_NULL(context, -1);
1461 return ub_fd(context->unbound_ctx);
1462 }
1463
1464 uint32_t
1465 getdns_context_get_num_pending_requests(struct getdns_context* context,
1466 struct timeval* next_timeout) {
1467 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1468 uint32_t r = context->outbound_requests->count;
1469 if (r > 0) {
1470 if (!context->extension && next_timeout) {
1471 /* default is 1 second */
1472 next_timeout->tv_sec = 1;
1473 next_timeout->tv_usec = 0;
1474 struct timeval now;
1475 if (gettimeofday(&now, NULL) == 0) {
1476 /* get the first timeout */
1477 ldns_rbnode_t* first = ldns_rbtree_first(context->timeouts_by_time);
1478 if (first) {
1479 getdns_timeout_data_t* timeout_data = (getdns_timeout_data_t*) first->data;
1480 /* subtract next_timeout from now */
1481 if (timeout_data->timeout_time.tv_sec > now.tv_sec ||
1482 (timeout_data->timeout_time.tv_sec == now.tv_sec &&
1483 timeout_data->timeout_time.tv_usec >= now.tv_usec)) {
1484 next_timeout->tv_sec = timeout_data->timeout_time.tv_sec - now.tv_sec;
1485 if (timeout_data->timeout_time.tv_usec < now.tv_usec) {
1486 /* we only enter this condition when timeout_data.tv_sec > now.tv_sec */
1487 next_timeout->tv_usec = (timeout_data->timeout_time.tv_usec + 100000) - now.tv_usec;
1488 next_timeout->tv_sec--;
1489 } else {
1490 next_timeout->tv_usec = timeout_data->timeout_time.tv_usec - now.tv_usec;
1491 }
1492 } else {
1493 /* timeout passed already */
1494 /* usec already 0 per setting default */
1495 next_timeout->tv_sec = 0;
1496 }
1497 }
1498 }
1499 }
1500 }
1501 return r;
1502 }
1503
1504 /* process async reqs */
1505 getdns_return_t getdns_context_process_async(struct getdns_context* context) {
1506 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1507 if (ub_poll(context->unbound_ctx)) {
1508 if (ub_process(context->unbound_ctx) != 0) {
1509 /* need an async return code? */
1510 return GETDNS_RETURN_GENERIC_ERROR;
1511 }
1512 }
1513 if (context->extension != NULL) {
1514 /* no need to process timeouts since it is delegated
1515 * to the extension */
1516 return GETDNS_RETURN_GOOD;
1517 }
1518 getdns_timeout_data_t key;
1519 /* set to 0 so it is the last timeout if we have
1520 * two with the same time */
1521 key.transaction_id = 0;
1522 if (gettimeofday(&key.timeout_time, NULL) != 0) {
1523 return GETDNS_RETURN_GENERIC_ERROR;
1524 }
1525 ldns_rbnode_t* next_timeout = ldns_rbtree_first(context->timeouts_by_time);
1526 while (next_timeout) {
1527 getdns_timeout_data_t* timeout_data = (getdns_timeout_data_t*) next_timeout->data;
1528 if (timeout_cmp(timeout_data, &key) > 0) {
1529 /* no more timeouts need to be fired. */
1530 break;
1531 }
1532 /* get the next_timeout */
1533 next_timeout = ldns_rbtree_next(next_timeout);
1534 /* delete the node */
1535 /* timeout data and the timeouts_by_id node are freed in the clear_timeout */
1536 ldns_rbnode_t* to_del = ldns_rbtree_delete(context->timeouts_by_time, timeout_data);
1537 if (to_del) {
1538 /* should always exist .. */
1539 GETDNS_FREE(context->my_mf, to_del);
1540 }
1541
1542 /* fire the timeout */
1543 timeout_data->callback(timeout_data->userarg);
1544 }
1545
1546 return GETDNS_RETURN_GOOD;
1547 }
1548
1549 typedef struct timeout_accumulator {
1550 getdns_transaction_t* ids;
1551 int idx;
1552 } timeout_accumulator;
1553
1554 static void
1555 accumulate_outstanding_transactions(ldns_rbnode_t* node, void* arg) {
1556 timeout_accumulator* acc = (timeout_accumulator*) arg;
1557 acc->ids[acc->idx] = *((getdns_transaction_t*) node->key);
1558 acc->idx++;
1559 }
1560
1561 static void
1562 cancel_outstanding_requests(struct getdns_context* context, int fire_callback) {
1563 if (context->outbound_requests->count > 0) {
1564 timeout_accumulator acc;
1565 int i;
1566 acc.idx = 0;
1567 acc.ids = GETDNS_XMALLOC(context->my_mf, getdns_transaction_t, context->outbound_requests->count);
1568 ldns_traverse_postorder(context->outbound_requests, accumulate_outstanding_transactions, &acc);
1569 for (i = 0; i < acc.idx; ++i) {
1570 getdns_context_cancel_request(context, acc.ids[i], fire_callback);
1571 }
1572 GETDNS_FREE(context->my_mf, acc.ids);
1573 }
1574 }
1575
1576 getdns_return_t
1577 getdns_extension_detach_eventloop(struct getdns_context* context)
1578 {
1579 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1580 getdns_return_t r = GETDNS_RETURN_GOOD;
1581 if (context->extension) {
1582 /* cancel all outstanding requests */
1583 cancel_outstanding_requests(context, 1);
1584 r = context->extension->cleanup_data(context, context->extension_data);
1585 if (r != GETDNS_RETURN_GOOD) {
1586 return r;
1587 }
1588 context->extension = NULL;
1589 context->extension_data = NULL;
1590 }
1591 return r;
1592 }
1593
1594 getdns_return_t
1595 getdns_extension_set_eventloop(struct getdns_context* context,
1596 getdns_eventloop_extension* extension, void* extension_data)
1597 {
1598 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1599 RETURN_IF_NULL(extension, GETDNS_RETURN_INVALID_PARAMETER);
1600 getdns_return_t r = getdns_extension_detach_eventloop(context);
1601 if (r != GETDNS_RETURN_GOOD) {
1602 return r;
1603 }
1604 context->extension = extension;
1605 context->extension_data = extension_data;
1606 return GETDNS_RETURN_GOOD;
1607 }
1608
1609 getdns_return_t
1610 getdns_context_schedule_timeout(struct getdns_context* context,
1611 getdns_transaction_t id, uint16_t timeout, getdns_timeout_callback callback,
1612 void* userarg) {
1613 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1614 RETURN_IF_NULL(callback, GETDNS_RETURN_INVALID_PARAMETER);
1615 getdns_return_t result;
1616 /* create a timeout */
1617 getdns_timeout_data_t* timeout_data = GETDNS_MALLOC(context->my_mf, getdns_timeout_data_t);
1618 if (!timeout_data) {
1619 return GETDNS_RETURN_GENERIC_ERROR;
1620 }
1621 timeout_data->context = context;
1622 timeout_data->transaction_id = id;
1623 timeout_data->callback = callback;
1624 timeout_data->userarg = userarg;
1625 timeout_data->extension_timer = NULL;
1626
1627 /* insert into transaction tree */
1628 ldns_rbnode_t *node = GETDNS_MALLOC(context->my_mf, ldns_rbnode_t);
1629 if (!node) {
1630 GETDNS_FREE(context->my_mf, timeout_data);
1631 return GETDNS_RETURN_GENERIC_ERROR;
1632 }
1633 node->key = &(timeout_data->transaction_id);
1634 node->data = timeout_data;
1635 node->left = NULL;
1636 node->right = NULL;
1637 if (!ldns_rbtree_insert(context->timeouts_by_id, node)) {
1638 /* free the node */
1639 GETDNS_FREE(context->my_mf, timeout_data);
1640 GETDNS_FREE(context->my_mf, node);
1641 return GETDNS_RETURN_GENERIC_ERROR;
1642 }
1643
1644 if (context->extension) {
1645 result = context->extension->schedule_timeout(context, context->extension_data,
1646 timeout, timeout_data, &(timeout_data->extension_timer));
1647 } else {
1648 result = GETDNS_RETURN_GENERIC_ERROR;
1649 if (gettimeofday(&timeout_data->timeout_time, NULL) == 0) {
1650 /* timeout is in millis */
1651 uint16_t num_secs = timeout / 1000;
1652 uint16_t num_usecs = (timeout % 1000) * 1000;
1653 timeout_data->timeout_time.tv_usec += num_usecs;
1654 /* overflow check */
1655 if (timeout_data->timeout_time.tv_usec > 1000000) {
1656 timeout_data->timeout_time.tv_usec -= 1000000;
1657 num_secs++;
1658 }
1659 timeout_data->timeout_time.tv_sec += num_secs;
1660
1661 ldns_rbnode_t* id_node = GETDNS_MALLOC(context->my_mf, ldns_rbnode_t);
1662 if (id_node) {
1663 id_node->key = timeout_data;
1664 id_node->data = timeout_data;
1665 id_node->left = NULL;
1666 id_node->right = NULL;
1667 if (!ldns_rbtree_insert(context->timeouts_by_time, id_node)) {
1668 GETDNS_FREE(context->my_mf, id_node);
1669 } else {
1670 result = GETDNS_RETURN_GOOD;
1671 }
1672 }
1673 }
1674 }
1675 if (result != GETDNS_RETURN_GOOD) {
1676 GETDNS_FREE(context->my_mf, timeout_data);
1677 GETDNS_FREE(context->my_mf, node);
1678 }
1679 return result;
1680 }
1681
1682 getdns_return_t
1683 getdns_context_clear_timeout(struct getdns_context* context,
1684 getdns_transaction_t id) {
1685 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1686 /* find the timeout_data by id */
1687 ldns_rbnode_t* node = ldns_rbtree_delete(context->timeouts_by_id, &id);
1688 if (!node) {
1689 return GETDNS_RETURN_UNKNOWN_TRANSACTION;
1690 }
1691 getdns_timeout_data_t* timeout_data = (getdns_timeout_data_t*) node->data;
1692 GETDNS_FREE(context->my_mf, node);
1693 if (context->extension) {
1694 context->extension->clear_timeout(context, context->extension_data,
1695 timeout_data->extension_timer);
1696 } else {
1697 /* make sure it is removed from the timeout node */
1698 ldns_rbnode_t* to_del = ldns_rbtree_delete(context->timeouts_by_time, timeout_data);
1699 if (to_del) {
1700 GETDNS_FREE(context->my_mf, to_del);
1701 }
1702 }
1703 GETDNS_FREE(context->my_mf, timeout_data);
1704 return GETDNS_RETURN_GOOD;
1705 }
1706
1707 void*
1708 getdns_context_get_extension_data(struct getdns_context* context) {
1709 RETURN_IF_NULL(context, NULL);
1710 return context->extension_data;
1711 }
1712
1713 static inline getdns_return_t
1714 priv_dict_set_list_if_not_null(getdns_dict* dict,
1715 const char* name, getdns_list* list) {
1716 if (!list) {
1717 return GETDNS_RETURN_GOOD;
1718 }
1719 return getdns_dict_set_list(dict, name, list);
1720 }
1721
1722 static getdns_dict*
1723 priv_get_context_settings(getdns_context* context) {
1724 getdns_return_t r = GETDNS_RETURN_GOOD;
1725 getdns_dict* result = getdns_dict_create_with_context(context);
1726 if (!result) {
1727 return NULL;
1728 }
1729 /* int fields */
1730 r = getdns_dict_set_int(result, "dns_transport", context->dns_transport);
1731 r |= getdns_dict_set_int(result, "timeout", context->timeout);
1732 r |= getdns_dict_set_int(result, "limit_outstanding_queries", context->limit_outstanding_queries);
1733 r |= getdns_dict_set_int(result, "dnssec_allowed_skew", context->dnssec_allowed_skew);
1734 r |= getdns_dict_set_int(result, "follow_redirects", context->follow_redirects);
1735 r |= getdns_dict_set_int(result, "edns_maximum_udp_payload_size", context->edns_maximum_udp_payload_size);
1736 r |= getdns_dict_set_int(result, "edns_extended_rcode", context->edns_extended_rcode);
1737 r |= getdns_dict_set_int(result, "edns_version", context->edns_version);
1738 r |= getdns_dict_set_int(result, "edns_do_bit", context->edns_do_bit);
1739 r |= getdns_dict_set_int(result, "append_name", context->append_name);
1740 /* list fields */
1741 r |= priv_dict_set_list_if_not_null(result, "suffix", context->suffix);
1742 r |= priv_dict_set_list_if_not_null(result, "upstream_recursive_servers", context->upstream_list);
1743 if (context->namespace_count > 0) {
1744 /* create a namespace list */
1745 size_t i;
1746 getdns_list* namespaces = getdns_list_create_with_context(context);
1747 if (namespaces) {
1748 for (i = 0; i < context->namespace_count; ++i) {
1749 r |= getdns_list_set_int(namespaces, i, context->namespaces[i]);
1750 }
1751 r |= getdns_dict_set_list(result, "namespaces", namespaces);
1752 }
1753 }
1754 if (r != GETDNS_RETURN_GOOD) {
1755 getdns_dict_destroy(result);
1756 result = NULL;
1757 }
1758 return result;
1759 }
1760
1761 getdns_dict*
1762 getdns_context_get_api_information(getdns_context* context) {
1763 getdns_return_t r = GETDNS_RETURN_GOOD;
1764 getdns_dict* result = getdns_dict_create_with_context(context);
1765 getdns_dict* settings;
1766 if (!result) {
1767 return NULL;
1768 }
1769 r = getdns_dict_util_set_string(result, "version_string", PACKAGE_VERSION);
1770 r |= getdns_dict_util_set_string(result, "implementation_string", PACKAGE_URL);
1771 r |= getdns_dict_set_int(result, "resolver_type", context->resolution_type);
1772 settings = priv_get_context_settings(context);
1773 r |= getdns_dict_set_dict(result, "all_context", settings);
1774 getdns_dict_destroy(settings);
1775 if (r != GETDNS_RETURN_GOOD) {
1776 getdns_dict_destroy(result);
1777 result = NULL;
1778 }
1779 return result;
1780 }
1781
1782 getdns_return_t
1783 getdns_context_set_return_dnssec_status(getdns_context* context, int enabled) {
1784 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
1785 if (enabled != GETDNS_EXTENSION_TRUE ||
1786 enabled != GETDNS_EXTENSION_FALSE) {
1787 return GETDNS_RETURN_INVALID_PARAMETER;
1788 }
1789 context->return_dnssec_status = enabled;
1790 return GETDNS_RETURN_GOOD;
1791 }
1792
1793 /* context.c */
0 /**
1 *
2 * \file context.h
3 * @brief getdns context management functions
4 *
5 * Originally taken from the getdns API description pseudo implementation.
6 *
7 */
8
9 /*
10 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * * Neither the names of the copyright holders nor the
21 * names of its contributors may be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 #ifndef _GETDNS_CONTEXT_H_
37 #define _GETDNS_CONTEXT_H_
38
39 #include <getdns/getdns.h>
40 #include <getdns/getdns_extra.h>
41 #include "types-internal.h"
42
43 struct getdns_dns_req;
44 struct ldns_rbtree_t;
45 struct ub_ctx;
46
47 #define GETDNS_FN_RESOLVCONF "/etc/resolv.conf"
48 #define GETDNS_FN_HOSTS "/etc/hosts"
49
50 enum filechgs { GETDNS_FCHG_ERRORS = -1
51 , GETDNS_FCHG_NOERROR = 0
52 , GETDNS_FCHG_NOCHANGES = 0
53 , GETDNS_FCHG_MTIME = 1
54 , GETDNS_FCHG_CTIME = 2};
55
56 /** function pointer typedefs */
57 typedef void (*getdns_update_callback) (struct getdns_context *,
58 getdns_context_code_t);
59
60 /* internal use only for detecting changes to system files */
61 struct filechg {
62 char *fn;
63 int changes;
64 int errors;
65 struct stat *prevstat;
66 };
67
68 struct getdns_context {
69
70 /* Context values */
71 getdns_resolution_t resolution_type;
72 getdns_namespace_t *namespaces;
73 int namespace_count;
74 uint64_t timeout;
75 getdns_redirects_t follow_redirects;
76 struct getdns_list *dns_root_servers;
77 getdns_append_name_t append_name;
78 struct getdns_list *suffix;
79 struct getdns_list *dnssec_trust_anchors;
80 struct getdns_list *upstream_list;
81 getdns_transport_t dns_transport;
82 uint16_t limit_outstanding_queries;
83 uint32_t dnssec_allowed_skew;
84
85 uint8_t edns_extended_rcode;
86 uint8_t edns_version;
87 uint8_t edns_do_bit;
88 uint16_t edns_maximum_udp_payload_size;
89
90 getdns_update_callback update_callback;
91
92 int destroying;
93
94 struct mem_funcs mf;
95 struct mem_funcs my_mf;
96
97 /* The underlying unbound contexts that do
98 * the real work */
99 struct ub_ctx *unbound_ctx;
100 int has_ta; /* No DNSSEC without trust anchor */
101 int return_dnssec_status;
102
103 /* which resolution type the contexts are configured for
104 * 0 means nothing set
105 */
106 getdns_resolution_t resolution_type_set;
107
108 /*
109 * outbound requests -> transaction to getdns_dns_req
110 */
111 struct ldns_rbtree_t *outbound_requests;
112
113 /*
114 * Event loop extension functions
115 * These structs are static and should never be freed
116 * since they are just a collection of function pointers
117 */
118 getdns_eventloop_extension* extension;
119 /*
120 * Extension data that will be freed by the functions
121 * in the extension struct
122 */
123 void* extension_data;
124
125 /*
126 * Timeout info one tree to manage timeout data
127 * keyed by transaction id. Second to manage by
128 * timeout time (ascending)
129 */
130 struct ldns_rbtree_t *timeouts_by_id;
131 struct ldns_rbtree_t *timeouts_by_time;
132
133 /*
134 * state data used to detect changes to the system config files
135 */
136 struct filechg *fchg_resolvconf;
137 struct filechg *fchg_hosts;
138
139 }; /* getdns_context */
140
141 /** internal functions **/
142 /**
143 * Sets up the unbound contexts with stub or recursive behavior
144 * if needed.
145 * @param context previously initialized getdns_context
146 * @param usenamespaces if 0 then only use the DNS, else use context namespace list
147 * @return GETDNS_RETURN_GOOD on success
148 */
149 getdns_return_t getdns_context_prepare_for_resolution(struct getdns_context *context,
150 int usenamespaces);
151
152 /* track an outbound request */
153 getdns_return_t getdns_context_track_outbound_request(struct getdns_dns_req
154 *req);
155 /* clear the outbound request from being tracked - does not cancel it */
156 getdns_return_t getdns_context_clear_outbound_request(struct getdns_dns_req
157 *req);
158 /* cancel callback internal - flag to indicate if req should be freed and callback fired */
159 getdns_return_t getdns_context_cancel_request(struct getdns_context *context,
160 getdns_transaction_t transaction_id, int fire_callback);
161
162 char *getdns_strdup(const struct mem_funcs *mfs, const char *str);
163
164 struct getdns_bindata *getdns_bindata_copy(
165 struct mem_funcs *mfs,
166 const struct getdns_bindata *src);
167
168 void getdns_bindata_destroy(
169 struct mem_funcs *mfs,
170 struct getdns_bindata *bindata);
171
172 /* timeout scheduling */
173 getdns_return_t getdns_context_schedule_timeout(struct getdns_context* context,
174 getdns_transaction_t id, uint16_t timeout, getdns_timeout_callback callback,
175 void* userarg);
176
177 getdns_return_t getdns_context_clear_timeout(struct getdns_context* context,
178 getdns_transaction_t id);
179
180 int filechg_check(struct getdns_context *context, struct filechg *fchg);
181
182 #endif /* _GETDNS_CONTEXT_H_ */
0 /**
1 *
2 * \file convert.c
3 * @brief getdns label conversion functions
4 *
5 */
6
7 /*
8 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * * Neither the names of the copyright holders nor the
19 * names of its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #include <getdns/getdns.h>
35 #include <stdio.h>
36 #include <arpa/inet.h>
37 #include <util-internal.h>
38 #include <locale.h>
39 #include <stringprep.h>
40 #include <idna.h>
41 #include <ldns/ldns.h>
42 #include "getdns_error.h"
43
44 /* stuff to make it compile pedantically */
45 #define UNUSED_PARAM(x) ((void)(x))
46
47 getdns_return_t
48 getdns_convert_dns_name_to_fqdn(
49 const struct getdns_bindata *dns_name_wire_fmt, char **fqdn_as_string)
50 {
51 ldns_rdf *rdf = ldns_rdf_new(LDNS_RDF_TYPE_DNAME,
52 dns_name_wire_fmt->size,
53 (void *)dns_name_wire_fmt->data); /* unconst is safe here */
54 if (!rdf) return GETDNS_RETURN_MEMORY_ERROR;
55 *fqdn_as_string = ldns_rdf2str(rdf);
56 ldns_rdf_free(rdf);
57 return *fqdn_as_string ? GETDNS_RETURN_GOOD
58 : GETDNS_RETURN_GENERIC_ERROR;
59 }
60
61 getdns_return_t
62 getdns_convert_fqdn_to_dns_name(
63 const char *fqdn_as_string, struct getdns_bindata **dns_name_wire_fmt)
64 {
65 ldns_rdf *rdf;
66 if (ldns_str2rdf_dname(&rdf, fqdn_as_string) != LDNS_STATUS_OK)
67 return GETDNS_RETURN_GENERIC_ERROR;;
68 *dns_name_wire_fmt = malloc(sizeof(struct getdns_bindata));
69 if (*dns_name_wire_fmt) {
70 (*dns_name_wire_fmt)->size = ldns_rdf_size(rdf);
71 (*dns_name_wire_fmt)->data = ldns_rdf_data(rdf);
72 }
73 ldns_rdf_free(rdf);
74 return *dns_name_wire_fmt ? GETDNS_RETURN_GOOD
75 : GETDNS_RETURN_MEMORY_ERROR;
76 }
77
78 /*---------------------------------------- getdns_convert_alabel_to_ulabel */
79 /**
80 * Convert UTF-8 string into an ACE-encoded domain
81 * It is the application programmer's responsibility to free()
82 * the returned buffer after use
83 *
84 * @param ulabel the UTF-8-encoded domain name to convert
85 * @return pointer to ACE-encoded string
86 * @return NULL if conversion fails
87 */
88
89 char *
90 getdns_convert_ulabel_to_alabel(const char *ulabel)
91 {
92 int ret;
93 char *buf;
94 char *prepped;
95 char *prepped2;
96
97 if (ulabel == NULL)
98 return 0;
99 prepped2 = malloc(BUFSIZ);
100 if(!prepped2)
101 return 0;
102 setlocale(LC_ALL, "");
103 if ((prepped = stringprep_locale_to_utf8(ulabel)) == 0) {
104 /* convert to utf8 fails, which it can, but continue anyway */
105 if(strlen(ulabel)+1 > BUFSIZ) {
106 free(prepped2);
107 return 0;
108 }
109 memcpy(prepped2, ulabel, strlen(ulabel)+1);
110 } else {
111 if(strlen(prepped)+1 > BUFSIZ) {
112 free(prepped);
113 free(prepped2);
114 return 0;
115 }
116 memcpy(prepped2, prepped, strlen(prepped)+1);
117 free(prepped);
118 }
119 if ((ret = stringprep(prepped2, BUFSIZ, 0, stringprep_nameprep)) != STRINGPREP_OK) {
120 free(prepped2);
121 return 0;
122 }
123 if ((ret = idna_to_ascii_8z(prepped2, &buf, 0)) != IDNA_SUCCESS) {
124 free(prepped2);
125 return 0;
126 }
127 free(prepped2);
128 return buf;
129 }
130
131 /*---------------------------------------- getdns_convert_alabel_to_ulabel */
132 /**
133 * Convert ACE-encoded domain name into a UTF-8 string.
134 * It is the application programmer's responsibility to free()
135 * the returned buffer after use
136 *
137 * @param alabel the ACE-encoded domain name to convert
138 * @return pointer to UTF-8 string
139 * @return NULL if conversion fails
140 */
141
142 char *
143 getdns_convert_alabel_to_ulabel(const char *alabel)
144 {
145 int ret; /* just in case we might want to use it someday */
146 char *buf;
147
148 if (alabel == NULL)
149 return 0;
150 if ((ret = idna_to_unicode_8z8z(alabel, &buf, 0)) != IDNA_SUCCESS) {
151 return NULL;
152 }
153 return buf;
154 }
155
156
157 char *
158 getdns_display_ip_address(const struct getdns_bindata
159 *bindata_of_ipv4_or_ipv6_address)
160 {
161 char buff[256];
162 if (!bindata_of_ipv4_or_ipv6_address ||
163 bindata_of_ipv4_or_ipv6_address->size == 0 ||
164 !bindata_of_ipv4_or_ipv6_address->data) {
165 return NULL;
166 }
167 if (bindata_of_ipv4_or_ipv6_address->size == 4) {
168 const char *ipStr = inet_ntop(AF_INET,
169 bindata_of_ipv4_or_ipv6_address->data,
170 buff,
171 256);
172 if (ipStr) {
173 return strdup(ipStr);
174 }
175 } else if (bindata_of_ipv4_or_ipv6_address->size == 16) {
176 const char *ipStr = inet_ntop(AF_INET6,
177 bindata_of_ipv4_or_ipv6_address->data,
178 buff,
179 256);
180 if (ipStr) {
181 return strdup(ipStr);
182 }
183 }
184 return NULL;
185 }
186
187 getdns_return_t
188 getdns_strerror(getdns_return_t err, char *buf, size_t buflen)
189 {
190 getdns_return_t retval = GETDNS_RETURN_GOOD;
191
192 const char *err_str = getdns_get_errorstr_by_id(err);
193 if (!err_str) {
194 return GETDNS_RETURN_GENERIC_ERROR;
195 }
196
197 snprintf(buf, buflen, "%s", err_str);
198
199 return retval;
200 } /* getdns_strerror */
201
202 /* convert.c */
0 /**
1 *
2 * getdns dict management functions, note that the internal storage is
3 * accomplished via an ldns_rbtree_t
4 *
5 * Interfaces originally taken from the getdns API description pseudo implementation.
6 *
7 */
8
9 /*
10 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * * Neither the names of the copyright holders nor the
21 * names of its contributors may be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 #include <ctype.h>
37 #include <ldns/buffer.h>
38 #include "types-internal.h"
39 #include "util-internal.h"
40 #include "dict.h"
41 #include "rr-dict.h"
42 #include "const-info.h"
43
44 /*---------------------------------------- getdns_dict_find */
45 /**
46 * private function used to locate a key in a dictionary
47 * @param dict dicitonary to search
48 * @param key key to search for
49 * @param addifnotfnd if TRUE then an item will be added if the key is not found
50 * @return pointer to dictionary item, caller must not free storage associated with item
51 * @return NULL if additnotfnd == FALSE and key is not in dictionary
52 */
53 struct getdns_dict_item *
54 getdns_dict_find(const struct getdns_dict *dict, const char *key)
55 {
56 return (struct getdns_dict_item *)
57 ldns_rbtree_search((ldns_rbtree_t *)&(dict->root), key);
58 } /* getdns_dict_find */
59
60 struct getdns_dict_item *
61 getdns_dict_find_and_add(struct getdns_dict *dict, const char *key)
62 {
63 struct getdns_dict_item *item;
64
65 item = (struct getdns_dict_item *)
66 ldns_rbtree_search(&(dict->root), key);
67
68 if (!item) {
69 /* add a node */
70 item = GETDNS_MALLOC(dict->mf, struct getdns_dict_item);
71 item->node.key = getdns_strdup(&dict->mf, key);
72 item->data.n = 0;
73 ldns_rbtree_insert(&(dict->root), (ldns_rbnode_t *) item);
74 }
75 return item;
76 } /* getdns_dict_find_and_add */
77
78
79 /*---------------------------------------- getdns_dict_get_names
80 */
81 getdns_return_t
82 getdns_dict_get_names(const struct getdns_dict * dict,
83 struct getdns_list ** answer)
84 {
85 struct getdns_dict_item *item;
86 size_t index;
87 struct getdns_bindata bindata;
88
89 if (!dict || !answer)
90 return GETDNS_RETURN_INVALID_PARAMETER;
91
92 *answer = getdns_list_create_with_extended_memory_functions(
93 dict->mf.mf_arg, dict->mf.mf.ext.malloc,
94 dict->mf.mf.ext.realloc, dict->mf.mf.ext.free);
95 if (!*answer)
96 return GETDNS_RETURN_NO_SUCH_DICT_NAME;
97
98 LDNS_RBTREE_FOR(item, struct getdns_dict_item *,
99 (ldns_rbtree_t *)&(dict->root)) {
100 if (getdns_list_add_item(*answer, &index) != GETDNS_RETURN_GOOD)
101 continue;
102 bindata.size = strlen(item->node.key) + 1;
103 bindata.data = (void *) item->node.key;
104 getdns_list_set_bindata(*answer, index, &bindata);
105 }
106 return GETDNS_RETURN_GOOD;
107 } /* getdns_dict_get_names */
108
109 /*---------------------------------------- getdns_dict_get_data_type */
110 getdns_return_t
111 getdns_dict_get_data_type(const struct getdns_dict * dict, const char *name,
112 getdns_data_type * answer)
113 {
114 struct getdns_dict_item *item;
115
116 if (!dict || !name || !answer)
117 return GETDNS_RETURN_INVALID_PARAMETER;
118
119 item = getdns_dict_find(dict, name);
120 if (!item)
121 return GETDNS_RETURN_NO_SUCH_DICT_NAME;
122
123 *answer = item->dtype;
124 return GETDNS_RETURN_GOOD;
125 } /* getdns_dict_get_data_type */
126
127 /*---------------------------------------- getdns_dict_get_dict */
128 getdns_return_t
129 getdns_dict_get_dict(const struct getdns_dict * dict, const char *name,
130 struct getdns_dict ** answer)
131 {
132 struct getdns_dict_item *item;
133
134 if (!dict || !name || !answer)
135 return GETDNS_RETURN_INVALID_PARAMETER;
136
137 item = getdns_dict_find(dict, name);
138 if (!item)
139 return GETDNS_RETURN_NO_SUCH_DICT_NAME;
140
141 if (item->dtype != t_dict)
142 return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
143
144 *answer = item->data.dict;
145 return GETDNS_RETURN_GOOD;
146 } /* getdns_dict_get_dict */
147
148 /*---------------------------------------- getdns_dict_get_list */
149 getdns_return_t
150 getdns_dict_get_list(const struct getdns_dict * dict, const char *name,
151 struct getdns_list ** answer)
152 {
153 struct getdns_dict_item *item;
154
155 if (!dict || !name || !answer)
156 return GETDNS_RETURN_INVALID_PARAMETER;
157
158 item = getdns_dict_find(dict, name);
159 if (!item)
160 return GETDNS_RETURN_NO_SUCH_DICT_NAME;
161
162 if (item->dtype != t_list)
163 return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
164
165 *answer = item->data.list;
166 return GETDNS_RETURN_GOOD;
167 } /* getdns_dict_get_list */
168
169 /*---------------------------------------- getdns_dict_get_bindata */
170 getdns_return_t
171 getdns_dict_get_bindata(const struct getdns_dict * dict, const char *name,
172 struct getdns_bindata ** answer)
173 {
174 struct getdns_dict_item *item;
175
176 if (!dict || !name || !answer)
177 return GETDNS_RETURN_INVALID_PARAMETER;
178
179 item = getdns_dict_find(dict, name);
180 if (!item)
181 return GETDNS_RETURN_NO_SUCH_DICT_NAME;
182
183 if (item->dtype != t_bindata)
184 return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
185
186 *answer = item->data.bindata;
187 return GETDNS_RETURN_GOOD;
188 } /* getdns_dict_get_bindata */
189
190 /*---------------------------------------- getdns_dict_get_int */
191 getdns_return_t
192 getdns_dict_get_int(const struct getdns_dict * dict, const char *name,
193 uint32_t * answer)
194 {
195 struct getdns_dict_item *item;
196
197 if (!dict || !name || !answer)
198 return GETDNS_RETURN_INVALID_PARAMETER;
199
200 item = getdns_dict_find(dict, name);
201 if (!item)
202 return GETDNS_RETURN_NO_SUCH_DICT_NAME;
203
204 if (item->dtype != t_int)
205 return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
206
207 *answer = item->data.n;
208 return GETDNS_RETURN_GOOD;
209 } /* getdns_dict_get_int */
210
211 struct getdns_dict *
212 getdns_dict_create_with_extended_memory_functions(
213 void *userarg,
214 void *(*malloc)(void *userarg, size_t),
215 void *(*realloc)(void *userarg, void *, size_t),
216 void (*free)(void *userarg, void *))
217 {
218 struct getdns_dict *dict;
219 mf_union mf;
220
221 if (!malloc || !realloc || !free)
222 return NULL;
223
224 mf.ext.malloc = malloc;
225 dict = userarg == MF_PLAIN
226 ? (struct getdns_dict*)(*mf.pln.malloc)(
227 sizeof(struct getdns_dict))
228 : (struct getdns_dict*)(*mf.ext.malloc)(userarg,
229 sizeof(struct getdns_dict));
230 if (!dict)
231 return NULL;
232
233 dict->mf.mf_arg = userarg;
234 dict->mf.mf.ext.malloc = malloc;
235 dict->mf.mf.ext.realloc = realloc;
236 dict->mf.mf.ext.free = free;
237
238 ldns_rbtree_init(&(dict->root),
239 (int (*)(const void *, const void *)) strcmp);
240 return dict;
241 }
242
243 struct getdns_dict *
244 getdns_dict_create_with_memory_functions(void *(*malloc)(size_t),
245 void *(*realloc)(void *, size_t), void (*free)(void *))
246 {
247 mf_union mf;
248 mf.pln.malloc = malloc;
249 mf.pln.realloc = realloc;
250 mf.pln.free = free;
251 return getdns_dict_create_with_extended_memory_functions(
252 MF_PLAIN, mf.ext.malloc, mf.ext.realloc, mf.ext.free);
253 }
254
255 /*-------------------------- getdns_dict_create_with_context */
256 struct getdns_dict *
257 getdns_dict_create_with_context(struct getdns_context *context)
258 {
259 if (context)
260 return getdns_dict_create_with_extended_memory_functions(
261 context->mf.mf_arg, context->mf.mf.ext.malloc,
262 context->mf.mf.ext.realloc, context->mf.mf.ext.free);
263 else
264 return getdns_dict_create_with_memory_functions(&malloc,
265 &realloc, &free);
266 } /* getdns_dict_create_with_context */
267
268 /*---------------------------------------- getdns_dict_create */
269 struct getdns_dict *
270 getdns_dict_create()
271 {
272 return getdns_dict_create_with_context(NULL);
273 } /* getdns_dict_create */
274
275 /*---------------------------------------- getdns_dict_copy */
276 /**
277 * private function used to make a copy of a dict structure,
278 * the caller is responsible * for freeing storage allocated to returned value
279 * @param srcdict the dictionary structure to copy
280 * @param dstdict the copy destination
281 * @return the address of the copy of the dictionary structure on success
282 * @return NULL on error (out of memory, invalid srcdict)
283 */
284 getdns_return_t
285 getdns_dict_copy(const struct getdns_dict * srcdict,
286 struct getdns_dict ** dstdict)
287 {
288 struct getdns_dict_item *item;
289 char *key;
290 getdns_return_t retval;
291
292 if (!dstdict)
293 return GETDNS_RETURN_INVALID_PARAMETER;
294
295 if (!srcdict) {
296 *dstdict = NULL;
297 return GETDNS_RETURN_GOOD;
298 }
299 *dstdict = getdns_dict_create_with_extended_memory_functions(
300 srcdict->mf.mf_arg,
301 srcdict->mf.mf.ext.malloc,
302 srcdict->mf.mf.ext.realloc,
303 srcdict->mf.mf.ext.free);
304 if (!*dstdict)
305 return GETDNS_RETURN_GENERIC_ERROR;
306
307 retval = GETDNS_RETURN_GOOD;
308 LDNS_RBTREE_FOR(item, struct getdns_dict_item *,
309 (struct ldns_rbtree_t *)&(srcdict->root)) {
310 key = (char *) item->node.key;
311 switch (item->dtype) {
312 case t_bindata:
313 retval = getdns_dict_set_bindata(*dstdict, key,
314 item->data.bindata);
315 break;
316
317 case t_dict:
318 retval = getdns_dict_set_dict(*dstdict, key,
319 item->data.dict);
320 break;
321
322 case t_int:
323 retval = getdns_dict_set_int(*dstdict, key,
324 item->data.n);
325 break;
326
327 case t_list:
328 retval = getdns_dict_set_list(*dstdict, key,
329 item->data.list);
330 break;
331 }
332 if (retval != GETDNS_RETURN_GOOD) {
333 getdns_dict_destroy(*dstdict);;
334 *dstdict = NULL;
335 return retval;
336 }
337 }
338 return GETDNS_RETURN_GOOD;
339 } /* getdns_dict_copy */
340
341 /*---------------------------------------- getdns_dict_item_free */
342 /**
343 * private function used to release storage associated with a dictionary item
344 * @param item all memory in this structure and its children will be freed
345 * @return void
346 */
347 void
348 getdns_dict_item_free(ldns_rbnode_t * node, void *arg)
349 {
350 struct getdns_dict_item *item = (struct getdns_dict_item *) node;
351 struct getdns_dict *dict = (struct getdns_dict *)arg;
352
353 if (!item)
354 return;
355
356 switch (item->dtype) {
357 case t_bindata:
358 getdns_bindata_destroy(&dict->mf, item->data.bindata);
359 break;
360 case t_dict:
361 getdns_dict_destroy(item->data.dict);
362 break;
363 case t_list:
364 getdns_list_destroy(item->data.list);
365 break;
366 default:
367 break;
368 }
369 if (item->node.key)
370 GETDNS_FREE(dict->mf, (void *)item->node.key);
371 GETDNS_FREE(dict->mf, item);
372 } /* getdns_dict_item_free */
373
374 /*---------------------------------------- getdns_dict_destroy */
375 void
376 getdns_dict_destroy(struct getdns_dict *dict)
377 {
378 if (!dict)
379 return;
380
381 ldns_traverse_postorder(&(dict->root),
382 getdns_dict_item_free, dict);
383 GETDNS_FREE(dict->mf, dict);
384 } /* getdns_dict_destroy */
385
386 /*---------------------------------------- getdns_dict_set_dict */
387 getdns_return_t
388 getdns_dict_set_dict(struct getdns_dict * dict, const char *name,
389 const struct getdns_dict * child_dict)
390 {
391 struct getdns_dict_item *item;
392 struct getdns_dict *newdict;
393 getdns_return_t retval;
394
395 if (!dict || !name || !child_dict)
396 return GETDNS_RETURN_INVALID_PARAMETER;
397
398 retval = getdns_dict_copy(child_dict, &newdict);
399 if (retval != GETDNS_RETURN_GOOD)
400 return retval;
401
402 item = getdns_dict_find_and_add(dict, name);
403 if (!item) {
404 getdns_dict_destroy(newdict);
405 return GETDNS_RETURN_NO_SUCH_DICT_NAME;
406 }
407 item->dtype = t_dict;
408 item->data.dict = newdict;
409 return GETDNS_RETURN_GOOD;
410 } /* getdns_dict_set_dict */
411
412 /*---------------------------------------- getdns_dict_set_list */
413 getdns_return_t
414 getdns_dict_set_list(struct getdns_dict * dict, const char *name,
415 const struct getdns_list * child_list)
416 {
417 struct getdns_dict_item *item;
418 struct getdns_list *newlist;
419 getdns_return_t retval;
420
421 if (!dict || !name || !child_list)
422 return GETDNS_RETURN_INVALID_PARAMETER;
423
424 retval = getdns_list_copy(child_list, &newlist);
425 if (retval != GETDNS_RETURN_GOOD)
426 return retval;
427
428 item = getdns_dict_find_and_add(dict, name);
429 if (!item) {
430 getdns_list_destroy(newlist);
431 return GETDNS_RETURN_NO_SUCH_DICT_NAME;
432 }
433 item->dtype = t_list;
434 item->data.list = newlist;
435 return GETDNS_RETURN_GOOD;
436 } /* getdns_dict_set_list */
437
438 /*---------------------------------------- getdns_dict_set_bindata */
439 getdns_return_t
440 getdns_dict_set_bindata(struct getdns_dict * dict, const char *name,
441 const struct getdns_bindata * child_bindata)
442 {
443 struct getdns_dict_item *item;
444 struct getdns_bindata *newbindata;
445
446 if (!dict || !name || !child_bindata)
447 return GETDNS_RETURN_INVALID_PARAMETER;
448
449 newbindata = getdns_bindata_copy(&dict->mf, child_bindata);
450 if (!newbindata)
451 return GETDNS_RETURN_NO_SUCH_DICT_NAME;
452
453 item = getdns_dict_find_and_add(dict, name);
454 if (!item) {
455 getdns_bindata_destroy(&dict->mf, newbindata);
456 return GETDNS_RETURN_NO_SUCH_DICT_NAME;
457 }
458 item->dtype = t_bindata;
459 item->data.bindata = newbindata;
460 return GETDNS_RETURN_GOOD;
461 } /* getdns_dict_set_bindata */
462
463 /*---------------------------------------- getdns_dict_set_int */
464 getdns_return_t
465 getdns_dict_set_int(struct getdns_dict * dict, const char *name,
466 uint32_t child_uint32)
467 {
468 struct getdns_dict_item *item;
469
470 if (!dict || !name)
471 return GETDNS_RETURN_INVALID_PARAMETER;
472
473 item = getdns_dict_find_and_add(dict, name);
474 if (!item)
475 return GETDNS_RETURN_NO_SUCH_DICT_NAME;
476
477 item->dtype = t_int;
478 item->data.n = child_uint32;
479 return GETDNS_RETURN_GOOD;
480 } /* getdns_dict_set_int */
481
482 /*---------------------------------------- getdns_pp_dict */
483 /**
484 * private function to help with indenting.
485 * @param indent number of spaces to return
486 * @return a character string containing min(80, indent) spaces
487 */
488 static const char *
489 getdns_indent(size_t indent)
490 {
491 static const char *spaces = " "
492 " ";
493 return spaces + 80 - (indent < 80 ? indent : 0);
494 } /* getdns_indent */
495
496 static int
497 priv_getdns_bindata_is_dname(struct getdns_bindata *bindata)
498 {
499 size_t i = 0, n_labels = 0;
500 while (i < bindata->size) {
501 i += ((size_t)bindata->data[i]) + 1;
502 n_labels++;
503 }
504 return i == bindata->size && n_labels > 1 &&
505 bindata->data[bindata->size - 1] == 0;
506 }
507
508 /*---------------------------------------- getdns_pp_bindata */
509 /**
510 * private function to pretty print bindata to a ldns_buffer
511 * @param buf buffer to write to
512 * @param indent number of spaces to append after newline
513 * @param bindata the bindata to print
514 * @return on success the number of written characters
515 * if an output error is encountered, a negative value
516 */
517 static int
518 getdns_pp_bindata(ldns_buffer * buf, size_t indent,
519 struct getdns_bindata *bindata)
520 {
521 size_t i, p = ldns_buffer_position(buf);
522 uint8_t *dptr;
523 char *dname;
524
525 if (ldns_buffer_printf(buf, " <bindata ") < 0)
526 return -1;
527
528 /* Walk through all printable characters */
529 i = 0;
530 if (bindata->size && bindata->data[bindata->size - 1] == 0)
531 while (i < bindata->size - 1 && isprint(bindata->data[i]))
532 i++;
533
534 if (bindata->size > 1 && i >= bindata->size - 1) { /* all printable? */
535 if (ldns_buffer_printf(buf, "of \"%s\">", bindata->data) < 0)
536 return -1;
537
538 } else if (bindata->size == 1 && *bindata->data == 0) {
539 if (ldns_buffer_printf(buf, "for .>") < 0)
540 return -1;
541
542 } else if (priv_getdns_bindata_is_dname(bindata)) {
543 if (GETDNS_RETURN_GOOD ==
544 getdns_convert_dns_name_to_fqdn(bindata, &dname) &&
545 ldns_buffer_printf(buf, "for %s>", dname) < 0) {
546 free(dname);
547 return -1;
548 }
549 free(dname);
550
551 } else {
552 if (ldns_buffer_printf(buf, "of 0x") < 0)
553 return -1;
554 for (dptr = bindata->data;
555 dptr < bindata->data + bindata->size; dptr++) {
556 if (dptr - bindata->data >= 16) {
557 if (ldns_buffer_printf(buf, "...") < 0)
558 return -1;
559 break;
560 }
561 if (ldns_buffer_printf(buf, "%.2x", *dptr) < 0)
562 return -1;
563 }
564 if (ldns_buffer_printf(buf, ">") < 0)
565 return -1;
566 }
567 return ldns_buffer_position(buf) - p;
568 } /* getdns_pp_bindata */
569
570 static int
571 getdns_pp_dict(ldns_buffer * buf, size_t indent,
572 const struct getdns_dict *dict);
573
574 /*---------------------------------------- getdns_pp_list */
575 /**
576 * private function to pretty print list to a ldns_buffer
577 * @param buf buffer to write to
578 * @param indent number of spaces to append after newline
579 * @param list the to list print
580 * @return on success the number of written characters
581 * if an output error is encountered, a negative value
582 */
583 static int
584 getdns_pp_list(ldns_buffer * buf, size_t indent, struct getdns_list *list)
585 {
586 size_t i, length, p = ldns_buffer_position(buf);
587 getdns_data_type dtype;
588 struct getdns_dict *dict_item;
589 struct getdns_list *list_item;
590 struct getdns_bindata *bindata_item;
591 uint32_t int_item;
592
593 if (list == NULL)
594 return 0;
595
596 if (ldns_buffer_printf(buf, "[") < 0)
597 return -1;
598
599 if (getdns_list_get_length(list, &length) != GETDNS_RETURN_GOOD)
600 return -1;
601
602 indent += 2;
603 for (i = 0; i < length; i++) {
604 if (ldns_buffer_printf(buf, "%s\n%s", (i ? "," : ""),
605 getdns_indent(indent)) < 0)
606 return -1;
607
608 if (getdns_list_get_data_type(list, i,
609 &dtype) != GETDNS_RETURN_GOOD)
610 return -1;
611
612 switch (dtype) {
613 case t_int:
614 if (getdns_list_get_int(list, i, &int_item) !=
615 GETDNS_RETURN_GOOD ||
616 ldns_buffer_printf(buf, "%d", (int) int_item) < 0)
617 return -1;
618 break;
619
620 case t_bindata:
621 if (getdns_list_get_bindata(list, i, &bindata_item) !=
622 GETDNS_RETURN_GOOD)
623 return -1;
624 if (getdns_pp_bindata(buf, indent, bindata_item) < 0)
625 return -1;
626 break;
627
628 case t_list:
629 if (getdns_list_get_list(list, i, &list_item) !=
630 GETDNS_RETURN_GOOD)
631 return -1;
632 if (getdns_pp_list(buf, indent, list_item) < 0)
633 return -1;
634 break;
635
636 case t_dict:
637 if (getdns_list_get_dict(list, i, &dict_item) !=
638 GETDNS_RETURN_GOOD)
639 return -1;
640 if (getdns_pp_dict(buf, indent, dict_item) < 0)
641 return -1;
642 break;
643
644 default:
645 if (ldns_buffer_printf(buf, " <unknown>") < 0)
646 return -1;
647 }
648 }
649 indent -= 2;
650 if (ldns_buffer_printf(buf, i ? "\n%s]" : "]",
651 getdns_indent(indent)) < 0)
652 return -1;
653
654 return ldns_buffer_position(buf) - p;
655 } /* getdns_pp_list */
656
657 static int
658 priv_getdns_print_class(ldns_buffer *buf, uint32_t klass)
659 {
660 switch (klass) {
661 case GETDNS_RRCLASS_IN:
662 (void) ldns_buffer_printf(buf, " GETDNS_RRCLASS_IN");
663 return 1;
664 case GETDNS_RRCLASS_CH:
665 (void) ldns_buffer_printf(buf, " GETDNS_RRCLASS_CH");
666 return 1;
667 case GETDNS_RRCLASS_HS:
668 (void) ldns_buffer_printf(buf, " GETDNS_RRCLASS_HS");
669 return 1;
670 case GETDNS_RRCLASS_NONE:
671 (void) ldns_buffer_printf(buf, " GETDNS_RRCLASS_NONE");
672 return 1;
673 case GETDNS_RRCLASS_ANY:
674 (void) ldns_buffer_printf(buf, " GETDNS_RRCLASS_ANY");
675 return 1;
676 }
677 return 0;
678 }
679
680 static int
681 priv_getdns_print_opcode(ldns_buffer *buf, uint32_t opcode)
682 {
683 switch (opcode) {
684 case GETDNS_OPCODE_QUERY:
685 (void) ldns_buffer_printf(buf, " GETDNS_OPCODE_QUERY");
686 return 1;
687 case GETDNS_OPCODE_IQUERY:
688 (void) ldns_buffer_printf(buf, " GETDNS_OPCODE_IQUERY");
689 return 1;
690 case GETDNS_OPCODE_STATUS:
691 (void) ldns_buffer_printf(buf, " GETDNS_OPCODE_STATUS");
692 return 1;
693 case GETDNS_OPCODE_NOTIFY:
694 (void) ldns_buffer_printf(buf, " GETDNS_OPCODE_NOTIFY");
695 return 1;
696 case GETDNS_OPCODE_UPDATE:
697 (void) ldns_buffer_printf(buf, " GETDNS_OPCODE_UPDATE");
698 return 1;
699 }
700 return 0;
701 }
702
703 static int
704 priv_getdns_print_rcode(ldns_buffer *buf, uint32_t rcode)
705 {
706 static const char *rcodes[] = {
707 " GETDNS_RCODE_NOERROR" , " GETDNS_RCODE_FORMERR" ,
708 " GETDNS_RCODE_SERVFAIL", " GETDNS_RCODE_NXDOMAIN",
709 " GETDNS_RCODE_NOTIMP" , " GETDNS_RCODE_REFUSED" ,
710 " GETDNS_RCODE_YXDOMAIN", " GETDNS_RCODE_YXRRSET" ,
711 " GETDNS_RCODE_NXRRSET" , " GETDNS_RCODE_NOTAUTH" ,
712 " GETDNS_RCODE_NOTZONE" ,
713 " GETDNS_RCODE_BADSIG" , " GETDNS_RCODE_BADKEY" ,
714 " GETDNS_RCODE_BADTIME" , " GETDNS_RCODE_BADMODE" ,
715 " GETDNS_RCODE_BADNAME" , " GETDNS_RCODE_BADALG" ,
716 " GETDNS_RCODE_BADTRUNC"
717 };
718 if (rcode <= 10)
719 (void) ldns_buffer_printf(buf, rcodes[rcode]);
720 else if (rcode >= 16 && rcode <= 22)
721 (void) ldns_buffer_printf(buf, rcodes[rcode-6]);
722 else
723 return 0;
724 return 1;
725 }
726
727 /*---------------------------------------- getdns_pp_dict */
728 /**
729 * private function to pretty print dict to a ldns_buffer
730 * @param buf buffer to write to
731 * @param indent number of spaces to append after newline
732 * @param dict the dict to print
733 * @return on success the number of written characters
734 * if an output error is encountered, a negative value
735 */
736 static int
737 getdns_pp_dict(ldns_buffer * buf, size_t indent,
738 const struct getdns_dict *dict)
739 {
740 size_t i, length, p = ldns_buffer_position(buf);
741 struct getdns_dict_item *item;
742 const char *strval;
743
744 if (dict == NULL)
745 return 0;
746
747 if (ldns_buffer_printf(buf, "{") < 0)
748 return -1;
749
750 i = 0;
751 indent += 2;
752 LDNS_RBTREE_FOR(item, struct getdns_dict_item *,
753 (ldns_rbtree_t *)&(dict->root)) {
754 if (ldns_buffer_printf(buf, "%s\n%s\"%s\":", (i ? "," : "")
755 , getdns_indent(indent)
756 , item->node.key) < 0)
757 return -1;
758
759 switch (item->dtype) {
760 case t_int:
761 if ((strcmp(item->node.key, "type") == 0 ||
762 strcmp(item->node.key, "type_covered") == 0 ||
763 strcmp(item->node.key, "qtype") == 0) &&
764 (strval = priv_getdns_rr_type_name(item->data.n))) {
765 if (ldns_buffer_printf(
766 buf, " GETDNS_RRTYPE_%s", strval) < 0)
767 return -1;
768 break;
769 }
770 if ((strcmp(item->node.key, "answer_type") == 0 ||
771 strcmp(item->node.key, "dnssec_status") == 0 ||
772 strcmp(item->node.key, "status") == 0) &&
773 (strval =
774 priv_getdns_get_const_info(item->data.n)->name)) {
775 if (ldns_buffer_printf(buf, " %s", strval) < 0)
776 return -1;
777 break;
778 }
779 if ((strcmp(item->node.key, "class") == 0 ||
780 strcmp(item->node.key, "qclass") == 0) &&
781 priv_getdns_print_class(buf, item->data.n))
782 break;
783 if (strcmp(item->node.key, "opcode") == 0 &&
784 priv_getdns_print_opcode(buf, item->data.n))
785 break;
786 if (strcmp(item->node.key, "rcode") == 0 &&
787 priv_getdns_print_rcode(buf, item->data.n))
788 break;
789 if (ldns_buffer_printf(buf, " %d", item->data.n) < 0)
790 return -1;
791 break;
792
793 case t_bindata:
794 if (getdns_pp_bindata(buf, indent,
795 item->data.bindata) < 0)
796 return -1;
797 break;
798
799 case t_list: /* Don't put empty lists on a new line */
800
801 if (getdns_list_get_length(item->data.list,
802 &length) != GETDNS_RETURN_GOOD)
803 return -1;
804 if (length == 0) {
805 if (ldns_buffer_printf(buf, " []") < 0)
806 return -1;
807 break;
808 }
809 if (ldns_buffer_printf(buf, "\n%s",
810 getdns_indent(indent)) < 0)
811 return -1;
812 if (getdns_pp_list(buf, indent, item->data.list) < 0)
813 return -1;
814 break;
815
816 case t_dict:
817 if (ldns_buffer_printf(buf, "\n%s",
818 getdns_indent(indent)) < 0)
819 return -1;
820 if (getdns_pp_dict(buf, indent, item->data.dict) < 0)
821 return -1;
822 break;
823
824 default:
825 if (ldns_buffer_printf(buf, " <unknown>") < 0)
826 return -1;
827 }
828 i++;
829 }
830 indent -= 2;
831 if (ldns_buffer_printf(buf, i ? "\n%s}" : "}",
832 getdns_indent(indent)) < 0)
833 return -1;
834
835 return ldns_buffer_position(buf) - p;
836 } /* getdns_pp_dict */
837
838 /*---------------------------------------- getdns_pretty_print_dict */
839 /**
840 * Return a character string containing a "human readable" representation
841 * of dict.
842 * @param dict the dict to pretty print
843 * @return the "human readable" representation of dict
844 * or NULL on error
845 */
846 char *
847 getdns_pretty_print_dict(const struct getdns_dict *dict)
848 {
849 ldns_buffer *buf;
850 char *ret;
851
852 if (!dict)
853 return NULL;
854
855 buf = ldns_buffer_new(100);
856 if (!buf)
857 return NULL;
858
859 if (getdns_pp_dict(buf, 0, dict) < 0) {
860 ldns_buffer_free(buf);
861 return NULL;
862 }
863 ret = (char *) ldns_buffer_export(buf);
864 ldns_buffer_free(buf);
865 return ret;
866 } /* getdns_pretty_print_dict */
867
868 getdns_return_t
869 getdns_dict_remove_name(struct getdns_dict *this_dict, const char *name)
870 {
871 struct getdns_dict_item *item;
872
873 if (!this_dict || !name)
874 return GETDNS_RETURN_INVALID_PARAMETER;
875
876 item = getdns_dict_find(this_dict, name);
877 if (!item)
878 return GETDNS_RETURN_NO_SUCH_DICT_NAME;
879
880 /* cleanup */
881 ldns_rbtree_delete(&this_dict->root, name);
882 getdns_dict_item_free(&item->node, this_dict);
883
884 return GETDNS_RETURN_GENERIC_ERROR;
885 }
886
887 /* dict.c */
0 /**
1 *
2 * /brief getdns dict data type management functions
3 *
4 *
5 */
6
7 /*
8 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * * Neither the names of the copyright holders nor the
19 * names of its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #ifndef _GETDNS_DICT_H_
35 #define _GETDNS_DICT_H_
36
37 #include <getdns/getdns.h>
38 #include <ldns/rbtree.h>
39 #include "types-internal.h"
40
41 union getdns_item
42 {
43 struct getdns_list *list;
44 struct getdns_dict *dict;
45 uint32_t n;
46 struct getdns_bindata *bindata;
47 };
48
49 /**
50 * this structure represents a single item in a dictionary type
51 */
52 struct getdns_dict_item
53 {
54 ldns_rbnode_t node;
55 getdns_data_type dtype;
56 union getdns_item data;
57 };
58
59 /**
60 * getdns dictionary data type
61 * Use helper functions getdns_dict_* to manipulate and iterate dictionaries
62 * dict is implemented using the t*() functions for manipulating binary search
63 * trees in the std library. The internal implementation may change so the
64 * application should stick to the helper functions.
65 */
66 struct getdns_dict
67 {
68 ldns_rbtree_t root;
69 struct mem_funcs mf;
70 };
71
72 #endif
73
74 /* dict.h */
0 /**
1 *
2 * /brief function for DNSSEC
3 *
4 * The priv_getdns_get_validation_chain function is called after an answer
5 * has been fetched when the dnssec_return_validation_chain extension is set.
6 * It fetches DNSKEYs, DSes and their signatures for all RRSIGs found in the
7 * answer.
8 */
9
10 /*
11 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are met:
16 * * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * * Neither the names of the copyright holders nor the
22 * names of its contributors may be used to endorse or promote products
23 * derived from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
29 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <unistd.h>
40 #include <unbound.h>
41 #include <ldns/ldns.h>
42 #include <getdns/getdns.h>
43 #include "config.h"
44 #include "context.h"
45 #include "util-internal.h"
46 #include "types-internal.h"
47 #include "dnssec.h"
48 #include "rr-dict.h"
49
50 void priv_getdns_call_user_callback(getdns_dns_req *, struct getdns_dict *);
51
52 struct validation_chain {
53 ldns_rbtree_t root;
54 struct mem_funcs mf;
55 getdns_dns_req *dns_req;
56 size_t lock;
57 struct getdns_dict **sync_response;
58 };
59
60 struct chain_response {
61 int err;
62 ldns_rr_list *result;
63 int sec;
64 char *bogus;
65 struct validation_chain *chain;
66 int unbound_id;
67 };
68
69 struct chain_link {
70 ldns_rbnode_t node;
71 struct chain_response DNSKEY;
72 struct chain_response DS;
73 };
74
75 static void launch_chain_link_lookup(struct validation_chain *chain, char *name);
76 static void destroy_chain(struct validation_chain *chain);
77
78 static void callback_on_complete_chain(struct validation_chain *chain)
79 {
80 struct getdns_context *context = chain->dns_req->context;
81 struct getdns_dict *response;
82 struct chain_link *link;
83 size_t ongoing = chain->lock;
84 ldns_rr_list *keys;
85 struct getdns_list *getdns_keys;
86
87 LDNS_RBTREE_FOR(link, struct chain_link *,
88 (ldns_rbtree_t *)&(chain->root)) {
89 if (link->DNSKEY.result == NULL && link->DNSKEY.err == 0)
90 ongoing++;
91 if (link->DS.result == NULL && link->DS.err == 0 &&
92 (((const char *)link->node.key)[0] != '.' ||
93 ((const char *)link->node.key)[1] != '\0' ))
94 ongoing++;
95 }
96 if (ongoing == 0) {
97 getdns_dns_req *dns_req = chain->dns_req;
98 response = create_getdns_response(chain->dns_req);
99
100 keys = ldns_rr_list_new();
101 LDNS_RBTREE_FOR(link, struct chain_link *,
102 (ldns_rbtree_t *)&(chain->root)) {
103 (void) ldns_rr_list_cat(keys, link->DNSKEY.result);
104 (void) ldns_rr_list_cat(keys, link->DS.result);
105 }
106 getdns_keys = create_list_from_rr_list(context, keys);
107 (void) getdns_dict_set_list(response, "validation_chain",
108 getdns_keys);
109 getdns_list_destroy(getdns_keys);
110 ldns_rr_list_free(keys);
111 if (chain->sync_response) {
112 *chain->sync_response = response;
113 } else
114 priv_getdns_call_user_callback(dns_req, response);
115 destroy_chain(chain);
116 }
117 }
118
119
120 static void
121 ub_chain_response_callback(void *arg, int err, struct ub_result* ub_res)
122 {
123 struct chain_response *response = (struct chain_response *) arg;
124 ldns_status r;
125 ldns_pkt *p;
126 ldns_rr_list *answer;
127 ldns_rr_list *keys;
128 size_t i;
129
130 response->err = err;
131 response->sec = ub_res ? ub_res->secure : 0;
132 response->bogus = ub_res ? ub_res->why_bogus : NULL;
133
134 if (ub_res == NULL)
135 goto done;
136
137 r = ldns_wire2pkt(&p, ub_res->answer_packet, ub_res->answer_len);
138 if (r != LDNS_STATUS_OK) {
139 if (err == 0)
140 response->err = r;
141 goto done;
142 }
143
144 keys = ldns_rr_list_new();
145 answer = ldns_pkt_answer(p);
146 for (i = 0; i < ldns_rr_list_rr_count(answer); i++) {
147 ldns_rr *rr = ldns_rr_list_rr(answer, i);
148
149 if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_DNSKEY ||
150 ldns_rr_get_type(rr) == LDNS_RR_TYPE_DS) {
151
152 (void) ldns_rr_list_push_rr(keys, ldns_rr_clone(rr));
153 continue;
154 }
155 if (ldns_rr_get_type(rr) != LDNS_RR_TYPE_RRSIG)
156 continue;
157
158 if (ldns_read_uint16(ldns_rdf_data(ldns_rr_rdf(rr, 0))) ==
159 LDNS_RR_TYPE_DS)
160 launch_chain_link_lookup(response->chain,
161 ldns_rdf2str(ldns_rr_rdf(rr, 7)));
162
163 else if (ldns_read_uint16(ldns_rdf_data(ldns_rr_rdf(rr, 0))) !=
164 LDNS_RR_TYPE_DNSKEY)
165 continue;
166
167 (void) ldns_rr_list_push_rr(keys, ldns_rr_clone(rr));
168 }
169 if (ldns_rr_list_rr_count(keys))
170 response->result = keys;
171 else
172 ldns_rr_list_free(keys);
173
174 ldns_pkt_free(p);
175 ub_resolve_free(ub_res);
176
177 done: if (response->err == 0 && response->result == NULL)
178 response->err = -1;
179
180 callback_on_complete_chain(response->chain);
181 }
182
183 static void chain_response_init(
184 struct validation_chain *chain, struct chain_response *response)
185 {
186 response->err = 0;
187 response->result = NULL;
188 response->sec = 0;
189 response->bogus = NULL;
190 response->chain = chain;
191 response->unbound_id = -1;
192 }
193
194 static int
195 resolve(char* name, int rrtype, struct chain_response *response)
196 {
197 int r;
198 struct ub_result *ub_res;
199
200 if (response->chain->sync_response) {
201 ub_res = NULL;
202 r = ub_resolve(response->chain->dns_req->context->unbound_ctx,
203 name, rrtype, LDNS_RR_CLASS_IN, &ub_res);
204 ub_chain_response_callback(response, r, ub_res);
205 return r;
206 } else
207 return ub_resolve_async(
208 response->chain->dns_req->context->unbound_ctx,
209 name, rrtype, LDNS_RR_CLASS_IN, response,
210 ub_chain_response_callback, &response->unbound_id);
211 }
212
213 static void
214 launch_chain_link_lookup(struct validation_chain *chain, char *name)
215 {
216 int r;
217 struct chain_link *link = (struct chain_link *)
218 ldns_rbtree_search((ldns_rbtree_t *)&(chain->root), name);
219
220 if (link) {
221 free(name);
222 return;
223 }
224 link = GETDNS_MALLOC(chain->mf, struct chain_link);
225 link->node.key = name;
226
227 chain_response_init(chain, &link->DNSKEY);
228 chain_response_init(chain, &link->DS);
229
230 ldns_rbtree_insert(&(chain->root), (ldns_rbnode_t *)link);
231
232 chain->lock++;
233 r = resolve(name, LDNS_RR_TYPE_DNSKEY, &link->DNSKEY);
234 if (r != 0)
235 link->DNSKEY.err = r;
236
237 if (name[0] != '.' || name[1] != '\0') {
238 r = resolve(name, LDNS_RR_TYPE_DS, &link->DS);
239 if (r != 0)
240 link->DS.err = r;
241 }
242 chain->lock--;
243 }
244
245 static struct validation_chain *create_chain(
246 getdns_dns_req *dns_req, struct getdns_dict **sync_response)
247 {
248 struct validation_chain *chain = GETDNS_MALLOC(
249 dns_req->context->mf, struct validation_chain);
250
251 if (! chain)
252 return NULL;
253
254 ldns_rbtree_init(&(chain->root),
255 (int (*)(const void *, const void *)) strcmp);
256 chain->mf.mf_arg = dns_req->context->mf.mf_arg;
257 chain->mf.mf.ext.malloc = dns_req->context->mf.mf.ext.malloc;
258 chain->mf.mf.ext.realloc = dns_req->context->mf.mf.ext.realloc;
259 chain->mf.mf.ext.free = dns_req->context->mf.mf.ext.free;
260 chain->dns_req = dns_req;
261 chain->lock = 0;
262 chain->sync_response = sync_response;
263 return chain;
264 }
265
266 static void destroy_chain_link(ldns_rbnode_t * node, void *arg)
267 {
268 struct chain_link *link = (struct chain_link*) node;
269 struct validation_chain *chain = (struct validation_chain*) arg;
270
271 free((void *)link->node.key);
272 ldns_rr_list_deep_free(link->DNSKEY.result);
273 ldns_rr_list_deep_free(link->DS.result);
274 GETDNS_FREE(chain->mf, link);
275 }
276
277 static void destroy_chain(struct validation_chain *chain)
278 {
279 ldns_traverse_postorder(&(chain->root),
280 destroy_chain_link, chain);
281 GETDNS_FREE(chain->mf, chain);
282 }
283
284 /* Do some additional requests to fetch the complete validation chain */
285 static void
286 getdns_get_validation_chain(
287 getdns_dns_req *dns_req, struct getdns_dict **sync_response)
288 {
289 getdns_network_req *netreq = dns_req->first_req;
290 struct validation_chain *chain = create_chain(dns_req, sync_response);
291
292 if (! chain) {
293 if (sync_response)
294 *sync_response = create_getdns_response(dns_req);
295 else
296 priv_getdns_call_user_callback(
297 dns_req, create_getdns_response(dns_req));
298 return;
299 }
300 while (netreq) {
301 size_t i;
302 ldns_rr_list *answer = ldns_pkt_answer(netreq->result);
303 for (i = 0; i < ldns_rr_list_rr_count(answer); i++) {
304 ldns_rr *rr = ldns_rr_list_rr(answer, i);
305 if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_RRSIG)
306 launch_chain_link_lookup(chain,
307 ldns_rdf2str(ldns_rr_rdf(rr, 7)));
308 }
309 netreq = netreq->next;
310 }
311 callback_on_complete_chain(chain);
312 }
313
314
315 void priv_getdns_get_validation_chain(getdns_dns_req *dns_req)
316 {
317 getdns_get_validation_chain(dns_req, NULL);
318 }
319
320 struct getdns_dict *
321 priv_getdns_get_validation_chain_sync(getdns_dns_req *dns_req)
322 {
323 struct getdns_dict *sync_response = NULL;
324 getdns_get_validation_chain(dns_req, &sync_response);
325 return sync_response;
326 }
327
328 /********************** functions for validate_dnssec *************************/
329
330 static getdns_return_t
331 priv_getdns_rr_list_from_list(struct getdns_list *list, ldns_rr_list **rr_list)
332 {
333 getdns_return_t r;
334 size_t i, l;
335 struct getdns_dict *rr_dict;
336 ldns_rr *rr;
337
338 if ((r = getdns_list_get_length(list, &l)))
339 return r;
340
341 if (! (*rr_list = ldns_rr_list_new()))
342 return GETDNS_RETURN_MEMORY_ERROR;
343
344 for (i = 0; i < l; i++) {
345 if ((r = getdns_list_get_dict(list, i, &rr_dict)))
346 break;
347
348 if ((r = priv_getdns_create_rr_from_dict(rr_dict, &rr)))
349 break;
350
351 if (! ldns_rr_list_push_rr(*rr_list, rr)) {
352 ldns_rr_free(rr);
353 r = GETDNS_RETURN_GENERIC_ERROR;
354 break;
355 }
356 }
357 if (r)
358 ldns_rr_list_deep_free(*rr_list);
359 return r;
360 }
361
362 static getdns_return_t
363 priv_getdns_dnssec_zone_from_list(struct getdns_list *list,
364 ldns_dnssec_zone **zone)
365 {
366 getdns_return_t r;
367 size_t i, l;
368 struct getdns_dict *rr_dict;
369 ldns_rr *rr;
370 ldns_status s;
371
372 if ((r = getdns_list_get_length(list, &l)))
373 return r;
374
375 if (! (*zone = ldns_dnssec_zone_new()))
376 return GETDNS_RETURN_MEMORY_ERROR;
377
378 for (i = 0; i < l; i++) {
379 if ((r = getdns_list_get_dict(list, i, &rr_dict)))
380 break;
381
382 if ((r = priv_getdns_create_rr_from_dict(rr_dict, &rr)))
383 break;
384
385 if ((s = ldns_dnssec_zone_add_rr(*zone, rr))) {
386 ldns_rr_free(rr);
387 r = GETDNS_RETURN_GENERIC_ERROR;
388 break;
389 }
390 }
391 if (r)
392 ldns_dnssec_zone_free(*zone);
393 return r;
394 }
395
396 typedef struct zone_iter {
397 ldns_dnssec_zone *zone;
398 ldns_rbnode_t *cur_node;
399 ldns_dnssec_rrsets *cur_rrset;
400 } zone_iter;
401
402 static void
403 rrset_iter_init_zone(zone_iter *i, ldns_dnssec_zone *zone)
404 {
405 assert(i);
406
407 i->zone = zone;
408 i->cur_node = zone->names ? ldns_rbtree_first(zone->names)
409 : LDNS_RBTREE_NULL;
410 i->cur_rrset = i->cur_node != LDNS_RBTREE_NULL
411 ? ((ldns_dnssec_name *)i->cur_node->data)->rrsets
412 : NULL;
413 }
414
415 static ldns_dnssec_rrsets *
416 rrset_iter_value(zone_iter *i)
417 {
418 assert(i);
419
420 return i->cur_rrset;
421 }
422
423 static void
424 rrset_iter_next(zone_iter *i)
425 {
426 assert(i);
427
428 if (! i->cur_rrset)
429 return;
430
431 if (! (i->cur_rrset = i->cur_rrset->next)) {
432 i->cur_node = ldns_rbtree_next(i->cur_node);
433 i->cur_rrset = i->cur_node != LDNS_RBTREE_NULL
434 ? ((ldns_dnssec_name *)i->cur_node->data)->rrsets
435 : NULL;
436 }
437 }
438
439 static ldns_rr_list *
440 rrs2rr_list(ldns_dnssec_rrs *rrs)
441 {
442 ldns_rr_list *r = ldns_rr_list_new();
443 if (r)
444 while (rrs) {
445 (void) ldns_rr_list_push_rr(r, rrs->rr);
446 rrs = rrs->next;
447 }
448 return r;
449 }
450
451 static ldns_status
452 verify_rrset(ldns_dnssec_rrsets *rrset_and_sigs,
453 const ldns_rr_list *keys, ldns_rr_list *good_keys)
454 {
455 ldns_status s;
456 ldns_rr_list *rrset = rrs2rr_list(rrset_and_sigs->rrs);
457 ldns_rr_list *sigs = rrs2rr_list(rrset_and_sigs->signatures);
458 s = ldns_verify(rrset, sigs, keys, good_keys);
459 ldns_rr_list_free(sigs);
460 ldns_rr_list_free(rrset);
461 return s;
462 }
463
464 static ldns_status
465 chase(ldns_dnssec_rrsets *rrset, ldns_dnssec_zone *support,
466 ldns_rr_list *support_keys, ldns_rr_list *trusted)
467 {
468 ldns_status s;
469 ldns_rr_list *verifying_keys;
470 size_t i, j;
471 ldns_rr *rr;
472 ldns_dnssec_rrsets *key_rrset;
473 ldns_dnssec_rrs *rrs;
474
475 /* Secure by trusted keys? */
476 s = verify_rrset(rrset, trusted, NULL);
477 if (s == 0)
478 return s;
479
480 /* No, chase with support records..
481 * Is there a verifying key in the support records?
482 */
483 verifying_keys = ldns_rr_list_new();
484 s = verify_rrset(rrset, support_keys, verifying_keys);
485 if (s != 0)
486 goto done_free_verifying_keys;
487
488 /* Ok, we have verifying keys from the support records.
489 * Compare them with the *trusted* keys or DSes,
490 * or chase them further down the validation chain.
491 */
492 for (i = 0; i < ldns_rr_list_rr_count(verifying_keys); i++) {
493 /* Lookup the rrset for key rr from the support records */
494 rr = ldns_rr_list_rr(verifying_keys, i);
495 key_rrset = ldns_dnssec_zone_find_rrset(
496 support, ldns_rr_owner(rr), ldns_rr_get_type(rr));
497 if (! key_rrset) {
498 s = LDNS_STATUS_CRYPTO_NO_DNSKEY;
499 break;
500 }
501 /* When we signed ourselves, we have to cross domain border
502 * and look for a matching DS signed by a parents key
503 */
504 if (rrset == key_rrset) {
505 /* Is the verifying key trusted?
506 * (i.e. DS in trusted)
507 */
508 for (j = 0; j < ldns_rr_list_rr_count(trusted); j++)
509 if (ldns_rr_compare_ds(ldns_rr_list_rr(
510 trusted, j), rr))
511 break;
512 /* If so, check for the next verifying key
513 * (or exit SECURE)
514 */
515 if (j < ldns_rr_list_rr_count(trusted))
516 continue;
517
518 /* Search for a matching DS in the support records */
519 key_rrset = ldns_dnssec_zone_find_rrset(
520 support, ldns_rr_owner(rr), LDNS_RR_TYPE_DS);
521 if (! key_rrset) {
522 s = LDNS_STATUS_CRYPTO_NO_DNSKEY;
523 break;
524 }
525 /* Now check if DS matches the DNSKEY! */
526 for (rrs = key_rrset->rrs; rrs; rrs = rrs->next)
527 if (ldns_rr_compare_ds(rr, rrs->rr))
528 break;
529 if (! rrs) {
530 s = LDNS_STATUS_CRYPTO_NO_DNSKEY;
531 break;
532 }
533 }
534 /* Pursue the chase with the verifying key (or its DS) */
535 s = chase(key_rrset, support, support_keys, trusted);
536 if (s != 0)
537 break;
538 }
539 done_free_verifying_keys:
540 ldns_rr_list_free(verifying_keys);
541 return s;
542 }
543
544 /*
545 * getdns_validate_dnssec
546 *
547 */
548 getdns_return_t
549 getdns_validate_dnssec(struct getdns_list *records_to_validate,
550 struct getdns_list *support_records,
551 struct getdns_list *trust_anchors)
552 {
553 getdns_return_t r;
554 ldns_rr_list *trusted;
555 ldns_dnssec_zone *support;
556 ldns_rr_list *support_keys;
557 ldns_dnssec_zone *to_validate;
558 zone_iter i;
559 ldns_dnssec_rrsets *rrset;
560 ldns_dnssec_rrs *rrs;
561 ldns_status s = LDNS_STATUS_OK;
562
563 if ((r = priv_getdns_rr_list_from_list(trust_anchors, &trusted)))
564 return r;
565
566 if ((r = priv_getdns_dnssec_zone_from_list(
567 support_records, &support)))
568 goto done_free_trusted;
569
570 if ((r = priv_getdns_dnssec_zone_from_list(
571 records_to_validate, &to_validate)))
572 goto done_free_support;
573
574 if (! (support_keys = ldns_rr_list_new())) {
575 r = GETDNS_RETURN_MEMORY_ERROR;
576 goto done_free_to_validate;
577 }
578 /* Create a rr_list of all the keys in the support records */
579 for (rrset_iter_init_zone(&i, support);
580 (rrset = rrset_iter_value(&i)); rrset_iter_next(&i))
581
582 if (ldns_dnssec_rrsets_type(rrset) == LDNS_RR_TYPE_DS ||
583 ldns_dnssec_rrsets_type(rrset) == LDNS_RR_TYPE_DNSKEY)
584
585 for (rrs = rrset->rrs; rrs; rrs = rrs->next)
586 (void) ldns_rr_list_push_rr(
587 support_keys, rrs->rr);
588
589 /* Now walk through the rrsets to validate */
590 for (rrset_iter_init_zone(&i, to_validate);
591 (rrset = rrset_iter_value(&i)); rrset_iter_next(&i)) {
592
593 s |= chase(rrset, support, support_keys, trusted);
594 if (s != 0)
595 break;
596 }
597 if (s == LDNS_STATUS_CRYPTO_BOGUS)
598 r = GETDNS_DNSSEC_BOGUS;
599 else if (s != LDNS_STATUS_OK)
600 r = GETDNS_DNSSEC_INSECURE;
601 else
602 r = GETDNS_DNSSEC_SECURE;
603
604 ldns_rr_list_free(support_keys);
605 done_free_to_validate:
606 ldns_dnssec_zone_deep_free(to_validate);
607 done_free_support:
608 ldns_dnssec_zone_deep_free(support);
609 done_free_trusted:
610 ldns_rr_list_deep_free(trusted);
611 return r;
612 } /* getdns_validate_dnssec */
613
614 int
615 priv_getdns_parse_ta_file(time_t *ta_mtime, ldns_rr_list *ta_rrs)
616 {
617 uint32_t ttl = 3600;
618 ldns_rdf* orig = NULL, *prev = NULL;
619 int line = 1;
620 ldns_status s;
621 ldns_rr *rr;
622 int nkeys;
623 struct stat st;
624 FILE *in;
625
626 if (stat(TRUST_ANCHOR_FILE, &st) != 0)
627 return 0;
628
629 if (ta_mtime)
630 *ta_mtime = st.st_mtime;
631
632 in = fopen(TRUST_ANCHOR_FILE, "r");
633 if (!in)
634 return 0;
635
636 nkeys = 0;
637 while (! feof(in)) {
638 rr = NULL;
639 s = ldns_rr_new_frm_fp_l(&rr, in, &ttl, &orig, &prev, &line);
640 if (s == LDNS_STATUS_SYNTAX_EMPTY /* empty line */
641 || s == LDNS_STATUS_SYNTAX_TTL /* $TTL */
642 || s == LDNS_STATUS_SYNTAX_ORIGIN /* $ORIGIN */)
643 continue;
644
645 if (s != LDNS_STATUS_OK) {
646 ldns_rr_free(rr);
647 nkeys = 0;
648 break;
649 }
650 if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_DS ||
651 ldns_rr_get_type(rr) == LDNS_RR_TYPE_DNSKEY) {
652
653 nkeys++;
654 if (ta_rrs) {
655 ldns_rr_list_push_rr(ta_rrs, rr);
656 continue;
657 }
658 }
659 ldns_rr_free(rr);
660 }
661 ldns_rdf_deep_free(orig);
662 ldns_rdf_deep_free(prev);
663 fclose(in);
664 return nkeys;
665 }
666
667 getdns_list *
668 getdns_root_trust_anchor(time_t *utc_date_of_anchor)
669 {
670 getdns_list *tas_gd_list = NULL;
671 ldns_rr_list *tas_rr_list = ldns_rr_list_new();
672
673 if (! tas_rr_list)
674 return NULL;
675
676 if (! priv_getdns_parse_ta_file(utc_date_of_anchor, tas_rr_list)) {
677 goto done_free_tas_rr_list;
678 return NULL;
679 }
680 tas_gd_list = create_list_from_rr_list(NULL, tas_rr_list);
681
682 done_free_tas_rr_list:
683 ldns_rr_list_deep_free(tas_rr_list);
684 return tas_gd_list;
685 }
686
687 /* dnssec.c */
0 /**
1 *
2 * /brief functions for DNSSEC
3 *
4 * The priv_getdns_get_validation_chain function is called after an answer
5 * has been fetched when the dnssec_return_validation_chain extension is set.
6 * It fetches DNSKEYs, DSes and their signatures for all RRSIGs found in the
7 * answer.
8 */
9
10 /*
11 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are met:
16 * * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * * Neither the names of the copyright holders nor the
22 * names of its contributors may be used to endorse or promote products
23 * derived from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
29 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #ifndef DNSSEC_H_
38 #define DNSSEC_H_
39
40 #include "getdns/getdns.h"
41 #include "types-internal.h"
42
43 /* Do some additional requests to fetch the complete validation chain */
44 void priv_getdns_get_validation_chain(getdns_dns_req *dns_req);
45
46 struct getdns_dict * priv_getdns_get_validation_chain_sync(
47 getdns_dns_req *dns_req);
48
49 int priv_getdns_parse_ta_file(time_t *ta_mtime, ldns_rr_list *ta_rrs);
50
51 #endif
52
53 /* dnssec.h */
0 #
1 # @configure_input@
2 #
3 # Copyright (c) 2013, Verisign, Inc., NLNet Labs
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 are met:
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # * Neither the names of the copyright holders nor the
14 # names of its contributors may be used to endorse or promote products
15 # derived from this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
21 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 package = @PACKAGE_NAME@
29 version = @PACKAGE_VERSION@
30 tarname = @PACKAGE_TARNAME@
31 distdir = $(tarname)-$(version)
32
33 prefix = @prefix@
34 exec_prefix = @exec_prefix@
35 bindir = @bindir@
36 LIBTOOL = ../../libtool
37
38 srcdir = @srcdir@
39 VPATH = @srcdir@
40
41 CC=@CC@
42 CFLAGS=@CFLAGS@ -Wall -I$(srcdir)/ -I$(srcdir)/../ -I/usr/local/include -std=c99
43 LDFLAGS=@LDFLAGS@ -L. -L.. -L$(srcdir)/../ -L/usr/local/lib
44 LDLIBS=-lgetdns -lgetdns_ext_event @LIBS@
45 PROGRAMS=example-all-functions example-simple-answers example-tree example-synchronous example-reverse
46
47 .SUFFIXES: .c .o .a .lo .h
48
49 .c.o:
50 $(CC) $(CFLAGS) -c $< -o $@
51
52 default: all
53 example: all
54
55 all: $(PROGRAMS)
56
57 example-all-functions: example-all-functions.o
58 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ example-all-functions.o
59
60 example-simple-answers: example-simple-answers.o
61 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ example-simple-answers.o
62
63 example-tree: example-tree.o
64 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ example-tree.o
65
66 example-synchronous: example-synchronous.o
67 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ example-synchronous.o
68
69 example-reverse: example-reverse.o
70 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ example-reverse.o
71
72 clean:
73 rm -f *.o $(PROGRAMS)
74 rm -rf .libs
75
76 distclean : clean
77 rm -f Makefile config.status config.log
78 rm -Rf autom4te.cache
79
80 $(distdir): FORCE
81 mkdir -p $(distdir)/src
82 cp configure.ac $(distdir)
83 cp configure $(distdir)
84 cp Makefile.in $(distdir)
85 cp src/Makefile.in $(distdir)/src
86
87 distcheck: $(distdir).tar.gz
88 gzip -cd $(distdir).tar.gz | tar xvf -
89 cd $(distdir) && ./configure
90 cd $(distdir) && $(MAKE) all
91 cd $(distdir) && $(MAKE) check
92 cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst install
93 cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst uninstall
94 @remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \
95 if test "$${remaining}" -ne 0; then
96 echo "@@@ $${remaining} file(s) remaining in stage directory!"; \
97 exit 1; \
98 fi
99 cd $(distdir) && $(MAKE) clean
100 rm -rf $(distdir)
101 @echo "*** Package $(distdir).tar.gz is ready for distribution"
102
103 Makefile: Makefile.in ../../config.status
104 cd ../.. && ./config.status $@
105
106 configure.status: configure
107 cd ../.. && ./config.status --recheck
108
109 .PHONY: clean
0 #include <stdio.h>
1 #include <stdint.h>
2 #include <inttypes.h>
3 #include <stdlib.h>
4 #include <string.h>
5 #include <getdns_libevent.h>
6
7 #define UNUSED_PARAM(x) ((void)(x))
8
9 /* The return values */
10 getdns_return_t retregular;
11 char * retcharstar;
12
13 /* The args */
14 int boolarg;
15 char * charstararg;
16 char ** charstarptrarg;
17 getdns_callback_t callbackarg;
18 uint16_t regulararg;
19 uint16_t *regularptrarg;
20 getdns_transaction_t txidarg;
21 getdns_transaction_t * txidptrarg;
22 getdns_namespace_t *namespaceptrarg;
23 getdns_resolution_t resolutionarg;
24 getdns_redirects_t redirectsarg;
25 getdns_transport_t transportarg;
26 getdns_append_name_t appendnamearg;
27
28 getdns_data_type * datatypeptrarg;
29 getdns_bindata ** bindataptrarg;
30 getdns_dict * dictarg;
31 getdns_bindata * bindataarg;
32 getdns_list * listarg;
33 getdns_dict ** dictptrarg;
34 getdns_list ** listptrarg;
35
36 size_t sizetarg;
37 size_t * sizetptrarg;
38 getdns_context *contextarg = NULL;
39 uint8_t uint8arg;
40 uint16_t uint16arg;
41 uint32_t uint32arg;
42 uint8_t * uint8ptrarg;
43 uint16_t * uint16ptrarg;
44 uint32_t * uint32ptrarg;
45 void * arrayarg;
46 void * userarg;
47 void * allocfunctionarg(size_t foo) {UNUSED_PARAM(foo); return NULL; }
48 void * reallocfunctionarg(void* foo, size_t bar)
49 {UNUSED_PARAM(foo); UNUSED_PARAM(bar); return NULL; }
50 void deallocfunctionarg(void* foo) {UNUSED_PARAM(foo);}
51 void * extendedallocfunctionarg(void* userarg, size_t foo)
52 {UNUSED_PARAM(userarg); UNUSED_PARAM(foo); return NULL; }
53 void * extendedreallocfunctionarg(void* userarg, void* foo, size_t bar)
54 {UNUSED_PARAM(userarg); UNUSED_PARAM(foo); UNUSED_PARAM(bar); return NULL; }
55 void extendeddeallocfunctionarg(void* userarg, void* foo)
56 {UNUSED_PARAM(userarg); UNUSED_PARAM(foo);}
57 void setcallbackfunctionarg(getdns_context *foo1, getdns_context_code_t foo2)
58 {UNUSED_PARAM(foo1);UNUSED_PARAM(foo2);}
59
60 int main()
61 {
62
63 retregular = getdns_general(
64 contextarg,
65 charstararg,
66 uint16arg,
67 dictarg,
68 arrayarg,
69 txidptrarg,
70 callbackarg
71 );
72
73 retregular = getdns_address(
74 contextarg,
75 charstararg,
76 dictarg,
77 arrayarg,
78 txidptrarg,
79 callbackarg
80 );
81
82 retregular = getdns_hostname(
83 contextarg,
84 dictarg,
85 dictarg,
86 arrayarg,
87 txidptrarg,
88 callbackarg
89 );
90
91 retregular = getdns_service(
92 contextarg,
93 charstararg,
94 dictarg,
95 arrayarg,
96 txidptrarg,
97 callbackarg
98 );
99
100 retregular = getdns_context_create(
101 &contextarg,
102 boolarg
103 );
104
105 retregular = getdns_context_create_with_memory_functions(
106 &contextarg,
107 boolarg,
108 allocfunctionarg,
109 reallocfunctionarg,
110 deallocfunctionarg
111 );
112
113 retregular = getdns_context_create_with_extended_memory_functions(
114 &contextarg,
115 boolarg,
116 userarg,
117 extendedallocfunctionarg,
118 extendedreallocfunctionarg,
119 extendeddeallocfunctionarg
120 );
121
122 getdns_context_destroy(
123 contextarg
124 );
125
126 retregular = getdns_cancel_callback(
127 contextarg,
128 txidarg
129 );
130
131 retregular = getdns_general_sync(
132 contextarg,
133 charstararg,
134 uint16arg,
135 dictarg,
136 &dictarg
137 );
138
139 retregular = getdns_address_sync(
140 contextarg,
141 charstararg,
142 dictarg,
143 &dictarg
144 );
145
146 retregular = getdns_hostname_sync(
147 contextarg,
148 dictarg,
149 dictarg,
150 &dictarg
151 );
152
153 retregular = getdns_service_sync(
154 contextarg,
155 charstararg,
156 dictarg,
157 &dictarg
158 );
159
160 retregular = getdns_list_get_length(listarg, sizetptrarg);
161 retregular = getdns_list_get_data_type(listarg, sizetarg, datatypeptrarg);
162 retregular = getdns_list_get_dict(listarg, sizetarg, dictptrarg);
163 retregular = getdns_list_get_list(listarg, sizetarg, listptrarg);
164 retregular = getdns_list_get_bindata(listarg, sizetarg, bindataptrarg);
165 retregular = getdns_list_get_int(listarg, sizetarg, uint32ptrarg);
166
167 retregular = getdns_dict_get_names(dictarg, listptrarg);
168 retregular = getdns_dict_get_data_type(dictarg, charstararg, datatypeptrarg);
169 retregular = getdns_dict_get_dict(dictarg, charstararg, dictptrarg);
170 retregular = getdns_dict_get_list(dictarg, charstararg, listptrarg);
171 retregular = getdns_dict_get_bindata(dictarg, charstararg, bindataptrarg);
172 retregular = getdns_dict_get_int(dictarg, charstararg, uint32ptrarg);
173
174 listarg = getdns_list_create();
175 listarg = getdns_list_create_with_context(contextarg);
176 listarg = getdns_list_create_with_memory_functions(
177 allocfunctionarg,
178 reallocfunctionarg,
179 deallocfunctionarg
180 );
181 listarg = getdns_list_create_with_extended_memory_functions(
182 userarg,
183 extendedallocfunctionarg,
184 extendedreallocfunctionarg,
185 extendeddeallocfunctionarg
186 );
187 getdns_list_destroy(listarg);
188 retregular = getdns_list_set_dict(listarg, sizetarg, dictarg);
189 retregular = getdns_list_set_list(listarg, sizetarg, listarg);
190 retregular = getdns_list_set_bindata(listarg, sizetarg, bindataarg);
191 retregular = getdns_list_set_int(listarg, sizetarg, uint32arg);
192
193 dictarg = getdns_dict_create();
194 dictarg = getdns_dict_create_with_context(contextarg);
195 dictarg = getdns_dict_create_with_memory_functions(
196 allocfunctionarg,
197 reallocfunctionarg,
198 deallocfunctionarg
199 );
200 dictarg = getdns_dict_create_with_extended_memory_functions(
201 userarg,
202 extendedallocfunctionarg,
203 extendedreallocfunctionarg,
204 extendeddeallocfunctionarg
205 );
206 getdns_dict_destroy(dictarg);
207 retregular = getdns_dict_set_dict(dictarg, charstararg, dictarg);
208 retregular = getdns_dict_set_list(dictarg, charstararg, listarg);
209 retregular = getdns_dict_set_bindata(dictarg, charstararg, bindataarg);
210 retregular = getdns_dict_set_int(dictarg, charstararg, uint32arg);
211 retregular = getdns_dict_remove_name(dictarg, charstararg);
212
213 retregular = getdns_convert_fqdn_to_dns_name(
214 charstararg,
215 bindataptrarg
216 );
217
218 retregular = getdns_convert_dns_name_to_fqdn(
219 bindataarg,
220 charstarptrarg
221 );
222
223 retcharstar = getdns_convert_ulabel_to_alabel(
224 charstararg
225 );
226
227 retcharstar = getdns_convert_alabel_to_ulabel(
228 charstararg
229 );
230
231 retregular = getdns_validate_dnssec(
232 listarg,
233 listarg,
234 listarg
235 );
236
237 retcharstar = getdns_pretty_print_dict(
238 dictarg
239 );
240
241 retcharstar = getdns_display_ip_address(
242 bindataarg
243 );
244
245 retregular = getdns_context_set_context_update_callback(
246 contextarg,
247 setcallbackfunctionarg
248 );
249
250 retregular = getdns_context_set_resolution_type(
251 contextarg,
252 resolutionarg
253 );
254
255 retregular = getdns_context_set_namespaces(
256 contextarg,
257 sizetarg,
258 namespaceptrarg
259 );
260
261 retregular = getdns_context_set_dns_transport(
262 contextarg,
263 transportarg
264 );
265
266 retregular = getdns_context_set_limit_outstanding_queries(
267 contextarg,
268 uint16arg
269 );
270
271 retregular = getdns_context_set_timeout(
272 contextarg,
273 uint16arg
274 );
275
276 retregular = getdns_context_set_follow_redirects(
277 contextarg,
278 redirectsarg
279 );
280
281 retregular = getdns_context_set_dns_root_servers(
282 contextarg,
283 listarg
284 );
285
286 retregular = getdns_context_set_append_name(
287 contextarg,
288 appendnamearg
289 );
290
291 retregular = getdns_context_set_suffix(
292 contextarg,
293 listarg
294 );
295
296 retregular = getdns_context_set_dnssec_trust_anchors(
297 contextarg,
298 listarg
299 );
300
301 retregular = getdns_context_set_dnssec_allowed_skew(
302 contextarg,
303 uint16arg
304 );
305
306 retregular = getdns_context_set_upstream_recursive_servers(
307 contextarg,
308 listarg
309 );
310
311 retregular = getdns_context_set_edns_maximum_udp_payload_size(
312 contextarg,
313 uint16arg
314 );
315
316 retregular = getdns_context_set_edns_extended_rcode(
317 contextarg,
318 uint8arg
319 );
320
321 retregular = getdns_context_set_edns_version(
322 contextarg,
323 uint8arg
324 );
325
326 retregular = getdns_context_set_edns_do_bit(
327 contextarg,
328 uint8arg
329 );
330
331 retregular = getdns_context_set_memory_functions(
332 contextarg,
333 allocfunctionarg,
334 reallocfunctionarg,
335 deallocfunctionarg
336 );
337
338 retregular = getdns_context_set_extended_memory_functions(
339 contextarg,
340 userarg,
341 extendedallocfunctionarg,
342 extendedreallocfunctionarg,
343 extendeddeallocfunctionarg
344 );
345
346 return(0); } /* End of main() */
0 #include <stdio.h>
1 #include <stdint.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <inttypes.h>
5 #include <getdns_libevent.h>
6
7 #define UNUSED_PARAM(x) ((void)(x))
8
9 /* Set up the callback function, which will also do the processing of the results */
10 void this_callbackfn(getdns_context *this_context,
11 getdns_callback_type_t this_callback_type,
12 getdns_dict *this_response,
13 void *this_userarg,
14 getdns_transaction_t this_transaction_id)
15 {
16 getdns_return_t this_ret; /* Holder for all function returns */
17 UNUSED_PARAM(this_userarg); /* Not looking at the userarg for this example */
18 UNUSED_PARAM(this_context); /* Not looking at the context for this example */
19 UNUSED_PARAM(this_ret); /* Set, but not read */
20 if (this_callback_type == GETDNS_CALLBACK_COMPLETE) /* This is a callback with data */
21 {
22 /* Be sure the search returned something */
23 uint32_t this_error;
24 this_ret = getdns_dict_get_int(this_response, "status", &this_error); // Ignore any error
25 if (this_error != GETDNS_RESPSTATUS_GOOD) // If the search didn't return "good"
26 {
27 fprintf(stderr, "The search had no results, and a return value of %d. Exiting.\n", this_error);
28 getdns_dict_destroy(this_response);
29 return;
30 }
31 getdns_list *replies_tree;
32 this_ret = getdns_dict_get_list(this_response, "replies_tree", &replies_tree); // Ignore any error
33 size_t num_replies;
34 this_ret = getdns_list_get_length(replies_tree, &num_replies); // Ignore any error
35 /* Go through each reply */
36 for ( size_t reply_count = 0; reply_count < num_replies; ++reply_count)
37 {
38 getdns_dict * this_reply;
39 this_ret = getdns_list_get_dict(replies_tree, reply_count, &this_reply); // Ignore any error
40 /* Just print the address */
41 getdns_list* reply_answers;
42 this_ret = getdns_dict_get_list(this_reply, "answer", &reply_answers); // Ignore any error
43 size_t num_answers;
44 this_ret = getdns_list_get_length(reply_answers, &num_answers); // Ignore any error
45 /* Go through each answer */
46 for ( size_t answer_count = 0; answer_count < num_answers; ++answer_count)
47 {
48 getdns_dict * this_rr;
49 this_ret = getdns_list_get_dict(reply_answers, answer_count, &this_rr);
50 /* Get the RDATA type */
51 uint32_t this_type;
52 this_ret = getdns_dict_get_int(this_rr, "type", &this_type); // Ignore any error
53 if (this_type == GETDNS_RRTYPE_PTR)
54 {
55 getdns_dict *this_rdata;
56 this_ret = getdns_dict_get_dict(this_rr, "rdata", &this_rdata); // Ignore any error
57
58 getdns_bindata * this_dname;
59 this_ret = getdns_dict_get_bindata(this_rdata, "rdata_raw", &this_dname);
60 char *this_dname_str;
61 this_ret = getdns_convert_dns_name_to_fqdn(this_dname, &this_dname_str); // Ignore any error
62 printf("The dname is %s\n", this_dname_str);
63 free(this_dname_str);
64 }
65 }
66
67 }
68 }
69 else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
70 fprintf(stderr, "The callback with ID %"PRIu64" was cancelled. Exiting.", this_transaction_id);
71 else
72 fprintf(stderr, "The callback got a callback_type of %d. Exiting.", this_callback_type);
73 getdns_dict_destroy(this_response);
74 }
75
76 int main()
77 {
78 /* Create the DNS context for this call */
79 getdns_context *this_context = NULL;
80 getdns_return_t context_create_return = getdns_context_create(&this_context, 1);
81 if (context_create_return != GETDNS_RETURN_GOOD)
82 {
83 fprintf(stderr, "Trying to create the context failed: %d", context_create_return);
84 return(GETDNS_RETURN_GENERIC_ERROR);
85 }
86 /* Create an event base and put it in the context using the unknown function name */
87 struct event_base *this_event_base;
88 this_event_base = event_base_new();
89 if (this_event_base == NULL)
90 {
91 fprintf(stderr, "Trying to create the event base failed.");
92 getdns_context_destroy(this_context);
93 return(GETDNS_RETURN_GENERIC_ERROR);
94 }
95 (void)getdns_extension_set_libevent_base(this_context, this_event_base);
96 /* Set up the getdns call */
97 getdns_dict * this_addr_to_look_up = getdns_dict_create();
98 // TODO: check the return value above
99 getdns_bindata this_type = { 4, (void *)"IPv4" };
100 getdns_return_t this_ret = getdns_dict_set_bindata(this_addr_to_look_up, "address_type", &this_type);
101 UNUSED_PARAM(this_ret);
102 getdns_bindata this_ipv4_addr = { 4, (void *)"\x08\x08\x08\x08" };
103 this_ret = getdns_dict_set_bindata(this_addr_to_look_up, "address_data", &this_ipv4_addr);
104 char* this_userarg = "somestring"; // Could add things here to help identify this call
105 getdns_transaction_t this_transaction_id = 0;
106
107 /* Make the call */
108 getdns_return_t dns_request_return = getdns_hostname(this_context, this_addr_to_look_up,
109 NULL, this_userarg, &this_transaction_id, this_callbackfn);
110 if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME)
111 {
112 char *ip_address_str = getdns_display_ip_address(&this_ipv4_addr);
113
114 fprintf(stderr, "A bad IP address was used: %s. Exiting.\n", ip_address_str);
115 free(ip_address_str);
116 getdns_dict_destroy(this_addr_to_look_up);
117 event_base_free(this_event_base);
118 getdns_context_destroy(this_context);
119 return(GETDNS_RETURN_GENERIC_ERROR);
120 }
121 else
122 {
123 /* Call the event loop */
124 int dispatch_return = event_base_dispatch(this_event_base);
125 UNUSED_PARAM(dispatch_return);
126 // TODO: check the return value above
127 }
128 /* Clean up */
129 getdns_dict_destroy(this_addr_to_look_up);
130 event_base_free(this_event_base);
131 getdns_context_destroy(this_context);
132 /* Assuming we get here, leave gracefully */
133 exit(EXIT_SUCCESS);
134 }
0 #include <stdio.h>
1 #include <stdint.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <inttypes.h>
5 #include <getdns_libevent.h>
6
7 #define UNUSED_PARAM(x) ((void)(x))
8
9 /* Set up the callback function, which will also do the processing of the results */
10 void this_callbackfn(getdns_context *this_context,
11 getdns_callback_type_t this_callback_type,
12 getdns_dict *this_response,
13 void *this_userarg,
14 getdns_transaction_t this_transaction_id)
15 {
16 UNUSED_PARAM(this_userarg); /* Not looking at the userarg for this example */
17 UNUSED_PARAM(this_context); /* Not looking at the context for this example */
18 getdns_return_t this_ret; /* Holder for all function returns */
19 if (this_callback_type == GETDNS_CALLBACK_COMPLETE) /* This is a callback with data */
20 {
21 /* Be sure the search returned something */
22 uint32_t this_error;
23 this_ret = getdns_dict_get_int(this_response, "status", &this_error); // Ignore any error
24 if (this_error != GETDNS_RESPSTATUS_GOOD) // If the search didn't return "good"
25 {
26 fprintf(stderr, "The search had no results, and a return value of %d. Exiting.\n", this_error);
27 getdns_dict_destroy(this_response);
28 return;
29 }
30 getdns_list * just_the_addresses_ptr;
31 this_ret = getdns_dict_get_list(this_response, "just_address_answers", &just_the_addresses_ptr);
32 if (this_ret != GETDNS_RETURN_GOOD) // This check is really not needed, but prevents a compiler error under "pedantic"
33 {
34 fprintf(stderr, "Trying to get the answers failed: %d\n", this_ret);
35 getdns_dict_destroy(this_response);
36 return;
37 }
38 size_t num_addresses;
39 this_ret = getdns_list_get_length(just_the_addresses_ptr, &num_addresses); // Ignore any error
40 /* Go through each record */
41 for ( size_t rec_count = 0; rec_count < num_addresses; ++rec_count )
42 {
43 getdns_dict * this_address;
44 this_ret = getdns_list_get_dict(just_the_addresses_ptr, rec_count, &this_address); // Ignore any error
45 /* Just print the address */
46 getdns_bindata * this_address_data;
47 this_ret = getdns_dict_get_bindata(this_address, "address_data", &this_address_data); // Ignore any error
48 char *this_address_str = getdns_display_ip_address(this_address_data);
49 printf("The address is %s\n", this_address_str);
50 free(this_address_str);
51 }
52 }
53 else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
54 fprintf(stderr, "The callback with ID %"PRIu64" was cancelled. Exiting.\n", this_transaction_id);
55 else
56 fprintf(stderr, "The callback got a callback_type of %d. Exiting.\n", this_callback_type);
57 getdns_dict_destroy(this_response);
58 }
59
60 int main()
61 {
62 /* Create the DNS context for this call */
63 getdns_context *this_context = NULL;
64 getdns_return_t context_create_return = getdns_context_create(&this_context, 1);
65 if (context_create_return != GETDNS_RETURN_GOOD)
66 {
67 fprintf(stderr, "Trying to create the context failed: %d", context_create_return);
68 return(GETDNS_RETURN_GENERIC_ERROR);
69 }
70 /* Create an event base and put it in the context using the unknown function name */
71 struct event_base *this_event_base;
72 this_event_base = event_base_new();
73 if (this_event_base == NULL)
74 {
75 fprintf(stderr, "Trying to create the event base failed.\n");
76 getdns_context_destroy(this_context);
77 return(GETDNS_RETURN_GENERIC_ERROR);
78 }
79 (void)getdns_extension_set_libevent_base(this_context, this_event_base);
80 /* Set up the getdns call */
81 const char * this_name = "www.example.com";
82 char* this_userarg = "somestring"; // Could add things here to help identify this call
83 getdns_transaction_t this_transaction_id = 0;
84
85 /* Make the call */
86 getdns_return_t dns_request_return = getdns_address(this_context, this_name,
87 NULL, this_userarg, &this_transaction_id, this_callbackfn);
88 if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME)
89 {
90 fprintf(stderr, "A bad domain name was used: %s. Exiting.\n", this_name);
91 event_base_free(this_event_base);
92 getdns_context_destroy(this_context);
93 return(GETDNS_RETURN_GENERIC_ERROR);
94 }
95 else
96 {
97 /* Call the event loop */
98 int dispatch_return = event_base_dispatch(this_event_base);
99 UNUSED_PARAM(dispatch_return);
100 // TODO: check the return value above
101 }
102 /* Clean up */
103 event_base_free(this_event_base);
104 getdns_context_destroy(this_context);
105 /* Assuming we get here, leave gracefully */
106 exit(EXIT_SUCCESS);
107 }
0 #include <stdio.h>
1 #include <stdint.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <inttypes.h>
5 #include <getdns_core_only.h>
6
7 int main()
8 {
9 getdns_return_t this_ret; /* Holder for all function returns */
10 /* Create the DNS context for this call */
11 getdns_context *this_context = NULL;
12 getdns_return_t context_create_return = getdns_context_create(&this_context, 1);
13 if (context_create_return != GETDNS_RETURN_GOOD)
14 {
15 fprintf(stderr, "Trying to create the context failed: %d\n", context_create_return);
16 return(GETDNS_RETURN_GENERIC_ERROR);
17 }
18 /* Set up the getdns_sync_request call */
19 const char * this_name = "www.example.com";
20 uint8_t this_request_type = GETDNS_RRTYPE_A;
21 /* Get the A and AAAA records */
22 getdns_dict * this_extensions = getdns_dict_create();
23 this_ret = getdns_dict_set_int(this_extensions, "return_both_v4_and_v6", GETDNS_EXTENSION_TRUE);
24 if (this_ret != GETDNS_RETURN_GOOD)
25 {
26 fprintf(stderr, "Trying to set an extension do both IPv4 and IPv6 failed: %d\n", this_ret);
27 getdns_dict_destroy(this_extensions);
28 getdns_context_destroy(this_context);
29 return(GETDNS_RETURN_GENERIC_ERROR);
30 }
31 getdns_dict * this_response = NULL;
32
33 /* Make the call */
34 getdns_return_t dns_request_return = getdns_general_sync(this_context, this_name, this_request_type,
35 this_extensions, &this_response);
36 if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME)
37 {
38 fprintf(stderr, "A bad domain name was used: %s. Exiting.\n", this_name);
39 getdns_dict_destroy(this_response);
40 getdns_dict_destroy(this_extensions);
41 getdns_context_destroy(this_context);
42 return(GETDNS_RETURN_GENERIC_ERROR);
43 }
44 else
45 {
46 /* Be sure the search returned something */
47 uint32_t this_error;
48 this_ret = getdns_dict_get_int(this_response, "status", &this_error); // Ignore any error
49 if (this_error != GETDNS_RESPSTATUS_GOOD) // If the search didn't return "good"
50 {
51 fprintf(stderr, "The search had no results, and a return value of %d. Exiting.\n", this_error);
52 getdns_dict_destroy(this_response);
53 getdns_dict_destroy(this_extensions);
54 getdns_context_destroy(this_context);
55 return(GETDNS_RETURN_GENERIC_ERROR);
56 }
57 getdns_list * just_the_addresses_ptr;
58 this_ret = getdns_dict_get_list(this_response, "just_address_answers", &just_the_addresses_ptr); // Ignore any error
59 size_t num_addresses;
60 this_ret = getdns_list_get_length(just_the_addresses_ptr, &num_addresses); // Ignore any error
61 /* Go through each record */
62 for ( size_t rec_count = 0; rec_count < num_addresses; ++rec_count )
63 {
64 getdns_dict * this_address;
65 this_ret = getdns_list_get_dict(just_the_addresses_ptr, rec_count, &this_address); // Ignore any error
66 /* Just print the address */
67 getdns_bindata * this_address_data;
68 this_ret = getdns_dict_get_bindata(this_address, "address_data", &this_address_data); // Ignore any error
69 char *this_address_str = getdns_display_ip_address(this_address_data);
70 printf("The address is %s\n", this_address_str);
71 free(this_address_str);
72 }
73 }
74 /* Clean up */
75 getdns_dict_destroy(this_response);
76 getdns_dict_destroy(this_extensions);
77 getdns_context_destroy(this_context);
78 /* Assuming we get here, leave gracefully */
79 exit(EXIT_SUCCESS);
80 }
0 #include <stdio.h>
1 #include <stdint.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <inttypes.h>
5 #include <getdns_libevent.h>
6
7 #define UNUSED_PARAM(x) ((void)(x))
8
9 /* Set up the callback function, which will also do the processing of the results */
10 void this_callbackfn(getdns_context *this_context,
11 getdns_callback_type_t this_callback_type,
12 getdns_dict *this_response,
13 void *this_userarg,
14 getdns_transaction_t this_transaction_id)
15 {
16 UNUSED_PARAM(this_userarg); /* Not looking at the userarg for this example */
17 UNUSED_PARAM(this_context); /* Not looking at the context for this example */
18 getdns_return_t this_ret; /* Holder for all function returns */
19 if (this_callback_type == GETDNS_CALLBACK_COMPLETE) /* This is a callback with data */
20 {
21 /* Be sure the search returned something */
22 uint32_t this_error;
23 this_ret = getdns_dict_get_int(this_response, "status", &this_error); // Ignore any error
24 if (this_error != GETDNS_RESPSTATUS_GOOD) // If the search didn't return "good"
25 {
26 fprintf(stderr, "The search had no results, and a return value of %d. Exiting.\n", this_error);
27 getdns_dict_destroy(this_response);
28 return;
29 }
30 /* Find all the answers returned */
31 getdns_list * these_answers;
32 this_ret = getdns_dict_get_list(this_response, "replies_tree", &these_answers);
33 if (this_ret == GETDNS_RETURN_NO_SUCH_DICT_NAME)
34 {
35 fprintf(stderr, "Weird: the response had no error, but also no replies_tree. Exiting.\n");
36 getdns_dict_destroy(this_response);
37 return;
38 }
39 size_t num_answers;
40 this_ret = getdns_list_get_length(these_answers, &num_answers);
41 /* Go through each answer */
42 for ( size_t rec_count = 0; rec_count < num_answers; ++rec_count )
43 {
44 getdns_dict * this_record;
45 this_ret = getdns_list_get_dict(these_answers, rec_count, &this_record); // Ignore any error
46 /* Get the answer section */
47 getdns_list * this_answer;
48 this_ret = getdns_dict_get_list(this_record, "answer", &this_answer); // Ignore any error
49 /* Get each RR in the answer section */
50 size_t num_rrs;
51 this_ret = getdns_list_get_length(this_answer, &num_rrs);
52 for ( size_t rr_count = 0; rr_count < num_rrs; ++rr_count )
53 {
54 getdns_dict *this_rr = NULL;
55 this_ret = getdns_list_get_dict(this_answer, rr_count, &this_rr); // Ignore any error
56 /* Get the RDATA */
57 getdns_dict * this_rdata = NULL;
58 this_ret = getdns_dict_get_dict(this_rr, "rdata", &this_rdata); // Ignore any error
59 /* Get the RDATA type */
60 uint32_t this_type;
61 this_ret = getdns_dict_get_int(this_rr, "type", &this_type); // Ignore any error
62 /* If it is type A or AAAA, print the value */
63 if (this_type == GETDNS_RRTYPE_A)
64 {
65 getdns_bindata * this_a_record = NULL;
66 this_ret = getdns_dict_get_bindata(this_rdata, "ipv4_address", &this_a_record);
67 if (this_ret == GETDNS_RETURN_NO_SUCH_DICT_NAME)
68 {
69 fprintf(stderr, "Weird: the A record at %d in record at %d had no address. Exiting.\n",
70 (int) rr_count, (int) rec_count);
71 getdns_dict_destroy(this_response);
72 return;
73 }
74 char *this_address_str = getdns_display_ip_address(this_a_record);
75 printf("The IPv4 address is %s\n", this_address_str);
76 free(this_address_str);
77 }
78 else if (this_type == GETDNS_RRTYPE_AAAA)
79 {
80 getdns_bindata * this_aaaa_record = NULL;
81 this_ret = getdns_dict_get_bindata(this_rdata, "ipv6_address", &this_aaaa_record);
82 if (this_ret == GETDNS_RETURN_NO_SUCH_DICT_NAME)
83 {
84 fprintf(stderr, "Weird: the AAAA record at %d in record at %d had no address. Exiting.\n",
85 (int) rr_count, (int) rec_count);
86 getdns_dict_destroy(this_response);
87 return;
88 }
89 char *this_address_str = getdns_display_ip_address(this_aaaa_record);
90 printf("The IPv6 address is %s\n", this_address_str);
91 free(this_address_str);
92 }
93 }
94 }
95 }
96 else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
97 fprintf(stderr, "The callback with ID %"PRIu64" was cancelled. Exiting.\n", this_transaction_id);
98 else
99 fprintf(stderr, "The callback got a callback_type of %d. Exiting.\n", this_callback_type);
100 getdns_dict_destroy(this_response);
101 }
102
103 int main()
104 {
105 /* Create the DNS context for this call */
106 getdns_context *this_context = NULL;
107 getdns_return_t context_create_return = getdns_context_create(&this_context, 1);
108 if (context_create_return != GETDNS_RETURN_GOOD)
109 {
110 fprintf(stderr, "Trying to create the context failed: %d\n", context_create_return);
111 return(GETDNS_RETURN_GENERIC_ERROR);
112 }
113 /* Create an event base and put it in the context using the unknown function name */
114 struct event_base *this_event_base;
115 this_event_base = event_base_new();
116 if (this_event_base == NULL)
117 {
118 fprintf(stderr, "Trying to create the event base failed.\n");
119 getdns_context_destroy(this_context);
120 return(GETDNS_RETURN_GENERIC_ERROR);
121 }
122 (void)getdns_extension_set_libevent_base(this_context, this_event_base);
123 /* Set up the getdns call */
124 const char * this_name = "www.example.com";
125 char* this_userarg = "somestring"; // Could add things here to help identify this call
126 getdns_transaction_t this_transaction_id = 0;
127
128 /* Make the call */
129 getdns_return_t dns_request_return = getdns_address(this_context, this_name,
130 NULL, this_userarg, &this_transaction_id, this_callbackfn);
131 if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME)
132 {
133 fprintf(stderr, "A bad domain name was used: %s. Exiting.\n", this_name);
134 event_base_free(this_event_base);
135 getdns_context_destroy(this_context);
136 return(GETDNS_RETURN_GENERIC_ERROR);
137 }
138 else
139 {
140 /* Call the event loop */
141 int dispatch_return = event_base_dispatch(this_event_base);
142 UNUSED_PARAM(dispatch_return);
143 // TODO: check the return value above
144 }
145 /* Clean up */
146 event_base_free(this_event_base);
147 getdns_context_destroy(this_context);
148 /* Assuming we get here, leave gracefully */
149 exit(EXIT_SUCCESS);
150 }
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #include <getdns/getdns.h>
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #include <getdns/getdns.h>
27 #include <getdns/getdns_ext_libevent.h>
28 #ifdef HAVE_EVENT2_EVENT_H
29 #include <event2/event.h>
30 #else
31 # ifndef u_char
32 # define u_char unsigned char
33 # endif
34 #include <event.h>
35 #endif
0 /**
1 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7
8 /*
9 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include <getdns/getdns_ext_libev.h>
36 #include <sys/time.h>
37 #include <stdio.h>
38 #include <ev.h>
39
40 #define RETURN_IF_NULL(ptr, code) if(ptr == NULL) return code;
41
42 /* extension info */
43 struct getdns_libev_data {
44 struct ev_loop* loop;
45 struct ev_io* poll_handle;
46 };
47
48 static void
49 request_count_changed(uint32_t request_count, struct getdns_libev_data *ev_data) {
50 if (request_count > 0) {
51 ev_io_start(ev_data->loop, ev_data->poll_handle);
52 } else {
53 ev_io_stop(ev_data->loop, ev_data->poll_handle);
54 }
55 }
56
57 /* lib ev callbacks */
58 static void
59 getdns_libev_cb(struct ev_loop *loop, struct ev_io *handle, int revents) {
60 struct getdns_context* context = (struct getdns_context*) handle->data;
61 getdns_context_process_async(context);
62 uint32_t rc = getdns_context_get_num_pending_requests(context, NULL);
63 struct getdns_libev_data* ev_data =
64 (struct getdns_libev_data*) getdns_context_get_extension_data(context);
65 request_count_changed(rc, ev_data);
66 }
67
68 static void
69 getdns_libev_timeout_cb(struct ev_loop *loop, struct ev_timer* handle, int status) {
70 getdns_timeout_data_t* timeout_data = (getdns_timeout_data_t*) handle->data;
71 timeout_data->callback(timeout_data->userarg);
72 uint32_t rc = getdns_context_get_num_pending_requests(timeout_data->context, NULL);
73 struct getdns_libev_data* ev_data =
74 (struct getdns_libev_data*) getdns_context_get_extension_data(timeout_data->context);
75 request_count_changed(rc, ev_data);
76 }
77
78 /* getdns extension functions */
79 static getdns_return_t
80 getdns_libev_request_count_changed(struct getdns_context* context,
81 uint32_t request_count, void* eventloop_data) {
82 struct getdns_libev_data *ev_data = (struct getdns_libev_data*) eventloop_data;
83 request_count_changed(request_count, ev_data);
84 return GETDNS_RETURN_GOOD;
85 }
86
87 static getdns_return_t
88 getdns_libev_cleanup(struct getdns_context* context, void* data) {
89 struct getdns_libev_data *ev_data = (struct getdns_libev_data*) data;
90 ev_io_stop(ev_data->loop, ev_data->poll_handle);
91 free(ev_data->poll_handle);
92 free(ev_data);
93 return GETDNS_RETURN_GOOD;
94 }
95
96 static getdns_return_t
97 getdns_libev_schedule_timeout(struct getdns_context* context,
98 void* eventloop_data, uint16_t timeout,
99 getdns_timeout_data_t* timeout_data,
100 void** eventloop_timer) {
101
102 struct ev_timer *timer;
103 struct getdns_libev_data* ev_data = (struct getdns_libev_data*) eventloop_data;
104 ev_tstamp to = timeout;
105 to /= 1000;
106 timer = (struct ev_timer*) malloc(sizeof(struct ev_timer));
107 ev_timer_init(timer, getdns_libev_timeout_cb, to, 0);
108 timer->data = timeout_data;
109 ev_timer_start(ev_data->loop, timer);
110
111 *eventloop_timer = timer;
112 return GETDNS_RETURN_GOOD;
113 }
114
115 static getdns_return_t
116 getdns_libev_clear_timeout(struct getdns_context* context,
117 void* eventloop_data, void* eventloop_timer) {
118 struct ev_timer* timer = (struct ev_timer*) eventloop_timer;
119 struct getdns_libev_data* ev_data = (struct getdns_libev_data*) eventloop_data;
120 ev_timer_stop(ev_data->loop, timer);
121 free(timer);
122 return GETDNS_RETURN_GOOD;
123 }
124
125
126 static getdns_eventloop_extension LIBEV_EXT = {
127 getdns_libev_cleanup,
128 getdns_libev_schedule_timeout,
129 getdns_libev_clear_timeout,
130 getdns_libev_request_count_changed
131 };
132
133 /*
134 * getdns_extension_set_libev_loop
135 *
136 */
137 getdns_return_t
138 getdns_extension_set_libev_loop(struct getdns_context *context,
139 struct ev_loop *loop)
140 {
141 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
142 RETURN_IF_NULL(loop, GETDNS_RETURN_INVALID_PARAMETER);
143 /* TODO: cleanup current extension base */
144 getdns_return_t r = getdns_extension_detach_eventloop(context);
145 if (r != GETDNS_RETURN_GOOD) {
146 return r;
147 }
148 struct getdns_libev_data* ev_data = (struct getdns_libev_data*) malloc(sizeof(struct getdns_libev_data));
149 if (!ev_data) {
150 return GETDNS_RETURN_MEMORY_ERROR;
151 }
152 int fd = getdns_context_fd(context);
153 ev_data->poll_handle = (struct ev_io*) malloc(sizeof(struct ev_io));
154 ev_io_init(ev_data->poll_handle, getdns_libev_cb, fd, EV_READ);
155 ev_data->loop = loop;
156
157 ev_data->poll_handle->data = context;
158 return getdns_extension_set_eventloop(context, &LIBEV_EXT, ev_data);
159 } /* getdns_extension_set_libev_loop */
0 /**
1 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7
8 /*
9 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include <getdns/getdns_ext_libevent.h>
36 #include "config.h"
37 #include <sys/time.h>
38
39 #ifdef HAVE_EVENT2_EVENT_H
40 # include <event2/event.h>
41 #else
42 # ifndef u_char
43 # define u_char unsigned char
44 # endif
45 # include <event.h>
46 # define evutil_socket_t int
47 # define event_free free
48 # define evtimer_new(b, cb, arg) event_new((b), -1, 0, (cb), (arg))
49 #endif
50 #define RETURN_IF_NULL(ptr, code) if(ptr == NULL) return code;
51
52 #ifndef HAVE_EVENT_BASE_FREE
53 #define event_base_free(x) /* nop */
54 #endif
55 #ifndef HAVE_EVENT_BASE_NEW
56 #define event_base_new event_init
57 #endif
58
59 #ifndef HAVE_EVENT2_EVENT_H
60 static struct event *
61 event_new(struct event_base *b, evutil_socket_t fd, short ev, void* cb, void *arg)
62 {
63 struct event* e = (struct event*)calloc(1, sizeof(struct event));
64 if(!e) return NULL;
65 event_set(e, fd, ev, cb, arg);
66 event_base_set(b, e);
67 return e;
68 }
69 #endif /* no event2 */
70
71 /* extension info */
72 struct event_data {
73 struct event* event;
74 struct event_base* event_base;
75 };
76
77 static void
78 request_count_changed(uint32_t request_count, struct event_data *ev_data) {
79 if (request_count > 0) {
80 event_add(ev_data->event, NULL);
81 } else {
82 event_del(ev_data->event);
83 }
84 }
85
86 /* lib event callbacks */
87 static void
88 getdns_libevent_cb(evutil_socket_t fd, short what, void *userarg) {
89 struct getdns_context* context = (struct getdns_context*) userarg;
90 getdns_context_process_async(context);
91 uint32_t rc = getdns_context_get_num_pending_requests(context, NULL);
92 struct event_data* ev_data =
93 (struct event_data*) getdns_context_get_extension_data(context);
94 request_count_changed(rc, ev_data);
95 }
96
97 static void
98 getdns_libevent_timeout_cb(evutil_socket_t fd, short what, void* userarg) {
99 getdns_timeout_data_t* timeout_data = (getdns_timeout_data_t*) userarg;
100 timeout_data->callback(timeout_data->userarg);
101 uint32_t rc = getdns_context_get_num_pending_requests(timeout_data->context, NULL);
102 struct event_data* ev_data =
103 (struct event_data*) getdns_context_get_extension_data(timeout_data->context);
104 request_count_changed(rc, ev_data);
105 }
106
107 /* getdns extension functions */
108 static getdns_return_t
109 getdns_libevent_request_count_changed(struct getdns_context* context,
110 uint32_t request_count, void* eventloop_data) {
111 struct event_data *edata = (struct event_data*) eventloop_data;
112 request_count_changed(request_count, edata);
113 return GETDNS_RETURN_GOOD;
114 }
115
116 static getdns_return_t
117 getdns_libevent_cleanup(struct getdns_context* context, void* data) {
118 struct event_data *edata = (struct event_data*) data;
119 event_del(edata->event);
120 event_free(edata->event);
121 free(edata);
122 return GETDNS_RETURN_GOOD;
123 }
124
125 static getdns_return_t
126 getdns_libevent_schedule_timeout(struct getdns_context* context,
127 void* eventloop_data, uint16_t timeout,
128 getdns_timeout_data_t* timeout_data,
129 void** eventloop_timer) {
130
131 struct timeval tv;
132 struct event* ev = NULL;
133 struct event_data* ev_data = (struct event_data*) eventloop_data;
134
135 tv.tv_sec = timeout / 1000;
136 tv.tv_usec = (timeout % 1000) * 1000;
137
138 ev = evtimer_new(ev_data->event_base, getdns_libevent_timeout_cb, timeout_data);
139 evtimer_add(ev, &tv);
140
141 *eventloop_timer = ev;
142 return GETDNS_RETURN_GOOD;
143 }
144
145 static getdns_return_t
146 getdns_libevent_clear_timeout(struct getdns_context* context,
147 void* eventloop_data, void* eventloop_timer) {
148 struct event* ev = (struct event*) eventloop_timer;
149 event_del(ev);
150 event_free(ev);
151 return GETDNS_RETURN_GOOD;
152 }
153
154
155 static getdns_eventloop_extension LIBEVENT_EXT = {
156 getdns_libevent_cleanup,
157 getdns_libevent_schedule_timeout,
158 getdns_libevent_clear_timeout,
159 getdns_libevent_request_count_changed
160 };
161
162 /*
163 * getdns_extension_set_libevent_base
164 *
165 */
166 getdns_return_t
167 getdns_extension_set_libevent_base(struct getdns_context *context,
168 struct event_base * this_event_base)
169 {
170 RETURN_IF_NULL(context, GETDNS_RETURN_BAD_CONTEXT);
171 RETURN_IF_NULL(this_event_base, GETDNS_RETURN_INVALID_PARAMETER);
172 /* TODO: cleanup current extension base */
173 getdns_return_t r = getdns_extension_detach_eventloop(context);
174 if (r != GETDNS_RETURN_GOOD) {
175 return r;
176 }
177 int fd = getdns_context_fd(context);
178 struct event* getdns_event = event_new(this_event_base, fd, EV_READ | EV_PERSIST, getdns_libevent_cb, context);
179 if (!getdns_event) {
180 return GETDNS_RETURN_GENERIC_ERROR;
181 }
182
183 /* TODO: use context functs? */
184 struct event_data* ev_data = (struct event_data*) malloc(sizeof(struct event_data));
185 if (!ev_data) {
186 /* cleanup */
187 event_del(getdns_event);
188 event_free(getdns_event);
189 return GETDNS_RETURN_GENERIC_ERROR;
190 }
191 ev_data->event = getdns_event;
192 ev_data->event_base = this_event_base;
193 return getdns_extension_set_eventloop(context, &LIBEVENT_EXT, ev_data);
194 } /* getdns_extension_set_libevent_base */
0 /**
1 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7
8 /*
9 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include <getdns/getdns_ext_libuv.h>
36 #include <sys/time.h>
37 #include <stdio.h>
38 #include <uv.h>
39
40 #define RETURN_IF_NULL(ptr, code) if(ptr == NULL) return code;
41
42 /* extension info */
43 struct getdns_libuv_data {
44 uv_loop_t* loop;
45 uv_poll_t* poll_handle;
46 uint8_t polling;
47 };
48
49 static void request_count_changed(uint32_t request_count, struct getdns_libuv_data *uv_data);
50
51 /* lib event callbacks */
52 static void
53 getdns_libuv_cb(uv_poll_t* handle, int status, int events) {
54 struct getdns_context* context = (struct getdns_context*) handle->data;
55 getdns_context_process_async(context);
56 uint32_t rc = getdns_context_get_num_pending_requests(context, NULL);
57 struct getdns_libuv_data* uv_data =
58 (struct getdns_libuv_data*) getdns_context_get_extension_data(context);
59 request_count_changed(rc, uv_data);
60 }
61
62 static void
63 request_count_changed(uint32_t request_count, struct getdns_libuv_data *uv_data) {
64 if (request_count > 0 && uv_data->polling == 0) {
65 uv_poll_start(uv_data->poll_handle, UV_READABLE, getdns_libuv_cb);
66 uv_data->polling = 1;
67 } else if (request_count == 0 && uv_data->polling == 1) {
68 uv_poll_stop(uv_data->poll_handle);
69 uv_data->polling = 0;
70 }
71 }
72
73 static void
74 getdns_libuv_timeout_cb(uv_timer_t* handle, int status) {
75 getdns_timeout_data_t* timeout_data = (getdns_timeout_data_t*) handle->data;
76 timeout_data->callback(timeout_data->userarg);
77 uint32_t rc = getdns_context_get_num_pending_requests(timeout_data->context, NULL);
78 struct getdns_libuv_data* uv_data =
79 (struct getdns_libuv_data*) getdns_context_get_extension_data(timeout_data->context);
80 request_count_changed(rc, uv_data);
81 }
82
83 static void
84 getdns_libuv_close_cb(uv_handle_t* handle) {
85 if (handle) {
86 free(handle);
87 }
88 }
89
90 /* getdns extension functions */
91 static getdns_return_t
92 getdns_libuv_request_count_changed(struct getdns_context* context,
93 uint32_t request_count, void* eventloop_data) {
94 struct getdns_libuv_data *edata = (struct getdns_libuv_data*) eventloop_data;
95 request_count_changed(request_count, edata);
96 return GETDNS_RETURN_GOOD;
97 }
98
99 static getdns_return_t
100 getdns_libuv_cleanup(struct getdns_context* context, void* data) {
101 struct getdns_libuv_data *uv_data = (struct getdns_libuv_data*) data;
102 uv_poll_stop(uv_data->poll_handle);
103 uv_close((uv_handle_t*) uv_data->poll_handle, getdns_libuv_close_cb);
104 /* handle itself gets cleaned up in close_cb */
105 free(uv_data);
106 return GETDNS_RETURN_GOOD;
107 }
108
109 static getdns_return_t
110 getdns_libuv_schedule_timeout(struct getdns_context* context,
111 void* eventloop_data, uint16_t timeout,
112 getdns_timeout_data_t* timeout_data,
113 void** eventloop_timer) {
114
115 uv_timer_t *timer;
116 struct getdns_libuv_data* uv_data = (struct getdns_libuv_data*) eventloop_data;
117
118 timer = (uv_timer_t*) malloc(sizeof(uv_timer_t));
119 timer->data = timeout_data;
120 uv_timer_init(uv_data->loop, timer);
121 uv_timer_start(timer, getdns_libuv_timeout_cb, timeout, 0);
122
123 *eventloop_timer = timer;
124 return GETDNS_RETURN_GOOD;
125 }
126
127 static getdns_return_t
128 getdns_libuv_clear_timeout(struct getdns_context* context,
129 void* eventloop_data, void* eventloop_timer) {
130 uv_timer_t* timer = (uv_timer_t*) eventloop_timer;
131 uv_timer_stop(timer);
132 uv_close((uv_handle_t*) timer, getdns_libuv_close_cb);
133 return GETDNS_RETURN_GOOD;
134 }
135
136
137 static getdns_eventloop_extension LIBUV_EXT = {
138 getdns_libuv_cleanup,
139 getdns_libuv_schedule_timeout,
140 getdns_libuv_clear_timeout,
141 getdns_libuv_request_count_changed
142 };
143
144 /*
145 * getdns_extension_set_libuv_loop
146 *
147 */
148 getdns_return_t
149 getdns_extension_set_libuv_loop(struct getdns_context *context,
150 struct uv_loop_s *uv_loop)
151 {
152 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
153 RETURN_IF_NULL(uv_loop, GETDNS_RETURN_INVALID_PARAMETER);
154 /* TODO: cleanup current extension base */
155 getdns_return_t r = getdns_extension_detach_eventloop(context);
156 if (r != GETDNS_RETURN_GOOD) {
157 return r;
158 }
159 struct getdns_libuv_data* uv_data = (struct getdns_libuv_data*) malloc(sizeof(struct getdns_libuv_data));
160 if (!uv_data) {
161 return GETDNS_RETURN_MEMORY_ERROR;
162 }
163 int fd = getdns_context_fd(context);
164 uv_data->poll_handle = (uv_poll_t*) malloc(sizeof(uv_poll_t));
165 uv_poll_init(uv_loop, uv_data->poll_handle, fd);
166 uv_data->poll_handle->data = context;
167 uv_data->loop = uv_loop;
168 uv_data->polling = 0;
169 return getdns_extension_set_eventloop(context, &LIBUV_EXT, uv_data);
170 } /* getdns_extension_set_libuv_loop */
0 /**
1 *
2 * \file general.c
3 * @brief getdns_general and related support functions
4 *
5 * The getdns_general function is called by most of the other public entry
6 * points to the library. Private support functions are also included in this
7 * file where they are directly logically related to the getdns_general implementation.
8 */
9
10 /*
11 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are met:
16 * * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * * Neither the names of the copyright holders nor the
22 * names of its contributors may be used to endorse or promote products
23 * derived from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
29 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #include "config.h"
38 #include <string.h>
39 #include <unbound.h>
40 #include <ldns/ldns.h>
41 #include "context.h"
42 #include "types-internal.h"
43 #include "util-internal.h"
44 #include "dnssec.h"
45 #include <stdio.h>
46
47 /* stuff to make it compile pedantically */
48 #define UNUSED_PARAM(x) ((void)(x))
49
50 /* declarations */
51 static void ub_resolve_callback(void* mydata, int err, struct ub_result* result);
52 static void ub_resolve_timeout(void *arg);
53 static void ub_local_resolve_timeout(void *arg);
54
55 static void handle_network_request_error(getdns_network_req * netreq, int err);
56 static void handle_dns_request_complete(getdns_dns_req * dns_req);
57 static int submit_network_request(getdns_network_req * netreq);
58
59 typedef struct netreq_cb_data
60 {
61 getdns_network_req *netreq;
62 int err;
63 struct ub_result* ub_res;
64 } netreq_cb_data;
65
66 /* cancel, cleanup and send timeout to callback */
67 static void
68 ub_resolve_timeout(void *arg)
69 {
70 getdns_dns_req *dns_req = (getdns_dns_req *) arg;
71 struct getdns_context *context = dns_req->context;
72 getdns_transaction_t trans_id = dns_req->trans_id;
73 getdns_callback_t cb = dns_req->user_callback;
74 void *user_arg = dns_req->user_pointer;
75
76 /* cancel the req - also clears it from outbound and cleans up*/
77 getdns_context_cancel_request(context, trans_id, 0);
78
79 cb(context, GETDNS_CALLBACK_TIMEOUT, NULL, user_arg, trans_id);
80 }
81
82 static void
83 ub_local_resolve_timeout(void *arg)
84 {
85 netreq_cb_data *cb_data = (netreq_cb_data *) arg;
86
87 /* cleanup the local timer here since the memory may be
88 * invalid after calling ub_resolve_callback
89 */
90 getdns_dns_req *dnsreq = cb_data->netreq->owner;
91 /* clear the timeout */
92
93 getdns_context_clear_timeout(dnsreq->context, dnsreq->local_timeout_id);
94 dnsreq->local_timeout_id = 0;
95
96 /* just call ub_resolve_callback */
97 ub_resolve_callback(cb_data->netreq, cb_data->err, cb_data->ub_res);
98
99 /* cleanup the state */
100 GETDNS_FREE(dnsreq->my_mf, cb_data);
101 }
102
103 void priv_getdns_call_user_callback(getdns_dns_req *dns_req,
104 struct getdns_dict *response)
105 {
106 struct getdns_context *context = dns_req->context;
107 getdns_transaction_t trans_id = dns_req->trans_id;
108 getdns_callback_t cb = dns_req->user_callback;
109 void *user_arg = dns_req->user_pointer;
110
111 /* clean up */
112 getdns_context_clear_outbound_request(dns_req);
113 dns_req_free(dns_req);
114
115 cb(context,
116 (response ? GETDNS_CALLBACK_COMPLETE : GETDNS_CALLBACK_ERROR),
117 response, user_arg, trans_id);
118 }
119
120 /* cleanup and send an error to the user callback */
121 static void
122 handle_network_request_error(getdns_network_req * netreq, int err)
123 {
124 priv_getdns_call_user_callback(netreq->owner, NULL);
125 }
126
127 /* cleanup and send the response to the user callback */
128 static void
129 handle_dns_request_complete(getdns_dns_req * dns_req)
130 {
131 if (is_extension_set(dns_req->extensions, "dnssec_return_validation_chain"))
132 priv_getdns_get_validation_chain(dns_req);
133 else
134 priv_getdns_call_user_callback(
135 dns_req, create_getdns_response(dns_req));
136 }
137
138 static int
139 submit_network_request(getdns_network_req * netreq)
140 {
141 getdns_dns_req *dns_req = netreq->owner;
142 int r = ub_resolve_async(dns_req->context->unbound_ctx,
143 dns_req->name,
144 netreq->request_type,
145 netreq->request_class,
146 netreq,
147 ub_resolve_callback,
148 &(netreq->unbound_id));
149 netreq->state = NET_REQ_IN_FLIGHT;
150 return r;
151 }
152
153 static void
154 ub_resolve_callback(void* arg, int err, struct ub_result* ub_res)
155 // ub_resolve_callback(void *arg, int err, ldns_buffer * result, int sec,
156 // char *bogus)
157 {
158 getdns_network_req *netreq = (getdns_network_req *) arg;
159 if (err != 0) {
160 handle_network_request_error(netreq, err);
161 return;
162 }
163 /* if netreq->state == NET_REQ_NOT_SENT here, that implies
164 * that ub called us back immediately - probably from a local file.
165 * This most likely means that getdns_general has not returned
166 */
167 if (netreq->state == NET_REQ_NOT_SENT) {
168 /* just do a very short timer since this was called immediately.
169 * we can make this less hacky, but it gets interesting when multiple
170 * netreqs need to be issued and some resolve immediately vs. not.
171 */
172 getdns_dns_req *dnsreq = netreq->owner;
173 netreq_cb_data *cb_data = GETDNS_MALLOC(dnsreq->my_mf, netreq_cb_data);
174 cb_data->netreq = netreq;
175 cb_data->err = err;
176 cb_data->ub_res = ub_res;
177
178 dnsreq->local_timeout_id = ldns_get_random();
179
180 getdns_context_schedule_timeout(dnsreq->context,
181 dnsreq->local_timeout_id, 1, ub_local_resolve_timeout, cb_data);
182 return;
183 }
184 netreq->state = NET_REQ_FINISHED;
185 /* parse */
186 /* TODO: optimize */
187 getdns_return_t r = getdns_apply_network_result(netreq, ub_res);
188 ub_resolve_free(ub_res);
189 if (r != GETDNS_RETURN_GOOD) {
190 handle_network_request_error(netreq, err);
191 } else {
192 /* is this the last request */
193 if (!netreq->next) {
194 /* finished */
195 handle_dns_request_complete(netreq->owner);
196 } else {
197 /* not finished - update to next request and ship it */
198 getdns_dns_req *dns_req = netreq->owner;
199 dns_req->current_req = netreq->next;
200 submit_network_request(netreq->next);
201 }
202 }
203 } /* ub_resolve_callback */
204
205 getdns_return_t
206 getdns_general_ub(struct getdns_context *context,
207 const char *name,
208 uint16_t request_type,
209 struct getdns_dict *extensions,
210 void *userarg,
211 getdns_transaction_t * transaction_id,
212 getdns_callback_t callbackfn,
213 int usenamespaces)
214 {
215 getdns_return_t gr;
216 int r;
217
218 if (!name) {
219 return GETDNS_RETURN_INVALID_PARAMETER;
220 }
221
222 gr = getdns_context_prepare_for_resolution(context, usenamespaces);
223 if (gr != GETDNS_RETURN_GOOD) {
224 return gr;
225 }
226
227 /* request state */
228 getdns_dns_req *req = dns_req_new(context,
229 name,
230 request_type,
231 extensions);
232 if (!req) {
233 return GETDNS_RETURN_GENERIC_ERROR;
234 }
235
236 req->user_pointer = userarg;
237 req->user_callback = callbackfn;
238
239 if (transaction_id) {
240 *transaction_id = req->trans_id;
241 }
242
243 getdns_context_track_outbound_request(req);
244
245 /* assign a timeout */
246 // req->ev_base = ev_base;
247 // req->timeout = evtimer_new(ev_base, ub_resolve_timeout, req);
248 /* schedule the timeout */
249 getdns_context_schedule_timeout(context, req->trans_id,
250 context->timeout, ub_resolve_timeout, req);
251
252 /* issue the first network req */
253
254 r = submit_network_request(req->first_req);
255
256 if (r != 0) {
257 /* clean up the request */
258 getdns_context_clear_outbound_request(req);
259 dns_req_free(req);
260 return GETDNS_RETURN_GENERIC_ERROR;
261 }
262 return GETDNS_RETURN_GOOD;
263 } /* getdns_general_ub */
264
265 /**
266 * getdns_general
267 */
268 getdns_return_t
269 getdns_general(struct getdns_context *context,
270 const char *name,
271 uint16_t request_type,
272 struct getdns_dict * extensions,
273 void *userarg,
274 getdns_transaction_t * transaction_id, getdns_callback_t callback)
275 {
276 int extcheck = GETDNS_RETURN_GOOD;
277
278 if (!context) {
279 /* Can't do async without an event loop
280 * or callback
281 */
282 return GETDNS_RETURN_INVALID_PARAMETER;
283 }
284
285 /* ensure callback is not NULL */
286 if (!callback || !name) {
287 return GETDNS_RETURN_INVALID_PARAMETER;
288 }
289
290 extcheck = validate_dname(name);
291 if (extcheck != GETDNS_RETURN_GOOD) {
292 return extcheck;
293 }
294
295 extcheck = validate_extensions(extensions);
296 if (extcheck != GETDNS_RETURN_GOOD)
297 return extcheck;
298
299 return getdns_general_ub(context,
300 name, request_type, extensions, userarg, transaction_id, callback, 0);
301
302 } /* getdns_general */
303
304 /*
305 * getdns_address
306 *
307 */
308 getdns_return_t
309 getdns_address(struct getdns_context *context,
310 const char *name,
311 struct getdns_dict * extensions,
312 void *userarg,
313 getdns_transaction_t * transaction_id, getdns_callback_t callback)
314 {
315 int cleanup_extensions = 0;
316 int extcheck;
317 getdns_return_t result;
318
319 if (!context)
320 return GETDNS_RETURN_INVALID_PARAMETER;
321 if (!callback || !name)
322 return GETDNS_RETURN_INVALID_PARAMETER;
323
324 extcheck = validate_dname(name);
325 if (extcheck != GETDNS_RETURN_GOOD)
326 return extcheck;
327
328 /* we set the extensions that make general behave like getdns_address */
329 if (!extensions)
330 {
331 extensions = getdns_dict_create_with_context(context);
332 cleanup_extensions = 1;
333 }
334 getdns_dict_set_int(extensions,
335 GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6, GETDNS_EXTENSION_TRUE);
336 extcheck = validate_extensions(extensions);
337 if (extcheck != GETDNS_RETURN_GOOD)
338 return extcheck;
339
340 result = getdns_general_ub(context,
341 name, GETDNS_RRTYPE_A, extensions, userarg, transaction_id, callback, 1);
342
343 if (cleanup_extensions)
344 getdns_dict_destroy(extensions);
345
346 return result;
347 } /* getdns_address */
348
349 /* getdns_general.c */
0 /**
1 *
2 * /brief getdns contect management functions
3 *
4 * This is the meat of the API
5 * Originally taken from the getdns API description pseudo implementation.
6 *
7 */
8 /*
9 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef _GETDNS_GENERAL_H_
36 #define _GETDNS_GENERAL_H_
37
38 #include <getdns/getdns.h>
39 #include "types-internal.h"
40
41 /* private inner helper used by sync and async */
42
43 getdns_return_t
44 getdns_general_ub(struct getdns_context *context,
45 const char *name,
46 uint16_t request_type,
47 struct getdns_dict *extensions,
48 void *userarg,
49 getdns_transaction_t * transaction_id,
50 getdns_callback_t callbackfn,
51 int usenamespaces);
52
53 void priv_getdns_call_user_callback(getdns_dns_req *, struct getdns_dict *);
54
55 #endif
0 # Makefile.in generated by automake 1.12.4 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2012 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 am__make_dryrun = \
18 { \
19 am__dry=no; \
20 case $$MAKEFLAGS in \
21 *\\[\ \ ]*) \
22 echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
23 | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
24 *) \
25 for am__flg in $$MAKEFLAGS; do \
26 case $$am__flg in \
27 *=*|--*) ;; \
28 *n*) am__dry=yes; break;; \
29 esac; \
30 done;; \
31 esac; \
32 test $$am__dry = yes; \
33 }
34 pkgdatadir = $(datadir)/@PACKAGE@
35 pkgincludedir = $(includedir)/@PACKAGE@
36 pkglibdir = $(libdir)/@PACKAGE@
37 pkglibexecdir = $(libexecdir)/@PACKAGE@
38 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
39 install_sh_DATA = $(install_sh) -c -m 644
40 install_sh_PROGRAM = $(install_sh) -c
41 install_sh_SCRIPT = $(install_sh) -c
42 INSTALL_HEADER = $(INSTALL_DATA)
43 transform = $(program_transform_name)
44 NORMAL_INSTALL = :
45 PRE_INSTALL = :
46 POST_INSTALL = :
47 NORMAL_UNINSTALL = :
48 PRE_UNINSTALL = :
49 POST_UNINSTALL = :
50 build_triplet = @build@
51 host_triplet = @host@
52 subdir = src/getdns
53 DIST_COMMON = $(pkginclude_HEADERS) $(srcdir)/Makefile.am \
54 $(srcdir)/Makefile.in ChangeLog install-sh
55 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
56 am__aclocal_m4_deps = $(top_srcdir)/configure.ac
57 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
58 $(ACLOCAL_M4)
59 mkinstalldirs = $(install_sh) -d
60 CONFIG_CLEAN_FILES =
61 CONFIG_CLEAN_VPATH_FILES =
62 SOURCES =
63 DIST_SOURCES =
64 am__can_run_installinfo = \
65 case $$AM_UPDATE_INFO_DIR in \
66 n|no|NO) false;; \
67 *) (install-info --version) >/dev/null 2>&1;; \
68 esac
69 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
70 am__vpath_adj = case $$p in \
71 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
72 *) f=$$p;; \
73 esac;
74 am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
75 am__install_max = 40
76 am__nobase_strip_setup = \
77 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
78 am__nobase_strip = \
79 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
80 am__nobase_list = $(am__nobase_strip_setup); \
81 for p in $$list; do echo "$$p $$p"; done | \
82 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
83 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
84 if (++n[$$2] == $(am__install_max)) \
85 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
86 END { for (dir in files) print dir, files[dir] }'
87 am__base_list = \
88 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
89 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
90 am__uninstall_files_from_dir = { \
91 test -z "$$files" \
92 || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
93 || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
94 $(am__cd) "$$dir" && rm -f $$files; }; \
95 }
96 am__installdirs = "$(DESTDIR)$(pkgincludedir)"
97 HEADERS = $(pkginclude_HEADERS)
98 ETAGS = etags
99 CTAGS = ctags
100 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
101 ACLOCAL = @ACLOCAL@
102 AMTAR = @AMTAR@
103 AR = @AR@
104 AUTOCONF = @AUTOCONF@
105 AUTOHEADER = @AUTOHEADER@
106 AUTOMAKE = @AUTOMAKE@
107 AWK = @AWK@
108 CC = @CC@
109 CCDEPMODE = @CCDEPMODE@
110 CFLAGS = @CFLAGS@
111 CPP = @CPP@
112 CPPFLAGS = @CPPFLAGS@
113 CYGPATH_W = @CYGPATH_W@
114 DEFS = @DEFS@
115 DEPDIR = @DEPDIR@
116 DLLTOOL = @DLLTOOL@
117 DSYMUTIL = @DSYMUTIL@
118 DUMPBIN = @DUMPBIN@
119 ECHO_C = @ECHO_C@
120 ECHO_N = @ECHO_N@
121 ECHO_T = @ECHO_T@
122 EGREP = @EGREP@
123 EXEEXT = @EXEEXT@
124 FGREP = @FGREP@
125 GREP = @GREP@
126 INSTALL = @INSTALL@
127 INSTALL_DATA = @INSTALL_DATA@
128 INSTALL_PROGRAM = @INSTALL_PROGRAM@
129 INSTALL_SCRIPT = @INSTALL_SCRIPT@
130 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
131 LD = @LD@
132 LDFLAGS = @LDFLAGS@
133 LIBOBJS = @LIBOBJS@
134 LIBS = @LIBS@
135 LIBTOOL = @LIBTOOL@
136 LIPO = @LIPO@
137 LN_S = @LN_S@
138 LTLIBOBJS = @LTLIBOBJS@
139 MAKEINFO = @MAKEINFO@
140 MANIFEST_TOOL = @MANIFEST_TOOL@
141 MKDIR_P = @MKDIR_P@
142 NM = @NM@
143 NMEDIT = @NMEDIT@
144 OBJDUMP = @OBJDUMP@
145 OBJEXT = @OBJEXT@
146 OTOOL = @OTOOL@
147 OTOOL64 = @OTOOL64@
148 PACKAGE = @PACKAGE@
149 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
150 PACKAGE_NAME = @PACKAGE_NAME@
151 PACKAGE_STRING = @PACKAGE_STRING@
152 PACKAGE_TARNAME = @PACKAGE_TARNAME@
153 PACKAGE_URL = @PACKAGE_URL@
154 PACKAGE_VERSION = @PACKAGE_VERSION@
155 PATH_SEPARATOR = @PATH_SEPARATOR@
156 RANLIB = @RANLIB@
157 SED = @SED@
158 SET_MAKE = @SET_MAKE@
159 SHELL = @SHELL@
160 STRIP = @STRIP@
161 VERSION = @VERSION@
162 abs_builddir = @abs_builddir@
163 abs_srcdir = @abs_srcdir@
164 abs_top_builddir = @abs_top_builddir@
165 abs_top_srcdir = @abs_top_srcdir@
166 ac_ct_AR = @ac_ct_AR@
167 ac_ct_CC = @ac_ct_CC@
168 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
169 am__include = @am__include@
170 am__leading_dot = @am__leading_dot@
171 am__quote = @am__quote@
172 am__tar = @am__tar@
173 am__untar = @am__untar@
174 bindir = @bindir@
175 build = @build@
176 build_alias = @build_alias@
177 build_cpu = @build_cpu@
178 build_os = @build_os@
179 build_vendor = @build_vendor@
180 builddir = @builddir@
181 datadir = @datadir@
182 datarootdir = @datarootdir@
183 docdir = @docdir@
184 dvidir = @dvidir@
185 exec_prefix = @exec_prefix@
186 host = @host@
187 host_alias = @host_alias@
188 host_cpu = @host_cpu@
189 host_os = @host_os@
190 host_vendor = @host_vendor@
191 htmldir = @htmldir@
192 includedir = @includedir@
193 infodir = @infodir@
194 install_sh = @install_sh@
195 libdir = @libdir@
196 libexecdir = @libexecdir@
197 localedir = @localedir@
198 localstatedir = @localstatedir@
199 mandir = @mandir@
200 mkdir_p = @mkdir_p@
201 oldincludedir = @oldincludedir@
202 pdfdir = @pdfdir@
203 prefix = @prefix@
204 program_transform_name = @program_transform_name@
205 psdir = @psdir@
206 sbindir = @sbindir@
207 sharedstatedir = @sharedstatedir@
208 srcdir = @srcdir@
209 subdirs = @subdirs@
210 sysconfdir = @sysconfdir@
211 target_alias = @target_alias@
212 top_build_prefix = @top_build_prefix@
213 top_builddir = @top_builddir@
214 top_srcdir = @top_srcdir@
215 pkginclude_HEADERS = getdns.h getdns_error.h
216 all: all-am
217
218 .SUFFIXES:
219 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
220 @for dep in $?; do \
221 case '$(am__configure_deps)' in \
222 *$$dep*) \
223 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
224 && { if test -f $@; then exit 0; else break; fi; }; \
225 exit 1;; \
226 esac; \
227 done; \
228 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/getdns/Makefile'; \
229 $(am__cd) $(top_srcdir) && \
230 $(AUTOMAKE) --gnu src/getdns/Makefile
231 .PRECIOUS: Makefile
232 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
233 @case '$?' in \
234 *config.status*) \
235 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
236 *) \
237 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
238 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
239 esac;
240
241 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
242 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
243
244 $(top_srcdir)/configure: $(am__configure_deps)
245 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
246 $(ACLOCAL_M4): $(am__aclocal_m4_deps)
247 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
248 $(am__aclocal_m4_deps):
249
250 mostlyclean-libtool:
251 -rm -f *.lo
252
253 clean-libtool:
254 -rm -rf .libs _libs
255 install-pkgincludeHEADERS: $(pkginclude_HEADERS)
256 @$(NORMAL_INSTALL)
257 @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
258 if test -n "$$list"; then \
259 echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \
260 $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \
261 fi; \
262 for p in $$list; do \
263 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
264 echo "$$d$$p"; \
265 done | $(am__base_list) | \
266 while read files; do \
267 echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \
268 $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \
269 done
270
271 uninstall-pkgincludeHEADERS:
272 @$(NORMAL_UNINSTALL)
273 @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \
274 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
275 dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir)
276
277 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
278 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
279 unique=`for i in $$list; do \
280 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
281 done | \
282 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
283 END { if (nonempty) { for (i in files) print i; }; }'`; \
284 mkid -fID $$unique
285 tags: TAGS
286
287 TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
288 $(TAGS_FILES) $(LISP)
289 set x; \
290 here=`pwd`; \
291 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
292 unique=`for i in $$list; do \
293 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
294 done | \
295 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
296 END { if (nonempty) { for (i in files) print i; }; }'`; \
297 shift; \
298 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
299 test -n "$$unique" || unique=$$empty_fix; \
300 if test $$# -gt 0; then \
301 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
302 "$$@" $$unique; \
303 else \
304 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
305 $$unique; \
306 fi; \
307 fi
308 ctags: CTAGS
309 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
310 $(TAGS_FILES) $(LISP)
311 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
312 unique=`for i in $$list; do \
313 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
314 done | \
315 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
316 END { if (nonempty) { for (i in files) print i; }; }'`; \
317 test -z "$(CTAGS_ARGS)$$unique" \
318 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
319 $$unique
320
321 GTAGS:
322 here=`$(am__cd) $(top_builddir) && pwd` \
323 && $(am__cd) $(top_srcdir) \
324 && gtags -i $(GTAGS_ARGS) "$$here"
325
326 cscopelist: $(HEADERS) $(SOURCES) $(LISP)
327 list='$(SOURCES) $(HEADERS) $(LISP)'; \
328 case "$(srcdir)" in \
329 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
330 *) sdir=$(subdir)/$(srcdir) ;; \
331 esac; \
332 for i in $$list; do \
333 if test -f "$$i"; then \
334 echo "$(subdir)/$$i"; \
335 else \
336 echo "$$sdir/$$i"; \
337 fi; \
338 done >> $(top_builddir)/cscope.files
339
340 distclean-tags:
341 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
342
343 distdir: $(DISTFILES)
344 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
345 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
346 list='$(DISTFILES)'; \
347 dist_files=`for file in $$list; do echo $$file; done | \
348 sed -e "s|^$$srcdirstrip/||;t" \
349 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
350 case $$dist_files in \
351 */*) $(MKDIR_P) `echo "$$dist_files" | \
352 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
353 sort -u` ;; \
354 esac; \
355 for file in $$dist_files; do \
356 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
357 if test -d $$d/$$file; then \
358 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
359 if test -d "$(distdir)/$$file"; then \
360 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
361 fi; \
362 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
363 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
364 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
365 fi; \
366 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
367 else \
368 test -f "$(distdir)/$$file" \
369 || cp -p $$d/$$file "$(distdir)/$$file" \
370 || exit 1; \
371 fi; \
372 done
373 check-am: all-am
374 check: check-am
375 all-am: Makefile $(HEADERS)
376 installdirs:
377 for dir in "$(DESTDIR)$(pkgincludedir)"; do \
378 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
379 done
380 install: install-am
381 install-exec: install-exec-am
382 install-data: install-data-am
383 uninstall: uninstall-am
384
385 install-am: all-am
386 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
387
388 installcheck: installcheck-am
389 install-strip:
390 if test -z '$(STRIP)'; then \
391 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
392 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
393 install; \
394 else \
395 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
396 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
397 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
398 fi
399 mostlyclean-generic:
400
401 clean-generic:
402
403 distclean-generic:
404 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
405 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
406
407 maintainer-clean-generic:
408 @echo "This command is intended for maintainers to use"
409 @echo "it deletes files that may require special tools to rebuild."
410 clean: clean-am
411
412 clean-am: clean-generic clean-libtool mostlyclean-am
413
414 distclean: distclean-am
415 -rm -f Makefile
416 distclean-am: clean-am distclean-generic distclean-tags
417
418 dvi: dvi-am
419
420 dvi-am:
421
422 html: html-am
423
424 html-am:
425
426 info: info-am
427
428 info-am:
429
430 install-data-am: install-pkgincludeHEADERS
431
432 install-dvi: install-dvi-am
433
434 install-dvi-am:
435
436 install-exec-am:
437
438 install-html: install-html-am
439
440 install-html-am:
441
442 install-info: install-info-am
443
444 install-info-am:
445
446 install-man:
447
448 install-pdf: install-pdf-am
449
450 install-pdf-am:
451
452 install-ps: install-ps-am
453
454 install-ps-am:
455
456 installcheck-am:
457
458 maintainer-clean: maintainer-clean-am
459 -rm -f Makefile
460 maintainer-clean-am: distclean-am maintainer-clean-generic
461
462 mostlyclean: mostlyclean-am
463
464 mostlyclean-am: mostlyclean-generic mostlyclean-libtool
465
466 pdf: pdf-am
467
468 pdf-am:
469
470 ps: ps-am
471
472 ps-am:
473
474 uninstall-am: uninstall-pkgincludeHEADERS
475
476 .MAKE: install-am install-strip
477
478 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
479 clean-libtool cscopelist ctags distclean distclean-generic \
480 distclean-libtool distclean-tags distdir dvi dvi-am html \
481 html-am info info-am install install-am install-data \
482 install-data-am install-dvi install-dvi-am install-exec \
483 install-exec-am install-html install-html-am install-info \
484 install-info-am install-man install-pdf install-pdf-am \
485 install-pkgincludeHEADERS install-ps install-ps-am \
486 install-strip installcheck installcheck-am installdirs \
487 maintainer-clean maintainer-clean-generic mostlyclean \
488 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
489 tags uninstall uninstall-am uninstall-pkgincludeHEADERS
490
491
492 # Tell versions [3.59,3.63) of GNU make to not export all variables.
493 # Otherwise a system limit (for SysV at least) may be exceeded.
494 .NOEXPORT:
0 /* config.h.in. Generated from configure.ac by autoheader. */
1
2 /* Define to 1 if you have the <inttypes.h> header file. */
3 #undef HAVE_INTTYPES_H
4
5 /* Define to 1 if you have the `event_core' library (-levent_core). */
6 #undef HAVE_LIBEVENT_CORE
7
8 /* Define to 1 if you have the `getdns' library (-lgetdns). */
9 #undef HAVE_LIBGETDNS
10
11 /* Define to 1 if you have the <memory.h> header file. */
12 #undef HAVE_MEMORY_H
13
14 /* Define to 1 if you have the <netinet/in.h> header file. */
15 #undef HAVE_NETINET_IN_H
16
17 /* Define to 1 if stdbool.h conforms to C99. */
18 #undef HAVE_STDBOOL_H
19
20 /* Define to 1 if you have the <stdint.h> header file. */
21 #undef HAVE_STDINT_H
22
23 /* Define to 1 if you have the <stdlib.h> header file. */
24 #undef HAVE_STDLIB_H
25
26 /* Define to 1 if you have the <strings.h> header file. */
27 #undef HAVE_STRINGS_H
28
29 /* Define to 1 if you have the <string.h> header file. */
30 #undef HAVE_STRING_H
31
32 /* Define to 1 if you have the <sys/stat.h> header file. */
33 #undef HAVE_SYS_STAT_H
34
35 /* Define to 1 if you have the <sys/types.h> header file. */
36 #undef HAVE_SYS_TYPES_H
37
38 /* Define to 1 if you have the <unistd.h> header file. */
39 #undef HAVE_UNISTD_H
40
41 /* Define to 1 if the system has the type `_Bool'. */
42 #undef HAVE__BOOL
43
44 /* Name of package */
45 #undef PACKAGE
46
47 /* Define to the address where bug reports for this package should be sent. */
48 #undef PACKAGE_BUGREPORT
49
50 /* Define to the full name of this package. */
51 #undef PACKAGE_NAME
52
53 /* Define to the full name and version of this package. */
54 #undef PACKAGE_STRING
55
56 /* Define to the one symbol short name of this package. */
57 #undef PACKAGE_TARNAME
58
59 /* Define to the home page for this package. */
60 #undef PACKAGE_URL
61
62 /* Define to the version of this package. */
63 #undef PACKAGE_VERSION
64
65 /* Define to 1 if you have the ANSI C header files. */
66 #undef STDC_HEADERS
67
68 /* Version number of package */
69 #undef VERSION
70
71 /* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
72 <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
73 #define below would cause a syntax error. */
74 #undef _UINT32_T
75
76 /* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
77 <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
78 #define below would cause a syntax error. */
79 #undef _UINT64_T
80
81 /* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
82 <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
83 #define below would cause a syntax error. */
84 #undef _UINT8_T
85
86 /* Define to `unsigned int' if <sys/types.h> does not define. */
87 #undef size_t
88
89 /* Define to the type of an unsigned integer type of width exactly 16 bits if
90 such a type exists and the standard includes do not define it. */
91 #undef uint16_t
92
93 /* Define to the type of an unsigned integer type of width exactly 32 bits if
94 such a type exists and the standard includes do not define it. */
95 #undef uint32_t
96
97 /* Define to the type of an unsigned integer type of width exactly 64 bits if
98 such a type exists and the standard includes do not define it. */
99 #undef uint64_t
100
101 /* Define to the type of an unsigned integer type of width exactly 8 bits if
102 such a type exists and the standard includes do not define it. */
103 #undef uint8_t
0 /**
1 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7
8 /*
9 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef GETDNS_H
36 #define GETDNS_H
37
38 #include <stdint.h>
39 #include <stdlib.h>
40 #include <time.h>
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #define GETDNS_COMPILATION_COMMENT "@GETDNS_COMPILATION_COMMENT@"
47
48 /* Return values */
49 typedef enum getdns_return_t {
50 GETDNS_RETURN_GOOD = 0,
51 GETDNS_RETURN_GENERIC_ERROR = 1,
52 GETDNS_RETURN_BAD_DOMAIN_NAME = 300,
53 GETDNS_RETURN_BAD_CONTEXT = 301,
54 GETDNS_RETURN_CONTEXT_UPDATE_FAIL = 302,
55 GETDNS_RETURN_UNKNOWN_TRANSACTION = 303,
56 GETDNS_RETURN_NO_SUCH_LIST_ITEM = 304,
57 GETDNS_RETURN_NO_SUCH_DICT_NAME = 305,
58 GETDNS_RETURN_WRONG_TYPE_REQUESTED = 306,
59 GETDNS_RETURN_NO_SUCH_EXTENSION = 307,
60 GETDNS_RETURN_EXTENSION_MISFORMAT = 308,
61 GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED = 309,
62 GETDNS_RETURN_MEMORY_ERROR = 310,
63 GETDNS_RETURN_INVALID_PARAMETER = 311
64 } getdns_return_t;
65
66 /**
67 * \defgroup Return values texts
68 * @{
69 */
70 #define GETDNS_RETURN_GOOD_TEXT "Good"
71 #define GETDNS_RETURN_GENERIC_ERROR_TEXT "Generic error"
72 #define GETDNS_RETURN_BAD_DOMAIN_NAME_TEXT "Badly-formed domain name in first argument"
73 #define GETDNS_RETURN_BAD_CONTEXT_TEXT "The context has internal deficiencies"
74 #define GETDNS_RETURN_CONTEXT_UPDATE_FAIL_TEXT "Did not update the context"
75 #define GETDNS_RETURN_UNKNOWN_TRANSACTION_TEXT "An attempt was made to cancel a callback with a transaction_id that is not recognized"
76 #define GETDNS_RETURN_NO_SUCH_LIST_ITEM_TEXT "A helper function for lists had an index argument that was too high."
77 #define GETDNS_RETURN_NO_SUCH_DICT_NAME_TEXT "A helper function for dicts had a name argument that for a name that is not in the dict."
78 #define GETDNS_RETURN_WRONG_TYPE_REQUESTED_TEXT "A helper function was supposed to return a certain type for an item, but the wrong type was given."
79 #define GETDNS_RETURN_NO_SUCH_EXTENSION_TEXT "A name in the extensions dict is not a valid extension."
80 #define GETDNS_RETURN_EXTENSION_MISFORMAT_TEXT "One or more of the extensions have a bad format."
81 #define GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED_TEXT "A query was made with a context that is using stub resolution and a DNSSEC extension specified."
82 #define GETDNS_RETURN_MEMORY_ERROR_TEXT "Unable to allocate the memory required."
83 #define GETDNS_RETURN_INVALID_PARAMETER_TEXT "A required parameter had an invalid value."
84 /** @}
85 */
86
87
88 /**
89 * \defgroup dnssecvalues DNSSEC values
90 * @{
91 */
92 #define GETDNS_DNSSEC_SECURE 400
93 #define GETDNS_DNSSEC_SECURE_TEXT "The record was determined to be secure in DNSSEC"
94 #define GETDNS_DNSSEC_BOGUS 401
95 #define GETDNS_DNSSEC_BOGUS_TEXT "The record was determined to be bogus in DNSSEC"
96 #define GETDNS_DNSSEC_INDETERMINATE 402
97 #define GETDNS_DNSSEC_INDETERMINATE_TEXT "The record was not determined to be any state in DNSSEC"
98 #define GETDNS_DNSSEC_INSECURE 403
99 #define GETDNS_DNSSEC_INSECURE_TEXT "The record was determined to be insecure in DNSSEC"
100 #define GETDNS_DNSSEC_NOT_PERFORMED 404
101 #define GETDNS_DNSSEC_NOT_PERFORMED_TEXT "DNSSEC validation was not performed (only used for debugging)"
102 /** @}
103 */
104
105
106 /* Namespace types */
107 typedef enum getdns_namespace_t {
108 GETDNS_NAMESPACE_DNS = 500,
109 GETDNS_NAMESPACE_LOCALNAMES = 501,
110 GETDNS_NAMESPACE_NETBIOS = 502,
111 GETDNS_NAMESPACE_MDNS = 503,
112 GETDNS_NAMESPACE_NIS = 504
113 } getdns_namespace_t;
114
115 /**
116 * \defgroup Namespace types texts
117 * @{
118 */
119 #define GETDNS_NAMESPACE_DNS_TEXT "See getdns_context_set_namespaces()"
120 #define GETDNS_NAMESPACE_LOCALNAMES_TEXT "See getdns_context_set_namespaces()"
121 #define GETDNS_NAMESPACE_NETBIOS_TEXT "See getdns_context_set_namespaces()"
122 #define GETDNS_NAMESPACE_MDNS_TEXT "See getdns_context_set_namespaces()"
123 #define GETDNS_NAMESPACE_NIS_TEXT "See getdns_context_set_namespaces()"
124 /** @}
125 */
126
127
128 /* Resolution types */
129 typedef enum getdns_resolution_t {
130 GETDNS_RESOLUTION_STUB = 520,
131 GETDNS_RESOLUTION_RECURSING = 521
132 } getdns_resolution_t;
133
134 /**
135 * \defgroup Resolution types texts
136 * @{
137 */
138 #define GETDNS_RESOLUTION_STUB_TEXT "See getdns_context_set_resolution_type()"
139 #define GETDNS_RESOLUTION_RECURSING_TEXT "See getdns_context_set_resolution_type()"
140 /** @}
141 */
142
143
144 /* Redirect policies */
145 typedef enum getdns_redirects_t {
146 GETDNS_REDIRECTS_FOLLOW = 530,
147 GETDNS_REDIRECTS_DO_NOT_FOLLOW = 531
148 } getdns_redirects_t;
149
150 /**
151 * \defgroup Redirect policies texts
152 * @{
153 */
154 #define GETDNS_REDIRECTS_FOLLOW_TEXT "See getdns_context_set_follow_redirects()"
155 #define GETDNS_REDIRECTS_DO_NOT_FOLLOW_TEXT "See getdns_context_set_follow_redirects()"
156 /** @}
157 */
158
159
160 /* Transport arrangements */
161 typedef enum getdns_transport_t {
162 GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP = 540,
163 GETDNS_TRANSPORT_UDP_ONLY = 541,
164 GETDNS_TRANSPORT_TCP_ONLY = 542,
165 GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN = 543
166 } getdns_transport_t;
167
168 /**
169 * \defgroup Transport arrangements texts
170 * @{
171 */
172 #define GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP_TEXT "See getdns_context_set_dns_transport()"
173 #define GETDNS_TRANSPORT_UDP_ONLY_TEXT "See getdns_context_set_dns_transport()"
174 #define GETDNS_TRANSPORT_TCP_ONLY_TEXT "See getdns_context_set_dns_transport()"
175 #define GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN_TEXT "See getdns_context_set_dns_transport()"
176 /** @}
177 */
178
179
180 /* Suffix appending methods */
181 typedef enum getdns_append_name_t {
182 GETDNS_APPEND_NAME_ALWAYS = 550,
183 GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE = 551,
184 GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE = 552,
185 GETDNS_APPEND_NAME_NEVER = 553
186 } getdns_append_name_t;
187
188 /**
189 * \defgroup Suffix appending methods texts
190 * @{
191 */
192 #define GETDNS_APPEND_NAME_ALWAYS_TEXT "See getdns_context_set_append_name()"
193 #define GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE_TEXT "See getdns_context_set_append_name()"
194 #define GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE_TEXT "See getdns_context_set_append_name()"
195 #define GETDNS_APPEND_NAME_NEVER_TEXT "See getdns_context_set_append_name()"
196 /** @}
197 */
198
199
200 /* Context codes */
201 typedef enum getdns_context_code_t {
202 GETDNS_CONTEXT_CODE_NAMESPACES = 600,
203 GETDNS_CONTEXT_CODE_RESOLUTION_TYPE = 601,
204 GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS = 602,
205 GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS = 603,
206 GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS = 604,
207 GETDNS_CONTEXT_CODE_DNS_TRANSPORT = 605,
208 GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES = 606,
209 GETDNS_CONTEXT_CODE_APPEND_NAME = 607,
210 GETDNS_CONTEXT_CODE_SUFFIX = 608,
211 GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS = 609,
212 GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE = 610,
213 GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE = 611,
214 GETDNS_CONTEXT_CODE_EDNS_VERSION = 612,
215 GETDNS_CONTEXT_CODE_EDNS_DO_BIT = 613,
216 GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW = 614,
217 GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS = 615,
218 GETDNS_CONTEXT_CODE_TIMEOUT = 616
219 } getdns_context_code_t;
220
221 /**
222 * \defgroup Context codes texts
223 * @{
224 */
225 #define GETDNS_CONTEXT_CODE_NAMESPACES_TEXT "Change related to getdns_context_set_namespaces"
226 #define GETDNS_CONTEXT_CODE_RESOLUTION_TYPE_TEXT "Change related to getdns_context_set_resolution_type"
227 #define GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS_TEXT "Change related to getdns_context_set_follow_redirects"
228 #define GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS_TEXT "Change related to getdns_context_set_upstream_recursive_servers"
229 #define GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS_TEXT "Change related to getdns_context_set_dns_root_servers"
230 #define GETDNS_CONTEXT_CODE_DNS_TRANSPORT_TEXT "Change related to getdns_context_set_dns_transport"
231 #define GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES_TEXT "Change related to getdns_context_set_limit_outstanding_queries"
232 #define GETDNS_CONTEXT_CODE_APPEND_NAME_TEXT "Change related to getdns_context_set_append_name"
233 #define GETDNS_CONTEXT_CODE_SUFFIX_TEXT "Change related to getdns_context_set_suffix"
234 #define GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS_TEXT "Change related to getdns_context_set_dnssec_trust_anchors"
235 #define GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE_TEXT "Change related to getdns_context_set_edns_maximum_udp_payload_size"
236 #define GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE_TEXT "Change related to getdns_context_set_edns_extended_rcode"
237 #define GETDNS_CONTEXT_CODE_EDNS_VERSION_TEXT "Change related to getdns_context_set_edns_version"
238 #define GETDNS_CONTEXT_CODE_EDNS_DO_BIT_TEXT "Change related to getdns_context_set_edns_do_bit"
239 #define GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW_TEXT "Change related to getdns_context_set_dnssec_allowed_skew"
240 #define GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS_TEXT "Change related to getdns_context_set_memory_functions"
241 #define GETDNS_CONTEXT_CODE_TIMEOUT_TEXT "Change related to getdns_context_set_timeout"
242 /** @}
243 */
244
245
246 /* Callback Type Variables */
247 typedef enum getdns_callback_type_t {
248 GETDNS_CALLBACK_COMPLETE = 700,
249 GETDNS_CALLBACK_CANCEL = 701,
250 GETDNS_CALLBACK_TIMEOUT = 702,
251 GETDNS_CALLBACK_ERROR = 703
252 } getdns_callback_type_t;
253
254 /**
255 * \defgroup Callback type variables texts
256 * @{
257 */
258 #define GETDNS_CALLBACK_COMPLETE_TEXT "The response has the requested data in it"
259 #define GETDNS_CALLBACK_CANCEL_TEXT "The calling program cancelled the callback; response is NULL"
260 #define GETDNS_CALLBACK_TIMEOUT_TEXT "The requested action timed out; response is NULL"
261 #define GETDNS_CALLBACK_ERROR_TEXT "The requested action had an error; response is NULL"
262 /** @}
263 */
264
265 /**
266 * \defgroup nametype Types of name services
267 * @{
268 */
269 #define GETDNS_NAMETYPE_DNS 800
270 #define GETDNS_NAMETYPE_DNS_TEXT "Normal DNS (RFC 1035)"
271 #define GETDNS_NAMETYPE_WINS 801
272 #define GETDNS_NAMETYPE_WINS_TEXT "The WINS name service (some reference needed)"
273 /** @}
274 */
275
276 /**
277 * \defgroup respstatus Status Codes for Responses
278 * @{
279 */
280 #define GETDNS_RESPSTATUS_GOOD 900
281 #define GETDNS_RESPSTATUS_GOOD_TEXT "At least one response was returned"
282 #define GETDNS_RESPSTATUS_NO_NAME 901
283 #define GETDNS_RESPSTATUS_NO_NAME_TEXT "Queries for the name yielded all negative responses"
284 #define GETDNS_RESPSTATUS_ALL_TIMEOUT 902
285 #define GETDNS_RESPSTATUS_ALL_TIMEOUT_TEXT "All queries for the name timed out"
286 #define GETDNS_RESPSTATUS_NO_SECURE_ANSWERS 903
287 #define GETDNS_RESPSTATUS_NO_SECURE_ANSWERS_TEXT "The context setting for getting only secure responses was specified, and at least one DNS response was received, but no DNS response was determined to be secure through DNSSEC."
288 /** @}
289 */
290
291 /**
292 * \defgroup extvals Values Associated With Extensions
293 * @{
294 */
295 #define GETDNS_EXTENSION_TRUE 1000
296 #define GETDNS_EXTENSION_TRUE_TEXT "Turn on the extension"
297 #define GETDNS_EXTENSION_FALSE 1001
298 #define GETDNS_EXTENSION_FALSE_TEXT "Do not turn on the extension"
299 /** @}
300 */
301
302 /**
303 * \defgroup dnserrors Values Associated With DNS Errors Found By The API
304 * @{
305 */
306 #define GETDNS_BAD_DNS_CNAME_IN_TARGET 1100
307 #define GETDNS_BAD_DNS_CNAME_IN_TARGET_TEXT "A DNS query type that does not allow a target to be a CNAME pointed to a CNAME"
308 #define GETDNS_BAD_DNS_ALL_NUMERIC_LABEL 1101
309 #define GETDNS_BAD_DNS_ALL_NUMERIC_LABEL_TEXT "One or more labels in a returned domain name is all-numeric; this is not legal for a hostname"
310 #define GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE 1102
311 #define GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE_TEXT "A DNS query for a type other than CNAME returned a CNAME response"
312 /** @}
313 */
314
315 /**
316 * \defgroup rrtypes RR Types
317 * @{
318 */
319 #define GETDNS_RRTYPE_A 1
320 #define GETDNS_RRTYPE_NS 2
321 #define GETDNS_RRTYPE_MD 3
322 #define GETDNS_RRTYPE_MF 4
323 #define GETDNS_RRTYPE_CNAME 5
324 #define GETDNS_RRTYPE_SOA 6
325 #define GETDNS_RRTYPE_MB 7
326 #define GETDNS_RRTYPE_MG 8
327 #define GETDNS_RRTYPE_MR 9
328 #define GETDNS_RRTYPE_NULL 10
329 #define GETDNS_RRTYPE_WKS 11
330 #define GETDNS_RRTYPE_PTR 12
331 #define GETDNS_RRTYPE_HINFO 13
332 #define GETDNS_RRTYPE_MINFO 14
333 #define GETDNS_RRTYPE_MX 15
334 #define GETDNS_RRTYPE_TXT 16
335 #define GETDNS_RRTYPE_RP 17
336 #define GETDNS_RRTYPE_AFSDB 18
337 #define GETDNS_RRTYPE_X25 19
338 #define GETDNS_RRTYPE_ISDN 20
339 #define GETDNS_RRTYPE_RT 21
340 #define GETDNS_RRTYPE_NSAP 22
341 #define GETDNS_RRTYPE_SIG 24
342 #define GETDNS_RRTYPE_KEY 25
343 #define GETDNS_RRTYPE_PX 26
344 #define GETDNS_RRTYPE_GPOS 27
345 #define GETDNS_RRTYPE_AAAA 28
346 #define GETDNS_RRTYPE_LOC 29
347 #define GETDNS_RRTYPE_NXT 30
348 #define GETDNS_RRTYPE_EID 31
349 #define GETDNS_RRTYPE_NIMLOC 32
350 #define GETDNS_RRTYPE_SRV 33
351 #define GETDNS_RRTYPE_ATMA 34
352 #define GETDNS_RRTYPE_NAPTR 35
353 #define GETDNS_RRTYPE_KX 36
354 #define GETDNS_RRTYPE_CERT 37
355 #define GETDNS_RRTYPE_A6 38
356 #define GETDNS_RRTYPE_DNAME 39
357 #define GETDNS_RRTYPE_SINK 40
358 #define GETDNS_RRTYPE_OPT 41
359 #define GETDNS_RRTYPE_APL 42
360 #define GETDNS_RRTYPE_DS 43
361 #define GETDNS_RRTYPE_SSHFP 44
362 #define GETDNS_RRTYPE_IPSECKEY 45
363 #define GETDNS_RRTYPE_RRSIG 46
364 #define GETDNS_RRTYPE_NSEC 47
365 #define GETDNS_RRTYPE_DNSKEY 48
366 #define GETDNS_RRTYPE_DHCID 49
367 #define GETDNS_RRTYPE_NSEC3 50
368 #define GETDNS_RRTYPE_NSEC3PARAM 51
369 #define GETDNS_RRTYPE_TLSA 52
370 #define GETDNS_RRTYPE_HIP 55
371 #define GETDNS_RRTYPE_NINFO 56
372 #define GETDNS_RRTYPE_RKEY 57
373 #define GETDNS_RRTYPE_TALINK 58
374 #define GETDNS_RRTYPE_CDS 59
375 #define GETDNS_RRTYPE_SPF 99
376 #define GETDNS_RRTYPE_UINFO 100
377 #define GETDNS_RRTYPE_UID 101
378 #define GETDNS_RRTYPE_GID 102
379 #define GETDNS_RRTYPE_UNSPEC 103
380 #define GETDNS_RRTYPE_NID 104
381 #define GETDNS_RRTYPE_L32 105
382 #define GETDNS_RRTYPE_L64 106
383 #define GETDNS_RRTYPE_LP 107
384 #define GETDNS_RRTYPE_EUI48 108
385 #define GETDNS_RRTYPE_EUI64 109
386 #define GETDNS_RRTYPE_TKEY 249
387 #define GETDNS_RRTYPE_TSIG 250
388 #define GETDNS_RRTYPE_IXFR 251
389 #define GETDNS_RRTYPE_AXFR 252
390 #define GETDNS_RRTYPE_MAILB 253
391 #define GETDNS_RRTYPE_MAILA 254
392 #define GETDNS_RRTYPE_ANY 255
393 #define GETDNS_RRTYPE_URI 256
394 #define GETDNS_RRTYPE_CAA 257
395 #define GETDNS_RRTYPE_TA 32768
396 #define GETDNS_RRTYPE_DLV 32769
397 /** @}
398 */
399
400 /**
401 * \defgroup rrclasses RR classes
402 * @{
403 */
404 #define GETDNS_RRCLASS_IN 1
405 #define GETDNS_RRCLASS_CH 3
406 #define GETDNS_RRCLASS_HS 4
407 #define GETDNS_RRCLASS_NONE 254
408 #define GETDNS_RRCLASS_ANY 255
409 /** @}
410 */
411
412 /**
413 * \defgroup opcodes Opcodes
414 * @{
415 */
416 #define GETDNS_OPCODE_QUERY 0
417 #define GETDNS_OPCODE_IQUERY 1
418 #define GETDNS_OPCODE_STATUS 2
419 #define GETDNS_OPCODE_NOTIFY 4
420 #define GETDNS_OPCODE_UPDATE 5
421 /** @}
422 */
423
424 /**
425 * \defgroup rcodes Rcodes
426 * @{
427 */
428 #define GETDNS_RCODE_NOERROR 0
429 #define GETDNS_RCODE_FORMERR 1
430 #define GETDNS_RCODE_SERVFAIL 2
431 #define GETDNS_RCODE_NXDOMAIN 3
432 #define GETDNS_RCODE_NOTIMP 4
433 #define GETDNS_RCODE_REFUSED 5
434 #define GETDNS_RCODE_YXDOMAIN 6
435 #define GETDNS_RCODE_YXRRSET 7
436 #define GETDNS_RCODE_NXRRSET 8
437 #define GETDNS_RCODE_NOTAUTH 9
438 #define GETDNS_RCODE_NOTZONE 10
439 #define GETDNS_RCODE_BADVERS 16
440 #define GETDNS_RCODE_BADSIG 16
441 #define GETDNS_RCODE_BADKEY 17
442 #define GETDNS_RCODE_BADTIME 18
443 #define GETDNS_RCODE_BADMODE 19
444 #define GETDNS_RCODE_BADNAME 20
445 #define GETDNS_RCODE_BADALG 21
446 #define GETDNS_RCODE_BADTRUNC 22
447 /** @}
448 */
449
450
451 typedef struct getdns_context getdns_context;
452 typedef uint64_t getdns_transaction_t;
453 /**
454 * used to check data types within complex types (dict, list)
455 */
456 typedef enum getdns_data_type
457 {
458 t_dict, t_list, t_int, t_bindata
459 } getdns_data_type;
460 typedef struct getdns_bindata
461 {
462 size_t size;
463 uint8_t *data;
464 } getdns_bindata;
465
466 /**
467 * getdns dictionary data type
468 * Use helper functions getdns_dict_* to manipulate and iterate dictionaries
469 */
470 typedef struct getdns_dict getdns_dict;
471
472 /**
473 * getdns list data type
474 * Use helper functions getdns_list_* to manipulate and iterate lists
475 * Indexes are 0 based.
476 */
477 typedef struct getdns_list getdns_list;
478
479 /**
480 * translate an error code to a string value, not in the original api description
481 * but seems like a nice thing to have
482 * @param err return code from GETDNS_RETURN_* defines
483 * @param buf buffer to which to copy the error string
484 * @param buflen length of buf
485 * @return GETDNS_RETURN_GOOD on success
486 */
487 getdns_return_t getdns_strerror(getdns_return_t err, char *buf, size_t buflen);
488
489 /**
490 * get the length of the specified list (returned in *answer)
491 * @param this_list list of any of the supported data types
492 * @param answer number of valid items in the list
493 * @return GETDNS_RETURN_GOOD on success
494 * @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if list is not valid or params are NULL
495 */
496 getdns_return_t getdns_list_get_length(const getdns_list *this_list,
497 size_t * answer);
498 /**
499 * get the enumerated data type of the indexed list item
500 * @param this_list the list from which to fetch the data type
501 * @param index the item in the list from which to fetch the data type
502 * @param *answer assigned the value of the data type on success
503 * @return GETDNS_RETURN_GOOD on success
504 * @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
505 */
506 getdns_return_t getdns_list_get_data_type(const getdns_list *this_list,
507 size_t index, getdns_data_type * answer);
508 /**
509 * retrieve the dictionary value of the specified list item, the caller must not free
510 * storage associated with the return value. When the list is destroyed this
511 * dict data is also free()'d - keep this in mind when using this function.
512 * @param this_list the list from which to fetch the value
513 * @param index the item in the list from which to fetch the value
514 * @param **answer assigned a pointer to the dict value of the indexed element
515 * @return GETDNS_RETURN_GOOD on success
516 * @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
517 * @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
518 */
519 getdns_return_t getdns_list_get_dict(const getdns_list *this_list, size_t index,
520 getdns_dict **answer);
521
522 /**
523 * retrieve the list value of the specified list item, the caller must not free
524 * storage associated with the return value. When the list is destroyed any
525 * list data is also free()'d - keep this in mind when using this function.
526 * @param this_list the list from which to fetch the value
527 * @param index the item in the list from which to fetch the value
528 * @param **answer assigned a pointer to the list value of the indexed element
529 * @return GETDNS_RETURN_GOOD on success
530 * @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
531 * @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
532 */
533 getdns_return_t getdns_list_get_list(const getdns_list *this_list, size_t index,
534 getdns_list **answer);
535 /**
536 * retrieve the binary data value of the specified list item, the caller must not
537 * free storage associated with the return value. When the list is destroyed any
538 * bindata data is also free()'d - keep this in mind when using this function.
539 * @param this_list the list from which to fetch the value
540 * @param index the item in the list from which to fetch the value
541 * @param **answer assigned a pointer to the list value of the indexed element
542 * @return GETDNS_RETURN_GOOD on success
543 * @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
544 * @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
545 */
546 getdns_return_t getdns_list_get_bindata(const getdns_list *this_list, size_t index,
547 getdns_bindata **answer);
548 /**
549 * retrieve the integer value of the specified list item
550 * @param this_list the list from which to fetch the item
551 * @param index the index of the element in the list to fetch from
552 * @param *answer assigned the integer value of the indexed element
553 * @return GETDNS_RETURN_GOOD on success
554 * @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if the index is out of range or the list is NULL
555 * @return GETDNS_RETURN_WRONG_TYPE_REQUESTED if the data type does not match the contents of the indexed item
556 */
557 getdns_return_t getdns_list_get_int(const getdns_list *this_list, size_t index,
558 uint32_t * answer);
559
560 /**
561 * fetch a list of names from the dictionary, this list must be freed by the caller
562 * via a call to getdns_list_destroy
563 * @param this_dict dictionary from which to produce the list of names
564 * @param **answer a pointer to the new list will be assigned to *answer
565 * @return GETDNS_RETURN_GOOD on success
566 * @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or empty
567 */
568 getdns_return_t getdns_dict_get_names(const getdns_dict *this_dict,
569 getdns_list **answer);
570 /**
571 * fetch the data type for the data associated with the specified name
572 * @param this_dict dictionary from which to fetch the data type
573 * @param name a name/key value to look up in the dictionary
574 * @param *answer data type will be stored at this address
575 * @return GETDNS_RETURN_GOOD on success
576 * @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
577 */
578 getdns_return_t getdns_dict_get_data_type(const getdns_dict *this_dict,
579 const char *name, getdns_data_type * answer);
580 /**
581 * fetch the dictionary associated with the specified name, the dictionary should
582 * not be free()'d by the caller, it will be freed when the parent dictionary is
583 * free()'d
584 * @param this_dict dictionary from which to fetch the dictionary
585 * @param name a name/key value to look up in the dictionary
586 * @param **answer a copy of the dictionary will be stored at this address
587 * @return GETDNS_RETURN_GOOD on success
588 * @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
589 */
590 getdns_return_t getdns_dict_get_dict(const getdns_dict *this_dict,
591 const char *name, getdns_dict **answer);
592 /**
593 * fetch the list associated with the specified name
594 * the list should not be free()'d by the caller, when the dictionary is destroyed
595 * the list will also be destroyed
596 * @param this_dict dictionary from which to fetch the list
597 * @param name a name/key value to look up in the dictionary
598 * @param **answer a copy of the list will be stored at this address
599 * @return GETDNS_RETURN_GOOD on success
600 * @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
601 */
602 getdns_return_t getdns_dict_get_list(const getdns_dict *this_dict,
603 const char *name, getdns_list **answer);
604 /**
605 * fetch the bindata associated with the specified name, the bindata should not be
606 * free()'d by the caller
607 * @param this_dict dictionary from which to fetch the bindata
608 * @param name a name/key value to look up in the dictionary
609 * @param **answer a copy of the bindata will be stored at this address
610 * @return GETDNS_RETURN_GOOD on success
611 * @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
612 */
613 getdns_return_t getdns_dict_get_bindata(const getdns_dict *this_dict,
614 const char *name, getdns_bindata **answer);
615 /**
616 * fetch the integer value associated with the specified name
617 * @param this_dict dictionary from which to fetch the integer
618 * @param name a name/key value to look up in the dictionary
619 * @param *answer the integer will be stored at this address
620 * @return GETDNS_RETURN_GOOD on success
621 * @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
622 */
623 getdns_return_t getdns_dict_get_int(const getdns_dict *this_dict,
624 const char *name, uint32_t * answer);
625
626 /**
627 * create a new list with no items
628 * @return pointer to an allocated list, NULL if insufficient memory
629 */
630 getdns_list *getdns_list_create();
631 getdns_list *getdns_list_create_with_context(getdns_context *context);
632 getdns_list *getdns_list_create_with_memory_functions(
633 void *(*malloc) (size_t),
634 void *(*realloc) (void *, size_t),
635 void (*free) (void *)
636 );
637 getdns_list *getdns_list_create_with_extended_memory_functions(
638 void *userarg,
639 void *(*malloc) (void *userarg, size_t),
640 void *(*realloc) (void *userarg, void *, size_t),
641 void (*free) (void *userarg, void *)
642 );
643
644 /**
645 * free memory allocated to the list (also frees all children of the list)
646 * note that lists and bindata retrieved from the list via the getdns_list_get_*
647 * helper functions will be destroyed as well - if you fetched them previously
648 * you MUST copy those instances BEFORE you destroy the list else
649 * unpleasant things will happen at run-time
650 */
651 void getdns_list_destroy(getdns_list *this_list);
652
653 /**
654 * assign the child_dict to an item in a parent list, the parent list copies
655 * the child dict and will free the copy when the list is destroyed
656 * @param this_list list containing the item to which child_list is to be assigned
657 * @param index index of the item within list to which child_list is to be assigned
658 * @param *child_list list to assign to the item
659 * @return GETDNS_RETURN_GOOD on success
660 * @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
661 */
662 getdns_return_t getdns_list_set_dict(getdns_list *this_list, size_t index,
663 const getdns_dict *child_dict);
664
665 /**
666 * assign the child_list to an item in a parent list, the parent list copies
667 * the child list and will free the copy when the list is destroyed
668 * @param this_list list containing the item to which child_list is to be assigned
669 * @param index index of the item within list to which child_list is to be assigned
670 * @param *child_list list to assign to the item
671 * @return GETDNS_RETURN_GOOD on success
672 * @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
673 */
674 getdns_return_t getdns_list_set_list(getdns_list *this_list, size_t index,
675 const getdns_list *child_list);
676 /**
677 * assign the child_bindata to an item in a parent list, the parent list copies
678 * the child data and will free the copy when the list is destroyed
679 * @param this_list list contiaining the item to which child_list is to be assigned
680 * @param index index of the item within list to which child_list is to be assigned
681 * @param *child_bindata data to assign to the item
682 * @return GETDNS_RETURN_GOOD on success
683 * @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
684 */
685 getdns_return_t getdns_list_set_bindata(getdns_list *this_list, size_t index,
686 const getdns_bindata *child_bindata);
687 /**
688 * set the integer value of the indexed item (zero based index)
689 * @return GETDNS_RETURN_GOOD on success
690 * @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
691 */
692 getdns_return_t getdns_list_set_int(getdns_list *this_list, size_t index,
693 uint32_t child_uint32);
694
695 /**
696 * create a new dictionary with no items
697 * @return pointer to an allocated dictionary, NULL if insufficient memory
698 */
699 getdns_dict *getdns_dict_create();
700 getdns_dict *getdns_dict_create_with_context(getdns_context *context);
701 getdns_dict *getdns_dict_create_with_memory_functions(
702 void *(*malloc) (size_t),
703 void *(*realloc) (void *, size_t),
704 void (*free) (void *)
705 );
706 getdns_dict *getdns_dict_create_with_extended_memory_functions(
707 void *userarg,
708 void *(*malloc) (void *userarg, size_t),
709 void *(*realloc) (void *userarg, void *, size_t),
710 void (*free) (void *userarg, void *)
711 );
712
713 /**
714 * destroy a dictionary and all items within that dictionary
715 * be aware that if you have fetched any data from the dictionary it will
716 * no longer be available (you are likely to experience bad things if you try)
717 */
718 void getdns_dict_destroy(getdns_dict *this_dict);
719
720 getdns_return_t getdns_dict_set_dict(getdns_dict *this_dict,
721 const char *name, const getdns_dict *child_dict);
722 /**
723 * create a new entry in the dictionary, or replace the value of an existing entry
724 * this routine makes a copy of the child_list
725 * @param this_dict dictionary in which to add or change the value
726 * @param name key that identifies which item in the dictionary to add/change
727 * @param child_list value to assign to the node identified by name
728 * @return GETDNS_RETURN_GOOD on success
729 */
730 getdns_return_t getdns_dict_set_list(getdns_dict *this_dict,
731 const char *name, const getdns_list *child_list);
732 /**
733 * create a new entry in the dictionary, or replace the value of an existing entry
734 * this routine makes a copy of the child_bindata
735 * @param this_dict dictionary in which to add or change the value
736 * @param name key that identifies which item in the dictionary to add/change
737 * @param child_bindata value to assign to the node identified by name
738 * @return GETDNS_RETURN_GOOD on success
739 */
740 getdns_return_t getdns_dict_set_bindata(getdns_dict *this_dict,
741 const char *name, const getdns_bindata *child_bindata);
742 /**
743 * create a new entry in the dictionary, or replace the value of an existing entry
744 * @param this_dict dictionary in which to add or change the value
745 * @param name key that identifies which item in the dictionary to add/change
746 * @param child_uint32 value to assign to the node identified by name
747 * @return GETDNS_RETURN_GOOD on success
748 */
749 getdns_return_t getdns_dict_set_int(getdns_dict *this_dict, const char *name,
750 uint32_t child_uint32);
751
752 /**
753 * remove the value associated with the specified name
754 * @param this_dict dictionary from which to fetch the integer
755 * @param name a name/key value to look up in the dictionary
756 * @return GETDNS_RETURN_GOOD on success
757 * @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
758 */
759 getdns_return_t getdns_dict_remove_name(getdns_dict *this_dict, const char *name);
760
761 /* Callback arguments */
762 typedef void (*getdns_callback_t) (getdns_context *context,
763 getdns_callback_type_t callback_type,
764 getdns_dict * response,
765 void *userarg, getdns_transaction_t transaction_id);
766
767 /* Function definitions */
768
769 getdns_return_t
770 getdns_general(getdns_context *context,
771 const char *name,
772 uint16_t request_type,
773 getdns_dict *extensions,
774 void *userarg,
775 getdns_transaction_t * transaction_id, getdns_callback_t callbackfn);
776 getdns_return_t
777 getdns_address(getdns_context *context,
778 const char *name,
779 getdns_dict *extensions,
780 void *userarg,
781 getdns_transaction_t * transaction_id, getdns_callback_t callbackfn);
782 getdns_return_t
783 getdns_hostname(getdns_context *context,
784 getdns_dict *address,
785 getdns_dict *extensions,
786 void *userarg,
787 getdns_transaction_t * transaction_id, getdns_callback_t callbackfn);
788 getdns_return_t
789 getdns_service(getdns_context *context,
790 const char *name,
791 getdns_dict *extensions,
792 void *userarg,
793 getdns_transaction_t * transaction_id, getdns_callback_t callbackfn);
794
795 getdns_return_t
796 getdns_context_create(getdns_context ** context, int set_from_os);
797
798 getdns_return_t
799 getdns_context_create_with_memory_functions(
800 getdns_context ** context,
801 int set_from_os,
802 void *(*malloc) (size_t),
803 void *(*realloc) (void *, size_t),
804 void (*free) (void *)
805 );
806
807 getdns_return_t
808 getdns_context_create_with_extended_memory_functions(
809 getdns_context **context,
810 int set_from_os,
811 void *userarg,
812 void *(*malloc) (void *userarg, size_t),
813 void *(*realloc) (void *userarg, void *, size_t),
814 void (*free) (void *userarg, void *)
815 );
816
817 void getdns_context_destroy(getdns_context *context);
818
819 getdns_return_t
820 getdns_cancel_callback(getdns_context *context,
821 getdns_transaction_t transaction_id);
822
823 /**
824 * \defgroup syncfuns Synchronous API functions that do not use callbacks
825 * These functions do not use callbacks, when the application calls one of these
826 * functions the library retrieves all of the data before returning. Return
827 * values are exactly the same as if you had used a callback with the
828 * asynchronous functions.
829 * @{
830 */
831
832 /**
833 * retrieve general DNS data
834 * @param context pointer to a previously created context to be used for this call
835 * @param name the ASCII based domain name to lookup
836 * @param request_type RR type for the query, e.g. GETDNS_RR_TYPE_NS
837 * @param extensions dict data structures, NULL to use no extensions
838 * @param response response
839 * @return GETDNS_RETURN_GOOD on success
840 */
841 getdns_return_t
842 getdns_general_sync(getdns_context *context,
843 const char *name,
844 uint16_t request_type,
845 getdns_dict *extensions,
846 getdns_dict **response);
847
848 /**
849 * retrieve address assigned to a DNS name
850 * @param context pointer to a previously created context to be used for this call
851 * @param name the ASCII based domain name to lookup
852 * @param extensions dict data structures, NULL to use no extensions
853 * @param response response
854 * @return GETDNS_RETURN_GOOD on success
855
856 */
857 getdns_return_t
858 getdns_address_sync(getdns_context *context,
859 const char *name,
860 getdns_dict *extensions,
861 getdns_dict **response);
862
863 /**
864 * retrieve hostname assigned to an IP address
865 * @param context pointer to a previously created context to be used for this call
866 * @param address the address to look up
867 * @param extensions dict data structures, NULL to use no extensions
868 * @param response response
869 * @return GETDNS_RETURN_GOOD on success
870 */
871 getdns_return_t
872 getdns_hostname_sync(getdns_context *context,
873 getdns_dict *address,
874 getdns_dict *extensions,
875 getdns_dict **response);
876
877 /**
878 * retrieve a service assigned to a DNS name
879 * @param context pointer to a previously created context to be used for this call
880 * @param name the ASCII based domain name to lookup
881 * @param extensions dict data structures, NULL to use no extensions
882 * @param response response
883 * @return GETDNS_RETURN_GOOD on success
884 */
885 getdns_return_t
886 getdns_service_sync(getdns_context *context,
887 const char *name,
888 getdns_dict *extensions,
889 getdns_dict **response);
890
891 /** @}
892 */
893
894 getdns_return_t
895 getdns_convert_dns_name_to_fqdn(
896 const getdns_bindata *dns_name_wire_fmt,
897 char **fqdn_as_string);
898
899 getdns_return_t
900 getdns_convert_fqdn_to_dns_name(
901 const char *fqdn_as_string,
902 getdns_bindata **dns_name_wire_fmt);
903
904 char *getdns_convert_ulabel_to_alabel(const char *ulabel);
905
906 char *getdns_convert_alabel_to_ulabel(const char *alabel);
907
908 getdns_return_t
909 getdns_validate_dnssec(getdns_list *to_validate,
910 getdns_list *support_records,
911 getdns_list *trust_anchors);
912
913 /**
914 * creates a string that describes the dictionary in a human readable form
915 * one line per item in the dictionary
916 * TODO: maybe this should be json or something machine readable too
917 * @param this_dict dictionary to pretty print
918 * @return character array (caller must free this) containing pretty string
919 */
920 char *getdns_pretty_print_dict(const getdns_dict *some_dict);
921
922 char *getdns_display_ip_address(const getdns_bindata
923 *bindata_of_ipv4_or_ipv6_address);
924
925 getdns_return_t
926 getdns_context_set_context_update_callback(
927 getdns_context *context,
928 void (*value)(getdns_context *context,
929 getdns_context_code_t changed_item)
930 );
931
932 getdns_return_t
933 getdns_context_set_resolution_type(getdns_context *context,
934 getdns_resolution_t value);
935
936 getdns_return_t
937 getdns_context_set_namespaces(getdns_context *context,
938 size_t namespace_count, getdns_namespace_t *namespaces);
939
940 getdns_return_t
941 getdns_context_set_dns_transport(getdns_context *context,
942 getdns_transport_t value);
943
944 getdns_return_t
945 getdns_context_set_limit_outstanding_queries(getdns_context *context,
946 uint16_t limit);
947
948 getdns_return_t
949 getdns_context_set_timeout(getdns_context *context, uint64_t timeout);
950
951 getdns_return_t
952 getdns_context_set_follow_redirects(getdns_context *context,
953 getdns_redirects_t value);
954
955 getdns_return_t
956 getdns_context_set_dns_root_servers(getdns_context *context,
957 getdns_list *addresses);
958
959 getdns_return_t
960 getdns_context_set_append_name(getdns_context *context,
961 getdns_append_name_t value);
962
963 getdns_return_t
964 getdns_context_set_suffix(getdns_context *context, getdns_list *value);
965
966 getdns_return_t
967 getdns_context_set_dnssec_trust_anchors(getdns_context *context,
968 getdns_list *value);
969
970 getdns_return_t
971 getdns_context_set_dnssec_allowed_skew(getdns_context *context,
972 uint32_t value);
973
974 getdns_return_t
975 getdns_context_set_upstream_recursive_servers(getdns_context *context,
976 getdns_list *upstream_list);
977
978 getdns_return_t
979 getdns_context_set_edns_maximum_udp_payload_size(getdns_context *context,
980 uint16_t value);
981
982 getdns_return_t
983 getdns_context_set_edns_extended_rcode(getdns_context *context,
984 uint8_t value);
985
986 getdns_return_t
987 getdns_context_set_edns_version(getdns_context *context, uint8_t value);
988
989 getdns_return_t
990 getdns_context_set_edns_do_bit(getdns_context *context, uint8_t value);
991
992 getdns_return_t
993 getdns_context_set_memory_functions(getdns_context *context,
994 void *(*malloc) (size_t),
995 void *(*realloc) (void *, size_t),
996 void (*free) (void *)
997 );
998
999 getdns_return_t
1000 getdns_context_set_extended_memory_functions(getdns_context *context,
1001 void *userarg,
1002 void *(*malloc) (void *userarg, size_t sz),
1003 void *(*realloc) (void *userarg, void *ptr, size_t sz),
1004 void (*free) (void *userarg, void *ptr)
1005 );
1006
1007 /* api information support */
1008 getdns_dict*
1009 getdns_context_get_api_information(getdns_context* context);
1010
1011 /* Get root trust anchor */
1012 getdns_list *getdns_root_trust_anchor(time_t *utc_date_of_anchor);
1013
1014 #ifdef __cplusplus
1015 }
1016 #endif
1017 #endif /* GETDNS_H */
0 /**
1 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7
8 /*
9 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef GETDNS_EXT_LIBEV_H
36 #define GETDNS_EXT_LIBEV_H
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 #include <getdns/getdns.h>
43 #include <getdns/getdns_extra.h>
44 struct ev_loop;
45
46 /* For libevent, which we are using for these examples */
47 getdns_return_t
48 getdns_extension_set_libev_loop(struct getdns_context *context,
49 struct ev_loop *ev_loop);
50
51 #ifdef __cplusplus
52 }
53 #endif
54 #endif
0 /**
1 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7
8 /*
9 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef GETDNS_EXT_LIBEVENT_H
36 #define GETDNS_EXT_LIBEVENT_H
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 #include <getdns/getdns.h>
43 #include <getdns/getdns_extra.h>
44 struct event_base;
45
46 /* For libevent, which we are using for these examples */
47 getdns_return_t
48 getdns_extension_set_libevent_base(struct getdns_context *context,
49 struct event_base *this_event_base);
50
51 #ifdef __cplusplus
52 }
53 #endif
54 #endif
0 /**
1 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7
8 /*
9 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef GETDNS_EXT_LIBUV_H
36 #define GETDNS_EXT_LIBUV_H
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 #include <getdns/getdns.h>
43 #include <getdns/getdns_extra.h>
44 struct uv_loop_s;
45
46 /* For libevent, which we are using for these examples */
47 getdns_return_t
48 getdns_extension_set_libuv_loop(struct getdns_context *context,
49 struct uv_loop_s *uv_loop);
50
51 #ifdef __cplusplus
52 }
53 #endif
54 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27 #ifndef _GETDNS_EXTRA_H_
28 #define _GETDNS_EXTRA_H_
29
30 #include <getdns/getdns.h>
31 #include <sys/time.h>
32
33 /* Enable the return_dnssec_status extension on every request.
34 value is either GETDNS_EXTENSION_TRUE or GETDNS_EXTENSION_FALSE
35 returns GETDNS_RETURN_GOOD on success or GETDNS_RETURN_INVALID_PARAMETER
36 if context or value is invalid */
37 getdns_return_t getdns_context_set_return_dnssec_status(getdns_context* context, int enabled);
38
39 /* dict util */
40 /* set a string as bindata */
41 getdns_return_t getdns_dict_util_set_string(struct getdns_dict * dict, char *name,
42 const char *value);
43
44 /* get a string from a dict. the result must be freed if valid */
45 getdns_return_t getdns_dict_util_get_string(struct getdns_dict * dict, char *name,
46 char **result);
47
48 /* Async support */
49 uint32_t getdns_context_get_num_pending_requests(getdns_context* context, struct timeval* next_timeout);
50
51 /* get the fd */
52 int getdns_context_fd(getdns_context* context);
53
54 /* process async reqs */
55 getdns_return_t getdns_context_process_async(getdns_context* context);
56
57
58 /* extensions */
59 typedef void (*getdns_timeout_callback) (void* userarg);
60
61 /* context timeout data */
62 typedef struct getdns_timeout_data {
63 /* a timeout id */
64 getdns_transaction_t transaction_id;
65 /* the absolute time of the timeout */
66 struct timeval timeout_time;
67 /* the timeout callback to fire */
68 getdns_timeout_callback callback;
69 /* timeout callback user arg */
70 void* userarg;
71 /* pointer to the underlying extension pointer that the extension
72 will create and free */
73 void* extension_timer;
74 /* context */
75 struct getdns_context* context;
76 } getdns_timeout_data_t;
77
78 /* call the extension when the data needs to be cleaned up */
79 typedef getdns_return_t (*getdns_eventloop_cleanup_t)(struct getdns_context* context, void* eventloop_data);
80
81 /* call the extension to schedule a timer. Any timer data that needs to be tracked should be
82 stored in eventloop_timer */
83 typedef getdns_return_t (*getdns_eventloop_schedule_timeout_t)(struct getdns_context* context,
84 void* eventloop_data, uint16_t timeout,
85 getdns_timeout_data_t* timeout_data,
86 void** eventloop_timer);
87
88 /* call the extension to free a timer. The timer passed in is the same as that returned in
89 the schedule timeout */
90 typedef getdns_return_t (*getdns_eventloop_clear_timeout_t)(struct getdns_context* context,
91 void* eventloop_data, void* eventloop_timer);
92
93 /* call the extension to tell it that the number of outbound requests changed. This is called
94 when an async request is submitted or canceled by the user */
95 typedef getdns_return_t (*getdns_eventloop_request_count_changed_t)(struct getdns_context* context,
96 uint32_t request_count, void* eventloop_data);
97
98 typedef struct getdns_eventloop_extension {
99 getdns_eventloop_cleanup_t cleanup_data;
100 getdns_eventloop_schedule_timeout_t schedule_timeout;
101 getdns_eventloop_clear_timeout_t clear_timeout;
102 getdns_eventloop_request_count_changed_t request_count_changed;
103 } getdns_eventloop_extension;
104
105 /* set an event loop extension on the context */
106 getdns_return_t
107 getdns_extension_set_eventloop(struct getdns_context* context,
108 getdns_eventloop_extension* extension, void* extension_data);
109
110 void*
111 getdns_context_get_extension_data(struct getdns_context* context);
112
113 /* detach the eventloop from the context */
114 getdns_return_t
115 getdns_extension_detach_eventloop(struct getdns_context* context);
116
117
118 #endif
0 /**
1 * \file getdns_error.c
2 * @brief getdns error code to string function
3 *
4 */
5
6 /*
7 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * * Neither the names of the copyright holders nor the
18 * names of its contributors may be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include <getdns/getdns.h>
34 #include "const-info.h"
35
36 /*---------------------------------------- getdns_get_errorstr_by_id() */
37 /**
38 * return error string from getdns return
39 * @param err getdns_return_t
40 * @return string containing error message
41 */
42
43 const char *
44 getdns_get_errorstr_by_id(uint16_t err)
45 {
46 return priv_getdns_get_const_info(err)->text;
47 }
48
49 /* getdns_error.c */
0 /**
1 * \file
2 * @brief defines and data structure for getdns_error_str_by_id()
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7 /*
8 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * * Neither the names of the copyright holders nor the
19 * names of its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #ifndef GETDNS_ERROR_H
35 #define GETDNS_ERROR_H
36
37 #include <getdns/getdns.h>
38
39 const char *getdns_get_errorstr_by_id(uint16_t err);
40
41 /** @}
42 */
43
44 #endif /* GETDNS_ERROR_H */
0 /**
1 *
2 * \file hostname.c
3 * @brief getdns core functions
4 *
5 * Originally taken from the getdns API description pseudo implementation.
6 *
7 */
8
9 /*
10 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * * Neither the names of the copyright holders nor the
21 * names of its contributors may be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36
37 #include <getdns/getdns.h>
38 #include "context.h"
39 #include "general.h"
40 #include "util-internal.h"
41 #include "types-internal.h"
42 #include <string.h>
43
44 /* stuff to make it compile pedantically */
45 #define UNUSED_PARAM(x) ((void)(x))
46
47 /*
48 * getdns_hostname
49 *
50 */
51 getdns_return_t
52 getdns_hostname(struct getdns_context *context,
53 struct getdns_dict * address,
54 struct getdns_dict * extensions,
55 void *userarg,
56 getdns_transaction_t * transaction_id, getdns_callback_t callback)
57 {
58 struct getdns_bindata *address_data;
59 struct getdns_bindata *address_type;
60 uint16_t req_type;
61 char *name;
62 getdns_return_t retval;
63
64 if ((retval =
65 getdns_dict_get_bindata(address, "address_data",
66 &address_data)) != GETDNS_RETURN_GOOD)
67 return retval;
68 if ((retval =
69 getdns_dict_get_bindata(address, "address_type",
70 &address_type)) != GETDNS_RETURN_GOOD)
71 return retval;
72 if ((strncmp(GETDNS_STR_IPV4, (char *) address_type->data,
73 ( strlen(GETDNS_STR_IPV4) < address_type->size
74 ? strlen(GETDNS_STR_IPV4) : address_type->size )) == 0
75 && address_data->size == 4)
76 || (strncmp(GETDNS_STR_IPV6, (char *) address_type->data,
77 ( strlen(GETDNS_STR_IPV6) < address_type->size
78 ? strlen(GETDNS_STR_IPV6) : address_type->size )) == 0
79 && address_data->size == 16))
80 req_type = GETDNS_RRTYPE_PTR;
81 else
82 return GETDNS_RETURN_INVALID_PARAMETER;
83 if ((name = reverse_address(address_data)) == NULL)
84 return GETDNS_RETURN_INVALID_PARAMETER;
85 retval = getdns_general(context, name, req_type, extensions,
86 userarg, transaction_id, callback);
87 free(name);
88 return retval;
89 } /* getdns_hostname */
90
91 /* hostname.c */
0 /**
1 *
2 * /brief getdns list management functions
3 *
4 * This is the meat of the API
5 * Originally taken from the getdns API description pseudo implementation.
6 *
7 */
8
9 /*
10 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * * Neither the names of the copyright holders nor the
21 * names of its contributors may be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 #include <string.h>
37 #include "types-internal.h"
38 #include "util-internal.h"
39 #include "list.h"
40
41 /*---------------------------------------- getdns_list_get_length */
42 getdns_return_t
43 getdns_list_get_length(const struct getdns_list * list, size_t * answer)
44 {
45 if (!list || !answer)
46 return GETDNS_RETURN_INVALID_PARAMETER;
47
48 *answer = list->numinuse;
49 return GETDNS_RETURN_GOOD;;
50 } /* getdns_list_get_length */
51
52 /*---------------------------------------- getdns_list_get_data_type */
53 getdns_return_t
54 getdns_list_get_data_type(const struct getdns_list * list, size_t index,
55 getdns_data_type * answer)
56 {
57 if (!list || !answer)
58 return GETDNS_RETURN_INVALID_PARAMETER;
59
60 if (index >= list->numinuse)
61 return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
62
63 *answer = list->items[index].dtype;
64 return GETDNS_RETURN_GOOD;
65 } /* getdns_list_get_data_type */
66
67 /*---------------------------------------- getdns_list_get_dict */
68 getdns_return_t
69 getdns_list_get_dict(const struct getdns_list * list, size_t index,
70 struct getdns_dict ** answer)
71 {
72 if (!list || !answer)
73 return GETDNS_RETURN_INVALID_PARAMETER;
74
75 if (index >= list->numinuse)
76 return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
77
78 if (list->items[index].dtype != t_dict)
79 return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
80
81 *answer = list->items[index].data.dict;
82 return GETDNS_RETURN_GOOD;
83 } /* getdns_list_get_dict */
84
85 /*---------------------------------------- getdns_list_get_list */
86 getdns_return_t
87 getdns_list_get_list(const struct getdns_list * list, size_t index,
88 struct getdns_list ** answer)
89 {
90 if (!list || !answer)
91 return GETDNS_RETURN_INVALID_PARAMETER;
92
93 if (index >= list->numinuse)
94 return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
95
96 if (list->items[index].dtype != t_list)
97 return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
98
99 *answer = list->items[index].data.list;
100 return GETDNS_RETURN_GOOD;
101 } /* getdns_list_get_list */
102
103 /*---------------------------------------- getdns_list_get_bindata */
104 getdns_return_t
105 getdns_list_get_bindata(const struct getdns_list * list, size_t index,
106 struct getdns_bindata ** answer)
107 {
108
109 if (!list || !answer)
110 return GETDNS_RETURN_INVALID_PARAMETER;
111
112 if (index >= list->numinuse)
113 return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
114
115 if (list->items[index].dtype != t_bindata)
116 return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
117
118 *answer = list->items[index].data.bindata;
119 return GETDNS_RETURN_GOOD;
120 } /* getdns_list_get_bindata */
121
122 /*---------------------------------------- getdns_list_get_int */
123 getdns_return_t
124 getdns_list_get_int(const struct getdns_list * list, size_t index,
125 uint32_t * answer)
126 {
127 if (!list || !answer)
128 return GETDNS_RETURN_INVALID_PARAMETER;
129
130 if (index >= list->numinuse)
131 return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
132
133 if (list->items[index].dtype != t_int)
134 return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
135
136 *answer = list->items[index].data.n;
137 return GETDNS_RETURN_GOOD;
138 } /* getdns_list_get_int */
139
140 /*---------------------------------------- getdns_list_realloc */
141 /**
142 * private function (API users should not be calling this)
143 * allocates a block of items, should be called when a list needs to grow
144 * preserves the existing items
145 * in case of an error the list should be considered unusable
146 * @return GETDNS_RETURN_GOOD on success, GETDNS_RETURN_GENERIC_ERROR if out of memory
147 */
148 getdns_return_t
149 getdns_list_realloc(struct getdns_list *list)
150 {
151 struct getdns_list_item *newlist;
152
153 if (!list)
154 return GETDNS_RETURN_INVALID_PARAMETER;
155
156 newlist = GETDNS_XREALLOC(list->mf, list->items,
157 struct getdns_list_item,
158 list->numalloc + GETDNS_LIST_BLOCKSZ);
159 if (!newlist)
160 return GETDNS_RETURN_GENERIC_ERROR;
161
162 list->items = newlist;
163 list->numalloc += GETDNS_LIST_BLOCKSZ;
164 return GETDNS_RETURN_GOOD;
165 } /* getdns_list_realloc */
166
167 /*---------------------------------------- getdns_list_copy */
168 getdns_return_t
169 getdns_list_copy(const struct getdns_list * srclist,
170 struct getdns_list ** dstlist)
171 {
172 int i;
173 size_t index;
174 getdns_return_t retval;
175
176 if (!dstlist)
177 return GETDNS_RETURN_INVALID_PARAMETER;
178
179 if (!srclist) {
180 *dstlist = NULL;
181 return GETDNS_RETURN_GOOD;
182 }
183 *dstlist = getdns_list_create_with_extended_memory_functions(
184 srclist->mf.mf_arg,
185 srclist->mf.mf.ext.malloc,
186 srclist->mf.mf.ext.realloc,
187 srclist->mf.mf.ext.free
188 );
189 if (!dstlist)
190 return GETDNS_RETURN_GENERIC_ERROR;
191
192 for (i = 0; i < srclist->numinuse; i++) {
193 retval = getdns_list_add_item(*dstlist, &index);
194 if (retval != GETDNS_RETURN_GOOD) {
195 getdns_list_destroy(*dstlist);
196 *dstlist = NULL;
197 return retval;
198 }
199 switch (srclist->items[i].dtype) {
200 case t_int:
201 retval = getdns_list_set_int(*dstlist, index,
202 srclist->items[i].data.n);
203 break;
204
205 case t_list:
206 retval =getdns_list_set_list(*dstlist, index,
207 srclist->items[i].data.list);
208 break;
209
210 case t_bindata:
211 retval = getdns_list_set_bindata(*dstlist, index,
212 srclist->items[i].data.bindata);
213 break;
214
215 case t_dict:
216 retval = getdns_list_set_dict(*dstlist, index,
217 srclist->items[i].data.dict);
218 break;
219 }
220 if (retval != GETDNS_RETURN_GOOD) {
221 getdns_list_destroy(*dstlist);
222 *dstlist = NULL;
223 return retval;
224 }
225 }
226 return GETDNS_RETURN_GOOD;
227 } /* getdns_list_copy */
228
229 struct getdns_list *
230 getdns_list_create_with_extended_memory_functions(
231 void *userarg,
232 void *(*malloc)(void *userarg, size_t),
233 void *(*realloc)(void *userarg, void *, size_t),
234 void (*free)(void *userarg, void *))
235 {
236 struct getdns_list *list;
237 mf_union mf;
238
239 if (!malloc || !realloc || !free)
240 return NULL;
241
242 mf.ext.malloc = malloc;
243 list = userarg == MF_PLAIN
244 ? (struct getdns_list *)(*mf.pln.malloc)(
245 sizeof(struct getdns_list))
246 : (struct getdns_list *)(*mf.ext.malloc)(userarg,
247 sizeof(struct getdns_list));
248 if (!list)
249 return NULL;
250
251 list->mf.mf_arg = userarg;
252 list->mf.mf.ext.malloc = malloc;
253 list->mf.mf.ext.realloc = realloc;
254 list->mf.mf.ext.free = free;
255
256 list->numalloc = 0;
257 list->numinuse = 0;
258 list->items = NULL;
259 if (getdns_list_realloc(list) != GETDNS_RETURN_GOOD) {
260 getdns_list_destroy(list);
261 return NULL;
262 }
263 return list;
264 }
265
266 struct getdns_list *
267 getdns_list_create_with_memory_functions(void *(*malloc)(size_t),
268 void *(*realloc)(void *, size_t), void (*free)(void *))
269 {
270 mf_union mf;
271 mf.pln.malloc = malloc;
272 mf.pln.realloc = realloc;
273 mf.pln.free = free;
274 return getdns_list_create_with_extended_memory_functions(
275 MF_PLAIN, mf.ext.malloc, mf.ext.realloc, mf.ext.free);
276 }
277
278
279 /*-------------------------- getdns_list_create_with_context */
280 struct getdns_list *
281 getdns_list_create_with_context(struct getdns_context *context)
282 {
283 if (context)
284 return getdns_list_create_with_extended_memory_functions(
285 context->mf.mf_arg,
286 context->mf.mf.ext.malloc,
287 context->mf.mf.ext.realloc,
288 context->mf.mf.ext.free
289 );
290 else
291 return getdns_list_create_with_memory_functions(malloc,
292 realloc, free);
293 } /* getdns_list_create_with_context */
294
295 /*---------------------------------------- getdns_list_create */
296 struct getdns_list *
297 getdns_list_create()
298 {
299 return getdns_list_create_with_context(NULL);
300 } /* getdns_list_create */
301
302 static void
303 getdns_list_destroy_item(struct getdns_list *list, size_t index)
304 {
305 switch (list->items[index].dtype) {
306 case t_dict:
307 getdns_dict_destroy(list->items[index].data.dict);
308 break;
309
310 case t_list:
311 getdns_list_destroy(list->items[index].data.list);
312 break;
313
314 case t_bindata:
315 getdns_bindata_destroy(&list->mf,
316 list->items[index].data.bindata);
317 break;
318
319 default:
320 break;
321 }
322 }
323
324 /*---------------------------------------- getdns_list_destroy */
325 void
326 getdns_list_destroy(struct getdns_list *list)
327 {
328 size_t i;
329
330 if (!list)
331 return;
332
333 for (i = 0; i < list->numinuse; i++)
334 getdns_list_destroy_item(list, i);
335
336 if (list->items)
337 GETDNS_FREE(list->mf, list->items);
338 GETDNS_FREE(list->mf, list);
339 } /* getdns_list_destroy */
340
341 /*---------------------------------------- getdns_list_add_item */
342 getdns_return_t
343 getdns_list_add_item(struct getdns_list *list, size_t * index)
344 {
345 getdns_return_t retval;
346
347 if (!list || !index)
348 return GETDNS_RETURN_INVALID_PARAMETER;
349
350 if (list->numalloc == list->numinuse) {
351 retval = getdns_list_realloc(list);
352 if (retval != GETDNS_RETURN_GOOD)
353 return retval;
354 }
355 *index = list->numinuse;
356 list->items[*index].dtype = t_int;
357 list->items[*index].data.n = 0;
358 list->numinuse++;
359 return GETDNS_RETURN_GOOD;
360 } /* getdns_list_add_item */
361
362 /*---------------------------------------- getdns_list_set_dict */
363 getdns_return_t
364 getdns_list_set_dict(struct getdns_list * list, size_t index,
365 const struct getdns_dict * child_dict)
366 {
367 struct getdns_dict *newdict;
368 getdns_return_t retval;
369
370 if (!list || !child_dict)
371 return GETDNS_RETURN_INVALID_PARAMETER;
372
373 if (index > list->numinuse)
374 return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
375
376 retval = getdns_dict_copy(child_dict, &newdict);
377 if (retval != GETDNS_RETURN_GOOD)
378 return retval;
379
380 if (index == list->numinuse) {
381 retval = getdns_list_add_item(list, &index);
382 if (retval != GETDNS_RETURN_GOOD) {
383 getdns_dict_destroy(newdict);
384 return retval;
385 }
386 } else
387 getdns_list_destroy_item(list, index);
388
389 list->items[index].dtype = t_dict;
390 list->items[index].data.dict = newdict;
391 return GETDNS_RETURN_GOOD;
392 } /* getdns_list_set_dict */
393
394 /*---------------------------------------- getdns_list_set_list */
395 getdns_return_t
396 getdns_list_set_list(struct getdns_list * list, size_t index,
397 const struct getdns_list * child_list)
398 {
399 struct getdns_list *newlist;
400 getdns_return_t retval;
401
402 if (!list || !child_list)
403 return GETDNS_RETURN_INVALID_PARAMETER;
404
405 if (index > list->numinuse)
406 return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
407
408 retval = getdns_list_copy(child_list, &newlist);
409 if (retval != GETDNS_RETURN_GOOD)
410 return retval;
411
412 if (index == list->numinuse) {
413 retval = getdns_list_add_item(list, &index);
414 if (retval != GETDNS_RETURN_GOOD) {
415 getdns_list_destroy(newlist);
416 return retval;
417 }
418 } else
419 getdns_list_destroy_item(list, index);
420
421 list->items[index].dtype = t_list;
422 list->items[index].data.list = newlist;
423 return GETDNS_RETURN_GOOD;
424 } /* getdns_list_set_list */
425
426 /*---------------------------------------- getdns_list_set_bindata */
427 getdns_return_t
428 getdns_list_set_bindata(struct getdns_list * list, size_t index,
429 const struct getdns_bindata * child_bindata)
430 {
431 struct getdns_bindata *newbindata;
432 getdns_return_t retval;
433
434 if (!list || !child_bindata)
435 return GETDNS_RETURN_INVALID_PARAMETER;
436
437 if (index > list->numinuse)
438 return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
439
440 newbindata = getdns_bindata_copy(&list->mf, child_bindata);
441 if (!newbindata)
442 return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
443
444 if (index == list->numinuse) {
445 retval = getdns_list_add_item(list, &index);
446 if (retval != GETDNS_RETURN_GOOD) {
447 getdns_bindata_destroy(&list->mf, newbindata);
448 return retval;
449 }
450 } else
451 getdns_list_destroy_item(list, index);
452
453 list->items[index].dtype = t_bindata;
454 list->items[index].data.bindata = newbindata;
455 return GETDNS_RETURN_GOOD;
456 } /* getdns_list_set_bindata */
457
458 /*---------------------------------------- getdns_list_set_int */
459 getdns_return_t
460 getdns_list_set_int(struct getdns_list * list, size_t index,
461 uint32_t child_int)
462 {
463 getdns_return_t retval;
464
465 if (!list)
466 return GETDNS_RETURN_INVALID_PARAMETER;
467
468 if (index > list->numinuse)
469 return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
470
471 if (index == list->numinuse) {
472 retval = getdns_list_add_item(list, &index);
473 if (retval != GETDNS_RETURN_GOOD)
474 return retval;
475 } else
476 getdns_list_destroy_item(list, index);
477
478 list->items[index].dtype = t_int;
479 list->items[index].data.n = child_int;
480 return GETDNS_RETURN_GOOD;
481 } /* getdns_list_set_int */
482 /* getdns_list.c */
483
0 /**
1 *
2 * \file list.h
3 * @brief getdns list management functions
4 *
5 * Originally taken from the getdns API description pseudo implementation.
6 *
7 */
8
9 /*
10 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * * Neither the names of the copyright holders nor the
21 * names of its contributors may be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 #ifndef _GETDNS_LIST_H_
37 #define _GETDNS_LIST_H_
38
39 #include <getdns/getdns.h>
40 #include "types-internal.h"
41
42 #define GETDNS_LIST_BLOCKSZ 10
43
44 /**
45 * this structure represents a single item in a list
46 */
47 struct getdns_list_item
48 {
49 getdns_data_type dtype;
50 union
51 {
52 struct getdns_list *list;
53 struct getdns_dict *dict;
54 int n;
55 struct getdns_bindata *bindata;
56 } data;
57 };
58
59 /**
60 * getdns list data type
61 * Use helper functions getdns_list_* to manipulate and iterate lists
62 * lists are implemented as arrays internally since the helper functions
63 * like to reference indexes in the list. Elements are allocated in blocks
64 * and then marked valid as they are used and invalid as they are not used
65 * The use cases do not justify working too hard at shrinking the structures.
66 * Indexes are 0 based.
67 */
68 struct getdns_list
69 {
70 size_t numalloc;
71 size_t numinuse;
72 struct getdns_list_item *items;
73 struct mem_funcs mf;
74 };
75
76 #endif
77
78 /* list.h */
0 /**
1 *
2 * /brief getdns contect management functions
3 *
4 * This is the meat of the API
5 * Originally taken from the getdns API description pseudo implementation.
6 *
7 */
8 /*
9 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include "config.h"
36 #include "types-internal.h"
37 #include "util-internal.h"
38
39 void
40 network_req_free(getdns_network_req * net_req)
41 {
42 if (!net_req) {
43 return;
44 }
45 if (net_req->result) {
46 ldns_pkt_free(net_req->result);
47 }
48 GETDNS_FREE(net_req->owner->my_mf, net_req);
49 }
50
51 getdns_network_req *
52 network_req_new(getdns_dns_req * owner,
53 uint16_t request_type,
54 uint16_t request_class, struct getdns_dict *extensions)
55 {
56
57 getdns_network_req *net_req = GETDNS_MALLOC( owner->my_mf
58 , getdns_network_req);
59 if (!net_req) {
60 return NULL;
61 }
62 net_req->result = NULL;
63 net_req->next = NULL;
64
65 net_req->request_type = request_type;
66 net_req->request_class = request_class;
67 net_req->unbound_id = -1;
68 net_req->state = NET_REQ_NOT_SENT;
69 net_req->owner = owner;
70
71 /* TODO: records and other extensions */
72
73 return net_req;
74 }
75
76 void
77 dns_req_free(getdns_dns_req * req)
78 {
79 if (!req) {
80 return;
81 }
82 getdns_network_req *net_req = NULL;
83 struct getdns_context *context = req->context;
84
85 /* free extensions */
86 getdns_dict_destroy(req->extensions);
87
88 /* free network requests */
89 net_req = req->first_req;
90 while (net_req) {
91 getdns_network_req *next = net_req->next;
92 network_req_free(net_req);
93 net_req = next;
94 }
95
96 if (req->local_timeout_id != 0) {
97 getdns_context_clear_timeout(context, req->local_timeout_id);
98 }
99
100 getdns_context_clear_timeout(context, req->trans_id);
101
102 /* free strduped name */
103 GETDNS_FREE(req->my_mf, req->name);
104
105 GETDNS_FREE(req->my_mf, req);
106 }
107
108 /* create a new dns req to be submitted */
109 getdns_dns_req *
110 dns_req_new(struct getdns_context *context,
111 const char *name, uint16_t request_type, struct getdns_dict *extensions)
112 {
113
114 getdns_dns_req *result = NULL;
115 getdns_network_req *req = NULL;
116
117 result = GETDNS_MALLOC(context->mf, getdns_dns_req);
118 if (result == NULL) {
119 return NULL;
120 }
121 result->my_mf = context->mf;
122 result->name = getdns_strdup(&(result->my_mf), name);
123 result->context = context;
124 result->canceled = 0;
125 result->current_req = NULL;
126 result->first_req = NULL;
127 result->trans_id = ldns_get_random();
128
129 getdns_dict_copy(extensions, &result->extensions);
130 result->return_dnssec_status = context->return_dnssec_status;
131
132 /* will be set by caller */
133 result->user_pointer = NULL;
134 result->user_callback = NULL;
135 result->local_timeout_id = 0;
136
137 /* create the requests */
138 req = network_req_new(result,
139 request_type, LDNS_RR_CLASS_IN, extensions);
140 if (!req) {
141 dns_req_free(result);
142 return NULL;
143 }
144
145 result->current_req = req;
146 result->first_req = req;
147
148 /* tack on A or AAAA if needed */
149 if (is_extension_set(extensions, "return_both_v4_and_v6") &&
150 (request_type == GETDNS_RRTYPE_A ||
151 request_type == GETDNS_RRTYPE_AAAA)) {
152
153 uint16_t next_req_type =
154 (request_type ==
155 GETDNS_RRTYPE_A) ? GETDNS_RRTYPE_AAAA : GETDNS_RRTYPE_A;
156 getdns_network_req *next_req = network_req_new(result,
157 next_req_type,
158 LDNS_RR_CLASS_IN,
159 extensions);
160 if (!next_req) {
161 dns_req_free(result);
162 return NULL;
163 }
164 req->next = next_req;
165 }
166
167 return result;
168 }
0 /**
1 *
2 * /brief getdns support functions for DNS Resource Records
3 *
4 * This file contains the tables with the information needed by getdns about
5 * individual RRs, such as their name and rdata fields and types.
6 * This information is provided via the response dict.
7 *
8 */
9 /*
10 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * * Neither the names of the copyright holders nor the
21 * names of its contributors may be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 #include "rr-dict.h"
37 #include "types-internal.h"
38 #include "context.h"
39 #include "dict.h"
40
41 #define ALEN(a) (sizeof(a)/sizeof(a[0]))
42
43 struct rdata_def {
44 const char *name;
45 int type;
46 };
47
48 struct rr_def {
49 const char *name;
50 const struct rdata_def *rdata;
51 int n_rdata_fields;
52 };
53
54 static struct rdata_def a_rdata[] = {
55 { "ipv4_address" , t_bindata }};
56 static struct rdata_def ns_rdata[] = {
57 { "nsdname" , t_bindata }};
58 static struct rdata_def md_rdata[] = {
59 { "madname" , t_bindata }};
60 static struct rdata_def mf_rdata[] = {
61 { "madname" , t_bindata }};
62 static struct rdata_def cname_rdata[] = {
63 { "cname" , t_bindata }};
64 static struct rdata_def soa_rdata[] = {
65 { "mname" , t_bindata },
66 { "rname" , t_bindata },
67 { "serial" , t_int },
68 { "refresh" , t_int },
69 { "refresh" , t_int },
70 { "retry" , t_int },
71 { "expire" , t_int }};
72 static struct rdata_def mb_rdata[] = {
73 { "madname" , t_bindata }};
74 static struct rdata_def mg_rdata[] = {
75 { "mgmname" , t_bindata }};
76 static struct rdata_def mr_rdata[] = {
77 { "newname" , t_bindata }};
78 static struct rdata_def null_rdata[] = {
79 { "anything" , t_bindata }};
80 static struct rdata_def wks_rdata[] = {
81 { "address" , t_bindata },
82 { "protocol" , t_int },
83 { "bitmap" , t_bindata }};
84 static struct rdata_def ptr_rdata[] = {
85 { "ptrdname" , t_bindata }};
86 static struct rdata_def hinfo_rdata[] = {
87 { "cpu" , t_bindata }};
88 static struct rdata_def minfo_rdata[] = {
89 { "rmailbx" , t_bindata }};
90 static struct rdata_def mx_rdata[] = {
91 { "preference" , t_bindata }};
92 static struct rdata_def txt_rdata[] = {
93 { "txt_strings" , t_list }};
94 static struct rdata_def rp_rdata[] = {
95 { "mbox_dname" , t_bindata }};
96 static struct rdata_def afsdb_rdata[] = {
97 { "subtype" , t_bindata }};
98 static struct rdata_def x25_rdata[] = {
99 { "psdn_address" , t_bindata }};
100 static struct rdata_def isdn_rdata[] = {
101 { "isdn_address" , t_bindata }};
102 static struct rdata_def rt_rdata[] = {
103 { "preference" , t_bindata }};
104 static struct rdata_def nsap_rdata[] = {
105 { "nsap" , t_bindata }};
106 static struct rdata_def sig_rdata[] = {
107 { "sig_obsolete" , t_bindata }};
108 static struct rdata_def key_rdata[] = {
109 { "key_obsolete" , t_bindata }};
110 static struct rdata_def px_rdata[] = {
111 { "preference" , t_int },
112 { "map822" , t_bindata },
113 { "mapx400" , t_bindata }};
114 static struct rdata_def gpos_rdata[] = {
115 { "longitude" , t_bindata },
116 { "latitude" , t_bindata },
117 { "altitude" , t_bindata }};
118 static struct rdata_def aaaa_rdata[] = {
119 { "ipv6_address" , t_bindata }};
120 static struct rdata_def loc_rdata[] = {
121 { "loc_obsolete" , t_bindata }};
122 static struct rdata_def nxt_rdata[] = {
123 { "nxt_obsolete" , t_bindata }};
124 static struct rdata_def eid_rdata[] = {
125 { "eid_unknown" , t_bindata }};
126 static struct rdata_def nimloc_rdata[] = {
127 { "nimloc_unknown" , t_bindata }};
128 static struct rdata_def srv_rdata[] = {
129 { "priority" , t_int },
130 { "weight" , t_int },
131 { "port" , t_int },
132 { "target" , t_bindata }};
133 static struct rdata_def atma_rdata[] = {
134 { "format" , t_bindata }};
135 static struct rdata_def naptr_rdata[] = {
136 { "order" , t_int },
137 { "preference" , t_int },
138 { "flags" , t_bindata },
139 { "service" , t_bindata },
140 { "regexp" , t_bindata },
141 { "replacement" , t_bindata }};
142 static struct rdata_def kx_rdata[] = {
143 { "preference" , t_bindata }};
144 static struct rdata_def cert_rdata[] = {
145 { "type" , t_int },
146 { "key_tag" , t_int },
147 { "algorithm" , t_int },
148 { "certificate_or_crl" , t_bindata }};
149 static struct rdata_def a6_rdata[] = {
150 { "a6_obsolete" , t_bindata }};
151 static struct rdata_def dname_rdata[] = {
152 { "target" , t_bindata }};
153 static struct rdata_def sink_rdata[] = {
154 { "sink_unknown" , t_bindata }};
155 static struct rdata_def opt_rdata[] = {
156 { "options" , t_dict },
157 { "option_code" , t_int },
158 { "option_data" , t_bindata },
159 { "udp_payload_size" , t_int },
160 { "extended_rcode" , t_int },
161 { "version" , t_int },
162 { "do" , t_int },
163 { "z" , t_int }};
164 static struct rdata_def apl_rdata[] = {
165 { "apitems" , t_dict },
166 { "address_family" , t_int },
167 { "prefix" , t_int },
168 { "n" , t_int },
169 { "afdpart" , t_bindata }};
170 static struct rdata_def ds_rdata[] = {
171 { "key_tag" , t_int },
172 { "algorithm" , t_int },
173 { "digest_type" , t_int },
174 { "digest" , t_bindata }};
175 static struct rdata_def sshfp_rdata[] = {
176 { "algorithm" , t_int },
177 { "fp_type" , t_int },
178 { "fingerprint" , t_bindata }};
179 static struct rdata_def ipseckey_rdata[] = {
180 { "algorithm" , t_int },
181 { "gateway_type" , t_int },
182 { "precedence" , t_int },
183 { "gateway" , t_bindata },
184 { "public_key" , t_bindata }};
185 static struct rdata_def rrsig_rdata[] = {
186 { "type_covered" , t_int },
187 { "algorithm" , t_int },
188 { "labels" , t_int },
189 { "original_ttl" , t_int },
190 { "signature_expiration" , t_int },
191 { "signature_inception" , t_int },
192 { "key_tag" , t_int },
193 { "signers_name" , t_bindata },
194 { "signature" , t_bindata }};
195 static struct rdata_def nsec_rdata[] = {
196 { "next_domain_name" , t_bindata }};
197 static struct rdata_def dnskey_rdata[] = {
198 { "flags" , t_int },
199 { "protocol" , t_int },
200 { "algorithm" , t_int },
201 { "public_key" , t_bindata }};
202 static struct rdata_def dhcid_rdata[] = {
203 { "dhcid_opaque" , t_bindata }};
204 static struct rdata_def nsec3_rdata[] = {
205 { "hash_algorithm" , t_int },
206 { "flags" , t_int },
207 { "iterations" , t_int },
208 { "salt" , t_bindata },
209 { "next_hashed_owner_name" , t_bindata },
210 { "type_bit_maps" , t_bindata }};
211 static struct rdata_def nsec3param_rdata[] = {
212 { "hash_algorithm" , t_int },
213 { "flags" , t_int },
214 { "iterations" , t_int },
215 { "salt" , t_bindata }};
216 static struct rdata_def tlsa_rdata[] = {
217 { "certificate_usage" , t_int },
218 { "selector" , t_int },
219 { "matching_type" , t_int },
220 { "certificate_association_data", t_bindata }};
221 static struct rdata_def hip_rdata[] = {
222 { "pk_algorithm" , t_int },
223 { "hit" , t_bindata },
224 { "public_key" , t_bindata },
225 { "rendezvous_servers" , t_list }};
226 static struct rdata_def ninfo_rdata[] = {
227 { "ninfo_unknown" , t_bindata }};
228 static struct rdata_def rkey_rdata[] = {
229 { "rkey_unknown" , t_bindata }};
230 static struct rdata_def talink_rdata[] = {
231 { "talink_unknown" , t_bindata }};
232 static struct rdata_def cds_rdata[] = {
233 { "cds_unknown" , t_bindata }};
234 static struct rdata_def spf_rdata[] = {
235 { "text" , t_bindata }};
236 static struct rdata_def uinfo_rdata[] = {
237 { "uinfo_unknown" , t_bindata }};
238 static struct rdata_def uid_rdata[] = {
239 { "uid_unknown" , t_bindata }};
240 static struct rdata_def gid_rdata[] = {
241 { "gid_unknown" , t_bindata }};
242 static struct rdata_def unspec_rdata[] = {
243 { "unspec_unknown" , t_bindata }};
244 static struct rdata_def nid_rdata[] = {
245 { "preference" , t_int },
246 { "node_id" , t_bindata }};
247 static struct rdata_def l32_rdata[] = {
248 { "preference" , t_int },
249 { "locator32" , t_bindata }};
250 static struct rdata_def l64_rdata[] = {
251 { "preference" , t_int },
252 { "locator64" , t_bindata }};
253 static struct rdata_def lp_rdata[] = {
254 { "preference" , t_int },
255 { "fqdn" , t_bindata }};
256 static struct rdata_def eui48_rdata[] = {
257 { "eui48_address" , t_bindata }};
258 static struct rdata_def eui64_rdata[] = {
259 { "eui64_address" , t_bindata }};
260 static struct rdata_def tkey_rdata[] = {
261 { "algorithm" , t_bindata },
262 { "inception" , t_int },
263 { "expiration" , t_int },
264 { "mode" , t_int },
265 { "error" , t_int },
266 { "key_data" , t_bindata },
267 { "other_data" , t_bindata }};
268 static struct rdata_def tsig_rdata[] = {
269 { "algorithm" , t_bindata },
270 { "time_signed" , t_bindata },
271 { "fudge" , t_int },
272 { "mac" , t_bindata },
273 { "original_id" , t_int },
274 { "error" , t_int },
275 { "other_data" , t_bindata }};
276 static struct rdata_def mailb_rdata[] = {
277 { "mailb_unknown" , t_bindata }};
278 static struct rdata_def maila_rdata[] = {
279 { "maila_unknown" , t_bindata }};
280 static struct rdata_def uri_rdata[] = {
281 { "priority" , t_int },
282 { "weight" , t_int },
283 { "target" , t_bindata }};
284 static struct rdata_def caa_rdata[] = {
285 { "flags" , t_int },
286 { "tag" , t_bindata },
287 { "value" , t_bindata }};
288 static struct rdata_def ta_rdata[] = {
289 { "ta_unknown" , t_bindata }};
290 static struct rdata_def dlv_rdata[] = {
291 { "key_tag" , t_int },
292 { "algorithm" , t_int },
293 { "digest_type" , t_int },
294 { "digest" , t_bindata }};
295
296 static struct rr_def rr_defs[] = {
297 { NULL, NULL, 0 },
298 { "A", a_rdata, ALEN( a_rdata) }, /* 1 - */
299 { "NS", ns_rdata, ALEN( ns_rdata) },
300 { "MD", md_rdata, ALEN( md_rdata) },
301 { "MF", mf_rdata, ALEN( mf_rdata) },
302 { "CNAME", cname_rdata, ALEN( cname_rdata) },
303 { "SOA", soa_rdata, ALEN( soa_rdata) },
304 { "MB", mb_rdata, ALEN( mb_rdata) },
305 { "MG", mg_rdata, ALEN( mg_rdata) },
306 { "MR", mr_rdata, ALEN( mr_rdata) },
307 { "NULL", null_rdata, ALEN( null_rdata) },
308 { "WKS", wks_rdata, ALEN( wks_rdata) },
309 { "PTR", ptr_rdata, ALEN( ptr_rdata) },
310 { "HINFO", hinfo_rdata, ALEN( hinfo_rdata) },
311 { "MINFO", minfo_rdata, ALEN( minfo_rdata) },
312 { "MX", mx_rdata, ALEN( mx_rdata) },
313 { "TXT", txt_rdata, ALEN( txt_rdata) },
314 { "RP", rp_rdata, ALEN( rp_rdata) },
315 { "AFSDB", afsdb_rdata, ALEN( afsdb_rdata) },
316 { "X25", x25_rdata, ALEN( x25_rdata) },
317 { "ISDN", isdn_rdata, ALEN( isdn_rdata) },
318 { "RT", rt_rdata, ALEN( rt_rdata) },
319 { "NSAP", nsap_rdata, ALEN( nsap_rdata) }, /* - 22 */
320 { NULL, NULL, 0 },
321 { "SIG", sig_rdata, ALEN( sig_rdata) }, /* 24 - */
322 { "KEY", key_rdata, ALEN( key_rdata) },
323 { "PX", px_rdata, ALEN( px_rdata) },
324 { "GPOS", gpos_rdata, ALEN( gpos_rdata) },
325 { "AAAA", aaaa_rdata, ALEN( aaaa_rdata) },
326 { "LOC", loc_rdata, ALEN( loc_rdata) },
327 { "NXT", nxt_rdata, ALEN( nxt_rdata) },
328 { "EID", eid_rdata, ALEN( eid_rdata) },
329 { "NIMLOC", nimloc_rdata, ALEN( nimloc_rdata) },
330 { "SRV", srv_rdata, ALEN( srv_rdata) },
331 { "ATMA", atma_rdata, ALEN( atma_rdata) },
332 { "NAPTR", naptr_rdata, ALEN( naptr_rdata) },
333 { "KX", kx_rdata, ALEN( kx_rdata) },
334 { "CERT", cert_rdata, ALEN( cert_rdata) },
335 { "A6", a6_rdata, ALEN( a6_rdata) },
336 { "DNAME", dname_rdata, ALEN( dname_rdata) },
337 { "SINK", sink_rdata, ALEN( sink_rdata) },
338 { "OPT", opt_rdata, ALEN( opt_rdata) },
339 { "APL", apl_rdata, ALEN( apl_rdata) },
340 { "DS", ds_rdata, ALEN( ds_rdata) },
341 { "SSHFP", sshfp_rdata, ALEN( sshfp_rdata) },
342 { "IPSECKEY", ipseckey_rdata, ALEN( ipseckey_rdata) },
343 { "RRSIG", rrsig_rdata, ALEN( rrsig_rdata) },
344 { "NSEC", nsec_rdata, ALEN( nsec_rdata) },
345 { "DNSKEY", dnskey_rdata, ALEN( dnskey_rdata) },
346 { "DHCID", dhcid_rdata, ALEN( dhcid_rdata) },
347 { "NSEC3", nsec3_rdata, ALEN( nsec3_rdata) },
348 { "NSEC3PARAM", nsec3param_rdata, ALEN(nsec3param_rdata) },
349 { "TLSA", tlsa_rdata, ALEN( tlsa_rdata) }, /* - 52 */
350 { NULL, NULL, 0 },
351 { NULL, NULL, 0 },
352 { "HIP", hip_rdata, ALEN( hip_rdata) }, /* 55 - */
353 { "NINFO", ninfo_rdata, ALEN( ninfo_rdata) },
354 { "RKEY", rkey_rdata, ALEN( rkey_rdata) },
355 { "TALINK", talink_rdata, ALEN( talink_rdata) },
356 { "CDS", cds_rdata, ALEN( cds_rdata) }, /* - 59 */
357 { NULL, NULL, 0 },
358 { NULL, NULL, 0 },
359 { NULL, NULL, 0 },
360 { NULL, NULL, 0 },
361 { NULL, NULL, 0 },
362 { NULL, NULL, 0 },
363 { NULL, NULL, 0 },
364 { NULL, NULL, 0 },
365 { NULL, NULL, 0 },
366 { NULL, NULL, 0 },
367 { NULL, NULL, 0 },
368 { NULL, NULL, 0 },
369 { NULL, NULL, 0 },
370 { NULL, NULL, 0 },
371 { NULL, NULL, 0 },
372 { NULL, NULL, 0 },
373 { NULL, NULL, 0 },
374 { NULL, NULL, 0 },
375 { NULL, NULL, 0 },
376 { NULL, NULL, 0 },
377 { NULL, NULL, 0 },
378 { NULL, NULL, 0 },
379 { NULL, NULL, 0 },
380 { NULL, NULL, 0 },
381 { NULL, NULL, 0 },
382 { NULL, NULL, 0 },
383 { NULL, NULL, 0 },
384 { NULL, NULL, 0 },
385 { NULL, NULL, 0 },
386 { NULL, NULL, 0 },
387 { NULL, NULL, 0 },
388 { NULL, NULL, 0 },
389 { NULL, NULL, 0 },
390 { NULL, NULL, 0 },
391 { NULL, NULL, 0 },
392 { NULL, NULL, 0 },
393 { NULL, NULL, 0 },
394 { NULL, NULL, 0 },
395 { NULL, NULL, 0 },
396 { "SPF", spf_rdata, ALEN( spf_rdata) }, /* 99 - */
397 { "UINFO", uinfo_rdata, ALEN( uinfo_rdata) },
398 { "UID", uid_rdata, ALEN( uid_rdata) },
399 { "GID", gid_rdata, ALEN( gid_rdata) },
400 { "UNSPEC", unspec_rdata, ALEN( unspec_rdata) },
401 { "NID", nid_rdata, ALEN( nid_rdata) },
402 { "L32", l32_rdata, ALEN( l32_rdata) },
403 { "L64", l64_rdata, ALEN( l64_rdata) },
404 { "LP", lp_rdata, ALEN( lp_rdata) },
405 { "EUI48", eui48_rdata, ALEN( eui48_rdata) },
406 { "EUI64", eui64_rdata, ALEN( eui64_rdata) }, /* - 109 */
407 { NULL, NULL, 0 },
408 { NULL, NULL, 0 },
409 { NULL, NULL, 0 },
410 { NULL, NULL, 0 },
411 { NULL, NULL, 0 },
412 { NULL, NULL, 0 },
413 { NULL, NULL, 0 },
414 { NULL, NULL, 0 },
415 { NULL, NULL, 0 },
416 { NULL, NULL, 0 },
417 { NULL, NULL, 0 },
418 { NULL, NULL, 0 },
419 { NULL, NULL, 0 },
420 { NULL, NULL, 0 },
421 { NULL, NULL, 0 },
422 { NULL, NULL, 0 },
423 { NULL, NULL, 0 },
424 { NULL, NULL, 0 },
425 { NULL, NULL, 0 },
426 { NULL, NULL, 0 },
427 { NULL, NULL, 0 },
428 { NULL, NULL, 0 },
429 { NULL, NULL, 0 },
430 { NULL, NULL, 0 },
431 { NULL, NULL, 0 },
432 { NULL, NULL, 0 },
433 { NULL, NULL, 0 },
434 { NULL, NULL, 0 },
435 { NULL, NULL, 0 },
436 { NULL, NULL, 0 },
437 { NULL, NULL, 0 },
438 { NULL, NULL, 0 },
439 { NULL, NULL, 0 },
440 { NULL, NULL, 0 },
441 { NULL, NULL, 0 },
442 { NULL, NULL, 0 },
443 { NULL, NULL, 0 },
444 { NULL, NULL, 0 },
445 { NULL, NULL, 0 },
446 { NULL, NULL, 0 },
447 { NULL, NULL, 0 },
448 { NULL, NULL, 0 },
449 { NULL, NULL, 0 },
450 { NULL, NULL, 0 },
451 { NULL, NULL, 0 },
452 { NULL, NULL, 0 },
453 { NULL, NULL, 0 },
454 { NULL, NULL, 0 },
455 { NULL, NULL, 0 },
456 { NULL, NULL, 0 },
457 { NULL, NULL, 0 },
458 { NULL, NULL, 0 },
459 { NULL, NULL, 0 },
460 { NULL, NULL, 0 },
461 { NULL, NULL, 0 },
462 { NULL, NULL, 0 },
463 { NULL, NULL, 0 },
464 { NULL, NULL, 0 },
465 { NULL, NULL, 0 },
466 { NULL, NULL, 0 },
467 { NULL, NULL, 0 },
468 { NULL, NULL, 0 },
469 { NULL, NULL, 0 },
470 { NULL, NULL, 0 },
471 { NULL, NULL, 0 },
472 { NULL, NULL, 0 },
473 { NULL, NULL, 0 },
474 { NULL, NULL, 0 },
475 { NULL, NULL, 0 },
476 { NULL, NULL, 0 },
477 { NULL, NULL, 0 },
478 { NULL, NULL, 0 },
479 { NULL, NULL, 0 },
480 { NULL, NULL, 0 },
481 { NULL, NULL, 0 },
482 { NULL, NULL, 0 },
483 { NULL, NULL, 0 },
484 { NULL, NULL, 0 },
485 { NULL, NULL, 0 },
486 { NULL, NULL, 0 },
487 { NULL, NULL, 0 },
488 { NULL, NULL, 0 },
489 { NULL, NULL, 0 },
490 { NULL, NULL, 0 },
491 { NULL, NULL, 0 },
492 { NULL, NULL, 0 },
493 { NULL, NULL, 0 },
494 { NULL, NULL, 0 },
495 { NULL, NULL, 0 },
496 { NULL, NULL, 0 },
497 { NULL, NULL, 0 },
498 { NULL, NULL, 0 },
499 { NULL, NULL, 0 },
500 { NULL, NULL, 0 },
501 { NULL, NULL, 0 },
502 { NULL, NULL, 0 },
503 { NULL, NULL, 0 },
504 { NULL, NULL, 0 },
505 { NULL, NULL, 0 },
506 { NULL, NULL, 0 },
507 { NULL, NULL, 0 },
508 { NULL, NULL, 0 },
509 { NULL, NULL, 0 },
510 { NULL, NULL, 0 },
511 { NULL, NULL, 0 },
512 { NULL, NULL, 0 },
513 { NULL, NULL, 0 },
514 { NULL, NULL, 0 },
515 { NULL, NULL, 0 },
516 { NULL, NULL, 0 },
517 { NULL, NULL, 0 },
518 { NULL, NULL, 0 },
519 { NULL, NULL, 0 },
520 { NULL, NULL, 0 },
521 { NULL, NULL, 0 },
522 { NULL, NULL, 0 },
523 { NULL, NULL, 0 },
524 { NULL, NULL, 0 },
525 { NULL, NULL, 0 },
526 { NULL, NULL, 0 },
527 { NULL, NULL, 0 },
528 { NULL, NULL, 0 },
529 { NULL, NULL, 0 },
530 { NULL, NULL, 0 },
531 { NULL, NULL, 0 },
532 { NULL, NULL, 0 },
533 { NULL, NULL, 0 },
534 { NULL, NULL, 0 },
535 { NULL, NULL, 0 },
536 { NULL, NULL, 0 },
537 { NULL, NULL, 0 },
538 { NULL, NULL, 0 },
539 { NULL, NULL, 0 },
540 { NULL, NULL, 0 },
541 { NULL, NULL, 0 },
542 { NULL, NULL, 0 },
543 { NULL, NULL, 0 },
544 { NULL, NULL, 0 },
545 { NULL, NULL, 0 },
546 { "TKEY", tkey_rdata, ALEN( tkey_rdata) }, /* 249 - */
547 { "TSIG", tsig_rdata, ALEN( tsig_rdata) }, /* - 250 */
548 { NULL, NULL, 0 },
549 { NULL, NULL, 0 },
550 { "MAILB", mailb_rdata, ALEN( mailb_rdata) }, /* 253 - */
551 { "MAILA", maila_rdata, ALEN( maila_rdata) }, /* - 254 */
552 { NULL, NULL, 0 },
553 { "URI", uri_rdata, ALEN( uri_rdata) }, /* 256 - */
554 { "CAA", caa_rdata, ALEN( caa_rdata) }, /* - 257 */
555 { "TA", ta_rdata, ALEN( ta_rdata) }, /* 32768 */
556 { "DLV", dlv_rdata, ALEN( dlv_rdata) } /* 32769 */
557 };
558
559 static const struct rr_def *
560 rr_def_lookup(uint16_t rr_type)
561 {
562 if (rr_type <= 257)
563 return &rr_defs[rr_type];
564 else if (rr_type == 32768)
565 return &rr_defs[258];
566 else if (rr_type == 32769)
567 return &rr_defs[259];
568 return rr_defs;
569 }
570
571 const char *
572 priv_getdns_rr_type_name(int rr_type)
573 {
574 return rr_def_lookup(rr_type)->name;
575 }
576
577 /* list of txt records */
578 static getdns_return_t
579 priv_getdns_equip_dict_with_txt_rdfs(struct getdns_dict* rdata, ldns_rr* rr,
580 const struct rr_def* def,
581 struct getdns_context* context) {
582 size_t i;
583 struct getdns_bindata bindata;
584 uint8_t buffer[LDNS_MAX_RDFLEN];
585 getdns_return_t r = GETDNS_RETURN_GOOD;
586 struct getdns_list* records = getdns_list_create_with_context(context);
587 if (!records) {
588 return GETDNS_RETURN_MEMORY_ERROR;
589 }
590 for (i = 0; i < ldns_rr_rd_count(rr) && r == GETDNS_RETURN_GOOD; ++i) {
591 ldns_rdf* rdf = ldns_rr_rdf(rr, i);
592 int rdf_size = (int) ldns_rdf_size(rdf);
593 uint8_t* rdf_data = ldns_rdf_data(rdf);
594 if (rdf_size < 1) {
595 r = GETDNS_RETURN_GENERIC_ERROR;
596 continue;
597 }
598 int txt_size = (int) rdf_data[0];
599 if (rdf_size < txt_size) {
600 r = GETDNS_RETURN_GENERIC_ERROR;
601 continue;
602 }
603 bindata.size = txt_size + 1;
604 memcpy(buffer, rdf_data + 1, txt_size);
605 buffer[txt_size] = 0;
606 bindata.data = buffer;
607
608 r = getdns_list_set_bindata(records, i, &bindata);
609 }
610 if (r == GETDNS_RETURN_GOOD) {
611 r = getdns_dict_set_list(rdata, def->rdata[0].name, records);
612 }
613 getdns_list_destroy(records);
614 return r;
615 }
616
617 /* heavily borrowed/copied from ldns 1.6.17 */
618 static
619 getdns_return_t getdns_rdf_hip_get_alg_hit_pk(ldns_rdf *rdf, uint8_t* alg,
620 struct getdns_bindata* hit,
621 struct getdns_bindata* pk)
622 {
623 uint8_t *data;
624 size_t rdf_size;
625
626 if ((rdf_size = ldns_rdf_size(rdf)) < 6) {
627 return GETDNS_RETURN_GENERIC_ERROR;
628 }
629 data = ldns_rdf_data(rdf);
630 hit->size = data[0];
631 *alg = data[1];
632 pk->size = ldns_read_uint16(data + 2);
633 hit->data = data + 4;
634 pk->data = data + 4 + hit->size;
635 if (hit->size == 0 || pk->size == 0 ||
636 rdf_size < (size_t) hit->size + pk->size + 4) {
637 return GETDNS_RETURN_GENERIC_ERROR;
638 }
639 return GETDNS_RETURN_GOOD;
640 }
641
642 static getdns_return_t
643 priv_getdns_equip_dict_with_hip_rdfs(struct getdns_dict* rdata, ldns_rr* rr,
644 const struct rr_def* def,
645 struct getdns_context* context) {
646 uint8_t alg;
647 getdns_return_t r;
648 struct getdns_bindata hit_data;
649 struct getdns_bindata key_data;
650 /* first rdf contains the key data */
651 ldns_rdf* rdf = ldns_rr_rdf(rr, 0);
652 /* ask LDNS to parse it for us */
653 r = getdns_rdf_hip_get_alg_hit_pk(rdf, &alg, &hit_data, &key_data);
654 if (r != GETDNS_RETURN_GOOD) {
655 return GETDNS_RETURN_GENERIC_ERROR;
656 }
657
658 r = getdns_dict_set_int(rdata, def->rdata[0].name, alg);
659 r |= getdns_dict_set_bindata(rdata, def->rdata[1].name, &hit_data);
660 r |= getdns_dict_set_bindata(rdata, def->rdata[2].name, &key_data);
661 if (r != GETDNS_RETURN_GOOD) {
662 return GETDNS_RETURN_GENERIC_ERROR;
663 }
664
665 if (ldns_rr_rd_count(rr) > 1) {
666 /* servers */
667 size_t i;
668 struct getdns_bindata server_data;
669 struct getdns_list* servers = getdns_list_create_with_context(context);
670 if (!servers) {
671 return GETDNS_RETURN_MEMORY_ERROR;
672 }
673 for (i = 1; i < ldns_rr_rd_count(rr) && r == GETDNS_RETURN_GOOD; ++i) {
674 ldns_rdf* server_rdf = ldns_rr_rdf(rr, i);
675 server_data.size = ldns_rdf_size(server_rdf);
676 server_data.data = ldns_rdf_data(server_rdf);
677 r = getdns_list_set_bindata(servers, i - 1, &server_data);
678 }
679 if (r == GETDNS_RETURN_GOOD) {
680 r = getdns_dict_set_list(rdata, def->rdata[3].name, servers);
681 }
682 /* always clean up */
683 getdns_list_destroy(servers);
684 if (r != GETDNS_RETURN_GOOD) {
685 return GETDNS_RETURN_GENERIC_ERROR;
686 }
687 }
688
689 return r;
690 }
691
692 static getdns_return_t
693 priv_append_apl_record(struct getdns_list* records, ldns_rdf* rdf,
694 const struct rr_def* def, struct getdns_context* context) {
695 getdns_return_t r = GETDNS_RETURN_GOOD;
696 uint8_t* data;
697 size_t size;
698 uint16_t family;
699 uint8_t prefix;
700 uint8_t negation;
701 size_t addr_len;
702 size_t pos = 0;
703 size_t index = 0;
704 struct getdns_bindata addr_data;
705
706 if (ldns_rdf_get_type(rdf) != LDNS_RDF_TYPE_APL) {
707 return GETDNS_RETURN_GENERIC_ERROR;
708 }
709 getdns_list_get_length(records, &index);
710
711 data = ldns_rdf_data(rdf);
712 size = ldns_rdf_size(rdf);
713 if (size < 4) {
714 /* not enough for the fam, prefix, n, and data len */
715 return GETDNS_RETURN_GENERIC_ERROR;
716 }
717 while (pos < size && r == GETDNS_RETURN_GOOD) {
718 struct getdns_dict* apl_dict;
719 family = ldns_read_uint16(data + pos);
720 prefix = data[pos + 2];
721 negation = (data[pos + 3] & 0x80) > 1 ? 1 : 0;
722 addr_len = data[pos + 3] & 0x7F;
723 if (size < 4 + addr_len) {
724 /* not enough.. */
725 return GETDNS_RETURN_GENERIC_ERROR;
726 }
727 addr_data.size = addr_len;
728 addr_data.data = data + 4 + pos;
729
730 /* add to a dictionary */
731 apl_dict = getdns_dict_create_with_context(context);
732 if (!apl_dict) {
733 /* memory fail */
734 return GETDNS_RETURN_MEMORY_ERROR;
735 }
736 r |= getdns_dict_set_int(apl_dict, def->rdata[1].name, family);
737 r |= getdns_dict_set_int(apl_dict, def->rdata[2].name, prefix);
738 r |= getdns_dict_set_int(apl_dict, def->rdata[3].name, negation);
739 r |= getdns_dict_set_bindata(apl_dict, def->rdata[4].name, &addr_data);
740
741 if (r == GETDNS_RETURN_GOOD) {
742 r = getdns_list_set_dict(records, index, apl_dict);
743 }
744 pos += addr_data.size + 4;
745 ++index;
746 /* always clean up */
747 getdns_dict_destroy(apl_dict);
748 }
749
750 return r;
751 }
752
753 static getdns_return_t
754 priv_getdns_equip_dict_with_apl_rdfs(struct getdns_dict* rdata, ldns_rr* rr,
755 const struct rr_def* def,
756 struct getdns_context* context) {
757 size_t i;
758 getdns_return_t r = GETDNS_RETURN_GOOD;
759 struct getdns_list* records = getdns_list_create_with_context(context);
760 if (!records) {
761 return GETDNS_RETURN_MEMORY_ERROR;
762 }
763 for (i = 0; i < ldns_rr_rd_count(rr) && r == GETDNS_RETURN_GOOD; ++i) {
764 r = priv_append_apl_record(records, ldns_rr_rdf(rr, i),
765 def, context);
766 }
767 if (r == GETDNS_RETURN_GOOD) {
768 getdns_dict_set_list(rdata, def->rdata[0].name, records);
769 }
770 getdns_list_destroy(records);
771
772 return GETDNS_RETURN_GOOD;
773 }
774
775 static getdns_return_t
776 priv_getdns_equip_dict_with_spf_rdfs(struct getdns_dict* rdata, ldns_rr* rr,
777 const struct rr_def* def,
778 struct getdns_context* context) {
779 size_t i;
780 struct getdns_bindata bindata;
781 getdns_return_t r = GETDNS_RETURN_GOOD;
782 int num_copied = 0;
783 bindata.size = 0;
784 /* one giant bindata */
785 /* validate and calculate size */
786 for (i = 0; i < ldns_rr_rd_count(rr) && r == GETDNS_RETURN_GOOD; ++i) {
787 ldns_rdf* rdf = ldns_rr_rdf(rr, i);
788 int rdf_size = (int) ldns_rdf_size(rdf);
789 uint8_t* rdf_data = ldns_rdf_data(rdf);
790 if (rdf_size < 1) {
791 r = GETDNS_RETURN_GENERIC_ERROR;
792 continue;
793 }
794 /* txt size without null byte */
795 int txt_size = (int) rdf_data[0];
796 if (rdf_size < txt_size) {
797 r = GETDNS_RETURN_GENERIC_ERROR;
798 continue;
799 }
800 bindata.size += txt_size;
801 }
802 /* add one for the null byte */
803 bindata.size++;
804
805 if (r != GETDNS_RETURN_GOOD) {
806 /* validations failed */
807 return r;
808 }
809 bindata.data = context
810 ? GETDNS_XMALLOC(context->my_mf, uint8_t, bindata.size)
811 : malloc(bindata.size);
812 if (!bindata.data) {
813 return GETDNS_RETURN_MEMORY_ERROR;
814 }
815 /* copy in */
816 for (i = 0; i < ldns_rr_rd_count(rr) && r == GETDNS_RETURN_GOOD; ++i) {
817 ldns_rdf* rdf = ldns_rr_rdf(rr, i);
818 /* safe to trust these now */
819 uint8_t* rdf_data = ldns_rdf_data(rdf);
820 int txt_size = (int) rdf_data[0];
821 memcpy(bindata.data + num_copied, rdf_data + 1, txt_size);
822 num_copied += txt_size;
823 }
824 bindata.data[num_copied] = 0;
825 r = getdns_dict_set_bindata(rdata, def->rdata[0].name, &bindata);
826 if (context)
827 GETDNS_FREE(context->my_mf, bindata.data);
828 else
829 free(bindata.data);
830 return r;
831 }
832
833
834 static getdns_return_t
835 priv_getdns_equip_dict_with_rdfs(struct getdns_dict *rdata, ldns_rr *rr,
836 struct getdns_context* context)
837 {
838 getdns_return_t r = GETDNS_RETURN_GOOD;
839 const struct rr_def *def;
840 struct getdns_bindata bindata;
841 size_t i;
842 int intval;
843
844 assert(rdata);
845 assert(rr);
846
847 def = rr_def_lookup(ldns_rr_get_type(rr));
848 /* specialty handlers */
849 /* TODO: convert generic one into function w/ similar signature and store in the
850 * def? */
851 if (def->rdata == txt_rdata) {
852 return priv_getdns_equip_dict_with_txt_rdfs(rdata, rr, def, context);
853 } else if (def->rdata == hip_rdata) {
854 return priv_getdns_equip_dict_with_hip_rdfs(rdata, rr, def, context);
855 } else if (def->rdata == apl_rdata) {
856 return priv_getdns_equip_dict_with_apl_rdfs(rdata, rr, def, context);
857 } else if (def->rdata == spf_rdata) {
858 return priv_getdns_equip_dict_with_spf_rdfs(rdata, rr, def, context);
859 }
860 /* generic */
861 for (i = 0; i < ldns_rr_rd_count(rr) && r == GETDNS_RETURN_GOOD; i++) {
862 if (i >= def->n_rdata_fields)
863 break;
864
865 switch (def->rdata[i].type) {
866 case t_bindata: bindata.size = ldns_rdf_size(ldns_rr_rdf(rr, i));
867 bindata.data = ldns_rdf_data(ldns_rr_rdf(rr, i));
868 r = getdns_dict_set_bindata(
869 rdata, (char *)def->rdata[i].name, &bindata);
870 break;
871 case t_int : switch (ldns_rdf_size(ldns_rr_rdf(rr, i))) {
872 case 1: intval = (uint8_t)*ldns_rdf_data(
873 ldns_rr_rdf(rr, i));
874 break;
875 case 2: intval = ldns_read_uint16(
876 ldns_rdf_data(ldns_rr_rdf(rr, i)));
877 break;
878 case 4: intval = ldns_read_uint32(
879 ldns_rdf_data(ldns_rr_rdf(rr, i)));
880 break;
881 default: intval = -1;
882 /* TODO Compare with LDNS rdf types */
883 break;
884 }
885 r = getdns_dict_set_int(
886 rdata, (char *)def->rdata[i].name, intval);
887 break;
888 default : break;
889 }
890 }
891 return r;
892 }
893
894 static getdns_return_t
895 priv_getdns_create_dict_from_rdfs(
896 struct getdns_context *context, ldns_rr *rr, struct getdns_dict** rdata)
897 {
898 getdns_return_t r = GETDNS_RETURN_GOOD;
899 struct getdns_bindata rdata_raw;
900 uint8_t *data_ptr;
901 size_t i;
902
903 assert(rr);
904 assert(rdata);
905
906 *rdata = getdns_dict_create_with_context(context);
907 if (! *rdata)
908 return GETDNS_RETURN_MEMORY_ERROR;
909 do { /* break on error (to cleanup *rdata) */
910
911 /* Count and reserve "raw" rdata space */
912 rdata_raw.size = 0;
913 for (i = 0; i < ldns_rr_rd_count(rr); i++)
914 rdata_raw.size += ldns_rdf_size(ldns_rr_rdf(rr, i));
915 rdata_raw.data = context
916 ? GETDNS_XMALLOC(context->mf, uint8_t, rdata_raw.size)
917 : malloc(rdata_raw.size);
918 if (! rdata_raw.data) {
919 r = GETDNS_RETURN_MEMORY_ERROR;
920 break;
921 }
922 /* Copy rdata fields to rdata space */
923 data_ptr = rdata_raw.data;
924 for (i = 0; i < ldns_rr_rd_count(rr); i++) {
925 (void) memcpy(data_ptr,
926 ldns_rdf_data(ldns_rr_rdf(rr, i)),
927 ldns_rdf_size(ldns_rr_rdf(rr, i)));
928 data_ptr += ldns_rdf_size(ldns_rr_rdf(rr, i));
929 }
930
931 /* Set "rdata_raw" attribute" */
932 r = getdns_dict_set_bindata(*rdata, "rdata_raw", &rdata_raw);
933 if (context)
934 GETDNS_FREE(context->mf, rdata_raw.data);
935 else
936 free(rdata_raw.data);
937 if (r != GETDNS_RETURN_GOOD)
938 break;
939
940 /* Now set the RR type specific attributes */
941 r = priv_getdns_equip_dict_with_rdfs(*rdata, rr, context);
942 if (r == GETDNS_RETURN_GOOD)
943 return r;
944 } while(0);
945 getdns_dict_destroy(*rdata);
946 return r;
947 }
948
949 getdns_return_t
950 priv_getdns_create_dict_from_rr(
951 struct getdns_context *context, ldns_rr *rr, struct getdns_dict** rr_dict)
952 {
953 getdns_return_t r = GETDNS_RETURN_GOOD;
954 struct getdns_bindata name;
955 struct getdns_dict *rdata;
956
957 assert(rr);
958 assert(rr_dict);
959
960 *rr_dict = getdns_dict_create_with_context(context);
961 if (! *rr_dict)
962 return GETDNS_RETURN_MEMORY_ERROR;
963 do { /* break on error (to cleanup *rr_dict) */
964 r = getdns_dict_set_int(*rr_dict,
965 "type", ldns_rr_get_type(rr));
966 if (r != GETDNS_RETURN_GOOD)
967 break;
968 r = getdns_dict_set_int(*rr_dict,
969 "class", ldns_rr_get_class(rr));
970 if (r != GETDNS_RETURN_GOOD)
971 break;
972 r = getdns_dict_set_int(*rr_dict, "ttl", ldns_rr_ttl(rr));
973 if (r != GETDNS_RETURN_GOOD)
974 break;
975
976 /* "name" attribute.
977 * ldns_rr_owner(rr) is already uncompressed!
978 */
979 name.size = ldns_rdf_size(ldns_rr_owner(rr));
980 name.data = ldns_rdf_data(ldns_rr_owner(rr));
981 r = getdns_dict_set_bindata(*rr_dict, "name", &name);
982 if (r != GETDNS_RETURN_GOOD)
983 break;
984
985 /* The "rdata" dict... copies of copies of copies :( */
986 r = priv_getdns_create_dict_from_rdfs(context, rr, &rdata);
987 if (r != GETDNS_RETURN_GOOD)
988 break;
989 r = getdns_dict_set_dict(*rr_dict, "rdata", rdata);
990 getdns_dict_destroy(rdata);
991 if (r == GETDNS_RETURN_GOOD)
992 return r;
993 } while (0);
994 getdns_dict_destroy(*rr_dict);
995 return r;
996 }
997
998 getdns_return_t
999 priv_getdns_create_reply_question_dict(
1000 struct getdns_context *context, ldns_pkt *pkt, struct getdns_dict** q_dict)
1001 {
1002 getdns_return_t r = GETDNS_RETURN_GOOD;
1003 ldns_rr *rr;
1004 struct getdns_bindata qname;
1005
1006 assert(pkt);
1007 assert(q_dict);
1008
1009 rr = ldns_rr_list_rr(ldns_pkt_question(pkt), 0);
1010 if (! rr)
1011 return GETDNS_RETURN_GENERIC_ERROR;
1012
1013 *q_dict = getdns_dict_create_with_context(context);
1014 if (! *q_dict)
1015 return GETDNS_RETURN_MEMORY_ERROR;
1016 do { /* break on error (to cleanup *q_dict) */
1017 r = getdns_dict_set_int(*q_dict,
1018 "qtype", ldns_rr_get_type(rr));
1019 if (r != GETDNS_RETURN_GOOD)
1020 break;
1021 r = getdns_dict_set_int(*q_dict,
1022 "qclass", ldns_rr_get_class(rr));
1023 if (r != GETDNS_RETURN_GOOD)
1024 break;
1025
1026 /* "qname" attribute.
1027 * ldns_rr_owner(rr) is already uncompressed!
1028 */
1029 qname.size = ldns_rdf_size(ldns_rr_owner(rr));
1030 qname.data = ldns_rdf_data(ldns_rr_owner(rr));
1031 r = getdns_dict_set_bindata(*q_dict, "qname", &qname);
1032 if (r == GETDNS_RETURN_GOOD)
1033 return r;
1034 } while (0);
1035 getdns_dict_destroy(*q_dict);
1036 return r;
1037 }
1038
1039 static getdns_return_t priv_getdns_construct_wire_rdata_from_rdata(
1040 struct getdns_dict *rdata, uint32_t rr_type,
1041 uint8_t **wire, size_t *wire_size)
1042 {
1043 getdns_return_t r = GETDNS_RETURN_GOOD;
1044 const ldns_rr_descriptor *rr_descript;
1045 const struct rr_def *def;
1046 size_t i, size;
1047 struct getdns_bindata *bindata;
1048 uint32_t value;
1049 uint8_t *ptr;
1050
1051 assert(rdata);
1052 assert(wire);
1053 assert(wire_size);
1054
1055 def = rr_def_lookup(rr_type);
1056 rr_descript = ldns_rr_descript(rr_type);
1057
1058 /* First calculate needed size */
1059 size = 0;
1060 for (i = 0; i < def->n_rdata_fields && r == GETDNS_RETURN_GOOD; i++) {
1061 switch (def->rdata[i].type) {
1062 case t_bindata: r = getdns_dict_get_bindata(rdata,
1063 def->rdata[i].name, &bindata);
1064 if (r)
1065 break;
1066 size += bindata->size;
1067 break;
1068 case t_int : switch (ldns_rr_descriptor_field_type(
1069 rr_descript, i)) {
1070
1071 case LDNS_RDF_TYPE_CLASS:
1072 case LDNS_RDF_TYPE_ALG :
1073 case LDNS_RDF_TYPE_INT8 : size += 1;
1074 break;
1075 case LDNS_RDF_TYPE_TYPE :
1076 case LDNS_RDF_TYPE_CERT_ALG:
1077 case LDNS_RDF_TYPE_INT16: size += 2;
1078 break;
1079 case LDNS_RDF_TYPE_TIME :
1080 case LDNS_RDF_TYPE_PERIOD:
1081 case LDNS_RDF_TYPE_INT32: size += 4;
1082 break;
1083 default: r = GETDNS_RETURN_GENERIC_ERROR;
1084 break;
1085 }
1086 break;
1087 default : r = GETDNS_RETURN_GENERIC_ERROR;
1088 break;
1089 }
1090 }
1091 *wire_size = size + 2;
1092 *wire = ptr = GETDNS_XMALLOC(rdata->mf, uint8_t, size + 2);
1093 if (! ptr)
1094 return GETDNS_RETURN_MEMORY_ERROR;
1095
1096 ptr[0] = (uint8_t) (size >> 8) & 0xff;
1097 ptr[1] = (uint8_t) size & 0xff;
1098 ptr += 2;
1099 for (i = 0; i < def->n_rdata_fields && r == GETDNS_RETURN_GOOD; i++) {
1100 switch (def->rdata[i].type) {
1101 case t_bindata: r = getdns_dict_get_bindata(rdata,
1102 def->rdata[i].name, &bindata);
1103 if (r)
1104 break;
1105 (void) memcpy(ptr, bindata->data,
1106 bindata->size);
1107 ptr += bindata->size;
1108 break;
1109 case t_int : r = getdns_dict_get_int(rdata,
1110 def->rdata[i].name, &value);
1111 if (r)
1112 break;
1113
1114 switch (ldns_rr_descriptor_field_type(
1115 rr_descript, i)) {
1116
1117 case LDNS_RDF_TYPE_CLASS:
1118 case LDNS_RDF_TYPE_ALG :
1119 case LDNS_RDF_TYPE_INT8 : ptr[0] = (uint8_t)
1120 value & 0xff;
1121 ptr += 1;
1122 break;
1123 case LDNS_RDF_TYPE_TYPE :
1124 case LDNS_RDF_TYPE_CERT_ALG:
1125 case LDNS_RDF_TYPE_INT16: ptr[0] = (uint8_t)
1126 (value>>8)&0xff;
1127 ptr[1] = (uint8_t)
1128 value & 0xff;
1129 ptr += 2;
1130 break;
1131 case LDNS_RDF_TYPE_TIME :
1132 case LDNS_RDF_TYPE_PERIOD:
1133 case LDNS_RDF_TYPE_INT32: ptr[0] = (uint8_t)
1134 (value>>24)&0xff;
1135 ptr[1] = (uint8_t)
1136 (value>>16)&0xff;
1137 ptr[2] = (uint8_t)
1138 (value>>8)&0xff;
1139 ptr[3] = (uint8_t)
1140 value & 0xff;
1141 ptr += 4;
1142 break;
1143 default: r = GETDNS_RETURN_GENERIC_ERROR;
1144 break;
1145 }
1146 break;
1147 default : r = GETDNS_RETURN_GENERIC_ERROR;
1148 break;
1149 }
1150 }
1151 if (r)
1152 GETDNS_FREE(rdata->mf, ptr);
1153 return r;
1154 }
1155
1156 static getdns_return_t
1157 priv_getdns_dict_get_raw_rdata(struct getdns_dict *rdata,
1158 uint8_t **wire, size_t *wire_size)
1159 {
1160 getdns_return_t r;
1161 struct getdns_bindata *bindata;
1162
1163 if ((r = getdns_dict_get_bindata(rdata, "rdata_raw", &bindata)))
1164 return r;
1165
1166 *wire_size = bindata->size + 2;
1167 *wire = GETDNS_XMALLOC(rdata->mf, uint8_t, *wire_size);
1168 if (! *wire)
1169 return GETDNS_RETURN_MEMORY_ERROR;
1170
1171 (*wire)[0] = (uint8_t) (bindata->size >> 8) & 0xff;
1172 (*wire)[1] = (uint8_t) bindata->size & 0xff;
1173
1174 (void) memcpy(*wire + 2, bindata->data, bindata->size);
1175 return GETDNS_RETURN_GOOD;
1176 }
1177
1178 getdns_return_t
1179 priv_getdns_create_rr_from_dict(struct getdns_dict *rr_dict, ldns_rr **rr)
1180 {
1181 getdns_return_t r = GETDNS_RETURN_GOOD;
1182 struct getdns_bindata *name;
1183 struct getdns_dict *rdata;
1184 uint32_t rr_type;
1185 ldns_rdf *owner;
1186 ldns_status s;
1187 size_t pos;
1188 uint8_t *wire;
1189 size_t wire_size;
1190
1191 assert(rr_dict);
1192 assert(rr);
1193
1194 *rr = ldns_rr_new();
1195 if (! *rr)
1196 return GETDNS_RETURN_MEMORY_ERROR;
1197 do {
1198 r = getdns_dict_get_bindata(rr_dict, "name", &name);
1199 if (r != GETDNS_RETURN_GOOD)
1200 break;
1201 owner = ldns_rdf_new_frm_data(
1202 LDNS_RDF_TYPE_DNAME, name->size, name->data);
1203 if (! owner) {
1204 r = GETDNS_RETURN_MEMORY_ERROR;
1205 break;
1206 }
1207 ldns_rr_set_owner(*rr, owner);
1208
1209 r = getdns_dict_get_int(rr_dict, "type", &rr_type);
1210 if (r != GETDNS_RETURN_GOOD)
1211 break;
1212 ldns_rr_set_type(*rr, rr_type);
1213
1214 r = getdns_dict_get_dict(rr_dict, "rdata", &rdata);
1215 if (r != GETDNS_RETURN_GOOD)
1216 break;
1217
1218 r = priv_getdns_dict_get_raw_rdata(rdata, &wire, &wire_size);
1219 if (r == GETDNS_RETURN_NO_SUCH_DICT_NAME) {
1220 r = priv_getdns_construct_wire_rdata_from_rdata(
1221 rdata, rr_type, &wire, &wire_size);
1222 }
1223 if (r != GETDNS_RETURN_GOOD)
1224 break;
1225 pos = 0;
1226 s = ldns_wire2rdf(*rr, wire, wire_size, &pos);
1227 GETDNS_FREE(rr_dict->mf, wire);
1228 if (s == LDNS_STATUS_OK)
1229 return r;
1230 r = GETDNS_RETURN_GENERIC_ERROR;
1231 } while (0);
1232 ldns_rr_free(*rr);
1233 return r;
1234 }
1235
1236 static getdns_return_t
1237 priv_getdns_get_opt_dict(struct getdns_context* context,
1238 struct getdns_dict** record_dict, uint8_t* record_start,
1239 size_t* bytes_remaining, size_t* bytes_parsed) {
1240
1241 getdns_return_t r = GETDNS_RETURN_GOOD;
1242 struct getdns_dict* opt = NULL;
1243 uint16_t code;
1244 struct getdns_bindata opt_data;
1245 if (*bytes_remaining < 4) {
1246 return GETDNS_RETURN_GENERIC_ERROR;
1247 }
1248 code = ldns_read_uint16(record_start);
1249 opt_data.size = ldns_read_uint16(record_start + 2);
1250 if (*bytes_remaining < (4 + opt_data.size)) {
1251 return GETDNS_RETURN_GENERIC_ERROR;
1252 }
1253 opt = getdns_dict_create_with_context(context);
1254 if (!opt) {
1255 return GETDNS_RETURN_MEMORY_ERROR;
1256 }
1257 /* set code */
1258 r = getdns_dict_set_int(opt, opt_rdata[1].name, code);
1259 if (r != GETDNS_RETURN_GOOD) {
1260 getdns_dict_destroy(opt);
1261 return r;
1262 }
1263 /* set data */
1264 opt_data.data = record_start + 4;
1265 getdns_dict_set_bindata(opt, opt_rdata[2].name, &opt_data);
1266 if (r != GETDNS_RETURN_GOOD) {
1267 getdns_dict_destroy(opt);
1268 return r;
1269 }
1270 /* set result data */
1271 *bytes_remaining = *bytes_remaining - (4 + opt_data.size);
1272 *bytes_parsed = *bytes_parsed + (4 + opt_data.size);
1273 *record_dict = opt;
1274 return r;
1275 }
1276
1277 static getdns_return_t
1278 priv_getdns_create_opt_rr(
1279 struct getdns_context *context, ldns_rdf* rdf,
1280 struct getdns_dict** rr_dict) {
1281
1282 struct getdns_dict* result = NULL;
1283 getdns_return_t r = GETDNS_RETURN_GOOD;
1284 size_t bytes_remaining = ldns_rdf_size(rdf);
1285 size_t bytes_parsed = 0;
1286 uint8_t* record_start = ldns_rdf_data(rdf);
1287 struct getdns_list* records = getdns_list_create_with_context(context);
1288 size_t idx = 0;
1289 if (!records) {
1290 return GETDNS_RETURN_MEMORY_ERROR;
1291 }
1292 while (r == GETDNS_RETURN_GOOD && bytes_remaining > 0) {
1293 struct getdns_dict* opt = NULL;
1294 r = priv_getdns_get_opt_dict(context, &opt,
1295 record_start + bytes_parsed, &bytes_remaining,
1296 &bytes_parsed);
1297 if (r == GETDNS_RETURN_GOOD) {
1298 getdns_list_set_dict(records, idx, opt);
1299 getdns_dict_destroy(opt);
1300 idx++;
1301 }
1302 }
1303 if (r != GETDNS_RETURN_GOOD) {
1304 getdns_list_destroy(records);
1305 return r;
1306 }
1307 result = getdns_dict_create_with_context(context);
1308 if (!result) {
1309 getdns_list_destroy(records);
1310 return GETDNS_RETURN_MEMORY_ERROR;
1311 }
1312 /* cheat */
1313 r = 0;
1314 r |= getdns_dict_set_list(result,
1315 opt_rdata[0].name, records);
1316 getdns_list_destroy(records);
1317
1318 /* does class makes sense? */
1319 if (r != GETDNS_RETURN_GOOD) {
1320 getdns_dict_destroy(result);
1321 return GETDNS_RETURN_GENERIC_ERROR;
1322 }
1323 *rr_dict = result;
1324 return r;
1325 }
1326
1327 getdns_return_t priv_getdns_append_opt_rr(
1328 struct getdns_context *context, struct getdns_list* rdatas, ldns_pkt* pkt) {
1329 struct getdns_dict* opt_rr;
1330 struct getdns_dict* rr_dict;
1331 getdns_return_t r = 0;
1332 struct getdns_bindata rdata;
1333 ldns_rdf* edns_data = ldns_pkt_edns_data(pkt);
1334 uint8_t rdata_buf[65536];
1335 size_t list_len;
1336 if (!edns_data) {
1337 /* nothing to do */
1338 return GETDNS_RETURN_GOOD;
1339 }
1340 r = getdns_list_get_length(rdatas, &list_len);
1341 if (r != GETDNS_RETURN_GOOD) {
1342 return GETDNS_RETURN_GENERIC_ERROR;
1343 }
1344 r = priv_getdns_create_opt_rr(context, edns_data,
1345 &opt_rr);
1346 if (r != GETDNS_RETURN_GOOD) {
1347 return r;
1348 }
1349 /* size is: 0 label, 2 byte type, 2 byte class (size),
1350 4 byte ttl, 2 byte opt len + data itself */
1351 rdata.size = 11 + ldns_rdf_size(edns_data);
1352 rdata.data = rdata_buf;
1353 rdata_buf[0] = 0;
1354 ldns_write_uint16(rdata_buf + 1, LDNS_RR_TYPE_OPT);
1355 ldns_write_uint16(rdata_buf + 3, ldns_pkt_edns_udp_size(pkt));
1356 rdata_buf[5] = ldns_pkt_edns_extended_rcode(pkt);
1357 rdata_buf[6] = ldns_pkt_edns_version(pkt);
1358 ldns_write_uint16(rdata_buf + 7, ldns_pkt_edns_z(pkt));
1359 ldns_write_uint16(rdata_buf + 9, ldns_rdf_size(edns_data));
1360 memcpy(rdata_buf + 11, ldns_rdf_data(edns_data), ldns_rdf_size(edns_data));
1361
1362 /* add data */
1363 r |= getdns_dict_set_bindata(opt_rr, "rdata_raw", &rdata);
1364 if (r != GETDNS_RETURN_GOOD) {
1365 getdns_dict_destroy(opt_rr);
1366 return GETDNS_RETURN_GENERIC_ERROR;
1367 }
1368
1369 rr_dict = getdns_dict_create_with_context(context);
1370 if (!rr_dict) {
1371 getdns_dict_destroy(opt_rr);
1372 return GETDNS_RETURN_GENERIC_ERROR;
1373 }
1374 r = getdns_dict_set_dict(rr_dict, "rdata", opt_rr);
1375 getdns_dict_destroy(opt_rr);
1376 if (r != GETDNS_RETURN_GOOD) {
1377 getdns_dict_destroy(rr_dict);
1378 return GETDNS_RETURN_GENERIC_ERROR;
1379 }
1380 /* add rest of the fields */
1381 r = getdns_dict_set_int(rr_dict, "type", GETDNS_RRTYPE_OPT);
1382 r |= getdns_dict_set_int(rr_dict, "udp_payload_size", ldns_pkt_edns_udp_size(pkt));
1383 r |= getdns_dict_set_int(rr_dict, "extended_rcode", ldns_pkt_edns_extended_rcode(pkt));
1384 r |= getdns_dict_set_int(rr_dict, "version", ldns_pkt_edns_version(pkt));
1385 r |= getdns_dict_set_int(rr_dict, "do", ldns_pkt_edns_do(pkt));
1386 r |= getdns_dict_set_int(rr_dict, "z", ldns_pkt_edns_z(pkt));
1387 if (r != GETDNS_RETURN_GOOD) {
1388 getdns_dict_destroy(rr_dict);
1389 return GETDNS_RETURN_GENERIC_ERROR;
1390 }
1391
1392 /* append */
1393 r = getdns_list_set_dict(rdatas, list_len, opt_rr);
1394 getdns_dict_destroy(opt_rr);
1395 if (r != GETDNS_RETURN_GOOD) {
1396 return GETDNS_RETURN_GENERIC_ERROR;
1397 }
1398 return r;
1399 }
1400
1401
0 /**
1 *
2 * /brief getdns support functions for DNS Resource Records
3 */
4 /*
5 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * * Neither the names of the copyright holders nor the
16 * names of its contributors may be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef RR_DICT_H_
32 #define RR_DICT_H_
33
34 #include <getdns/getdns.h>
35 #include <ldns/ldns.h>
36
37 getdns_return_t priv_getdns_create_dict_from_rr(
38 struct getdns_context *context, ldns_rr *rr, struct getdns_dict** rr_dict);
39
40 getdns_return_t priv_getdns_create_reply_question_dict(
41 struct getdns_context *context, ldns_pkt *pkt, struct getdns_dict** q_dict);
42
43 getdns_return_t priv_getdns_create_rr_from_dict(
44 struct getdns_dict *rr_dict, ldns_rr **rr);
45
46 const char *priv_getdns_rr_type_name(int rr_type);
47
48 getdns_return_t priv_getdns_append_opt_rr(
49 struct getdns_context *context, struct getdns_list* rdatas, ldns_pkt* pkt);
50
51 #endif
52
53 /* rrs.h */
0 /**
1 *
2 * \file service.c
3 * @brief getdns core functions
4 *
5 * Originally taken from the getdns API description pseudo implementation.
6 *
7 */
8
9 /*
10 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * * Neither the names of the copyright holders nor the
21 * names of its contributors may be used to endorse or promote products
22 * derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 #include <getdns/getdns.h>
37 #include "general.h"
38 #include "util-internal.h"
39
40 /*
41 * getdns_service
42 *
43 */
44 getdns_return_t
45 getdns_service(struct getdns_context *context,
46 const char *name,
47 struct getdns_dict * extensions,
48 void *userarg,
49 getdns_transaction_t * transaction_id, getdns_callback_t callback)
50 {
51 int parmcheck;
52 getdns_return_t result;
53
54 if (!context)
55 return GETDNS_RETURN_INVALID_PARAMETER;
56 if (!callback || !name)
57 return GETDNS_RETURN_INVALID_PARAMETER;
58
59 parmcheck = validate_dname(name);
60 if (parmcheck != GETDNS_RETURN_GOOD)
61 return parmcheck;
62
63 if(extensions)
64 {
65 parmcheck = validate_extensions(extensions);
66 if (parmcheck != GETDNS_RETURN_GOOD)
67 return parmcheck;
68 }
69
70 result = getdns_general_ub(context,
71 name, GETDNS_RRTYPE_SRV, extensions, userarg, transaction_id, callback, 1);
72
73 return result;
74 } /* getdns_service */
75
76 /* service.c */
0 /**
1 *
2 * /brief getdns core functions for synchronous use
3 *
4 * Originally taken from the getdns API description pseudo implementation.
5 *
6 */
7
8 /*
9 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include "config.h"
36 #include <getdns/getdns.h>
37 #include <unbound.h>
38 #include "context.h"
39 #include "general.h"
40 #include "types-internal.h"
41 #include "util-internal.h"
42 #include <string.h>
43 #include "dnssec.h"
44
45 /* stuff to make it compile pedantically */
46 #define UNUSED_PARAM(x) ((void)(x))
47 #define RETURN_IF_NULL(ptr, code) if(ptr == NULL) return code;
48
49 getdns_return_t submit_request_sync(getdns_dns_req* req) {
50 struct ub_result* ub_res = NULL;
51 getdns_return_t gr = GETDNS_RETURN_GOOD;
52 getdns_network_req *netreq = req->first_req;
53 while (netreq) {
54 int r = ub_resolve(req->context->unbound_ctx,
55 req->name,
56 netreq->request_type,
57 netreq->request_class,
58 &ub_res);
59 if (r != 0) {
60 return GETDNS_RETURN_GENERIC_ERROR;
61 }
62 gr = getdns_apply_network_result(netreq, ub_res);
63 ub_resolve_free(ub_res);
64 ub_res = NULL;
65 if (gr != GETDNS_RETURN_GOOD) {
66 return gr;
67 }
68 netreq = netreq->next;
69 }
70 return gr;
71 }
72
73 getdns_return_t
74 getdns_general_sync(struct getdns_context *context,
75 const char *name,
76 uint16_t request_type,
77 struct getdns_dict *extensions,
78 struct getdns_dict **response)
79 {
80 getdns_dns_req *req;
81 getdns_return_t response_status;
82
83 RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
84 RETURN_IF_NULL(response, GETDNS_RETURN_INVALID_PARAMETER);
85 RETURN_IF_NULL(name, GETDNS_RETURN_INVALID_PARAMETER);
86
87 response_status = validate_dname(name);
88 if (response_status != GETDNS_RETURN_GOOD)
89 return response_status;
90
91 response_status = validate_extensions(extensions);
92 if (response_status != GETDNS_RETURN_GOOD)
93 return response_status;
94
95 /* general, so without dns lookup (no namespaces) */;
96 response_status = getdns_context_prepare_for_resolution(context, 0);
97 if (response_status != GETDNS_RETURN_GOOD)
98 return response_status;
99
100 /* for each netreq we call ub_ctx_resolve */
101 /* request state */
102 req = dns_req_new(context, name, request_type, extensions);
103 if (!req)
104 return GETDNS_RETURN_MEMORY_ERROR;
105
106 response_status = submit_request_sync(req);
107 if (response_status == GETDNS_RETURN_GOOD) {
108 if (is_extension_set(req->extensions,
109 "dnssec_return_validation_chain"))
110 *response = priv_getdns_get_validation_chain_sync(req);
111 else
112 *response = create_getdns_response(req);
113 }
114
115 dns_req_free(req);
116 return response_status;
117 }
118
119 getdns_return_t
120 getdns_address_sync(struct getdns_context *context,
121 const char *name,
122 struct getdns_dict * extensions,
123 struct getdns_dict ** response)
124 {
125 int cleanup_extensions = 0;
126 if (!extensions) {
127 extensions = getdns_dict_create_with_context(context);
128 cleanup_extensions = 1;
129 }
130 getdns_dict_set_int(extensions,
131 GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6, GETDNS_EXTENSION_TRUE);
132
133 getdns_return_t result =
134 getdns_general_sync(context, name, GETDNS_RRTYPE_A,
135 extensions, response);
136 if (cleanup_extensions) {
137 getdns_dict_destroy(extensions);
138 }
139 return result;
140 }
141
142 getdns_return_t
143 getdns_hostname_sync(struct getdns_context *context,
144 struct getdns_dict * address,
145 struct getdns_dict * extensions,
146 struct getdns_dict ** response)
147 {
148 struct getdns_bindata *address_data;
149 struct getdns_bindata *address_type;
150 uint16_t req_type;
151 char *name;
152 getdns_return_t retval;
153
154 if ((retval =
155 getdns_dict_get_bindata(address, "address_data",
156 &address_data)) != GETDNS_RETURN_GOOD)
157 return retval;
158 if ((retval =
159 getdns_dict_get_bindata(address, "address_type",
160 &address_type)) != GETDNS_RETURN_GOOD)
161 return retval;
162 if ((strncmp(GETDNS_STR_IPV4, (char *) address_type->data,
163 ( strlen(GETDNS_STR_IPV4) < address_type->size
164 ? strlen(GETDNS_STR_IPV4) : address_type->size )) == 0
165 && address_data->size == 4)
166 || (strncmp(GETDNS_STR_IPV6, (char *) address_type->data,
167 ( strlen(GETDNS_STR_IPV6) < address_type->size
168 ? strlen(GETDNS_STR_IPV6) : address_type->size )) == 0
169 && address_data->size == 16))
170 req_type = GETDNS_RRTYPE_PTR;
171 else
172 return GETDNS_RETURN_INVALID_PARAMETER;
173 if ((name = reverse_address(address_data)) == NULL)
174 return GETDNS_RETURN_INVALID_PARAMETER;
175 retval = getdns_general_sync(context, name, req_type, extensions,
176 response);
177 free(name);
178 return retval;
179 }
180
181 getdns_return_t
182 getdns_service_sync(struct getdns_context *context,
183 const char *name,
184 struct getdns_dict * extensions,
185 struct getdns_dict ** response)
186 {
187
188 return getdns_general_sync(context, name, GETDNS_RRTYPE_SRV,
189 extensions, response);
190
191 }
192
193 void
194 getdns_free_sync_request_memory(struct getdns_dict *response)
195 {
196 getdns_dict_destroy(response);
197 }
198
199 /* getdns_core_sync.c */
0 #
1 # @configure_input@
2 #
3 # Copyright (c) 2013, Verisign, Inc., NLNet Labs
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 are met:
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # * Neither the names of the copyright holders nor the
14 # names of its contributors may be used to endorse or promote products
15 # derived from this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
21 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 package = @PACKAGE_NAME@
29 version = @PACKAGE_VERSION@
30 tarname = @PACKAGE_TARNAME@
31 distdir = $(tarname)-$(version)
32
33 prefix = @prefix@
34 exec_prefix = @exec_prefix@
35 bindir = @bindir@
36 LIBTOOL = ../../libtool
37
38 srcdir = @srcdir@
39 VPATH = @srcdir@
40
41 have_libevent = @have_libevent@
42 have_libuv = @have_libuv@
43 have_libev = @have_libev@
44
45 EXTENSION_LIBEVENT_EXT_LIBS=@EXTENSION_LIBEVENT_EXT_LIBS@
46 EXTENSION_LIBUV_EXT_LIBS=@EXTENSION_LIBUV_EXT_LIBS@
47 EXTENSION_LIBEV_EXT_LIBS=@EXTENSION_LIBEV_EXT_LIBS@
48
49 CHECK_UV_PROG=@CHECK_UV_PROG@
50 CHECK_EVENT_PROG=@CHECK_EVENT_PROG@
51 CHECK_EV_PROG=@CHECK_EV_PROG@
52
53 CC=@CC@
54 CFLAGS=@CFLAGS@ -Wall -I$(srcdir)/ -I$(srcdir)/../ -I/usr/local/include -std=c99 $(cflags)
55 LDFLAGS=@LDFLAGS@ -L. -L.. -L$(srcdir)/../ -L/usr/local/lib
56 LDLIBS=-lgetdns @LIBS@ -lcheck
57 PROGRAMS=tests_dict tests_list tests_stub_async tests_stub_sync check_getdns tests_dnssec $(CHECK_EV_PROG) $(CHECK_EVENT_PROG) $(CHECK_UV_PROG)
58
59 .SUFFIXES: .c .o .a .lo .h
60
61 .c.o:
62 $(CC) $(CFLAGS) -c $< -o $@
63
64 default: all
65
66 all: $(PROGRAMS)
67
68 tests_dict: tests_dict.o testmessages.o
69 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_dict.o testmessages.o
70
71 tests_list: tests_list.o testmessages.o
72 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_list.o testmessages.o
73
74 tests_stub_async: tests_stub_async.o testmessages.o
75 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lgetdns_ext_event $(LDLIBS) -o $@ tests_stub_async.o testmessages.o
76
77 tests_stub_sync: tests_stub_sync.o
78 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_sync.o
79
80 check_getdns_common: check_getdns_common.o
81 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns_common.o
82
83 check_getdns: check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_selectloop.o
84 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -lpthread -o $@ check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_selectloop.o
85
86 check_getdns_event: check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_libevent.o
87 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lpthread -lgetdns_ext_event $(EXTENSION_LIBEVENT_EXT_LIBS) $(LDLIBS) -o $@ check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_libevent.o
88
89 check_getdns_uv: check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_libuv.o
90 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lpthread -lgetdns_ext_uv $(EXTENSION_LIBUV_EXT_LIBS) $(LDLIBS) -o $@ check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_libuv.o
91
92 check_getdns_ev: check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_libev.o
93 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lpthread -lgetdns_ext_ev $(EXTENSION_LIBEV_EXT_LIBS) $(LDLIBS) -o $@ check_getdns.o check_getdns_common.o check_getdns_context_set_timeout.o check_getdns_libev.o
94
95 tests_dnssec: tests_dnssec.o testmessages.o
96 $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -lgetdns_ext_event $(LDLIBS) -o $@ tests_dnssec.o testmessages.o
97
98
99 test: all
100 ./check_getdns
101 if test $(have_libevent) = 1 ; then ./$(CHECK_EVENT_PROG) ; fi
102 if test $(have_libev) = 1 ; then ./$(CHECK_EV_PROG) ; fi
103 if test $(have_libuv) = 1 ; then ./$(CHECK_UV_PROG) ; fi
104 @echo "All tests OK"
105
106 clean:
107 rm -f *.o $(PROGRAMS)
108 rm -rf .libs
109
110 distclean : clean
111 rm -f Makefile config.status config.log
112 rm -Rf autom4te.cache
113
114 $(distdir): FORCE
115 mkdir -p $(distdir)/src
116 cp configure.ac $(distdir)
117 cp configure $(distdir)
118 cp Makefile.in $(distdir)
119 cp src/Makefile.in $(distdir)/src
120
121 distcheck: $(distdir).tar.gz
122 gzip -cd $(distdir).tar.gz | tar xvf -
123 cd $(distdir) && ./configure
124 cd $(distdir) && $(MAKE) all
125 cd $(distdir) && $(MAKE) check
126 cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst install
127 cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst uninstall
128 @remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \
129 if test "$${remaining}" -ne 0; then
130 echo "@@@ $${remaining} file(s) remaining in stage directory!"; \
131 exit 1; \
132 fi
133 cd $(distdir) && $(MAKE) clean
134 rm -rf $(distdir)
135 @echo "*** Package $(distdir).tar.gz is ready for distribution"
136
137 Makefile: Makefile.in ../../config.status
138 cd ../.. && ./config.status $@
139
140 configure.status: configure
141 cd ../.. && ./config.status --recheck
142
143 .PHONY: clean test
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #include <stdio.h>
27 #include <stdint.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <inttypes.h>
31 #include <unistd.h>
32 #include <check.h>
33 #include <getdns/getdns.h>
34 #include "check_getdns_common.h"
35 #include "check_getdns_general.h"
36 #include "check_getdns_general_sync.h"
37 #include "check_getdns_address.h"
38 #include "check_getdns_address_sync.h"
39 #include "check_getdns_hostname.h"
40 #include "check_getdns_hostname_sync.h"
41 #include "check_getdns_context_create.h"
42 #include "check_getdns_context_destroy.h"
43 #include "check_getdns_cancel_callback.h"
44 #include "check_getdns_list_get_length.h"
45 #include "check_getdns_list_get_data_type.h"
46 #include "check_getdns_list_get_dict.h"
47 #include "check_getdns_list_get_list.h"
48 #include "check_getdns_list_get_int.h"
49 #include "check_getdns_list_get_bindata.h"
50 #include "check_getdns_dict_get_names.h"
51 #include "check_getdns_dict_get_data_type.h"
52 #include "check_getdns_dict_get_dict.h"
53 #include "check_getdns_dict_get_list.h"
54 #include "check_getdns_dict_get_bindata.h"
55 #include "check_getdns_dict_get_int.h"
56 #include "check_getdns_dict_destroy.h"
57 #include "check_getdns_dict_set_dict.h"
58 #include "check_getdns_dict_set_list.h"
59 #include "check_getdns_dict_set_bindata.h"
60 #include "check_getdns_dict_set_int.h"
61 #include "check_getdns_convert_ulabel_to_alabel.h"
62 #include "check_getdns_convert_alabel_to_ulabel.h"
63 #include "check_getdns_pretty_print_dict.h"
64 #include "check_getdns_display_ip_address.h"
65 #include "check_getdns_context_set_context_update_callback.h"
66 #include "check_getdns_context_set_timeout.h"
67 #include "check_getdns_context_set_upstream_recursive_servers.h"
68 #include "check_getdns_service.h"
69 #include "check_getdns_service_sync.h"
70
71
72 int
73 main (int argc, char** argv)
74 {
75 int number_failed;
76 SRunner *sr ;
77
78 Suite *getdns_general_suite(void);
79 Suite *getdns_general_sync_suite(void);
80 Suite *getdns_address_suite(void);
81 Suite *getdns_address_sync_suite(void);
82 Suite *getdns_hostname_suite(void);
83 Suite *getdns_hostname_sync_suite(void);
84 Suite *getdns_context_create_suite(void);
85 Suite *getdns_context_destroy_suite(void);
86 Suite *getdns_cancel_callback_suite(void);
87 Suite *getdns_list_get_length_suite(void);
88 Suite *getdns_list_get_dict_suite(void);
89 Suite *getdns_list_get_list_suite(void);
90 Suite *getdns_list_get_int_suite(void);
91 Suite *getdns_list_get_data_type_suite(void);
92 Suite *getdns_list_get_bindata_suite(void);
93 Suite *getdns_dict_get_names_suite(void);
94 Suite *getdns_dict_get_data_type_suite(void);
95 Suite *getdns_dict_get_dict_suite(void);
96 Suite *getdns_dict_get_list_suite(void);
97 Suite *getdns_dict_get_dict_suite(void);
98 Suite *getdns_dict_get_bindata_suite(void);
99 Suite *getdns_dict_get_int_suite(void);
100 Suite *getdns_dict_destroy_suite(void);
101 Suite *getdns_dict_set_dict_suite(void);
102 Suite *getdns_dict_set_list_suite(void);
103 Suite *getdns_dict_set_bindata_suite(void);
104 Suite *getdns_dict_set_int_suite(void);
105 Suite *getdns_convert_ulabel_to_alabel_suite(void);
106 Suite *getdns_convert_alabel_to_ulabel_suite(void);
107 Suite *getdns_pretty_print_dict_suite(void);
108 Suite *getdns_display_ip_address_suite(void);
109 Suite *getdns_context_set_context_update_callback_suite(void);
110 Suite *getdns_context_set_upstream_recursive_servers_suite(void);
111 Suite *getdns_service_suite(void);
112 Suite *getdns_service_sync_suite(void);
113 Suite *getdns_context_set_timeout_suite(void);
114
115 sr = srunner_create(getdns_general_suite());
116 srunner_add_suite(sr, getdns_general_sync_suite());
117 srunner_add_suite(sr, getdns_address_suite());
118 srunner_add_suite(sr, getdns_address_sync_suite());
119 srunner_add_suite(sr, getdns_hostname_suite());
120 srunner_add_suite(sr, getdns_hostname_sync_suite());
121 srunner_add_suite(sr, getdns_context_create_suite());
122 srunner_add_suite(sr, getdns_context_destroy_suite());
123 srunner_add_suite(sr, getdns_cancel_callback_suite());
124 srunner_add_suite(sr, getdns_list_get_length_suite());
125 srunner_add_suite(sr, getdns_list_get_data_type_suite());
126 srunner_add_suite(sr, getdns_list_get_dict_suite());
127 srunner_add_suite(sr, getdns_list_get_list_suite());
128 srunner_add_suite(sr, getdns_list_get_int_suite());
129 srunner_add_suite(sr, getdns_list_get_bindata_suite());
130 srunner_add_suite(sr, getdns_dict_get_names_suite());
131 srunner_add_suite(sr, getdns_dict_get_data_type_suite());
132 srunner_add_suite(sr, getdns_dict_get_dict_suite());
133 srunner_add_suite(sr, getdns_dict_get_list_suite());
134 srunner_add_suite(sr, getdns_dict_get_bindata_suite());
135 srunner_add_suite(sr, getdns_dict_get_int_suite());
136 srunner_add_suite(sr, getdns_dict_destroy_suite());
137 srunner_add_suite(sr, getdns_dict_set_dict_suite());
138 srunner_add_suite(sr, getdns_dict_set_list_suite());
139 srunner_add_suite(sr, getdns_dict_set_bindata_suite());
140 srunner_add_suite(sr, getdns_dict_set_int_suite());
141 srunner_add_suite(sr, getdns_convert_ulabel_to_alabel_suite());
142 srunner_add_suite(sr, getdns_convert_alabel_to_ulabel_suite());
143 srunner_add_suite(sr, getdns_pretty_print_dict_suite());
144 srunner_add_suite(sr,getdns_display_ip_address_suite());
145 srunner_add_suite(sr,getdns_context_set_context_update_callback_suite());
146 srunner_add_suite(sr,getdns_context_set_timeout_suite());
147 srunner_add_suite(sr,getdns_context_set_upstream_recursive_servers_suite());
148 srunner_add_suite(sr,getdns_service_suite());
149 srunner_add_suite(sr,getdns_service_sync_suite());
150
151 srunner_set_log(sr, "check_getdns.log");
152 srunner_run_all(sr, CK_NORMAL);
153 number_failed = srunner_ntests_failed(sr);
154 srunner_free(sr);
155 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
156 }
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_address_h_
27 #define _check_getdns_address_h_
28
29 /*
30 ***************************************************
31 * *
32 * T E S T S F O R G E T D N S _ A D D R E S S *
33 * *
34 ***************************************************
35 */
36
37 START_TEST (getdns_address_1)
38 {
39 /*
40 * context = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_context *context = NULL;
44 getdns_transaction_t transaction_id = 0;
45
46 ASSERT_RC(getdns_address(context, "google.com", NULL,
47 NULL, &transaction_id, callbackfn),
48 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_address()");
49 }
50 END_TEST
51
52 START_TEST (getdns_address_2)
53 {
54 /*
55 * name = NULL
56 * expect: GETDNS_RETURN_INVALID_PARAMETER
57 */
58 struct getdns_context *context = NULL; \
59 void* eventloop = NULL; \
60 getdns_transaction_t transaction_id = 0;
61
62 CONTEXT_CREATE(TRUE);
63 EVENT_BASE_CREATE;
64
65 ASSERT_RC(getdns_address(context, NULL, NULL,
66 NULL, &transaction_id, callbackfn),
67 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_address()");
68
69 RUN_EVENT_LOOP;
70 CONTEXT_DESTROY;
71 }
72 END_TEST
73
74 START_TEST (getdns_address_3)
75 {
76 /*
77 * name = invalid domain (too many octets)
78 * expect: GETDNS_RETURN_BAD_DOMAIN_NAME
79 */
80 struct getdns_context *context = NULL; \
81 void* eventloop = NULL; \
82 getdns_transaction_t transaction_id = 0;
83 const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com";
84
85 CONTEXT_CREATE(TRUE);
86 EVENT_BASE_CREATE;
87
88 ASSERT_RC(getdns_address(context, name, NULL,
89 NULL, &transaction_id, callbackfn),
90 GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_address()");
91
92 RUN_EVENT_LOOP;
93 CONTEXT_DESTROY;
94 }
95 END_TEST
96
97 START_TEST (getdns_address_4)
98 {
99 /*
100 * name = invalid domain (label too long)
101 * expect: GETDNS_RETURN_BAD_DOMAIN_NAME
102 */
103 struct getdns_context *context = NULL; \
104 void* eventloop = NULL; \
105 getdns_transaction_t transaction_id = 0;
106 const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com";
107
108 CONTEXT_CREATE(TRUE);
109 EVENT_BASE_CREATE;
110
111 ASSERT_RC(getdns_address(context, name, NULL,
112 NULL, &transaction_id, callbackfn),
113 GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_address()");
114
115 RUN_EVENT_LOOP;
116 CONTEXT_DESTROY;
117 }
118 END_TEST
119
120 START_TEST (getdns_address_5)
121 {
122 /*
123 * callbackfn = NULL
124 * expect: GETDNS_RETURN_INVALID_PARAMETER
125 */
126 struct getdns_context *context = NULL; \
127 void* eventloop = NULL; \
128 getdns_transaction_t transaction_id = 0;
129
130 CONTEXT_CREATE(TRUE);
131 EVENT_BASE_CREATE;
132
133 ASSERT_RC(getdns_address(context, "google.com", NULL,
134 NULL, &transaction_id, NULL),
135 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_address()");
136
137 RUN_EVENT_LOOP;
138 CONTEXT_DESTROY;
139 }
140 END_TEST
141
142
143 START_TEST (getdns_address_6)
144 {
145 /*
146 * name = "google.com"
147 * status = GETDNS_RESPSTATUS_GOOD
148 * rcode = 0
149 */
150 void verify_getdns_address_6(struct extracted_response *ex_response);
151 struct getdns_context *context = NULL; \
152 void* eventloop = NULL; \
153 getdns_transaction_t transaction_id = 0;
154
155 CONTEXT_CREATE(TRUE);
156 EVENT_BASE_CREATE;
157
158 ASSERT_RC(getdns_address(context, "google.com", NULL,
159 verify_getdns_address_6, &transaction_id, callbackfn),
160 GETDNS_RETURN_GOOD, "Return code from getdns_address()");
161
162 RUN_EVENT_LOOP;
163 CONTEXT_DESTROY;
164 }
165 END_TEST
166
167 void verify_getdns_address_6(struct extracted_response *ex_response)
168 {
169 assert_noerror(ex_response);
170 //assert_soa_in_authority(ex_response);
171 assert_address_in_answer(ex_response, TRUE, TRUE);
172 }
173
174
175 START_TEST (getdns_address_7)
176 {
177 /*
178 * name = "localhost" name should be resolved from host file
179 * expect: NOERROR/NODATA response:
180 * status = GETDNS_RESPSTATUS_GOOD
181 * rcode = 0
182 * ancount = 1 (number of records in ANSWER section)
183 */
184 void verify_getdns_address_7(struct extracted_response *ex_response);
185 struct getdns_context *context = NULL; \
186 void* eventloop = NULL; \
187 getdns_transaction_t transaction_id = 0;
188
189 CONTEXT_CREATE(TRUE);
190 EVENT_BASE_CREATE;
191
192 ASSERT_RC(getdns_address(context, "localhost", NULL,
193 verify_getdns_address_7, &transaction_id, callbackfn),
194 GETDNS_RETURN_GOOD, "Return code from getdns_address()");
195
196 RUN_EVENT_LOOP;
197 CONTEXT_DESTROY;
198 }
199 END_TEST
200
201 void verify_getdns_address_7(struct extracted_response *ex_response)
202 {
203 assert_noerror(ex_response);
204 assert_address_in_answer(ex_response, TRUE, TRUE);
205 }
206
207 START_TEST (getdns_address_8)
208 {
209 /*
210 * name = "hostnamedoesntexist" (name should not be resolved)
211 * expect: NXDOMAIN response
212 * status = GETDNS_RESPSTATUS_GOOD
213 * rcode = 3 (NXDOMAIN)
214 */
215 void verify_getdns_address_8(struct extracted_response *ex_response);
216 struct getdns_context *context = NULL; \
217 void* eventloop = NULL; \
218 getdns_transaction_t transaction_id = 0;
219
220 CONTEXT_CREATE(TRUE);
221
222 EVENT_BASE_CREATE;
223
224 ASSERT_RC(getdns_address(context, "hostnamedoesntexist", NULL,
225 verify_getdns_address_8, &transaction_id, callbackfn),
226 GETDNS_RETURN_GOOD, "Return code from getdns_address()");
227
228 RUN_EVENT_LOOP;
229 CONTEXT_DESTROY;
230 }
231 END_TEST
232
233 void verify_getdns_address_8(struct extracted_response *ex_response)
234 {
235 assert_nxdomain(ex_response);
236 assert_nodata(ex_response);
237 assert_soa_in_authority(ex_response);
238 }
239
240
241 Suite *
242 getdns_address_suite (void)
243 {
244 Suite *s = suite_create ("getdns_address()");
245
246 /* Negative test caseis */
247 TCase *tc_neg = tcase_create("Negative");
248 tcase_add_test(tc_neg, getdns_address_1);
249 tcase_add_test(tc_neg, getdns_address_2);
250 tcase_add_test(tc_neg, getdns_address_3);
251 tcase_add_test(tc_neg, getdns_address_4);
252 tcase_add_test(tc_neg, getdns_address_5);
253 suite_add_tcase(s, tc_neg);
254
255 /* Positive test cases */
256 TCase *tc_pos = tcase_create("Positive");
257 tcase_add_test(tc_pos, getdns_address_6);
258 tcase_add_test(tc_pos, getdns_address_7);
259 tcase_add_test(tc_pos, getdns_address_8);
260 suite_add_tcase(s, tc_pos);
261
262 return s;
263 }
264
265 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_address_sync_h_
27 #define _check_getdns_address_sync_h_
28
29 /*
30 **************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ A D D R E S S _ S Y N C *
33 * *
34 **************************************************************
35 */
36
37 START_TEST (getdns_address_sync_1)
38 {
39 /*
40 * context = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_context *context = NULL;
44 struct getdns_dict *response = NULL;
45
46 ASSERT_RC(getdns_address_sync(context, "google.com", NULL, &response),
47 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_address_sync()");
48 }
49 END_TEST
50
51 START_TEST (getdns_address_sync_2)
52 {
53 /*
54 * name = NULL
55 * expect: GETDNS_RETURN_INVALID_PARAMETER
56 */
57 struct getdns_context *context = NULL;
58 struct getdns_dict *response = NULL;
59
60 CONTEXT_CREATE(TRUE);
61
62 ASSERT_RC(getdns_address_sync(context, NULL, NULL, &response),
63 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_address_sync()");
64
65 CONTEXT_DESTROY;
66 }
67 END_TEST
68
69 START_TEST (getdns_address_sync_3)
70 {
71 /*
72 * name = NULL
73 * expect: GETDNS_RETURN_BAD_DOMAIN_NAME
74 */
75 struct getdns_context *context = NULL;
76 struct getdns_dict *response = NULL;
77 const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com";
78
79 CONTEXT_CREATE(TRUE);
80
81 ASSERT_RC(getdns_address_sync(context, name, NULL, &response),
82 GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_address_sync()");
83
84 CONTEXT_DESTROY;
85 }
86 END_TEST
87
88
89
90 START_TEST (getdns_address_sync_4)
91 {
92 /*
93 * name = "google.com"
94 * status = GETDNS_RETURN_GOOD
95 * rcode = 0
96 */
97 struct getdns_context *context = NULL;
98 struct getdns_dict *response = NULL;
99
100 CONTEXT_CREATE(TRUE);
101
102 ASSERT_RC(getdns_address_sync(context, "google.com", NULL, &response),
103 GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()");
104
105 EXTRACT_RESPONSE;
106
107 CONTEXT_DESTROY;
108 }
109 END_TEST
110
111
112
113 START_TEST (getdns_address_sync_5)
114 {
115 /*
116 * name = "localhost"
117 * expect: NOERROR response:
118 * expect: GETDNS_RETURN_GOOD
119 * rcode = 0
120 todo: investigate that proper search order is set for resolution (is local being checked)
121 todo: create zonefile with exact count
122 * ancount = tbd (number of records in ANSWER section)
123 */
124 struct getdns_context *context = NULL;
125 struct getdns_dict *response = NULL;
126
127 CONTEXT_CREATE(TRUE);
128
129 ASSERT_RC(getdns_address_sync(context, "localhost", NULL, &response),
130 GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()");
131
132 EXTRACT_RESPONSE;
133
134 assert_noerror( &ex_response);
135 assert_address_in_answer(&ex_response, TRUE, TRUE);
136
137
138 CONTEXT_DESTROY;
139 }
140 END_TEST
141
142
143 START_TEST (getdns_address_sync_6)
144 {
145 /*
146 * name = "hampster.com" need to replace this with domain from unbound zone
147 * expect: NOERROR/NODATA response:
148 * status = GETDNS_RESPSTATUS_GOOD
149 * rcode = 0
150 * ancount = 0 (number of records in ANSWER section)
151 */
152 struct getdns_context *context = NULL;
153 struct getdns_dict *response = NULL;
154
155 CONTEXT_CREATE(TRUE);
156
157 ASSERT_RC(getdns_address_sync(context, "hampster.com", NULL, &response),
158 GETDNS_RETURN_GOOD, "Return code from getdns_address_sync()");
159
160 EXTRACT_RESPONSE;
161
162 assert_noerror(&ex_response);
163 //assert_soa_in_authority(&ex_response);
164
165 CONTEXT_DESTROY;
166 }
167 END_TEST
168
169 Suite *
170 getdns_address_sync_suite (void)
171 {
172 Suite *s = suite_create ("getdns_address_sync()");
173
174 /* Negative test caseis */
175 TCase *tc_neg = tcase_create("Negative");
176 tcase_add_test(tc_neg, getdns_address_sync_1);
177 tcase_add_test(tc_neg, getdns_address_sync_2);
178 tcase_add_test(tc_neg, getdns_address_sync_3);
179 suite_add_tcase(s, tc_neg);
180 /* Positive test cases */
181
182 TCase *tc_pos = tcase_create("Positive");
183 tcase_add_test(tc_pos, getdns_address_sync_4);
184 tcase_add_test(tc_pos, getdns_address_sync_5);
185 tcase_add_test(tc_pos, getdns_address_sync_6);
186 suite_add_tcase(s, tc_pos);
187
188 return s;
189 }
190
191 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_cancel_callback_h_
27 #define _check_getdns_cancel_callback_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ C A N C E L _ C A L L B A C K *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_cancel_callback_1)
38 {
39 /*
40 * context = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 getdns_transaction_t transaction_id = 0;
44
45 ASSERT_RC(getdns_cancel_callback(NULL, transaction_id),
46 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_cancel_callback()");
47 }
48 END_TEST
49
50 START_TEST (getdns_cancel_callback_2)
51 {
52 /*
53 * transaction_id corresponds to callback that has already been called
54 * expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
55 */
56 void verify_getdns_cancel_callback(struct extracted_response *ex_response);
57 struct getdns_context *context = NULL;
58 void* eventloop = NULL;
59 getdns_transaction_t transaction_id = 0;
60
61 callback_called = 0; /* Initialize counter */
62
63 CONTEXT_CREATE(TRUE);
64 EVENT_BASE_CREATE;
65
66 ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
67 verify_getdns_cancel_callback, &transaction_id, callbackfn),
68 GETDNS_RETURN_GOOD, "Return code from getdns_general()");
69
70 RUN_EVENT_LOOP;
71
72 ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called);
73
74 ASSERT_RC(getdns_cancel_callback(context, transaction_id),
75 GETDNS_RETURN_UNKNOWN_TRANSACTION, "Return code from getdns_cancel_callback()");
76
77 CONTEXT_DESTROY;
78 }
79 END_TEST
80
81 START_TEST (getdns_cancel_callback_3)
82 {
83 /*
84 * transaction_id is unknown
85 * expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
86 */
87 void verify_getdns_cancel_callback(struct extracted_response *ex_response);
88 struct getdns_context *context = NULL;
89 void* eventloop = NULL;
90 getdns_transaction_t transaction_id = 0;
91
92 callback_called = 0; /* Initialize counter */
93
94 CONTEXT_CREATE(TRUE);
95 EVENT_BASE_CREATE;
96
97 ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
98 verify_getdns_cancel_callback, &transaction_id, callbackfn),
99 GETDNS_RETURN_GOOD, "Return code from getdns_general()");
100
101 RUN_EVENT_LOOP;
102
103 ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called);
104
105 transaction_id++;
106 ASSERT_RC(getdns_cancel_callback(context, transaction_id),
107 GETDNS_RETURN_UNKNOWN_TRANSACTION, "Return code from getdns_cancel_callback()");
108
109 CONTEXT_DESTROY;
110 }
111 END_TEST
112
113 START_TEST (getdns_cancel_callback_4)
114 {
115 /*
116 * getdns_cancel_callback() called with transaction_id returned from getdns_general()
117 *
118 * if transaction_id is odd, callback is canceled before event loop
119 * expect: GETDNS_RETURN_GOOD
120 * if transaction_id is even, callback is canceled after event loop
121 * expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
122 *
123 * expect: callback to be called with GETDNS_CALLBACK_CANCELED (if canceled)
124 * or GETDNS_CALLBACK_COMPLETE (if not canceled).
125 */
126 void cancel_callbackfn(
127 struct getdns_context *context,
128 getdns_callback_type_t callback_type,
129 struct getdns_dict *response,
130 void *userarg,
131 getdns_transaction_t transaction_id);
132 struct getdns_context *context = NULL;
133 void* eventloop = NULL;
134 getdns_transaction_t transaction_id = 0;
135 getdns_transaction_t transaction_id_array[10] = {};
136 int i;
137 int odd = 0;
138 int even = 0;
139
140 /*
141 * Initialize counters
142 */
143 callback_called = 0;
144 callback_completed = 0;
145 callback_canceled = 0;
146
147 CONTEXT_CREATE(TRUE);
148 EVENT_BASE_CREATE;
149
150 for(i = 0; i < 10; i++)
151 {
152 ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
153 NULL, &transaction_id, cancel_callbackfn),
154 GETDNS_RETURN_GOOD, "Return code from getdns_general()");
155
156 transaction_id_array[i] = transaction_id;
157
158 /*
159 * Cancel callback if transaction_id is odd which should be accepted
160 */
161 if(transaction_id % 2)
162 {
163 odd++;
164 ASSERT_RC(getdns_cancel_callback(context, transaction_id),
165 GETDNS_RETURN_GOOD, "Return code from getdns_cancel_callback()");
166 }
167 }
168
169 RUN_EVENT_LOOP;
170
171 /*
172 * Cancel the callback for even transaction_ids which should be complete
173 */
174 for(i = 0; i < 10; i++)
175 {
176 if((transaction_id_array[i] % 2) == 0)
177 {
178 even++;
179 ASSERT_RC(getdns_cancel_callback(context, transaction_id_array[i]),
180 GETDNS_RETURN_UNKNOWN_TRANSACTION, "Return code from getdns_cancel_callback()");
181 }
182 }
183
184 ck_assert_msg(callback_called == 10, "callback_called should == 10, got: %d", callback_called);
185 ck_assert_msg(callback_completed == even, "callback_completed should == %d, got: %d", even, callback_completed);
186 ck_assert_msg(callback_canceled == odd, "callback_canceled should == %d, got: %d", odd, callback_canceled);
187
188 CONTEXT_DESTROY;
189 }
190 END_TEST
191
192 START_TEST (getdns_cancel_callback_5)
193 {
194 /*
195 * getdns_cancel_callback() called with transaction_id returned from getdns_address()
196 *
197 * if transaction_id is odd, callback is canceled before event loop
198 * expect: GETDNS_RETURN_GOOD
199 * if transaction_id is even, callback is canceled after event loop
200 * expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
201 *
202 * expect: callback to be called with GETDNS_CALLBACK_CANCELED (if canceled)
203 * or GETDNS_CALLBACK_COMPLETE (if not canceled).
204 */
205 void cancel_callbackfn(
206 struct getdns_context *context,
207 getdns_callback_type_t callback_type,
208 struct getdns_dict *response,
209 void *userarg,
210 getdns_transaction_t transaction_id);
211 struct getdns_context *context = NULL;
212 void* eventloop = NULL;
213 getdns_transaction_t transaction_id = 0;
214 getdns_transaction_t transaction_id_array[10] = {};
215 int i;
216 int odd = 0;
217 int even = 0;
218
219 /*
220 * Initialize counters
221 */
222 callback_called = 0;
223 callback_completed = 0;
224 callback_canceled = 0;
225
226
227 CONTEXT_CREATE(TRUE);
228 EVENT_BASE_CREATE;
229
230 for(i = 0; i < 10; i++)
231 {
232 ASSERT_RC(getdns_address(context, "google.com", NULL,
233 NULL, &transaction_id, cancel_callbackfn),
234 GETDNS_RETURN_GOOD, "Return code from getdns_address()");
235
236 transaction_id_array[i] = transaction_id;
237
238 /*
239 * Cancel callback if transaction_id is odd which should be accepted
240 */
241 if(transaction_id % 2)
242 {
243 odd++;
244 ASSERT_RC(getdns_cancel_callback(context, transaction_id),
245 GETDNS_RETURN_GOOD, "Return code from getdns_cancel_callback()");
246 }
247 }
248
249 RUN_EVENT_LOOP;
250
251 /*
252 * Cancel the callback for even transaction_ids which should be complete
253 */
254 for(i = 0; i < 10; i++)
255 {
256 if((transaction_id_array[i] % 2) == 0)
257 {
258 even++;
259 ASSERT_RC(getdns_cancel_callback(context, transaction_id_array[i]),
260 GETDNS_RETURN_UNKNOWN_TRANSACTION, "Return code from getdns_cancel_callback()");
261 }
262 }
263
264 ck_assert_msg(callback_called == 10, "callback_called should == 10, got: %d", callback_called);
265 ck_assert_msg(callback_completed == even, "callback_completed should == %d, got: %d", even, callback_completed);
266 ck_assert_msg(callback_canceled == odd, "callback_canceled should == %d, got: %d", odd, callback_canceled);
267
268 CONTEXT_DESTROY;
269 }
270 END_TEST
271
272 START_TEST (getdns_cancel_callback_6)
273 {
274 /*
275 * getdns_cancel_callback() called with transaction_id returned from getdns_hostname()
276 *
277 * if transaction_id is odd, callback is canceled before event loop
278 * expect: GETDNS_RETURN_GOOD
279 * if transaction_id is even, callback is canceled after event loop
280 * expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
281 *
282 * expect: callback to be called with GETDNS_CALLBACK_CANCELED (if canceled)
283 * or GETDNS_CALLBACK_COMPLETE (if not canceled).
284 */
285 void cancel_callbackfn(
286 struct getdns_context *context,
287 getdns_callback_type_t callback_type,
288 struct getdns_dict *response,
289 void *userarg,
290 getdns_transaction_t transaction_id);
291 struct getdns_context *context = NULL;
292 void* eventloop = NULL;
293 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
294 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
295 struct getdns_dict *address = NULL;
296 getdns_transaction_t transaction_id = 0;
297 getdns_transaction_t transaction_id_array[10] = {};
298 int i;
299 int odd = 0;
300 int even = 0;
301
302 /*
303 * Initialize counters
304 */
305 callback_called = 0;
306 callback_completed = 0;
307 callback_canceled = 0;
308
309 CONTEXT_CREATE(TRUE);
310 EVENT_BASE_CREATE;
311
312 DICT_CREATE(address);
313 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
314 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata");
315 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
316 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata");
317
318 for(i = 0; i < 10; i++)
319 {
320 ASSERT_RC(getdns_hostname(context, address, NULL,
321 NULL, &transaction_id, cancel_callbackfn),
322 GETDNS_RETURN_GOOD, "Return code from getdns_address()");
323
324 transaction_id_array[i] = transaction_id;
325
326 /*
327 * Cancel callback if transaction_id is odd which should be accepted
328 */
329 if(transaction_id % 2)
330 {
331 odd++;
332 ASSERT_RC(getdns_cancel_callback(context, transaction_id),
333 GETDNS_RETURN_GOOD, "Return code from getdns_cancel_callback()");
334 }
335 }
336
337 RUN_EVENT_LOOP;
338
339 /*
340 * Cancel the callback for even transaction_ids which should be complete
341 */
342 for(i = 0; i < 10; i++)
343 {
344 if((transaction_id_array[i] % 2) == 0)
345 {
346 even++;
347 ASSERT_RC(getdns_cancel_callback(context, transaction_id_array[i]),
348 GETDNS_RETURN_UNKNOWN_TRANSACTION, "Return code from getdns_cancel_callback()");
349 }
350 }
351
352 ck_assert_msg(callback_called == 10, "callback_called should == 10, got: %d", callback_called);
353 ck_assert_msg(callback_completed == even, "callback_completed should == %d, got: %d", even, callback_completed);
354 ck_assert_msg(callback_canceled == odd, "callback_canceled should == %d, got: %d", odd, callback_canceled);
355
356 DICT_DESTROY(address);
357 CONTEXT_DESTROY;
358 }
359 END_TEST
360
361 START_TEST (getdns_cancel_callback_7)
362 {
363 /*
364 * getdns_cancel_callback() called with transaction_id returned from getdns_service()
365 *
366 * if transaction_id is odd, callback is canceled before event loop
367 * expect: GETDNS_RETURN_GOOD
368 * if transaction_id is even, callback is canceled after event loop
369 * expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
370 *
371 * expect: callback to be called with GETDNS_CALLBACK_CANCELED (if canceled)
372 * or GETDNS_CALLBACK_COMPLETE (if not canceled).
373 */
374 void cancel_callbackfn(
375 struct getdns_context *context,
376 getdns_callback_type_t callback_type,
377 struct getdns_dict *response,
378 void *userarg,
379 getdns_transaction_t transaction_id);
380 struct getdns_context *context = NULL;
381 void* eventloop = NULL;
382 getdns_transaction_t transaction_id = 0;
383 getdns_transaction_t transaction_id_array[10] = {};
384 int i;
385 int odd = 0;
386 int even = 0;
387
388 /*
389 * Initialize counters
390 */
391 callback_called = 0;
392 callback_completed = 0;
393 callback_canceled = 0;
394
395 CONTEXT_CREATE(TRUE);
396 EVENT_BASE_CREATE;
397
398 for(i = 0; i < 10; i++)
399 {
400 ASSERT_RC(getdns_service(context, "google.com", NULL,
401 NULL, &transaction_id, cancel_callbackfn),
402 GETDNS_RETURN_GOOD, "Return code from getdns_service()");
403
404 transaction_id_array[i] = transaction_id;
405
406 /*
407 * Cancel callback if transaction_id is odd which should be accepted
408 */
409 if(transaction_id % 2)
410 {
411 odd++;
412 ASSERT_RC(getdns_cancel_callback(context, transaction_id),
413 GETDNS_RETURN_GOOD, "Return code from getdns_cancel_callback()");
414 }
415 }
416
417 RUN_EVENT_LOOP;
418
419 /*
420 * Cancel the callback for even transaction_ids which should be complete
421 */
422 for(i = 0; i < 10; i++)
423 {
424 if((transaction_id_array[i] % 2) == 0)
425 {
426 even++;
427 ASSERT_RC(getdns_cancel_callback(context, transaction_id_array[i]),
428 GETDNS_RETURN_UNKNOWN_TRANSACTION, "Return code from getdns_cancel_callback()");
429 }
430 }
431
432 ck_assert_msg(callback_called == 10, "callback_called should == 10, got: %d", callback_called);
433 ck_assert_msg(callback_completed == even, "callback_completed should == %d, got: %d", even, callback_completed);
434 ck_assert_msg(callback_canceled == odd, "callback_canceled should == %d, got: %d", odd, callback_canceled);
435
436 CONTEXT_DESTROY;
437 }
438 END_TEST
439
440 /*
441 * Callback function for getdns_cancel_callback() tests
442 *
443 * callback_type should be GETDNS_CALLBACK_CANCEL for odd transaction_ids
444 * should be GETDNS_CALLBACK_COMPLETE for even transaction_ids
445 */
446 void cancel_callbackfn(
447 struct getdns_context *context,
448 getdns_callback_type_t callback_type,
449 struct getdns_dict *response,
450 void *userarg,
451 getdns_transaction_t transaction_id)
452 {
453 callback_called++;
454
455 if(callback_type == GETDNS_CALLBACK_CANCEL)
456 {
457 callback_canceled++;
458 ck_assert_msg(transaction_id % 2,
459 "Only callbacks with odd transaction_ids were canceled, this one is even: %d",
460 transaction_id);
461 }
462 else if(callback_type == GETDNS_CALLBACK_COMPLETE)
463 {
464 callback_completed++;
465 ck_assert_msg((transaction_id % 2) == 0,
466 "One callbacks with even transaction_ids should complete, this one is odd: %d",
467 transaction_id);
468 }
469 else
470 {
471 if(transaction_id % 2)
472 ck_abort_msg("callback_type should == GETDNS_CALLBACK_CANCEL for odd transaction_id (%d), got: %d",
473 transaction_id, callback_type);
474 else
475 ck_abort_msg("callback_type should == GETDNS_CALLBACK_COMPLETE for even transaction_id (%d), got %d",
476 transaction_id, callback_type);
477 }
478 }
479
480 /*
481 * Function passed via userarg to async functions for cancel callback tests
482 */
483 void verify_getdns_cancel_callback(struct extracted_response *ex_response)
484 {
485 /*
486 * increment callback_called global to prove callback was called.
487 */
488 callback_called++;
489 }
490
491 Suite *
492 getdns_cancel_callback_suite (void)
493 {
494 Suite *s = suite_create ("getdns_cancel_callback()");
495
496 /* Negative test caseis */
497 TCase *tc_neg = tcase_create("Negative");
498 tcase_add_test(tc_neg, getdns_cancel_callback_1);
499 tcase_add_test(tc_neg, getdns_cancel_callback_2);
500 tcase_add_test(tc_neg, getdns_cancel_callback_3);
501 suite_add_tcase(s, tc_neg);
502
503 /* Positive test cases */
504 TCase *tc_pos = tcase_create("Positive");
505 tcase_add_test(tc_pos, getdns_cancel_callback_4);
506 tcase_add_test(tc_pos, getdns_cancel_callback_5);
507 tcase_add_test(tc_pos, getdns_cancel_callback_6);
508 tcase_add_test(tc_pos, getdns_cancel_callback_7);
509
510 suite_add_tcase(s, tc_pos);
511 return s;
512 }
513
514 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #include <stdio.h>
27 #include <stdint.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <inttypes.h>
31 #include <check.h>
32 #include <getdns/getdns.h>
33 #include "config.h"
34 #include "check_getdns_common.h"
35 #include "check_getdns_eventloop.h"
36 #include <unistd.h>
37 #include <sys/time.h>
38
39 int callback_called = 0;
40 int callback_completed = 0;
41 int callback_canceled = 0;
42 uint16_t expected_changed_item = 0;
43 int event_loop_type = 0;
44
45 /*
46 * extract_response extracts all of the various information
47 * a test may want to look at from the response.
48 */
49 void extract_response(struct getdns_dict *response, struct extracted_response *ex_response)
50 {
51 ck_assert_msg(response != NULL, "Response should not be NULL");
52
53 ASSERT_RC(getdns_dict_get_int(response, "answer_type", &ex_response->top_answer_type),
54 GETDNS_RETURN_GOOD, "Failed to extract \"top answer_type\"");
55
56 ASSERT_RC(getdns_dict_get_bindata(response, "canonical_name", &ex_response->top_canonical_name),
57 GETDNS_RETURN_GOOD, "Failed to extract \"top canonical_name\"");
58
59 ASSERT_RC(getdns_dict_get_list(response, "just_address_answers", &ex_response->just_address_answers),
60 GETDNS_RETURN_GOOD, "Failed to extract \"just_address_answers\"");
61 ck_assert_msg(ex_response->just_address_answers != NULL, "just_address_answers should not be NULL");
62
63 ASSERT_RC(getdns_dict_get_list(response, "replies_full", &ex_response->replies_full),
64 GETDNS_RETURN_GOOD, "Failed to extract \"replies_full\"");
65 ck_assert_msg(ex_response->replies_full != NULL, "replies_full should not be NULL");
66
67 ASSERT_RC(getdns_dict_get_list(response, "replies_tree", &ex_response->replies_tree),
68 GETDNS_RETURN_GOOD, "Failed to extract \"replies_tree\"");
69 ck_assert_msg(ex_response->replies_tree != NULL, "replies_tree should not be NULL");
70
71 ASSERT_RC(getdns_list_get_dict(ex_response->replies_tree, 0, &ex_response->replies_tree_sub_dict),
72 GETDNS_RETURN_GOOD, "Failed to extract \"replies_tree[0]\"");
73 ck_assert_msg(ex_response->replies_tree_sub_dict != NULL, "replies_tree[0] dict should not be NULL");
74
75 ASSERT_RC(getdns_dict_get_list(ex_response->replies_tree_sub_dict, "additional", &ex_response->additional),
76 GETDNS_RETURN_GOOD, "Failed to extract \"additional\"");
77 ck_assert_msg(ex_response->additional != NULL, "additional should not be NULL");
78
79 ASSERT_RC(getdns_dict_get_list(ex_response->replies_tree_sub_dict, "answer", &ex_response->answer),
80 GETDNS_RETURN_GOOD, "Failed to extract \"answer\"");
81 ck_assert_msg(ex_response->answer != NULL, "answer should not be NULL");
82
83 ASSERT_RC(getdns_dict_get_int(ex_response->replies_tree_sub_dict, "answer_type", &ex_response->answer_type),
84 GETDNS_RETURN_GOOD, "Failed to extract \"answer_type\"");
85
86 ASSERT_RC(getdns_dict_get_list(ex_response->replies_tree_sub_dict, "authority", &ex_response->authority),
87 GETDNS_RETURN_GOOD, "Failed to extract \"authority\"");
88 ck_assert_msg(ex_response->authority != NULL, "authority should not be NULL");
89
90 ASSERT_RC(getdns_dict_get_bindata(ex_response->replies_tree_sub_dict, "canonical_name", &ex_response->canonical_name),
91 GETDNS_RETURN_GOOD, "Failed to extract \"canonical_name\"");
92
93 ASSERT_RC(getdns_dict_get_dict(ex_response->replies_tree_sub_dict, "header", &ex_response->header),
94 GETDNS_RETURN_GOOD, "Failed to extract \"header\"");
95 ck_assert_msg(ex_response->header != NULL, "header should not be NULL");
96
97 ASSERT_RC(getdns_dict_get_dict(ex_response->replies_tree_sub_dict, "question", &ex_response->question),
98 GETDNS_RETURN_GOOD, "Failed to extract \"question\"");
99 ck_assert_msg(ex_response->question != NULL, "question should not be NULL");
100
101 ASSERT_RC(getdns_dict_get_int(response, "status", &ex_response->status),
102 GETDNS_RETURN_GOOD, "Failed to extract \"status\"");
103 }
104
105 /*
106 * assert_noerror asserts that the rcode is 0
107 */
108 void assert_noerror(struct extracted_response *ex_response)
109 {
110 uint32_t rcode;
111
112 ASSERT_RC(ex_response->status, GETDNS_RESPSTATUS_GOOD, "Unexpected value for \"status\"");
113 ASSERT_RC(getdns_dict_get_int(ex_response->header, "rcode", &rcode), GETDNS_RETURN_GOOD, "Failed to extract \"rcode\"");
114 ck_assert_msg(rcode == 0, "Expected rcode == 0, got %d", rcode);
115 }
116
117 /*
118 * assert_nodata asserts that ancount in the header and the
119 * of the answer section (list) are both zero.
120 */
121 void assert_nodata(struct extracted_response *ex_response)
122 {
123 uint32_t ancount;
124 size_t length;
125
126 ASSERT_RC(getdns_dict_get_int(ex_response->header, "ancount", &ancount),
127 GETDNS_RETURN_GOOD, "Failed to extract \"ancount\"");
128 ck_assert_msg(ancount == 0, "Expected ancount == 0, got %d", ancount);
129
130 ASSERT_RC(getdns_list_get_length(ex_response->answer, &length),
131 GETDNS_RETURN_GOOD, "Failed to extract \"answer\" length");
132 ck_assert_msg(length == 0, "Expected \"answer\" length == 0, got %d", length);
133 }
134
135 /*
136 * assert_address_records_in_answer asserts that ancount in the header
137 * is >= 1, ancount is equal to the length of "answer", and that all of
138 * the records in the answer section are A and/or AAAA resource records
139 * based on the value of the a/aaaa arguments.
140 */
141 void assert_address_in_answer(struct extracted_response *ex_response, int a, int aaaa)
142 {
143 uint32_t ancount;
144 size_t length;
145 struct getdns_dict *rr_dict;
146 uint32_t type;
147 uint32_t address_records = 0;
148 size_t i;
149
150 ASSERT_RC(getdns_dict_get_int(ex_response->header, "ancount", &ancount),
151 GETDNS_RETURN_GOOD, "Failed to extract \"ancount\"");
152 ck_assert_msg(ancount >= 1, "Expected ancount >= 1, got %d", ancount);
153
154 ASSERT_RC(getdns_list_get_length(ex_response->answer, &length),
155 GETDNS_RETURN_GOOD, "Failed to extract \"answer\" length");
156 ck_assert_msg(length == ancount, "Expected \"answer\" length == ancount: %d, got %d", ancount, length);
157
158 for(i = 0; i < length; i++)
159 {
160 ASSERT_RC(getdns_list_get_dict(ex_response->answer, i, &rr_dict),
161 GETDNS_RETURN_GOOD, "Failed to extract \"answer\" record");
162 ASSERT_RC(getdns_dict_get_int(rr_dict, "type", &type),
163 GETDNS_RETURN_GOOD, "Failed to extract \"type\" from answer record");
164 switch (type)
165 {
166 case GETDNS_RRTYPE_A:
167 if(a && type == GETDNS_RRTYPE_A)
168 address_records++;
169 case GETDNS_RRTYPE_AAAA:
170 if(aaaa && type == GETDNS_RRTYPE_AAAA)
171 address_records++;
172 }
173 }
174 ck_assert_msg(ancount == address_records, "ancount: %d address records mismatch: %d",
175 ancount, address_records);
176 }
177
178 /*
179 * assert_nxdomain asserts that an NXDOMAIN response was
180 * was returned for the DNS query meaning:
181 * rcode == 3
182 */
183 void assert_nxdomain(struct extracted_response *ex_response)
184 {
185 uint32_t rcode;
186
187 ASSERT_RC(ex_response->status, GETDNS_RESPSTATUS_NO_NAME, "Unexpected value for \"status\"");
188 ASSERT_RC(getdns_dict_get_int(ex_response->header, "rcode", &rcode), GETDNS_RETURN_GOOD, "Failed to extract \"rcode\"");
189 ck_assert_msg(rcode == 3, "Expected rcode == 0, got %d", rcode);
190 }
191
192 /*
193 * assert_soa_in_authority asserts that a SOA record was
194 * returned in the authority sections.
195 */
196 void assert_soa_in_authority(struct extracted_response *ex_response)
197 {
198 uint32_t nscount;
199 size_t length;
200 struct getdns_dict *rr_dict;
201 uint32_t type;
202 uint32_t soa_records = 0;
203 size_t i;
204
205 ASSERT_RC(getdns_dict_get_int(ex_response->header, "nscount", &nscount),
206 GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
207 ck_assert_msg(nscount >= 1, "Expected nscount >= 1, got %d", nscount);
208
209 ASSERT_RC(getdns_list_get_length(ex_response->authority, &length),
210 GETDNS_RETURN_GOOD, "Failed to extract \"authority\" length");
211 ck_assert_msg(length == nscount, "Expected \"authority\" length == nscount: %d, got %d", nscount, length);
212
213 for(i = 0; i < length; i++)
214 {
215 ASSERT_RC(getdns_list_get_dict(ex_response->authority, i, &rr_dict),
216 GETDNS_RETURN_GOOD, "Failed to extract \"authority\" record");
217 ASSERT_RC(getdns_dict_get_int(rr_dict, "type", &type),
218 GETDNS_RETURN_GOOD, "Failed to extract \"type\" from authority record");
219 if(type == GETDNS_RRTYPE_SOA)
220 soa_records++;
221 }
222
223 ck_assert_msg(soa_records == 1, "Expected to find one SOA record in authority section, got %d", soa_records);
224 }
225
226 /*
227 * assert_ptr_in_answer asserts that a PTR record was
228 * returned in the answer sections.
229 */
230 void assert_ptr_in_answer(struct extracted_response *ex_response)
231 {
232 uint32_t ancount;
233 size_t length;
234 struct getdns_dict *rr_dict;
235 uint32_t type;
236 uint32_t ptr_records = 0;
237 size_t i;
238
239 ASSERT_RC(getdns_dict_get_int(ex_response->header, "ancount", &ancount),
240 GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
241 ck_assert_msg(ancount >= 1, "Expected ancount >= 1, got %d", ancount);
242
243 ASSERT_RC(getdns_list_get_length(ex_response->answer, &length),
244 GETDNS_RETURN_GOOD, "Failed to extract \"answer\" length");
245 ck_assert_msg(length == ancount, "Expected \"answer\" length == ancount: %d, got %d", ancount, length);
246
247 for(i = 0; i < length; i++)
248 {
249 ASSERT_RC(getdns_list_get_dict(ex_response->answer, i, &rr_dict),
250 GETDNS_RETURN_GOOD, "Failed to extract \"answer\" record");
251 ASSERT_RC(getdns_dict_get_int(rr_dict, "type", &type),
252 GETDNS_RETURN_GOOD, "Failed to extract \"type\" from answer record");
253 if(type == GETDNS_RRTYPE_PTR)
254 ptr_records++;
255 }
256
257 ck_assert_msg(ptr_records == 1, "Expected to find one PTR record in answer section, got %d", ptr_records);
258 }
259
260 /*
261 * callbackfn is the callback function given to all
262 * asynchronous query tests. It is expected to only
263 * be called for positive tests and will verify the
264 * response that is returned.
265 */
266 void callbackfn(struct getdns_context *context,
267 getdns_callback_type_t callback_type,
268 struct getdns_dict *response,
269 void *userarg,
270 getdns_transaction_t transaction_id)
271 {
272 typedef void (*fn_ptr)(struct extracted_response *ex_response);
273 fn_ptr fn = userarg;
274
275 /*
276 * If userarg is NULL, either a negative test case
277 * erroneously reached the query state, or the value
278 * in userarg (verification function) was somehow
279 * lost in transit.
280 */
281 ck_assert_msg(userarg != NULL, "Callback called with NULL userarg");
282
283 /*
284 * We expect the callback type to be COMPLETE.
285 */
286 ASSERT_RC(callback_type, GETDNS_CALLBACK_COMPLETE, "Callback type");
287
288 /*
289 printf("DICT:\n%s\n", getdns_pretty_print_dict(response));
290 */
291
292 /*
293 * Extract the response.
294 */
295 EXTRACT_RESPONSE;
296
297 /*
298 * Call the response verification function that
299 * was passed via userarg.
300 */
301 fn(&ex_response);
302
303 }
304
305 /*
306 * update_callbackfn is expected to only
307 * be called for positive tests and will verify the
308 * response that is returned.
309 */
310 void update_callbackfn(struct getdns_context *context,
311 getdns_context_code_t changed_item)
312 {
313
314 ck_assert_msg(changed_item == expected_changed_item,
315 "Expected changed_item == %d, got %d",
316 changed_item, expected_changed_item);
317 }
318
319 void run_event_loop(struct getdns_context* context, void* eventloop) {
320 run_event_loop_impl(context, eventloop);
321 }
322
323 void* create_event_base(struct getdns_context* context) {
324 return create_eventloop_impl(context);
325 }
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_common_h_
27 #define _check_getdns_common_h_
28
29 #include <getdns/getdns.h>
30
31 #define TRUE 1
32 #define FALSE 0
33 #define MAXLEN 200
34
35 extern int callback_called;
36 extern int callback_completed;
37 extern int callback_canceled;
38 extern uint16_t expected_changed_item;
39
40 struct extracted_response {
41 uint32_t top_answer_type;
42 struct getdns_bindata *top_canonical_name;
43 struct getdns_list *just_address_answers;
44 struct getdns_list *replies_full;
45 struct getdns_list *replies_tree;
46 struct getdns_dict *replies_tree_sub_dict;
47 struct getdns_list *additional;
48 struct getdns_list *answer;
49 uint32_t answer_type;
50 struct getdns_list *authority;
51 struct getdns_bindata *canonical_name;
52 struct getdns_dict *header;
53 struct getdns_dict *question;
54 uint32_t status;
55 };
56
57 /*
58 * The ASSERT_RC macro is used to assert
59 * whether the return code from the last
60 * getdns API call is what was expected.
61 */
62 #define ASSERT_RC(rc, expected_rc, prefix) \
63 { \
64 size_t buflen = MAXLEN; \
65 char error_string[MAXLEN]; \
66 uint32_t evaluated_rc = rc; \
67 getdns_strerror(evaluated_rc, error_string, buflen); \
68 ck_assert_msg((uint32_t) evaluated_rc == (uint32_t) expected_rc, \
69 "%s: expecting %s: %d, but received: %d: %s", \
70 prefix, #expected_rc, expected_rc, evaluated_rc, error_string); \
71 }
72
73 /*
74 * The CONTEXT_CREATE macro is used to
75 * create a context and assert the proper
76 * return code is returned.
77 */
78 #define CONTEXT_CREATE(set_from_os) \
79 ASSERT_RC(getdns_context_create(&context, set_from_os), \
80 GETDNS_RETURN_GOOD, \
81 "Return code from getdns_context_create()");
82
83 /*
84 * The CONTEXT_FREE macro is used to
85 * destroy the current context.
86 */
87 #define CONTEXT_DESTROY getdns_context_destroy(context);
88
89 /*
90 * The EVENT_BASE_CREATE macro is used to
91 * create an event base and put it in the
92 * context.
93 */
94 #define EVENT_BASE_CREATE eventloop = create_event_base(context);
95
96 /*
97 * The RUN_EVENT_LOOP macro calls the event loop.
98 */
99 #define RUN_EVENT_LOOP run_event_loop(context, eventloop);
100
101 /*
102 * The LIST_CREATE macro simply creates a
103 * list and verifies the returned pointer
104 * is not NULL.
105 */
106 #define LIST_CREATE(list) \
107 list = getdns_list_create(); \
108 ck_assert_msg(list != NULL, \
109 "NULL pointer returned by getdns_list_create()");
110
111 /*
112 * The LIST_DESTROY macro destroys a list.
113 */
114 #define LIST_DESTROY(list) getdns_list_destroy(list);
115
116 /*
117 * The DICT_CREATE macro simply creates a
118 * dict and verifies the returned pointer
119 * is not NULL.
120 */
121 #define DICT_CREATE(dict) \
122 dict = getdns_dict_create(); \
123 ck_assert_msg(dict != NULL, \
124 "NULL pointer returned by getdns_dict_create()");
125
126 /*
127 * The DICT_DESTROY macro destroys a dict.
128 */
129 #define DICT_DESTROY(dict) getdns_dict_destroy(dict);
130
131 /*
132 * The process_response macro declares the
133 * variables needed to house the response and
134 * calls the function that extracts it.
135 */
136 #define EXTRACT_RESPONSE \
137 struct extracted_response ex_response; \
138 extract_response(response, &ex_response);
139
140 //
141 // FUNCTION DECLARATIONS
142 //
143
144 /*
145 * extract_response extracts all of the various information
146 * a test may want to look at from the response.
147 */
148 void extract_response(struct getdns_dict *response, struct extracted_response *ex_response);
149
150 /*
151 * assert_noerror asserts that the rcode is 0.
152 */
153 void assert_noerror(struct extracted_response *ex_response);
154
155 /*
156 * assert_nodata asserts that ancount in the header and the
157 * of the answer section (list) are both zero.
158 */
159 void assert_nodata(struct extracted_response *ex_response);
160
161 /*
162 * assert_address_records_in_answer asserts that ancount in
163 * the header * is >= 1, ancount is equal to the length
164 * of "answer", and that all of * the records in the
165 * answer section are A and/or AAAA resource records based
166 * on the value of the a/aaaa arguments.
167 */
168 void assert_address_in_answer(struct extracted_response *ex_response, int a, int aaaa);
169
170 /*
171 * assert_nxdomain asserts that an NXDOMAIN response was
172 * was returned for the DNS query meaning rcode == 3.
173 */
174 void assert_nxdomain(struct extracted_response *ex_response);
175
176 /*
177 * assert_soa_in_authority asserts that a SOA record was
178 * returned in the authority sections.
179 */
180 void assert_soa_in_authority(struct extracted_response *ex_response);
181
182 /*
183 * assert_ptr_in_answer asserts that a PTR record was
184 * returned in the answer sections.
185 */
186 void assert_ptr_in_answer(struct extracted_response *ex_response);
187
188 /*
189 * callbackfn is the callback function given to all
190 * asynchronous query tests. It is expected to only
191 * be called for positive tests and will verify the
192 * response that is returned.
193 */
194 void callbackfn(struct getdns_context *context,
195 getdns_callback_type_t callback_type,
196 struct getdns_dict *response,
197 void *userarg,
198 getdns_transaction_t transaction_id);
199
200 /*
201 * update_callbackfn is the callback function given to
202 * getdns_context_set_context_update_callback tests.
203 */
204 void update_callbackfn(struct getdns_context *context,
205 getdns_context_code_t changed_item);
206
207 /* run the event loop */
208 void run_event_loop(struct getdns_context *context, void* eventloop);
209
210 void* create_event_base(struct getdns_context* context);
211
212 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_context_create_h_
27 #define _check_getdns_context_create_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ C O N T E X T _ C R E A T E *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_context_create_1)
38 {
39 /*
40 * context = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43
44 ASSERT_RC(getdns_context_create(NULL, TRUE),
45 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_create()");
46 }
47 END_TEST
48
49 START_TEST (getdns_context_create_2)
50 {
51 /*
52 * set_from_os = TRUE
53 * expect: context initialized with operating system info
54 * GETDNS_RETURN_GOOD
55 */
56 struct getdns_context *context = NULL;
57
58 CONTEXT_CREATE(TRUE);
59 // TODO: Do something here to verify set_from_os = TRUE
60 CONTEXT_DESTROY;
61 }
62 END_TEST
63
64 START_TEST (getdns_context_create_3)
65 {
66 /*
67 * set_from_os = FALSE
68 * expect: context is not initialized with operating system info
69 * GETDNS_RETURN_GOOD
70 */
71 struct getdns_context *context = NULL;
72
73 CONTEXT_CREATE(FALSE);
74 // TODO: Do something here to verify set_from_os = TRUE
75 CONTEXT_DESTROY;
76 }
77 END_TEST
78
79 Suite *
80 getdns_context_create_suite (void)
81 {
82 Suite *s = suite_create ("getdns_context_create()");
83
84 /* Negative test caseis */
85 TCase *tc_neg = tcase_create("Negative");
86 tcase_add_test(tc_neg, getdns_context_create_1);
87 suite_add_tcase(s, tc_neg);
88
89 /* Positive test cases */
90 TCase *tc_pos = tcase_create("Positive");
91 tcase_add_test(tc_pos, getdns_context_create_2);
92 tcase_add_test(tc_pos, getdns_context_create_3);
93 suite_add_tcase(s, tc_pos);
94
95 return s;
96 }
97
98 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_context_destroy_h_
27 #define _check_getdns_context_destroy_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ C O N T E X T _ D E S T R O Y *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_context_destroy_1)
38 {
39 /*
40 * context = NULL
41 * expect: nothing, no segmentation fault
42 */
43
44 getdns_context_destroy(NULL);
45 }
46 END_TEST
47
48 START_TEST (getdns_context_destroy_2)
49 {
50 /*
51 * destroy called with valid context and no outstanding transactions
52 * expect: nothing, context is freed
53 */
54 struct getdns_context *context = NULL;
55
56 CONTEXT_CREATE(TRUE);
57 CONTEXT_DESTROY;
58 }
59 END_TEST
60
61 START_TEST (getdns_context_destroy_3)
62 {
63 /*
64 * destroy called immediately following getdns_general
65 * expect: callback should be called before getdns_context_destroy() returns
66 */
67 void verify_getdns_context_destroy(struct extracted_response *ex_response);
68 struct getdns_context *context = NULL;
69 void* eventloop = NULL;
70 getdns_transaction_t transaction_id = 0;
71
72 callback_called = 0; /* Initialize counter */
73
74 CONTEXT_CREATE(TRUE);
75 EVENT_BASE_CREATE;
76
77 ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
78 verify_getdns_context_destroy, &transaction_id, callbackfn),
79 GETDNS_RETURN_GOOD, "Return code from getdns_general()");
80
81 RUN_EVENT_LOOP;
82 CONTEXT_DESTROY;
83
84 ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called);
85 }
86 END_TEST
87
88 START_TEST (getdns_context_destroy_4)
89 {
90 /*
91 * destroy called immediately following getdns_address
92 * expect: callback should be called before getdns_context_destroy() returns
93 */
94 void verify_getdns_context_destroy(struct extracted_response *ex_response);
95 struct getdns_context *context = NULL;
96 void* eventloop = NULL;
97 getdns_transaction_t transaction_id = 0;
98
99 callback_called = 0; /* Initialize counter */
100
101 CONTEXT_CREATE(TRUE);
102 EVENT_BASE_CREATE;
103
104 ASSERT_RC(getdns_address(context, "google.com", NULL,
105 verify_getdns_context_destroy, &transaction_id, callbackfn),
106 GETDNS_RETURN_GOOD, "Return code from getdns_address()");
107
108 RUN_EVENT_LOOP;
109 CONTEXT_DESTROY;
110
111 ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called);
112 }
113 END_TEST
114
115 START_TEST (getdns_context_destroy_5)
116 {
117 /*
118 * destroy called immediately following getdns_address
119 * expect: callback should be called before getdns_context_destroy() returns
120 */
121 void verify_getdns_context_destroy(struct extracted_response *ex_response);
122 struct getdns_context *context = NULL;
123 void* eventloop = NULL;
124 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
125 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
126 struct getdns_dict *address = NULL;
127 getdns_transaction_t transaction_id = 0;
128
129 callback_called = 0; /* Initialize counter */
130
131 CONTEXT_CREATE(TRUE);
132 EVENT_BASE_CREATE;
133
134 DICT_CREATE(address);
135 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
136 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata");
137 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
138 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata");
139
140 ASSERT_RC(getdns_hostname(context, address, NULL,
141 verify_getdns_context_destroy, &transaction_id, callbackfn),
142 GETDNS_RETURN_GOOD, "Return code from getdns_address()");
143
144 RUN_EVENT_LOOP;
145 DICT_DESTROY(address);
146 CONTEXT_DESTROY;
147
148 ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called);
149 }
150 END_TEST
151
152 START_TEST (getdns_context_destroy_6)
153 {
154 /*
155 * destroy called immediately following getdns_address
156 * expect: callback should be called before getdns_context_destroy() returns
157 */
158 void verify_getdns_context_destroy(struct extracted_response *ex_response);
159 struct getdns_context *context = NULL;
160 void* eventloop = NULL;
161 getdns_transaction_t transaction_id = 0;
162
163 callback_called = 0; /* Initialize counter */
164
165 CONTEXT_CREATE(TRUE);
166 EVENT_BASE_CREATE;
167
168 ASSERT_RC(getdns_service(context, "google.com", NULL,
169 verify_getdns_context_destroy, &transaction_id, callbackfn),
170 GETDNS_RETURN_GOOD, "Return code from getdns_service()");
171
172 RUN_EVENT_LOOP;
173 CONTEXT_DESTROY;
174
175 ck_assert_msg(callback_called == 1, "callback_called should == 1, got %d", callback_called);
176 }
177 END_TEST
178
179 void verify_getdns_context_destroy(struct extracted_response *ex_response)
180 {
181 /*
182 * Sleep for a second to make getdns_context_destroy() wait.
183 */
184 sleep(1);
185
186 /*
187 * callback_called is a global and we increment it
188 * here to show that the callback was called.
189 */
190 callback_called++;
191 }
192
193 Suite *
194 getdns_context_destroy_suite (void)
195 {
196 Suite *s = suite_create ("getdns_context_destroy()");
197
198 /* Negative test caseis */
199 TCase *tc_neg = tcase_create("Negative");
200 tcase_add_test(tc_neg, getdns_context_destroy_1);
201 suite_add_tcase(s, tc_neg);
202
203 /* Positive test cases */
204 TCase *tc_pos = tcase_create("Positive");
205 tcase_add_test(tc_pos, getdns_context_destroy_2);
206 tcase_add_test(tc_pos, getdns_context_destroy_3);
207 tcase_add_test(tc_pos, getdns_context_destroy_4);
208 tcase_add_test(tc_pos, getdns_context_destroy_5);
209 tcase_add_test(tc_pos, getdns_context_destroy_6);
210 suite_add_tcase(s, tc_pos);
211
212 return s;
213 }
214
215 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_context_set_context_update_callback_h_
27 #define _check_getdns_context_set_context_update_callback_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ C O N T E X T _ S E T _ C O N T E X T _ U P D A T E _ C A L L B A C K *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_context_set_context_update_callback_1)
38 {
39 /*
40 * context is NULL
41 * expect: GETDNS_RETURN_BAD_CONTEXT
42 */
43
44 struct getdns_context *context = NULL;
45
46 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
47 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_context_update_callback()");
48
49 }
50 END_TEST
51
52 START_TEST (getdns_context_set_context_update_callback_2)
53 {
54 /*
55 * value is NULL
56 * expect: GETDNS_RETURN_INVALID_PARAMETER
57 */
58
59 struct getdns_context *context = NULL;
60 CONTEXT_CREATE(TRUE);
61
62 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
63 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
64
65 expected_changed_item = GETDNS_CONTEXT_CODE_TIMEOUT;
66
67
68 ASSERT_RC(getdns_context_set_timeout(context, 3),
69 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_timeout()");
70
71 ASSERT_RC(getdns_context_set_context_update_callback(context, NULL),
72 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
73
74 CONTEXT_DESTROY;
75
76 }
77 END_TEST
78
79 START_TEST (getdns_context_set_context_update_callback_5)
80 {
81 /*
82 * Create a context by calling getdns_context_create()
83 * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
84 * getdns_context_set_resolution_type() to GETDNS_RESOLUTION_STUB
85 * expect: GETDNS_CONTEXT_CODE_RESOLUTION_TYPE
86 */
87 struct getdns_context *context = NULL;
88 CONTEXT_CREATE(TRUE);
89
90 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
91 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
92
93 expected_changed_item = GETDNS_CONTEXT_CODE_RESOLUTION_TYPE;
94
95 ASSERT_RC(getdns_context_set_resolution_type(context, GETDNS_RESOLUTION_STUB),
96 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_resolution_type()");
97
98 CONTEXT_DESTROY;
99
100 }
101 END_TEST
102
103 START_TEST (getdns_context_set_context_update_callback_6)
104 {
105 /*
106 * Create a context by calling getdns_context_create()
107 * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
108 * Call getdns_context_set_namespaces() to change the order and/or number of namespaces to be queried
109 * expect: GETDNS_CONTEXT_CODE_NAMESPACES
110 */
111 struct getdns_context *context = NULL;
112 getdns_namespace_t namespace_arr[2] = {GETDNS_NAMESPACE_DNS, GETDNS_NAMESPACE_LOCALNAMES};
113 CONTEXT_CREATE(TRUE);
114
115 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
116 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
117
118 expected_changed_item = GETDNS_CONTEXT_CODE_NAMESPACES;
119
120 ASSERT_RC(getdns_context_set_namespaces(context, 2,namespace_arr),
121 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_namespaces()");
122
123 CONTEXT_DESTROY;
124
125 }
126 END_TEST
127
128 START_TEST (getdns_context_set_context_update_callback_7)
129 {
130 /*
131 * Create a context by calling getdns_context_create()
132 * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
133 * Call getdns_context_set_dns_transport() to GETDNS_TRANSPORT_UDP_ONLY
134 * expect: GETDNS_CONTEXT_CODE_DNS_TRANSPORT
135 */
136 struct getdns_context *context = NULL;
137 CONTEXT_CREATE(TRUE);
138
139 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
140 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
141
142 expected_changed_item = GETDNS_CONTEXT_CODE_DNS_TRANSPORT;
143
144 ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_UDP_ONLY),
145 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
146
147 CONTEXT_DESTROY;
148
149 }
150 END_TEST
151
152 START_TEST (getdns_context_set_context_update_callback_8)
153 {
154 /*
155 * Create a context by calling getdns_context_create()
156 * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
157 * Call getdns_context_set_limit_outstanding_queries() and set limit to 10
158 * expect: GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES
159 */
160 struct getdns_context *context = NULL;
161 CONTEXT_CREATE(TRUE);
162
163 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
164 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
165
166 expected_changed_item = GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES;
167
168 ASSERT_RC(getdns_context_set_limit_outstanding_queries(context, 10),
169 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_limit_outstanding_queries()");
170
171 CONTEXT_DESTROY;
172
173 }
174 END_TEST
175
176 START_TEST (getdns_context_set_context_update_callback_9)
177 {
178 /*
179 * Create a context by calling getdns_context_create()
180 * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
181 * Call getdns_context_set_timeout() and set timeout to 3 seconds
182 * expect: GETDNS_CONTEXT_CODE_TIMEOUT
183 */
184 struct getdns_context *context = NULL;
185 CONTEXT_CREATE(TRUE);
186
187 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
188 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
189
190 expected_changed_item = GETDNS_CONTEXT_CODE_TIMEOUT;
191
192 ASSERT_RC(getdns_context_set_timeout(context, 3),
193 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_timeout()");
194
195 CONTEXT_DESTROY;
196
197 }
198 END_TEST
199
200 START_TEST (getdns_context_set_context_update_callback_10)
201 {
202 /*
203 * Create a context by calling getdns_context_create()
204 * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
205 * Call getdns_context_set_follow_redirects() to GETDNS_REDIRECTS_DO_NOT_FOLLOW
206 * expect: GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS
207 */
208 struct getdns_context *context = NULL;
209 CONTEXT_CREATE(TRUE);
210
211 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
212 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
213
214 expected_changed_item = GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS;
215
216 ASSERT_RC(getdns_context_set_follow_redirects(context, GETDNS_REDIRECTS_DO_NOT_FOLLOW),
217 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_follow_redirects()");
218
219 CONTEXT_DESTROY;
220
221 }
222 END_TEST
223
224 START_TEST (getdns_context_set_context_update_callback_15)
225 {
226 /*
227 * Create a context by calling getdns_context_create()
228 * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
229 * Call getdns_context_set_stub_resolution() providing where the API should send queries to
230 * expect: GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS
231 */
232 struct getdns_context *context = NULL;
233 struct getdns_list *upstream_list = NULL;
234 struct getdns_dict *dict = NULL;
235 size_t index = 0;
236 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
237 struct getdns_bindata address_data = { 4, (void *)"\x0A\x58\x1E\x52" };
238
239
240
241 CONTEXT_CREATE(TRUE);
242 LIST_CREATE(upstream_list);
243 DICT_CREATE(dict);
244
245 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
246 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
247
248 expected_changed_item = GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS;
249
250 ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type),
251 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
252
253 ASSERT_RC(getdns_dict_set_bindata(dict, "address_data", &address_data),
254 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
255
256 ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD,
257 "Return code from getdns_list_set_dict()");
258
259
260
261 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list),
262 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_upstream_recursive_servers()");
263
264 CONTEXT_DESTROY;
265 LIST_DESTROY(upstream_list);
266 DICT_DESTROY(dict);
267
268 }
269 END_TEST
270
271 START_TEST (getdns_context_set_context_update_callback_16)
272 {
273 /*
274 * Create a context by calling getdns_context_create()
275 * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
276 * Call getdns_context_set_edns_maximum_udp_payload_size() setting max UDP payload to 512
277 * expect: GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE
278 */
279 struct getdns_context *context = NULL;
280 CONTEXT_CREATE(TRUE);
281
282 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
283 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
284
285 expected_changed_item = GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE;
286
287 ASSERT_RC(getdns_context_set_edns_maximum_udp_payload_size(context, 512),
288 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_maximum_udp_payload_size()");
289
290 CONTEXT_DESTROY;
291
292 }
293 END_TEST
294
295 START_TEST (getdns_context_set_context_update_callback_17)
296 {
297 /*
298 * Create a context by calling getdns_context_create()
299 * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
300 * Call getdns_context_set_edns_extended_rcode() setting extended rcode to 1
301 * expect: GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE
302 */
303 struct getdns_context *context = NULL;
304 CONTEXT_CREATE(TRUE);
305
306 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
307 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
308
309 expected_changed_item = GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE;
310
311 ASSERT_RC(getdns_context_set_edns_extended_rcode(context, 1),
312 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_extended_rcode()");
313
314 CONTEXT_DESTROY;
315
316 }
317 END_TEST
318
319 START_TEST (getdns_context_set_context_update_callback_18)
320 {
321 /*
322 * Create a context by calling getdns_context_create()
323 * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
324 * Call getdns_context_set_edns_version() setting edns version to 1
325 * expect: GETDNS_CONTEXT_CODE_EDNS_VERSION
326 */
327 struct getdns_context *context = NULL;
328 CONTEXT_CREATE(TRUE);
329
330 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
331 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
332
333 expected_changed_item = GETDNS_CONTEXT_CODE_EDNS_VERSION;
334
335 ASSERT_RC(getdns_context_set_edns_version(context, 1),
336 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_version()");
337
338 CONTEXT_DESTROY;
339
340 }
341 END_TEST
342
343 START_TEST (getdns_context_set_context_update_callback_19)
344 {
345 /*
346 * Create a context by calling getdns_context_create()
347 * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
348 * Call getdns_context_set_edns_do_bit() setting edns do bit to 1
349 * expect: GETDNS_CONTEXT_CODE_EDNS_DO_BIT
350 */
351 struct getdns_context *context = NULL;
352 CONTEXT_CREATE(TRUE);
353
354 ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
355 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
356
357 expected_changed_item = GETDNS_CONTEXT_CODE_EDNS_DO_BIT;
358
359 ASSERT_RC(getdns_context_set_edns_do_bit(context, 1),
360 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_do_bit()");
361
362 CONTEXT_DESTROY;
363
364 }
365 END_TEST
366
367
368
369 Suite *
370 getdns_context_set_context_update_callback_suite (void)
371 {
372 Suite *s = suite_create ("getdns_context_set_context_update_callback()");
373
374 /* Negative test caseis */
375 TCase *tc_neg = tcase_create("Negative");
376 tcase_add_test(tc_neg, getdns_context_set_context_update_callback_1);
377 tcase_add_test(tc_neg, getdns_context_set_context_update_callback_2);
378 suite_add_tcase(s, tc_neg);
379
380 /* Positive test cases */
381 TCase *tc_pos = tcase_create("Positive");
382 tcase_add_test(tc_pos, getdns_context_set_context_update_callback_5);
383 tcase_add_test(tc_pos, getdns_context_set_context_update_callback_6);
384 tcase_add_test(tc_pos, getdns_context_set_context_update_callback_7);
385 tcase_add_test(tc_pos, getdns_context_set_context_update_callback_8);
386 tcase_add_test(tc_pos, getdns_context_set_context_update_callback_9);
387 tcase_add_test(tc_pos, getdns_context_set_context_update_callback_10);
388 tcase_add_test(tc_pos, getdns_context_set_context_update_callback_15);
389 tcase_add_test(tc_pos, getdns_context_set_context_update_callback_16);
390 tcase_add_test(tc_pos, getdns_context_set_context_update_callback_17);
391 tcase_add_test(tc_pos, getdns_context_set_context_update_callback_18);
392 tcase_add_test(tc_pos, getdns_context_set_context_update_callback_19);
393 suite_add_tcase(s, tc_pos);
394
395 return s;
396
397 }
398
399 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_context_set_dns_transport_h_
27 #define _check_getdns_context_set_dns_transport_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ C O N T E X T _ S E T _ C O N T E X T _ U P D A T E _ C A L L B A C K *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_context_set_dns_transport_1)
38 {
39 /*
40 * context is NULL
41 * expect: GETDNS_RETURN_BAD_CONTEXT
42 */
43
44 struct getdns_context *context = NULL;
45 uint16_t value = 302;
46
47 ASSERT_RC(getdns_context_set_dns_transport(context, value),
48 GETDNS_RETURN_BAD_CONTEXT, "Return code from getdns_context_set_dns_transport()");
49
50 }
51 END_TEST
52
53 START_TEST (getdns_context_set_dns_transport_2)
54 {
55 /*
56 * value is an undefined transport value
57 * expect: GETDNS_RETURN_CONTEXT_UPDATE_FAIL
58 */
59
60 struct getdns_context *context = NULL;
61 //uint16_t value = 233;
62 CONTEXT_CREATE(TRUE);
63
64
65 ASSERT_RC(getdns_context_set_dns_transport(context, 233),
66 GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_dns_transport()");
67
68 CONTEXT_DESTROY;
69
70 }
71 END_TEST
72
73 START_TEST (getdns_context_set_dns_transport_3)
74 {
75 /*
76 * Call getdns_context_set_dns_transport() with value = GETDNS_TRANSPORT_UDP_ONLY
77 * Define a callback routine for context changes and call getdns_context_set_context_update_callback() so that it gets called when there are context changes
78 * getdns_context_set_resolution_type() to GETDNS_RESOLUTION_STUB
79 * expect: GETDNS_CONTEXT_CODE_RESOLUTION_TYPE
80 */
81 struct getdns_context *context = NULL;
82 struct getdns_dict *response = NULL;
83 uint32_t ancount;
84 uint32_t arcount;
85 uint32_t nscount;
86 uint32_t tcp_ancount;
87 uint32_t tcp_arcount;
88 uint32_t tcp_nscount;
89 int udp_sum;
90 int tcp_sum;
91
92 CONTEXT_CREATE(TRUE);
93
94
95 ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_UDP_ONLY),
96 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
97
98
99 ASSERT_RC(getdns_general_sync(context, "google.com", 255, NULL, &response),
100 GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
101
102 EXTRACT_RESPONSE;
103
104
105 ASSERT_RC(getdns_dict_get_int(ex_response.header, "ancount", &ancount),
106 GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
107
108 ASSERT_RC(getdns_dict_get_int(ex_response.header, "arcount", &arcount),
109 GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
110
111 ASSERT_RC(getdns_dict_get_int(ex_response.header, "nscount", &nscount),
112 GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
113
114 printf("the resp is %s\n", getdns_pretty_print_dict(response));
115 printf("the ancount is %d\n", ancount);
116 printf("the arcount is %d\n", arcount);
117 printf("the nscount is %d\n", nscount);
118 udp_sum = ancount + arcount + nscount;
119 printf("the udp_sum is %d\n", udp_sum);
120
121 //tcp count
122 ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_TCP_ONLY),
123 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
124
125
126 ASSERT_RC(getdns_general_sync(context, "google.com", 255, NULL, &response),
127 GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
128
129 struct extracted_response ex_response1;
130 extract_response(response, &ex_response1);
131
132 ASSERT_RC(getdns_dict_get_int(ex_response1.header, "ancount", &tcp_ancount),
133 GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
134
135 ASSERT_RC(getdns_dict_get_int(ex_response1.header, "arcount", &tcp_arcount),
136 GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
137
138 ASSERT_RC(getdns_dict_get_int(ex_response1.header, "nscount", &tcp_nscount),
139 GETDNS_RETURN_GOOD, "Failed to extract \"nscount\"");
140
141 printf("the resp is %s\n", getdns_pretty_print_dict(response));
142
143 printf("the tcp_ancount is %d\n", tcp_ancount);
144 printf("the tcp_arcount is %d\n", tcp_arcount);
145 printf("the tcp_nscount is %d\n", tcp_nscount);
146 tcp_sum = tcp_ancount + tcp_arcount + tcp_nscount;
147 printf("the tcp_sum is %d\n", udp_sum);
148
149 CONTEXT_DESTROY;
150
151
152
153 }
154 END_TEST
155
156
157
158
159
160 Suite *
161 getdns_context_set_dns_transport_suite (void)
162 {
163 Suite *s = suite_create ("getdns_context_set_dns_transport()");
164
165 /* Negative test caseis */
166 TCase *tc_neg = tcase_create("Negative");
167 tcase_add_test(tc_neg, getdns_context_set_dns_transport_1);
168 tcase_add_test(tc_neg, getdns_context_set_dns_transport_2);
169 suite_add_tcase(s, tc_neg);
170
171 /* Positive test cases */
172 TCase *tc_pos = tcase_create("Positive");
173 tcase_add_test(tc_pos, getdns_context_set_dns_transport_3);
174
175 suite_add_tcase(s, tc_pos);
176
177 return s;
178
179 }
180
181 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27
28 #include "check_getdns_context_set_timeout.h"
29 #include "check_getdns_common.h"
30 #include <pthread.h>
31 #include <unistd.h>
32 #include <sys/socket.h>
33 #include <netinet/in.h>
34 #include <stdio.h>
35 #include <ldns/ldns.h>
36
37
38 /*
39 **************************************************************************
40 * *
41 * T E S T S F O R G E T D N S _ C O N T E X T _ S E T _ TIMEOUT *
42 * *
43 **************************************************************************
44 */
45
46 START_TEST (getdns_context_set_timeout_1)
47 {
48 /*
49 * context is NULL
50 * expect: GETDNS_RETURN_INVALID_PARAMETER
51 */
52
53 struct getdns_context *context = NULL;
54
55 ASSERT_RC(getdns_context_set_timeout(context, 1000),
56 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_timeout()");
57
58 }
59 END_TEST
60
61 START_TEST (getdns_context_set_timeout_2)
62 {
63 /*
64 * timeout is 0
65 * expect: GETDNS_RETURN_INVALID_PARAMETER
66 */
67
68 struct getdns_context *context = NULL;
69 CONTEXT_CREATE(TRUE);
70
71 ASSERT_RC(getdns_context_set_timeout(context, 0),
72 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_timeout()");
73
74 CONTEXT_DESTROY;
75
76 }
77 END_TEST
78
79 #define GETDNS_STR_IPV4 "IPv4"
80 #define GETDNS_STR_IPV6 "IPv6"
81 #define GETDNS_STR_ADDRESS_TYPE "address_type"
82 #define GETDNS_STR_ADDRESS_DATA "address_data"
83 #define GETDNS_STR_PORT "port"
84
85 /* utilities to start a junk udp listener */
86 typedef struct timeout_thread_data {
87 uint16_t port;
88 volatile int running;
89 int num_callbacks;
90 int num_timeouts;
91 } timeout_thread_data;
92
93 typedef struct queued_response {
94 struct sockaddr_in client_addr;
95 ldns_pkt* pkt;
96 } queued_response;
97
98 void* run_server(void* data) {
99 timeout_thread_data* tdata = (timeout_thread_data*)data;
100 int fd;
101 struct sockaddr_in serv_addr;
102 uint8_t mesg[65536];
103 fd_set read_fds;
104 ldns_rdf* answerfrom;
105 ldns_resolver* resolver;
106 int num_received = 0;
107 queued_response responses[10];
108
109 ldns_resolver_new_frm_file(&resolver, NULL);
110
111
112 fd=socket(AF_INET,SOCK_DGRAM,0);
113
114 memset(&serv_addr, 0, sizeof(serv_addr));
115 serv_addr.sin_family = AF_INET;
116 serv_addr.sin_addr.s_addr=htonl(INADDR_ANY);
117 serv_addr.sin_port=htons(tdata->port);
118 bind(fd,(struct sockaddr *)&serv_addr,sizeof(serv_addr));
119
120 /* signal that it's listening */
121 /* dirty timing hack to yield */
122 sleep(1);
123 tdata->running = 1;
124 /* queue up query responses to send out, and delay sending them
125 * for a second */
126 while (tdata->running) {
127 struct sockaddr_in client_addr;
128 FD_ZERO(&read_fds);
129 FD_SET(fd, &read_fds);
130 struct timeval tv;
131 tv.tv_sec = 1;
132 tv.tv_usec = 0;
133 int r = select(fd + 1, &read_fds, NULL, NULL, &tv);
134 if (r > 0 && num_received < 10) {
135 ldns_pkt* query;
136 socklen_t len = sizeof(client_addr);
137 int n = recvfrom(fd,mesg,65536,0,(struct sockaddr *)&(responses[num_received].client_addr),&len);
138 ldns_wire2pkt(&query, mesg, n);
139 ldns_resolver_send_pkt(&(responses[num_received].pkt), resolver, query);
140 ldns_str2rdf_a(&answerfrom, "127.0.0.1");
141 ldns_pkt_set_answerfrom(responses[num_received].pkt, answerfrom);
142 ldns_pkt_free(query);
143 ++num_received;
144 } else if (r == 0 && num_received > 0) {
145 int i = 0;
146 /* timeout - see if we have anything to send */
147 for (i = 0; i < num_received; ++i) {
148 uint8_t* pkt_data;
149 size_t pkt_len;
150 ldns_pkt* answer = responses[i].pkt;
151 ldns_pkt2wire(&pkt_data, answer, &pkt_len);
152 sendto(fd,pkt_data,pkt_len,0,(struct sockaddr *)&(responses[i].client_addr),sizeof(client_addr));
153 free(pkt_data);
154 ldns_pkt_free(answer);
155 }
156 num_received = 0;
157 }
158 }
159 ldns_resolver_deep_free(resolver);
160
161 return NULL;
162
163 }
164
165 void timeout_3_cb(struct getdns_context *context,
166 getdns_callback_type_t callback_type,
167 struct getdns_dict * response,
168 void *userarg, getdns_transaction_t transaction_id) {
169 timeout_thread_data *tdata = (timeout_thread_data*)userarg;
170 tdata->num_callbacks++;
171 if (callback_type == GETDNS_CALLBACK_TIMEOUT) {
172 tdata->num_timeouts++;
173 }
174 if (tdata->num_callbacks == 1) {
175 /* set timeout to 2 seconds and then issue request */
176 getdns_context_set_timeout(context, 500);
177 getdns_general(context, "getdnsapi.org", GETDNS_RRTYPE_A, NULL,
178 tdata, NULL, timeout_3_cb);
179 }
180 }
181
182 START_TEST (getdns_context_set_timeout_3)
183 {
184 /*
185 * Create a context by calling getdns_context_create()
186 * Create listener thread
187 * Set upstream to localhost:port
188 *
189 * getdns_context_set_resolution_type() to GETDNS_RESOLUTION_STUB
190 * expect: GETDNS_CONTEXT_CODE_RESOLUTION_TYPE
191 */
192
193 struct getdns_context *context = NULL;
194 void* eventloop = NULL;
195 struct getdns_dict* server_dict;
196 struct getdns_list* upstream_list;
197 struct getdns_bindata bindata;
198 uint32_t local_addr = htonl(0x7F000001);
199 pthread_t thread;
200
201 timeout_thread_data t_data;
202 t_data.running = 0;
203 t_data.num_callbacks = 0;
204 t_data.num_timeouts = 0;
205 t_data.port = 43210;
206
207 pthread_create(&thread, NULL, run_server, (void *)&t_data);
208
209 while (!t_data.running) {
210 sleep(1);
211 }
212
213 /* set up */
214 CONTEXT_CREATE(TRUE);
215 server_dict = getdns_dict_create_with_context(context);
216 ck_assert_msg(server_dict != NULL, "Allocate IP dictionary failed");
217 bindata.size = strlen(GETDNS_STR_IPV4) + 1;
218 bindata.data = (uint8_t*) GETDNS_STR_IPV4;
219 ASSERT_RC(getdns_dict_set_bindata(server_dict, GETDNS_STR_ADDRESS_TYPE, &bindata),
220 GETDNS_RETURN_GOOD, "set ip bindata");
221 bindata.size = 4;
222 bindata.data = (uint8_t*) &local_addr;
223 ASSERT_RC(getdns_dict_set_bindata(server_dict, GETDNS_STR_ADDRESS_DATA, &bindata),
224 GETDNS_RETURN_GOOD, "set addr bindata");
225 ASSERT_RC(getdns_dict_set_int(server_dict, GETDNS_STR_PORT, 43210),
226 GETDNS_RETURN_GOOD, "set addr port");
227
228 upstream_list = getdns_list_create_with_context(context);
229 ck_assert_msg(upstream_list != NULL, "Allocate lists");
230
231 ASSERT_RC(getdns_list_set_dict(upstream_list, 0, server_dict),
232 GETDNS_RETURN_GOOD, "set upstream");
233
234 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list),
235 GETDNS_RETURN_GOOD, "set rec servers");
236
237 /* stub */
238 ASSERT_RC(getdns_context_set_resolution_type(context, GETDNS_RESOLUTION_STUB),
239 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_resolution_type()");
240
241 EVENT_BASE_CREATE;
242
243 getdns_general(context, "getdnsapi.net", GETDNS_RRTYPE_A, NULL,
244 &t_data, NULL, timeout_3_cb);
245
246 RUN_EVENT_LOOP;
247
248 CONTEXT_DESTROY;
249
250 t_data.running = 0;
251 pthread_join(thread, NULL);
252 ck_assert_msg(t_data.num_callbacks == 2, "callbacks != 2");
253 ck_assert_msg(t_data.num_timeouts == 1, "timeouts != 1");
254
255 }
256 END_TEST
257
258
259
260
261 Suite *
262 getdns_context_set_timeout_suite (void)
263 {
264 Suite *s = suite_create ("getdns_context_set_timeout()");
265
266 /* Negative test caseis */
267 TCase *tc_neg = tcase_create("Negative");
268 tcase_add_test(tc_neg, getdns_context_set_timeout_1);
269 tcase_add_test(tc_neg, getdns_context_set_timeout_2);
270 suite_add_tcase(s, tc_neg);
271
272 /* Positive test cases */
273 TCase *tc_pos = tcase_create("Positive");
274 tcase_set_timeout(tc_pos, 15.0);
275 tcase_add_test(tc_pos, getdns_context_set_timeout_3);
276 suite_add_tcase(s, tc_pos);
277
278 return s;
279
280 }
281
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_context_set_timeout_h_
27 #define _check_getdns_context_set_timeout_h_
28
29 #include <check.h>
30
31 Suite *
32 getdns_context_set_timeout_suite (void);
33
34 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_context_set_upstream_recursive_servers_h_
27 #define _check_getdns_context_set_upstream_recursive_servers_h_
28
29 /*
30 ******************************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ C O N T E X T _ S E T _ S T U B _ R E S O L U T I O N *
33 * *
34 ******************************************************************************************
35 */
36
37 START_TEST (getdns_context_set_upstream_recursive_servers_1)
38 {
39 /*
40 * context is NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43
44 struct getdns_context *context = NULL;
45 struct getdns_list *upstream_list = NULL;
46
47 LIST_CREATE(upstream_list);
48
49 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list),
50 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_upstream_recursive_servers()");
51
52 LIST_DESTROY(upstream_list);
53 }
54 END_TEST
55
56 START_TEST (getdns_context_set_upstream_recursive_servers_2)
57 {
58 /*
59 * upstream_list is NULL
60 * expect: GETDNS_RETURN_INVALID_PARAMETER
61 */
62
63 struct getdns_context *context = NULL;
64 CONTEXT_CREATE(TRUE);
65
66 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, NULL),
67 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_upstream_recursive_servers()");
68
69
70 CONTEXT_DESTROY;
71 }
72 END_TEST
73
74 START_TEST (getdns_context_set_upstream_recursive_servers_3)
75 {
76 /*
77 * create upstream_list
78 * create context
79 * a dict in upstream_list does not contain getdns_bindata
80 */
81
82 struct getdns_context *context = NULL;
83 struct getdns_list *upstream_list = NULL;
84 struct getdns_dict *dict = NULL;
85 size_t index = 0;
86
87 CONTEXT_CREATE(TRUE);
88 LIST_CREATE(upstream_list);
89 DICT_CREATE(dict);
90
91 ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD,
92 "Return code from getdns_list_set_dict()");
93
94
95 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list),
96 GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_upstream_recursive_servers()");
97
98 CONTEXT_DESTROY;
99 LIST_DESTROY(upstream_list);
100 DICT_DESTROY(dict);
101 }
102 END_TEST
103
104 START_TEST (getdns_context_set_upstream_recursive_servers_4)
105 {
106 /*
107 * create upstream_list
108 * create context
109 * a dict in upstream_list does not contain two names
110 */
111
112 struct getdns_context *context = NULL;
113 struct getdns_list *upstream_list = NULL;
114 struct getdns_dict *dict = NULL;
115 struct getdns_bindata address_type = { 5, (void *) "IPv4" };
116 size_t index = 0;
117
118 CONTEXT_CREATE(TRUE);
119 LIST_CREATE(upstream_list);
120 DICT_CREATE(dict);
121
122 ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD,
123 "Return code from getdns_list_set_dict()");
124
125 ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type),
126 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
127
128
129 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list),
130 GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_upstream_recursive_servers()");
131
132 CONTEXT_DESTROY;
133 LIST_DESTROY(upstream_list);
134 DICT_DESTROY(dict);
135 }
136 END_TEST
137
138 START_TEST (getdns_context_set_upstream_recursive_servers_5)
139 {
140 /*
141 * create upstream_list
142 * create context
143 * a dict in upstream_list contains names other than address_type ,
144 address_data, and port
145 */
146
147 struct getdns_context *context = NULL;
148 struct getdns_list *upstream_list = NULL;
149 struct getdns_dict *dict = NULL;
150 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
151 size_t index = 0;
152
153 CONTEXT_CREATE(TRUE);
154 LIST_CREATE(upstream_list);
155 DICT_CREATE(dict);
156
157 ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD,
158 "Return code from getdns_list_set_dict()");
159
160 ASSERT_RC(getdns_dict_set_int(dict, "not_address_type", 100),
161 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
162
163 ASSERT_RC(getdns_dict_set_bindata(dict, "not_address_data", &address_data),
164 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
165
166 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list),
167 GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_upstream_recursive_servers()");
168
169 CONTEXT_DESTROY;
170 LIST_DESTROY(upstream_list);
171 DICT_DESTROY(dict);
172 }
173 END_TEST
174
175 START_TEST (getdns_context_set_upstream_recursive_servers_6)
176 {
177 /*
178 * create upstream_list
179 * create context
180 * a dict in upstream_list contains invalid address_ type (not “IPv4” or “IPv6”)
181 */
182
183 struct getdns_context *context = NULL;
184 struct getdns_list *upstream_list = NULL;
185 struct getdns_dict *dict = NULL;
186 struct getdns_bindata address_type = { 5, (void *)"IPv5" };
187 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
188 size_t index = 0;
189
190 CONTEXT_CREATE(TRUE);
191 LIST_CREATE(upstream_list);
192 DICT_CREATE(dict);
193
194 ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD,
195 "Return code from getdns_list_set_dict()");
196
197 ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type),
198 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
199 ASSERT_RC(getdns_dict_set_bindata(dict, "address_data", &address_data),
200 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
201
202 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list),
203 GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_upstream_recursive_servers()");
204
205 CONTEXT_DESTROY;
206 LIST_DESTROY(upstream_list);
207 DICT_DESTROY(dict);
208 }
209 END_TEST
210
211 START_TEST (getdns_context_set_upstream_recursive_servers_7)
212 {
213 /*
214 * create upstream_list
215 * create context
216 * a dict in upstream_list contains named address_type and
217 address_data but the data type isn’t bindata
218 */
219
220 struct getdns_context *context = NULL;
221 struct getdns_list *upstream_list = NULL;
222 struct getdns_dict *dict = NULL;
223 size_t index = 0;
224
225 CONTEXT_CREATE(TRUE);
226 LIST_CREATE(upstream_list);
227 DICT_CREATE(dict);
228
229 ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD,
230 "Return code from getdns_list_set_dict()");
231
232 ASSERT_RC(getdns_dict_set_int(dict, "address_type", 100),
233 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
234
235 ASSERT_RC(getdns_dict_set_int(dict, "address_data", 200),
236 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
237
238 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list),
239 GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_upstream_recursive_servers()");
240
241 CONTEXT_DESTROY;
242 LIST_DESTROY(upstream_list);
243 DICT_DESTROY(dict);
244 }
245 END_TEST
246
247 START_TEST (getdns_context_set_upstream_recursive_servers_8)
248 {
249 /*
250 * create upstream_list
251 * create context
252 * a dict in upstream_list contains invalid address_data
253 */
254
255 struct getdns_context *context = NULL;
256 struct getdns_list *upstream_list = NULL;
257 struct getdns_dict *dict = NULL;
258 struct getdns_bindata address_type = { 5, (void *)"IPv5" };
259 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
260 size_t index = 0;
261
262 CONTEXT_CREATE(TRUE);
263 LIST_CREATE(upstream_list);
264 DICT_CREATE(dict);
265
266 ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD,
267 "Return code from getdns_list_set_dict()");
268
269 ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type),
270 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
271 ASSERT_RC(getdns_dict_set_bindata(dict, "address_data", &address_data),
272 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
273
274 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list),
275 GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_upstream_recursive_servers()");
276
277 CONTEXT_DESTROY;
278 LIST_DESTROY(upstream_list);
279 DICT_DESTROY(dict);
280 }
281 END_TEST
282
283 START_TEST (getdns_context_set_upstream_recursive_servers_9)
284 {
285 /*
286 * create context
287 * Call getdns_list_create() to create a list
288 * Call getdns_dict_create() to create a list
289 * Create bindata containing “IPv4”
290 */
291
292 struct getdns_context *context = NULL;
293 struct getdns_list *upstream_list = NULL;
294 struct getdns_dict *dict = NULL;
295 struct getdns_dict *response = NULL;
296 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
297 struct getdns_bindata address_data = { 4, (void *)"\x0A\xAA\x0C\x38" };
298 size_t index = 0;
299
300 CONTEXT_CREATE(TRUE);
301 LIST_CREATE(upstream_list);
302 DICT_CREATE(dict);
303
304 ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type),
305 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
306
307 ASSERT_RC(getdns_dict_set_bindata(dict, "address_data", &address_data),
308 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
309
310 ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD,
311 "Return code from getdns_list_set_dict()");
312
313
314 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list),
315 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_upstream_recursive_servers()");
316
317 ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response),
318 GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
319
320
321 EXTRACT_RESPONSE;
322
323 assert_noerror(&ex_response);
324 assert_address_in_answer(&ex_response, TRUE, FALSE);
325
326 CONTEXT_DESTROY;
327 LIST_DESTROY(upstream_list);
328 DICT_DESTROY(dict);
329 DICT_DESTROY(response);
330 }
331 END_TEST
332
333 START_TEST (getdns_context_set_upstream_recursive_servers_10)
334 {
335 /*
336 * create context
337 * Call getdns_list_create() to create a list
338 * Call getdns_dict_create() to create a list
339 * Create bindata containing “IPv6”
340 */
341
342 struct getdns_context *context = NULL;
343 struct getdns_list *upstream_list = NULL;
344 struct getdns_dict *dict = NULL;
345 struct getdns_dict *response = NULL;
346 struct getdns_bindata address_type = { 5, (void *)"IPv6" };
347 struct getdns_bindata address_data = { 16, (void *)"\x20\x01\x48\x60\x48\x60\x00\x00\x00\x00\x00\x00\x00\x00\x88\x44" };
348 size_t index = 0;
349
350 CONTEXT_CREATE(TRUE);
351 LIST_CREATE(upstream_list);
352 DICT_CREATE(dict);
353
354 ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type),
355 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
356
357 ASSERT_RC(getdns_dict_set_bindata(dict, "address_data", &address_data),
358 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
359
360 ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD,
361 "Return code from getdns_list_set_dict()");
362
363
364 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list),
365 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_upstream_recursive_servers()");
366
367 ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response),
368 GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
369
370 EXTRACT_RESPONSE;
371
372 assert_noerror(&ex_response);
373 assert_address_in_answer(&ex_response, TRUE, FALSE);
374
375 CONTEXT_DESTROY;
376 LIST_DESTROY(upstream_list);
377 DICT_DESTROY(dict);
378 DICT_DESTROY(response);
379 }
380 END_TEST
381
382 START_TEST (getdns_context_set_upstream_recursive_servers_11)
383 {
384 /*
385 * create context
386 * Call getdns_list_create() to create a list
387 * Call getdns_dict_create() to create a list
388 * Create bindata containing “IPv4”
389 */
390
391 struct getdns_context *context = NULL;
392 struct getdns_list *upstream_list = NULL;
393 struct getdns_dict *dict = NULL;
394 struct getdns_dict *response = NULL;
395 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
396 struct getdns_bindata address_data = { 4, (void *)"\x0A\xAA\x0C\x38" };
397 struct getdns_bindata port = { 3, (void *)"53" };
398 size_t index = 0;
399
400 CONTEXT_CREATE(TRUE);
401 LIST_CREATE(upstream_list);
402 DICT_CREATE(dict);
403
404 ASSERT_RC(getdns_dict_set_bindata(dict, "address_type", &address_type),
405 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
406
407 ASSERT_RC(getdns_dict_set_bindata(dict, "address_data", &address_data),
408 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
409
410 ASSERT_RC(getdns_dict_set_bindata(dict, "53", &port),
411 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
412
413 ASSERT_RC(getdns_list_set_dict(upstream_list, index, dict), GETDNS_RETURN_GOOD,
414 "Return code from getdns_list_set_dict()");
415
416
417 ASSERT_RC(getdns_context_set_upstream_recursive_servers(context, upstream_list),
418 GETDNS_RETURN_GOOD, "Return code from getdns_context_set_upstream_recursive_servers()");
419
420 ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response),
421 GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
422
423
424 EXTRACT_RESPONSE;
425 printf("the resp is %s\n", getdns_pretty_print_dict(response));
426
427
428 assert_noerror(&ex_response);
429 assert_address_in_answer(&ex_response, TRUE, FALSE);
430
431 CONTEXT_DESTROY;
432 LIST_DESTROY(upstream_list);
433 DICT_DESTROY(dict);
434 DICT_DESTROY(response);
435 }
436 END_TEST
437
438
439
440
441 Suite *
442 getdns_context_set_upstream_recursive_servers_suite (void)
443 {
444 Suite *s = suite_create ("getdns_context_set_upstream_recursive_servers()");
445
446 /* Negative test caseis */
447 TCase *tc_neg = tcase_create("Negative");
448 tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_1);
449 tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_2);
450 tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_3);
451 tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_4);
452 tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_5);
453 tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_6);
454 tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_7);
455 tcase_add_test(tc_neg, getdns_context_set_upstream_recursive_servers_8);
456
457 suite_add_tcase(s, tc_neg);
458
459 /* Positive test cases */
460 TCase *tc_pos = tcase_create("Positive");
461 tcase_add_test(tc_pos, getdns_context_set_upstream_recursive_servers_9);
462 tcase_add_test(tc_pos, getdns_context_set_upstream_recursive_servers_10);
463 tcase_add_test(tc_pos, getdns_context_set_upstream_recursive_servers_11);
464
465 suite_add_tcase(s, tc_pos);
466
467 return s;
468
469 }
470
471 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_convert_alabel_to_ulabel_h_
27 #define _check_getdns_convert_alabel_to_ulabel_h_
28
29 /*
30 *************************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ C O N V E R T _ A L A B E L _ T O _ U L A B E L *
33 * *
34 *************************************************************************************
35 */
36
37 START_TEST (getdns_convert_alabel_to_ulabel_1)
38 {
39 /*
40 * alabel = NULL
41 * expect: GETDNS_RETURN_GENERIC_ERROR
42 */
43 char *alabel = NULL;
44
45 ck_assert_msg( getdns_convert_alabel_to_ulabel( alabel ) == 0,
46 "Was not expecting %d from getdns_convert_alabel_to_ulabel()", getdns_convert_alabel_to_ulabel( alabel ) );
47
48 }
49 END_TEST
50
51 START_TEST (getdns_convert_alabel_to_ulabel_2)
52 {
53 /*
54 * alabel = invalid characters
55 * expect: GETDNS_RETURN_GENERIC_ERROR
56 */
57 char *alabel = "#$%_";
58
59 ck_assert_msg(strcmp( getdns_convert_alabel_to_ulabel( alabel ), "#$%_" ) == 0,
60 "Was not expecting %s from getdns_convert_alabel_to_ulabel()", getdns_convert_alabel_to_ulabel( alabel ) );
61
62
63 }
64 END_TEST
65
66 START_TEST (getdns_convert_alabel_to_ulabel_3)
67 {
68 /*
69 * alabel = valid characters (ace must begin with prefix "xn--" and be followed by a valid puny algorithm output; length limited to 59 chars)
70 * expect: GETDNS_RETURN_GOOD
71 */
72 char *alabel = "xn--caf-dma";
73
74 ck_assert_msg(strcmp( getdns_convert_alabel_to_ulabel( alabel ), "café" ) == 0,
75 "Was not expecting %s from getdns_convert_alabel_to_ulabel()", getdns_convert_alabel_to_ulabel( alabel ) );
76
77 }
78 END_TEST
79
80 Suite *
81 getdns_convert_alabel_to_ulabel_suite (void)
82 {
83 Suite *s = suite_create ("getdns_convert_alabel_to_ulabel()");
84
85 /* Negative test caseis */
86 TCase *tc_neg = tcase_create("Negative");
87 tcase_add_test(tc_neg, getdns_convert_alabel_to_ulabel_1);
88 tcase_add_test(tc_neg, getdns_convert_alabel_to_ulabel_2);
89 suite_add_tcase(s, tc_neg);
90
91 /* Positive test cases */
92 TCase *tc_pos = tcase_create("Positive");
93 tcase_add_test(tc_pos, getdns_convert_alabel_to_ulabel_3);
94 suite_add_tcase(s, tc_pos);
95
96 return s;
97 }
98
99 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_convert_ulabel_to_alabel_h_
27 #define _check_getdns_convert_ulabel_to_alabel_h_
28
29 /*
30 *************************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ C O N V E R T _ U L A B E L _ T O _ A L A B E L *
33 * *
34 *************************************************************************************
35 */
36
37 START_TEST (getdns_convert_ulabel_to_alabel_1)
38 {
39 /*
40 * ulabel = NULL
41 * expect: GETDNS_RETURN_GENERIC_ERROR
42 */
43 char *ulabel = NULL;
44
45
46 ck_assert_msg(( getdns_convert_ulabel_to_alabel( ulabel ) == 0 ),
47 "Was not expecting %d from getdns_convert_ulabel_to_alabel()", getdns_convert_ulabel_to_alabel( ulabel ) );
48 }
49 END_TEST
50
51 START_TEST (getdns_convert_ulabel_to_alabel_2)
52 {
53 /*
54 * ulabel = invalid characters
55 * expect: GETDNS_RETURN_GENERIC_ERROR
56 */
57 char *ulabel = "#$%_";
58
59 ck_assert_msg(strcmp( getdns_convert_ulabel_to_alabel( ulabel ), "#$%_" ) == 0,
60 "Was not expecting %s from getdns_convert_ulabel_to_alabel()", getdns_convert_ulabel_to_alabel( ulabel ) );
61 }
62 END_TEST
63
64 START_TEST (getdns_convert_ulabel_to_alabel_3)
65 {
66 /*
67 * ulabel = valid characters ( _abc, -abc, -abc-, abc- and limited to 63 octets )
68 * expect: GETDNS_RETURN_GOOD
69 */
70 char *ulabel = "café";
71
72 ck_assert_msg(strcmp( getdns_convert_ulabel_to_alabel( ulabel ), "xn--caf-dma" ) == 0,
73 "Was not expecting %s from getdns_convert_ulabel_to_alabel()", getdns_convert_ulabel_to_alabel( ulabel ) );
74
75 }
76 END_TEST
77
78 Suite *
79 getdns_convert_ulabel_to_alabel_suite (void)
80 {
81 Suite *s = suite_create ("getdns_convert_ulabel_to_alabel()");
82
83 /* Negative test caseis */
84 TCase *tc_neg = tcase_create("Negative");
85 tcase_add_test(tc_neg, getdns_convert_ulabel_to_alabel_1);
86 tcase_add_test(tc_neg, getdns_convert_ulabel_to_alabel_2);
87 suite_add_tcase(s, tc_neg);
88
89 /* Positive test cases */
90 TCase *tc_pos = tcase_create("Positive");
91 tcase_add_test(tc_pos, getdns_convert_ulabel_to_alabel_3);
92 suite_add_tcase(s, tc_pos);
93
94 return s;
95 }
96
97 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_dict_destroy_h_
27 #define _check_getdns_dict_destroy_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ D I C T _ D E S T R O Y *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_dict_destroy_1)
38 {
39 /*
40 * this_dict = NULL
41 * expect: nothing
42 */
43 struct getdns_dict *this_dict = NULL;
44
45 DICT_DESTROY(this_dict);
46 }
47 END_TEST
48
49 START_TEST (getdns_dict_destroy_2)
50 {
51 /*
52 * build a complex dict and then destroy it
53 *
54 * dict1-> "int" = 1
55 * -> "bindata" = { 8, "bindata" }
56 * -> "dict" = dict2->"int" = 2
57 * -> "bindata" = { 8, "bindata" }
58 * -> "dict" = dict3 -> "int" = 3
59 * -> "bindata" = { 8, "bindata" }
60 * -> "dict" = dict4 -> "int" = 4
61 * -> "list" = list1 0: int = 5
62 * -> "list" = list2 0: int = 6
63 * 1: bindata = { 8, "bindata" }
64 * 2: dict = dict5 -> "bindata" = { 8, "bindata" }
65 * 3: list = list3 0: bindata = { 8, "bindata" }
66 * -> "list" = list4 0: int = 6
67 * 1: bindata = { 8, "bindata" }
68 * 2: dict6 -> "int" = 8
69 * -> "bindata" = { 8, "bindata" }
70 * -> "dict" = dict7 -> "int" = 9
71 * -> "list" = list5 0: int = 10
72 * 3: list6 0: int = 11
73 * 1: bindata = { 8, "bindata" }
74 * 2: dict8 -> "bindata" = { 8, "bindata" }
75 * 3: list7 0: bindata = { 8, "bindata" }
76 *
77 * expect: nothing
78 */
79 struct getdns_bindata bindata = { 8, (void *)"bindata" };
80 struct getdns_list *list7;
81 struct getdns_dict *dict8;
82 struct getdns_list *list6;
83 struct getdns_list *list5;
84 struct getdns_dict *dict7;
85 struct getdns_dict *dict6;
86 struct getdns_list *list4;
87 struct getdns_list *list3;
88 struct getdns_dict *dict5;
89 struct getdns_list *list2;
90 struct getdns_list *list1;
91 struct getdns_dict *dict4;
92 struct getdns_dict *dict3;
93 struct getdns_dict *dict2;
94 struct getdns_dict *dict1;
95
96 /*
97 * Build it backwards, with the deepest elements first.
98 */
99 LIST_CREATE(list7);
100 ASSERT_RC(getdns_list_set_bindata(list7, 0, &bindata),
101 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
102
103 DICT_CREATE(dict8);
104 ASSERT_RC(getdns_dict_set_bindata(dict8, "bindata", &bindata),
105 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
106
107 LIST_CREATE(list6);
108 ASSERT_RC(getdns_list_set_int(list6, 0, 11),
109 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
110 ASSERT_RC(getdns_list_set_bindata(list6, 1, &bindata),
111 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
112 ASSERT_RC(getdns_list_set_dict(list6, 2, dict8),
113 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()");
114 ASSERT_RC(getdns_list_set_list(list6, 3, list7),
115 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()");
116
117 LIST_CREATE(list5);
118 ASSERT_RC(getdns_list_set_int(list5, 0, 10),
119 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
120
121 DICT_CREATE(dict7);
122 ASSERT_RC(getdns_dict_set_int(dict7, "int", 9),
123 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
124
125 DICT_CREATE(dict6);
126 ASSERT_RC(getdns_dict_set_int(dict6, "int", 8),
127 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
128 ASSERT_RC(getdns_dict_set_bindata(dict6, "bindata", &bindata),
129 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
130 ASSERT_RC(getdns_dict_set_dict(dict6, "dict", dict7),
131 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
132 ASSERT_RC(getdns_dict_set_list(dict6, "list", list5),
133 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
134
135 LIST_CREATE(list4);
136 ASSERT_RC(getdns_list_set_int(list4, 0, 7),
137 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
138 ASSERT_RC(getdns_list_set_bindata(list4, 1, &bindata),
139 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
140 ASSERT_RC(getdns_list_set_dict(list4, 2, dict6),
141 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()");
142 ASSERT_RC(getdns_list_set_list(list4, 3, list5),
143 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()");
144
145 LIST_CREATE(list3);
146 ASSERT_RC(getdns_list_set_bindata(list3, 0, &bindata),
147 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
148
149 DICT_CREATE(dict5);
150 ASSERT_RC(getdns_dict_set_bindata(dict5, "bindata", &bindata),
151 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
152
153 LIST_CREATE(list2);
154 ASSERT_RC(getdns_list_set_int(list2, 0, 6),
155 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
156 ASSERT_RC(getdns_list_set_bindata(list2, 1, &bindata),
157 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
158 ASSERT_RC(getdns_list_set_dict(list2, 2, dict5),
159 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()");
160 ASSERT_RC(getdns_list_set_list(list2, 3, list3),
161 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()");
162
163 LIST_CREATE(list1);
164 ASSERT_RC(getdns_list_set_int(list1, 0, 5),
165 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
166
167 DICT_CREATE(dict4);
168 ASSERT_RC(getdns_dict_set_int(dict4, "int", 4),
169 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
170
171 DICT_CREATE(dict3);
172 ASSERT_RC(getdns_dict_set_int(dict3, "int", 3),
173 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
174 ASSERT_RC(getdns_dict_set_bindata(dict3, "bindata", &bindata),
175 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
176 ASSERT_RC(getdns_dict_set_dict(dict3, "dict", dict4),
177 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
178 ASSERT_RC(getdns_dict_set_list(dict3, "list", list1),
179 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
180
181 DICT_CREATE(dict2);
182 ASSERT_RC(getdns_dict_set_int(dict2, "int", 2),
183 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
184 ASSERT_RC(getdns_dict_set_bindata(dict2, "bindata", &bindata),
185 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
186 ASSERT_RC(getdns_dict_set_dict(dict2, "dict", dict3),
187 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
188 ASSERT_RC(getdns_dict_set_list(dict2, "list", list2),
189 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
190
191 DICT_CREATE(dict1);
192 ASSERT_RC(getdns_dict_set_int(dict1, "int", 1),
193 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
194 ASSERT_RC(getdns_dict_set_bindata(dict1, "bindata", &bindata),
195 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
196 ASSERT_RC(getdns_dict_set_dict(dict1, "dict", dict2),
197 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
198 ASSERT_RC(getdns_dict_set_list(dict1, "list", list4),
199 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
200
201 /*
202 * Destroy all of the sub-dicts and sub-lists
203 */
204 LIST_DESTROY(list7);
205 DICT_DESTROY(dict8);
206 LIST_DESTROY(list6);
207 LIST_DESTROY(list5);
208 DICT_DESTROY(dict7);
209 DICT_DESTROY(dict6);
210 LIST_DESTROY(list4);
211 LIST_DESTROY(list3);
212 DICT_DESTROY(dict5);
213 LIST_DESTROY(list2);
214 LIST_DESTROY(list1);
215 DICT_DESTROY(dict4);
216 DICT_DESTROY(dict3);
217 DICT_DESTROY(dict2);
218
219 /*
220 * And now destroy the mother of all ints, bindata, dicts, and lists
221 */
222 DICT_DESTROY(dict1);
223 }
224 END_TEST
225
226 Suite *
227 getdns_dict_destroy_suite (void)
228 {
229 Suite *s = suite_create ("getdns_dict_destroy()");
230
231 /* Negative test caseis */
232 TCase *tc_neg = tcase_create("Negative");
233 tcase_add_test(tc_neg, getdns_dict_destroy_1);
234 suite_add_tcase(s, tc_neg);
235
236 /* Positive test cases */
237 TCase *tc_pos = tcase_create("Positive");
238 tcase_add_test(tc_pos, getdns_dict_destroy_2);
239 suite_add_tcase(s, tc_pos);
240
241 return s;
242 }
243
244 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_dict_get_bindata_h_
27 #define _check_getdns_dict_get_bindata_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ D I C T _ G E T _ B I N D A T A *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_dict_get_bindata_1)
38 {
39 /*
40 * this_dict = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_dict *this_dict = NULL;
44 struct getdns_bindata *answer = NULL;
45
46 ASSERT_RC(getdns_dict_get_bindata(this_dict, "key", &answer),
47 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_bindata()");
48
49 }
50 END_TEST
51
52 START_TEST (getdns_dict_get_bindata_2)
53 {
54 /*
55 * name = NULL
56 * expect: GETDNS_RETURN_INVALID_PARAMETER
57 */
58 struct getdns_dict *this_dict = NULL;
59 struct getdns_bindata bindata = { 8, (void *)"bindata" };
60 struct getdns_bindata *answer = NULL;
61
62 DICT_CREATE(this_dict);
63 ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata),
64 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
65
66 ASSERT_RC(getdns_dict_get_bindata(this_dict, NULL, &answer),
67 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_bindata()");
68
69 DICT_DESTROY(this_dict);
70 }
71 END_TEST
72
73 START_TEST (getdns_dict_get_bindata_3)
74 {
75 /*
76 * name does not exist in dict
77 * Create a dict
78 * Create some bindata containing "bindata" and add it to the dict with name = "bindata"
79 * Call getdns_dict_get_bindata() against the first dict with name = "bindata1"
80 * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME
81 */
82 struct getdns_dict *this_dict = NULL;
83 struct getdns_bindata bindata = { 8, (void *)"bindata" };
84 struct getdns_bindata *answer = NULL;
85
86 DICT_CREATE(this_dict);
87 ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata),
88 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
89
90 ASSERT_RC(getdns_dict_get_bindata(this_dict, "bindata1", &answer),
91 GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_dict_get_bindata()");
92
93 DICT_DESTROY(this_dict);
94 }
95 END_TEST
96
97 START_TEST (getdns_dict_get_bindata_4)
98 {
99 /*
100 * data type at name is not bindata
101 * Create a dict with one int (name = "ten", value = 10)
102 * Call getdns_dict_get_bindata() with name = "ten"
103 * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
104 */
105 struct getdns_dict *this_dict = NULL;
106 struct getdns_bindata *answer = NULL;
107
108 DICT_CREATE(this_dict);
109
110 ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10),
111 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
112
113 ASSERT_RC(getdns_dict_get_bindata(this_dict, "ten", &answer),
114 GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_dict_get_bindata()");
115
116 DICT_DESTROY(this_dict);
117 }
118 END_TEST
119
120 START_TEST (getdns_dict_get_bindata_5)
121 {
122 /*
123 * answer = NULL
124 * expect: GETDNS_RETURN_INVALID_PARAMETER
125 */
126 struct getdns_dict *this_dict = NULL;
127 struct getdns_bindata bindata = { 8, (void *)"bindata" };
128
129 DICT_CREATE(this_dict);
130
131 ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata),
132 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
133
134 ASSERT_RC(getdns_dict_get_bindata(this_dict, "bindata", NULL),
135 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_bindata()");
136
137 DICT_DESTROY(this_dict);
138 }
139 END_TEST
140
141 START_TEST (getdns_dict_get_bindata_6)
142 {
143 /*
144 * successful get bindata
145 * Create a dict
146 * Create some bindata containing "bindata" and add it to the dict with name = "bindata"
147 * Call getdns_dict_get_bindata() against the first dict with name = "bindata"
148 * expect: retrieved bindata should == "bindata"
149 */
150 struct getdns_dict *this_dict = NULL;
151 struct getdns_bindata bindata = { 8, (void *)"bindata" };
152 struct getdns_bindata *answer = NULL;
153
154 DICT_CREATE(this_dict);
155
156 ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata),
157 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
158
159 ASSERT_RC(getdns_dict_get_bindata(this_dict, "bindata", &answer),
160 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_bindata()");
161
162 ck_assert_msg(answer->size == bindata.size, "Expected bindata size == %d, got: %d",
163 bindata.size, answer->size);
164 ck_assert_msg(strcmp((char *)answer->data, (char *)bindata.data) == 0,
165 "Expected bindata data to be \"%s\", got: \"%s\"",
166 (char *)bindata.data, (char *)answer->data);
167
168 DICT_DESTROY(this_dict);
169 }
170 END_TEST
171
172 Suite *
173 getdns_dict_get_bindata_suite (void)
174 {
175 Suite *s = suite_create ("getdns_dict_get_bindata()");
176
177 /* Negative test caseis */
178 TCase *tc_neg = tcase_create("Negative");
179 tcase_add_test(tc_neg, getdns_dict_get_bindata_1);
180 tcase_add_test(tc_neg, getdns_dict_get_bindata_2);
181 tcase_add_test(tc_neg, getdns_dict_get_bindata_3);
182 tcase_add_test(tc_neg, getdns_dict_get_bindata_4);
183 tcase_add_test(tc_neg, getdns_dict_get_bindata_5);
184 suite_add_tcase(s, tc_neg);
185
186 /* Positive test cases */
187 TCase *tc_pos = tcase_create("Positive");
188 tcase_add_test(tc_pos, getdns_dict_get_bindata_6);
189 suite_add_tcase(s, tc_pos);
190
191 return s;
192 }
193
194 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_dict_get_data_type_h_
27 #define _check_getdns_dict_get_data_type_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ D I C T _ G E T _ D A T A _ T Y P E *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_dict_get_data_type_1)
38 {
39 /*
40 * this_dict = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_dict *this_dict = NULL;
44 getdns_data_type answer;
45
46 ASSERT_RC(getdns_dict_get_data_type(this_dict, "key", &answer),
47 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_data_type()");
48
49 }
50 END_TEST
51
52 START_TEST (getdns_dict_get_data_type_2)
53 {
54 /*
55 * name = NULL
56 * expect: GETDNS_RETURN_INVALID_PARAMETER
57 */
58 struct getdns_dict *this_dict = NULL;
59 getdns_data_type answer;
60
61 DICT_CREATE(this_dict);
62 ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10),
63 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
64
65 ASSERT_RC(getdns_dict_get_data_type(this_dict, NULL, &answer),
66 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_data_type()");
67
68 DICT_DESTROY(this_dict);
69
70 }
71 END_TEST
72
73 START_TEST (getdns_dict_get_data_type_3)
74 {
75 /*
76 * name does not exist in dict
77 * Create a dict with three keys ("ten" = 10, "eleven" = 11, "twelve" = 12)
78 * Call getdns_dict_get_data_type() with name = "nine"
79 * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME
80 */
81 struct getdns_dict *this_dict = NULL;
82 char *keys[3] = { "ten", "eleven", "twelve" };
83 uint32_t values[3] = { 10, 11, 12 };
84 int i;
85 getdns_data_type answer;
86
87 DICT_CREATE(this_dict);
88
89 for(i = 0; i < 3; i++)
90 {
91 ASSERT_RC(getdns_dict_set_int(this_dict, keys[i], values[i]),
92 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
93 }
94
95 ASSERT_RC(getdns_dict_get_data_type(this_dict, "nine", &answer),
96 GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_dict_get_names()");
97
98 DICT_DESTROY(this_dict);
99 }
100 END_TEST
101
102 START_TEST (getdns_dict_get_data_type_4)
103 {
104 /*
105 * answer = NULL
106 * expect: GETDNS_RETURN_INVALID_PARAMETER
107 */
108 struct getdns_dict *this_dict = NULL;
109
110 DICT_CREATE(this_dict);
111 ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10),
112 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
113
114 ASSERT_RC(getdns_dict_get_data_type(this_dict, "ten", NULL),
115 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_names()");
116
117 DICT_DESTROY(this_dict);
118 }
119 END_TEST
120
121 START_TEST (getdns_dict_get_data_type_5)
122 {
123 /*
124 * data type is dict
125 * Create a dict
126 * Create a second dict and add it to the first as name = "dict"
127 * Call getdns_dict_get_data_type() for name = "dict"
128 * expect: GETDNS_RETURN_GOOD
129 * retrieved answer should = t_dict
130 */
131 struct getdns_dict *this_dict = NULL;
132 struct getdns_dict *second_dict = NULL;
133 getdns_data_type answer;
134
135 DICT_CREATE(this_dict);
136 DICT_CREATE(second_dict);
137 ASSERT_RC(getdns_dict_set_dict(this_dict, "dict", second_dict),
138 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
139
140 ASSERT_RC(getdns_dict_get_data_type(this_dict, "dict", &answer),
141 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_data_type()");
142
143 ck_assert_msg(answer == t_dict, "Expected answer = t_dict (%d), got: %d", t_dict, answer);
144
145 DICT_DESTROY(this_dict);
146 DICT_DESTROY(second_dict);
147 }
148 END_TEST
149
150 START_TEST (getdns_dict_get_data_type_6)
151 {
152 /*
153 * data type is list
154 * Create a dict
155 * Create a list and add it to the dict as name = "list"
156 * Call getdns_dict_get_data_type() for name = "list"
157 * expect: GETDNS_RETURN_GOOD
158 * retrieved answer should = t_list
159 */
160 struct getdns_dict *this_dict = NULL;
161 struct getdns_list *list = NULL;
162 getdns_data_type answer;
163
164 DICT_CREATE(this_dict);
165 LIST_CREATE(list);
166 ASSERT_RC(getdns_dict_set_list(this_dict, "list", list),
167 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
168
169 ASSERT_RC(getdns_dict_get_data_type(this_dict, "list", &answer),
170 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_data_type()");
171
172 ck_assert_msg(answer == t_list, "Expected answer = t_list (%d), got: %d", t_list, answer);
173
174 DICT_DESTROY(this_dict);
175 LIST_DESTROY(list);
176 }
177 END_TEST
178
179 START_TEST (getdns_dict_get_data_type_7)
180 {
181 /*
182 * data type is bindata
183 * Create a dict
184 * Create some bindata and add it to the dict as name = "bindata"
185 * Call getdns_dict_get_data_type() for name = "bindata"
186 * expect: GETDNS_RETURN_GOOD
187 * retrieved answer should = t_bindata
188 */
189 struct getdns_dict *this_dict = NULL;
190 struct getdns_bindata bindata = { 8, (void *)"bindata" };
191 getdns_data_type answer;
192
193 DICT_CREATE(this_dict);
194 ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata),
195 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
196
197 ASSERT_RC(getdns_dict_get_data_type(this_dict, "bindata", &answer),
198 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_data_type()");
199
200 ck_assert_msg(answer == t_bindata, "Expected answer = t_bindata (%d), got: %d", t_bindata, answer);
201
202 DICT_DESTROY(this_dict);
203 }
204 END_TEST
205
206 START_TEST (getdns_dict_get_data_type_8)
207 {
208 /*
209 * data type is int
210 * Create a dict
211 * Add an int to the dict as name = "int"
212 * Call getdns_dict_get_data_type() for name = "int"
213 * expect: GETDNS_RETURN_GOOD
214 * retrieved answer should = t_int
215 */
216 struct getdns_dict *this_dict = NULL;
217 getdns_data_type answer;
218
219 DICT_CREATE(this_dict);
220 ASSERT_RC(getdns_dict_set_int(this_dict, "int", 100),
221 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
222
223 ASSERT_RC(getdns_dict_get_data_type(this_dict, "int", &answer),
224 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_data_type()");
225
226 ck_assert_msg(answer == t_int, "Expected answer = t_int (%d), got: %d", t_int, answer);
227
228 DICT_DESTROY(this_dict);
229 }
230 END_TEST
231
232 Suite *
233 getdns_dict_get_data_type_suite (void)
234 {
235 Suite *s = suite_create ("getdns_dict_get_data_type()");
236
237 /* Negative test caseis */
238 TCase *tc_neg = tcase_create("Negative");
239 tcase_add_test(tc_neg, getdns_dict_get_data_type_1);
240 tcase_add_test(tc_neg, getdns_dict_get_data_type_2);
241 tcase_add_test(tc_neg, getdns_dict_get_data_type_3);
242 tcase_add_test(tc_neg, getdns_dict_get_data_type_4);
243 suite_add_tcase(s, tc_neg);
244
245 /* Positive test cases */
246 TCase *tc_pos = tcase_create("Positive");
247 tcase_add_test(tc_pos, getdns_dict_get_data_type_5);
248 tcase_add_test(tc_pos, getdns_dict_get_data_type_6);
249 tcase_add_test(tc_pos, getdns_dict_get_data_type_7);
250 tcase_add_test(tc_pos, getdns_dict_get_data_type_8);
251 suite_add_tcase(s, tc_pos);
252
253 return s;
254 }
255
256 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_dict_get_dict_h_
27 #define _check_getdns_dict_get_dict_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ D I C T _ G E T _ D I C T *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_dict_get_dict_1)
38 {
39 /*
40 * this_dict = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_dict *this_dict = NULL;
44 struct getdns_dict *answer = NULL;
45
46 ASSERT_RC(getdns_dict_get_dict(this_dict, "key", &answer),
47 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_dict()");
48
49 }
50 END_TEST
51
52 START_TEST (getdns_dict_get_dict_2)
53 {
54 /*
55 * name = NULL
56 * expect: GETDNS_RETURN_INVALID_PARAMETER
57 */
58 struct getdns_dict *this_dict = NULL;
59 struct getdns_dict *second_dict = NULL;
60 struct getdns_dict *answer = NULL;
61
62 DICT_CREATE(this_dict);
63 DICT_CREATE(second_dict);
64 ASSERT_RC(getdns_dict_set_dict(this_dict, "dict", second_dict),
65 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
66
67 ASSERT_RC(getdns_dict_get_dict(this_dict, NULL, &answer),
68 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_dict()");
69
70 DICT_DESTROY(this_dict);
71 DICT_DESTROY(second_dict);
72 }
73 END_TEST
74
75 START_TEST (getdns_dict_get_dict_3)
76 {
77 /*
78 * name does not exist in dict
79 * Create a dict
80 * Create a second dict with three ints ("ten" = 10, "eleven" = 11, "twelve" = 12)
81 * Add the second dict to the first dict as name = "numbers"
82 * Call getdns_dict_get_dict() against the first dict with name = "letters"
83 * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME
84 */
85 struct getdns_dict *this_dict = NULL;
86 struct getdns_dict *second_dict = NULL;
87 char *keys[3] = { "ten", "eleven", "twelve" };
88 uint32_t values[3] = { 10, 11, 12 };
89 int i;
90 struct getdns_dict *answer = NULL;
91
92 DICT_CREATE(this_dict);
93 DICT_CREATE(second_dict);
94
95 for(i = 0; i < 3; i++)
96 {
97 ASSERT_RC(getdns_dict_set_int(second_dict, keys[i], values[i]),
98 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
99 }
100
101 ASSERT_RC(getdns_dict_set_dict(this_dict, "numbers", second_dict),
102 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
103
104 ASSERT_RC(getdns_dict_get_dict(this_dict, "letters", &answer),
105 GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_dict_get_dict()");
106
107 DICT_DESTROY(this_dict);
108 DICT_DESTROY(second_dict);
109 }
110 END_TEST
111
112 START_TEST (getdns_dict_get_dict_4)
113 {
114 /*
115 * data type at name is not a dict
116 * Create a dict with one int (name = "ten", value = 10)
117 * Call getdns_dict_get_dict() with name = "ten"
118 * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
119 */
120 struct getdns_dict *this_dict = NULL;
121 struct getdns_dict *answer = NULL;
122
123 DICT_CREATE(this_dict);
124
125 ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10),
126 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
127
128 ASSERT_RC(getdns_dict_get_dict(this_dict, "ten", &answer),
129 GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_dict_get_dict()");
130
131 DICT_DESTROY(this_dict);
132 }
133 END_TEST
134
135 START_TEST (getdns_dict_get_dict_5)
136 {
137 /*
138 * answer = NULL
139 * expect: GETDNS_RETURN_INVALID_PARAMETER
140 */
141 struct getdns_dict *this_dict = NULL;
142 struct getdns_dict *second_dict = NULL;
143
144 DICT_CREATE(this_dict);
145 DICT_CREATE(second_dict);
146
147 ASSERT_RC(getdns_dict_set_dict(this_dict, "dict", second_dict),
148 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
149
150 ASSERT_RC(getdns_dict_get_dict(this_dict, "dict", NULL),
151 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_dict()");
152
153 DICT_DESTROY(this_dict);
154 DICT_DESTROY(second_dict);
155 }
156 END_TEST
157
158 START_TEST (getdns_dict_get_dict_6)
159 {
160 /*
161 * successful get dict
162 * Create a dict
163 * Create a second dict with three ints ("ten" = 10, "eleven" = 11, "twelve" = 12)
164 * Add the second dict to the first dict as name = "numbers"
165 * Call getdns_dict_get_dict() against the first dict for name = "numbers"
166 * Call getdns_dict_get_names() against the retrieved "numbers" dict to get a list of names
167 * Call getdns_list_get_length() against the returned list to set a loop counter
168 * Iterate through the names in the list and add the int value from each key to sum
169 * expect: sum == 33
170 */
171 struct getdns_dict *this_dict = NULL;
172 struct getdns_dict *second_dict = NULL;
173 char *keys[3] = { "ten", "eleven", "twelve" };
174 uint32_t values[3] = { 10, 11, 12 };
175 size_t i;
176 uint32_t sum_of_values = 0;
177 struct getdns_dict *answer = NULL;
178 struct getdns_list *names = NULL;
179 size_t length;
180 struct getdns_bindata *bindata = NULL;
181 uint32_t value;
182 uint32_t sum = 0;
183
184 DICT_CREATE(this_dict);
185 DICT_CREATE(second_dict);
186
187 for(i = 0; i < 3; i++)
188 {
189 ASSERT_RC(getdns_dict_set_int(second_dict, keys[i], values[i]),
190 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
191 sum_of_values += values[i];
192 }
193
194 ASSERT_RC(getdns_dict_set_dict(this_dict, "numbers", second_dict),
195 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
196
197 ASSERT_RC(getdns_dict_get_dict(this_dict, "numbers", &answer),
198 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_dict()");
199
200 ASSERT_RC(getdns_dict_get_names(answer, &names),
201 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_names()");
202
203 ASSERT_RC(getdns_list_get_length(names, &length),
204 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()");
205
206 for(i = 0; i < length; i++)
207 {
208 ASSERT_RC(getdns_list_get_bindata(names, i, &bindata),
209 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_bindata()");
210 ASSERT_RC(getdns_dict_get_int(answer, (char *)bindata->data, &value),
211 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()");
212 sum += value;
213 }
214
215 ck_assert_msg(sum == sum_of_values, "Sum of int values in dict should == %d, got: %d",
216 sum_of_values, sum);
217
218 LIST_DESTROY(names);
219 DICT_DESTROY(this_dict);
220 DICT_DESTROY(second_dict);
221 }
222 END_TEST
223
224 Suite *
225 getdns_dict_get_dict_suite (void)
226 {
227 Suite *s = suite_create ("getdns_dict_get_dict()");
228
229 /* Negative test caseis */
230 TCase *tc_neg = tcase_create("Negative");
231 tcase_add_test(tc_neg, getdns_dict_get_dict_1);
232 tcase_add_test(tc_neg, getdns_dict_get_dict_2);
233 tcase_add_test(tc_neg, getdns_dict_get_dict_3);
234 tcase_add_test(tc_neg, getdns_dict_get_dict_4);
235 tcase_add_test(tc_neg, getdns_dict_get_dict_5);
236 suite_add_tcase(s, tc_neg);
237
238 /* Positive test cases */
239 TCase *tc_pos = tcase_create("Positive");
240 tcase_add_test(tc_pos, getdns_dict_get_dict_6);
241 suite_add_tcase(s, tc_pos);
242
243 return s;
244 }
245
246 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_dict_get_int_h_
27 #define _check_getdns_dict_get_int_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ D I C T _ G E T _ I N T *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_dict_get_int_1)
38 {
39 /*
40 * this_dict = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_dict *this_dict = NULL;
44 uint32_t answer;
45
46 ASSERT_RC(getdns_dict_get_int(this_dict, "key", &answer),
47 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_int()");
48
49 }
50 END_TEST
51
52 START_TEST (getdns_dict_get_int_2)
53 {
54 /*
55 * name = NULL
56 * expect: GETDNS_RETURN_INVALID_PARAMETER
57 */
58 struct getdns_dict *this_dict = NULL;
59 uint32_t answer;
60
61 DICT_CREATE(this_dict);
62 ASSERT_RC(getdns_dict_set_int(this_dict, "int", 10),
63 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
64
65 ASSERT_RC(getdns_dict_get_int(this_dict, NULL, &answer),
66 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_int()");
67
68 DICT_DESTROY(this_dict);
69 }
70 END_TEST
71
72 START_TEST (getdns_dict_get_int_3)
73 {
74 /*
75 * name does not exist in dict
76 * Create a dict with one int (name = "ten", value = 10)
77 * Call getdns_dict_get_int() against the dict with name = "nine"
78 * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME
79 */
80 struct getdns_dict *this_dict = NULL;
81 uint32_t answer;
82
83 DICT_CREATE(this_dict);
84 ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10),
85 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
86
87 ASSERT_RC(getdns_dict_get_int(this_dict, "nine", &answer),
88 GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_dict_get_int()");
89
90 DICT_DESTROY(this_dict);
91 }
92 END_TEST
93
94 START_TEST (getdns_dict_get_int_4)
95 {
96 /*
97 * data type at name is not int
98 * Create a dict
99 * Create some bindata containing "bindata" and add it to the dict with name = "bindata"
100 * Call getdns_dict_get_int() with name = "bindata"
101 * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
102 */
103 struct getdns_dict *this_dict = NULL;
104 struct getdns_bindata bindata = { 8, (void *)"bindata" };
105 uint32_t answer;
106
107 DICT_CREATE(this_dict);
108
109 ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata),
110 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
111
112 ASSERT_RC(getdns_dict_get_int(this_dict, "bindata", &answer),
113 GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_dict_get_int()");
114
115 DICT_DESTROY(this_dict);
116 }
117 END_TEST
118
119 START_TEST (getdns_dict_get_int_5)
120 {
121 /*
122 * answer = NULL
123 * expect: GETDNS_RETURN_INVALID_PARAMETER
124 */
125 struct getdns_dict *this_dict = NULL;
126
127 DICT_CREATE(this_dict);
128
129 ASSERT_RC(getdns_dict_set_int(this_dict, "int", 10),
130 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
131
132 ASSERT_RC(getdns_dict_get_int(this_dict, "int", NULL),
133 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_int()");
134
135 DICT_DESTROY(this_dict);
136 }
137 END_TEST
138
139 START_TEST (getdns_dict_get_int_6)
140 {
141 /*
142 * successful get int
143 * Create a dict with one int (name = "ten", value = 10)
144 * Call getdns_dict_get_int() against the dict with name = "ten"
145 * expect: GETDNS_RETURN_GOOD
146 * int retrievedshould == 10
147 *
148 */
149 struct getdns_dict *this_dict = NULL;
150 uint32_t answer;
151
152 DICT_CREATE(this_dict);
153
154 ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10),
155 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
156
157 ASSERT_RC(getdns_dict_get_int(this_dict, "ten", &answer),
158 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()");
159
160 ck_assert_msg(answer == 10, "Expected retrieve int == 10, got: %d",
161 answer);
162
163 DICT_DESTROY(this_dict);
164 }
165 END_TEST
166
167 Suite *
168 getdns_dict_get_int_suite (void)
169 {
170 Suite *s = suite_create ("getdns_dict_get_int()");
171
172 /* Negative test caseis */
173 TCase *tc_neg = tcase_create("Negative");
174 tcase_add_test(tc_neg, getdns_dict_get_int_1);
175 tcase_add_test(tc_neg, getdns_dict_get_int_2);
176 tcase_add_test(tc_neg, getdns_dict_get_int_3);
177 tcase_add_test(tc_neg, getdns_dict_get_int_4);
178 tcase_add_test(tc_neg, getdns_dict_get_int_5);
179 suite_add_tcase(s, tc_neg);
180
181 /* Positive test cases */
182 TCase *tc_pos = tcase_create("Positive");
183 tcase_add_test(tc_pos, getdns_dict_get_int_6);
184 suite_add_tcase(s, tc_pos);
185
186 return s;
187 }
188
189 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_dict_get_list_h_
27 #define _check_getdns_dict_get_list_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ D I C T _ G E T _ L I S T *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_dict_get_list_1)
38 {
39 /*
40 * this_dict = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_dict *this_dict = NULL;
44 struct getdns_list *answer = NULL;
45
46 ASSERT_RC(getdns_dict_get_list(this_dict, "key", &answer),
47 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_list()");
48
49 }
50 END_TEST
51
52 START_TEST (getdns_dict_get_list_2)
53 {
54 /*
55 * name = NULL
56 * expect: GETDNS_RETURN_INVALID_PARAMETER
57 */
58 struct getdns_dict *this_dict = NULL;
59 struct getdns_list *list = NULL;
60 struct getdns_list *answer = NULL;
61
62 DICT_CREATE(this_dict);
63 LIST_CREATE(list);
64 ASSERT_RC(getdns_dict_set_list(this_dict, "list", list),
65 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
66
67 ASSERT_RC(getdns_dict_get_list(this_dict, NULL, &answer),
68 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_list()");
69
70 DICT_DESTROY(this_dict);
71 LIST_DESTROY(list);
72 }
73 END_TEST
74
75 START_TEST (getdns_dict_get_list_3)
76 {
77 /*
78 * name does not exist in dict
79 * Create a dict with three ints ("ten" = 10, "eleven" = 11, "twelve" = 12)
80 * Call getdns_dict_get_list() against the first dict with name = "nine"
81 * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME
82 */
83 struct getdns_dict *this_dict = NULL;
84 char *keys[3] = { "ten", "eleven", "twelve" };
85 uint32_t values[3] = { 10, 11, 12 };
86 int i;
87 struct getdns_list *answer = NULL;
88
89 DICT_CREATE(this_dict);
90
91 for(i = 0; i < 3; i++)
92 {
93 ASSERT_RC(getdns_dict_set_int(this_dict, keys[i], values[i]),
94 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
95 }
96
97 ASSERT_RC(getdns_dict_get_list(this_dict, "nine", &answer),
98 GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_dict_get_list()");
99
100 DICT_DESTROY(this_dict);
101 }
102 END_TEST
103
104 START_TEST (getdns_dict_get_list_4)
105 {
106 /*
107 * data type at name is not a list
108 * Create a dict with one int (name = "ten", value = 10)
109 * Call getdns_dict_get_list() with name = "ten"
110 * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
111 */
112 struct getdns_dict *this_dict = NULL;
113 struct getdns_list *answer = NULL;
114
115 DICT_CREATE(this_dict);
116
117 ASSERT_RC(getdns_dict_set_int(this_dict, "ten", 10),
118 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
119
120 ASSERT_RC(getdns_dict_get_list(this_dict, "ten", &answer),
121 GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_dict_get_list()");
122
123 DICT_DESTROY(this_dict);
124 }
125 END_TEST
126
127 START_TEST (getdns_dict_get_list_5)
128 {
129 /*
130 * answer = NULL
131 * expect: GETDNS_RETURN_INVALID_PARAMETER
132 */
133 struct getdns_dict *this_dict = NULL;
134 struct getdns_list *list = NULL;
135
136 DICT_CREATE(this_dict);
137 LIST_CREATE(list);
138
139 ASSERT_RC(getdns_dict_set_list(this_dict, "list", list),
140 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
141
142 ASSERT_RC(getdns_dict_get_list(this_dict, "list", NULL),
143 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_list()");
144
145 DICT_DESTROY(this_dict);
146 LIST_DESTROY(list);
147 }
148 END_TEST
149
150 START_TEST (getdns_dict_get_list_6)
151 {
152 /*
153 * successful get list
154 * Create a dict
155 * Create a list and set index 0 to an int with a value of 100
156 * Add the list to the dict as name "list"
157 * Call getdns_dict_get_list() against the dict for name = "list"
158 * Call getdns_list_set_int() for index 0
159 * expect: int retrieved = 100
160 */
161 struct getdns_dict *this_dict = NULL;
162 struct getdns_list *list = NULL;
163 struct getdns_list *answer = NULL;
164 uint32_t value;
165
166 DICT_CREATE(this_dict);
167 LIST_CREATE(list);
168
169 ASSERT_RC(getdns_list_set_int(list, 0, 100),
170 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
171
172 ASSERT_RC(getdns_dict_set_list(this_dict, "list", list),
173 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
174
175 ASSERT_RC(getdns_dict_get_list(this_dict, "list", &answer),
176 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_list()");
177
178 ASSERT_RC(getdns_list_get_int(answer, 0, &value),
179 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_int()");
180
181 ck_assert_msg(value == 100, "Expected int retrieved == 100, got: %d", value);
182
183 DICT_DESTROY(this_dict);
184 LIST_DESTROY(list);
185 }
186 END_TEST
187
188 Suite *
189 getdns_dict_get_list_suite (void)
190 {
191 Suite *s = suite_create ("getdns_dict_get_list()");
192
193 /* Negative test caseis */
194 TCase *tc_neg = tcase_create("Negative");
195 tcase_add_test(tc_neg, getdns_dict_get_list_1);
196 tcase_add_test(tc_neg, getdns_dict_get_list_2);
197 tcase_add_test(tc_neg, getdns_dict_get_list_3);
198 tcase_add_test(tc_neg, getdns_dict_get_list_4);
199 tcase_add_test(tc_neg, getdns_dict_get_list_5);
200 suite_add_tcase(s, tc_neg);
201
202 /* Positive test cases */
203 TCase *tc_pos = tcase_create("Positive");
204 tcase_add_test(tc_pos, getdns_dict_get_list_6);
205 suite_add_tcase(s, tc_pos);
206
207 return s;
208 }
209
210 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_dict_get_names_h_
27 #define _check_getdns_dict_get_names_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ D I C T _ G E T _ N A M E S *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_dict_get_names_1)
38 {
39 /*
40 * this_dict = NULL
41 * expect = GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_dict *this_dict = NULL;
44 struct getdns_list *answer = NULL;
45
46 ASSERT_RC(getdns_dict_get_names(this_dict, &answer),
47 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_names()");
48
49 }
50 END_TEST
51
52 START_TEST (getdns_dict_get_names_2)
53 {
54 /*
55 * answer = NULL
56 * expect: GETDNS_RETURN_INVALID_PARAMETER
57 */
58 struct getdns_dict *this_dict = NULL;
59
60 DICT_CREATE(this_dict);
61
62 ASSERT_RC(getdns_dict_get_names(this_dict, NULL),
63 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_get_names()");
64
65 DICT_DESTROY(this_dict);
66 }
67 END_TEST
68
69 START_TEST (getdns_dict_get_names_3)
70 {
71 /*
72 * Create a dict with three keys ("ten" = 10, "eleven" = 11, "twelve" = 12)
73 * Call getdns_dict_get_names()
74 * Iterate through list and append names together in a single string
75 * expect: string == "teneleventwelve"
76 */
77 struct getdns_dict *this_dict = NULL;
78 struct getdns_list *answer = NULL;
79 char *keys[3] = { "ten", "eleven", "twelve" };
80 uint32_t values[3] = { 10, 11, 12 };
81 int i;
82 size_t length;
83 struct getdns_bindata *key = NULL;
84 char string_buffer[20] = "";
85
86 DICT_CREATE(this_dict);
87
88 for(i = 0; i < 3; i++)
89 {
90 ASSERT_RC(getdns_dict_set_int(this_dict, keys[i], values[i]),
91 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
92 }
93
94 ASSERT_RC(getdns_dict_get_names(this_dict, &answer),
95 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_names()");
96
97 ASSERT_RC(getdns_list_get_length(answer, &length),
98 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()");
99
100 ck_assert_msg(length == 3, "Expected length == 3, got %d", length);
101
102 for(i = 0; i < length; i++)
103 {
104 ASSERT_RC(getdns_list_get_bindata(answer, i, &key),
105 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_bindata()");
106 /* concatenate strings, if enough buffer space */
107 if(strlen(string_buffer) + strlen((char*)key->data) + 1
108 < sizeof(string_buffer)) {
109 memmove(string_buffer+strlen(string_buffer), key->data,
110 strlen((char*)key->data)+1);
111 }
112 }
113
114 ck_assert_msg(strcmp(string_buffer, "elevententwelve") == 0,
115 "Expected concatenated names to be \"elevententwelve\", got \"%s\"", string_buffer);
116
117 LIST_DESTROY(answer);
118 DICT_DESTROY(this_dict);
119 }
120 END_TEST
121
122 Suite *
123 getdns_dict_get_names_suite (void)
124 {
125 Suite *s = suite_create ("getdns_dict_get_names()");
126
127 /* Negative test caseis */
128 TCase *tc_neg = tcase_create("Negative");
129 tcase_add_test(tc_neg, getdns_dict_get_names_1);
130 tcase_add_test(tc_neg, getdns_dict_get_names_2);
131 suite_add_tcase(s, tc_neg);
132
133 /* Positive test cases */
134 TCase *tc_pos = tcase_create("Positive");
135 tcase_add_test(tc_pos, getdns_dict_get_names_3);
136 suite_add_tcase(s, tc_pos);
137
138 return s;
139 }
140
141 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_dict_set_bindata_h_
27 #define _check_getdns_dict_set_bindata_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ D I C T _ S E T _ B I N D A T A *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_dict_set_bindata_1)
38 {
39 /*
40 * this_dict = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_dict *this_dict = NULL;
44 struct getdns_bindata bindata = { 8, (void *)"bindata" };
45
46 ASSERT_RC(getdns_dict_set_bindata(this_dict, "key", &bindata),
47 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_bindata()");
48
49 }
50 END_TEST
51
52 START_TEST (getdns_dict_set_bindata_2)
53 {
54 /*
55 * name = NULL
56 * expect: GETDNS_RETURN_INVALID_PARAMETER
57 */
58 struct getdns_dict *this_dict = NULL;
59 struct getdns_bindata bindata = { 8, (void *)"bindata" };
60
61 DICT_CREATE(this_dict);
62
63 ASSERT_RC(getdns_dict_set_bindata(this_dict, NULL, &bindata),
64 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_bindata()");
65
66 DICT_DESTROY(this_dict);
67 }
68 END_TEST
69
70 START_TEST (getdns_dict_set_bindata_3)
71 {
72 /*
73 * child_bindata = NULL
74 * expect: GETDNS_RETURN_INVALID_PARAMETER
75 */
76 struct getdns_dict *this_dict = NULL;
77
78 DICT_CREATE(this_dict);
79
80 ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", NULL),
81 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_bindata()");
82
83 DICT_DESTROY(this_dict);
84 }
85 END_TEST
86
87 START_TEST (getdns_dict_set_bindata_4)
88 {
89 /*
90 * name already exists in dict
91 * Create a dict
92 * Add bindata to the dict (name = "bindata", value = { 8, "bindata" })
93 * Add bindata to the dict (name = "bindata", value = { 15, "second_bindata" })
94 * Call getdns_dict_get_bindata() with name = "bindata"
95 * expect: GETDNS_RETURN_GOOD (all functions)
96 * bindata retrieved = "second_bindata"
97 */
98 struct getdns_dict *this_dict = NULL;
99 struct getdns_bindata bindata = { 8, (void *)"bindata" };
100 struct getdns_bindata second_bindata = { 15, (void *)"second_bindata" };
101 struct getdns_bindata *retrieved_bindata = NULL;
102
103 DICT_CREATE(this_dict);
104
105 ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata),
106 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
107
108 ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &second_bindata),
109 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
110
111 ASSERT_RC(getdns_dict_get_bindata(this_dict, "bindata", &retrieved_bindata),
112 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_bindata()");
113
114 ck_assert_msg(retrieved_bindata->size, second_bindata.size,
115 "Expected retrieved bindata size == %d, got: %d",
116 second_bindata.size, retrieved_bindata->size);
117
118 ck_assert_msg(strcmp((char *)retrieved_bindata->data, (char *)second_bindata.data) == 0,
119 "Expected retrieved bindata to be \"%s\", got: \"%s\"",
120 (char *)second_bindata.data, (char *)retrieved_bindata->data);
121
122 DICT_DESTROY(this_dict);
123 }
124 END_TEST
125
126 START_TEST (getdns_dict_set_bindata_5)
127 {
128 /*
129 * name already exists in dict, changing data type
130 * Create a dict
131 * Add an int to the dict (name = "int", value = 100)
132 * Add bindata to the dict (name = "int", value = { 8, "bindata" })
133 * Call getdns_dict_get_bindata() against the dict with name = "int"
134 * expect: GETDNS_RETURN_GOOD (all functions)
135 * retrieved bindata should == "bindata"
136 */
137 struct getdns_dict *this_dict = NULL;
138 struct getdns_bindata bindata = { 8, (void *)"bindata" };
139 struct getdns_bindata *retrieved_bindata = NULL;
140
141 DICT_CREATE(this_dict);
142
143 ASSERT_RC(getdns_dict_set_int(this_dict, "int", 100),
144 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
145
146 ASSERT_RC(getdns_dict_set_bindata(this_dict, "int", &bindata),
147 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
148
149 ASSERT_RC(getdns_dict_get_bindata(this_dict, "int", &retrieved_bindata),
150 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_bindata()");
151
152 ck_assert_msg(retrieved_bindata->size == bindata.size,
153 "Expected retrieved bindata size == %d, got: %d",
154 bindata.size, retrieved_bindata->size);
155
156 ck_assert_msg(strcmp((char *)retrieved_bindata->data, (char *)bindata.data) == 0,
157 "Expected bindata data to be \"%s\", got: \"%s\"",
158 (char *)bindata.data, (char *)retrieved_bindata->data);
159
160 DICT_DESTROY(this_dict);
161 }
162 END_TEST
163
164 Suite *
165 getdns_dict_set_bindata_suite (void)
166 {
167 Suite *s = suite_create ("getdns_dict_set_bindata()");
168
169 /* Negative test caseis */
170 TCase *tc_neg = tcase_create("Negative");
171 tcase_add_test(tc_neg, getdns_dict_set_bindata_1);
172 tcase_add_test(tc_neg, getdns_dict_set_bindata_2);
173 tcase_add_test(tc_neg, getdns_dict_set_bindata_3);
174 suite_add_tcase(s, tc_neg);
175
176 /* Positive test cases */
177 TCase *tc_pos = tcase_create("Positive");
178 tcase_add_test(tc_pos, getdns_dict_set_bindata_4);
179 tcase_add_test(tc_pos, getdns_dict_set_bindata_5);
180 suite_add_tcase(s, tc_pos);
181
182 return s;
183 }
184
185 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_dict_set_dict_h_
27 #define _check_getdns_dict_set_dict_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ D I C T _ S E T _ D I C T *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_dict_set_dict_1)
38 {
39 /*
40 * this_dict = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_dict *this_dict = NULL;
44 struct getdns_dict *child_dict = NULL;
45
46 DICT_CREATE(child_dict);
47 ASSERT_RC(getdns_dict_set_dict(this_dict, "dict", child_dict),
48 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_dict()");
49 DICT_DESTROY(child_dict);
50
51 }
52 END_TEST
53
54 START_TEST (getdns_dict_set_dict_2)
55 {
56 /*
57 * name= NULL
58 * expect: GETDNS_RETURN_INVALID_PARAMETER
59 */
60 struct getdns_dict *this_dict = NULL;
61 struct getdns_dict *child_dict = NULL;
62
63 DICT_CREATE(this_dict);
64 DICT_CREATE(child_dict);
65 ASSERT_RC(getdns_dict_set_dict(this_dict, NULL, child_dict),
66 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_dict()");
67
68 DICT_DESTROY(this_dict);
69 DICT_DESTROY(child_dict);
70
71 }
72 END_TEST
73
74 START_TEST (getdns_dict_set_dict_3)
75 {
76 /*
77 * child_dict = NULL
78 * expect: GETDNS_RETURN_INVALID_PARAMETER
79 */
80 struct getdns_dict *this_dict = NULL;
81 struct getdns_dict *child_dict = NULL;
82
83 DICT_CREATE(this_dict);
84 ASSERT_RC(getdns_dict_set_dict(this_dict, "dict", child_dict),
85 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_dict()");
86
87 DICT_DESTROY(this_dict);
88 }
89 END_TEST
90
91 START_TEST (getdns_dict_set_dict_4)
92 {
93 /*
94 * name already exists in dict
95 * Create a dict
96 * Create a second dict containing name = "int" with value = 100
97 * Add the second dict to the first dict as name = "dict"
98 * Create a third dict containing name = "int" with value = 101
99 * Add the third dict to the first dict as name = "dict"
100 * Call getdns_dict_get_dict() against the first dict with name = "dict"
101 * Call getdns_dict_get_int() against the retrieved dict for name = "int"
102 * expect: GETDNS_RETURN_GOOD (all functions)
103 * retrieved int should = 101
104 */
105 struct getdns_dict *first_dict = NULL;
106 struct getdns_dict *second_dict = NULL;
107 struct getdns_dict *third_dict = NULL;
108 struct getdns_dict *answer = NULL;
109 uint32_t retrieved_int;
110
111 DICT_CREATE(first_dict);
112
113 DICT_CREATE(second_dict);
114 ASSERT_RC(getdns_dict_set_int(second_dict, "int", 100),
115 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
116 ASSERT_RC(getdns_dict_set_dict(first_dict, "dict", second_dict),
117 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
118
119 DICT_CREATE(third_dict);
120 ASSERT_RC(getdns_dict_set_int(third_dict, "int", 101),
121 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
122 ASSERT_RC(getdns_dict_set_dict(first_dict, "dict", third_dict),
123 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
124
125 ASSERT_RC(getdns_dict_get_dict(first_dict, "dict", &answer),
126 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_dict()");
127
128 ASSERT_RC(getdns_dict_get_int(answer, "int", &retrieved_int),
129 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()");
130
131 ck_assert_msg(retrieved_int == 101, "Exepected retrieved int == 101, got: %d",
132 retrieved_int);
133
134 DICT_DESTROY(first_dict);
135 DICT_DESTROY(second_dict);
136 DICT_DESTROY(third_dict);
137 }
138 END_TEST
139
140 START_TEST (getdns_dict_set_dict_5)
141 {
142 /*
143 * name already exists in dict, changing data type
144 * Create a dict
145 * Create a list
146 * Set list value at index 0 to int 100
147 * Add the list to the dict as name = "list"
148 * Create a second dict
149 * Add an int to the second dict with name = "int", value = 101
150 * Add the second dict to the first dict as name = "list"
151 * Call getdns_dict_get_dict to retrieve the second dict
152 * Call getdns_dict_get_int with name = "int"
153 * expect: GETDNS_RETURN_GOOD (all functions)
154 * retrieved int should = 101
155 */
156 struct getdns_dict *this_dict = NULL;
157 struct getdns_list *list = NULL;
158 struct getdns_dict *second_dict = NULL;
159 struct getdns_dict *answer = NULL;
160 uint32_t retrieved_int;
161
162 DICT_CREATE(this_dict);
163
164 LIST_CREATE(list);
165 ASSERT_RC(getdns_list_set_int(list, 0, 100),
166 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
167
168 ASSERT_RC(getdns_dict_set_list(this_dict, "list", list),
169 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
170
171 DICT_CREATE(second_dict);
172 ASSERT_RC(getdns_dict_set_int(second_dict, "int", 101),
173 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
174 ASSERT_RC(getdns_dict_set_dict(this_dict, "list", second_dict),
175 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
176
177 ASSERT_RC(getdns_dict_get_dict(this_dict, "list", &answer),
178 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_dict()");
179 ASSERT_RC(getdns_dict_get_int(answer, "int", &retrieved_int),
180 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()");
181
182 ck_assert_msg(retrieved_int == 101, "Exepected retrieved int == 101, got: %d",
183 retrieved_int);
184
185 DICT_DESTROY(this_dict);
186 LIST_DESTROY(list);
187 DICT_DESTROY(second_dict);
188 }
189 END_TEST
190
191 Suite *
192 getdns_dict_set_dict_suite (void)
193 {
194 Suite *s = suite_create ("getdns_dict_set_dict()");
195
196 /* Negative test caseis */
197 TCase *tc_neg = tcase_create("Negative");
198 tcase_add_test(tc_neg, getdns_dict_set_dict_1);
199 tcase_add_test(tc_neg, getdns_dict_set_dict_2);
200 tcase_add_test(tc_neg, getdns_dict_set_dict_3);
201 suite_add_tcase(s, tc_neg);
202
203 /* Positive test cases */
204 TCase *tc_pos = tcase_create("Positive");
205 tcase_add_test(tc_pos, getdns_dict_set_dict_4);
206 tcase_add_test(tc_pos, getdns_dict_set_dict_5);
207 suite_add_tcase(s, tc_pos);
208
209 return s;
210 }
211
212 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_dict_set_int_h_
27 #define _check_getdns_dict_set_int_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ D I C T _ S E T _ I N T *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_dict_set_int_1)
38 {
39 /*
40 * this_dict = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_dict *this_dict = NULL;
44
45 ASSERT_RC(getdns_dict_set_int(this_dict, "key", 100),
46 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_int()");
47
48 }
49 END_TEST
50
51 START_TEST (getdns_dict_set_int_2)
52 {
53 /*
54 * name = NULL
55 * expect: GETDNS_RETURN_INVALID_PARAMETER
56 */
57 struct getdns_dict *this_dict = NULL;
58
59 DICT_CREATE(this_dict);
60
61 ASSERT_RC(getdns_dict_set_int(this_dict, NULL, 100),
62 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_int()");
63
64 DICT_DESTROY(this_dict);
65 }
66 END_TEST
67
68 START_TEST (getdns_dict_set_int_3)
69 {
70 /*
71 * name already exists in dict
72 * Create a dict
73 * Add an int to the dict (name = "int", value = 100)
74 * Add an int to the dict (name = "int", value = 101)
75 * Call getdns_dict_get_int() against the dict with name = "int"
76 * expect: GETDNS_RETURN_GOOD (all functions)
77 * int retrieved should = 101
78 */
79 struct getdns_dict *this_dict = NULL;
80 uint32_t value;
81
82 DICT_CREATE(this_dict);
83
84 ASSERT_RC(getdns_dict_set_int(this_dict, "int", 100),
85 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
86
87 ASSERT_RC(getdns_dict_set_int(this_dict, "int", 101),
88 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
89
90 ASSERT_RC(getdns_dict_get_int(this_dict, "int", &value),
91 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()");
92
93 ck_assert_msg(value == 101, "Expected retrieved int == 101, got: %d",
94 value);
95
96 DICT_DESTROY(this_dict);
97 }
98 END_TEST
99
100 START_TEST (getdns_dict_set_int_4)
101 {
102 /*
103 * name already exists in dict, changing data type
104 * Create a dict
105 * Add bindata to the dict (name = "bindata", value = { 8, "bindata" })
106 * Add an int to the dict (name = "bindata", value = 101)
107 * Call getdns_dict_get_int() with name = "bindata"
108 * expect: GETDNS_RETURN_GOOD (all functions)
109 * int retrieved should = 101
110 */
111 struct getdns_dict *this_dict = NULL;
112 struct getdns_bindata bindata = { 8, (void *)"bindata" };
113 uint32_t value;
114
115 DICT_CREATE(this_dict);
116
117 ASSERT_RC(getdns_dict_set_bindata(this_dict, "bindata", &bindata),
118 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
119
120 ASSERT_RC(getdns_dict_set_int(this_dict, "bindata", 101),
121 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
122
123 ASSERT_RC(getdns_dict_get_int(this_dict, "bindata", &value),
124 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()");
125
126 ck_assert_msg(value == 101, "Expected retrieved int == 101, got: %d",
127 value);
128
129 DICT_DESTROY(this_dict);
130 }
131 END_TEST
132
133 Suite *
134 getdns_dict_set_int_suite (void)
135 {
136 Suite *s = suite_create ("getdns_dict_set_int()");
137
138 /* Negative test caseis */
139 TCase *tc_neg = tcase_create("Negative");
140 tcase_add_test(tc_neg, getdns_dict_set_int_1);
141 tcase_add_test(tc_neg, getdns_dict_set_int_2);
142 suite_add_tcase(s, tc_neg);
143
144 /* Positive test cases */
145 TCase *tc_pos = tcase_create("Positive");
146 tcase_add_test(tc_pos, getdns_dict_set_int_3);
147 tcase_add_test(tc_pos, getdns_dict_set_int_4);
148 suite_add_tcase(s, tc_pos);
149
150 return s;
151 }
152
153 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_dict_set_list_h_
27 #define _check_getdns_dict_set_list_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ D I C T _ S E T _ L I S T *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_dict_set_list_1)
38 {
39 /*
40 * this_dict = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_dict *this_dict = NULL;
44 struct getdns_list *list = NULL;
45
46 DICT_CREATE(this_dict);
47 ASSERT_RC(getdns_dict_set_list(this_dict, "list", list),
48 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_list()");
49
50 }
51 END_TEST
52
53 START_TEST (getdns_dict_set_list_2)
54 {
55 /*
56 * name = NULL
57 * expect: GETDNS_RETURN_INVALID_PARAMETER
58 */
59 struct getdns_dict *this_dict = NULL;
60 struct getdns_list *list = NULL;
61
62 DICT_CREATE(this_dict);
63 LIST_CREATE(list);
64 ASSERT_RC(getdns_dict_set_list(this_dict, NULL, list),
65 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_list()");
66
67 DICT_DESTROY(this_dict);
68 LIST_DESTROY(list);
69 }
70 END_TEST
71
72 START_TEST (getdns_dict_set_list_3)
73 {
74 /*
75 * child_list = NULL
76 * expect: GETDNS_RETURN_INVALID_PARAMETER
77 */
78 struct getdns_dict *this_dict = NULL;
79
80 DICT_CREATE(this_dict);
81 ASSERT_RC(getdns_dict_set_list(this_dict, "list", NULL),
82 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_dict_set_list()");
83
84 DICT_DESTROY(this_dict);
85 }
86 END_TEST
87
88 START_TEST (getdns_dict_set_list_4)
89 {
90 /*
91 * name already exists in dict
92 * Create a dict
93 * Create a list
94 * Set list value at index 0 via getdns_list_set_int() to 100
95 * Add the list to the dict as name "list"
96 * Create a second list
97 * Set list value at index 0 in the second list to 101
98 * Add the second list to the dict using name "list" again
99 * Call getdns_dict_get_list() against the dict with name = "list"
100 * Call getdns_list_get_int() for index 0 against the retrieved list
101 * expect: GETDNS_RETURN_GOOD (all functions)
102 * retrieved int should = 101
103 */
104 struct getdns_dict *this_dict = NULL;
105 struct getdns_list *first_list = NULL;
106 struct getdns_list *second_list = NULL;
107 struct getdns_list *retrieved_list = NULL;
108 uint32_t value;
109
110 DICT_CREATE(this_dict);
111
112 LIST_CREATE(first_list);
113 ASSERT_RC(getdns_list_set_int(first_list, 0, 100),
114 GETDNS_RETURN_GOOD, "Return from getdns_list_set_int()");
115
116 ASSERT_RC(getdns_dict_set_list(this_dict, "list", first_list),
117 GETDNS_RETURN_GOOD, "Return from getdns_list_set_list()");
118
119 LIST_CREATE(second_list);
120 ASSERT_RC(getdns_list_set_int(second_list, 0, 101),
121 GETDNS_RETURN_GOOD, "Return from getdns_list_set_int()");
122
123 ASSERT_RC(getdns_dict_set_list(this_dict, "list", second_list),
124 GETDNS_RETURN_GOOD, "Return from getdns_list_set_list()");
125
126 ASSERT_RC(getdns_dict_get_list(this_dict, "list", &retrieved_list),
127 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_list()");
128
129 ASSERT_RC(getdns_list_get_int(retrieved_list, 0, &value),
130 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_int()");
131
132 ck_assert_msg(value == 101, "Expected int retrieved == 101, got: %d",
133 value);
134
135 DICT_DESTROY(this_dict);
136 LIST_DESTROY(first_list);
137 LIST_DESTROY(second_list);
138 }
139 END_TEST
140
141 START_TEST (getdns_dict_set_list_5)
142 {
143 /*
144 * name already exists in dict, changing data type
145 * Create a dict
146 * Create a second dict
147 * Add an int to the second dict (name = "int", value = 100)
148 * Add the second dict to the first dict as name "list"
149 * Create a list
150 * Set list value at index 0 in the list to 101
151 * Add the list to the first dict using name "list" again
152 * Call getdns_dict_get_list() against the dict with name = "list"
153 * Call getdns_list_get_int() for index 0 against the retrieved list
154 * expect: GETDNS_RETURN_GOOD (all functions)
155 * retrieved int should = 101
156 */
157 struct getdns_dict *first_dict = NULL;
158 struct getdns_dict *second_dict = NULL;
159 struct getdns_list *list = NULL;
160 struct getdns_list *retrieved_list = NULL;
161 uint32_t value;
162
163 DICT_CREATE(first_dict);
164
165 DICT_CREATE(second_dict);
166 ASSERT_RC(getdns_dict_set_int(second_dict, "int", 100),
167 GETDNS_RETURN_GOOD, "Return from getdns_dict_set_int()");
168
169 ASSERT_RC(getdns_dict_set_dict(first_dict, "list", second_dict),
170 GETDNS_RETURN_GOOD, "Return from getdns_dict_set_dict()");
171
172 LIST_CREATE(list);
173 ASSERT_RC(getdns_list_set_int(list, 0, 101),
174 GETDNS_RETURN_GOOD, "Return from getdns_list_set_int()");
175
176 ASSERT_RC(getdns_dict_set_list(first_dict, "list", list),
177 GETDNS_RETURN_GOOD, "Return from getdns_dict_set_list()");
178
179 ASSERT_RC(getdns_dict_get_list(first_dict, "list", &retrieved_list),
180 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_list()");
181
182 ASSERT_RC(getdns_list_get_int(retrieved_list, 0, &value),
183 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_int()");
184
185 ck_assert_msg(value == 101, "Expected int retrieved == 101, got: %d",
186 value);
187
188 DICT_DESTROY(first_dict);
189 DICT_DESTROY(second_dict);
190 LIST_DESTROY(list);
191 }
192 END_TEST
193
194 Suite *
195 getdns_dict_set_list_suite (void)
196 {
197 Suite *s = suite_create ("getdns_dict_set_list()");
198
199 /* Negative test caseis */
200 TCase *tc_neg = tcase_create("Negative");
201 tcase_add_test(tc_neg, getdns_dict_set_list_1);
202 tcase_add_test(tc_neg, getdns_dict_set_list_2);
203 tcase_add_test(tc_neg, getdns_dict_set_list_3);
204 suite_add_tcase(s, tc_neg);
205
206 /* Positive test cases */
207 TCase *tc_pos = tcase_create("Positive");
208 tcase_add_test(tc_pos, getdns_dict_set_list_4);
209 tcase_add_test(tc_pos, getdns_dict_set_list_5);
210 suite_add_tcase(s, tc_pos);
211
212 return s;
213 }
214
215 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_display_ip_address_h_
27 #define _check_getdns_display_ip_address_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ D I S P L A Y _ I P _ A D D R E S S *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_display_ip_address_1)
38 {
39 /*
40 * bindata_of_ipv4_or_ipv6_address = NULL
41 * expect: NULL
42 */
43
44 //struct getdns_bindata bindata_of_ipv4_or_ipv6_address = NULL;
45 char *ptr = NULL;
46
47 ptr = getdns_display_ip_address(NULL);
48 ck_assert_msg(ptr == NULL, "Expected retrieved bindata == NULL, got: %p",
49 ptr);
50 }
51 END_TEST
52
53 START_TEST (getdns_display_ip_address_2)
54 {
55 /*
56 * bindata_of_ipv4_or_ipv6_address is getdns_bindata but not ip addresses
57 * expect: Unknown
58 */
59
60 char *ptr = NULL;
61 struct getdns_bindata bindata_of_ipv4_or_ipv6_address = { 8, (void *)"bindata" };
62
63 ptr = getdns_display_ip_address(&bindata_of_ipv4_or_ipv6_address);
64
65 ck_assert_msg(ptr == NULL, "Expected pointer == NULL, got: %p",
66 ptr);
67
68 }
69 END_TEST
70
71 START_TEST (getdns_display_ip_address_3)
72 {
73 /*
74 * Create bindata containing “10.88.30.82"
75 * Call getdns_display_ip_address() passing bindata
76 * expect: 10.88.30.82
77 */
78
79 char *ptr = NULL;
80 struct getdns_bindata bindata_of_ipv4_or_ipv6_address = { 4, (void *)"\x0A\x58\x1E\x52" };
81
82 ptr = getdns_display_ip_address(&bindata_of_ipv4_or_ipv6_address);
83
84 ck_assert_msg(strcmp(ptr, "10.88.30.82") == 0, "Expected pointer == “10.88.30.82”, got: %s",
85 ptr);
86
87 }
88 END_TEST
89
90 START_TEST (getdns_display_ip_address_4)
91 {
92 /*
93 * Create bindata containing 2607:f8b0:4006:802::1004
94 * Call getdns_display_ip_address() passing bindata
95 * expect: 2607:f8b0:4006:802::1004
96 */
97
98 char *ptr = NULL;
99 struct getdns_bindata bindata_of_ipv4_or_ipv6_address = { 16, (void *)"\x26\x07\xf8\xb0\x40\x06\x08\x02\x00\x00\x00\x00\x00\x00\x10\x04" };
100
101 ptr = getdns_display_ip_address(&bindata_of_ipv4_or_ipv6_address);
102
103
104 ck_assert_msg(strcmp(ptr, "2607:f8b0:4006:802::1004") == 0, "Expected pointer == “2607:f8b0:4006:802::1004”, got: %s",
105 ptr);
106
107 }
108 END_TEST
109
110
111 Suite *
112 getdns_display_ip_address_suite (void)
113 {
114 Suite *s = suite_create ("getdns_display_ip_address()");
115
116 /* Negative test caseis */
117 TCase *tc_neg = tcase_create("Negative");
118 tcase_add_test(tc_neg, getdns_display_ip_address_1);
119 tcase_add_test(tc_neg, getdns_display_ip_address_2);
120 suite_add_tcase(s, tc_neg);
121
122 /* Positive test cases */
123 TCase *tc_pos = tcase_create("Positive");
124 tcase_add_test(tc_pos, getdns_display_ip_address_3);
125 tcase_add_test(tc_pos, getdns_display_ip_address_4);
126 suite_add_tcase(s, tc_pos);
127
128 return s;
129
130 }
131
132 #endif
0 /**
1 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7
8 /*
9 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 /* this is used to prevent header conflicts with libevent and libev */
36 #ifndef _check_getdns_eventloop_h_
37 #define _check_getdns_eventloop_h_
38
39 #include "config.h"
40
41 struct getdns_context* context;
42 void run_event_loop_impl(struct getdns_context* context, void* eventloop);
43 void* create_eventloop_impl(struct getdns_context* context);
44
45 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_general_h_
27 #define _check_getdns_general_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ G E M E R A L *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_general_1)
38 {
39 /*
40 * context = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_context *context = NULL;
44 getdns_transaction_t transaction_id = 0;
45
46 ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
47 NULL, &transaction_id, callbackfn),
48 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general()");
49 }
50 END_TEST
51
52 START_TEST (getdns_general_2)
53 {
54 /*
55 * name = NULL
56 * expect: GETDNS_RETURN_INVALID_PARAMETER
57 */
58 struct getdns_context *context = NULL; \
59 void* eventloop = NULL; \
60 getdns_transaction_t transaction_id = 0;
61
62 CONTEXT_CREATE(TRUE);
63 EVENT_BASE_CREATE;
64
65 ASSERT_RC(getdns_general(context, NULL, GETDNS_RRTYPE_A, NULL,
66 NULL, &transaction_id, callbackfn),
67 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general()");
68
69 RUN_EVENT_LOOP;
70 CONTEXT_DESTROY;
71 }
72 END_TEST
73
74 START_TEST (getdns_general_3)
75 {
76 /*
77 * name = invalid domain (too many octets)
78 * expect: GETDNS_RETURN_BAD_DOMAIN_NAME
79 */
80 struct getdns_context *context = NULL; \
81 void* eventloop = NULL; \
82 getdns_transaction_t transaction_id = 0;
83 const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com";
84
85 CONTEXT_CREATE(TRUE);
86 EVENT_BASE_CREATE;
87
88 ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_A, NULL,
89 NULL, &transaction_id, callbackfn),
90 GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general()");
91
92 RUN_EVENT_LOOP;
93 CONTEXT_DESTROY;
94 }
95 END_TEST
96
97 START_TEST (getdns_general_4)
98 {
99 /*
100 * name = invalid domain (label too long)
101 * expect: GETDNS_RETURN_BAD_DOMAIN_NAME
102 */
103 struct getdns_context *context = NULL; \
104 void* eventloop = NULL; \
105 getdns_transaction_t transaction_id = 0;
106 const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com";
107
108 CONTEXT_CREATE(TRUE);
109 EVENT_BASE_CREATE;
110
111 ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_A, NULL,
112 NULL, &transaction_id, callbackfn),
113 GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general()");
114
115 RUN_EVENT_LOOP;
116 CONTEXT_DESTROY;
117 }
118 END_TEST
119
120 START_TEST (getdns_general_5)
121 {
122 /*
123 * callbackfn = NULL
124 * expect: GETDNS_RETURN_INVALID_PARAMETER
125 */
126 struct getdns_context *context = NULL; \
127 void* eventloop = NULL; \
128 getdns_transaction_t transaction_id = 0;
129
130 CONTEXT_CREATE(TRUE);
131 EVENT_BASE_CREATE;
132
133 ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
134 NULL, &transaction_id, NULL),
135 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general()");
136
137 RUN_EVENT_LOOP;
138 CONTEXT_DESTROY;
139 }
140 END_TEST
141
142 START_TEST (getdns_general_6)
143 {
144 /*
145 * name = "google.com"
146 * request_type = 0 (minimum valid RRTYPE)
147 * expect: NOERROR/NODATA response:
148 * status = GETDNS_RESPSTATUS_GOOD
149 * rcode = 0
150 * ancount = 0 (number of records in ANSWER section)
151 */
152 void verify_getdns_general_6(struct extracted_response *ex_response);
153 struct getdns_context *context = NULL; \
154 void* eventloop = NULL; \
155 getdns_transaction_t transaction_id = 0;
156
157 CONTEXT_CREATE(TRUE);
158 EVENT_BASE_CREATE;
159
160 ASSERT_RC(getdns_general(context, "google.com", 0, NULL,
161 verify_getdns_general_6, &transaction_id, callbackfn),
162 GETDNS_RETURN_GOOD, "Return code from getdns_general()");
163
164 RUN_EVENT_LOOP;
165 CONTEXT_DESTROY;
166 }
167 END_TEST
168
169 void verify_getdns_general_6(struct extracted_response *ex_response)
170 {
171 assert_noerror(ex_response);
172 assert_nodata(ex_response);
173 }
174
175 START_TEST (getdns_general_7)
176 {
177 /*
178 * name = "google.com"
179 * request_type = 65279 (maximum unassigned RRTYPE)
180 * expect: NOERROR/NODATA response:
181 * status = GETDNS_RESPSTATUS_GOOD
182 * rcode = 0
183 * ancount = 0 (number of records in ANSWER section)
184 */
185 void verify_getdns_general_7(struct extracted_response *ex_response);
186 struct getdns_context *context = NULL; \
187 void* eventloop = NULL; \
188 getdns_transaction_t transaction_id = 0;
189
190 CONTEXT_CREATE(TRUE);
191 EVENT_BASE_CREATE;
192
193 ASSERT_RC(getdns_general(context, "google.com", 65279, NULL,
194 verify_getdns_general_7, &transaction_id, callbackfn),
195 GETDNS_RETURN_GOOD, "Return code from getdns_general()");
196
197 RUN_EVENT_LOOP;
198 CONTEXT_DESTROY;
199 }
200 END_TEST
201
202 void verify_getdns_general_7(struct extracted_response *ex_response)
203 {
204 assert_noerror(ex_response);
205 assert_nodata(ex_response);
206 }
207
208 START_TEST (getdns_general_8)
209 {
210 /*
211 * name = "google.com"
212 * request_type = GETDNS_RRTYPE_A
213 * expect: NOERROR response with A records
214 * status = GETDNS_RESPSTATUS_GOOD
215 * rcode = 0
216 * ancount >= 1 (number of records in ANSWER section)
217 * and equals number of A records ("type": 1) in "answer" list
218 */
219 void verify_getdns_general_8(struct extracted_response *ex_response);
220 struct getdns_context *context = NULL; \
221 void* eventloop = NULL; \
222 getdns_transaction_t transaction_id = 0;
223
224 CONTEXT_CREATE(TRUE);
225 EVENT_BASE_CREATE;
226
227 ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
228 verify_getdns_general_8, &transaction_id, callbackfn),
229 GETDNS_RETURN_GOOD, "Return code from getdns_general()");
230
231 RUN_EVENT_LOOP;
232 CONTEXT_DESTROY;
233 }
234 END_TEST
235
236 void verify_getdns_general_8(struct extracted_response *ex_response)
237 {
238 assert_noerror(ex_response);
239 assert_address_in_answer(ex_response, TRUE, FALSE);
240 }
241
242 START_TEST (getdns_general_9)
243 {
244 /*
245 * name = "google.com"
246 * request_type = GETDNS_RRTYPE_AAAA
247 * expect: NOERROR response with AAAA records
248 * status = GETDNS_RESPSTATUS_GOOD
249 * rcode = 0
250 * ancount >= 1 (number of records in ANSWER section)
251 * and equals number of AAAA records ("type": 28) in "answer" list
252 */
253 void verify_getdns_general_9(struct extracted_response *ex_response);
254 struct getdns_context *context = NULL; \
255 void* eventloop = NULL; \
256 getdns_transaction_t transaction_id = 0;
257
258 CONTEXT_CREATE(TRUE);
259 EVENT_BASE_CREATE;
260
261 ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_AAAA, NULL,
262 verify_getdns_general_9, &transaction_id, callbackfn),
263 GETDNS_RETURN_GOOD, "Return code from getdns_general()");
264
265 RUN_EVENT_LOOP;
266 CONTEXT_DESTROY;
267 }
268 END_TEST
269
270 void verify_getdns_general_9(struct extracted_response *ex_response)
271 {
272 assert_noerror(ex_response);
273 assert_address_in_answer(ex_response, FALSE, TRUE);
274 }
275
276 START_TEST (getdns_general_10)
277 {
278 /*
279 * name = "thisdomainsurelydoesntexist.com"
280 * request_type = GETDNS_RRTYPE_TXT`
281 * expect: NXDOMAIN response with SOA record
282 * status = GETDNS_RESPSTATUS_GOOD
283 * rcode = 3
284 * ancount = 0 (number of records in ANSWER section)
285 * nscount = 1 (number of records in AUTHORITY section)
286 * and SOA record ("type": 6) present in "authority" list
287 */
288 void verify_getdns_general_10(struct extracted_response *ex_response);
289 struct getdns_context *context = NULL; \
290 void* eventloop = NULL; \
291 getdns_transaction_t transaction_id = 0;
292 const char *name = "thisdomainsurelydoesntexist.com";
293
294 CONTEXT_CREATE(TRUE);
295 EVENT_BASE_CREATE;
296
297 ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_TXT, NULL,
298 verify_getdns_general_10, &transaction_id, callbackfn),
299 GETDNS_RETURN_GOOD, "Return code from getdns_general()");
300
301 RUN_EVENT_LOOP;
302 CONTEXT_DESTROY;
303 }
304 END_TEST
305
306 void verify_getdns_general_10(struct extracted_response *ex_response)
307 {
308 assert_nxdomain(ex_response);
309 assert_nodata(ex_response);
310 assert_soa_in_authority(ex_response);
311 }
312
313 START_TEST (getdns_general_11)
314 {
315 /*
316 * name = "hampster.com" need to replace this with domain from unbound zone
317 * request_type = GETDNS_RRTYPE_MX
318 * expect: NOERROR/NODATA response:
319 * status = GETDNS_RESPSTATUS_GOOD
320 * rcode = 0
321 * ancount = 0 (number of records in ANSWER section)
322 */
323 void verify_getdns_general_11(struct extracted_response *ex_response);
324 struct getdns_context *context = NULL; \
325 void* eventloop = NULL; \
326 getdns_transaction_t transaction_id = 0;
327
328 CONTEXT_CREATE(TRUE);
329 EVENT_BASE_CREATE;
330
331 ASSERT_RC(getdns_general(context, "hampster.com", GETDNS_RRTYPE_MX, NULL,
332 verify_getdns_general_11, &transaction_id, callbackfn),
333 GETDNS_RETURN_GOOD, "Return code from getdns_general()");
334
335 RUN_EVENT_LOOP;
336 CONTEXT_DESTROY;
337 }
338 END_TEST
339
340 void verify_getdns_general_11(struct extracted_response *ex_response)
341 {
342 assert_noerror(ex_response);
343 assert_nodata(ex_response);
344 }
345
346 START_TEST (getdns_general_12)
347 {
348 /*
349 * name = "google.com" need to swap this out for max domain name length with max lable length`
350 * request_type = GETDNS_RRTYPE_A
351 * expect: NOERROR response with A records
352 * status = GETDNS_RESPSTATUS_GOOD
353 * rcode = 0
354 * ancount >= 1 (number of records in ANSWER section)
355 * and equals number of A records ("type": 1) in "answer" list
356 */
357 void verify_getdns_general_12(struct extracted_response *ex_response);
358 struct getdns_context *context = NULL; \
359 void* eventloop = NULL; \
360 getdns_transaction_t transaction_id = 0;
361
362 CONTEXT_CREATE(TRUE);
363 EVENT_BASE_CREATE;
364
365 ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
366 verify_getdns_general_12, &transaction_id, callbackfn),
367 GETDNS_RETURN_GOOD, "Return code from getdns_general()");
368
369 RUN_EVENT_LOOP;
370 CONTEXT_DESTROY;
371 }
372 END_TEST
373
374 void verify_getdns_general_12(struct extracted_response *ex_response)
375 {
376 assert_noerror(ex_response);
377 assert_address_in_answer(ex_response, TRUE, FALSE);
378 }
379
380 Suite *
381 getdns_general_suite (void)
382 {
383 Suite *s = suite_create ("getdns_general()");
384
385 /* Negative test caseis */
386 TCase *tc_neg = tcase_create("Negative");
387 tcase_add_test(tc_neg, getdns_general_1);
388 tcase_add_test(tc_neg, getdns_general_2);
389 tcase_add_test(tc_neg, getdns_general_3);
390 tcase_add_test(tc_neg, getdns_general_4);
391 tcase_add_test(tc_neg, getdns_general_5);
392 suite_add_tcase(s, tc_neg);
393
394 /* Positive test cases */
395 TCase *tc_pos = tcase_create("Positive");
396 tcase_add_test(tc_pos, getdns_general_6);
397 tcase_add_test(tc_pos, getdns_general_7);
398 tcase_add_test(tc_pos, getdns_general_8);
399 tcase_add_test(tc_pos, getdns_general_9);
400 tcase_add_test(tc_pos, getdns_general_10);
401 tcase_add_test(tc_pos, getdns_general_11);
402 tcase_add_test(tc_pos, getdns_general_12);
403 suite_add_tcase(s, tc_pos);
404
405 return s;
406 }
407
408 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_general_sync_h_
27 #define _check_getdns_general_sync_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ G E N E R A L _ S Y N C *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_general_sync_1)
38 {
39 /*
40 * context = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_context *context = NULL;
44 struct getdns_dict *response = NULL;
45
46 ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response),
47 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general_sync()");
48 }
49 END_TEST
50
51 START_TEST (getdns_general_sync_2)
52 {
53 /*
54 * name = NULL
55 * expect: GETDNS_RETURN_INVALID_PARAMETER
56 */
57 struct getdns_context *context = NULL;
58 struct getdns_dict *response = NULL;
59
60 CONTEXT_CREATE(TRUE);
61
62 ASSERT_RC(getdns_general_sync(context, NULL, GETDNS_RRTYPE_A, NULL, &response),
63 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general_sync()");
64
65 CONTEXT_DESTROY;
66 }
67 END_TEST
68
69 START_TEST (getdns_general_sync_3)
70 {
71 /*
72 * name = invalid domain (too many octets)
73 * expect: GETDNS_RETURN_BAD_DOMAIN_NAME
74 */
75 struct getdns_context *context = NULL;
76 struct getdns_dict *response = NULL;
77 const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com";
78
79 CONTEXT_CREATE(TRUE);
80
81 ASSERT_RC(getdns_general_sync(context, name, GETDNS_RRTYPE_A, NULL, &response),
82 GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general_sync()");
83
84 CONTEXT_DESTROY;
85 }
86 END_TEST
87
88 START_TEST (getdns_general_sync_4)
89 {
90 /*
91 * name = invalid domain (label too long)
92 * expect: GETDNS_RETURN_BAD_DOMAIN_NAME
93 */
94 struct getdns_context *context = NULL;
95 struct getdns_dict *response = NULL;
96 const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com";
97
98 CONTEXT_CREATE(TRUE);
99
100 ASSERT_RC(getdns_general_sync(context, name, GETDNS_RRTYPE_A, NULL, &response),
101 GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_general_sync()");
102
103 CONTEXT_DESTROY;
104 }
105 END_TEST
106
107 START_TEST (getdns_general_sync_5)
108 {
109 /*
110 * response = NULL
111 * expect: GETDNS_RETURN_INVALID_PARAMETER
112 */
113 struct getdns_context *context = NULL;
114
115 CONTEXT_CREATE(TRUE);
116
117 ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, NULL),
118 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_general_sync()");
119
120 CONTEXT_DESTROY;
121 }
122 END_TEST
123
124 START_TEST (getdns_general_sync_6)
125 {
126 /*
127 * name = "google.com"
128 * request_type = 0 (minimum valid RRTYPE)
129 * expect: NOERROR/NODATA response:
130 * status = GETDNS_RESPSTATUS_GOOD
131 * rcode = 0
132 * ancount = 0 (number of records in ANSWER section)
133 */
134 struct getdns_context *context = NULL;
135 struct getdns_dict *response = NULL;
136
137 CONTEXT_CREATE(TRUE);
138
139 ASSERT_RC(getdns_general_sync(context, "google.com", 0, NULL, &response),
140 GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
141
142 EXTRACT_RESPONSE;
143
144 assert_noerror(&ex_response);
145 assert_nodata(&ex_response);
146
147 CONTEXT_DESTROY;
148 }
149 END_TEST
150
151 START_TEST (getdns_general_sync_7)
152 {
153 /*
154 * name = "google.com"
155 * request_type = 65279 (maximum unassigned RRTYPE)
156 * expect: NOERROR/NODATA response:
157 * status = GETDNS_RESPSTATUS_GOOD
158 * rcode = 0
159 * ancount = 0 (number of records in ANSWER section)
160 */
161 struct getdns_context *context = NULL;
162 struct getdns_dict *response = NULL;
163
164 CONTEXT_CREATE(TRUE);
165
166 ASSERT_RC(getdns_general_sync(context, "google.com", 65279, NULL, &response),
167 GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
168
169 EXTRACT_RESPONSE;
170
171 assert_noerror(&ex_response);
172 assert_nodata(&ex_response);
173
174 CONTEXT_DESTROY;
175 }
176 END_TEST
177
178 START_TEST (getdns_general_sync_8)
179 {
180 /*
181 * name = "google.com"
182 * request_type = GETDNS_RRTYPE_A
183 * expect: NOERROR response with A records
184 * status = GETDNS_RESPSTATUS_GOOD
185 * rcode = 0
186 * ancount >= 1 (number of records in ANSWER section)
187 * and equals number of A records ("type": 1) in "answer" list
188 */
189 struct getdns_context *context = NULL;
190 struct getdns_dict *response = NULL;
191
192 CONTEXT_CREATE(TRUE);
193
194 ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response),
195 GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
196
197 EXTRACT_RESPONSE;
198
199 assert_noerror(&ex_response);
200 assert_address_in_answer(&ex_response, TRUE, FALSE);
201
202 CONTEXT_DESTROY;
203 }
204 END_TEST
205
206 START_TEST (getdns_general_sync_9)
207 {
208 /*
209 * name = "google.com"
210 * request_type = GETDNS_RRTYPE_AAAA
211 * expect: NOERROR response with AAAA records
212 * status = GETDNS_RESPSTATUS_GOOD
213 * rcode = 0
214 * ancount >= 1 (number of records in ANSWER section)
215 * and equals number of AAAA records ("type": 28) in "answer" list
216 */
217 struct getdns_context *context = NULL;
218 struct getdns_dict *response = NULL;
219
220 CONTEXT_CREATE(TRUE);
221
222 ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_AAAA, NULL, &response),
223 GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
224
225 EXTRACT_RESPONSE;
226
227 assert_noerror(&ex_response);
228 assert_address_in_answer(&ex_response, FALSE, TRUE);
229
230 CONTEXT_DESTROY;
231 }
232 END_TEST
233
234 START_TEST (getdns_general_sync_10)
235 {
236 /*
237 * name = "thisdomainsurelydoesntexist.com"
238 * request_type = GETDNS_RRTYPE_TXT`
239 * expect: NXDOMAIN response with SOA record
240 * status = GETDNS_RESPSTATUS_GOOD
241 * rcode = 3
242 * ancount = 0 (number of records in ANSWER section)
243 * nscount = 1 (number of records in AUTHORITY section)
244 * and SOA record ("type": 6) present in "authority" list
245 */
246 struct getdns_context *context = NULL;
247 struct getdns_dict *response = NULL;
248 const char *name = "thisdomainsurelydoesntexist.com";
249
250 CONTEXT_CREATE(TRUE);
251
252 ASSERT_RC(getdns_general_sync(context, name, GETDNS_RRTYPE_TXT, NULL, &response),
253 GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
254
255 EXTRACT_RESPONSE;
256
257 assert_nxdomain(&ex_response);
258 assert_nodata(&ex_response);
259 assert_soa_in_authority(&ex_response);
260
261 CONTEXT_DESTROY;
262 }
263 END_TEST
264
265 START_TEST (getdns_general_sync_11)
266 {
267 /*
268 * name = "hampster.com" need to replace this with domain from unbound zone
269 * request_type = GETDNS_RRTYPE_MX
270 * expect: NOERROR/NODATA response:
271 * status = GETDNS_RESPSTATUS_GOOD
272 * rcode = 0
273 * ancount = 0 (number of records in ANSWER section)
274 */
275 struct getdns_context *context = NULL;
276 struct getdns_dict *response = NULL;
277
278 CONTEXT_CREATE(TRUE);
279
280 ASSERT_RC(getdns_general_sync(context, "hampster.com", GETDNS_RRTYPE_MX, NULL, &response),
281 GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
282
283 EXTRACT_RESPONSE;
284
285 assert_noerror(&ex_response);
286 assert_nodata(&ex_response);
287
288 CONTEXT_DESTROY;
289 }
290 END_TEST
291
292 START_TEST (getdns_general_sync_12)
293 {
294 /*
295 * name = "google.com" need to swap this out for max domain name length with max lable length`
296 * request_type = GETDNS_RRTYPE_A
297 * expect: NOERROR response with A records
298 * status = GETDNS_RESPSTATUS_GOOD
299 * rcode = 0
300 * ancount >= 1 (number of records in ANSWER section)
301 * and equals number of A records ("type": 1) in "answer" list
302 */
303 struct getdns_context *context = NULL;
304 struct getdns_dict *response = NULL;
305
306 CONTEXT_CREATE(TRUE);
307
308 ASSERT_RC(getdns_general_sync(context, "google.com", GETDNS_RRTYPE_A, NULL, &response),
309 GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
310
311 EXTRACT_RESPONSE;
312
313 assert_noerror(&ex_response);
314 assert_address_in_answer(&ex_response, TRUE, FALSE);
315
316 CONTEXT_DESTROY;
317 }
318 END_TEST
319
320 Suite *
321 getdns_general_sync_suite (void)
322 {
323 Suite *s = suite_create ("getdns_general_sync()");
324
325 /* Negative test caseis */
326 TCase *tc_neg = tcase_create("Negative");
327 tcase_add_test(tc_neg, getdns_general_sync_1);
328 tcase_add_test(tc_neg, getdns_general_sync_2);
329 tcase_add_test(tc_neg, getdns_general_sync_3);
330 tcase_add_test(tc_neg, getdns_general_sync_4);
331 tcase_add_test(tc_neg, getdns_general_sync_5);
332 suite_add_tcase(s, tc_neg);
333 /* Positive test cases */
334
335 TCase *tc_pos = tcase_create("Positive");
336 tcase_add_test(tc_pos, getdns_general_sync_6);
337 tcase_add_test(tc_pos, getdns_general_sync_7);
338 tcase_add_test(tc_pos, getdns_general_sync_8);
339 tcase_add_test(tc_pos, getdns_general_sync_9);
340 tcase_add_test(tc_pos, getdns_general_sync_10);
341 tcase_add_test(tc_pos, getdns_general_sync_11);
342 tcase_add_test(tc_pos, getdns_general_sync_12);
343 suite_add_tcase(s, tc_pos);
344
345 return s;
346 }
347
348 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_hostname_h_
27 #define _check_getdns_hostname_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ H O S T N A M E *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_hostname_1)
38 {
39 /*
40 * context = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_context *context = NULL;
44 struct getdns_dict *address = NULL;
45 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
46 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
47 getdns_transaction_t transaction_id = 0;
48
49 DICT_CREATE(address);
50 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
51 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
52 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
53 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
54
55 ASSERT_RC(getdns_hostname(context, address, NULL,
56 NULL, &transaction_id, callbackfn),
57 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()");
58
59 DICT_DESTROY(address);
60 }
61 END_TEST
62
63 START_TEST (getdns_hostname_2)
64 {
65 /*
66 * address = NULL
67 * expect: GETDNS_RETURN_INVALID_PARAMETER
68 */
69 struct getdns_context *context = NULL;
70 void* eventloop = NULL;
71 getdns_transaction_t transaction_id = 0;
72
73 CONTEXT_CREATE(TRUE);
74 EVENT_BASE_CREATE;
75
76 ASSERT_RC(getdns_hostname(context, NULL, NULL,
77 NULL, &transaction_id, callbackfn),
78 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()");
79
80 RUN_EVENT_LOOP;
81 CONTEXT_DESTROY;
82 }
83 END_TEST
84
85 START_TEST (getdns_hostname_3)
86 {
87 /*
88 * dict in address does not contain getdns_bindata
89 * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME
90 */
91 struct getdns_context *context = NULL;
92 struct getdns_dict *address = NULL;
93 void* eventloop = NULL;
94 getdns_transaction_t transaction_id = 0;
95
96 CONTEXT_CREATE(TRUE);
97 DICT_CREATE(address);
98 EVENT_BASE_CREATE;
99
100 ASSERT_RC(getdns_hostname(context, address, NULL,
101 NULL, &transaction_id, callbackfn),
102 GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname()");
103
104 RUN_EVENT_LOOP;
105 DICT_DESTROY(address);
106 CONTEXT_DESTROY;
107 }
108 END_TEST
109
110 START_TEST (getdns_hostname_4)
111 {
112 /*
113 * dict in address does not contain two names
114 * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME
115 */
116 struct getdns_context *context = NULL;
117 struct getdns_dict *address = NULL;
118 struct getdns_bindata address_type = { 5, (void *) "IPv4" };
119 void* eventloop = NULL;
120 getdns_transaction_t transaction_id = 0;
121
122 CONTEXT_CREATE(TRUE);
123
124 DICT_CREATE(address);
125 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
126 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
127
128 EVENT_BASE_CREATE;
129
130 ASSERT_RC(getdns_hostname(context, address, NULL,
131 NULL, &transaction_id, callbackfn),
132 GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname()");
133
134 RUN_EVENT_LOOP;
135
136 DICT_DESTROY(address);
137 CONTEXT_DESTROY;
138 }
139 END_TEST
140
141 START_TEST (getdns_hostname_5)
142 {
143 /*
144 * dict in address contains names other than adddress_type
145 * and address_data.
146 * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME
147 */
148 struct getdns_context *context = NULL;
149 struct getdns_dict *address = NULL;
150 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
151 void* eventloop = NULL;
152 getdns_transaction_t transaction_id = 0;
153
154 CONTEXT_CREATE(TRUE);
155
156 DICT_CREATE(address);
157 ASSERT_RC(getdns_dict_set_int(address, "not_address_type", 100),
158 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
159 ASSERT_RC(getdns_dict_set_bindata(address, "not_address_data", &address_data),
160 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
161
162 EVENT_BASE_CREATE;
163
164 ASSERT_RC(getdns_hostname(context, address, NULL,
165 NULL, &transaction_id, callbackfn),
166 GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname()");
167
168 RUN_EVENT_LOOP;
169
170 DICT_DESTROY(address);
171 CONTEXT_DESTROY;
172 }
173 END_TEST
174
175 START_TEST (getdns_hostname_6)
176 {
177 /*
178 * dict in address contains names address_type
179 * and address_data but data type is not bindata
180 * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
181 */
182 struct getdns_context *context = NULL;
183 struct getdns_dict *address = NULL;
184 void* eventloop = NULL;
185 getdns_transaction_t transaction_id = 0;
186
187 CONTEXT_CREATE(TRUE);
188
189 DICT_CREATE(address);
190 ASSERT_RC(getdns_dict_set_int(address, "address_type", 100),
191 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
192 ASSERT_RC(getdns_dict_set_int(address, "address_data", 200),
193 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
194
195 EVENT_BASE_CREATE;
196
197 ASSERT_RC(getdns_hostname(context, address, NULL,
198 NULL, &transaction_id, callbackfn),
199 GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_hostname()");
200
201 RUN_EVENT_LOOP;
202
203 DICT_DESTROY(address);
204 CONTEXT_DESTROY;
205 }
206 END_TEST
207
208 START_TEST (getdns_hostname_7)
209 {
210 /*
211 * dict in address contains invalid address_type
212 * expect: GETDNS_RETURN_INVALID_PARAMETER
213 */
214 struct getdns_context *context = NULL;
215 struct getdns_dict *address = NULL;
216 struct getdns_bindata address_type = { 5, (void *)"IPv5" };
217 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
218 void* eventloop = NULL;
219 getdns_transaction_t transaction_id = 0;
220
221 CONTEXT_CREATE(TRUE);
222
223 DICT_CREATE(address);
224 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
225 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
226 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
227 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
228
229 EVENT_BASE_CREATE;
230
231 ASSERT_RC(getdns_hostname(context, address, NULL,
232 NULL, &transaction_id, callbackfn),
233 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()");
234
235 RUN_EVENT_LOOP;
236
237 DICT_DESTROY(address);
238 CONTEXT_DESTROY;
239 }
240 END_TEST
241
242 START_TEST (getdns_hostname_8)
243 {
244 /*
245 * dict in address contains invalid address_data
246 * expect: GETDNS_RETURN_INVALID_PARAMETER
247 */
248 struct getdns_context *context = NULL;
249 struct getdns_dict *address = NULL;
250 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
251 struct getdns_bindata address_data = { 5, (void *)"\x08\x08\x08\x08\x08" };
252 void* eventloop = NULL;
253 getdns_transaction_t transaction_id = 0;
254
255 CONTEXT_CREATE(TRUE);
256
257 DICT_CREATE(address);
258 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
259 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
260 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
261 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
262
263 EVENT_BASE_CREATE;
264
265 ASSERT_RC(getdns_hostname(context, address, NULL,
266 NULL, &transaction_id, callbackfn),
267 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()");
268
269 RUN_EVENT_LOOP;
270
271 DICT_DESTROY(address);
272 CONTEXT_DESTROY;
273 }
274 END_TEST
275
276 START_TEST (getdns_hostname_9)
277 {
278 /*
279 * callbackfn = NULL
280 * expect: GETDNS_RETURN_INVALID_PARAMETER
281 */
282 struct getdns_context *context = NULL;
283 struct getdns_dict *address = NULL;
284 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
285 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
286 void* eventloop = NULL;
287 getdns_transaction_t transaction_id = 0;
288
289 CONTEXT_CREATE(TRUE);
290
291 DICT_CREATE(address);
292 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
293 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
294 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
295 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
296
297 EVENT_BASE_CREATE;
298
299 ASSERT_RC(getdns_hostname(context, address, NULL,
300 NULL, &transaction_id, NULL),
301 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname()");
302
303 RUN_EVENT_LOOP;
304
305 DICT_DESTROY(address);
306 CONTEXT_DESTROY;
307 }
308 END_TEST
309
310 START_TEST (getdns_hostname_10)
311 {
312 /*
313 * dict in address has resolvable IPv4 address
314 * expect: response with correct hostname
315 */
316 void verify_getdns_hostname_10(struct extracted_response *ex_response);
317 struct getdns_context *context = NULL;
318 struct getdns_dict *address = NULL;
319 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
320 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
321 void* eventloop = NULL;
322 getdns_transaction_t transaction_id = 0;
323
324 CONTEXT_CREATE(TRUE);
325
326 DICT_CREATE(address);
327 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
328 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
329 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
330 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
331
332 EVENT_BASE_CREATE;
333
334 ASSERT_RC(getdns_hostname(context, address, NULL,
335 verify_getdns_hostname_10, &transaction_id, callbackfn),
336 GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
337
338 RUN_EVENT_LOOP;
339
340 DICT_DESTROY(address);
341 CONTEXT_DESTROY;
342 }
343 END_TEST
344
345 void verify_getdns_hostname_10(struct extracted_response *ex_response)
346 {
347 assert_noerror(ex_response);
348 assert_ptr_in_answer(ex_response);
349 }
350
351 START_TEST (getdns_hostname_11)
352 {
353 /*
354 * dict in address has unresolvable IPv4 address
355 * expect: response with no hostname
356 */
357 void verify_getdns_hostname_11(struct extracted_response *ex_response);
358 struct getdns_context *context = NULL;
359 struct getdns_dict *address = NULL;
360 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
361 struct getdns_bindata address_data = { 4, (void *)"\x01\x01\x01\x01" };
362 void* eventloop = NULL;
363 getdns_transaction_t transaction_id = 0;
364
365 CONTEXT_CREATE(TRUE);
366
367 DICT_CREATE(address);
368 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
369 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
370 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
371 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
372
373 EVENT_BASE_CREATE;
374
375 ASSERT_RC(getdns_hostname(context, address, NULL,
376 verify_getdns_hostname_11, &transaction_id, callbackfn),
377 GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
378
379 RUN_EVENT_LOOP;
380
381 DICT_DESTROY(address);
382 CONTEXT_DESTROY;
383 }
384 END_TEST
385
386 void verify_getdns_hostname_11(struct extracted_response *ex_response)
387 {
388 assert_nxdomain(ex_response);
389 assert_nodata(ex_response);
390 assert_soa_in_authority(ex_response);
391 }
392
393 START_TEST (getdns_hostname_12)
394 {
395 /*
396 * dict in address has resolvable IPv6 address
397 * expect: response with correct hostname
398 */
399 void verify_getdns_hostname_12(struct extracted_response *ex_response);
400 struct getdns_context *context = NULL;
401 struct getdns_dict *address = NULL;
402 struct getdns_bindata address_type = { 5, (void *)"IPv6" };
403 struct getdns_bindata address_data = { 16, (void *)"\x26\x07\xf8\xb0\x40\x06\x08\x02\x00\x00\x00\x00\x00\x00\x10\x04" };
404 void* eventloop = NULL;
405 getdns_transaction_t transaction_id = 0;
406
407 CONTEXT_CREATE(TRUE);
408
409 DICT_CREATE(address);
410 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
411 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
412 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
413 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
414
415 EVENT_BASE_CREATE;
416
417 ASSERT_RC(getdns_hostname(context, address, NULL,
418 verify_getdns_hostname_12, &transaction_id, callbackfn),
419 GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
420
421 RUN_EVENT_LOOP;
422
423 DICT_DESTROY(address);
424 CONTEXT_DESTROY;
425 }
426 END_TEST
427
428 void verify_getdns_hostname_12(struct extracted_response *ex_response)
429 {
430 assert_noerror(ex_response);
431 assert_ptr_in_answer(ex_response);
432 }
433
434 START_TEST (getdns_hostname_13)
435 {
436 /*
437 * dict in address has unresolvable IPv4 address
438 * expect: response with no hostname
439 */
440 void verify_getdns_hostname_13(struct extracted_response *ex_response);
441 struct getdns_context *context = NULL;
442 struct getdns_dict *address = NULL;
443 struct getdns_bindata address_type = { 5, (void *)"IPv6" };
444 struct getdns_bindata address_data = { 16, (void *)"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" };
445 void* eventloop = NULL;
446 getdns_transaction_t transaction_id = 0;
447
448 CONTEXT_CREATE(TRUE);
449
450 DICT_CREATE(address);
451 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
452 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
453 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
454 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
455
456 EVENT_BASE_CREATE;
457
458 ASSERT_RC(getdns_hostname(context, address, NULL,
459 verify_getdns_hostname_13, &transaction_id, callbackfn),
460 GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
461
462 RUN_EVENT_LOOP;
463
464 DICT_DESTROY(address);
465 CONTEXT_DESTROY;
466 }
467 END_TEST
468
469 void verify_getdns_hostname_13(struct extracted_response *ex_response)
470 {
471 assert_nxdomain(ex_response);
472 assert_nodata(ex_response);
473 assert_soa_in_authority(ex_response);
474 }
475
476 Suite *
477 getdns_hostname_suite (void)
478 {
479 Suite *s = suite_create ("getdns_hostname()");
480
481 /* Negative test caseis */
482 TCase *tc_neg = tcase_create("Negative");
483 tcase_add_test(tc_neg, getdns_hostname_1);
484 tcase_add_test(tc_neg, getdns_hostname_2);
485 tcase_add_test(tc_neg, getdns_hostname_3);
486 tcase_add_test(tc_neg, getdns_hostname_4);
487 tcase_add_test(tc_neg, getdns_hostname_5);
488 tcase_add_test(tc_neg, getdns_hostname_6);
489 tcase_add_test(tc_neg, getdns_hostname_7);
490 tcase_add_test(tc_neg, getdns_hostname_8);
491 tcase_add_test(tc_neg, getdns_hostname_9);
492 suite_add_tcase(s, tc_neg);
493
494 /* Positive test cases */
495 TCase *tc_pos = tcase_create("Positive");
496 tcase_add_test(tc_pos, getdns_hostname_10);
497 tcase_add_test(tc_pos, getdns_hostname_11);
498 tcase_add_test(tc_pos, getdns_hostname_12);
499 tcase_add_test(tc_pos, getdns_hostname_13);
500 suite_add_tcase(s, tc_pos);
501
502 return s;
503 }
504
505 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_hostname_sync_h_
27 #define _check_getdns_hostname_sync_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ H O S T N A M E _ S Y N C *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_hostname_sync_1)
38 {
39 /*
40 * context = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_context *context = NULL;
44 struct getdns_dict *address = NULL;
45 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
46 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
47 struct getdns_dict *response = NULL;
48
49 DICT_CREATE(address);
50 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
51 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
52 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
53 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
54
55 ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response),
56 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname_sync()");
57
58 DICT_DESTROY(address);
59 }
60 END_TEST
61
62 START_TEST (getdns_hostname_sync_2)
63 {
64 /*
65 * address = NULL
66 * expect: GETDNS_RETURN_INVALID_PARAMETER
67 */
68 struct getdns_context *context = NULL;
69 struct getdns_dict *response = NULL;
70
71 CONTEXT_CREATE(TRUE);
72
73 ASSERT_RC(getdns_hostname_sync(context, NULL, NULL, &response),
74 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname_sync()");
75
76 CONTEXT_DESTROY;
77 }
78 END_TEST
79
80 START_TEST (getdns_hostname_sync_3)
81 {
82 /*
83 * response = NULL
84 * expect: GETDNS_RETURN_INVALID_PARAMETER
85 */
86 struct getdns_context *context = NULL;
87 struct getdns_dict *address = NULL;
88 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
89 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
90
91 CONTEXT_CREATE(TRUE);
92
93 DICT_CREATE(address);
94 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
95 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
96 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
97 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
98
99 ASSERT_RC(getdns_hostname_sync(context, address, NULL, NULL),
100 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname_sync()");
101
102 DICT_DESTROY(address);
103 CONTEXT_DESTROY;
104 }
105 END_TEST
106
107 START_TEST (getdns_hostname_sync_4)
108 {
109 /*
110 * dict in address does not contain getdns_bindata
111 * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME
112 */
113 struct getdns_context *context = NULL;
114 struct getdns_dict *address = NULL;
115 struct getdns_dict *response = NULL;
116
117 CONTEXT_CREATE(TRUE);
118 DICT_CREATE(address);
119
120 ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response),
121 GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname_sync()");
122
123 DICT_DESTROY(address);
124 CONTEXT_DESTROY;
125 }
126 END_TEST
127
128 START_TEST (getdns_hostname_sync_5)
129 {
130 /*
131 * dict in address does not contain two names
132 * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME
133 */
134 struct getdns_context *context = NULL;
135 struct getdns_dict *address = NULL;
136 struct getdns_bindata address_type = { 5, (void *) "IPv4" };
137 struct getdns_dict *response = NULL;
138
139 CONTEXT_CREATE(TRUE);
140
141 DICT_CREATE(address);
142 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
143 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
144
145 ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response),
146 GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname_sync()");
147
148 DICT_DESTROY(address);
149 CONTEXT_DESTROY;
150 }
151 END_TEST
152
153 START_TEST (getdns_hostname_sync_6)
154 {
155 /*
156 * dict in address contains names other than adddress_type
157 * and address_data.
158 * expect: GETDNS_RETURN_NO_SUCH_DICT_NAME
159 */
160 struct getdns_context *context = NULL;
161 struct getdns_dict *address = NULL;
162 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
163 struct getdns_dict *response = NULL;
164
165 CONTEXT_CREATE(TRUE);
166
167 DICT_CREATE(address);
168 ASSERT_RC(getdns_dict_set_int(address, "not_address_type", 100),
169 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
170 ASSERT_RC(getdns_dict_set_bindata(address, "not_address_data", &address_data),
171 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
172
173 ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response),
174 GETDNS_RETURN_NO_SUCH_DICT_NAME, "Return code from getdns_hostname_sync()");
175
176 DICT_DESTROY(address);
177 CONTEXT_DESTROY;
178 }
179 END_TEST
180
181 START_TEST (getdns_hostname_sync_7)
182 {
183 /*
184 * dict in address contains names address_type
185 * and address_data but data type is not bindata
186 * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
187 */
188 struct getdns_context *context = NULL;
189 struct getdns_dict *address = NULL;
190 struct getdns_dict *response = NULL;
191
192 CONTEXT_CREATE(TRUE);
193
194 DICT_CREATE(address);
195 ASSERT_RC(getdns_dict_set_int(address, "address_type", 100),
196 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
197 ASSERT_RC(getdns_dict_set_int(address, "address_data", 200),
198 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
199
200 ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response),
201 GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_hostname_sync()");
202
203 DICT_DESTROY(address);
204 CONTEXT_DESTROY;
205 }
206 END_TEST
207
208 START_TEST (getdns_hostname_sync_8)
209 {
210 /*
211 * dict in address contains invalid address_type
212 * expect: GETDNS_RETURN_INVALID_PARAMETER
213 */
214 struct getdns_context *context = NULL;
215 struct getdns_dict *address = NULL;
216 struct getdns_bindata address_type = { 5, (void *)"IPv5" };
217 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
218 struct getdns_dict *response = NULL;
219
220 CONTEXT_CREATE(TRUE);
221
222 DICT_CREATE(address);
223 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
224 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
225 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
226 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
227
228 ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response),
229 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname_sync()");
230
231 DICT_DESTROY(address);
232 CONTEXT_DESTROY;
233 }
234 END_TEST
235
236 START_TEST (getdns_hostname_sync_9)
237 {
238 /*
239 * dict in address contains invalid address_data
240 * expect: GETDNS_RETURN_INVALID_PARAMETER
241 */
242 struct getdns_context *context = NULL;
243 struct getdns_dict *address = NULL;
244 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
245 struct getdns_bindata address_data = { 5, (void *)"\x08\x08\x08\x08\x08" };
246 struct getdns_dict *response = NULL;
247
248 CONTEXT_CREATE(TRUE);
249
250 DICT_CREATE(address);
251 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
252 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
253 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
254 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
255
256 ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response),
257 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_hostname_sync()");
258
259 DICT_DESTROY(address);
260 CONTEXT_DESTROY;
261 }
262 END_TEST
263
264 START_TEST (getdns_hostname_sync_10)
265 {
266 /*
267 * dict in address has resolvable IPv4 address
268 * expect: response with correct hostnam
269 */
270 struct getdns_context *context = NULL;
271 struct getdns_dict *address = NULL;
272 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
273 struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
274 struct getdns_dict *response = NULL;
275
276 CONTEXT_CREATE(TRUE);
277
278 DICT_CREATE(address);
279 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
280 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
281 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
282 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
283
284 ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response),
285 GETDNS_RETURN_GOOD, "Return code from getdns_hostname_sync()");
286
287 EXTRACT_RESPONSE;
288
289 assert_noerror(&ex_response);
290 assert_ptr_in_answer(&ex_response);
291
292 DICT_DESTROY(address);
293 CONTEXT_DESTROY;
294 }
295 END_TEST
296
297 START_TEST (getdns_hostname_sync_11)
298 {
299 /*
300 * dict in address has unresolvable IPv4 address
301 * expect: response with no hostname
302 */
303 struct getdns_context *context = NULL;
304 struct getdns_dict *address = NULL;
305 struct getdns_bindata address_type = { 5, (void *)"IPv4" };
306 struct getdns_bindata address_data = { 4, (void *)"\x01\x01\x01\x01" };
307 struct getdns_dict *response = NULL;
308
309 CONTEXT_CREATE(TRUE);
310
311 DICT_CREATE(address);
312 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
313 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
314 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
315 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
316
317 ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response),
318 GETDNS_RETURN_GOOD, "Return code from getdns_hostname_sync()");
319
320 EXTRACT_RESPONSE;
321
322 assert_nxdomain(&ex_response);
323 assert_nodata(&ex_response);
324 assert_soa_in_authority(&ex_response);
325
326 DICT_DESTROY(address);
327 CONTEXT_DESTROY;
328 }
329 END_TEST
330
331 START_TEST (getdns_hostname_sync_12)
332 {
333 /*
334 * dict in address has resolvable IPv6 address
335 * expect: response with correct hostnam
336 */
337 struct getdns_context *context = NULL;
338 struct getdns_dict *address = NULL;
339 struct getdns_bindata address_type = { 5, (void *)"IPv6" };
340 struct getdns_bindata address_data = { 16, (void *)"\x26\x07\xf8\xb0\x40\x06\x08\x02\x00\x00\x00\x00\x00\x00\x10\x04" };
341 struct getdns_dict *response = NULL;
342
343 CONTEXT_CREATE(TRUE);
344
345 DICT_CREATE(address);
346 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
347 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
348 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
349 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
350
351 ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response),
352 GETDNS_RETURN_GOOD, "Return code from getdns_hostname_sync()");
353
354 EXTRACT_RESPONSE;
355
356 assert_noerror(&ex_response);
357 assert_ptr_in_answer(&ex_response);
358
359 DICT_DESTROY(address);
360 CONTEXT_DESTROY;
361 }
362 END_TEST
363
364 START_TEST (getdns_hostname_sync_13)
365 {
366 /*
367 * dict in address has unresolvable IPv6 address
368 * expect: response with no hostname
369 */
370 struct getdns_context *context = NULL;
371 struct getdns_dict *address = NULL;
372 struct getdns_bindata address_type = { 5, (void *)"IPv6" };
373 struct getdns_bindata address_data = { 16, (void *)"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" };
374 struct getdns_dict *response = NULL;
375
376 CONTEXT_CREATE(TRUE);
377
378 DICT_CREATE(address);
379 ASSERT_RC(getdns_dict_set_bindata(address, "address_type", &address_type),
380 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
381 ASSERT_RC(getdns_dict_set_bindata(address, "address_data", &address_data),
382 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
383
384 ASSERT_RC(getdns_hostname_sync(context, address, NULL, &response),
385 GETDNS_RETURN_GOOD, "Return code from getdns_hostname_sync()");
386
387 EXTRACT_RESPONSE;
388
389 assert_nxdomain(&ex_response);
390 assert_nodata(&ex_response);
391 assert_soa_in_authority(&ex_response);
392
393 DICT_DESTROY(address);
394 CONTEXT_DESTROY;
395 }
396 END_TEST
397
398 Suite *
399 getdns_hostname_sync_suite (void)
400 {
401 Suite *s = suite_create ("getdns_hostname_sync()");
402
403 /* Negative test caseis */
404 TCase *tc_neg = tcase_create("Negative");
405 tcase_add_test(tc_neg, getdns_hostname_sync_1);
406 tcase_add_test(tc_neg, getdns_hostname_sync_2);
407 tcase_add_test(tc_neg, getdns_hostname_sync_3);
408 tcase_add_test(tc_neg, getdns_hostname_sync_4);
409 tcase_add_test(tc_neg, getdns_hostname_sync_5);
410 tcase_add_test(tc_neg, getdns_hostname_sync_6);
411 tcase_add_test(tc_neg, getdns_hostname_sync_7);
412 tcase_add_test(tc_neg, getdns_hostname_sync_8);
413 tcase_add_test(tc_neg, getdns_hostname_sync_9);
414 suite_add_tcase(s, tc_neg);
415 /* Positive test cases */
416
417 TCase *tc_pos = tcase_create("Positive");
418 tcase_add_test(tc_pos, getdns_hostname_sync_10);
419 tcase_add_test(tc_pos, getdns_hostname_sync_11);
420 tcase_add_test(tc_pos, getdns_hostname_sync_12);
421 tcase_add_test(tc_pos, getdns_hostname_sync_13);
422 suite_add_tcase(s, tc_pos);
423
424 return s;
425 }
426
427 #endif
0 /**
1 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7
8 /*
9 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include "check_getdns_eventloop.h"
36
37 #include <getdns/getdns_ext_libev.h>
38 #include <ev.h>
39 #include <check.h>
40 #include "check_getdns_common.h"
41
42 void run_event_loop_impl(struct getdns_context* context, void* eventloop) {
43 struct ev_loop* loop = (struct ev_loop*) eventloop;
44 ev_run(loop, 0);
45 }
46
47 void* create_eventloop_impl(struct getdns_context* context) {
48 struct ev_loop* result = ev_default_loop(0);
49 ck_assert_msg(result != NULL, "EV loop creation failed");
50 ASSERT_RC(getdns_extension_set_libev_loop(context, result),
51 GETDNS_RETURN_GOOD,
52 "Return code from getdns_extension_set_libev_loop()");
53 return result;
54 }
0 /**
1 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7
8 /*
9 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include "check_getdns_eventloop.h"
36
37 #include <getdns/getdns_ext_libevent.h>
38 #include "check_getdns_libevent.h"
39 #include <check.h>
40 #include "check_getdns_common.h"
41
42 void run_event_loop_impl(struct getdns_context* context, void* eventloop) {
43 struct event_base* base = (struct event_base*) eventloop;
44 event_base_dispatch(base);
45 }
46
47 void* create_eventloop_impl(struct getdns_context* context) {
48 struct event_base* result = event_base_new();
49 ck_assert_msg(result != NULL, "Event base creation failed");
50 ASSERT_RC(getdns_extension_set_libevent_base(context, result),
51 GETDNS_RETURN_GOOD,
52 "Return code from getdns_extension_set_libevent_base()");
53 return result;
54 }
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifdef HAVE_EVENT2_EVENT_H
27 #include <event2/event.h>
28 #else
29 # ifndef u_char
30 # define u_char unsigned char
31 # endif
32 #include <event.h>
33 #endif
0 /**
1 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7
8 /*
9 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include "check_getdns_eventloop.h"
36
37 #include <getdns/getdns_ext_libuv.h>
38 #include <uv.h>
39 #include <check.h>
40 #include "check_getdns_common.h"
41
42 void run_event_loop_impl(struct getdns_context* context, void* eventloop) {
43 uv_loop_t* loop = (uv_loop_t*) eventloop;
44 uv_run(loop, UV_RUN_DEFAULT);
45 }
46
47
48 void* create_eventloop_impl(struct getdns_context* context) {
49 uv_loop_t* result = uv_default_loop();
50 ck_assert_msg(result != NULL, "UV loop creation failed");
51 ASSERT_RC(getdns_extension_set_libuv_loop(context, result),
52 GETDNS_RETURN_GOOD,
53 "Return code from getdns_extension_set_libuv_loop()");
54 return result;
55 }
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_list_get_bindata_h_
27 #define _check_getdns_list_get_bindata_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ L I S T _ G E T _ N A M E *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_list_get_bindata_1)
38 {
39 /*
40 * list = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_list *list = NULL;
44 size_t index = 0;
45 struct getdns_bindata *answer = NULL;
46
47 ASSERT_RC(getdns_list_get_bindata(list, index, &answer),
48 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_names()");
49
50 }
51 END_TEST
52
53 START_TEST (getdns_list_get_bindata_2)
54 {
55 /* index is out of range
56 * create a list and and set index 0 to an int with a value of 100
57 * Call getdns_get_list() for index 1
58 * expect: GETDNS_RETURN_INVALID_PARAMETER
59 */
60 struct getdns_list *list = NULL;
61 size_t index = 0;
62
63 LIST_CREATE(list);
64
65 ASSERT_RC(getdns_list_set_int(list, index, 1),
66 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
67
68 index++;
69 ASSERT_RC(getdns_list_get_bindata(list, index, NULL),
70 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_bindata()");
71
72 LIST_DESTROY(list);
73 }
74 END_TEST
75
76 START_TEST (getdns_list_get_bindata_3)
77 {
78 /* data type at index is not int
79 * create a list and set index 0 to an int with a value of 100
80 * Call getdns_list_get_bindata() for index 0
81 * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
82 */
83 struct getdns_list *list = NULL;
84 size_t index = 0;
85 struct getdns_bindata *answer = NULL;
86
87 LIST_CREATE(list);
88
89 ASSERT_RC(getdns_list_set_int(list, index, 1),
90 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
91
92
93 ASSERT_RC(getdns_list_get_bindata(list, index, &answer),
94 GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_list_get_bindata()");
95
96 LIST_DESTROY(list);
97 }
98 END_TEST
99
100 START_TEST (getdns_list_get_bindata_4)
101 {
102 /* answer is NULL
103 * expect: GETDNS_RETURN_INVALID_PARAMETER
104 */
105 struct getdns_list *list = NULL;
106 size_t index = 0;
107
108 ASSERT_RC(getdns_list_get_bindata(list, index, NULL),
109 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_bindata()");
110 }
111 END_TEST
112
113 START_TEST (getdns_list_get_bindata_5)
114 {
115 /*
116 * create a list
117 * Create some bindata containing "bindata" and add it to the list with name = "bindata"
118 * Set list value at index 0 via getdns_list_set_list() to the bindata
119 * Call getdns_list_get_list() for index 0
120 * expect: GETDNS_RETURN_GOOD
121 */
122 struct getdns_list *list = NULL;
123 struct getdns_bindata bindata = { 8, (void *)"bindata" };
124 size_t index = 0;
125 struct getdns_bindata *answer = NULL;
126
127 LIST_CREATE(list);
128
129 ASSERT_RC(getdns_list_set_bindata(list, index, &bindata),
130 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
131
132
133 ASSERT_RC(getdns_list_get_bindata(list, index, &answer),
134 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_bindata()");
135
136 ck_assert_msg(strcmp((char *)answer->data, (char *)bindata.data) == 0,
137 "Expected bindata data to be \"%s\", got: \"%s\"",
138 (char *)bindata.data, (char *)answer->data);
139
140 LIST_DESTROY(list);
141 }
142 END_TEST
143
144
145
146
147
148
149 Suite *
150 getdns_list_get_bindata_suite (void)
151 {
152 Suite *s = suite_create ("getdns_list_get_bindata()");
153
154 /* Negative test caseis */
155 TCase *tc_neg = tcase_create("Negative");
156 tcase_add_test(tc_neg, getdns_list_get_bindata_1);
157 tcase_add_test(tc_neg, getdns_list_get_bindata_2);
158 tcase_add_test(tc_neg, getdns_list_get_bindata_3);
159 tcase_add_test(tc_neg, getdns_list_get_bindata_4);
160 suite_add_tcase(s, tc_neg);
161
162 /* Positive test cases */
163 TCase *tc_pos = tcase_create("Positive");
164 tcase_add_test(tc_pos, getdns_list_get_bindata_5);
165 suite_add_tcase(s, tc_pos);
166
167 return s;
168 }
169
170 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_list_get_data_type_h_
27 #define _check_getdns_list_get_data_type_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ L I S T _ G E T _ D A T A _ T Y P E *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_list_get_data_type_1)
38 {
39 /*
40 * list = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_list *list = NULL;
44 size_t index = 0;
45 getdns_data_type answer;
46
47 ASSERT_RC(getdns_list_get_data_type(list, index, &answer),
48 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_data_type()");
49 }
50 END_TEST
51
52 START_TEST (getdns_list_get_data_type_2)
53 {
54 /*
55 * index is out of range
56 * Create a list, add an int to it, and then attempt
57 * to get the data type at index 1
58 * expect: GETDNS_RETURN_NO_SUCH_LIST_ITEM
59 */
60 struct getdns_list *list = NULL;
61 size_t index = 0;
62 getdns_data_type answer;
63
64 LIST_CREATE(list);
65
66 ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD,
67 "Return code from getdns_list_set_int()");
68
69 index++;
70 ASSERT_RC(getdns_list_get_data_type(list, index, &answer),
71 GETDNS_RETURN_NO_SUCH_LIST_ITEM, "Return code from getdns_list_get_data_type()");
72
73 LIST_DESTROY(list);
74 }
75 END_TEST
76
77 START_TEST (getdns_list_get_data_type_3)
78 {
79 /*
80 * answer = NULL
81 * expect: GETDNS_RETURN_INVALID_PARAMETER
82 */
83 struct getdns_list *list = NULL;
84 size_t index = 0;
85
86 LIST_CREATE(list);
87
88 ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD,
89 "Return code from getdns_list_set_int()");
90
91 ASSERT_RC(getdns_list_get_data_type(list, index, NULL),
92 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_data_type()");
93
94 LIST_DESTROY(list);
95 }
96 END_TEST
97
98 START_TEST (getdns_list_get_data_type_4)
99 {
100 /*
101 * Create a list (empty) and attempt to get the
102 * data type at index 0.
103 * expect: GETDNS_RETURN_NO_SUCH_LIST_ITEM
104 */
105 struct getdns_list *list = NULL;
106 size_t index = 0;
107 getdns_data_type answer;
108
109 LIST_CREATE(list);
110
111 ASSERT_RC(getdns_list_get_data_type(list, index, &answer),
112 GETDNS_RETURN_NO_SUCH_LIST_ITEM, "Return code from getdns_list_get_data_type()");
113
114 LIST_DESTROY(list);
115 }
116 END_TEST
117
118 START_TEST (getdns_list_get_data_type_5)
119 {
120 /*
121 * Create a list, create a dict, set list value at index 0
122 * to the dict, and then get the data type at index 0.
123 * data type at index 0.
124 * expect: GETDNS_RETURN_GOOD
125 * answer = t_dict (retrieved data type)
126 */
127 struct getdns_list *list = NULL;
128 struct getdns_dict *dict = NULL;
129 size_t index = 0;
130 getdns_data_type answer;
131
132 LIST_CREATE(list);
133 DICT_CREATE(dict);
134
135 ASSERT_RC(getdns_list_set_dict(list, index, dict), GETDNS_RETURN_GOOD,
136 "Return code from getdns_list_set_dict()");
137
138 ASSERT_RC(getdns_list_get_data_type(list, index, &answer),
139 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_data_type()");
140
141 ck_assert_msg(answer == t_dict,
142 "Wrong data type, expected t_dict: %d, got %d", t_dict, answer);
143
144 LIST_DESTROY(list);
145 DICT_DESTROY(dict);
146 }
147 END_TEST
148
149 START_TEST (getdns_list_get_data_type_6)
150 {
151 /*
152 * Create a list, create a second list, set list value at
153 * index 0 to the second list, and then get the data type
154 * at index 0.
155 * expect: GETDNS_RETURN_GOOD
156 * answer = t_list (retrieved data type)
157 */
158 struct getdns_list *list1 = NULL;
159 struct getdns_list *list2 = NULL;
160 size_t index = 0;
161 getdns_data_type answer;
162
163 LIST_CREATE(list1);
164 LIST_CREATE(list2);
165
166 ASSERT_RC(getdns_list_set_list(list1, index, list2), GETDNS_RETURN_GOOD,
167 "Return code from getdns_list_set_list()");
168
169 ASSERT_RC(getdns_list_get_data_type(list1, index, &answer),
170 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_data_type()");
171
172 ck_assert_msg(answer == t_list,
173 "Wrong data type, expected t_list: %d, got %d", t_list, answer);
174
175 LIST_DESTROY(list1);
176 LIST_DESTROY(list2);
177 }
178 END_TEST
179
180 START_TEST (getdns_list_get_data_type_7)
181 {
182 /*
183 * Create a list, create some bindata, set list value at
184 * index 0 to the bindata, and then get the data type at
185 * index 0.
186 * expect: GETDNS_RETURN_GOOD
187 * answer = t_bindata (retrieved data type)
188 */
189 struct getdns_list *list = NULL;
190 struct getdns_bindata bindata = { 8, (void *)"bindata" };
191 size_t index = 0;
192 getdns_data_type answer;
193
194 LIST_CREATE(list);
195
196 ASSERT_RC(getdns_list_set_bindata(list, index, &bindata), GETDNS_RETURN_GOOD,
197 "Return code from getdns_list_set_bindata()");
198
199 ASSERT_RC(getdns_list_get_data_type(list, index, &answer),
200 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_data_type()");
201
202 ck_assert_msg(answer == t_bindata,
203 "Wrong data type, expected t_bindata: %d, got %d", t_bindata, answer);
204
205 LIST_DESTROY(list);
206 }
207 END_TEST
208
209 START_TEST (getdns_list_get_data_type_8)
210 {
211 /*
212 * Create a list, set list value at index 0 to 100 (int),
213 * and then get the data type at index 0.
214 * expect: GETDNS_RETURN_GOOD
215 * answer = t_int (retrieved data type)
216 */
217 struct getdns_list *list = NULL;
218 size_t index = 0;
219 getdns_data_type answer;
220
221 LIST_CREATE(list);
222
223 ASSERT_RC(getdns_list_set_int(list, index, 100), GETDNS_RETURN_GOOD,
224 "Return code from getdns_list_set_int()");
225
226 ASSERT_RC(getdns_list_get_data_type(list, index, &answer),
227 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_data_type()");
228
229 ck_assert_msg(answer == t_int,
230 "Wrong data type, expected t_int: %d, got %d", t_int, answer);
231
232 LIST_DESTROY(list);
233 }
234 END_TEST
235
236 Suite *
237 getdns_list_get_data_type_suite (void)
238 {
239 Suite *s = suite_create ("getdns_list_get_data_type()");
240
241 /* Negative test caseis */
242 TCase *tc_neg = tcase_create("Negative");
243 tcase_add_test(tc_neg, getdns_list_get_data_type_1);
244 tcase_add_test(tc_neg, getdns_list_get_data_type_2);
245 tcase_add_test(tc_neg, getdns_list_get_data_type_3);
246 tcase_add_test(tc_neg, getdns_list_get_data_type_4);
247 suite_add_tcase(s, tc_neg);
248
249 /* Positive test cases */
250 TCase *tc_pos = tcase_create("Positive");
251 tcase_add_test(tc_pos, getdns_list_get_data_type_5);
252 tcase_add_test(tc_pos, getdns_list_get_data_type_6);
253 tcase_add_test(tc_pos, getdns_list_get_data_type_7);
254 tcase_add_test(tc_pos, getdns_list_get_data_type_8);
255 suite_add_tcase(s, tc_pos);
256
257 return s;
258 }
259
260 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_list_get_dict_h_
27 #define _check_getdns_list_get_dict_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ L I S T _ G E T _ D I C T *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_list_get_dict_1)
38 {
39 /*
40 * list = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_list *list = NULL;
44 size_t index = 0;
45 struct getdns_dict *answer = NULL;
46
47 ASSERT_RC(getdns_list_get_dict(list, index, &answer),
48 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_dict()");
49 }
50 END_TEST
51
52 START_TEST (getdns_list_get_dict_2)
53 {
54 /*
55 * index is out of range
56 * Create a list, add an dict to it, and then attempt
57 * expect: GETDNS_RETURN_INVALID_PARAMETER
58 */
59 struct getdns_list *list = NULL;
60 size_t index = 0;
61 struct getdns_dict *answer = NULL;
62
63 LIST_CREATE(list);
64 DICT_CREATE(answer);
65
66 ASSERT_RC(getdns_list_set_int(list, index, 1), GETDNS_RETURN_GOOD,
67 "Return code from getdns_list_set_int()");
68
69 index++;
70 ASSERT_RC(getdns_list_get_dict(list, index, NULL),
71 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_dict()");
72
73
74 LIST_DESTROY(list);
75 DICT_DESTROY(answer);
76 }
77 END_TEST
78
79 START_TEST (getdns_list_get_dict_3)
80 {
81 /*
82 * data type at index is not dict
83 * create a list
84 * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
85 */
86 struct getdns_list *list = NULL;
87 struct getdns_dict *answer = NULL;
88 size_t index = 0;
89
90 LIST_CREATE(list);
91 DICT_CREATE(answer);
92
93 ASSERT_RC(getdns_list_set_int(list, index, 10), GETDNS_RETURN_GOOD,
94 "Return code from getdns_list_set_int()");
95
96 ASSERT_RC(getdns_list_get_dict(list, index, &answer),
97 GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_list_get_dict()");
98
99 LIST_DESTROY(list);
100 DICT_DESTROY(answer);
101 }
102 END_TEST
103
104
105 START_TEST (getdns_list_get_dict_4)
106 {
107 /*
108 * answer = NULL
109 * expect: GETDNS_RETURN_INVALID_PARAMETER
110 */
111 struct getdns_list *list = NULL;
112 size_t index = 0;
113
114 ASSERT_RC(getdns_list_get_dict(list, index, NULL),
115 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_dict()");
116 }
117 END_TEST
118
119
120
121
122
123 START_TEST (getdns_list_get_dict_5)
124 {
125 /*
126 * create a list
127 * Create a dict with one int (name = "ten", value = 10)
128 * Call getdns_dict_get_list() with name = "ten"
129 * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
130 */
131 struct getdns_dict *dict = NULL;
132 size_t index = 0;
133 struct getdns_dict *answer = NULL;
134
135 struct getdns_list *list = NULL;
136 uint32_t value;
137
138 LIST_CREATE(list);
139 DICT_CREATE(dict);
140
141 ASSERT_RC(getdns_dict_set_int(dict, "ten", 10),
142 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
143
144 ASSERT_RC(getdns_list_set_dict(list, index, dict), GETDNS_RETURN_GOOD,
145 "Return code from getdns_list_set_dict()");
146
147 ASSERT_RC(getdns_list_get_dict(list, index, &answer),
148 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_dict()");
149
150 ASSERT_RC(getdns_dict_get_int(answer, "ten", &value),
151 GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_int()");
152
153 ck_assert_msg(value == 10, "Expected retrieved int == 10, got: %d",
154 value);
155
156
157 LIST_DESTROY(list);
158 DICT_DESTROY(dict);
159 }
160 END_TEST
161
162
163
164
165
166 Suite *
167 getdns_list_get_dict_suite (void)
168 {
169 Suite *s = suite_create ("getdns_list_get_dict()");
170
171 /* Negative test caseis */
172 TCase *tc_neg = tcase_create("Negative");
173 tcase_add_test(tc_neg, getdns_list_get_dict_1);
174 tcase_add_test(tc_neg, getdns_list_get_dict_2);
175 tcase_add_test(tc_neg, getdns_list_get_dict_3);
176 tcase_add_test(tc_neg, getdns_list_get_dict_4);
177 suite_add_tcase(s, tc_neg);
178
179 /* Positive test cases */
180 TCase *tc_pos = tcase_create("Positive");
181 tcase_add_test(tc_pos, getdns_list_get_dict_5);
182 suite_add_tcase(s, tc_pos);
183
184 return s;
185 }
186
187 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_list_get_int_h_
27 #define _check_getdns_list_get_int_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ L I S T _ G E T _ I N T *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_list_get_int_1)
38 {
39 /*
40 * list = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_list *list = NULL;
44 size_t index = 0;
45 uint32_t answer;
46
47 ASSERT_RC(getdns_list_get_int(list, index, &answer),
48 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_int()");
49 }
50 END_TEST
51
52 START_TEST (getdns_list_get_int_2)
53 {
54 /* index is out of range
55 * create a list and set index 0 to an int with a value of 100
56 * Call getdns_get_list() for index 1
57 * expect: GETDNS_RETURN_INVALID_PARAMETER
58 */
59 struct getdns_list *list = NULL;
60 size_t index = 0;
61
62 LIST_CREATE(list);
63
64 ASSERT_RC(getdns_list_set_int(list, index, 1),
65 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
66
67 index++;
68 ASSERT_RC(getdns_list_get_list(list, index, NULL),
69 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_list()");
70
71 LIST_DESTROY(list);
72 }
73 END_TEST
74
75 START_TEST (getdns_list_get_int_3)
76 {
77 /* data type at index is not int
78 * create a list
79 * Create some bindata containing "bindata" and add it to the list with name = "bindata"
80 * expect: GETDNS_RETURN_INVALID_PARAMETER
81 */
82 struct getdns_list *list = NULL;
83 struct getdns_bindata bindata = { 8, (void *)"bindata" };
84 size_t index = 0;
85 uint32_t answer;
86
87 LIST_CREATE(list);
88
89 ASSERT_RC(getdns_list_set_bindata(list, index, &bindata),
90 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
91
92
93 ASSERT_RC(getdns_list_get_int(list, index, &answer),
94 GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_list_get_list()");
95
96 LIST_DESTROY(list);
97 }
98 END_TEST
99
100 START_TEST (getdns_list_get_int_4)
101 {
102 /* answer is NULL
103 * expect: GETDNS_RETURN_INVALID_PARAMETER
104 */
105 struct getdns_list *list = NULL;
106 size_t index = 0;
107
108 ASSERT_RC(getdns_list_get_int(list, index, NULL),
109 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_int()");
110 }
111 END_TEST
112
113 START_TEST (getdns_list_get_int_5)
114 {
115 /* create a list
116 * expect: GETDNS_RETURN_GOOD
117 */
118 struct getdns_list *list = NULL;
119 size_t index = 0;
120 uint32_t answer;
121
122
123 LIST_CREATE(list);
124
125 ASSERT_RC(getdns_list_set_int(list, index, 1),
126 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
127
128
129 ASSERT_RC(getdns_list_get_int(list, index, &answer),
130 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_int()");
131
132 ck_assert_msg(answer == 1, "Expected retrieved int == 1, got: %d",
133 answer);
134
135 LIST_DESTROY(list);
136 }
137 END_TEST
138
139
140
141
142
143
144 Suite *
145 getdns_list_get_int_suite (void)
146 {
147 Suite *s = suite_create ("getdns_list_get_int()");
148
149 /* Negative test caseis */
150 TCase *tc_neg = tcase_create("Negative");
151 tcase_add_test(tc_neg, getdns_list_get_int_1);
152 tcase_add_test(tc_neg, getdns_list_get_int_2);
153 tcase_add_test(tc_neg, getdns_list_get_int_3);
154 tcase_add_test(tc_neg, getdns_list_get_int_4);
155 suite_add_tcase(s, tc_neg);
156
157 /* Positive test cases */
158 TCase *tc_pos = tcase_create("Positive");
159 tcase_add_test(tc_pos, getdns_list_get_int_5);
160 suite_add_tcase(s, tc_pos);
161
162 return s;
163 }
164
165 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_list_get_length_h_
27 #define _check_getdns_list_get_length_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ L I S T _ G E T _ L E N G T H *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_list_get_length_1)
38 {
39 /*
40 * list = NULL
41 * expect = GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_list *list = NULL;
44 size_t length;
45
46 ASSERT_RC(getdns_list_get_length(list, &length),
47 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_length()");
48
49 }
50 END_TEST
51
52 START_TEST (getdns_list_get_length_2)
53 {
54 /*
55 * answer = NULL
56 * expect: GETDNS_RETURN_INVALID_PARAMETER
57 */
58 struct getdns_list *list = NULL;
59
60 LIST_CREATE(list);
61
62 ASSERT_RC(getdns_list_get_length(list, NULL),
63 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_length()");
64
65 LIST_DESTROY(list);
66 }
67 END_TEST
68
69 START_TEST (getdns_list_get_length_3)
70 {
71 /*
72 * Create a list, add 3 ints to it, get the length.
73 * expect: GETDNS_RETURN_GOOD
74 * length = 3
75 */
76 struct getdns_list *list = NULL;
77 size_t i;
78 size_t length;
79
80 LIST_CREATE(list);
81
82 for(i = 0; i < 3; i++)
83 {
84 ASSERT_RC(getdns_list_set_int(list, i, i), GETDNS_RETURN_GOOD,
85 "Return code from getdns_list_set_int()");
86 }
87
88 ASSERT_RC(getdns_list_get_length(list, &length),
89 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()");
90
91 ck_assert_msg(length == 3, "Expected length == 3, got %d", length);
92
93 LIST_DESTROY(list);
94 }
95 END_TEST
96
97 START_TEST (getdns_list_get_length_4)
98 {
99 /*
100 * Create a list (empty) and get the length
101 * expect: GETDNS_RETURN_GOOD
102 * length = 3
103 */
104 struct getdns_list *list = NULL;
105 size_t length;
106
107 LIST_CREATE(list);
108
109 ASSERT_RC(getdns_list_get_length(list, &length),
110 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()");
111
112 ck_assert_msg(length == 0, "Expected length == 3, got %d", length);
113
114 LIST_DESTROY(list);
115 }
116 END_TEST
117
118 Suite *
119 getdns_list_get_length_suite (void)
120 {
121 Suite *s = suite_create ("getdns_list_get_length()");
122
123 /* Negative test caseis */
124 TCase *tc_neg = tcase_create("Negative");
125 tcase_add_test(tc_neg, getdns_list_get_length_1);
126 tcase_add_test(tc_neg, getdns_list_get_length_2);
127 suite_add_tcase(s, tc_neg);
128
129 /* Positive test cases */
130 TCase *tc_pos = tcase_create("Positive");
131 tcase_add_test(tc_pos, getdns_list_get_length_3);
132 tcase_add_test(tc_pos, getdns_list_get_length_4);
133 suite_add_tcase(s, tc_pos);
134
135 return s;
136 }
137
138 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_list_get_list_h_
27 #define _check_getdns_list_get_list_h_
28
29 /*
30 **************************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ L I S T _ G E T _ L I S T *
33 * *
34 **************************************************************************
35 */
36
37 START_TEST (getdns_list_get_list_1)
38 {
39 /*
40 * list = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_list *list = NULL;
44 size_t index = 0;
45 struct getdns_list *answer = NULL;
46
47 ASSERT_RC(getdns_list_get_list(list, index, &answer),
48 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_list()");
49 }
50 END_TEST
51
52 START_TEST (getdns_list_get_list_2)
53 {
54 /* index is out of range
55 * create a list and set index 0 to an int with a value of 100
56 * Call getdns_get_list() for index 1
57 * expect: GETDNS_RETURN_INVALID_PARAMETER
58 */
59 struct getdns_list *list = NULL;
60 size_t index = 0;
61
62 LIST_CREATE(list);
63
64 ASSERT_RC(getdns_list_set_int(list, index, 1),
65 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
66
67 index++;
68 ASSERT_RC(getdns_list_get_list(list,index,NULL),
69 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_list()");
70
71 LIST_DESTROY(list);
72 }
73 END_TEST
74
75
76 START_TEST (getdns_list_get_list_3)
77 {
78 /* data type at index is not a list
79 * create a list and set index 0 to an int with a value of 100
80 * expect: GETDNS_RETURN_WRONG_TYPE_REQUESTED
81 */
82 struct getdns_list *list = NULL;
83 size_t index = 0;
84 struct getdns_list *answer = NULL;
85
86 LIST_CREATE(list);
87
88 ASSERT_RC(getdns_list_set_int(list, index, 1),
89 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
90
91 ASSERT_RC(getdns_list_get_list(list, index, &answer),
92 GETDNS_RETURN_WRONG_TYPE_REQUESTED, "Return code from getdns_list_get_list()");
93
94 LIST_DESTROY(list);
95 }
96 END_TEST
97
98 START_TEST (getdns_list_get_list_4)
99 {
100 /* answer == NULL
101 * expect: GETDNS_RETURN_INVALID_PARAMETER
102 */
103 struct getdns_list *list = NULL;
104 size_t index = 0;
105
106 ASSERT_RC(getdns_list_get_list(list, index, NULL),
107 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_list_get_list()");
108 }
109 END_TEST
110
111 START_TEST (getdns_list_get_list_5)
112 {
113 /* create a list. Also create a second list
114 * Set list value at index 0 in the second list via getdns_list_set_int() to 45
115 * Set list value at index 0 in the first list via getdns_list_set_list() to the second list
116 * Call getdns_list_get_list() for index 0 against the first list
117 * Call getdns_list_get_int() for index 0 against retrieved list
118 * expect: GETDNS_RETURN_GOOD
119 */
120 struct getdns_list *list = NULL;
121 struct getdns_list *second_list = NULL;
122 size_t index = 0;
123 struct getdns_list *answer = NULL;
124 uint32_t value;
125
126 LIST_CREATE(list);
127 LIST_CREATE(second_list);
128
129 ASSERT_RC(getdns_list_set_int(second_list, index, 45),
130 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
131
132 ASSERT_RC(getdns_list_set_list(list, index, second_list),
133 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()");
134
135 ASSERT_RC(getdns_list_get_list(list, index, &answer),
136 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_list()");
137
138 ASSERT_RC(getdns_list_get_int(answer, index, &value),
139 GETDNS_RETURN_GOOD, "Return code from getdns_list_get_int()");
140
141 ck_assert_msg(value == 45, "Expected retrieved int == 45, got: %d",
142 value);
143
144 LIST_DESTROY(list);
145 LIST_DESTROY(second_list);
146 }
147 END_TEST
148
149
150
151
152
153
154 Suite *
155 getdns_list_get_list_suite (void)
156 {
157 Suite *s = suite_create ("getdns_list_get_list()");
158
159 /* Negative test caseis */
160 TCase *tc_neg = tcase_create("Negative");
161 tcase_add_test(tc_neg, getdns_list_get_list_1);
162 tcase_add_test(tc_neg, getdns_list_get_list_2);
163 tcase_add_test(tc_neg, getdns_list_get_list_3);
164 tcase_add_test(tc_neg, getdns_list_get_list_4);
165 suite_add_tcase(s, tc_neg);
166
167 /* Positive test cases */
168 TCase *tc_pos = tcase_create("Positive");
169 tcase_add_test(tc_pos, getdns_list_get_list_5);
170 suite_add_tcase(s, tc_pos);
171
172 return s;
173 }
174
175 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_pretty_print_dict_h_
27 #define _check_getdns_pretty_print_dict_h_
28
29 static const char pretty_expected[] = "{\n"
30 " \"bindata\": <bindata of \"bindata\">,\n"
31 " \"dict\":\n"
32 " {\n"
33 " \"bindata\": <bindata of \"bindata\">,\n"
34 " \"dict\":\n"
35 " {\n"
36 " \"bindata\": <bindata of \"bindata\">,\n"
37 " \"dict\":\n"
38 " {\n"
39 " \"int\": 4\n"
40 " },\n"
41 " \"int\": 3,\n"
42 " \"list\":\n"
43 " [\n"
44 " 5\n"
45 " ]\n"
46 " },\n"
47 " \"int\": 2,\n"
48 " \"list\":\n"
49 " [\n"
50 " 6,\n"
51 " <bindata of \"bindata\">,\n"
52 " {\n"
53 " \"bindata\": <bindata of \"bindata\">\n"
54 " },\n"
55 " [\n"
56 " <bindata of \"bindata\">\n"
57 " ]\n"
58 " ]\n"
59 " },\n"
60 " \"int\": 1,\n"
61 " \"list\":\n"
62 " [\n"
63 " 7,\n"
64 " <bindata of \"bindata\">,\n"
65 " {\n"
66 " \"bindata\": <bindata of \"bindata\">,\n"
67 " \"dict\":\n"
68 " {\n"
69 " \"int\": 9\n"
70 " },\n"
71 " \"int\": 8,\n"
72 " \"list\":\n"
73 " [\n"
74 " 10\n"
75 " ]\n"
76 " },\n"
77 " [\n"
78 " 11,\n"
79 " <bindata of \"bindata\">,\n"
80 " {\n"
81 " \"bindata\": <bindata of \"bindata\">\n"
82 " },\n"
83 " [\n"
84 " <bindata of \"bindata\">\n"
85 " ]\n"
86 " ]\n"
87 " ]\n"
88 "}";
89
90 /*
91 **************************************************************************
92 * *
93 * T E S T S F O R G E T D N S _ D I C T _ D E S T R O Y *
94 * *
95 **************************************************************************
96 */
97
98 START_TEST (getdns_pretty_print_dict_1)
99 {
100 /*
101 * this_dict = NULL
102 * expect: nothing
103 */
104 struct getdns_dict *some_dict = NULL;
105
106 DICT_DESTROY(some_dict);
107 }
108 END_TEST
109
110 START_TEST (getdns_pretty_print_dict_2)
111 {
112 /*
113 * build a complex dict and then print it
114 *
115 * dict1-> "int" = 1
116 * -> "bindata" = { 8, "bindata" }
117 * -> "dict" = dict2->"int" = 2
118 * -> "bindata" = { 8, "bindata" }
119 * -> "dict" = dict3 -> "int" = 3
120 * -> "bindata" = { 8, "bindata" }
121 * -> "dict" = dict4 -> "int" = 4
122 * -> "list" = list1 0: int = 5
123 * -> "list" = list2 0: int = 6
124 * 1: bindata = { 8, "bindata" }
125 * 2: dict = dict5 -> "bindata" = { 8, "bindata" }
126 * 3: list = list3 0: bindata = { 8, "bindata" }
127 * -> "list" = list4 0: int = 7
128 * 1: bindata = { 8, "bindata" }
129 * 2: dict6 -> "int" = 8
130 * -> "bindata" = { 8, "bindata" }
131 * -> "dict" = dict7 -> "int" = 9
132 * -> "list" = list5 0: int = 10
133 * 3: list6 0: int = 11
134 * 1: bindata = { 8, "bindata" }
135 * 2: dict8 -> "bindata" = { 8, "bindata" }
136 * 3: list7 0: bindata = { 8, "bindata" }
137 *
138 * expect: string to accurately represent dict defined above
139 */
140 struct getdns_bindata bindata = { 8, (void *)"bindata" };
141 struct getdns_list *list7;
142 struct getdns_dict *dict8;
143 struct getdns_list *list6;
144 struct getdns_list *list5;
145 struct getdns_dict *dict7;
146 struct getdns_dict *dict6;
147 struct getdns_list *list4;
148 struct getdns_list *list3;
149 struct getdns_dict *dict5;
150 struct getdns_list *list2;
151 struct getdns_list *list1;
152 struct getdns_dict *dict4;
153 struct getdns_dict *dict3;
154 struct getdns_dict *dict2;
155 struct getdns_dict *dict1;
156 char *pretty = NULL;
157
158 /*
159 * Build it backwards, with the deepest elements first.
160 */
161
162 LIST_CREATE(list7);
163 ASSERT_RC(getdns_list_set_bindata(list7, 0, &bindata),
164 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
165
166 DICT_CREATE(dict8);
167 ASSERT_RC(getdns_dict_set_bindata(dict8, "bindata", &bindata),
168 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
169
170 LIST_CREATE(list6);
171 ASSERT_RC(getdns_list_set_int(list6, 0, 11),
172 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
173 ASSERT_RC(getdns_list_set_bindata(list6, 1, &bindata),
174 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
175 ASSERT_RC(getdns_list_set_dict(list6, 2, dict8),
176 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()");
177 ASSERT_RC(getdns_list_set_list(list6, 3, list7),
178 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()");
179
180 LIST_CREATE(list5);
181 ASSERT_RC(getdns_list_set_int(list5, 0, 10),
182 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
183
184 DICT_CREATE(dict7);
185 ASSERT_RC(getdns_dict_set_int(dict7, "int", 9),
186 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
187
188 DICT_CREATE(dict6);
189 ASSERT_RC(getdns_dict_set_int(dict6, "int", 8),
190 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
191 ASSERT_RC(getdns_dict_set_bindata(dict6, "bindata", &bindata),
192 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
193 ASSERT_RC(getdns_dict_set_dict(dict6, "dict", dict7),
194 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
195 ASSERT_RC(getdns_dict_set_list(dict6, "list", list5),
196 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
197
198 LIST_CREATE(list4);
199 ASSERT_RC(getdns_list_set_int(list4, 0, 7),
200 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
201 ASSERT_RC(getdns_list_set_bindata(list4, 1, &bindata),
202 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
203 ASSERT_RC(getdns_list_set_dict(list4, 2, dict6),
204 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()");
205 ASSERT_RC(getdns_list_set_list(list4, 3, list6),
206 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()");
207
208 LIST_CREATE(list3);
209 ASSERT_RC(getdns_list_set_bindata(list3, 0, &bindata),
210 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
211
212 DICT_CREATE(dict5);
213 ASSERT_RC(getdns_dict_set_bindata(dict5, "bindata", &bindata),
214 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
215
216 LIST_CREATE(list2);
217 ASSERT_RC(getdns_list_set_int(list2, 0, 6),
218 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
219 ASSERT_RC(getdns_list_set_bindata(list2, 1, &bindata),
220 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
221 ASSERT_RC(getdns_list_set_dict(list2, 2, dict5),
222 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_dict()");
223 ASSERT_RC(getdns_list_set_list(list2, 3, list3),
224 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_list()");
225
226 LIST_CREATE(list1);
227 ASSERT_RC(getdns_list_set_int(list1, 0, 5),
228 GETDNS_RETURN_GOOD, "Return code from getdns_list_set_int()");
229
230 DICT_CREATE(dict4);
231 ASSERT_RC(getdns_dict_set_int(dict4, "int", 4),
232 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
233
234 DICT_CREATE(dict3);
235 ASSERT_RC(getdns_dict_set_int(dict3, "int", 3),
236 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
237 ASSERT_RC(getdns_dict_set_bindata(dict3, "bindata", &bindata),
238 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
239 ASSERT_RC(getdns_dict_set_dict(dict3, "dict", dict4),
240 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
241 ASSERT_RC(getdns_dict_set_list(dict3, "list", list1),
242 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
243
244 DICT_CREATE(dict2);
245 ASSERT_RC(getdns_dict_set_int(dict2, "int", 2),
246 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
247 ASSERT_RC(getdns_dict_set_bindata(dict2, "bindata", &bindata),
248 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
249 ASSERT_RC(getdns_dict_set_dict(dict2, "dict", dict3),
250 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
251 ASSERT_RC(getdns_dict_set_list(dict2, "list", list2),
252 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
253
254 DICT_CREATE(dict1);
255 ASSERT_RC(getdns_dict_set_int(dict1, "int", 1),
256 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
257 ASSERT_RC(getdns_dict_set_bindata(dict1, "bindata", &bindata),
258 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata()");
259 ASSERT_RC(getdns_dict_set_dict(dict1, "dict", dict2),
260 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_dict()");
261 ASSERT_RC(getdns_dict_set_list(dict1, "list", list4),
262 GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_list()");
263
264 pretty = getdns_pretty_print_dict(dict1);
265 ck_assert_msg(pretty != NULL, "NULL returned by getdns_pretty_print_dict()");
266 ck_assert_msg(strcmp(pretty_expected, pretty) == 0,
267 "Expected:\n%s\ngot:\n%s\n", pretty_expected, pretty);
268
269 /*
270 * Destroy all of the sub-dicts and sub-lists
271 */
272 LIST_DESTROY(list7);
273 DICT_DESTROY(dict8);
274 LIST_DESTROY(list6);
275 LIST_DESTROY(list5);
276 DICT_DESTROY(dict7);
277 DICT_DESTROY(dict6);
278 LIST_DESTROY(list4);
279 LIST_DESTROY(list3);
280 DICT_DESTROY(dict5);
281 LIST_DESTROY(list2);
282 LIST_DESTROY(list1);
283 DICT_DESTROY(dict4);
284 DICT_DESTROY(dict3);
285 DICT_DESTROY(dict2);
286
287 /*
288 * And now destroy the mother of all ints, bindata, dicts, and lists
289 */
290 DICT_DESTROY(dict1);
291 }
292 END_TEST
293
294 Suite *
295 getdns_pretty_print_dict_suite (void)
296 {
297 Suite *s = suite_create ("getdns_pretty_print_dict()");
298
299 /* Negative test caseis */
300 TCase *tc_neg = tcase_create("Negative");
301 tcase_add_test(tc_neg, getdns_pretty_print_dict_1);
302 suite_add_tcase(s, tc_neg);
303
304 /* Positive test cases */
305 TCase *tc_pos = tcase_create("Positive");
306 tcase_add_test(tc_pos, getdns_pretty_print_dict_2);
307 suite_add_tcase(s, tc_pos);
308
309 return s;
310 }
311
312 #endif
0 /**
1 * \file
2 * \brief Public interfaces to getdns, include in your application to use getdns API.
3 *
4 * This source was taken from the original pseudo-implementation by
5 * Paul Hoffman.
6 */
7
8 /*
9 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #include "check_getdns_eventloop.h"
36 #include <getdns/getdns_extra.h>
37
38 void run_event_loop_impl(struct getdns_context* context, void* eventloop) {
39 struct timeval tv;
40 while (getdns_context_get_num_pending_requests(context, &tv) > 0) {
41 int fd = getdns_context_fd(context);
42 fd_set read_fds;
43 FD_ZERO(&read_fds);
44 FD_SET(fd, &read_fds);
45 select(fd + 1, &read_fds, NULL, NULL, &tv);
46 getdns_context_process_async(context);
47 }
48 }
49
50
51 void* create_eventloop_impl(struct getdns_context* context) {
52 return NULL;
53 }
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_service_h_
27 #define _check_getdns_service_h_
28
29 /*
30 ***************************************************
31 * *
32 * T E S T S F O R G E T D N S _ S E R V I C E *
33 * *
34 ***************************************************
35 */
36
37 START_TEST (getdns_service_1)
38 {
39 /*
40 * context = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_context *context = NULL;
44 getdns_transaction_t transaction_id = 0;
45
46 ASSERT_RC(getdns_service(context, "google.com", NULL,
47 NULL, &transaction_id, callbackfn),
48 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_service()");
49 }
50 END_TEST
51
52 START_TEST (getdns_service_2)
53 {
54 /*
55 * name = NULL
56 * expect: GETDNS_RETURN_INVALID_PARAMETER
57 */
58 struct getdns_context *context = NULL;
59 void* eventloop = NULL;
60 getdns_transaction_t transaction_id = 0;
61
62 CONTEXT_CREATE(TRUE);
63 EVENT_BASE_CREATE;
64
65 ASSERT_RC(getdns_service(context, NULL, NULL,
66 NULL, &transaction_id, callbackfn),
67 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_service()");
68
69 RUN_EVENT_LOOP;
70 CONTEXT_DESTROY;
71 }
72 END_TEST
73
74 START_TEST (getdns_service_3)
75 {
76 /*
77 * name = invalid domain (too many octets)
78 * expect: GETDNS_RETURN_BAD_DOMAIN_NAME
79 */
80 struct getdns_context *context = NULL;
81 void* eventloop = NULL;
82 getdns_transaction_t transaction_id = 0;
83 const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com";
84
85 CONTEXT_CREATE(TRUE);
86 EVENT_BASE_CREATE;
87
88 ASSERT_RC(getdns_service(context, name, NULL,
89 NULL, &transaction_id, callbackfn),
90 GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_service()");
91 RUN_EVENT_LOOP;
92 CONTEXT_DESTROY;
93
94 }
95 END_TEST
96
97 START_TEST (getdns_service_4)
98 {
99 /*
100 * name is invalid (domain name label length > 63)
101 * expect: GETDNS_RETURN_BAD_DOMAIN_NAME
102 */
103 struct getdns_context *context = NULL;
104 void* eventloop = NULL;
105 getdns_transaction_t transaction_id = 0;
106 const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com";
107
108 CONTEXT_CREATE(TRUE);
109 EVENT_BASE_CREATE;
110
111 ASSERT_RC(getdns_service(context, name, NULL,
112 NULL, &transaction_id, callbackfn),
113 GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_service()");
114 RUN_EVENT_LOOP;
115 CONTEXT_DESTROY;
116
117 }
118 END_TEST
119
120 START_TEST (getdns_service_5)
121 {
122 /*
123 * callbackfn = NULL
124 * expect: GETDNS_RETURN_INVALID_PARAMETER
125 */
126 struct getdns_context *context = NULL;
127 void* eventloop = NULL;
128 getdns_transaction_t transaction_id = 0;
129
130 CONTEXT_CREATE(TRUE);
131 EVENT_BASE_CREATE;
132
133 ASSERT_RC(getdns_service(context, "google.com", NULL,
134 NULL, &transaction_id, NULL),
135 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_service()");
136 RUN_EVENT_LOOP;
137 CONTEXT_DESTROY;
138
139 }
140 END_TEST
141
142
143 START_TEST (getdns_service_7)
144 {
145 /*
146 * name is <non-existent domain name> (NXDOMAIN)
147 * expect: NXDOMAIN response (with SOA record)
148 */
149 void verify_getdns_service_7(struct extracted_response *ex_response);
150 struct getdns_context *context = NULL; \
151 void* eventloop = NULL; \
152 getdns_transaction_t transaction_id = 0;
153
154 CONTEXT_CREATE(TRUE);
155
156 EVENT_BASE_CREATE;
157
158 ASSERT_RC(getdns_service(context, "nitinsinghit.com", NULL,
159 verify_getdns_address_8, &transaction_id, callbackfn),
160 GETDNS_RETURN_GOOD, "Return code from getdns_service()");
161
162 RUN_EVENT_LOOP;
163 CONTEXT_DESTROY;
164 }
165 END_TEST
166
167 void verify_getdns_service_7(struct extracted_response *ex_response)
168 {
169 assert_nxdomain(ex_response);
170 assert_nodata(ex_response);
171 assert_soa_in_authority(ex_response);
172 }
173
174
175
176
177 Suite *
178 getdns_service_suite (void)
179 {
180 Suite *s = suite_create ("getdns_service()");
181
182 /* Negative test caseis */
183 TCase *tc_neg = tcase_create("Negative");
184 tcase_add_test(tc_neg, getdns_service_1);
185 tcase_add_test(tc_neg, getdns_service_2);
186 tcase_add_test(tc_neg, getdns_service_3);
187 tcase_add_test(tc_neg, getdns_service_4);
188 tcase_add_test(tc_neg, getdns_service_5);
189
190 suite_add_tcase(s, tc_neg);
191
192 /* Positive test cases */
193 TCase *tc_pos = tcase_create("Positive");
194 tcase_add_test(tc_pos, getdns_service_7);
195 suite_add_tcase(s, tc_pos);
196
197 return s;
198 }
199
200 #endif
0 /*
1 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the names of the copyright holders nor the
12 * names of its contributors may be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 #ifndef _check_getdns_service_sync_h_
27 #define _check_getdns_service_sync_h_
28
29 /*
30 *************************************************************
31 * *
32 * T E S T S F O R G E T D N S _ S E R V I C E _ S Y N C *
33 * *
34 *************************************************************
35 */
36
37 START_TEST (getdns_service_sync_1)
38 {
39 /*
40 * context = NULL
41 * expect: GETDNS_RETURN_INVALID_PARAMETER
42 */
43 struct getdns_context *context = NULL;
44 struct getdns_dict *response = NULL;
45
46 ASSERT_RC(getdns_service_sync(context, "google.com", NULL, &response),
47 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_service_sync()");
48 }
49 END_TEST
50
51 START_TEST (getdns_service_sync_2)
52 {
53 /*
54 * name = NULL
55 * expect: GETDNS_RETURN_INVALID_PARAMETER
56 */
57 struct getdns_context *context = NULL;
58 struct getdns_dict *response = NULL;
59
60 CONTEXT_CREATE(TRUE);
61
62 ASSERT_RC(getdns_service_sync(context, NULL, NULL, &response),
63 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_service_sync()");
64 }
65 END_TEST
66
67 START_TEST (getdns_service_sync_3)
68 {
69 /*
70 * name is invalid (domain name length > 255)
71 * expect: GETDNS_RETURN_BAD_DOMAIN_NAME
72 */
73 struct getdns_context *context = NULL;
74 struct getdns_dict *response = NULL;
75 const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com";
76
77 CONTEXT_CREATE(TRUE);
78
79 ASSERT_RC(getdns_service_sync(context, name, NULL, &response),
80 GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_service_sync()");
81 }
82 END_TEST
83
84 START_TEST (getdns_service_sync_4)
85 {
86 /*
87 * name is invalid (domain name label length > 63)
88 * expect: GETDNS_RETURN_BAD_DOMAIN_NAME
89 */
90 struct getdns_context *context = NULL;
91 struct getdns_dict *response = NULL;
92 const char *name = "this.domain.hasalabelwhichexceedsthemaximumdnslabelsizeofsixtythreecharacters.com";
93
94 CONTEXT_CREATE(TRUE);
95
96 ASSERT_RC(getdns_service_sync(context, name, NULL, &response),
97 GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_service_sync()");
98 }
99 END_TEST
100
101 START_TEST (getdns_service_sync_5)
102 {
103 /*
104 * response is NULL
105 * expect: GETDNS_RETURN_INVALID_PARAMETER
106 */
107 struct getdns_context *context = NULL;
108
109 CONTEXT_CREATE(TRUE);
110
111 ASSERT_RC(getdns_service_sync(context, "google.com", NULL, NULL),
112 GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_service_sync()");
113 }
114 END_TEST
115
116 START_TEST (getdns_service_sync_7)
117 {
118 /*
119 * rname is <non-existent domain name> (NXDOMAIN)
120 * no extensions
121 * expected: NXDOMAIN response (with SOA record)
122
123 */
124 struct getdns_context *context = NULL;
125 struct getdns_dict *response = NULL;
126 const char *name = "labelsizeofsixtythreecharacterscom";
127
128 CONTEXT_CREATE(TRUE);
129
130 ASSERT_RC(getdns_service_sync(context, name, NULL, &response),
131 GETDNS_RETURN_GOOD, "Return code from getdns_service_sync()");
132
133 EXTRACT_RESPONSE;
134
135 assert_nxdomain(&ex_response);
136 assert_nodata(&ex_response);
137 assert_soa_in_authority(&ex_response);
138 }
139 END_TEST
140
141
142
143
144 Suite *
145 getdns_service_sync_suite (void)
146 {
147 Suite *s = suite_create ("getdns_service_sync()");
148
149 /* Negative test caseis */
150 TCase *tc_neg = tcase_create("Negative");
151 tcase_add_test(tc_neg, getdns_service_sync_1);
152 tcase_add_test(tc_neg, getdns_service_sync_2);
153 tcase_add_test(tc_neg, getdns_service_sync_3);
154 tcase_add_test(tc_neg, getdns_service_sync_4);
155 tcase_add_test(tc_neg, getdns_service_sync_5);
156
157 suite_add_tcase(s, tc_neg);
158
159 /* Positive test cases */
160 TCase *tc_pos = tcase_create("Positive");
161 tcase_add_test(tc_pos, getdns_service_sync_7);
162 suite_add_tcase(s, tc_pos);
163
164 return s;
165 }
166
167 #endif
0 /**
1 * \file
2 * @brief display messages to support unit testing
3 */
4
5 /*
6 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * * Neither the names of the copyright holders nor the
17 * names of its contributors may be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <strings.h>
35 #include <string.h>
36 #include "testmessages.h"
37
38 static char *testprog = NULL;
39 static char **cases = NULL;
40 static int ncases = 0;
41
42 void
43 tstmsg_prog_begin(char *prognm)
44 {
45 if (testprog != NULL) {
46 tstmsg_prog_end();
47 free(testprog);
48 }
49 testprog = strdup(prognm);
50 printf("TESTPROG %s START\n", testprog);
51 } /* tstmsg_prog_begin */
52
53 void
54 tstmsg_prog_end()
55 {
56 printf("TESTPROG %s END\n", testprog);
57 free(testprog);
58 } /* tstmsg_prog_end */
59
60 void
61 tstmsg_case_begin(char *casenm)
62 {
63 ncases++;
64 cases = (char **) realloc(cases, sizeof(char *) * ncases);
65 cases[ncases - 1] = strdup(casenm);
66
67 printf("TESTCASE %s:%s BEGIN\n", testprog, cases[ncases - 1]);
68 } /* tstmsg_case_begin */
69
70 void
71 tstmsg_case_end(void)
72 {
73 if (ncases > 0) {
74 printf("TESTCASE %s:%s END\n", testprog, cases[ncases - 1]);
75 ncases--;
76 free(cases[ncases]);
77 if (ncases) {
78 cases =
79 (char **) realloc(cases, sizeof(char *) * ncases);
80 } else {
81 cases = NULL;
82 }
83 }
84 } /* tstmsg_case_end */
85
86 void
87 tstmsg_case_msg(char *msg)
88 {
89 printf(" %s:%s: %s\n", testprog, cases[ncases - 1], msg);
90 } /* tstmsg_case_msg */
91
92 /* testmessages.c */
0 /**
1 * \file
2 * \brief display messages to support unit testing
3 */
4
5 /*
6 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * * Neither the names of the copyright holders nor the
17 * names of its contributors may be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef TESTMESSAGES_H
33 #define TESTMESSAGES_H 1
34
35 /**
36 * call at the start of a test program to display start message
37 */
38 void tstmsg_prog_begin(char *prognm);
39 /**
40 * call at the end of a test program to display end message
41 */
42 void tstmsg_prog_end();
43
44 /**
45 * call at the start of a test case (after test_prog_begin)
46 * to display case start message
47 */
48 void tstmsg_case_begin(char *casenm);
49 /**
50 * call at the end of a test case (after test_prog_begin/test_case_begin)
51 * to display case end message
52 */
53 void tstmsg_case_end();
54
55 /**
56 * call to display message regarding the current test case
57 * to display case end message
58 * TODO: add macro to automatically output source file line
59 */
60 void tstmsg_case_msg(char *msg);
61
62 #endif
63
64 /* testmessages.h */
0 /**
1 * \file
2 * unit tests for getdns_dict helper routines, these should be used to
3 * perform regression tests, output must be unchanged from canonical output
4 * stored with the sources
5 */
6
7 /*
8 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * * Neither the names of the copyright holders nor the
19 * names of its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37 #include "testmessages.h"
38 #include <getdns/getdns.h>
39
40 #define TSTMSGBUF 80
41
42 /* Prototypes for functions not part of the API
43 * TODO: remove these
44 */
45 getdns_return_t getdns_list_add_item(struct getdns_list *list, size_t * index);
46 getdns_return_t getdns_dict_copy(struct getdns_dict *srcdict, struct getdns_dict **dstdict);
47
48 /*---------------------------------------- tst_bindatasetget */
49 /**
50 * test the bindata get and set routines
51 */
52 void
53 tst_bindatasetget(void)
54 {
55 char msg[TSTMSGBUF];
56 char key[20];
57 getdns_return_t retval;
58 struct getdns_dict *dict = NULL;
59 struct getdns_bindata *ans_bdata;
60 struct getdns_bindata *bindata;
61
62 tstmsg_case_begin("tst_bindatasetget");
63
64 dict = getdns_dict_create();
65
66 /* test int get function against empty dict and with bogus params */
67
68 strcpy(key, "foo");
69
70 tstmsg_case_msg("getdns_dict_get_bindata() empty dict");
71 retval = getdns_dict_get_bindata(NULL, key, &ans_bdata);
72 snprintf(msg, sizeof(msg),
73 "test 1: getdns_dict_get_bindata(NULL, key, &ans_bdata),retval = %d",
74 retval);
75 tstmsg_case_msg(msg);
76
77 retval = getdns_dict_get_bindata(dict, key, NULL);
78 snprintf(msg, sizeof(msg),
79 "test 2: getdns_dict_get_bindata(dict, key, NULL),retval = %d",
80 retval);
81 tstmsg_case_msg(msg);
82
83 tstmsg_case_msg("getdns_dict_get_bindata(dict, NULL, &ans_bindata)");
84 retval = getdns_dict_get_bindata(dict, NULL, &ans_bdata);
85 snprintf(msg, sizeof(msg), "test 3: getdns_dict_get_bindata,retval = %d", retval);
86 tstmsg_case_msg(msg);
87
88 tstmsg_case_msg("getdns_dict_get_bindata(dict, key, &ans_bdata)");
89 retval = getdns_dict_get_bindata(dict, key, &ans_bdata);
90 snprintf(msg, sizeof(msg), "test 4: getdns_list_get_bindata,retval = %d", retval);
91 tstmsg_case_msg(msg);
92
93 getdns_dict_destroy(dict);
94
95 /* TODO: test getdns_dict_set functions with bogus params */
96
97 /* test set and get legitimate use case */
98
99 dict = getdns_dict_create();
100
101 strcpy(key, "foo");
102 bindata =
103 (struct getdns_bindata *) malloc(sizeof(struct getdns_bindata));
104 bindata->size = strlen("foobar") + 1;
105 bindata->data = (void *) strdup("foobar");
106
107 tstmsg_case_msg("getdns_dict_set_bindata(dict, key, bindata)");
108 retval = getdns_dict_set_bindata(dict, key, bindata);
109 snprintf(msg, sizeof(msg), "test 5: getdns_dict_set_bindata,retval=%d,key=%s",
110 retval, key);
111 tstmsg_case_msg(msg);
112
113 tstmsg_case_msg("getdns_dict_get_bindata(dict, key, &ans_bdata)");
114 retval = getdns_dict_get_bindata(dict, key, &ans_bdata);
115 snprintf(msg, sizeof(msg),
116 "test 6: getdns_dict_get_bindata,retval=%d,key=%s,data=%s",
117 retval, key, ans_bdata->data);
118 tstmsg_case_msg(msg);
119
120 getdns_dict_destroy(dict);
121 free(bindata->data);
122 free(bindata);
123
124 tstmsg_case_end();
125
126 return;
127 } /* tst_bindatasetget */
128
129 /*---------------------------------------- tst_dictsetget */
130 /**
131 * test the dict get and set routines
132 */
133 void
134 tst_dictsetget(void)
135 {
136 char msg[TSTMSGBUF];
137 char key[20];
138 uint32_t int1;
139 uint32_t int2;
140 getdns_return_t retval;
141 struct getdns_dict *newdict;
142 struct getdns_dict *ansdict;
143 struct getdns_dict *dict = NULL;
144
145 tstmsg_case_begin("tst_dictsetget");
146
147 dict = getdns_dict_create();
148
149 /* test get function against empty list and with bogus params */
150
151 strcpy(key, "foo");
152
153 tstmsg_case_msg("getdns_dict_get_dict() empty dict");
154 retval = getdns_dict_get_dict(NULL, key, &ansdict);
155 snprintf(msg, sizeof(msg),
156 "test 7: getdns_dict_get_dict(NULL, key, &ansdict),retval = %d",
157 retval);
158 tstmsg_case_msg(msg);
159
160 retval = getdns_dict_get_dict(dict, key, NULL);
161 snprintf(msg, sizeof(msg),
162 "test 8: getdns_dict_get_dict(dict, key, NULL),retval = %d",
163 retval);
164 tstmsg_case_msg(msg);
165
166 tstmsg_case_msg("getdns_dict_get_dict(dict, NULL, &ansdict)");
167 retval = getdns_dict_get_dict(dict, NULL, &ansdict);
168 snprintf(msg, sizeof(msg), "test 9: getdns_dict_get_dict,retval = %d", retval);
169 tstmsg_case_msg(msg);
170
171 tstmsg_case_msg("getdns_dict_get_dict(dict, key, &ansdict)");
172 retval = getdns_dict_get_dict(dict, key, &ansdict);
173 snprintf(msg, sizeof(msg), "test 10: getdns_list_get_dict,retval = %d", retval);
174 tstmsg_case_msg(msg);
175
176 getdns_dict_destroy(dict);
177
178 /* TODO: test getdns_dict_set functions with bogus params */
179
180 /* test set and get legitimate use case */
181
182 dict = getdns_dict_create();
183
184 strcpy(key, "foo");
185 newdict = getdns_dict_create();
186 getdns_dict_set_int(newdict, "foo", 42);
187 getdns_dict_set_int(newdict, "bar", 52);
188
189 tstmsg_case_msg("getdns_dict_set_dict(dict, key, newdict)");
190 retval = getdns_dict_set_dict(dict, key, newdict);
191 snprintf(msg, sizeof(msg), "test 11: getdns_dict_set_dict,retval=%d,key=%s", retval,
192 key);
193 tstmsg_case_msg(msg);
194 getdns_dict_destroy(newdict);
195
196 tstmsg_case_msg("getdns_dict_get_dict(dict, key, &ansdict)");
197 retval = getdns_dict_get_dict(dict, key, &ansdict);
198 getdns_dict_get_int(ansdict, "foo", &int1);
199 getdns_dict_get_int(ansdict, "bar", &int2);
200 snprintf(msg, sizeof(msg),
201 "test 12: getdns_dict_get_dict,retval=%d,key=%s,int1=%d,int2=%d",
202 retval, key, int1, int2);
203 tstmsg_case_msg(msg);
204
205 getdns_dict_destroy(dict);
206
207 tstmsg_case_end();
208
209 return;
210 } /* tst_dictsetget */
211
212 /*---------------------------------------- tst_getnames */
213 /**
214 * exercise the getdns_dict_get_names function
215 */
216 void
217 tst_getnames(void)
218 {
219 size_t index;
220 size_t llen;
221 uint32_t ansint;
222 int i;
223 getdns_return_t result;
224 getdns_data_type dtype;
225 struct getdns_dict *dict = NULL;
226 struct getdns_list *list = NULL;
227
228 tstmsg_case_begin("tst_getnames");
229
230 dict = getdns_dict_create();
231
232 /* degenerative use cases */
233
234 tstmsg_case_msg("getdns_dict_get_names(NULL, &list)");
235 getdns_dict_get_names(NULL, &list);
236 getdns_list_destroy(list);
237
238 tstmsg_case_msg("getdns_dict_get_names(dict, NULL)");
239 getdns_dict_get_names(dict, NULL);
240
241 tstmsg_case_msg
242 ("getdns_dict_get_names(dict, &list), empty dictionary");
243 getdns_dict_get_names(dict, &list);
244 getdns_list_destroy(list);
245
246 /* legit use case, add items out of order to exercise tree */
247 /* TODO: add elements of type dict, bindata, list to the dict */
248
249 i = 0;
250 getdns_dict_set_int(dict, "foo", i++);
251 getdns_dict_set_int(dict, "bar", i++);
252 getdns_dict_set_int(dict, "quz", i++);
253 getdns_dict_set_int(dict, "alpha", i++);
254
255 getdns_dict_get_names(dict, &list);
256
257 result = getdns_list_get_length(list, &llen);
258 if (result != GETDNS_RETURN_GOOD) {
259 tstmsg_case_msg
260 ("getdns_list_get_length failed, exiting");
261 return;
262 }
263 if (llen != i) {
264 tstmsg_case_msg
265 ("getdns_list_get_length returned unreasonable length, exiting");
266 return;
267 }
268
269 for (index = 0; index < llen; index++) {
270 getdns_list_get_data_type(list, index, &dtype);
271 printf(" list item %d: ", (int) index);
272 switch (dtype) {
273 case t_bindata:
274 printf("NOTIMPLEMENTED");
275 break;
276
277 case t_dict:
278 printf("NOTIMPLEMENTED");
279 break;
280
281 case t_int:
282 getdns_list_get_int(list, index, &ansint);
283 printf("t_int, value=%d\n", ansint);
284 break;
285
286 case t_list:
287 printf("NOTIMPLEMENTED");
288 break;
289
290 default:
291 printf("data type invalid");
292 break;
293 }
294 }
295
296 getdns_dict_destroy(dict);
297 getdns_list_destroy(list);
298
299 tstmsg_case_end();
300 } /* tst_getnames */
301
302 /*---------------------------------------- tst_listsetget */
303 /**
304 * test the list get and set routines
305 */
306 void
307 tst_listsetget(void)
308 {
309 char msg[TSTMSGBUF];
310 char key[20];
311 size_t index;
312 uint32_t int1;
313 uint32_t int2;
314 getdns_return_t retval;
315 struct getdns_list *newlist;
316 struct getdns_list *anslist;
317 struct getdns_dict *dict = NULL;
318
319 tstmsg_case_begin("tst_listsetget");
320
321 dict = getdns_dict_create();
322
323 /* test get function against empty list and with bogus params */
324
325 strcpy(key, "foo");
326
327 tstmsg_case_msg("getdns_dict_get_list() empty dict");
328 retval = getdns_dict_get_list(NULL, key, &anslist);
329 snprintf(msg, sizeof(msg),
330 "test 13: getdns_dict_get_list(NULL, key, &anslist),retval = %d",
331 retval);
332 tstmsg_case_msg(msg);
333
334 retval = getdns_dict_get_list(dict, key, NULL);
335 snprintf(msg, sizeof(msg),
336 "test 14: getdns_dict_get_list(dict, key, NULL),retval = %d",
337 retval);
338 tstmsg_case_msg(msg);
339
340 tstmsg_case_msg("getdns_dict_get_list(dict, NULL, &anslist)");
341 retval = getdns_dict_get_list(dict, NULL, &anslist);
342 snprintf(msg, sizeof(msg), "test 15: getdns_dict_get_list,retval = %d", retval);
343 tstmsg_case_msg(msg);
344
345 tstmsg_case_msg("getdns_dict_get_list(dict, key, &anslist)");
346 retval = getdns_dict_get_list(dict, key, &anslist);
347 snprintf(msg, sizeof(msg), "test 16: getdns_list_get_list,retval = %d", retval);
348 tstmsg_case_msg(msg);
349
350 getdns_dict_destroy(dict);
351
352 /* TODO: test getdns_dict_set functions with bogus params */
353
354 /* test set and get legitimate use case */
355
356 dict = getdns_dict_create();
357
358 strcpy(key, "foo");
359 newlist = getdns_list_create();
360 getdns_list_add_item(newlist, &index);
361 getdns_list_set_int(newlist, index, 42);
362 getdns_list_add_item(newlist, &index);
363 getdns_list_set_int(newlist, index, 52);
364
365 tstmsg_case_msg("getdns_dict_set_list(dict, key, newlist)");
366 retval = getdns_dict_set_list(dict, key, newlist);
367 snprintf(msg, sizeof(msg), "test 17: getdns_dict_set_list,retval=%d,key=%s",
368 retval, key);
369 tstmsg_case_msg(msg);
370 getdns_list_destroy(newlist);
371
372 tstmsg_case_msg("getdns_dict_get_list(dict, key, &anslist)");
373 retval = getdns_dict_get_list(dict, key, &anslist);
374 getdns_list_get_int(anslist, 0, &int1);
375 getdns_list_get_int(anslist, 1, &int2);
376 snprintf(msg, sizeof(msg),
377 "test 18: getdns_dict_get_list,retval=%d,key=%s,int1=%d,int2=%d",
378 retval, key, int1, int2);
379 tstmsg_case_msg(msg);
380
381 getdns_dict_destroy(dict);
382
383 tstmsg_case_end();
384
385 return;
386 } /* tst_listsetget */
387
388 /*---------------------------------------- tst_intsetget */
389 /**
390 * test the int get and set routines
391 */
392 void
393 tst_intsetget(void)
394 {
395 char msg[TSTMSGBUF];
396 char key[20];
397 uint32_t ans_int;
398 uint32_t newint;
399 getdns_return_t retval;
400 struct getdns_dict *dict = NULL;
401 getdns_data_type dtype;
402
403 tstmsg_case_begin("tst_intsetget");
404
405 dict = getdns_dict_create();
406
407 /* test int get function against empty list and with bogus params */
408
409 strcpy(key, "foo");
410
411 tstmsg_case_msg("getdns_dict_get_int() empty dict");
412 retval = getdns_dict_get_int(NULL, key, &ans_int);
413 snprintf(msg, sizeof(msg),
414 "test 19: getdns_dict_get_int(NULL, key, &ans_int),retval = %d",
415 retval);
416 tstmsg_case_msg(msg);
417
418 retval = getdns_dict_get_int(dict, key, NULL);
419 snprintf(msg, sizeof(msg),
420 "test 20: getdns_dict_get_int(dict, key, NULL),retval = %d",
421 retval);
422 tstmsg_case_msg(msg);
423
424 tstmsg_case_msg("getdns_dict_get_int(dict, NULL, &ans_int)");
425 retval = getdns_dict_get_int(dict, NULL, &ans_int);
426 snprintf(msg, sizeof(msg), "test 21: getdns_dict_get_int,retval = %d", retval);
427 tstmsg_case_msg(msg);
428
429 tstmsg_case_msg("getdns_dict_get_int(dict, key, &ans_int)");
430 retval = getdns_dict_get_int(dict, key, &ans_int);
431 snprintf(msg, sizeof(msg), "test 22: getdns_list_get_int,retval = %d", retval);
432 tstmsg_case_msg(msg);
433
434 getdns_dict_destroy(dict);
435
436 /* TODO: test getdns_dict_set functions with bogus params */
437
438 /* test set and get legitimate use case */
439
440 dict = getdns_dict_create();
441
442 strcpy(key, "foo");
443 newint = 42;
444
445 tstmsg_case_msg("getdns_dict_set_int(dict, key, newint)");
446 retval = getdns_dict_set_int(dict, key, newint);
447 snprintf(msg, sizeof(msg), "test 23: getdns_dict_set_int,retval=%d,key=%s,int=%d",
448 retval, key, newint);
449 tstmsg_case_msg(msg);
450
451 tstmsg_case_msg("getdns_dict_get_int(dict, key, &ans_int)");
452 retval = getdns_dict_get_int(dict, key, &ans_int);
453 snprintf(msg, sizeof(msg), "test 24: getdns_dict_get_int,retval=%d,key=%s,int=%d",
454 retval, key, ans_int);
455 tstmsg_case_msg(msg);
456
457 strcpy(key, "bar");
458 newint = 52;
459 tstmsg_case_msg("getdns_dict_set_int(dict, key, newint)");
460 retval = getdns_dict_set_int(dict, key, newint);
461 snprintf(msg, sizeof(msg), "test 25: getdns_dict_set_int,retval=%d,key=%s,int=%d",
462 retval, key, newint);
463 tstmsg_case_msg(msg);
464
465 tstmsg_case_msg("getdns_dict_get_int(dict, key, &ans_int)");
466 retval = getdns_dict_get_int(dict, key, &ans_int);
467 snprintf(msg, sizeof(msg), "test 26: getdns_dict_get_int,retval=%d,key=%s,int=%d",
468 retval, key, ans_int);
469 tstmsg_case_msg(msg);
470
471 tstmsg_case_msg("getdns_dict_get_data_type(dict, key, &dtype)");
472 retval = getdns_dict_get_data_type(dict, key, &dtype);
473 snprintf(msg, sizeof(msg),
474 "test 27: getdns_dict_get_data_type,retval=%d,key=%s,dtype=%d",
475 retval, key, dtype);
476 tstmsg_case_msg(msg);
477
478 getdns_dict_destroy(dict);
479
480 tstmsg_case_end();
481
482 return;
483 } /* tst_intsetget */
484
485 /*---------------------------------------- tst_copy */
486 /**
487 * test the copy and pretty print functions
488 */
489 void
490 tst_copy(void)
491 {
492 char *dictstr = NULL;
493 struct getdns_dict *dict1 = NULL;
494 struct getdns_dict *dict2 = NULL;
495
496 tstmsg_case_begin("tst_copy");
497
498 tstmsg_case_msg("empty list cases");
499
500 getdns_dict_copy(NULL, NULL);
501 dict1 = getdns_dict_create();
502 getdns_dict_copy(dict1, &dict2);
503 getdns_dict_destroy(dict2);
504 /* getdns_dict_copy(NULL, &dict1); */
505
506 tstmsg_case_msg("dict1 populate");
507
508 getdns_dict_set_int(dict1, "foo", 42);
509 getdns_dict_set_int(dict1, "bar", 52);
510 getdns_dict_set_int(dict1, "quz", 62);
511
512 dictstr = getdns_pretty_print_dict(dict1);
513 printf("%s\n", dictstr);
514 free(dictstr);
515
516 tstmsg_case_msg("getdns_dict_copy(dict1, &dict2)");
517
518 getdns_dict_copy(dict1, &dict2);
519
520 dictstr = getdns_pretty_print_dict(dict2);
521 printf("%s\n", dictstr);
522 free(dictstr);
523
524 getdns_dict_destroy(dict1);
525 getdns_dict_destroy(dict2);
526
527 tstmsg_case_end();
528
529 return;
530 } /* tst_copy */
531
532 /*---------------------------------------- tst_create */
533 /**
534 * test the create, destroy and allocation functions
535 */
536 void
537 tst_create(void)
538 {
539 struct getdns_dict *dict = NULL;
540
541 /* make sure we can do a simple create/destroy first */
542
543 tstmsg_case_begin("tst_create");
544
545 tstmsg_case_msg("getdns_dict_create");
546 dict = getdns_dict_create();
547
548 if (dict != NULL) {
549 tstmsg_case_msg("getdns_dict_destroy(dict)");
550 getdns_dict_destroy(dict);
551 }
552
553 tstmsg_case_msg("getdns_dict_destroy(NULL)");
554 getdns_dict_destroy(NULL);
555
556 tstmsg_case_end();
557
558 return;
559 } /* tst_create */
560
561 /*---------------------------------------- main */
562 /**
563 * runs unit tests against list management routines
564 */
565 int
566 main(int argc, char *argv[])
567 {
568 tstmsg_prog_begin("tests_dict");
569
570 tst_create();
571
572 tst_bindatasetget();
573
574 tst_dictsetget();
575
576 tst_intsetget();
577
578 tst_listsetget();
579
580 tst_getnames();
581
582 tst_copy();
583
584 tstmsg_prog_end();
585
586 return 0;
587 } /* main */
588
589 /* tests_dict.c */
0 TESTPROG tests_dict START
1 TESTCASE tests_dict:tst_create BEGIN
2 tests_dict:tst_create: getdns_dict_create
3 tests_dict:tst_create: getdns_dict_destroy(dict)
4 tests_dict:tst_create: getdns_dict_destroy(NULL)
5 TESTCASE tests_dict:tst_create END
6 TESTCASE tests_dict:tst_bindatasetget BEGIN
7 tests_dict:tst_bindatasetget: getdns_dict_get_bindata() empty dict
8 tests_dict:tst_bindatasetget: test 1: getdns_dict_get_bindata(NULL, key, &ans_bdata),retval = 311
9 tests_dict:tst_bindatasetget: test 2: getdns_dict_get_bindata(dict, key, NULL),retval = 311
10 tests_dict:tst_bindatasetget: getdns_dict_get_bindata(dict, NULL, &ans_bindata)
11 tests_dict:tst_bindatasetget: test 3: getdns_dict_get_bindata,retval = 311
12 tests_dict:tst_bindatasetget: getdns_dict_get_bindata(dict, key, &ans_bdata)
13 tests_dict:tst_bindatasetget: test 4: getdns_list_get_bindata,retval = 305
14 tests_dict:tst_bindatasetget: getdns_dict_set_bindata(dict, key, bindata)
15 tests_dict:tst_bindatasetget: test 5: getdns_dict_set_bindata,retval=0,key=foo
16 tests_dict:tst_bindatasetget: getdns_dict_get_bindata(dict, key, &ans_bdata)
17 tests_dict:tst_bindatasetget: test 6: getdns_dict_get_bindata,retval=0,key=foo,data=foobar
18 TESTCASE tests_dict:tst_bindatasetget END
19 TESTCASE tests_dict:tst_dictsetget BEGIN
20 tests_dict:tst_dictsetget: getdns_dict_get_dict() empty dict
21 tests_dict:tst_dictsetget: test 7: getdns_dict_get_dict(NULL, key, &ansdict),retval = 311
22 tests_dict:tst_dictsetget: test 8: getdns_dict_get_dict(dict, key, NULL),retval = 311
23 tests_dict:tst_dictsetget: getdns_dict_get_dict(dict, NULL, &ansdict)
24 tests_dict:tst_dictsetget: test 9: getdns_dict_get_dict,retval = 311
25 tests_dict:tst_dictsetget: getdns_dict_get_dict(dict, key, &ansdict)
26 tests_dict:tst_dictsetget: test 10: getdns_list_get_dict,retval = 305
27 tests_dict:tst_dictsetget: getdns_dict_set_dict(dict, key, newdict)
28 tests_dict:tst_dictsetget: test 11: getdns_dict_set_dict,retval=0,key=foo
29 tests_dict:tst_dictsetget: getdns_dict_get_dict(dict, key, &ansdict)
30 tests_dict:tst_dictsetget: test 12: getdns_dict_get_dict,retval=0,key=foo,int1=42,int2=52
31 TESTCASE tests_dict:tst_dictsetget END
32 TESTCASE tests_dict:tst_intsetget BEGIN
33 tests_dict:tst_intsetget: getdns_dict_get_int() empty dict
34 tests_dict:tst_intsetget: test 19: getdns_dict_get_int(NULL, key, &ans_int),retval = 311
35 tests_dict:tst_intsetget: test 20: getdns_dict_get_int(dict, key, NULL),retval = 311
36 tests_dict:tst_intsetget: getdns_dict_get_int(dict, NULL, &ans_int)
37 tests_dict:tst_intsetget: test 21: getdns_dict_get_int,retval = 311
38 tests_dict:tst_intsetget: getdns_dict_get_int(dict, key, &ans_int)
39 tests_dict:tst_intsetget: test 22: getdns_list_get_int,retval = 305
40 tests_dict:tst_intsetget: getdns_dict_set_int(dict, key, newint)
41 tests_dict:tst_intsetget: test 23: getdns_dict_set_int,retval=0,key=foo,int=42
42 tests_dict:tst_intsetget: getdns_dict_get_int(dict, key, &ans_int)
43 tests_dict:tst_intsetget: test 24: getdns_dict_get_int,retval=0,key=foo,int=42
44 tests_dict:tst_intsetget: getdns_dict_set_int(dict, key, newint)
45 tests_dict:tst_intsetget: test 25: getdns_dict_set_int,retval=0,key=bar,int=52
46 tests_dict:tst_intsetget: getdns_dict_get_int(dict, key, &ans_int)
47 tests_dict:tst_intsetget: test 26: getdns_dict_get_int,retval=0,key=bar,int=52
48 tests_dict:tst_intsetget: getdns_dict_get_data_type(dict, key, &dtype)
49 tests_dict:tst_intsetget: test 27: getdns_dict_get_data_type,retval=0,key=bar,dtype=2
50 TESTCASE tests_dict:tst_intsetget END
51 TESTCASE tests_dict:tst_listsetget BEGIN
52 tests_dict:tst_listsetget: getdns_dict_get_list() empty dict
53 tests_dict:tst_listsetget: test 13: getdns_dict_get_list(NULL, key, &anslist),retval = 311
54 tests_dict:tst_listsetget: test 14: getdns_dict_get_list(dict, key, NULL),retval = 311
55 tests_dict:tst_listsetget: getdns_dict_get_list(dict, NULL, &anslist)
56 tests_dict:tst_listsetget: test 15: getdns_dict_get_list,retval = 311
57 tests_dict:tst_listsetget: getdns_dict_get_list(dict, key, &anslist)
58 tests_dict:tst_listsetget: test 16: getdns_list_get_list,retval = 305
59 tests_dict:tst_listsetget: getdns_dict_set_list(dict, key, newlist)
60 tests_dict:tst_listsetget: test 17: getdns_dict_set_list,retval=0,key=foo
61 tests_dict:tst_listsetget: getdns_dict_get_list(dict, key, &anslist)
62 tests_dict:tst_listsetget: test 18: getdns_dict_get_list,retval=0,key=foo,int1=42,int2=52
63 TESTCASE tests_dict:tst_listsetget END
64 TESTCASE tests_dict:tst_getnames BEGIN
65 tests_dict:tst_getnames: getdns_dict_get_names(NULL, &list)
66 tests_dict:tst_getnames: getdns_dict_get_names(dict, NULL)
67 tests_dict:tst_getnames: getdns_dict_get_names(dict, &list), empty dictionary
68 list item 0: NOTIMPLEMENTED list item 1: NOTIMPLEMENTED list item 2: NOTIMPLEMENTED list item 3: NOTIMPLEMENTEDTESTCASE tests_dict:tst_getnames END
69 TESTCASE tests_dict:tst_copy BEGIN
70 tests_dict:tst_copy: empty list cases
71 tests_dict:tst_copy: dict1 populate
72 {
73 "bar": 52,
74 "foo": 42,
75 "quz": 62
76 }
77 tests_dict:tst_copy: getdns_dict_copy(dict1, &dict2)
78 {
79 "bar": 52,
80 "foo": 42,
81 "quz": 62
82 }
83 TESTCASE tests_dict:tst_copy END
84 TESTPROG tests_dict END
0 /**
1 * \file
2 * unit tests for getdns_dict helper routines, these should be used to
3 * perform regression tests, output must be unchanged from canonical output
4 * stored with the sources
5 */
6
7 /*
8 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * * Neither the names of the copyright holders nor the
19 * names of its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34
35 #include "config.h"
36 #ifdef HAVE_EVENT2_EVENT_H
37 # include <event2/event.h>
38 #else
39 # include <event.h>
40 #endif
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include "testmessages.h"
45 #include <getdns/getdns.h>
46 #include <getdns/getdns_ext_libevent.h>
47
48 /* Set up the callback function, which will also do the processing of the results */
49 void
50 callbackfn(struct getdns_context *context,
51 getdns_callback_type_t callback_type,
52 struct getdns_dict *response, void *userarg,
53 getdns_transaction_t transaction_id)
54 {
55 struct getdns_list *validation_chain;
56 struct getdns_list *trust_anchors;
57 struct getdns_list *replies_tree;
58 size_t replies_tree_length, i;
59 struct getdns_dict *reply;
60 struct getdns_list *answer;
61 size_t answer_length;
62 getdns_return_t r;
63
64 do {
65 if (callback_type == GETDNS_CALLBACK_CANCEL) {
66 fprintf(stderr,
67 "The callback with ID %llu was cancelled.\n",
68 (long long unsigned int)transaction_id);
69 break;
70 } else if (callback_type != GETDNS_CALLBACK_COMPLETE) {
71 fprintf(stderr,
72 "The callback got a callback_type of %d.\n",
73 callback_type);
74 break;
75 }
76 r = getdns_dict_get_list(response,
77 "validation_chain", &validation_chain);
78 if (r != GETDNS_RETURN_GOOD) {
79 fprintf(stderr,
80 "Could not get \"validation_chain\" from response:"
81 " %d\n", r);
82 break;
83 }
84 r = getdns_dict_get_list(response, "replies_tree", &replies_tree);
85 if (r != GETDNS_RETURN_GOOD) {
86 fprintf(stderr,
87 "Could not get \"replies_tree\" from response:"
88 " %d\n", r);
89 break;
90 }
91 r = getdns_list_get_length(replies_tree, &replies_tree_length);
92 if (r != GETDNS_RETURN_GOOD) {
93 fprintf(stderr,
94 "Could not get length of the replies_tree:"
95 " %d\n", r);
96 break;
97 }
98 trust_anchors = getdns_root_trust_anchor(NULL);
99 if (! trust_anchors) {
100 fprintf(stderr,
101 "No root trust anchor present:"
102 " %d\n", r);
103 break;
104 }
105 for (i = 0; i < replies_tree_length; i++) {
106 r = getdns_list_get_dict(replies_tree, i, &reply);
107 if (r != GETDNS_RETURN_GOOD) {
108 fprintf(stderr,
109 "Could not get \"reply\" from replies_tree:"
110 " %d\n", r);
111 break;
112 }
113 r = getdns_dict_get_list(reply, "answer", &answer);
114 if (r != GETDNS_RETURN_GOOD) {
115 fprintf(stderr,
116 "Could not get \"answer\" from reply:"
117 " %d\n", r);
118 break;
119 }
120 r = getdns_list_get_length(answer, &answer_length);
121 if (r != GETDNS_RETURN_GOOD) {
122 fprintf(stderr,
123 "Could not get length of answer list:"
124 " %d\n", r);
125 break;
126 }
127 if (answer_length == 0)
128 continue;
129
130 r = getdns_validate_dnssec(answer,
131 validation_chain, trust_anchors);
132 printf("getdns_validate_dnssec returned: %d\n", r);
133 }
134 getdns_list_destroy(trust_anchors);
135 } while (0);
136 getdns_dict_destroy(response);
137 (void) event_base_loopexit((struct event_base *)userarg, NULL);
138 }
139
140 int
141 main(int argc, char** argv)
142 {
143 const char *name = argc > 1 ? argv[1] : "www.example.com";
144 struct getdns_context *context;
145 struct getdns_dict *extensions;
146 struct event_base *event_base = NULL;
147 getdns_transaction_t transaction_id = 0;
148 getdns_return_t r;
149
150 r = getdns_context_create(&context, 1);
151 if (r != GETDNS_RETURN_GOOD) {
152 fprintf(stderr, "Create context failed: %d", r);
153 return r;
154 }
155 r = getdns_context_set_timeout(context, 5000);
156 if (r != GETDNS_RETURN_GOOD) {
157 fprintf(stderr, "Set timeout failed: %d", r);
158 goto done_destroy_context;
159 }
160 extensions = getdns_dict_create();
161 if (! extensions) {
162 fprintf(stderr, "Could not create extensions dict\n");
163 r = GETDNS_RETURN_MEMORY_ERROR;
164 goto done_destroy_context;
165 }
166 r = getdns_dict_set_int(extensions, "dnssec_return_validation_chain",
167 GETDNS_EXTENSION_TRUE);
168 if (r != GETDNS_RETURN_GOOD) {
169 fprintf(stderr, "Could not set extension "
170 "\"dnssec_return_validation_chain\": %d\n", r);
171 goto done_destroy_extensions;
172 }
173
174 /* Create an event base and put it in the context */
175 event_base = event_base_new();
176 if (event_base == NULL) {
177 fprintf(stderr, "Trying to create the event base failed.");
178 r = GETDNS_RETURN_GENERIC_ERROR;
179 goto done_destroy_extensions;
180 }
181 (void) getdns_extension_set_libevent_base(context, event_base);
182
183 /* Make the call */
184 r = getdns_address(context, name, extensions, event_base,
185 &transaction_id, callbackfn);
186 if (r == GETDNS_RETURN_BAD_DOMAIN_NAME) {
187 fprintf(stderr, "Bad domain name: %s.", name);
188 goto done_destroy_extensions;
189 }
190 /* Call the event loop */
191 event_base_dispatch(event_base);
192
193 /* Clean up */
194 done_destroy_extensions:
195 getdns_dict_destroy(extensions);
196 done_destroy_context:
197 getdns_context_destroy(context);
198
199 /* Event base must be destroyed after the context, because
200 * the context has to re-register its sockets from the eventbase,
201 * who has to communicate this to the system event-mechanism.
202 */
203 if (event_base)
204 event_base_free(event_base);
205
206 return r;
207 }
0 /**
1 * \file
2 * unit tests for getdns_list helper routines, these should be used to
3 * perform regression tests, output must be unchanged from canonical output
4 * stored with the sources
5 */
6
7 /*
8 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * * Neither the names of the copyright holders nor the
19 * names of its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37 #include "testmessages.h"
38 #include <getdns/getdns.h>
39
40 #define TSTMSGBUF 80
41 #define GETDNS_LIST_BLOCKSZ 10
42
43
44 /* TODO: might want a separate unit test for getdns_list_copy() - right now the code gets
45 covered as a result of other tests */
46
47 /*---------------------------------------- tst_bindatasetget */
48 /**
49 * test the list get and set routines
50 */
51 void
52 tst_bindatasetget(void)
53 {
54 char msg[TSTMSGBUF];
55 size_t index = 0;
56 getdns_return_t retval;
57 struct getdns_list *list = NULL;
58 struct getdns_bindata *new_bindata = NULL;
59 struct getdns_bindata *ans_bindata = NULL;
60
61 tstmsg_case_begin("tst_bindatasetget");
62
63 list = getdns_list_create();
64
65 /* test get function against empty list and with bogus params */
66
67 tstmsg_case_msg("getdns_list_get_bindata() empty list");
68 retval = getdns_list_get_bindata(NULL, index, &ans_bindata);
69 snprintf(msg, sizeof(msg),
70 "getdns_list_get_bindata(NULL, index, &ans_bindata),retval = %d",
71 retval);
72 tstmsg_case_msg(msg);
73
74 retval = getdns_list_get_bindata(list, index, NULL);
75 snprintf(msg, sizeof(msg), "getdns_list_get_bindata(list, index, NULL),retval = %d",
76 retval);
77 tstmsg_case_msg(msg);
78
79 tstmsg_case_msg("getdns_list_get_bindata(list, 0, &ans_bindata)");
80 retval = getdns_list_get_bindata(list, 0, &ans_bindata);
81 snprintf(msg, sizeof(msg), "getdns_list_get_bindata,retval = %d", retval);
82 tstmsg_case_msg(msg);
83
84 tstmsg_case_msg("getdns_list_get_bindata(list, 1, &ans_bindata)");
85 retval = getdns_list_get_bindata(list, 1, &ans_bindata);
86 snprintf(msg, sizeof(msg), "getdns_list_get_bindata,retval = %d", retval);
87 tstmsg_case_msg(msg);
88
89 /* test set function against empty list with bogus params */
90
91 tstmsg_case_msg("getdns_list_set_bindata(list, -1, ans_bindata)");
92 retval = getdns_list_set_bindata(list, -1, NULL);
93 snprintf(msg, sizeof(msg), "getdns_list_set_bindata,retval = %d", retval);
94 tstmsg_case_msg(msg);
95
96 tstmsg_case_msg("getdns_list_set_bindata(list, 1, ans_bindata)");
97 retval = getdns_list_set_bindata(list, 1, NULL);
98 snprintf(msg, sizeof(msg), "getdns_list_set_bindata,retval = %d", retval);
99 tstmsg_case_msg(msg);
100
101 /* test set and get legitimate use case */
102
103 new_bindata =
104 (struct getdns_bindata *) malloc(sizeof(struct getdns_bindata));
105 new_bindata->size = strlen("foobar") + 1;
106 new_bindata->data = (uint8_t *) "foobar";
107
108 getdns_list_set_bindata(list, index, new_bindata);
109 retval = getdns_list_get_bindata(list, index, &ans_bindata);
110 snprintf(msg, sizeof(msg),
111 "getdns_list_set/get_bindata,retval = %d, bindata->data = %d,%s",
112 retval, (int) ans_bindata->size, (char *) ans_bindata->data);
113 tstmsg_case_msg(msg);
114
115 getdns_list_destroy(list);
116
117 tstmsg_case_end();
118
119 return;
120 } /* tst_bindatasetget */
121
122 /*---------------------------------------- tst_dictsetget */
123 /**
124 * test the dict get and set routines
125 */
126 void
127 tst_dictsetget(void)
128 {
129 char msg[TSTMSGBUF];
130 size_t index = 0;
131 uint32_t ans_int;
132 getdns_return_t retval;
133 struct getdns_list *list = NULL;
134 struct getdns_dict *dict = NULL;
135 struct getdns_dict *ansdict = NULL;
136
137 tstmsg_case_begin("tst_dictsetget");
138
139 list = getdns_list_create();
140 dict = getdns_dict_create();
141
142 /* test dict get function against empty list and with bogus params */
143
144 tstmsg_case_msg("getdns_list_get_dict() empty list");
145 retval = getdns_list_get_dict(NULL, index, &dict);
146 snprintf(msg, sizeof(msg), "getdns_list_get_dict(NULL, index, &dict),retval = %d",
147 retval);
148 tstmsg_case_msg(msg);
149
150 retval = getdns_list_get_dict(list, index, NULL);
151 snprintf(msg, sizeof(msg), "getdns_list_get_dict(list, index, NULL),retval = %d",
152 retval);
153 tstmsg_case_msg(msg);
154
155 tstmsg_case_msg("getdns_list_get_dict(list, 0, &dict)");
156 retval = getdns_list_get_dict(list, 0, &dict);
157 snprintf(msg, sizeof(msg), "getdns_list_get_dict,retval = %d", retval);
158 tstmsg_case_msg(msg);
159
160 tstmsg_case_msg("getdns_list_get_dict(list, 1, &dict)");
161 retval = getdns_list_get_dict(list, 1, &dict);
162 snprintf(msg, sizeof(msg), "getdns_list_get_dict,retval = %d", retval);
163 tstmsg_case_msg(msg);
164
165 /* test int set function against empty list with bogus params */
166
167 tstmsg_case_msg("getdns_list_set_dict(list, 0, dict)");
168 retval = getdns_list_set_dict(list, -1, dict);
169 snprintf(msg, sizeof(msg), "getdns_list_set_dict,retval = %d", retval);
170 tstmsg_case_msg(msg);
171
172 tstmsg_case_msg("getdns_list_set_dict(list, 1, dict)");
173 retval = getdns_list_set_dict(list, 1, dict);
174 snprintf(msg, sizeof(msg), "getdns_list_set_dict,retval = %d", retval);
175 tstmsg_case_msg(msg);
176
177 /* test set and get legitimate use case */
178
179 getdns_dict_set_int(dict, "foo", 42);
180 getdns_list_set_dict(list, index, dict);
181 retval = getdns_list_get_dict(list, index, &ansdict);
182 getdns_dict_get_int(ansdict, "foo", &ans_int);
183 snprintf(msg, sizeof(msg), "getdns_list_set/get_dict,retval=%d, ans=%d", retval,
184 ans_int);
185 tstmsg_case_msg(msg);
186
187 getdns_dict_destroy(dict);
188 getdns_list_destroy(list);
189
190 tstmsg_case_end();
191
192 return;
193 } /* tst_dictsetget */
194
195 /*---------------------------------------- tst_listsetget */
196 /**
197 * test the list get and set routines
198 */
199 void
200 tst_listsetget(void)
201 {
202 char msg[TSTMSGBUF];
203 size_t index = 0;
204 getdns_return_t retval;
205 uint32_t ans_int;
206 struct getdns_list *list = NULL;
207 struct getdns_list *new_list = NULL;
208 struct getdns_list *ans_list = NULL;
209
210 tstmsg_case_begin("tst_listsetget");
211
212 list = getdns_list_create();
213
214 /* test get function against empty list and with bogus params */
215
216 tstmsg_case_msg("getdns_list_get_list() empty list");
217 retval = getdns_list_get_list(NULL, index, &ans_list);
218 snprintf(msg, sizeof(msg),
219 "getdns_list_get_list(NULL, index, &ans_list),retval = %d",
220 retval);
221 tstmsg_case_msg(msg);
222
223 retval = getdns_list_get_list(list, index, NULL);
224 snprintf(msg, sizeof(msg), "getdns_list_get_list(list, index, NULL),retval = %d",
225 retval);
226 tstmsg_case_msg(msg);
227
228 tstmsg_case_msg("getdns_list_get_list(list, 0, &ans_list)");
229 retval = getdns_list_get_list(list, 0, &ans_list);
230 snprintf(msg, sizeof(msg), "getdns_list_get_list,retval = %d", retval);
231 tstmsg_case_msg(msg);
232
233 tstmsg_case_msg("getdns_list_get_list(list, 1, &ans_list)");
234 retval = getdns_list_get_list(list, 1, &ans_list);
235 snprintf(msg, sizeof(msg), "getdns_list_get_list,retval = %d", retval);
236 tstmsg_case_msg(msg);
237
238 /* test set function against empty list with bogus params */
239
240 tstmsg_case_msg("getdns_list_set_list(list, -1, ans_list)");
241 retval = getdns_list_set_list(list, -1, NULL);
242 snprintf(msg, sizeof(msg), "getdns_list_set_list,retval = %d", retval);
243 tstmsg_case_msg(msg);
244
245 tstmsg_case_msg("getdns_list_set_list(list, 1, ans_list)");
246 retval = getdns_list_set_list(list, 1, NULL);
247 snprintf(msg, sizeof(msg), "getdns_list_set_list,retval = %d", retval);
248 tstmsg_case_msg(msg);
249
250 /* test set and get legitimate use case */
251
252 new_list = getdns_list_create();
253 getdns_list_set_int(new_list, index, 42);
254
255 getdns_list_set_list(list, index, new_list);
256 retval = getdns_list_get_list(list, index, &ans_list);
257 getdns_list_get_int(ans_list, 0, &ans_int);
258 snprintf(msg, sizeof(msg), "getdns_list_set/get_list,retval = %d, ans[0] = %d",
259 retval, ans_int);
260 tstmsg_case_msg(msg);
261
262 getdns_list_destroy(new_list);
263 getdns_list_destroy(list);
264
265 tstmsg_case_end();
266
267 return;
268 } /* tst_listsetget */
269
270 /*---------------------------------------- tst_intsetget */
271 /**
272 * test the int get and set routines
273 */
274 void
275 tst_intsetget(void)
276 {
277 char msg[TSTMSGBUF];
278 size_t index = 0;
279 uint32_t ans_int;
280 getdns_return_t retval;
281 struct getdns_list *list = NULL;
282
283 tstmsg_case_begin("tst_intsetget");
284
285 list = getdns_list_create();
286
287 /* test int get function against empty list and with bogus params */
288
289 tstmsg_case_msg("getdns_list_get_int() empty list");
290 retval = getdns_list_get_int(NULL, index, &ans_int);
291 snprintf(msg, sizeof(msg), "getdns_list_get_int(NULL, index, &ans_int),retval = %d",
292 retval);
293 tstmsg_case_msg(msg);
294
295 retval = getdns_list_get_int(list, index, NULL);
296 snprintf(msg, sizeof(msg), "getdns_list_get_int(list, index, NULL),retval = %d",
297 retval);
298 tstmsg_case_msg(msg);
299
300 tstmsg_case_msg("getdns_list_get_int(list, 0, &ans_int)");
301 retval = getdns_list_get_int(list, 0, &ans_int);
302 snprintf(msg, sizeof(msg), "getdns_list_get_int,retval = %d", retval);
303 tstmsg_case_msg(msg);
304
305 tstmsg_case_msg("getdns_list_get_int(list, 1, &ans_int)");
306 retval = getdns_list_get_int(list, 1, &ans_int);
307 snprintf(msg, sizeof(msg), "getdns_list_get_int,retval = %d", retval);
308 tstmsg_case_msg(msg);
309
310 /* test int set function against empty list with bogus params */
311
312 tstmsg_case_msg("getdns_list_set_int(list, -1, ans_int)");
313 retval = getdns_list_set_int(list, -1, ans_int);
314 snprintf(msg, sizeof(msg), "getdns_list_set_int,retval = %d", retval);
315 tstmsg_case_msg(msg);
316
317 tstmsg_case_msg("getdns_list_set_int(list, 1, ans_int)");
318 retval = getdns_list_set_int(list, 1, ans_int);
319 snprintf(msg, sizeof(msg), "getdns_list_set_int,retval = %d", retval);
320 tstmsg_case_msg(msg);
321
322 /* test set and get legitimate use case */
323
324 getdns_list_set_int(list, index, 42);
325 retval = getdns_list_get_int(list, index, &ans_int);
326 snprintf(msg, sizeof(msg), "getdns_list_set/get_int,retval = %d, ans = %d", retval,
327 ans_int);
328 tstmsg_case_msg(msg);
329
330 getdns_list_destroy(list);
331
332 tstmsg_case_end();
333
334 return;
335 } /* tst_intsetget */
336
337 /*---------------------------------------- tst_create */
338 /**
339 * test the create, destroy and allocation functions
340 */
341 void
342 tst_create(void)
343 {
344 char msg[TSTMSGBUF];
345 size_t index;
346 int i;
347 getdns_return_t retval;
348 struct getdns_list *list = NULL;
349
350 /* make sure we can do a simple create/destroy first */
351
352 tstmsg_case_begin("tst_create");
353
354 tstmsg_case_msg("getdns_list_create");
355 list = getdns_list_create();
356
357 if (list != NULL) {
358 tstmsg_case_msg("getdns_list_destroy(list)");
359 getdns_list_destroy(list);
360 }
361
362 tstmsg_case_msg("getdns_list_destroy(NULL)");
363 getdns_list_destroy(NULL);
364
365 /* add items until we force it to allocate more storage */
366
367 tstmsg_case_msg("getdns_list_set_int(list, i) past block size");
368 list = getdns_list_create();
369 for (i = 0; i < GETDNS_LIST_BLOCKSZ + 2; i++) {
370 retval = getdns_list_set_int(list, i, i);
371 if (retval != GETDNS_RETURN_GOOD) {
372 snprintf(msg, sizeof(msg), "getdns_list_set_int,i=%d,retval = %d",
373 i, retval);
374 tstmsg_case_msg(msg);
375 }
376 }
377
378 tstmsg_case_msg("getdns_list_get_length(list)");
379 retval = getdns_list_get_length(list, &index);
380 snprintf(msg, sizeof(msg), "list length = %d", (int) index);
381 tstmsg_case_msg(msg);
382
383 tstmsg_case_msg("getdns_list_get_length()");
384 retval = getdns_list_get_length(NULL, &index);
385 snprintf(msg, sizeof(msg), "NUll, %i, retval = %d", (int)index, retval);
386 tstmsg_case_msg(msg);
387
388 retval = getdns_list_get_length(NULL, NULL);
389 snprintf(msg, sizeof(msg), "NUll, NULL, retval = %d", retval);
390 tstmsg_case_msg(msg);
391
392 retval = getdns_list_get_length(list, NULL);
393 snprintf(msg, sizeof(msg), "list, NULL, retval = %d", retval);
394 tstmsg_case_msg(msg);
395
396 getdns_list_destroy(list);
397
398 tstmsg_case_end();
399
400 return;
401 } /* tst_create */
402
403 /*---------------------------------------- main */
404 /**
405 * runs unit tests against list management routines
406 */
407 int
408 main(int argc, char *argv[])
409 {
410 tstmsg_prog_begin("tests_list");
411
412 tst_create();
413
414 tst_bindatasetget();
415
416 tst_dictsetget();
417
418 tst_intsetget();
419
420 tst_listsetget();
421
422 tstmsg_prog_end();
423
424 return 0;
425 } /* main */
426
427 /* end tests_list.c */
0 TESTPROG tests_list START
1 TESTCASE tests_list:tst_create BEGIN
2 tests_list:tst_create: getdns_list_create
3 tests_list:tst_create: getdns_list_destroy(list)
4 tests_list:tst_create: getdns_list_destroy(NULL)
5 tests_list:tst_create: getdns_list_set_int(list, i) past block size
6 tests_list:tst_create: getdns_list_get_length(list)
7 tests_list:tst_create: list length = 12
8 tests_list:tst_create: getdns_list_get_length()
9 tests_list:tst_create: NUll, 12, retval = 311
10 tests_list:tst_create: NUll, NULL, retval = 311
11 tests_list:tst_create: list, NULL, retval = 311
12 TESTCASE tests_list:tst_create END
13 TESTCASE tests_list:tst_bindatasetget BEGIN
14 tests_list:tst_bindatasetget: getdns_list_get_bindata() empty list
15 tests_list:tst_bindatasetget: getdns_list_get_bindata(NULL, index, &ans_bindata),retval = 311
16 tests_list:tst_bindatasetget: getdns_list_get_bindata(list, index, NULL),retval = 311
17 tests_list:tst_bindatasetget: getdns_list_get_bindata(list, 0, &ans_bindata)
18 tests_list:tst_bindatasetget: getdns_list_get_bindata,retval = 304
19 tests_list:tst_bindatasetget: getdns_list_get_bindata(list, 1, &ans_bindata)
20 tests_list:tst_bindatasetget: getdns_list_get_bindata,retval = 304
21 tests_list:tst_bindatasetget: getdns_list_set_bindata(list, -1, ans_bindata)
22 tests_list:tst_bindatasetget: getdns_list_set_bindata,retval = 311
23 tests_list:tst_bindatasetget: getdns_list_set_bindata(list, 1, ans_bindata)
24 tests_list:tst_bindatasetget: getdns_list_set_bindata,retval = 311
25 tests_list:tst_bindatasetget: getdns_list_set/get_bindata,retval = 0, bindata->data = 7,foobar
26 TESTCASE tests_list:tst_bindatasetget END
27 TESTCASE tests_list:tst_dictsetget BEGIN
28 tests_list:tst_dictsetget: getdns_list_get_dict() empty list
29 tests_list:tst_dictsetget: getdns_list_get_dict(NULL, index, &dict),retval = 311
30 tests_list:tst_dictsetget: getdns_list_get_dict(list, index, NULL),retval = 311
31 tests_list:tst_dictsetget: getdns_list_get_dict(list, 0, &dict)
32 tests_list:tst_dictsetget: getdns_list_get_dict,retval = 304
33 tests_list:tst_dictsetget: getdns_list_get_dict(list, 1, &dict)
34 tests_list:tst_dictsetget: getdns_list_get_dict,retval = 304
35 tests_list:tst_dictsetget: getdns_list_set_dict(list, 0, dict)
36 tests_list:tst_dictsetget: getdns_list_set_dict,retval = 304
37 tests_list:tst_dictsetget: getdns_list_set_dict(list, 1, dict)
38 tests_list:tst_dictsetget: getdns_list_set_dict,retval = 304
39 tests_list:tst_dictsetget: getdns_list_set/get_dict,retval=0, ans=42
40 TESTCASE tests_list:tst_dictsetget END
41 TESTCASE tests_list:tst_intsetget BEGIN
42 tests_list:tst_intsetget: getdns_list_get_int() empty list
43 tests_list:tst_intsetget: getdns_list_get_int(NULL, index, &ans_int),retval = 311
44 tests_list:tst_intsetget: getdns_list_get_int(list, index, NULL),retval = 311
45 tests_list:tst_intsetget: getdns_list_get_int(list, 0, &ans_int)
46 tests_list:tst_intsetget: getdns_list_get_int,retval = 304
47 tests_list:tst_intsetget: getdns_list_get_int(list, 1, &ans_int)
48 tests_list:tst_intsetget: getdns_list_get_int,retval = 304
49 tests_list:tst_intsetget: getdns_list_set_int(list, -1, ans_int)
50 tests_list:tst_intsetget: getdns_list_set_int,retval = 304
51 tests_list:tst_intsetget: getdns_list_set_int(list, 1, ans_int)
52 tests_list:tst_intsetget: getdns_list_set_int,retval = 304
53 tests_list:tst_intsetget: getdns_list_set/get_int,retval = 0, ans = 42
54 TESTCASE tests_list:tst_intsetget END
55 TESTCASE tests_list:tst_listsetget BEGIN
56 tests_list:tst_listsetget: getdns_list_get_list() empty list
57 tests_list:tst_listsetget: getdns_list_get_list(NULL, index, &ans_list),retval = 311
58 tests_list:tst_listsetget: getdns_list_get_list(list, index, NULL),retval = 311
59 tests_list:tst_listsetget: getdns_list_get_list(list, 0, &ans_list)
60 tests_list:tst_listsetget: getdns_list_get_list,retval = 304
61 tests_list:tst_listsetget: getdns_list_get_list(list, 1, &ans_list)
62 tests_list:tst_listsetget: getdns_list_get_list,retval = 304
63 tests_list:tst_listsetget: getdns_list_set_list(list, -1, ans_list)
64 tests_list:tst_listsetget: getdns_list_set_list,retval = 311
65 tests_list:tst_listsetget: getdns_list_set_list(list, 1, ans_list)
66 tests_list:tst_listsetget: getdns_list_set_list,retval = 311
67 tests_list:tst_listsetget: getdns_list_set/get_list,retval = 0, ans[0] = 42
68 TESTCASE tests_list:tst_listsetget END
69 TESTPROG tests_list END
0 /**
1 * \file
2 * unit tests for getdns_dict helper routines, these should be used to
3 * perform regression tests, output must be unchanged from canonical output
4 * stored with the sources
5 */
6
7 /*
8 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * * Neither the names of the copyright holders nor the
19 * names of its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #include "config.h"
35 #ifdef HAVE_EVENT2_EVENT_H
36 # include <event2/event.h>
37 #else
38 # include <event.h>
39 #endif
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43 #include "testmessages.h"
44 #include <getdns/getdns.h>
45 #include <getdns/getdns_ext_libevent.h>
46 #include <sys/time.h>
47
48 /* Set up the callback function, which will also do the processing of the results */
49 void
50 this_callbackfn(struct getdns_context *this_context,
51 getdns_callback_type_t this_callback_type,
52 struct getdns_dict *this_response,
53 void *this_userarg, getdns_transaction_t this_transaction_id)
54 {
55 if (this_callback_type == GETDNS_CALLBACK_COMPLETE) { /* This is a callback with data */
56 char *res = getdns_pretty_print_dict(this_response);
57 fprintf(stdout, "%s\n", res);
58 free(res);
59
60 } else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
61 fprintf(stderr,
62 "The callback with ID %llu was cancelled. Exiting.",
63 (unsigned long long)this_transaction_id);
64 else
65 fprintf(stderr,
66 "The callback got a callback_type of %d. Exiting.",
67 this_callback_type);
68 getdns_dict_destroy(this_response);
69 }
70
71 int
72 main(int argc, char** argv)
73 {
74 /* Create the DNS context for this call */
75 struct getdns_context *this_context = NULL;
76 getdns_return_t context_create_return =
77 getdns_context_create(&this_context, 1);
78 if (context_create_return != GETDNS_RETURN_GOOD) {
79 fprintf(stderr, "Trying to create the context failed: %d",
80 context_create_return);
81 return (GETDNS_RETURN_GENERIC_ERROR);
82 }
83 getdns_context_set_resolution_type(this_context, GETDNS_RESOLUTION_STUB);
84
85 getdns_context_set_timeout(this_context, 5000);
86 /* Create an event base and put it in the context using the unknown function name */
87 struct event_base *this_event_base;
88 this_event_base = event_base_new();
89 if (this_event_base == NULL) {
90 fprintf(stderr, "Trying to create the event base failed.");
91 getdns_context_destroy(this_context);
92 return (GETDNS_RETURN_GENERIC_ERROR);
93 }
94 if (getdns_extension_set_libevent_base(this_context,
95 this_event_base) != GETDNS_RETURN_GOOD) {
96 fprintf(stderr, "Setting event base failed.");
97 getdns_context_destroy(this_context);
98 return (GETDNS_RETURN_GENERIC_ERROR);
99 }
100 /* Set up the getdns call */
101 const char *this_name = argc > 1 ? argv[1] : "getdnsapi.net";
102 char *this_userarg = "somestring"; // Could add things here to help identify this call
103 getdns_transaction_t this_transaction_id = 0;
104
105 /* Make the call */
106 getdns_return_t dns_request_return =
107 getdns_general(this_context, this_name, GETDNS_RRTYPE_A,
108 NULL, this_userarg, &this_transaction_id, this_callbackfn);
109 if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME) {
110 fprintf(stderr, "A bad domain name was used: %s. Exiting.",
111 this_name);
112 getdns_context_destroy(this_context);
113 event_base_free(this_event_base);
114 return (GETDNS_RETURN_GENERIC_ERROR);
115 }
116 // dns_request_return = getdns_service(this_context, this_name, NULL, this_userarg, &this_transaction_id,
117 // this_callbackfn);
118 // if (dns_request_return == GETDNS_RETURN_BAD_DOMAIN_NAME)
119 // {
120 // fprintf(stderr, "A bad domain name was used: %s. Exiting.", this_name);
121 // return(GETDNS_RETURN_GENERIC_ERROR);
122 // }
123 else {
124 /* Call the event loop */
125 event_base_loop(this_event_base, EVLOOP_ONCE);
126 while (getdns_context_get_num_pending_requests(this_context, NULL) > 0) {
127 event_base_loop(this_event_base, EVLOOP_ONCE);
128 }
129 // TODO: check the return value above
130 }
131 /* Clean up */
132 getdns_context_destroy(this_context);
133 /* the event base can only be free'd after the context has removed
134 * all of its events from it */
135 event_base_free(this_event_base);
136 /* Assuming we get here, leave gracefully */
137 exit(EXIT_SUCCESS);
138 } /* main */
139
140 /* tests_stub_async.c */
0 {
1 "answer_type": 800,
2 "canonical_name": <bindata of "www.google.com.">,
3 "just_address_answers":
4 [
5 {
6 "address_data": <bindata of 0x4a7d8369>,
7 "address_type": <bindata of "IPv4">
8 },
9 {
10 "address_data": <bindata of 0x4a7d8367>,
11 "address_type": <bindata of "IPv4">
12 },
13 {
14 "address_data": <bindata of 0x4a7d8368>,
15 "address_type": <bindata of "IPv4">
16 },
17 {
18 "address_data": <bindata of 0x4a7d8393>,
19 "address_type": <bindata of "IPv4">
20 },
21 {
22 "address_data": <bindata of 0x4a7d836a>,
23 "address_type": <bindata of "IPv4">
24 },
25 {
26 "address_data": <bindata of 0x4a7d8363>,
27 "address_type": <bindata of "IPv4">
28 },
29 {
30 "address_data": <bindata of 0x2607f8b0400c0c030000000000000067>,
31 "address_type": <bindata of "IPv6">
32 }
33 ],
34 "replies_full":
35 [
36 <bindata of 0x00008180000100060000000103777777...>,
37 <bindata of 0x00008180000100010000000103777777...>
38 ],
39 "replies_tree":
40 [
41 {
42 "additional": [],
43 "answer":
44 [
45 {
46 "class": 1,
47 "name": <bindata for www.google.com.>,
48 "rdata":
49 {
50 "ipv4_address": <bindata of 0x4a7d8369>,
51 "rdata_raw": <bindata of 0x4a7d8369>
52 },
53 "ttl": 227,
54 "type": GETDNS_RRTYPE_A
55 },
56 {
57 "class": 1,
58 "name": <bindata for www.google.com.>,
59 "rdata":
60 {
61 "ipv4_address": <bindata of 0x4a7d8367>,
62 "rdata_raw": <bindata of 0x4a7d8367>
63 },
64 "ttl": 227,
65 "type": GETDNS_RRTYPE_A
66 },
67 {
68 "class": 1,
69 "name": <bindata for www.google.com.>,
70 "rdata":
71 {
72 "ipv4_address": <bindata of 0x4a7d8368>,
73 "rdata_raw": <bindata of 0x4a7d8368>
74 },
75 "ttl": 227,
76 "type": GETDNS_RRTYPE_A
77 },
78 {
79 "class": 1,
80 "name": <bindata for www.google.com.>,
81 "rdata":
82 {
83 "ipv4_address": <bindata of 0x4a7d8393>,
84 "rdata_raw": <bindata of 0x4a7d8393>
85 },
86 "ttl": 227,
87 "type": GETDNS_RRTYPE_A
88 },
89 {
90 "class": 1,
91 "name": <bindata for www.google.com.>,
92 "rdata":
93 {
94 "ipv4_address": <bindata of 0x4a7d836a>,
95 "rdata_raw": <bindata of 0x4a7d836a>
96 },
97 "ttl": 227,
98 "type": GETDNS_RRTYPE_A
99 },
100 {
101 "class": 1,
102 "name": <bindata for www.google.com.>,
103 "rdata":
104 {
105 "ipv4_address": <bindata of 0x4a7d8363>,
106 "rdata_raw": <bindata of 0x4a7d8363>
107 },
108 "ttl": 227,
109 "type": GETDNS_RRTYPE_A
110 }
111 ],
112 "answer_type": 800,
113 "authority": [],
114 "canonical_name": <bindata of "www.google.com.">,
115 "header":
116 {
117 "aa": 0,
118 "ad": 0,
119 "ancount": 6,
120 "arcount": 0,
121 "cd": 0,
122 "id": 0,
123 "nscount": 0,
124 "opcode": 0,
125 "qdcount": 1,
126 "qr": 1,
127 "ra": 1,
128 "rcode": 0,
129 "rd": 1,
130 "tc": 0,
131 "z": 0
132 },
133 "question":
134 {
135 "qclass": 1,
136 "qname": <bindata for www.google.com.>,
137 "qtype": 1
138 }
139 },
140 {
141 "additional": [],
142 "answer":
143 [
144 {
145 "class": 1,
146 "name": <bindata for www.google.com.>,
147 "rdata":
148 {
149 "ipv6_address": <bindata of 0x2607f8b0400c0c030000000000000067>,
150 "rdata_raw": <bindata of 0x2607f8b0400c0c030000000000000067>
151 },
152 "ttl": 136,
153 "type": GETDNS_RRTYPE_AAAA
154 }
155 ],
156 "answer_type": 800,
157 "authority": [],
158 "canonical_name": <bindata of "www.google.com.">,
159 "header":
160 {
161 "aa": 0,
162 "ad": 0,
163 "ancount": 1,
164 "arcount": 0,
165 "cd": 0,
166 "id": 0,
167 "nscount": 0,
168 "opcode": 0,
169 "qdcount": 1,
170 "qr": 1,
171 "ra": 1,
172 "rcode": 0,
173 "rd": 1,
174 "tc": 0,
175 "z": 0
176 },
177 "question":
178 {
179 "qclass": 1,
180 "qname": <bindata for www.google.com.>,
181 "qtype": 28
182 }
183 }
184 ],
185 "status": 900
186 }
0 /**
1 * \file
2 * unit tests for getdns_dict helper routines, these should be used to
3 * perform regression tests, output must be unchanged from canonical output
4 * stored with the sources
5 */
6
7 /*
8 * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * * Neither the names of the copyright holders nor the
19 * names of its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
26 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37 #include "testmessages.h"
38 #include <getdns/getdns.h>
39
40 static void
41 print_response(struct getdns_dict * response)
42 {
43 char *dict_str = getdns_pretty_print_dict(response);
44 if (dict_str) {
45 fprintf(stdout, "The packet %s\n", dict_str);
46 free(dict_str);
47 }
48 }
49
50 int
51 main()
52 {
53 /* Create the DNS context for this call */
54 struct getdns_context *this_context = NULL;
55 getdns_return_t context_create_return =
56 getdns_context_create(&this_context, 1);
57 if (context_create_return != GETDNS_RETURN_GOOD) {
58 fprintf(stderr, "Trying to create the context failed: %d",
59 context_create_return);
60 return (GETDNS_RETURN_GENERIC_ERROR);
61 }
62 getdns_context_set_resolution_type(this_context, GETDNS_RESOLUTION_STUB);
63
64 struct getdns_dict *response = NULL;
65 getdns_return_t ret =
66 getdns_address_sync(this_context, "www.google.com", NULL, &response);
67
68 if (ret != GETDNS_RETURN_GOOD || response == NULL) {
69 fprintf(stderr, "Address sync returned error.\n");
70 exit(EXIT_FAILURE);
71 }
72 print_response(response);
73 getdns_dict_destroy(response);
74
75 ret =
76 getdns_service_sync(this_context, "www.google.com", NULL, &response);
77 if (ret != GETDNS_RETURN_GOOD || response == NULL) {
78 fprintf(stderr, "Service sync returned error.\n");
79 exit(EXIT_FAILURE);
80 }
81 print_response(response);
82 getdns_dict_destroy(response);
83
84 /* Clean up */
85 getdns_context_destroy(this_context);
86 /* Assuming we get here, leave gracefully */
87 exit(EXIT_SUCCESS);
88 } /* main */
89
90 /* tests_stub_sync.c */
0 The packet {
1 "answer_type": 800,
2 "canonical_name": <bindata of "www.google.com.">,
3 "just_address_answers":
4 [
5 {
6 "address_data": <bindata of 0x4a7d8393>,
7 "address_type": <bindata of "IPv4">
8 },
9 {
10 "address_data": <bindata of 0x4a7d8368>,
11 "address_type": <bindata of "IPv4">
12 },
13 {
14 "address_data": <bindata of 0x4a7d8363>,
15 "address_type": <bindata of "IPv4">
16 },
17 {
18 "address_data": <bindata of 0x4a7d8367>,
19 "address_type": <bindata of "IPv4">
20 },
21 {
22 "address_data": <bindata of 0x4a7d836a>,
23 "address_type": <bindata of "IPv4">
24 },
25 {
26 "address_data": <bindata of 0x4a7d8369>,
27 "address_type": <bindata of "IPv4">
28 },
29 {
30 "address_data": <bindata of 0x2607f8b0400c0c030000000000000068>,
31 "address_type": <bindata of "IPv6">
32 }
33 ],
34 "replies_full":
35 [
36 <bindata of 0x00008180000100060000000103777777...>,
37 <bindata of 0x00008180000100010000000103777777...>
38 ],
39 "replies_tree":
40 [
41 {
42 "additional": [],
43 "answer":
44 [
45 {
46 "class": 1,
47 "name": <bindata for www.google.com.>,
48 "rdata":
49 {
50 "ipv4_address": <bindata of 0x4a7d8393>,
51 "rdata_raw": <bindata of 0x4a7d8393>
52 },
53 "ttl": 300,
54 "type": GETDNS_RRTYPE_A
55 },
56 {
57 "class": 1,
58 "name": <bindata for www.google.com.>,
59 "rdata":
60 {
61 "ipv4_address": <bindata of 0x4a7d8368>,
62 "rdata_raw": <bindata of 0x4a7d8368>
63 },
64 "ttl": 300,
65 "type": GETDNS_RRTYPE_A
66 },
67 {
68 "class": 1,
69 "name": <bindata for www.google.com.>,
70 "rdata":
71 {
72 "ipv4_address": <bindata of 0x4a7d8363>,
73 "rdata_raw": <bindata of 0x4a7d8363>
74 },
75 "ttl": 300,
76 "type": GETDNS_RRTYPE_A
77 },
78 {
79 "class": 1,
80 "name": <bindata for www.google.com.>,
81 "rdata":
82 {
83 "ipv4_address": <bindata of 0x4a7d8367>,
84 "rdata_raw": <bindata of 0x4a7d8367>
85 },
86 "ttl": 300,
87 "type": GETDNS_RRTYPE_A
88 },
89 {
90 "class": 1,
91 "name": <bindata for www.google.com.>,
92 "rdata":
93 {
94 "ipv4_address": <bindata of 0x4a7d836a>,
95 "rdata_raw": <bindata of 0x4a7d836a>
96 },
97 "ttl": 300,
98 "type": GETDNS_RRTYPE_A
99 },
100 {
101 "class": 1,
102 "name": <bindata for www.google.com.>,
103 "rdata":
104 {
105 "ipv4_address": <bindata of 0x4a7d8369>,
106 "rdata_raw": <bindata of 0x4a7d8369>
107 },
108 "ttl": 300,
109 "type": GETDNS_RRTYPE_A
110 }
111 ],
112 "answer_type": 800,
113 "authority": [],
114 "canonical_name": <bindata of "www.google.com.">,
115 "header":
116 {
117 "aa": 0,
118 "ad": 0,
119 "ancount": 6,
120 "arcount": 0,
121 "cd": 0,
122 "id": 0,
123 "nscount": 0,
124 "opcode": 0,
125 "qdcount": 1,
126 "qr": 1,
127 "ra": 1,
128 "rcode": 0,
129 "rd": 1,
130 "tc": 0,
131 "z": 0
132 },
133 "question":
134 {
135 "qclass": 1,
136 "qname": <bindata for www.google.com.>,
137 "qtype": 1
138 }
139 },
140 {
141 "additional": [],
142 "answer":
143 [
144 {
145 "class": 1,
146 "name": <bindata for www.google.com.>,
147 "rdata":
148 {
149 "ipv6_address": <bindata of 0x2607f8b0400c0c030000000000000068>,
150 "rdata_raw": <bindata of 0x2607f8b0400c0c030000000000000068>
151 },
152 "ttl": 300,
153 "type": GETDNS_RRTYPE_AAAA
154 }
155 ],
156 "answer_type": 800,
157 "authority": [],
158 "canonical_name": <bindata of "www.google.com.">,
159 "header":
160 {
161 "aa": 0,
162 "ad": 0,
163 "ancount": 1,
164 "arcount": 0,
165 "cd": 0,
166 "id": 0,
167 "nscount": 0,
168 "opcode": 0,
169 "qdcount": 1,
170 "qr": 1,
171 "ra": 1,
172 "rcode": 0,
173 "rd": 1,
174 "tc": 0,
175 "z": 0
176 },
177 "question":
178 {
179 "qclass": 1,
180 "qname": <bindata for www.google.com.>,
181 "qtype": 28
182 }
183 }
184 ],
185 "status": 900
186 }
187 The packet {
188 "answer_type": 800,
189 "canonical_name": <bindata of "www.google.com.">,
190 "just_address_answers": [],
191 "replies_full":
192 [
193 <bindata of 0x00008180000100000001000103777777...>
194 ],
195 "replies_tree":
196 [
197 {
198 "additional": [],
199 "answer": [],
200 "answer_type": 800,
201 "authority":
202 [
203 {
204 "class": 1,
205 "name": <bindata for google.com.>,
206 "rdata":
207 {
208 "expire": 300,
209 "mname": <bindata for ns1.google.com.>,
210 "rdata_raw": <bindata of 0x036e733106676f6f676c6503636f6d00...>,
211 "refresh": 1800,
212 "retry": 1209600,
213 "rname": <bindata for dns-admin.google.com.>,
214 "serial": 1546121
215 },
216 "ttl": 60,
217 "type": GETDNS_RRTYPE_SOA
218 }
219 ],
220 "canonical_name": <bindata of "www.google.com.">,
221 "header":
222 {
223 "aa": 0,
224 "ad": 0,
225 "ancount": 0,
226 "arcount": 0,
227 "cd": 0,
228 "id": 0,
229 "nscount": 1,
230 "opcode": 0,
231 "qdcount": 1,
232 "qr": 1,
233 "ra": 1,
234 "rcode": 0,
235 "rd": 1,
236 "tc": 0,
237 "z": 0
238 },
239 "question":
240 {
241 "qclass": 1,
242 "qname": <bindata for www.google.com.>,
243 "qtype": 33
244 }
245 }
246 ],
247 "status": 900
248 }
0 #!/bin/sh
1 # Copyright (c) 2013, Verisign, Inc., NLNet Labs
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are met:
6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution.
11 # * Neither the names of the copyright holders nor the
12 # names of its contributors may be used to endorse or promote products
13 # derived from this software without specific prior written permission.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 # DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
19 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26 # run $1 > $2 and exit on failure to execute
27 runit () {
28 echo -n "Test $1:"
29 ./$1 > $2
30 if test $? -ne 0; then
31 echo " failed (execution failed)"
32 exit 1
33 fi
34 }
35
36 # check output files $1 and $2, exit on failure
37 diffit () {
38 if diff $1 $2; then
39 echo " OK"
40 else
41 echo " failed (differences above)"
42 exit 1
43 fi
44 }
45
46 # check output of program $1, known_good must be in $1.good
47 checkoutput () {
48 runit $1 output
49 diffit output $1.good
50 }
51
52 # filter out TTL and bindata stuff from $1 to $2
53 filterout () {
54 sed -e '/"ttl"/d' -e '/"ipv4_address"/d' -e '/"ipv6_address"/d' -e '/"rdata_raw"/d' -e '/<bindata/d' -e '/"serial"/d' <$1 >$2
55 }
56
57 # like checkoutput but removes addresses and TTLs and bindata
58 # this makes the test almost useless, but it tests runtime lookup
59 # and the structure of the answer format, against the live internet.
60 checkpacket () {
61 runit $1 output
62 cp $1.good output.good
63 filterout output output2
64 filterout output.good output2.good
65 diffit output2 output2.good
66 }
67
68 echo "./check_getdns"
69 ./check_getdns
70 if test $? -ne 0; then
71 echo " failed (unit test execution failed)"
72 exit 1
73 fi
74 checkoutput tests_dict
75 checkoutput tests_list
76
77 # the packets are too different to compare for people
78 #checkpacket tests_stub_async
79 #checkpacket tests_stub_sync
80
81 runit tests_stub_async output
82 echo " exitcode-OK"
83 runit tests_stub_sync output
84 echo " exitcode-OK"
85 runit tests_dnssec output
86 echo " exitcode-OK"
87
88 rm -f output output.good output2 output2.good
89 exit 0
0 /**
1 *
2 * /brief type declarations private to the getdns library
3 *
4 * These type declarations are not meant to be used by applications calling
5 * the public library functions.
6 */
7
8 /*
9 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * * Neither the names of the copyright holders nor the
20 * names of its contributors may be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef TYPES_INTERNAL_H_
36 #define TYPES_INTERNAL_H_
37
38 #include <getdns/getdns.h>
39 #include <netinet/in.h>
40 #include <ldns/ldns.h>
41 struct getdns_context;
42
43 /**
44 * \defgroup strings String Constants
45 * @{
46 */
47 #define GETDNS_STR_IPV4 "IPv4"
48 #define GETDNS_STR_IPV6 "IPv6"
49 #define GETDNS_STR_ADDRESS_TYPE "address_type"
50 #define GETDNS_STR_ADDRESS_DATA "address_data"
51 #define GETDNS_STR_ADDRESS_STRING "address_string"
52 #define GETDNS_STR_PORT "port"
53 #define GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6 "return_both_v4_and_v6"
54
55 #define GETDNS_STR_KEY_STATUS "status"
56 #define GETDNS_STR_KEY_REPLIES_TREE "replies_tree"
57 #define GETDNS_STR_KEY_REPLIES_FULL "replies_full"
58 #define GETDNS_STR_KEY_JUST_ADDRS "just_address_answers"
59 #define GETDNS_STR_KEY_CANONICAL_NM "canonical_name"
60 #define GETDNS_STR_KEY_ANSWER_TYPE "answer_type"
61 #define GETDNS_STR_KEY_INTERM_ALIASES "intermediate_aliases"
62 #define GETDNS_STR_KEY_NAME "name"
63 #define GETDNS_STR_KEY_HEADER "header"
64 #define GETDNS_STR_KEY_QUESTION "question"
65 #define GETDNS_STR_KEY_ANSWER "answer"
66 #define GETDNS_STR_KEY_TYPE "type"
67 #define GETDNS_STR_KEY_CLASS "class"
68 #define GETDNS_STR_KEY_TTL "ttl"
69 #define GETDNS_STR_KEY_RDATA "rdata"
70 #define GETDNS_STR_KEY_V4_ADDR "ipv4_address"
71 #define GETDNS_STR_KEY_V6_ADDR "ipv6_address"
72 #define GETDNS_STR_KEY_RDATA_RAW "rdata_raw"
73 #define GETDNS_STR_KEY_AUTHORITY "authority"
74 #define GETDNS_STR_KEY_ADDITIONAL "additional"
75 #define GETDNS_STR_KEY_QTYPE "qtype"
76 #define GETDNS_STR_KEY_QCLASS "qclass"
77 #define GETDNS_STR_KEY_QNAME "qname"
78 #define GETDNS_STR_KEY_QR "qr"
79 /* header flags */
80 #define GETDNS_STR_KEY_ID "id"
81 #define GETDNS_STR_KEY_OPCODE "opcode"
82 #define GETDNS_STR_KEY_RCODE "rcode"
83 #define GETDNS_STR_KEY_AA "aa"
84 #define GETDNS_STR_KEY_TC "tc"
85 #define GETDNS_STR_KEY_RD "rd"
86 #define GETDNS_STR_KEY_RA "ra"
87 #define GETDNS_STR_KEY_AD "ad"
88 #define GETDNS_STR_KEY_CD "cd"
89 #define GETDNS_STR_KEY_Z "z"
90 #define GETDNS_STR_KEY_QDCOUNT "qdcount"
91 #define GETDNS_STR_KEY_ANCOUNT "ancount"
92 #define GETDNS_STR_KEY_NSCOUNT "nscount"
93 #define GETDNS_STR_KEY_ARCOUNT "arcount"
94
95
96 /** @}
97 */
98
99 /* declarations */
100 struct getdns_dns_req;
101 struct getdns_network_req;
102
103
104 #define MF_PLAIN ((void *)&plain_mem_funcs_user_arg)
105 extern void *plain_mem_funcs_user_arg;
106
107 typedef union {
108 struct {
109 void *(*malloc)(size_t);
110 void *(*realloc)(void *, size_t);
111 void (*free)(void *);
112 } pln;
113 struct {
114 void *(*malloc)(void *userarg, size_t);
115 void *(*realloc)(void *userarg, void *, size_t);
116 void (*free)(void *userarg, void *);
117 } ext;
118 } mf_union;
119
120 struct mem_funcs {
121 void *mf_arg;
122 mf_union mf;
123 };
124
125 typedef enum network_req_state_enum
126 {
127 NET_REQ_NOT_SENT,
128 NET_REQ_IN_FLIGHT,
129 NET_REQ_FINISHED,
130 NET_REQ_CANCELED
131 } network_req_state;
132
133 /**
134 * structure used by validate_extensions() to check extension formats
135 */
136 typedef struct getdns_extension_format
137 {
138 char *extstring;
139 getdns_data_type exttype;
140 } getdns_extension_format;
141
142 /**
143 * Request data for unbound
144 **/
145 typedef struct getdns_network_req
146 {
147 /* the async_id from unbound */
148 int unbound_id;
149 /* state var */
150 network_req_state state;
151 /* owner request (contains name) */
152 struct getdns_dns_req *owner;
153
154 /* request type */
155 uint16_t request_type;
156
157 /* request class */
158 uint16_t request_class;
159
160 /* result */
161 ldns_pkt *result;
162 int secure;
163 int bogus;
164
165 /* next request to issue after this one */
166 struct getdns_network_req *next;
167 } getdns_network_req;
168
169 /**
170 * dns request - manages a number of network requests and
171 * the initial data passed to getdns_general
172 */
173 typedef struct getdns_dns_req
174 {
175
176 /* name */
177 char *name;
178
179 /* canceled flag */
180 int canceled;
181
182 /* current network request */
183 struct getdns_network_req *current_req;
184
185 /* first request in list */
186 struct getdns_network_req *first_req;
187
188 /* context that owns the request */
189 struct getdns_context *context;
190
191 /* request extensions */
192 struct getdns_dict *extensions;
193
194 /* callback data */
195 getdns_callback_t user_callback;
196 void *user_pointer;
197
198 /* the transaction id */
199 getdns_transaction_t trans_id;
200
201 /* local timeout id */
202 getdns_transaction_t local_timeout_id;
203
204 /* dnssec status */
205 int return_dnssec_status;
206
207 /* mem funcs */
208 struct mem_funcs my_mf;
209
210 } getdns_dns_req;
211
212 #define GETDNS_XMALLOC(obj, type, count) \
213 ((obj).mf_arg == MF_PLAIN \
214 ? ((type *)(*(obj).mf.pln.malloc)( (count)*sizeof(type))) \
215 : ((type *)(*(obj).mf.ext.malloc)((obj).mf_arg, (count)*sizeof(type))) \
216 )
217
218 #define GETDNS_XREALLOC(obj, ptr, type, count) \
219 ((obj).mf_arg == MF_PLAIN \
220 ? ((type *)(*(obj).mf.pln.realloc)( (ptr), (count)*sizeof(type))) \
221 : ((type *)(*(obj).mf.ext.realloc)( (obj).mf_arg \
222 , (ptr), (count)*sizeof(type))) \
223 )
224
225 #define GETDNS_FREE(obj, ptr) \
226 ((obj).mf_arg == MF_PLAIN \
227 ? ((*(obj).mf.pln.free)( (ptr))) \
228 : ((*(obj).mf.ext.free)((obj).mf_arg, (ptr))) \
229 )
230
231 #define GETDNS_MALLOC(obj, type) GETDNS_XMALLOC(obj, type, 1)
232 #define GETDNS_REALLOC(obj, ptr, type) GETDNS_XREALLOC(obj, ptr, type, 1);
233
234
235 /* utility methods */
236
237 /* network request utilities */
238 void network_req_free(getdns_network_req * net_req);
239
240 getdns_network_req *network_req_new(getdns_dns_req * owner,
241 uint16_t request_type,
242 uint16_t request_class, struct getdns_dict *extensions);
243
244 /* dns request utils */
245 getdns_dns_req *dns_req_new(struct getdns_context *context,
246 const char *name, uint16_t request_type, struct getdns_dict *extensions);
247
248 void dns_req_free(getdns_dns_req * req);
249
250
251 #endif
252
253 /* types-internal.h */
0 /**
1 *
2 * \file util-internal.c
3 * @brief private library routines
4 *
5 * These routines are not intended to be used by applications calling into
6 * the library.
7 *
8 */
9
10 /*
11 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are met:
16 * * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * * Neither the names of the copyright holders nor the
22 * names of its contributors may be used to endorse or promote products
23 * derived from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
29 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #include "getdns/getdns.h"
38 #include <ldns/rbtree.h>
39 #include "dict.h"
40 #include "list.h"
41 #include "util-internal.h"
42 #include "types-internal.h"
43 #include <unbound.h>
44 #include "rr-dict.h"
45
46 /**
47 * this is a comprehensive list of extensions and their data types
48 * used by validate_extensions()
49 * The list has to be in sorted order for bsearch lookup in function
50 * validate_extensions.
51 */
52 static getdns_extension_format extformats[] = {
53 {"add_opt_parameters", t_dict},
54 {"add_warning_for_bad_dns", t_int},
55 {"dnssec_return_only_secure", t_int},
56 {"dnssec_return_status", t_int},
57 {"dnssec_return_validation_chain", t_int},
58 {"return_api_information", t_int},
59 {"return_both_v4_and_v6", t_int},
60 {"return_call_debugging", t_int},
61 {"specify_class", t_int},
62 };
63
64 static struct getdns_bindata IPv4_str_bindata = { 5, (void *)"IPv4" };
65 static struct getdns_bindata IPv6_str_bindata = { 5, (void *)"IPv6" };
66
67 getdns_return_t
68 getdns_dict_util_set_string(struct getdns_dict * dict, char *name, const char *value)
69 {
70 /* account for the null term */
71 if (value == NULL) {
72 return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
73 }
74 struct getdns_bindata type_bin = { strlen(value) + 1, (uint8_t *) value };
75 return getdns_dict_set_bindata(dict, name, &type_bin);
76 }
77
78 getdns_return_t
79 getdns_dict_util_get_string(struct getdns_dict * dict, char *name, char **result)
80 {
81 struct getdns_bindata *bindata = NULL;
82 if (!result) {
83 return GETDNS_RETURN_GENERIC_ERROR;
84 }
85 *result = NULL;
86 getdns_dict_get_bindata(dict, name, &bindata);
87 if (!bindata) {
88 return GETDNS_RETURN_GENERIC_ERROR;
89 }
90 *result = (char *) bindata->data;
91 return GETDNS_RETURN_GOOD;
92 }
93
94 getdns_return_t
95 dict_to_sockaddr(struct getdns_dict * ns, struct sockaddr_storage * output)
96 {
97 char *address_type = NULL;
98 struct getdns_bindata *address_data = NULL;
99 uint32_t port = 53;
100 memset(output, 0, sizeof(struct sockaddr_storage));
101 output->ss_family = AF_UNSPEC;
102
103 uint32_t prt = 0;
104 if (getdns_dict_get_int(ns, GETDNS_STR_PORT,
105 &prt) == GETDNS_RETURN_GOOD) {
106 port = prt;
107 }
108
109 getdns_dict_util_get_string(ns, GETDNS_STR_ADDRESS_TYPE,
110 &address_type);
111 getdns_dict_get_bindata(ns, GETDNS_STR_ADDRESS_DATA, &address_data);
112 if (!address_type || !address_data) {
113 return GETDNS_RETURN_GENERIC_ERROR;
114 }
115 if (strncmp(GETDNS_STR_IPV4, address_type,
116 strlen(GETDNS_STR_IPV4)) == 0) {
117 /* data is an in_addr_t */
118 struct sockaddr_in *addr = (struct sockaddr_in *) output;
119 addr->sin_family = AF_INET;
120 addr->sin_port = htons((uint16_t) port);
121 memcpy(&(addr->sin_addr), address_data->data,
122 address_data->size);
123 } else {
124 /* data is a v6 addr in host order */
125 struct sockaddr_in6 *addr = (struct sockaddr_in6 *) output;
126 addr->sin6_family = AF_INET6;
127 addr->sin6_port = htons((uint16_t) port);
128 memcpy(&(addr->sin6_addr), address_data->data,
129 address_data->size);
130 }
131 return GETDNS_RETURN_GOOD;
132 }
133
134 getdns_return_t
135 sockaddr_to_dict(struct getdns_context *context, struct sockaddr_storage *address,
136 struct getdns_dict ** output)
137 {
138 if (!output || !address) {
139 return GETDNS_RETURN_GENERIC_ERROR;
140 }
141 struct getdns_bindata addr_data;
142 *output = NULL;
143 struct getdns_dict *result = getdns_dict_create_with_context(context);
144 if (address->ss_family == AF_INET) {
145 struct sockaddr_in *addr = (struct sockaddr_in *) address;
146 getdns_dict_util_set_string(result, GETDNS_STR_ADDRESS_TYPE,
147 GETDNS_STR_IPV4);
148 addr_data.size = sizeof(addr->sin_addr);
149 addr_data.data = (uint8_t *) & (addr->sin_addr);
150 getdns_dict_set_bindata(result, GETDNS_STR_ADDRESS_DATA,
151 &addr_data);
152 } else if (address->ss_family == AF_INET6) {
153 struct sockaddr_in6 *addr = (struct sockaddr_in6 *) address;
154 getdns_dict_util_set_string(result, GETDNS_STR_ADDRESS_TYPE,
155 GETDNS_STR_IPV6);
156 addr_data.size = sizeof(addr->sin6_addr);
157 addr_data.data = (uint8_t *) & (addr->sin6_addr);
158 getdns_dict_set_bindata(result, GETDNS_STR_ADDRESS_DATA,
159 &addr_data);
160 } else {
161 // invalid
162 getdns_dict_destroy(result);
163 return GETDNS_RETURN_GENERIC_ERROR;
164 }
165 *output = result;
166 return GETDNS_RETURN_GOOD;
167 }
168
169 /* result must be freed */
170 static char *
171 convert_rdf_to_str(ldns_rdf * rdf)
172 {
173 if (ldns_rdf_get_type(rdf) == LDNS_RDF_TYPE_DNAME) {
174 ldns_dname2canonical(rdf);
175 }
176 return ldns_rdf2str(rdf);
177 }
178
179 /* create the header dict */
180 static struct getdns_dict *
181 create_reply_header_dict(struct getdns_context *context, ldns_pkt * reply)
182 {
183 /* { "id": 23456, "qr": 1, "opcode": 0, ... }, */
184 int r = 0;
185 struct getdns_dict *result = getdns_dict_create_with_context(context);
186 if (!result) {
187 return NULL;
188 }
189 /* cheat since we know GETDNS_RETURN_GOOD == 0 */
190 do {
191 r = getdns_dict_set_int(result, GETDNS_STR_KEY_ID,
192 ldns_pkt_id(reply));
193 if (r != GETDNS_RETURN_GOOD)
194 break;
195
196 /* set bits - seems like this could be macro-ified*/
197 r = getdns_dict_set_int(result, GETDNS_STR_KEY_QR,
198 (int) ldns_pkt_qr(reply));
199 if (r != GETDNS_RETURN_GOOD)
200 break;
201
202 r = getdns_dict_set_int(result, GETDNS_STR_KEY_AA,
203 (int) ldns_pkt_aa(reply));
204 if (r != GETDNS_RETURN_GOOD)
205 break;
206
207 r = getdns_dict_set_int(result, GETDNS_STR_KEY_TC,
208 (int) ldns_pkt_tc(reply));
209 if (r != GETDNS_RETURN_GOOD)
210 break;
211
212 r = getdns_dict_set_int(result, GETDNS_STR_KEY_RD,
213 (int) ldns_pkt_rd(reply));
214 if (r != GETDNS_RETURN_GOOD)
215 break;
216
217 r = getdns_dict_set_int(result, GETDNS_STR_KEY_CD,
218 (int) ldns_pkt_cd(reply));
219 if (r != GETDNS_RETURN_GOOD)
220 break;
221
222 r = getdns_dict_set_int(result, GETDNS_STR_KEY_RA,
223 (int) ldns_pkt_ra(reply));
224 if (r != GETDNS_RETURN_GOOD)
225 break;
226
227 r = getdns_dict_set_int(result, GETDNS_STR_KEY_AD,
228 (int) ldns_pkt_ad(reply));
229 if (r != GETDNS_RETURN_GOOD)
230 break;
231
232 /* codes */
233 r = getdns_dict_set_int(result, GETDNS_STR_KEY_OPCODE,
234 (int) ldns_pkt_get_opcode(reply));
235 if (r != GETDNS_RETURN_GOOD)
236 break;
237
238 r = getdns_dict_set_int(result, GETDNS_STR_KEY_RCODE,
239 (int) ldns_pkt_get_rcode(reply));
240 if (r != GETDNS_RETURN_GOOD)
241 break;
242
243 /* default z to 0 */
244 r = getdns_dict_set_int(result, GETDNS_STR_KEY_Z, 0);
245 if (r != GETDNS_RETURN_GOOD)
246 break;
247
248 /* counts */
249 r = getdns_dict_set_int(result, GETDNS_STR_KEY_QDCOUNT,
250 (int) ldns_pkt_qdcount(reply));
251 if (r != GETDNS_RETURN_GOOD)
252 break;
253
254 r = getdns_dict_set_int(result, GETDNS_STR_KEY_ANCOUNT,
255 (int) ldns_pkt_ancount(reply));
256 if (r != GETDNS_RETURN_GOOD)
257 break;
258
259 r = getdns_dict_set_int(result, GETDNS_STR_KEY_NSCOUNT,
260 (int) ldns_pkt_nscount(reply));
261 if (r != GETDNS_RETURN_GOOD)
262 break;
263
264 r = getdns_dict_set_int(result, GETDNS_STR_KEY_ARCOUNT,
265 (int) ldns_pkt_arcount(reply));
266 } while (0);
267
268 if (r != 0) {
269 getdns_dict_destroy(result);
270 result = NULL;
271 }
272 return result;
273 }
274
275 /* helper to convert an rr_list to getdns_list.
276 returns a list of objects where each object
277 is a result from create_dict_from_rr */
278 struct getdns_list *
279 create_list_from_rr_list(struct getdns_context *context, ldns_rr_list * rr_list)
280 {
281 size_t i = 0;
282 size_t idx = 0;
283 int r = GETDNS_RETURN_GOOD;
284 struct getdns_list *result = getdns_list_create_with_context(context);
285 struct getdns_dict *rrdict;
286 for (i = 0; i < ldns_rr_list_rr_count(rr_list) && r == GETDNS_RETURN_GOOD;
287 ++i) {
288 ldns_rr *rr = ldns_rr_list_rr(rr_list, i);
289 r = priv_getdns_create_dict_from_rr(context, rr, &rrdict);
290 if (r != GETDNS_RETURN_GOOD)
291 break; /* Could not create, do not destroy */
292 r = getdns_list_add_item(result, &idx);
293 if (r == GETDNS_RETURN_GOOD)
294 r = getdns_list_set_dict(result, idx, rrdict);
295 getdns_dict_destroy(rrdict);
296 }
297 if (r != GETDNS_RETURN_GOOD) {
298 getdns_list_destroy(result);
299 result = NULL;
300 }
301 return result;
302 }
303
304 /* helper to add the ipv4 or ipv6 bin data to the list of addrs */
305 static getdns_return_t
306 add_only_addresses(struct getdns_list * addrs, ldns_rr_list * rr_list)
307 {
308 int r = GETDNS_RETURN_GOOD;
309 size_t i = 0;
310 size_t item_idx = 0;
311
312 r = getdns_list_get_length(addrs, &item_idx);
313 for (i = 0; r == GETDNS_RETURN_GOOD &&
314 i < ldns_rr_list_rr_count(rr_list); ++i) {
315 ldns_rr *rr = ldns_rr_list_rr(rr_list, i);
316 size_t j = 0;
317 size_t rd_count = ldns_rr_rd_count(rr);
318 for (j = 0; r == GETDNS_RETURN_GOOD && j < rd_count; ++j) {
319 ldns_rdf *rdf = ldns_rr_rdf(rr, j);
320 if (ldns_rdf_get_type(rdf) != LDNS_RDF_TYPE_A &&
321 ldns_rdf_get_type(rdf) != LDNS_RDF_TYPE_AAAA) {
322 continue;
323 }
324 struct getdns_dict *this_address =
325 getdns_dict_create_with_extended_memory_functions(
326 addrs->mf.mf_arg,
327 addrs->mf.mf.ext.malloc,
328 addrs->mf.mf.ext.realloc,
329 addrs->mf.mf.ext.free);
330 if (this_address == NULL) {
331 r = GETDNS_RETURN_MEMORY_ERROR;
332 break;
333 }
334 struct getdns_bindata rbin =
335 { ldns_rdf_size(rdf), ldns_rdf_data(rdf) };
336 r = getdns_dict_set_bindata(this_address,
337 GETDNS_STR_ADDRESS_TYPE,
338 ( ldns_rdf_get_type(rdf) == LDNS_RDF_TYPE_A
339 ? &IPv4_str_bindata : &IPv6_str_bindata));
340 if (r != GETDNS_RETURN_GOOD) {
341 getdns_dict_destroy(this_address);
342 break;
343 }
344
345 r = getdns_dict_set_bindata(this_address,
346 GETDNS_STR_ADDRESS_DATA, &rbin);
347 if (r != GETDNS_RETURN_GOOD) {
348 getdns_dict_destroy(this_address);
349 break;
350 }
351
352 r = getdns_list_set_dict(addrs, item_idx++,
353 this_address);
354 getdns_dict_destroy(this_address);
355 }
356 }
357 return r;
358 }
359
360 static struct getdns_dict *
361 create_reply_dict(struct getdns_context *context, getdns_network_req * req,
362 struct getdns_list * just_addrs)
363 {
364 /* turn a packet into this glorious structure
365 *
366 * { # This is the first reply
367 * "header": { "id": 23456, "qr": 1, "opcode": 0, ... },
368 * "question": { "qname": <bindata for "www.example.com">, "qtype": 1, "qclass": 1 },
369 * "answer":
370 * [
371 * {
372 * "name": <bindata for "www.example.com">,
373 * "type": 1,
374 * "class": 1,
375 * "ttl": 33000,
376 * "rdata":
377 * {
378 * "ipv4_address": <bindata of 0x0a0b0c01>
379 * "rdata_raw": <bindata of 0x0a0b0c01>
380 * }
381 * }
382 * ],
383 * "authority":
384 * [
385 * {
386 * "name": <bindata for "ns1.example.com">,
387 * "type": 1,
388 * "class": 1,
389 * "ttl": 600,
390 * "rdata":
391 * {
392 * "ipv4_address": <bindata of 0x65439876>
393 * "rdata_raw": <bindata of 0x65439876>
394 * }
395 * }
396 * ]
397 * "additional": [],
398 * "canonical_name": <bindata for "www.example.com">,
399 * "answer_type": GETDNS_NAMETYPE_DNS
400 * }
401 *
402 */
403 getdns_return_t r = 0;
404 ldns_pkt *reply = req->result;
405 ldns_rr_list *rr_list = NULL;
406 ldns_rr *question = NULL;
407 struct getdns_dict *subdict = NULL;
408 struct getdns_list *sublist = NULL;
409 char *name = NULL;
410
411 struct getdns_dict *result = getdns_dict_create_with_context(context);
412 if (!result) {
413 return NULL;
414 }
415
416 /* header */
417 do {
418 subdict = create_reply_header_dict(context, reply);
419 r = getdns_dict_set_dict(result, GETDNS_STR_KEY_HEADER, subdict);
420 getdns_dict_destroy(subdict);
421 if (r != GETDNS_RETURN_GOOD) {
422 break;
423 }
424
425 /* question */
426 r = priv_getdns_create_reply_question_dict(context, reply, &subdict);
427 if (r != GETDNS_RETURN_GOOD) {
428 break;
429 }
430 r = getdns_dict_set_dict(result, GETDNS_STR_KEY_QUESTION, subdict);
431 getdns_dict_destroy(subdict);
432 if (r != GETDNS_RETURN_GOOD) {
433 break;
434 }
435
436 /* answers */
437 rr_list = ldns_pkt_answer(reply);
438 sublist = create_list_from_rr_list(context, rr_list);
439
440 r = getdns_dict_set_list(result, GETDNS_STR_KEY_ANSWER, sublist);
441 getdns_list_destroy(sublist);
442 if (r != GETDNS_RETURN_GOOD) {
443 break;
444 }
445
446 if ((req->request_type == GETDNS_RRTYPE_A ||
447 req->request_type == GETDNS_RRTYPE_AAAA)) {
448 /* add to just addrs */
449 r = add_only_addresses(just_addrs, rr_list);
450 if (r != GETDNS_RETURN_GOOD) {
451 break;
452 }
453 }
454
455 /* authority */
456 rr_list = ldns_pkt_authority(reply);
457 sublist = create_list_from_rr_list(context, rr_list);
458 r = getdns_dict_set_list(result, GETDNS_STR_KEY_AUTHORITY, sublist);
459 getdns_list_destroy(sublist);
460 if (r != GETDNS_RETURN_GOOD) {
461 break;
462 }
463
464 /* additional */
465 rr_list = ldns_pkt_additional(reply);
466 sublist = create_list_from_rr_list(context, rr_list);
467 if (sublist) {
468 r |= priv_getdns_append_opt_rr(context, sublist, reply);
469 r |= getdns_dict_set_list(result, GETDNS_STR_KEY_ADDITIONAL, sublist);
470 getdns_list_destroy(sublist);
471 if (r != GETDNS_RETURN_GOOD) {
472 break;
473 }
474 }
475
476 /* other stuff */
477 r = getdns_dict_set_int(result, GETDNS_STR_KEY_ANSWER_TYPE,
478 GETDNS_NAMETYPE_DNS);
479 if (r != GETDNS_RETURN_GOOD) {
480 break;
481 }
482 question = ldns_rr_list_rr(ldns_pkt_question(reply), 0);
483 name = convert_rdf_to_str(ldns_rr_owner(question));
484 if (! name) {
485 r = GETDNS_RETURN_MEMORY_ERROR;
486 break;
487 }
488 r = getdns_dict_util_set_string(result,
489 GETDNS_STR_KEY_CANONICAL_NM, name);
490 free(name);
491
492 } while (0);
493
494 if (r != 0) {
495 getdns_dict_destroy(result);
496 result = NULL;
497 }
498 return result;
499 }
500
501 static char *
502 get_canonical_name(const char *name)
503 {
504 ldns_rdf *rdf = ldns_rdf_new_frm_str(LDNS_RDF_TYPE_DNAME, name);
505 if (!rdf) {
506 return NULL;
507 }
508 char *result = convert_rdf_to_str(rdf);
509 ldns_rdf_deep_free(rdf);
510 return result;
511 }
512
513 static int
514 rrsigs_in_answer(ldns_pkt *pkt)
515 {
516 ldns_rr_list *rr_list = ldns_pkt_answer(pkt);
517 size_t i;
518
519 if (! rr_list)
520 return 0;
521
522 for (i = 0; i < ldns_rr_list_rr_count(rr_list); i++)
523 if (LDNS_RR_TYPE_RRSIG ==
524 ldns_rr_get_type(ldns_rr_list_rr(rr_list, i)))
525 return 1;
526 return 0;
527 }
528
529 struct getdns_dict *
530 create_getdns_response(struct getdns_dns_req * completed_request)
531 {
532 struct getdns_dict *result = getdns_dict_create_with_context(completed_request->context);
533 struct getdns_list *replies_full = getdns_list_create_with_context(
534 completed_request->context);
535 struct getdns_list *just_addrs = NULL;
536 struct getdns_list *replies_tree = getdns_list_create_with_context(
537 completed_request->context);
538 getdns_network_req *netreq;
539 char *canonical_name = NULL;
540 getdns_return_t r = 0;
541 int nreplies = 0, nanswers = 0, nsecure = 0, ninsecure = 0, nbogus = 0;
542
543 /* info (bools) about dns_req */
544 int dnssec_return_validation_chain;
545 int dnssec_return_only_secure;
546 int dnssec_return_status;
547
548 dnssec_return_validation_chain = is_extension_set(
549 completed_request->extensions, "dnssec_return_validation_chain");
550 dnssec_return_only_secure = is_extension_set(
551 completed_request->extensions, "dnssec_return_only_secure");
552 dnssec_return_status = dnssec_return_only_secure || is_extension_set(
553 completed_request->extensions, "dnssec_return_status") ||
554 completed_request->return_dnssec_status == GETDNS_EXTENSION_TRUE;
555
556 if (completed_request->first_req->request_class == GETDNS_RRTYPE_A ||
557 completed_request->first_req->request_class ==
558 GETDNS_RRTYPE_AAAA) {
559 just_addrs = getdns_list_create_with_context(
560 completed_request->context);
561 }
562 do {
563 canonical_name = get_canonical_name(completed_request->name);
564 r = getdns_dict_util_set_string(result, GETDNS_STR_KEY_CANONICAL_NM,
565 canonical_name);
566 free(canonical_name);
567 if (r != GETDNS_RETURN_GOOD) {
568 break;
569 }
570
571 r = getdns_dict_set_int(result, GETDNS_STR_KEY_ANSWER_TYPE,
572 GETDNS_NAMETYPE_DNS);
573 if (r != GETDNS_RETURN_GOOD) {
574 break;
575 }
576
577 for ( netreq = completed_request->first_req
578 ; netreq && r == GETDNS_RETURN_GOOD
579 ; netreq = netreq->next ) {
580
581 nreplies++;
582 if (netreq->secure)
583 nsecure++;
584 else if (! netreq->bogus)
585 ninsecure++;
586 if (dnssec_return_status && netreq->bogus)
587 nbogus++;
588 else if (LDNS_RCODE_NOERROR ==
589 ldns_pkt_get_rcode(netreq->result))
590 nanswers++;
591
592 if (! dnssec_return_validation_chain) {
593 if (dnssec_return_status && netreq->bogus)
594 continue;
595 else if (dnssec_return_only_secure && ! netreq->secure)
596 continue;
597 }
598 struct getdns_bindata full_data;
599 full_data.data = NULL;
600 full_data.size = 0;
601 ldns_pkt *pkt = netreq->result;
602 ldns_status s =
603 ldns_pkt2wire(&(full_data.data), pkt, &(full_data.size));
604 if (s != LDNS_STATUS_OK) {
605 // break inner
606 r = GETDNS_RETURN_MEMORY_ERROR;
607 break;
608 }
609 size_t idx = 0;
610 /* reply tree */
611 struct getdns_dict *reply = create_reply_dict(
612 completed_request->context, netreq, just_addrs);
613
614 if (! reply) {
615 r = GETDNS_RETURN_MEMORY_ERROR;
616 break;
617 }
618 if (dnssec_return_status || dnssec_return_validation_chain) {
619 r = getdns_dict_set_int(reply, "dnssec_status",
620 ( netreq->secure ? GETDNS_DNSSEC_SECURE
621 : netreq->bogus ? GETDNS_DNSSEC_BOGUS
622 : rrsigs_in_answer(netreq->result) &&
623 completed_request->context->has_ta
624 ? GETDNS_DNSSEC_INDETERMINATE
625 : GETDNS_DNSSEC_INSECURE ));
626
627 if (r != GETDNS_RETURN_GOOD) {
628 getdns_dict_destroy(reply);
629 break;
630 }
631 }
632 r = getdns_list_add_item(replies_tree, &idx);
633 if (r != GETDNS_RETURN_GOOD) {
634 getdns_dict_destroy(reply);
635 // break inner while
636 break;
637 }
638
639 r = getdns_list_set_dict(replies_tree, idx, reply);
640 getdns_dict_destroy(reply);
641 if (r != GETDNS_RETURN_GOOD) {
642 // break inner while
643 break;
644 }
645 /* buffer */
646 r = getdns_list_add_item(replies_full, &idx);
647 if (r != GETDNS_RETURN_GOOD) {
648 free(full_data.data);
649 // break inner while
650 break;
651 }
652 r = getdns_list_set_bindata(replies_full, idx,
653 &full_data);
654 free(full_data.data);
655 if (r != GETDNS_RETURN_GOOD) {
656 free(full_data.data);
657 // break inner while
658 break;
659 }
660 }
661
662 if (r != GETDNS_RETURN_GOOD)
663 break;
664
665 r = getdns_dict_set_list(result, GETDNS_STR_KEY_REPLIES_TREE,
666 replies_tree);
667 if (r != GETDNS_RETURN_GOOD)
668 break;
669
670 r = getdns_dict_set_list(result, GETDNS_STR_KEY_REPLIES_FULL,
671 replies_full);
672 if (r != GETDNS_RETURN_GOOD)
673 break;
674
675 if (just_addrs) {
676 r = getdns_dict_set_list(result, GETDNS_STR_KEY_JUST_ADDRS,
677 just_addrs);
678 if (r != GETDNS_RETURN_GOOD) {
679 break;
680 }
681 }
682 r = getdns_dict_set_int(result, GETDNS_STR_KEY_STATUS,
683 nreplies == 0 ? GETDNS_RESPSTATUS_ALL_TIMEOUT :
684 dnssec_return_only_secure && nsecure == 0 && ninsecure > 0
685 ? GETDNS_RESPSTATUS_NO_SECURE_ANSWERS :
686 nanswers == 0 ? GETDNS_RESPSTATUS_NO_NAME
687 : GETDNS_RESPSTATUS_GOOD);
688 } while (0);
689
690 /* cleanup */
691 getdns_list_destroy(replies_tree);
692 getdns_list_destroy(replies_full);
693 getdns_list_destroy(just_addrs);
694
695 if (r != 0) {
696 getdns_dict_destroy(result);
697 result = NULL;
698 }
699
700 return result;
701 }
702
703 /**
704 * reverse an IP address for PTR lookup
705 * @param address_data IP address to reverse
706 * @return NULL on allocation failure
707 * @return reversed string on success, caller must free storage via call to free()
708 */
709 char *
710 reverse_address(struct getdns_bindata *address_data)
711 {
712 ldns_rdf *addr_rdf;
713 ldns_rdf *rev_rdf;
714 char *rev_str;
715
716 if (address_data->size == 4)
717 addr_rdf = ldns_rdf_new(LDNS_RDF_TYPE_A, 4, address_data->data);
718 else if (address_data->size == 16)
719 addr_rdf = ldns_rdf_new(LDNS_RDF_TYPE_AAAA, 16, address_data->data);
720 else
721 return NULL;
722 if (!addr_rdf)
723 return NULL;
724
725 rev_rdf = ldns_rdf_address_reverse(addr_rdf);
726 ldns_rdf_free(addr_rdf);
727 if (!rev_rdf)
728 return NULL;
729
730 rev_str = ldns_rdf2str(rev_rdf);
731 ldns_rdf_deep_free(rev_rdf);
732 return rev_str;
733 }
734
735 static int
736 extformatcmp(const void *a, const void *b)
737 {
738 return strcmp(((getdns_extension_format *) a)->extstring,
739 ((getdns_extension_format *) b)->extstring);
740 }
741
742 /*---------------------------------------- validate_extensions */
743 getdns_return_t
744 validate_extensions(struct getdns_dict * extensions)
745 {
746 struct getdns_dict_item *item;
747 getdns_extension_format *extformat;
748
749 if (extensions)
750 LDNS_RBTREE_FOR(item, struct getdns_dict_item *,
751 &(extensions->root))
752 {
753 getdns_extension_format key;
754 key.extstring = (char *) item->node.key;
755 extformat = bsearch(&key, extformats,
756 sizeof(extformats) /
757 sizeof(getdns_extension_format),
758 sizeof(getdns_extension_format), extformatcmp);
759 if (!extformat)
760 return GETDNS_RETURN_NO_SUCH_EXTENSION;
761
762 if (item->dtype != extformat->exttype)
763 return GETDNS_RETURN_EXTENSION_MISFORMAT;
764 }
765 return GETDNS_RETURN_GOOD;
766 } /* validate_extensions */
767
768 getdns_return_t
769 getdns_apply_network_result(getdns_network_req* netreq,
770 struct ub_result* ub_res) {
771
772 ldns_status r =
773 ldns_wire2pkt(&(netreq->result), ub_res->answer_packet, ub_res->answer_len);
774 if (r != LDNS_STATUS_OK) {
775 return GETDNS_RETURN_GENERIC_ERROR;
776 }
777 netreq->secure = ub_res->secure;
778 netreq->bogus = ub_res->bogus;
779 return GETDNS_RETURN_GOOD;
780 }
781
782
783 getdns_return_t
784 validate_dname(const char* dname) {
785 int len;
786 int label_len;
787 const char* s;
788 if (dname == NULL) {
789 return GETDNS_RETURN_INVALID_PARAMETER;
790 }
791 len = strlen(dname);
792 if (len > GETDNS_MAX_DNAME_LEN * 4 || len == 0) {
793 return GETDNS_RETURN_BAD_DOMAIN_NAME;
794 }
795 if (len == 1 && dname[0] == '.') {
796 /* root is ok */
797 return GETDNS_RETURN_GOOD;
798 }
799 /* By specification [RFC1035] the total length of a DNS label is
800 * restricted to 63 octets and must be larger than 0 (except for the
801 * final root-label). The total length of a domain name (i.e., label
802 * octets and label length octets) is restricted to 255 octets or less.
803 * With a fully qualified domain name this includes the last label
804 * length octet for the root label. In a normalized representation the
805 * number of labels (including the root) plus the number of octets in
806 * each label may not be larger than 255.
807 */
808 len = 0;
809 label_len = 0;
810 for (s = dname; *s; ++s) {
811 switch (*s) {
812 case '.':
813 if (label_len > GETDNS_MAX_LABEL_LEN ||
814 label_len == 0) {
815 return GETDNS_RETURN_BAD_DOMAIN_NAME;
816 }
817 label_len = 0;
818 len += 1;
819 break;
820 case '\\':
821 s += 1;
822 if (isdigit(s[0])) {
823 /* octet value */
824 if (! isdigit(s[1]) && ! isdigit(s[2]))
825 return GETDNS_RETURN_BAD_DOMAIN_NAME;
826
827 if ((s[0] - '0') * 100 +
828 (s[1] - '0') * 10 + (s[2] - '0') > 255)
829 return GETDNS_RETURN_BAD_DOMAIN_NAME;
830
831 s += 2;
832 }
833 /* else literal char (1 octet) */
834 label_len++;
835 len += 1;
836 break;
837 default:
838 label_len++;
839 len += 1;
840 break;
841 }
842 }
843 if (len > GETDNS_MAX_DNAME_LEN || label_len > GETDNS_MAX_LABEL_LEN) {
844 return GETDNS_RETURN_BAD_DOMAIN_NAME;
845 }
846 return GETDNS_RETURN_GOOD;
847 } /* validate_dname */
848
849 int
850 is_extension_set(struct getdns_dict *extensions, const char *extension)
851 {
852 getdns_return_t r;
853 uint32_t value;
854
855 if (! extensions)
856 return 0;
857
858 r = getdns_dict_get_int(extensions, extension, &value);
859 return r == GETDNS_RETURN_GOOD && value == GETDNS_EXTENSION_TRUE;
860 }
861
862 /* util-internal.c */
0 /**
1 *
2 * \file util-internal.h
3 * /brief getdns contect management functions
4 *
5 * This is the meat of the API
6 * Originally taken from the getdns API description pseudo implementation.
7 *
8 */
9
10 /*
11 * Copyright (c) 2013, NLnet Labs, Verisign, Inc.
12 * All rights reserved.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are met:
16 * * Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * * Neither the names of the copyright holders nor the
22 * names of its contributors may be used to endorse or promote products
23 * derived from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
29 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 /*
38 #include "types-internal.h"
39 */
40
41 #include <ldns/ldns.h>
42 #include "context.h"
43
44 struct ub_result;
45 struct getdns_network_req;
46 getdns_return_t getdns_apply_network_result(getdns_network_req* netreq, struct ub_result* result);
47
48 #define GETDNS_MAX_DNAME_LEN 255
49 #define GETDNS_MAX_LABEL_LEN 63
50
51 /**
52 * add an item to the tail of a list - note that this was not in the getdns API
53 * description but the list_set functions seem to be designed to modify an existing
54 * item in the list. The newly added item has no data type.
55 * @param list list containing the item to which child_list is to be added
56 * @param *index assigned to the index of the newly added item on success
57 * @return GETDNS_RETURN_GOOD on success
58 * @return GETDNS_RETURN_GENERAL_ERROR if out of memory
59 */
60 getdns_return_t getdns_list_add_item(struct getdns_list *list, size_t * index);
61
62 /**
63 * private function (API users should not be calling this), this uses library
64 * routines to make a copy of the list - would be faster to make the copy directly
65 * caller must ensure that dstlist points to unallocated storage - the address will
66 * be overwritten by a new list via a call to getdns_list_create(context)
67 * @param srclist pointer to list to copy
68 * @param dstlist pointer to pointer to list to receive the copy (will be allocated)
69 * @return GETDNS_RETURN_GOOD on success
70 * @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if list is invalid
71 * @return GETDNS_RETURN_GENERIC_ERROR if out of memory
72 */
73 getdns_return_t getdns_list_copy(const struct getdns_list *srclist,
74 struct getdns_list **dstlist);
75
76 /**
77 * private function used to make a copy of a dict structure, the caller is responsible
78 * for freeing storage allocated to returned value
79 * NOTE: not thread safe - this needs to be fixed to be thread safe
80 * @param srcdict the dictionary structure to copy
81 * @param dstdict pointer to the location to write pointer to new dictionary
82 * @return GETDNS_RETURN_GOOD on success
83 */
84 getdns_return_t
85 getdns_dict_copy(const struct getdns_dict *srcdict,
86 struct getdns_dict **dstdict);
87
88 /**
89 * convert an ip address (v4/v6) dict to a sock storage
90 * expects dict to contain keys GETDNS_STR_PORT, GETDNS_STR_ADDRESS_TYPE
91 * GETDNS_STR_ADDRESS_DATA
92 * @param ns pointer to dictionary containing keys listed above
93 * @param output previously allocated storage used to return numeric address
94 * @return GETDNS_RETURN_GOOD on success
95 * @return GETDNS_RETURN_GENERIC_ERROR if keys missing from dictionary
96 */
97 getdns_return_t dict_to_sockaddr(struct getdns_dict * ns,
98 struct sockaddr_storage *output);
99 getdns_return_t sockaddr_to_dict(struct getdns_context *context,
100 struct sockaddr_storage *sockaddr, struct getdns_dict ** output);
101
102 struct getdns_dns_req;
103 struct getdns_dict *create_getdns_response(struct getdns_dns_req *completed_request);
104
105 char *reverse_address(struct getdns_bindata *address_data);
106
107 getdns_return_t validate_dname(const char* dname);
108
109 /**
110 * detect unrecognized extension strings or invalid extension formats
111 * TODO: this could be optimized by searching a sorted list
112 * @param extensions dictionary of valid extension strings and values
113 * @return GETDNS_RETURN_GOOD if each extension string is valid and the format matches the API specification
114 * @return GETDNS_RETURN_NO_SUCH_EXTENSION A name in the extensions dict is not a valid extension.
115 * @return GETDNS_RETURN_EXTENSION_MISFORMAT One or more of the extensions has a bad format.
116 */
117 getdns_return_t validate_extensions(struct getdns_dict * extensions);
118
119 /**
120 * helper to convert an rr_list to getdns_list
121 * @param context initialized getdns_context
122 * @param rr_list ldns rr list to be converted
123 * @return a list of objects where each object is a result from create_dict_from_rr
124 */
125 struct getdns_list *
126 create_list_from_rr_list(struct getdns_context *context, ldns_rr_list * rr_list);
127
128 int is_extension_set(struct getdns_dict *extensions, const char *extension);
129
130 /* util-internal.h */