log: don't use utils.h
Prefer GLib over utils.h.
This commit is contained in:
22
src/log.c
22
src/log.c
@@ -17,9 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -27,6 +25,13 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#define LOG_DATE_BUF_SIZE 16
|
#define LOG_DATE_BUF_SIZE 16
|
||||||
#define LOG_DATE_LEN (LOG_DATE_BUF_SIZE - 1)
|
#define LOG_DATE_LEN (LOG_DATE_BUF_SIZE - 1)
|
||||||
@@ -72,7 +77,14 @@ static void buffer_warning(const char *fmt, va_list args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
vsnprintf(tmp, len, fmt, args);
|
vsnprintf(tmp, len, fmt, args);
|
||||||
warningBuffer = appendToString(warningBuffer, buffer);
|
|
||||||
|
if (warningBuffer == NULL)
|
||||||
|
warningBuffer = g_strdup(tmp);
|
||||||
|
else {
|
||||||
|
tmp = g_strconcat(warningBuffer, tmp, NULL);
|
||||||
|
g_free(warningBuffer);
|
||||||
|
warningBuffer = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
@@ -256,7 +268,7 @@ void close_log_files(void)
|
|||||||
return;
|
return;
|
||||||
assert(out_fd >= 0);
|
assert(out_fd >= 0);
|
||||||
assert(err_fd >= 0);
|
assert(err_fd >= 0);
|
||||||
xclose(out_fd);
|
close(out_fd);
|
||||||
xclose(err_fd);
|
close(err_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
src/utils.c
20
src/utils.c
@@ -75,26 +75,6 @@ int ipv6Supported(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char *appendToString(char *dest, const char *src)
|
|
||||||
{
|
|
||||||
int destlen;
|
|
||||||
int srclen = strlen(src);
|
|
||||||
|
|
||||||
if (dest == NULL) {
|
|
||||||
dest = xmalloc(srclen + 1);
|
|
||||||
memset(dest, 0, srclen + 1);
|
|
||||||
destlen = 0;
|
|
||||||
} else {
|
|
||||||
destlen = strlen(dest);
|
|
||||||
dest = xrealloc(dest, destlen + srclen + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(dest + destlen, src, srclen);
|
|
||||||
dest[destlen + srclen] = '\0';
|
|
||||||
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long readLEuint32(const unsigned char *p)
|
unsigned long readLEuint32(const unsigned char *p)
|
||||||
{
|
{
|
||||||
return ((unsigned long)p[0] << 0) |
|
return ((unsigned long)p[0] << 0) |
|
||||||
|
@@ -37,8 +37,6 @@ void my_usleep(long usec);
|
|||||||
|
|
||||||
int ipv6Supported(void);
|
int ipv6Supported(void);
|
||||||
|
|
||||||
char *appendToString(char *dest, const char *src);
|
|
||||||
|
|
||||||
unsigned long readLEuint32(const unsigned char *p);
|
unsigned long readLEuint32(const unsigned char *p);
|
||||||
|
|
||||||
/* trivial functions, keep them inlined */
|
/* trivial functions, keep them inlined */
|
||||||
|
Reference in New Issue
Block a user