____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"00001 // ____ _ __ 00002 // / __ )____ _____ | | / /___ ___________ 00003 // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/ 00004 // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ ) 00005 // /_____/\____/____/ |__/|__/\__,_/_/ /____/ 00006 // 00007 // A futuristic real-time strategy game. 00008 // This file is part of Bos Wars. 00009 // 00011 // 00012 // (c) Copyright 1998-2008 by Lutz Sammer and Jimmy Salmon 00013 // 00014 // This program is free software; you can redistribute it and/or modify 00015 // it under the terms of the GNU General Public License as published by 00016 // the Free Software Foundation; only version 2 of the License. 00017 // 00018 // This program is distributed in the hope that it will be useful, 00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 // GNU General Public License for more details. 00022 // 00023 // You should have received a copy of the GNU General Public License 00024 // along with this program; if not, write to the Free Software 00025 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00026 // 02111-1307, USA. 00027 00028 #ifndef __UTIL_H__ 00029 #define __UTIL_H__ 00030 00032 00033 /*---------------------------------------------------------------------------- 00034 -- Random 00035 ----------------------------------------------------------------------------*/ 00036 00037 extern unsigned SyncRandSeed; 00038 00039 extern void InitSyncRand(void); 00040 extern int SyncRand(void); 00041 extern int SyncRand(int max); 00042 00043 /*---------------------------------------------------------------------------- 00044 -- Math 00045 ----------------------------------------------------------------------------*/ 00046 00048 #define MyRand() rand() 00049 00051 extern long isqrt(long num); 00052 00053 /*---------------------------------------------------------------------------- 00054 -- Strings 00055 ----------------------------------------------------------------------------*/ 00056 00057 #include <string.h> 00058 00059 #if !defined(_MSC_VER) || _MSC_VER < 1400 00060 #define _TRUNCATE ((size_t)-1) 00061 extern unsigned int strcpy_s(char *dst, size_t dstsize, const char *src); 00062 extern unsigned int strncpy_s(char *dst, size_t dstsize, const char *src, size_t count); 00063 extern unsigned int strcat_s(char *dst, size_t dstsize, const char *src); 00064 extern int sprintf_s(char *dest, size_t destSize, const char *format, ...); 00065 #endif 00066 00067 inline char *new_strdup(const char *str) 00068 { 00069 int len = strlen(str) + 1; 00070 char *newstr = new char[len]; 00071 strcpy_s(newstr, len, str); 00072 return newstr; 00073 } 00074 00076 extern char *strdcat(const char *l, const char *r); 00078 extern char *strdcat3(const char *l, const char *m, const char *r); 00079 00080 #ifndef HAVE_STRCASESTR 00082 extern char *strcasestr(const char *str, const char *substr); 00083 #endif // !HAVE_STRCASESTR 00084 00085 #ifndef HAVE_STRNLEN 00087 extern size_t strnlen(const char *str, size_t strsize); 00088 #endif // !HAVE_STRNLEN 00089 00090 /*---------------------------------------------------------------------------- 00091 -- Clipboard 00092 ----------------------------------------------------------------------------*/ 00093 00094 #include <string> 00095 00096 int GetClipboard(std::string &str); 00097 00098 /*---------------------------------------------------------------------------- 00099 -- UTF8 00100 ----------------------------------------------------------------------------*/ 00101 00102 int UTF8GetNext(const std::string &text, int curpos); 00103 int UTF8GetPrev(const std::string &text, int curpos); 00104 00106 00107 #endif /* __UTIL_H__ */
1.5.6