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 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
|
/*************************************************************************************************
* System configurations for QDBM
* Copyright (C) 2000-2007 Mikio Hirabayashi
* This file is part of QDBM, Quick Database Manager.
* QDBM is free software; you can redistribute it and/or modify it under the terms of the GNU
* Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License or any later version. QDBM 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 Lesser General Public License for more
* details.
* You should have received a copy of the GNU Lesser General Public License along with QDBM; if
* not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA.
*************************************************************************************************/
#ifndef _MYCONF_H /* duplication check */
#define _MYCONF_H
#if defined(__cplusplus) /* export for C++ */
extern "C" {
#endif
/*************************************************************************************************
* system discrimination
*************************************************************************************************/
#if defined(__linux__)
#define _SYS_LINUX_
#define _QDBM_SYSNAME "Linux"
#elif defined(__FreeBSD__)
#define _SYS_FREEBSD_
#define _QDBM_SYSNAME "FreeBSD"
#elif defined(__NetBSD__)
#define _SYS_NETBSD_
#define _QDBM_SYSNAME "NetBSD"
#elif defined(__OpenBSD__)
#define _SYS_OPENBSD_
#define _QDBM_SYSNAME "OpenBSD"
#elif defined(__sun__)
#define _SYS_SUNOS_
#define _QDBM_SYSNAME "SunOS"
#elif defined(__hpux)
#define _SYS_HPUX_
#define _QDBM_SYSNAME "HP-UX"
#elif defined(__osf)
#define _SYS_TRU64_
#define _QDBM_SYSNAME "Tru64"
#elif defined(_AIX)
#define _SYS_AIX_
#define _QDBM_SYSNAME "AIX"
#elif defined(__APPLE__) && defined(__MACH__)
#define _SYS_MACOSX_
#define _QDBM_SYSNAME "Mac OS X"
#elif defined(_MSC_VER)
#define _SYS_MSVC_
#define _QDBM_SYSNAME "Windows (VC++)"
#elif defined(_WIN32)
#define _SYS_MINGW_
#define _QDBM_SYSNAME "Windows (MinGW)"
#elif defined(__CYGWIN__)
#define _SYS_CYGWIN_
#define _QDBM_SYSNAME "Windows (Cygwin)"
#elif defined(__riscos__) || defined(__riscos)
#define _SYS_RISCOS_
#define _QDBM_SYSNAME "RISC OS"
#else
#define _SYS_GENERIC_
#define _QDBM_SYSNAME "Generic"
#endif
/*************************************************************************************************
* general headers
*************************************************************************************************/
#if defined(_SYS_MSVC_)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <assert.h>
#include <stdarg.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <direct.h>
#include <windows.h>
#include <io.h>
#elif defined(_SYS_MINGW_)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <assert.h>
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <windows.h>
#include <io.h>
#elif defined(_SYS_CYGWIN_)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <assert.h>
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/times.h>
#include <fcntl.h>
#include <dirent.h>
#include <windows.h>
#include <io.h>
#else
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <time.h>
#include <assert.h>
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/times.h>
#include <fcntl.h>
#include <dirent.h>
#endif
/*************************************************************************************************
* notation of filesystems
*************************************************************************************************/
#if defined(_SYS_MSVC_) || defined(_SYS_MINGW_)
#define MYPATHCHR '\\'
#define MYPATHSTR "\\"
#define MYEXTCHR '.'
#define MYEXTSTR "."
#define MYCDIRSTR "."
#define MYPDIRSTR ".."
#elif defined(_SYS_RISCOS_)
#define MYPATHCHR '.'
#define MYPATHSTR "."
#define MYEXTCHR '/'
#define MYEXTSTR "/"
#define MYCDIRSTR "@"
#define MYPDIRSTR "^"
#else
#define MYPATHCHR '/'
#define MYPATHSTR "/"
#define MYEXTCHR '.'
#define MYEXTSTR "."
#define MYCDIRSTR "."
#define MYPDIRSTR ".."
#endif
/*************************************************************************************************
* for dosish filesystems
*************************************************************************************************/
#if defined(_SYS_MSVC_) || defined(_SYS_MINGW_) || defined(_SYS_CYGWIN_)
#undef UNICODE
#undef open
#define \
open(pathname, flags, mode) \
open(pathname, flags | O_BINARY, mode)
#define \
lstat(pathname, buf) \
_qdbm_win32_lstat(pathname, buf)
int _qdbm_win32_lstat(const char *pathname, struct stat *buf);
#else
#undef O_BINARY
#undef O_TEXT
#undef setmode
#define O_BINARY 0
#define O_TEXT 1
#define \
setmode(fd, mode) \
(O_BINARY)
#endif
/*************************************************************************************************
* for POSIX thread
*************************************************************************************************/
#if defined(MYPTHREAD)
#define _qdbm_ptsafe TRUE
void *_qdbm_settsd(void *ptr, int size, const void *initval);
#else
#define _qdbm_ptsafe FALSE
#define \
_qdbm_settsd(ptr, size, initval) \
(NULL)
#endif
/*************************************************************************************************
* for systems without file locking
*************************************************************************************************/
#if defined(_SYS_RISCOS_) || defined(MYNOLOCK)
#undef fcntl
#define \
fcntl(fd, cmd, lock) \
(0)
#endif
/*************************************************************************************************
* for systems without mmap
*************************************************************************************************/
#if defined(_SYS_MSVC_) || defined(_SYS_MINGW_) || \
defined(_SYS_FREEBSD_) || defined(_SYS_NETBSD_) || defined(_SYS_OPENBSD_) || \
defined(_SYS_AIX_) || defined(_SYS_RISCOS_) || defined(MYNOMMAP)
#undef PROT_EXEC
#undef PROT_READ
#undef PROT_WRITE
#undef PROT_NONE
#undef MAP_FIXED
#undef MAP_SHARED
#undef MAP_PRIVATE
#undef MAP_FAILED
#undef MS_ASYNC
#undef MS_SYNC
#undef MS_INVALIDATE
#undef mmap
#undef munmap
#undef msync
#undef mflush
#define PROT_EXEC (1 << 0)
#define PROT_READ (1 << 1)
#define PROT_WRITE (1 << 2)
#define PROT_NONE (1 << 3)
#define MAP_FIXED 1
#define MAP_SHARED 2
#define MAP_PRIVATE 3
#define MAP_FAILED ((void *)-1)
#define MS_ASYNC (1 << 0)
#define MS_SYNC (1 << 1)
#define MS_INVALIDATE (1 << 2)
#define \
mmap(start, length, prot, flags, fd, offset) \
_qdbm_mmap(start, length, prot, flags, fd, offset)
#define \
munmap(start, length) \
_qdbm_munmap(start, length)
#define \
msync(start, length, flags) \
_qdbm_msync(start, length, flags)
#define \
mflush(start, length, flags) \
_qdbm_msync(start, length, flags)
void *_qdbm_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
int _qdbm_munmap(void *start, size_t length);
int _qdbm_msync(const void *start, size_t length, int flags);
#else
#undef mflush
#define \
mflush(start, length, flags) \
(0)
#endif
/*************************************************************************************************
* for reentrant time routines
*************************************************************************************************/
struct tm *_qdbm_gmtime(const time_t *timep, struct tm *result);
struct tm *_qdbm_localtime(const time_t *timep, struct tm *result);
/*************************************************************************************************
* for systems without times
*************************************************************************************************/
#if defined(_SYS_MSVC_) || defined(_SYS_MINGW_)
#undef times
#undef sysconf
struct tms {
clock_t tms_utime;
clock_t tms_stime;
clock_t tms_cutime;
clock_t tms_cstime;
};
#define \
times(buf) \
_qdbm_times(buf)
#define \
sysconf(name) \
(CLOCKS_PER_SEC)
clock_t _qdbm_times(struct tms *buf);
#endif
/*************************************************************************************************
* for Win32
*************************************************************************************************/
#if defined(_SYS_MSVC_) || defined(_SYS_MINGW_)
#undef F_WRLCK
#undef F_RDLCK
#undef F_SETLK
#undef F_SETLKW
#undef fcntl
#undef ftruncate
#undef fsync
#undef mkdir
#undef rename
#define F_WRLCK 0
#define F_RDLCK 1
#define F_SETLK 0
#define F_SETLKW 1
struct flock {
int l_type;
int l_whence;
int l_start;
int l_len;
int l_pid;
};
#define \
fcntl(fd, cmd, lock) \
_qdbm_win32_fcntl(fd, cmd, lock)
#define \
ftruncate(fd, length) \
_chsize(fd, length)
#define \
fsync(fd) \
(0)
#define \
mkdir(pathname, mode) \
mkdir(pathname)
#define \
rename(oldpath, newpath) \
(unlink(newpath), rename(oldpath, newpath))
int _qdbm_win32_fcntl(int fd, int cmd, struct flock *lock);
#endif
#if defined(_SYS_MSVC_)
#undef S_ISDIR
#undef S_ISREG
#undef opendir
#undef closedir
#undef readdir
#define S_ISDIR(x) (x & _S_IFDIR)
#define S_ISREG(x) (x & _S_IFREG)
struct dirent {
char d_name[1024];
};
typedef struct {
HANDLE fh;
WIN32_FIND_DATA data;
struct dirent de;
int first;
} DIR;
#define \
opendir(name) \
_qdbm_win32_opendir(name)
#define \
closedir(dir) \
_qdbm_win32_closedir(dir)
#define \
readdir(dir) \
_qdbm_win32_readdir(dir)
DIR *_qdbm_win32_opendir(const char *name);
int _qdbm_win32_closedir(DIR *dir);
struct dirent *_qdbm_win32_readdir(DIR *dir);
#endif
/*************************************************************************************************
* for checking information of the system
*************************************************************************************************/
int _qdbm_vmemavail(size_t size);
/*************************************************************************************************
* for ZLIB
*************************************************************************************************/
enum {
_QDBM_ZMZLIB,
_QDBM_ZMRAW,
_QDBM_ZMGZIP
};
extern char *(*_qdbm_deflate)(const char *, int, int *, int);
extern char *(*_qdbm_inflate)(const char *, int, int *, int);
extern unsigned int (*_qdbm_getcrc)(const char *, int);
/*************************************************************************************************
* for LZO
*************************************************************************************************/
extern char *(*_qdbm_lzoencode)(const char *, int, int *);
extern char *(*_qdbm_lzodecode)(const char *, int, int *);
/*************************************************************************************************
* for BZIP2
*************************************************************************************************/
extern char *(*_qdbm_bzencode)(const char *, int, int *);
extern char *(*_qdbm_bzdecode)(const char *, int, int *);
/*************************************************************************************************
* for ICONV
*************************************************************************************************/
extern char *(*_qdbm_iconv)(const char *, int, const char *, const char *, int *, int *);
extern const char *(*_qdbm_encname)(const char *, int);
/*************************************************************************************************
* common settings
*************************************************************************************************/
#undef TRUE
#define TRUE 1
#undef FALSE
#define FALSE 0
#define sizeof(a) ((int)sizeof(a))
int _qdbm_dummyfunc(void);
#if defined(__cplusplus) /* export for C++ */
}
#endif
#endif /* duplication check */
/* END OF FILE */
|