Plugin Management support C plugin

This commit is contained in:
luwenpeng
2022-07-27 18:32:22 +08:00
parent 649d29e538
commit 50111e7cd0
35 changed files with 4220 additions and 193 deletions

View File

@@ -1,22 +1,82 @@
#include "session.h"
#include "packet.h"
#include "plugin.h"
#include "http.h"
#include <stdlib.h>
#include <stdio.h>
static char *g_handler = NULL;
int http_event_plugin_entry(const struct stellar_session *s, int what, struct stellar_packet *p, const char *payload, uint32_t len, void **pme)
struct per_session_pme_info
{
int flag;
char data[16];
};
extern "C" void http_event_plugin_entry(const struct stellar_session *s, enum session_event_type event, struct stellar_packet *p, const char *payload, uint16_t len, void **pme)
{
struct per_session_pme_info **per_session_pme = (struct per_session_pme_info **)pme;
printf("RUN http_event_plugin_entry, event: %d\n", event);
if (event & SESSION_EVENT_OPENING)
{
if (*per_session_pme == NULL)
{
struct per_session_pme_info *cur_ctx = (struct per_session_pme_info *)malloc(sizeof(struct per_session_pme_info));
snprintf(cur_ctx->data, 6, "******");
*per_session_pme = *&cur_ctx;
printf("http_event_plugin_entry->opening_handler\n");
}
}
if (event & SESSION_EVENT_RAWPKT)
{
printf("http_event_plugin_entry->rawpkt_handler\n");
}
if (event & SESSION_EVENT_ORDPKT)
{
printf("http_event_plugin_entry->ordpkt_handler\n");
}
if (event & SESSION_EVENT_META)
{
printf("http_event_plugin_entry->meta_handler\n");
}
if (event & SESSION_EVENT_CLOSING)
{
if (*per_session_pme)
{
printf("http_event_plugin_entry->closing_hanler\n");
free(*per_session_pme);
*per_session_pme = NULL;
}
}
}
extern "C" int http_event_plugin_init(void)
{
printf("RUN http_event_plugin_init\n");
if (g_handler == NULL)
{
g_handler = (char *)malloc(1024);
snprintf(g_handler, 1024, "111111");
}
return 0;
}
int http_event_plugin_init()
extern "C" void http_event_plugin_exit(void)
{
//plugin_manager_event_register("HTTP", http_event_plugin_entry, nullptr);
return 0;
}
printf("RUN http_event_plugin_exit\n");
void http_event_plugin_destroy()
{
return ;
if (g_handler)
{
free(g_handler);
g_handler = NULL;
}
}