DNSConf-macros.h revision 70e5a7403f0e0a3bd292b8287c5fed5772c15270
d0be1e954bd4674fc27f2616c72adb37cf3525a2David Lawrence/*
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
499b34cea04a46823d003d4c0520c8b03e8513cbBrian Wellington * Copyright (C) 2000, 2001 Internet Software Consortium.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater * Permission to use, copy, modify, and/or distribute this software for any
d0be1e954bd4674fc27f2616c72adb37cf3525a2David Lawrence * purpose with or without fee is hereby granted, provided that the above
d0be1e954bd4674fc27f2616c72adb37cf3525a2David Lawrence * copyright notice and this permission notice appear in all copies.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
d0be1e954bd4674fc27f2616c72adb37cf3525a2David Lawrence */
d0be1e954bd4674fc27f2616c72adb37cf3525a2David Lawrence
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater/* $Id: DNSConf-macros.h,v 1.9 2007/06/19 23:47:07 tbox Exp $ */
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence
51f90e94e4dcea187628175b50217bc525570b55James Brister#define CONCAT(a,b) a ## b
51f90e94e4dcea187628175b50217bc525570b55James Brister#define DNSCONF_SET_STRING(FIELD) \
51f90e94e4dcea187628175b50217bc525570b55James Bristervoid CONCAT(DNSConf_set, FIELD)(DNSConf *cfg, const char *arg) { \
51f90e94e4dcea187628175b50217bc525570b55James Brister \
51f90e94e4dcea187628175b50217bc525570b55James Brister DBGPRINT("inside DNSConf_set" #FIELD "\n"); \
51f90e94e4dcea187628175b50217bc525570b55James Brister \
51f90e94e4dcea187628175b50217bc525570b55James Brister if (!DNSConf_initctx(cfg)) \
51f90e94e4dcea187628175b50217bc525570b55James Brister return; \
51f90e94e4dcea187628175b50217bc525570b55James Brister \
51f90e94e4dcea187628175b50217bc525570b55James Brister if (arg == NULL) { \
51f90e94e4dcea187628175b50217bc525570b55James Brister DBGPRINT("null pointer\n"); \
51f90e94e4dcea187628175b50217bc525570b55James Brister CONCAT(dns_c_ctx_unset, FIELD)(cfg->confctx); \
51f90e94e4dcea187628175b50217bc525570b55James Brister } else if (*arg == '\0') { \
51f90e94e4dcea187628175b50217bc525570b55James Brister DBGPRINT("empty string\n"); \
51f90e94e4dcea187628175b50217bc525570b55James Brister CONCAT(dns_c_ctx_unset, FIELD)(cfg->confctx); \
51f90e94e4dcea187628175b50217bc525570b55James Brister } else \
51f90e94e4dcea187628175b50217bc525570b55James Brister CONCAT(dns_c_ctx_set, FIELD)(cfg->confctx, arg); \
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence}
51f90e94e4dcea187628175b50217bc525570b55James Brister
51f90e94e4dcea187628175b50217bc525570b55James Brister#define DNSCONF_GET_STRING(FIELD) \
51f90e94e4dcea187628175b50217bc525570b55James Bristerchar * CONCAT(DNSConf_get, FIELD)(DNSConf *cfg) { \
51f90e94e4dcea187628175b50217bc525570b55James Brister char *result = NULL; \
51f90e94e4dcea187628175b50217bc525570b55James Brister isc_result_t tmpres; \
51f90e94e4dcea187628175b50217bc525570b55James Brister \
51f90e94e4dcea187628175b50217bc525570b55James Brister if (cfg == NULL || cfg->confctx == NULL) \
51f90e94e4dcea187628175b50217bc525570b55James Brister return NULL; \
51f90e94e4dcea187628175b50217bc525570b55James Brister \
51f90e94e4dcea187628175b50217bc525570b55James Brister tmpres = CONCAT(dns_c_ctx_get, FIELD)(cfg->confctx, &result); \
51f90e94e4dcea187628175b50217bc525570b55James Brister if (tmpres == ISC_R_NOTFOUND) \
51f90e94e4dcea187628175b50217bc525570b55James Brister return NULL; \
51f90e94e4dcea187628175b50217bc525570b55James Brister \
51f90e94e4dcea187628175b50217bc525570b55James Brister return result; \
51f90e94e4dcea187628175b50217bc525570b55James Brister} \
51f90e94e4dcea187628175b50217bc525570b55James Brister
51f90e94e4dcea187628175b50217bc525570b55James Brister
51f90e94e4dcea187628175b50217bc525570b55James Brister#define STRING_FIELD_DEFS(FIELD) \
51f90e94e4dcea187628175b50217bc525570b55James Brister DNSCONF_GET_STRING(FIELD) DNSCONF_SET_STRING(FIELD)
51f90e94e4dcea187628175b50217bc525570b55James Brister
51f90e94e4dcea187628175b50217bc525570b55James Brister#define INT_FIELD_DEFS(FIELD)