-/* Static task callback prototypes */
-SILC_TASK_CALLBACK(silc_client_connect_to_server_start);
-SILC_TASK_CALLBACK(silc_client_connect_to_server_second);
-SILC_TASK_CALLBACK(silc_client_connect_to_server_final);
-SILC_TASK_CALLBACK(silc_client_rekey_callback);
-SILC_TASK_CALLBACK(silc_client_rekey_final);
-
-static bool silc_client_packet_parse(SilcPacketParserContext *parser_context,
- void *context);
-static void silc_client_packet_parse_type(SilcClient client,
- SilcSocketConnection sock,
- SilcPacketContext *packet);
-void silc_client_resolve_auth_method(bool success,
- SilcProtocolAuthMeth auth_meth,
- const unsigned char *auth_data,
- uint32 auth_data_len, void *context);
-
-/* Allocates new client object. This has to be done before client may
- work. After calling this one must call silc_client_init to initialize
- the client. The `application' is application specific user data pointer
- and caller must free it. */
-
-SilcClient silc_client_alloc(SilcClientOperations *ops,
- SilcClientParams *params,
- void *application,
- const char *silc_version)
-{
- SilcClient new_client;
-
- new_client = silc_calloc(1, sizeof(*new_client));
- new_client->application = application;
- new_client->ops = ops;
- new_client->silc_client_version = strdup(silc_version);
- new_client->params = silc_calloc(1, sizeof(*new_client->params));
-
- if (params)
- memcpy(new_client->params, params, sizeof(*params));
-
- if (!new_client->params->task_max)
- new_client->params->task_max = 200;
-
- if (!new_client->params->rekey_secs)
- new_client->params->rekey_secs = 3600;
-
- if (!new_client->params->connauth_request_secs)
- new_client->params->connauth_request_secs = 2;
-
- new_client->params->
- nickname_format[sizeof(new_client->params->nickname_format) - 1] = 0;
-
- return new_client;
-}
-
-/* Frees client object and its internals. */
-
-void silc_client_free(SilcClient client)
-{
- if (client) {
- if (client->rng)
- silc_rng_free(client->rng);
-
- silc_free(client->silc_client_version);
- silc_free(client->params);
- silc_free(client);
- }
-}
-
-/* Initializes the client. This makes all the necessary steps to make
- the client ready to be run. One must call silc_client_run to run the
- client. Returns FALSE if error occured, TRUE otherwise. */
-
-int silc_client_init(SilcClient client)
-{
- SILC_LOG_DEBUG(("Initializing client"));
-
- /* Initialize hash functions for client to use */
- silc_hash_alloc("md5", &client->md5hash);
- silc_hash_alloc("sha1", &client->sha1hash);
-
- /* Initialize none cipher */
- silc_cipher_alloc("none", &client->none_cipher);
-
- /* Initialize random number generator */
- client->rng = silc_rng_alloc();
- silc_rng_init(client->rng);
- silc_rng_global_init(client->rng);
-
- /* Register protocols */
- silc_client_protocols_register();
-
- /* Initialize the scheduler */
- client->schedule = silc_schedule_init(client->params->task_max ?
- client->params->task_max : 200);
- if (!client->schedule)
- return FALSE;
-
- return TRUE;
-}