Move module object inside MODULE_INFO

This allows modules to only expose one entry point with a consistent
signature. In the future, this could be used to implement declarations of
module parameters.
This commit is contained in:
Markus Mäkelä
2017-01-03 14:04:20 +02:00
parent 6c53999c97
commit ae0577c695
53 changed files with 1346 additions and 1483 deletions

View File

@ -38,15 +38,6 @@
#include <maxscale/modinfo.h>
#include <maxscale/poll.h>
MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_IN_DEVELOPMENT,
GWPROTOCOL_VERSION,
"A Change Data Capture Listener implementation for use in binlog events retrieval",
"V1.0.0"
};
#define ISspace(x) isspace((int)(x))
#define CDC_SERVER_STRING "MaxScale(c) v.1.0.0"
@ -69,25 +60,6 @@ static char* cdc_default_auth()
return "CDCPlainAuth";
}
/**
* The "module object" for the CDC protocol module.
*/
static GWPROTOCOL MyObject =
{
cdc_read_event, /* Read - EPOLLIN handler */
cdc_write, /* Write - data from gateway */
cdc_write_event, /* WriteReady - EPOLLOUT handler */
cdc_error, /* Error - EPOLLERR handler */
cdc_hangup, /* HangUp - EPOLLHUP handler */
cdc_accept, /* Accept */
NULL, /* Connect */
cdc_close, /* Close */
cdc_listen, /* Create a listener */
NULL, /* Authentication */
NULL, /* Session */
cdc_default_auth /* default authentication */
};
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -96,10 +68,34 @@ static GWPROTOCOL MyObject =
*
* @return The module object
*/
GWPROTOCOL *
GetModuleObject()
MODULE_INFO* GetModuleObject()
{
return &MyObject;
static GWPROTOCOL MyObject =
{
cdc_read_event, /* Read - EPOLLIN handler */
cdc_write, /* Write - data from gateway */
cdc_write_event, /* WriteReady - EPOLLOUT handler */
cdc_error, /* Error - EPOLLERR handler */
cdc_hangup, /* HangUp - EPOLLHUP handler */
cdc_accept, /* Accept */
NULL, /* Connect */
cdc_close, /* Close */
cdc_listen, /* Create a listener */
NULL, /* Authentication */
NULL, /* Session */
cdc_default_auth /* default authentication */
};
static MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_IN_DEVELOPMENT,
GWPROTOCOL_VERSION,
"A Change Data Capture Listener implementation for use in binlog events retrieval",
"V1.0.0"
};
return &info;
}
/**
@ -274,7 +270,7 @@ cdc_accept(DCB *listener)
int n_connect = 0;
DCB *client_dcb;
while ((client_dcb = dcb_accept(listener, &MyObject)) != NULL)
while ((client_dcb = dcb_accept(listener)) != NULL)
{
CDC_session *client_data = NULL;
CDC_protocol *protocol = NULL;

View File

@ -40,20 +40,6 @@
#include <maxscale/log_manager.h>
#include <maxscale/resultset.h>
/* @see function load_module in load_utils.c for explanation of the following
* lint directives.
*/
/*lint -e14 */
MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_IN_DEVELOPMENT,
GWPROTOCOL_VERSION,
"An experimental HTTPD implementation for use in administration",
"V1.2.0"
};
/*lint +e14 */
#define ISspace(x) isspace((int)(x))
#define HTTP_SERVER_STRING "MaxScale(c) v.1.0.0"
@ -69,26 +55,6 @@ static int httpd_get_line(int sock, char *buf, int size);
static void httpd_send_headers(DCB *dcb, int final, bool auth_ok);
static char *httpd_default_auth();
/**
* The "module object" for the httpd protocol module.
*/
static GWPROTOCOL MyObject =
{
httpd_read_event, /**< Read - EPOLLIN handler */
httpd_write, /**< Write - data from gateway */
httpd_write_event, /**< WriteReady - EPOLLOUT handler */
httpd_error, /**< Error - EPOLLERR handler */
httpd_hangup, /**< HangUp - EPOLLHUP handler */
httpd_accept, /**< Accept */
NULL, /**< Connect */
httpd_close, /**< Close */
httpd_listen, /**< Create a listener */
NULL, /**< Authentication */
NULL, /**< Session */
httpd_default_auth, /**< Default authenticator */
NULL /**< Connection limit reached */
};
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -97,9 +63,36 @@ static GWPROTOCOL MyObject =
*
* @return The module object
*/
GWPROTOCOL* GetModuleObject()
MODULE_INFO* GetModuleObject()
{
return &MyObject;
static GWPROTOCOL MyObject =
{
httpd_read_event, /**< Read - EPOLLIN handler */
httpd_write, /**< Write - data from gateway */
httpd_write_event, /**< WriteReady - EPOLLOUT handler */
httpd_error, /**< Error - EPOLLERR handler */
httpd_hangup, /**< HangUp - EPOLLHUP handler */
httpd_accept, /**< Accept */
NULL, /**< Connect */
httpd_close, /**< Close */
httpd_listen, /**< Create a listener */
NULL, /**< Authentication */
NULL, /**< Session */
httpd_default_auth, /**< Default authenticator */
NULL /**< Connection limit reached */
};
static MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_IN_DEVELOPMENT,
GWPROTOCOL_VERSION,
"An experimental HTTPD implementation for use in administration",
"V1.2.0",
&MyObject
};
return &info;
}
/*lint +e14 */
@ -358,7 +351,7 @@ static int httpd_accept(DCB *listener)
int n_connect = 0;
DCB *client_dcb;
while ((client_dcb = dcb_accept(listener, &MyObject)) != NULL)
while ((client_dcb = dcb_accept(listener)) != NULL)
{
HTTPD_session *client_data = NULL;

View File

@ -17,6 +17,10 @@
#include <maxscale/utils.h>
#include <netinet/tcp.h>
#include <mysqld_error.h>
#include <maxscale/alloc.h>
#include <maxscale/modinfo.h>
#include <maxscale/gw_protocol.h>
#include <mysql_auth.h>
/*
* MySQL Protocol module for handling the protocol between the gateway
@ -46,24 +50,6 @@
* 23/05/2016 Martin Brampton Provide for backend SSL
*
*/
#include <maxscale/alloc.h>
#include <maxscale/modinfo.h>
#include <maxscale/gw_protocol.h>
#include <mysql_auth.h>
/* @see function load_module in load_utils.c for explanation of the following
* lint directives.
*/
/*lint -e14 */
MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_GA,
GWPROTOCOL_VERSION,
"The MySQL to backend server protocol",
"V2.0.0"
};
/*lint +e14 */
static int gw_create_backend_connection(DCB *backend, SERVER *server, SESSION *in_session);
static int gw_read_backend_event(DCB* dcb);
@ -91,27 +77,6 @@ static int gw_send_change_user_to_backend(char *dbname,
uint8_t *passwd,
MySQLProtocol *conn);
#if defined(NOT_USED)
static int gw_session(DCB *backend_dcb, void *data);
#endif
static GWPROTOCOL MyObject =
{
gw_read_backend_event, /* Read - EPOLLIN handler */
gw_MySQLWrite_backend, /* Write - data from gateway */
gw_write_backend_event, /* WriteReady - EPOLLOUT handler */
gw_error_backend_event, /* Error - EPOLLERR handler */
gw_backend_hangup, /* HangUp - EPOLLHUP handler */
NULL, /* Accept */
gw_create_backend_connection, /* Connect */
gw_backend_close, /* Close */
NULL, /* Listen */
gw_change_user, /* Authentication */
NULL, /* Session */
gw_backend_default_auth, /* Default authenticator */
NULL /* Connection limit reached */
};
/*
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -120,9 +85,36 @@ static GWPROTOCOL MyObject =
*
* @return The module object
*/
GWPROTOCOL* GetModuleObject()
MODULE_INFO* GetModuleObject()
{
return &MyObject;
static GWPROTOCOL MyObject =
{
gw_read_backend_event, /* Read - EPOLLIN handler */
gw_MySQLWrite_backend, /* Write - data from gateway */
gw_write_backend_event, /* WriteReady - EPOLLOUT handler */
gw_error_backend_event, /* Error - EPOLLERR handler */
gw_backend_hangup, /* HangUp - EPOLLHUP handler */
NULL, /* Accept */
gw_create_backend_connection, /* Connect */
gw_backend_close, /* Close */
NULL, /* Listen */
gw_change_user, /* Authentication */
NULL, /* Session */
gw_backend_default_auth, /* Default authenticator */
NULL /* Connection limit reached */
};
static MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_GA,
GWPROTOCOL_VERSION,
"The MySQL to backend server protocol",
"V2.0.0",
&MyObject
};
return &info;
}
/**

View File

@ -60,20 +60,6 @@
#include <maxscale/gw_authenticator.h>
#include <maxscale/session.h>
/* @see function load_module in load_utils.c for explanation of the following
* lint directives.
*/
/*lint -e14 */
MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_GA,
GWPROTOCOL_VERSION,
"The client to MaxScale MySQL protocol implementation",
"V1.1.0"
};
/*lint +e14*/
static int gw_MySQLAccept(DCB *listener);
static int gw_MySQLListener(DCB *listener, char *config_bind);
static int gw_read_client_event(DCB* dcb);
@ -97,22 +83,7 @@ static void gw_process_one_new_client(DCB *client_dcb);
/*
* The "module object" for the mysqld client protocol module.
*/
static GWPROTOCOL MyObject =
{
gw_read_client_event, /* Read - EPOLLIN handler */
gw_MySQLWrite_client, /* Write - data from gateway */
gw_write_client_event, /* WriteReady - EPOLLOUT handler */
gw_error_client_event, /* Error - EPOLLERR handler */
gw_client_hangup_event, /* HangUp - EPOLLHUP handler */
gw_MySQLAccept, /* Accept */
NULL, /* Connect */
gw_client_close, /* Close */
gw_MySQLListener, /* Listen */
NULL, /* Authentication */
NULL, /* Session */
gw_default_auth, /* Default authenticator */
gw_connection_limit /* Send error connection limit */
};
/**
* The module entry point routine. It is this routine that
@ -122,9 +93,36 @@ static GWPROTOCOL MyObject =
*
* @return The module object
*/
GWPROTOCOL* GetModuleObject()
MODULE_INFO* GetModuleObject()
{
return &MyObject;
static GWPROTOCOL MyObject =
{
gw_read_client_event, /* Read - EPOLLIN handler */
gw_MySQLWrite_client, /* Write - data from gateway */
gw_write_client_event, /* WriteReady - EPOLLOUT handler */
gw_error_client_event, /* Error - EPOLLERR handler */
gw_client_hangup_event, /* HangUp - EPOLLHUP handler */
gw_MySQLAccept, /* Accept */
NULL, /* Connect */
gw_client_close, /* Close */
gw_MySQLListener, /* Listen */
NULL, /* Authentication */
NULL, /* Session */
gw_default_auth, /* Default authenticator */
gw_connection_limit /* Send error connection limit */
};
static MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_GA,
GWPROTOCOL_VERSION,
"The client to MaxScale MySQL protocol implementation",
"V1.1.0",
&MyObject
};
return &info;
}
/*lint +e14 */
@ -1142,7 +1140,7 @@ int gw_MySQLAccept(DCB *listener)
}
else
{
while ((client_dcb = dcb_accept(listener, &MyObject)) != NULL)
while ((client_dcb = dcb_accept(listener)) != NULL)
{
gw_process_one_new_client(client_dcb);
} /**< while client_dcb != NULL */

View File

@ -37,20 +37,6 @@
#include <maxscale/maxadmin.h>
#include <maxscale/alloc.h>
/* @see function load_module in load_utils.c for explanation of the following
* lint directives.
*/
/*lint -e14 */
MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_GA,
GWPROTOCOL_VERSION,
"A maxscale protocol for the administration interface",
"V2.0.0"
};
/*lint +e14 */
/**
* @file maxscaled.c - MaxScale administration protocol
*
@ -170,27 +156,6 @@ static bool authenticate_socket(MAXSCALED *protocol, DCB *dcb)
return authenticated;
}
/**
* The "module object" for the maxscaled protocol module.
*/
static GWPROTOCOL MyObject =
{
maxscaled_read_event, /**< Read - EPOLLIN handler */
maxscaled_write, /**< Write - data from gateway */
maxscaled_write_event, /**< WriteReady - EPOLLOUT handler */
maxscaled_error, /**< Error - EPOLLERR handler */
maxscaled_hangup, /**< HangUp - EPOLLHUP handler */
maxscaled_accept, /**< Accept */
NULL, /**< Connect */
maxscaled_close, /**< Close */
maxscaled_listen, /**< Create a listener */
NULL, /**< Authentication */
NULL, /**< Session */
mxsd_default_auth, /**< Default authenticator */
NULL /**< Connection limit reached */
};
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -199,10 +164,38 @@ static GWPROTOCOL MyObject =
*
* @return The module object
*/
GWPROTOCOL* GetModuleObject()
MODULE_INFO* GetModuleObject()
{
MXS_INFO("Initialise MaxScaled Protocol module.");
return &MyObject;
static GWPROTOCOL MyObject =
{
maxscaled_read_event, /**< Read - EPOLLIN handler */
maxscaled_write, /**< Write - data from gateway */
maxscaled_write_event, /**< WriteReady - EPOLLOUT handler */
maxscaled_error, /**< Error - EPOLLERR handler */
maxscaled_hangup, /**< HangUp - EPOLLHUP handler */
maxscaled_accept, /**< Accept */
NULL, /**< Connect */
maxscaled_close, /**< Close */
maxscaled_listen, /**< Create a listener */
NULL, /**< Authentication */
NULL, /**< Session */
mxsd_default_auth, /**< Default authenticator */
NULL /**< Connection limit reached */
};
static MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_GA,
GWPROTOCOL_VERSION,
"A maxscale protocol for the administration interface",
"V2.0.0",
&MyObject
};
return &info;
}
/*lint +e14 */
@ -343,7 +336,7 @@ static int maxscaled_accept(DCB *listener)
socklen_t len = sizeof(struct ucred);
struct ucred ucred;
while ((client_dcb = dcb_accept(listener, &MyObject)) != NULL)
while ((client_dcb = dcb_accept(listener)) != NULL)
{
MAXSCALED *maxscaled_protocol = (MAXSCALED *)calloc(1, sizeof(MAXSCALED));

View File

@ -33,20 +33,6 @@
#include <maxscale/log_manager.h>
#include <maxscale/modinfo.h>
/* @see function load_module in load_utils.c for explanation of the following
* lint directives.
*/
/*lint -e14 */
MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_GA,
GWPROTOCOL_VERSION,
"A telnet deamon protocol for simple administration interface",
"V1.1.1"
};
/*lint +e14 */
/**
* @file telnetd.c - telnet daemon protocol module
*
@ -82,22 +68,7 @@ static char *telnetd_default_auth();
/**
* The "module object" for the telnetd protocol module.
*/
static GWPROTOCOL MyObject =
{
telnetd_read_event, /**< Read - EPOLLIN handler */
telnetd_write, /**< Write - data from gateway */
telnetd_write_event, /**< WriteReady - EPOLLOUT handler */
telnetd_error, /**< Error - EPOLLERR handler */
telnetd_hangup, /**< HangUp - EPOLLHUP handler */
telnetd_accept, /**< Accept */
NULL, /**< Connect */
telnetd_close, /**< Close */
telnetd_listen, /**< Create a listener */
NULL, /**< Authentication */
NULL, /**< Session */
telnetd_default_auth, /**< Default authenticator */
NULL /**< Connection limit reached */
};
static void telnetd_command(DCB *, unsigned char *cmd);
static void telnetd_echo(DCB *dcb, int enable);
@ -110,10 +81,37 @@ static void telnetd_echo(DCB *dcb, int enable);
*
* @return The module object
*/
GWPROTOCOL* GetModuleObject()
MODULE_INFO* GetModuleObject()
{
MXS_INFO("Initialise Telnetd Protocol module.");
return &MyObject;
static GWPROTOCOL MyObject =
{
telnetd_read_event, /**< Read - EPOLLIN handler */
telnetd_write, /**< Write - data from gateway */
telnetd_write_event, /**< WriteReady - EPOLLOUT handler */
telnetd_error, /**< Error - EPOLLERR handler */
telnetd_hangup, /**< HangUp - EPOLLHUP handler */
telnetd_accept, /**< Accept */
NULL, /**< Connect */
telnetd_close, /**< Close */
telnetd_listen, /**< Create a listener */
NULL, /**< Authentication */
NULL, /**< Session */
telnetd_default_auth, /**< Default authenticator */
NULL /**< Connection limit reached */
};
static MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_GA,
GWPROTOCOL_VERSION,
"A telnet deamon protocol for simple administration interface",
"V1.1.1",
&MyObject
};
return &info;
}
/*lint +e14 */
@ -268,7 +266,7 @@ static int telnetd_accept(DCB *listener)
int n_connect = 0;
DCB *client_dcb;
while ((client_dcb = dcb_accept(listener, &MyObject)) != NULL)
while ((client_dcb = dcb_accept(listener)) != NULL)
{
TELNETD* telnetd_protocol = NULL;

View File

@ -30,20 +30,6 @@
#include <maxscale/buffer.h>
#include <maxscale/gw_protocol.h>
/* @see function load_module in load_utils.c for explanation of the following
* lint directives.
*/
/*lint -e14 */
MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_IN_DEVELOPMENT,
GWPROTOCOL_VERSION,
"Test protocol",
"V1.1.0"
};
/*lint +e14 */
static int test_read(DCB* dcb){ return 1;}
static int test_write(DCB *dcb, GWBUF* buf){ return 1;}
static int test_write_ready(DCB *dcb){ return 1;}
@ -57,25 +43,6 @@ static int test_auth(DCB* dcb, struct server *srv, struct session *ses, GWBUF *b
static int test_session(DCB *dcb, void* data){ return 1;}
static char *test_default_auth(){return "NullAuthAllow";}
static int test_connection_limit(DCB *dcb, int limit){return 0;}
/**
* The "module object" for the httpd protocol module.
*/
static GWPROTOCOL MyObject =
{
test_read, /**< Read - EPOLLIN handler */
test_write, /**< Write - data from gateway */
test_write_ready, /**< WriteReady - EPOLLOUT handler */
test_error, /**< Error - EPOLLERR handler */
test_hangup, /**< HangUp - EPOLLHUP handler */
test_accept, /**< Accept */
test_connect, /**< Connect */
test_close, /**< Close */
test_listen, /**< Create a listener */
test_auth, /**< Authentication */
test_session, /**< Session */
test_default_auth, /**< Default authenticator */
test_connection_limit /**< Connection limit */
};
/**
* The module entry point routine. It is this routine that
@ -85,8 +52,34 @@ static GWPROTOCOL MyObject =
*
* @return The module object
*/
GWPROTOCOL* GetModuleObject()
MODULE_INFO* GetModuleObject()
{
return &MyObject;
static GWPROTOCOL MyObject =
{
test_read, /**< Read - EPOLLIN handler */
test_write, /**< Write - data from gateway */
test_write_ready, /**< WriteReady - EPOLLOUT handler */
test_error, /**< Error - EPOLLERR handler */
test_hangup, /**< HangUp - EPOLLHUP handler */
test_accept, /**< Accept */
test_connect, /**< Connect */
test_close, /**< Close */
test_listen, /**< Create a listener */
test_auth, /**< Authentication */
test_session, /**< Session */
test_default_auth, /**< Default authenticator */
test_connection_limit /**< Connection limit */
};
static MODULE_INFO info =
{
MODULE_API_PROTOCOL,
MODULE_IN_DEVELOPMENT,
GWPROTOCOL_VERSION,
"Test protocol",
"V1.1.0",
&MyObject
};
return &info;
}
/*lint +e14 */