48 lines
1.0 KiB
C++
48 lines
1.0 KiB
C++
// Copyright (C) 2007 EQ2EMulator Development Team - GNU GPL v3+ License
|
|
|
|
#pragma once
|
|
|
|
#include <unistd.h>
|
|
#include <thread>
|
|
#include <chrono>
|
|
#include <algorithm>
|
|
#include <cctype>
|
|
#include <cstring>
|
|
|
|
#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
|
|
#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP {0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __LOCK_INITIALIZER}
|
|
#endif
|
|
|
|
typedef int SOCKET;
|
|
|
|
// Cross-platform sleep function - pauses execution for specified milliseconds
|
|
void Sleep(unsigned int x)
|
|
{
|
|
if (x > 0) {
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(x));
|
|
}
|
|
}
|
|
|
|
// Converts string to uppercase in-place - modifies original string and returns pointer
|
|
char* strupr(char* tmp)
|
|
{
|
|
if (!tmp) return tmp;
|
|
|
|
int l = strlen(tmp);
|
|
for (int x = 0; x < l; x++) {
|
|
tmp[x] = toupper(tmp[x]);
|
|
}
|
|
return tmp;
|
|
}
|
|
|
|
// Converts string to lowercase in-place - modifies original string and returns pointer
|
|
char* strlwr(char* tmp)
|
|
{
|
|
if (!tmp) return tmp;
|
|
|
|
int l = strlen(tmp);
|
|
for (int x = 0; x < l; x++) {
|
|
tmp[x] = tolower(tmp[x]);
|
|
}
|
|
return tmp;
|
|
} |