+NOTE: These calls are performed only and only if application did not call
+silc_client_connect_to_server function, but performed the connecting
+process manually.
+
+
+1.5 Example Client
+
+This section includes an example SILC client implementation in pseudo-like
+C code. It creates and initializes the client and sets up an imaginary
+user interface. The user will use the user interface then to create
+the connections. The SilcClientOperations are expected to be implemented.
+
+#include "silcincludes.h"
+#include "silcapi.h"
+
+int main()
+{
+ SilcClientOperations ops = {
+ silc_say,
+ silc_channel_message,
+ silc_private_message,
+ silc_notify,
+ silc_command,
+ silc_command_reply,
+ silc_connect,
+ silc_disconnect,
+ silc_get_auth_method,
+ silc_verify_public_key,
+ silc_ask_passphrase,
+ silc_failure,
+ silc_key_agreement,
+ };
+
+ SilcClient client;
+
+ /* Allocate SILC client. The `silc_version_string' is defined
+ in includes/version.h file. */
+ client = silc_client_alloc(&ops, NULL, silc_version_string);
+
+ /* Register default ciphers, pkcs, hash funtions and hmacs. */
+ silc_cipher_register_default();
+ silc_pkcs_register_default();
+ silc_hash_register_default();
+ silc_hmac_register_default();
+
+ /* Set the mandatory pointers, read public and private key from
+ files (or somewhere) and return pointers and PKCS context. */
+ client->username = silc_get_username();
+ client->hostname = silc_net_localhost();
+ client->realname = silc_get_real_name();
+ client->pkcs = get_public_and_private_key(&client->public_key,
+ &client->private_key);
+
+ /* If the keys does not exist, create a key pair since we must
+ provide key pair to the library. */
+ if (!client->pkcs)
+ generate_key_new_key_pair(client);
+
+ /* Iinitialize client */
+ if (!silc_client_init(client))
+ fatal_error("Could not initialize client");
+
+ /* Initialize user interface. The user interface can be generally
+ initialized at any phase, including before actually allocating
+ and initializing the client, if wished. */
+ InitUserInterface();
+ DoCoolThings();
+
+ /* Start the client. This will start the scheduler. At this phase
+ the user might have the user interface in front of him already.
+ He will use the user interface to create the connection to the
+ server for example. When this function returns the program is
+ ended. */
+ silc_client_run(client);
+
+ /* Client is ended */
+ return 0;
+}