SilcCommandPayload payload;
/* Get command reply payload from packet */
- payload = silc_command_parse_payload(buffer);
+ payload = silc_command_payload_parse(buffer);
if (!payload) {
/* Silently ignore bad reply packet */
SILC_LOG_DEBUG(("Bad command reply packet"));
ctx->client = client;
ctx->sock = sock;
ctx->payload = payload;
+ ctx->args = silc_command_get_args(ctx->payload);
ctx->packet = packet;
/* Check for pending commands and mark to be exeucted */
memset(buf, 0, sizeof(buf));
- argc = silc_command_get_arg_num(cmd->payload);
- id_data = silc_command_get_arg_type(cmd->payload, 2, NULL);
+ argc = silc_argument_get_arg_num(cmd->args);
+ id_data = silc_argument_get_arg_type(cmd->args, 2, NULL);
- nickname = silc_command_get_arg_type(cmd->payload, 3, &len);
+ nickname = silc_argument_get_arg_type(cmd->args, 3, &len);
if (nickname) {
strncat(buf, nickname, len);
strncat(buf, " is ", 4);
}
- username = silc_command_get_arg_type(cmd->payload, 4, &len);
+ username = silc_argument_get_arg_type(cmd->args, 4, &len);
if (username) {
strncat(buf, username, len);
}
- realname = silc_command_get_arg_type(cmd->payload, 5, &len);
+ realname = silc_argument_get_arg_type(cmd->args, 5, &len);
if (realname) {
strncat(buf, " (", 2);
strncat(buf, realname, len);
SILC_LOG_DEBUG(("Start"));
- tmp = silc_command_get_arg_type(cmd->payload, 1, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK &&
status != SILC_STATUS_LIST_START &&
status != SILC_STATUS_LIST_END) {
if (status == SILC_STATUS_ERR_NO_SUCH_NICK) {
/* Take nickname which may be provided */
- tmp = silc_command_get_arg_type(cmd->payload, 3, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 3, NULL);
if (tmp)
cmd->client->ops->say(cmd->client, conn, "%s: %s", tmp,
silc_client_command_status_message(status));
SILC_LOG_DEBUG(("Start"));
- tmp = silc_command_get_arg_type(cmd->payload, 1, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
if (status == SILC_STATUS_ERR_NO_SUCH_NICK) {
/* Take nickname which may be provided */
- tmp = silc_command_get_arg_type(cmd->payload, 3, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 3, NULL);
if (tmp)
cmd->client->ops->say(cmd->client, conn, "%s: %s", tmp,
silc_client_command_status_message(status));
unsigned char *id_data;
char *nickname;
- id_data = silc_command_get_arg_type(cmd->payload, 2, NULL);
- nickname = silc_command_get_arg_type(cmd->payload, 3, NULL);
+ id_data = silc_argument_get_arg_type(cmd->args, 2, NULL);
+ nickname = silc_argument_get_arg_type(cmd->args, 3, NULL);
/* Allocate client entry */
client_entry = silc_calloc(1, sizeof(*client_entry));
SILC_LOG_DEBUG(("Start"));
- tmp = silc_command_get_arg_type(cmd->payload, 1, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
cmd->client->ops->say(cmd->client, conn, "Cannot set nickname: %s",
goto out;
}
- argc = silc_command_get_arg_num(cmd->payload);
+ argc = silc_argument_get_arg_num(cmd->args);
if (argc < 2 || argc > 2) {
cmd->client->ops->say(cmd->client, conn,
"Cannot set nickname: bad reply to command");
}
/* Take received Client ID */
- id_string = silc_command_get_arg_type(cmd->payload, 2, NULL);
+ id_string = silc_argument_get_arg_type(cmd->args, 2, NULL);
silc_client_receive_new_id(cmd->client, cmd->sock, id_string);
/* Notify application */
char *topic;
int argc;
- tmp = silc_command_get_arg_type(cmd->payload, 1, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
cmd->client->ops->say(cmd->client, conn,
return;
}
- argc = silc_command_get_arg_num(cmd->payload);
+ argc = silc_argument_get_arg_num(cmd->args);
if (argc < 1 || argc > 3) {
COMMAND_REPLY_ERROR;
goto out;
}
/* Take Channel ID */
- id_string = silc_command_get_arg_type(cmd->payload, 2, NULL);
+ id_string = silc_argument_get_arg_type(cmd->args, 2, NULL);
if (!id_string)
goto out;
channel_id = silc_id_str2id(id_string, SILC_ID_CHANNEL);
/* Take topic */
- topic = silc_command_get_arg_type(cmd->payload, 3, NULL);
+ topic = silc_argument_get_arg_type(cmd->args, 3, NULL);
if (!topic)
goto out;
SilcCommandStatus status;
unsigned char *tmp;
- tmp = silc_command_get_arg_type(cmd->payload, 1, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
cmd->client->ops->say(cmd->client, conn,
SilcCommandStatus status;
unsigned char *tmp;
- tmp = silc_command_get_arg_type(cmd->payload, 1, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
cmd->client->ops->say(cmd->client, conn,
}
/* Get server ID */
- tmp = silc_command_get_arg_type(cmd->payload, 2, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 2, NULL);
if (!tmp)
goto out;
/* XXX save server id */
/* Get server info */
- tmp = silc_command_get_arg_type(cmd->payload, 3, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 3, NULL);
if (!tmp)
goto out;
int i;
time_t diff, curtime;
- tmp = silc_command_get_arg_type(cmd->payload, 1, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
cmd->client->ops->say(cmd->client, conn,
SILC_LOG_DEBUG(("Start"));
- tmp = silc_command_get_arg_type(cmd->payload, 1, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
cmd->client->ops->say(cmd->client, conn,
goto out;
}
- argc = silc_command_get_arg_num(cmd->payload);
+ argc = silc_argument_get_arg_num(cmd->args);
if (argc < 3 || argc > 5) {
cmd->client->ops->say(cmd->client, conn,
"Cannot join channel: Bad reply packet");
}
/* Get channel name */
- tmp = silc_command_get_arg_type(cmd->payload, 2, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 2, NULL);
if (!tmp) {
cmd->client->ops->say(cmd->client, conn,
"Cannot join channel: Bad reply packet");
channel_name = strdup(tmp);
/* Get Channel ID */
- id_string = silc_command_get_arg_type(cmd->payload, 3, NULL);
+ id_string = silc_argument_get_arg_type(cmd->args, 3, NULL);
if (!id_string) {
cmd->client->ops->say(cmd->client, conn,
"Cannot join channel: Bad reply packet");
}
/* Get channel mode */
- tmp = silc_command_get_arg_type(cmd->payload, 4, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 4, NULL);
if (tmp)
SILC_GET32_MSB(mode, tmp);
else
mode = 0;
/* Get topic */
- topic = silc_command_get_arg_type(cmd->payload, 5, NULL);
+ topic = silc_argument_get_arg_type(cmd->args, 5, NULL);
/* Save received Channel ID */
silc_client_new_channel_id(cmd->client, cmd->sock, channel_name,
unsigned char *tmp;
char *motd = NULL, *cp, line[256];
- tmp = silc_command_get_arg_type(cmd->payload, 1, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
cmd->client->ops->say(cmd->client, conn,
return;
}
- argc = silc_command_get_arg_num(cmd->payload);
+ argc = silc_argument_get_arg_num(cmd->args);
if (argc > 2) {
COMMAND_REPLY_ERROR;
goto out;
}
if (argc == 2) {
- motd = silc_command_get_arg_type(cmd->payload, 2, NULL);
+ motd = silc_argument_get_arg_type(cmd->args, 2, NULL);
if (!motd) {
COMMAND_REPLY_ERROR;
goto out;
SilcCommandStatus status;
unsigned char *tmp;
- tmp = silc_command_get_arg_type(cmd->payload, 1, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
cmd->client->ops->say(cmd->client, conn,
SILC_LOG_DEBUG(("Start"));
- tmp = silc_command_get_arg_type(cmd->payload, 1, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
SILC_GET16_MSB(status, tmp);
if (status != SILC_STATUS_OK) {
cmd->client->ops->say(cmd->client, conn,
}
/* Get channel ID */
- tmp = silc_command_get_arg_type(cmd->payload, 2, NULL);
+ tmp = silc_argument_get_arg_type(cmd->args, 2, NULL);
if (!tmp) {
cmd->client->ops->say(cmd->client, conn,
"Cannot get user list: Bad reply packet");
channel_id = silc_id_str2id(tmp, SILC_ID_CHANNEL);
/* Get the name list of the channel */
- name_list = silc_command_get_arg_type(cmd->payload, 3, &len1);
+ name_list = silc_argument_get_arg_type(cmd->args, 3, &len1);
if (!name_list) {
cmd->client->ops->say(cmd->client, conn,
"Cannot get user list: Bad reply packet");
}
/* Get Client ID list */
- tmp = silc_command_get_arg_type(cmd->payload, 4, &len2);
+ tmp = silc_argument_get_arg_type(cmd->args, 4, &len2);
if (!tmp) {
cmd->client->ops->say(cmd->client, conn,
"Cannot get user list: Bad reply packet");