EMSI handshake FTSC-0088 compliant, protocol_order, EMSI TZUTC
This commit is contained in:
@@ -84,6 +84,8 @@ s_conf_entry bforce_config[BFORCE_NUMBER_OF_KEYWORDS+1] = {
|
||||
CONF_KEY(emsi_FR_time, CT_STRING),
|
||||
CONF_KEY(emsi_OH_time, CT_STRING),
|
||||
CONF_KEY(emsi_slave_sends_nak, CT_BOOLEAN),
|
||||
CONF_KEY(emsi_send_tz, CT_BOOLEAN),
|
||||
CONF_KEY(emsi_send_time, CT_BOOLEAN),
|
||||
CONF_KEY(filebox, CT_FILEBOX),
|
||||
CONF_KEY(filebox_directory, CT_PATH),
|
||||
CONF_KEY(flags, CT_STRING),
|
||||
@@ -144,6 +146,7 @@ s_conf_entry bforce_config[BFORCE_NUMBER_OF_KEYWORDS+1] = {
|
||||
CONF_KEY(password, CT_PASSWORD),
|
||||
CONF_KEY(phone, CT_STRING),
|
||||
CONF_KEY(phone_translate, CT_TRANSLATE),
|
||||
CONF_KEY(proto_order, CT_STRING),
|
||||
CONF_KEY(recode_file_in, CT_STRING),
|
||||
CONF_KEY(recode_file_out, CT_STRING),
|
||||
CONF_KEY(recode_intro_in, CT_STRING),
|
||||
|
||||
@@ -123,8 +123,8 @@ int tcpip_connect(const char *hostname, e_tcpmode tcpmode)
|
||||
port = "binkp";
|
||||
else if( tcpmode == TCPMODE_TELNET )
|
||||
port = "telnet";
|
||||
else /* Default service name is "fido" */
|
||||
port = "fido";
|
||||
else /* Can not rely on /etc/services - it is not well-known port */
|
||||
port = "60179";
|
||||
|
||||
if( ISDEC(port) )
|
||||
server.sin_port = htons(atoi(port));
|
||||
|
||||
@@ -77,7 +77,7 @@ static char *lock_getname(const char *lockdir, const s_modemport *modemport)
|
||||
|
||||
ASSERT(modemport != NULL);
|
||||
|
||||
if( lockdir && *lockdir )
|
||||
if( *lockdir )
|
||||
lckname = (char *)xstrcpy(lockdir);
|
||||
else
|
||||
lckname = (char *)xstrcpy(BFORCE_LOCK_DIR);
|
||||
@@ -314,7 +314,7 @@ int port_lock(const char *lockdir, const s_modemport *modemport)
|
||||
char *lckname;
|
||||
char *tmpname, *p_tmpname;
|
||||
|
||||
if( lockdir && *lockdir )
|
||||
if( *lockdir )
|
||||
tmpname = xstrcpy(lockdir);
|
||||
else
|
||||
tmpname = xstrcpy(BFORCE_LOCK_DIR);
|
||||
|
||||
@@ -598,6 +598,8 @@ void emsi_set_sysinfo(s_emsi *emsi, s_emsi *remote_emsi, int hrc,
|
||||
s_cval_entry *addr_ptr;
|
||||
s_cval_entry *hide_ptr;
|
||||
s_faddr *primary = NULL;
|
||||
char xdt[EMSI_MAXXDATETIME+1];
|
||||
time_t xtm;
|
||||
|
||||
const long options = conf_options(cf_options);
|
||||
const long speed = conf_number(cf_max_speed);
|
||||
@@ -737,6 +739,10 @@ void emsi_set_sysinfo(s_emsi *emsi, s_emsi *remote_emsi, int hrc,
|
||||
{ emsi->compcodes.JAN = 1; }
|
||||
if( (options & OPTIONS_NO_HYDRA) != OPTIONS_NO_HYDRA )
|
||||
{ emsi->compcodes.HYD = 1; }
|
||||
DEB((D_HSHAKE,"Generated compcodes for caller: NCP:%x.ZMO:%x.ZAP:%x.DZA:%x.JAN:%x.HYD:%x.KER:%x.SLK:%x.TZA:%x",
|
||||
emsi->compcodes.NCP, emsi->compcodes.ZMO, emsi->compcodes.ZAP,
|
||||
emsi->compcodes.DZA, emsi->compcodes.JAN, emsi->compcodes.HYD,
|
||||
emsi->compcodes.KER, emsi->compcodes.SLK, emsi->compcodes.TZA));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -813,6 +819,22 @@ void emsi_set_sysinfo(s_emsi *emsi, s_emsi *remote_emsi, int hrc,
|
||||
strnxcpy(emsi->flags, p_flags ? p_flags : "MO", sizeof(emsi->flags));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Data for {TZUTC} and {XDATETIME} field */
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
if ( conf_boolean(cf_emsi_send_tz) ) {
|
||||
emsi->have_tzutc = 1;
|
||||
emsi->tzutc = (int)(time_gmtoffset());
|
||||
}
|
||||
|
||||
if ( conf_boolean(cf_emsi_send_time) ) {
|
||||
emsi->have_xdatetime = 1;
|
||||
|
||||
strnxcpy(xdt,time_string_format(xdt, EMSI_MAXXDATETIME, "%d.%m.%Y %H:%M:%S %z", xtm),EMSI_MAXXDATETIME);
|
||||
strnxcpy(emsi->xdatetime, xdt, sizeof(emsi->xdatetime));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Data for {OHFR} field */
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
@@ -134,6 +134,7 @@ int emsi_incoming(s_handshake_protocol *THIS)
|
||||
int rc = HRC_OK;
|
||||
s_emsi *remote_emsi = NULL;
|
||||
s_emsi *local_emsi = NULL;
|
||||
char *p = NULL;
|
||||
|
||||
ASSERT(THIS);
|
||||
ASSERT(THIS->remote_data);
|
||||
@@ -198,18 +199,46 @@ int emsi_incoming(s_handshake_protocol *THIS)
|
||||
|
||||
/*
|
||||
* Set protocol that we will use
|
||||
* EMSI-II compatible as of v0.25
|
||||
*/
|
||||
if( remote_emsi->compcodes.HYD && !(options & OPTIONS_NO_HYDRA) )
|
||||
THIS->protocol = PROT_HYDRA;
|
||||
else if( remote_emsi->compcodes.ZAP && !(options & OPTIONS_NO_ZEDZAP) )
|
||||
THIS->protocol = PROT_ZEDZAP;
|
||||
else if( remote_emsi->compcodes.ZMO && !(options & OPTIONS_NO_ZMODEM) )
|
||||
THIS->protocol = PROT_ZMODEM;
|
||||
else /* NCP */
|
||||
{
|
||||
if ( remote_emsi->compcodes.EII ) {
|
||||
/* EMSI-II relies on protocol order sent by CALLER
|
||||
* we must agree on first matching protocol
|
||||
*/
|
||||
p = xstrcpy( remote_emsi->proto_order );
|
||||
THIS->protocol = PROT_NOPROT;
|
||||
rc = HRC_NO_PROTOS;
|
||||
for ( p = strtok( p, "," ); p ; p=strtok( NULL, "," ) ) {
|
||||
if ( !strcmp(p, "ZMO") && !(options & OPTIONS_NO_ZMODEM)) {
|
||||
if ( THIS->protocol == PROT_NOPROT ) THIS->protocol = PROT_ZMODEM;
|
||||
}
|
||||
if ( !strcmp(p, "HYD") && !(options & OPTIONS_NO_HYDRA)) {
|
||||
if ( THIS->protocol == PROT_NOPROT ) THIS->protocol = PROT_HYDRA;
|
||||
}
|
||||
if ( !strcmp(p, "ZAP") && !(options & OPTIONS_NO_ZEDZAP)) {
|
||||
if ( THIS->protocol == PROT_NOPROT ) THIS->protocol = PROT_ZEDZAP;
|
||||
}
|
||||
if ( !strcmp(p, "DZA") && !(options & OPTIONS_NO_DIRZAP)) {
|
||||
if ( THIS->protocol == PROT_NOPROT ) THIS->protocol = PROT_DIRZAP;
|
||||
}
|
||||
/* if ( !strcmp(p, "JAN") && !(options & OPTIONS_NO_JANUS)) {
|
||||
if ( THIS->protocol == PROT_NOPROT ) THIS->protocol = PROT_JANUS;
|
||||
} */
|
||||
}
|
||||
|
||||
} else {
|
||||
/* EMSI-I relies on our self order, not the CALLER's */
|
||||
if( remote_emsi->compcodes.HYD && !(options & OPTIONS_NO_HYDRA) )
|
||||
THIS->protocol = PROT_HYDRA;
|
||||
else if( remote_emsi->compcodes.ZAP && !(options & OPTIONS_NO_ZEDZAP) )
|
||||
THIS->protocol = PROT_ZEDZAP;
|
||||
else if( remote_emsi->compcodes.ZMO && !(options & OPTIONS_NO_ZMODEM) )
|
||||
THIS->protocol = PROT_ZMODEM;
|
||||
else /* NCP */
|
||||
{
|
||||
THIS->protocol = PROT_NOPROT;
|
||||
}
|
||||
}
|
||||
if ( THIS->protocol == PROT_NOPROT ) rc = HRC_NO_PROTOS;
|
||||
|
||||
/*
|
||||
* Check EMSI flags and set corresponding local HOLD flags
|
||||
|
||||
+161
-13
@@ -103,6 +103,10 @@ char *emsi_createdat(s_emsi *emsi)
|
||||
char *tmp = NULL;
|
||||
char buf[100];
|
||||
char abuf[BF_MAXADDRSTR+1];
|
||||
char *p_order = NULL;
|
||||
char *ord = NULL;
|
||||
|
||||
|
||||
|
||||
tmp = (char *)xstrcpy("**EMSI_DAT0000");
|
||||
|
||||
@@ -179,14 +183,79 @@ char *emsi_createdat(s_emsi *emsi)
|
||||
tmp = add_char(tmp, '}');
|
||||
}
|
||||
|
||||
/* compatibility_codes */
|
||||
/* compatibility_codes (EMSI behavior as FTS-0088) */
|
||||
tmp = add_char(tmp, '{');
|
||||
if( emsi->compcodes.NCP ) tmp = add_str(tmp, "NCP,");
|
||||
if( emsi->compcodes.ZMO ) tmp = add_str(tmp, "ZMO,");
|
||||
if( emsi->compcodes.ZAP ) tmp = add_str(tmp, "ZAP,");
|
||||
if( emsi->compcodes.DZA ) tmp = add_str(tmp, "DZA,");
|
||||
if( emsi->compcodes.JAN ) tmp = add_str(tmp, "JAN,");
|
||||
if( emsi->compcodes.HYD ) tmp = add_str(tmp, "HYD,");
|
||||
|
||||
p_order = conf_string(cf_proto_order);
|
||||
|
||||
if ( !p_order ) {
|
||||
if( emsi->compcodes.HYD ) tmp = add_str(tmp, "HYD,");
|
||||
if( emsi->compcodes.JAN ) tmp = add_str(tmp, "JAN,");
|
||||
if( emsi->compcodes.DZA ) tmp = add_str(tmp, "DZA,");
|
||||
if( emsi->compcodes.ZAP ) tmp = add_str(tmp, "ZAP,");
|
||||
if( emsi->compcodes.ZMO ) tmp = add_str(tmp, "ZMO,");
|
||||
if( emsi->compcodes.TZA ) tmp = add_str(tmp, "TZA,");
|
||||
if( emsi->compcodes.SLK ) tmp = add_str(tmp, "SLK,");
|
||||
if( emsi->compcodes.KER ) tmp = add_str(tmp, "KER,");
|
||||
if( emsi->compcodes.NCP ) tmp = add_str(tmp, "NCP,");
|
||||
} else {
|
||||
ord = xmalloc(4);
|
||||
DEB((D_HSHAKE,"Protocol order found: %s", p_order));
|
||||
ord = strncpy(ord, p_order,3);
|
||||
ord[3] = '\0';
|
||||
DEB((D_HSHAKE,"Protocol order chunk: %s", ord));
|
||||
if ( ord == NULL )
|
||||
DEB((D_HSHAKE,"EMSI create order error"));
|
||||
if ( !strcmp(ord,"HYD") )
|
||||
if ( emsi->compcodes.HYD) tmp = add_str(tmp, "HYD,");
|
||||
if ( !strcmp(ord,"JAN") )
|
||||
if ( emsi->compcodes.JAN) tmp = add_str(tmp, "JAN,");
|
||||
if ( !strcmp(ord,"DZA") )
|
||||
if ( emsi->compcodes.DZA) tmp = add_str(tmp, "DZA,");
|
||||
if ( !strcmp(ord,"ZAP") )
|
||||
if ( emsi->compcodes.ZAP) tmp = add_str(tmp, "ZAP,");
|
||||
if ( !strcmp(ord,"ZMO") )
|
||||
if ( emsi->compcodes.ZMO) tmp = add_str(tmp, "ZMO,");
|
||||
if ( !strcmp(ord,"TZA") )
|
||||
if ( emsi->compcodes.TZA) tmp = add_str(tmp, "TZA,");
|
||||
if ( !strcmp(ord,"SLK") )
|
||||
if ( emsi->compcodes.SLK) tmp = add_str(tmp, "SLK,");
|
||||
if ( !strcmp(ord,"KER") )
|
||||
if ( emsi->compcodes.KER) tmp = add_str(tmp, "KER,");
|
||||
if ( !strcmp(ord,"NCP") )
|
||||
if ( emsi->compcodes.NCP) tmp = add_str(tmp, "NCP,");
|
||||
p_order = strchr(p_order, ',');
|
||||
if ( p_order ) p_order = p_order+1; /* skip ',' */
|
||||
while ( p_order ) {
|
||||
ord = strncpy(ord, p_order,3);
|
||||
ord[3] = '\0';
|
||||
DEB((D_HSHAKE,"Protocol order chunk: %s", ord));
|
||||
if ( ord == NULL )
|
||||
DEB((D_HSHAKE,"EMSI create order error"));
|
||||
if ( !strcmp(ord,"HYD") )
|
||||
if ( emsi->compcodes.HYD) tmp = add_str(tmp, "HYD,");
|
||||
if ( !strcmp(ord,"JAN") )
|
||||
if ( emsi->compcodes.JAN) tmp = add_str(tmp, "JAN,");
|
||||
if ( !strcmp(ord,"DZA") )
|
||||
if ( emsi->compcodes.DZA) tmp = add_str(tmp, "DZA,");
|
||||
if ( !strcmp(ord,"ZAP") )
|
||||
if ( emsi->compcodes.ZAP) tmp = add_str(tmp, "ZAP,");
|
||||
if ( !strcmp(ord,"ZMO") )
|
||||
if ( emsi->compcodes.ZMO) tmp = add_str(tmp, "ZMO,");
|
||||
if ( !strcmp(ord,"TZA") )
|
||||
if ( emsi->compcodes.TZA) tmp = add_str(tmp, "TZA,");
|
||||
if ( !strcmp(ord,"SLK") )
|
||||
if ( emsi->compcodes.SLK) tmp = add_str(tmp, "SLK,");
|
||||
if ( !strcmp(ord,"KER") )
|
||||
if ( emsi->compcodes.KER) tmp = add_str(tmp, "KER,");
|
||||
if ( !strcmp(ord,"NCP") )
|
||||
if ( emsi->compcodes.NCP) tmp = add_str(tmp, "NCP,");
|
||||
p_order = strchr(p_order, ',');
|
||||
if ( p_order ) p_order = p_order+1; /* skip ',' */
|
||||
}
|
||||
free(ord);
|
||||
}
|
||||
|
||||
if( emsi->compcodes.FRQ ) tmp = add_str(tmp, "FRQ,");
|
||||
if( emsi->compcodes.NRQ ) tmp = add_str(tmp, "NRQ,");
|
||||
if( emsi->compcodes.ARC ) tmp = add_str(tmp, "ARC,");
|
||||
@@ -325,10 +394,15 @@ char *emsi_createdat(s_emsi *emsi)
|
||||
|
||||
tmp = add_char(tmp, '{');
|
||||
tmp = add_char(tmp, '[');
|
||||
sprintf(buf, "+%04d", emsi->tzutc);
|
||||
tmp = add_str(tmp, buf);
|
||||
/* BUGGY */
|
||||
// sprintf(buf, "+%04d", emsi->tzutc);
|
||||
ord = xmalloc(6);
|
||||
ord = xstrcpy(time_string_gmtoffset(ord));
|
||||
ord[5] = '\0';
|
||||
tmp = add_str(tmp, ord);
|
||||
tmp = add_char(tmp, ']');
|
||||
tmp = add_char(tmp, '}');
|
||||
free(ord);
|
||||
}
|
||||
|
||||
/* {XDATE} indentifier.. What's the fucking invention :-/
|
||||
@@ -450,6 +524,8 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
|
||||
{
|
||||
int i;
|
||||
char *tmp, *p, *q, *n;
|
||||
unsigned int tzh, tzm,tzn ;
|
||||
char *tzc, *otmp;
|
||||
|
||||
while( (tmp=get_field(&emsi_dat, '{', '}')) != NULL )
|
||||
{
|
||||
@@ -525,13 +601,64 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
|
||||
/* compatibility codes */
|
||||
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
|
||||
DEB((D_HSHAKE, "parse_emsidat: compatibility codes: %s", p));
|
||||
emsi->proto_order[0] = '\0';
|
||||
|
||||
for( p = strtok(p, ","); p; p=strtok(NULL, ",") )
|
||||
{
|
||||
if( !strcmp(p, "ZMO") ) emsi->compcodes.ZMO = 1;
|
||||
/* if( !strcmp(p, "ZMO") ) emsi->compcodes.ZMO = 1;
|
||||
else if( !strcmp(p, "ZAP") ) emsi->compcodes.ZAP = 1;
|
||||
else if( !strcmp(p, "DZA") ) emsi->compcodes.DZA = 1;
|
||||
else if( !strcmp(p, "JAN") ) emsi->compcodes.JAN = 1;
|
||||
else if( !strcmp(p, "HYD") ) emsi->compcodes.HYD = 1;
|
||||
*/
|
||||
if ( !strcmp(p, "ZMO") ) {
|
||||
emsi->compcodes.ZMO = 1;
|
||||
otmp = strcat(emsi->proto_order,"ZMO,");
|
||||
strcpy(emsi->proto_order, otmp);
|
||||
DEB((D_HSHAKE,"Parse_emsidat: ordered proto added: %s", otmp));
|
||||
}
|
||||
else if ( !strcmp(p, "ZAP") ) {
|
||||
emsi->compcodes.ZAP = 1;
|
||||
otmp = strcat(emsi->proto_order,"ZAP,");
|
||||
strcpy(emsi->proto_order, otmp);
|
||||
DEB((D_HSHAKE,"Parse_emsidat: ordered proto added: %s", otmp));
|
||||
}
|
||||
else if ( !strcmp(p, "DZA") ) {
|
||||
emsi->compcodes.DZA = 1;
|
||||
otmp = strcat(emsi->proto_order,"DZA,");
|
||||
strcpy(emsi->proto_order, otmp);
|
||||
DEB((D_HSHAKE,"Parse_emsidat: ordered proto added: %s", otmp));
|
||||
}
|
||||
else if ( !strcmp(p, "JAN") ) {
|
||||
emsi->compcodes.JAN = 1;
|
||||
otmp = strcat(emsi->proto_order,"JAN,");
|
||||
strcpy(emsi->proto_order, otmp);
|
||||
DEB((D_HSHAKE,"Parse_emsidat: ordered proto added: %s", otmp));
|
||||
}
|
||||
else if ( !strcmp(p, "HYD") ) {
|
||||
emsi->compcodes.HYD = 1;
|
||||
otmp = strcat(emsi->proto_order,"HYD,");
|
||||
strcpy(emsi->proto_order, otmp);
|
||||
DEB((D_HSHAKE,"Parse_emsidat: ordered proto added: %s", otmp));
|
||||
}
|
||||
else if ( !strcmp(p, "KER") ) {
|
||||
emsi->compcodes.KER = 1;
|
||||
otmp = strcat(emsi->proto_order,"KER,");
|
||||
strcpy(emsi->proto_order, otmp);
|
||||
DEB((D_HSHAKE,"Parse_emsidat: ordered proto added: %s", otmp));
|
||||
}
|
||||
else if ( !strcmp(p, "TZA") ) {
|
||||
emsi->compcodes.TZA = 1;
|
||||
otmp = strcat(emsi->proto_order,"TZA,");
|
||||
strcpy(emsi->proto_order, otmp);
|
||||
DEB((D_HSHAKE,"Parse_emsidat: ordered proto added: %s", otmp));
|
||||
}
|
||||
else if ( !strcmp(p, "SLK") ) {
|
||||
emsi->compcodes.SLK = 1;
|
||||
otmp = strcat(emsi->proto_order,"SLK,");
|
||||
strcpy(emsi->proto_order, otmp);
|
||||
DEB((D_HSHAKE,"Parse_emsidat: ordered proto added: %s", otmp));
|
||||
}
|
||||
else if( !strcmp(p, "NCP") ) emsi->compcodes.NCP = 1;
|
||||
else if( !strcmp(p, "NRQ") ) emsi->compcodes.NRQ = 1;
|
||||
else if( !strcmp(p, "ARC") ) emsi->compcodes.ARC = 1;
|
||||
@@ -542,6 +669,9 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
|
||||
else if( !strcmp(p, "BBS") ) emsi->compcodes.BBS = 1;
|
||||
else if( !strcmp(p, "HFR") ) emsi->compcodes.HFR = 1;
|
||||
}
|
||||
/* Delete last comma from order list */
|
||||
emsi->proto_order[strlen(emsi->proto_order)-1] = '\0';
|
||||
DEB((D_HSHAKE,"Ordered compcodes: %s",emsi->proto_order));
|
||||
|
||||
/* mailer information */
|
||||
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
|
||||
@@ -645,14 +775,32 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
|
||||
if( *p ) strnxcpy(emsi->xdatetime, p, sizeof(emsi->xdatetime));
|
||||
}
|
||||
else if( strcmp(tmp, "TZUTC") == 0 )
|
||||
{
|
||||
emsi->have_tzutc = 1;
|
||||
|
||||
{
|
||||
if( (p=get_field(&emsi_dat, '{', '}')) == NULL ) return(1);
|
||||
if( (p=get_field(&p, '[', ']')) == NULL ) return(1);
|
||||
/* Parse EMSI TZUTC in fmt (+|-)HHMM */
|
||||
if( *p ) {
|
||||
tzc = malloc(2);
|
||||
DEB((D_HSHAKE, "Got TZUTC=%s for parsing", p));
|
||||
tzn = sscanf( p, "%1c%02u%02u", tzc, &tzh, &tzm);
|
||||
tzc[1] = '\0';
|
||||
if ( tzn == 3) {
|
||||
DEB((D_HSHAKE, "Got TZC=%s , H=%u, M=%u", tzc, tzh,tzm));
|
||||
emsi->have_tzutc = 1;
|
||||
if ( strcmp(tzc, "-") == 0 ) {
|
||||
emsi->tzutc = -(tzh*60 + tzm);
|
||||
} else {
|
||||
emsi->tzutc = tzh*60 + tzm;
|
||||
}
|
||||
} else {
|
||||
DEB((D_HSHAKE,"TZUTC value not parsed!"));
|
||||
}
|
||||
free(tzc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEB((D_HSHAKE, "Step - no known EMSI-part - got %s", tmp));
|
||||
strnxcat(emsi->addons, "{", sizeof(emsi->addons));
|
||||
strnxcat(emsi->addons, tmp, sizeof(emsi->addons));
|
||||
strnxcat(emsi->addons, "}", sizeof(emsi->addons));
|
||||
|
||||
@@ -71,6 +71,7 @@ int answ_system(e_session type, char *connstr, int inetd)
|
||||
|
||||
if( inetd )
|
||||
{
|
||||
log("Answering TCPIP call...");
|
||||
if( connstr && *connstr )
|
||||
state.connstr = (char*)xstrcpy(connstr);
|
||||
else if( getpeername(0, (struct sockaddr*)&client, &clientlen) == -1 )
|
||||
@@ -116,9 +117,10 @@ int answ_system(e_session type, char *connstr, int inetd)
|
||||
port_carrier(0, TRUE);
|
||||
|
||||
rc = session();
|
||||
|
||||
log("Session ended up, rc=%d, inetd=%d", rc, inetd);
|
||||
if( ( !inetd ) )
|
||||
{
|
||||
log("Deactivating modem port");
|
||||
port_deinit(0, &oldtio);
|
||||
port_close();
|
||||
}
|
||||
|
||||
@@ -173,18 +173,18 @@ long time_gmtoffset(void)
|
||||
time_t tt = time(NULL);
|
||||
struct tm local = *localtime(&tt);
|
||||
struct tm gmt = *gmtime(&tt);
|
||||
long tz = gmt.tm_yday - local.tm_yday;
|
||||
long tz = local.tm_yday - gmt.tm_yday;
|
||||
|
||||
if( tz > 1 )
|
||||
tz = -24;
|
||||
else if( tz < -1 )
|
||||
tz = 24;
|
||||
else if( tz < -1 )
|
||||
tz = -24;
|
||||
else
|
||||
tz *= 24;
|
||||
|
||||
tz += gmt.tm_hour - local.tm_hour;
|
||||
tz += local.tm_hour - gmt.tm_hour;
|
||||
tz *= 60;
|
||||
tz += gmt.tm_min - local.tm_min;
|
||||
tz += local.tm_min - gmt.tm_min;
|
||||
|
||||
return tz;
|
||||
}
|
||||
@@ -202,10 +202,11 @@ char *time_string_gmtoffset(char *buffer)
|
||||
{
|
||||
long tz = time_gmtoffset();
|
||||
char sign = (tz > 0)?'+':'-';
|
||||
int hour = tz/60;
|
||||
int mint = tz%60;
|
||||
tz = abs(tz);
|
||||
unsigned int hour = tz/60;
|
||||
unsigned int mint = tz%60;
|
||||
|
||||
sprintf(buffer, "%c%02d%02d", sign, hour, mint);
|
||||
sprintf(buffer, "%c%02u%02u", sign, hour, mint);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user