1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

the hook callback shall return 0 in case of success.

the number of returned samples is now updated in the passed hook_info::count
This commit is contained in:
Steffen Vogel 2017-03-20 09:14:10 -03:00
parent 8613ee688e
commit 8c8a2c57b7
9 changed files with 10 additions and 20 deletions

View file

@ -97,6 +97,7 @@ struct hook_type {
enum hook_when when; /**< The type of the hook as a bitfield */
hook_cb_t cb; /**< The hook callback function as a function pointer. */
int priority; /**< Default priority of this hook type. */
size_t size; /**< Size of allocation for struct hook::_vd */
};
/** Descriptor for user defined hooks. See hooks[]. */
@ -133,17 +134,6 @@ int hook_destroy(struct hook *h);
/** Compare two hook functions with their priority. Used by list_sort() */
int hook_cmp_priority(const void *a, const void *b);
/** Allocate & deallocate private memory per hook.
*
* Hooks which use this function must be flagged with HOOL_STORAGE.
*
* @param h A pointer to the hook structure.
* @param when Which event cause the hook to be executed?
* @param len The size of hook prvate memory allocation.
* @return A pointer to the allocated memory region or NULL after it was released.
*/
void * hook_storage(struct hook *h, int when, size_t len, ctor_cb_t ctor, dtor_cb_t dtor);
/** Parses an object of hooks
*
* Example:

View file

@ -48,7 +48,7 @@ static int hook_convert(struct hook *h, int when, struct hook_info *j)
}
}
return j->count;
break;
}
return 0;

View file

@ -34,7 +34,7 @@ int hook_fix_ts(struct hook *h, int when, struct hook_info *j)
j->samples[i]->ts.origin = now;
}
return j->count;
return 0;
}
static struct plugin p = {

View file

@ -52,7 +52,7 @@ static int hook_print(struct hook *h, int when, struct hook_info *j)
break;
}
return j->count;
return 0;
}
static struct plugin p = {

View file

@ -33,7 +33,7 @@ static int hook_restart(struct hook *h, int when, struct hook_info *j)
h->prev = h->last;
}
return j->count;
return 0;
}
static struct plugin p = {

View file

@ -95,7 +95,7 @@ static int hook_shift(struct hook *h, int when, struct hook_info *j)
}
}
return j->count;
break;
}
return 0;

View file

@ -111,8 +111,8 @@ static int hook_skip_first(struct hook *h, int when, struct hook_info *j)
* only the first 'ok' samples in 'smps[]' are accepted and further processed.
*/
}
return ok;
j->count = ok;
}
return 0;

View file

@ -102,7 +102,7 @@ static int hook_stats(struct hook *h, int when, struct hook_info *j)
break;
}
return j->count;
return 0;
}
struct stats_send {

View file

@ -19,7 +19,7 @@ static int hook_ts(struct hook *h, int when, struct hook_info *j)
for (int i = 0; i < j->count; i++)
j->samples[i]->ts.origin = j->samples[i]->ts.received;
return j->count;
return 0;
}
static struct plugin p = {