*/
/* $Id$ */
-#include "silcincludes.h"
+#include "silc.h"
#include "silcclient.h"
#include "client_internal.h"
/* Executes a command */
-bool silc_client_command_call(SilcClient client,
+SilcBool silc_client_command_call(SilcClient client,
SilcClientConnection conn,
const char *command_line, ...)
{
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) {
} 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) {
case 'C':
if (add) {
int k;
- bool chadd = FALSE;
+ SilcBool chadd = FALSE;
SilcPublicKey chpk = NULL;
mode |= SILC_CHANNEL_MODE_CHANNEL_AUTH;
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);
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 [<service name>] [-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
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,
`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,
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);
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");