From: Pekka Riikonen Date: Wed, 16 May 2007 16:02:29 +0000 (+0000) Subject: Fixed all anonymous structures from public headers. X-Git-Tag: silc.toolkit.1.1.beta3~6 X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=commitdiff_plain;h=0987234560b29a99fea5b99f7d68e501df024f8c Fixed all anonymous structures from public headers. Change silc_buffer_*len macros to inline functions. --- diff --git a/lib/silcclient/silcclient.h b/lib/silcclient/silcclient.h index fedeea74..536f3ee9 100644 --- a/lib/silcclient/silcclient.h +++ b/lib/silcclient/silcclient.h @@ -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. diff --git a/lib/silccore/silcargument.h b/lib/silccore/silcargument.h index 49234d3b..bc258d99 100644 --- a/lib/silccore/silcargument.h +++ b/lib/silccore/silcargument.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - 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; diff --git a/lib/silccore/silcid.h b/lib/silccore/silcid.h index 25cca444..4cab7b75 100644 --- a/lib/silccore/silcid.h +++ b/lib/silccore/silcid.h @@ -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; diff --git a/lib/silccrypt/silcpk.c b/lib/silccrypt/silcpk.c index ecbb8506..c9de5492 100644 --- a/lib/silccrypt/silcpk.c +++ b/lib/silccrypt/silcpk.c @@ -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; } diff --git a/lib/silccrypt/silcpk.h b/lib/silccrypt/silcpk.h index de22c5ee..f62c628c 100644 --- a/lib/silccrypt/silcpk.h +++ b/lib/silccrypt/silcpk.h @@ -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; diff --git a/lib/silccrypt/silcpkcs.h b/lib/silccrypt/silcpkcs.h index 857824f4..0c746bef 100644 --- a/lib/silccrypt/silcpkcs.h +++ b/lib/silccrypt/silcpkcs.h @@ -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; diff --git a/lib/silcsftp/silcsftp.h b/lib/silcsftp/silcsftp.h index cf6711fe..5a2702fc 100644 --- a/lib/silcsftp/silcsftp.h +++ b/lib/silcsftp/silcsftp.h @@ -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, diff --git a/lib/silcsftp/silcsftp_fs.h b/lib/silcsftp/silcsftp_fs.h index 97b61d9a..d3aede65 100644 --- a/lib/silcsftp/silcsftp_fs.h +++ b/lib/silcsftp/silcsftp_fs.h @@ -277,7 +277,7 @@ typedef struct SilcSFTPFilesystemOpsStruct { * * SOURCE */ -typedef struct { +typedef struct SilcSFTPFilesystemStruct { SilcSFTPFilesystemOps fs; void *fs_context; } *SilcSFTPFilesystem; diff --git a/lib/silcske/silcske.h b/lib/silcske/silcske.h index 7152392d..45837b36 100644 --- a/lib/silcske/silcske.h +++ b/lib/silcske/silcske.h @@ -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; diff --git a/lib/silcutil/silcbuffer.h b/lib/silcutil/silcbuffer.h index 673c4a7f..ff9efe31 100644 --- a/lib/silcutil/silcbuffer.h +++ b/lib/silcutil/silcbuffer.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - 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 @@ -110,7 +110,7 @@ * * 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 * diff --git a/lib/silcutil/silclist.h b/lib/silcutil/silclist.h index ec4d7be1..cda1123f 100644 --- a/lib/silcutil/silclist.h +++ b/lib/silcutil/silclist.h @@ -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 */ diff --git a/lib/silcutil/silctime.h b/lib/silcutil/silctime.h index 64eb3719..6c22d90a 100644 --- a/lib/silcutil/silctime.h +++ b/lib/silcutil/silctime.h @@ -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. *