X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilccore%2Fsilccommand.h;h=059797e5bc5d03c95beb5dc299490f94d19b6b66;hp=531f1935aa114e9c66b939c02db1d810fad226a9;hb=HEAD;hpb=275e2f50c1cbe4a0eec582cf490ef485049541af diff --git a/lib/silccore/silccommand.h b/lib/silccore/silccommand.h index 531f1935..059797e5 100644 --- a/lib/silccore/silccommand.h +++ b/lib/silccore/silccommand.h @@ -1,16 +1,15 @@ /* - + silccommand.h - + Author: Pekka Riikonen - - Copyright (C) 1997 - 2001 Pekka Riikonen - + + Copyright (C) 1997 - 2008 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - + the Free Software Foundation; version 2 of the License. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -31,27 +30,10 @@ #ifndef SILCCOMMAND_H #define SILCCOMMAND_H -/****f* silccore/SilcCommandAPI/SilcCommandCb - * - * SYNOPSIS - * - * typedef void (*SilcCommandCb)(void *context, void *context2); - * - * DESCRIPTION - * - * Command function callback. The actual command function pointer. - * This is generic command callback that the application may choose to - * use with its command routines. However, none of the generic - * routines depend on this callback so application may freely define - * their own command callback if desired. - * - ***/ -typedef void (*SilcCommandCb)(void *context, void *context2); - /****s* silccore/SilcCommandAPI/SilcCommandPayload * * NAME - * + * * typedef struct SilcCommandPayloadStruct *SilcCommandPayload; * * DESCRIPTION @@ -67,7 +49,7 @@ typedef struct SilcCommandPayloadStruct *SilcCommandPayload; /****d* silccore/SilcCommandAPI/SilcCommandFlags * * NAME - * + * * typedef enum { ... } SilcCommandFlags; * * DESCRIPTION @@ -98,7 +80,7 @@ typedef enum { /* Command is available only for server operators */ SILC_CF_OPER = (1L << 4), - /* Command is available only for SILC (router) operators. If this + /* Command is available only for SILC (router) operators. If this is set SILC_CF_OPER is not necessary to be set. */ SILC_CF_SILC_OPER = (1L << 5), @@ -108,8 +90,8 @@ typedef enum { /****d* silccore/SilcCommandAPI/SilcCommand * * NAME - * - * typedef unsigned char SilcCommand; + * + * typedef SilcUInt8 SilcCommand; * * DESCRIPTION * @@ -119,7 +101,7 @@ typedef enum { * * SOURCE */ -typedef unsigned char SilcCommand; +typedef SilcUInt8 SilcCommand; /* All SILC commands. These are commands that have client and server counterparts. */ @@ -145,12 +127,15 @@ typedef unsigned char SilcCommand; #define SILC_COMMAND_KICK 19 #define SILC_COMMAND_BAN 20 #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 @@ -159,74 +144,13 @@ typedef unsigned char SilcCommand; #define SILC_COMMAND_RESERVED 255 /***/ -/****d* silccore/SilcCommandAPI/SilcCommandStatus - * - * NAME - * - * typedef SilcUInt8 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 SilcUInt8 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 * * SYNOPSIS * - * SilcCommandPayload + * SilcCommandPayload * silc_command_payload_parse(const unsigned char *payload, * SilcUInt32 payload_len); * @@ -266,7 +190,7 @@ SilcBuffer silc_command_payload_encode(SilcCommand cmd, * * SYNOPSIS * - * SilcBuffer + * SilcBuffer * silc_command_payload_encode_payload(SilcCommandPayload payload); * * DESCRIPTION @@ -281,31 +205,31 @@ SilcBuffer silc_command_payload_encode_payload(SilcCommandPayload payload); * * SYNOPSIS * - * SilcBuffer silc_command_payload_encode_va(SilcCommand cmd, - * SilcUInt16 ident, + * SilcBuffer silc_command_payload_encode_va(SilcCommand cmd, + * SilcUInt16 ident, * SilcUInt32 argc, ...); * * DESCRIPTION * * Encodes Command payload with variable argument list. The arguments - * must be: SilcUInt32, unsigned char *, unsigned int, ... One - * {SilcUInt32, unsigned char * and unsigned int} forms one argument, - * thus `argc' in case when sending one {SilcUInt32, unsigned char * + * must be: SilcUInt32, unsigned char *, unsigned int, ... One + * {SilcUInt32, unsigned char * and unsigned int} forms one argument, + * thus `argc' in case when sending one {SilcUInt32, unsigned char * * and SilcUInt32} equals one (1) and when sending two of those it * equals two (2), and so on. This has to be preserved or bad things * will happen. The variable arguments is: {type, data, data_len}. * ***/ -SilcBuffer silc_command_payload_encode_va(SilcCommand cmd, - SilcUInt16 ident, +SilcBuffer silc_command_payload_encode_va(SilcCommand cmd, + SilcUInt16 ident, SilcUInt32 argc, ...); /****f* silccore/SilcCommandAPI/silc_command_payload_encode_vap * * SYNOPSIS * - * SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd, - * SilcUInt16 ident, + * SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd, + * SilcUInt16 ident, * SilcUInt32 argc, va_list ap); * * DESCRIPTION @@ -314,25 +238,25 @@ SilcBuffer silc_command_payload_encode_va(SilcCommand cmd, * takes the va_list as argument. * ***/ -SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd, - SilcUInt16 ident, +SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd, + SilcUInt16 ident, SilcUInt32 argc, va_list ap); /****f* silccore/SilcCommandAPI/silc_command_reply_payload_encode_va * * SYNOPSIS * - * SilcBuffer - * silc_command_reply_payload_encode_va(SilcCommand cmd, - * SilcCommandStatus status, - * SilcCommandStatus error, + * SilcBuffer + * silc_command_reply_payload_encode_va(SilcCommand cmd, + * 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 `argc' must not count + * Same as silc_command_payload_encode_va except that this is used to + * 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 @@ -350,10 +274,10 @@ SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd, * replies are sent after the successful replies. * ***/ -SilcBuffer -silc_command_reply_payload_encode_va(SilcCommand cmd, - SilcCommandStatus status, - SilcCommandStatus error, +SilcBuffer +silc_command_reply_payload_encode_va(SilcCommand cmd, + SilcStatus status, + SilcStatus error, SilcUInt16 ident, SilcUInt32 argc, ...); @@ -361,10 +285,10 @@ silc_command_reply_payload_encode_va(SilcCommand cmd, * * SYNOPSIS * - * SilcBuffer - * silc_command_reply_payload_encode_vap(SilcCommand cmd, - * SilcCommandStatus status, - * SilcCommandStatus error, + * SilcBuffer + * silc_command_reply_payload_encode_vap(SilcCommand cmd, + * SilcStatus status, + * SilcStatus error, * SilcUInt16 ident, SilcUInt32 argc, * va_list ap); * @@ -374,11 +298,11 @@ silc_command_reply_payload_encode_va(SilcCommand cmd, * takes the va_list as argument. * ***/ -SilcBuffer -silc_command_reply_payload_encode_vap(SilcCommand cmd, - SilcCommandStatus status, - SilcCommandStatus error, - SilcUInt16 ident, SilcUInt32 argc, +SilcBuffer +silc_command_reply_payload_encode_vap(SilcCommand cmd, + SilcStatus status, + SilcStatus error, + SilcUInt16 ident, SilcUInt32 argc, va_list ap); /****f* silccore/SilcCommandAPI/silc_command_free @@ -441,9 +365,9 @@ SilcUInt16 silc_command_get_ident(SilcCommandPayload payload); * * SYNOPSIS * - * bool silc_command_get_status(SilcCommandPayload payload, - * SilcCommandStatus *status, - * SilcCommandStatus *error); + * SilcBool silc_command_get_status(SilcCommandPayload payload, + * SilcStatus *status, + * SilcStatus *error); * * DESCRIPTION * @@ -455,22 +379,22 @@ SilcUInt16 silc_command_get_ident(SilcCommandPayload payload); * which indicates that there will be list of errors. * ***/ -bool silc_command_get_status(SilcCommandPayload payload, - SilcCommandStatus *status, - SilcCommandStatus *error); +SilcBool 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, + * void silc_command_set_ident(SilcCommandPayload payload, * SilcUInt16 ident); * * DESCRIPTION * * 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 without encoding new Command Payload. + * to set the identifier without encoding new Command Payload. * ***/ void silc_command_set_ident(SilcCommandPayload payload, SilcUInt16 ident); @@ -479,7 +403,7 @@ void silc_command_set_ident(SilcCommandPayload payload, SilcUInt16 ident); * * SYNOPSIS * - * void silc_command_set_command(SilcCommandPayload payload, + * void silc_command_set_command(SilcCommandPayload payload, * SilcCommand command); * * DESCRIPTION