From a788ad407a51e84cfd41fedc6c053e62283ea2d7 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sat, 26 Jan 2008 21:29:28 +0200 Subject: [PATCH] Created SILC Runtime Toolkit git repository Part II. Added lib/silcutil/silcruntime.h.in, the file that is the main include file for application programmers. Added includes/silcompile.h which is included only during compilation of the Runtime Toolkit. Changed all files to use the silcruntime.h instead of silc.h header file. Made the many other changes in makefiles, configuration scripts and other files to try to complete the creation of the Runtime git repository. --- .gitignore | 9 +- CHANGES.RUNTIME | 7 +- Makefile.ad | 21 - Makefile.defines_int.in | 4 +- TODO | 406 +------ apps/Makefile.ad | 19 +- configure.ad | 1398 +++++++++------------- distdir/autodist.conf | 49 + distdir/client | 13 - distdir/default | 14 +- distdir/post-dist | 5 +- distdir/runtime | 29 + distdir/server | 13 - includes/silc.h.in | 34 - includes/silccompile.h | 131 ++ lib/.gitignore | 9 +- lib/Makefile.ad | 191 +-- lib/Makefile.runtime.ad | 83 ++ lib/configure.ad | 366 ------ lib/contrib/stringprep.h | 2 +- lib/silcutil/.gitignore | 8 +- lib/silcutil/DIRECTORY | 7 +- lib/silcutil/Makefile.ad | 28 +- lib/silcutil/silcasync.c | 4 +- lib/silcutil/silcbase64.c | 4 +- lib/silcutil/silcbitops.c | 4 +- lib/silcutil/silcbuffer.h | 2 +- lib/silcutil/silcbuffmt.c | 9 +- lib/silcutil/silcconfig.c | 5 +- lib/silcutil/silcconfig.h | 8 +- lib/silcutil/silcdll.c | 10 +- lib/silcutil/silcenv.c | 4 +- lib/silcutil/silcenv.h | 3 +- lib/silcutil/silcerrno.c | 12 +- lib/silcutil/silcfdstream.c | 4 +- lib/silcutil/silcfileutil.c | 5 +- lib/silcutil/silcfileutil.h | 6 +- lib/silcutil/silcfsm.c | 4 +- lib/silcutil/silcgetopt.c | 4 +- lib/silcutil/silchashtable.c | 6 +- lib/silcutil/silclog.c | 5 +- lib/silcutil/silcmemory.c | 3 +- lib/silcutil/silcmime.c | 4 +- lib/silcutil/silcmime.h | 4 +- lib/silcutil/silcnet.c | 21 +- lib/silcutil/silcregex.c | 8 +- lib/silcutil/silcregex.h | 5 + lib/silcutil/silcschedule.c | 29 +- lib/silcutil/silcschedule.h | 13 +- lib/silcutil/silcsnprintf.c | 2 +- lib/silcutil/silcsocketstream.c | 4 +- lib/silcutil/silcsocketstream.h | 4 +- lib/silcutil/silcstack.c | 2 +- lib/silcutil/silcstack.h | 11 +- lib/silcutil/silcstream.c | 4 +- lib/silcutil/silcstream.h | 5 +- lib/silcutil/silcstringprep.c | 5 +- lib/silcutil/silcstrutil.c | 6 +- lib/silcutil/silcstrutil.h | 4 +- lib/silcutil/silcthread.c | 4 +- lib/silcutil/silctime.c | 4 +- lib/silcutil/silctimer.c | 4 +- lib/silcutil/silctypes.h | 2 +- lib/silcutil/silcutf8.c | 7 +- lib/silcutil/silcutil.c | 11 +- lib/silcutil/stacktrace.c | 4 +- lib/silcutil/symbian/.gitignore | 8 +- lib/silcutil/tests/Makefile.am | 37 +- lib/silcutil/tests/test_silcasync.c | 6 +- lib/silcutil/tests/test_silcatomic.c | 5 +- lib/silcutil/tests/test_silcbitops.c | 4 +- lib/silcutil/tests/test_silcbuffmt.c | 4 +- lib/silcutil/tests/test_silcdir.c | 4 +- lib/silcutil/tests/test_silcdll.c | 6 +- lib/silcutil/tests/test_silcenv.c | 9 +- lib/silcutil/tests/test_silcfdstream.c | 6 +- lib/silcutil/tests/test_silcfsm.c | 6 +- lib/silcutil/tests/test_silchashtable.c | 4 +- lib/silcutil/tests/test_silclist.c | 32 +- lib/silcutil/tests/test_silcmime.c | 6 +- lib/silcutil/tests/test_silcmutex.c | 5 +- lib/silcutil/tests/test_silcnet.c | 6 +- lib/silcutil/tests/test_silcregex.c | 4 +- lib/silcutil/tests/test_silcschedule.c | 10 +- lib/silcutil/tests/test_silcstack.c | 56 +- lib/silcutil/tests/test_silcstringprep.c | 8 +- lib/silcutil/tests/test_silcstrutil.c | 10 +- lib/silcutil/tests/test_silcthread.c | 6 +- lib/silcutil/tests/test_silctime.c | 4 +- lib/silcutil/tests/test_silctimer.c | 10 +- lib/silcutil/unix/.gitignore | 8 +- lib/silcutil/unix/silcunixdir.c | 4 +- lib/silcutil/unix/silcunixnet.c | 9 +- lib/silcutil/unix/silcunixschedule.c | 5 +- lib/silcutil/unix/silcunixsocketstream.c | 5 +- lib/silcutil/unix/silcunixthread.c | 9 +- lib/silcutil/unix/silcunixutil.c | 4 +- lib/silcutil/win32/.gitignore | 8 +- srt.m4 | 89 +- win32/Makefile.am | 4 +- 100 files changed, 1299 insertions(+), 2217 deletions(-) create mode 100644 distdir/autodist.conf delete mode 100644 distdir/client create mode 100644 distdir/runtime delete mode 100644 distdir/server create mode 100644 includes/silccompile.h create mode 100644 lib/Makefile.runtime.ad delete mode 100644 lib/configure.ad diff --git a/.gitignore b/.gitignore index 4c10a89f..67ff1f2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +.gitignore +autodist.dist +autodist.log +makedist.log Makefile Makefile.defines Makefile.defines_int @@ -14,12 +18,13 @@ config.status config.sub configure configure.in +configure.ac libtool libtool-shared ltconfig ltmain.sh -stamp-h -stamp-h.in +stamp-h* +stamp-h*.in *.o *.lo *.am diff --git a/CHANGES.RUNTIME b/CHANGES.RUNTIME index d62f668f..5be15e26 100644 --- a/CHANGES.RUNTIME +++ b/CHANGES.RUNTIME @@ -1,3 +1,8 @@ +This file is not updated anymore manually. See git history for same +information. + +----------------------------------------------------------------------------- + Thu Jan 17 16:40:49 EET 2008 Pekka Riikonen * Added SILC Thread Queue API to lib/silcutil/silcthreadqueue.[ch]. @@ -362,4 +367,4 @@ Mon Jul 2 17:13:51 EEST 2007 Pekka Riikonen ----------------------------------------------------------------------------- -For older changes please see the CHANGES file from the CVS tree. +For older changes please see the CHANGES file from the GIT tree. diff --git a/Makefile.ad b/Makefile.ad index e7dacff6..611d85ae 100644 --- a/Makefile.ad +++ b/Makefile.ad @@ -18,36 +18,15 @@ AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign SUBDIRS = \ -#ifdef SILC_DIST_LIB @LIBSUBDIR@ \ -#endif SILC_DIST_LIB -#ifdef SILC_DIST_APPS apps \ -#endif SILC_DIST_APPS -#ifdef SILC_DIST_TOOLKIT win32 \ -#endif SILC_DIST_TOOLKIT -#ifdef SILC_DIST_INCLUDES includes \ -#endif SILC_DIST_INCLUDES -#ifdef SILC_DIST_DOC doc -#endif SILC_DIST_DOC EXTRA_DIST = \ silcdefs.h.in \ -#ifdef SILC_DIST_TOOLKIT - silc-toolkit.spec \ symbian \ -#endif SILC_DIST_TOOLKIT -#ifdef SILC_DIST_CLIENT - README.PLUGIN \ -#endif SILC_DIST_CLIENT -#ifdef SILC_DIST_SILC - libtoolfix \ CHANGES CREDITS -#endif SILC_DIST_SILC -#ifdef SILC_DIST_SILC include $(top_srcdir)/Makefile.defines.in -#endif SILC_DIST_SILC diff --git a/Makefile.defines_int.in b/Makefile.defines_int.in index 8d639153..92fd95cd 100644 --- a/Makefile.defines_int.in +++ b/Makefile.defines_int.in @@ -30,7 +30,7 @@ silc_install_prefix=@prefix@ # Common libraries that are linked against the created executable # SILC_COMMON_LDFLAGS= @LDFLAGS@ -SILC_COMMON_LIBS= -lsilc @LIBS@ +SILC_COMMON_LIBS= @LIBS@ # # Common compilation flags @@ -57,4 +57,4 @@ mandir = $(DESTDIR)@mandir@ #ifdef SILC_DIST_SERVER silc_logsdir=@LOGSDIR@ logsdir = $(DESTDIR)$(silc_logsdir) -#endif SILC_DIST_SERVER \ No newline at end of file +#endif SILC_DIST_SERVER diff --git a/TODO b/TODO index 9ae27025..4a432c67 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,5 @@ -TODO for 1.2 And Beyond -======================= +SILC Runtime Toolkit 1.2 and beyond +=================================== NOTE: Any item that doesn't have (***DONE) in it, isn't done yet. The (***TESTING NEEDED) means that the item has been done but not yet properly @@ -38,61 +38,15 @@ General to include support for OpenPGP, X.509 and SSH2. -lib/silccore -============ - - o SILC_PACKET_FLAG_ACK support. Implement ACK packet and packet payload - to silcpacket.c. - - o All payload encoding routines should take SilcStack as argument. - - o Remove SilcCommandCb from silccommand.h. - - o All payload test routines into lib/silccore/tests/. - - -lib/silcclient, The Client Library -================================== - - o UDP SILC connection support to SILC server - - o Giving WHOIS for nick that doesn't exist should remove any same - named entries from the client cache. - - o peer-to-peer private messages - - o Private message key request notification to application. See XXX in - client_prvmsg.c. - - o in JOIN notify handle resolving that timedout. Currently the user is - never joined the channel if this happens. What to do if message is - received from user that hasn't been resolved/joined? - - o Add the SilcStream (socket stream) from the SilcPacketStream and - SilcSocket from the socket stream to SilcClientConnection for easier - access to them for programmers. Currently these have to be digged up - from the packet stream. - - o Connection option that attemps to connect to remot host with various - different mechanisms: UDP 706, TCP 706, TCP 80, TCP 443, UDP 7706 and - TCP 7706. This is the so called hole punching mechanism. - - o Message ACKing support. - - o in /cmode and /cumode with +r, maybe the public key and private key - could be just some "string", which would then match to "string.pub" and - "string.prv". - - o If the SILC Events (see below) are implemented, perhaps client library - should provide events so that application developer has a choice of - developing the SILC app with callbacks or with events. - - o Ability to recover from rekey errors, at least try to. - - Runtime library, lib/silcutil/ ============================== + o Simple SILC Rand API for pseudo-random numbers. use SILC Crypto + Toolkit for really good random numbers. + + o file removing, chmod, rmmod, etc. chdir, rmdir etc. to + lib/silcutil/silcfileutil.h. + o silc_malloc et. al. to respect --with-alignment. o Fix universal time decoding (doesn't accept all formats) in silctime.c. @@ -211,347 +165,3 @@ lib/silcutil/symbian/ like silc_debug etc. They won't work on EPOC. Perhaps logging and debugging is to be disabled on EPOC. The logging currently works by it cannot be controlled, same with debugging. - - -SFTP Library, lib/silcsftp/ -=========================== - - o Read prefetch (read-ahead, reading ahead of time). Maybe if this can - be done easily. - - -SKR Library, lib/silcskr/ -========================= - - o Add fingerprint as search constraint. - - o Add OpenPGP support. Adding, removing, fetching PGP keys. (Keyring - support?) - - o Add support for importing public keys from a directory and/or from a - file. Add support for exporting the repository (different formats for - different key types?). - - o Change the entire silc_skr_find API. Remove SilcSKRFind and just simply - add the find constraints as variable argument list to silc_skr_find, eg: - - silc_skr_find(skr, schedule, callback, context, - SILC_SKR_FIND_PUBLIC_KEY, public_key, - SILC_SKR_FIND_COUNTRY, "FI", - SILC_SKR_FIND_USAGE, SILC_SKR_USAGE_AUTH, - SILC_SKR_FIND_END); - - NULL argument would be ignored and skipped. - - o Add OR logical rule in addition of the current default AND, eg: - - // Found key(s) MUST have this public key AND this country. - silc_skr_find(skr, schedule, callback, context, - SILC_SKR_FIND_RULE_AND, - SILC_SKR_FIND_PUBLIC_KEY, public_key, - SILC_SKR_FIND_COUNTRY, "FI", - SILC_SKR_FIND_END); - - // Found key(s) MUST have this public key OR this key context - silc_skr_find(skr, schedule, callback, context, - SILC_SKR_FIND_RULE_OR, - SILC_SKR_FIND_PUBLIC_KEY, public_key, - SILC_SKR_FIND_CONTEXT, key_context, - SILC_SKR_FIND_END); - - o SilcStack to SKR API. - - -Crypto Library, lib/silccrypt/ -============================== - - o Add silc_crypto_init and silc_crypto_uninit. The _init should take - SilcStack that will act as global memory pool for all of crypto - library. It should not be necessary anymore to separately register - default ciphers, HMACs, etc, the _init would do that. However, if - user after _init calls silc_pkcs_register, for example, it would take - preference over the default once, ie. user can always dictate the - order of algorithms. (***DONE) - - o Add fingerprint to SilcSILCPublicKey and retrieval to silcpk.h, and - possibly to silcpkcs.h. - - /* Return fingerprint of the `public_key'. Returns also the algorithm - that has been used to make the fingerprint. */ - const unsigned char * - silc_pkcs_get_fingerprint(SilcPublicKey public_key, - const char **hash_algorithm, - SilcUInt32 *fingerprint_len); - - o Change SILC PKCS API to asynchronous, so that accelerators can be used. - All PKCS routines should now take callbacks as argument and they should - be delivered to SilcPKCSObject and SilcPKCSAlgorithm too. (***DONE) - - o The asynchronous functions to perhaps to _async to preserve backwards - compatibility with synchronous versions, and make easier to migrate - from 1.1 to 1.2. - - o Change PKCS Algorithm API to take SilcPKCSAlgorithm as argument to - encrypt, decrypt, sign and verify functions. We may need to for exmaple - check the alg->hash, supported hash functions. Maybe deliver it also - to all other functions in SilcPKCSAlgorithm to be consistent. (***DONE) - - o Add DSA support to SILC public key. - - o Add DSS support. (***DONE) - - o Implement the defined SilcDH API. The definition is in - lib/silccrypt/silcdh.h. Make sure it is asynchronous so that it can - be accelerated. Also take into account that it could use elliptic - curves. - - o Add ECDSA support. - - o Add ECDH support. - - o AES CBC is missing proper alignment code (see silc_1_1_branch). - - o All cipher, hash, hmac etc. allocation routines should take their name - in as const char * not const unsigned char *. (***DONE) - - -SILC Accelerator Library -======================== - - o SILC Accelerator API. Provides generic way to use different kind of - accelerators. Basically implements SILC PKCS API so that SilcPublicKey - and SilcPrivateKey can be used but they call the accelerators. - (***DONE) - - o Implement software accelerator. It is a thread pool system where the - public key and private key operations are executed in threads. - (***DONE) - - o Add init options to SilcAcceleratorObject as a SilcAcceleratorOption - structure. Each accelerator defines the options that they support and - can be retrieved from the SilcAccelerator with silc_acc_get_options. - The format must also be machine parseable. The structure can be of the - following format: - - typedef struct SilcAcceleratorOptionStruct { - const char *option; /* Option name */ - const char *display_name; /* Option displayable name */ - SilcParamType type; /* Option data format */ - void *default_value; /* Option's default value */ - SilcUInt32 default_value_len; /* Default value length */ - } *SilcAcceleratorOption; - - For software accelerator it could be for example: - - { "min_threads", "Minimum threads", SILC_PARAM_UINT32, (void *)2, 4 }, - { "max_threads", "Maximum threads", SILC_PARAM_UINT32, (void *)4, 4 }, - - o Diffie-Hellman acceleration - - (o Symmetric key cryptosystem acceleration? They are always sycnhronouos - even with hardware acceleration so the crypto API shouldn't require - changes.) maybe - - -lib/silcmath -============ - - o Import TFM. We want TFM's speed but its memory requirements are - just too much. By default it uses large pre-allocated tables which - will eat memory when there are thousands of public keys in system. - We probably want to change TFM's fp_int dynamic so that a specific - size can be allocated for the int. We could have two new functions: - - SilcBool silc_mp_init_size(SilcMPInt *mp, SilcUInt32 bit_size); - SilcBool silc_mp_sinit_size(SilcStack stack, SilcMPInt *mp, - SilcUInt32 bit_size); - - Which by default allocates `bit_size' bits instead of some default - value. silc_mp_init would allocate the default FP_SIZE with TFM - and do normal init with TMA and GMP. _init_size with TMA and GMP - would be same as _init. - - o Add AND, OR and XOR support to TFM or ask Tom to do it. - - o The SILC MP API function must start returning indication of success - and failure of the operation. - - o Do SilcStack support for silc_mp_init, silc_mp_init_size and other - any other MP function (including utility ones) that may allocate - memory. - - o Prime generation progress using callback instead of printing to - stdout. - - o All utility functions should be made non-allocating ones. - - -SILC XML Library, lib/silcxml/ -============================== - - o SILC XML API (wrapper to expat). Look at the expat API and simplify - it. The SILC XML API should have at most 8-10 API functions. It should - be possible to create full XML parser with only one function. And, it - should be possible to have a function that is able to parse an entire - XML document. It should also have a parser function to be able to - parse a stream of XML data (SilcStream). It MUST NOT have operations - that require multiple function calls to be able to execute that one - operation (like creating parser). - - -lib/silcske/silcske.[ch] -======================== - - o Ratelimit to UDP/IP transport for incoming packets. - - -lib/silcasn1 -============ - - o Negative integer encoding is missing, add it. - - o SILC_ASN1_CHOICE should perhaps return an index what choice in the - choice list was found. Currently it is left for caller to figure out - which choice was found. (***DONE) - - o SILC_ASN1_NULL in decoding should return SilcBool whether or not - the NULL was present. It's important when it's SILC_ASN1_OPTIONAL - and we need to know whether it was present or not. (***DONE) - - -lib/silcpgp -=========== - - o OpenPGP certificate support, allowing the use of PGP public keys. - - -lib/silcssh -=========== - - o SSH2 public key/private key support, allowing the use of SSH2 keys. - RFC 4716. (***DONE) - - -lib/silcpkix -============ - - o PKIX implementation - - -apps/silcd -========== - - o Deprecate the old server. Write interface for the new lib/silcserver - server library. The interface should work on Unix/Linux systems. - - o Consider deprecating also the old config file format and use XML - istead. This should require SILC XML API implementation first. - - o The configuration must support dynamic router and server connections. - The silcd must work without specifying any servers or routers to - connect to. - - o The configuration must support specifying whether the server is - SILC Server or SILC Router. This should not be deduced from the - configuration as it was in < 1.2. - - o The configuration must support specifying the ciphers and hmacs and - their order so that user can specify which algorithms take preference. - - -lib/silcserver -============== - - o Rewrite the entire server. Deprecate apps/silcd as the main server - implementation and create lib/silcserver/. It is a platform - independent server library. The apps/silcd will merely provide a - a simple interface for the library. - - o Write the SILC Server library extensively using SILC FSM. - - o Server library must support multiple networks. This means that one - server must be able to create multiple connections that each reach - different SILC network. This means also that all cache's etc. must - be either connection-specific or network-specific. - - o Library must support dynamic router and server connections. This means - that connections are create only when they are needed, like when someone - says JOIN foo@foo.bar.com or WHOIS foobar@silcnet.org. - - o Library must support server-to-server connections even though protocol - prohibits that. The responder of the connection should automatically - act as a router. The two servers create an own, isolated, SILC network. - To be used specifically with dynamic connections. - - o Library must support multiple threads and must be entirely thread safe. - - o Library must have support for SERVICE command. - - o Both UDP and TCP support for incoming connecetions. Maintaining long - term UDP sessions. - - o The server must be able to run behind NAT device. This means that - Server ID must be based on public IP instead of private IP (See - also NAT detection protocol in SILC protocol specification). - - o The following data must be in per-connection context: client id cache, - server id cache, channel id cache, all statistics must be - per-connection. - - o The following data must be in per-thread context: command context - freelist/pool, pending commands, random number generator. - - o Do inccoming packet processing in an own FSM thread in the - server-threads FSM. Same as in client library. - - o Binding to other ports than 706 too. To allow easier traversing - through NATs and firewalls server should also bind to 80, 443 and 7706 - by default (at least try to bind). Connections must work normally - even if they were established to some other port other than 706. - - Connection option that attemps to connect to remot server with various - different mechanisms: UDP 706, TCP 706, TCP 80, TCP 443, UDP 7706 and - TCP 7706. This is the so called hole punching mechanism. - - o Ability to recover from rekey errors, at least try to. - - o Reference count all Silc*Entry structures. - - Some issues that must be kept in mind from 1.0 and 1.1 silcd's: - - o The server and router software MUST work out of the box. After - installation the server must not require any configuration to run the - most basic working configuration. No defining IP addresses, etc. - The server must work just by running it. - - o The SERVER_SIGNOFF notify handing is not optimal, because it'll - cause sending of multiple SIGNOFF notify's instead of the one - SERVER_SIGNOFF notify that the server received. This should be - optimized so that the only SERVER_SIGNOFF is sent and not - SIGNOFF of notify at all (using SIGNOFF takes the idea about - SERVER_SIGNOFF away entirely). - - o Another SERVER_SIGNOFF opt/bugfix: Currently the signoff is - sent to a client if it is on same channel as the client that - signoffed. However, the entire SERVER_SIGNOFF list is sent to - the client, ie. it may receive clients that was not on the - same channel. This is actually against the specs. It must be - done per channel. It shouldn't receive the whole list just - because one client happened to be on same channel. - - o If client's public key is saved in the server (and doing public key - authentication) then the hostname and the username information could - be taken from the public key. Should be a configuration option! - - o Add a timeout to handling incoming JOIN commands. It should be - enforced that JOIN command is executed only once in a second or two - seconds. Now it is possible to accept n incoming JOIN commands - and process them without any timeouts. THis must be employed because - each JOIN command will create and distribute the new channel key - to everybody on the channel. - - o Related to above. If multiple JOINs are received in sequence perhaps - new key should be created only once, if the JOINs are handeled at the same - time. Now we create multiple keys and never end up using them because - many JOINs are processed at the same time in sequence. Only the last - key ends up being used. diff --git a/apps/Makefile.ad b/apps/Makefile.ad index 4c8d26d6..42c6b686 100644 --- a/apps/Makefile.ad +++ b/apps/Makefile.ad @@ -17,21 +17,4 @@ AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign -SUBDIRS = \ -#ifdef SILC_DIST_AUTODIST - autodist \ -#endif SILC_DIST_AUTODIST -#ifdef SILC_DIST_SERVER - @SILCD_SUBDIR@ \ -#endif SILC_DIST_SERVER -#ifdef SILC_DIST_CLIENT - @IRSSI_SUBDIR@ \ -#endif SILC_DIST_CLIENT -#ifdef SILC_DIST_INPLACE -# silcstress \ -#endif SILC_DIST_INPLACE -#ifdef SILC_DIST_ASN1UTILS - asn1utils \ -#endif SILC_DIST_ASN1UTILS - - +SUBDIRS = diff --git a/configure.ad b/configure.ad index a162625a..3fad7429 100644 --- a/configure.ad +++ b/configure.ad @@ -29,30 +29,81 @@ AC_PROG_EGREP AC_SUBST(LN_S) AC_PATH_PROG(sedpath, sed) -#ifdef SILC_DIST_COMPILER +AC_PROG_CC +AM_PROG_AS +AC_C_INLINE +AC_C_CONST + +AC_PROG_RANLIB +#ifdef SILC_DIST_INPLACE +AC_DISABLE_SHARED +#endif SILC_DIST_INPLACE +AC_PROG_LIBTOOL + +SILC_TOP_SRCDIR=`pwd` + +## +## Library versioning. +## -# Put here any platform specific stuff +# Do the releases and library versioning according to following rules: # -case "$target" in - *-*-linux*) - check_threads=true - CFLAGS=`echo $CFLAGS -D_GNU_SOURCE` - ;; - *-*-freebsd*) - check_threads=true - ;; - *-*-netbsd*) - check_threads=true - ;; - *-*-*bsd*) - check_threads=false - ;; - *) - check_threads=true - ;; -esac +# - If any code has changed in library, increment RUNTIME_REVISION +# - If API were added, removed or changed, set RUNTIME_REVISION to 0 +# - If API were added, removed or changed, increment RUNTIME_CURRENT +# - If APi were added, increment RUNTIME_AGE +# - If API were removed, set RUNTIME_AGE to 0 +# + +# Base version for library. +RUNTIME_BASE_VERSION=1.2 + +# libsilc versions +RUNTIME_CURRENT=1 # prev = 0 +RUNTIME_REVISION=0 # prev = 0 +RUNTIME_AGE=0 # prev = 0 + +# Substitute the version numbers +AC_SUBST(RUNTIME_BASE_VERSION) +AC_SUBST(RUNTIME_CURRENT) +AC_SUBST(RUNTIME_REVISION) +AC_SUBST(RUNTIME_AGE) + + +## +## Installation +## + +# Default installation destination +AC_PREFIX_DEFAULT(/usr/local) +if test "x$prefix" != xNONE; then + silc_prefix="$prefix" +else + silc_prefix="$ac_default_prefix" + prefix="$silc_prefix" +fi + + +## +## Detect CPU +## + +# Disable all CPU feature optimizations +AC_MSG_CHECKING(whether to enable CPU feature optimizations) +AC_ARG_ENABLE(cpu-optimizations, + [ --disable-cpu-optimizations do not use any CPU feature optimizations], + [ + AC_MSG_RESULT(no) + AC_DEFINE([SILC_NO_CPU_OPTIMIZATIONS], [], [SILC_NO_CPU_OPTIMIZATIONS]) + want_cpu_optimizations=false + ], + [ + AC_MSG_RESULT(yes) + want_cpu_optimizations=true + ]) +AM_CONDITIONAL(SILC_NO_CPU_OPTIMIZATIONS, + test x$want_cpu_optimizations = xfalse) -# Get CPU SILC_SYSTEM_IS_SMP(AC_DEFINE([SILC_SMP], [], [SILC_SMP]), [], AC_DEFINE([SILC_SMP], [], [SILC_SMP])) cpu_i386=false @@ -94,11 +145,11 @@ case "$host_cpu" in fi # Check for specific CPU features - SILC_CPU_FLAG(mmx, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), []) - SILC_CPU_FLAG(sse2, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), []) - SILC_CPU_FLAG(pni, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), []) - SILC_CPU_FLAG(ssse3, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), []) - SILC_CPU_FLAG(sse4, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), []) + SILC_CPU_FLAG(mmx, true, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), []) + SILC_CPU_FLAG(sse2, true, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), []) + SILC_CPU_FLAG(pni, true, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), []) + SILC_CPU_FLAG(ssse3, true, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), []) + SILC_CPU_FLAG(sse4, true, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), []) ;; # Intel IA-64, 64-bit CPU (not x86_64 compatible) @@ -107,11 +158,11 @@ case "$host_cpu" in cpu_ia64=true # Check for specific CPU features - SILC_CPU_FLAG(mmx, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), []) - SILC_CPU_FLAG(sse2, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), []) - SILC_CPU_FLAG(pni, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), []) - SILC_CPU_FLAG(ssse3, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), []) - SILC_CPU_FLAG(sse4, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), []) + SILC_CPU_FLAG(mmx, true, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), []) + SILC_CPU_FLAG(sse2, true, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), []) + SILC_CPU_FLAG(pni, true, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), []) + SILC_CPU_FLAG(ssse3, true, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), []) + SILC_CPU_FLAG(sse4, true, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), []) ;; # AMD/Intel x86_64, 64-bit CPU @@ -120,11 +171,11 @@ case "$host_cpu" in cpu_x86_64=true # Check for specific CPU features - SILC_CPU_FLAG(mmx, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), []) - SILC_CPU_FLAG(sse2, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), []) - SILC_CPU_FLAG(pni, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), []) - SILC_CPU_FLAG(ssse3, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), []) - SILC_CPU_FLAG(sse4, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), []) + SILC_CPU_FLAG(mmx, true, AC_DEFINE([SILC_CPU_MMX], [], [SILC_CPU_MMX]), []) + SILC_CPU_FLAG(sse2, true, AC_DEFINE([SILC_CPU_SSE2], [], [SILC_CPU_SSE2]), []) + SILC_CPU_FLAG(pni, true, AC_DEFINE([SILC_CPU_SSE3], [], [SILC_CPU_SSE3]), []) + SILC_CPU_FLAG(ssse3, true, AC_DEFINE([SILC_CPU_SSSE3], [], [SILC_CPU_SSSE3]), []) + SILC_CPU_FLAG(sse4, true, AC_DEFINE([SILC_CPU_SSE4], [], [SILC_CPU_SSE4]), []) ;; # PowerPC, 32-bit and 64-bit CPUs @@ -142,82 +193,67 @@ AM_CONDITIONAL(SILC_X86_64, test x$cpu_x86_64 = xtrue) AM_CONDITIONAL(SILC_POWERPC, test x$cpu_ppc = xtrue) AM_CONDITIONAL(SILC_IA64, test x$cpu_ia64 = xtrue) -# Control compiler optimizations -CFLAGS=`echo $CFLAGS | sed 's/-O[ 0123456789s]*//g'` - -AC_PROG_CC -AC_C_INLINE -AC_C_CONST - -# Set some compiler options based on CPU -if test "x$CC" = "xicc"; then - # ICC flags - if test x$x_have_cpu_sse2 = xtrue; then - SILC_ADD_CFLAGS(-axW) - fi - if test x$x_have_cpu_sse3 = xtrue; then - SILC_ADD_CFLAGS(-axP) - fi - if test x$x_have_cpu_ssse3 = xtrue; then - SILC_ADD_CFLAGS(-axT) - fi - if test x$x_have_cpu_sse4 = xtrue; then - SILC_ADD_CFLAGS(-axS) - fi -else - # Other compilers - if test x$x_have_cpu_sse2 = xtrue; then - SILC_ADD_CFLAGS(-msse2) - fi - if test x$x_have_cpu_pni = xtrue; then - SILC_ADD_CFLAGS(-msse3) - fi - if test x$x_have_cpu_ssse3 = xtrue; then - SILC_ADD_CFLAGS(-mssse3) - fi - if test x$x_have_cpu_sse4 = xtrue; then - SILC_ADD_CFLAGS(-msse3) +if test x$want_cpu_optimizations = xtrue; then + # Set some compiler options based on CPU + if test "x$CC" = "xicc"; then + # ICC flags + if test x$x_have_cpu_sse2 = xtrue; then + SILC_ADD_CFLAGS(-axW) + fi + if test x$x_have_cpu_sse3 = xtrue; then + SILC_ADD_CFLAGS(-axP) + fi + if test x$x_have_cpu_ssse3 = xtrue; then + SILC_ADD_CFLAGS(-axT) + fi + if test x$x_have_cpu_sse4 = xtrue; then + SILC_ADD_CFLAGS(-axS) + fi + else + # Other compilers + if test x$x_have_cpu_sse2 = xtrue; then + SILC_ADD_CFLAGS(-msse2) + fi + if test x$x_have_cpu_pni = xtrue; then + SILC_ADD_CFLAGS(-msse3) + fi + if test x$x_have_cpu_ssse3 = xtrue; then + SILC_ADD_CFLAGS(-mssse3) + fi + if test x$x_have_cpu_sse4 = xtrue; then + SILC_ADD_CFLAGS(-msse4) + fi fi fi -__SILC_HAVE_PTHREAD="" -__SILC_HAVE_SIM="" -__SILC_ENABLE_DEBUG="" -#ifdef SILC_DIST_TOOLKIT -toolkitver=`echo $VERSION | sed 's/\./ /g'` -maj=0 -min=0 -bld=0 -for v in $toolkitver -do - if test $maj -eq 0; then - maj=$v - continue - fi - if test $min -eq 0; then - min=$v - continue - fi - if test $bld -eq 0; then - bld=$v - continue - fi -done -__SILC_PACKAGE_VERSION="#define __SILC_TOOLKIT_VERSION SILC_VERSION($maj,$min,$bld)" -#endif SILC_DIST_TOOLKIT +## +## Put here any platform specific stuff +## -AC_PROG_RANLIB -#ifndef SILC_DIST_TOOLKIT -AC_DISABLE_SHARED -#endif SILC_DIST_TOOLKIT -#ifdef SILC_DIST_INPLACE -AC_DISABLE_SHARED -#endif SILC_DIST_INPLACE -AC_PROG_LIBTOOL +case "$target" in + *-*-linux*) + check_threads=true + CFLAGS=`echo $CFLAGS -D_GNU_SOURCE` + ;; + *-*-freebsd*) + check_threads=true + ;; + *-*-netbsd*) + check_threads=true + ;; + *-*-*bsd*) + check_threads=false + ;; + *) + check_threads=true + ;; +esac -# Header checking -# + +## +## Header checking +## AC_HEADER_STDC AC_HEADER_TIME AC_HEADER_STAT @@ -231,14 +267,15 @@ AC_CHECK_HEADERS(pwd.h grp.h termcap.h paths.h) AC_CHECK_HEADERS(ncurses.h signal.h ctype.h utime.h dirent.h) AC_CHECK_HEADERS(arpa/inet.h sys/mman.h limits.h termios.h locale.h langinfo.h) -# Data type checking -# + +## +## Data type checking +## AC_TYPE_SIGNAL AC_TYPE_SIZE_T AC_TYPE_MODE_T AC_TYPE_UID_T AC_TYPE_PID_T - AC_CHECK_SIZEOF(long long, 0) AC_SUBST(SILC_SIZEOF_LONG_LONG, $ac_cv_sizeof_long_long) AC_CHECK_SIZEOF(long, 0) @@ -254,24 +291,90 @@ AC_SUBST(SILC_SIZEOF_VOID_P, $ac_cv_sizeof_void_p) AC_CHECK_TYPES(long long) AC_CHECK_TYPES(long double) -# Function and library checking -# -AC_CHECK_FUNC(gethostbyname, [], +# Check for big-endian machines +AC_C_BIGENDIAN + + +## +## Compiler and compiler flag checks +## + +# Disable all compiler optimizations +AC_MSG_CHECKING(whether to enable compiler optimizations) +AC_ARG_ENABLE(optimizations, + [ --disable-optimizations do not use any compiler optimizations], [ - AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl") - AC_CHECK_FUNC(res_gethostbyname, [], - AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv") - ) - ]) -AC_CHECK_FUNC(socket, [], - AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket") -) -AC_CHECK_FUNC(clock_gettime, [], + AC_MSG_RESULT(no) + AC_DEFINE([SILC_NO_CC_OPTIMIZATIONS], [], [SILC_NO_CC_OPTIMIZATIONS]) + want_cc_optimizations=false + ], [ - AC_CHECK_LIB(rt, clock_gettime, - [ LIBS="$LIBS -lrt" - AC_DEFINE([HAVE_CLOCK_GETTIME], [], [HAVE_CLOCK_GETTIME])]) + AC_MSG_RESULT(yes) + want_cc_optimizations=true ]) +AM_CONDITIONAL(SILC_NO_CC_OPTIMIZATIONS, test x$want_cc_optimizations = xfalse) + +if test "$GCC"; then + # GCC specific options + if test "x$summary_debug" = "xyes"; then + SILC_ADD_CFLAGS(-g) + else + SILC_ADD_CFLAGS(-g) + fi + SILC_ADD_CFLAGS(-Wall -finline-functions) + SILC_ADD_CFLAGS(-Wno-pointer-sign) +else + # Other compilers + case "$target" in + alpha*-dec-osf*) + SILC_ADD_CFLAGS(-g3) + ;; + mips*-sgi-irix*) + SILC_ADD_CFLAGS(-g3) + ;; + *) + SILC_ADD_CFLAGS(-g) + ;; + esac + + # Intel C++ Compiler flags + if test "x$CC" = "xicc"; then + SILC_ADD_CFLAGS(-restrict) + SILC_ADD_CFLAGS(-finline-functions) + + # Don't define __GNUC__ except for system includes + SILC_ADD_CFLAGS(-gcc-sys) + fi +fi + +if test x$want_cc_optimizations = xtrue; then + if test "$GCC"; then + # GCC specific options + if test "x$summary_debug" = "xyes"; then + SILC_ADD_CFLAGS(-O) + else + SILC_ADD_CFLAGS(-O2) + fi + else + # Other compilers + case "$target" in + alpha*-dec-osf*) + SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O)) + ;; + mips*-sgi-irix*) + SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O)) + ;; + *) + SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O)) + ;; + esac + fi +fi + + +## +## Function and libary checking +## AC_CHECK_FUNCS(gethostname gethostbyaddr getservbyname getservbyport) AC_CHECK_FUNCS(poll select listen bind shutdown close connect setsockopt) AC_CHECK_FUNCS(setrlimit time ctime utime gettimeofday getrusage) @@ -281,8 +384,7 @@ AC_CHECK_FUNCS(setgroups initgroups nl_langinfo nanosleep) AC_CHECK_FUNCS(strchr snprintf strstr strcpy strncpy memcpy memset memmove) AC_CHECK_FUNCS(setenv getenv putenv unsetenv clearenv) -# lib/contrib conditionals -# +# Check getopt_long AC_CHECK_FUNC(getopt_long, [ AC_DEFINE([HAVE_GETOPT_LONG], [], [HAVE_GETOPT_LONG]) @@ -290,154 +392,50 @@ AC_CHECK_FUNC(getopt_long, ], have_getopt_long=0 ) -## -## Enable/disable checking -## +# Check gethostbyname +AC_CHECK_FUNC(gethostbyname, [], + [ + AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl") + AC_CHECK_FUNC(res_gethostbyname, [], + AC_CHECK_LIB(resolv, res_gethostbyname, LIBS="$LIBS -lresolv") + ) + ]) -# IPv6 support -# -AC_MSG_CHECKING(whether to enable IPv6 support) -AC_ARG_ENABLE(ipv6, - [ --enable-ipv6 enable IPv6 support], +# Check socket +AC_CHECK_FUNC(socket, [], + AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket") +) + +# Check clock_gettime +AC_CHECK_FUNC(clock_gettime, [], [ - case "${enableval}" in - yes) - want_ipv6=true - check_ipv6=false - summary_ipv6="yes" - AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6]) - AC_MSG_RESULT(yes) - ;; - *) - want_ipv6=false - check_ipv6=false - summary_ipv6="no" - AC_MSG_RESULT(no) - ;; - esac - ], - check_ipv6=true - ) - -if test x$check_ipv6 = xtrue; then - summary_ipv6="no" - AC_TRY_COMPILE( - [ - #ifdef HAVE_SYS_TYPES_H - #include - #endif - #ifdef HAVE_NETINET_TCP_H - #include - #endif - #ifdef HAVE_NETDB_H - #include - #endif - #include - #ifdef HAVE_NETINET_IN_H - #include - #endif - ], - [ - struct sockaddr_in6 sin6; - int family = AF_INET6; - ], - [ - AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6]) - AC_MSG_RESULT(yes) - summary_ipv6="yes" - ], - AC_MSG_RESULT(no) - ) -fi - -# Debug checking -# -AC_MSG_CHECKING(whether to enable debugging) -summary_debug="no" -__SILC_ENABLE_DEBUG="" -AC_ARG_ENABLE(debug, - [ --enable-debug enable debugging], - [ - case "${enableval}" in - yes) - AC_MSG_RESULT(yes) - AC_DEFINE([SILC_DEBUG], [], [enable-debug]) - summary_debug="yes" - __SILC_ENABLE_DEBUG="#define __SILC_ENABLE_DEBUG 1" - ;; - *) - AC_MSG_RESULT(no) - ;; - esac - ], - [ - AC_MSG_RESULT(no) + AC_CHECK_LIB(rt, clock_gettime, + [ LIBS="$LIBS -lrt" + AC_DEFINE([HAVE_CLOCK_GETTIME], [], [HAVE_CLOCK_GETTIME])]) ]) -# Disable all compiler optimizations -# -AC_MSG_CHECKING(whether to enable compiler optimizations) -want_cc_optimizations=true -AC_ARG_ENABLE(optimizations, - [ --disable-optimizations do not use any compiler optimizations], +# Check for epoll_wait and verify that epoll_create works +AC_CHECK_FUNC(epoll_wait, [ - AC_MSG_RESULT(no) - AC_DEFINE([SILC_NO_CC_OPTIMIZATIONS], [], [SILC_NO_CC_OPTIMIZATIONS]) - want_cc_optimizations=false - ], - [ - AC_MSG_RESULT(yes) - want_cc_optimizations=true + AC_RUN_IFELSE( + [ + #include + int main() + { + int ret = epoll_create(5); + if (ret < 0) + return 1; + close(ret); + return 0; + } + ], + [ + AC_DEFINE([HAVE_EPOLL_WAIT], [1], [HAVE_EPOLL_WAIT]) + ], + ) ]) -AM_CONDITIONAL(SILC_NO_CC_OPTIMIZATIONS, test x$want_cc_optimizations = xfalse) -# Disable all assembler optimizations -# -AC_MSG_CHECKING(whether to enable assembler optimizations) -want_asm=true -AC_ARG_ENABLE(asm, - [ --disable-asm do not use assembler optimizations], - [ - AC_MSG_RESULT(no) - AC_DEFINE([SILC_NO_ASM], [], [SILC_NO_ASM]) - want_asm=false - ], - [ - AC_MSG_RESULT(yes) - want_asm=true - ]) -AM_CONDITIONAL(SILC_NO_ASM, test x$want_asm = xfalse) - -# Check for assembler -# -SILC_ASSEMBLER="" -have_assembler=false -if test x$want_asm = xtrue; then - AC_PATH_PROG([NASM], [nasm], [no]) - if test "x$NASM" != "xno"; then - if test x$cpu_x86_64 = xtrue; then - SILC_ASSEMBLER="$NASM -O2 -felf64" - else - SILC_ASSEMBLER="$NASM -O2 -felf" - fi - have_assembler=true - fi - - AC_PATH_PROG([YASM], [yasm], [no]) - if test "x$YASM" != "xno"; then - if test x$cpu_x86_64 = xtrue; then - SILC_ASSEMBLER="$YASM -Xgnu -felf64" - else - SILC_ASSEMBLER="$YASM -Xgnu -felf" - fi - have_assembler=true - fi -fi -AC_SUBST(SILC_ASSEMBLER) - -## -## va_copy checks -## +# Check for va_copy va_copy=false AC_MSG_CHECKING(for va_copy) AC_TRY_COMPILE( @@ -538,400 +536,324 @@ if test x$va_copy = xfalse; then ) fi -## -## Compiler and compiler flag checks -## +# Check for timezone and tm_gmtoff for timezone information +AC_MSG_CHECKING(whether system has timezone) +AC_RUN_IFELSE( + [ + #include + #include + int main() + { + timezone = 0; + return 0; + } + ], + [ AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_TIMEZONE], [], [HAVE_TIMEZONE]) ], + [ AC_MSG_RESULT(no) ], + [ AC_MSG_RESULT(no) ] +) +AC_MSG_CHECKING(whether system has tm_gmtoff) +AC_RUN_IFELSE( + [ + #include + #include + int main() + { + struct tm tm; + tm.tm_gmtoff = 0; + return 0; + } + ], + [ AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_TM_GMTOFF], [], [HAVE_TM_GMTOFF]) ], + [ AC_MSG_RESULT(no) ], + [ AC_MSG_RESULT(no) ] +) +AC_MSG_CHECKING(whether system has __tm_gmtoff) +AC_RUN_IFELSE( + [ + #include + #include + int main() + { + struct tm tm; + tm.__tm_gmtoff = 0; + return 0; + } + ], + [ AC_MSG_RESULT(yes) + AC_DEFINE([HAVE___TM_GMTOFF], [], [HAVE___TM_GMTOFF]) ], + [ AC_MSG_RESULT(no) ], + [ AC_MSG_RESULT(no) ] +) +AC_MSG_CHECKING(whether system has __tm_gmtoff__) +AC_RUN_IFELSE( + [ + #include + #include + int main() + { + struct tm tm; + tm.__tm_gmtoff__ = 0; + return 0; + } + ], + [ AC_MSG_RESULT(yes) + AC_DEFINE([HAVE___TM_GMTOFF__], [], [HAVE___TM_GMTOFF__]) ], + [ AC_MSG_RESULT(no) ], + [ AC_MSG_RESULT(no) ] +) -if test "$GCC"; then - # GCC specific options - if test "x$summary_debug" = "xyes"; then - SILC_ADD_CFLAGS(-g) - else - SILC_ADD_CFLAGS(-g) - fi - SILC_ADD_CFLAGS(-Wall -finline-functions) - SILC_ADD_CFLAGS(-Wno-pointer-sign) -else - # Other compilers - case "$target" in - alpha*-dec-osf*) - SILC_ADD_CFLAGS(-g3) - ;; - mips*-sgi-irix*) - SILC_ADD_CFLAGS(-g3) - ;; - *) - SILC_ADD_CFLAGS(-g) - ;; - esac +# Check for dlopen() and friends +AC_CHECK_HEADERS(dlfcn.h, + [ + AC_CHECK_LIB(dl, dlopen, + [ + AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN]) + LIBS="$LIBS -ldl" + ], + [ + AC_CHECK_LIB(c, dlopen, + [ + AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN]) + ]) + ]) + ]) - # Intel C++ Compiler flags - if test "x$CC" = "xicc"; then - SILC_ADD_CFLAGS(-restrict) - SILC_ADD_CFLAGS(-finline-functions) +__SILC_ENABLE_DEBUG="" - # Don't define __GNUC__ except for system includes - SILC_ADD_CFLAGS(-gcc-sys) +runtimever=`echo $VERSION | sed 's/\./ /g'` +maj=0 +min=0 +bld=0 +for v in $runtimever +do + if test $maj -eq 0; then + maj=$v + continue fi -fi + if test $min -eq 0; then + min=$v + continue + fi + if test $bld -eq 0; then + bld=$v + continue + fi +done +__RUNTIME_PACKAGE_VERSION="#define __SILC_RUNTIME_VERSION SILC_VERSION($maj,$min,$bld)" -if test x$want_cc_optimizations = xtrue; then - if test "$GCC"; then - # GCC specific options - if test "x$summary_debug" = "xyes"; then - SILC_ADD_CFLAGS(-O) - else - SILC_ADD_CFLAGS(-O2) - fi - else - # Other compilers - case "$target" in - alpha*-dec-osf*) - SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O)) - ;; - mips*-sgi-irix*) - SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O)) + +## +## Enable/disable checking +## + +# IPv6 support +AC_MSG_CHECKING(whether to enable IPv6 support) +AC_ARG_ENABLE(ipv6, + [ --enable-ipv6 enable IPv6 support], + [ + case "${enableval}" in + yes) + want_ipv6=true + check_ipv6=false + summary_ipv6="yes" + AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6]) + AC_MSG_RESULT(yes) ;; *) - SILC_ADD_CFLAGS(-O2, SILC_ADD_CFLAGS(-O)) + want_ipv6=false + check_ipv6=false + summary_ipv6="no" + AC_MSG_RESULT(no) ;; esac - fi -fi + ], + check_ipv6=true + ) -# -# Workaround a bug in GCC 2.x which causes memory exhaustion -# when compiling sha1 with optimizations on UltraSPARC. -# -FIX_SHA1='#' -if test "$GCC" -a "$host_cpu" = "sparc64"; then - AC_MSG_CHECKING(whether to enable GCC 2.x workaround for SHA1) +if test x$check_ipv6 = xtrue; then + summary_ipv6="no" AC_TRY_COMPILE( [ - #if defined(__sparc64__) && (__GNUC__ == 2) - #else - choke me + #ifdef HAVE_SYS_TYPES_H + #include + #endif + #ifdef HAVE_NETINET_TCP_H + #include + #endif + #ifdef HAVE_NETDB_H + #include + #endif + #include + #ifdef HAVE_NETINET_IN_H + #include #endif ], - [], [ - FIX_SHA1='' + struct sockaddr_in6 sin6; + int family = AF_INET6; + ], + [ + AC_DEFINE([HAVE_IPV6], [], [HAVE_IPV6]) AC_MSG_RESULT(yes) + summary_ipv6="yes" ], AC_MSG_RESULT(no) ) fi -AC_SUBST(FIX_SHA1) -#endif SILC_DIST_COMPILER - -## -## Installation -## - -# Default installation destination -# -AC_PREFIX_DEFAULT(/usr/local) -if test "x$prefix" != xNONE; then - silc_prefix="$prefix" -else - silc_prefix="$ac_default_prefix" - prefix="$silc_prefix" -fi -#ifndef SILC_DIST_AUTODIST -ETCDIR=`eval echo $sysconfdir`;ETCDIR=`eval echo $ETCDIR` -AC_SUBST(ETCDIR) -AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR]) - -DOCDIR=`eval echo $docdir`;DOCDIR=`eval echo $DOCDIR` -AC_SUBST(DOCDIR) -AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOCDIR]) -#endif SILC_DIST_AUTODIST - -#ifdef SILC_DIST_COMPILER -## -## With/without checkings -## - -# -# SILC library checking -compile_libs=true -LIBSUBDIR=lib - -#ifndef SILC_DIST_TOOLKIT -AC_ARG_WITH(silc-includes, - [ --with-silc-includes=DIR SILC Toolkit includes [search in DIR]], - [ac_silc_includes="$withval"], [ac_silc_includes="no"]) -AC_ARG_WITH(silc-libs, - [ --with-silc-libs=DIR SILC Toolkit libraries [search in DIR]], - [ac_silc_libs="$withval"], [ac_silc_libs="no"]) - -if test -n "$with_silc_includes" || test -n "$with_silc_libs"; then - - # Manually provided libs - if test "$ac_silc_includes" != "no"; then - compile_libs=false - SILC_LIB_INCLUDES="-I$ac_silc_includes" - LIBSUBDIR= - fi - if test "$ac_silc_libs" != "no"; then - compile_libs=false - LIBSUBDIR= - LDFLAGS="-L$ac_silc_libs $LDFLAGS" - else - LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS" - fi - - # Check libs to link against - f=`$EGREP __SILC_HAVE_PTHREAD $ac_silc_includes/silc.h` - if test -n "$f"; then - LIBS="$LIBS -lpthread" - check_threads=false - has_threads=true - fi - f=`$EGREP __SILC_HAVE_SIM $ac_silc_includes/silc.h` - if test -n "$f"; then - LIBS="$LIBS -ldl" - fi - -else - # pkg-config check - PKG_CHECK_MODULES(SILC, [silc >= 1.1], compile_libs=false, compile_libs=true) -#ifdef SILC_DIST_CLIENTLIB - PKG_CHECK_MODULES(SILCCLIENT, [silcclient >= 1.1.1], compile_libs=false, compile_libs=true) -#endif SILC_DIST_CLIENTLIB -#ifdef SILC_DIST_SERVERLIB - PKG_CHECK_MODULES(SILCSERVER, silcserver, compile_libs=false, compile_libs=true) -#endif SILC_DIST_SERVERLIB - - if test x$compile_libs = xfalse; then - LIBSUBDIR= - LIBS="$SILC_LIBS $LIBS" - CFLAGS="$CFLAGS $SILC_CFLAGS" -#ifdef SILC_DIST_CLIENTLIB - LIBS="$SILCCLIENT_LIBS $LIBS" - CFLAGS="$CFLAGS $SILCCLIENT_CFLAGS" -#endif SILC_DIST_CLIENTLIB -#ifdef SILC_DIST_SERVERLIB - LIBS="$LIBS $SILCSERVER_LIBS" - CFLAGS="$CFLAGS $SILCSERVER_CFLAGS" -#endif SILC_DIST_SERVERLIB - else - LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS" - fi -fi - -#else SILC_DIST_TOOLKIT -LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS" -#endif SILC_DIST_TOOLKIT - -#ifdef SILC_DIST_SIM -# SIM support checking -# XXX These needs to be changed as more supported platforms appear. -# XXX This probably needs to be made platform dependant check. -# -sim_support=false -AC_MSG_CHECKING(for SIM support) -AC_MSG_RESULT() -AC_CHECK_HEADERS(dlfcn.h, +# Memory alignment. User can specify what alignment memory allocation and +# SilcStack allocation use. Default is system default alignemnt. +AC_ARG_WITH(alignment, + [ --with-alignment=NUMBER Memory alignment in bytes], [ - AC_CHECK_LIB(dl, dlopen, - [ - AC_DEFINE([SILC_SIM], [], [HAVE_SIM]) - AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN]) - sim_support=true - LIBS="$LIBS -ldl" - ], - [ - AC_CHECK_LIB(c, dlopen, - [ - AC_DEFINE([SILC_SIM], [], [HAVE_SIM]) - AC_DEFINE([HAVE_DLOPEN], [], [HAVE_DLOPEN]) - sim_support=true - ]) - ]) - ]) + AC_DEFINE_UNQUOTED([SILC_ALIGNMENT], [$withval], [SILC_ALIGNMENT]) + AC_MSG_RESULT(Memory allocation alignment is $withval bytes) + ], + [ + AC_DEFINE([SILC_ALIGNMENT], SILC_SIZEOF_VOID_P, [SILC_ALIGNMENT]) + ]) -AM_CONDITIONAL(SILC_SIM, test x$sim_support = xtrue) -if test x$sim_support = xtrue; then - AC_MSG_RESULT(Enabled SIM support.) - __SILC_HAVE_SIM="#define __SILC_HAVE_SIM 1" -else - AC_MSG_RESULT(No SIM support found.) -fi -#endif SILC_DIST_SIM +# Stack trace checking +AC_MSG_CHECKING(whether to enable stack tracing) +AC_ARG_ENABLE(stack-trace, + [ --enable-stack-trace enable memory stack trace], + [ + case "${enableval}" in + yes) + AC_MSG_RESULT(yes) + AC_DEFINE([SILC_STACKTRACE], [], [SILC_STACKTRACE]) + ;; + *) + AC_MSG_RESULT(no) + ;; + esac + ], + AC_MSG_RESULT(no) + ) -# SOCKS4 support checking +#ifdef SILC_DIST_INPLACE # -SAVE_LIBS="$LIBS" -SAVE_CFLAGS="$CFLAGS" -SAVE_LDFLAGS="$LDFLAGS" -AC_MSG_CHECKING(whether to support SOCKS4) -AC_ARG_WITH(socks4, - [[ --with-socks4[=DIR] with SOCKS4 support [search in DIR/lib and DIR/include]]], +# Profiling options (never delivered to distributions) +# +AC_MSG_CHECKING(whether to enable gprof) +AC_ARG_ENABLE(gprof, + [ --enable-gprof enable gprof profiling], [ - case "$withval" in - no) - AC_MSG_RESULT(no) + case "${enableval}" in + yes) + AC_MSG_RESULT(yes) + SILC_ADD_CFLAGS(-pg) + LIBS="$LIBS -pg" ;; *) - AC_MSG_RESULT(yes) - socks=4 - - if test -d "$withval/include"; then - CFLAGS="$CFLAGS -I$withval/include" - fi - if test -d "$withval/lib"; then - LDFLAGS="$LDFLAGS -L$withval/lib" - fi + AC_MSG_RESULT(no) + ;; + esac + ], + [ + AC_MSG_RESULT(no) + ]) - LIBS="-lsocks $LIBS" +AC_MSG_CHECKING(whether to enable gcov) +AC_ARG_ENABLE(gcov, + [ --enable-gcov enable gcov], + [ + case "${enableval}" in + yes) + AC_MSG_RESULT(yes) + SILC_ADD_CFLAGS(-fprofile-arcs) + LIBS="$LIBS -lgcov" + ;; + *) + AC_MSG_RESULT(no) ;; esac - - AC_TRY_LINK([], - [ - Rconnect(); - ], [], - [ - AC_MSG_ERROR(Could not find SOCKS4 library.) - LIBS="$SAVE_LIBS" - CFLAGS="$SAVE_CFLAGS" - LDFLAGS="$SAVE_LDFLAGS" - ]) ], + [ AC_MSG_RESULT(no) - ) + ]) +#endif SILC_DIST_INPLACE -# SOCKS5 support checking -# -SAVE_LIBS="$LIBS" -SAVE_CFLAGS="$CFLAGS" -SAVE_LDFLAGS="$LDFLAGS" -AC_MSG_CHECKING(whether to support SOCKS5) -AC_ARG_WITH(socks5, - [[ --with-socks5[=DIR] with SOCKS5 support [search in DIR/lib and DIR/include]]], +# Debug checking +AC_MSG_CHECKING(whether to enable debugging) +summary_debug="no" +__SILC_ENABLE_DEBUG="" +AC_ARG_ENABLE(debug, + [ --enable-debug enable debugging], [ - case "$withval" in - no) - AC_MSG_RESULT(no) + case "${enableval}" in + yes) + AC_MSG_RESULT(yes) + AC_DEFINE([SILC_DEBUG], [], [enable-debug]) + summary_debug="yes" + __SILC_ENABLE_DEBUG="#define __SILC_ENABLE_DEBUG 1" ;; *) - AC_MSG_RESULT(yes) - socks=5 - - if test -d "$withval/include"; then - CFLAGS="$CFLAGS -I$withval/include" - fi - if test -d "$withval/lib"; then - LDFLAGS="$LDFLAGS -L$withval/lib" - fi - - LIBS="-lsocks5 $LIBS" + AC_MSG_RESULT(no) ;; esac - - AC_TRY_LINK([], - [ - SOCKSconnect(); - ], [], - [ - AC_MSG_ERROR(Could not find SOCKS5 library.) - LIBS="$SAVE_LIBS" - CFLAGS="$SAVE_CFLAGS" - LDFLAGS="$SAVE_LDFLAGS" - ]) ], + [ AC_MSG_RESULT(no) - ) + ]) -if test "x$socks" = "x4"; then - AC_DEFINE([SOCKS], [], [Socks]) - CFLAGS="$CFLAGS -Dconnect=Rconnect -Dgetsockname=Rgetsockname -Dbind=Rbind -Daccept=Raccept -Dlisten=Rlisten -Dselect=Rselect" -fi +# Disable all assembler optimizations +AC_MSG_CHECKING(whether to enable assembler optimizations) +AC_ARG_ENABLE(asm, + [ --disable-asm do not use assembler optimizations], + [ + AC_MSG_RESULT(no) + AC_DEFINE([SILC_NO_ASM], [], [SILC_NO_ASM]) + want_asm=false + ], + [ + AC_MSG_RESULT(yes) + want_asm=true + ]) +AM_CONDITIONAL(SILC_NO_ASM, test x$want_asm = xfalse) + +# Check for assembler +SILC_ASSEMBLER="" +have_assembler=false +if test x$want_asm = xtrue; then + AC_PATH_PROG([NASM], [nasm], [no]) + if test "x$NASM" != "xno"; then + if test x$cpu_x86_64 = xtrue; then + SILC_ASSEMBLER="$NASM -O2 -felf64" + else + SILC_ASSEMBLER="$NASM -O2 -felf" + fi + have_assembler=true + fi -if test "x$socks" = "x5"; then - AC_DEFINE([SOCKS], [], [Socks]) - AC_DEFINE([SOCKS5], [], [Socks5]) - AC_DEFINE([Rconnect], [SOCKSconnect], [Socks]) - AC_DEFINE([Rgetsockname], [SOCKSgetsockname], [Socks]) - AC_DEFINE([Rgetpeername], [SOCKSgetpeername], [Socks]) - AC_DEFINE([Rbind], [SOCKSbind], [Socks]) - AC_DEFINE([Raccept], [SOCKSaccept], [Socks]) - AC_DEFINE([Rlisten], [SOCKSlisten], [Socks]) - AC_DEFINE([Rselect], [SOCKSselect], [Socks]) - AC_DEFINE([Rrecvfrom], [SOCKSrecvfrom], [Socks]) - AC_DEFINE([Rsendto], [SOCKSsendto], [Socks]) - AC_DEFINE([Rrecv], [SOCKSrecv], [Socks]) - AC_DEFINE([Rsend], [SOCKSsend], [Socks]) - AC_DEFINE([Rread], [SOCKSread], [Socks]) - AC_DEFINE([Rwrite], [SOCKSwrite], [Socks]) - AC_DEFINE([Rrresvport], [SOCKSrresvport], [Socks]) - AC_DEFINE([Rshutdown], [SOCKSshutdown], [Socks]) - AC_DEFINE([Rlisten], [SOCKSlisten], [Socks]) - AC_DEFINE([Rclose], [SOCKSclose], [Socks]) - AC_DEFINE([Rdup], [SOCKSdup], [Socks]) - AC_DEFINE([Rdup2], [SOCKSdup2], [Socks]) - AC_DEFINE([Rfclose], [SOCKSfclose], [Socks]) - AC_DEFINE([Rgethostbyname], [SOCKSgethostbyname], [Socks]) + AC_PATH_PROG([YASM], [yasm], [no]) + if test "x$YASM" != "xno"; then + if test x$cpu_x86_64 = xtrue; then + SILC_ASSEMBLER="$YASM -Xgnu -felf64" + else + SILC_ASSEMBLER="$YASM -Xgnu -felf" + fi + have_assembler=true + fi fi +AC_SUBST(SILC_ASSEMBLER) -#ifdef SILC_DIST_MATH -# MP library checking. First check whether user wants to use GMP and use -# it if found. If not or not defined then compile the default library in the -# source tree. -# -mp_gmp=false -SAVE_LIBS="$LIBS" -SAVE_CFLAGS="$CFLAGS" -SAVE_LDFLAGS="$LDFLAGS" -AC_MSG_CHECKING(whether to search for GMP) -AC_ARG_WITH(gmp, - [[ --with-gmp[=DIR] use GMP instead of SILC Math [search in DIR/lib and DIR/include]]], - [ - case "$withval" in - no) - AC_MSG_RESULT(no) - ;; - *) - AC_MSG_RESULT(yes) - if test -d "$withval/include"; then - CFLAGS="$CFLAGS -I$withval/include" - fi - if test -d "$withval/lib"; then - LDFLAGS="$LDFLAGS -L$withval/lib" - fi +## +## With/without checkings +## - LIBS="-lgmp $LIBS" - ;; - esac +LIBSUBDIR=lib +LDFLAGS="-L\$(silc_top_srcdir)/lib $LDFLAGS" - AC_CHECK_LIB(gmp, __gmpz_init, - [ - mp_gmp=true - AC_DEFINE([SILC_MP_GMP], [], [GMP]) - AC_MSG_RESULT(Using GMP as a MP library.) - ], - [ - LIBS="$SAVE_LIBS" - CFLAGS="$SAVE_CFLAGS" - LDFLAGS="$SAVE_LDFLAGS" - ]) - ], - AC_MSG_RESULT(no) - ) +SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/contrib" +SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcutil" -AM_CONDITIONAL(SILC_MP_GMP, test x$mp_gmp = xtrue) -AM_CONDITIONAL(SILC_MP_SILCMATH, test x$mp_gmp = xfalse) -if test x$mp_gmp = xfalse; then - AC_DEFINE([SILC_MP_SILCMATH], [], [SILCMATH]) - AC_MSG_RESULT(Using SILC Math as a MP library.) -fi -#endif SILC_DIST_MATH -# iconv support -# +# Check for iconv support check_iconv=true has_iconv=false SAVE_LIBS="$LIBS" @@ -1110,8 +1032,7 @@ if test x$has_iconv = xtrue; then fi fi -# POSIX threads support -# +# Check for POSIX threads support AC_MSG_CHECKING(whether to search for POSIX threads) AC_ARG_WITH(pthreads, [[ --with-pthreads[=DIR] use POSIX threads [search in DIR/include and DIR/lib]]], @@ -1264,216 +1185,83 @@ if test x$has_threads = xtrue; then __SILC_HAVE_PTHREAD="#define __SILC_HAVE_PTHREAD 1" fi -# -# Check for timezone and tm_gmtoff for timezone information -# -AC_MSG_CHECKING(whether system has timezone) -AC_RUN_IFELSE( - [ - #include - #include - int main() - { - timezone = 0; - return 0; - } - ], - [ AC_MSG_RESULT(yes) - AC_DEFINE([HAVE_TIMEZONE], [], [HAVE_TIMEZONE]) ], - [ AC_MSG_RESULT(no) ], - [ AC_MSG_RESULT(no) ] -) -AC_MSG_CHECKING(whether system has tm_gmtoff) -AC_RUN_IFELSE( - [ - #include - #include - int main() - { - struct tm tm; - tm.tm_gmtoff = 0; - return 0; - } - ], - [ AC_MSG_RESULT(yes) - AC_DEFINE([HAVE_TM_GMTOFF], [], [HAVE_TM_GMTOFF]) ], - [ AC_MSG_RESULT(no) ], - [ AC_MSG_RESULT(no) ] -) -AC_MSG_CHECKING(whether system has __tm_gmtoff) -AC_RUN_IFELSE( - [ - #include - #include - int main() - { - struct tm tm; - tm.__tm_gmtoff = 0; - return 0; - } - ], - [ AC_MSG_RESULT(yes) - AC_DEFINE([HAVE___TM_GMTOFF], [], [HAVE___TM_GMTOFF]) ], - [ AC_MSG_RESULT(no) ], - [ AC_MSG_RESULT(no) ] -) -AC_MSG_CHECKING(whether system has __tm_gmtoff__) -AC_RUN_IFELSE( - [ - #include - #include - int main() - { - struct tm tm; - tm.__tm_gmtoff__ = 0; - return 0; - } - ], - [ AC_MSG_RESULT(yes) - AC_DEFINE([HAVE___TM_GMTOFF__], [], [HAVE___TM_GMTOFF__]) ], - [ AC_MSG_RESULT(no) ], - [ AC_MSG_RESULT(no) ] -) - -# Native WIN32 compilation under cygwin -# -AC_MSG_CHECKING(whether to compile native WIN32 code) -AC_ARG_WITH(win32, - [ --with-win32 compile native WIN32 (MinGW) code (-mno-cygwin)], - [ - AC_MSG_RESULT(yes) - AC_DEFINE([SILC_WIN32], [], [SILC_WIN32]) - win32_support=true - CFLAGS="-mno-cygwin $CFLAGS" - LIBS="$LIBS -lwsock32" - ], - [ - AC_MSG_RESULT(no) - ]) -AM_CONDITIONAL(SILC_WIN32, test x$win32_support = xtrue) - -# Native Symbian OS support (disabled by default) -# -AM_CONDITIONAL(SILC_SYMBIAN, test xfalse = xtrue) - -# Native BeOS support (disabled by default) -# -AM_CONDITIONAL(SILC_BEOS, test xfalse = xtrue) - -# Native OS2 support (disabled by default) -# -AM_CONDITIONAL(SILC_OS2, test xfalse = xtrue) - -#ifdef SILC_DIST_SERVER -without_silcd=false -#endif SILC_DIST_SERVER -#ifdef SILC_DIST_CLIENT -AM_CONDITIONAL(with_irssi, true) -#endif SILC_DIST_CLIENT -#ifdef SILC_DIST_INPLACE -without_irssi=false -without_silcd=false -#endif SILC_DIST_INPLACE - -libtoolfix=true -AC_MSG_CHECKING(whether to do libtoolfix) -AC_ARG_WITH(libtoolfix, - [ --without-libtoolfix Do not fix libtool, for package builders], - [ - AC_MSG_RESULT(no) - libtoolfix=false - ], - [ - AC_MSG_RESULT(yes) - ]) - -AC_SUBST(ETCDIR) -AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR]) -#endif SILC_DIST_COMPILER ## -## Misc +## Outputs and substitutions ## -# Make enable-shared aware -AM_CONDITIONAL(SILC_ENABLE_SHARED, test "$enable_shared" = yes) - -SILC_TOP_SRCDIR=`pwd` - -# Included configure scripts -AD_INCLUDE_CONFIGURE - -#ifdef SILC_DIST_COMPILER -# -# Substitutions -# AC_SUBST(LIBSUBDIR) AC_SUBST(SILC_TOP_SRCDIR) AC_SUBST(LDFLAGS) AC_SUBST(LIBS) AC_SUBST(SILC_LIB_INCLUDES) -AC_SUBST(__SILC_HAVE_PTHREAD) -AC_SUBST(__SILC_HAVE_SIM) AC_SUBST(__SILC_ENABLE_DEBUG) -AC_SUBST(__SILC_PACKAGE_VERSION) +AC_SUBST(__SILC_HAVE_PTHREAD) +AC_SUBST(__RUNTIME_PACKAGE_VERSION) -# -# Fix the libtool to support run-time configuration. This allows us -# to in run-time specify when to compile shared/static libraries without -# need to reconfigure the entire libtool. -# -if test x$libtoolfix = xtrue; then - ./libtoolfix $SILC_TOP_SRCDIR/ltmain.sh -fi -AM_CONDITIONAL(SILC_LIBTOOLFIX, test x$libtoolfix = xtrue) +# Native Windows support (disabled by default) +AM_CONDITIONAL(SILC_WIN32, test xfalse = xtrue) + +# Native Symbian OS support (disabled by default) +AM_CONDITIONAL(SILC_SYMBIAN, test xfalse = xtrue) + +# Make enable-shared aware +AM_CONDITIONAL(SILC_ENABLE_SHARED, test "$enable_shared" = yes) + +ETCDIR=`eval echo $sysconfdir`;ETCDIR=`eval echo $ETCDIR` +AC_SUBST(ETCDIR) +AC_DEFINE_UNQUOTED([SILC_ETCDIR], "$ETCDIR", [SILC_ETCDIR]) + +DOCDIR=`eval echo $docdir`;DOCDIR=`eval echo $DOCDIR` +AC_SUBST(DOCDIR) +AC_DEFINE_UNQUOTED([SILC_DOCDIR], "$DOCDIR", [SILC_DOCDIR]) INCLUDE_DEFINES_INT="include \$(top_srcdir)/Makefile.defines_int" AC_SUBST(INCLUDE_DEFINES_INT) -#endif SILC_DIST_COMPILER # # Makefile outputs # AC_CONFIG_FILES( Makefile -#ifdef SILC_DIST_DOC doc/Makefile -#endif SILC_DIST_DOC -#ifdef SILC_DIST_COMPILER Makefile.defines Makefile.defines_int includes/Makefile includes/silcversion.h includes/silc.h -#endif SILC_DIST_COMPILER -#ifdef SILC_DIST_APPS apps/Makefile -#endif SILC_DIST_APPS +win32/Makefile ) -#ifdef SILC_DIST_TOOLKIT AC_CONFIG_FILES( -win32/Makefile -win32/libsilc/Makefile -win32/libsilcclient/Makefile -tutorial/Makefile -tutorial/Makefile.defines -tutorial/Makefile.defines_int +lib/Makefile +lib/contrib/Makefile +lib/silcutil/silcruntime.h +lib/silcutil/Makefile +lib/silcutil/tests/Makefile +lib/silcutil/unix/Makefile +lib/silcutil/win32/Makefile +lib/silcutil/symbian/Makefile +lib/srt.pc ) -#endif SILC_DIST_TOOLKIT AC_OUTPUT -#ifdef SILC_DIST_COMPILER + +## +## Summary output +## + s_bindir=`eval echo $bindir`;s_bindir=`eval echo $s_bindir` s_sbindir=`eval echo $sbindir`;s_sbindir=`eval echo $s_sbindir` s_mandir=`eval echo $mandir`;s_mandir=`eval echo $s_mandir` s_includedir=`eval echo $includedir`;s_includedir=`eval echo $s_includedir` echo "" -echo "$PACKAGE Configuration Summary:" -echo "---------------------------" +echo "SILC Runtime Toolkit configuration summary:" +echo "------------------------------------------" echo " Target host ...................: $target" echo " Compiler ......................: $CC" echo " CFLAGS ........................: $CFLAGS" @@ -1486,37 +1274,8 @@ echo " sbin directory ................: $s_sbindir" echo " etc directory .................: $ETCDIR" echo " man directory .................: $s_mandir" echo " doc directory .................: $DOCDIR" -#ifdef SILC_DIST_SIM -echo " SIM directory .................: $MODULESDIR" -#endif SILC_DIST_SIM -#ifdef SILC_DIST_INCLUDES echo " include directory .............: $s_includedir" -#endif SILC_DIST_INCLUDES echo "" - -#ifdef SILC_DIST_CLIENT -if test x$without_irssi = xtrue; then - irssi="no" -fi -echo " Compile SILC Client ...........: $irssi" -#endif SILC_DIST_CLIENT - -#ifdef SILC_DIST_SERVER -if test x$without_silcd = xtrue; then - silcd="no" -fi -echo " Compile SILC Server ...........: $silcd" -#endif SILC_DIST_SERVER - -#ifdef SILC_DIST_SIM -if test x$sim_support = xfalse; then - sim_support="no" -else - sim_support="yes" -fi -echo " SIM support ...................: $sim_support" -#endif SILC_DIST_SIM - echo " IPv6 support ..................: $summary_ipv6" if test x$has_iconv = xfalse; then @@ -1533,11 +1292,19 @@ else fi echo " Assembler optimizations .......: $summary_asm" -#ifdef SILC_DIST_MATH -if test x$mp_gmp = xtrue; then - echo " Arithmetic library ............: GMP" +if test x$want_cc_optimizations = xfalse; then + summary_cc_opt="no" +else + summary_cc_opt="yes" +fi +echo " Compiler optimizations ........: $summary_cc_opt" + +if test x$want_cpu_optimizations = xfalse; then + summary_cpu_opt="no" +else + summary_cpu_opt="yes" fi -#endif SILC_DIST_MATH +echo " CPU feature optimizations .....: $summary_cpu_opt" threads="no" if test x$has_threads = xtrue; then @@ -1547,4 +1314,3 @@ echo " Multi-threads support .........: $threads" echo " Debugging enabled .............: $summary_debug" echo "" echo "Compile the sources with 'make' or 'gmake' command." -#endif SILC_DIST_COMPILER diff --git a/distdir/autodist.conf b/distdir/autodist.conf new file mode 100644 index 00000000..207e228c --- /dev/null +++ b/distdir/autodist.conf @@ -0,0 +1,49 @@ +# Autodist configuration file + +# By default distdef prefix is '_DIST_'. To add your own prefix set the +# prefix here. NOTE: Remember to change all 'define' directives in +# distributions to use the new prefix if you change it. Example: +# +# DISTPREFIX="SILC" +# +# Will set the distdef prefix as 'SILC_DIST_'. +# +DISTPREFIX="SILC" + +# The distdef header will be created by the Autodist. It need to be included +# in the source code in order for the preprocessor to respect distdef +# conditionals in source code. Example: +# +# DISTDEFS="include/distdefs.h" +# +DISTDEFS="includes/silcdistdefs.h" + +# Location of the aclocal tool. If this is omitted the Autodist will not +# run aclocal. User need to run it manually then. +# +ACLOCAL="aclocal -I ." + +# Location of the autoheader tool. If this is omitted the Autodist will not +# run autoheader. User need to run it manually then. +# +AUTOHEADER="autoheader" + +# Location of the autoconf tool. If this is omitted the Autodist will not +# run autoconf. User need to run it manually then. +# +AUTOCONF="autoconf" + +# Location of the automake tool. If this is omitted the Autodist will not +# run automake. User need to run it manually then. +# +AUTOMAKE="automake" + +# Location of the libtoolize tool. This option should be omitted if your +# source tree does not use libtool. +# +LIBTOOLIZE="libtoolize --automake --copy" + +# Location of the make program. This must be specified in order to be +# able to create distributions. +# +MAKE="gmake" diff --git a/distdir/client b/distdir/client deleted file mode 100644 index 4ad2f057..00000000 --- a/distdir/client +++ /dev/null @@ -1,13 +0,0 @@ -name Client -package silc-client -bug-report silc-devel@lists.silcnet.org -prereq 1.3.2 - -inherit common -define SILC_DIST_CLIENT -define SILC_DIST_CLIENTLIB - -pre-hook distdir/pre-run -pre-dist-hook distdir/pre-dist-client -post-process-dist-hook distdir/post-process-dist -post-dist-hook distdir/post-dist diff --git a/distdir/default b/distdir/default index 87acf347..3ca6c68d 100644 --- a/distdir/default +++ b/distdir/default @@ -8,18 +8,6 @@ option no-dist # Default distribution for preparing raw CVS sources. -inherit common -inherit client -inherit server -inherit toolkit +inherit runtime define SILC_DIST_INPLACE - -# SFTP and VCARD is undefined in server, so force it here -define SILC_DIST_SFTP -define SILC_DIST_VCARD - -# Apps -define SILC_DIST_ASN1UTILS - -pre-hook distdir/pre-run diff --git a/distdir/post-dist b/distdir/post-dist index c026866e..cf1f93bd 100644 --- a/distdir/post-dist +++ b/distdir/post-dist @@ -6,9 +6,8 @@ package=$3 distdir=$4 if test -f $distdir.tar.gz; then - md5sum $distdir.tar.gz > $distdir.tar.gz.md5 + sha1sum $distdir.tar.gz > $distdir.tar.gz.sha1 fi if test -f $distdir.tar.bz2; then - md5sum $distdir.tar.bz2 > $distdir.tar.bz2.md5 + sha1sum $distdir.tar.bz2 > $distdir.tar.bz2.sha1 fi - diff --git a/distdir/runtime b/distdir/runtime new file mode 100644 index 00000000..e0ec6736 --- /dev/null +++ b/distdir/runtime @@ -0,0 +1,29 @@ +name Runtime Toolkit +package srt +bug-report silc-devel@lists.silcnet.org +prereq 1.3.2 + +# License +license distdir/RUNTIME +include distdir/GPL GPL +include distdir/BSD BSD +license-header distdir/GPL-header distdir/RUNTIME-header + +# Distdefs +define SILC_DIST_RUNTIME + +# Includes +include README.WIN32 +include README.MACOSX +include README.SYMBIAN + +# Noprocess to optimize packaging and avoid re-licensing of certain files +noprocess COPYING GPL BSD +noprocess doc/runtime/ +noprocess apps/ +noprocess win32/ +noprocess symbian/ + +post-process-dist-hook distdir/post-process-dist +pre-dist-hook distdir/pre-dist-runtime +post-dist-hook distdir/post-dist diff --git a/distdir/server b/distdir/server deleted file mode 100644 index 4734b305..00000000 --- a/distdir/server +++ /dev/null @@ -1,13 +0,0 @@ -name Server -package silc-server -bug-report silc-devel@lists.silcnet.org - -inherit common -define SILC_DIST_SERVER -#define SILC_DIST_SERVERLIB -define SILC_DIST_HTTP -undef SILC_DIST_SFTP -undef SILC_DIST_VCARD - -post-process-dist-hook distdir/post-process-dist -post-dist-hook distdir/post-dist diff --git a/includes/silc.h.in b/includes/silc.h.in index c64d33b8..f573e3d3 100644 --- a/includes/silc.h.in +++ b/includes/silc.h.in @@ -28,41 +28,7 @@ extern "C" { #endif -#define SILC_UNIX - -#ifdef WIN32 -#ifndef SILC_WIN32 -#define SILC_WIN32 -#undef SILC_UNIX -#endif -#endif - -#if defined(__EPOC32__) || defined(__SYMBIAN32__) -#ifndef SILC_SYMBIAN -#define SILC_SYMBIAN -#undef SILC_UNIX -#undef SILC_WIN32 -#endif -#endif - -#if defined(__MACH__) && defined(__APPLE__) -#ifndef SILC_MACOSX -#define SILC_MACOSX -#undef SILC_WIN32 -#undef SILC_SYMBIAN -#endif -#endif - -/* Types */ -#define SILC_SIZEOF_LONG_LONG @SILC_SIZEOF_LONG_LONG@ -#define SILC_SIZEOF_LONG @SILC_SIZEOF_LONG@ -#define SILC_SIZEOF_INT @SILC_SIZEOF_INT@ -#define SILC_SIZEOF_SHORT @SILC_SIZEOF_SHORT@ -#define SILC_SIZEOF_CHAR @SILC_SIZEOF_CHAR@ -#define SILC_SIZEOF_VOID_P @SILC_SIZEOF_VOID_P@ - /* Compilation time defines, for third-party software */ -@__SILC_HAVE_PTHREAD@ @__SILC_HAVE_SIM@ @__SILC_ENABLE_DEBUG@ diff --git a/includes/silccompile.h b/includes/silccompile.h new file mode 100644 index 00000000..9cd0378f --- /dev/null +++ b/includes/silccompile.h @@ -0,0 +1,131 @@ +/* + + silccompile.h + + Author: Pekka Riikonen + + Copyright (C) 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; 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 + GNU General Public License for more details. + +*/ + +#ifndef SILCCOMPILE_H +#define SILCCOMPILE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_SIGNAL_H +#include +#endif + +#ifdef HAVE_FCNTL_H +#include +#endif + +#ifdef HAVE_ERRNO_H +#include +#endif + +#ifdef HAVE_ASSERT_H +#include +#endif + +#if !defined(SILC_WIN32) + +#include +#include +#include +#include + +#ifdef HAVE_GRP_H +#include +#endif + +#ifdef SOCKS5 +#include "socks.h" +#endif + +#include +#ifdef HAVE_NETINET_IN_H +#include +#endif + +#ifdef HAVE_XTI_H +#include +#else +#ifdef HAVE_NETINET_TCP_H +#include +#endif +#endif + +#ifdef HAVE_NETDB_H +#include +#endif + +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#ifdef HAVE_SYS_MMAN_H +#include +#endif + +#ifdef HAVE_DLFCN_H +#include +#endif + +#ifdef HAVE_LIMITS_H +#include +#endif + +#ifdef SILC_HAVE_PTHREAD +#include +#endif + +#ifdef HAVE_STDDEF_H +#include +#endif + +#ifdef HAVE_TERMIOS_H +#include +#endif + +#ifdef HAVE_UTIME_H +#include +#endif + +#ifdef HAVE_ICONV_H +#include +#endif + +#ifdef HAVE_LOCALE_H +#include +#endif + +#ifdef HAVE_LANGINFO_H +#include +#endif + +#ifdef HAVE_SYS_RESOURCE_H +#include +#endif + +#endif /* !SILC_WIN32 */ + +#endif /* SILCCOMPILE_H */ diff --git a/lib/.gitignore b/lib/.gitignore index a324157c..a501f929 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1,3 +1,8 @@ Makefile -Makefile.in -Makefile.am +*.in +*.am +*.o +*.lo +*.la +*.a +*.pc diff --git a/lib/Makefile.ad b/lib/Makefile.ad index 9f3cb467..0fbdfd86 100644 --- a/lib/Makefile.ad +++ b/lib/Makefile.ad @@ -3,7 +3,7 @@ # # Author: Pekka Riikonen # -# Copyright (C) 2000 - 2007 Pekka Riikonen +# Copyright (C) 2000 - 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 @@ -17,193 +17,8 @@ AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign -# SILC Library dirs -SILCLIB_DIRS = \ - contrib \ - silccore \ - silcutil \ - silcapputil \ -#ifdef SILC_DIST_CRYPTO - silccrypt \ -#endif SILC_DIST_CRYPTO -#ifdef SILC_DIST_SKR - silcskr \ -#endif SILC_DIST_SKR -#ifdef SILC_DIST_MATH - silcmath \ -#endif SILC_DIST_MATH -#ifdef SILC_DIST_SIM - silcsim \ -#endif SILC_DIST_SIM -#ifdef SILC_DIST_ASN1 - silcasn1 \ -#endif SILC_DIST_ASN1 - silcske \ -#ifdef SILC_DIST_HTTP - silchttp \ -#endif SILC_DIST_HTTP -#ifdef SILC_DIST_SFTP - silcsftp \ -#endif SILC_DIST_SFTP -#ifdef SILC_DIST_VCARD - silcvcard \ -#endif SILC_DIST_VCARD -#ifdef SILC_DIST_ACC - silcacc \ -#endif SILC_DIST_ACC -#ifdef SILC_DIST_SSH - silcssh \ -#endif SILC_DIST_SSH +SUBDIRS= -if SILC_ENABLE_SHARED -if SILC_WIN32 -LIBTOOL_OPTS= -release $(LIB_BASE_VERSION) -rpath $(DESTDIR)$(libdir) -export-dynamic -no-undefined -else -LIBTOOL_OPTS= -release $(LIB_BASE_VERSION) -rpath $(DESTDIR)$(libdir) -endif -LIBTOOL_SILC_VERSION = -version-info $(LIBSILC_CURRENT):$(LIBSILC_REVISION):$(LIBSILC_AGE) -LIBTOOL_SILCCLIENT_VERSION = -version-info $(LIBSILCCLIENT_CURRENT):$(LIBSILCCLIENT_REVISION):$(LIBSILCCLIENT_AGE) -LIBTOOL_SILCSERVER_VERSION = -version-info $(LIBSILCSERVER_CURRENT):$(LIBSILCSERVER_REVISION):$(LIBSILCSERVER_AGE) -else -LIBTOOL_OPTS= -LIBTOOL_SILC_VERSION = -LIBTOOL_SILCCLIENT_VERSION = -LIBTOOL_SILCSERVER_VERSION = -endif - -if SILC_WIN32 -SILC_LINK_LIBS=$(LIBS) -SILCCLIENT_LINK_LIBS=$(LIBS) -lsilc -SILCSERVER_LIBS=$(LIBS) -lsilc -else -SILC_LINK_LIBS= -SILCCLIENT_LINK_LIBS= -SILCSERVER_LIBS= -endif - -SILCLIB = libsilc.a - -#ifdef SILC_DIST_CLIENTLIB -# SILC Client Library dirs -SILCCLIENTLIB_DIRS = silcclient -SILCCLIENTLIB = libsilcclient.a -#endif SILC_DIST_CLIENTLIB - -#ifdef SILC_DIST_SERVERLIB -# SILC Server Library dirs -SILCSERVERLIB_DIRS = silcserver -SILCSERVERLIB = libsilcserver.a -#endif SILC_DIST_SERVERLIB - -SUBDIRS = $(SILCLIB_DIRS) $(SILCSERVERLIB_DIRS) $(SILCCLIENTLIB_DIRS) - -CLEANFILES = libsilc.a $(SILCCLIENTLIB) $(SILCSERVERLIB) -DISTCLEANFILES = libsilc.a $(SILCCLIENTLIB) $(SILCSERVERLIB) - -remove: - -rm -f $(CLEANFILES) - -all: - $(MAKE) remove $(SILCLIB) $(SILCSERVERLIB) $(SILCCLIENTLIB) - -#ifdef SILC_DIST_TOOLKIT -install-exec-hook: - -mkdir -p $(DESTDIR)$(libdir) - -$(LIBTOOL) $(INSTALL) libsilc.la $(DESTDIR)$(libdir)/ -#ifdef SILC_DIST_CLIENTLIB - -$(LIBTOOL) $(INSTALL) libsilcclient.la $(DESTDIR)$(libdir)/ -#endif SILC_DIST_CLIENTLIB -#ifdef SILC_DIST_SERVERLIB - -$(LIBTOOL) $(INSTALL) libsilcserver.la $(DESTDIR)$(libdir)/ -#endif SILC_DIST_SERVERLIB -#else !SILC_DIST_TOOLKIT - -#ifdef SILC_DIST_SERVERLIB -install-exec-hook: -if SILC_ENABLE_SHARED - -mkdir -p $(libdir) - -$(LIBTOOL) $(INSTALL) libsilc.la $(DESTDIR)$(libdir)/ - -$(LIBTOOL) $(INSTALL) libsilcserver.la $(DESTDIR)$(libdir)/ - -rm -rf $(DESTDIR)$(libdir)/libsilc.a - -rm -rf $(DESTDIR)$(libdir)/libsilcserver.a -endif -#endif SILC_DIST_SERVERLIB - -#ifdef SILC_DIST_CLIENTLIB -install-exec-hook: -if SILC_ENABLE_SHARED - -mkdir -p $(libdir) - -$(LIBTOOL) $(INSTALL) libsilc.la $(DESTDIR)$(libdir)/ - -$(LIBTOOL) $(INSTALL) libsilcclient.la $(DESTDIR)$(libdir)/ - -rm -rf $(DESTDIR)$(libdir)/libsilc.a - -rm -rf $(DESTDIR)$(libdir)/libsilcclient.a -endif -#endif SILC_DIST_CLIENTLIB -#endif SILC_DIST_TOOLKIT - -LIB_BASE_VERSION=@LIB_BASE_VERSION@ -LIBSILC_CURRENT=@LIBSILC_CURRENT@ -LIBSILC_REVISION=@LIBSILC_REVISION@ -LIBSILC_AGE=@LIBSILC_AGE@ - -libsilc.a: - find $(SILCLIB_DIRS) -type f -name *.lo | xargs \ - $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(SILC_LINK_LIBS) \ - $(LIBTOOL_SILC_VERSION) \ - $(LIBTOOL_OPTS) -o libsilc.la - -#ifdef SILC_DIST_CLIENTLIB -LIBSILCCLIENT_CURRENT=@LIBSILCCLIENT_CURRENT@ -LIBSILCCLIENT_REVISION=@LIBSILCCLIENT_REVISION@ -LIBSILCCLIENT_AGE=@LIBSILCCLIENT_AGE@ - -libsilcclient.a: - find $(SILCCLIENTLIB_DIRS) -type f -name *.lo | xargs \ - $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) \ - $(SILCCLIENT_LINK_LIBS) $(LIBTOOL_SILCCLIENT_VERSION) \ - $(LIBTOOL_OPTS) -o libsilcclient.la -#endif SILC_DIST_CLIENTLIB - -#ifdef SILC_DIST_SERVERLIB -LIBSILCSERVER_CURRENT=@LIBSILCSERVER_CURRENT@ -LIBSILCSERVER_REVISION=@LIBSILCSERVER_REVISION@ -LIBSILCSERVER_AGE=@LIBSILCSERVER_AGE@ - -libsilcserver.a: - find $(SILCSERVERLIB_DIRS) -type f -name *.lo | xargs \ - $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(SILCSERVER_LIBS) \ - $(LIBTOOL_SILCSERVER_VERSION) \ - $(LIBTOOL_OPTS) -o libsilcserver.la -#endif SILC_DIST_SERVERLIB - -#ifdef SILC_DIST_TOOLKIT -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = silc.pc \ -#ifdef SILC_DIST_CLIENTLIB - silcclient.pc \ -#endif SILC_DIST_CLIENTLIB -#ifdef SILC_DIST_SERVERLIB - silcserver.pc -#endif SILC_DIST_SERVERLIB - -EXTRA_DIST = silc.pc.in \ -#ifdef SILC_DIST_CLIENTLIB - silcclient.pc.in \ -#endif SILC_DIST_CLIENTLIB -#ifdef SILC_DIST_SERVERLIB - silcserver.pc.in -#endif SILC_DIST_SERVERLIB - -toolkit-install: - -mkdir -p $(docdir)/toolkit/ - -$(INSTALL_DATA) $(top_srcdir)/doc/toolkit/* $(docdir)/toolkit - -$(INSTALL_DATA) $(top_srcdir)/lib/doc/*.gif $(docdir)/toolkit - -cp -R $(top_srcdir)/tutorial $(docdir) -#endif SILC_DIST_TOOLKIT - -install-data-hook: \ -#ifdef SILC_DIST_TOOLKIT - toolkit-install -#endif SILC_DIST_TOOLKIT +include Makefile.runtime include $(top_srcdir)/Makefile.defines.in diff --git a/lib/Makefile.runtime.ad b/lib/Makefile.runtime.ad new file mode 100644 index 00000000..c71f102f --- /dev/null +++ b/lib/Makefile.runtime.ad @@ -0,0 +1,83 @@ +# +# Makefile.runtime.am +# +# Author: Pekka Riikonen +# +# Copyright (C) 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; 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 +# GNU General Public License for more details. +# + +RUNTIME_BASE_VERSION=@RUNTIME_BASE_VERSION@ +RUNTIME_CURRENT=@RUNTIME_CURRENT@ +RUNTIME_REVISION=@RUNTIME_REVISION@ +RUNTIME_AGE=@RUNTIME_AGE@ + +# SILC Library dirs +RUNTIME_DIRS = \ + contrib \ + silcutil + +if SILC_ENABLE_SHARED +if SILC_WIN32 +LIBTOOL_OPTS= -release $(RUNTIME_BASE_VERSION) -rpath $(DESTDIR)$(libdir) \ + -export-dynamic -no-undefined +else +LIBTOOL_OPTS= -release $(RUNTIME_BASE_VERSION) -rpath $(DESTDIR)$(libdir) +endif +LIBTOOL_RUNTIME_VERSION = \ + -version-info $(RUNTIME_CURRENT):$(RUNTIME_REVISION):$(RUNTIME_AGE) +else +LIBTOOL_OPTS= +LIBTOOL_RUNTIME_VERSION = +endif +if SILC_WIN32 +RUNTIME_LINK_LIBS=$(LIBS) +else +RUNTIME_LINK_LIBS= +endif + +RUNTIME_LIB = libsrt.a + +SUBDIRS += $(RUNTIME_DIRS) + +CLEANFILES = $(RUNTIME_LIB) +DISTCLEANFILES = $(RUNTIME_LIB) + +remove: + -rm -f $(CLEANFILES) + +all: + $(MAKE) remove $(RUNTIME_LIB) + +install-exec-hook: + -mkdir -p $(DESTDIR)$(libdir) + -$(LIBTOOL) $(INSTALL) libsrt.la $(DESTDIR)$(libdir)/ + +libsrt.a: + find $(RUNTIME_DIRS) -type f -name *.lo | xargs \ + $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) \ + $(RUNTIME_LINK_LIBS) \ + $(LIBTOOL_RUNTIME_VERSION) \ + $(LIBTOOL_OPTS) -o libsrt.la + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = srt.pc + +EXTRA_DIST = srt.pc.in + +#srt-install: +# -mkdir -p $(docdir)/toolkit/ +# -$(INSTALL_DATA) $(top_srcdir)/doc/toolkit/* $(docdir)/toolkit +# -$(INSTALL_DATA) $(top_srcdir)/lib/doc/*.gif $(docdir)/toolkit +# -cp -R $(top_srcdir)/tutorial $(docdir) + +#install-data-hook: \ +# srt-install diff --git a/lib/configure.ad b/lib/configure.ad deleted file mode 100644 index d9b6ba39..00000000 --- a/lib/configure.ad +++ /dev/null @@ -1,366 +0,0 @@ -#ifdef SILC_DIST_LIB -# -# lib/configure.ad -# -# Author: Pekka Riikonen -# -# Copyright (C) 2005, 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 -# 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 -# GNU General Public License for more details. -# - -if test x$compile_libs = xtrue; then - -AM_PROG_AS - -## -## Will compile included libs -## -AC_MSG_NOTICE([Configuring SILC libraries]) - -# SILC Library directories -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/contrib" -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silccore" -#ifdef SILC_DIST_CRYPTO -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silccrypt" -#endif SILC_DIST_CRYPTO -#ifdef SILC_DIST_MATH -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcmath" -#endif SILC_DIST_MATH -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcutil" -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcapputil" -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcske" -#ifdef SILC_DIST_SFTP -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcsftp" -#endif SILC_DIST_SFTP -#ifdef SILC_DIST_SIM -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcsim" -#endif SILC_DIST_SIM -#ifdef SILC_DIST_CLIENTLIB -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcclient" -#endif SILC_DIST_CLIENTLIB -#ifdef SILC_DIST_ASN1 -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcasn1" -#endif SILC_DIST_ASN1 -#ifdef SILC_DIST_SKR -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcskr" -#endif SILC_DIST_SKR -#ifdef SILC_DIST_SERVERLIB -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcserver" -#endif SILC_DIST_SERVERLIB -#ifdef SILC_DIST_HTTP -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silchttp" -#endif SILC_DIST_HTTP -#ifdef SILC_DIST_VCARD -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcvcard" -#endif SILC_DIST_VCARD -#ifdef SILC_DIST_ACC -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcacc" -#endif SILC_DIST_ACC -#ifdef SILC_DIST_PGP -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcpgp" -#endif SILC_DIST_PGP -#ifdef SILC_DIST_SSH -SILC_LIB_INCLUDES="$SILC_LIB_INCLUDES -I$SILC_TOP_SRCDIR/lib/silcssh" -#endif SILC_DIST_SSH - -## -## Library versioning. -## -# Do the releases and library versioning according to following rules: -# -# - If any code has changed in library, increment [LIB]_REVISION -# - If functions were added, removed or changed, set [LIB]_REVISION to 0 -# - If functions were added, removed or changed, increment [LIB]_CURRENT -# - If functions were added, increment [LIB]_AGE -# - If functions were removed, set [LIB]_AGE to 0 -# -# where [LIB] is LIBSILC, LIBSILCCLIENT or LIBSILCSERVER, and where -# "functions" means functions public interfaces (API). -# -# The LIB_BASE_VERSION defines the SILC software major.minor version and -# it is increment only when these version numbers actually change. -# - -# Base version for libraries. Do not change this unless SILC version -# changes too. -LIB_BASE_VERSION=1.1 - -# libsilc versions -LIBSILC_CURRENT=2 # prev = 1 -LIBSILC_REVISION=0 # prev = 0 -LIBSILC_AGE=0 # prev = 0 - -# libsilcclient versions -LIBSILCCLIENT_CURRENT=2 # prev = 1 -LIBSILCCLIENT_REVISION=0 # prev = 0 -LIBSILCCLIENT_AGE=0 # prev = 0 - -# libsilcserver versions -LIBSILCSERVER_CURRENT=1 # prev = 0 -LIBSILCSERVER_REVISION=0 # prev = 0 -LIBSILCSERVER_AGE=0 # prev = 0 - -# Substitute the version numbers -AC_SUBST(LIB_BASE_VERSION) -AC_SUBST(LIBSILC_CURRENT) -AC_SUBST(LIBSILC_REVISION) -AC_SUBST(LIBSILC_AGE) -AC_SUBST(LIBSILCCLIENT_CURRENT) -AC_SUBST(LIBSILCCLIENT_REVISION) -AC_SUBST(LIBSILCCLIENT_AGE) -AC_SUBST(LIBSILCSERVER_CURRENT) -AC_SUBST(LIBSILCSERVER_REVISION) -AC_SUBST(LIBSILCSERVER_AGE) - -# Check for big-endian machines -AC_C_BIGENDIAN - -# Check for epoll_wait and verify that epoll_create works -AC_CHECK_FUNC(epoll_wait, - [ - AC_RUN_IFELSE( - [ - #include - int main() - { - int ret = epoll_create(5); - if (ret < 0) - return 1; - close(ret); - return 0; - } - ], - [ - AC_DEFINE([HAVE_EPOLL_WAIT], [1], [HAVE_EPOLL_WAIT]) - ], - ) - ]) - -# -# Memory alignment. User can specify what alignment memory allocation and -# SilcStack allocation use. Default is system default alignemnt. -# -AC_ARG_WITH(alignment, - [ --with-alignment=NUMBER Memory alignment in bytes], - [ - AC_DEFINE_UNQUOTED([SILC_ALIGNMENT], [$withval], [SILC_ALIGNMENT]) - AC_MSG_RESULT(Memory allocation alignment is $withval bytes) - ], - [ - AC_DEFINE([SILC_ALIGNMENT], SILC_SIZEOF_VOID_P, [SILC_ALIGNMENT]) - ]) - - -MODULESDIR="$silc_prefix/lib/modules" -#ifdef SILC_DIST_SIM -# SIM modules directory -# -AC_ARG_WITH(simdir, - [[ --with-simdir=DIR directory for SIM modules [PREFIX/modules]]], - [ - case "$withval" in - no|yes) - ;; - *) - MODULESDIR="$withval" - ;; - esac - ]) -AC_DEFINE_UNQUOTED([SILC_MODULESDIR], "$MODULESDIR", [SILC_MODULESDIR]) -#endif SILC_DIST_SIM -AC_SUBST(MODULESDIR) - -#ifdef SILC_DIST_TOOLKIT -# Stack trace checking -# -AC_MSG_CHECKING(whether to enable stack tracing) -AC_ARG_ENABLE(stack-trace, - [ --enable-stack-trace enable memory stack trace], - [ - case "${enableval}" in - yes) - AC_MSG_RESULT(yes) - AC_DEFINE([SILC_STACKTRACE], [], [SILC_STACKTRACE]) - ;; - *) - AC_MSG_RESULT(no) - ;; - esac - ], - AC_MSG_RESULT(no) - ) -#endif SILC_DIST_TOOLKIT - -#ifdef SILC_DIST_INPLACE -# -# Profiling options (never delivered to distributions) -# -AC_MSG_CHECKING(whether to enable gprof) -AC_ARG_ENABLE(gprof, - [ --enable-gprof enable gprof profiling], - [ - case "${enableval}" in - yes) - AC_MSG_RESULT(yes) - SILC_ADD_CFLAGS(-pg) - LIBS="$LIBS -pg" - ;; - *) - AC_MSG_RESULT(no) - ;; - esac - ], - [ - AC_MSG_RESULT(no) - ]) - -AC_MSG_CHECKING(whether to enable gcov) -AC_ARG_ENABLE(gcov, - [ --enable-gcov enable gcov], - [ - case "${enableval}" in - yes) - AC_MSG_RESULT(yes) - SILC_ADD_CFLAGS(-fprofile-arcs) - LIBS="$LIBS -lgcov" - ;; - *) - AC_MSG_RESULT(no) - ;; - esac - ], - [ - AC_MSG_RESULT(no) - ]) -#endif SILC_DIST_INPLACE - -# -# Makefile outputs -# -AC_CONFIG_FILES( -lib/Makefile -lib/contrib/Makefile -lib/silccore/Makefile -#ifdef SILC_DIST_SIM -lib/silcsim/Makefile -#endif SILC_DIST_SIM -lib/silcske/Makefile -lib/silcutil/Makefile -#ifdef SILC_DIST_TOOLKIT -lib/silcutil/unix/Makefile -lib/silcutil/win32/Makefile -lib/silcutil/symbian/Makefile -#else !SILC_DIST_TOOLKIT -#ifdef SILC_DIST_CLIENT -lib/silcutil/unix/Makefile -lib/silcutil/win32/Makefile -#else !SILC_DIST_CLIENT -#ifdef SILC_DIST_SERVER -lib/silcutil/unix/Makefile -#endif SILC_DIST_SERVER -#endif SILC_DIST_CLIENT -#endif SILC_DIST_TOOLKIT -lib/silcapputil/Makefile -#ifdef SILC_DIST_SFTP -lib/silcsftp/Makefile -#endif SILC_DIST_SFTP -#ifdef SILC_DIST_INPLACE -lib/silcutil/tests/Makefile -lib/silccore/tests/Makefile -lib/silcsftp/tests/Makefile -#endif SILC_DIST_INPLACE -) - -#ifdef SILC_DIST_TOOLKIT -AC_CONFIG_FILES( -lib/silc.pc -lib/silcclient.pc -lib/silcserver.pc -) -#endif SILC_DIST_TOOLKIT - -#ifdef SILC_DIST_CLIENTLIB -AC_CONFIG_FILES( -lib/silcclient/Makefile -lib/silcclient/tests/Makefile -) -#endif SILC_DIST_CLIENTLIB - -#ifdef SILC_DIST_SERVERLIB -AC_CONFIG_FILES( -lib/silcserver/Makefile -lib/silcserver/tests/Makefile -) -#endif SILC_DIST_SERVERLIB - -#ifdef SILC_DIST_ASN1 -AC_CONFIG_FILES( -lib/silcasn1/Makefile -#ifdef SILC_DIST_INPLACE -lib/silcasn1/tests/Makefile -#endif SILC_DIST_INPLACE -) -#endif SILC_DIST_ASN1 - -#ifdef SILC_DIST_SKR -AC_CONFIG_FILES( -lib/silcskr/Makefile -#ifdef SILC_DIST_INPLACE -lib/silcskr/tests/Makefile -#endif SILC_DIST_INPLACE -) -#endif SILC_DIST_SKR - -#ifdef SILC_DIST_HTTP -AC_CONFIG_FILES( -lib/silchttp/Makefile -#ifdef SILC_DIST_INPLACE -lib/silchttp/tests/Makefile -#endif SILC_DIST_INPLACE -) -#endif SILC_DIST_HTTP - -#ifdef SILC_DIST_VCARD -AC_CONFIG_FILES( -lib/silcvcard/Makefile -) -#endif SILC_DIST_VCARD - -#ifdef SILC_DIST_ACC -AC_CONFIG_FILES( -lib/silcacc/Makefile -#ifdef SILC_DIST_INPLACE -lib/silcacc/tests/Makefile -#endif SILC_DIST_INPLACE -) -#endif SILC_DIST_ACC - -#ifdef SILC_DIST_PGP -AC_CONFIG_FILES( -lib/silcpgp/Makefile -#ifdef SILC_DIST_INPLACE -lib/silcpgp/tests/Makefile -#endif SILC_DIST_INPLACE -) -#endif SILC_DIST_PGP - -#ifdef SILC_DIST_SSH -AC_CONFIG_FILES( -lib/silcssh/Makefile -#ifdef SILC_DIST_INPLACE -lib/silcssh/tests/Makefile -#endif SILC_DIST_INPLACE -) -#endif SILC_DIST_SSH - -fi # compile_libs - -#endif SILC_DIST_LIB diff --git a/lib/contrib/stringprep.h b/lib/contrib/stringprep.h index 84349cab..b610dbb5 100644 --- a/lib/contrib/stringprep.h +++ b/lib/contrib/stringprep.h @@ -30,7 +30,7 @@ extern "C" #include /* size_t */ #include -#include "silc.h" +#include "silcruntime.h" #ifndef uint32_t #define uint32_t SilcUInt32 diff --git a/lib/silcutil/.gitignore b/lib/silcutil/.gitignore index 282522db..a501f929 100644 --- a/lib/silcutil/.gitignore +++ b/lib/silcutil/.gitignore @@ -1,2 +1,8 @@ Makefile -Makefile.in +*.in +*.am +*.o +*.lo +*.la +*.a +*.pc diff --git a/lib/silcutil/DIRECTORY b/lib/silcutil/DIRECTORY index 436bec94..daf3fb79 100644 --- a/lib/silcutil/DIRECTORY +++ b/lib/silcutil/DIRECTORY @@ -1,6 +1,7 @@ -SILC Utility Library +SILC Runtime Toolkit
Directory: lib/silcutil/
diff --git a/lib/silcutil/Makefile.ad b/lib/silcutil/Makefile.ad index 8e86f36b..3456e38d 100644 --- a/lib/silcutil/Makefile.ad +++ b/lib/silcutil/Makefile.ad @@ -3,7 +3,7 @@ # # Author: Pekka Riikonen # -# Copyright (C) 2000 - 2007 Pekka Riikonen +# Copyright (C) 2000 - 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 @@ -23,26 +23,14 @@ else if SILC_SYMBIAN SUBDIRS=symbian else -SUBDIRS=unix +SUBDIRS=unix tests endif endif -#ifdef SILC_DIST_TOOLKIT -DIST_SUBDIRS=win32 symbian unix -#else !SILC_DIST_TOOLKIT -#ifdef SILC_DIST_CLIENT -DIST_SUBDIRS=win32 unix -#else !SILC_DIST_CLIENT -#ifdef SILC_DIST_SERVER -DIST_SUBDIRS=unix -#endif SILC_DIST_SERVER -#endif SILC_DIST_CLIENT -#endif SILC_DIST_TOOLKIT +DIST_SUBDIRS=win32 symbian unix tests -#ifdef SILC_DIST_TOOLKIT SILC_DIST_SOURCE = stacktrace.c SILC_DIST_HEADER = stacktrace.h -#endif SILC_DIST_TOOLKIT noinst_LTLIBRARIES = libsilcutil.la @@ -77,9 +65,9 @@ libsilcutil_la_SOURCES = \ silcbitops.c \ silcerrno.c \ silcgetopt.c \ - silcregex.c + silcregex.c \ + silcthreadqueue.c -#ifdef SILC_DIST_TOOLKIT include_HEADERS = \ $(SILC_DIST_HEADER) \ silcbuffer.h \ @@ -128,10 +116,10 @@ include_HEADERS = \ silcbitops.h \ silcerrno.h \ silcgetopt.h \ - silcregex.h + silcregex.h \ + silcthreadqueue.h -SILC_EXTRA_DIST = tests -#endif SILC_DIST_TOOLKIT +SILC_EXTRA_DIST = EXTRA_DIST = *.h $(SILC_EXTRA_DIST) diff --git a/lib/silcutil/silcasync.c b/lib/silcutil/silcasync.c index 216e30af..09d3d1cf 100644 --- a/lib/silcutil/silcasync.c +++ b/lib/silcutil/silcasync.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005, 2006 Pekka Riikonen + Copyright (C) 2005 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /* Halts async operation */ diff --git a/lib/silcutil/silcbase64.c b/lib/silcutil/silcbase64.c index ba9b2c8d..17d199d4 100644 --- a/lib/silcutil/silcbase64.c +++ b/lib/silcutil/silcbase64.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2007 Pekka Riikonen + Copyright (C) 2007 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" static unsigned char pem_enc[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; diff --git a/lib/silcutil/silcbitops.c b/lib/silcutil/silcbitops.c index 405ed539..dfb9dea6 100644 --- a/lib/silcutil/silcbitops.c +++ b/lib/silcutil/silcbitops.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2007 Pekka Riikonen + Copyright (C) 2007 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" #define SILC_BIT_POS(bit) (bit / SILC_BIT_SIZE) #define SILC_BIT_MASK(bit) (1UL << (bit % SILC_BIT_SIZE)) diff --git a/lib/silcutil/silcbuffer.h b/lib/silcutil/silcbuffer.h index dc9d405c..6083fbb8 100644 --- a/lib/silcutil/silcbuffer.h +++ b/lib/silcutil/silcbuffer.h @@ -16,7 +16,7 @@ GNU General Public License for more details. */ -/* $Id$ */ +/* $Id: silcbuffer.h,v 1.43 2008/01/15 06:36:54 priikone Exp $ */ /****h* silcutil/SILC Buffer Interface * diff --git a/lib/silcutil/silcbuffmt.c b/lib/silcutil/silcbuffmt.c index 65346963..944841d4 100644 --- a/lib/silcutil/silcbuffmt.c +++ b/lib/silcutil/silcbuffmt.c @@ -16,9 +16,8 @@ GNU General Public License for more details. */ -/* $Id$ */ -#include "silc.h" +#include "silcruntime.h" /************************** Types and definitions ***************************/ @@ -180,7 +179,7 @@ int silc_buffer_sformat_vp_i(SilcStack stack, SilcBuffer dst, va_list ap, case SILC_PARAM_REGEX: { const char *regex = va_arg(ap, char *); - SilcBufferRegexFlags rflags = va_arg(ap, SilcUInt32); + SilcBufferRegexFlags rflags = va_arg(ap, SilcBufferRegexFlags); SilcBufferStruct match; SilcBool match_all = (rflags & SILC_STR_REGEX_ALL) != 0; SilcBool match_nl = (rflags & SILC_STR_REGEX_NL) != 0; @@ -284,7 +283,7 @@ int silc_buffer_sformat_vp_i(SilcStack stack, SilcBuffer dst, va_list ap, if (x && tmp_len) { FORMAT_HAS_SPACE(stack, dst, tmp_len); - silc_buffer_put(dst, x, tmp_len); + silc_buffer_put(dst, (unsigned char *)x, tmp_len); silc_buffer_pull(dst, tmp_len); } break; @@ -669,7 +668,7 @@ int silc_buffer_sunformat_vp_i(SilcStack stack, SilcBuffer src, va_list ap, case SILC_PARAM_REGEX: { const char *regex = va_arg(ap, char *); - SilcBufferRegexFlags rflags = va_arg(ap, SilcUInt32); + SilcBufferRegexFlags rflags = va_arg(ap, SilcBufferRegexFlags); SilcBufferStruct match; SilcBool match_all = (rflags & SILC_STR_REGEX_ALL) != 0; SilcBool match_nl = (rflags & SILC_STR_REGEX_NL) != 0; diff --git a/lib/silcutil/silcconfig.c b/lib/silcutil/silcconfig.c index 55524a32..0568bd42 100644 --- a/lib/silcutil/silcconfig.c +++ b/lib/silcutil/silcconfig.c @@ -4,7 +4,7 @@ Author: Giovanni Giacobbi - Copyright (C) 2002 - 2007 Giovanni Giacobbi + Copyright (C) 2002 - 2008 Giovanni Giacobbi 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 @@ -16,9 +16,8 @@ GNU General Public License for more details. */ -/* $Id$ */ -#include "silc.h" +#include "silcruntime.h" /* limit debug logging verbosity */ #if 0 diff --git a/lib/silcutil/silcconfig.h b/lib/silcutil/silcconfig.h index c58bd28a..4d4be425 100644 --- a/lib/silcutil/silcconfig.h +++ b/lib/silcutil/silcconfig.h @@ -34,10 +34,10 @@ * * Now you can use the newly created Entity to register a group of expected * known options and sub-blocks, and then you can call the main parsing loop - * with the silc_config_main() function. When silc_config_main() will - * return, if some error encoured the object file will point to the file - * that caused this error (this can be different from the originally - * opened file if it contained `Include' directives). If no errors + * with the silc_config_main() function. When silc_config_main() will + * return, if some error encoured the object file will point to the file + * that caused this error (this can be different from the originally + * opened file if it contained `Include' directives). If no errors * encoured then the File objects will still point to the original file. * * While silc_config_main() will take care of destroying Entities before diff --git a/lib/silcutil/silcdll.c b/lib/silcutil/silcdll.c index 59ca44d5..2c5de41d 100644 --- a/lib/silcutil/silcdll.c +++ b/lib/silcutil/silcdll.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2007 Pekka Riikonen + Copyright (C) 2007 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /* Load shared object */ @@ -48,7 +48,9 @@ SilcDll silc_dll_load(const char *object_path) void silc_dll_close(SilcDll dll) { #ifdef SILC_UNIX +#if defined(HAVE_DLOPEN) dlclose(dll); +#endif /* HAVE_DLOPEN */ #elif SILC_WIN32 FreeLibrary(dll); #else @@ -61,7 +63,9 @@ void silc_dll_close(SilcDll dll) void *silc_dll_getsym(SilcDll dll, const char *symbol) { #ifdef SILC_UNIX +#if defined(HAVE_DLOPEN) return (void *)dlsym(dll, symbol); +#endif /* HAVE_DLOPEN */ #elif SILC_WIN32 return (void *)GetProcAddress(dll, symbol); #else @@ -77,7 +81,9 @@ void *silc_dll_getsym(SilcDll dll, const char *symbol) const char *silc_dll_error(SilcDll dll) { #ifdef SILC_UNIX +#if defined(HAVE_DLOPEN) return dlerror(); +#endif /* HAVE_DLOPEN */ #elif SILC_WIN32 return NULL; #else diff --git a/lib/silcutil/silcenv.c b/lib/silcutil/silcenv.c index fda48490..fe50269d 100644 --- a/lib/silcutil/silcenv.c +++ b/lib/silcutil/silcenv.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2007 Pekka Riikonen + Copyright (C) 2007 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /* Set environment variable with value */ diff --git a/lib/silcutil/silcenv.h b/lib/silcutil/silcenv.h index f8474c6c..97dd6630 100644 --- a/lib/silcutil/silcenv.h +++ b/lib/silcutil/silcenv.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2007 Pekka Riikonen + Copyright (C) 2007 - 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 @@ -90,5 +90,4 @@ SilcBool silc_unsetenv(const char *variable); ***/ SilcBool silc_clearenv(void); - #endif /* SILCENV_H */ diff --git a/lib/silcutil/silcerrno.c b/lib/silcutil/silcerrno.c index 5f415e94..c8245c64 100644 --- a/lib/silcutil/silcerrno.c +++ b/lib/silcutil/silcerrno.c @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /* Get last error */ @@ -44,8 +44,6 @@ void silc_set_errno(SilcResult error) return; } - SILC_LOG_DEBUG(("Error: %s (%d)", silc_errno_string(error), error)); - tls->error_reason[0] = '\0'; tls->error = error; } @@ -59,8 +57,6 @@ void silc_set_errno_nofail(SilcResult error) if (!tls) return; - SILC_LOG_DEBUG(("Error: %s (%d)", silc_errno_string(error), error)); - tls->error_reason[0] = '\0'; tls->error = error; } @@ -83,9 +79,6 @@ void silc_set_errno_reason(SilcResult error, const char *format, ...) silc_vsnprintf(tls->error_reason, sizeof(tls->error_reason), format, va); va_end(va); - SILC_LOG_DEBUG(("Error: %s (%d): %s", silc_errno_string(error), error, - tls->error_reason)); - tls->error = error; } @@ -103,9 +96,6 @@ void silc_set_errno_reason_nofail(SilcResult error, const char *format, ...) silc_vsnprintf(tls->error_reason, sizeof(tls->error_reason), format, va); va_end(va); - SILC_LOG_DEBUG(("Error: %s (%d): %s", silc_errno_string(error), error, - tls->error_reason)); - tls->error = error; } diff --git a/lib/silcutil/silcfdstream.c b/lib/silcutil/silcfdstream.c index ea043f2b..5ba65ba9 100644 --- a/lib/silcutil/silcfdstream.c +++ b/lib/silcutil/silcfdstream.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005 - 2007 Pekka Riikonen + Copyright (C) 2005 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /************************** Types and definitions ***************************/ diff --git a/lib/silcutil/silcfileutil.c b/lib/silcutil/silcfileutil.c index ea48479b..a4b9739c 100644 --- a/lib/silcutil/silcfileutil.c +++ b/lib/silcutil/silcfileutil.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2007 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 @@ -16,9 +16,8 @@ GNU General Public License for more details. */ -/* $Id$ */ -#include "silc.h" +#include "silcruntime.h" /* Opens a file indicated by the filename `filename' with flags indicated by the `flags'. */ diff --git a/lib/silcutil/silcfileutil.h b/lib/silcutil/silcfileutil.h index b3b0312c..a02c49b3 100644 --- a/lib/silcutil/silcfileutil.h +++ b/lib/silcutil/silcfileutil.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2007 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 @@ -21,8 +21,8 @@ * * DESCRIPTION * - * The SILC File Util Interface is a small set of functions that provides a - * portable access method to the filesystem. + * The SILC File Util Interface is a small set of functions that provides a + * portable access method to the filesystem. * ***/ diff --git a/lib/silcutil/silcfsm.c b/lib/silcutil/silcfsm.c index 2ded9832..bbd297a0 100644 --- a/lib/silcutil/silcfsm.c +++ b/lib/silcutil/silcfsm.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005 - 2007 Pekka Riikonen + Copyright (C) 2005 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" SILC_TASK_CALLBACK(silc_fsm_run); SILC_TASK_CALLBACK(silc_fsm_finish_fsm); diff --git a/lib/silcutil/silcgetopt.c b/lib/silcutil/silcgetopt.c index 56976176..32d4d8f6 100644 --- a/lib/silcutil/silcgetopt.c +++ b/lib/silcutil/silcgetopt.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2007 Pekka Riikonen + Copyright (C) 2007 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /* Getopt, like getopt(3). */ diff --git a/lib/silcutil/silchashtable.c b/lib/silcutil/silchashtable.c index 13c655e7..f440be49 100644 --- a/lib/silcutil/silchashtable.c +++ b/lib/silcutil/silchashtable.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2001 - 2007 Pekka Riikonen + Copyright (C) 2001 - 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 @@ -23,10 +23,8 @@ However, this is reliable and no data is lost at any point. If you know that you never have duplicate keys then this is as fast as any simple hash table. */ -/* $Id$ */ -#include "silc.h" -#include "silchashtable.h" +#include "silcruntime.h" /* Define to 1 if you want hash table debug enabled */ #define SILC_HASH_TABLE_DEBUG 0 diff --git a/lib/silcutil/silclog.c b/lib/silcutil/silclog.c index d0bec0c1..18cff9a5 100644 --- a/lib/silcutil/silclog.c +++ b/lib/silcutil/silclog.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2007 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 @@ -16,9 +16,8 @@ GNU General Public License for more details. */ -/* $Id$ */ -#include "silc.h" +#include "silcruntime.h" /* SilcLogSettings context */ typedef struct { diff --git a/lib/silcutil/silcmemory.c b/lib/silcutil/silcmemory.c index b7f69df8..f57ff458 100644 --- a/lib/silcutil/silcmemory.c +++ b/lib/silcutil/silcmemory.c @@ -16,9 +16,8 @@ GNU General Public License for more details. */ -/* $Id$ */ -#include "silc.h" +#include "silcruntime.h" #ifndef SILC_STACKTRACE diff --git a/lib/silcutil/silcmime.c b/lib/silcutil/silcmime.c index 839eb354..293393bc 100644 --- a/lib/silcutil/silcmime.c +++ b/lib/silcutil/silcmime.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005 - 2007 Pekka Riikonen + Copyright (C) 2005 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /************************** Types and definitions ***************************/ diff --git a/lib/silcutil/silcmime.h b/lib/silcutil/silcmime.h index 664b526a..3b22e618 100644 --- a/lib/silcutil/silcmime.h +++ b/lib/silcutil/silcmime.h @@ -21,11 +21,11 @@ * * DESCRIPTION * - * Simple implementation of MIME. Supports creation and parsing of simple + * Simple MIME Interface. This API supports creation and parsing of simple * MIME messages, multipart MIME messages, including nested multiparts, and * MIME fragmentation and defragmentation. * - * SILC Mime API is not thread-safe. If the same MIME context must be + * SILC Mime API is not thread-safe. If the same SilcMime context must be * used in multithreaded environment concurrency control must be employed. * ***/ diff --git a/lib/silcutil/silcnet.c b/lib/silcutil/silcnet.c index edd982a6..5c6dadb0 100644 --- a/lib/silcutil/silcnet.c +++ b/lib/silcutil/silcnet.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2007 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 @@ -16,9 +16,8 @@ GNU General Public License for more details. */ -/* $Id$ */ -#include "silc.h" +#include "silcruntime.h" /* Returns bound port from listener */ @@ -112,7 +111,7 @@ int silc_net_set_socket_opt(int sock, int level, int option, int on) int silc_net_get_socket_opt(int sock, int level, int option, void *optval, int *opt_len) { - int ret = getsockopt(sock, level, option, optval, opt_len); + int ret = getsockopt(sock, level, option, optval, (unsigned int *)opt_len); if (ret < 0) silc_set_errno_posix(errno); return ret; @@ -383,7 +382,8 @@ SilcBool silc_net_check_host_by_sock(SilcSocket sock, char **hostname, char **ip) { char host[1024]; - int rval, len; + int rval; + unsigned int len; #ifdef HAVE_IPV6 struct sockaddr_storage remote; @@ -462,7 +462,8 @@ SilcBool silc_net_check_local_by_sock(SilcSocket sock, char **hostname, char **ip) { char host[1024]; - int rval, len; + int rval; + unsigned int len; #ifdef HAVE_IPV6 struct sockaddr_storage local; @@ -540,7 +541,7 @@ SilcUInt16 silc_net_get_remote_port(SilcSocket sock) { #ifdef HAVE_IPV6 struct sockaddr_storage remote; - int len; + unsigned int len; char s[NI_MAXSERV]; memset(&remote, 0, sizeof(remote)); @@ -555,7 +556,7 @@ SilcUInt16 silc_net_get_remote_port(SilcSocket sock) return atoi(s); #else struct sockaddr_in remote; - int len; + unsigned int len; memset(&remote, 0, sizeof(remote)); len = sizeof(remote); @@ -572,7 +573,7 @@ SilcUInt16 silc_net_get_local_port(SilcSocket sock) { #ifdef HAVE_IPV6 struct sockaddr_storage local; - int len; + unsigned int len; char s[NI_MAXSERV]; memset(&local, 0, sizeof(local)); @@ -587,7 +588,7 @@ SilcUInt16 silc_net_get_local_port(SilcSocket sock) return atoi(s); #else struct sockaddr_in local; - int len; + unsigned int len; memset(&local, 0, sizeof(local)); len = sizeof(local); diff --git a/lib/silcutil/silcregex.c b/lib/silcutil/silcregex.c index dba552b7..84449695 100644 --- a/lib/silcutil/silcregex.c +++ b/lib/silcutil/silcregex.c @@ -36,7 +36,7 @@ - SilcStack support compile/match without real memory allocations */ -#include "silc.h" +#include "silcruntime.h" #define RE_NREGS 128 /* number of registers available */ @@ -2315,7 +2315,7 @@ SilcBool silc_regex_compile(SilcRegex regexp, const char *regex, regexp->rstack = silc_stack_alloc(512, regexp->rstack); /* Compile */ - ret = silc_re_compile_pattern((char *)regex, strlen(regex), regexp); + ret = silc_re_compile_pattern((unsigned char *)regex, strlen(regex), regexp); if (ret != SILC_OK) silc_set_errno(ret); @@ -2359,8 +2359,8 @@ SilcBool silc_regex_match(SilcRegex regexp, const char *string, f |= RE_NOTEOL; /* Search */ - ret = silc_re_search(regexp, (char *)string, string_len, 0, string_len, - num_match ? ®s : NULL, f); + ret = silc_re_search(regexp, (unsigned char *)string, string_len, 0, + string_len, num_match ? ®s : NULL, f); if (ret < 0) { if (ret == -1) silc_set_errno(SILC_ERR_NOT_FOUND); diff --git a/lib/silcutil/silcregex.h b/lib/silcutil/silcregex.h index 4047088f..8b5a6654 100644 --- a/lib/silcutil/silcregex.h +++ b/lib/silcutil/silcregex.h @@ -370,6 +370,11 @@ SilcBool silc_regex_buffer(SilcBuffer buffer, const char *regex, * using the SILC_STR_REGEX in SILC Buffer Format API directly. This * function only provides basic matching and substitution. * + * EXAMPLE + * + * // Replace all foos with bar on all lines in the buffer + * silc_subst(buffer, "s/foo/bar/g"); + * ***/ SilcBool silc_subst(SilcBuffer buffer, const char *subst); diff --git a/lib/silcutil/silcschedule.c b/lib/silcutil/silcschedule.c index 5550181a..bb9c19f2 100644 --- a/lib/silcutil/silcschedule.c +++ b/lib/silcutil/silcschedule.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1998 - 2007 Pekka Riikonen + Copyright (C) 1998 - 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 @@ -16,9 +16,8 @@ GNU General Public License for more details. */ -/* $Id$ */ -#include "silc.h" +#include "silcruntime.h" /************************** Types and definitions ***************************/ @@ -227,13 +226,15 @@ static void silc_schedule_task_remove(SilcSchedule schedule, SilcTask task) /* Delete even tasks */ parent = silc_schedule_get_parent(schedule); - silc_hash_table_list(parent->events, &htl); - while (silc_hash_table_get(&htl, NULL, (void *)&etask)) { - silc_hash_table_del_by_context(parent->events, etask->event, etask); - silc_free(etask->event); - silc_free(etask); + if (parent->events) { + silc_hash_table_list(parent->events, &htl); + while (silc_hash_table_get(&htl, NULL, (void *)&etask)) { + silc_hash_table_del_by_context(parent->events, etask->event, etask); + silc_free(etask->event); + silc_free(etask); + } + silc_hash_table_list_reset(&htl); } - silc_hash_table_list_reset(&htl); return; } @@ -880,10 +881,12 @@ SilcBool silc_schedule_task_del(SilcSchedule schedule, SilcTask task) /* Delete even tasks */ parent = silc_schedule_get_parent(schedule); - silc_hash_table_list(parent->events, &htl); - while (silc_hash_table_get(&htl, NULL, (void *)&task)) - task->valid = FALSE; - silc_hash_table_list_reset(&htl); + if (parent->events) { + silc_hash_table_list(parent->events, &htl); + while (silc_hash_table_get(&htl, NULL, (void *)&task)) + task->valid = FALSE; + silc_hash_table_list_reset(&htl); + } SILC_SCHEDULE_UNLOCK(schedule); return TRUE; diff --git a/lib/silcutil/silcschedule.h b/lib/silcutil/silcschedule.h index c3120181..9cb47540 100644 --- a/lib/silcutil/silcschedule.h +++ b/lib/silcutil/silcschedule.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1998 - 2007 Pekka Riikonen + Copyright (C) 1998 - 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 @@ -33,16 +33,16 @@ * * The SILC Scheduler is designed to be the sole main loop of the application * so that the application does not need any other main loop. However, - * SILC Scheduler does support running the scheduler only once, so that the - * scheduler does not block, and thus providing a possiblity that some + * SILC Scheduler does support running the scheduler only one iteration, so + * that the scheduler does not block, and thus providing a possiblity that some * external main loop is run over the SILC Scheduler. * - * Typical application first initializes the scheduler and then registers + * Typical application first initializes the scheduler and then register * the very first tasks to the scheduler and then run the scheduler. After * the scheduler's run function returns the application is considered to be * ended. * - * On WIN32 systems the SILC Scheduler is too designed to work as the main + * On Windows systems the SILC Scheduler is too designed to work as the main * loop of the GUI application. It can handle all Windows messages and * it dispatches them from the scheduler, and thus makes it possible to * create GUI applications. The scheduler can also handle all kinds of @@ -57,7 +57,8 @@ * which makes it possible to allocate several schedulers for one application. * Since the scheduler must be run in single-thread, a multi-threaded * application could be created by allocating own scheduler for each of the - * worker threads. + * worker threads. Each scheduler in worker thread should be a child + * scheduler created from the main thread's parent schedule. * ***/ diff --git a/lib/silcutil/silcsnprintf.c b/lib/silcutil/silcsnprintf.c index d49b6d1f..120ab027 100644 --- a/lib/silcutil/silcsnprintf.c +++ b/lib/silcutil/silcsnprintf.c @@ -55,7 +55,7 @@ * **************************************************************/ -#include "silc.h" +#include "silcruntime.h" #ifdef HAVE_LONG_DOUBLE #define LDOUBLE long double diff --git a/lib/silcutil/silcsocketstream.c b/lib/silcutil/silcsocketstream.c index e11fff73..7f61e518 100644 --- a/lib/silcutil/silcsocketstream.c +++ b/lib/silcutil/silcsocketstream.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005 - 2007 Pekka Riikonen + Copyright (C) 2005 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /************************** Types and definitions ***************************/ diff --git a/lib/silcutil/silcsocketstream.h b/lib/silcutil/silcsocketstream.h index 46cce4fa..ad7ce71d 100644 --- a/lib/silcutil/silcsocketstream.h +++ b/lib/silcutil/silcsocketstream.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005 - 2007 Pekka Riikonen + Copyright (C) 2005 - 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 @@ -230,7 +230,7 @@ SilcBool silc_socket_stream_set_info(SilcStream stream, * more than `read_limit_bytes' of data. The `limit_sec' and `limit_usec' * specifies the time limit that is applied if `read_rate' and/or * `read_limit_bytes' is reached. If all arguments except `stream' - * are zero this resets the QoS from the socket stream, all QoS for + * are zero this resets the QoS from the socket stream, all QoS data for * this socket stream that may be pending will be cancelled. * ***/ diff --git a/lib/silcutil/silcstack.c b/lib/silcutil/silcstack.c index 3fd06d33..6a2d5d6b 100644 --- a/lib/silcutil/silcstack.c +++ b/lib/silcutil/silcstack.c @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /************************** Types and definitions ***************************/ diff --git a/lib/silcutil/silcstack.h b/lib/silcutil/silcstack.h index f2663eef..0a41e6ba 100644 --- a/lib/silcutil/silcstack.h +++ b/lib/silcutil/silcstack.h @@ -21,7 +21,7 @@ * * DESCRIPTION * - * Implementation of data stack which can be used to do fast allocations from + * Data stack interface which can be used to do fast allocations from * the stack. Basically SilcStack is a pre-allocated memory pool system * which allows fast memory allocation for routines and applications that * frequently allocate small amounts of memory. Other advantage of this @@ -163,7 +163,7 @@ void silc_stack_free(SilcStack stack); * * DESCRIPTION * - * Push the top of the stack down which becomes the new top of the stack. + * Push the top of the stack and add new stack frame on top of the stack. * For every silc_stack_push call there must be silc_stack_pop call. All * allocations between these two calls will be done from the top of the * stack and all allocated memory is freed after the next silc_stack_pop @@ -223,8 +223,8 @@ SilcUInt32 silc_stack_push(SilcStack stack, SilcStackFrame *frame); * * DESCRIPTION * - * Pop the top of the stack which removes the previous stack frame and - * becomes the top of the stack. After popping, memory allocated in + * Pop the top of the stack to remove the previous stack frame and use + * previous frame as top of the stack. After popping, memory allocated in * the old frame is freed. For each silc_stack_push call there must be * silc_stack_pop call to free all memory (in reality any memory is not * freed but within the stack it is). This returns the stack pointer of @@ -295,7 +295,8 @@ void *silc_stack_malloc(SilcStack stack, SilcUInt32 size); * NOTES * * This function should be used only if low level memory allocation with - * SilcStack is needed. Instead, silc_srealloc could be used. + * SilcStack is needed. Instead, silc_srealloc could be used which can + * handle failed reallocation by allocating new block. * ***/ void *silc_stack_realloc(SilcStack stack, SilcUInt32 old_size, diff --git a/lib/silcutil/silcstream.c b/lib/silcutil/silcstream.c index af4789df..5e01ad39 100644 --- a/lib/silcutil/silcstream.c +++ b/lib/silcutil/silcstream.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005 - 2006 Pekka Riikonen + Copyright (C) 2005 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" typedef struct { SilcStreamOps *ops; diff --git a/lib/silcutil/silcstream.h b/lib/silcutil/silcstream.h index 85364d2a..d88efa92 100644 --- a/lib/silcutil/silcstream.h +++ b/lib/silcutil/silcstream.h @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2005 - 2007 Pekka Riikonen + Copyright (C) 2005 - 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 @@ -26,6 +26,9 @@ * other stream API derived from this API can use this same interface for * reading and writing. * + * The SilcStream is an abstraction. It can represent any stream, socket + * stream, file descriptor stream, packet stream, etc. + * * Note that stream implementations usually are not thread-safe. Always * verify whether a stream implementation is thread-safe by checking their * corresponding documentation. diff --git a/lib/silcutil/silcstringprep.c b/lib/silcutil/silcstringprep.c index b1716cc5..96cc9cbd 100644 --- a/lib/silcutil/silcstringprep.c +++ b/lib/silcutil/silcstringprep.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2004 - 2005 Pekka Riikonen + Copyright (C) 2004 - 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 @@ -17,8 +17,7 @@ */ -#include "silc.h" -#include "silcstringprep.h" +#include "silcruntime.h" #include "stringprep.h" /* We use GNU Libidn which has stringprep to do the magic. Only bad thing diff --git a/lib/silcutil/silcstrutil.c b/lib/silcutil/silcstrutil.c index 3251c2b0..f13233e0 100644 --- a/lib/silcutil/silcstrutil.c +++ b/lib/silcutil/silcstrutil.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2002 - 2007 Pekka Riikonen + Copyright (C) 2002 - 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 @@ -16,10 +16,8 @@ GNU General Public License for more details. */ -/* $Id$ */ -#include "silc.h" -#include "silcstrutil.h" +#include "silcruntime.h" /* Concatenates the `src' into `dest'. If `src_len' is more than the size of the `dest' (minus NULL at the end) the `src' will be diff --git a/lib/silcutil/silcstrutil.h b/lib/silcutil/silcstrutil.h index bc692975..2caeb4c7 100644 --- a/lib/silcutil/silcstrutil.h +++ b/lib/silcutil/silcstrutil.h @@ -21,9 +21,7 @@ * * DESCRIPTION * - * String manipulation utility routines. These routines provides - * various helper functions for encoding, decoding and otherwise - * managing strings. + * Various string utility routines. * ***/ diff --git a/lib/silcutil/silcthread.c b/lib/silcutil/silcthread.c index 8e51a15d..aad875a0 100644 --- a/lib/silcutil/silcthread.c +++ b/lib/silcutil/silcthread.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2007 Pekka Riikonen + Copyright (C) 2007 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /***************************** Thread Pool API *****************************/ diff --git a/lib/silcutil/silctime.c b/lib/silcutil/silctime.c index 4dc7f217..37444269 100644 --- a/lib/silcutil/silctime.c +++ b/lib/silcutil/silctime.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2003 - 2007 Pekka Riikonen + Copyright (C) 2003 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /* Fills the SilcTime structure with correct values */ diff --git a/lib/silcutil/silctimer.c b/lib/silcutil/silctimer.c index 0313a315..049341b7 100644 --- a/lib/silcutil/silctimer.c +++ b/lib/silcutil/silctimer.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2007 Pekka Riikonen + Copyright (C) 2007 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /* Start timer */ diff --git a/lib/silcutil/silctypes.h b/lib/silcutil/silctypes.h index 08b05320..8cbb20d0 100644 --- a/lib/silcutil/silctypes.h +++ b/lib/silcutil/silctypes.h @@ -255,7 +255,7 @@ typedef SilcUInt32 * void *; * Platform specific socket. On POSIX compliant systems this is simply * an integer, representing the socket. On other systems it is platform * specific socket context. Access it only through routines that can - * handle SilcSocket types, unless you know what you are doing. + * handle SilcSocket types. * * SOURCE */ diff --git a/lib/silcutil/silcutf8.c b/lib/silcutil/silcutf8.c index 8bbb5ece..617c3d47 100644 --- a/lib/silcutil/silcutf8.c +++ b/lib/silcutil/silcutf8.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2004 - 2007 Pekka Riikonen + Copyright (C) 2004 - 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 @@ -17,8 +17,7 @@ */ -#include "silc.h" -#include "silcutf8.h" +#include "silcruntime.h" /* Encodes the string `bin' of which encoding is `bin_encoding' to the UTF-8 encoding into the buffer `utf8' which is of size of `utf8_size'. @@ -508,7 +507,7 @@ SilcUInt32 silc_utf8_decode(const unsigned char *utf8, SilcUInt32 utf8_len, if (enclen + 3 > bin_size) goto overflow; bin[enclen] = '\\'; - silc_snprintf(bin + enclen + 1, 3, "%02X", cv); + silc_snprintf((char *)bin + enclen + 1, 3, "%02X", cv); } enclen += 3; continue; diff --git a/lib/silcutil/silcutil.c b/lib/silcutil/silcutil.c index 75e85f93..0d6498f3 100644 --- a/lib/silcutil/silcutil.c +++ b/lib/silcutil/silcutil.c @@ -20,9 +20,8 @@ * These are general utility functions that doesn't belong to any specific * group of routines. */ -/* $Id$ */ -#include "silc.h" +#include "silcruntime.h" /* Gets line from a buffer. Stops reading when a newline or EOF occurs. This doesn't remove the newline sign from the destination buffer. The @@ -256,14 +255,14 @@ char *silc_fingerprint(const unsigned char *data, SilcUInt32 data_len) return NULL; for (i = 0; i < data_len; i++) { - silc_snprintf(cp, len, "%02X", data[i]); + silc_snprintf((char *)cp, len, "%02X", data[i]); cp += 2; len -= 2; if ((i + 1) % 2 == 0) - silc_snprintf(cp++, len--, " "); + silc_snprintf((char *)cp++, len--, " "); if ((i + 1) % 10 == 0) - silc_snprintf(cp++, len--, " "); + silc_snprintf((char *)cp++, len--, " "); } i--; if ((i + 1) % 10 == 0) @@ -271,7 +270,7 @@ char *silc_fingerprint(const unsigned char *data, SilcUInt32 data_len) if ((i + 1) % 2 == 0) *(--cp) = '\0'; - return fingerprint; + return (char *)fingerprint; } /* Return TRUE if the `data' is ASCII string. */ diff --git a/lib/silcutil/stacktrace.c b/lib/silcutil/stacktrace.c index 9f335e44..e1563415 100644 --- a/lib/silcutil/stacktrace.c +++ b/lib/silcutil/stacktrace.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2002, 2007 Pekka Riikonen + Copyright (C) 2002 - 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" #ifdef SILC_STACKTRACE diff --git a/lib/silcutil/symbian/.gitignore b/lib/silcutil/symbian/.gitignore index 282522db..a501f929 100644 --- a/lib/silcutil/symbian/.gitignore +++ b/lib/silcutil/symbian/.gitignore @@ -1,2 +1,8 @@ Makefile -Makefile.in +*.in +*.am +*.o +*.lo +*.la +*.a +*.pc diff --git a/lib/silcutil/tests/Makefile.am b/lib/silcutil/tests/Makefile.am index 94f01274..e4997279 100644 --- a/lib/silcutil/tests/Makefile.am +++ b/lib/silcutil/tests/Makefile.am @@ -3,7 +3,7 @@ # # Author: Pekka Riikonen # -# Copyright (C) 2004 - 2007 Pekka Riikonen +# Copyright (C) 2004 - 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 @@ -17,37 +17,22 @@ AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign -bin_PROGRAMS = test_silcstrutil test_silcstringprep test_silchashtable \ +check_PROGRAMS = \ + test_silcstrutil test_silcstringprep test_silchashtable \ test_silclist test_silcfsm test_silcasync test_silcschedule \ test_silcnet test_silcstack test_silcmime test_silcfdstream \ test_silcatomic test_silcmutex test_silctime test_silcthread \ test_silcdll test_silcenv test_silctimer test_silcbitops \ - test_silcregex test_silcbuffmt test_silcdir + test_silcregex test_silcbuffmt test_silcdir test_silcthreadqueue -test_silcstrutil_SOURCES = test_silcstrutil.c -test_silcstringprep_SOURCES = test_silcstringprep.c -test_silchashtable_SOURCES = test_silchashtable.c -test_silclist_SOURCES = test_silclist.c -test_silcmime_SOURCES = test_silcmime.c -test_silcfsm_SOURCES = test_silcfsm.c -test_silcasync_SOURCES = test_silcasync.c -test_silcschedule_SOURCES = test_silcschedule.c -test_silcnet_SOURCES = test_silcnet.c -test_silcstack_SOURCES = test_silcstack.c -test_silcfdstream_SOURCES = test_silcfdstream.c -test_silcatomic_SOURCES = test_silcatomic.c -test_silcmutex_SOURCES = test_silcmutex.c -test_silctime_SOURCES = test_silctime.c -test_silcthread_SOURCES = test_silcthread.c -test_silcdll_SOURCES = test_silcdll.c -test_silcenv_SOURCES = test_silcenv.c -test_silctimer_SOURCES = test_silctimer.c -test_silcbitops_SOURCES = test_silcbitops.c -test_silcregex_SOURCES = test_silcregex.c -test_silcbuffmt_SOURCES = test_silcbuffmt.c -test_silcdir_SOURCES = test_silcdir.c +TESTS = test_silcstrutil test_silcstringprep test_silchashtable \ + test_silclist test_silcfsm test_silcasync test_silcschedule \ + test_silcnet test_silcstack test_silcmime test_silcfdstream \ + test_silcatomic test_silctime test_silcthread \ + test_silcdll test_silcenv test_silctimer test_silcbitops \ + test_silcregex test_silcbuffmt test_silcdir test_silcthreadqueue LIBS = $(SILC_COMMON_LIBS) -LDADD = -L.. -L../.. -lsilc +LDADD = -L.. -L../.. -lsrt include $(top_srcdir)/Makefile.defines.in diff --git a/lib/silcutil/tests/test_silcasync.c b/lib/silcutil/tests/test_silcasync.c index 92ff6669..7e8be9e3 100644 --- a/lib/silcutil/tests/test_silcasync.c +++ b/lib/silcutil/tests/test_silcasync.c @@ -1,6 +1,6 @@ /* SilcAsyncOperation tests */ -#include "silc.h" +#include "silcruntime.h" #include "silcfsm.h" #include "silcasync.h" @@ -126,7 +126,7 @@ int main(int argc, char **argv) } SILC_LOG_DEBUG(("Allocating scheduler")); - schedule = silc_schedule_init(0, NULL, NULL); + schedule = silc_schedule_init(0, NULL, NULL, NULL); f = silc_calloc(1, sizeof(*f)); if (!f) @@ -154,5 +154,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcatomic.c b/lib/silcutil/tests/test_silcatomic.c index 59637427..f1f99872 100644 --- a/lib/silcutil/tests/test_silcatomic.c +++ b/lib/silcutil/tests/test_silcatomic.c @@ -1,7 +1,6 @@ /* atomic operation tests */ -#include "silc.h" -#include "silcatomic.h" +#include "silcruntime.h" int main(int argc, char **argv) { @@ -115,5 +114,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcbitops.c b/lib/silcutil/tests/test_silcbitops.c index 0c5b1e6e..80fb00f0 100644 --- a/lib/silcutil/tests/test_silcbitops.c +++ b/lib/silcutil/tests/test_silcbitops.c @@ -1,6 +1,6 @@ /* Bit operation tests */ -#include "silc.h" +#include "silcruntime.h" int main(int argc, char **argv) { @@ -134,5 +134,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcbuffmt.c b/lib/silcutil/tests/test_silcbuffmt.c index 44bac0ac..6e856e97 100644 --- a/lib/silcutil/tests/test_silcbuffmt.c +++ b/lib/silcutil/tests/test_silcbuffmt.c @@ -1,6 +1,6 @@ /* Buffer formatting tests */ -#include "silc.h" +#include "silcruntime.h" int print(SilcStack stack, SilcBuffer buf, void *value, void *context) { @@ -153,5 +153,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcdir.c b/lib/silcutil/tests/test_silcdir.c index e9e36941..151aad67 100644 --- a/lib/silcutil/tests/test_silcdir.c +++ b/lib/silcutil/tests/test_silcdir.c @@ -1,6 +1,6 @@ /* SilcDir tests */ -#include "silc.h" +#include "silcruntime.h" int main(int argc, char **argv) { @@ -49,5 +49,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcdll.c b/lib/silcutil/tests/test_silcdll.c index e4c3b9eb..a9805cff 100644 --- a/lib/silcutil/tests/test_silcdll.c +++ b/lib/silcutil/tests/test_silcdll.c @@ -1,6 +1,6 @@ /* SilcDll tests */ -#include "silc.h" +#include "silcruntime.h" int main(int argc, char **argv) { @@ -17,6 +17,8 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Load shared object /lib/libc.so.6")); dll = silc_dll_load("/lib/libc.so.6"); + if (!dll) + dll = silc_dll_load("/lib64/libc.so.6"); if (!dll) { SILC_LOG_DEBUG(("Cannot load: %s", silc_dll_error(dll))); goto err; @@ -37,5 +39,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcenv.c b/lib/silcutil/tests/test_silcenv.c index bd56d937..52a5e81e 100644 --- a/lib/silcutil/tests/test_silcenv.c +++ b/lib/silcutil/tests/test_silcenv.c @@ -1,6 +1,6 @@ /* environment tests */ -#include "silc.h" +#include "silcruntime.h" int main(int argc, char **argv) { @@ -21,14 +21,9 @@ int main(int argc, char **argv) goto err; success = TRUE; - for (i = 0; i < SILC_ERR_MAX + 10; i++) { - fprintf(stderr, "%d: ", i); - silc_set_errno(i); - } - err: SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcfdstream.c b/lib/silcutil/tests/test_silcfdstream.c index dfc23173..c3c3b99c 100644 --- a/lib/silcutil/tests/test_silcfdstream.c +++ b/lib/silcutil/tests/test_silcfdstream.c @@ -1,6 +1,6 @@ /* SILC FD Stream tests */ -#include "silc.h" +#include "silcruntime.h" SilcBool success = FALSE; SilcSchedule schedule; @@ -203,7 +203,7 @@ int main(int argc, char **argv) } SILC_LOG_DEBUG(("Allocating scheduler")); - schedule = silc_schedule_init(0, NULL, NULL); + schedule = silc_schedule_init(0, NULL, NULL, NULL); if (!schedule) goto err; @@ -227,5 +227,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcfsm.c b/lib/silcutil/tests/test_silcfsm.c index 782165f6..8cfda2dc 100644 --- a/lib/silcutil/tests/test_silcfsm.c +++ b/lib/silcutil/tests/test_silcfsm.c @@ -1,6 +1,6 @@ /* SILC FSM tests */ -#include "silc.h" +#include "silcruntime.h" #include "silcfsm.h" typedef void (*Callback)(void *context); @@ -454,7 +454,7 @@ int main(int argc, char **argv) } SILC_LOG_DEBUG(("Allocating scheduler")); - schedule = silc_schedule_init(0, NULL, NULL); + schedule = silc_schedule_init(0, NULL, NULL, NULL); f = silc_calloc(1, sizeof(*f)); if (!f) @@ -482,5 +482,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silchashtable.c b/lib/silcutil/tests/test_silchashtable.c index 742b3728..2ee6ddbb 100644 --- a/lib/silcutil/tests/test_silchashtable.c +++ b/lib/silcutil/tests/test_silchashtable.c @@ -1,6 +1,6 @@ /* Hash table tests */ -#include "silc.h" +#include "silcruntime.h" typedef struct entry_struct { char name[8]; @@ -313,5 +313,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silclist.c b/lib/silcutil/tests/test_silclist.c index f0783f37..9efff72a 100644 --- a/lib/silcutil/tests/test_silclist.c +++ b/lib/silcutil/tests/test_silclist.c @@ -1,6 +1,6 @@ /* SilcList tests */ -#include "silc.h" +#include "silcruntime.h" struct foo { int i; @@ -42,11 +42,11 @@ int main(int argc, char **argv) silc_list_add(list, f1); silc_list_start(list); while ((f = silc_list_get(list)) != SILC_LIST_END) { - SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, + SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, f->prev)); } SILC_LOG_DEBUG(("Delete the entry")); - silc_list_del(list, f1); + silc_list_del(list, f1); silc_list_start(list); while ((f = silc_list_get(list)) != SILC_LIST_END) goto err; @@ -55,11 +55,11 @@ int main(int argc, char **argv) silc_list_add(list, f1); silc_list_start(list); while ((f = silc_list_get(list)) != SILC_LIST_END) { - SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, + SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, f->prev)); } SILC_LOG_DEBUG(("Delete the entry")); - silc_list_del(list, f1); + silc_list_del(list, f1); silc_list_start(list); while ((f = silc_list_get(list)) != SILC_LIST_END) goto err; @@ -68,7 +68,7 @@ int main(int argc, char **argv) silc_list_insert(list, NULL, f4); silc_list_start(list); while ((f = silc_list_get(list)) != SILC_LIST_END) { - SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, + SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, f->prev)); } @@ -86,7 +86,7 @@ int main(int argc, char **argv) silc_list_start(list); while ((f = silc_list_get(list)) != SILC_LIST_END) { - SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, + SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, f->prev)); } @@ -94,7 +94,7 @@ int main(int argc, char **argv) silc_list_insert(list, f1, f4); silc_list_start(list); while ((f = silc_list_get(list)) != SILC_LIST_END) { - SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, + SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, f->prev)); } @@ -105,7 +105,7 @@ int main(int argc, char **argv) silc_list_insert(list, f3, f4); silc_list_start(list); while ((f = silc_list_get(list)) != SILC_LIST_END) { - SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, + SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, f->prev)); } @@ -116,24 +116,24 @@ int main(int argc, char **argv) silc_list_insert(list, NULL, f4); silc_list_start(list); while ((f = silc_list_get(list)) != SILC_LIST_END) { - SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, + SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, f->prev)); } silc_list_start(list); silc_list_del(list, f1); while ((f = silc_list_get(list)) != SILC_LIST_END) { - SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, + SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, f->prev)); } silc_list_del(list, f3); while ((f = silc_list_get(list)) != SILC_LIST_END) { - SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, + SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, f->prev)); } silc_list_del(list, f2); while ((f = silc_list_get(list)) != SILC_LIST_END) { - SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, + SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, f->prev)); } @@ -143,7 +143,7 @@ int main(int argc, char **argv) silc_list_start(list); while ((f = silc_list_get(list)) != SILC_LIST_END) { - SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, + SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, f->prev)); } @@ -151,7 +151,7 @@ int main(int argc, char **argv) silc_list_start(list); while ((f = silc_list_get(list)) != SILC_LIST_END) { - SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, + SILC_LOG_DEBUG(("entry %d, %p, next=%p, prev=%p", f->i, f, f->next, f->prev)); } @@ -161,5 +161,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcmime.c b/lib/silcutil/tests/test_silcmime.c index d3b7d35d..5cf38bd8 100644 --- a/lib/silcutil/tests/test_silcmime.c +++ b/lib/silcutil/tests/test_silcmime.c @@ -1,6 +1,6 @@ /* SilcMime tests */ -#include "silc.h" +#include "silcruntime.h" #include "silcmime.h" int main(int argc, char **argv) @@ -22,7 +22,7 @@ int main(int argc, char **argv) silc_log_set_debug_string("*mime*,*errno*"); } - /* + /* * Simple MIME test */ SILC_LOG_DEBUG(("Allocating MIME message context")); @@ -279,5 +279,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcmutex.c b/lib/silcutil/tests/test_silcmutex.c index ffe17bd6..e52e1aaf 100644 --- a/lib/silcutil/tests/test_silcmutex.c +++ b/lib/silcutil/tests/test_silcmutex.c @@ -1,7 +1,7 @@ /* Locking performance tests. Gives locsk&unlocks/second. */ /* Version 1.0 */ -#include "silc.h" +#include "silcruntime.h" typedef struct { SilcThread thread; @@ -84,6 +84,7 @@ int main(int argc, char **argv) sleep(1); val = rdtsc() - val; val /= 1000; /* Gives us milliseconds */ + cpu_freq = val; fprintf(stderr, "CPU frequency: %llu\n", val); max_locks = MAX_LOCKS; @@ -179,5 +180,5 @@ int main(int argc, char **argv) fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcnet.c b/lib/silcutil/tests/test_silcnet.c index 7b1551ce..d478ed58 100644 --- a/lib/silcutil/tests/test_silcnet.c +++ b/lib/silcutil/tests/test_silcnet.c @@ -1,6 +1,6 @@ /* SILC Net API tests */ -#include "silc.h" +#include "silcruntime.h" SilcSchedule schedule; @@ -203,7 +203,7 @@ int main(int argc, char **argv) } SILC_LOG_DEBUG(("Allocating scheduler")); - schedule = silc_schedule_init(0, NULL, NULL); + schedule = silc_schedule_init(0, NULL, NULL, NULL); f = silc_calloc(1, sizeof(*f)); if (!f) @@ -231,5 +231,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcregex.c b/lib/silcutil/tests/test_silcregex.c index c1c6b44b..c0e970c0 100644 --- a/lib/silcutil/tests/test_silcregex.c +++ b/lib/silcutil/tests/test_silcregex.c @@ -1,6 +1,6 @@ /* Regex tests */ -#include "silc.h" +#include "silcruntime.h" int main(int argc, char **argv) { @@ -612,5 +612,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcschedule.c b/lib/silcutil/tests/test_silcschedule.c index 28d25632..216f14e6 100644 --- a/lib/silcutil/tests/test_silcschedule.c +++ b/lib/silcutil/tests/test_silcschedule.c @@ -1,6 +1,6 @@ /* SilcSchedule tests */ -#include "silc.h" +#include "silcruntime.h" typedef void (*Callback)(void *context); @@ -41,7 +41,7 @@ SILC_TASK_CALLBACK(timeout) SILC_TASK_CALLBACK(cont2) { #ifdef SILC_DEBUG - silc_schedule_stats(schedule); +// silc_schedule_stats(schedule); #endif /* SILC_DEBUG */ SILC_LOG_DEBUG(("Adding %d fd tasks", NUM_FTASK - 10)); @@ -50,6 +50,8 @@ SILC_TASK_CALLBACK(cont2) for (i = 0; i < NUM_FTASK - 10; i++) silc_schedule_task_add_fd(schedule, i + 5, foo, (void *)(i + 5)); #endif + + silc_schedule_event_signal(schedule, "interrupted", NULL, schedule); } SILC_TASK_CALLBACK(cont) @@ -57,7 +59,7 @@ SILC_TASK_CALLBACK(cont) int i; #ifdef SILC_DEBUG - silc_schedule_stats(schedule); +// silc_schedule_stats(schedule); #endif /* SILC_DEBUG */ SILC_LOG_DEBUG(("Adding %d timeout tasks", NUM_TTASK / 3)); @@ -185,5 +187,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcstack.c b/lib/silcutil/tests/test_silcstack.c index 34b6fc3f..00d65b15 100644 --- a/lib/silcutil/tests/test_silcstack.c +++ b/lib/silcutil/tests/test_silcstack.c @@ -1,6 +1,6 @@ /* SilcStack tests */ -#include "silc.h" +#include "silcruntime.h" #define NUM_ALLS 300 @@ -22,13 +22,17 @@ int main(int argc, char **argv) stack = silc_stack_alloc(0, NULL); if (!stack) goto err; +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Allocating 2048 bytes from stack")); ptr = silc_smalloc(stack, 2048); if (!ptr) goto err; +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Freeing the stack")); silc_stack_free(stack); @@ -37,7 +41,9 @@ int main(int argc, char **argv) stack = silc_stack_alloc(0, NULL); if (!stack) goto err; +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and allocating %d times", NUM_ALLS)); if (!silc_stack_push(stack, NULL)) @@ -47,10 +53,14 @@ int main(int argc, char **argv) if (!ptr2) goto err; } +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ silc_stack_pop(stack); SILC_LOG_DEBUG(("Popping")); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and allocating %d times", NUM_ALLS)); if (!silc_stack_push(stack, NULL)) @@ -60,10 +70,14 @@ int main(int argc, char **argv) if (!ptr2) goto err; } +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ silc_stack_pop(stack); SILC_LOG_DEBUG(("Popping")); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing %d times", NUM_ALLS / 2)); for (i = 0; i < NUM_ALLS / 2; i++) { @@ -73,11 +87,15 @@ int main(int argc, char **argv) if (!ptr2) goto err; } +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Popping %d times", NUM_ALLS / 2)); for (i = 0; i < NUM_ALLS / 2; i++) silc_stack_pop(stack); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and reallocating %d times", NUM_ALLS / 10)); ptr2 = NULL; @@ -88,10 +106,14 @@ int main(int argc, char **argv) if (!ptr2) goto err; } +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ silc_stack_pop(stack); SILC_LOG_DEBUG(("Popping")); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Creating child stack")); child = silc_stack_alloc(8190, stack); @@ -105,11 +127,15 @@ int main(int argc, char **argv) if (!ptr2) goto err; } +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Popping %d times", NUM_ALLS / 2)); for (i = 0; i < NUM_ALLS / 2; i++) silc_stack_pop(child); +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and reallocating %d times", NUM_ALLS / 10)); ptr2 = NULL; @@ -121,13 +147,21 @@ int main(int argc, char **argv) goto err; } ptr = silc_smalloc(child, 100000); +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ silc_stack_pop(child); SILC_LOG_DEBUG(("Popping")); +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ silc_stack_free(child); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Creating child stack")); child = silc_stack_alloc(8192, stack); @@ -141,11 +175,15 @@ int main(int argc, char **argv) if (!ptr2) goto err; } +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Popping %d times", NUM_ALLS / 10)); for (i = 0; i < NUM_ALLS / 10; i++) silc_stack_pop(child); +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Pushing and reallocating %d times", NUM_ALLS / 10)); ptr2 = NULL; @@ -159,19 +197,31 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Allocate child from child")); child2 = silc_stack_alloc(0, child); ptr = silc_smalloc(child2, 500000); +#ifdef SILC_DIST_INPLACE silc_stack_stats(child2); +#endif /* SILC_DIST_INPLACE */ silc_stack_free(child2); - silc_stack_stats(child); +#ifdef SILC_DIST_INPLACE + silc_stack_stats(child2); +#endif /* SILC_DIST_INPLACE */ silc_stack_pop(child); SILC_LOG_DEBUG(("Popping")); +#ifdef SILC_DIST_INPLACE silc_stack_stats(child); +#endif /* SILC_DIST_INPLACE */ +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ silc_stack_free(child); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Purge stack")); silc_stack_purge(stack); +#ifdef SILC_DIST_INPLACE silc_stack_stats(stack); +#endif /* SILC_DIST_INPLACE */ SILC_LOG_DEBUG(("Current alignment: %d", silc_stack_get_alignment(stack))); SILC_LOG_DEBUG(("Set alignemtn to 16")); @@ -203,5 +253,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcstringprep.c b/lib/silcutil/tests/test_silcstringprep.c index 82fc8ca2..ff56171f 100644 --- a/lib/silcutil/tests/test_silcstringprep.c +++ b/lib/silcutil/tests/test_silcstringprep.c @@ -1,6 +1,6 @@ /* Stringprep tests */ -#include "silc.h" +#include "silcruntime.h" typedef struct { const char *comment; @@ -30,7 +30,7 @@ const test_st tests[] = { {"Locale test", "Päivää", "päivää", 0, SILC_STRING_LOCALE}, {"Locale test2", - "#öäöö/&#\\#(&(&#(.äöäÄÖäÄÖÄÖ^'", + "#öäöö/&#\\#(&(&#(.äöäÄÖäÄÖÄÖ^'", "#öäöö/&#\\#(&(&#(.äöääöääöäö^'", 0, SILC_STRING_LOCALE}, /* Some libidn tests */ @@ -64,7 +64,7 @@ const test_st tests_norm[] = { {"Locale test", "Päivää", "päivää", 0, SILC_STRING_LOCALE}, {"Locale test2", - "#öäöö/&#\\#(&(&#(.äöäÄÖäÄÖÄÖ^'", + "#öäöö/&#\\#(&(&#(.äöäÄÖäÄÖÄÖ^'", "#öäöö/&#\\#(&(&#(.äöääöääöäö^'", 0, SILC_STRING_LOCALE}, }; @@ -163,5 +163,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcstrutil.c b/lib/silcutil/tests/test_silcstrutil.c index a728dfd5..33bfc621 100644 --- a/lib/silcutil/tests/test_silcstrutil.c +++ b/lib/silcutil/tests/test_silcstrutil.c @@ -1,7 +1,7 @@ /* UTF-8 decoding tests */ /* Other string util tests too */ -#include "silc.h" +#include "silcruntime.h" #define utf8fail(n, data, len) \ const unsigned char u##n[] = (data); \ @@ -121,7 +121,7 @@ int main(int argc, char **argv) /* To UTF-8 */ l = silc_utf8_encoded_len(s3, strlen(s3), SILC_STRING_LDAP_DN); if (!l) - goto err; + goto err; s4 = silc_calloc(l + 1, sizeof(*s4)); silc_utf8_encode(s3, strlen(s3), SILC_STRING_LDAP_DN, s4, l); SILC_LOG_DEBUG(("utf8 = %s", s4)); @@ -139,13 +139,13 @@ int main(int argc, char **argv) s2 = "PÄIVÄÄ VUAN YRJÖ"; l = silc_utf8_encoded_len(s1, strlen(s1), SILC_STRING_LOCALE); if (!l) - goto err; + goto err; s3 = silc_calloc(l + 1, sizeof(*s3)); silc_utf8_encode(s1, strlen(s1), SILC_STRING_LOCALE, s3, l); l = silc_utf8_encoded_len(s2, strlen(s2), SILC_STRING_LOCALE); if (!l) - goto err; + goto err; s4 = silc_calloc(l + 1, sizeof(*s4)); silc_utf8_encode(s2, strlen(s2), SILC_STRING_LOCALE, s4, l); @@ -192,5 +192,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silcthread.c b/lib/silcutil/tests/test_silcthread.c index da078b3e..75546654 100644 --- a/lib/silcutil/tests/test_silcthread.c +++ b/lib/silcutil/tests/test_silcthread.c @@ -1,6 +1,6 @@ /* SilcThreadPool tests */ -#include "silc.h" +#include "silcruntime.h" SilcSchedule schedule; @@ -31,7 +31,7 @@ int main(int argc, char **argv) silc_log_set_debug_string("*thread*,*errno*"); } - schedule = silc_schedule_init(0, NULL, NULL); + schedule = silc_schedule_init(0, NULL, NULL, NULL); if (!schedule) goto err; @@ -103,5 +103,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silctime.c b/lib/silcutil/tests/test_silctime.c index d269eb60..82289901 100644 --- a/lib/silcutil/tests/test_silctime.c +++ b/lib/silcutil/tests/test_silctime.c @@ -1,6 +1,6 @@ /* SilcTime tests */ -#include "silc.h" +#include "silcruntime.h" int main(int argc, char **argv) { @@ -41,5 +41,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/tests/test_silctimer.c b/lib/silcutil/tests/test_silctimer.c index e0646cf7..f2395756 100644 --- a/lib/silcutil/tests/test_silctimer.c +++ b/lib/silcutil/tests/test_silctimer.c @@ -1,6 +1,6 @@ /* SilcTimer tests */ -#include "silc.h" +#include "silcruntime.h" SilcSchedule schedule; SilcTimerStruct timer; @@ -40,9 +40,9 @@ SILC_TASK_CALLBACK(check) silc_timer_start_time(&timer, &st); silc_timer_value_time(&timer, &t); silc_time_universal_string(&st, ts, sizeof(ts)); - SILC_LOG_DEBUG(("Start time: %s", ts)); + SILC_LOG_DEBUG(("Start time: %s", ts)); silc_time_universal_string(&t, ts, sizeof(ts)); - SILC_LOG_DEBUG(("End time: %s", ts)); + SILC_LOG_DEBUG(("End time: %s", ts)); success = TRUE; silc_schedule_stop(schedule); @@ -69,7 +69,7 @@ int main(int argc, char **argv) silc_log_set_debug_string("*timer*,*errno*"); } - schedule = silc_schedule_init(0, NULL, NULL); + schedule = silc_schedule_init(0, NULL, NULL, NULL); if (!schedule) goto err; @@ -90,5 +90,5 @@ int main(int argc, char **argv) SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE")); fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE"); - return success; + return !success; } diff --git a/lib/silcutil/unix/.gitignore b/lib/silcutil/unix/.gitignore index 282522db..a501f929 100644 --- a/lib/silcutil/unix/.gitignore +++ b/lib/silcutil/unix/.gitignore @@ -1,2 +1,8 @@ Makefile -Makefile.in +*.in +*.am +*.o +*.lo +*.la +*.a +*.pc diff --git a/lib/silcutil/unix/silcunixdir.c b/lib/silcutil/unix/silcunixdir.c index 9d8d1b16..49de3079 100644 --- a/lib/silcutil/unix/silcunixdir.c +++ b/lib/silcutil/unix/silcunixdir.c @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /************************** Types and definitions ***************************/ @@ -42,7 +42,7 @@ SilcDir silc_dir_open(const char *name) { SilcDir dir; - if (!name || !strlen(!name)) { + if (!name || !strlen(name)) { silc_set_errno(SILC_ERR_INVALID_ARGUMENT); return NULL; } diff --git a/lib/silcutil/unix/silcunixnet.c b/lib/silcutil/unix/silcunixnet.c index 15720dcd..f18af24e 100644 --- a/lib/silcutil/unix/silcunixnet.c +++ b/lib/silcutil/unix/silcunixnet.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2007 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 @@ -16,10 +16,8 @@ GNU General Public License for more details. */ -/* $Id$ */ -#include "silc.h" -#include "silcnet.h" +#include "silcruntime.h" /************************** Types and definitions ***************************/ @@ -524,7 +522,8 @@ int silc_net_udp_receive(SilcStream stream, char *remote_ip_addr, SilcSocketStream sock = stream; SilcSockaddr s; struct sockaddr *from; - int len, flen; + int len; + unsigned int flen; SILC_LOG_DEBUG(("Reading data from UDP socket %d", sock->sock)); diff --git a/lib/silcutil/unix/silcunixschedule.c b/lib/silcutil/unix/silcunixschedule.c index d81cfa75..5626eef5 100644 --- a/lib/silcutil/unix/silcunixschedule.c +++ b/lib/silcutil/unix/silcunixschedule.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1998 - 2007 Pekka Riikonen + Copyright (C) 1998 - 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 @@ -16,9 +16,8 @@ GNU General Public License for more details. */ -/* $Id$ */ -#include "silc.h" +#include "silcruntime.h" #if defined(HAVE_EPOLL_WAIT) #include diff --git a/lib/silcutil/unix/silcunixsocketstream.c b/lib/silcutil/unix/silcunixsocketstream.c index 86c8491a..552fa611 100644 --- a/lib/silcutil/unix/silcunixsocketstream.c +++ b/lib/silcutil/unix/silcunixsocketstream.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2007 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 @@ -16,9 +16,8 @@ GNU General Public License for more details. */ -/* $Id$ */ -#include "silc.h" +#include "silcruntime.h" /************************ Static utility functions **************************/ diff --git a/lib/silcutil/unix/silcunixthread.c b/lib/silcutil/unix/silcunixthread.c index 1f13f619..2a826251 100644 --- a/lib/silcutil/unix/silcunixthread.c +++ b/lib/silcutil/unix/silcunixthread.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 2001 - 2007 Pekka Riikonen + Copyright (C) 2001 - 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 @@ -16,9 +16,8 @@ GNU General Public License for more details. */ -/* $Id$ */ -#include "silc.h" +#include "silcruntime.h" /**************************** SILC Thread API *******************************/ @@ -343,6 +342,7 @@ SilcBool silc_cond_timedwait(SilcCond cond, SilcMutex mutex, #if (defined(SILC_THREADS) && defined(HAVE_PTHREAD_KEY_CREATE) && \ defined(HAVE_PTHREAD_ONCE)) +static SilcBool key_set = FALSE; static pthread_key_t key; static pthread_once_t key_once = PTHREAD_ONCE_INIT; @@ -355,6 +355,7 @@ static void silc_thread_tls_alloc(void) { if (pthread_key_create(&key, silc_thread_tls_destructor)) SILC_LOG_ERROR(("Error creating Thread-local storage")); + key_set = TRUE; } SilcTls silc_thread_tls_init(void) @@ -379,6 +380,8 @@ SilcTls silc_thread_tls_init(void) SilcTls silc_thread_get_tls(void) { + if (!key_set) + return NULL; return pthread_getspecific(key); } diff --git a/lib/silcutil/unix/silcunixutil.c b/lib/silcutil/unix/silcunixutil.c index ef608f92..def4f1d7 100644 --- a/lib/silcutil/unix/silcunixutil.c +++ b/lib/silcutil/unix/silcunixutil.c @@ -4,7 +4,7 @@ Author: Pekka Riikonen - Copyright (C) 1997 - 2007 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 @@ -17,7 +17,7 @@ */ -#include "silc.h" +#include "silcruntime.h" /* Returns the username of the user. If the global variable LOGNAME does not exists we will get the name from the password file. */ diff --git a/lib/silcutil/win32/.gitignore b/lib/silcutil/win32/.gitignore index 282522db..a501f929 100644 --- a/lib/silcutil/win32/.gitignore +++ b/lib/silcutil/win32/.gitignore @@ -1,2 +1,8 @@ Makefile -Makefile.in +*.in +*.am +*.o +*.lo +*.la +*.a +*.pc diff --git a/srt.m4 b/srt.m4 index 300f3035..4a3c6119 100644 --- a/srt.m4 +++ b/srt.m4 @@ -1,9 +1,9 @@ # -# silc.m4 +# srt.m4 # # Author: Pekka Riikonen # -# Copyright (C) 2007 Pekka Riikonen +# Copyright (C) 2007 - 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 @@ -20,11 +20,11 @@ # Usage: SILC_SYSTEM_IS_SMP([ACTION-IF-FOUND] [, ACTION-IF-NOT-FOUND] # [, ACTION-IF-NOT-DETECTED]) # -# The ACTION-IF-NOT-DETECTED is called if we could not detect whether or +# The ACTION-IF-NOT-DETECTED is called if we could not detect whether or # not the system is SMP. # # x_is_smp variable is set to true or false as a result for calling this -# function. Caller may use the variable to check for the result in the +# function. Caller may use the variable to check for the result in the # code. # AC_DEFUN([SILC_SYSTEM_IS_SMP], @@ -77,54 +77,71 @@ AC_DEFUN([SILC_SYSTEM_IS_SMP], # Function to check for CPU feature flags. # -# Usage: SILC_CPU_FLAG(flag [, ACTION-IF-FOUND] [, ACTION-IF-NOT-FOUND]) +# Usage: SILC_CPU_FLAG(flag, enable, [, ACTION-IF-FOUND] +# [, ACTION-IF-NOT-FOUND]) # # x_have_cpu_ variable is set to true or false value as a result for # calling this function for the . Caller may use the variable to -# check the result in the code. +# check the result in the code. If is true this will add +# AC_ARG_ENABLE option for the . # AC_DEFUN([SILC_CPU_FLAG], [ AC_MSG_CHECKING(whether CPU supports $1) x_have_cpu_$1=false - case "$target" in - *-*-linux*) - # Take data from Linux /proc - if test -f /proc/cpuinfo; then - cpuflags=`grep "^flags.*$1 " /proc/cpuinfo 2> /dev/null` + if test x$2 = xtrue; then + AC_ARG_ENABLE($1, + [ --enable-$1 ], + [ + AC_MSG_RESULT(yes - enabled by --enable-$1) + x_have_cpu_$1=true + ]) + fi + + if test x$x_have_cpu_$1 = xfalse; then + case "$target" in + *-*-linux*) + # Take data from Linux /proc + if test -f /proc/cpuinfo; then + cpuflags=`grep "^flags.*$1 " /proc/cpuinfo 2> /dev/null` + if test $? != 0; then + AC_MSG_RESULT(no) + x_have_cpu_$1=false + ifelse([$4], , :, [$4]) + else + AC_MSG_RESULT(yes) + x_have_cpu_$1=true + ifelse([$3], , :, [$3]) + fi + else + AC_MSG_RESULT(no) + x_have_cpu_$1=false + ifelse([$4], , :, [$4]) + fi + ;; + + *-*-*bsd*) + # BSDs have some flags in sysctl 'machdep' variable + cpuflags=`/sbin/sysctl machdep 2> /dev/null | grep "\.$1.*.1"` if test $? != 0; then AC_MSG_RESULT(no) - ifelse([$3], , :, [$3]) + x_have_cpu_$1=false + ifelse([$4], , :, [$4]) else AC_MSG_RESULT(yes) x_have_cpu_$1=true - ifelse([$2], , :, [$2]) + ifelse([$3], , :, [$3]) fi - else - AC_MSG_RESULT(no) - ifelse([$3], , :, [$3]) - fi - ;; - - *-*-*bsd*) - # BSDs have some flags in sysctl 'machdep' variable - cpuflags=`/sbin/sysctl machdep 2> /dev/null | grep "\.$1.*.1"` - if test $? != 0; then - AC_MSG_RESULT(no) - ifelse([$3], , :, [$3]) - else - AC_MSG_RESULT(yes) - x_have_cpu_$1=true - ifelse([$2], , :, [$2]) - fi - ;; + ;; - *) - AC_MSG_RESULT(no, cannot detect on this system) - ifelse([$3], , :, [$3]) - ;; - esac + *) + AC_MSG_RESULT(no - cannot detect on this system) + x_have_cpu_$1=false + ifelse([$4], , :, [$4]) + ;; + esac + fi ]) # Function to check if compiler option works with the compiler. If you diff --git a/win32/Makefile.am b/win32/Makefile.am index 8f4dc98f..26d56ef4 100644 --- a/win32/Makefile.am +++ b/win32/Makefile.am @@ -18,11 +18,11 @@ AUTOMAKE_OPTIONS = 1.0 no-dependencies foreign -SUBDIRS = libsilc libsilcclient +SUBDIRS = EXTRA_DIST = \ silcdefs.h silc.dsw copy_dll \ tests all.dsp clean_dist.pl README \ - libsilc_static libsilcclient_static + libsilc_static include $(top_srcdir)/Makefile.defines.in -- 2.24.0