diff --git a/ccmain/pagesegmain.cpp b/ccmain/pagesegmain.cpp index c285bf16..94e5f352 100644 --- a/ccmain/pagesegmain.cpp +++ b/ccmain/pagesegmain.cpp @@ -18,7 +18,9 @@ **********************************************************************/ #ifdef WIN32 +#ifndef __GNUC__ #include +#endif /* __GNUC__ */ #else #include #endif @@ -26,16 +28,14 @@ #pragma warning(disable:4244) // Conversion warnings #endif +#include + // Include automatically generated configuration file if running autoconf. #ifdef HAVE_CONFIG_H #include "config_auto.h" #endif -#ifdef HAVE_LIBLEPT -// Include leptonica library only if autoconf (or makefile etc) tell us to. #include "allheaders.h" -#endif - #include "tesseractclass.h" #include "img.h" #include "blobbox.h" diff --git a/ccutil/ambigs.cpp b/ccutil/ambigs.cpp index c5f93308..f917897b 100644 --- a/ccutil/ambigs.cpp +++ b/ccutil/ambigs.cpp @@ -18,12 +18,19 @@ // /////////////////////////////////////////////////////////////////////// +#include +#include + #include "ambigs.h" #include "helpers.h" #ifdef WIN32 +#ifndef __GNUC__ #define strtok_r strtok_s -#endif +#else +#include "strtok_r.h" +#endif /* __GNUC__ */ +#endif /* WIN32 */ namespace tesseract { diff --git a/ccutil/ocrclass.h b/ccutil/ocrclass.h index 3bc8acf6..87f55bf1 100644 --- a/ccutil/ocrclass.h +++ b/ccutil/ocrclass.h @@ -24,12 +24,14 @@ * structure alignment upto 8. **********************************************************************/ -#ifndef OCRCLASS_H -#define OCRCLASS_H +#ifndef CCUTIL_OCRCLASS_H_ +#define CCUTIL_OCRCLASS_H_ +#ifndef __GNUC__ #ifdef __MSW32__ #include #include "gettimeofday.h" +#endif #else #include #endif @@ -126,8 +128,7 @@ OR these together for enhancement in ocr_append_char*/ #define EUC_SUPERSCRIPT 16 /*superscript char */ /*enum for character rendering direction*/ -enum OCR_CHAR_DIRECTION -{ +enum OCR_CHAR_DIRECTION { OCR_CDIR_RIGHT_LEFT, /*right to left horizontal */ OCR_CDIR_LEFT_RIGHT, /*left to right horizontal */ OCR_CDIR_TOP_BOTTOM, /*top to bottom vertical */ @@ -135,29 +136,27 @@ enum OCR_CHAR_DIRECTION }; /*enum for line rendering direction*/ -enum OCR_LINE_DIRECTION -{ +enum OCR_LINE_DIRECTION { OCR_LDIR_DOWN_RIGHT, /*horizontal lines go down */ /*vertical lines go right */ OCR_LDIR_UP_LEFT /*horizontal lines go up */ }; /*enum for newline type*/ -enum OCR_NEWLINE_TYPE -{ +enum OCR_NEWLINE_TYPE { OCR_NL_NONE, /*not a newline */ OCR_NL_NEWLINE, /*this is a newline but not new para */ OCR_NL_NEWPARA /*this is a newline and a new para */ }; -/*error codes that can be returned from the API functions other than OKAY and HPERR*/ +/*error codes that can be returned from the API functions other than OKAY +and HPERR*/ #define OCR_API_NO_MEM (-2) /*filled output buffer */ #define OCR_API_BAD_CHAR (-3) /*whitespace sent to ocr_append_char */ #define OCR_API_BAD_STATE (-4) /*invalid call sequence */ /*error codes used for passing errors back to the HP side*/ -enum OCR_ERR_CODE -{ +enum OCR_ERR_CODE { OCR_ERR_NONE, /*no error */ OCR_ERR_CLEAN_EXIT, /*no error */ OCR_ERR_NO_MEM, /*out of memory */ @@ -187,8 +186,7 @@ enum OCR_ERR_CODE * The name may be either a valid font on the system or the empty string. **********************************************************************/ -typedef struct /*font description */ -{ +typedef struct { /*font description */ uinT16 language; /*default language */ uinT8 font_family; /*serif/not, fixed/not */ uinT8 char_set; /*character set standard */ @@ -204,8 +202,7 @@ typedef struct /*font description */ * can recognize. **********************************************************************/ -typedef struct /*startup info */ -{ +typedef struct { /*startup info */ inT32 protocol; /*interface version */ uinT32 font_count; /*number of fonts */ uinT16 language; /*default language */ @@ -225,8 +222,7 @@ typedef struct /*startup info */ * The top leftmost pixel is in the most significant bit of the first byte. **********************************************************************/ -typedef struct /*bitmap strip */ -{ +typedef struct { /*bitmap strip */ inT16 x_size; /*width in pixels */ inT16 y_size; /*of full image */ inT16 strip_size; /*of this strip */ @@ -258,15 +254,15 @@ typedef struct /*bitmap strip */ * version. **********************************************************************/ -typedef struct /*single character */ -{ -// It should be noted that the format for char_code for version 2.0 and beyond is UTF8 -// which means that ASCII characters will come out as one structure but other characters -// will be returned in two or more instances of this structure with a single byte of the -// UTF8 code in each, but each will have the same bounding box. -// Programs which want to handle languagues with different characters sets will need to -// handle extended characters appropriately, but *all* code needs to be prepared to -// receive UTF8 coded characters for characters such as bullet and fancy quotes. +typedef struct { /*single character */ +// It should be noted that the format for char_code for version 2.0 and beyond +// is UTF8 which means that ASCII characters will come out as one structure but +// other characters will be returned in two or more instances of this structure +// with a single byte of the UTF8 code in each, but each will have the same +// bounding box. Programs which want to handle languagues with different +// characters sets will need to handle extended characters appropriately, but +// *all* code needs to be prepared to receive UTF8 coded characters for +// characters such as bullet and fancy quotes. uinT16 char_code; /*character itself */ inT16 left; /*of char (-1) */ inT16 right; /*of char (-1) */ @@ -295,19 +291,18 @@ typedef struct /*single character */ **********************************************************************/ typedef bool (*CANCEL_FUNC)(void* cancel_this, int words); -class ETEXT_DESC /*output header */ -{ +class ETEXT_DESC { // output header public: - inT16 count; /*chars in this buffer(0) */ - inT16 progress; /*percent complete increasing (0-100) */ - inT8 more_to_come; /*true if not last */ - volatile inT8 ocr_alive; /*ocr sets to 1, HP 0 */ - inT8 err_code; /*for errcode use */ - CANCEL_FUNC cancel; /*returns true to cancel */ - void* cancel_this; /*this or other data for cancel*/ - struct timeval end_time; /*time to stop. expected to be set only by call - to set_deadline_msecs()*/ - EANYCODE_CHAR text[1]; /*character data */ + inT16 count; // chars in this buffer(0) + inT16 progress; // percent complete increasing (0-100) + inT8 more_to_come; // true if not last + volatile inT8 ocr_alive; // ocr sets to 1, HP 0 + inT8 err_code; // for errcode use + CANCEL_FUNC cancel; // returns true to cancel + void* cancel_this; // this or other data for cancel + struct timeval end_time; // time to stop. expected to be set only by call + // to set_deadline_msecs() + EANYCODE_CHAR text[1]; // character data ETEXT_DESC() : count(0), progress(0), more_to_come(0), ocr_alive(0), err_code(0), cancel(NULL), cancel_this(NULL) { @@ -337,4 +332,4 @@ class ETEXT_DESC /*output header */ } }; -#endif +#endif // CCUTIL_OCRCLASS_H_ diff --git a/ccutil/platform.h b/ccutil/platform.h index 1e0da588..5c1d4c16 100644 --- a/ccutil/platform.h +++ b/ccutil/platform.h @@ -1,11 +1,39 @@ -// Place holder +/////////////////////////////////////////////////////////////////////// +// File: platform.h +// Description: Place holder +// Author: +// Created: +// +// (C) Copyright 2006, Google Inc. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/////////////////////////////////////////////////////////////////////// + +#ifndef TESSERACT_CCUTIL_PLATFORM_H__ +#define TESSERACT_CCUTIL_PLATFORM_H__ + #define DLLSYM #ifdef __MSW32__ +#ifdef __GNUC__ +#define ultoa _ultoa +typedef struct _BLOB { + unsigned int cbSize; + char *pBlobData; +} BLOB, *LPBLOB; +#endif /* __GNUC__ */ #define SIGNED #define snprintf _snprintf #if (_MSC_VER <= 1400) #define vsnprintf _vsnprintf -#endif +#endif /* __MSW32__ */ #else #define __UNIX__ #include @@ -16,3 +44,5 @@ #endif #define SIGNED signed #endif + +#endif // TESSERACT_CCUTIL_PLATFORM_H__ diff --git a/dict/dawg.h b/dict/dawg.h index 5c7e6acc..2606f6ed 100644 --- a/dict/dawg.h +++ b/dict/dawg.h @@ -24,8 +24,8 @@ * *********************************************************************************/ -#ifndef DAWG_H -#define DAWG_H +#ifndef DICT_DAWG_H_ +#define DICT_DAWG_H_ /*---------------------------------------------------------------------- I n c l u d e s @@ -35,11 +35,13 @@ #include "ratngs.h" #include "params.h" +#ifndef __GNUC__ #ifdef __MSW32__ #define NO_EDGE (inT64) 0xffffffffffffffffi64 +#endif /*__MSW32__*/ #else #define NO_EDGE (inT64) 0xffffffffffffffffll -#endif +#endif /*__GNUC__*/ /*---------------------------------------------------------------------- T y p e s @@ -481,4 +483,4 @@ class SquishedDawg : public Dawg { } // namespace tesseract -#endif +#endif // DICT_DAWG_H_ diff --git a/viewer/svutil.cpp b/viewer/svutil.cpp index c0f106c4..b7fa31f6 100644 --- a/viewer/svutil.cpp +++ b/viewer/svutil.cpp @@ -22,8 +22,6 @@ #include #ifdef WIN32 -#include -#include struct addrinfo { struct sockaddr* ai_addr; int ai_addrlen; @@ -66,7 +64,7 @@ const int kMaxMsgSize = 4096; // Signals a thread to exit. void SVSync::ExitThread() { #ifdef WIN32 - //ExitThread(0); + // ExitThread(0); #else pthread_exit(0); #endif @@ -248,7 +246,7 @@ char* SVNetwork::Receive() { msg_buffer_in_[i] = '\0'; has_content = true; #ifdef WIN32 - return strtok(msg_buffer_in_,"\n"); + return strtok(msg_buffer_in_, "\n"); #else // Setup a new string tokenizer. return strtok_r(msg_buffer_in_, "\n", &buffer_ptr_); diff --git a/viewer/svutil.h b/viewer/svutil.h index 7bddaec8..59916349 100644 --- a/viewer/svutil.h +++ b/viewer/svutil.h @@ -25,6 +25,7 @@ #define TESSERACT_VIEWER_SVUTIL_H__ #ifdef WIN32 +#ifndef __GNUC__ #include #define snprintf _snprintf #if (_MSC_VER <= 1400) @@ -32,6 +33,10 @@ #endif #pragma warning(disable:4786) #else +#include "platform.h" +#include +#endif +#else #include #include #endif @@ -129,7 +134,7 @@ class SVNetwork { /// Stores the messages which are supposed to go out. std::string msg_buffer_out_; - bool has_content; // Win32 (strtok) + bool has_content; // Win32 (strtok) /// Where we are at in our msg_buffer_in_ char* buffer_ptr_; // Unix (strtok_r) }; diff --git a/vs2008/port/stdint.h b/vs2008/include/stdint.h similarity index 80% rename from vs2008/port/stdint.h rename to vs2008/include/stdint.h index d02608a5..8ef8cb7e 100644 --- a/vs2008/port/stdint.h +++ b/vs2008/include/stdint.h @@ -1,39 +1,44 @@ +/////////////////////////////////////////////////////////////////////// // ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// // Copyright (c) 2006-2008 Alexander Chemeris -// +// // 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 of the author may be used to endorse or promote products // derived from this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 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 THE AUTHOR 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, +// 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. -// +// /////////////////////////////////////////////////////////////////////////////// -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] +#ifndef VS2008_INCLUDE_STDINT_H_ +#define VS2008_INCLUDE_STDINT_H_ -#ifndef _MSC_STDINT_H_ // [ +#ifndef __GNUC__ +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ #define _MSC_STDINT_H_ #if _MSC_VER > 1000 @@ -72,19 +77,19 @@ extern "C" { // realize that, e.g. char has the same size as __int8 // so we give up on __intX for them. #if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; #else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; #endif typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; @@ -111,13 +116,13 @@ typedef uint32_t uint_fast32_t; typedef uint64_t uint_fast64_t; // 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] +#ifdef _WIN64 // [ + typedef signed __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 signed int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] // 7.18.1.5 Greatest-width integer types typedef int64_t intmax_t; @@ -126,7 +131,8 @@ typedef uint64_t uintmax_t; // 7.18.2 Limits of specified-width integer types -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) +// [ See footnote 220 at page 257 and footnote 221 at page 259 // 7.18.2.1 Limits of exact-width integer types #define INT8_MIN ((int8_t)_I8_MIN) @@ -171,15 +177,15 @@ typedef uint64_t uintmax_t; #define UINT_FAST64_MAX UINT64_MAX // 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ +#ifdef _WIN64 // [ # define INTPTR_MIN INT64_MIN # define INTPTR_MAX INT64_MAX # define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ +#else // _WIN64 ][ # define INTPTR_MIN INT32_MIN # define INTPTR_MAX INT32_MAX # define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] +#endif // _WIN64 ] // 7.18.2.5 Limits of greatest-width integer types #define INTMAX_MIN INT64_MIN @@ -188,7 +194,7 @@ typedef uint64_t uintmax_t; // 7.18.3 Limits of other integer types -#ifdef _WIN64 // [ +#ifdef _WIN64 // [ # define PTRDIFF_MIN _I64_MIN # define PTRDIFF_MAX _I64_MAX #else // _WIN64 ][ @@ -199,31 +205,31 @@ typedef uint64_t uintmax_t; #define SIG_ATOMIC_MIN INT_MIN #define SIG_ATOMIC_MAX INT_MAX -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ # define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ +# else // _WIN64 ][ # define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] +# endif // _WIN64 ] +#endif // SIZE_MAX ] // WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ +#ifndef WCHAR_MIN // [ # define WCHAR_MIN 0 #endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ +#ifndef WCHAR_MAX // [ # define WCHAR_MAX _UI16_MAX #endif // WCHAR_MAX ] #define WINT_MIN 0 #define WINT_MAX _UI16_MAX -#endif // __STDC_LIMIT_MACROS ] - +#endif // __STDC_LIMIT_MACROS ] // 7.18.4 Limits of other integer types -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) +// [ See footnote 224 at page 260 // 7.18.4.1 Macros for minimum-width integer constants @@ -241,7 +247,9 @@ typedef uint64_t uintmax_t; #define INTMAX_C INT64_C #define UINTMAX_C UINT64_C -#endif // __STDC_CONSTANT_MACROS ] +#endif // __STDC_CONSTANT_MACROS ] +#endif // _MSC_STDINT_H_ ] +#endif // __GNUC__ -#endif // _MSC_STDINT_H_ ] +#endif // VS2008_INCLUDE_STDINT_H_ diff --git a/vs2008/port/gettimeofday.cpp b/vs2008/port/gettimeofday.cpp index d9fd9aeb..295f9818 100644 --- a/vs2008/port/gettimeofday.cpp +++ b/vs2008/port/gettimeofday.cpp @@ -26,21 +26,16 @@ * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ -//*#include "c.h" - -//#include #ifdef __MSW32__ #include // timeval is defined in here. #endif /* FILETIME of Jan 1 1970 00:00:00. */ -//static const unsigned __int64 epoch = UINT64CONST(116444736000000000); static const unsigned __int64 epoch = 11644473600000000Ui64; -struct timezone -{ - int tz_minuteswest; /* minutes W of Greenwich */ - int tz_dsttime; /* type of dst correction */ +struct timezone { + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ }; /* @@ -50,19 +45,18 @@ struct timezone * elapsed_time(). */ int -gettimeofday(struct timeval * tp, struct timezone * tzp) -{ - FILETIME file_time; - SYSTEMTIME system_time; - ULARGE_INTEGER ularge; +gettimeofday(struct timeval * tp, struct timezone * tzp) { + FILETIME file_time; + SYSTEMTIME system_time; + ULARGE_INTEGER ularge; - GetSystemTime(&system_time); - SystemTimeToFileTime(&system_time, &file_time); - ularge.LowPart = file_time.dwLowDateTime; - ularge.HighPart = file_time.dwHighDateTime; + GetSystemTime(&system_time); + SystemTimeToFileTime(&system_time, &file_time); + ularge.LowPart = file_time.dwLowDateTime; + ularge.HighPart = file_time.dwHighDateTime; - tp->tv_sec = (long) ((ularge.QuadPart - epoch) / 10000000L); - tp->tv_usec = (long) (system_time.wMilliseconds * 1000); + tp->tv_sec = (long)((ularge.QuadPart - epoch) / 10000000L); + tp->tv_usec = (long)(system_time.wMilliseconds * 1000); - return 0; + return 0; } diff --git a/vs2008/port/gettimeofday.h b/vs2008/port/gettimeofday.h index 2a016bb4..00fbea1a 100644 --- a/vs2008/port/gettimeofday.h +++ b/vs2008/port/gettimeofday.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////// // File: gettimeofday.h -// Description: Header file for gettimeofday.c (source postgreslq.org) +// Description: Header file for gettimeofday.c (source postgresql.org) // Author: zdenop // Created: Fri Nov 19 21:05:06 CET 2010 // @@ -17,10 +17,15 @@ // /////////////////////////////////////////////////////////////////////// +#ifndef VS2008_PORT_GETTIMEOFDAY_H_ +#define VS2008_PORT_GETTIMEOFDAY_H_ + #ifdef __MSW32__ #include // timeval is defined in here. #endif typedef struct timezone tz; -int gettimeofday(struct timeval * tp, struct timezone * tzp); \ No newline at end of file +int gettimeofday(struct timeval * tp, struct timezone * tzp); + +#endif // VS2008_PORT_GETTIMEOFDAY_H_ diff --git a/vs2008/port/strtok_r.cpp b/vs2008/port/strtok_r.cpp new file mode 100644 index 00000000..a89b50f1 --- /dev/null +++ b/vs2008/port/strtok_r.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * 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. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS 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 THE INSTITUTE OR 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. + */ + +// source: https://github.com/heimdal/heimdal/blob/master/lib/roken/strtok_r.c + +#include + +char *strtok_r(char *s1, const char *s2, char **lasts) { + char *ret; + + if (s1 == NULL) + s1 = *lasts; + while (*s1 && strchr(s2, *s1)) + ++s1; + if (*s1 == '\0') + return NULL; + ret = s1; + while (*s1 && !strchr(s2, *s1)) + ++s1; + if (*s1) + *s1++ = '\0'; + *lasts = s1; + return ret; +} + diff --git a/vs2008/port/strtok_r.h b/vs2008/port/strtok_r.h new file mode 100644 index 00000000..01b33d9e --- /dev/null +++ b/vs2008/port/strtok_r.h @@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////// +// File: strtok_r.h +// Description: Header file for strtok_r.cpp +// source: https://github.com/heimdal/heimdal/blob/master/lib/roken/ +// strtok_r.c +// Author: zdenop +// Created: Fri Aug 12 23:55:06 CET 2011 +// +// (C) Copyright 2011, Google Inc. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/////////////////////////////////////////////////////////////////////// + +#ifndef VS2008_PORT_GETTIMEOFDAY_H_ +#define VS2008_PORT_GETTIMEOFDAY_H_ + +char *strtok_r(char *s1, const char *s2, char **lasts); + +#endif // VS2008_PORT_GETTIMEOFDAY_H_ diff --git a/vs2008/include/version.h b/vs2008/port/version.h similarity index 86% rename from vs2008/include/version.h rename to vs2008/port/version.h index c7a2d28c..a43ff02c 100644 --- a/vs2008/include/version.h +++ b/vs2008/port/version.h @@ -1,20 +1,25 @@ -/////////////////////////////////////////////////////////////////////// -// File: version.h -// Description: define version identifier for Windows -// Author: zdenop@gmail.com -// Created: Fri Nov 19 21:05:06 CET 2010 -// -// (C) Copyright 2010, Google Inc. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -/////////////////////////////////////////////////////////////////////// - -#define VERSION "3.01" \ No newline at end of file +/////////////////////////////////////////////////////////////////////// +// File: version.h +// Description: define version identifier for Windows +// Author: zdenop@gmail.com +// Created: Fri Nov 19 21:05:06 CET 2010 +// +// (C) Copyright 2010, Google Inc. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/////////////////////////////////////////////////////////////////////// + +#ifndef VS2008_PORT_VERSION_H_ +#define VS2008_PORT_VERSION_H_ + +#define VERSION "3.01" + +#endif // VS2008_PORT_VERSION_H_ diff --git a/vs2010/port/stdint.h b/vs2010/include/stdint.h similarity index 80% rename from vs2010/port/stdint.h rename to vs2010/include/stdint.h index d02608a5..8ef8cb7e 100644 --- a/vs2010/port/stdint.h +++ b/vs2010/include/stdint.h @@ -1,39 +1,44 @@ +/////////////////////////////////////////////////////////////////////// // ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// // Copyright (c) 2006-2008 Alexander Chemeris -// +// // 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 of the author may be used to endorse or promote products // derived from this software without specific prior written permission. -// +// // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 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 THE AUTHOR 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, +// 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. -// +// /////////////////////////////////////////////////////////////////////////////// -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] +#ifndef VS2008_INCLUDE_STDINT_H_ +#define VS2008_INCLUDE_STDINT_H_ -#ifndef _MSC_STDINT_H_ // [ +#ifndef __GNUC__ +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ #define _MSC_STDINT_H_ #if _MSC_VER > 1000 @@ -72,19 +77,19 @@ extern "C" { // realize that, e.g. char has the same size as __int8 // so we give up on __intX for them. #if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; + typedef signed char int8_t; + typedef signed short int16_t; + typedef signed int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; #else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; + typedef signed __int8 int8_t; + typedef signed __int16 int16_t; + typedef signed __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; #endif typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; @@ -111,13 +116,13 @@ typedef uint32_t uint_fast32_t; typedef uint64_t uint_fast64_t; // 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] +#ifdef _WIN64 // [ + typedef signed __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 signed int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] // 7.18.1.5 Greatest-width integer types typedef int64_t intmax_t; @@ -126,7 +131,8 @@ typedef uint64_t uintmax_t; // 7.18.2 Limits of specified-width integer types -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) +// [ See footnote 220 at page 257 and footnote 221 at page 259 // 7.18.2.1 Limits of exact-width integer types #define INT8_MIN ((int8_t)_I8_MIN) @@ -171,15 +177,15 @@ typedef uint64_t uintmax_t; #define UINT_FAST64_MAX UINT64_MAX // 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ +#ifdef _WIN64 // [ # define INTPTR_MIN INT64_MIN # define INTPTR_MAX INT64_MAX # define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ +#else // _WIN64 ][ # define INTPTR_MIN INT32_MIN # define INTPTR_MAX INT32_MAX # define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] +#endif // _WIN64 ] // 7.18.2.5 Limits of greatest-width integer types #define INTMAX_MIN INT64_MIN @@ -188,7 +194,7 @@ typedef uint64_t uintmax_t; // 7.18.3 Limits of other integer types -#ifdef _WIN64 // [ +#ifdef _WIN64 // [ # define PTRDIFF_MIN _I64_MIN # define PTRDIFF_MAX _I64_MAX #else // _WIN64 ][ @@ -199,31 +205,31 @@ typedef uint64_t uintmax_t; #define SIG_ATOMIC_MIN INT_MIN #define SIG_ATOMIC_MAX INT_MAX -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ # define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ +# else // _WIN64 ][ # define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] +# endif // _WIN64 ] +#endif // SIZE_MAX ] // WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ +#ifndef WCHAR_MIN // [ # define WCHAR_MIN 0 #endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ +#ifndef WCHAR_MAX // [ # define WCHAR_MAX _UI16_MAX #endif // WCHAR_MAX ] #define WINT_MIN 0 #define WINT_MAX _UI16_MAX -#endif // __STDC_LIMIT_MACROS ] - +#endif // __STDC_LIMIT_MACROS ] // 7.18.4 Limits of other integer types -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) +// [ See footnote 224 at page 260 // 7.18.4.1 Macros for minimum-width integer constants @@ -241,7 +247,9 @@ typedef uint64_t uintmax_t; #define INTMAX_C INT64_C #define UINTMAX_C UINT64_C -#endif // __STDC_CONSTANT_MACROS ] +#endif // __STDC_CONSTANT_MACROS ] +#endif // _MSC_STDINT_H_ ] +#endif // __GNUC__ -#endif // _MSC_STDINT_H_ ] +#endif // VS2008_INCLUDE_STDINT_H_ diff --git a/vs2010/include/version.h b/vs2010/include/version.h index c7a2d28c..a43ff02c 100644 --- a/vs2010/include/version.h +++ b/vs2010/include/version.h @@ -1,20 +1,25 @@ -/////////////////////////////////////////////////////////////////////// -// File: version.h -// Description: define version identifier for Windows -// Author: zdenop@gmail.com -// Created: Fri Nov 19 21:05:06 CET 2010 -// -// (C) Copyright 2010, Google Inc. -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -/////////////////////////////////////////////////////////////////////// - -#define VERSION "3.01" \ No newline at end of file +/////////////////////////////////////////////////////////////////////// +// File: version.h +// Description: define version identifier for Windows +// Author: zdenop@gmail.com +// Created: Fri Nov 19 21:05:06 CET 2010 +// +// (C) Copyright 2010, Google Inc. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/////////////////////////////////////////////////////////////////////// + +#ifndef VS2008_PORT_VERSION_H_ +#define VS2008_PORT_VERSION_H_ + +#define VERSION "3.01" + +#endif // VS2008_PORT_VERSION_H_