Commit 0ea8055b authored by Daniel Salzman's avatar Daniel Salzman

utils: rename files and internals (add 'k' prefix)

parent 74736c77
......@@ -35,30 +35,30 @@ knotd_SOURCES = \
knot/main.c
kdig_SOURCES = \
utils/dig/dig_exec.c \
utils/dig/dig_exec.h \
utils/dig/dig_main.c \
utils/dig/dig_params.c \
utils/dig/dig_params.h
utils/kdig/kdig_exec.c \
utils/kdig/kdig_exec.h \
utils/kdig/kdig_main.c \
utils/kdig/kdig_params.c \
utils/kdig/kdig_params.h
khost_SOURCES = \
utils/dig/dig_exec.c \
utils/dig/dig_exec.h \
utils/dig/dig_params.c \
utils/dig/dig_params.h \
utils/host/host_main.c \
utils/host/host_params.c \
utils/host/host_params.h
utils/kdig/kdig_exec.c \
utils/kdig/kdig_exec.h \
utils/kdig/kdig_params.c \
utils/kdig/kdig_params.h \
utils/khost/khost_main.c \
utils/khost/khost_params.c \
utils/khost/khost_params.h
knsupdate_SOURCES = \
utils/nsupdate/nsupdate_exec.c \
utils/nsupdate/nsupdate_exec.h \
utils/nsupdate/nsupdate_main.c \
utils/nsupdate/nsupdate_params.c \
utils/nsupdate/nsupdate_params.h
utils/knsupdate/knsupdate_exec.c \
utils/knsupdate/knsupdate_exec.h \
utils/knsupdate/knsupdate_main.c \
utils/knsupdate/knsupdate_params.c \
utils/knsupdate/knsupdate_params.h
knsec3hash_SOURCES = \
utils/nsec3hash/nsec3hash_main.c
utils/knsec3hash/knsec3hash_main.c
# static: common shared (also in libknot)
libknotcs_la_SOURCES = \
......
......@@ -19,7 +19,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "libknot/errcode.h"
#include "libknot/libknot.h"
/*!
* \brief Convert HEX char to byte.
......
......@@ -28,8 +28,7 @@
#include "utils/common/netio.h"
#include "utils/common/msg.h"
#include "libknot/descriptor.h"
#include "libknot/errcode.h"
#include "libknot/libknot.h"
#include "libknot/internal/sockaddr.h"
srv_info_t* srv_info_create(const char *name, const char *service)
......
......@@ -20,7 +20,7 @@
#include "utils/common/resolv.h"
#include "utils/common/msg.h"
#include "utils/common/params.h"
#include "libknot/errcode.h"
#include "libknot/libknot.h"
#include "libknot/internal/lists.h"
#define RESOLV_FILE "/etc/resolv.conf"
......
......@@ -29,7 +29,7 @@
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include "libknot/errcode.h"
#include "libknot/libknot.h"
typedef long long int knot_strtoll_result_t;
typedef unsigned long long int knot_strtoull_result_t;
......
......@@ -21,7 +21,7 @@
#include "utils/common/token.h"
#include "utils/common/msg.h"
#include "libknot/errcode.h"
#include "libknot/libknot.h"
#include "libknot/internal/getline.h"
int tok_scan(const char* lp, const char **tbl, int *lpm)
......
......@@ -19,7 +19,7 @@
#include <sys/socket.h>
#include <sys/time.h>
#include "utils/dig/dig_exec.h"
#include "utils/kdig/kdig_exec.h"
#include "utils/common/exec.h"
#include "utils/common/msg.h"
#include "utils/common/netio.h"
......@@ -946,7 +946,7 @@ static void process_xfr(const query_t *query)
knot_pkt_free(&out_packet);
}
int dig_exec(const dig_params_t *params)
int kdig_exec(const kdig_params_t *params)
{
node_t *n = NULL;
......
......@@ -14,11 +14,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file dig_exec.h
* \file kdig_exec.h
*
* \author Daniel Salzman <daniel.salzman@nic.cz>
*
* \brief dig executives.
* \brief kdig executives.
*
* \addtogroup knot_utils
* @{
......@@ -27,8 +27,8 @@
#pragma once
#include "utils/common/params.h"
#include "utils/dig/dig_params.h"
#include "utils/kdig/kdig_params.h"
int dig_exec(const dig_params_t *params);
int kdig_exec(const kdig_params_t *params);
/*! @} */
......@@ -16,23 +16,23 @@
#include <stdlib.h>
#include "utils/host/host_params.h"
#include "utils/dig/dig_exec.h"
#include "utils/kdig/kdig_params.h"
#include "utils/kdig/kdig_exec.h"
#include "libknot/errcode.h"
int main(int argc, char *argv[])
{
int ret = EXIT_SUCCESS;
dig_params_t params;
if (host_parse(&params, argc, argv) == KNOT_EOK) {
if (!params.stop && dig_exec(&params) != KNOT_EOK) {
kdig_params_t params;
if (kdig_parse(&params, argc, argv) == KNOT_EOK) {
if (!params.stop && kdig_exec(&params) != KNOT_EOK) {
ret = EXIT_FAILURE;
}
} else {
ret = EXIT_FAILURE;
}
host_clean(&params);
kdig_clean(&params);
return ret;
}
......@@ -21,7 +21,7 @@
#include <string.h>
#include <stdlib.h>
#include "utils/dig/dig_params.h"
#include "utils/kdig/kdig_params.h"
#include "utils/common/msg.h"
#include "utils/common/params.h"
#include "utils/common/resolv.h"
......@@ -717,7 +717,7 @@ static int opt_bufsize(const char *arg, void *query)
return KNOT_EOK;
}
static const param_t dig_opts2[] = {
static const param_t kdig_opts2[] = {
{ "multiline", ARG_NONE, opt_multiline },
{ "nomultiline", ARG_NONE, opt_nomultiline },
......@@ -967,7 +967,7 @@ void query_free(query_t *query)
free(query);
}
int dig_init(dig_params_t *params)
int kdig_init(kdig_params_t *params)
{
if (params == NULL) {
DBG_NULL;
......@@ -989,7 +989,7 @@ int dig_init(dig_params_t *params)
return KNOT_EOK;
}
void dig_clean(dig_params_t *params)
void kdig_clean(kdig_params_t *params)
{
node_t *n = NULL, *nxt = NULL;
......@@ -1139,7 +1139,7 @@ static int parse_reverse(const char *value, list_t *queries, const query_t *conf
return KNOT_EOK;
}
static int parse_server(const char *value, dig_params_t *params)
static int parse_server(const char *value, kdig_params_t *params)
{
query_t *query;
......@@ -1333,7 +1333,7 @@ void complete_queries(list_t *queries, const query_t *conf)
}
}
static void dig_help(void)
static void kdig_help(void)
{
printf("Usage: kdig [-4] [-6] [-dh] [-b address] [-c class] [-p port]\n"
" [-q name] [-t type] [-x address] [-k keyfile]\n"
......@@ -1378,7 +1378,7 @@ static void dig_help(void)
" -v, --version Print program version.\n");
}
static int parse_opt1(const char *opt, const char *value, dig_params_t *params,
static int parse_opt1(const char *opt, const char *value, kdig_params_t *params,
int *index)
{
const char *val = value;
......@@ -1437,7 +1437,7 @@ static int parse_opt1(const char *opt, const char *value, dig_params_t *params,
return KNOT_ENOTSUP;
}
dig_help();
kdig_help();
params->stop = true;
break;
case 'c':
......@@ -1580,7 +1580,7 @@ static int parse_opt1(const char *opt, const char *value, dig_params_t *params,
break;
case '-':
if (strcmp(opt, "-help") == 0) {
dig_help();
kdig_help();
params->stop = true;
} else if (strcmp(opt, "-version") == 0) {
printf(KDIG_VERSION);
......@@ -1598,7 +1598,7 @@ static int parse_opt1(const char *opt, const char *value, dig_params_t *params,
return KNOT_EOK;
}
static int parse_opt2(const char *value, dig_params_t *params)
static int parse_opt2(const char *value, kdig_params_t *params)
{
query_t *query;
......@@ -1626,7 +1626,7 @@ static int parse_opt2(const char *value, dig_params_t *params)
// Check if the given option is supported.
bool unique;
int ret = best_param(value, opt_len, dig_opts2, &unique);
int ret = best_param(value, opt_len, kdig_opts2, &unique);
if (ret < 0) {
ERR("invalid option: +%s\n", value);
return KNOT_ENOTSUP;
......@@ -1636,7 +1636,7 @@ static int parse_opt2(const char *value, dig_params_t *params)
}
// Check argument presence.
switch (dig_opts2[ret].arg) {
switch (kdig_opts2[ret].arg) {
case ARG_NONE:
if (arg != NULL) {
ERR("superfluous option argument: +%s\n", value);
......@@ -1657,10 +1657,10 @@ static int parse_opt2(const char *value, dig_params_t *params)
}
// Call option handler.
return dig_opts2[ret].handler(arg, query);
return kdig_opts2[ret].handler(arg, query);
}
static int parse_token(const char *value, dig_params_t *params)
static int parse_token(const char *value, kdig_params_t *params)
{
query_t *query;
......@@ -1685,7 +1685,7 @@ static int parse_token(const char *value, dig_params_t *params)
return KNOT_EINVAL;
}
int dig_parse(dig_params_t *params, int argc, char *argv[])
int kdig_parse(kdig_params_t *params, int argc, char *argv[])
{
if (params == NULL || argv == NULL) {
DBG_NULL;
......@@ -1693,7 +1693,7 @@ int dig_parse(dig_params_t *params, int argc, char *argv[])
}
// Initialize parameters.
if (dig_init(params) != KNOT_EOK) {
if (kdig_init(params) != KNOT_EOK) {
return KNOT_ERROR;
}
......@@ -1734,7 +1734,7 @@ int dig_parse(dig_params_t *params, int argc, char *argv[])
}
break;
case KNOT_ENOTSUP:
dig_help();
kdig_help();
default: // Fall through.
return ret;
}
......
......@@ -14,11 +14,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file dig_params.h
* \file kdig_params.h
*
* \author Daniel Salzman <daniel.salzman@nic.cz>
*
* \brief dig command line parameters.
* \brief kdig command line parameters.
*
* \addtogroup knot_utils
* @{
......@@ -40,7 +40,7 @@
#define KDIG_VERSION "kdig, version " PACKAGE_VERSION "\n"
/*! \brief Operation mode of dig. */
/*! \brief Operation mode of kdig. */
typedef enum {
/*!< Standard 1-message query/reply. */
OPERATION_QUERY,
......@@ -147,7 +147,7 @@ struct query {
#endif // USE_DNSTAP
};
/*! \brief Settings for dig. */
/*! \brief Settings for kdig. */
typedef struct {
/*!< Stop processing - just print help, version,... */
bool stop;
......@@ -155,14 +155,14 @@ typedef struct {
list_t queries;
/*!< Default settings for queries. */
query_t *config;
} dig_params_t;
} kdig_params_t;
query_t* query_create(const char *owner, const query_t *config);
void query_free(query_t *query);
void complete_queries(list_t *queries, const query_t *conf);
int dig_init(dig_params_t *params);
int dig_parse(dig_params_t *params, int argc, char *argv[]);
void dig_clean(dig_params_t *params);
int kdig_init(kdig_params_t *params);
int kdig_parse(kdig_params_t *params, int argc, char *argv[]);
void kdig_clean(kdig_params_t *params);
/*! @} */
......@@ -16,23 +16,23 @@
#include <stdlib.h>
#include "utils/dig/dig_params.h"
#include "utils/dig/dig_exec.h"
#include "libknot/errcode.h"
#include "utils/khost/khost_params.h"
#include "utils/kdig/kdig_exec.h"
#include "libknot/libknot.h"
int main(int argc, char *argv[])
{
int ret = EXIT_SUCCESS;
dig_params_t params;
if (dig_parse(&params, argc, argv) == KNOT_EOK) {
if (!params.stop && dig_exec(&params) != KNOT_EOK) {
kdig_params_t params;
if (khost_parse(&params, argc, argv) == KNOT_EOK) {
if (!params.stop && kdig_exec(&params) != KNOT_EOK) {
ret = EXIT_FAILURE;
}
} else {
ret = EXIT_FAILURE;
}
dig_clean(&params);
khost_clean(&params);
return ret;
}
......@@ -20,14 +20,13 @@
#include <stdlib.h>
#include <string.h>
#include "utils/host/host_params.h"
#include "utils/khost/khost_params.h"
#include "utils/kdig/kdig_params.h"
#include "utils/common/msg.h"
#include "utils/common/params.h"
#include "utils/common/resolv.h"
#include "utils/dig/dig_params.h"
#include "libknot/libknot.h"
#include "libknot/internal/lists.h"
#include "libknot/descriptor.h"
#include "libknot/errcode.h"
#define DEFAULT_RETRIES_HOST 1
#define DEFAULT_TIMEOUT_HOST 2
......@@ -55,16 +54,16 @@ static const style_t DEFAULT_STYLE_HOST = {
.show_footer = false
};
static int host_init(dig_params_t *params)
static int khost_init(kdig_params_t *params)
{
// Initialize params with dig defaults.
int ret = dig_init(params);
// Initialize params with kdig defaults.
int ret = kdig_init(params);
if (ret != KNOT_EOK) {
return ret;
}
// Set host specific defaults.
// Set khost specific defaults.
free(params->config->port);
params->config->port = strdup(DEFAULT_DNS_PORT);
params->config->retries = DEFAULT_RETRIES_HOST;
......@@ -83,14 +82,14 @@ static int host_init(dig_params_t *params)
return KNOT_EOK;
}
void host_clean(dig_params_t *params)
void khost_clean(kdig_params_t *params)
{
if (params == NULL) {
DBG_NULL;
return;
}
dig_clean(params);
kdig_clean(params);
}
static int parse_name(const char *value, list_t *queries, const query_t *conf)
......@@ -192,7 +191,7 @@ static int parse_name(const char *value, list_t *queries, const query_t *conf)
return KNOT_EOK;
}
static void host_help(void)
static void khost_help(void)
{
printf("Usage: khost [-4] [-6] [-adhrsTvVw] [-c class] [-t type]\n"
" [-R retries] [-W time] name [server]\n\n"
......@@ -214,7 +213,7 @@ static void host_help(void)
);
}
int host_parse(dig_params_t *params, int argc, char *argv[])
int khost_parse(kdig_params_t *params, int argc, char *argv[])
{
int opt = 0, li = 0;
......@@ -223,7 +222,7 @@ int host_parse(dig_params_t *params, int argc, char *argv[])
return KNOT_EINVAL;
}
if (host_init(params) != KNOT_EOK) {
if (khost_init(params) != KNOT_EOK) {
return KNOT_ERROR;
}
......@@ -267,7 +266,7 @@ int host_parse(dig_params_t *params, int argc, char *argv[])
msg_enable_debug(1);
break;
case 'h':
host_help();
khost_help();
params->stop = false;
return KNOT_EOK;
case 'r':
......@@ -328,7 +327,7 @@ int host_parse(dig_params_t *params, int argc, char *argv[])
}
break;
default:
host_help();
khost_help();
return KNOT_ENOTSUP;
}
}
......@@ -348,7 +347,7 @@ int host_parse(dig_params_t *params, int argc, char *argv[])
}
break;
default:
host_help();
khost_help();
return KNOT_ENOTSUP;
}
......
......@@ -14,11 +14,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file host_params.h
* \file khost_params.h
*
* \author Daniel Salzman <daniel.salzman@nic.cz>
*
* \brief host command line parameters.
* \brief khost command line parameters.
*
* \addtogroup knot_utils
* @{
......@@ -26,11 +26,11 @@
#pragma once
#include "utils/dig/dig_params.h"
#include "utils/kdig/kdig_params.h"
#define KHOST_VERSION "khost, version " PACKAGE_VERSION "\n"
int host_parse(dig_params_t *params, int argc, char *argv[]);
void host_clean(dig_params_t *params);
int khost_parse(kdig_params_t *params, int argc, char *argv[]);
void khost_clean(kdig_params_t *params);
/*! @} */
......@@ -21,12 +21,12 @@
#include <stdint.h>
#include <stdio.h>
#include "utils/common/params.h"
#include "libknot/internal/base32hex.h"
#include "libknot/dnssec/crypto.h"
#include "libknot/errcode.h"
#include "utils/common/hex.h"
#include "utils/common/params.h"
#include "utils/common/strtonum.h"
#include "libknot/libknot.h"
#include "libknot/dnssec/crypto.h"
#include "libknot/internal/base32hex.h"
#define PROGRAM_NAME "knsec3hash"
......
......@@ -14,7 +14,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file nsupdate_exec.h
* \file knsupdate_exec.h
*
* \author Marek Vavrusa <marek.vavrusa@nic.cz>
*
......@@ -26,8 +26,8 @@
#pragma once
#include "utils/nsupdate/nsupdate_params.h"
#include "utils/knsupdate/knsupdate_params.h"
int nsupdate_exec(nsupdate_params_t *params);
int knsupdate_exec(knsupdate_params_t *params);
/*! @} */
......@@ -16,10 +16,10 @@
#include <stdlib.h>
#include "utils/nsupdate/nsupdate_exec.h"
#include "utils/nsupdate/nsupdate_params.h"
#include "utils/knsupdate/knsupdate_exec.h"
#include "utils/knsupdate/knsupdate_params.h"
#include "libknot/libknot.h"
#include "libknot/dnssec/crypto.h"
#include "libknot/errcode.h"
int main(int argc, char *argv[])
{
......@@ -27,15 +27,15 @@ int main(int argc, char *argv[])
int ret = EXIT_SUCCESS;
nsupdate_params_t params;
if (nsupdate_parse(&params, argc, argv) == KNOT_EOK) {
if (!params.stop && nsupdate_exec(&params) != KNOT_EOK) {
knsupdate_params_t params;
if (knsupdate_parse(&params, argc, argv) == KNOT_EOK) {
if (!params.stop && knsupdate_exec(&params) != KNOT_EOK) {
ret = EXIT_FAILURE;
}
} else {
ret = EXIT_FAILURE;
}
nsupdate_clean(&params);
knsupdate_clean(&params);
return ret;
}
......@@ -20,7 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include "utils/nsupdate/nsupdate_params.h"
#include "utils/knsupdate/knsupdate_params.h"
#include "utils/common/msg.h"
#include "utils/common/netio.h"
#include "libknot/libknot.h"
......@@ -78,9 +78,9 @@ static int parser_set_default(zs_scanner_t *s, const char *fmt, ...)
return KNOT_EOK;
}
static int nsupdate_init(nsupdate_params_t *params)
static int knsupdate_init(knsupdate_params_t *params)
{
memset(params, 0, sizeof(nsupdate_params_t));
memset(params, 0, sizeof(knsupdate_params_t));
/* Initialize lists. */
init_list(&params->qfiles);
......@@ -121,14 +121,14 @@ static int nsupdate_init(nsupdate_params_t *params)
return KNOT_EOK;
}
void nsupdate_clean(nsupdate_params_t *params)
void knsupdate_clean(knsupdate_params_t *params)
{
if (params == NULL) {
return;
}
/* Clear current query. */
nsupdate_reset(params);
knsupdate_reset(params);
/* Free qfiles. */
ptrlist_free(&params->qfiles, &params->mm);
......@@ -160,7 +160,7 @@ static void rr_list_free(list_t *list, mm_ctx_t *mm)
ptrlist_free(list, mm);
}
void nsupdate_reset(nsupdate_params_t *params)
void knsupdate_reset(knsupdate_params_t *params)
{
/* Free ADD/REMOVE RRSets. */
rr_list_free(&params->update_list, &params->mm);
......@@ -169,13 +169,13 @@ void nsupdate_reset(nsupdate_params_t *params)
rr_list_free(&params->prereq_list, &params->mm);
}
static void nsupdate_help(void)
static void knsupdate_help(void)
{
printf("Usage: knsupdate [-d] [-v] [-k keyfile | -y [hmac:]name:key]\n"
" [-p port] [-t timeout] [-r retries] [filename]\n");
}
int nsupdate_parse(nsupdate_params_t *params, int argc, char *argv[])
int knsupdate_parse(knsupdate_params_t *params, int argc, char *argv[])
{
int opt = 0, li = 0;
int ret = KNOT_EOK;
......@@ -184,7 +184,7 @@ int nsupdate_parse(nsupdate_params_t *params, int argc, char *argv[])
return KNOT_EINVAL;
}
ret = nsupdate_init(params);
ret = knsupdate_init(params);
if (ret != KNOT_EOK) {
return ret;
}
......@@ -205,7 +205,7 @@ int nsupdate_parse(nsupdate_params_t *params, int argc, char *argv[])
msg_enable_debug(1);
break;
case 'h':
nsupdate_help();
knsupdate_help();
params->stop = true;
return KNOT_EOK;
case 'v':
......@@ -240,7 +240,7 @@ int nsupdate_parse(nsupdate_params_t *params, int argc, char *argv[])
if (ret != KNOT_EOK) return ret;
break;
default:
nsupdate_help();
knsupdate_help();
return KNOT_ENOTSUP;
}
}
......@@ -266,7 +266,7 @@ int nsupdate_parse(nsupdate_params_t *params, int argc, char *argv[])
return ret;
}
int nsupdate_set_ttl(nsupdate_params_t *params, const uint32_t ttl)
int knsupdate_set_ttl(knsupdate_params_t *params, const uint32_t ttl)
{
int ret = parser_set_default(params->parser, "$TTL %u\n", ttl);
if (ret == KNOT_EOK) {
......@@ -277,7 +277,7 @@ int nsupdate_set_ttl(nsupdate_params_t *params, const uint32_t ttl)
return ret;
}
int nsupdate_set_origin(nsupdate_params_t *params, const char *origin)
int knsupdate_set_origin(knsupdate_params_t *params, const char *origin)
{
char *fqdn = get_fqd_name(origin);
......
......@@ -14,11 +14,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file nsupdate_params.h
* \file knsupdate_params.h
*
* \author Marek Vavrusa <marek.vavrusa@nic.cz>
*
* \brief nsupdate command line parameters.
* \brief knsupdate command line parameters.
*
* \addtogroup knot_utils
* @{
......@@ -40,7 +40,7 @@
/*! Parser init string. */
#define PARSER_INIT_STR "$ORIGIN %s\n$TTL %u\n"
/*! \brief nsupdate-specific params data. */
/*! \brief knsupdate-specific params data. */
typedef struct {
/*!< Stop processing - just print help, version,... */
bool stop;
......@@ -80,12 +80,12 @@ typedef struct {
style_t style;
/*!< Memory context. */
mm_ctx_t mm;
} nsupdate_params_t;
} knsupdate_params_t;
int nsupdate_parse(nsupdate_params_t *params, int argc, char *argv[]);
int nsupdate_set_ttl(nsupdate_params_t *params, const uint32_t ttl);
int nsupdate_set_origin(nsupdate_params_t *params, const char *origin);
void nsupdate_clean(nsupdate_params_t *params);
void nsupdate_reset(nsupdate_params_t *params);
int knsupdate_parse(knsupdate_params_t *params, int argc, char *argv[]);
int knsupdate_set_ttl(knsupdate_params_t *params, const uint32_t ttl);
int knsupdate_set_origin(knsupdate_params_t *params, const char *origin);
void knsupdate_clean(knsupdate_params_t *params);
void knsupdate_reset(knsupdate_params_t *params);
/*! @} */