add event plugin type

This commit is contained in:
Ron Pedde
2006-05-04 06:20:26 +00:00
parent 0c407a7eca
commit 4440ac7013
9 changed files with 298 additions and 21 deletions

View File

@@ -5,13 +5,21 @@
#ifndef _MTD_PLUGINS_H_
#define _MTD_PLUGINS_H_
#define PLUGIN_OUTPUT 0
#define PLUGIN_SCANNER 1
#define PLUGIN_DATABASE 2
#define PLUGIN_OTHER 3
#define PLUGIN_OUTPUT 1
#define PLUGIN_SCANNER 2
#define PLUGIN_DATABASE 4
#define PLUGIN_EVENT 8
#define PLUGIN_VERSION 1
#define PLUGIN_EVENT_LOG 0
#define PLUGIN_EVENT_FULLSCAN_START 1
#define PLUGIN_EVENT_FULLSCAN_END 2
#define PLUGIN_EVENT_STARTING 3
#define PLUGIN_EVENT_SHUTDOWN 4
#define PLUGIN_EVENT_STARTSTREAM 5
#define PLUGIN_EVENT_ABORTSTREAM 6
#define PLUGIN_EVENT_ENDSTREAM 7
typedef void* PARSETREE;
@@ -23,6 +31,10 @@ typedef struct tag_plugin_output_fn {
int(*auth)(WS_CONNINFO *pwsc, char *username, char *pw);
} PLUGIN_OUTPUT_FN;
typedef struct tag_plugin_event_fn {
void(*handler)(int event_id, int intval, void *vp, int len);
} PLUGIN_EVENT_FN;
typedef struct tag_plugin_rend_info {
char *type;
char *txt;
@@ -33,8 +45,9 @@ typedef struct tag_plugin_info {
int type;
char *server;
char *url; /* regex of namespace to handle if OUTPUT type */
void *handler_functions;
void *fn; /* input functions*/
PLUGIN_OUTPUT_FN *output_fns;
PLUGIN_EVENT_FN *event_fns;
void *pi; /* exported functions */
PLUGIN_REND_INFO *rend_info;
} PLUGIN_INFO;

View File

@@ -8,7 +8,7 @@
#define RSP_VERSION "1.0"
extern PLUGIN_INFO _pi;
#define infn ((PLUGIN_INPUT_FN *)(_pi.fn))
#define infn ((PLUGIN_INPUT_FN *)(_pi.pi))
#ifndef TRUE
# define TRUE 1

65
src/plugins/w32-event.c Normal file
View File

@@ -0,0 +1,65 @@
/*
* $Id: $
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "compat.h"
#include "mtd-plugins.h"
/* Forwards */
PLUGIN_INFO *plugin_info(void);
void plugin_handler(int, int, void *, int);
#define PIPE_BUFFER_SIZE 4096
/* Globals */
PLUGIN_EVENT_FN _pefn = { plugin_handler };
PLUGIN_INFO _pi = {
PLUGIN_VERSION,
PLUGIN_EVENT,
"w32-event/1.0",
NULL,
NULL,
&_pefn,
NULL,
NULL
};
typedef struct tag_plugin_msg {
int size;
int event_id;
int intval;
char vp[1];
} PLUGIN_MSG;
#define infn ((PLUGIN_INPUT_FN *)(_pi.pi))
PLUGIN_INFO *plugin_info(void) {
return &_pi;
}
void plugin_handler(int event_id, int intval, void *vp, int len) {
int total_len = 3 * sizeof(int) + len + 1;
PLUGIN_MSG *pmsg;
pmsg = (PLUGIN_MSG*)malloc(total_len);
if(!pmsg) {
infn->log(E_LOG,"Malloc error in w32-event.c/plugin_handler\n");
return;
}
memset(pmsg,0,total_len);
pmsg->size = total_len;
pmsg->event_id = event_id;
pmsg->intval = intval;
memcpy(&pmsg->vp,vp,len);
CallNamedPipe("\\\\.\\pipe\\firefly",NULL,0,pmsg,total_len,NULL,NMPWAIT_NOWAIT);
free(pmsg);
return;
}