summaryrefslogtreecommitdiffstats
path: root/lib/utils_base.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils_base.c')
-rw-r--r--lib/utils_base.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/utils_base.c b/lib/utils_base.c
index 4303e15..c9f0912 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -310,3 +310,64 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
310 return value; 310 return value;
311} 311}
312 312
313/*
314 * Returns a string to use as a keyname, based on an md5 hash of argv, thus
315 * hopefully a unique key per service/plugin invocation. Use the extra-opts
316 * parse of argv, so that uniqueness in parameters are reflected there.
317 */
318char *np_state_generate_key(const char **argv) {
319 return "Ahash";
320}
321
322/*
323 * Initiatializer for state routines.
324 * Sets variables. Generates filename. Returns np_state_key. die with
325 * UNKNOWN if exception
326 */
327state_key *np_state_init(char *plugin_name, char *keyname, int expected_data_version) {
328 state_key *this_state = NULL;
329
330 this_state = (state_key *) malloc(sizeof(state_key));
331
332 if(this_state==NULL)
333 die(STATE_UNKNOWN, _("Cannot allocate memory for state key"));
334
335 this_state->name=keyname;
336 this_state->plugin_name=plugin_name;
337 this_state->data_version=expected_data_version;
338
339 /* Calculate filename */
340 this_state->_filename="Tobedone";
341
342 return this_state;
343}
344
345/*
346 * Will return NULL if no data is available (first run). If key currently
347 * exists, read data. If state file format version is not expected, return
348 * as if no data. Get state data version number and compares to expected.
349 * If numerically lower, then return as no previous state. die with UNKNOWN
350 * if exceptional error.
351 */
352state_data *np_state_read(state_key *my_state_key) {
353 state_data *this_state_data=NULL;
354 my_state_key->state_data = this_state_data;
355 return this_state_data;
356}
357
358/*
359 * If time=NULL, use current time. Create state file, with state format
360 * version, default text. Writes version, time, and data. Avoid locking
361 * problems - use mv to write and then swap. Possible loss of state data if
362 * two things writing to same key at same time.
363 * Will die with UNKNOWN if errors
364 */
365void np_state_write_string(state_key *my_state_key, time_t data_time, char *data_string) {
366}
367
368/*
369 * Cleanup
370 */
371void np_state_cleanup(state_key *my_state_key) {
372}
373