CTWave Connection Functions

Name

CTWave Connection Functions -- CTWave Connection object management functions.

Synopsis


#include ctwave/ctwave-connection.h


struct      CTWaveConnection;
CTWaveConnection* ctwave_connection_new     (CS_CONTEXT *context);
void        ctwave_connection_del           (CTWaveConnection *conn);

WaveResult  ctwave_connection_connect       ();
WaveResult  ctwave_connection_disconnect    (gboolean and_detach);
CTWaveConnection* ctwave_connection_get_active
                                            ();
gint        ctwave_connection_count         (CTWaveConnectionHolder *holder);
CTWaveConnection* ctwave_connection_find_free
                                            (CTWaveConnectionHolder *db);
WaveResult  ctwave_connection_poll          (CTWaveConnectionHolder *db);

WaveResult  ctwave_connection_setLocale     (CTWaveConnection *conn,
                                             const gchar *locName);
WaveResult  ctwave_connection_alloc         (CTWaveConnection *conn);
WaveResult  ctwave_connection_free          (CTWaveConnection *conn);
WaveResult  ctwave_connection_attach        (CTWaveConnection *conn,
                                             CTWaveConnectionHolder *db,
                                             const gchar *loc_name);
WaveResult  ctwave_connection_detach        (CTWaveConnection *conn);
WaveResult  ctwave_connection_release       (CTWaveConnection *conn);
WaveResult  ctwave_connection_activate      (CTWaveConnection *conn);
void        ctwave_connection_deactivate    (CTWaveConnection *conn);
gboolean    ctwave_connection_is_open       (CTWaveConnection *conn);
void        ctwave_connection_bind          (CTWaveConnection *conn,
                                             void *object);

WaveResult  ctwave_connection_start_trans   (CTWaveConnection *conn);
WaveResult  ctwave_connection_commit_trans  (CTWaveConnection *conn);
WaveResult  ctwave_connection_rollback_trans
                                            (CTWaveConnection *conn);

void        ctwave_connection_message       (int severity,
                                             char *text);
void        ctwave_connection_clear_error   ();
gboolean    ctwave_connection_is_error      ();

Description

These functions manage connections to Sybase.

Details

struct CTWaveConnection

struct CTWaveConnection {
  CTWaveConnectionHolder   *db;
  CS_CONTEXT               *context;
  CS_CONNECTION            *connection;

  gboolean                  has_transaction;
  gint                      has_error;

  void                     *object;
  CS_COMMAND               *client;
};

Use internals at your own risk.


ctwave_connection_new ()

CTWaveConnection* ctwave_connection_new     (CS_CONTEXT *context);

Creates a new CTWave Connection object.

context: CT-Lib context pointer.
Returns : The new CTWave Connection Object.


ctwave_connection_del ()

void        ctwave_connection_del           (CTWaveConnection *conn);

Destroys the specified CTWave Connection Object. Any transactions on the connection are rolled back and the object is connected to Sybase the connection is broken.

conn: CTWave Connection Object.


ctwave_connection_connect ()

WaveResult  ctwave_connection_connect       ();

Initiates a connection to Sybase. The currently active CTWave Database object is used. CTWave Database objects are activated using the function ctwave_database_activate.

Returns : WAVE_OK or WAVE_FAIL.


ctwave_connection_disconnect ()

WaveResult  ctwave_connection_disconnect    (gboolean and_detach);

Deactivates the current connection. If and_detach is TRUE then the connection to Sybase is broken and the connection is removed from the pool

and_detach: Disconnect from Sybase
Returns : WAVE_OK or WAVE_FAIL.


ctwave_connection_get_active ()

CTWaveConnection* ctwave_connection_get_active
                                            ();

Returns the first connection object from the list.

Returns : The CTWave Connection Object or NULL.


ctwave_connection_count ()

gint        ctwave_connection_count         (CTWaveConnectionHolder *holder);

Counts the number of connections associated with the specified CTWave Connection Holder Object.

holder: CTWave Connection Holder Object.
Returns : The number of connections.


ctwave_connection_find_free ()

CTWaveConnection* ctwave_connection_find_free
                                            (CTWaveConnectionHolder *db);

Scans the connection list of the specified CTWave Connection Holder Object and adjusts the list for optimal size.

db: CTWave Connection Holder Object.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_connection_poll ()

WaveResult  ctwave_connection_poll          (CTWaveConnectionHolder *db);

db: 
Returns : 


ctwave_connection_setLocale ()

WaveResult  ctwave_connection_setLocale     (CTWaveConnection *conn,
                                             const gchar *locName);

conn: 
locName: 
Returns : 


ctwave_connection_alloc ()

WaveResult  ctwave_connection_alloc         (CTWaveConnection *conn);

Allocates a CT-Lib connection, ie. ct_con_alloc.

conn: CTWave Connection Object.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_connection_free ()

WaveResult  ctwave_connection_free          (CTWaveConnection *conn);

Deallocates a CT-Lib connection, ie. ct_con_drop.

conn: CTWave Connection Object.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_connection_attach ()

WaveResult  ctwave_connection_attach        (CTWaveConnection *conn,
                                             CTWaveConnectionHolder *db,
                                             const gchar *loc_name);

Attaches the specfied CTWave Connection Object to the named CTWave Connection Holder Object. Then attempts to initiate a connection to Sybase.

conn: CTWave Connection Object.
db: CTWave Connection Holder Object.
loc_name: Locale name (CS_LOCALE).
Returns : WAVE_OK or WAVE_FAIL.


ctwave_connection_detach ()

WaveResult  ctwave_connection_detach        (CTWaveConnection *conn);

Detaches the specfied CTWave Connection Object from its CTWave Connection Holder Object. Then closes the connection to Sybase.

conn: CTWave Connection Object.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_connection_release ()

WaveResult  ctwave_connection_release       (CTWaveConnection *conn);

Releases the specified CTWave Connection Object. Any transactions on the connection are rolled back and if the object is connected to Sybase the connection is broken.

conn: CTWave Connection Object.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_connection_activate ()

WaveResult  ctwave_connection_activate      (CTWaveConnection *conn);

Activates the specified CTWave Connection Object. The object is placed at the head of the connection list.

conn: CTWave Connection Object.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_connection_deactivate ()

void        ctwave_connection_deactivate    (CTWaveConnection *conn);

Deactivates the specified CTWave Connection Object by moving the object to the end of the connection list.

conn: CTWave Connection Object.


ctwave_connection_is_open ()

gboolean    ctwave_connection_is_open       (CTWaveConnection *conn);

Determines if the specified connection object is part of some ones connection list.

conn: CTWave Connection Object.
Returns : TRUE or FALSE.


ctwave_connection_bind ()

void        ctwave_connection_bind          (CTWaveConnection *conn,
                                             void *object);

Binds object to the CTWave Connection Object. This is used to make sure that the connection is deallocated.

conn: CTWave Connection Object.
object: object to bind.


ctwave_connection_start_trans ()

WaveResult  ctwave_connection_start_trans   (CTWaveConnection *conn);

Initiates a "begin transaction" on the current transaction. Sets the "has_transaction" flag TRUE.

conn: CTWave Connection Object.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_connection_commit_trans ()

WaveResult  ctwave_connection_commit_trans  (CTWaveConnection *conn);

Initiates a "commit work" on the current transaction. Sets the "has_transaction" flag FALSE.

conn: CTWave Connection Object.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_connection_rollback_trans ()

WaveResult  ctwave_connection_rollback_trans
                                            (CTWaveConnection *conn);

Initiates a "rollback work" on the current transaction. Sets the "has_transaction" flag FALSE.

conn: CTWave Connection Object.
Returns : WAVE_OK or WAVE_FAIL.


ctwave_connection_message ()

void        ctwave_connection_message       (int severity,
                                             char *text);

Calls g_log with the message text. The severity determines the message level.

severity: Message Severity Level.
text: Message Text.


ctwave_connection_clear_error ()

void        ctwave_connection_clear_error   ();

Sets the "has_error" flag FALSE for the current active connection.


ctwave_connection_is_error ()

gboolean    ctwave_connection_is_error      ();

Returns the "has_error" flag for the current active connection.

Returns : TRUE or FALSE.