annotate plugins/crazychat/util.h @ 12448:4266abdccb97

[gaim-migrate @ 14755] This should make win32 builds say perl is enabled in the about window. Maybe someone who knows more about how perl is enabled/disabled based on the existence of perl during install on win32 can make this more accurate? committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Sat, 10 Dec 2005 13:49:05 +0000
parents 8bcd4d4ccef6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11232
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
1 #ifndef __UTIL_H__
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
2 #define __UTIL_H__
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
3
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
4 #include <debug.h>
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
5
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
6 #define SET_TIME(x) \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
7 do { \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
8 assert(!gettimeofday((x), NULL)); \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
9 } while(0)
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
10
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
11 #define SET_TIMEOUT(timespec, given_timeout) /* timeout is in ms */ \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
12 do { \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
13 struct timeval* curr = (struct timeval*)(timespec); \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
14 unsigned int tout; \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
15 if (given_timeout > 100) { \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
16 tout = given_timeout; \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
17 } else { \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
18 tout = 100; \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
19 } \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
20 SET_TIME(curr); \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
21 curr->tv_sec += (tout / 1000); \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
22 curr->tv_usec /= 1000; /* set to ms */ \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
23 curr->tv_usec += (tout % 1000); \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
24 curr->tv_sec += (curr->tv_usec / 1000); \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
25 curr->tv_usec = (curr->tv_usec % 1000); \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
26 curr->tv_usec *= 1000000; \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
27 } while (0)
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
28
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
29 #endif
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
30
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
31 /* -- gcc specific vararg macro support ... but its so nice! -- */
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
32 #ifdef _DEBUG_
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
33 #define Debug(x, args...) \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
34 do { \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
35 printf(x, ## args); \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
36 gaim_debug(GAIM_DEBUG_INFO, "crazychat", x, ## args); \
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
37 } while (0)
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
38 #else
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
39 #define Debug(x, args...) do{}while(0)
8bcd4d4ccef6 [gaim-migrate @ 13372]
Charlie Stockman <chuckleberry>
parents:
diff changeset
40 #endif