Example #1
0
static void
    demo_client_connection_annihilate (
    demo_client_connection_t * ( * self_p )  //  Reference to object reference
)
{

    demo_client_connection_t *
        self = *self_p;                 //  Dereferenced Reference to object reference

DEMO_CLIENT_CONNECTION_ASSERT_SANE (self);

//
if (self->alive) {
    demo_client_agent_connection_close (self->thread);
    while (self->alive) {
        //  Wait until we get back an CLOSED method, or timeout
        s_wait_for_methods (self, self->timeout, FALSE);
    }
}
icl_longstr_destroy (&self->server_properties);
icl_longstr_destroy (&self->mechanisms);
icl_longstr_destroy (&self->locales);
icl_longstr_destroy (&self->challenge);
smt_method_queue_destroy (&self->method_queue);
smt_thread_unlink (&self->thread);

}
Example #2
0
static void s_do_authenticated_port_scan (
    char *s_opt_host, char *s_opt_vhost, char *s_opt_user, char *s_opt_pass)
{
    int
        port;
    icl_longstr_t
        *auth_data;                     //  Authorisation data
    amq_client_connection_t
        *connection;
    icl_shortstr_t
        host;
    int
        brokers_found = 0;

    icl_console_out ("Scanning for all accessible brokers on %s (ports 5000-9999)", s_opt_host);
    auth_data = amq_client_connection_auth_plain (s_opt_user, s_opt_pass);
    for (port = 5000; port < 10000; port++) {
        icl_shortstr_fmt (host, "%s:%d", s_opt_host, port);
        connection = amq_client_connection_new (host, s_opt_vhost, auth_data, "amq_shell", 0, 1000);
        if (connection) {
            icl_console_out ("Found %s/%s on %s",
                connection->server_product, connection->server_version, host);
            brokers_found++;
            amq_client_connection_destroy (&connection);
        }
    }
    icl_longstr_destroy (&auth_data);
    if (!brokers_found)
        icl_console_out ("No accessible AMQP brokers found");
    exit (EXIT_SUCCESS);
}
Example #3
0
static void
    icl_demo_serial_annihilate (
    icl_demo_serial_t * ( * self_p )    //  Reference to object reference
)
{
#if (defined (BASE_THREADSAFE))
    icl_rwlock_t
        *rwlock;
#endif

    icl_demo_serial_t *
        self = *self_p;                 //  Dereferenced Reference to object reference

    ICL_DEMO_SERIAL_ASSERT_SANE (self);
#if (defined (BASE_THREADSAFE))
    rwlock = self->rwlock;
    if (rwlock)
         icl_rwlock_write_lock (rwlock);
#endif

icl_longstr_destroy (&self->item_options);
#if (defined (BASE_THREADSAFE))
    if (rwlock)
        icl_rwlock_unlock (rwlock);
#endif

}
Example #4
0
void
    asl_field_new_field_table_ (
    char * file,                        //  Source file for call
    size_t line,                        //  Line number for call
    asl_field_list_t * list,            //  Parent field list
    char * name,                        //  Field name
    asl_field_list_t * value            //  The value
)
{
asl_field_t
    *self;
icl_longstr_t
    *flattened;

//
assert (strlen (name) <= ASL_FIELD_NAME_MAX);

flattened = asl_field_list_flatten (value);
self = asl_field_new_ (file, line);
strcpy (self->name, name);
self->type   = ASL_FIELD_TYPE_FIELD_TABLE;
self->string = icl_longstr_dup (flattened);
asl_field_list_queue (list, self);
asl_field_unlink (&self);
icl_longstr_destroy (&flattened);
}
Example #5
0
static void
    asl_field_annihilate_ (
    asl_field_t * ( * self_p ),         //  Reference to object reference
    char * file,                        //  Source file
    size_t line                         //  Line number
)
{
#if defined (DEBUG) || defined (BASE_HISTORY) || defined (BASE_HISTORY_ASL_FIELD)
    int
        history_last;
#endif

    asl_field_t *
        self = *self_p;                 //  Dereferenced Reference to object reference

#if defined (DEBUG) || defined (BASE_HISTORY) || defined (BASE_HISTORY_ASL_FIELD)
    //  Track possession operation in history
    history_last = icl_atomic_inc32 ((volatile qbyte *) &self->history_last) + 1;
    self->history_file  [history_last % ASL_FIELD_HISTORY_LENGTH] = file;
    self->history_line  [history_last % ASL_FIELD_HISTORY_LENGTH] = line;
    self->history_type  [history_last % ASL_FIELD_HISTORY_LENGTH] = "destroy";
    self->history_links [history_last % ASL_FIELD_HISTORY_LENGTH] = self->links;
#endif

    ASL_FIELD_ASSERT_SANE (self);
    asl_field_remove_from_all_containers (self);

icl_longstr_destroy (&self->string);

}
Example #6
0
void free_amq_auth_cls( amq_auth_cls *obj) {
  if (obj && obj->auth) {
	icl_longstr_destroy(&(obj->auth));
    obj->auth=0;
  }
  if (obj)
    free(obj);
}
Example #7
0
        inline openamq_t (const char *host_, const char *send_rk_,
            const char *receive_rk_, bool direct)
        {
	    //  Store routing keys.
            strncpy (send_rk, send_rk_, 256);
	    strncpy (receive_rk, receive_rk_, 256);

            //  Initialise iCL.
            icl_system_initialise (0, NULL);

            //  Open a connection.
            icl_longstr_t *auth_data =
                amq_client_connection_auth_plain ("guest", "guest");
            connection = amq_client_connection_new (
                (char*) host_, "/", auth_data, "perf", 0, 30000);
            assert (connection);
            icl_longstr_destroy (&auth_data);

            //  Switch into direct mode if required.
            if (direct)
                connection->direct = TRUE;

            //  Open a channel.
            session = amq_client_session_new (connection);
            assert (session);

           //  Create a private queue.
           amq_client_session_queue_declare (
               session, 0, NULL, FALSE, FALSE, TRUE, TRUE, NULL);

           //  Bind the queue to the exchange.
           amq_client_session_queue_bind (session, 0, NULL, "amq.direct",
               (char*) receive_rk, NULL);

           //  Consume from the queue.
           amq_client_session_basic_consume (
               session, 0, NULL, NULL, TRUE, TRUE, TRUE, NULL);
        }
Example #8
0
void
    asl_field_selftest (
void)
{
asl_field_list_t
    *list,                          //  List of fields
    *embedded_list;                 //  List embedded in the top list
asl_field_t
    *field,                         //  One field in list
    *embedded_field;                //  Field in the embedded list
icl_longstr_t
    *string;                        //  Serialised field list

//
//  We create a new empty list by passing it a null string
//
list = asl_field_list_new (NULL);

//  To add fields to the list, we use these methods, which
//  do not return any values.
//
asl_field_new_string  (list, "string",  "ring a ding ding");
asl_field_new_integer (list, "integer", 123456789);
asl_field_new_decimal (list, "decimal", 123456789, 3);
asl_field_new_time    (list, "time",    123456789);
asl_field_new_void    (list, "void");
embedded_list = asl_field_list_new (NULL);
asl_field_new_string  (embedded_list, "string",  "hello world");
asl_field_new_integer (embedded_list, "integer", 654321);
asl_field_new_field_table (list, "table", embedded_list);
asl_field_list_unlink (&embedded_list);

//  When we want to send a field list, we flatten it into a
//  string, which the list_flatten method allocates for us.
//
string = asl_field_list_flatten (list);
asl_field_list_destroy (&list);

//  Let's recreate the list and check that it's correct
list = asl_field_list_new (string);

field = asl_field_list_search (list, "string");
assert (streq (asl_field_string (field), "ring a ding ding"));
asl_field_unlink (&field);

field = asl_field_list_search (list, "integer");
assert (asl_field_integer (field) == 123456789);
assert (streq (asl_field_string (field), "123456789"));
asl_field_unlink (&field);

field = asl_field_list_search (list, "decimal");
assert (asl_field_integer (field) == 123456);
assert (streq (asl_field_string (field), "123457"));
asl_field_unlink (&field);

field = asl_field_list_search (list, "time");
assert (asl_field_integer (field) == 123456789);
asl_field_unlink (&field);

field = asl_field_list_search (list, "void");
assert (asl_field_integer (field) == 0);
asl_field_unlink (&field);

field = asl_field_list_search (list, "table");
embedded_list = asl_field_field_table (field);
embedded_field = asl_field_list_search (embedded_list, "string");
assert (streq (asl_field_string (embedded_field), "hello world"));
asl_field_unlink (&embedded_field);
embedded_field = asl_field_list_search (embedded_list, "integer");
assert (asl_field_integer (embedded_field) == 654321);
asl_field_unlink (&embedded_field);
asl_field_list_unlink (&embedded_list);
asl_field_unlink (&field);

//  We must destroy the flat string when finished with it
asl_field_list_destroy (&list);
icl_longstr_destroy (&string);
}