File: compatibility.h

package info (click to toggle)
growl-for-linux 0.8.5-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 3,244 kB
  • sloc: sh: 4,121; ansic: 3,735; makefile: 74
file content (56 lines) | stat: -rw-r--r-- 862 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
52
53
54
55
56
#ifndef compatibility_h_
#define compatibility_h_

#include <stddef.h>
#include <stdlib.h>
#include <string.h>

#include "gol.h"
#include <gtk/gtk.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _WIN32

typedef char sockopt_t;
typedef int socklen_t;

# ifndef strncasecmp
#  define strncasecmp strnicmp
# endif

GOL_INLINE char*
strndup(const char* src, size_t n) {
  const size_t srclen = strlen(src);
  n = n < srclen ? n : srclen;
  char* ptr = (char*) malloc(n + 1);
  *(ptr + n) = 0;
  memcpy(ptr, src, n);
  return ptr;
}

#else // _WIN32

# define closesocket(x) close(x)

typedef int sockopt_t;

# ifndef SD_BOTH
#  define SD_BOTH SHUT_RDWR
# endif

#endif // _WIN32

#if !GTK_CHECK_VERSION(2, 20, 0)
// Workaround for GTK < 2.20
#  define gdk_screen_get_primary_monitor(GdkScreen) (0)
#endif

#ifdef __cplusplus
}
#endif

#endif // compatibility_h_