00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <libstoragemgmt/libstoragemgmt_plug_interface.h>
00011 #include <stdlib.h>
00012 #include <stdint.h>
00013
00014 static char name[] = "Simple limited plug-in example";
00015 static char version [] = "0.01";
00016
00017 struct plugin_data {
00018 uint32_t tmo;
00019
00020 };
00021
00022
00023
00024 static int tmoSet(lsm_plugin_ptr c, uint32_t timeout, lsm_flag flags )
00025 {
00026 int rc = LSM_ERR_OK;
00027 struct plugin_data *pd = (struct plugin_data*)lsm_private_data_get(c);
00028
00029 pd->tmo = timeout;
00030 return rc;
00031 }
00032
00033 static int tmoGet(lsm_plugin_ptr c, uint32_t *timeout, lsm_flag flags )
00034 {
00035 int rc = LSM_ERR_OK;
00036 struct plugin_data *pd = (struct plugin_data*)lsm_private_data_get(c);
00037
00038 *timeout = pd->tmo;
00039 return rc;
00040 }
00041
00042
00043
00044 static struct lsm_mgmt_ops_v1 mgmOps = {
00045 tmoSet,
00046 tmoGet,
00047 NULL,
00048 NULL,
00049 NULL,
00050 NULL,
00051 NULL
00052 };
00053
00054 int load( lsm_plugin_ptr c, const char *uri, const char *password,
00055 uint32_t timeout, lsm_flag flags )
00056 {
00057
00058 struct plugin_data *data = (struct plugin_data *)
00059 malloc(sizeof(struct plugin_data));
00060
00061 if (!data) {
00062 return LSM_ERR_NO_MEMORY;
00063 }
00064
00065
00066 int rc = lsm_register_plugin_v1( c, data, &mgmOps, NULL, NULL, NULL);
00067 return rc;
00068 }
00069
00070 int unload( lsm_plugin_ptr c, lsm_flag flags)
00071 {
00072
00073 struct plugin_data *pd = (struct plugin_data*)lsm_private_data_get(c);
00074 free(pd);
00075 return LSM_ERR_OK;
00076 }
00077
00078 int main(int argc, char *argv[] )
00079 {
00080 return lsm_plugin_init_v1(argc, argv, load, unload, name, version);
00081 }