-static int
-silc_server_command_identify_parse(SilcServerCommandContext cmd,
- SilcClientID **client_id,
- char **nickname,
- char **server_name,
- int *count)
-{
- unsigned char *tmp;
- unsigned int len;
- unsigned int argc = silc_argument_get_arg_num(cmd->args);
-
- /* If client ID is in the command it must be used instead of nickname */
- tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
- if (!tmp) {
- /* No ID, get the nickname@server string and parse it. */
- tmp = silc_argument_get_arg_type(cmd->args, 1, NULL);
- if (tmp) {
- if (strchr(tmp, '@')) {
- len = strcspn(tmp, "@");
- *nickname = silc_calloc(len + 1, sizeof(char));
- memcpy(*nickname, tmp, len);
- *server_name = silc_calloc(strlen(tmp) - len, sizeof(char));
- memcpy(*server_name, tmp + len + 1, strlen(tmp) - len - 1);
- } else {
- *nickname = strdup(tmp);
- }
- } else {
- silc_server_command_send_status_reply(cmd, SILC_COMMAND_IDENTIFY,
- SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
- return FALSE;
- }
- } else {
- /* Command includes ID, use that */
- *client_id = silc_id_payload_parse_id(tmp, len);
- }
-
- /* Get the max count of reply messages allowed */
- if (argc == 3) {
- tmp = silc_argument_get_arg_type(cmd->args, 3, NULL);
- if (!tmp) {
- silc_server_command_send_status_reply(cmd, SILC_COMMAND_IDENTIFY,
- SILC_STATUS_ERR_TOO_MANY_PARAMS);
- if (*nickname)
- silc_free(*nickname);
- if (*server_name)
- silc_free(*server_name);
-
- return FALSE;
- }
- *count = atoi(tmp);
- }
-
- return TRUE;
-}
-