Skip to content

Instantly share code, notes, and snippets.

@tom-lpsd
Created April 13, 2011 05:30
Show Gist options
  • Save tom-lpsd/917007 to your computer and use it in GitHub Desktop.
Save tom-lpsd/917007 to your computer and use it in GitHub Desktop.
MySQL daemon plugin sample.
#include <stdio.h>
#include <mysql_version.h>
#include <mysql/plugin.h>
struct st_mysql_daemon hello_daemon_plugin =
{ MYSQL_DAEMON_INTERFACE_VERSION };
static FILE *fp;
int hello_daemon_plugin_init(void *p)
{
fp = fopen("/tmp/hellodaemon.txt", "w");
fprintf(fp, "Yeah! Hello MySQL Daemon Plugin!!\n");
fflush(fp);
return 0;
}
int hello_daemon_plugin_deinit(void *p)
{
fprintf(fp, "Shutting down Hello Daemon!!\n");
fclose(fp);
return 0;
}
mysql_declare_plugin(hello_daemon)
{
MYSQL_DAEMON_PLUGIN,
&hello_daemon_plugin,
"hello_daemon",
"Tom Tsuruhara",
"A simple daemon plugin example",
PLUGIN_LICENSE_GPL,
hello_daemon_plugin_init, /* Plugin Init */
hello_daemon_plugin_deinit, /* Plugin Deinit */
0x0100,
NULL,
NULL,
NULL
}
mysql_declare_plugin_end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment