/*
- * Copyright (C) 2016, 2017 "IoT.bzh"
+ * Copyright (C) 2016, 2017, 2018 "IoT.bzh"
* Author José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
#include <string.h>
#include <pthread.h>
#include <unistd.h>
-#include <fnmatch.h>
#include <sys/uio.h>
#include <json-c/json.h>
#include "afb-api.h"
#include "verbose.h"
+#include <fnmatch.h>
+#define MATCH(pattern,string) (!fnmatch((pattern),(string),FNM_CASEFOLD|FNM_EXTMATCH))
+
/**
* Definition of a hook for xreq
*/
static void init_hookid(struct afb_hookid *hookid)
{
hookid->id = __atomic_add_fetch(&next_hookid, 1, __ATOMIC_RELAXED);
- clock_gettime(CLOCK_MONOTONIC, &hookid->time);
+ clock_gettime(CLOCK_REALTIME, &hookid->time);
}
/******************************************************************************
while (hook) { \
if (hook->itf->hook_evt_##what \
&& (hook->flags & afb_hook_flag_evt_##what) != 0 \
- && (!hook->pattern || !fnmatch(hook->pattern, evt, FNM_CASEFOLD))) { \
+ && (!hook->pattern || MATCH(hook->pattern, evt))) { \
hook->itf->hook_evt_##what(hook->closure, &hookid, __VA_ARGS__); \
} \
hook = hook->next; \
pthread_rwlock_rdlock(&rwlock);
hook = list_of_evt_hooks;
while (hook) {
- if (!name || !hook->pattern || !fnmatch(hook->pattern, name, FNM_CASEFOLD))
+ if (!name || !hook->pattern || MATCH(hook->pattern, name))
flags |= hook->flags;
hook = hook->next;
}
while (hook) { \
if (hook->itf->hook_session_##what \
&& (hook->flags & afb_hook_flag_session_##what) != 0 \
- && (!hook->pattern || !fnmatch(hook->pattern, (sessid?:(sessid=afb_session_uuid(session))), FNM_CASEFOLD))) { \
+ && (!hook->pattern || MATCH(hook->pattern, (sessid?:(sessid=afb_session_uuid(session)))))) { \
hook->itf->hook_session_##what(hook->closure, &hookid, __VA_ARGS__); \
} \
hook = hook->next; \