Fixed the application of the T.30 T1 timeout in faxing.

This commit is contained in:
Steve Underwood committed 2016-01-24 01:58:36 +08:00
1 parent ce62c06241
commit 9113f23b75
6 files changed
+217 -4

No files matched your search

+86
View File
@@ -120,26 +120,34 @@ SPAN_DECLARE(int) t33_sub_address_extract_field(uint8_t num[21], const uint8_t t
{
type = T33_SST;
}
/*endif*/
while (t33[i])
{
ch = t33[i++];
if (ch == '#')
break;
/*endif*/
num[j++] = ch;
if (j >= 20)
return -1;
/*endif*/
}
/*endwhile*/
num[j] = '\0';
return type;
}
/*endif*/
/* Skip this field */
i++;
while (t33[i])
{
if (t33[i++] == '#')
break;
/*endif*/
}
/*endwhile*/
}
/*endfor*/
return T33_NONE;
}
/*- End of function --------------------------------------------------------*/
@@ -148,8 +156,10 @@ SPAN_DECLARE(void) t33_sub_address_add_field(uint8_t t33[], const uint8_t field[
{
if (t33[0] != '\0')
strcat((char *) t33, "#");
/*endif*/
if (type == T33_SST)
strcat((char *) t33, "#");
/*endif*/
strcat((char *) t33, (const char *) field);
}
/*- End of function --------------------------------------------------------*/
@@ -161,8 +171,10 @@ SPAN_DECLARE(int) t30_set_tx_ident(t30_state_t *s, const char *id)
s->tx_info.ident[0] = '\0';
return 0;
}
/*endif*/
if (strlen(id) > T30_MAX_IDENT_LEN)
return -1;
/*endif*/
strcpy(s->tx_info.ident, id);
t4_tx_set_local_ident(&s->t4.tx, s->tx_info.ident);
return 0;
@@ -173,6 +185,7 @@ SPAN_DECLARE(const char *) t30_get_tx_ident(t30_state_t *s)
{
if (s->tx_info.ident[0] == '\0')
return NULL;
/*endif*/
return s->tx_info.ident;
}
/*- End of function --------------------------------------------------------*/
@@ -181,6 +194,7 @@ SPAN_DECLARE(const char *) t30_get_rx_ident(t30_state_t *s)
{
if (s->rx_info.ident[0] == '\0')
return NULL;
/*endif*/
return s->rx_info.ident;
}
/*- End of function --------------------------------------------------------*/
@@ -192,8 +206,10 @@ SPAN_DECLARE(int) t30_set_tx_sub_address(t30_state_t *s, const char *sub_address
s->tx_info.sub_address[0] = '\0';
return 0;
}
/*endif*/
if (strlen(sub_address) > T30_MAX_IDENT_LEN)
return -1;
/*endif*/
strcpy(s->tx_info.sub_address, sub_address);
return 0;
}
@@ -203,6 +219,7 @@ SPAN_DECLARE(const char *) t30_get_tx_sub_address(t30_state_t *s)
{
if (s->tx_info.sub_address[0] == '\0')
return NULL;
/*endif*/
return s->tx_info.sub_address;
}
/*- End of function --------------------------------------------------------*/
@@ -211,6 +228,7 @@ SPAN_DECLARE(const char *) t30_get_rx_sub_address(t30_state_t *s)
{
if (s->rx_info.sub_address[0] == '\0')
return NULL;
/*endif*/
return s->rx_info.sub_address;
}
/*- End of function --------------------------------------------------------*/
@@ -222,8 +240,10 @@ SPAN_DECLARE(int) t30_set_tx_selective_polling_address(t30_state_t *s, const cha
s->tx_info.selective_polling_address[0] = '\0';
return 0;
}
/*endif*/
if (strlen(selective_polling_address) > T30_MAX_IDENT_LEN)
return -1;
/*endif*/
strcpy(s->tx_info.selective_polling_address, selective_polling_address);
return 0;
}
@@ -233,6 +253,7 @@ SPAN_DECLARE(const char *) t30_get_tx_selective_polling_address(t30_state_t *s)
{
if (s->tx_info.selective_polling_address[0] == '\0')
return NULL;
/*endif*/
return s->tx_info.selective_polling_address;
}
/*- End of function --------------------------------------------------------*/
@@ -241,6 +262,7 @@ SPAN_DECLARE(const char *) t30_get_rx_selective_polling_address(t30_state_t *s)
{
if (s->rx_info.selective_polling_address[0] == '\0')
return NULL;
/*endif*/
return s->rx_info.selective_polling_address;
}
/*- End of function --------------------------------------------------------*/
@@ -252,8 +274,10 @@ SPAN_DECLARE(int) t30_set_tx_polled_sub_address(t30_state_t *s, const char *poll
s->tx_info.polled_sub_address[0] = '\0';
return 0;
}
/*endif*/
if (strlen(polled_sub_address) > T30_MAX_IDENT_LEN)
return -1;
/*endif*/
strcpy(s->tx_info.polled_sub_address, polled_sub_address);
return 0;
}
@@ -263,6 +287,7 @@ SPAN_DECLARE(const char *) t30_get_tx_polled_sub_address(t30_state_t *s)
{
if (s->tx_info.polled_sub_address[0] == '\0')
return NULL;
/*endif*/
return s->tx_info.polled_sub_address;
}
/*- End of function --------------------------------------------------------*/
@@ -271,6 +296,7 @@ SPAN_DECLARE(const char *) t30_get_rx_polled_sub_address(t30_state_t *s)
{
if (s->rx_info.polled_sub_address[0] == '\0')
return NULL;
/*endif*/
return s->rx_info.polled_sub_address;
}
/*- End of function --------------------------------------------------------*/
@@ -282,8 +308,10 @@ SPAN_DECLARE(int) t30_set_tx_sender_ident(t30_state_t *s, const char *sender_ide
s->tx_info.sender_ident[0] = '\0';
return 0;
}
/*endif*/
if (strlen(sender_ident) > T30_MAX_IDENT_LEN)
return -1;
/*endif*/
strcpy(s->tx_info.sender_ident, sender_ident);
return 0;
}
@@ -293,6 +321,7 @@ SPAN_DECLARE(const char *) t30_get_tx_sender_ident(t30_state_t *s)
{
if (s->tx_info.sender_ident[0] == '\0')
return NULL;
/*endif*/
return s->tx_info.sender_ident;
}
/*- End of function --------------------------------------------------------*/
@@ -301,6 +330,7 @@ SPAN_DECLARE(const char *) t30_get_rx_sender_ident(t30_state_t *s)
{
if (s->rx_info.sender_ident[0] == '\0')
return NULL;
/*endif*/
return s->rx_info.sender_ident;
}
/*- End of function --------------------------------------------------------*/
@@ -312,8 +342,10 @@ SPAN_DECLARE(int) t30_set_tx_password(t30_state_t *s, const char *password)
s->tx_info.password[0] = '\0';
return 0;
}
/*endif*/
if (strlen(password) > T30_MAX_IDENT_LEN)
return -1;
/*endif*/
strcpy(s->tx_info.password, password);
return 0;
}
@@ -323,6 +355,7 @@ SPAN_DECLARE(const char *) t30_get_tx_password(t30_state_t *s)
{
if (s->tx_info.password[0] == '\0')
return NULL;
/*endif*/
return s->tx_info.password;
}
/*- End of function --------------------------------------------------------*/
@@ -331,6 +364,7 @@ SPAN_DECLARE(const char *) t30_get_rx_password(t30_state_t *s)
{
if (s->rx_info.password[0] == '\0')
return NULL;
/*endif*/
return s->rx_info.password;
}
/*- End of function --------------------------------------------------------*/
@@ -339,6 +373,7 @@ SPAN_DECLARE(int) t30_set_tx_nsf(t30_state_t *s, const uint8_t *nsf, int len)
{
if (s->tx_info.nsf)
span_free(s->tx_info.nsf);
/*endif*/
if (nsf && len > 0 && (s->tx_info.nsf = span_alloc(len + 3)))
{
memcpy(&s->tx_info.nsf[3], nsf, len);
@@ -349,6 +384,7 @@ SPAN_DECLARE(int) t30_set_tx_nsf(t30_state_t *s, const uint8_t *nsf, int len)
s->tx_info.nsf = NULL;
s->tx_info.nsf_len = 0;
}
/*endif*/
return 0;
}
/*- End of function --------------------------------------------------------*/
@@ -357,6 +393,7 @@ SPAN_DECLARE(size_t) t30_get_tx_nsf(t30_state_t *s, const uint8_t *nsf[])
{
if (nsf)
*nsf = s->tx_info.nsf;
/*endif*/
return s->tx_info.nsf_len;
}
/*- End of function --------------------------------------------------------*/
@@ -365,6 +402,7 @@ SPAN_DECLARE(size_t) t30_get_rx_nsf(t30_state_t *s, const uint8_t *nsf[])
{
if (nsf)
*nsf = s->rx_info.nsf;
/*endif*/
return s->rx_info.nsf_len;
}
/*- End of function --------------------------------------------------------*/
@@ -373,6 +411,7 @@ SPAN_DECLARE(int) t30_set_tx_nsc(t30_state_t *s, const uint8_t *nsc, int len)
{
if (s->tx_info.nsc)
span_free(s->tx_info.nsc);
/*endif*/
if (nsc && len > 0 && (s->tx_info.nsc = span_alloc(len + 3)))
{
memcpy(&s->tx_info.nsc[3], nsc, len);
@@ -383,6 +422,7 @@ SPAN_DECLARE(int) t30_set_tx_nsc(t30_state_t *s, const uint8_t *nsc, int len)
s->tx_info.nsc = NULL;
s->tx_info.nsc_len = 0;
}
/*endif*/
return 0;
}
/*- End of function --------------------------------------------------------*/
@@ -391,6 +431,7 @@ SPAN_DECLARE(size_t) t30_get_tx_nsc(t30_state_t *s, const uint8_t *nsc[])
{
if (nsc)
*nsc = s->tx_info.nsc;
/*endif*/
return s->tx_info.nsc_len;
}
/*- End of function --------------------------------------------------------*/
@@ -399,6 +440,7 @@ SPAN_DECLARE(size_t) t30_get_rx_nsc(t30_state_t *s, const uint8_t *nsc[])
{
if (nsc)
*nsc = s->rx_info.nsc;
/*endif*/
return s->rx_info.nsc_len;
}
/*- End of function --------------------------------------------------------*/
@@ -407,6 +449,7 @@ SPAN_DECLARE(int) t30_set_tx_nss(t30_state_t *s, const uint8_t *nss, int len)
{
if (s->tx_info.nss)
span_free(s->tx_info.nss);
/*endif*/
if (nss && len > 0 && (s->tx_info.nss = span_alloc(len + 3)))
{
memcpy(&s->tx_info.nss[3], nss, len);
@@ -417,6 +460,7 @@ SPAN_DECLARE(int) t30_set_tx_nss(t30_state_t *s, const uint8_t *nss, int len)
s->tx_info.nss = NULL;
s->tx_info.nss_len = 0;
}
/*endif*/
return 0;
}
/*- End of function --------------------------------------------------------*/
@@ -425,6 +469,7 @@ SPAN_DECLARE(size_t) t30_get_tx_nss(t30_state_t *s, const uint8_t *nss[])
{
if (nss)
*nss = s->tx_info.nss;
/*endif*/
return s->tx_info.nss_len;
}
/*- End of function --------------------------------------------------------*/
@@ -433,6 +478,7 @@ SPAN_DECLARE(size_t) t30_get_rx_nss(t30_state_t *s, const uint8_t *nss[])
{
if (nss)
*nss = s->rx_info.nss;
/*endif*/
return s->rx_info.nss_len;
}
/*- End of function --------------------------------------------------------*/
@@ -441,20 +487,24 @@ SPAN_DECLARE(int) t30_set_tx_tsa(t30_state_t *s, int type, const char *address,
{
if (s->tx_info.tsa)
span_free(s->tx_info.tsa);
/*endif*/
if (address == NULL || len == 0)
{
s->tx_info.tsa = NULL;
s->tx_info.tsa_len = 0;
return 0;
}
/*endif*/
s->tx_info.tsa_type = type;
if (len < 0)
len = strlen(address);
/*endif*/
if ((s->tx_info.tsa = span_alloc(len)))
{
memcpy(s->tx_info.tsa, address, len);
s->tx_info.tsa_len = len;
}
/*endif*/
return 0;
}
/*- End of function --------------------------------------------------------*/
@@ -463,8 +513,10 @@ SPAN_DECLARE(size_t) t30_get_tx_tsa(t30_state_t *s, int *type, const char *addre
{
if (type)
*type = s->tx_info.tsa_type;
/*endif*/
if (address)
*address = s->tx_info.tsa;
/*endif*/
return s->tx_info.tsa_len;
}
/*- End of function --------------------------------------------------------*/
@@ -473,8 +525,10 @@ SPAN_DECLARE(size_t) t30_get_rx_tsa(t30_state_t *s, int *type, const char *addre
{
if (type)
*type = s->rx_info.tsa_type;
/*endif*/
if (address)
*address = s->rx_info.tsa;
/*endif*/
return s->rx_info.tsa_len;
}
/*- End of function --------------------------------------------------------*/
@@ -483,11 +537,13 @@ SPAN_DECLARE(int) t30_set_tx_ira(t30_state_t *s, int type, const char *address,
{
if (s->tx_info.ira)
span_free(s->tx_info.ira);
/*endif*/
if (address == NULL)
{
s->tx_info.ira = NULL;
return 0;
}
/*endif*/
s->tx_info.ira = strdup(address);
return 0;
}
@@ -497,8 +553,10 @@ SPAN_DECLARE(size_t) t30_get_tx_ira(t30_state_t *s, int *type, const char *addre
{
if (type)
*type = s->tx_info.ira_type;
/*endif*/
if (address)
*address = s->tx_info.ira;
/*endif*/
return s->tx_info.ira_len;
}
/*- End of function --------------------------------------------------------*/
@@ -507,8 +565,10 @@ SPAN_DECLARE(size_t) t30_get_rx_ira(t30_state_t *s, int *type, const char *addre
{
if (type)
*type = s->rx_info.ira_type;
/*endif*/
if (address)
*address = s->rx_info.ira;
/*endif*/
return s->rx_info.ira_len;
}
/*- End of function --------------------------------------------------------*/
@@ -517,11 +577,13 @@ SPAN_DECLARE(int) t30_set_tx_cia(t30_state_t *s, int type, const char *address,
{
if (s->tx_info.cia)
span_free(s->tx_info.cia);
/*endif*/
if (address == NULL)
{
s->tx_info.cia = NULL;
return 0;
}
/*endif*/
s->tx_info.cia = strdup(address);
return 0;
}
@@ -531,8 +593,10 @@ SPAN_DECLARE(size_t) t30_get_tx_cia(t30_state_t *s, int *type, const char *addre
{
if (type)
*type = s->tx_info.cia_type;
/*endif*/
if (address)
*address = s->tx_info.cia;
/*endif*/
return s->tx_info.cia_len;
}
/*- End of function --------------------------------------------------------*/
@@ -541,8 +605,10 @@ SPAN_DECLARE(size_t) t30_get_rx_cia(t30_state_t *s, int *type, const char *addre
{
if (type)
*type = s->rx_info.cia_type;
/*endif*/
if (address)
*address = s->rx_info.cia;
/*endif*/
return s->rx_info.cia_len;
}
/*- End of function --------------------------------------------------------*/
@@ -551,11 +617,13 @@ SPAN_DECLARE(int) t30_set_tx_isp(t30_state_t *s, int type, const char *address,
{
if (s->tx_info.isp)
span_free(s->tx_info.isp);
/*endif*/
if (address == NULL)
{
s->tx_info.isp = NULL;
return 0;
}
/*endif*/
s->tx_info.isp = strdup(address);
return 0;
}
@@ -565,8 +633,10 @@ SPAN_DECLARE(size_t) t30_get_tx_isp(t30_state_t *s, int *type, const char *addre
{
if (type)
*type = s->tx_info.isp_type;
/*endif*/
if (address)
*address = s->tx_info.isp;
/*endif*/
return s->tx_info.isp_len;
}
/*- End of function --------------------------------------------------------*/
@@ -575,8 +645,10 @@ SPAN_DECLARE(size_t) t30_get_rx_isp(t30_state_t *s, int *type, const char *addre
{
if (type)
*type = s->rx_info.isp_type;
/*endif*/
if (address)
*address = s->rx_info.isp;
/*endif*/
return s->rx_info.isp_len;
}
/*- End of function --------------------------------------------------------*/
@@ -585,11 +657,13 @@ SPAN_DECLARE(int) t30_set_tx_csa(t30_state_t *s, int type, const char *address,
{
if (s->tx_info.csa)
span_free(s->tx_info.csa);
/*endif*/
if (address == NULL)
{
s->tx_info.csa = NULL;
return 0;
}
/*endif*/
s->tx_info.csa = strdup(address);
return 0;
}
@@ -599,8 +673,10 @@ SPAN_DECLARE(size_t) t30_get_tx_csa(t30_state_t *s, int *type, const char *addre
{
if (type)
*type = s->tx_info.csa_type;
/*endif*/
if (address)
*address = s->tx_info.csa;
/*endif*/
return s->tx_info.csa_len;
}
/*- End of function --------------------------------------------------------*/
@@ -609,8 +685,10 @@ SPAN_DECLARE(size_t) t30_get_rx_csa(t30_state_t *s, int *type, const char *addre
{
if (type)
*type = s->rx_info.csa_type;
/*endif*/
if (address)
*address = s->rx_info.csa;
/*endif*/
return s->rx_info.csa_len;
}
/*- End of function --------------------------------------------------------*/
@@ -630,8 +708,10 @@ SPAN_DECLARE(int) t30_set_tx_page_header_info(t30_state_t *s, const char *info)
s->header_info[0] = '\0';
return 0;
}
/*endif*/
if (strlen(info) > T30_MAX_PAGE_HEADER_INFO)
return -1;
/*endif*/
strcpy(s->header_info, info);
t4_tx_set_header_info(&s->t4.tx, s->header_info);
return 0;
@@ -642,6 +722,7 @@ SPAN_DECLARE(size_t) t30_get_tx_page_header_info(t30_state_t *s, char *info)
{
if (info)
strcpy(info, s->header_info);
/*endif*/
return strlen(s->header_info);
}
/*- End of function --------------------------------------------------------*/
@@ -654,6 +735,7 @@ SPAN_DECLARE(int) t30_set_tx_page_header_tz(t30_state_t *s, const char *tzstring
t4_tx_set_header_tz(&s->t4.tx, &s->tz);
return 0;
}
/*endif*/
return -1;
}
/*- End of function --------------------------------------------------------*/
@@ -758,6 +840,7 @@ SPAN_DECLARE(int) t30_set_minimum_scan_line_time(t30_state_t *s, int min_time)
s->local_min_scan_time_code = 4;
else
return -1;
/*endif*/
t30_build_dis_or_dtc(s);
return 0;
}
@@ -856,8 +939,10 @@ SPAN_DECLARE(int) t30_set_supported_image_sizes(t30_state_t *s, int supported_im
/* Force the sizes which depend on sizes which are supported */
if ((supported_image_sizes & T4_SUPPORT_LENGTH_UNLIMITED))
supported_image_sizes |= T4_SUPPORT_LENGTH_B4;
/*endif*/
if ((supported_image_sizes & T4_SUPPORT_WIDTH_303MM))
supported_image_sizes |= T4_SUPPORT_WIDTH_255MM;
/*endif*/
s->supported_image_sizes = supported_image_sizes;
t30_build_dis_or_dtc(s);
return 0;
@@ -879,6 +964,7 @@ SPAN_DECLARE(void) t30_set_status(t30_state_t *s, int status)
span_log(&s->logging, SPAN_LOG_FLOW, "Status changing to '%s'\n", t30_completion_code_to_str(status));
s->current_status = status;
}
/*endif*/
}
/*- End of function --------------------------------------------------------*/