- SILC_LOG_DEBUG(("Stopping client"));
-
- silc_schedule_stop(client->schedule);
- silc_schedule_uninit(client->schedule);
-
- silc_client_protocols_unregister();
- silc_client_commands_unregister(client);
-
- SILC_LOG_DEBUG(("Client stopped"));
-}
-
-/* Runs the client. This starts the scheduler from the utility library.
- When this functions returns the execution of the appliation is over. */
-
-void silc_client_run(SilcClient client)
-{
- SILC_LOG_DEBUG(("Running client"));
-
- /* Start the scheduler, the heart of the SILC client. When this returns
- the program will be terminated. */
- silc_schedule(client->schedule);
-}
-
-/* Runs the client and returns immeadiately. This function is used when
- the SILC Client object indicated by the `client' is run under some
- other scheduler, or event loop or main loop. On GUI applications,
- for example this may be desired to use to run the client under the
- GUI application's main loop. Typically the GUI application would
- register an idle task that calls this function multiple times in
- a second to quickly process the SILC specific data. */
-
-void silc_client_run_one(SilcClient client)
-{
- /* Run the scheduler once. */
- silc_schedule_one(client->schedule, 0);
-}
-
-static void silc_client_entry_destructor(SilcIDCache cache,
- SilcIDCacheEntry entry)
-{
- silc_free(entry->name);
-}
-
-/* Allocates and adds new connection to the client. This adds the allocated
- connection to the connection table and returns a pointer to it. A client
- can have multiple connections to multiple servers. Every connection must
- be added to the client using this function. User data `context' may
- be sent as argument. This function is normally used only if the
- application performed the connecting outside the library. The library
- however may use this internally. */
-
-SilcClientConnection silc_client_add_connection(SilcClient client,
- char *hostname,
- int port,
- void *context)
-{
- SilcClientConnection conn;
- int i;
-
- conn = silc_calloc(1, sizeof(*conn));
-
- /* Initialize ID caches */
- conn->client_cache = silc_idcache_alloc(0, SILC_ID_CLIENT,
- silc_client_entry_destructor);
- conn->channel_cache = silc_idcache_alloc(0, SILC_ID_CHANNEL, NULL);
- conn->server_cache = silc_idcache_alloc(0, SILC_ID_SERVER, NULL);
- conn->client = client;
- conn->remote_host = strdup(hostname);
- conn->remote_port = port;
- conn->context = context;
- conn->pending_commands = silc_dlist_init();
- conn->ftp_sessions = silc_dlist_init();
-
- /* Add the connection to connections table */
- for (i = 0; i < client->internal->conns_count; i++)
- if (client->internal->conns && !client->internal->conns[i]) {
- client->internal->conns[i] = conn;
- return conn;
- }
-
- client->internal->conns =
- silc_realloc(client->internal->conns, sizeof(*client->internal->conns)
- * (client->internal->conns_count + 1));
- client->internal->conns[client->internal->conns_count] = conn;
- client->internal->conns_count++;