- Fix build on linux
This commit is contained in:
parent
56bc05a259
commit
e153639fef
2
Makefile
2
Makefile
@ -23,7 +23,7 @@ get-deps:
|
||||
$(SUBDIRS):
|
||||
$(MAKE) -C $@ all
|
||||
|
||||
test: logfile.c logfile_test.c
|
||||
test: logfile.h logfile.c logfile_test.c
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) logfile.c logfile_test.c -o logfile_test
|
||||
|
||||
clean:
|
||||
|
8
fsipd.c
8
fsipd.c
@ -55,6 +55,10 @@
|
||||
#define PORT 5060
|
||||
#define BACKLOG 1024
|
||||
|
||||
#ifndef IPV6_BINDV6ONLY /* Linux does not have IPV6_BINDV6ONLY */
|
||||
#define IPV6_BINDV6ONLY IPV6_V6ONLY
|
||||
#endif /*IPV6_BINDV6ONLY */
|
||||
|
||||
|
||||
/*
|
||||
* Globals
|
||||
@ -75,7 +79,7 @@ int t6_sockfd, u6_sockfd;
|
||||
* trim string from whitespace characters
|
||||
*/
|
||||
size_t
|
||||
chomp(char *restrict s)
|
||||
chomp(char *s)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -130,7 +134,7 @@ signal_handler(int sig)
|
||||
}
|
||||
|
||||
void
|
||||
process_request(int af, struct sockaddr *restrict src, int proto, char *str)
|
||||
process_request(int af, struct sockaddr *src, int proto, char *str)
|
||||
{
|
||||
char *p_names[] = {"TCP", "UDP", "RAW", "UNKNOWN"};
|
||||
char *pname;
|
||||
|
14
logfile.c
14
logfile.c
@ -26,6 +26,12 @@
|
||||
|
||||
#include "logfile.h"
|
||||
|
||||
#ifdef __linux__
|
||||
#define _PROGNAME program_invocation_short_name
|
||||
#else
|
||||
#define _PROGNAME getprogname()
|
||||
#endif /* __linux__ */
|
||||
|
||||
log_t *
|
||||
log_open(const char *path, mode_t mode)
|
||||
{
|
||||
@ -35,7 +41,7 @@ log_open(const char *path, mode_t mode)
|
||||
int fd;
|
||||
|
||||
if (path == NULL) {
|
||||
asprintf(&filename, "%s/%s.log", LOGPATH, getprogname());
|
||||
asprintf(&filename, "%s/%s.log", LOGPATH, _PROGNAME);
|
||||
} else {
|
||||
filename = (char *)path;
|
||||
}
|
||||
@ -44,8 +50,12 @@ log_open(const char *path, mode_t mode)
|
||||
* try to create / append the file and make sure it is correctly
|
||||
* created
|
||||
*/
|
||||
if ((fd = open(filename, O_WRONLY | O_APPEND | O_CREAT | O_EXLOCK | O_SYNC, mode)) == -1)
|
||||
if ((fd = open(filename, O_WRONLY | O_APPEND | O_CREAT | O_SYNC, mode)) == -1)
|
||||
return (NULL);
|
||||
if (flock(fd, LOCK_EX) == -1 ) {
|
||||
close(fd);
|
||||
return (NULL);
|
||||
}
|
||||
if (stat(filename, &sb) == -1) {
|
||||
close(fd);
|
||||
return (NULL);
|
||||
|
@ -27,6 +27,10 @@
|
||||
#ifndef _LOGFILE_H
|
||||
#define _LOGFILE_H
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <sys/file.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -41,6 +45,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#define LOGPATH "/var/log"
|
||||
#define MAX_MSG_SIZE 65536
|
||||
|
Loading…
x
Reference in New Issue
Block a user