/usr/include/pstoedit/cppcomp.h is in libpstoedit-dev 3.70-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | #ifndef cppcomp_h
#define cppcomp_h
//{
/*
cppcomp.h : This file is part of pstoedit
header declaring compiler dependent stuff
Copyright (C) 1998 - 2014 Wolfgang Glunz, wglunz35_AT_pstoedit.net
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef HAVE_CONFIG_H
#include "pstoedit_config.h"
#endif
#ifdef _MSC_VER
#ifndef DLLEXPORT
#define DLLEXPORT __declspec( dllexport )
#endif
#else
#define DLLEXPORT
#endif
#ifdef _AIX
#define _unix
#endif
#if defined (_MSC_VER) && (_MSC_VER >= 1100)
// MSVC 5 and 6 have ANSI C++ header files, but the compilation
// is much slower and object files get bigger.
// add other compiler that support STL and the ANSI C++ standard here
// 1100 means : compiler v 11 which is MSVC 5
// 1200 - VS 6
// 1300 - VS 7 (2002)
// 1400 - VS 8 (2005)
// NOTE: If your compiler or installation does not come with
// an installation of the STL, just comment out the next line
#define HAVE_STL
// old - now using STL dynamic vectors #define USE_FIXED_ARRAY 1
#define HAVE_TYPENAME
#define USE_NEWSTRSTREAM
#define HAVE_AUTOPTR
#endif
#if defined (FORCESTLUSAGE)
//
#define HAVE_STL
#endif
#if defined (__GNUG__) && (__GNUC__>=3)
#define HAVE_STL
#define HAVE_TYPENAME
#define HAVE_AUTOPTR
#define USE_NEWSTRSTREAM
#endif
#ifdef __SUNPRO_CC
#if __SUNPRO_CC >= 0x500
#define HAVE_TYPENAME
#if __SUNPRO_CC_COMPAT >= 5
// SUN's new compiler seems to work with STL (only)
#define HAVE_STL
#define HAVE_AUTOPTR
#ifndef INTERNALBOOL
#define INTERNALBOOL
#endif
#else
// we compile with -compat=4
#ifdef INTERNALBOOL
#undef INTERNALBOOL
#endif
#endif
#else
// for the old version (CC 4.x)
#endif
#endif
#ifndef HAVE_TYPENAME
#define typename
#endif
//
// Note: for MSVC the usage of precompiled headers has to be turned
// off, otherwise compilation fails within the stdio. (the first time
// it works, but not a second one) (at least with MSVC 5)
//
//{
#ifdef HAVE_STL
#define I_fstream <fstream>
#define I_iomanip <iomanip>
#define I_ios <ios>
#define I_iostream <iostream>
#if (defined (_MSC_VER) && _MSC_VER >= 1100)
// 1100 is version 5.0
#pragma warning(disable: 4786)
#define I_istream <istream>
#define I_ostream <ostream>
#define I_streamb <streambuf>
#else
#define I_istream <iostream>
#define I_ostream <iostream>
#define I_streamb <iostream>
#endif
#ifdef USE_NEWSTRSTREAM
#define I_strstream <sstream>
#define C_istrstream istringstream
#define C_ostrstream ostringstream
#else
#define I_strstream <strstream>
#define C_istrstream istrstream
#define C_ostrstream ostrstream
#endif
#define I_stdio <cstdio>
#define I_stdlib <cstdlib>
#define USESTD using namespace std;
#else
//} {
// section for non ANSI C++ compilers
#define I_fstream <fstream.h>
#define I_iomanip <iomanip.h>
#define I_ios <ios.h>
#define I_iostream <iostream.h>
#define I_istream <iostream.h>
#define I_ostream <iostream.h>
#define I_streamb <iostream.h>
#if (defined(unix) || defined(__unix__) || defined(_unix) || defined(__unix) || defined(__EMX__) || defined (NetBSD) ) && !defined(DJGPP)
#define I_strstream <strstream.h>
// next macro is to avoid usage of the above lengthy || list and because in .fl file __unix__ cannot be used sometimes because m4
// expands this sometimes to ""
#define PSTOEDIT_UNIXLIKE
#else
#define I_strstream <strstrea.h>
#endif
#define C_istrstream istrstream
#define C_ostrstream ostrstream
#if defined (__GNUG__) || defined (BOOLDEFINED) || ( defined (_MSC_VER) && _MSC_VER >= 1100) || defined (__BCPLUSPLUS__) && __BCPLUSPLUS__ >= 0x0400 || defined (INTERNALBOOL) || defined (_BOOL_EXISTS)
// no need to define bool
// 1100 is version 5.0
// is for Digital Unix
#else
typedef int bool;
const bool false = 0;
const bool true = 1;
#define BOOLDEFINED 1
#endif
#define I_stdio <stdio.h>
#define I_stdlib <stdlib.h>
#define USESTD
#endif
//}
// if (defined (_MSC_VER) && _MSC_VER >= 1100) || defined (LINT) || defined (__COVERITY__)
#if 1
#define NOCOPYANDASSIGN(classname) \
private: \
classname(const classname&); \
const classname & operator=(const classname&);
#else
/* nothing - GNU has problems with this anyway. But, it does not harm.
During compilation with VC++ potential misusages of the
forbidden methods will be detected */
#define NOCOPYANDASSIGN(classname)
#endif
// rcw2: work round case insensitivity in RiscOS
#ifdef riscos
#define I_string_h "unix:string.h"
#else
#define I_string_h <string.h>
#endif
// some code seems to rely on _WIN32 instead of WIN32
#if defined (WIN32)
#ifndef _WIN32
#define _WIN32 WIN32
#endif
#endif
#ifndef NIL
// 0 pointers
#define NIL 0
#endif
//{
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
// for MS VS 8 (== cl version 14) we can use the new secure *_s string functions
// for other systems we have to "emulate" them
#define TARGETWITHLEN(str,len) str,len
// MSVC moans: 'open': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _open. See online help for details.
#define OPEN _open
#define CLOSE _close
#define READ _read
#define STRICMP _stricmp
#define FILENO _fileno
#define SETMODE _setmode
#define TEMPNAM _tempnam
#define GETCWD _getcwd
#else
//} {
#include I_iostream
#include I_string_h // for strlen
#include I_stdlib // for exit
#define OPEN open
#define CLOSE close
#define READ read
#define STRICMP strcasecmp
//#define STRICMP stricmp
#define FILENO fileno
#define SETMODE setmode
#define TEMPNAM tempnam
#define GETCWD getcwd
USESTD
// approach for emulation:
// * guarantee that the result string ends with \n (array[size-1] = 0)
// * if the above condition cannot be achieved - exit with error message
//
// the implementation is far from optimal from a performance point of view - but for pstoedit this is not critical
//
static inline void strncpy_s(char * de, size_t de_size, const char * so, size_t count) {
const size_t sourcelen = so ? strlen(so) : 0;
size_t tobecopied = sourcelen < count ? sourcelen : count;
if ( tobecopied < de_size ) {
while (so && *so && (tobecopied > 0) ) {
*de = *so; ++de; ++so; --tobecopied;
} // does not copy final 0
*de = 0;
} else {
cerr << "buffer overflow in strcpy_s. Input string: '" << (so ? so : "NULL") << "' count: " << count << " sourcelen " << sourcelen << " buffersize " << de_size << endl;
exit(1);
}
}
static inline void strcpy_s(char * de, size_t de_size, const char * so) {
strncpy_s(de, de_size, so, strlen(so) );
}
static inline void strcat_s(char * de, size_t de_size, const char * so) {
// copy string into de + strlen(de)
const size_t already_in = strlen(de);
strcpy_s(de + already_in, de_size - already_in, so);
}
// sprintf_s requires a second argument indicating the size of the target string
// because sprintf can have any number of arguments, we cannot handle this in the
// same manner as the functions above. So we need to hide/unhide this second argument
// for older compilers
#ifdef HAVE_SNPRINTF
#define sprintf_s snprintf
#define TARGETWITHLEN(str,len) str,len
#else
#define sprintf_s sprintf
#define TARGETWITHLEN(str,len) str
#endif
// sscanf_s requires a size argument for output strings, unless we use "to-string", we can use sscanf
// but this has to be assured in each individual case !!!
// TARGETWITHLEN is not being used in the context of sscanf
#define sscanf_s sscanf
#endif
//}
#endif
//}
|