+
+/* Return command status */
+
+bool silc_command_get_status(SilcCommandPayload payload,
+ SilcStatus *status,
+ SilcStatus *error)
+{
+ unsigned char *tmp;
+ SilcUInt32 tmp_len;
+
+ if (!payload->args)
+ return 0;
+ tmp = silc_argument_get_arg_type(payload->args, 1, &tmp_len);
+ if (!tmp || tmp_len != 2)
+ return 0;
+
+ /* Check for 1.0 protocol version which didn't have `error' */
+ if (tmp[0] == 0 && tmp[1] != 0) {
+ /* Protocol 1.0 version */
+ SilcStatus s;
+ SILC_GET16_MSB(s, tmp);
+ if (status)
+ *status = s;
+ if (error)
+ *error = 0;
+ if (s >= SILC_STATUS_ERR_NO_SUCH_NICK && error)
+ *error = s;
+ return (s < SILC_STATUS_ERR_NO_SUCH_NICK);
+ }
+
+ /* Take both status and possible error */
+ if (status)
+ *status = (SilcStatus)tmp[0];
+ if (error)
+ *error = (SilcStatus)tmp[1];
+
+ /* If single error occurred have the both `status' and `error' indicate
+ the error value for convenience. */
+ if (tmp[0] >= SILC_STATUS_ERR_NO_SUCH_NICK && error)
+ *error = tmp[0];
+
+ return (tmp[0] < SILC_STATUS_ERR_NO_SUCH_NICK && tmp[1] == SILC_STATUS_OK);
+}
+
+/* Function to set identifier to already allocated Command Payload. Command
+ payloads are frequentlly resent in SILC and thusly this makes it easy
+ to set the identifier. */
+
+void silc_command_set_ident(SilcCommandPayload payload, SilcUInt16 ident)
+{
+ payload->ident = ident;
+}
+
+/* Function to set the command to already allocated Command Payload. */
+
+void silc_command_set_command(SilcCommandPayload payload, SilcCommand command)
+{
+ payload->cmd = command;
+}