1 /*
2 
3   $Id$
4 
5   G N O K I I
6 
7   A Linux/Unix toolset and driver for the mobile phones.
8 
9   This file is part of gnokii.
10 
11   Gnokii is free software; you can redistribute it and/or modify
12   it under the terms of the GNU General Public License as published by
13   the Free Software Foundation; either version 2 of the License, or
14   (at your option) any later version.
15 
16   Gnokii is distributed in the hope that it will be useful,
17   but WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   GNU General Public License for more details.
20 
21   You should have received a copy of the GNU General Public License
22   along with gnokii; if not, write to the Free Software
23   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24 
25   Copyright (C) 1999-2000 Hugh Blemings & Pavel Janik ml.
26   Copyright (C) 2000      Jan Derfinak
27   Copyright (C) 2001-2002 Chris Kemp, Pavel Machek
28   Copyright (C) 2001-2004 Pawel Kot, BORBELY Zoltan
29 
30   Header file for miscellaneous defines, typedefs etc.
31 
32 */
33 
34 #ifndef _gnokii_misc_h
35 #define _gnokii_misc_h
36 
37 #include <stdio.h>
38 #include <sys/types.h>
39 
40 #include "compat.h"
41 
42 /* Some general defines. */
43 
44 #define ARRAY_LEN(x) (sizeof((x)) / sizeof((x)[0]))
45 
46 #define GNOKII_MAX(a, b)  (((a) > (b)) ? (a) : (b))
47 #define GNOKII_MIN(a, b)  (((a) < (b)) ? (a) : (b))
48 
49 /* A define to make debug printfs neat */
50 #ifdef __GNUC__
51 #  ifndef DEBUG
52 #    define dprintf(a...) do { } while (0)
53 #  else
54 #    define dprintf(a...) do { gn_log_debug(a); } while (0)
55 #  endif /* DEBUG */
56 #  /* Use it for error reporting */
57 #  define dump(a...) do { gn_elog_write(a); } while (0)
58 #else
59 #  ifndef DEBUG
60 #    define dump while (0)
61 #    define dprintf while (0)
62 #  else
63 #    define dump gn_elog_write
64 #    define dprintf gn_log_debug
65 #  endif /* DEBUG */
66 #endif /* __GNUC__ */
67 
68 /* Use gsprintf instead of sprintf and sprintf */
69 #define gsprintf		snprintf
70 #define gvsprintf		vsnprintf
71 #define gasprintf		asprintf
72 #define gvasprintf		vasprintf
73 
74 /* This is for the bitmaps mostly, but may be useful also for the other
75  * things. Counts how many octets we need to cover the given ammount of
76  * the bits.
77  */
78 #define ceiling_to_octet(x) ((x) + 7) / 8
79 
80 #define PM_OLD_DEFAULT		PM_SPEEDDIAL | PM_SMS | PM_DTMF | PM_KEYBOARD | PM_CALENDAR
81 #define PM_DEFAULT		PM_OLD_DEFAULT | PM_CALLERGROUP | PM_EXTPBK | PM_FOLDERS
82 #define PM_DEFAULT_S40_3RD	PM_DEFAULT | PM_SMSFILE | PM_EXTPBK2 | PM_EXTCALENDAR
83 /* Series 30 phones support a very limited subset of the Series 40 commands */
84 #define PM_DEFAULT_S30		PM_DEFAULT_S40_3RD
85 
86 #define PM_CALLERGROUP		0x0001
87 #define PM_NETMONITOR		0x0002
88 #define PM_KEYBOARD		0x0004
89 #define PM_SMS			0x0008
90 #define PM_CALENDAR		0x0010
91 #define PM_DTMF			0x0020
92 #define PM_DATA			0x0040
93 #define PM_SPEEDDIAL		0x0080
94 #define PM_EXTPBK		0x0100
95 #define PM_AUTHENTICATION	0x0200
96 #define PM_FOLDERS		0x0400
97 #define PM_FULLPBK		0x0800
98 /* Verify if these three might not be coupled into one */
99 #define PM_SMSFILE		0x1000
100 #define PM_EXTPBK2		0x2000
101 #define PM_EXTCALENDAR		0x4000
102 
103 /* This one indicated reported cases of breaking the phone by xgnokii
104  * in FBUS orver IrDA mode */
105 #define PM_XGNOKIIBREAKAGE	0x8000
106 
107 char **gnokii_strsplit(const char *string, const char *delimiter, int tokens);
108 void gnokii_strfreev(char **str_array);
109 int gnokii_strcmpsep(const char *s1, const char *s2, char sep);
110 
111 #endif /* _gnokii_misc_h */
112