File: common.h

package info (click to toggle)
tango 10.0.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 89,484 kB
  • sloc: cpp: 201,245; sh: 1,645; python: 953; java: 800; perl: 467; javascript: 447; xml: 325; makefile: 269; sql: 72; ruby: 24
file content (65 lines) | stat: -rw-r--r-- 1,732 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
57
58
59
60
61
62
63
64
65
#ifndef TANGO_DB_COMMON_H
#define TANGO_DB_COMMON_H

#include <cmake_config.h>

#include <tango/tango.h>
#include <mysql.h>
#include "update_starter.h"

#if !defined(LIBMARIADB) && !defined(MARIADB_BASE_VERSION)
#if MYSQL_VERSION_ID >= 80001 && MYSQL_VERSION_ID != 80002
typedef bool my_bool;
#endif
#endif

#ifdef _TG_WINDOWS_
#include <ws2tcpip.h>
#include <windows.h>
static inline void sleep(DWORD seconds)
{
    Sleep(seconds * 1000);
}
#else
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#endif

#define DB_SQLError              "DB_SQLError"
#define DB_IncorrectArguments    "DB_IncorrectArguments"
#define DB_IncorrectDeviceName   "DB_IncorrectDeviceName"
#define DB_IncorrectServerName   "DB_IncorrectServerName"
#define DB_DeviceNotDefined      "DB_DeviceNotDefined"
#define DB_AliasNotDefined       "DB_AliasNotDefined"
#define DB_NoFreeMySQLConnection "DB_NoFreeMySQLConnection"
#define DB_MySQLLibNotThreadSafe "DB_MySQLLibNotThreadSafe"
#define DB_ParseStringError      "DB_ParseStringError"

#define STARTER_DEVNAME_DOMAIN "tango"
#define STARTER_DEVNAME_FAMILY "/admin/"

#define	DEFAULT_CONN_POOL_SIZE		20

//	Define time measuremnt type (depends on OS)
#ifndef WIN32

#	define	TimeVal	struct timeval
#	define	GetTime(t)	gettimeofday(&t, NULL);
#	define	Elapsed(before, after)	\
		1000.0*(after.tv_sec-before.tv_sec) + \
		((double)after.tv_usec-before.tv_usec) / 1000

#else

static LARGE_INTEGER	cpu_freq;
#	define	TimeVal	LARGE_INTEGER
#	define	GetTime(t)	w_gettimeofday(&t);
#	define	Elapsed(before, after)		\
		(cpu_freq.QuadPart==0) ? 0.0 :	\
			(double) (after.QuadPart - before.QuadPart)/cpu_freq.QuadPart * 1000;

#endif	/*	WIN32		*/

#endif //TANGO_DB_COMMON_H