1 /*
2 SMS Server Tools 3
3 Copyright (C) 2006- Keijo Kasvi
4 http://smstools3.kekekasvi.com/
5 
6 Based on SMS Server Tools 2, http://stefanfrings.de/smstools/
7 SMS Server Tools version 2 and below are Copyright (C) Stefan Frings.
8 
9 This program is free software unless you got it under another license directly
10 from the author. You can redistribute it and/or modify it under the terms of
11 the GNU General Public License as published by the Free Software Foundation.
12 Either version 2 of the License, or (at your option) any later version.
13 */
14 
15 #ifndef SMSD_CFG_H
16 #define SMSD_CFG_H
17 
18 #include <limits.h>
19 #include <sys/types.h>
20 #include <time.h>
21 #include <signal.h>
22 
23 #ifndef __FreeBSD__
24 #define DEFAULT_CONFIGFILE "/etc/smsd.conf"
25 #else
26 #define DEFAULT_CONFIGFILE "/usr/local/etc/smsd.conf"
27 #endif
28 
29 #define DATETIME_DEFAULT "%y-%m-%d %H:%M:%S"
30 #define LOGTIME_DEFAULT "%Y-%m-%d %H:%M:%S"
31 #define DATE_FILENAME_DEFAULT "%Y-%m-%d"
32 
33 #define POLL_FASTER_DEFAULT 5
34 
35 #define CONCATENATED_DIR_FNAME "%s/%s-concatenated"
36 
37 #define MM_CORE_FNAME "/tmp/mm_smsd_%i" /* %i is PID */
38 
39 #define NUMS 64
40 #define SIZE_NUM 16
41 
42 // 3.1.18: Definitions for process_id's:
43 #define PROCESS_ID_MAINPROCESS -1
44 #define PROCESS_ID_NOTIFIER -2
45 #define PROCESS_ID_CHILD -3
46 #define PROCESS_IS_MODEM (process_id >= 0)
47 
48 #define DEVICE devices[process_id]
49 #define DEVICE_IS_SOCKET (devices[process_id].device[0] == '@')
50 #define DEVICE_X_IS_SOCKET (devices[x].device[0] == '@')
51 #define STATISTICS statistics[process_id]
52 
53 // Maximum size of a message text
54 #define MAXTEXT 39016
55 
56 // Maxmum size of a single sms, can be 160/140 or less
57 #define maxsms_pdu 160
58 #define maxsms_ucs2 140
59 #define maxsms_binary 140
60 
61 // Sizes for some buffers:
62 #define SIZE_TO 100
63 #define SIZE_FROM 100
64 #define SIZE_SMSC 100
65 #define SIZE_QUEUENAME 100
66 #define SIZE_UDH_DATA 500
67 #define SIZE_UDH_TYPE 4096
68 #define SIZE_RR_CMD 513
69 #define SIZE_MACROS 4096
70 #define SIZE_HEADER 101
71 #define SIZE_MESSAGEIDS 4096
72 #define SIZE_IDENTITY 100
73 #define SIZE_TB 1024
74 #define SIZE_LOG_LINE 16384
75 #define SIZE_PRIVILEDGED_NUMBERS 512
76 #define SIZE_SMSD_DEBUG 100
77 #define SIZE_SHARED_BUFFER 256
78 #define SIZE_FILENAME_PREVIEW 256
79 #define SIZE_PB_ENTRY 101
80 
81 #define SIZE_CHECK_MEMORY_BUFFER 512
82 // 3.1.12: Changed size from 16384 when CMGL* method is used:
83 #define SIZE_CHECK_MEMORY_BUFFER_CMGL 65536
84 
85 #define SIZE_IGNORE_UNEXPECTED_INPUT 512
86 
87 // Check memory methods:
88 #define CM_NO_CPMS 0
89 #define CM_S_NO_CPMS "Fixed values are used because CPMS does not work."
90 #define CM_CPMS 1
91 #define CM_S_CPMS "CPMS is used."
92 #define CM_CMGD 2
93 #define CM_S_CMGD "CMGD is used."
94 #define CM_CMGL 3
95 #define CM_S_CMGL "CMGL is used."
96 #define CM_CMGL_DEL_LAST 4
97 #define CM_S_CMGL_DEL_LAST "CMGL is used and messages are deleted after all messsages are read."
98 #define CM_CMGL_CHECK 31
99 #define CM_S_CMGL_CHECK "CMGL is used and messages are taken from the list."
100 #define CM_CMGL_DEL_LAST_CHECK 41
101 #define CM_S_CMGL_DEL_LAST_CHECK "CMGL is used and messages are taken from the list, messages are deleted after all messages are read."
102 #define CM_CMGL_SIMCOM 5
103 #define CM_S_CMGL_SIMCOM "CMGL is used. SIM600 compatible, see the manual for details."
104 
105 // 3.1.12:
106 #define select_check_memory_buffer_size() (value_in(DEVICE.check_memory_method, 5, CM_CMGL, CM_CMGL_DEL_LAST, CM_CMGL_CHECK, CM_CMGL_DEL_LAST_CHECK, CM_CMGL_SIMCOM))? SIZE_CHECK_MEMORY_BUFFER_CMGL : SIZE_CHECK_MEMORY_BUFFER
107 
108 #define LENGTH_PDU_DETAIL_REC 70
109 
110 // For put_command() calls:
111 #define EXPECT_OK_ERROR "(OK)|(ERROR)"
112 #define EXPECT_OK_ERROR_0_4 "(OK)|(ERROR)|(0)|(4)" // 3.1.16beta.
113 
114 #define TELNET_LOGIN_PROMPT_DEFAULT "login:"
115 #define TELNET_LOGIN_PROMPT_IGNORE_DEFAULT "Last login:"
116 #define TELNET_PASSWORD_PROMPT_DEFAULT "Password:"
117 
118 #define isdigitc(ch) isdigit((int)(ch))
119 #define isalnumc(ch) isalnum((int)(ch))
120 
121 #define ALPHABET_GSM            -1
122 #define ALPHABET_ISO            0
123 #define ALPHABET_BINARY         1
124 #define ALPHABET_UCS2           2
125 #define ALPHABET_UTF8           3
126 #define ALPHABET_UNKNOWN        4
127 #define ALPHABET_DEFAULT        0
128 
129 char process_title[32];         // smsd for main task, NOTIFIER or CHILD, name of a modem for other tasks.
130 int process_id;                 // -1 for main task, all modems have numbers starting with 0.
131                                 // This is the same as device, can be used like devices[process_id] if IS_MODEM_PROCESS.
132 
133 time_t process_start_time;
134 
135 int modem_handle;               // Handle for modem.
136 
137 int put_command_timeouts;
138 unsigned long long put_command_sent; // 3.1.16beta.
139 char tmpdir[PATH_MAX];          // 3.1.16beta.
140 
141 typedef struct
142 {
143   char name[32]; 		// Name of the queue
144   char numbers[NUMS][SIZE_NUM];	// Phone numbers assigned to this queue
145   char directory[PATH_MAX];		// Queue directory
146 } _queue;
147 
148 typedef struct
149 {
150   char name[32];		// Name of the modem
151   char number[32];              // 3.1.4: SIM card's telephone number.
152   char device[PATH_MAX];	// Serial port name
153   int device_open_retries;      // 3.1.7: Defines count of retries when opening a device fails.
154   int device_open_errorsleeptime; // 3.1.7: Sleeping time after opening error.
155   int device_open_alarm_after;  // 3.1.7: Defines after how many failures an alarmhandler is called.
156   char identity[SIZE_IDENTITY]; // Identification asked from the modem (CIMI)
157   char imei[SIZE_IDENTITY]; 	// 3.1.16beta: IMEI asked from the modem (CGSN)
158   char conf_identity[SIZE_IDENTITY]; // Identification set in the conf file (CIMI)
159   char queues[NUMBER_OF_MODEMS][32]; // Assigned queues
160   int incoming; 		// Try to receive SMS. 0=No, 1=Low priority, 2=High priority
161   int outgoing;                 // = 0 if a modem is not used to send messages.
162   int report; 			// Ask for delivery report 0 or 1 (experimental state)
163   int phonecalls;               // Check for phonebook status for calls, 0 or 1. 3.1.7: value 2 = +CLIP report is handled.
164   char phonecalls_purge[32];    // Defines if a purge command should be used. yes / no / command to use. yes = AT^SPBD="MC"
165   int phonecalls_error_max;     // 3.1.7: Max nr of errors before phonecalls are ignored.
166   char pin[16];			// SIM PIN
167   int pinsleeptime;             // Number of seconds to sleep after a PIN is entered.
168   char mode[10]; 		// Command set version old or new
169   char smsc[16];		// Number of SMSC
170   int baudrate;			// Baudrate
171   int send_delay;		// Makes sending characters slower (milliseconds)
172   int send_handshake_select;    // 3.1.9.
173   int cs_convert; 		// Convert character set  0 or 1 (iso-9660)
174   int cs_convert_optical;       // 3.1.16beta2.
175   char initstring[100];		// first Init String
176   char initstring2[100];        // second Init String
177   char eventhandler[PATH_MAX];	// event handler program or script
178   char eventhandler_ussd[PATH_MAX]; // 3.1.7: event handler program or script for USSD answers
179   int ussd_convert;             // 3.1.7: Convert string from USSD answer
180   int rtscts;			// hardware handshake RTS/CTS, 0 or 1
181   int read_memory_start;	// first memory space for sms
182   char primary_memory[10];      // primary memory, if dual-memory handler is used
183   char secondary_memory[10];    // secondary memory, if dual-memory handler is used
184   int secondary_memory_max;     // max value for secondary memory, if dual-memory handler is used and modem does not tell correct max value
185   char pdu_from_file[PATH_MAX]; // for testing purposes: incoming pdu can be read from file if this is set.
186   int sending_disabled;         // 1 = do not actually send a message. For testing purposes.
187   int modem_disabled;           // 1 = disables modem handling. For testing purposes.
188   int decode_unicode_text;      // 1 if unicode text is decoded internally.
189   int internal_combine;         // 1 if multipart message is combined internally.
190   int internal_combine_binary;  // 1 if multipart binary message is combined internally. Defaults to internal_combine.
191   int pre_init;                 // 1 if pre-initialization is used with a modem.
192   int check_network;            // 0 if a modem does not support AT+CREG command.
193   char admin_to[SIZE_TO];       // Destination number for administrative messages.
194   int message_limit;            // Limit counter for outgoing messages. 0 = no limit.
195   int message_count_clear;      // Period to automatically clear message counter. Value is MINUTES.
196   int keep_open;                // 1 = do not close modem while idle.
197   char dev_rr[PATH_MAX];        // Script/program which is run regularly.
198   char dev_rr_post_run[PATH_MAX]; // 3.1.7: Script/program which is run regularly (POST_RUN).
199   int dev_rr_interval;          // Number of seconds between running a regular_run script/progdam.
200   char dev_rr_cmdfile[PATH_MAX];//
201   char dev_rr_cmd[SIZE_RR_CMD]; //
202   char dev_rr_logfile[PATH_MAX];
203   int dev_rr_loglevel; // defaults to 5, LOG_NOTICE. Has only effect when a main log is used.
204   char dev_rr_statfile[PATH_MAX];
205   int dev_rr_keep_open;         // 3.1.16beta2.
206   char logfile[PATH_MAX];       // Name or Handle of Log File
207   int loglevel;                 // Log Level (9=highest). Verbosity of log file.
208   int messageids;               // Defines how message id's are stored: 1 = first, 2 = last (default), 3 = all.
209   int voicecall_vts_list;       // Defines how VTS command is sent: 1 = as a list like "1,2,3,4", 2 = single note with one VTS command (default).
210   int voicecall_ignore_modem_response; // Delay defined with TIME: is not breaked even if modem gives some response.
211   int voicecall_hangup_ath;     // If ATH is used instead of AT+CHUP.
212   int voicecall_vts_quotation_marks; // Defines if AT+VTS="n" command is given with quotation marks.
213   int voicecall_cpas;           // Defines if AT+CPAS is used to detect when a call is answered (phone returns OK after ATD).
214   int voicecall_clcc;           // 3.1.12: Defines if AT+CLCC is used to detect when a call is answered (phone returns OK after ATD).
215   int check_memory_method;      // 0 = CPMS not supported, 1 = CPMS supported and must work (default), 2 = CMGD used to check messages, 3 = CMGL is used.
216   char cmgl_value[32];          // With check_memory_method 3, correct value for AT+CMGL= must be given here.
217   char priviledged_numbers[SIZE_PRIVILEDGED_NUMBERS]; // Priviledged numbers in incoming messages.
218   int read_timeout;             // Timeout for reading from a modem, in seconds.
219   int ms_purge_hours;           // Wich check_memory_method 5 (SIM600), messages with missing part(s) are removed from a
220   int ms_purge_minutes;         // modem after timeout defined with these two settings. Both values 0 disables this feature.
221   int ms_purge_read;            // 1 if available parts are read when purge timeout is reached. 0 if parts are only deleted.
222   int detect_message_routing;   // 0 if CMT/CDS detection is disabled.
223   int detect_unexpected_input;  // 0 if if detection is disabled.
224   int unexpected_input_is_trouble; // 0 if unexpected input / routed message should NOT activate trouble.log
225   int adminmessage_limit;       // Limit counter for administrative alert messages. 0 = no limit.
226   int adminmessage_count_clear; // Period to automatically clear administrative alert counter. Value is MINUTES.
227   int status_signal_quality;    // 1 = signal quality is written to status file.
228   int status_include_counters;  // 1 = succeeded, failed and received counters are included in the status line.
229   int communication_delay;      // Time between each put_command (milliseconds), some modems need this.
230   int hangup_incoming_call;     // 1 = if detected unexpected input contains RING and we want to end call.
231   int max_continuous_sending;   // Defines when sending is breaked to do check/do other tasks. Time in seconds.
232   int socket_connection_retries; // 3.1.7: Defines count of retries when socket connection fails.
233   int socket_connection_errorsleeptime; // 3.1.7: Sleeping time after socket connetcion error.
234   int socket_connection_alarm_after; // 3.1.7: Defines after how many failures an alarmhandler is called.
235   int report_device_details;    // Defines if device details are logged when modem process is starting.
236   int using_routed_status_report; // Disables a warning about routed status reports.
237   int routed_status_report_cnma; // Defines if +CNMA acknowledgement is needed to send.
238   int needs_wakeup_at;          // After idle time, some modems may not answer to the first AT command.
239   int keep_messages;            // Defines if messages are not deleted. Smsd continues running.
240   char startstring[100];        // 3.1.7: Command(s) to send to the modem when a devicespooler is starting.
241   int startsleeptime;           // 3.1.7: Second to wait after startstring is sent.
242   char stopstring[100];         // 3.1.7: Command(s) to send to the modem when a devicespooler is stopping.
243   int trust_spool;		// 3.1.9
244   int smsc_pdu;			// 3.1.12: 1 if smsc is included in the PDU.
245   char telnet_login[64];	// 3.1.12: Settings for telnet.
246   char telnet_login_prompt[64];
247   char telnet_login_prompt_ignore[64];
248   char telnet_password[64];
249   char telnet_password_prompt[64];
250   char telnet_cmd[64]; // 3.1.16beta.
251   char telnet_cmd_prompt[100]; // 3.1.16beta.
252   int telnet_crlf; // 3.1.16beta.
253   char wakeup_init[64]; // 3.1.16beta.
254   int signal_quality_ber_ignore; // 3.1.14.
255   int verify_pdu; // 3.1.14.
256   int loglevel_lac_ci; // 3.1.14.
257   int log_not_registered_after; // 3.1.14.
258   int send_retries; // 3.1.16beta.
259   int report_read_timeouts; // 3.1.16beta.
260   int select_pdu_mode; // 3.1.16beta2.
261   char ignore_unexpected_input[SIZE_IGNORE_UNEXPECTED_INPUT]; // 3.1.16beta2.
262   int national_toa_unknown; // 3.1.16beta2.
263   int reply_path; // 3.1.16beta2.
264   char description[64]; // 3.1.16beta2.
265   char text_is_pdu_key[SIZE_TO]; // 3.1.16beta2.
266   int sentsleeptime; // 3.1.16beta2.
267   int poll_faster; // 3.1.16beta2.
268   int read_delay; // 3.1.16beta2. milliseconds
269   int language; //3.1.16beta2.
270   int language_ext; //3.1.16beta2.
271   int notice_ucs2; // 3.1.16beta2.
272   int receive_before_send; // 3.1.17. Now also a modem setting.
273   int delaytime; // 3.1.18.
274   int delaytime_random_start; // 3.1.18.
275   int read_identity_after_suspend; // 3.1.18.
276   int read_configuration_after_suspend; // 3.1.18.
277   int check_sim; // 3.1.21.
278   char check_sim_cmd[64]; // 3.1.21.
279   int check_sim_keep_open; // 3.1.21.
280   char check_sim_reset[64]; // 3.1.21.
281   int check_sim_retries; // 3.1.21.
282   int check_sim_wait; // 3.1.21.
283 } _device;
284 
285 // NOTE for regular run intervals: effective value is at least delaytime.
286 
287 char configfile[PATH_MAX];	// Path to config file
288 char d_spool[PATH_MAX];		// Spool directory
289 char d_failed[PATH_MAX];	// Failed spool directory
290 char d_failed_copy[PATH_MAX];	// 3.1.17.
291 char d_incoming[PATH_MAX];	// Incoming spool directory
292 char d_incoming_copy[PATH_MAX]; // 3.1.16beta2.
293 char d_report[PATH_MAX];	// Incoming report spool directory
294 char d_report_copy[PATH_MAX];	// 3.1.17.
295 char d_phonecalls[PATH_MAX];    // Incoming phonecalls data directory
296 char d_saved[PATH_MAX];         // Directory for smsd's internal use, concatenation storage files etc.
297 char d_sent[PATH_MAX];		// Sent spool directory
298 char d_sent_copy[PATH_MAX];	// 3.1.17.
299 char d_checked[PATH_MAX];	// Spool directory for checked messages (only used when no provider queues used)
300 char eventhandler[PATH_MAX];	// Global event handler program or script
301 char alarmhandler[PATH_MAX];	// Global alarm handler program or script
302 char checkhandler[PATH_MAX];    // Handler that checks if the sms file is valid.
303 int alarmlevel;			// Alarm Level (9=highest). Verbosity of alarm handler.
304 char logfile[PATH_MAX];		// Name or Handle of Log File
305 int  loglevel;			// Log Level (9=highest). Verbosity of log file.
306 _queue queues[NUMBER_OF_MODEMS]; // Queues
307 _device devices[NUMBER_OF_MODEMS]; // Modem devices
308 int delaytime;			// sleep-time after workless
309 int delaytime_mainprocess;      // sleep-time after workless, main process. If -1, delaytime is used.
310 int blocktime;			// sleep-time after multiple errors
311 int blockafter;                 // Block modem after n errors
312 int errorsleeptime;		// sleep-time after each error
313 int autosplit;			// Splitting of large text messages 0=no, 1=yes 2=number with text, 3=number with UDH
314 int receive_before_send;	// if 1 smsd tries to receive one message before sending
315 int store_received_pdu;         // 0=no, 1=unsupported pdu's only, 2=unsupported and 8bit/unicode, 3=all
316 int store_sent_pdu;             // 0=no, 1=failed pdu's only, 2=failed and 8bit/unicode, 3=all
317 int validity_period;            // Validity period for messages.
318 int decode_unicode_text;        // 1 if unicode text is decoded internally.
319 int internal_combine;           // 1 if multipart message is combined internally.
320 int internal_combine_binary;    // 1 if multipart binary message is combined internally. Defaults to internal_combine.
321 int keep_filename;              // 0 if unique filename is created to each directory when a message file is moved.
322 int store_original_filename;    // 1 if an original filename is saved to message file when it's moved from
323                                 // outgoing directory to spooler. Works together with keep_filename.
324 int date_filename;              // 1 or 2 if YYYYMMDD is included to the filename of incoming message.
325 char regular_run[PATH_MAX];     // Script/program which is run regularly.
326 int regular_run_interval;       // Number of seconds between running a regular_run script/progdam.
327 char admin_to[SIZE_TO];         // Destination number for administrative messages.
328 int filename_preview;           // Number of chars of message text to concatenate to filename.
329 int incoming_utf8;              // 1 if incoming files are saved using UTF-8 character set.
330 int outgoing_utf8;              // 1 if outgoing files are automatically converted from UTF-8 to ISO and GSM.
331 int log_charconv;               // 1 if character set conversion is logged.
332 int log_single_lines;           // 1 if linefeeds are removed from the modem response to be logged.
333 int executable_check;           // 0 if eventhandler and other executables are NOT checked during the startup checking.
334 int keep_messages;              // For testing purposes: messages are not deleted and smsd stops after first run.
335 char priviledged_numbers[SIZE_PRIVILEDGED_NUMBERS]; // Priviledged numbers in incoming messages.
336 int ic_purge_hours;             // If internal_combine is used, concatenation storage is checked every ic_purge_interval minutes
337 int ic_purge_minutes;           // and if there is message parts older than defined, they are handled or deleted.
338 int ic_purge_read;              // 1 = message parts are stored as single messages. 0 = parts are just deleted.
339 int ic_purge_interval;          //
340 char shell[PATH_MAX];           // Shell used to run eventhandler, defaults to /bin/sh
341 char adminmessage_device[32];   // Name of device used to send administrative messages of mainspooler.
342 int smart_logging;              // 1 = if loglevel is less than 7, degug log is written is there has been any errors.
343 int status_signal_quality;      // 1 = signal quality is written to status file.
344 int status_include_counters;    // 1 = succeeded, failed and received counters are included in the status line.
345 int status_include_uptime;      // 3.1.16beta: 1 = include started & uptime line in the status file.
346 int hangup_incoming_call;       // 1 = if detected unexpected input contains RING and we want to end call.
347 int max_continuous_sending;     // Defines when sending is breaked to do check/do other tasks. Time in minutes.
348 int voicecall_hangup_ath;       // If ATH is used instead of AT+CHUP.
349 
350 // 3.1.5:
351 int trust_outgoing;             // 1 = it's _sure_ that files are created by rename AND permissions are correct. Speeds up spooling.
352 
353 // 3.1.5:
354 int ignore_outgoing_priority;   // 1 = Priority: high header is not checked. Speeds up spooling.
355 
356 // 3.1.7:
357 int ignore_exec_output;         // 1 = stdout and stderr of eventhandlers is _not_ checked.
358 
359 // 3.1.7:
360 mode_t conf_umask;              // File mode creation mask for smsd and modem processes.
361 
362 // 3.1.7:
363 int trim_text;                  // 1 = trailing whitespaces are removed from text:
364 
365 // 3.1.7:
366 int use_linux_ps_trick;         // 1 = change argv[0] to "smsd: MAINPROCESS", "smsd: GSM1" etc.
367 
368 // 3.1.7:
369 int log_unmodified;
370 
371 // 3.1.7:
372 char suspend_filename[PATH_MAX];
373 
374 // 3.1.9:
375 int spool_directory_order;
376 
377 // 3.1.9: 1 if read_from_modem is logged.
378 int log_read_from_modem;
379 
380 // 3.1.16beta2: log_read_timing for performance tuning.
381 int log_read_timing;
382 
383 // 3.1.16beta:
384 int log_response_time;
385 
386 // 3.1.16beta2:
387 int default_alphabet;
388 
389 // 3.1.17: Child process for the mainprocess:
390 char mainprocess_child[PATH_MAX];
391 char mainprocess_child_args[PATH_MAX];
392 
393 // 3.1.17: Notifier for the mainprocess:
394 int mainprocess_notifier;
395 
396 // 3.1.17: If *_copy was made, evenhandler can use it instead of original file:
397 int eventhandler_use_copy;
398 
399 // 3.1.17: This defines how long to sleep while looping:
400 int sleeptime_mainprocess;
401 
402 // 3.1.17: Defines how often PID is checked to detect if another smsd is running:
403 int check_pid_interval;
404 
405 // 3.1.18: start script/program for mainprocess:
406 char mainprocess_start[PATH_MAX];
407 char mainprocess_start_args[PATH_MAX];
408 
409 int message_count;              // Counter for sent messages. Multipart message is one message.
410 
411 volatile sig_atomic_t break_workless_delay; // To break the delay when SIGCONT is received.
412 volatile sig_atomic_t terminate; // To terminate when SIGTERM is received.
413 
414 char username[65];              // user and group name which are used to run.
415 char groupname[65];             // (max length is just a guess)
416 
417 char infofile[PATH_MAX];        // Hepler file for stopping the smsd smoothly.
418 char pidfile[PATH_MAX];         // File where a process id is stored.
419 
420 // Command line arguments:
421 char arg_username[65];
422 char arg_groupname[65];
423 char arg_infofile[PATH_MAX];
424 char arg_pidfile[PATH_MAX];
425 char arg_logfile[PATH_MAX];
426 int arg_terminal;
427 // 3.1.7:
428 char arg_7bit_packed[512];
429 int do_encode_decode_arg_7bit_packed;
430 
431 int terminal;                   // 1 if smsd is communicating with terminal.
432 pid_t device_pids[NUMBER_OF_MODEMS]; // Pid's of modem processes.
433 char run_info[PATH_MAX];        // Information about external script/program execution.
434 
435 char communicate[32];           // Device name for terminal communication mode.
436 
437 char international_prefixes[PATH_MAX +1];
438 char national_prefixes[PATH_MAX +1];
439 
440 // Storage for startup errors:
441 char *startup_err_str;
442 int startup_err_count;
443 
444 // Storage for PDU's:
445 char *incoming_pdu_store;
446 char *outgoing_pdu_store;
447 char *routed_pdu_store;
448 
449 // Storage for getfile errors:
450 char *getfile_err_store;
451 
452 // Text buffer for error messages:
453 char tb[SIZE_TB];
454 
455 // Buffer for SIM memory checking:
456 char *check_memory_buffer;
457 size_t check_memory_buffer_size;
458 
459 int os_cygwin;                  // 1 if we are on Cygwin.
460 
461 char language_file[PATH_MAX];   // File name of translated headers.
462 char yes_chars[SIZE_HEADER];    // Characters which mean "yes" in the yesno() question.
463 char no_chars[SIZE_HEADER];     // See details inside read_translation() function.
464 char yes_word[SIZE_HEADER];     // "yes" printed as an output.
465 char no_word[SIZE_HEADER];      // "no"
466 char datetime_format[SIZE_HEADER]; // strftime format string for time stamps (not inside status reports).
467 char logtime_format[SIZE_HEADER]; // 3.1.7: strftime format string for logging time stamps
468 char date_filename_format[SIZE_HEADER]; // 3.1.7: strftime format string for date_filename
469 int translate_incoming;         // 0 if incoming message headers are NOT transtaled.
470 
471 // 3.1.14:
472 int logtime_us;
473 int logtime_ms;
474 
475 // 3.1.14:
476 int shell_test;
477 
478 // Next two are for debugging purposes:
479 int enable_smsd_debug;
480 char smsd_debug[SIZE_SMSD_DEBUG]; // Header of an outgoing message file.
481 
482 // 3.1.20: Alt keys in communication mode:
483 #define COMMUNICATE_A_KEY_COUNT 10
484 char communicate_a_keys[COMMUNICATE_A_KEY_COUNT][256];
485 
486 /* initialize all variable with default values */
487 
488 void initcfg();
489 
490 
491 /* read the config file */
492 
493 int readcfg();
494 
495 
496 /* Retuns the array-index and the directory of a queue or -1 if
497    not found. Name is the name of the queue or a phone number. */
498 
499 int getqueue(char* name, char* directory);
500 
501 
502 /* Returns the array-index of a device or -1 if not found */
503 
504 int getdevice(char* name);
505 
506 
507 /* Show help */
508 
509 void help();
510 
511 /* parse arguments */
512 
513 void parsearguments(int argc,char** argv);
514 
515 int startup_check(int result);
516 
517 void abnormal_termination(int all);
518 
519 #ifdef __GNUC__
520 char *tb_sprintf(char* format, ...) __attribute__ ((format(printf, 1, 2)));
521 #else
522 char *tb_sprintf(char* format, ...);
523 #endif
524 
525 int savephonecall(char *entry_number, int entry_type, char *entry_text);
526 
527 int refresh_configuration();
528 
529 #endif
530