summaryrefslogtreecommitdiffstats
path: root/src/journald/instutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/journald/instutil.c')
-rw-r--r--src/journald/instutil.c71
1 files changed, 33 insertions, 38 deletions
diff --git a/src/journald/instutil.c b/src/journald/instutil.c
index 413a8b1..b2ed0e7 100644
--- a/src/journald/instutil.c
+++ b/src/journald/instutil.c
@@ -21,13 +21,8 @@
#include <errno.h>
#include <syslog.h>
#include <unistd.h>
-#include <glib.h>
-
-#include <konkret/konkret.h>
-#include <cmpi/cmpimacs.h>
#include "instutil.h"
-#include "globals.h"
#include "journal.h"
#include "LMI_JournalLogRecord.h"
@@ -276,7 +271,7 @@ int match_journal_record(sd_journal *j, const char *message, const char *code_fu
void ind_init()
{
- char errbuf[STRERROR_BUF_LEN];
+ char errbuf[BUFLEN];
if (ind_journal == NULL) {
sd_journal *journal;
@@ -284,13 +279,13 @@ void ind_init()
r = sd_journal_open(&journal, 0);
if (r < 0) {
- error("ind_init(): Error opening journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("ind_init(): Error opening journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
return;
}
r = sd_journal_seek_tail(journal);
if (r < 0) {
- error("ind_init(): Error seeking to the end of the journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("ind_init(): Error seeking to the end of the journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
sd_journal_close(journal);
return;
}
@@ -298,13 +293,13 @@ void ind_init()
/* need to position the marker one step before EOF or otherwise the next sd_journal_next() call will overflow to the beginning */
r = sd_journal_previous(journal);
if (r < 0) {
- error("ind_init(): Error seeking to the end of the journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("ind_init(): Error seeking to the end of the journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
sd_journal_close(journal);
return;
}
ind_journal = journal;
} else
- warn("ind_init(): indications already initialized, possible bug in the code\n");
+ lmi_warn("ind_init(): indications already initialized, possible bug in the code\n");
}
void ind_destroy()
@@ -318,10 +313,10 @@ void ind_destroy()
bool ind_watcher(void **data)
{
int r;
- char errbuf[STRERROR_BUF_LEN];
+ char errbuf[BUFLEN];
if (ind_journal == NULL) {
- error("ind_watcher(): indications have not been initialized yet or error occurred previously\n");
+ lmi_error("ind_watcher(): indications have not been initialized yet or error occurred previously\n");
return false;
}
@@ -336,11 +331,11 @@ bool ind_watcher(void **data)
r = sd_journal_wait(ind_journal, (uint64_t) -1);
}
if (r < 0) {
- warn("ind_watcher(): Error while waiting for new record: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_warn("ind_watcher(): Error while waiting for new record: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
return false;
}
if (r == SD_JOURNAL_INVALIDATE) {
- warn("ind_watcher(): Journal not valid, reopen needed\n");
+ lmi_warn("ind_watcher(): Journal not valid, reopen needed\n");
ind_destroy();
ind_init();
return false;
@@ -356,14 +351,14 @@ bool ind_gather(const IMManager *manager, CMPIInstance **old, CMPIInstance **new
int r;
LMI_JournalLogRecord log_record;
CMPIStatus st;
- char errbuf[STRERROR_BUF_LEN];
+ char errbuf[BUFLEN];
g_return_val_if_fail(data != NULL, false);
journal = data;
r = sd_journal_next(journal);
if (r < 0) {
- error("ind_gather(): Failed to iterate to next entry: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("ind_gather(): Failed to iterate to next entry: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
return false;
}
if (r == 0) {
@@ -375,13 +370,13 @@ bool ind_gather(const IMManager *manager, CMPIInstance **old, CMPIInstance **new
LMI_JournalLogRecord_Init(&log_record, manager->broker, "root/cimv2");
r = create_LMI_JournalLogRecord(journal, &log_record, manager->broker);
if (r <= 0) {
- error("ind_gather(): Failed to create instance: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("ind_gather(): Failed to create instance: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
return false;
}
g_assert(new != NULL);
*new = LMI_JournalLogRecord_ToInstance(&log_record, &st);
- debug(" ind_gather(): new instance created\n");
+ lmi_debug(" ind_gather(): new instance created\n");
return true;
}
@@ -445,7 +440,7 @@ journal_iter_new(const gchar *req_cursor, gboolean seek_tail, sd_journal **journ
char *cursor;
sd_journal *journal;
int r;
- char errbuf[STRERROR_BUF_LEN];
+ char errbuf[BUFLEN];
gboolean eof_set;
if (journal_out)
@@ -453,7 +448,7 @@ journal_iter_new(const gchar *req_cursor, gboolean seek_tail, sd_journal **journ
r = sd_journal_open(&journal, 0);
if (r < 0) {
- error("Error opening journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("Error opening journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
return NULL;
}
@@ -467,7 +462,7 @@ journal_iter_new(const gchar *req_cursor, gboolean seek_tail, sd_journal **journ
}
if (r < 0) {
- error("Error seeking to the requested journal position: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("Error seeking to the requested journal position: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
sd_journal_close(journal);
return NULL;
}
@@ -477,7 +472,7 @@ journal_iter_new(const gchar *req_cursor, gboolean seek_tail, sd_journal **journ
else
r = sd_journal_next(journal);
if (r < 0) {
- error("Error stepping next in the journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("Error stepping next in the journal: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
sd_journal_close(journal);
return NULL;
}
@@ -485,7 +480,7 @@ journal_iter_new(const gchar *req_cursor, gboolean seek_tail, sd_journal **journ
r = sd_journal_get_cursor(journal, &cursor);
if (r < 0) {
- error("Error getting current cursor: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("Error getting current cursor: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
sd_journal_close(journal);
return NULL;
}
@@ -494,7 +489,7 @@ journal_iter_new(const gchar *req_cursor, gboolean seek_tail, sd_journal **journ
if (cmpi_iters == NULL)
cmpi_iters = g_hash_table_new_full(g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) sd_journal_close);
if (cmpi_iters == NULL) {
- error("Memory allocation failure\n");
+ lmi_error("Memory allocation failure\n");
sd_journal_close(journal);
G_UNLOCK(cmpi_iters);
return NULL;
@@ -503,7 +498,7 @@ journal_iter_new(const gchar *req_cursor, gboolean seek_tail, sd_journal **journ
if (iter_id)
iter_id_full = make_iterator_string(journal, cursor, iter_id, eof_set);
if (iter_id == NULL || iter_id_full == NULL) {
- error("Memory allocation failure\n");
+ lmi_error("Memory allocation failure\n");
sd_journal_close(journal);
} else {
g_hash_table_insert(cmpi_iters, iter_id, journal);
@@ -543,11 +538,11 @@ journal_iter_validate_id(gchar **iter_id, sd_journal **journal_out, gchar **pref
G_UNLOCK(cmpi_iters);
if (*journal_out == NULL || *journal_out != iter_ptr) {
/* Assume stale iterator ID, reopen journal and try to find the position by the cursor */
- warn("journal_iter_validate_id(): iterator pointer %p doesn't match with hashtable %p, reopening journal...\n", iter_ptr, *journal_out);
+ lmi_warn("journal_iter_validate_id(): iterator pointer %p doesn't match with hashtable %p, reopening journal...\n", iter_ptr, *journal_out);
g_free(*iter_id);
*iter_id = journal_iter_new(iter_cursor, FALSE, journal_out);
if (*iter_id == NULL) {
- error("The IterationIdentifier is not valid anymore: \'%s\'\n", *iter_id);
+ lmi_error("The IterationIdentifier is not valid anymore: \'%s\'\n", *iter_id);
res = FALSE;
}
}
@@ -575,7 +570,7 @@ journal_iter_cancel(const char *iter_id)
b = cmpi_iters && g_hash_table_remove(cmpi_iters, iter_id);
G_UNLOCK(cmpi_iters);
if (! b) {
- error("IterationIdentifier \'%s\' not registered\n", iter_id);
+ lmi_error("IterationIdentifier \'%s\' not registered\n", iter_id);
return false;
}
@@ -588,12 +583,12 @@ update_iter(gchar **iter_id, gboolean explicit_eof, sd_journal *journal)
gchar *iter_id_short;
char *cursor;
int r;
- char errbuf[STRERROR_BUF_LEN];
+ char errbuf[BUFLEN];
gboolean eof_set;
r = sd_journal_get_cursor(journal, &cursor);
if (r < 0) {
- error("Error getting current cursor: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("Error getting current cursor: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
return false;
}
@@ -608,12 +603,12 @@ bool
journal_iter_seek(gchar **iter_id, sd_journal *journal, gint64 position)
{
int r;
- char errbuf[STRERROR_BUF_LEN];
+ char errbuf[BUFLEN];
g_return_val_if_fail(journal != NULL, false);
if (position == 0) { /* NOP */
- warn("journal_iter_seek(): Spurious seek request to relative position 0\n");
+ lmi_warn("journal_iter_seek(): Spurious seek request to relative position 0\n");
return true;
}
@@ -623,12 +618,12 @@ journal_iter_seek(gchar **iter_id, sd_journal *journal, gint64 position)
r = sd_journal_previous_skip(journal, -position);
if (r < 0) {
- error("Error seeking to the requested position: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("Error seeking to the requested position: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
return false;
}
if (! update_iter(iter_id, r == 0, journal)) {
- error("Error seeking to the requested position\n");
+ lmi_error("Error seeking to the requested position\n");
return false;
}
@@ -640,7 +635,7 @@ journal_iter_get_data(gchar **iter_id, sd_journal *journal, gboolean step_next)
{
gchar *d;
int r;
- char errbuf[STRERROR_BUF_LEN];
+ char errbuf[BUFLEN];
gboolean eof_set;
g_return_val_if_fail(journal != NULL, false);
@@ -657,21 +652,21 @@ journal_iter_get_data(gchar **iter_id, sd_journal *journal, gboolean step_next)
/* Construct the message */
r = get_record_message(journal, TRUE, &d);
if (r < 0) {
- error("Error getting record message: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("Error getting record message: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
return NULL;
}
if (step_next) {
r = sd_journal_next(journal);
if (r < 0) {
- error("Error advancing to the next record: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
+ lmi_error("Error advancing to the next record: %s\n", strerror_r(-r, errbuf, sizeof(errbuf)));
g_free(d);
return NULL;
}
}
if (! update_iter(iter_id, r == 0, journal)) {
- error("Error getting record message\n");
+ lmi_error("Error getting record message\n");
return NULL;
}