0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * above copyright notice and this permission notice appear in all
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * THE SOFTWARE IS PROVIDED "AS IS" AND STICHTING NLNET
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * STICHTING NLNET BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * USE OR PERFORMANCE OF THIS SOFTWARE.
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * conceived and contributed by Rob Butler.
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * Permission to use, copy, modify, and distribute this software for any
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * purpose with or without fee is hereby granted, provided that the
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * above copyright notice and this permission notice appear in all
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * THE SOFTWARE IS PROVIDED "AS IS" AND ROB BUTLER
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * ROB BUTLER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * USE OR PERFORMANCE OF THIS SOFTWARE.
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * Copyright (C) 1999-2001, 2016 Internet Systems Consortium, Inc. ("ISC")
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * This Source Code Form is subject to the terms of the Mozilla Public
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * License, v. 2.0. If a copy of the MPL was not distributed with this
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉/* temporarily include time. */
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉static dns_sdlzimplementation_t *dlz_postgres = NULL;
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * Private methods
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉/* ---------------
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * Escaping arbitrary strings to get valid SQL strings/identifiers.
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * Replaces "\\" with "\\\\" and "'" with "''".
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * length is the length of the buffer pointed to by
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * from. The buffer at to must be at least 2*length + 1 characters
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * long. A terminating NUL character is written.
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * This function was borrowed directly from PostgreSQL's libpq.
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * The function was originally called PQescapeString and renamed
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * to postgres_makesafe to avoid a naming collision.
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * PQescapeString is a new function made available in Postgres 7.2.
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * For some reason the function is not properly exported on Win32
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * builds making the function unavailable on Windows. Also, since
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * this function is new it would require building this driver with
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * the libpq 7.2. By borrowing this function the Windows problem
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * is solved, and the dependence on libpq 7.2 is removed. Libpq is
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * still required of course, but an older version should work now too.
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * The copyright statements from the original file containing this
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * function are included below:
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * Portions Copyright (c) 1994, Regents of the University of California
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉 * ---------------
a27fe4c990f96bd792f2a07ca4d38c78d5b9df2cTatuya JINMEI 神明達哉postgres_makesafe(char *to, const char *from, size_t length)
target++;
target++;
source++;
target++;
remaining--;
#ifdef ISC_PLATFORM_USETHREADS
static dbinstance_t *
count++;
count);
return NULL;
return NULL;
return NULL;
return outstr;
static isc_result_t
#ifdef ISC_PLATFORM_USETHREADS
goto cleanup;
switch(query) {
case ALLNODES:
goto cleanup;
case ALLOWXFR:
goto cleanup;
case AUTHORITY:
goto cleanup;
case FINDZONE:
goto cleanup;
case LOOKUP:
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
switch(query) {
case ALLNODES:
case ALLOWXFR:
case AUTHORITY:
case FINDZONE:
case LOOKUP:
goto cleanup;
goto cleanup;
dlz_thread_num, j);
return ISC_R_FAILURE;
#ifdef ISC_PLATFORM_USETHREADS
return result;
static isc_result_t
for (i=0; i < rows; i++) {
switch(fields) {
return (ISC_R_FAILURE);
if (rows > 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
static isc_result_t
return (ISC_R_FAILURE);
if (rows > 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
static isc_result_t
const char *client)
return (ISC_R_NOTFOUND);
return result;
return (ISC_R_FAILURE);
if (rows > 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOPERM);
static isc_result_t
return result;
return (ISC_R_FAILURE);
for (i=0; i < rows; i++) {
ttl,
return (ISC_R_FAILURE);
return (ISC_R_FAILURE);
if (rows > 0)
return (ISC_R_SUCCESS);
return (ISC_R_NOTFOUND);
static isc_result_t
return result;
return (ISC_R_FAILURE);
static isc_result_t
return (ISC_R_FAILURE);
static isc_result_t
#ifdef ISC_PLATFORM_USETHREADS
#ifdef ISC_PLATFORM_USETHREADS
return (ISC_R_FAILURE);
return (ISC_R_FAILURE);
#ifdef ISC_PLATFORM_USETHREADS
return (ISC_R_FAILURE);
return (ISC_R_NOMEMORY);
for (i=0; i < dbcount; i++) {
switch(argc) {
goto cleanup;
#ifdef ISC_PLATFORM_USETHREADS
goto cleanup;
#ifdef ISC_PLATFORM_USETHREADS
goto cleanup;
goto cleanup;
return(ISC_R_SUCCESS);
#ifdef ISC_PLATFORM_USETHREADS
return(ISC_R_FAILURE);
#ifdef ISC_PLATFORM_USETHREADS
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
return result;