Commit ea8a4aa0 authored by Lubos Slovak's avatar Lubos Slovak

Renamed error codes

parent 58fdee1f
......@@ -42,7 +42,7 @@ int _map_errno(int fallback_value, int arg0, ...)
va_list ap;
va_start(ap, arg0);
/* KNOTDERROR serves as a sentinel. */
/* KNOTD_ERROR serves as a sentinel. */
for (int c = arg0; c != 0; c = va_arg(ap, int)) {
/* Error code matches with mapped. */
......
......@@ -94,8 +94,8 @@ knot_nameserver_t *knot_ns_create();
* \param packet Packet structure to be filled with the parsed query.
* \param type Type of the query.
*
* \retval KNOTDEOK
* \retval KNOTDEMALF if the query is totally unusable. Such query must be
* \retval KNOTD_EOK
* \retval KNOTD_EMALF if the query is totally unusable. Such query must be
* ignored.
* \retval KNOT_RCODE_SERVFAIL if there was some internal error. Call
* ns_error_response() with \a rcode set to this
......@@ -137,8 +137,8 @@ void knot_ns_error_response(knot_nameserver_t *nameserver, uint16_t query_id,
* \param rsize Input: maximum acceptable size of the response. Output: real
* size of the response.
*
* \retval KNOTDEOK if a valid response was created.
* \retval KNOTDEMALF if an error occured and the response is not valid.
* \retval KNOTD_EOK if a valid response was created.
* \retval KNOTD_EMALF if an error occured and the response is not valid.
*/
int knot_ns_answer_normal(knot_nameserver_t *nameserver, knot_packet_t *query,
uint8_t *response_wire, size_t *rsize);
......@@ -160,10 +160,10 @@ int knot_ns_xfr_send_error(knot_ns_xfr_t *xfr, knot_rcode_t rcode);
* \note Currently only a stub which sends one error response using the given
* callback.
*
* \retval KNOTDEOK
* \retval KNOTDEINVAL
* \retval KNOTDENOMEM
* \retval KNOTDERROR
* \retval KNOTD_EOK
* \retval KNOTD_EINVAL
* \retval KNOTD_ENOMEM
* \retval KNOTD_ERROR
*
* \todo Maybe the place for the wire format should be passed in as in
* the ns_answer_request() function...?
......
......@@ -8,12 +8,12 @@
* Contains tests for:
* - ENDS API
*/
#ifndef _KNOTDEDNS_TESTS_H_
#define _KNOTDEDNS_TESTS_H_
#ifndef _KNOTD_EDNS_TESTS_H_
#define _KNOTD_EDNS_TESTS_H_
#include "common/libtap/tap_unit.h"
/* Unit API. */
unit_api edns_tests_api;
#endif /* _KNOTDEDNS_TESTS_H_ */
#endif /* _KNOTD_EDNS_TESTS_H_ */
......@@ -8,12 +8,12 @@
* Contains tests for:
* - ENDS API
*/
#ifndef _KNOTDEDNS_TESTS_H_
#define _KNOTDEDNS_TESTS_H_
#ifndef _KNOTD_EDNS_TESTS_H_
#define _KNOTD_EDNS_TESTS_H_
#include "common/libtap/tap_unit.h"
/* Unit API. */
unit_api edns_tests_api;
#endif /* _KNOTDEDNS_TESTS_H_ */
#endif /* _KNOTD_EDNS_TESTS_H_ */
......@@ -29,9 +29,9 @@
* \param size In: available space in the buffer. Out: actual size of the
* message in bytes.
*
* \retval KNOTDEOK
* \retval KNOTDESPACE
* \retval KNOTDERROR
* \retval KNOTD_EOK
* \retval KNOTD_ESPACE
* \retval KNOTD_ERROR
*/
int xfrin_create_soa_query(const knot_zone_contents_t *zone, uint8_t *buffer,
size_t *size);
......@@ -58,9 +58,9 @@ int xfrin_transfer_needed(const knot_zone_contents_t *zone,
* \param size In: available space in the buffer. Out: actual size of the
* message in bytes.
*
* \retval KNOTDEOK
* \retval KNOTDESPACE
* \retval KNOTDERROR
* \retval KNOTD_EOK
* \retval KNOTD_ESPACE
* \retval KNOTD_ERROR
*/
int xfrin_create_axfr_query(const knot_zone_contents_t *zone, uint8_t *buffer,
size_t *size);
......@@ -73,9 +73,9 @@ int xfrin_create_axfr_query(const knot_zone_contents_t *zone, uint8_t *buffer,
* \param size In: available space in the buffer. Out: actual size of the
* message in bytes.
*
* \retval KNOTDEOK
* \retval KNOTDESPACE
* \retval KNOTDERROR
* \retval KNOTD_EOK
* \retval KNOTD_ESPACE
* \retval KNOTD_ERROR
*/
int xfrin_create_ixfr_query(const knot_zone_contents_t *zone, uint8_t *buffer,
size_t *size);
......@@ -86,7 +86,7 @@ int xfrin_create_ixfr_query(const knot_zone_contents_t *zone, uint8_t *buffer,
* \param nameserver Name server to update.
* \param zone Zone build from transfer.
*
* \retval KNOTDENOTSUP
* \retval KNOTD_ENOTSUP
*/
int xfrin_zone_transferred(knot_nameserver_t *nameserver,
knot_zone_contents_t *zone);
......@@ -101,7 +101,7 @@ int xfrin_zone_transferred(knot_nameserver_t *nameserver,
* first packet, \a *zone may be set to NULL, in which case a new
* zone structure is created).
*
* \retval KNOTDEOK
* \retval KNOTD_EOK
*
* \todo Refactor!!!
*/
......@@ -125,10 +125,10 @@ void xfrin_free_changesets(knot_changesets_t **changesets);
* \param size Size of the packet in bytes.
* \param changesets Changesets to be filled in.
*
* \retval KNOTDEOK
* \retval KNOTDEINVAL
* \retval KNOTDEMALF
* \retval KNOTDENOMEM
* \retval KNOTD_EOK
* \retval KNOTD_EINVAL
* \retval KNOTD_EMALF
* \retval KNOTD_ENOMEM
*/
int xfrin_process_ixfr_packet(const uint8_t *pkt, size_t size,
knot_changesets_t **changesets);
......
......@@ -70,7 +70,7 @@ void cf_error(const char *msg, void *scanner)
new_config->filename, msg, cf_get_lineno(scanner),
(char *)cf_get_text(scanner));
_parser_res = KNOTDEPARSEFAIL;
_parser_res = KNOTD_EPARSEFAIL;
}
/*
......@@ -298,10 +298,10 @@ void __attribute__ ((destructor)) conf_deinit()
static int conf_fparser(conf_t *conf)
{
if (!conf->filename) {
return KNOTDEINVAL;
return KNOTD_EINVAL;
}
int ret = KNOTDEOK;
int ret = KNOTD_EOK;
pthread_mutex_lock(&_parser_lock);
// {
// Hook new configuration
......@@ -309,11 +309,11 @@ static int conf_fparser(conf_t *conf)
FILE *f = fopen(conf->filename, "r");
if (f == 0) {
pthread_mutex_unlock(&_parser_lock);
return KNOTDENOENT;
return KNOTD_ENOENT;
}
// Parse config
_parser_res = KNOTDEOK;
_parser_res = KNOTD_EOK;
new_config->filename = conf->filename;
void *scanner = NULL;
cf_lex_init(&scanner);
......@@ -333,21 +333,21 @@ static int conf_fparser(conf_t *conf)
static int conf_strparser(conf_t *conf, const char *src)
{
if (!src) {
return KNOTDEINVAL;
return KNOTD_EINVAL;
}
int ret = KNOTDEOK;
int ret = KNOTD_EOK;
pthread_mutex_lock(&_parser_lock);
// {
// Hook new configuration
new_config = conf;
if (src == 0) {
pthread_mutex_unlock(&_parser_lock);
return KNOTDENOENT;
return KNOTD_ENOENT;
}
// Parse config
_parser_res = KNOTDEOK;
_parser_res = KNOTD_EOK;
char *oldfn = new_config->filename;
new_config->filename = "(stdin)";
void *scanner = NULL;
......@@ -397,7 +397,7 @@ int conf_add_hook(conf_t * conf, int sections,
{
conf_hook_t *hook = malloc(sizeof(conf_hook_t));
if (!hook) {
return KNOTDENOMEM;
return KNOTD_ENOMEM;
}
hook->sections = sections;
......@@ -406,7 +406,7 @@ int conf_add_hook(conf_t * conf, int sections,
add_tail(&conf->hooks, &hook->n);
++conf->hooks_count;
return KNOTDEOK;
return KNOTD_EOK;
}
int conf_parse(conf_t *conf)
......@@ -421,10 +421,10 @@ int conf_parse(conf_t *conf)
conf_update_hooks(conf);
if (ret < 0) {
return KNOTDEPARSEFAIL;
return KNOTD_EPARSEFAIL;
}
return KNOTDEOK;
return KNOTD_EOK;
}
int conf_parse_str(conf_t *conf, const char* src)
......@@ -439,10 +439,10 @@ int conf_parse_str(conf_t *conf, const char* src)
conf_update_hooks(conf);
if (ret < 0) {
return KNOTDEPARSEFAIL;
return KNOTD_EPARSEFAIL;
}
return KNOTDEOK;
return KNOTD_EOK;
}
void conf_truncate(conf_t *conf, int unload_hooks)
......@@ -564,13 +564,13 @@ int conf_open(const char* path)
{
/* Check path. */
if (!path) {
return KNOTDEINVAL;
return KNOTD_EINVAL;
}
/* Check if exists. */
struct stat st;
if (stat(path, &st) != 0) {
return KNOTDENOENT;
return KNOTD_ENOENT;
}
/* Create new config. */
......@@ -578,7 +578,7 @@ int conf_open(const char* path)
/* Parse config. */
int ret = conf_fparser(nconf);
if (ret != KNOTDEOK) {
if (ret != KNOTD_EOK) {
conf_free(nconf);
return ret;
}
......@@ -610,7 +610,7 @@ int conf_open(const char* path)
/* Update hooks. */
conf_update_hooks(nconf);
return KNOTDEOK;
return KNOTD_EOK;
}
char* strcdup(const char *s1, const char *s2)
......
......@@ -221,8 +221,8 @@ conf_t *conf_new(const char* path);
* \param on_update Callback.
* \param data User specified data for hook.
*
* \retval KNOTDEOK on success.
* \retval KNOTDENOMEM out of memory error.
* \retval KNOTD_EOK on success.
* \retval KNOTD_ENOMEM out of memory error.
*/
int conf_add_hook(conf_t * conf, int sections,
int (*on_update)(const conf_t*, void*), void *data);
......@@ -234,8 +234,8 @@ int conf_add_hook(conf_t * conf, int sections,
*
* \param conf Configuration context.
*
* \retval KNOTDEOK on success.
* \retval KNOTDEPARSEFAIL on parser error.
* \retval KNOTD_EOK on success.
* \retval KNOTD_EPARSEFAIL on parser error.
*/
int conf_parse(conf_t *conf);
......@@ -247,8 +247,8 @@ int conf_parse(conf_t *conf);
* \param conf Configuration context.
* \param src Source string.
*
* \retval KNOTDEOK on success.
* \retval KNOTDEPARSEFAIL on parser error.
* \retval KNOTD_EOK on success.
* \retval KNOTD_EPARSEFAIL on parser error.
*/
int conf_parse_str(conf_t *conf, const char* src);
......@@ -289,9 +289,9 @@ char* conf_find_default();
*
* \param path Path to configuration file.
*
* \retval KNOTDEOK on success.
* \retval KNOTDEINVAL on null path.
* \retval KNOTDENOENT if the path doesn't exist.
* \retval KNOTD_EOK on success.
* \retval KNOTD_EINVAL on null path.
* \retval KNOTD_ENOENT if the path doesn't exist.
*/
int conf_open(const char* path);
......
......@@ -20,7 +20,7 @@ int log_conf_hook(const struct conf_t *conf, void *data)
// Check if log declaration exists, otherwise ignore
if (conf->logs_count < 1) {
return KNOTDEINVAL;
return KNOTD_EINVAL;
}
// Find maximum log facility id
......@@ -81,6 +81,6 @@ int log_conf_hook(const struct conf_t *conf, void *data)
log_levels_set(LOGT_STDERR, LOG_ANY, bmask);
}
return KNOTDEOK;
return KNOTD_EOK;
}
......@@ -19,9 +19,9 @@ struct conf_t;
*
* \see syslog.h
*
* \retval KNOTDEOK on success.
* \retval KNOTDEINVAL on invalid parameters.
* \retval KNOTDENOMEM out of memory error.
* \retval KNOTD_EOK on success.
* \retval KNOTD_EINVAL on invalid parameters.
* \retval KNOTD_ENOMEM out of memory error.
*/
int log_conf_hook(const struct conf_t *conf, void *data);
......
......@@ -50,8 +50,8 @@ void help(int argc, char **argv)
* \param db Path to zone db file.
* \param source Path to zone source file.
*
* \retval KNOTDEOK if up to date.
* \retval KNOTDERROR if needs recompilation.
* \retval KNOTD_EOK if up to date.
* \retval KNOTD_ERROR if needs recompilation.
*/
int check_zone(const char *db, const char* source)
{
......@@ -59,14 +59,14 @@ int check_zone(const char *db, const char* source)
/* Read zonedb header. */
zloader_t *zl = knot_zload_open(db);
if (!zl) {
return KNOTDERROR;
return KNOTD_ERROR;
}
/* Check source files and mtime. */
int ret = KNOTDERROR;
int ret = KNOTD_ERROR;
int src_changed = strcmp(source, zl->source) != 0;
if (!src_changed && !knot_zload_needs_update(zl)) {
ret = KNOTDEOK;
ret = KNOTD_EOK;
}
knot_zload_close(zl);
......@@ -277,7 +277,7 @@ int execute(const char *action, char **argv, int argc, pid_t pid, int verbose,
conf_zone_t *zone = (conf_zone_t*)n;
// Check source files and mtime
if (check_zone(zone->db, zone->file) == KNOTDEOK) {
if (check_zone(zone->db, zone->file) == KNOTD_EOK) {
printf("Zone '%s' is up-to-date.\n",
zone->name);
......
......@@ -33,7 +33,7 @@ pid_t pid_read(const char* fn)
if (fn) {
FILE *fp = fopen(fn, "r");
if (!fp) {
return KNOTDENOENT;
return KNOTD_ENOENT;
}
int readb = 0;
......@@ -49,26 +49,26 @@ pid_t pid_read(const char* fn)
// Check read result
if (readb < 1) {
return KNOTDENOENT;
return KNOTD_ENOENT;
}
// Convert pid
char* ep = 0;
unsigned long pid = strtoul(buf, &ep, 10);
if ((errno == ERANGE) || (*ep && !isspace(*ep))) {
return KNOTDERANGE;
return KNOTD_ERANGE;
}
return (pid_t)pid;
}
return KNOTDEINVAL;
return KNOTD_EINVAL;
}
int pid_write(const char* fn)
{
if (!fn) {
return KNOTDEINVAL;
return KNOTD_EINVAL;
}
// Convert
......@@ -76,7 +76,7 @@ int pid_write(const char* fn)
int wbytes = 0;
wbytes = snprintf(buf, sizeof(buf), "%lu", (unsigned long) getpid());
if (wbytes < 0) {
return KNOTDEINVAL;
return KNOTD_EINVAL;
}
// Write
......@@ -85,22 +85,22 @@ int pid_write(const char* fn)
int rc = fwrite(buf, wbytes, 1, fp);
fclose(fp);
if (rc < 0) {
return KNOTDERROR;
return KNOTD_ERROR;
}
return 0;
}
return KNOTDENOENT;
return KNOTD_ENOENT;
}
int pid_remove(const char* fn)
{
if (unlink(fn) < 0) {
return KNOTDEINVAL;
return KNOTD_EINVAL;
}
return KNOTDEOK;
return KNOTD_EOK;
}
int pid_running(pid_t pid)
......
......@@ -28,9 +28,9 @@ char* pid_filename();
* \param fn Filename containing PID.
*
* \retval PID on success (positive integer).
* \retval KNOTDEINVAL on null path.
* \retval KNOTDENOENT if the filename content cannot be read.
* \retval KNOTDERANGE if the stored PID is out of range.
* \retval KNOTD_EINVAL on null path.
* \retval KNOTD_ENOENT if the filename content cannot be read.
* \retval KNOTD_ERANGE if the stored PID is out of range.
*/
pid_t pid_read(const char* fn);
......@@ -39,10 +39,10 @@ pid_t pid_read(const char* fn);
*
* \param fn Filename containing PID.
*
* \retval KNOTDEOK on success.
* \retval KNOTDEINVAL on null path.
* \retval KNOTDENOENT filename cannot be opened for writing.
* \retval KNOTDERROR unspecified error.
* \retval KNOTD_EOK on success.
* \retval KNOTD_EINVAL on null path.
* \retval KNOTD_ENOENT filename cannot be opened for writing.
* \retval KNOTD_ERROR unspecified error.
*/
int pid_write(const char* fn);
......@@ -53,8 +53,8 @@ int pid_write(const char* fn);
*
* \warning Filename content won't be checked.
*
* \retval KNOTDEOK on success.
* \retval KNOTDEINVAL failed to remove filename.
* \retval KNOTD_EOK on success.
* \retval KNOTD_EINVAL failed to remove filename.
*/
int pid_remove(const char* fn);
......
......@@ -151,7 +151,7 @@ int main(int argc, char **argv)
// Open configuration
log_server_info("Parsing configuration '%s' ...\n", config_fn);
if (conf_open(config_fn) != KNOTDEOK) {
if (conf_open(config_fn) != KNOTD_EOK) {
log_server_error("Failed to parse configuration file '%s'.\n",
config_fn);
......@@ -177,7 +177,7 @@ int main(int argc, char **argv)
// Run server
int res = 0;
log_server_info("Starting server...\n");
if ((res = server_start(server)) == KNOTDEOK) {
if ((res = server_start(server)) == KNOTD_EOK) {
// Save PID
int rc = pid_write(pidfile);
......@@ -227,11 +227,11 @@ int main(int argc, char **argv)
sig_req_reload = 0;
int cf_ret = cf_ret = conf_open(config_fn);
switch (cf_ret) {
case KNOTDEOK:
case KNOTD_EOK:
log_server_info("Configuration "
"reloaded.\n");
break;
case KNOTDENOENT:
case KNOTD_ENOENT:
log_server_error("Configuration "
"file '%s' "
"not found.\n",
......@@ -257,7 +257,7 @@ int main(int argc, char **argv)
}
}
if ((res = server_wait(server)) != KNOTDEOK) {
if ((res = server_wait(server)) != KNOTD_EOK) {
log_server_error("An error occured while "
"waiting for server to finish.\n");
} else {
......
......@@ -4,26 +4,26 @@
const error_table_t knot_error_msgs[] = {
/* Mapped errors. */
{KNOTDEOK, "OK"},
{KNOTDENOMEM, "Not enough memory."},
{KNOTDEINVAL, "Invalid parameter passed."},
{KNOTDENOTSUP, "Parameter not supported."},
{KNOTDEBUSY, "Requested resource is busy."},
{KNOTDEAGAIN, "The system lacked the necessary resource, try again."},
{KNOTDEACCES, "Permission to perform requested operation is denied."},
{KNOTDECONNREFUSED, "Connection is refused."},
{KNOTDEISCONN, "Already connected."},
{KNOTDEADDRINUSE, "Address already in use."},
{KNOTDENOENT, "Resource not found."},
{KNOTDERANGE, "Value is out of range."},
{KNOTD_EOK, "OK"},
{KNOTD_ENOMEM, "Not enough memory."},
{KNOTD_EINVAL, "Invalid parameter passed."},
{KNOTD_ENOTSUP, "Parameter not supported."},
{KNOTD_EBUSY, "Requested resource is busy."},
{KNOTD_EAGAIN, "The system lacked the necessary resource, try again."},
{KNOTD_EACCES, "Permission to perform requested operation is denied."},
{KNOTD_ECONNREFUSED, "Connection is refused."},
{KNOTD_EISCONN, "Already connected."},
{KNOTD_EADDRINUSE, "Address already in use."},
{KNOTD_ENOENT, "Resource not found."},
{KNOTD_ERANGE, "Value is out of range."},
/* Custom errors. */
{KNOTDERROR, "Generic error."},
{KNOTDEZONEINVAL, "Invalid zone file."},
{KNOTDENOTRUNNING, "Resource is not running."},
{KNOTDEPARSEFAIL, "Parser failed."},
{KNOTDENOIPV6, "IPv6 support disabled."},
{KNOTDEMALF, "Malformed data."},
{KNOTDESPACE, "Not enough space provided."},
{KNOTDERROR, 0}
{KNOTD_ERROR, "Generic error."},
{KNOTD_EZONEINVAL, "Invalid zone file."},
{KNOTD_ENOTRUNNING, "Resource is not running."},
{KNOTD_EPARSEFAIL, "Parser failed."},
{KNOTD_ENOIPV6, "IPv6 support disabled."},
{KNOTD_EMALF, "Malformed data."},
{KNOTD_ESPACE, "Not enough space provided."},
{KNOTD_ERROR, 0}
};
......@@ -10,8 +10,8 @@
* @{
*/
#ifndef _KNOTDERROR_H_
#define _KNOTDERROR_H_
#ifndef _KNOTD_ERROR_H_
#define _KNOTD_ERROR_H_
#include <errno.h>
......@@ -26,33 +26,33 @@
enum knot_error_t {
/* Directly mapped error codes. */
KNOTDEOK = 0,
KNOTDENOMEM = -ENOMEM, /*!< \brief Out of memory. */
KNOTDEINVAL = -EINVAL, /*!< \brief Invalid parameter passed. */
KNOTDENOTSUP = -ENOTSUP, /*!< \brief Parameter not supported. */
KNOTDEBUSY = -EBUSY, /*!< \brief Requested resource is busy. */
KNOTDEAGAIN = -EAGAIN, /*!< \brief OS lacked necessary resources. */
KNOTDEACCES = -EACCES, /*!< \brief Permission is denied. */
KNOTDECONNREFUSED = -ECONNREFUSED, /*!< \brief Connection is refused. */
KNOTDEISCONN = -EISCONN, /*!< \brief Already connected. */
KNOTDEADDRINUSE = -EADDRINUSE, /*!< \brief Address already in use. */
KNOTDENOENT = -ENOENT, /*!< \brief Resource not found. */
KNOTDERANGE = -ERANGE, /*!< \brief Value is out of range. */
KNOTD_EOK = 0,
KNOTD_ENOMEM = -ENOMEM, /*!< \brief Out of memory. */
KNOTD_EINVAL = -EINVAL, /*!< \brief Invalid parameter passed. */
KNOTD_ENOTSUP = -ENOTSUP, /*!< \brief Parameter not supported. */
KNOTD_EBUSY = -EBUSY, /*!< \brief Requested resource is busy. */
KNOTD_EAGAIN = -EAGAIN, /*!< \brief OS lacked necessary resources. */
KNOTD_EACCES = -EACCES, /*!< \brief Permission is denied. */
KNOTD_ECONNREFUSED = -ECONNREFUSED, /*!< \brief Connection is refused. */
KNOTD_EISCONN = -EISCONN, /*!< \brief Already connected. */
KNOTD_EADDRINUSE = -EADDRINUSE, /*!< \brief Address already in use. */
KNOTD_ENOENT = -ENOENT, /*!< \brief Resource not found. */
KNOTD_ERANGE = -ERANGE, /*!< \brief Value is out of range. */
/* Custom error codes. */
KNOTDERROR = -16384, /*!< \brief Generic error. */
KNOTDEZONEINVAL, /*!< \brief Invalid zone file. */
KNOTDENOTRUNNING, /*!< \brief Resource is not running. */
KNOTDEPARSEFAIL, /*!< \brief Parser fail. */
KNOTDENOIPV6, /*!< \brief No IPv6 support. */
KNOTDEMALF, /*!< \brief Malformed data. */
KNOTDESPACE, /*!< \brief Not enough space provided. */
KNOTD_ERROR = -16384, /*!< \brief Generic error. */
KNOTD_EZONEINVAL, /*!< \brief Invalid zone file. */
KNOTD_ENOTRUNNING, /*!< \brief Resource is not running. */
KNOTD_EPARSEFAIL, /*!< \brief Parser fail. */
KNOTD_ENOIPV6, /*!< \brief No IPv6 support. */
KNOTD_EMALF, /*!< \brief Malformed data. */
KNOTD_ESPACE, /*!< \brief Not enough space provided. */
KNOTDERROR_COUNT = 20
KNOTD_ERROR_COUNT = 20
};
/*! \brief Table linking error messages to error codes. */
extern const error_table_t knot_error_msgs[KNOTDERROR_COUNT];
extern const error_table_t knot_error_msgs[KNOTD_ERROR_COUNT];
/*!
* \brief Returns error message for the given error code.
......@@ -76,8 +76,8 @@ static inline const char *knot_strerror(int code)
*
* \return Mapped error code.
*/
#define knot_map_errno(err...) map_errno(KNOTDERROR, err);
#define knot_map_errno(err...) map_errno(KNOTD_ERROR, err);
#endif /* _KNOTDERROR_H_ */
#endif /* _KNOTD_ERROR_H_ */
/*! @} */
......@@ -24,7 +24,7 @@ int log_setup(int logfiles)
{
/* Check facilities count. */
if (logfiles < 0) {
return KNOTDEINVAL;
return KNOTD_EINVAL;
}
/* Ensure minimum facilities count. */
......@@ -38,7 +38,7 @@ int log_setup(int logfiles)
LOG_FCL_SIZE = 0;
LOG_FCL = malloc(new_size);
if (!LOG_FCL) {
return KNOTDENOMEM;
return KNOTD_ENOMEM;
}
/* Reserve space for logfiles. */
......@@ -47,14 +47,14 @@ int log_setup(int logfiles)
if (!LOG_FDS) {
free(LOG_FCL);
LOG_FCL = 0;
return KNOTDENOMEM;
return KNOTD_ENOMEM;
}
memset(LOG_FDS, 0, sizeof(FILE*) * logfiles);
}
memset(LOG_FCL, 0, new_size);
LOG_FCL_SIZE = new_size; // Assign only when all is set
return KNOTDEOK;
return KNOTD_EOK;
}
......@@ -68,7 +68,7 @@ int log_init()
LOG_FDS_OPEN = 0;
/* Setup initial state. */
int ret = KNOTDEOK;
int ret = KNOTD_EOK;
int emask = LOG_MASK(LOG_WARNING)|LOG_MASK(LOG_ERR)|LOG_MASK(LOG_FATAL);
int imask = LOG_MASK(LOG_INFO)|LOG_MASK(LOG_NOTICE);
......@@ -121,13 +121,13 @@ int log_open_file(const char* filename)
{
// Check facility
if (unlikely(!LOG_FCL_SIZE || LOGT_FILE + LOG_FDS_OPEN >= LOG_FCL_SIZE)) {
return KNOTDERROR;
return KNOTD_ERROR;
}
// Open file
LOG_FDS[LOG_FDS_OPEN] = fopen(filename, "w");
if (!LOG_FDS[LOG_FDS_OPEN]) {
return KNOTDEINVAL;
return KNOTD_EINVAL;
}
// Disable buffering
......@@ -150,7 +150,7 @@ int log_levels_set(int facility, logsrc_t src, uint8_t levels)
{
// Check facility
if (unlikely(!LOG_FCL_SIZE || facility >= LOG_FCL_SIZE)) {
return KNOTDEINVAL;
return KNOTD_EINVAL;
}
// Get facility pointer from offset
......@@ -166,7 +166,7 @@ int log_levels_set(int facility, logsrc_t src, uint8_t levels)
}
}
return KNOTDEOK;
return KNOTD_EOK;
}
int log_levels_add(int facility, logsrc_t src, uint8_t levels)
......@@ -178,7 +178,7 @@ int log_levels_add(int facility, logsrc_t src, uint8_t levels)
static int _log_msg(logsrc_t src, int level, const char *msg)
{
if(!log_isopen()) {
return KNOTDERROR;