Define logger(), cleans up source code and allows us to write log entries
to a separate file.
This commit is contained in:
parent
8681047030
commit
0b9175e998
35 changed files with 582 additions and 560 deletions
16
src/netutl.c
16
src/netutl.c
|
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: netutl.c,v 1.12.4.44 2002/09/09 22:32:44 guus Exp $
|
||||
$Id: netutl.c,v 1.12.4.45 2003/07/06 22:11:32 guus Exp $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
|
@ -33,7 +33,6 @@
|
|||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <sys/socket.h>
|
||||
#include <syslog.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <utils.h>
|
||||
|
|
@ -43,6 +42,7 @@
|
|||
#include "conf.h"
|
||||
#include "net.h"
|
||||
#include "netutl.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include "system.h"
|
||||
|
||||
|
|
@ -67,10 +67,8 @@ struct addrinfo *str2addrinfo(char *address, char *service, int socktype)
|
|||
err = getaddrinfo(address, service, &hint, &ai);
|
||||
|
||||
if(err) {
|
||||
if(debug_lvl >= DEBUG_ERROR)
|
||||
syslog(LOG_WARNING, _("Error looking up %s port %s: %s\n"), address,
|
||||
logger(DEBUG_ALWAYS, LOG_WARNING, _("Error looking up %s port %s: %s\n"), address,
|
||||
service, gai_strerror(err));
|
||||
cp_trace();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +92,7 @@ sockaddr_t str2sockaddr(char *address, char *port)
|
|||
err = getaddrinfo(address, port, &hint, &ai);
|
||||
|
||||
if(err || !ai) {
|
||||
syslog(LOG_ERR, _("Error looking up %s port %s: %s\n"), address, port,
|
||||
logger(DEBUG_ALWAYS, LOG_ERR, _("Error looking up %s port %s: %s\n"), address, port,
|
||||
gai_strerror(err));
|
||||
cp_trace();
|
||||
raise(SIGFPE);
|
||||
|
|
@ -119,7 +117,7 @@ void sockaddr2str(sockaddr_t *sa, char **addrstr, char **portstr)
|
|||
err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
|
||||
if(err) {
|
||||
syslog(LOG_ERR, _("Error while translating addresses: %s"),
|
||||
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while translating addresses: %s"),
|
||||
gai_strerror(err));
|
||||
cp_trace();
|
||||
raise(SIGFPE);
|
||||
|
|
@ -147,7 +145,7 @@ char *sockaddr2hostname(sockaddr_t *sa)
|
|||
err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port),
|
||||
hostnames ? 0 : (NI_NUMERICHOST | NI_NUMERICSERV));
|
||||
if(err) {
|
||||
syslog(LOG_ERR, _("Error while looking up hostname: %s"),
|
||||
logger(DEBUG_ALWAYS, LOG_ERR, _("Error while looking up hostname: %s"),
|
||||
gai_strerror(err));
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +186,7 @@ int sockaddrcmp(sockaddr_t *a, sockaddr_t *b)
|
|||
return memcmp(&a->in6.sin6_port, &b->in6.sin6_port, sizeof(a->in6.sin6_port));
|
||||
|
||||
default:
|
||||
syslog(LOG_ERR, _("sockaddrcmp() was called with unknown address family %d, exitting!"),
|
||||
logger(DEBUG_ALWAYS, LOG_ERR, _("sockaddrcmp() was called with unknown address family %d, exitting!"),
|
||||
a->sa.sa_family);
|
||||
cp_trace();
|
||||
raise(SIGFPE);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue