GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: a tiny graphical app kit for ruby
Homepage: http://code.whytheluckystiff.net/shoes
Clone URL: git://github.com/why/shoes.git
shoes / shoes / internal.c
100644 47 lines (37 sloc) 0.793 kb
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
//
// shoes/internal.c
// Internal debug functions.
//
#ifdef SHOES_WIN32
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>
#include <windows.h>
 
void odprintf(const char *format, ...)
{
  char buf[4096], *p = buf;
  va_list args;
  int n;
 
  va_start(args, format);
  n = _vsnprintf(p, sizeof buf - 3, format, args); // buf-3 is room for CR/LF/NUL
  va_end(args);
 
  p += (n < 0) ? sizeof buf - 3 : n;
 
  while(p > buf && isspace(p[-1]))
    *--p = '\0';
 
  *p++ = '\r';
  *p++ = '\n';
  *p = '\0';
 
  OutputDebugString(buf);
}
 
int
shoes_snprintf(char* str, size_t size, const char* format, ...)
{
  size_t count;
  va_list args;
 
  va_start(args, format);
  count = _vscprintf(format, args);
  _vsnprintf(str, size, format, args);
  va_end(args);
 
  return count;
}
#endif