File: crn_platform.cpp

package info (click to toggle)
crunch-dxtc 0.55.5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,624 kB
  • sloc: cpp: 64,979; ansic: 633; python: 321; makefile: 116
file content (51 lines) | stat: -rw-r--r-- 980 bytes parent folder | download | duplicates (2)
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
// 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

#if !defined(_WIN32)
char* crnlib_strnlwr(char* p, size_t n) {
  char* q = p;
  for (size_t i = 0; i < n && *q; i++) {
    char c = *q;
    *q++ = tolower(c);
  }
  return p;
}

char* crnlib_strnupr(char* p, size_t n) {
  char* q = p;
  for (size_t i = 0; i < n && *q; i++) {
    char c = *q;
    *q++ = toupper(c);
  }
  return p;
}
#endif

void crnlib_debug_break(void) {
  CRNLIB_BREAKPOINT
}

#if CRNLIB_USE_WIN32_API
#include "crn_winhdr.h"

bool crnlib_is_debugger_present(void) {
  return IsDebuggerPresent() != 0;
}

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