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.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/journald/instutil.c b/src/journald/instutil.c
index a38202a..e664621 100644
--- a/src/journald/instutil.c
+++ b/src/journald/instutil.c
@@ -20,6 +20,7 @@
#include <errno.h>
#include <syslog.h>
+#include <unistd.h>
#include <glib.h>
#include <konkret/konkret.h>
@@ -239,6 +240,34 @@ int create_LMI_JournalLogRecord(sd_journal *j,
return 1;
}
+int match_journal_record(sd_journal *j, const char *message, const char *code_func)
+{
+ gchar *msg = NULL;
+ gchar *pid = NULL;
+ gchar *cfunc = NULL;
+ char *conv_err = NULL;
+ long int pid_n;
+ int r;
+
+ r = dup_journal_data(j, "MESSAGE", &msg);
+ if (r < 0)
+ return r;
+ dup_journal_data(j, "_PID", &pid);
+ dup_journal_data(j, "CODE_FUNC", &cfunc);
+
+ if (pid)
+ pid_n = strtol(pid, &conv_err, 10);
+
+ r = msg && pid && cfunc &&
+ (strcmp(message, msg) == 0) && (strcmp(code_func, cfunc) == 0) &&
+ (conv_err == NULL || *conv_err == '\0') && (pid_n == getpid());
+
+ g_free(msg);
+ g_free(pid);
+ g_free(cfunc);
+
+ return r;
+}
void ind_init()
{