int flom_handle_set_unicast_address(flom_handle_t *handle, const char *value) { FLOM_TRACE(("flom_handle_set_unicast_address: " "old value='%s', new value='%s'\n", STRORNULL(flom_config_get_unicast_address(handle->config)), STRORNULL(value))); switch (handle->state) { case FLOM_HANDLE_STATE_INIT: case FLOM_HANDLE_STATE_DISCONNECTED: flom_config_set_unicast_address(handle->config, (const gchar *)value); /* reset socket name and multicast address*/ if (NULL != value) { flom_handle_set_socket_name(handle, NULL); flom_handle_set_multicast_address(handle, NULL); } /* if (NULL != value) */ break; default: FLOM_TRACE(("flom_handle_set_unicast_address: state %d " \ "is not compatible with set operation\n", handle->state)); return FLOM_RC_API_IMMUTABLE_HANDLE; } /* switch (handle->state) */ return FLOM_RC_OK; }
void flom_handle_set_trace_filename(flom_handle_t *handle, const char *value) { FLOM_TRACE(("flom_handle_set_trace_filename: " "old value='%s', new value='%s'\n", STRORNULL(flom_config_get_command_trace_file(handle->config)), STRORNULL(value))); flom_config_set_command_trace_file(handle->config, (const gchar *)value); }
int flom_handle_set_resource_name(flom_handle_t *handle, const char *value) { FLOM_TRACE(("flom_handle_set_resource_name: " "old value='%s', new value='%s'\n", STRORNULL(flom_config_get_resource_name(handle->config)), STRORNULL(value))); return flom_config_set_resource_name(handle->config, (const gchar *)value); }
int flom_handle_set_trace_filename(flom_handle_t *handle, const char *value) { FLOM_TRACE(("flom_handle_set_trace_filename: " "old value='%s', new value='%s'\n", STRORNULL(flom_config_get_command_trace_file(handle->config)), STRORNULL(value))); flom_config_set_command_trace_file(handle->config, (const gchar *)value); FLOM_TRACE_REOPEN(flom_config_get_command_trace_file(handle->config), FALSE); return FLOM_RC_OK; }
void flom_handle_set_unicast_address(flom_handle_t *handle, const char *value) { FLOM_TRACE(("flom_handle_set_unicast_address: " "old value='%s', new value='%s'\n", STRORNULL(flom_config_get_unicast_address(handle->config)), STRORNULL(value))); flom_config_set_unicast_address(handle->config, (const gchar *)value); /* reset socket name and multicast address*/ if (NULL != value) { flom_handle_set_socket_name(handle, NULL); flom_handle_set_multicast_address(handle, NULL); } /* if (NULL != value) */ }
const char *flom_handle_get_trace_filename(const flom_handle_t *handle) { FLOM_TRACE(("flom_handle_get_trace_filename: value='%s'\n", STRORNULL(flom_config_get_command_trace_file( handle->config)))); return (const char *)flom_config_get_command_trace_file(handle->config); }
const char *flom_handle_get_tls_ca_certificate(const flom_handle_t *handle) { FLOM_TRACE(("flom_handle_get_tls_ca_certificate: value='%s'\n", STRORNULL( flom_config_get_tls_ca_certificate(handle->config)))); return (const char *)flom_config_get_tls_ca_certificate(handle->config); }
int flom_handle_set_resource_name(flom_handle_t *handle, const char *value) { FLOM_TRACE(("flom_handle_set_resource_name: " "old value='%s', new value='%s'\n", STRORNULL(flom_config_get_resource_name(handle->config)), STRORNULL(value))); switch (handle->state) { case FLOM_HANDLE_STATE_INIT: case FLOM_HANDLE_STATE_DISCONNECTED: case FLOM_HANDLE_STATE_CONNECTED: flom_config_set_resource_name(handle->config, (const gchar *)value); break; default: FLOM_TRACE(("flom_handle_set_resource_name: state %d " \ "is not compatible with set operation\n", handle->state)); return FLOM_RC_API_IMMUTABLE_HANDLE; } /* switch (handle->state) */ return FLOM_RC_OK; }
int flom_handle_set_tls_private_key(flom_handle_t *handle, const char *value) { int ret_cod; FLOM_TRACE(("flom_handle_set_tls_private_key: " "old value='%s', new value='%s'\n", STRORNULL(flom_config_get_tls_private_key(handle->config)), STRORNULL(value))); switch (handle->state) { case FLOM_HANDLE_STATE_INIT: case FLOM_HANDLE_STATE_DISCONNECTED: ret_cod = flom_config_set_tls_private_key(handle->config, (const gchar *)value); break; default: FLOM_TRACE(("flom_handle_set_tls_private_key: state %d " \ "is not compatible with set operation\n", handle->state)); ret_cod = FLOM_RC_API_IMMUTABLE_HANDLE; } /* switch (handle->state) */ return ret_cod; }
const char *flom_handle_get_unicast_address(const flom_handle_t *handle) { FLOM_TRACE(("flom_handle_get_unicast_address: value='%s'\n", STRORNULL(flom_config_get_unicast_address(handle->config)))); return (const char *)flom_config_get_unicast_address(handle->config); }
const char *flom_handle_get_socket_name(const flom_handle_t *handle) { FLOM_TRACE(("flom_handle_get_socket_name: value='%s'\n", STRORNULL(flom_config_get_socket_name(handle->config)))); return (const char *)flom_config_get_socket_name(handle->config); }
/** * This is a private library function, not exposed in the interface, that's * used both by @ref flom_handle_unlock and by * @ref flom_handle_unlock_rollback . * See above functions for more details. * @param handle (Input/Output): a valid object handle * @param rollback: a boolean value, TRUE means the state of the transactional * resource must be backed out * @return a reason code */ int flom_handle_unlock_internal(flom_handle_t *handle, int rollback) { enum Exception { NULL_OBJECT , API_INVALID_SEQUENCE , OBJ_CORRUPTED , CLIENT_UNLOCK_ERROR , CLIENT_DISCONNECT_ERROR , RESOURCE_IS_NOT_TRANSACTIONAL , NONE } excp; int ret_cod = FLOM_RC_INTERNAL_ERROR; /* check flom library is initialized */ if (FLOM_RC_OK != (ret_cod = flom_init_check())) return ret_cod; FLOM_TRACE(("flom_handle_unlock_internal: rollback=%d\n", rollback)); TRY { flom_conn_t *conn = NULL; int ignored_rollback = FALSE; /* check handle is not NULL */ if (NULL == handle) THROW(NULL_OBJECT); /* cast and retrieve conn fron the proxy object */ conn = (flom_conn_t *)handle->conn; /* check handle state */ if (FLOM_HANDLE_STATE_LOCKED != handle->state && FLOM_HANDLE_STATE_CONNECTED != handle->state) { FLOM_TRACE(("flom_handle_unlock_internal: handle->state=%d\n", handle->state)); THROW(API_INVALID_SEQUENCE); } /* check the connection data pointer is not NULL (we can't be sure it's a valid pointer) */ if (NULL == handle->conn) THROW(OBJ_CORRUPTED); /* check transactionality */ if (rollback) { int transactional = flom_rsrc_get_transactional( flom_config_get_resource_name(handle->config)); if (!transactional) { FLOM_TRACE(("flom_handle_unlock_internal: asked rollback for " "a non transactional resource ('%s'), " "ignoring...\n", STRORNULL(flom_config_get_resource_name( handle->config)))); ignored_rollback = TRUE; /* overwrite rollback parameter */ rollback = FALSE; } } if (FLOM_HANDLE_STATE_LOCKED == handle->state) { /* lock release */ if (FLOM_RC_OK != (ret_cod = flom_client_unlock( handle->config, conn, rollback))) THROW(CLIENT_UNLOCK_ERROR); /* state update */ handle->state = FLOM_HANDLE_STATE_CONNECTED; } else { FLOM_TRACE(("flom_handle_unlock_internal: resource already " "unlocked (%d), skipping...\n", handle->state)); } /* gracefully disconnect from daemon */ if (FLOM_RC_OK != (ret_cod = flom_client_disconnect(conn))) THROW(CLIENT_DISCONNECT_ERROR); /* free locked element name is allocated */ g_free(handle->locked_element); handle->locked_element = NULL; /* state update */ handle->state = FLOM_HANDLE_STATE_DISCONNECTED; if (ignored_rollback) THROW(RESOURCE_IS_NOT_TRANSACTIONAL); THROW(NONE); } CATCH { switch (excp) { case NULL_OBJECT: ret_cod = FLOM_RC_NULL_OBJECT; break; case API_INVALID_SEQUENCE: ret_cod = FLOM_RC_API_INVALID_SEQUENCE; break; case OBJ_CORRUPTED: ret_cod = FLOM_RC_OBJ_CORRUPTED; break; case CLIENT_UNLOCK_ERROR: case CLIENT_DISCONNECT_ERROR: break; case NONE: ret_cod = FLOM_RC_OK; break; case RESOURCE_IS_NOT_TRANSACTIONAL: ret_cod = FLOM_RC_RESOURCE_IS_NOT_TRANSACTIONAL; break; default: ret_cod = FLOM_RC_INTERNAL_ERROR; } /* switch (excp) */ } /* TRY-CATCH */ FLOM_TRACE(("flom_handle_unlock_internal/excp=%d/" "ret_cod=%d/errno=%d\n", excp, ret_cod, errno)); return ret_cod; }
const char *flom_handle_get_tls_private_key(const flom_handle_t *handle) { FLOM_TRACE(("flom_handle_get_tls_private_key: value='%s'\n", STRORNULL(flom_config_get_tls_private_key(handle->config)))); return (const char *)flom_config_get_tls_private_key(handle->config); }