1 /* $Id: climm.h 2856 2010-03-07 12:55:15Z kuhlmann $ */
2 
3 #ifndef CLIMM_H
4 #define CLIMM_H
5 
6 #ifdef HAVE_CONFIG_H
7 #include "config.h"
8 #elif defined(__WIN32)
9 #include "config.h.win32"
10 #endif
11 
12 #include "climmconfig.h"
13 
14 #if TM_IN_SYS_TIME
15   #include <sys/time.h>
16   #if TIME_WITH_SYS_TIME
17     #include <time.h>
18   #endif
19 #else
20   #include <time.h>
21   #if TIME_WITH_SYS_TIME
22     #include <sys/time.h>
23   #endif
24 #endif
25 
26 #include <stdio.h>
27 
28 #ifdef PREFER_PORTABLE_SNPRINTF
29 #include <../replace/snprintf.h>
30 #endif
31 
32 #ifdef PREFER_PORTABLE_MEMMOVE
33 #include <../replace/memmove.h>
34 #endif
35 
36 #ifndef HAVE_TIMEGM
37 #define HAVE_TIMEGM 1
38 #define timegm portable_timegm
39 time_t portable_timegm (struct tm *tm);
40 #endif
41 
42 #ifndef HAVE_TIMELOCAL
43 #define timelocal mktime
44 #endif
45 
46 #if ENABLE_XMPP && defined(LIBGLOOX_VERSION) && LIBGLOOX_VERSION >= 0x000907
47 #define CLIMM_XMPP_FILE_TRANSFER
48 #endif
49 
50 #if ENABLE_XMPP
51 #define ENABLE_CONT_HIER 1
52 #endif
53 
54 #ifndef HAVE_LOCALTIME_R
55 #define HAVE_LOCALTIME_R 1
56 #define localtime_r(t, s)      memcpy(s, localtime(t), sizeof(struct tm))
57 #endif
58 
59 #ifndef _REENTRANT
60 #define _REENTRANT 1
61 #endif
62 
63 #ifndef __attribute__
64 #if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
65   #define __attribute__(x)
66 #endif
67 #endif
68 
69 #define ENABLE_DEBUG 1
70 
71 #if ENABLE_AUTOPACKAGE
72 extern int libtcl8_4_is_present;
73 extern int libgnutls_is_present;
74 extern int libgcrypt_is_present;
75 extern int libopenssl_is_present;
76 extern int libotr_is_present;
77 #else
78 #define libtcl8_4_is_present 1
79 #define libgnutls_is_present 1
80 #define libgnutls_symbol_is_present(s) 1
81 #define libgcrypt_is_present 1
82 #define libopenssl_is_present 1
83 #define libotr_is_present    1
84 #endif
85 
86 struct Queue_s;
87 struct Event_s;
88 struct Contact_s;
89 struct Packet_s;
90 struct Connection_s;
91 struct Server_s;
92 struct Preferences_s;
93 struct ConnectionPreferences_s;
94 struct Cap_s;
95 struct Extra_s;
96 struct Message_s;
97 
98 typedef struct Queue_s            Queue;
99 typedef struct Event_s            Event;
100 typedef struct Opt_s              Opt;
101 typedef struct Contact_s          Contact;
102 typedef struct ContactGroup_s     ContactGroup;
103 typedef struct ContactAlias_s     ContactAlias;
104 typedef struct Packet_s           Packet;
105 typedef struct Server_s           Server;
106 typedef struct Connection_s       Connection;
107 typedef struct Preferences_s      Preferences;
108 typedef struct Cap_s              Cap;
109 typedef struct Extra_s            Extra;
110 typedef struct Message_s          Message;
111 
112 typedef void MSN_Handle;
113 
114 #include "datatype.h"
115 #include <stdlib.h>
116 #ifdef HAVE_STRING_H
117 #include <string.h>
118 #endif
119 #ifdef HAVE_STRINGS_H
120 #include <strings.h>
121 #endif
122 
123 #include "autopackage_prefix.h"
124 
125 #if ENABLE_DEBUG && HAVE_VARIADIC_MACRO
126 #define DEBUGARGS    , __FILE__, __LINE__
127 #define DEBUGPARAM   , const char *debugfile, int debugline
128 #define DEBUG0ARGS   __FILE__, __LINE__
129 #define DEBUG0PARAM  const char *debugfile, int debugline
130 #define DEBUGFOR     , debugfile, debugline
131 #define DEBUGNONE    , "", 0
132 #define Debug(l,f,...) DebugReal (l, f " {%s:%d}<<{%s:%d}" , ## __VA_ARGS__, \
133                                   __FILE__, __LINE__, debugfile, debugline)
134 #define DebugH(l,f,...) DebugReal (l, f " {%s:%d}<|" , ## __VA_ARGS__, \
135                                    __FILE__, __LINE__)
136 #else
137 #define DEBUGARGS
138 #define DEBUGPARAM
139 #define DEBUG0ARGS
140 #define DEBUG0PARAM  void
141 #define DEBUGFOR
142 #define DEBUGNONE
143 #define DebugH DebugReal
144 #define Debug DebugReal
145 #endif
146 
147 #include "msg_queue.h"
148 #include "mreadline.h"
149 #include "color.h"
150 
151 #define SOUND_ON 1
152 #define SOUND_OFF 0
153 #define SOUND_CMD 2
154 
155 #define default_away_time 600
156 
157 #define ICQ_VER 5
158 
159 #define STDIN 0
160 #define STDOUT 1
161 #define STDERR 2
162 
163 #include "icq_v2.h"
164 #include "icq_v5.h"
165 #include "icq_tcp.h"
166 
167 typedef enum {
168   imr_online   = 0,
169   imr_away     = 1,
170   imr_dnd      = 2,
171   imr_na       = 3,
172   imr_occ      = 4,
173   imr_ffc      = 5,
174   imr_offline  = 7
175 } status_noi_t;
176 
177 typedef enum {
178   ims_online   = 0,
179   ims_away     = 1,
180   ims_dnd      = 2,
181   ims_na       = 3,
182   ims_occ      = 4,
183   ims_ffc      = 5,
184   ims_offline  = 7,
185   ims_inv      = 8,
186   ims_inv_ffc  = ims_inv + ims_ffc,
187   ims_inv_away = ims_inv + ims_away,
188   ims_inv_na   = ims_inv + ims_na,
189   ims_inv_occ  = ims_inv + ims_occ,
190   ims_inv_dnd  = ims_inv + ims_dnd
191 } status_t;
192 
193 typedef enum {
194   imf_none   = 0,
195   imf_birth  = 1,
196   imf_web    = 2,
197   imf_dcauth = 4,
198   imf_dccont = 8,
199   imf_bw     = 3,
200   imf_ab     = 5,
201   imf_aw     = 6,
202   imf_awb    = 7,
203   imf_cb     = 9,
204   imf_cw     = 10,
205   imf_cwb    = 11,
206   imf_ca     = 12,
207   imf_cab    = 13,
208   imf_caw    = 14,
209   imf_cawb   = 15
210 } statusflag_t;
211 
212 typedef enum {
213   i_idle      = 0,
214   i_os        = 1,
215   i_want_away = 2,
216   i_want_na   = 3
217 } idleflag_t;
218 
219 #define MSGF_MASS         0x8000
220 #define MSGF_GETAUTO      0x0300
221 
222 #define MSG_AUTO          0x00
223 #define MSG_NORM          0x01
224 #define MSG_CHAT          0x02
225 #define MSG_FILE          0x03
226 #define MSG_URL           0x04
227 #define MSG_AUTH_REQ      0x06
228 #define MSG_AUTH_DENY     0x07
229 #define MSG_AUTH_GRANT    0x08
230 #define MSG_AUTH_DONE     0x09 /* xmpp */
231 #define MSG_AUTH_ADDED    0x0c
232 #define MSG_WEB           0x0d
233 #define MSG_EMAIL         0x0e
234 #define MSG_CONTACT       0x13
235 #define MSG_EXTENDED      0x1a
236 #define MSG_GET_AWAY      0xe8
237 #define MSG_GET_OCC       0xe9
238 #define MSG_GET_NA        0xea
239 #define MSG_GET_DND       0xeb
240 #define MSG_GET_FFC       0xec
241 /* climm extension */
242 #define MSG_GET_PEEK      0xf0
243 #define MSG_GET_VER       0xf4
244 /* Licq extension */
245 #define MSG_SSL_CLOSE     0xee
246 #define MSG_SSL_OPEN      0xef
247 /* XMPP */
248 #define MSG_NORM_SUBJ     0x30
249 
250 #define INV_LIST_UPDATE         0x01
251 #define VIS_LIST_UPDATE         0x02
252 #define CONT_LIST_UPDATE        0x00
253 
254 #define LOG_MAX_PATH 255
255 #define DSCSIZ 192 /* Maximum length of log file descriptor lines. */
256 
257 /*
258  * Should you decide to move a global variable from one struct to another,
259  * change it manually in the header file, and then in the src directory
260  * the following incantation can be handy (assuming you want to move, say,
261  * Hermit, from uiG to ss G):
262  * perl -pi -e 's/(\W)uiG\.(Hermit)(\W)/$1ss G.$2$3/g;' *.c
263  */
264 
265 /* user interface global state variables */
266 typedef struct
267 {
268     Contact *last_rcvd;
269     Contact *last_sent;
270     char    *last_message_sent;
271     UDWORD   last_message_sent_type;
272     time_t   start_time;
273     UDWORD   away_time_prev;
274     UBYTE    reconnect_count;
275     BOOL     quit;
276     UDWORD   packets, events;
277     time_t   idle_val;
278     UDWORD   idle_msgs;
279     char    *idle_uins;
280     UWORD    nick_len;   /* this *must* be an int why??*/
281     Server  *conn;          /* Current connection */
282 } user_interface_state;
283 
284 extern user_interface_state uiG;
285 extern Preferences *prG;
286 
287 enum logtype
288 {
289     LOG_MISC,    /* miscellaneous */
290     LOG_SENT,    /* sent message */
291     LOG_AUTO,    /* automatic reply */
292     LOG_RECVD,   /* received message */
293     LOG_CHANGE,  /* status change */
294     LOG_REPORT,  /* status report */
295     LOG_GUESS,   /* status guess */
296     LOG_ONLINE,  /* went online */
297     LOG_OFFLINE, /* went offline */
298     LOG_ACK,     /* message acknowedgment */
299     LOG_ADDED,   /* added to contact list by someone */
300     LOG_LIST,    /* added someone to the contact list */
301     LOG_EVENT    /* other event */
302 };
303 
304 #endif /* CLIMM_H */
305 
306 #include "i18n.h"
307 #include "util_str.h"
308