You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1959 lines
52 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /**[txh]********************************************************************
  2. Description:
  3. This header works as a distribution point. It parses the Uses_*
  4. definitions and includes (or defines) the needed stuff.@p
  5. Important guidelines:@*
  6. Never include string.h use Use_string instead.
  7. strlwr and strupr are defined.@*
  8. stricmp and strnicmp are deprecated, use strcasecmp and strncasecmp
  9. instead.@*
  10. Never use ios::bin (CLY_IOSBin).
  11. Never use filebuf::openprot (CLY_FBOpenProtDef).
  12. The O_TEXT and O_BINARY from fcntl needs Uses_fcntl.
  13. S_IS* from sys/stat needs Uses_sys_stat.
  14. Never use s/random, use s/rand which are ANSI/POSIX.
  15. Streambuf members: setbuf, seekoff and sync have wrappers requested with
  16. Uses_PubStreamBuf.
  17. Request alloca with Uses_alloca.
  18. Never use movmem, use memmove instead (ANSI/POSIX).
  19. Even when supported the old calls to fexpand, isDir, pathValid,
  20. validFileName, getCurDir, isWild, __file_exists, relativePath and driveValid
  21. should be replaced by a CLY_* function.
  22. When possible POSIX compliant replacements are supplied for: glob, fnmatch
  23. and regex.
  24. Added itoa for faster and safe integer to string conversion.
  25. Copyright (c) 2000-2003 by Salvador E. Tropea
  26. Covered by the GPL license.
  27. ***************************************************************************/
  28. /* A global protection isn't suitable for all projects. Collisions should
  29. be solved individually.
  30. #ifndef CLY_CompatLayerIncluded
  31. #define CLY_CompatLayerIncluded
  32. */
  33. #include <tv/configtv.h>
  34. #ifdef Uses_fstream_simple
  35. #ifdef HAVE_SSC
  36. #define Uses_SSC_Streams 1
  37. #else
  38. #define Uses_fstream
  39. #endif
  40. #endif
  41. #ifdef Uses_iostream_simple
  42. #ifdef HAVE_SSC
  43. #define Uses_SSC_Streams 1
  44. #else
  45. #define Uses_iostream
  46. #endif
  47. #endif
  48. #ifdef Uses_SSC_Streams
  49. #define Uses_stdio
  50. #endif
  51. /* MSS memory leak debugger */
  52. #ifdef MSS
  53. #include <mss.h>
  54. #endif
  55. #ifdef __cplusplus
  56. #define CLY_CFunc extern "C"
  57. #else
  58. #define CLY_CFunc extern
  59. #endif
  60. #if !defined(CLY_DoNotDefineSizedTypes) && !defined(CLY_SizedTypesDefined)
  61. #define CLY_SizedTypesDefined 1
  62. /* The following types should be platform independent */
  63. typedef signed char int8;
  64. typedef short int16;
  65. typedef int int32;
  66. typedef unsigned char uint8;
  67. typedef unsigned short uint16;
  68. typedef unsigned int uint32;
  69. #if defined(TVComp_GCC)
  70. typedef unsigned long long uint64;
  71. typedef long long int64;
  72. #elif defined(TVComp_BCPP) || defined(TVComp_MSC)
  73. typedef unsigned __int64 uint64;
  74. typedef __int64 int64;
  75. #else
  76. #error Can not define uint64 type: unknown compiler.
  77. #endif
  78. #endif /* CLY_DoNotDefineSizedTypes */
  79. #if defined(CLY_DefineUTypes) || defined(__cplusplus)
  80. /* The following are just aliases and the size is platform dependant */
  81. typedef unsigned char uchar;
  82. typedef unsigned short ushort;
  83. typedef unsigned int uint;
  84. typedef unsigned long ulong;
  85. #endif /* CLY_DefineUTypes */
  86. #ifdef Uses_stdio
  87. #undef Include_stdio
  88. #define Include_stdio 1
  89. #endif
  90. #ifdef Uses_stdarg
  91. #undef Include_stdarg
  92. #define Include_stdarg 1
  93. #endif
  94. #ifdef Uses_CLYFileAttrs
  95. /* For mode_t */
  96. #undef Uses_sys_stat
  97. #define Uses_sys_stat 1
  98. #endif
  99. #undef FSTREAM_HEADER
  100. #define FSTREAM_HEADER <fstream.h>
  101. #undef IOMANIP_HEADER
  102. #define IOMANIP_HEADER <iomanip.h>
  103. #undef IOSTREAM_HEADER
  104. #define IOSTREAM_HEADER <iostream.h>
  105. #ifdef Uses_time
  106. #undef Include_time
  107. #define Include_time 1
  108. #endif
  109. /* The following are unconditionally defined for all platforms so here I avoid
  110. redefinitions. */
  111. #undef CLY_Packed
  112. #undef NEVER_RETURNS
  113. #undef RETURN_WHEN_NEVER_RETURNS
  114. #undef DeleteArray
  115. #undef IfStreamGetLine
  116. #undef CLY_UseCrLf
  117. #undef CLY_Have_UGID
  118. #undef CLY_HaveDriveLetters
  119. #undef CLY_IsValidDirSep
  120. #undef PATHSEPARATOR
  121. #undef PATHSEPARATOR_
  122. #undef DIRSEPARATOR
  123. #undef DIRSEPARATOR_
  124. #undef CLY_ISOCpp98
  125. #undef CLY_filebuf
  126. #undef CLY_int_filebuf
  127. #undef CLY_streambuf
  128. #undef CLY_OpenModeT
  129. #undef CLY_StreamPosT
  130. #undef CLY_StreamOffT
  131. #undef CLY_IOSSeekDir
  132. #undef CLY_FBOpenProtDef
  133. #undef CLY_NewFBFromFD
  134. #undef CLY_PubSetBuf
  135. #undef CLY_HaveFBAttach
  136. #undef CLY_FBOpen
  137. #undef CLY_IOSBin
  138. #undef CLY_IOSOut
  139. #undef CLY_IOSIn
  140. #undef CLY_IOSApp
  141. #undef CLY_IOSAtE
  142. #undef CLY_IOSBeg
  143. #undef CLY_IOSCur
  144. #undef CLY_IOSEnd
  145. #undef CLY_IOSBadBit
  146. #undef CLY_IOSEOFBit
  147. #undef CLY_IOSFailBit
  148. #undef CLY_IOSGoodBit
  149. #undef CLY_PubSeekOff
  150. #undef CLY_PubSync
  151. #undef CLY_std
  152. #undef CreateStrStream
  153. #undef GetStrStream
  154. #undef UsingNamespaceStd
  155. #undef CLY_HiddenDifferent
  156. #undef CLY_DummyTStreamRW
  157. #undef CLY_Have_snprintf
  158. #undef CLY_destroy
  159. #undef CLY_DONT_DEFINE_MIN_MAX
  160. /* Most targets doesn't define destroy, but BC++ 5.6 defines
  161. _stl::destroy and looks like it collides with any destroy not defined
  162. inside another namespace. For this reason portable code should use
  163. CLY_destroy and not destroy. To allow compiling old applications using
  164. "clean" targets CLY_destroy is defined as destroy (then undefined for
  165. BC++ 5.6) */
  166. #define CLY_destroy destroy
  167. /* Assume it as default */
  168. #define CLY_Have_snprintf 1
  169. /* Most C++ compilers doesn't need it, only MSVC seems to need *all* the
  170. virtual members (even when not used) to link */
  171. #define CLY_DummyTStreamRW(cla)
  172. #ifdef TVComp_GCC
  173. /* GNU C is supported for various OSs: */
  174. #ifdef Uses_chdir
  175. #undef Uses_unistd
  176. #define Uses_unistd
  177. #endif
  178. #ifdef Uses_string
  179. #undef Include_string
  180. #define Include_string 1
  181. #endif
  182. #ifdef Uses_limits
  183. #undef Include_limits
  184. #define Include_limits 1
  185. #endif
  186. #ifdef Uses_fcntl
  187. #undef Include_fcntl
  188. #define Include_fcntl 1
  189. #endif
  190. #ifdef Uses_sys_stat
  191. #undef Include_sys_stat
  192. #define Include_sys_stat 1
  193. #endif
  194. #ifdef Uses_ctype
  195. #undef Include_ctype
  196. #define Include_ctype 1
  197. #endif
  198. #ifdef Uses_unistd
  199. #undef Include_unistd
  200. #define Include_unistd 1
  201. #endif
  202. #ifdef Uses_access
  203. #undef Include_unistd
  204. #define Include_unistd 1
  205. #endif
  206. #ifdef Uses_alloca
  207. #undef Include_stdlib
  208. #define Include_stdlib 1
  209. #endif
  210. #ifdef Uses_free
  211. #undef Include_stdlib
  212. #define Include_stdlib 1
  213. #endif
  214. #ifdef Uses_stdlib
  215. #undef Include_stdlib
  216. #define Include_stdlib 1
  217. #endif
  218. #ifdef Uses_dirent
  219. #undef Include_dirent
  220. #define Include_dirent 1
  221. #endif
  222. #ifdef Uses_abort
  223. #undef Include_stdlib
  224. #define Include_stdlib 1
  225. #endif
  226. #ifdef Uses_AllocLocal
  227. #undef AllocLocalStr
  228. #define AllocLocalStr(s,l) char s[l]
  229. #undef AllocLocalUShort
  230. #define AllocLocalUShort(s,l) ushort s[l]
  231. #endif
  232. #define NEVER_RETURNS __attribute__((noreturn))
  233. #define RETURN_WHEN_NEVER_RETURNS
  234. #define CLY_Packed __attribute__((packed))
  235. /* SET: Anything allocated with new[] should be deleted with [].
  236. Pointed out by Laurynas Biveinis. */
  237. #define DeleteArray(a) delete[] a
  238. #ifdef Uses_getcurdir
  239. #undef getcurdir
  240. #define getcurdir CLY_getcurdir
  241. #endif
  242. /* Not yet supported for Win9x with Ming
  243. SET: I guess they can be defined for Win9x, but Anatoli's code seems to
  244. be using NETAPI32.DLL functions that only exists under NT. */
  245. #undef CLY_IsUNCShare
  246. #define CLY_IsUNCShare(a) (0)
  247. #undef CLY_IsUNC
  248. #define CLY_IsUNC(a) (0)
  249. #ifdef Uses_ftell
  250. #undef Include_stdio
  251. #define Include_stdio 1
  252. #endif
  253. #ifdef Uses_strstream
  254. #undef Include_strstream
  255. #define Include_strstream 1
  256. #endif
  257. /* ifstream::getline behaves strangely in BC++
  258. I take the gcc implementation. */
  259. #define IfStreamGetLine(istream,buffer,size) \
  260. istream.getline(buffer,size)
  261. /* ISO C++ 1998 standard changed a lot of details in the standard C++
  262. library. GCC implemented it in version 3.0. BC++ implemented some
  263. stuff in versions like BC++ 5.5. So that's a real mess. */
  264. #if __GNUC__>=3
  265. // gcc 3.1 needs a special filebuf
  266. #define CLY_filebuf std::filebuf
  267. #if __GNUC_MINOR__<1
  268. #define CLY_int_filebuf CLY_filebuf
  269. #define CLY_NewFBFromFD(buf,f) buf=new CLY_int_filebuf(fdopen(f,"rb+"),ios::in|ios::out|ios::binary)
  270. #else
  271. #undef CLY_DefineSpecialFileBuf
  272. #define CLY_DefineSpecialFileBuf 1
  273. #define CLY_NewFBFromFD(buf,f) buf=new CLY_int_filebuf(f,ios::in|ios::out|ios::binary)
  274. #endif
  275. #define CLY_streambuf std::streambuf
  276. #define CLY_ISOCpp98 1
  277. #define CLY_OpenModeT std::ios::openmode
  278. #define CLY_StreamPosT std::streampos
  279. #define CLY_StreamOffT std::streamoff
  280. #define CLY_IOSSeekDir std::ios::seekdir
  281. #define CLY_FBOpenProtDef 0
  282. #define CLY_PubSetBuf(a,b) pubsetbuf(a,b)
  283. #define CLY_FBOpen(a,b,c) open(a,b)
  284. #define CLY_IOSBin std::ios::binary
  285. #define CLY_IOSOut std::ios::out
  286. #define CLY_IOSIn std::ios::in
  287. #define CLY_IOSApp std::ios::app
  288. #define CLY_IOSAtE std::ios::ate
  289. #define CLY_IOSBeg std::ios::beg
  290. #define CLY_IOSCur std::ios::cur
  291. #define CLY_IOSEnd std::ios::end
  292. #define CLY_IOSBadBit std::ios::badbit
  293. #define CLY_IOSEOFBit std::ios::eofbit
  294. #define CLY_IOSFailBit std::ios::failbit
  295. #define CLY_IOSGoodBit std::ios::goodbit
  296. #define CLY_PubSeekOff pubseekoff
  297. #define CLY_PubSync pubsync
  298. #define CLY_std(a) std::a
  299. #define UsingNamespaceStd using namespace std;
  300. #define CreateStrStream(os,buf,size) std::string buf; std::ostringstream os(buf)
  301. #define GetStrStream(os,buf) os.str().c_str()
  302. #ifdef Uses_StrStream
  303. #undef Include_sstream
  304. #define Include_sstream 1
  305. #endif
  306. #undef FSTREAM_HEADER
  307. #define FSTREAM_HEADER <fstream>
  308. #undef IOMANIP_HEADER
  309. #define IOMANIP_HEADER <iomanip>
  310. #undef IOSTREAM_HEADER
  311. #define IOSTREAM_HEADER <iostream>
  312. #else
  313. #define CLY_filebuf filebuf
  314. #define CLY_int_filebuf filebuf
  315. #define CLY_streambuf streambuf
  316. #define CLY_OpenModeT int
  317. #define CLY_StreamPosT streampos
  318. #define CLY_StreamOffT streamoff
  319. #define CLY_IOSSeekDir ios::seek_dir
  320. #define CLY_FBOpenProtDef filebuf::openprot
  321. #define CLY_NewFBFromFD(buf,f) buf=new filebuf(f)
  322. #define CLY_PubSetBuf(a,b) setbuf(a,b)
  323. #define CLY_HaveFBAttach 1
  324. #define CLY_FBOpen(a,b,c) open(a,b,c)
  325. #define CLY_IOSBin ios::bin
  326. #define CLY_IOSOut ios::out
  327. #define CLY_IOSIn ios::in
  328. #define CLY_IOSApp ios::app
  329. #define CLY_IOSAtE ios::ate
  330. #define CLY_IOSBeg ios::beg
  331. #define CLY_IOSCur ios::cur
  332. #define CLY_IOSEnd ios::end
  333. #define CLY_IOSBadBit ios::badbit
  334. #define CLY_IOSEOFBit ios::eofbit
  335. #define CLY_IOSFailBit ios::failbit
  336. #define CLY_IOSGoodBit ios::goodbit
  337. #define CLY_PubSeekOff seekoff
  338. #define CLY_PubSync sync
  339. #define CLY_std(a) a
  340. #define UsingNamespaceStd
  341. #define CreateStrStream(os,buf,size) char buf[size]; \
  342. ostrstream os(buf,sizeof(buf))
  343. #define GetStrStream(os,buf) buf
  344. #ifdef Uses_StrStream
  345. #undef Include_strstream
  346. #define Include_strstream 1
  347. #endif
  348. #endif
  349. /* Use the internal bool type for Boolean */
  350. #undef Boolean
  351. #undef False
  352. #undef True
  353. #define Boolean bool
  354. #define True true
  355. #define False false
  356. #ifdef TVCompf_MinGW
  357. #define CLY_UseCrLf 1
  358. #define CLY_HaveDriveLetters 1
  359. #undef FA_ARCH
  360. #undef FA_DIREC
  361. #undef FA_RDONLY
  362. #define FA_ARCH 0x01
  363. #define FA_DIREC 0x02
  364. #define FA_RDONLY 0x04
  365. #ifdef Uses_filelength
  366. #undef filelength
  367. #define filelength _filelength
  368. #undef Include_io
  369. #define Include_io 1
  370. #endif
  371. #define PATHSEPARATOR ';'
  372. #define PATHSEPARATOR_ ";"
  373. /* SET: Not sure why Vadim wanted it. Perhaps to make the port more usable
  374. for users accustomed to back slashes, but then the library isn't uniform
  375. across platforms */
  376. #define DIRSEPARATOR '\\'
  377. #define DIRSEPARATOR_ "\\"
  378. #define CLY_IsValidDirSep(a) (a=='/' || a=='\\')
  379. #ifdef Uses_fixpath
  380. CLY_CFunc void _fixpath(const char *in, char *out);
  381. #endif
  382. #ifdef Uses_HaveLFNs
  383. #undef OS_HaveLFNs
  384. #define OS_HaveLFNs 1
  385. #endif
  386. #ifdef Uses_glob
  387. #undef Include_cl_glob
  388. #define Include_cl_glob 1
  389. #endif
  390. #ifdef Uses_fnmatch
  391. #undef Include_cl_fnmatch
  392. #define Include_cl_fnmatch 1
  393. #endif
  394. #ifdef Uses_regex
  395. #undef Include_cl_regex
  396. #define Include_cl_regex 1
  397. #endif
  398. #ifdef Uses_getopt
  399. #undef Include_cl_getopt
  400. #define Include_cl_getopt 1
  401. #endif
  402. #ifdef Uses_io
  403. #undef Include_io
  404. #define Include_io 1
  405. #endif
  406. #ifdef Uses_utime
  407. /* I can't beleive they forgot the header when the function is there! */
  408. #undef Include_cl_utime
  409. #define Include_cl_utime 1
  410. #undef Include_time
  411. #define Include_time 1
  412. #endif
  413. #ifdef Uses_mkstemp
  414. CLY_CFunc int mkstemp(char *_template);
  415. #endif
  416. #ifdef Uses_getcwd
  417. #undef Include_io
  418. #define Include_io 1
  419. #endif
  420. #ifdef Uses_itoa
  421. #undef Include_stdlib
  422. #define Include_stdlib 1
  423. #endif
  424. #ifdef Uses_direct
  425. #undef Include_direct
  426. #define Include_direct 1
  427. #endif
  428. #ifdef Uses_dir
  429. #undef Include_dir
  430. #define Include_dir 1
  431. #endif
  432. #ifdef Uses_nl_langinfo
  433. #undef Uses_CLY_nl_langinfo
  434. #define Uses_CLY_nl_langinfo 1
  435. #endif
  436. #ifdef Uses_getline
  437. #undef Uses_CLY_getline
  438. #define Uses_CLY_getline 1
  439. #undef Uses_CLY_ssize_t
  440. #define Uses_CLY_ssize_t 1
  441. #endif
  442. #ifndef usleep
  443. #define usleep(microseconds) CLY_YieldProcessor(microseconds)
  444. #endif
  445. #ifndef __MINGW32_MAJOR_VERSION
  446. // MinGW people is really ignorant about gcc.
  447. // This definition should be done by gcc itself.
  448. #include <_mingw.h>
  449. #endif
  450. #if defined(Uses_alloca) && (__MINGW32_MAJOR_VERSION>=2) && !defined(alloca)
  451. // Why needed? that's a really idiot thing.
  452. #define alloca __builtin_alloca
  453. #endif
  454. #endif
  455. /* Win32/Cygwin -- OH! */
  456. #ifdef TVCompf_Cygwin
  457. #define CLY_HiddenDifferent 1
  458. #define CLY_Have_UGID 1
  459. #undef FA_ARCH
  460. #undef FA_DIREC
  461. #undef FA_RDONLY
  462. #define FA_ARCH 0x01
  463. #define FA_DIREC 0x02
  464. #define FA_RDONLY 0x04
  465. #ifdef Uses_filelength
  466. #undef filelength
  467. #define filelength CLY_filelength
  468. #endif
  469. #define PATHSEPARATOR ':'
  470. #define PATHSEPARATOR_ ":"
  471. #define DIRSEPARATOR '/'
  472. #define DIRSEPARATOR_ "/"
  473. #define CLY_IsValidDirSep(a) (a=='/')
  474. #ifdef Uses_fixpath
  475. CLY_CFunc void _fixpath(const char *in, char *out);
  476. #endif
  477. #ifdef Uses_HaveLFNs
  478. #undef OS_HaveLFNs
  479. #define OS_HaveLFNs 1
  480. #endif
  481. #ifdef Uses_glob
  482. #undef Include_glob
  483. #define Include_glob 1
  484. #endif
  485. #ifdef Uses_fnmatch
  486. #undef Include_cl_fnmatch
  487. #define Include_cl_fnmatch 1
  488. #endif
  489. #ifdef Uses_regex
  490. #undef Include_sys_types
  491. #define Include_sys_types 1
  492. #undef Include_regex
  493. #define Include_regex 1
  494. #endif
  495. #ifdef Uses_getopt
  496. #undef Include_getopt
  497. #define Include_getopt 1
  498. #endif
  499. #ifdef Uses_utime
  500. #undef Include_utime
  501. #define Include_utime 1
  502. #endif
  503. #ifdef Uses_mkstemp
  504. #undef Include_stdio
  505. #define Include_stdio 1
  506. #endif
  507. #ifdef Uses_getcwd
  508. #undef Include_unistd
  509. #define Include_unistd 1
  510. #endif
  511. #ifdef Uses_itoa
  512. CLY_CFunc char *itoa(int value, char *string, int radix);
  513. #endif
  514. #ifdef Uses_dir
  515. #undef Include_dir
  516. #define Include_dir 1
  517. #undef Include_direct
  518. #define Include_direct 1
  519. #endif
  520. #ifdef Uses_nl_langinfo
  521. #undef Uses_CLY_nl_langinfo
  522. #define Uses_CLY_nl_langinfo 1
  523. #endif
  524. #ifdef Uses_getline
  525. #undef Uses_CLY_getline
  526. #define Uses_CLY_getline 1
  527. #endif
  528. #endif
  529. /* Under DOS djgpp defines it */
  530. #ifdef TVCompf_djgpp
  531. #define CLY_UseCrLf 1
  532. #define CLY_HaveDriveLetters 1
  533. #ifdef Uses_filelength
  534. #undef Include_io
  535. #define Include_io 1
  536. #endif
  537. #define PATHSEPARATOR ';'
  538. #define PATHSEPARATOR_ ";"
  539. #define DIRSEPARATOR '/'
  540. #define DIRSEPARATOR_ "/"
  541. #define CLY_IsValidDirSep(a) (a=='/' || a=='\\')
  542. #ifdef Uses_fixpath
  543. #undef Include_sys_stat
  544. #define Include_sys_stat 1
  545. #endif
  546. #ifdef Uses_HaveLFNs
  547. #undef Include_fcntl
  548. #define Include_fcntl 1
  549. #undef DJGPP_HaveLFNs
  550. #define DJGPP_HaveLFNs 1
  551. #endif
  552. #ifdef Uses_glob
  553. #undef Include_glob
  554. #define Include_glob 1
  555. #endif
  556. #ifdef Uses_fnmatch
  557. #undef Include_fnmatch
  558. #define Include_fnmatch 1
  559. #endif
  560. #ifdef Uses_regex
  561. #undef Include_sys_types
  562. #define Include_sys_types 1
  563. #undef Include_regex
  564. #define Include_regex 1
  565. #endif
  566. #ifdef Uses_getopt
  567. #undef Include_cl_getopt
  568. #define Include_cl_getopt 1
  569. #endif
  570. #ifdef Uses_io
  571. #undef Include_io
  572. #define Include_io 1
  573. #endif
  574. #ifdef Uses_utime
  575. #undef Include_utime
  576. #define Include_utime 1
  577. #endif
  578. #ifdef Uses_mkstemp
  579. #undef Include_stdio
  580. #define Include_stdio 1
  581. #endif
  582. #ifdef Uses_getcwd
  583. #undef Include_unistd
  584. #define Include_unistd 1
  585. #endif
  586. #ifdef Uses_itoa
  587. #undef Include_stdlib
  588. #define Include_stdlib 1
  589. #endif
  590. #ifdef Uses_direct
  591. #undef Include_direct
  592. #define Include_direct 1
  593. #endif
  594. #ifdef Uses_dir
  595. #undef Include_dir
  596. #define Include_dir 1
  597. #endif
  598. #ifdef Uses_nl_langinfo
  599. #undef Uses_CLY_nl_langinfo
  600. #define Uses_CLY_nl_langinfo 1
  601. #endif
  602. #ifdef Uses_getline
  603. #undef Uses_CLY_getline
  604. #define Uses_CLY_getline 1
  605. #endif
  606. #undef CLY_Have_snprintf
  607. #endif
  608. /* Common to all UNIX systems */
  609. #ifdef TVOS_UNIX
  610. /* Filesystem */
  611. #define CLY_HiddenDifferent 1
  612. #define CLY_Have_UGID 1
  613. #undef FA_ARCH
  614. #undef FA_DIREC
  615. #undef FA_RDONLY
  616. #define FA_ARCH 0x01
  617. #define FA_DIREC 0x02
  618. #define FA_RDONLY 0x04
  619. #define PATHSEPARATOR ':'
  620. #define PATHSEPARATOR_ ":"
  621. #define DIRSEPARATOR '/'
  622. #define DIRSEPARATOR_ "/"
  623. #define CLY_IsValidDirSep(a) (a=='/')
  624. #ifdef Uses_HaveLFNs
  625. #undef OS_HaveLFNs
  626. #define OS_HaveLFNs 1
  627. #endif
  628. /* Non standard */
  629. #ifdef Uses_string
  630. CLY_CFunc char *strlwr(char *s);
  631. CLY_CFunc char *strupr(char *s);
  632. #endif
  633. #ifdef Uses_itoa
  634. CLY_CFunc char *itoa(int value, char *string, int radix);
  635. #endif
  636. #ifdef Uses_filelength
  637. #undef filelength
  638. #define filelength CLY_filelength
  639. #endif
  640. #ifdef Uses_fixpath
  641. CLY_CFunc void _fixpath(const char *in, char *out);
  642. #endif
  643. /* POSIX */
  644. #ifdef Uses_glob
  645. #undef Include_glob
  646. #define Include_glob 1
  647. #endif
  648. #ifdef Uses_fnmatch
  649. #undef Include_fnmatch
  650. #define Include_fnmatch 1
  651. #endif
  652. #ifdef Uses_regex
  653. #undef Include_sys_types
  654. #define Include_sys_types 1
  655. #undef Include_regex
  656. #define Include_regex 1
  657. #endif
  658. #ifdef Uses_utime
  659. #undef Include_utime
  660. #define Include_utime 1
  661. #endif
  662. #ifdef Uses_mkstemp
  663. #undef Include_stdio
  664. #define Include_stdio 1
  665. #endif
  666. #ifdef Uses_getcwd
  667. #undef Include_unistd
  668. #define Include_unistd 1
  669. #endif
  670. /* Headers */
  671. #ifdef Uses_direct
  672. #undef Include_direct
  673. #define Include_direct 1
  674. #endif
  675. #ifdef Uses_dir
  676. #undef Include_dir
  677. #define Include_dir 1
  678. #endif
  679. #endif
  680. /* Linux (glibc) */
  681. #ifdef TVOSf_Linux
  682. #ifdef Uses_nl_langinfo
  683. #undef Include_langinfo
  684. #define Include_langinfo 1
  685. #endif
  686. #ifdef Uses_getopt
  687. #undef Include_getopt
  688. #define Include_getopt 1
  689. #endif
  690. #ifdef Uses_CLYFileAttrs
  691. /* Is that a bug? shouldn't be sys/stat.h enough? */
  692. #undef Include_sys_types
  693. #define Include_sys_types 1
  694. #endif
  695. #ifdef Uses_getline
  696. #undef Include_stdio
  697. #define Include_stdio 1
  698. /* That's a GNU extension and needs it */
  699. #undef _GNU_SOURCE
  700. #define _GNU_SOURCE
  701. #define CLY_getline getline
  702. #endif
  703. // Avoid including libintl.h, we have the prototypes
  704. // This is a temporal workaround.
  705. #undef _LIBINTL_H
  706. #define _LIBINTL_H 1
  707. #endif
  708. /* Solaris using gcc but not glibc */
  709. #ifdef TVOSf_Solaris
  710. #ifdef Uses_getopt
  711. #undef Include_cl_getopt
  712. #define Include_cl_getopt 1
  713. #endif
  714. #ifdef Uses_nl_langinfo
  715. #undef Include_langinfo
  716. #define Include_langinfo 1
  717. #endif
  718. #ifdef Uses_getline
  719. #undef Uses_CLY_getline
  720. #define Uses_CLY_getline 1
  721. #endif
  722. #ifdef TV_MAJOR_VERSION
  723. // size_t needs a explicit include for Solaris.
  724. // That's used by TV headers by default.
  725. #undef Include_stdio
  726. #define Include_stdio 1
  727. #endif
  728. #endif
  729. /* Generic UNIX system */
  730. #if defined(TVOS_UNIX) && !defined(TVOSf_Linux) && !defined(TVOSf_Solaris)
  731. #ifdef Uses_getopt
  732. #undef Include_cl_getopt
  733. #define Include_cl_getopt 1
  734. #endif
  735. #ifdef Uses_nl_langinfo
  736. #undef Uses_CLY_nl_langinfo
  737. #define Uses_CLY_nl_langinfo 1
  738. #endif
  739. #ifdef Uses_getline
  740. #undef Uses_CLY_getline
  741. #define Uses_CLY_getline 1
  742. #endif
  743. #endif
  744. #endif /* TVComp_GCC */
  745. /* BC++ 5.5 and 5.6 for Win32 are supported */
  746. #ifdef TVComp_BCPP
  747. #define CLY_UseCrLf 1
  748. #define CLY_HaveDriveLetters 1
  749. #define CLY_Packed
  750. #ifndef CLY_BooleanDefined
  751. #define CLY_BooleanDefined 1
  752. /* Simple Boolean type */
  753. enum Boolean { False, True };
  754. #endif
  755. #ifdef Uses_string
  756. #undef Include_string
  757. #define Include_string 1
  758. #undef strncasecmp
  759. #define strncasecmp strnicmp
  760. #undef strcasecmp
  761. #define strcasecmp stricmp
  762. #endif
  763. #ifdef Uses_abort
  764. #undef Include_stdlib
  765. #define Include_stdlib 1
  766. #endif
  767. #ifdef Uses_limits
  768. #undef Include_limits
  769. #define Include_limits 1
  770. #endif
  771. #ifdef Uses_fcntl
  772. #undef Include_fcntl
  773. #define Include_fcntl 1
  774. #endif
  775. #ifdef Uses_sys_stat
  776. #undef Include_sys_stat
  777. #define Include_sys_stat 1
  778. #endif
  779. #ifdef Uses_unistd
  780. #undef Include_cl_unistd
  781. #define Include_cl_unistd 1
  782. /* Most unistd equivalents are here: */
  783. #undef Include_io
  784. #define Include_io 1
  785. #endif
  786. #ifdef Uses_access
  787. #undef Include_io
  788. #define Include_io 1
  789. #undef R_OK
  790. #define R_OK 4
  791. #undef W_OK
  792. #define W_OK 2
  793. #undef F_OK
  794. #define F_OK 0
  795. // No test for execute => just exists
  796. #undef X_OK
  797. #define X_OK 0
  798. #endif
  799. #ifdef Uses_ctype
  800. #undef Include_ctype
  801. #define Include_ctype 1
  802. #endif
  803. #ifdef Uses_filelength
  804. #undef Include_io
  805. #define Include_io 1
  806. #endif
  807. #ifdef Uses_getcurdir
  808. #undef Include_dir
  809. #define Include_dir 1
  810. #endif
  811. #ifdef Uses_AllocLocal
  812. #undef AllocLocalStr
  813. #define AllocLocalStr(s,l) char* s = (char*)alloca(l)
  814. #undef AllocLocalUShort
  815. #define AllocLocalUShort(s,l) ushort *s = (ushort*)alloca(sizeof(ushort) * (l))
  816. #undef Uses_alloca
  817. #define Uses_alloca 1
  818. #endif
  819. #ifdef Uses_alloca
  820. #undef Include_malloc
  821. #define Include_malloc 1
  822. #endif
  823. #ifdef Uses_free
  824. #undef Include_malloc
  825. #define Include_malloc 1
  826. #endif
  827. #define NEVER_RETURNS
  828. #define RETURN_WHEN_NEVER_RETURNS return 0
  829. #undef __attribute__
  830. #define __attribute__( value )
  831. #undef __inline__
  832. #define __inline__ inline
  833. #define DeleteArray(a) delete[] a
  834. #define PATHSEPARATOR ';'
  835. #define PATHSEPARATOR_ ";"
  836. #define DIRSEPARATOR '/'
  837. #define DIRSEPARATOR_ "/"
  838. #define CLY_IsValidDirSep(a) (a=='/' || a=='\\')
  839. #ifdef Uses_fixpath
  840. CLY_CFunc void _fixpath(const char *in, char *out);
  841. #endif
  842. /* Checks for UNCs under NT provided by Anantoli Soltan */
  843. CLY_CFunc int CLY_IsUNC(const char* path);
  844. CLY_CFunc int CLY_IsUNCShare(const char* path);
  845. #ifdef Uses_HaveLFNs
  846. #undef OS_HaveLFNs
  847. #define OS_HaveLFNs 1
  848. #endif
  849. #ifdef Uses_glob
  850. #undef Include_cl_glob
  851. #define Include_cl_glob 1
  852. #endif
  853. #ifdef Uses_fnmatch
  854. #undef Include_cl_fnmatch
  855. #define Include_cl_fnmatch 1
  856. #endif
  857. #ifdef Uses_regex
  858. #undef Include_cl_regex
  859. #define Include_cl_regex 1
  860. #endif
  861. #ifdef Uses_getopt
  862. #undef Include_cl_getopt
  863. #define Include_cl_getopt 1
  864. #endif
  865. #ifdef Uses_io
  866. #undef Include_io
  867. #define Include_io 1
  868. #endif
  869. #ifdef Uses_dirent
  870. #undef Include_cl_dirent
  871. #define Include_cl_dirent 1
  872. #endif
  873. #ifdef Uses_ftell
  874. #undef Include_io
  875. #define Include_io 1
  876. #undef Include_stdio
  877. #define Include_stdio 1
  878. #endif
  879. #ifdef Uses_stdlib
  880. #undef Include_stdlib
  881. #define Include_stdlib 1
  882. #endif
  883. #ifdef Uses_utime
  884. #undef Include_utime
  885. #define Include_utime 1
  886. #endif
  887. #ifdef Uses_mkstemp
  888. CLY_CFunc int mkstemp(char *_template);
  889. #endif
  890. #ifdef Uses_getcwd
  891. #undef Include_dir
  892. #define Include_dir 1
  893. #endif
  894. #ifdef Uses_itoa
  895. #undef Include_stdlib
  896. #define Include_stdlib 1
  897. #endif
  898. #ifdef Uses_direct
  899. #undef Include_direct
  900. #define Include_direct 1
  901. #endif
  902. #ifdef Uses_dir
  903. #undef Include_dir
  904. #define Include_dir 1
  905. #endif
  906. #ifdef Uses_strstream
  907. #undef Include_strstream
  908. #define Include_strstream 1
  909. #endif
  910. #ifdef Uses_nl_langinfo
  911. #undef Uses_CLY_nl_langinfo
  912. #define Uses_CLY_nl_langinfo 1
  913. #endif
  914. #ifdef Uses_getline
  915. #undef Uses_CLY_getline
  916. #define Uses_CLY_getline 1
  917. #undef Uses_CLY_ssize_t
  918. #define Uses_CLY_ssize_t 1
  919. #endif
  920. #ifndef usleep
  921. // Doesn't work, needs to be fixed.
  922. #define usleep(microseconds) CLY_YieldProcessor(microseconds)
  923. #endif
  924. /* ifstream::getline behaves strangely in BC++
  925. I take the gcc implementation, here is a replacement. */
  926. #define IfStreamGetLine(istream,buffer,size) \
  927. CLY_IfStreamGetLine(istream,buffer,size)
  928. #ifdef Uses_IfStreamGetLine
  929. #undef Uses_fstream
  930. #define Uses_fstream 1
  931. #undef Uses_CLY_IfStreamGetLine
  932. #define Uses_CLY_IfStreamGetLine 1
  933. #endif
  934. #if __BORLANDC__>0x550
  935. // BC++ 5.6 (Builder 6)
  936. #define CLY_ISOCpp98 1
  937. #define CLY_DONT_DEFINE_MIN_MAX 1
  938. // BC++ 5.6 supports the "open(int fd)" UNIX extension.
  939. #define CLY_NewFBFromFD(buf,f) buf=new filebuf(); buf->open(f)
  940. #undef CLY_destroy
  941. // Note: that 0777 fails to create the file and 0666 creates a hidden file.
  942. #define CLY_FBOpenProtDef 0
  943. #else
  944. #define CLY_NewFBFromFD(buf,f) buf=new filebuf(f)
  945. #define CLY_FBOpenProtDef 0666
  946. #endif
  947. #define CLY_int_filebuf filebuf
  948. #define CLY_filebuf filebuf
  949. #define CLY_streambuf streambuf
  950. #define CLY_OpenModeT int
  951. #define CLY_StreamPosT streampos
  952. #define CLY_StreamOffT streamoff
  953. #define CLY_IOSSeekDir ios::seek_dir
  954. #define CLY_PubSetBuf(a,b) pubsetbuf(a,b)
  955. #define CLY_FBOpen(a,b,c) open(a,b,c)
  956. #define CLY_IOSBin ios::binary
  957. #define CLY_IOSOut ios::out
  958. #define CLY_IOSIn ios::in
  959. #define CLY_IOSApp ios::app
  960. #define CLY_IOSAtE ios::ate
  961. #define CLY_IOSBeg ios::beg
  962. #define CLY_IOSCur ios::cur
  963. #define CLY_IOSEnd ios::end
  964. #define CLY_IOSBadBit ios::badbit
  965. #define CLY_IOSEOFBit ios::eofbit
  966. #define CLY_IOSFailBit ios::failbit
  967. #define CLY_IOSGoodBit ios::goodbit
  968. #define CLY_PubSeekOff pubseekoff
  969. #define CLY_PubSync pubsync
  970. #define CLY_std(a) a
  971. #define CreateStrStream(os,buf,size) char buf[size]; \
  972. ostrstream os(buf,sizeof(buf))
  973. #define GetStrStream(os,buf) buf
  974. #ifdef Uses_StrStream
  975. #undef Include_strstream
  976. #define Include_strstream 1
  977. #endif
  978. #define UsingNamespaceStd
  979. #endif
  980. /* MSVC will be supported if volunteers tests it or Microsoft decides to
  981. give it for free ;-). After all Borland released BC++ 5.5. */
  982. #if (defined(_MSVC) || defined(__MSC_VER)) && !defined(_MSC_VER)
  983. #if !defined(__MSC_VER) // let M$ compiler be version 1.00, if nothing else has been defined.
  984. #define __MSC_VER 100
  985. #endif
  986. #define _MSC_VER __MSC_VER
  987. #endif
  988. #ifdef TVComp_MSC
  989. #define CLY_UseCrLf 1
  990. #define CLY_HaveDriveLetters 1
  991. #define CLY_Packed
  992. #ifndef CLY_BooleanDefined
  993. #define CLY_BooleanDefined 1
  994. /* Simple Boolean type */
  995. enum Boolean { False, True };
  996. #endif
  997. #ifdef Uses_string
  998. #undef Include_string
  999. #define Include_string 1
  1000. #undef strncasecmp
  1001. #define strncasecmp strnicmp
  1002. #undef strcasecmp
  1003. #define strcasecmp stricmp
  1004. #endif
  1005. #ifdef Uses_chdir
  1006. #undef Include_direct
  1007. #define Include_direct 1
  1008. #undef chdir
  1009. #define chdir _chdir
  1010. #endif
  1011. #ifdef Uses_getcwd
  1012. #undef Include_direct
  1013. #define Include_direct 1
  1014. #endif
  1015. #ifdef Uses_stdlib
  1016. #undef Include_stdlib
  1017. #define Include_stdlib 1
  1018. #endif
  1019. #ifdef Uses_abort
  1020. #undef Include_process
  1021. #define Include_process 1
  1022. #endif
  1023. #ifdef Uses_limits
  1024. #undef Include_limits
  1025. #define Include_limits 1
  1026. #endif
  1027. #ifdef Uses_stdio
  1028. #undef popen
  1029. #define popen _popen
  1030. #undef pclose
  1031. #define pclose _pclose
  1032. #undef pipe
  1033. #define pipe _pipe
  1034. #endif
  1035. #ifdef Uses_fcntl
  1036. #undef Include_fcntl
  1037. #define Include_fcntl 1
  1038. /* open and creat belongs here */
  1039. #undef Include_io
  1040. #define Include_io 1
  1041. #undef open
  1042. #define open _open
  1043. #undef creat
  1044. #define creat _creat
  1045. #undef CLY_DefineFileConstants
  1046. #define CLY_DefineFileConstants 1
  1047. #endif
  1048. #ifdef Uses_sys_stat
  1049. #undef Include_sys_stat
  1050. #define Include_sys_stat 1
  1051. #undef Fake_S_IS
  1052. #define Fake_S_IS 1
  1053. #undef CLY_DefineIRW
  1054. #define CLY_DefineIRW 1
  1055. #endif
  1056. #ifdef Uses_unistd
  1057. #undef Include_unistd
  1058. /* Doesn't exist
  1059. #define Include_unistd 1 */
  1060. /* Most unistd equivalents are here: */
  1061. #undef Include_io
  1062. #define Include_io 1
  1063. /* close, dup, dup2, read, write and lseek is defined here */
  1064. #undef CLY_Define_Inline_IO_Translations
  1065. #define CLY_Define_Inline_IO_Translations 1
  1066. /* Standard file descriptors. */
  1067. #ifndef STDIN_FILENO
  1068. #define STDIN_FILENO 0 /* Standard input. */
  1069. #endif
  1070. #ifndef STDOUT_FILENO
  1071. #define STDOUT_FILENO 1 /* Standard output. */
  1072. #endif
  1073. #ifndef STDERR_FILENO
  1074. #define STDERR_FILENO 2 /* Standard error output. */
  1075. #endif
  1076. #endif
  1077. #ifdef Uses_access
  1078. #undef Include_io
  1079. #define Include_io 1
  1080. #define access(a,b) _access(a,b)
  1081. #undef R_OK
  1082. #define R_OK 4
  1083. #undef W_OK
  1084. #define W_OK 2
  1085. #undef F_OK
  1086. #define F_OK 0
  1087. // No test for execute => just exists
  1088. #undef X_OK
  1089. #define X_OK 0
  1090. #endif
  1091. #ifdef Uses_ctype
  1092. #undef Include_ctype
  1093. #define Include_ctype 1
  1094. #endif
  1095. #ifdef Uses_filelength
  1096. #undef filelength
  1097. #define filelength _filelength
  1098. #undef Include_io
  1099. #define Include_io 1
  1100. #endif
  1101. #ifdef Uses_AllocLocal
  1102. #undef AllocLocalStr
  1103. #define AllocLocalStr(s,l) char* s = (char*)alloca(l)
  1104. #undef AllocLocalUShort
  1105. #define AllocLocalUShort(s,l) ushort *s = (ushort*)alloca(sizeof(ushort) * (l))
  1106. #undef Uses_alloca
  1107. #define Uses_alloca 1
  1108. #endif
  1109. #ifdef Uses_alloca
  1110. #undef Include_malloc
  1111. #define Include_malloc 1
  1112. #endif
  1113. #ifdef Uses_free
  1114. #undef Include_malloc
  1115. #define Include_malloc 1
  1116. #endif
  1117. #ifdef Uses_getcurdir
  1118. #undef getcurdir
  1119. #define getcurdir CLY_getcurdir
  1120. #endif
  1121. #define NEVER_RETURNS
  1122. #define RETURN_WHEN_NEVER_RETURNS return 0
  1123. #undef __attribute__
  1124. #define __attribute__( value )
  1125. #undef __inline__
  1126. #define __inline__ inline
  1127. #pragma warning( disable : 4250 )
  1128. /* SET: MSVC have a non-standard delete[] support. It doesn't follow last
  1129. standard. And which is worst doesn't understand it.
  1130. Vadim Beloborodov pointed out this missfeature. */
  1131. #define DeleteArray(a) delete (void *)a
  1132. #undef FA_ARCH
  1133. #define FA_ARCH 0x01
  1134. #undef FA_DIREC
  1135. #define FA_DIREC 0x02
  1136. #undef FA_RDONLY
  1137. #define FA_RDONLY 0x04
  1138. #define PATHSEPARATOR ';'
  1139. #define PATHSEPARATOR_ ";"
  1140. /* SET: Not sure why Vadim wanted it. Perhaps to make the port more usable
  1141. for users accustomed to back slashes, but then the library isn't uniform
  1142. across platforms */
  1143. #define DIRSEPARATOR '\\'
  1144. #define DIRSEPARATOR_ "\\"
  1145. #define CLY_IsValidDirSep(a) (a=='/' || a=='\\')
  1146. #ifdef Uses_fixpath
  1147. CLY_CFunc void _fixpath(const char *in, char *out);
  1148. #endif
  1149. /* Not yet supported for Win9x with MSVC */
  1150. #undef CLY_IsUNCShare
  1151. #define CLY_IsUNCShare(a) (0)
  1152. #undef CLY_IsUNC
  1153. #define CLY_IsUNC(a) (0)
  1154. #ifdef Uses_HaveLFNs
  1155. #undef OS_HaveLFNs
  1156. #define OS_HaveLFNs 1
  1157. #endif
  1158. #ifdef Uses_glob
  1159. #undef Include_cl_glob
  1160. #define Include_cl_glob 1
  1161. #endif
  1162. #ifdef Uses_fnmatch
  1163. #undef Include_cl_fnmatch
  1164. #define Include_cl_fnmatch 1
  1165. #endif
  1166. #ifdef Uses_regex
  1167. #undef Include_cl_regex
  1168. #define Include_cl_regex 1
  1169. #endif
  1170. #ifdef Uses_getopt
  1171. #undef Include_cl_getopt
  1172. #define Include_cl_getopt 1
  1173. #endif
  1174. #ifdef Uses_io
  1175. #undef Include_io
  1176. #define Include_io 1
  1177. #endif
  1178. #ifdef Uses_dirent
  1179. #undef Include_cl_dirent
  1180. #define Include_cl_dirent 1
  1181. #endif
  1182. #ifdef Uses_ftell
  1183. #undef Include_stdio
  1184. #define Include_stdio 1
  1185. #endif
  1186. #ifdef Uses_utime
  1187. #undef Include_sys_utime
  1188. #define Include_sys_utime 1
  1189. /*#undef utime
  1190. #define utime _utime
  1191. #undef utimbuf
  1192. #define utimbuf _utimbuf*/
  1193. #endif
  1194. #ifdef Uses_mkstemp
  1195. CLY_CFunc int mkstemp(char *_template);
  1196. #endif
  1197. #ifdef Uses_getcwd
  1198. #undef Include_io
  1199. #define Include_io 1
  1200. #endif
  1201. #ifdef Uses_itoa
  1202. #undef Include_stdlib
  1203. #define Include_stdlib 1
  1204. #endif
  1205. #ifdef Uses_direct
  1206. #undef Include_direct
  1207. #define Include_direct 1
  1208. #endif
  1209. #ifdef Uses_dir
  1210. #undef Include_dir
  1211. #define Include_dir 1
  1212. #endif
  1213. #ifdef Uses_strstream
  1214. #undef Include_strstrea
  1215. #define Include_strstrea 1
  1216. #endif
  1217. #ifdef Uses_nl_langinfo
  1218. #undef Uses_CLY_nl_langinfo
  1219. #define Uses_CLY_nl_langinfo 1
  1220. #endif
  1221. #ifdef Uses_getline
  1222. #undef Uses_CLY_getline
  1223. #define Uses_CLY_getline 1
  1224. #undef Uses_CLY_ssize_t
  1225. #define Uses_CLY_ssize_t 1
  1226. #endif
  1227. /* ifstream::getline behaves strangely in BC++
  1228. I take the gcc implementation. I hope MSVC is like it. */
  1229. #define IfStreamGetLine(istream,buffer,size) \
  1230. istream.getline(buffer,size)
  1231. #define CLY_filebuf filebuf
  1232. #define CLY_int_filebuf filebuf
  1233. #define CLY_streambuf streambuf
  1234. #define CLY_OpenModeT int
  1235. #define CLY_StreamPosT streampos
  1236. #define CLY_StreamOffT streamoff
  1237. #define CLY_IOSSeekDir ios::seek_dir
  1238. #define CLY_FBOpenProtDef filebuf::openprot
  1239. #define CLY_NewFBFromFD(buf,f) buf=new filebuf(f)
  1240. #define CLY_PubSetBuf(a,b) setbuf(a,b)
  1241. #define CLY_HaveFBAttach 1
  1242. #define CLY_FBOpen(a,b,c) open(a,b,c)
  1243. #define CLY_IOSBin ios::binary
  1244. #define CLY_IOSOut ios::out
  1245. #define CLY_IOSIn ios::in
  1246. #define CLY_IOSApp ios::app
  1247. #define CLY_IOSAtE ios::ate
  1248. #define CLY_IOSBeg ios::beg
  1249. #define CLY_IOSCur ios::cur
  1250. #define CLY_IOSEnd ios::end
  1251. #define CLY_IOSBadBit ios::badbit
  1252. #define CLY_IOSEOFBit ios::eofbit
  1253. #define CLY_IOSFailBit ios::failbit
  1254. #define CLY_IOSGoodBit ios::goodbit
  1255. #define CLY_PubSeekOff seekoff
  1256. #define CLY_PubSync sync
  1257. #define CLY_std(a) a
  1258. #define CreateStrStream(os,buf,size) char buf[size]; \
  1259. ostrstream os(buf,sizeof(buf))
  1260. #define GetStrStream(os,buf) buf
  1261. #ifdef Uses_StrStream
  1262. #undef Include_strstrea
  1263. #define Include_strstrea 1
  1264. #endif
  1265. #define UsingNamespaceStd
  1266. #undef CLY_DummyTStreamRW
  1267. #define CLY_DummyTStreamRW(cla) void write(opstream &os) { cla::write(os); }; \
  1268. void *read(ipstream &is) { return cla::read(is); };
  1269. #endif
  1270. #ifdef Uses_IOS_BIN
  1271. #undef IOS_BIN
  1272. #define IOS_BIN CLY_IOSBin
  1273. #endif
  1274. #ifdef Uses_snprintf
  1275. #ifdef CLY_Have_snprintf
  1276. #undef Include_stdio
  1277. #define Include_stdio 1
  1278. #define CLY_snprintf snprintf
  1279. #ifdef TVComp_MSC
  1280. #if _MSC_VER>=1300 // from MSVC .NET first release - v13.0.
  1281. #define CLY_vsnprintf _vsnprintf
  1282. #else
  1283. #define CLY_vsnprintf vsnprintf
  1284. #endif
  1285. #else
  1286. #define CLY_vsnprintf vsnprintf
  1287. #endif
  1288. #else
  1289. #undef Include_stdarg
  1290. #define Include_stdarg 1
  1291. #endif
  1292. #endif
  1293. // Simple Streams Compatibility hack *EXPERIMENTAL*
  1294. #ifdef HAVE_SSC
  1295. #undef CLY_filebuf
  1296. #undef CLY_int_filebuf
  1297. #undef CLY_streambuf
  1298. #undef CLY_OpenModeT
  1299. #undef CLY_StreamPosT
  1300. #undef CLY_StreamOffT
  1301. #undef CLY_IOSSeekDir
  1302. #undef CLY_FBOpenProtDef
  1303. #undef CLY_NewFBFromFD
  1304. #undef CLY_PubSetBuf
  1305. #undef CLY_HaveFBAttach
  1306. #undef CLY_FBOpen
  1307. #undef CLY_IOSBin
  1308. #undef CLY_IOSOut
  1309. #undef CLY_IOSIn
  1310. #undef CLY_IOSApp
  1311. #undef CLY_IOSAtE
  1312. #undef CLY_IOSBeg
  1313. #undef CLY_IOSCur
  1314. #undef CLY_IOSEnd
  1315. #undef CLY_IOSBadBit
  1316. #undef CLY_IOSEOFBit
  1317. #undef CLY_IOSFailBit
  1318. #undef CLY_IOSGoodBit
  1319. #undef CLY_PubSeekOff
  1320. #undef CLY_PubSync
  1321. #undef CLY_DefineSpecialFileBuf
  1322. #undef CLY_ISOCpp98
  1323. #define CLY_filebuf SSC_filebuf
  1324. #define CLY_int_filebuf SSC_filebuf
  1325. #define CLY_streambuf SSC_streambuf
  1326. #define CLY_OpenModeT SSC_ios::openmode
  1327. #define CLY_StreamPosT SSC_ios::seekoff
  1328. #define CLY_StreamOffT SSC_ios::seekoff
  1329. #define CLY_IOSSeekDir SSC_ios::seekdir
  1330. #define CLY_FBOpenProtDef 0666
  1331. #define CLY_NewFBFromFD(buf,f) buf=new SSC_filebuf(f,SSC_ios::in|SSC_ios::out|SSC_ios::binary)
  1332. #define CLY_PubSetBuf(a,b) setbuf(a,b)
  1333. #define CLY_HaveFBAttach 1
  1334. #define CLY_FBOpen(a,b,c) open(a,b,c)
  1335. #define CLY_IOSBin SSC_ios::binary
  1336. #define CLY_IOSOut SSC_ios::out
  1337. #define CLY_IOSIn SSC_ios::in
  1338. #define CLY_IOSApp SSC_ios::app
  1339. #define CLY_IOSAtE SSC_ios::ate
  1340. #define CLY_IOSBeg SSC_ios::beg
  1341. #define CLY_IOSCur SSC_ios::cur
  1342. #define CLY_IOSEnd SSC_ios::end
  1343. #define CLY_IOSBadBit SSC_ios::badbit
  1344. #define CLY_IOSEOFBit SSC_ios::eofbit
  1345. #define CLY_IOSFailBit SSC_ios::failbit
  1346. #define CLY_IOSGoodBit SSC_ios::goodbit
  1347. #define CLY_PubSeekOff seekoff
  1348. #define CLY_PubSync sync
  1349. #endif
  1350. CLY_CFunc void CLY_YieldProcessor(int micros);
  1351. CLY_CFunc void CLY_ReleaseCPU();
  1352. /* Return the number of ticks (on MSDOS 1 tick is 1/18 sec),
  1353. this is used to compute the double click */
  1354. CLY_CFunc unsigned short CLY_Ticks(void);
  1355. /* An utility to split directory and file components of a path:
  1356. Extracts from path the directory part and filename part.
  1357. if 'dir' and/or 'file' == NULL, it is not filled.
  1358. The directory will have a trailing slash. */
  1359. CLY_CFunc void CLY_ExpandPath(const char *path, char *dir, char *file);
  1360. /* An utility function. It makes the path an absolute one and replaces the
  1361. original value passed. Should use fixpath. */
  1362. CLY_CFunc void CLY_fexpand(char *rpath);
  1363. #undef fexpand
  1364. #define fexpand(a) CLY_fexpand(a)
  1365. /* Utility function to know if a drive letter is valid. */
  1366. CLY_CFunc int CLY_DriveValid(char drive);
  1367. #ifdef __cplusplus
  1368. #define driveValid(a) (CLY_DriveValid(a) ? True : False)
  1369. #endif
  1370. /* Utility function to know is a file is in fact a directory */
  1371. CLY_CFunc int CLY_IsDir(const char *str);
  1372. #ifdef __cplusplus
  1373. #define isDir(a) (CLY_DriveValid(a) ? True : False)
  1374. #endif
  1375. /* Utility function to know if a path is valid (existing directory or file) */
  1376. CLY_CFunc int CLY_PathValid(const char *path);
  1377. #ifdef __cplusplus
  1378. #define pathValid(a) (CLY_PathValid(a) ? True : False)
  1379. #endif
  1380. /* Utility function to know if a file name is valid to create a new file */
  1381. CLY_CFunc int CLY_ValidFileName(const char *fileName);
  1382. #ifdef __cplusplus
  1383. #define validFileName(a) (CLY_ValidFileName(a) ? True : False)
  1384. #endif
  1385. /* Utility function to know the current directory including a trailing
  1386. slash */
  1387. CLY_CFunc void CLY_GetCurDirSlash(char *dir);
  1388. #undef getCurDir
  1389. #define getCurDir(a) CLY_GetCurDirSlash(a)
  1390. /* Utility function to know if a path contains a supported wildcard */
  1391. CLY_CFunc int CLY_IsWild(const char *f);
  1392. #ifdef __cplusplus
  1393. #define isWild(a) (CLY_IsWild(a) ? True : False)
  1394. #endif
  1395. /* Utility function to know if a file exist and we can read from it */
  1396. CLY_CFunc int CLY_FileExists(const char *fname);
  1397. #ifndef TVCompf_djgpp
  1398. #undef __file_exists
  1399. #define __file_exists(a) CLY_FileExists(a)
  1400. #endif
  1401. /* Utility function to know if a path is relative */
  1402. CLY_CFunc int CLY_IsRelativePath(const char *path);
  1403. #ifdef __cplusplus
  1404. #define relativePath(a) (CLY_IsRelativePath(a) ? True : False)
  1405. #endif
  1406. /* Utility function to generated a beep */
  1407. #define CLY_Beep() TScreen::beep()
  1408. /* Used internally, just call filelength prior request */
  1409. CLY_CFunc long CLY_filelength(int);
  1410. /* Used internally, just call getcurdir prior request */
  1411. CLY_CFunc int CLY_getcurdir(int drive, char *buffer);
  1412. /* cl/unistd.h includes dir.h */
  1413. #ifdef Include_cl_unistd
  1414. #undef Include_dir
  1415. #define Include_dir 1
  1416. #endif
  1417. #ifdef Uses_ifsFileLength
  1418. #undef Uses_fstream
  1419. #define Uses_fstream 1
  1420. #endif
  1421. #ifdef Uses_CLY_getline
  1422. /* Prototypes uses ssize_t and size_t */
  1423. #undef Include_sys_types
  1424. #define Include_sys_types 1
  1425. #endif
  1426. #if defined(Include_sys_types) && !defined(Included_sys_types)
  1427. #define Included_sys_types 1
  1428. #include <sys/types.h>
  1429. #endif
  1430. /* Platforms where sys/tyes.h doesn't define ssize_t: */
  1431. #if defined(Uses_CLY_ssize_t) && !defined(CLY_ssize_t)
  1432. #define CLY_ssize_t 1
  1433. typedef long ssize_t;
  1434. #endif
  1435. #if defined(Include_string) && !defined(Included_string)
  1436. #define Included_string 1
  1437. #include <string.h>
  1438. #if defined(TVOSf_QNXRtP)
  1439. #include <strings.h> // QNX RtP requires this include for functions strcasecmp, etc.
  1440. #endif // __QNXNTO__
  1441. #endif
  1442. #if defined(Include_limits) && !defined(Included_limits)
  1443. #define Included_limits 1
  1444. #include <limits.h>
  1445. #ifndef PATH_MAX /* BC++ and MSVC */
  1446. #define PATH_MAX 512
  1447. #endif
  1448. #endif
  1449. #if defined(Include_fcntl) && !defined(Included_fcntl)
  1450. #define Included_fcntl 1
  1451. #include <fcntl.h>
  1452. #ifndef O_TEXT /* UNIX */
  1453. #define O_TEXT (0)
  1454. #endif
  1455. #ifndef O_BINARY /* UNIX */
  1456. #define O_BINARY (0)
  1457. #endif
  1458. #ifdef CLY_DefineFileConstants
  1459. #if !defined(O_RDONLY) && defined(_O_RDONLY)
  1460. #define O_RDONLY _O_RDONLY
  1461. #endif
  1462. #if !defined(O_WRONLY) && defined(_O_WRONLY)
  1463. #define O_WRONLY _O_WRONLY
  1464. #endif
  1465. #if !defined(O_RDWR) && defined(_O_RDWR)
  1466. #define O_RDWR _O_RDWR
  1467. #endif
  1468. #if !defined(O_APPEND) && defined(_O_APPEND)
  1469. #define O_APPEND _O_APPEND
  1470. #endif
  1471. #if !defined(O_CREAT) && defined(_O_CREAT)
  1472. #define O_CREAT _O_CREAT
  1473. #endif
  1474. #if !defined(O_EXCL) && defined(_O_EXCL)
  1475. #define O_EXCL _O_EXCL
  1476. #endif
  1477. #if !defined(O_TRUNC) && defined(_O_TRUNC)
  1478. #define O_TRUNC _O_TRUNC
  1479. #endif
  1480. #endif
  1481. #endif
  1482. #if defined(Include_sys_stat) && !defined(Included_sys_stat)
  1483. #define Included_sys_stat 1
  1484. #include <sys/stat.h>
  1485. #ifdef Fake_S_IS
  1486. #undef S_ISDIR
  1487. #define S_ISDIR(m) ((m) & S_IFDIR)
  1488. #undef S_ISCHR
  1489. #define S_ISCHR(m) ((m) & S_IFCHR)
  1490. #undef S_ISBLK
  1491. #define S_ISBLK(m) ((m) & S_IFBLK)
  1492. #undef S_ISREG
  1493. #define S_ISREG(m) ((m) & S_IFREG)
  1494. #undef S_ISFIFO
  1495. #define S_ISFIFO(m) ((m) & S_IFIFO)
  1496. #endif
  1497. #ifdef CLY_DefineIRW
  1498. #ifndef S_IREAD
  1499. #define S_IREAD _S_IREAD
  1500. #endif
  1501. #ifndef S_IWRITE
  1502. #define S_IWRITE _S_IWRITE
  1503. #endif
  1504. #endif
  1505. #endif
  1506. #if defined(Include_stdlib) && !defined(Included_stdlib)
  1507. #define Included_stdlib 1
  1508. #include <stdlib.h>
  1509. #endif
  1510. #if defined(Include_malloc) && !defined(Included_malloc)
  1511. /* BC++ and MSVC defines alloca here */
  1512. #define Included_malloc 1
  1513. #include <malloc.h>
  1514. #endif
  1515. #if defined(Include_io) && !defined(Included_io)
  1516. #define Included_io 1
  1517. #include <io.h>
  1518. #endif
  1519. #if defined(Include_direct) && !defined(Included_direct)
  1520. #define Included_direct 1
  1521. #include <direct.h>
  1522. #endif
  1523. #if defined(Include_dir) && !defined(Included_dir)
  1524. #define Included_dir 1
  1525. #include <dir.h>
  1526. #endif
  1527. #if defined(Include_langinfo) && !defined(Included_langinfo)
  1528. #define Included_langinfo 1
  1529. #include <langinfo.h>
  1530. /* Workaround a bug in glibc */
  1531. #if !defined(RADIXCHAR) && defined(DECIMAL_POINT)
  1532. #define RADIXCHAR DECIMAL_POINT
  1533. #endif
  1534. #endif
  1535. #if defined(Include_ctype) && !defined(Included_ctype)
  1536. #define Included_ctype 1
  1537. #include <ctype.h>
  1538. /* The following macros are defined to avoid passing negative values to
  1539. the ctype functions in the common case: isxxxx(char).
  1540. They are suitable for x86 DOS and Linux, perhaps not for others */
  1541. #define ucisalnum(a) isalnum((unsigned char)a)
  1542. #define ucisalpha(a) isalpha((unsigned char)a)
  1543. #define ucisascii(a) isascii((unsigned char)a)
  1544. #define uciscntrl(a) iscntrl((unsigned char)a)
  1545. #define ucisdigit(a) isdigit((unsigned char)a)
  1546. #define ucisgraph(a) isgraph((unsigned char)a)
  1547. #define ucislower(a) islower((unsigned char)a)
  1548. #define ucisprint(a) isprint((unsigned char)a)
  1549. #define ucispunct(a) ispunct((unsigned char)a)
  1550. #define ucisspace(a) isspace((unsigned char)a)
  1551. #define ucisupper(a) isupper((unsigned char)a)
  1552. #define ucisxdigit(a) isxdigit((unsigned char)a)
  1553. #define uctoascii(a) toascii((unsigned char)a)
  1554. #define uctolower(a) tolower((unsigned char)a)
  1555. #define uctoupper(a) toupper((unsigned char)a)
  1556. #endif
  1557. #if defined(Include_unistd) && !defined(Included_unistd)
  1558. #define Included_unistd 1
  1559. #include <unistd.h>
  1560. // It just fills in the gaps
  1561. #include <cl/unistd.h>
  1562. #endif
  1563. #if defined(Include_process) && !defined(Included_process)
  1564. #define Included_process 1
  1565. #include <process.h>
  1566. #endif
  1567. #if defined(Include_cl_unistd) && !defined(Included_cl_unistd)
  1568. #define Included_cl_unistd 1
  1569. #include <cl/unistd.h>
  1570. #endif
  1571. #if defined(Include_glob) && !defined(Included_glob)
  1572. #define Included_glob 1
  1573. /* POSIX */
  1574. #include <glob.h>
  1575. #endif
  1576. #if defined(Include_cl_glob) && !defined(Included_cl_glob)
  1577. #define Included_cl_glob 1
  1578. /* Replacement */
  1579. #include <cl/glob.h>
  1580. #endif
  1581. #if defined(Include_fnmatch) && !defined(Included_fnmatch)
  1582. #define Included_fnmatch 1
  1583. /* POSIX */
  1584. #include <fnmatch.h>
  1585. #endif
  1586. #if defined(Include_cl_fnmatch) && !defined(Included_cl_fnmatch)
  1587. #define Included_cl_fnmatch 1
  1588. /* Replacement */
  1589. #include <cl/fnmatch.h>
  1590. #endif
  1591. #if defined(Include_regex) && !defined(Included_regex)
  1592. #define Included_regex 1
  1593. /* POSIX */
  1594. #include <regex.h>
  1595. #endif
  1596. #if defined(Include_cl_regex) && !defined(Included_cl_regex)
  1597. #define Included_cl_regex 1
  1598. /* Replacement */
  1599. #include <cl/regex.h>
  1600. #endif
  1601. #if defined(Include_getopt) && !defined(Included_getopt)
  1602. #define Included_getopt 1
  1603. #include <getopt.h>
  1604. // Define our aliases
  1605. #define CLY_optarg optarg
  1606. #define CLY_optind optind
  1607. #define CLY_opterr opterr
  1608. #define CLY_optopt optopt
  1609. #define CLY_option option
  1610. #define CLY_no_argument no_argument
  1611. #define CLY_required_argument required_argument
  1612. #define CLY_optional_argument optional_argument
  1613. #define CLY_getopt getopt
  1614. #define CLY_getopt_long getopt_long
  1615. #define CLY_getopt_long_only getopt_long_only
  1616. #endif
  1617. #if defined(Include_cl_getopt) && !defined(Included_cl_getopt)
  1618. #define Included_cl_getopt 1
  1619. // This header defines all as CLY_* to avoid conflicts
  1620. #include <cl/getopt.h>
  1621. #endif
  1622. #if defined(Include_io) && !defined(Included_io)
  1623. #define Included_io 1
  1624. #include <io.h>
  1625. #ifdef CLY_Define_Inline_IO_Translations
  1626. /* Needed for MSVC */
  1627. /* Note we must avoid macros here or we risk to collide with TV read/write
  1628. C++ members. */
  1629. #ifndef CLY_close_inline_defined
  1630. #define CLY_close_inline_defined 1
  1631. __inline int close(int FILEDES)
  1632. { return _close(FILEDES); }
  1633. #endif
  1634. #ifndef CLY_dup_inline_defined
  1635. #define CLY_dup_inline_defined 1
  1636. __inline int dup(int OLD)
  1637. { return _dup(OLD); }
  1638. #endif
  1639. #ifndef CLY_dup2_inline_defined
  1640. #define CLY_dup2_inline_defined 1
  1641. __inline int dup2(int OLD, int NEW)
  1642. { return _dup2(OLD,NEW); }
  1643. #endif
  1644. #ifndef CLY_read_inline_defined
  1645. #define CLY_read_inline_defined 1
  1646. __inline long read(int FILEDES, void *BUFFER, unsigned long SIZE)
  1647. { return _read(FILEDES,BUFFER,SIZE); }
  1648. #endif
  1649. #ifndef CLY_write_inline_defined
  1650. #define CLY_write_inline_defined 1
  1651. __inline long write(int FILEDES, void *BUFFER, unsigned long SIZE)
  1652. { return _write(FILEDES,BUFFER,SIZE); }
  1653. #endif
  1654. #ifndef CLY_lseek_inline_defined
  1655. #define CLY_lseek_inline_defined 1
  1656. __inline long lseek(int FILEDES, long OFFSET, int WHENCE)
  1657. { return _lseek(FILEDES,OFFSET,WHENCE); }
  1658. #endif
  1659. #endif
  1660. #endif
  1661. #if defined(Include_stdio) && !defined(Included_stdio)
  1662. #define Included_stdio 1
  1663. #include <stdio.h>
  1664. #endif
  1665. #if defined(Include_dirent) && !defined(Included_dirent)
  1666. #define Included_dirent 1
  1667. #include <dirent.h>
  1668. #endif
  1669. #if defined(Include_cl_dirent) && !defined(Included_cl_dirent)
  1670. #define Included_cl_dirent 1
  1671. #include <cl/dirent.h>
  1672. #endif
  1673. #if defined(Include_time) && !defined(Included_time)
  1674. #define Included_time 1
  1675. #include <time.h>
  1676. #endif
  1677. #if defined(Include_utime) && !defined(Included_utime)
  1678. #define Included_utime 1
  1679. #include <utime.h>
  1680. #endif
  1681. #if defined(Include_stdarg) && !defined(Included_stdarg)
  1682. #define Included_stdarg 1
  1683. #include <stdarg.h>
  1684. #endif
  1685. #if defined(Include_sys_utime) && !defined(Included_sys_utime)
  1686. #define Included_sys_utime 1
  1687. #include <sys/utime.h>
  1688. #endif
  1689. #if defined(Include_cl_utime) && !defined(Included_cl_utime)
  1690. #define Included_cl_utime 1
  1691. #include <cl/utime.h>
  1692. #endif
  1693. #if defined(Include_strstream) && !defined(Included_strstream)
  1694. #define Included_strstream 1
  1695. #include <strstream.h>
  1696. #endif
  1697. #if defined(Include_strstrea) && !defined(Included_strstrea)
  1698. #define Included_strstrea 1
  1699. #include <strstrea.h>
  1700. #endif
  1701. #if defined(Include_sstream) && !defined(Included_sstream)
  1702. #define Included_sstream 1
  1703. #include <sstream>
  1704. #endif
  1705. #if defined(Uses_fstream) && !defined(Included_fstream)
  1706. #define Included_fstream 1
  1707. #include FSTREAM_HEADER
  1708. #endif
  1709. #if defined(Uses_iomanip) && !defined(Included_iomanip)
  1710. #define Included_iomanip 1
  1711. #include IOMANIP_HEADER
  1712. #endif
  1713. #if defined(Uses_iostream) && !defined(Included_iostream)
  1714. #define Included_iostream 1
  1715. #include IOSTREAM_HEADER
  1716. #endif
  1717. #if defined(Uses_SSC_Streams) && !defined(Included_SSC_Streams)
  1718. #include <tv/ssc_streams.h>
  1719. #endif
  1720. #if defined(Uses_CLYFileAttrs) && !defined(Uses_CLYFileAttrsDef)
  1721. #define Uses_CLYFileAttrsDef
  1722. /* Equivalent to mode_t */
  1723. #ifdef CLY_Have_UGID
  1724. /* In systems with User and Group ID the mode is an structure */
  1725. typedef struct
  1726. {
  1727. mode_t mode,writemask;
  1728. uid_t user;
  1729. gid_t group;
  1730. } CLY_mode_t;
  1731. #else
  1732. typedef unsigned int CLY_mode_t;
  1733. #endif
  1734. /* Utility function to find the attributes of a file. You must call stat
  1735. first and pass the st_mode member of stat's struct in statVal. */
  1736. CLY_CFunc void CLY_GetFileAttributes(CLY_mode_t *mode, struct stat *statVal, const char *fileName);
  1737. /* The reverse. The file must be closed! */
  1738. CLY_CFunc int CLY_SetFileAttributes(CLY_mode_t *newmode, const char *fileName);
  1739. /* This function alters mode content so the attribute indicates that the
  1740. owner of the file can't read from it */
  1741. CLY_CFunc void CLY_FileAttrReadOnly(CLY_mode_t *mode);
  1742. /* This function alters mode content so the attribute indicates that the
  1743. owner of the file can read from it */
  1744. CLY_CFunc void CLY_FileAttrReadWrite(CLY_mode_t *mode);
  1745. /* Returns !=0 if the file is read-only */
  1746. CLY_CFunc int CLY_FileAttrIsRO(CLY_mode_t *mode);
  1747. /* Sets the attribute that indicates the file was modified */
  1748. CLY_CFunc void CLY_FileAttrModified(CLY_mode_t *mode);
  1749. /* It returns a mode that can be used for a newly created file */
  1750. CLY_CFunc void CLY_GetDefaultFileAttr(CLY_mode_t *mode);
  1751. #endif
  1752. /* Returns the name of the shell command */
  1753. CLY_CFunc char *CLY_GetShellName(void);
  1754. /* v/snprintf functions */
  1755. #if defined(Uses_snprintf) && !defined(CLY_Have_snprintf)
  1756. CLY_CFunc int CLY_vsnprintf(char *string, size_t length, const char * format, va_list args);
  1757. CLY_CFunc int CLY_snprintf(char *string, size_t length, const char * format, ...);
  1758. #endif
  1759. #ifdef Uses_ifsFileLength
  1760. extern long CLY_ifsFileLength(CLY_std(ifstream) &f);
  1761. #endif
  1762. #ifdef Uses_CLY_IfStreamGetLine
  1763. extern int CLY_IfStreamGetLine(CLY_std(ifstream) &is, char *buffer, unsigned len);
  1764. #endif
  1765. /* Internal definition of nl_langinfo */
  1766. #if defined(Uses_CLY_nl_langinfo) && !defined(CLY_nl_langinfo_Defined)
  1767. #define CLY_nl_langinfo_Defined 1
  1768. typedef int nl_item;
  1769. #define CURRENCY_SYMBOL 0 /*currency_symbol*/
  1770. #define CRNCYSTR 0 /*currency_symbol*/ /*deprecated*/
  1771. #define DECIMAL_POINT 1 /*decimal_point*/
  1772. #define RADIXCHAR 1 /*decimal_point*/ /*deprecated*/
  1773. #define GROUPING 2 /*grouping*/
  1774. #define INT_CURR_SYMBOL 3 /*int_curr_symbol*/
  1775. #define MON_DECIMAL_POINT 4 /*mon_decimal_point*/
  1776. #define MON_GROUPING 5 /*mon_grouping*/
  1777. #define NEGATIVE_SIGN 6 /*negative_sign*/
  1778. #define POSITIVE_SIGN 7 /*positive_sign*/
  1779. #define THOUSANDS_SEP 8 /*thousands_sep*/
  1780. #define THOUSEP 8 /*thousands_sep*/ /*deprecated*/
  1781. /*char*/
  1782. #define FRAC_DIGITS 9 /*frac_digits*/
  1783. #define INT_FRAC_DIGITS 10 /*int_frac_digits*/
  1784. #define N_CS_PRECEDES 11 /*n_cs_precedes*/
  1785. #define N_SEP_BY_SPACE 12 /*n_sep_by_space*/
  1786. #define P_SIGN_POSN 13 /*p_sign_posn*/
  1787. #define N_SIGN_POSN 14 /*n_sign_posn*/
  1788. #define P_CS_PRECEDES 15 /*p_cs_precedes*/
  1789. #define P_SEP_BY_SPACE 16 /*p_sep_by_space*/
  1790. #define nl_langinfo CLY_nl_langinfo
  1791. CLY_CFunc char *CLY_nl_langinfo(nl_item item);
  1792. #endif /* defined(Uses_CLY_nl_langinfo) && !defined(CLY_nl_langinfo_Defined) */
  1793. #ifdef Uses_CLY_getline
  1794. CLY_CFunc ssize_t CLY_getstr(char **lineptr, size_t *n, FILE *stream,
  1795. char terminator, int offset, int limit);
  1796. CLY_CFunc ssize_t CLY_getline(char **lineptr, size_t *n, FILE *stream);
  1797. CLY_CFunc ssize_t CLY_getline_safe(char **lineptr, size_t *n, FILE *stream,
  1798. int limit);
  1799. #endif
  1800. #undef CLY_High16
  1801. #undef CLY_Low16
  1802. #ifdef TV_BIG_ENDIAN
  1803. /* Most RISC machines */
  1804. #define CLY_High16(a) ((a) & 0xFF)
  1805. #define CLY_Low16(a) ((a) >> 8)
  1806. #else
  1807. /* Intel machines */
  1808. #define CLY_High16(a) ((a) >> 8)
  1809. #define CLY_Low16(a) ((a) & 0xFF)
  1810. #endif
  1811. #if defined(DJGPP_HaveLFNs) && !defined(CLY_HaveLFNs_Defined)
  1812. #define CLY_HaveLFNs_Defined 1
  1813. inline
  1814. int CLY_HaveLFNs()
  1815. {
  1816. return _use_lfn(0);
  1817. }
  1818. #endif
  1819. #if defined(OS_HaveLFNs) && !defined(OS_HaveLFNs_Defined)
  1820. #define OS_HaveLFNs_Defined 1
  1821. inline
  1822. int CLY_HaveLFNs()
  1823. {
  1824. return 1;
  1825. }
  1826. #endif
  1827. /* Is that an EOL char? */
  1828. /* Ask for no */
  1829. #undef CLY_IsntEOL
  1830. #define CLY_IsntEOL(a) (a!='\r' && a!='\n')
  1831. /* Ask for yes */
  1832. #undef CLY_IsEOL
  1833. #define CLY_IsEOL(a) (a=='\r' || a=='\n')
  1834. #undef CLY_LenEOL
  1835. #undef CLY_crlf
  1836. #undef CLY_IsTrueEOL
  1837. #ifdef CLY_UseCrLf
  1838. #define CLY_LenEOL 2
  1839. /* This asks if the EOL is really usable for the OS */
  1840. #define CLY_IsTrueEOL(a) (a=='\r' || a=='\n')
  1841. /* String containing EOL */
  1842. #define CLY_crlf "\r\n"
  1843. #else
  1844. #define CLY_LenEOL 1
  1845. #define CLY_crlf "\n"
  1846. #define CLY_IsTrueEOL(a) (a=='\n')
  1847. #endif
  1848. #undef CLY_CFunc
  1849. /*#endif // CLY_CompatLayerIncluded */