Gammu internals  1.38.0
gammu-misc.h
Go to the documentation of this file.
1 
7 #ifndef __gammu_misc_h
8 #define __gammu_misc_h
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 
14 #ifdef WIN32
15 # define WIN32_LEAN_AND_MEAN
16 # include <windows.h>
17 #endif
18 
19 #include <stdio.h>
20 #include <gammu-file.h>
21 #include <gammu-config.h>
22 #if defined(HAVE_UNISTD_H)
23 # include <unistd.h>
24 #endif
25 
35 size_t GetLine(FILE * File, char *Line, int count);
36 
40 const char *GetGammuVersion(void);
41 
45 const char *GetCompiler(void);
46 
50 const char *GetOS(void);
51 
55 const char *GetGammuLocalePath(void);
56 
65 extern void GSM_InitLocales(const char *path);
66 
67 #undef MAX
68 #define MAX(a,b) ((a)>(b) ? (a) : (b))
69 #undef MIN
70 #define MIN(a,b) ((a)<(b) ? (a) : (b))
71 
72 #ifdef WIN32
73 # if !defined(HAVE_UNISTD_H) || defined(__MINGW32__)
74 # define sleep(x) Sleep((x) * 1000)
75 # define usleep(x) Sleep(((x) < 1000) ? 1 : ((x) / 1000))
76 # endif /* HAVE_UNISTD_H */
77 #endif
78 
79 /* Easy check for GCC */
80 #if defined __GNUC__ && defined __GNUC_MINOR__
81 # define GSM_GNUC_PREREQ(maj, min) \
82  ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
83 #else
84 # define GSM_GNUC_PREREQ(maj, min) 0
85 #endif
86 
87 /* Various hints for compilers */
88 #if GSM_GNUC_PREREQ (2,8) || defined(__clang__)
89 #define PRINTF_STYLE(f, a) __attribute__ ((format(__printf__, f, a)))
90 #define SCANF_STYLE(f, a) __attribute__ ((format(__scanf__, f, a)))
91 #else
92 #define PRINTF_STYLE(f, a)
93 #define SCANF_STYLE(f, a)
94 #endif
95 
96 #if GSM_GNUC_PREREQ (3,4) || defined(__clang__)
97 #define WARNUNUSED __attribute__ ((__warn_unused_result__))
98 #else
99 #define WARNUNUSED
100 #endif
101 
102 #if GSM_GNUC_PREREQ (3,1) || defined(__clang__)
103 #define UNUSED __attribute__ ((unused))
104 #else
105 #define UNUSED
106 #endif
107 
108 #if defined(__GNUC__) || defined(__clang__)
109 #define NORETURN __attribute__((__noreturn__))
110 #else
111 #define NORETURN
112 #endif
113 
114 /* Working snprintf on MSVC */
115 #ifdef _MSC_VER
116 #define snprintf _snprintf
117 #endif
118 
119 /* Working __FUNCTION__ on BCC */
120 #ifndef HAVE_MACRO_FUNCTION
121 # ifdef HAVE_MACRO_FUNC
122 # define __FUNCTION__ __FUNC__
123 # define __FUNCTION__WORKING
124 # else
125 # define __FUNCTION__ "unknown"
126 # endif
127 #else
128 # define __FUNCTION__WORKING
129 #endif
130 
131 /* strtoull for BCC (and maybe others) */
132 #ifndef HAVE_STRTOULL
133 /* MSVC provides same function under different name */
134 #if _MSC_VER >= 1300
135 #include <stdlib.h>
136 #define strtoull _strtoui64
137 #else
138 #define strtoull(A,B,C) strtoul((A),(B),(C))
139 #endif
140 #endif
141 
142 /* ssize_t for compilers where it does not exist (BCC) */
143 #ifndef HAVE_SSIZE_T
144 typedef long ssize_t;
145 #endif
146 
147 /* intptr_t for compilers where it does not exist (BCC) */
148 #ifndef HAVE_INTPTR_T
149 typedef int intptr_t;
150 #endif
151 
155 void EncodeHexBin(char *dest, const unsigned char *src, size_t len);
156 
165 gboolean GSM_IsNewerVersion(const char *latest_version,
166  const char *current_version);
167 
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 #endif
182 
183 /* Editor configuration
184  * vim: noexpandtab sw=8 ts=8 sts=8 tw=72:
185  */
gboolean GSM_IsNewerVersion(const char *latest_version, const char *current_version)
Definition: misc.c:699
const char * GetCompiler(void)
Definition: misc.c:659
const char * GetGammuLocalePath(void)
Definition: gsmcomon.c:200
void EncodeHexBin(char *dest, const unsigned char *src, size_t len)
Definition: coding.c:426
const char * GetOS(void)
Definition: misc.c:537
GSM_Error
Definition: gammu-error.h:23
const char * GetGammuVersion(void)
Definition: gsmcomon.c:210
int gboolean
Definition: gammu-types.h:23
size_t GetLine(FILE *File, char *Line, int count)
Definition: misc.c:370
GSM_Error GSM_SetPower(GSM_StateMachine *s, gboolean on)
Definition: api.c:307
void GSM_InitLocales(const char *path)