diff options
author | Jan Synacek <jsynacek@redhat.com> | 2014-04-29 08:33:13 +0200 |
---|---|---|
committer | Jan Synacek <jsynacek@redhat.com> | 2014-04-30 15:54:14 +0200 |
commit | 55f63d29f5d2b4e82979d71386df58394e87ef5a (patch) | |
tree | 34227f5696df9b3a85c5999d2fd48f50be82681f /src/journald | |
parent | dab89c6afb2a2b339ebadea3d47e841cd749b5ef (diff) | |
download | openlmi-providers-55f63d29f5d2b4e82979d71386df58394e87ef5a.tar.gz openlmi-providers-55f63d29f5d2b4e82979d71386df58394e87ef5a.tar.xz openlmi-providers-55f63d29f5d2b4e82979d71386df58394e87ef5a.zip |
libopenlmi: reorganize and gather
Make naming consistent. Gather common functionality into one library and
try to use it across all providers.
Introduce libtool-style versioning for libraries.
Diffstat (limited to 'src/journald')
-rw-r--r-- | src/journald/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c | 1 | ||||
-rw-r--r-- | src/journald/LMI_JournalLogRecordProvider.c | 12 | ||||
-rw-r--r-- | src/journald/LMI_JournalMessageLogProvider.c | 3 | ||||
-rw-r--r-- | src/journald/LMI_JournalRecordInLogProvider.c | 3 | ||||
-rw-r--r-- | src/journald/instutil.c | 71 |
6 files changed, 42 insertions, 50 deletions
diff --git a/src/journald/CMakeLists.txt b/src/journald/CMakeLists.txt index 1e6f193..029f3f0 100644 --- a/src/journald/CMakeLists.txt +++ b/src/journald/CMakeLists.txt @@ -34,7 +34,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR} ) target_link_libraries(${LIBRARY_NAME} - openlmicommon + openlmi openlmiindmanager ${KONKRETCMPI_LIBRARIES} ${GLIB2_LIBRARIES} diff --git a/src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c b/src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c index 7eb57f7..f6f3360 100644 --- a/src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c +++ b/src/journald/LMI_JournalLogRecordInstanceCreationIndicationProvider.c @@ -24,7 +24,6 @@ #include "ind_manager.h" #include "instutil.h" #include "journal.h" -#include <globals.h> static const CMPIBroker* _cb = NULL; diff --git a/src/journald/LMI_JournalLogRecordProvider.c b/src/journald/LMI_JournalLogRecordProvider.c index cf49535..d16880f 100644 --- a/src/journald/LMI_JournalLogRecordProvider.c +++ b/src/journald/LMI_JournalLogRecordProvider.c @@ -27,7 +27,7 @@ #include <glib.h> #include <systemd/sd-journal.h> -#include "globals.h" + #include "journal.h" #include "instutil.h" @@ -42,13 +42,13 @@ static void LMI_JournalLogRecordInitialize(const CMPIContext *ctx) { sd_journal *journal; int r; - char errbuf[STRERROR_BUF_LEN]; + char errbuf[BUFLEN]; lmi_init(JOURNAL_CIM_LOG_NAME, _cb, ctx, provider_config_defaults); 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; } journal_iter = journal; @@ -77,7 +77,7 @@ static CMPIStatus LMI_JournalLogRecordEnumInstanceNames( int r; LMI_JournalLogRecordRef log_record_ref; unsigned long count = 0; - char errbuf[STRERROR_BUF_LEN]; + char errbuf[BUFLEN]; /* Open our own journal instance to prevent losing cursor position in the global instance */ r = sd_journal_open(&journal, 0); @@ -145,7 +145,7 @@ static CMPIStatus LMI_JournalLogRecordGetInstance( { LMI_JournalLogRecord log_record; int r; - char errbuf[STRERROR_BUF_LEN]; + char errbuf[BUFLEN]; LMI_JournalLogRecord_InitFromObjectPath(&log_record, _cb, cop); @@ -202,7 +202,7 @@ static CMPIStatus LMI_JournalLogRecordCreateInstance( int r; CMPIrc rc; bool found; - char errbuf[STRERROR_BUF_LEN]; + char errbuf[BUFLEN]; cr_cl_n = get_string_property("CreationClassName", ci); log_cr_cl_n = get_string_property("LogCreationClassName", ci); diff --git a/src/journald/LMI_JournalMessageLogProvider.c b/src/journald/LMI_JournalMessageLogProvider.c index 297a775..4ce60e7 100644 --- a/src/journald/LMI_JournalMessageLogProvider.c +++ b/src/journald/LMI_JournalMessageLogProvider.c @@ -20,11 +20,10 @@ #include <konkret/konkret.h> #include "LMI_JournalMessageLog.h" - #include <glib.h> #include <systemd/sd-journal.h> -#include "globals.h" + #include "journal.h" #include "instutil.h" diff --git a/src/journald/LMI_JournalRecordInLogProvider.c b/src/journald/LMI_JournalRecordInLogProvider.c index 84f3960..a8b8efc 100644 --- a/src/journald/LMI_JournalRecordInLogProvider.c +++ b/src/journald/LMI_JournalRecordInLogProvider.c @@ -23,7 +23,6 @@ #include <systemd/sd-journal.h> -#include "globals.h" #include "journal.h" #include "instutil.h" @@ -68,7 +67,7 @@ static CMPIStatus LMI_JournalRecordInLogEnumInstances( int r; CMPIStatus rc; unsigned long count = 0; - char errbuf[STRERROR_BUF_LEN]; + char errbuf[BUFLEN]; LMI_JournalMessageLogRef_Init(&message_log_ref, _cb, ns); LMI_JournalMessageLogRef_Set_CreationClassName(&message_log_ref, LMI_JournalMessageLog_ClassName); 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; } |