Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2006 Pekka Riikonen
+ Copyright (C) 1997 - 2007 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
SILC_FSM_STATE(silc_client_command_continue_error)
{
/* Destructor will free all resources */
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Command reply callback to continue with the execution of a command.
if (status != SILC_STATUS_OK)
silc_fsm_next(&cmd->thread, silc_client_command_continue_error);
- if (clients)
- silc_dlist_uninit(clients);
-
/* Continue with the command */
SILC_FSM_CALL_CONTINUE(&cmd->thread);
}
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
for (i = 1; i < cmd->argc; i++) {
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/******************************** WHOWAS ************************************/
"Usage: /WHOWAS <nickname>[@<server>] [<count>]");
COMMAND_ERROR((cmd->argc < 2 ? SILC_STATUS_ERR_NOT_ENOUGH_PARAMS :
SILC_STATUS_ERR_TOO_MANY_PARAMS));
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
if (cmd->argc == 2) {
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/******************************** IDENTIFY **********************************/
int c;
if (cmd->argc < 2 || cmd->argc > 3)
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
if (cmd->argc == 2) {
silc_client_command_send_va(conn, cmd, cmd->cmd, NULL, NULL,
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** NICK ************************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************** LIST ************************************/
{
SilcClientCommandContext cmd = fsm_context;
SilcClientConnection conn = cmd->conn;
- SilcChannelEntry channel;
+ SilcClient client = conn->client;
+ SilcChannelEntry channel = NULL;
SilcBuffer idp = NULL;
if (cmd->argc == 2) {
1, 1, silc_buffer_datalen(idp));
silc_buffer_free(idp);
+ silc_client_unref_channel(client, conn, channel);
/* Notify application */
COMMAND(SILC_STATUS_OK);
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** TOPIC ***********************************/
{
SilcClientCommandContext cmd = fsm_context;
SilcClientConnection conn = cmd->conn;
+ SilcClient client = conn->client;
SilcChannelEntry channel;
SilcBuffer idp;
char *name;
1, silc_buffer_datalen(idp));
silc_buffer_free(idp);
+ silc_client_unref_channel(client, conn, channel);
/* Notify application */
COMMAND(SILC_STATUS_OK);
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************* INVITE ***********************************/
SilcClientConnection conn = cmd->conn;
SilcClient client = conn->client;
SilcClientEntry client_entry = NULL;
- SilcChannelEntry channel;
+ SilcChannelEntry channel = NULL;
SilcBuffer clidp, chidp, args = NULL;
SilcPublicKey pubkey = NULL;
SilcDList clients = NULL;
}
channel = conn->current_channel;
+ silc_client_ref_channel(client, conn, channel);
} else {
name = cmd->argv[1];
silc_buffer_free(args);
silc_free(nickname);
silc_client_list_free(client, conn, clients);
+ silc_client_unref_channel(client, conn, channel);
/* Notify application */
COMMAND(SILC_STATUS_OK);
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
silc_free(nickname);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************** QUIT ************************************/
SILC_FSM_EVENT_SIGNAL(&conn->internal->wait_event);
}
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Command QUIT. Closes connection with current server. */
/* We close the connection with a little timeout */
silc_fsm_next_later(fsm, silc_client_command_quit_final, 2, 0);
- SILC_FSM_WAIT;
+ return SILC_FSM_WAIT;
}
/********************************** KILL ************************************/
SAY(conn->client, conn, SILC_CLIENT_MESSAGE_INFO,
"Usage: /KILL <nickname> [<comment>] [-pubkey]");
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Parse the typed nickname. */
if (!silc_client_nickname_parse(client, conn, cmd->argv[1], &nickname))
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
/* Get the target client */
clients = silc_client_get_clients_local(client, conn, nickname,
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** INFO ************************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** STATS ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** PING ************************************/
if (cmd->argc < 2) {
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Send the command */
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** JOIN ************************************/
{
SilcClientCommandContext cmd = fsm_context;
SilcClientConnection conn = cmd->conn;
- SilcChannelEntry channel;
+ SilcClient client = conn->client;
+ SilcChannelEntry channel = NULL;
SilcBuffer auth = NULL, cauth = NULL;
char *name, *passphrase = NULL, *pu8, *cipher = NULL, *hmac = NULL;
int i, passphrase_len = 0;
if (passphrase)
memset(passphrase, 0, strlen(passphrase));
silc_free(passphrase);
+ silc_client_unref_channel(client, conn, channel);
/* Notify application */
COMMAND(SILC_STATUS_OK);
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ silc_client_unref_channel(client, conn, channel);
+ return SILC_FSM_FINISH;
}
/********************************** MOTD ************************************/
"Usage: /MOTD [<server>]");
COMMAND_ERROR((cmd->argc < 1 ? SILC_STATUS_ERR_NOT_ENOUGH_PARAMS :
SILC_STATUS_ERR_TOO_MANY_PARAMS));
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Send the command */
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** UMODE ***********************************/
SAY(conn->client, conn, SILC_CLIENT_MESSAGE_INFO,
"Usage: /UMODE +|-<modes>");
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
mode = conn->local_entry->mode;
break;
default:
COMMAND_ERROR(SILC_STATUS_ERR_UNKNOWN_MODE);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
break;
}
}
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** CMODE ***********************************/
SilcClientCommandContext cmd = fsm_context;
SilcClientConnection conn = cmd->conn;
SilcClient client = conn->client;
- SilcChannelEntry channel;
+ SilcChannelEntry channel = NULL;
SilcBuffer chidp, auth = NULL, pk = NULL;
unsigned char *name, *cp, modebuf[4], tmp[4], *arg = NULL;
SilcUInt32 mode, add, type, len, arg_len = 0;
}
channel = conn->current_channel;
+ silc_client_ref_channel(client, conn, channel);
} else {
name = cmd->argv[1];
silc_buffer_free(chidp);
silc_buffer_free(auth);
silc_buffer_free(pk);
+ silc_client_unref_channel(client, conn, channel);
/* Notify application */
COMMAND(SILC_STATUS_OK);
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ silc_client_unref_channel(client, conn, channel);
+ return SILC_FSM_FINISH;
}
/********************************* CUMODE ***********************************/
SilcClientCommandContext cmd = fsm_context;
SilcClientConnection conn = cmd->conn;
SilcClient client = conn->client;
- SilcChannelEntry channel;
+ SilcChannelEntry channel = NULL;
SilcChannelUser chu;
SilcClientEntry client_entry;
SilcBuffer clidp, chidp, auth = NULL;
}
channel = conn->current_channel;
+ silc_client_ref_channel(client, conn, channel);
} else {
name = cmd->argv[1];
silc_buffer_free(auth);
silc_free(nickname);
silc_client_list_free(client, conn, clients);
+ silc_client_unref_channel(client, conn, channel);
/* Notify application */
COMMAND(SILC_STATUS_OK);
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
+ silc_client_unref_channel(client, conn, channel);
silc_client_list_free(client, conn, clients);
silc_free(nickname);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************** KICK ************************************/
SilcClientCommandContext cmd = fsm_context;
SilcClientConnection conn = cmd->conn;
SilcClient client = conn->client;
- SilcChannelEntry channel;
+ SilcChannelEntry channel = NULL;
SilcBuffer idp, idp2;
SilcClientEntry target;
SilcDList clients = NULL;
silc_buffer_free(idp2);
silc_free(nickname);
silc_client_list_free(client, conn, clients);
+ silc_client_unref_channel(client, conn, channel);
/* Notify application */
COMMAND(SILC_STATUS_OK);
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
+ silc_client_unref_channel(client, conn, channel);
silc_free(nickname);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/***************************** OPER & SILCOPER ******************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* OPER command. Used to obtain server operator privileges. */
SAY(conn->client, conn, SILC_CLIENT_MESSAGE_INFO,
"Usage: /OPER <username> [-pubkey]");
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Get passphrase */
if (cmd->argc < 3) {
oper = silc_calloc(1, sizeof(*oper));
if (!oper)
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
cmd->context = oper;
SILC_FSM_CALL(conn->client->internal->
ops->ask_passphrase(conn->client, conn,
}
silc_fsm_next(fsm, silc_client_command_oper_send);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* SILCOPER command. Used to obtain router operator privileges. */
SAY(conn->client, conn, SILC_CLIENT_MESSAGE_INFO,
"Usage: /SILCOPER <username> [-pubkey]");
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Get passphrase */
if (cmd->argc < 3) {
oper = silc_calloc(1, sizeof(*oper));
if (!oper)
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
cmd->context = oper;
SILC_FSM_CALL(conn->client->internal->
ops->ask_passphrase(conn->client, conn,
}
silc_fsm_next(fsm, silc_client_command_oper_send);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/*********************************** BAN ************************************/
{
SilcClientCommandContext cmd = fsm_context;
SilcClientConnection conn = cmd->conn;
+ SilcClient client = conn->client;
SilcChannelEntry channel;
SilcBuffer chidp, args = NULL;
char *name, *ban = NULL;
}
channel = conn->current_channel;
+ silc_client_ref_channel(client, conn, channel);
} else {
name = cmd->argv[1];
silc_buffer_free(chidp);
silc_buffer_free(args);
+ silc_client_unref_channel(client, conn, channel);
/* Notify application */
COMMAND(SILC_STATUS_OK);
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************* DETACH ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************** WATCH ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************** LEAVE ***********************************/
{
SilcClientCommandContext cmd = fsm_context;
SilcClientConnection conn = cmd->conn;
+ SilcClient client = conn->client;
SilcChannelEntry channel;
SilcBuffer idp;
char *name;
if (conn->current_channel == channel)
conn->current_channel = NULL;
+ silc_client_unref_channel(client, conn, channel);
+
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************** USERS ***********************************/
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
out:
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/********************************* GETKEY ***********************************/
client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_INFO,
"Usage: /GETKEY <nickname or server name>");
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Parse the typed nickname. */
if (!silc_client_nickname_parse(client, conn, cmd->argv[1], &nickname)) {
COMMAND_ERROR(SILC_STATUS_ERR_RESOURCE_LIMIT);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Find client entry */
errors are handled in the resolving callback. */
COMMAND_ERROR(SILC_STATUS_ERR_NO_SUCH_NICK);
COMMAND_ERROR(SILC_STATUS_ERR_NO_SUCH_SERVER);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* No client or server exist with this name, query for both. */
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/********************************* SERVICE **********************************/
SAY(conn->client, conn, SILC_CLIENT_MESSAGE_INFO,
"Usage: /SERVICE [<service name>] [-pubkey]");
COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
name = cmd->argv[1];
/** Wait for command reply */
silc_fsm_next(fsm, silc_client_command_reply_wait);
- SILC_FSM_CONTINUE;
+ return SILC_FSM_CONTINUE;
}
/* Register all default commands provided by the client library for the
silc_buffer_len(&packet->buffer));
if (!payload) {
SILC_LOG_DEBUG(("Bad command packet"));
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}
/* Get arguments */
}
silc_command_payload_free(payload);
- SILC_FSM_FINISH;
+ return SILC_FSM_FINISH;
}