00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "hsmsd_cnx_proxy.h"
00021 #include "hsmsd_cli.h"
00022
00023 using namespace freesecs;
00024
00025 int hsmsd_alloc_handle (hsmsd_handle_t *ph, const char *cnx_name)
00026 {
00027 try
00028 {
00029 *ph = (hsmsd_handle_t) new hsmsd_proxy_t(cnx_name);
00030 }
00031 catch(...)
00032 {
00033 return -1;
00034 }
00035 return 0;
00036 }
00037
00038 int hsmsd_free_handle (hsmsd_handle_t h)
00039 {
00040 hsmsd_proxy_t *cp = (hsmsd_proxy_t*)h;
00041 delete cp;
00042 return 0;
00043 }
00044
00045 int hsmsd_subscribe_for_msgs (hsmsd_handle_t h, hsmsd_msg_handler_t mh)
00046 {
00047 hsmsd_proxy_t *cp = (hsmsd_proxy_t*)h;
00048 return cp->set_msg_handler(mh);
00049 }
00050
00051 int hsmsd_unsubscribe_for_msgs (hsmsd_handle_t h)
00052 {
00053 hsmsd_proxy_t *cp = (hsmsd_proxy_t*)h;
00054 return cp->set_msg_handler(NULL);
00055 }
00056
00057 int hsmsd_subscribe_for_cnx_state (hsmsd_handle_t h, hsmsd_cnx_state_handler_t sh)
00058 {
00059 hsmsd_proxy_t *cp = (hsmsd_proxy_t*)h;
00060 return cp->set_cnx_state_handler(sh);
00061 }
00062
00063 int hsmsd_unsubscribe_for_cnx_state (hsmsd_handle_t h)
00064 {
00065 hsmsd_proxy_t *cp = (hsmsd_proxy_t*)h;
00066 return cp->set_cnx_state_handler(NULL);
00067 }
00068
00069 int hsmsd_subscribe_for_cnx_error (hsmsd_handle_t h, hsmsd_cnx_error_handler_t eh)
00070 {
00071 hsmsd_proxy_t *cp = (hsmsd_proxy_t*)h;
00072 return cp->set_cnx_error_handler(eh);
00073 }
00074
00075 int hsmsd_unsubscribe_for_cnx_error (hsmsd_handle_t h)
00076 {
00077 hsmsd_proxy_t *cp = (hsmsd_proxy_t*)h;
00078 return cp->set_cnx_error_handler(NULL);
00079 }
00080
00081 int hsmsd_cnx_start (hsmsd_handle_t h)
00082 {
00083 hsmsd_proxy_t *cp = (hsmsd_proxy_t*)h;
00084 return cp->start();
00085 }
00086
00087 int hsmsd_cnx_stop (hsmsd_handle_t h)
00088 {
00089 hsmsd_proxy_t *cp = (hsmsd_proxy_t*)h;
00090 return cp->stop();
00091 }
00092
00093 int hsmsd_cnx_get_state (hsmsd_handle_t h, hsmsd_cnx_state_t *pstate)
00094 {
00095 hsmsd_proxy_t *cp = (hsmsd_proxy_t*)h;
00096 return cp->get_state(pstate);
00097 }
00098
00099 int hsmsd_cnx_send_msg (hsmsd_handle_t h, hsmsd_msg_t *pmsg)
00100 {
00101 hsmsd_proxy_t *cp = (hsmsd_proxy_t*)h;
00102 return cp->send_msg(pmsg);
00103 }