Update of /cvsroot/aolserver/knutil/include/knutil In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv6393/include/knutil Added Files: atomicint.h counter.h kncircularmapping.h knconsistenthash.h kncrashhandler.h kncrypt.h knerror.h knexportlibraryknutil.h knhash.h knlog.h knmarkuputil.h knmemory.h knmutex.h knnetwork.h knnewdelete.h knpattern.h knperfstatistics.h knregex.h knrwlock.h knrwlogginglock.h knset.h knsett.h knsleep.h knsmartref.h knstring.h knstringtokenizer.h knstrops.h knsysutility.h kntclargs.h kntclerrors.h kntclfile.h kntclinterp.h kntemplateuri.h kntime.h kntypes.h knurl.h mtrand.h randomnumber.h shahash.h simplecache.h simpleheap.h simpleiterator.h simplelist.h simplemap.h simplenull.h simplequeue.h simpleset.h simplesynccache.h simplesyncmap.h simplesyncvector.h simpletraits.h simplevector.h uuidgenerator.h Log Message: Added this library to the AOLServer.com repository. It contains a number of C/C++ utilities, some of which integrate into AOLServer, and many of which standalone. A portion of the library is required for the knregistration module, which will be checked in next. I believe this compiles fine in "native" AOLServer, but it has not been tested recently. --- NEW FILE: atomicint.h --- #ifndef ATOMICINT_H #define ATOMICINT_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ /* * Object supporting atomic integer operations. */ #include "knutil/knexportlibraryknutil.h" #include "knutil/kntypes.h" class EXPORT_LIBRARY_KNUTIL AtomicInt { public: /* * Constructors/destructor. */ inline AtomicInt(int cnt=0) : m_cnt(cnt){}; inline AtomicInt(const AtomicInt &atom):m_cnt(atom.m_cnt){}; inline ~AtomicInt(){}; /* * Set the object to an arbitrary value. */ inline AtomicInt &operator=(const AtomicInt &atom) {m_cnt = atom.m_cnt;return *this;}; inline AtomicInt &operator=(int cnt) {m_cnt = cnt;return *this;} /* * Increment/decrement the object by an arbitrary value. */ int operator+=(int cnt); int operator-=(int cnt); /* * Prefix and postfix increment. */ int operator++(); int operator++(int); /* * Prefix and postfix decrement. */ int operator--(); int operator--(int); /* * Object returned as an integer. */ inline operator int() const { return m_cnt; } /* * Decrement the object, and return true if the result is 0. */ bool decrementAndTest(); /* * Increment the object, without returning the result. */ void increment(); private: int m_cnt; }; #endif /* ATOMICINT_H */ --- NEW FILE: counter.h --- #ifndef COUNTER_H /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define COUNTER_H #include "knutil/knexportlibraryknutil.h" #include "knutil/atomicint.h" #include "knutil/knmutex.h" class EXPORT_LIBRARY_KNUTIL Counter { public: Counter(int c = 1); ~Counter(); AtomicInt count; }; #endif /* COUNTER_H */ --- NEW FILE: kncircularmapping.h --- #ifndef KN_CIRCULAR_MAPPING_H #define KN_CIRCULAR_MAPPING_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include <limits.h> #include <map> #include <string> #include <vector> #include "knutil/knexportlibraryknutil.h" #include "knutil/knset.h" class Bucket; class ReplicaPoint; class EXPORT_LIBRARY_KNUTIL KnCircularMapping { public: KnCircularMapping(); virtual ~KnCircularMapping(); typedef unsigned int PointT; // Add a bucket bool addBucket(const char* bucketName, std::vector<PointT>& points, double weight); bool addBucketsFromSet(const KnSet& bucketSet); // Remove a bucket by name bool removeBucket(const char* bucketName); // Remove all buckets void removeAllBuckets(); // Compute the bucket where the point should go // and return the bucket's name std::string assignPointToBucket(PointT point); int bucketCount(); double getWeight(const std::string& bucketName); double getTotalWeight(); bool existsBucket(const std::string& bucketName); private: typedef std::map<std::string, Bucket*> BucketMap; typedef BucketMap::iterator BucketMapIterator; typedef std::map<PointT, ReplicaPoint*> ReplicaMap; typedef ReplicaMap::iterator ReplicaMapIterator; typedef std::pair<ReplicaMapIterator, ReplicaMapIterator> ReplicaMapRange; ReplicaPoint* findOrAddReplicaPoint(PointT point); ReplicaPoint* findReplicaPoint(PointT point); bool removeReplicaPoint(PointT point, Bucket* bucket); Bucket* findBucketForPoint(PointT point); BucketMap m_buckets; ReplicaMap m_replicaMap; double m_totalWeight; }; #endif --- NEW FILE: knconsistenthash.h --- #ifndef KN_CONSISTENT_HASH_H #define KN_CONSISTENT_HASH_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include <limits.h> #include <string> #include <map> #include "knutil/knexportlibraryknutil.h" #include "knutil/knset.h" #include "knutil/knrwlock.h" #include "knutil/kncircularmapping.h" #define DEFAULT_REPLICAS_PER_BUCKET 200 class EXPORT_LIBRARY_KNUTIL KnConsistentHash { public: KnConsistentHash(int replicasPerBucket = DEFAULT_REPLICAS_PER_BUCKET, KnCircularMapping::PointT pointInterval = UINT_MAX); virtual ~KnConsistentHash(); typedef unsigned int IDHash; // Compute the hash for a bucket virtual IDHash computeHash(const char* identifier); // Add a bucket given a hash computed from some unique data virtual bool addBucket(const char* bucketName, IDHash bucketHash, double weight); // or by the computing hash from bucket name bool addBucket(const char* bucketName, double weight); // Remove a bucket by name bool removeBucket(const char* bucketName); // Remove all buckets void removeAllBuckets(); // Add buckets from a set where the keys are bucket names and the values are weights bool addBucketsFromSet(const KnSet& bucketSet); bool setBucketsFromSet(const KnSet& bucketSet); int bucketCount(); // Given a resource identifier find the point on the circle it belongs to virtual KnCircularMapping::PointT computePointForResource(const char* identifier); // Compute the bucket where the point should go and return the bucket's name std::string assignPointToBucket(KnCircularMapping::PointT point); // Calculate the point and then assign the point to a bucket for a resource std::string assignResourceToBucket(const char* identifier); double getTotalWeight(); private: bool addBucketUnsafe(const char* bucketName, IDHash bucketHash, double weight); bool addBucketsFromSetUnsafe(const KnSet& bucketSet); KnCircularMapping m_mapping; KnRWLock m_bucketLock; int m_replicasPerBucket; KnCircularMapping::PointT m_pointInterval; }; #endif --- NEW FILE: kncrashhandler.h --- #ifndef KNCRASHHANDLER_H #define KNCRASHHANDLER_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/knexportlibraryknutil.h" /** * Register the KnowNow standard crash handler for this module * (no-op under Unix or Linux right now). Returns false if could * not register. Logs any error itself. */ extern EXPORT_LIBRARY_KNUTIL bool KnSetCrashHandler() ; /** * Set the crash handler's dump location and severity */ extern EXPORT_LIBRARY_KNUTIL bool KnSetCrashInfo(const char* location, const char* level) ; #endif /* KNCRASHHANDLER_H */ --- NEW FILE: kncrypt.h --- #ifndef KNCRYPT_H /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define KNCRYPT_H #include "knutil/knexportlibraryknutil.h" #include "knutil/knstring.h" /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * Encrypt the specified key, perturbed by salt, into buf. */ EXPORT_LIBRARY_KNUTIL KnError KnCrypt(KnString &buf, const KnString &key, const KnString &salt); #endif /* KNCRYPT_H */ --- NEW FILE: knerror.h --- #ifndef KNERROR_H #define KNERROR_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/knexportlibraryknutil.h" #include "knutil/kntypes.h" /** * Error state, and preferred return type. */ /** * In 3.1.9, experimenting with moving to an Apache-style set of * codes. All codes come from the HTTP error space, with 6xx codes below * 655 reserved for KnowNow errors. * * We shift them left 8 bits, then add in any subcodes we care about. * This assumes that enums are represented as at least 16 bit unsigned ints. * To get an HTTP error code, shift right 8. To get a nice string, look * them up as-is. * * This check-in requires recompiling the Modules to get the new constants * * Use KnError_Is(constant, code) to do comparisons; we'll figure out how * to get it inlined, yet available to C modules, yet. * * I.e., if you just care if it's found or not, use * KnError_Is(KnErrorNotFound, status) * so you don't have to know the encodings. */ enum KnError { KnErrorSuccess = (200 << 8), ///< Operation succeeded KnErrorUnauthorized = (401 << 8), ///< Operation requires credentials (401) KnErrorForbidden = (403 << 8), ///< Credentials are not authorized (403) KnErrorNotFound = (404 << 8), ///< Something (page) not found KnErrorNotFound_Event = (404 << 8) + 1, KnErrorNotFound_Route = (404 << 8) + 2, KnErrorNotFound_Topic = (404 << 8) + 3, KnErrorNotFound_Journal = (404 << 8) + 4, KnErrorNotFound_Parent = (404 << 8) + 5, KnErrorNotFound_SubTopic = (404 << 8) + 6, KnErrorNotFound_Filter = (404 << 8) + 7, KnErrorNotFound_User = (404 << 8) + 10, KnErrorNotFound_Group = (404 << 8) + 11, KnErrorFailure = (500 << 8) ///< Operation failed (500) }; extern EXPORT_LIBRARY_KNUTIL const int KnError_AsHTTP( const KnError code ) ; #ifdef __cplusplus inline int KnError_Is(const KnError constant, const KnError code ) { return (static_cast<unsigned int>(constant) & static_cast<unsigned int>(code)) == static_cast<unsigned int>(constant); } #else #define KnError_Is(c,s) (c == (c & s)) #endif #endif /* KNERROR_H */ --- NEW FILE: knexportlibraryknutil.h --- /* /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ * Defines export/import declarations for windows interfaces for this dll. * It is important to declare this as export when compiling modules in the dll * and import for modules not in the dll. */ #ifndef KNEXPORTLIBRARYKNUTIL_H #define KNEXPORTLIBRARYKNUTIL_H #ifdef WIN32 #ifdef EXPORT_LIBRARY_KNUTIL_MODULE #define EXPORT_LIBRARY_KNUTIL __declspec(dllexport) #else #define EXPORT_LIBRARY_KNUTIL __declspec(dllimport) #endif #else #define EXPORT_LIBRARY_KNUTIL #endif #endif /* KNEXPORTLIBRARYKNUTIL_H */ --- NEW FILE: knhash.h --- #ifndef KNHASH_H #define KNHASH_H /** * Copyright (c) 2001 KnowNow, Inc. All rights reserved. * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #include "knutil/knexportlibraryknutil.h" #include "knutil/kntypes.h" #ifdef __cplusplus extern "C" { #endif /* * General purpose hashing routine. The seed parameter can be * any value, such as the previous hash result. Please see * http://burtleburtle.net/bob/hash/evahash.html for theory. */ extern EXPORT_LIBRARY_KNUTIL uint32_t hash32(const void *buf, uint32_t len, uint32_t seed); extern EXPORT_LIBRARY_KNUTIL uint64_t hash64(const void *buf, uint64_t len, uint64_t seed); #ifdef __cplusplus } // extern "C" #endif #endif /* KNHASH_H */ --- NEW FILE: knlog.h --- #ifndef KNLOG_H /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ #define KNLOG_H #include "knutil/knexportlibraryknutil.h" #include "knutil/knerror.h" #include "knutil/knstring.h" /***************************************************************/ * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * /**@defgroup loggingAPI Logging API * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * * Log to the server.log file. * @{ ****************************************************************/ /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * Logging levels. See KnLog for details on their use. */ enum KnLogSeverity { KnLogNotice, ///< Something somebody might care about KnLogWarning, ///< Something somebody should do something about KnLogError, ///< Something somebody should call KnowNow about KnLogFatal, ///< Something that will cause a non-recoverable crash KnLogBug, ///< Something that "asserts" a fault in the code KnLogDebug, ///< Something only printed when Log_Debug is enabled KnLogDev ///< Something conditional on a specific debug flag }; /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * Log a message to the router. */ extern EXPORT_LIBRARY_KNUTIL KnError KnLog(KnLogSeverity severity, const KnString &msg); /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * Log a printf-style message to the router. */ extern EXPORT_LIBRARY_KNUTIL KnError KnLog(KnLogSeverity severity, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); #endif --- NEW FILE: knmarkuputil.h --- ////////////////////////////////////////////////////// /** * (c) Copyright 2008 KnowNow, Inc., Sunnyvale CA * * @KNOWNOW_LICENSE_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The name "KnowNow" is a trademark of KnowNow, Inc. and may not * be used to endorse or promote any product without prior written * permission from KnowNow, Inc. * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL KNOWNOW, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @KNOWNOW_LICENSE_END@ **/ // knmarkuputil.h // // (c)2002-2006, KnowNow, Inc. All Rights Reserved. #ifndef KNMARKUPUTIL_H #define KNMARKUPUTIL_H #include "knutil/knexportlibraryknutil.h... [truncated message content] |