summaryrefslogtreecommitdiff
path: root/hugin.c
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-01-04 11:30:22 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2013-01-04 11:30:22 +0100
commit08827265399f3f69f7f25512e991f67da5bbac63 (patch)
treecd87241b1c4b4ca140e09145670b6e185da1a215 /hugin.c
parentf64458ebda5b914f235ae2fe81a466f03cb6c14b (diff)
Change function prefixes according to projet namechange.
Diffstat (limited to 'hugin.c')
-rw-r--r--hugin.c166
1 files changed, 83 insertions, 83 deletions
diff --git a/hugin.c b/hugin.c
index aebfd08..6aff5b8 100644
--- a/hugin.c
+++ b/hugin.c
@@ -37,58 +37,58 @@
#include <sys/stat.h>
#include <fcntl.h>
-#ifdef WITH_DBG_MUTEX
+#ifdef WITH_HUG_MUTEX
#include <pthread.h>
#endif
-#ifdef WITH_DBG_FILTER
+#ifdef WITH_HUG_FILTER
#include "hugin_filter.h"
#endif
-#ifdef WITH_DBG_SYSLOG
+#ifdef WITH_HUG_SYSLOG
#include "hugin_syslog.h"
#endif
-struct dbg_config_t {
+struct hug_config_t {
unsigned int flags;
int fd;
int file_fd;
int stdout_no_date;
-#ifdef WITH_DBG_MUTEX
+#ifdef WITH_HUG_MUTEX
pthread_mutex_t mutex;
#endif
-#ifdef WITH_DBG_SYSLOG
+#ifdef WITH_HUG_SYSLOG
const char* syslog_host;
int syslog_port;
#endif
-} dbg_config = {
- DBG_FLAG_DEFAULT, // flags
+} hug_config = {
+ HUG_FLAG_DEFAULT, // flags
-1, // fd
-1, // file_fd
0, //stdout_no_date
-#ifdef WITH_DBG_MUTEX
+#ifdef WITH_HUG_MUTEX
{}, // mutex;
#endif
-#ifdef WITH_DBG_SYSLOG
+#ifdef WITH_HUG_SYSLOG
"", // syslog_host;
-1, // syslog_port;
#endif
/* // This doesn't work in C++
- .flags = DBG_FLAG_DEFAULT,
+ .flags = HUG_FLAG_DEFAULT,
.fd = -1,
.file_fd = -1,
.stdout_no_date = 0
*/
};
-#ifdef WITH_DBG_MUTEX
+#ifdef WITH_HUG_MUTEX
pthread_mutex_t localtime_mutex;
#endif
-struct tm *dbg_localtime(const time_t *timep, struct tm *result)
+struct tm *hug_localtime(const time_t *timep, struct tm *result)
{
struct tm *res = NULL;
-#ifdef WITH_DBG_MUTEX
+#ifdef WITH_HUG_MUTEX
pthread_mutex_lock(&localtime_mutex);
#endif
@@ -97,7 +97,7 @@ struct tm *dbg_localtime(const time_t *timep, struct tm *result)
res = result;
}
-#ifdef WITH_DBG_MUTEX
+#ifdef WITH_HUG_MUTEX
pthread_mutex_unlock(&localtime_mutex);
#endif
@@ -105,54 +105,54 @@ struct tm *dbg_localtime(const time_t *timep, struct tm *result)
}
-static void dbg_mutex_init()
+static void hug_mutex_init()
{
-#ifdef WITH_DBG_MUTEX
- if(dbg_config.flags & DBG_FLAG_USE_MUTEX) {
- pthread_mutex_init(&dbg_config.mutex, NULL);
+#ifdef WITH_HUG_MUTEX
+ if(hug_config.flags & HUG_FLAG_USE_MUTEX) {
+ pthread_mutex_init(&hug_config.mutex, NULL);
}
pthread_mutex_init(&localtime_mutex, NULL);
#endif
}
-static void dbg_mutex_lock()
+static void hug_mutex_lock()
{
-#ifdef WITH_DBG_MUTEX
- if(dbg_config.flags & DBG_FLAG_USE_MUTEX) {
- pthread_mutex_lock(&dbg_config.mutex);
+#ifdef WITH_HUG_MUTEX
+ if(hug_config.flags & HUG_FLAG_USE_MUTEX) {
+ pthread_mutex_lock(&hug_config.mutex);
}
#endif
}
-static void dbg_mutex_unlock()
+static void hug_mutex_unlock()
{
-#ifdef WITH_DBG_MUTEX
- if(dbg_config.flags & DBG_FLAG_USE_MUTEX) {
- pthread_mutex_unlock(&dbg_config.mutex);
+#ifdef WITH_HUG_MUTEX
+ if(hug_config.flags & HUG_FLAG_USE_MUTEX) {
+ pthread_mutex_unlock(&hug_config.mutex);
}
#endif
}
-static void dbg_mutex_close()
+static void hug_mutex_close()
{
-#ifdef WITH_DBG_MUTEX
- if(dbg_config.flags & DBG_FLAG_USE_MUTEX) {
+#ifdef WITH_HUG_MUTEX
+ if(hug_config.flags & HUG_FLAG_USE_MUTEX) {
// Make sure we don't destroy the mutex while another thread is using it.
- dbg_mutex_lock();
- dbg_mutex_unlock();
- pthread_mutex_destroy(&dbg_config.mutex);
+ hug_mutex_lock();
+ hug_mutex_unlock();
+ pthread_mutex_destroy(&hug_config.mutex);
}
pthread_mutex_destroy(&localtime_mutex);
#endif
}
-dbg_status_t dbg_init(unsigned int flags, ...)
+hug_status_t hug_init(unsigned int flags, ...)
{
- dbg_status_t status = DBG_STATUS_OK;
+ hug_status_t status = HUG_STATUS_OK;
- dbg_config.flags = flags;
+ hug_config.flags = flags;
int end = 0;
@@ -161,46 +161,46 @@ dbg_status_t dbg_init(unsigned int flags, ...)
while(!end) {
int option = va_arg(vl, int);
switch(option) {
- case DBG_OPTION_END:
+ case HUG_OPTION_END:
end = 1;
break;
- case DBG_OPTION_FD:
- dbg_config.fd = va_arg(vl, int);
+ case HUG_OPTION_FD:
+ hug_config.fd = va_arg(vl, int);
break;
- case DBG_OPTION_STDOUT_NO_DATE:
- dbg_config.stdout_no_date = va_arg(vl, int);
+ case HUG_OPTION_STDOUT_NO_DATE:
+ hug_config.stdout_no_date = va_arg(vl, int);
break;
- case DBG_OPTION_FILENAME:
- if(dbg_config.flags & DBG_FLAG_OUTPUT_TO_FILE) {
+ case HUG_OPTION_FILENAME:
+ if(hug_config.flags & HUG_FLAG_OUTPUT_TO_FILE) {
const char *filename = (const char*)va_arg(vl, char*);
- dbg_config.file_fd = open(filename, O_CREAT | O_RDWR, 0777);
+ hug_config.file_fd = open(filename, O_CREAT | O_RDWR, 0777);
}
break;
-#ifdef WITH_DBG_SYSLOG
- case DBG_OPTION_SYSLOG_PORT:
- dbg_config.syslog_port = va_arg(vl, int);
+#ifdef WITH_HUG_SYSLOG
+ case HUG_OPTION_SYSLOG_PORT:
+ hug_config.syslog_port = va_arg(vl, int);
break;
- case DBG_OPTION_SYSLOG_HOST:
- dbg_config.syslog_host = (const char*)va_arg(vl, char*);
+ case HUG_OPTION_SYSLOG_HOST:
+ hug_config.syslog_host = (const char*)va_arg(vl, char*);
break;
#endif
-#ifdef WITH_DBG_FILTER
- case DBG_OPTION_FILTER:
- dbg_filter_parse((const char*)va_arg(vl, char*));
+#ifdef WITH_HUG_FILTER
+ case HUG_OPTION_FILTER:
+ hug_filter_parse((const char*)va_arg(vl, char*));
break;
#endif
default:
- status = DBG_STATUS_UNKNOWN_OPTION;
+ status = HUG_STATUS_UNKNOWN_OPTION;
printf("option: %x\n", option);
goto err;
}
}
- dbg_mutex_init();
+ hug_mutex_init();
-#ifdef WITH_DBG_SYSLOG
- if(dbg_config.flags & DBG_FLAG_OUTPUT_TO_SYSLOG) {
- dbg_syslog_init(dbg_config.syslog_host, dbg_config.syslog_port);
+#ifdef WITH_HUG_SYSLOG
+ if(hug_config.flags & HUG_FLAG_OUTPUT_TO_SYSLOG) {
+ hug_syslog_init(hug_config.syslog_host, hug_config.syslog_port);
}
#endif
@@ -210,17 +210,17 @@ dbg_status_t dbg_init(unsigned int flags, ...)
return status;
}
-void dbg_close()
+void hug_close()
{
- if(dbg_config.flags & DBG_FLAG_OUTPUT_TO_FILE) {
- if(dbg_config.file_fd != -1) close(dbg_config.file_fd);
+ if(hug_config.flags & HUG_FLAG_OUTPUT_TO_FILE) {
+ if(hug_config.file_fd != -1) close(hug_config.file_fd);
}
-#ifdef WITH_DBG_SYSLOG
- dbg_syslog_close();
+#ifdef WITH_HUG_SYSLOG
+ hug_syslog_close();
#endif
- dbg_mutex_close();
+ hug_mutex_close();
}
/*
@@ -230,11 +230,11 @@ static unsigned int gettid()
}
*/
-static int dbg_create_header(char *hdr, size_t size)
+static int hug_create_header(char *hdr, size_t size)
{
time_t rawtime = time(NULL);
struct tm t;
- dbg_localtime(&rawtime, &t);
+ hug_localtime(&rawtime, &t);
return snprintf(hdr, size,
"%d-%02d-%02d %02d:%02d:%02d",
@@ -246,7 +246,7 @@ static int dbg_create_header(char *hdr, size_t size)
t.tm_sec);
}
-static int dbg_output_fd(int fd, const char *msg, int withdate)
+static int hug_output_fd(int fd, const char *msg, int withdate)
{
int s;
@@ -254,7 +254,7 @@ static int dbg_output_fd(int fd, const char *msg, int withdate)
if(withdate) {
char hdr[32];
- dbg_create_header(hdr, sizeof(hdr));
+ hug_create_header(hdr, sizeof(hdr));
s = write(fd, hdr, strlen(hdr));
s = write(fd, " ", 1);
@@ -278,10 +278,10 @@ int __debug(const char *func, const int line,
const char * const debug_class_str[] =
{ "fixme", "err", "warn", "info", "debug" };
- dbg_mutex_lock();
+ hug_mutex_lock();
-#ifdef WITH_DBG_FILTER
- if(!dbg_filter_enabled(cl, ch)) goto done;
+#ifdef WITH_HUG_FILTER
+ if(!hug_filter_enabled(cl, ch)) goto done;
#endif
//
@@ -301,32 +301,32 @@ int __debug(const char *func, const int line,
// Send message to output
//
- if(dbg_config.flags & DBG_FLAG_OUTPUT_TO_STDOUT) {
- dbg_output_fd(STDOUT_FILENO, buf, dbg_config.stdout_no_date == 0);
+ if(hug_config.flags & HUG_FLAG_OUTPUT_TO_STDOUT) {
+ hug_output_fd(STDOUT_FILENO, buf, hug_config.stdout_no_date == 0);
}
- if(dbg_config.flags & DBG_FLAG_OUTPUT_TO_STDERR) {
- dbg_output_fd(STDERR_FILENO, buf, 1);
+ if(hug_config.flags & HUG_FLAG_OUTPUT_TO_STDERR) {
+ hug_output_fd(STDERR_FILENO, buf, 1);
}
- if(dbg_config.flags & DBG_FLAG_OUTPUT_TO_FD) {
- dbg_output_fd(dbg_config.fd, buf, 1);
+ if(hug_config.flags & HUG_FLAG_OUTPUT_TO_FD) {
+ hug_output_fd(hug_config.fd, buf, 1);
}
- if(dbg_config.flags & DBG_FLAG_OUTPUT_TO_FILE) {
- dbg_output_fd(dbg_config.file_fd, buf, 1);
+ if(hug_config.flags & HUG_FLAG_OUTPUT_TO_FILE) {
+ hug_output_fd(hug_config.file_fd, buf, 1);
}
-#ifdef WITH_DBG_SYSLOG
- if(dbg_config.flags & DBG_FLAG_OUTPUT_TO_SYSLOG) {
- dbg_syslog_output(buf);
+#ifdef WITH_HUG_SYSLOG
+ if(hug_config.flags & HUG_FLAG_OUTPUT_TO_SYSLOG) {
+ hug_syslog_output(buf);
}
#endif
-#ifdef WITH_DBG_FILTER
+#ifdef WITH_HUG_FILTER
done:
#endif
- dbg_mutex_unlock();
+ hug_mutex_unlock();
return result;
}