EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
eve-compat.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PRId8   "hhd"
 
#define PRIi8   "hhi"
 
#define PRIo8   "hho"
 
#define PRIu8   "hhu"
 
#define PRIx8   "hhx"
 
#define PRIX8   "hhX"
 
#define PRId16   "hd"
 
#define PRIi16   "hi"
 
#define PRIo16   "ho"
 
#define PRIu16   "hu"
 
#define PRIx16   "hx"
 
#define PRIX16   "hX"
 
#define PRId32   "I32d"
 
#define PRIi32   "I32i"
 
#define PRIo32   "I32o"
 
#define PRIu32   "I32u"
 
#define PRIx32   "I32x"
 
#define PRIX32   "I32X"
 
#define PRId64   "I64d"
 
#define PRIi64   "I64i"
 
#define PRIo64   "I64o"
 
#define PRIu64   "I64u"
 
#define PRIx64   "I64x"
 
#define PRIX64   "I64X"
 
#define SCNd8   "hhd"
 
#define SCNi8   "hhi"
 
#define SCNo8   "hho"
 
#define SCNu8   "hhu"
 
#define SCNx8   "hhx"
 
#define SCNd16   "hd"
 
#define SCNi16   "hi"
 
#define SCNo16   "ho"
 
#define SCNu16   "hu"
 
#define SCNx16   "hx"
 
#define SCNd32   "I32d"
 
#define SCNi32   "I32i"
 
#define SCNo32   "I32o"
 
#define SCNu32   "I32u"
 
#define SCNx32   "I32x"
 
#define SCNd64   "I64d"
 
#define SCNi64   "I64i"
 
#define SCNo64   "I64o"
 
#define SCNu64   "I64u"
 
#define SCNx64   "I64x"
 
#define INVALID_SOCKET   -1
 
#define SOCKET_ERROR   -1
 
#define MSG_NOSIGNAL   0
 
#define asinh   boost::math::asinh
 
#define va_copy(a, b)   ::memcpy( &( a ), &( b ), sizeof( va_list ) )
 
#define snprintf   _snprintf
 
#define vsnprintf   _vsnprintf
 
#define strtoll   _strtoi64
 
#define strtoull   _strtoui64
 
#define strdup   _strdup
 
#define strcasecmp   _stricmp
 
#define strncasecmp   _strnicmp
 

Typedefs

typedef signed __int8 int8
 
typedef unsigned __int8 uint8
 
typedef signed __int16 int16
 
typedef unsigned __int16 uint16
 
typedef signed __int32 int32
 
typedef unsigned __int32 uint32
 
typedef signed __int64 int64
 
typedef int SOCKET
 

Functions

void Sleep (uint32 x)
 
uint32 GetTickCount ()
 
int CreateDirectory (const char *name, void *)
 
int asprintf (char **strp, const char *fmt,...)
 
int vasprintf (char **strp, const char *fmt, va_list ap)
 
std::string sprintf (const char *fmt,...)
 sprintf for std::string. More...
 
std::string vsprintf (const char *fmt, va_list ap)
 vsprintf for std::string. More...
 
int sprintf (std::string &str, const char *fmt,...)
 sprintf for std::string. More...
 
int vsprintf (std::string &str, const char *fmt, va_list ap)
 vsprintf for std::string. More...
 
float strtof (const char *nptr, char **endptr)
 
tm * localtime_r (const time_t *timep, tm *result)
 

Macro Definition Documentation

#define asinh   boost::math::asinh

Definition at line 145 of file eve-compat.h.

Referenced by TargetManager::TimeToLock().

#define INVALID_SOCKET   -1

Definition at line 129 of file eve-compat.h.

Referenced by Socket::accept(), and Socket::Socket().

#define MSG_NOSIGNAL   0

Definition at line 137 of file eve-compat.h.

Referenced by TCPConnection::SendData().

#define PRId16   "hd"

Definition at line 68 of file eve-compat.h.

#define PRId32   "I32d"

Definition at line 75 of file eve-compat.h.

#define PRId64   "I64d"

Definition at line 82 of file eve-compat.h.

#define PRId8   "hhd"

Definition at line 61 of file eve-compat.h.

#define PRIi16   "hi"

Definition at line 69 of file eve-compat.h.

#define PRIi32   "I32i"

Definition at line 76 of file eve-compat.h.

#define PRIi64   "I64i"

Definition at line 83 of file eve-compat.h.

Referenced by CharacterDB::SaveCorpData(), and PyDumpVisitor::VisitLong().

#define PRIi8   "hhi"

Definition at line 62 of file eve-compat.h.

#define PRIo16   "ho"

Definition at line 70 of file eve-compat.h.

#define PRIo32   "I32o"

Definition at line 77 of file eve-compat.h.

#define PRIo64   "I64o"

Definition at line 84 of file eve-compat.h.

#define PRIo8   "hho"

Definition at line 63 of file eve-compat.h.

#define PRIu16   "hu"

Definition at line 71 of file eve-compat.h.

#define PRIu32   "I32u"

Definition at line 78 of file eve-compat.h.

#define PRIu8   "hhu"

Definition at line 64 of file eve-compat.h.

#define PRIx16   "hx"

Definition at line 72 of file eve-compat.h.

#define PRIX16   "hX"

Definition at line 73 of file eve-compat.h.

#define PRIx32   "I32x"

Definition at line 79 of file eve-compat.h.

#define PRIX32   "I32X"

Definition at line 80 of file eve-compat.h.

#define PRIx64   "I64x"

Definition at line 86 of file eve-compat.h.

#define PRIX64   "I64X"

Definition at line 87 of file eve-compat.h.

#define PRIx8   "hhx"

Definition at line 65 of file eve-compat.h.

#define PRIX8   "hhX"

Definition at line 66 of file eve-compat.h.

#define SCNd16   "hd"

Definition at line 95 of file eve-compat.h.

#define SCNd32   "I32d"

Definition at line 101 of file eve-compat.h.

#define SCNd64   "I64d"

Definition at line 107 of file eve-compat.h.

#define SCNd8   "hhd"

Definition at line 89 of file eve-compat.h.

#define SCNi16   "hi"

Definition at line 96 of file eve-compat.h.

#define SCNi32   "I32i"

Definition at line 102 of file eve-compat.h.

#define SCNi64   "I64i"

Definition at line 108 of file eve-compat.h.

#define SCNi8   "hhi"

Definition at line 90 of file eve-compat.h.

#define SCNo16   "ho"

Definition at line 97 of file eve-compat.h.

#define SCNo32   "I32o"

Definition at line 103 of file eve-compat.h.

#define SCNo64   "I64o"

Definition at line 109 of file eve-compat.h.

#define SCNo8   "hho"

Definition at line 91 of file eve-compat.h.

#define SCNu16   "hu"

Definition at line 98 of file eve-compat.h.

#define SCNu32   "I32u"

Definition at line 104 of file eve-compat.h.

#define SCNu64   "I64u"

Definition at line 110 of file eve-compat.h.

Referenced by TimeToString().

#define SCNu8   "hhu"

Definition at line 92 of file eve-compat.h.

#define SCNx16   "hx"

Definition at line 99 of file eve-compat.h.

#define SCNx32   "I32x"

Definition at line 105 of file eve-compat.h.

#define SCNx64   "I64x"

Definition at line 111 of file eve-compat.h.

#define SCNx8   "hhx"

Definition at line 93 of file eve-compat.h.

#define snprintf   _snprintf

Definition at line 184 of file eve-compat.h.

Referenced by Client::Board(), Client::BoardShip(), build_hex_line(), Command_attrlist(), Command_autostop(), Command_beltlist(), Command_bindList(), Command_bubblelist(), Command_bubbletrack(), Command_bubblewarp(), Command_cargo(), Command_commandlist(), Command_destinyvars(), Command_entityspawn(), Command_fleetboost(), Command_fleetinvite(), Command_getposition(), Command_halt(), Command_inventory(), Command_list(), Command_location(), Command_players(), Command_runtest(), Command_savedungeon(), Command_secstatus(), Command_shipdna(), Command_shipinventory(), Command_shipvars(), Command_showall(), Command_showsession(), Command_siglist(), Command_skilllist(), Command_status(), Command_targlist(), Command_tr(), Command_track(), Command_warpto(), TCPConnection::Connect(), DBcore::Connect(), Client::Eject(), TCPConnection::GetAddress(), BaseRowsetReader::iterator::GetAsString(), PyBoundObject::GetBindStr(), itoa(), ListToINString(), UnmarshalStream::LoadStringTable(), log_messageVA(), Client::MoveToLocation(), BaseTCPServer::Open(), ClassDecodeGenerator::ProcessDictInline(), ClassEncodeGenerator::ProcessDictInline(), ClassDecodeGenerator::ProcessDictInt(), ClassEncodeGenerator::ProcessDictInt(), ClassDecodeGenerator::ProcessDictRaw(), ClassEncodeGenerator::ProcessDictRaw(), ClassDecodeGenerator::ProcessDictStr(), ClassEncodeGenerator::ProcessDictStr(), ClassDecodeGenerator::ProcessListInline(), ClassEncodeGenerator::ProcessListInline(), ClassDecodeGenerator::ProcessListInt(), ClassEncodeGenerator::ProcessListInt(), ClassDecodeGenerator::ProcessListLong(), ClassEncodeGenerator::ProcessListLong(), ClassDecodeGenerator::ProcessListStr(), ClassEncodeGenerator::ProcessListStr(), ClassDecodeGenerator::ProcessObjectInline(), ClassEncodeGenerator::ProcessObjectInline(), ClassDecodeGenerator::ProcessStringInline(), ClassDecodeGenerator::ProcessSubStreamInline(), ClassEncodeGenerator::ProcessSubStreamInline(), ClassDecodeGenerator::ProcessSubStructInline(), ClassEncodeGenerator::ProcessSubStructInline(), ClassDecodeGenerator::ProcessTokenInline(), ClassDecodeGenerator::ProcessTupleInline(), ClassEncodeGenerator::ProcessTupleInline(), ClassDecodeGenerator::ProcessWStringInline(), EVETCPConnection::RecvData(), TCPConnection::RecvData(), ResolveIP(), CharacterDB::SavePausedSkillQueue(), CharacterDB::SaveSkillQueue(), TCPConnection::SendData(), NewLog::SetLogfileDefault(), EvilNumber::to_str(), Client::UpdateNewShip(), Client::WarpIn(), and Client::WarpOut().

#define SOCKET_ERROR   -1
#define strcasecmp   _stricmp

Definition at line 262 of file eve-compat.h.

Referenced by generic_createitem(), load_log_settings(), and str2< bool >().

#define strdup   _strdup

Definition at line 258 of file eve-compat.h.

Referenced by CheckIPs(), and EVE_NIDS_main().

#define strncasecmp   _strnicmp

Definition at line 266 of file eve-compat.h.

#define strtoll   _strtoi64

Definition at line 243 of file eve-compat.h.

Referenced by DBResultRow::GetInt64().

#define strtoull   _strtoui64

Definition at line 247 of file eve-compat.h.

Referenced by APICharacterManager::_CharacterSheet().

#define va_copy (   a,
 
)    ::memcpy( &( a ), &( b ), sizeof( va_list ) )

Definition at line 177 of file eve-compat.h.

Referenced by NewLog::PrintVa().

#define vsnprintf   _vsnprintf

Definition at line 188 of file eve-compat.h.

Referenced by log_messageVA(), DBcore::RunQuery(), vasprintf(), and vsprintf().

Typedef Documentation

typedef signed __int16 int16

Definition at line 47 of file eve-compat.h.

typedef signed __int32 int32

Definition at line 49 of file eve-compat.h.

typedef signed __int64 int64

Definition at line 51 of file eve-compat.h.

typedef signed __int8 int8

Definition at line 45 of file eve-compat.h.

typedef int SOCKET

Definition at line 127 of file eve-compat.h.

typedef unsigned __int16 uint16

Definition at line 48 of file eve-compat.h.

typedef unsigned __int32 uint32

Definition at line 50 of file eve-compat.h.

typedef unsigned __int8 uint8

Definition at line 46 of file eve-compat.h.

Function Documentation

int asprintf ( char **  strp,
const char *  fmt,
  ... 
)

Definition at line 57 of file eve-compat.cpp.

References vasprintf().

58 {
59  va_list ap;
60 
61  va_start( ap, fmt );
62  int res = ::vasprintf( strp, fmt, ap );
63  va_end( ap );
64 
65  return res;
66 }
int vasprintf(char **strp, const char *fmt, va_list ap)
Definition: eve-compat.cpp:70

Here is the call graph for this function:

int CreateDirectory ( const char *  name,
void *   
)

Definition at line 46 of file eve-compat.cpp.

Referenced by ImageServer::ImageServer(), PyCallable_Make_InnerDispatcher(), and StuffExtract().

47 {
48  // Create the directory with mode 0755
49  return 0 == ::mkdir( name,
50  S_IRUSR | S_IWUSR | S_IXUSR
51  | S_IRGRP | S_IXGRP
52  | S_IROTH | S_IXOTH );
53 }

Here is the caller graph for this function:

uint32 GetTickCount ( )

Definition at line 39 of file eve-compat.cpp.

Referenced by main(), TCPConnection::TCPConnectionLoop(), and BaseTCPServer::TCPServerLoop().

40 {
41  struct timespec ts;
42  ::clock_gettime(CLOCK_MONOTONIC, &ts);
43  return (ts.tv_sec * 1000) + (ts.tv_nsec / 1000000);
44 }

Here is the caller graph for this function:

tm* localtime_r ( const time_t *  timep,
tm *  result 
)

Definition at line 184 of file eve-compat.cpp.

Referenced by log_messageVA(), NewLog::PrintTime(), and NewLog::SetLogfileDefault().

185 {
186 # ifdef HAVE_LOCALTIME_S
187  const errno_t err = ::localtime_s( result, timep );
188  if( 0 != err )
189  {
190  errno = err;
191  return NULL;
192  }
193 # else /* !HAVE_LOCALTIME_S */
194  /* This is quite dangerous stuff (not necessarily
195  thread-safe), but what can we do? Also,
196  there is a chance that localtime will use
197  thread-specific memory (MS's localtime does that). */
198  ::memcpy( result, ::localtime( timep ), sizeof( tm ) );
199 # endif /* !HAVE_LOCALTIME_S */
200 
201  return result;
202 }

Here is the caller graph for this function:

void Sleep ( uint32  x)

Definition at line 32 of file eve-compat.cpp.

Referenced by main(), MRMutex::ReadLock(), Threading::RunLoop(), TCPConnection::TCPConnectionLoop(), BaseTCPServer::TCPServerLoop(), and MRMutex::WriteLock().

33 {
34  if( 0 < x )
35  ::usleep( 1000 * x );
36 }

Here is the caller graph for this function:

std::string sprintf ( const char *  fmt,
  ... 
)

sprintf for std::string.

Parameters
[in]fmtThe format string.
[in]...Arguments.
Returns
The printed string.

Definition at line 106 of file eve-compat.cpp.

References vsprintf().

Referenced by adres(), GetMTimeTillNow(), GetUTimeTillNow(), MakeIntString(), and MakeIntStringNoZero().

107 {
108  va_list ap;
109  va_start( ap, fmt );
110 
111  // The string buffer
112  std::string str;
113  // Print into the buffer
114  int code = ::vsprintf( str, fmt, ap );
115  assert( 0 <= code );
116 
117  va_end( ap );
118 
119  return str;
120 }
std::string vsprintf(const char *fmt, va_list ap)
vsprintf for std::string.
Definition: eve-compat.cpp:122

Here is the call graph for this function:

Here is the caller graph for this function:

int sprintf ( std::string &  str,
const char *  fmt,
  ... 
)

sprintf for std::string.

Parameters
[out]strWhere to store the result.
[in]fmtThe format string.
[in]...Arguments.
Returns
A value returned by vsprintf.

Definition at line 133 of file eve-compat.cpp.

References vsprintf().

134 {
135  va_list ap;
136 
137  va_start( ap, fmt );
138  int code = ::vsprintf( str, fmt, ap );
139  va_end( ap );
140 
141  return code;
142 }
std::string vsprintf(const char *fmt, va_list ap)
vsprintf for std::string.
Definition: eve-compat.cpp:122

Here is the call graph for this function:

float strtof ( const char *  nptr,
char **  endptr 
)

Definition at line 176 of file eve-compat.cpp.

Referenced by DBResultRow::GetFloat().

177 {
178  // Implement using strtod
179  return (float)::strtod( nptr, endptr );
180 }

Here is the caller graph for this function:

int vasprintf ( char **  strp,
const char *  fmt,
va_list  ap 
)

Definition at line 70 of file eve-compat.cpp.

References vsnprintf.

Referenced by PyPfxVisitor::_pfxExtend(), asprintf(), CustomError::CustomError(), DBcore::RunQuery(), DBcore::RunQueryLID(), Client::SelfChatMessage(), Client::SelfEveMail(), Client::SendErrorMsg(), Client::SendInfoModalMsg(), and Client::SendNotifyMsg().

71 {
72  // Return code
73  int code;
74  // Size of the buffer (doubled each cycle)
75  size_t size = 0x40;
76 
77  // No buffer yet
78  *strp = NULL;
79 
80  do
81  {
82  // Reallocate the buffer
83  *strp = (char*)::realloc( *strp, size );
84 
85  // Try to print into the buffer
86  code = ::vsnprintf( *strp, size, fmt, ap );
87  // Check for truncation
88  if( size <= code )
89  // Output truncated
90  code = -1;
91 
92  // Double the size of buffer
93  size <<= 1;
94  } while( 0 > code );
95 
96  // Reallocate to save memory
97  *strp = (char*)::realloc( *strp, code + 1 );
98  // Terminate the string
99  (*strp)[code] = '\0';
100 
101  // Return the code
102  return code;
103 }
#define vsnprintf
Definition: eve-compat.h:188

Here is the caller graph for this function:

std::string vsprintf ( const char *  fmt,
va_list  ap 
)

vsprintf for std::string.

Parameters
[in]fmtThe format string.
[in]apArguments.
Returns
The printed string.

Definition at line 122 of file eve-compat.cpp.

References vsprintf().

Referenced by sprintf(), and vsprintf().

123 {
124  // The string buffer
125  std::string str;
126  // Print into the buffer
127  int code = ::vsprintf( str, fmt, ap );
128  assert( 0 <= code );
129 
130  return str;
131 }
std::string vsprintf(const char *fmt, va_list ap)
vsprintf for std::string.
Definition: eve-compat.cpp:122

Here is the call graph for this function:

Here is the caller graph for this function:

int vsprintf ( std::string &  str,
const char *  fmt,
va_list  ap 
)

vsprintf for std::string.

Parameters
[out]strWhere to store the result.
[in]fmtThe format string.
[in]apArguments.
Returns
A value returned by vsnprintf.

Definition at line 144 of file eve-compat.cpp.

References vsnprintf.

145 {
146  // Return code
147  int code;
148  // Offset within the string
149  size_t offset = str.length();
150  // Size of the buffer
151  size_t size = 0x40;
152 
153  do
154  {
155  // Resize the buffer
156  str.resize( offset + size );
157 
158  // Try to print into the buffer
159  code = ::vsnprintf( &str[offset], size, fmt, ap );
160  // Check for truncation
161  if( size <= code )
162  // Output truncated
163  code = -1;
164 
165  // Double the size of the buffer
166  size <<= 1;
167  } while( 0 > code );
168 
169  // Resize to save memory
170  str.resize( offset + code );
171  // Return the code
172  return code;
173 }
#define vsnprintf
Definition: eve-compat.h:188