5 * Miscellaneous helper functions.
11 # define WIN32_LEAN_AND_MEAN
16 #include <gammu-file.h>
17 #include <gammu-config.h>
18 #if defined(HAVE_UNISTD_H)
23 * Reads single line from file.
25 * \param File File descriptor to read from.
26 * \param Line Buffer where t ostore result.
27 * \param count Maximal length of text which can be stored in buffer.
29 * \return Length of read line, -1 on error.
31 int GetLine(FILE * File
, char *Line
, int count
);
34 * Gets Gammu library version.
36 const char *GetGammuVersion(void);
39 * Gets compiler which was used to compile Gammu library.
41 const char *GetCompiler(void);
46 const char *GetOS(void);
49 * Returns path to Gammu locales.
51 const char *GetGammuLocalePath(void);
54 * Initializes locales. This sets up things needed for proper string
55 * conversion from local charset as well as initializes gettext based
58 * \param path Path to gettext translation. If NULL compiled in default
61 extern void GSM_InitLocales(const char *path
);
64 #define MAX(a,b) ((a)>(b) ? (a) : (b))
66 #define MIN(a,b) ((a)<(b) ? (a) : (b))
69 # if !defined(HAVE_UNISTD_H) || defined(__MINGW32__)
70 # define sleep(x) Sleep((x) * 1000)
71 # define usleep(x) Sleep(((x) < 1000) ? 1 : ((x) / 1000))
72 # endif /* HAVE_UNISTD_H */
75 /* Easy check for GCC */
76 #if defined __GNUC__ && defined __GNUC_MINOR__
77 # define GSM_GNUC_PREREQ(maj, min) \
78 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
80 # define GSM_GNUC_PREREQ(maj, min) 0
83 /* Various hints for compilers */
84 #if GSM_GNUC_PREREQ (2,8) || defined(__clang__)
85 #define PRINTF_STYLE(f, a) __attribute__ ((format(__printf__, f, a)))
86 #define SCANF_STYLE(f, a) __attribute__ ((format(__scanf__, f, a)))
88 #define PRINTF_STYLE(f, a)
89 #define SCANF_STYLE(f, a)
92 #if GSM_GNUC_PREREQ (3,4) || defined(__clang__)
93 #define WARNUNUSED __attribute__ ((__warn_unused_result__))
98 #if GSM_GNUC_PREREQ (3,1) || defined(__clang__)
99 #define UNUSED __attribute__ ((unused))
104 #if defined(__GNUC__) || defined(__clang__)
105 #define NORETURN __attribute__((__noreturn__))
110 /* Clang has bug in handling inline functions */
111 #if defined(__GNUC__) && !defined(__clang__)
112 #define INLINE inline
117 /* Working snprintf on MSVC */
119 #define snprintf _snprintf
122 /* Working __FUNCTION__ on BCC */
123 #ifndef HAVE_MACRO_FUNCTION
124 # ifdef HAVE_MACRO_FUNC
125 # define __FUNCTION__ __FUNC__
126 # define __FUNCTION__WORKING
128 # define __FUNCTION__ "unknown"
131 # define __FUNCTION__WORKING
134 /* strtoull for BCC (and maybe others) */
135 #ifndef HAVE_STRTOULL
136 /* MSVC provides same function under different name */
139 #define strtoull _strtoui64
141 #define strtoull(A,B,C) strtoul((A),(B),(C))
145 /* ssize_t for compilers where it does not exist (BCC) */
147 typedef long ssize_t
;
150 /* intptr_t for compilers where it does not exist (BCC) */
151 #ifndef HAVE_INTPTR_T
152 typedef int intptr_t;
156 * Encodes text to hexadecimal binary representation.
158 void EncodeHexBin(char *dest
, const unsigned char *src
, size_t len
);
161 * Returns TRUE if firmware version is newer.
163 * \param latest_version String containing version (eg. latest available).
164 * \param current_version String containing version (eg. current one).
166 * \return True if latest_version > current_version.
168 gboolean
GSM_IsNewerVersion(const char *latest_version
,
169 const char *current_version
);
172 /* Editor configuration
173 * vim: noexpandtab sw=8 ts=8 sts=8 tw=72: