~ubuntu-branches/ubuntu/saucy/stalonetray/saucy

« back to all changes in this revision

Viewing changes to src/common.h

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2009-10-10 02:05:20 UTC
  • mfrom: (1.1.7 upstream) (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091010020520-adj6s9i1ujpvzapo
Tags: 0.8.0~beta1-1
* New upstream release
* bump Standards-Version to 3.8.3
* Remove Torsten from Uploaders as requested

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#define MIN_ICON_SIZE 16
20
20
/* Default KDE icon size */
21
21
#define KDE_ICON_SIZE 22
 
22
/* Number of time icon is allowed to change its size after which
 
23
 * stalonetray gives up */
 
24
#define ICON_SIZE_RESETS_THRESHOLD 2
22
25
 
23
26
/* Meaningful names for return values */
24
27
#define SUCCESS 1
25
28
#define FAILURE 0
26
29
 
 
30
/* Simple macro to return status and log it if necessary */
 
31
#define RETURN_STATUS(rc) do { \
 
32
        LOG_TRACE(("status = %s\n", ((rc) == SUCCESS ? "SUCCESS" : "FAILURE"))); \
 
33
        return rc; \
 
34
} while(0)
 
35
 
27
36
/* Meaningful names for return values of icon mass-operations */
28
37
#define MATCH 1
29
38
#define NO_MATCH 0
30
39
 
 
40
/* Simple macro to return mass-op status and log it if necessary */
 
41
#define RETURN_MATCH(rc) do { \
 
42
        LOG_TRACE(("status = %s\n", rc == MATCH : "MATCH" : "NO_MATCH")); \
 
43
        return rc; \
 
44
} while(0)
 
45
 
 
46
/* Meaningful names for return values of icon mass-operations */
 
47
#define MATCH 1
31
48
/* Portable macro for function name */
32
49
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
33
50
        #define __FUNC__ __func__
37
54
        #define __FUNC__ "unknown"
38
55
#endif
39
56
 
40
 
/* Print a error message */
41
 
#ifdef DEBUG
42
 
        #define ERR(message)    DBG(0, message)
43
 
#else
44
 
        #define ERR(message)    print_message_to_stderr message
45
 
#endif
46
 
 
 
57
/* DIE */
 
58
#define DIEDIE() exit(-1)
47
59
/* Print a message and... DIE */
48
 
#define DIE(message)            do { ERR(message); exit(-1); } while(0)
49
 
 
50
 
/* WARNING: feed following macro only with 
51
 
 * side-effects-free expressions */
52
 
 
 
60
#define DIE(message) do { LOG_ERROR(message); DIEDIE(); } while(0)
 
61
/* Log OOM condition */
 
62
#define LOG_ERR_IE(message) do { \
 
63
        LOG_ERROR(("Internal error, please report to maintaner (see AUTHORS)\n")); \
 
64
        LOG_ERROR(message); \
 
65
} while(0);
 
66
/* DIE on internal error */
 
67
#define DIE_IE(message) do { LOG_ERR_IE(message); DIEDIE(); } while(0)
 
68
/* Log OOM condition */
 
69
#define LOG_ERR_OOM(message) do { \
 
70
        LOG_ERROR(("Out of memory\n")); \
 
71
        LOG_ERROR(message); \
 
72
} while(0);
 
73
/* DIE on OOM error */
 
74
#define DIE_OOM(message) do { LOG_ERR_OOM(message); DIEDIE(); } while(0)
 
75
 
 
76
/*** WARNING: feed following macros only with side-effects-free expressions ***/
53
77
/* Get a value within target interval */
54
78
#define cutoff(tgt,min,max) (tgt) < (min) ? (min) : ((tgt) > (max) ? max : tgt)
55
 
 
56
79
/* Update value to fit into target interval */
57
80
#define val_range(tgt,min,max) (tgt) = cutoff(tgt,min,max)
58
81