2010-06-22 14:04:33 +00:00
|
|
|
/**
|
|
|
|
* This is a minimal example plugin for uhub.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// #include "uhub.h"
|
|
|
|
#include "plugin_api/handle.h"
|
|
|
|
|
|
|
|
struct ip_addr_encap;
|
|
|
|
|
2010-07-29 06:43:22 +00:00
|
|
|
plugin_st log_connect(struct plugin_handle* plugin, struct ip_addr_encap* addr)
|
2010-06-22 14:04:33 +00:00
|
|
|
{
|
|
|
|
return st_default;
|
|
|
|
}
|
|
|
|
|
2010-07-29 06:43:22 +00:00
|
|
|
void log_user_login(struct plugin_handle* plugin, struct plugin_user* user)
|
2010-06-22 14:04:33 +00:00
|
|
|
{
|
|
|
|
printf("login: \"%s\"\n", user->nick);
|
|
|
|
}
|
|
|
|
|
2010-07-29 06:43:22 +00:00
|
|
|
void log_user_logout(struct plugin_handle* plugin, struct plugin_user* user)
|
2010-06-22 14:04:33 +00:00
|
|
|
{
|
|
|
|
printf("logout: \"%s\"\n", user->nick);
|
|
|
|
}
|
|
|
|
|
2010-07-29 06:43:22 +00:00
|
|
|
plugin_st log_change_nick(struct plugin_handle* plugin, struct plugin_user* user, const char* new_nick)
|
2010-06-22 14:04:33 +00:00
|
|
|
{
|
|
|
|
printf("\"%s\" -> \"%s\"\n", user->nick, new_nick);
|
|
|
|
return st_default;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-29 06:43:22 +00:00
|
|
|
int plugin_register(struct plugin_handle* plugin, const char* config)
|
2010-06-22 14:04:33 +00:00
|
|
|
{
|
|
|
|
plugin->name = "Logging plugin";
|
|
|
|
plugin->version = "1.0";
|
|
|
|
plugin->description = "Logs users entering and leaving the hub.";
|
|
|
|
plugin->ptr = NULL;
|
|
|
|
plugin->plugin_api_version = PLUGIN_API_VERSION;
|
|
|
|
plugin->plugin_funcs_size = sizeof(struct plugin_funcs);
|
|
|
|
memset(&plugin->funcs, 0, sizeof(struct plugin_funcs));
|
2010-07-08 12:24:40 +00:00
|
|
|
/*
|
2010-06-22 14:04:33 +00:00
|
|
|
plugin->funcs.on_connect = log_connect;
|
|
|
|
plugin->funcs.on_user_login = log_user_login;
|
|
|
|
plugin->funcs.on_user_logout = log_user_logout;
|
|
|
|
plugin->funcs.on_user_change_nick = log_change_nick;
|
2010-07-08 12:24:40 +00:00
|
|
|
*/
|
2010-06-22 14:04:33 +00:00
|
|
|
puts("* plugin register");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-29 06:43:22 +00:00
|
|
|
int plugin_unregister(struct plugin_handle* plugin)
|
2010-06-22 14:04:33 +00:00
|
|
|
{
|
|
|
|
/* No need to do anything! */
|
|
|
|
puts("* plugin unregister");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|