summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/misc/misc.h
Unidiff
Diffstat (limited to 'gammu/emb/common/misc/misc.h') (more/less context) (show whitespace changes)
-rw-r--r--gammu/emb/common/misc/misc.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/gammu/emb/common/misc/misc.h b/gammu/emb/common/misc/misc.h
index 8b46170..c461001 100644
--- a/gammu/emb/common/misc/misc.h
+++ b/gammu/emb/common/misc/misc.h
@@ -1,53 +1,57 @@
1/* (c) 2002-2004 by Marcin Wiacek */ 1/* (c) 2002-2004 by Marcin Wiacek */
2 2
3#ifndef __misc_h 3#ifndef __misc_h
4#define __misc_h 4#define __misc_h
5 5
6#if defined(_MSC_VER) && defined(__cplusplus)
7 extern "C" {
8#endif
9
6#include <stdio.h> 10#include <stdio.h>
7#include <time.h> 11#include <time.h>
8#ifdef WIN32 12#ifdef WIN32
9# include <windows.h> 13# include <windows.h>
10#endif 14#endif
11 15
12#include "../config.h" 16#include "../config.h"
13 17
14#ifndef __cplusplus 18#ifndef __cplusplus
15#ifndef false 19#ifndef false
16# define false 0 20# define false 0
17#endif 21#endif
18#ifndef true 22#ifndef true
19 # define true !0 23 # define true !0
20#endif 24#endif
21#ifndef bool 25#ifndef bool
22 # define boolchar 26 # define boolchar
23#endif 27#endif
24#endif /* __cplusplus */ 28#endif /* __cplusplus */
25 29
26#ifdef WIN32 30#ifdef WIN32
27# define my_sleep(x) ((x)<1000 ? Sleep(1) : Sleep((x)/1000)) 31# define my_sleep(x) ((x)<1000 ? Sleep(1) : Sleep((x)/1000))
28#else 32#else
29# define my_sleep(x) usleep(x) 33# define my_sleep(x) usleep(x)
30#endif 34#endif
31 35
32#undef MAX 36#undef MAX
33#define MAX(a,b) ((a)>(b) ? (a) : (b)) 37#define MAX(a,b) ((a)>(b) ? (a) : (b))
34#undef MIN 38#undef MIN
35#define MIN(a,b) ((a)<(b) ? (a) : (b)) 39#define MIN(a,b) ((a)<(b) ? (a) : (b))
36 40
37/* ------------------------------------------------------------------------- */ 41/* ------------------------------------------------------------------------- */
38 42
39#define MAX_LINES 50 43#define MAX_LINES 50
40 44
41int GetLine(FILE *File, char *Line, int count); 45int GetLine(FILE *File, char *Line, int count);
42 46
43typedef struct { 47typedef struct {
44 int numbers[MAX_LINES*2]; 48 int numbers[MAX_LINES*2];
45} GSM_Lines; 49} GSM_Lines;
46 50
47void SplitLines(unsigned char *message, int messagesize, GSM_Lines *lines, unsigned char *whitespaces, int spaceslen, bool eot); 51void SplitLines(unsigned char *message, int messagesize, GSM_Lines *lines, unsigned char *whitespaces, int spaceslen, bool eot);
48char *GetLineString(unsigned char *message, GSM_Lines lines, int start); 52char *GetLineString(unsigned char *message, GSM_Lines lines, int start);
49void CopyLineString(unsigned char *dest, unsigned char *src, GSM_Lines lines, int start); 53void CopyLineString(unsigned char *dest, unsigned char *src, GSM_Lines lines, int start);
50 54
51/* ------------------------------------------------------------------------- */ 55/* ------------------------------------------------------------------------- */
52 56
53typedef enum { 57typedef enum {
@@ -85,53 +89,57 @@ int dbgprintf(const char *format, ...);
85#ifdef __GNUC__ 89#ifdef __GNUC__
86__attribute__((format(printf, 3, 4))) 90__attribute__((format(printf, 3, 4)))
87#endif 91#endif
88int smfprintf(FILE *f, Debug_Level dl, const char *format, ...); 92int smfprintf(FILE *f, Debug_Level dl, const char *format, ...);
89 93
90void DumpMessage(FILE *df, Debug_Level dl, const unsigned char *message, int messagesize); 94void DumpMessage(FILE *df, Debug_Level dl, const unsigned char *message, int messagesize);
91 95
92bool GSM_SetDebugLevel(char *info, Debug_Info *di); 96bool GSM_SetDebugLevel(char *info, Debug_Info *di);
93 97
94/* ------------------------------------------------------------------------- */ 98/* ------------------------------------------------------------------------- */
95 99
96/** 100/**
97 * Structure used for saving date and time 101 * Structure used for saving date and time
98 */ 102 */
99typedef struct { 103typedef struct {
100 /** 104 /**
101 * The difference between local time and GMT in hours 105 * The difference between local time and GMT in hours
102 */ 106 */
103 int Timezone; 107 int Timezone;
104 108
105 unsigned int Second; 109 unsigned int Second;
106 unsigned int Minute; 110 unsigned int Minute;
107 unsigned int Hour; 111 unsigned int Hour;
108 112
109 unsigned int Day; 113 unsigned int Day;
110 /** 114 /**
111 * January = 1, February = 2, etc. 115 * January = 1, February = 2, etc.
112 */ 116 */
113 unsigned int Month; 117 unsigned int Month;
114 /** 118 /**
115 * Complete year number. Not 03, but 2003 119 * Complete year number. Not 03, but 2003
116 */ 120 */
117 unsigned int Year; 121 unsigned int Year;
118} GSM_DateTime; 122} GSM_DateTime;
119 123
120 void GSM_GetCurrentDateTime (GSM_DateTime *Date); 124 void GSM_GetCurrentDateTime (GSM_DateTime *Date);
121 char *OSDateTime (GSM_DateTime dt, bool TimeZone); 125 char *OSDateTime (GSM_DateTime dt, bool TimeZone);
122 char *OSDate (GSM_DateTime dt); 126 char *OSDate (GSM_DateTime dt);
123 char *DayOfWeek (int year, int month, int day); 127 char *DayOfWeek (int year, int month, int day);
124 time_t Fill_Time_T (GSM_DateTime DT, int TZ); 128 time_t Fill_Time_T (GSM_DateTime DT, int TZ);
125 void GetTimeDifference (unsigned long diff, GSM_DateTime *DT, bool Plus, int multi); 129 void GetTimeDifference (unsigned long diff, GSM_DateTime *DT, bool Plus, int multi);
126 void Fill_GSM_DateTime (GSM_DateTime *Date, time_t timet); 130 void Fill_GSM_DateTime (GSM_DateTime *Date, time_t timet);
127 bool CheckDate (GSM_DateTime *date); 131 bool CheckDate (GSM_DateTime *date);
128 bool CheckTime (GSM_DateTime *date); 132 bool CheckTime (GSM_DateTime *date);
129 133
130 char *GetCompiler(void); 134 char *GetCompiler(void);
131 char *GetOS(void); 135 char *GetOS(void);
132 136
137#if defined(_MSC_VER) && defined(__cplusplus)
138 }
139#endif
140
133#endif 141#endif
134 142
135/* How should editor hadle tabs in this file? Add editor commands here. 143/* How should editor hadle tabs in this file? Add editor commands here.
136 * vim: noexpandtab sw=8 ts=8 sts=8: 144 * vim: noexpandtab sw=8 ts=8 sts=8:
137 */ 145 */