X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcclient%2Fcommand.c;h=935e5fd03c6186c5c2209ac40effb67ecb90c6f9;hb=40f8443d8d3a6577336ee66d18e04d9ac4d956bb;hp=e2537fe69ca3b2a7a5daf0347e83ef4f63895531;hpb=c257b555225193e54d85daf541d29578b3c93882;p=silc.git diff --git a/lib/silcclient/command.c b/lib/silcclient/command.c index e2537fe6..935e5fd0 100644 --- a/lib/silcclient/command.c +++ b/lib/silcclient/command.c @@ -18,7 +18,7 @@ */ /* $Id$ */ -#include "silcincludes.h" +#include "silc.h" #include "silcclient.h" #include "client_internal.h" @@ -80,7 +80,7 @@ SilcClientCommand silc_client_command_find(SilcClient client, /* Executes a command */ -bool silc_client_command_call(SilcClient client, +SilcBool silc_client_command_call(SilcClient client, SilcClientConnection conn, const char *command_line, ...) { @@ -286,7 +286,7 @@ SILC_CLIENT_CMD_FUNC(whois) SilcBuffer buffer, attrs = NULL; unsigned char count[4], *tmp = NULL; int i; - bool details = FALSE, nick = FALSE; + SilcBool details = FALSE, nick = FALSE; unsigned char *pubkey = NULL; if (!cmd->conn) { @@ -1190,7 +1190,7 @@ SILC_CLIENT_CMD_FUNC(join) } else if (!strcasecmp(cmd->argv[i], "-auth")) { SilcPublicKey pubkey = cmd->client->public_key; SilcPrivateKey privkey = cmd->client->private_key; - unsigned char *pk, pkhash[20], *pubdata; + unsigned char *pk, pkhash[SILC_HASH_MAXLEN], *pubdata; SilcUInt32 pk_len; if (cmd->argc >= i + 3) { @@ -1664,7 +1664,7 @@ SILC_CLIENT_CMD_FUNC(cmode) case 'C': if (add) { int k; - bool chadd = FALSE; + SilcBool chadd = FALSE; SilcPublicKey chpk = NULL; mode |= SILC_CHANNEL_MODE_CHANNEL_AUTH; @@ -2327,7 +2327,7 @@ SILC_CLIENT_CMD_FUNC(watch) SilcBuffer buffer, idp = NULL, args = NULL; int type = 0; const char *pubkey = NULL; - bool pubkey_add = TRUE; + SilcBool pubkey_add = TRUE; if (!cmd->conn) { SILC_NOT_CONNECTED(cmd->client, cmd->conn); @@ -2624,6 +2624,47 @@ SILC_CLIENT_CMD_FUNC(getkey) silc_client_command_free(cmd); } +/* Command SERVICE. Negotiates service agreement with server. */ +/* XXX incomplete */ + +SILC_CLIENT_CMD_FUNC(service) +{ + SilcClientCommandContext cmd = (SilcClientCommandContext)context; + SilcClientConnection conn = cmd->conn; + SilcBuffer buffer; + char *name; + + if (!cmd->conn) { + SILC_NOT_CONNECTED(cmd->client, cmd->conn); + COMMAND_ERROR(SILC_STATUS_ERR_NOT_REGISTERED); + goto out; + } + + if (cmd->argc < 2) { + SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, + "Usage: /SERVICE [] [-pubkey]"); + COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS); + goto out; + } + + name = cmd->argv[1]; + + /* Send SERVICE command to the server */ + buffer = silc_command_payload_encode_va(SILC_COMMAND_SERVICE, + ++conn->cmd_ident, 1, + 1, name, strlen(name)); + silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND, + NULL, 0, NULL, NULL, buffer->data, + buffer->len, TRUE); + silc_buffer_free(buffer); + + /* Notify application */ + COMMAND(SILC_STATUS_OK); + + out: + silc_client_command_free(cmd); +} + /* Register a new command indicated by the `command' to the SILC client. The `name' is optional command name. If provided the command may be searched using the silc_client_command_find by that name. The @@ -2637,7 +2678,7 @@ SILC_CLIENT_CMD_FUNC(getkey) command identifier `ident'. Application usually does not need it and set it to zero value. */ -bool silc_client_command_register(SilcClient client, +SilcBool silc_client_command_register(SilcClient client, SilcCommand command, const char *name, SilcCommandCb command_function, @@ -2664,7 +2705,7 @@ bool silc_client_command_register(SilcClient client, `command_function' and command reply function `command_reply_function'. Returns TRUE if the command was found and unregistered. */ -bool silc_client_command_unregister(SilcClient client, +SilcBool silc_client_command_unregister(SilcClient client, SilcCommand command, SilcCommandCb command_function, SilcCommandCb command_reply_function, @@ -2847,6 +2888,7 @@ void silc_client_commands_register(SilcClient client) SILC_CLIENT_CMD(leave, LEAVE, "LEAVE", 2); SILC_CLIENT_CMD(users, USERS, "USERS", 2); SILC_CLIENT_CMD(getkey, GETKEY, "GETKEY", 2); + SILC_CLIENT_CMD(service, SERVICE, "SERVICE", 10); SILC_CLIENT_CMD(connect, PRIV_CONNECT, "CONNECT", 3); SILC_CLIENT_CMD(close, PRIV_CLOSE, "CLOSE", 3); @@ -2883,6 +2925,7 @@ void silc_client_commands_unregister(SilcClient client) SILC_CLIENT_CMDU(leave, LEAVE, "LEAVE"); SILC_CLIENT_CMDU(users, USERS, "USERS"); SILC_CLIENT_CMDU(getkey, GETKEY, "GETKEY"); + SILC_CLIENT_CMDU(service, SERVICE, "SERVICE"); SILC_CLIENT_CMDU(connect, PRIV_CONNECT, "CONNECT"); SILC_CLIENT_CMDU(close, PRIV_CLOSE, "CLOSE");