Browse Source

* two new headers : mod-*.h

master
Alex 'AdUser' Z 3 years ago
parent
commit
4cbc227d20
  1. 1
      src/backend.c
  2. 10
      src/backends/backend.h
  3. 1
      src/filter.c
  4. 11
      src/filters/filter.h
  5. 53
      src/mod-api.h
  6. 9
      src/mod-defs.h
  7. 4
      src/source.c
  8. 11
      src/sources/source.h

1
src/backend.c

@ -7,6 +7,7 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "mod-defs.h"
#include "backend.h"
#include <dlfcn.h>

10
src/backends/backend.h

@ -7,14 +7,8 @@
#include <stdbool.h>
#include <stdarg.h>
enum loglevel {
debug = 0,
info = 1,
notice = 2,
warn = 3,
error = 4,
fatal = 5,
}; /* see log.h */
#include "../mod-defs.h"
#include "../mod-api.h"
/**
* @file

1
src/filter.c

@ -7,6 +7,7 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "mod-defs.h"
#include "filter.h"
#include <dlfcn.h>

11
src/filters/filter.h

@ -15,15 +15,8 @@
#include <string.h>
#include "../strlcpy.h"
enum loglevel {
debug = 0,
info = 1,
notice = 2,
warn = 3,
error = 4,
fatal = 5,
}; /* see log.h */
#include "../mod-defs.h"
#include "../mod-api.h"
/**
* @file

53
src/mod-api.h

@ -0,0 +1,53 @@
/** @file This file contains common exportable types and routines used by all modules */
enum loglevel {
debug = 0,
info = 1,
notice = 2,
warn = 3,
error = 4,
fatal = 5,
};
/**
* Opaque module handler, contains module internal structs
*/
typedef struct _config cfg_t;
/**
* @brief Create instance of module
* @param init Module-specific init string
* @returns Opaque module handler or NULL on failure
*/
extern cfg_t *create(const char *init);
/**
* @brief Configure module instance
* @param cfg Module handler
* @param key Parameter name
* @param value Parameter value
* @returns true on success, false on error
*/
extern bool config(cfg_t *cfg, const char *key, const char *value);
/**
* @brief Get internal module state as set of flags (see mod.h)
* @param cfg Module handler
* @returns <0 on error
*/
extern int state(cfg_t *cfg);
/**
* @brief Sets the log callback
* @param cfg Module handler
* @param cb Logging callback
* @note Optional, if this function is not called, warnings/errors of module will be suppressed
*/
extern void logcb(cfg_t *cfg, void (*cb)(enum loglevel l, const char *msg));
/**
* @brief Free module handle
* @param cfg Module handler
* @note Module handler becomes invalid after calling this function on it
*/
extern void destroy(cfg_t *cfg);

9
src/mod-defs.h

@ -0,0 +1,9 @@
/** used as in return value of state() call */
#define MOD_IS_READY 1
#define MOD_WRONG_API 2
#define MOD_STARTED 4 /* source, backend */
#define MOD_NEED_FILTER 8 /* only source */
/* reserved */
#define MOD_TYPE_SOURCE 1024
#define MOD_TYPE_FILTER 2048
#define MOD_TYPE_BACKEND 4096

4
src/source.c

@ -7,11 +7,11 @@
#include "common.h"
#include "config.h"
#include "log.h"
#include "mod-defs.h"
#include "source.h"
#include <dlfcn.h>
#include "source.h"
#define SOURCE_LIBRARY_PARAM "load"
f2b_source_t *

11
src/sources/source.h

@ -14,15 +14,8 @@
#include <unistd.h>
#include "../strlcpy.h"
enum loglevel {
debug = 0,
info = 1,
notice = 2,
warn = 3,
error = 4,
fatal = 5,
}; /* see log.h */
#include "../mod-defs.h"
#include "../mod-api.h"
/**
* @file

Loading…
Cancel
Save