Fixed all anonymous structures from public headers.
authorPekka Riikonen <priikone@silcnet.org>
Wed, 16 May 2007 16:02:29 +0000 (16:02 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 16 May 2007 16:02:29 +0000 (16:02 +0000)
Change silc_buffer_*len macros to inline functions.

12 files changed:
lib/silcclient/silcclient.h
lib/silccore/silcargument.h
lib/silccore/silcid.h
lib/silccrypt/silcpk.c
lib/silccrypt/silcpk.h
lib/silccrypt/silcpkcs.h
lib/silcsftp/silcsftp.h
lib/silcsftp/silcsftp_fs.h
lib/silcske/silcske.h
lib/silcutil/silcbuffer.h
lib/silcutil/silclist.h
lib/silcutil/silctime.h

index fedeea7489abcf93b8001db5786a846fa489a5a1..536f3ee915a21e3130e5f6b81464cd397057032f 100644 (file)
@@ -277,7 +277,7 @@ struct SilcChannelUserStruct {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcClientStatsStruct {
   SilcUInt32 starttime;                /* SILC server start time */
   SilcUInt32 uptime;           /* SILC server uptime*/
   SilcUInt32 my_clients;       /* Number of clients in the server */
@@ -365,7 +365,7 @@ typedef void (*SilcKeyAgreementCallback)(SilcClient client,
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcPrivateMessageKeysStruct {
   SilcClientEntry client_entry;       /* The remote client entry */
   char *cipher;                              /* The cipher name */
   unsigned char *key;                /* The original key, If the appliation
@@ -501,7 +501,7 @@ typedef enum {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcClientOperationsStruct {
   /* Message sent to the application by library. `conn' associates the
      message to a specific connection.  `conn', however, may be NULL.
      The `type' indicates the type of the message sent by the library.
@@ -641,7 +641,7 @@ typedef struct {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcClientParamsStruct {
   /* If this boolean is set to TRUE then the client library will use
      threads.  Any of the callback functions in the SilcClientOperations
      and other callbacks may be called at any time in a thread.  The
@@ -839,7 +839,7 @@ void silc_client_stop(SilcClient client, SilcClientStopped stopped,
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcClientConnectionParamsStruct {
   /* If this is provided the user's nickname in the network will be the
      string given here.  If it is given, it must be UTF-8 encoded.  If this
      string is not given, the user's username by default is used as nickname.
index 49234d3b9e693faed8db77116125c3735d12b35a..bc258d9983234abf6e8c1372719847ee3262e465 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2001 - 2006 Pekka Riikonen
+  Copyright (C) 2001 - 2007 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
@@ -308,7 +308,7 @@ silc_argument_list_parse(const unsigned char *payload, SilcUInt32 payload_len);
  *    of freeing the contents of the structure and the structure itself.
  *
  ***/
-typedef struct {
+typedef struct SilcArgumentDecodedListStruct {
   void *argument;           /* Decoded argument, caller must know its type */
   SilcUInt32 arg_type;      /* Argument type number from the payload */
 } *SilcArgumentDecodedList;
index 25cca44421ec87acc9c7ca970a428cdc2dcb8a1f..4cab7b75354947305c52ea3813049e18943335f9 100644 (file)
@@ -82,7 +82,7 @@ typedef SilcUInt16 SilcIdType;
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcIDIPStruct {
   unsigned char data[16];      /* IP data (in MSB first order) */
   SilcUInt8 data_len;          /* Length of the data (4 or 16) */
 } SilcIDIP;
@@ -104,7 +104,7 @@ typedef struct {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcServerIDStruct {
   SilcIDIP ip;                 /* n bit IP address */
   SilcUInt16 port;             /* 16 bit port */
   SilcUInt16 rnd;              /* 16 bit random number */
@@ -127,7 +127,7 @@ typedef struct {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcClientIDStruct {
   SilcIDIP ip;                                 /* n bit IP address */
   unsigned char rnd;                           /* 8 bit random number */
   unsigned char hash[CLIENTID_HASH_LEN];       /* 88 bit MD5 hash */
@@ -150,7 +150,7 @@ typedef struct {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcChannelIDStruct {
   SilcIDIP ip;                 /* n bit IP address */
   SilcUInt16 port;             /* 16 bit port */
   SilcUInt16 rnd;              /* 16 bit random number */
@@ -172,7 +172,7 @@ typedef struct {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcIDStruct {
   union {
     SilcServerID server_id;
     SilcChannelID channel_id;
index ecbb85065e51b42d87355e09abd48d89fe363b7a..c9de54924fb9bdb0b39ed381e162fb8436b29147 100644 (file)
@@ -595,8 +595,10 @@ unsigned char *silc_pkcs_silc_export_public_key(void *public_key,
   /* Export PKCS algorithm public key */
   if (pkcs->export_public_key)
     pk = pkcs->export_public_key(silc_pubkey->public_key, &pk_len);
-  if (!pk)
+  if (!pk) {
+    SILC_LOG_ERROR(("Error exporting PKCS algorithm key"));
     return NULL;
+  }
   silc_buffer_set(&alg_key, pk, pk_len);
 
   /* Encode identifier */
@@ -608,8 +610,10 @@ unsigned char *silc_pkcs_silc_export_public_key(void *public_key,
                                     silc_pubkey->identifier.org,
                                     silc_pubkey->identifier.country,
                                     silc_pubkey->identifier.version);
-  if (!identifier)
+  if (!identifier) {
+    SILC_LOG_ERROR(("Error encoding SILC public key identifier"));
     goto err;
+  }
 
   asn1 = silc_asn1_alloc();
   if (!asn1)
@@ -658,7 +662,7 @@ unsigned char *silc_pkcs_silc_export_public_key(void *public_key,
     goto err;
 
   } else {
-    SILC_LOG_DEBUG(("Unsupported PKCS algorithm"));
+    SILC_LOG_ERROR(("Unsupported PKCS algorithm: %s", pkcs->name));
     goto err;
   }
 
index de22c5ee7a050e11016c82752ae633b1f0761111..f62c628c9f0cc4d7b9967d05138c77451bf31e6b 100644 (file)
@@ -43,7 +43,7 @@
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcPublicKeyIdentifierObject {
   char *username;
   char *host;
   char *realname;
@@ -69,7 +69,7 @@ typedef struct {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcSILCPublicKeyStruct {
   SilcPublicKeyIdentifierStruct identifier;
   const SilcPKCSAlgorithm *pkcs;   /* PKCS algorithm */
   void *public_key;               /* PKCS algorithm specific public key */
@@ -89,7 +89,7 @@ typedef struct {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcSILCPrivateKeyStruct {
   const SilcPKCSAlgorithm *pkcs;   /* PKCS algorithm */
   void *private_key;              /* PKCS algorithm specific private key */
 } *SilcSILCPrivateKey;
index 857824f440f37828849041148980137effbf6830..0c746bef062b1c0935d05094277758cd2a96bbf1 100644 (file)
@@ -70,7 +70,7 @@ typedef enum {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcPublicKeyStruct {
   const SilcPKCSObject *pkcs;  /* PKCS */
   void *public_key;            /* PKCS specific public key */
 } *SilcPublicKey;
@@ -88,7 +88,7 @@ typedef struct {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcPrivateKeyStruct {
   const SilcPKCSObject *pkcs;  /* PKCS */
   void *private_key;           /* PKCS specific private key */
 } *SilcPrivateKey;
index cf6711fe9b4d7dc194116dd4d48b60a93f90eb0c..5a2702fcb19c86ed0b234525de32b90347b32124 100644 (file)
@@ -158,7 +158,7 @@ typedef enum {
  *    server, and by server to return file attributes to the client.
  *
  ***/
-typedef struct {
+typedef struct SilcSFTPAttributesObject {
   SilcUInt32 flags;            /* Flags to indicate present attributes */
   SilcUInt64 size;             /* Sife of the file in bytes */
   SilcUInt32 uid;                      /* Unix user ID */
@@ -186,7 +186,7 @@ typedef struct {
  *    example when reading the contents of a directory.
  *
  ***/
-typedef struct {
+typedef struct SilcSFTPNameObject {
   char **filename;
   char **long_filename;
   SilcSFTPAttributes *attrs;
@@ -948,7 +948,7 @@ typedef enum {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcSFTPMonitorDataObject {
   SilcSFTPVersion version;     /* _INIT */
   char *name;                  /* _OPEN, _REMOVE, _RENAME, _MKDIR,
                                   _RMDIR, _OPENDIR, _STAT, _LSTAT,
index 97b61d9af47debfbe7900f258b52b4cd94eb2684..d3aede6597beb74d4f5f5b053e7cedb6f562d4af 100644 (file)
@@ -277,7 +277,7 @@ typedef struct SilcSFTPFilesystemOpsStruct {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcSFTPFilesystemStruct {
   SilcSFTPFilesystemOps fs;
   void *fs_context;
 } *SilcSFTPFilesystem;
index 7152392dd8f8a1ce0c778881d065b8d621a7a9c8..45837b367d504cfbbda33628a5812d9eea232596 100644 (file)
@@ -116,7 +116,7 @@ typedef enum {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcSKESecurityPropertiesStruct {
   SilcSKESecurityPropertyFlag flags;    /* Flags */
   SilcSKEDiffieHellmanGroup group;      /* Selected Diffie Hellman group */
   SilcCipher cipher;                    /* Selected cipher */
@@ -142,7 +142,7 @@ typedef struct {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcSKEKeyMaterialStruct {
   unsigned char *send_iv;
   unsigned char *receive_iv;
   SilcUInt32 iv_len;
@@ -171,7 +171,7 @@ typedef struct {
  *    function.
  *
  ***/
-typedef struct {
+typedef struct SilcSKERekeyMaterialStruct {
   unsigned char *send_enc_key;
   char *hash;
   unsigned int enc_key_len  : 23;
@@ -192,7 +192,7 @@ typedef struct {
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcSKEParamsObject {
   /* The SKE version string that is sent to the remote end.  This field
      must be set.  Caller must free the pointer. */
   char *version;
index 673c4a7ff0608da0bd421c4f42be134060c5c313..ff9efe3100bb7d2f82ca8bd3fc2696c5211d6bc4 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1998 - 2006 Pekka Riikonen
+  Copyright (C) 1998 - 2007 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
  *
  * SOURCE
  */
-typedef struct {
+typedef struct SilcBufferObject {
   unsigned char *head;
   unsigned char *data;
   unsigned char *tail;
@@ -120,106 +120,114 @@ typedef struct {
 
 /* Macros */
 
-/****d* silcutil/SilcBufferAPI/silc_buffer_truelen
+/****f* silcutil/SilcBufferAPI/silc_buffer_data
  *
  * NAME
  *
- *    SilcUInt32 silc_buffer_truelen(SilcBuffer sb)
+ *    unsigned char *silc_buffer_data(SilcBuffer sb)
  *
  * DESCRIPTION
  *
- *    Returns the true length of the buffer.
+ *    Returns pointer to the data area of the buffer.
  *
  * SOURCE
  */
-#define silc_buffer_truelen(x) (SilcUInt32)((x)->end - (x)->head)
+#define silc_buffer_data(x) (x)->data
 /***/
 
-/****d* silcutil/SilcBufferAPI/silc_buffer_len
+/****f* silcutil/SilcBufferAPI/silc_buffer_datalen
  *
  * NAME
  *
- *    SilcUInt32 silc_buffer_len(SilcBuffer sb)
+ *    #define silc_buffer_datalen ...
  *
  * DESCRIPTION
  *
- *    Returns the current length of the data area of the buffer.
+ *    Macro that can be used in function argument list to give the data
+ *    pointer and the data length, instead of calling both silc_buffer_data
+ *    and silc_buffer_len separately.
+ *
+ * EXAMPLE
+ *
+ *    // Following are the same thing
+ *    silc_foo_function(foo, silc_buffer_datalen(buf));
+ *    silc_foo_function(foo, silc_buffer_data(buf), silc_buffer_len(buf));
  *
  * SOURCE
  */
-#define silc_buffer_len(x) (SilcUInt32)((x)->tail - (x)->data)
+#define silc_buffer_datalen(x) (x) ? silc_buffer_data((x)) : NULL, \
+  (x) ? silc_buffer_len((x)) : 0
 /***/
 
-/****d* silcutil/SilcBufferAPI/silc_buffer_headlen
+/* Inline functions */
+
+/****d* silcutil/SilcBufferAPI/silc_buffer_truelen
  *
  * NAME
  *
- *    SilcUInt32 silc_buffer_headlen(SilcBuffer sb)
+ *    SilcUInt32 silc_buffer_truelen(SilcBuffer sb)
  *
  * DESCRIPTION
  *
- *    Returns the current length of the head data area of the buffer.
+ *    Returns the true length of the buffer.
  *
- * SOURCE
- */
-#define silc_buffer_headlen(x) (SilcUInt32)((x)->data - (x)->head)
-/***/
+ ***/
+static inline
+SilcUInt32 silc_buffer_truelen(SilcBuffer x)
+{
+  return (SilcUInt32)(x->end - x->head);
+}
 
-/****d* silcutil/SilcBufferAPI/silc_buffer_taillen
+/****d* silcutil/SilcBufferAPI/silc_buffer_len
  *
  * NAME
  *
- *    SilcUInt32 silc_buffer_taillen(SilcBuffer sb)
+ *    SilcUInt32 silc_buffer_len(SilcBuffer sb)
  *
  * DESCRIPTION
  *
- *    Returns the current length of the tail data area of the buffer.
+ *    Returns the current length of the data area of the buffer.
  *
- * SOURCE
- */
-#define silc_buffer_taillen(x) (SilcUInt32)((x)->end - (x)->tail)
-/***/
+ ***/
+static inline
+SilcUInt32 silc_buffer_len(SilcBuffer x)
+{
+  return (SilcUInt32)(x->tail - x->data);
+}
 
-/****f* silcutil/SilcBufferAPI/silc_buffer_data
+/****d* silcutil/SilcBufferAPI/silc_buffer_headlen
  *
  * NAME
  *
- *    unsigned char *silc_buffer_data(SilcBuffer sb)
+ *    SilcUInt32 silc_buffer_headlen(SilcBuffer sb)
  *
  * DESCRIPTION
  *
- *    Returns pointer to the data area of the buffer.
+ *    Returns the current length of the head data area of the buffer.
  *
- * SOURCE
- */
-#define silc_buffer_data(x) (x)->data
-/***/
+ ***/
+static inline
+SilcUInt32 silc_buffer_headlen(SilcBuffer x)
+{
+  return (SilcUInt32)(x->data - x->head);
+}
 
-/****f* silcutil/SilcBufferAPI/silc_buffer_datalen
+/****d* silcutil/SilcBufferAPI/silc_buffer_taillen
  *
  * NAME
  *
- *    #define silc_buffer_datalen ...
+ *    SilcUInt32 silc_buffer_taillen(SilcBuffer sb)
  *
  * DESCRIPTION
  *
- *    Macro that can be used in function argument list to give the data
- *    pointer and the data length, instead of calling both silc_buffer_data
- *    and silc_buffer_len separately.
- *
- * EXAMPLE
- *
- *    // Following are the same thing
- *    silc_foo_function(foo, silc_buffer_datalen(buf));
- *    silc_foo_function(foo, silc_buffer_data(buf), silc_buffer_len(buf));
+ *    Returns the current length of the tail data area of the buffer.
  *
- * SOURCE
- */
-#define silc_buffer_datalen(x) (x) ? silc_buffer_data((x)) : NULL, \
-  (x) ? silc_buffer_len((x)) : 0
-/***/
-
-/* Inline functions */
+ ***/
+static inline
+SilcUInt32 silc_buffer_taillen(SilcBuffer x)
+{
+  return (SilcUInt32)(x->end - x->tail);
+}
 
 /****f* silcutil/SilcBufferAPI/silc_buffer_alloc
  *
index ec4d7be15fea364d49d1ba32e4dfafdbd828aeef..cda1123f7fcfdf4338fa8bc1dcb97a32d00f32b8 100644 (file)
@@ -44,7 +44,7 @@
  *    function silc_list_init.
  *
  ***/
-typedef struct {
+typedef struct SilcListStruct {
   void *head;                       /* Start of the list */
   void *tail;                       /* End of the list */
   void *current;                    /* Current pointer in list */
index 64eb37198ffb075754fabaf2fdaf938b71999f3b..6c22d90ae1a3c7079888dd9e9b84428c973fd691 100644 (file)
@@ -44,7 +44,7 @@
  * SOURCE
  *
  ***/
-typedef struct {
+typedef struct SilcTimeObject {
   unsigned int year       : 15;           /* Year,     0 - 32768 */
   unsigned int month      : 4;    /* Month,    1 - 12 */
   unsigned int day        : 5;    /* Day,      1 - 31 */
@@ -251,7 +251,7 @@ SilcBool silc_time_generalized_string(SilcTime time_val, char *ret_string,
  *
  * DESCRIPTION
  *
- *    Compares `t1' and `t2' time structures and returns less than zero, 
+ *    Compares `t1' and `t2' time structures and returns less than zero,
  *    zero or more than zero when `t1' is smaller, equal or bigger than
  *    `t2', respectively.
  *