Skip to content
Snippets Groups Projects
Commit af86e3d5 authored by rswindell's avatar rswindell
Browse files

Now ignores comments following string-style .ini key values (as shown in the

example sexpots.ini in docs/sexpots.txt) - now truncates string values (com dev
name, init strings, etc.) at first white-space char. Bug reported by Netsurge.
parent 7346893d
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* * * *
* Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html * * Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
* * * *
* This program is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License * * modify it under the terms of the GNU General Public License *
...@@ -59,8 +59,8 @@ ...@@ -59,8 +59,8 @@
/* global vars */ /* global vars */
BOOL daemonize=FALSE; BOOL daemonize=FALSE;
char termtype[TELNET_TERM_MAXLEN+1] = NAME; char termtype[INI_MAX_VALUE_LEN+1] = NAME;
char termspeed[TELNET_TERM_MAXLEN+1] = "28800,28800"; /* "tx,rx", max length not defined */ char termspeed[INI_MAX_VALUE_LEN+1] = "28800,28800"; /* "tx,rx", max length not defined */
char revision[16]; char revision[16];
char mdm_init[INI_MAX_VALUE_LEN] = "AT&F"; char mdm_init[INI_MAX_VALUE_LEN] = "AT&F";
...@@ -1328,6 +1328,20 @@ BOOL WINAPI ControlHandler(DWORD CtrlType) ...@@ -1328,6 +1328,20 @@ BOOL WINAPI ControlHandler(DWORD CtrlType)
} }
#endif #endif
/****************************************************************************/
/****************************************************************************/
char* iniGetExistingWord(str_list_t list, const char* section, const char* key
,const char* deflt, char* value)
{
char* p;
if((p=iniGetExistingString(list, section, key, deflt, value)) !=NULL) {
FIND_WHITESPACE(value);
*value=0;
}
return p;
}
void parse_ini_file(const char* ini_fname) void parse_ini_file(const char* ini_fname)
{ {
FILE* fp; FILE* fp;
...@@ -1349,7 +1363,7 @@ void parse_ini_file(const char* ini_fname) ...@@ -1349,7 +1363,7 @@ void parse_ini_file(const char* ini_fname)
/* [COM] Section */ /* [COM] Section */
section="COM"; section="COM";
iniGetExistingString(list, section, "Device", NULL, com_dev); iniGetExistingWord(list, section, "Device", NULL, com_dev);
com_baudrate = iniGetLongInt(list, section, "BaudRate", com_baudrate); com_baudrate = iniGetLongInt(list, section, "BaudRate", com_baudrate);
com_hangup = iniGetBool(list, section, "Hangup", com_hangup); com_hangup = iniGetBool(list, section, "Hangup", com_hangup);
hangup_attempts = iniGetInteger(list, section, "HangupAttempts", hangup_attempts); hangup_attempts = iniGetInteger(list, section, "HangupAttempts", hangup_attempts);
...@@ -1360,15 +1374,15 @@ void parse_ini_file(const char* ini_fname) ...@@ -1360,15 +1374,15 @@ void parse_ini_file(const char* ini_fname)
/* [Modem] Section */ /* [Modem] Section */
section="Modem"; section="Modem";
iniGetExistingString(list, section, "Init", "", mdm_init); iniGetExistingWord(list, section, "Init", "", mdm_init);
iniGetExistingString(list, section, "AutoAnswer", "", mdm_autoans); iniGetExistingWord(list, section, "AutoAnswer", "", mdm_autoans);
iniGetExistingString(list, section, "Cleanup", "", mdm_cleanup); iniGetExistingWord(list, section, "Cleanup", "", mdm_cleanup);
iniGetExistingString(list, section, "EnableCallerID", "", mdm_cid); iniGetExistingWord(list, section, "EnableCallerID", "", mdm_cid);
mdm_timeout = iniGetInteger(list, section, "Timeout", mdm_timeout); mdm_timeout = iniGetInteger(list, section, "Timeout", mdm_timeout);
/* [TCP] Section */ /* [TCP] Section */
section="TCP"; section="TCP";
iniGetExistingString(list, section, "Host", NULL, host); iniGetExistingWord(list, section, "Host", NULL, host);
port = iniGetShortInt(list, section, "Port", port); port = iniGetShortInt(list, section, "Port", port);
tcp_nodelay = iniGetBool(list,section,"NODELAY", tcp_nodelay); tcp_nodelay = iniGetBool(list,section,"NODELAY", tcp_nodelay);
...@@ -1377,15 +1391,15 @@ void parse_ini_file(const char* ini_fname) ...@@ -1377,15 +1391,15 @@ void parse_ini_file(const char* ini_fname)
telnet = iniGetBool(list,section,"Enabled", telnet); telnet = iniGetBool(list,section,"Enabled", telnet);
debug_telnet = iniGetBool(list,section,"Debug", debug_telnet); debug_telnet = iniGetBool(list,section,"Debug", debug_telnet);
telnet_advertise_cid = iniGetBool(list,section,"AdvertiseLocation", telnet_advertise_cid); telnet_advertise_cid = iniGetBool(list,section,"AdvertiseLocation", telnet_advertise_cid);
iniGetExistingString(list, section, "TermType", NULL, termtype); iniGetExistingWord(list, section, "TermType", NULL, termtype);
iniGetExistingString(list, section, "TermSpeed", NULL, termspeed); iniGetExistingWord(list, section, "TermSpeed", NULL, termspeed);
/* [Ident] Section */ /* [Ident] Section */
section="Ident"; section="Ident";
ident = iniGetBool(list,section,"Enabled", ident); ident = iniGetBool(list,section,"Enabled", ident);
ident_port = iniGetShortInt(list, section, "Port", ident_port); ident_port = iniGetShortInt(list, section, "Port", ident_port);
ident_interface = iniGetIpAddress(list, section, "Interface", ident_interface); ident_interface = iniGetIpAddress(list, section, "Interface", ident_interface);
iniGetExistingString(list, section, "Response", NULL, ident_response); iniGetExistingWord(list, section, "Response", NULL, ident_response);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment