v1.03 prerelease - Full Linux port of crnlib/crunch, in progress - still more testing to do, and some cmd line options (such as -timestamp) don't work under linux yet, but the core stuff (compression/decompression/transcoding) should work fine and performance under Linux is comparable to Windows. The 3 examples haven't been ported yet.
This commit is contained in:
+78
-5
@@ -1,6 +1,73 @@
|
||||
// File: crn_platform.cpp
|
||||
// See Copyright Notice and license at the end of inc/crnlib.h
|
||||
#include "crn_core.h"
|
||||
|
||||
#if CRNLIB_USE_WIN32_API
|
||||
#include "crn_winhdr.h"
|
||||
#endif
|
||||
#ifndef _MSC_VER
|
||||
int sprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, ...)
|
||||
{
|
||||
if (!sizeOfBuffer)
|
||||
return 0;
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
int c = vsnprintf(buffer, sizeOfBuffer, format, args);
|
||||
va_end(args);
|
||||
|
||||
buffer[sizeOfBuffer - 1] = '\0';
|
||||
|
||||
if (c < 0)
|
||||
return sizeOfBuffer - 1;
|
||||
|
||||
return CRNLIB_MIN(c, (int)sizeOfBuffer - 1);
|
||||
}
|
||||
|
||||
int vsprintf_s(char *buffer, size_t sizeOfBuffer, const char *format, va_list args)
|
||||
{
|
||||
if (!sizeOfBuffer)
|
||||
return 0;
|
||||
|
||||
int c = vsnprintf(buffer, sizeOfBuffer, format, args);
|
||||
|
||||
buffer[sizeOfBuffer - 1] = '\0';
|
||||
|
||||
if (c < 0)
|
||||
return sizeOfBuffer - 1;
|
||||
|
||||
return CRNLIB_MIN(c, (int)sizeOfBuffer - 1);
|
||||
}
|
||||
|
||||
char* strlwr(char* p)
|
||||
{
|
||||
char *q = p;
|
||||
while (*q)
|
||||
{
|
||||
char c = *q;
|
||||
*q++ = tolower(c);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
char* strupr(char *p)
|
||||
{
|
||||
char *q = p;
|
||||
while (*q)
|
||||
{
|
||||
char c = *q;
|
||||
*q++ = toupper(c);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
#endif // __GNUC__
|
||||
|
||||
void crnlib_debug_break(void)
|
||||
{
|
||||
CRNLIB_BREAKPOINT
|
||||
}
|
||||
|
||||
#if CRNLIB_USE_WIN32_API
|
||||
#include "crn_winhdr.h"
|
||||
|
||||
bool crnlib_is_debugger_present(void)
|
||||
@@ -8,12 +75,18 @@ bool crnlib_is_debugger_present(void)
|
||||
return IsDebuggerPresent() != 0;
|
||||
}
|
||||
|
||||
void crnlib_debug_break(void)
|
||||
{
|
||||
DebugBreak();
|
||||
}
|
||||
|
||||
void crnlib_output_debug_string(const char* p)
|
||||
{
|
||||
OutputDebugStringA(p);
|
||||
}
|
||||
#else
|
||||
bool crnlib_is_debugger_present(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void crnlib_output_debug_string(const char* p)
|
||||
{
|
||||
puts(p);
|
||||
}
|
||||
#endif // CRNLIB_USE_WIN32_API
|
||||
|
||||
Reference in New Issue
Block a user