Improved UTF-8 encoding and decoding, improved toolkit doc,
[silc.git] / lib / silccore / silccommand.h
index 46e7ddd1d96d4bd1356256a6e115faac3b16f299..3fbda03a977df1dfa22a862d308599749b938ca3 100644 (file)
@@ -134,7 +134,7 @@ typedef unsigned char SilcCommand;
 #define SILC_COMMAND_QUIT              8
 #define SILC_COMMAND_KILL              9
 #define SILC_COMMAND_INFO              10
-#define SILC_COMMAND_CONNECT           11
+#define SILC_COMMAND_STATS             11
 #define SILC_COMMAND_PING              12
 #define SILC_COMMAND_OPER              13
 #define SILC_COMMAND_JOIN              14
@@ -144,78 +144,25 @@ typedef unsigned char SilcCommand;
 #define SILC_COMMAND_CUMODE            18
 #define SILC_COMMAND_KICK              19
 #define SILC_COMMAND_BAN               20
-#define        SILC_COMMAND_CLOSE              21
-#define        SILC_COMMAND_SHUTDOWN           22
+#define SILC_COMMAND_DETACH            21
+#define SILC_COMMAND_WATCH             22
 #define SILC_COMMAND_SILCOPER          23
 #define SILC_COMMAND_LEAVE             24
 #define SILC_COMMAND_USERS             25
 #define SILC_COMMAND_GETKEY            26
+#define SILC_COMMAND_SERVICE           27
+
+/* Private range start */
+#define SILC_COMMAND_PRIVATE            200
+
+#define SILC_COMMAND_PRIV_CONNECT       200
+#define SILC_COMMAND_PRIV_CLOSE         201
+#define SILC_COMMAND_PRIV_SHUTDOWN      202
 
 /* Reserved */
 #define SILC_COMMAND_RESERVED           255
 /***/
 
-/****d* silccore/SilcCommandAPI/SilcCommandStatus
- *
- * NAME
- * 
- *    typedef SilcUInt16 SilcCommandStatus;
- *
- * DESCRIPTION
- *
- *    The SilcCommandStatus type definition and the status defines.
- *    The server returns a status in each Command Payload indicating
- *    the status of the command.
- *
- * SOURCE
- */
-typedef SilcUInt16 SilcCommandStatus;
-
-/* Command Status messages */
-#define SILC_STATUS_OK                      0
-#define SILC_STATUS_LIST_START              1
-#define SILC_STATUS_LIST_ITEM               2
-#define SILC_STATUS_LIST_END                3
-#define SILC_STATUS_ERR_NO_SUCH_NICK        10
-#define SILC_STATUS_ERR_NO_SUCH_CHANNEL     11
-#define SILC_STATUS_ERR_NO_SUCH_SERVER      12
-#define SILC_STATUS_ERR_TOO_MANY_TARGETS    13
-#define SILC_STATUS_ERR_NO_RECIPIENT        14
-#define SILC_STATUS_ERR_UNKNOWN_COMMAND     15
-#define SILC_STATUS_ERR_WILDCARDS           16
-#define SILC_STATUS_ERR_NO_CLIENT_ID        17
-#define SILC_STATUS_ERR_NO_CHANNEL_ID       18
-#define SILC_STATUS_ERR_NO_SERVER_ID        19
-#define SILC_STATUS_ERR_BAD_CLIENT_ID       20
-#define SILC_STATUS_ERR_BAD_CHANNEL_ID      21
-#define SILC_STATUS_ERR_NO_SUCH_CLIENT_ID   22
-#define SILC_STATUS_ERR_NO_SUCH_CHANNEL_ID  23
-#define SILC_STATUS_ERR_NICKNAME_IN_USE     24
-#define SILC_STATUS_ERR_NOT_ON_CHANNEL      25
-#define SILC_STATUS_ERR_USER_NOT_ON_CHANNEL 26
-#define SILC_STATUS_ERR_USER_ON_CHANNEL     27
-#define SILC_STATUS_ERR_NOT_REGISTERED      28
-#define SILC_STATUS_ERR_NOT_ENOUGH_PARAMS   29
-#define SILC_STATUS_ERR_TOO_MANY_PARAMS     30
-#define SILC_STATUS_ERR_PERM_DENIED         31
-#define SILC_STATUS_ERR_BANNED_FROM_SERVER  32
-#define SILC_STATUS_ERR_BAD_PASSWORD        33
-#define SILC_STATUS_ERR_CHANNEL_IS_FULL     34
-#define SILC_STATUS_ERR_NOT_INVITED         35
-#define SILC_STATUS_ERR_BANNED_FROM_CHANNEL 36
-#define SILC_STATUS_ERR_UNKNOWN_MODE        37
-#define SILC_STATUS_ERR_NOT_YOU             38
-#define SILC_STATUS_ERR_NO_CHANNEL_PRIV     39
-#define SILC_STATUS_ERR_NO_CHANNEL_FOPRIV   40
-#define SILC_STATUS_ERR_NO_SERVER_PRIV      41
-#define SILC_STATUS_ERR_NO_ROUTER_PRIV      42
-#define SILC_STATUS_ERR_BAD_NICKNAME        43
-#define SILC_STATUS_ERR_BAD_CHANNEL         44
-#define SILC_STATUS_ERR_AUTH_FAILED         45
-#define SILC_STATUS_ERR_UNKNOWN_ALGORITHM   46
-#define SILC_STATUS_ERR_NO_SUCH_SERVER_ID   47
-/***/
-
 /* Prototypes */
 
 /****f* silccore/SilcCommandAPI/silc_command_payload_parse
@@ -320,21 +267,36 @@ SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd,
  *
  *    SilcBuffer 
  *    silc_command_reply_payload_encode_va(SilcCommand cmd, 
- *                                         SilcCommandStatus status,
+ *                                         SilcStatus status,
+ *                                         SilcStatus error,
  *                                         SilcUInt16 ident,
  *                                         SilcUInt32 argc, ...);
  *
  * DESCRIPTION
  *
  *    Same as silc_command_payload_encode_va except that this is used to 
- *    encode strictly command reply packets. The command status message
- *    to be returned is sent as extra argument to this function. The `argc'
- *    must not count `status' as on argument.
+ *    encode strictly command reply packets.  The `argc' must not count 
+ *    `status' and `error' as arguments.  The `status' includes the
+ *    command reply status.  If single reply will be sent then it includes
+ *    SILC_STATUS_OK if error did not occur.  It includes an error value
+ *    if error did occur.  In this case `error' field is ignored.  If
+ *    there will be multiple successful command replies then the `status'
+ *    includes a list value and `error' is ignored.  If there will
+ *    multiple error replies the `status' includes a list value, and
+ *    the `error' includes an error value.  Thus, the `error' value is
+ *    specified only if there will be list of errors.
+ *
+ * NOTES
+ *
+ *    Protocol defines that it is possible to send both list of successful
+ *    and list of error replies at the same time, as long as the error
+ *    replies are sent after the successful replies.
  *
  ***/
 SilcBuffer 
 silc_command_reply_payload_encode_va(SilcCommand cmd, 
-                                    SilcCommandStatus status,
+                                    SilcStatus status,
+                                    SilcStatus error,
                                     SilcUInt16 ident,
                                     SilcUInt32 argc, ...);
 
@@ -344,7 +306,8 @@ silc_command_reply_payload_encode_va(SilcCommand cmd,
  *
  *    SilcBuffer 
  *    silc_command_reply_payload_encode_vap(SilcCommand cmd, 
- *                                          SilcCommandStatus status,
+ *                                          SilcStatus status,
+ *                                          SilcStatus error,
  *                                          SilcUInt16 ident, SilcUInt32 argc,
  *                                          va_list ap);
  *
@@ -356,7 +319,8 @@ silc_command_reply_payload_encode_va(SilcCommand cmd,
  ***/
 SilcBuffer 
 silc_command_reply_payload_encode_vap(SilcCommand cmd, 
-                                     SilcCommandStatus status,
+                                     SilcStatus status,
+                                     SilcStatus error,
                                      SilcUInt16 ident, SilcUInt32 argc, 
                                      va_list ap);
 
@@ -416,11 +380,34 @@ SilcArgumentPayload silc_command_get_args(SilcCommandPayload payload);
  ***/
 SilcUInt16 silc_command_get_ident(SilcCommandPayload payload);
 
+/****f* silccore/SilcCommandAPI/silc_command_get_status
+ *
+ * SYNOPSIS
+ *
+ *    bool silc_command_get_status(SilcCommandPayload payload, 
+ *                                 SilcStatus *status,
+ *                                 SilcStatus *error);
+ *
+ * DESCRIPTION
+ *
+ *    This function returns the command reply status into `status' and
+ *    error status, if error occurred into the `error'.  The function
+ *    returns TRUE if command reply status is not error, and FALSE if
+ *    error occurred.  In this case the `error' will include the actual
+ *    error status.  The `status' can be in this case some list value
+ *    which indicates that there will be list of errors.
+ *
+ ***/
+bool silc_command_get_status(SilcCommandPayload payload, 
+                            SilcStatus *status,
+                            SilcStatus *error);
+
 /****f* silccore/SilcCommandAPI/silc_command_set_ident
  *
  * SYNOPSIS
  *
- *    void silc_command_set_ident(SilcCommandPayload payload, SilcUInt16 ident);
+ *    void silc_command_set_ident(SilcCommandPayload payload, 
+ *                                SilcUInt16 ident);
  *
  * DESCRIPTION
  *