Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/t30_api.c @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 1 /* | |
| 2 * SpanDSP - a series of DSP components for telephony | |
| 3 * | |
| 4 * t30_api.c - ITU T.30 FAX transfer processing | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Steve Underwood | |
| 9 * | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * This program is free software; you can redistribute it and/or modify | |
| 13 * it under the terms of the GNU Lesser General Public License version 2.1, | |
| 14 * as published by the Free Software Foundation. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU Lesser General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU Lesser General Public | |
| 22 * License along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 24 * | |
| 25 * $Id: t30_api.c,v 1.13.4.2 2009/12/19 14:18:13 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \file */ | |
| 29 | |
| 30 #if defined(HAVE_CONFIG_H) | |
| 31 #include "config.h" | |
| 32 #endif | |
| 33 | |
| 34 #include <stdlib.h> | |
| 35 #include <stdio.h> | |
| 36 #include <inttypes.h> | |
| 37 #include <string.h> | |
| 38 #include <fcntl.h> | |
| 39 #include <time.h> | |
| 40 #if defined(HAVE_TGMATH_H) | |
| 41 #include <tgmath.h> | |
| 42 #endif | |
| 43 #if defined(HAVE_MATH_H) | |
| 44 #include <math.h> | |
| 45 #endif | |
| 46 #include "floating_fudge.h" | |
| 47 #include <tiffio.h> | |
| 48 | |
| 49 #include "spandsp/telephony.h" | |
| 50 #include "spandsp/logging.h" | |
| 51 #include "spandsp/bit_operations.h" | |
| 52 #include "spandsp/queue.h" | |
| 53 #include "spandsp/power_meter.h" | |
| 54 #include "spandsp/complex.h" | |
| 55 #include "spandsp/tone_generate.h" | |
| 56 #include "spandsp/async.h" | |
| 57 #include "spandsp/hdlc.h" | |
| 58 #include "spandsp/fsk.h" | |
| 59 #include "spandsp/v29rx.h" | |
| 60 #include "spandsp/v29tx.h" | |
| 61 #include "spandsp/v27ter_rx.h" | |
| 62 #include "spandsp/v27ter_tx.h" | |
| 63 #include "spandsp/t4_rx.h" | |
| 64 #include "spandsp/t4_tx.h" | |
| 65 #include "spandsp/t30_fcf.h" | |
| 66 #include "spandsp/t35.h" | |
| 67 #include "spandsp/t30.h" | |
| 68 #include "spandsp/t30_api.h" | |
| 69 #include "spandsp/t30_logging.h" | |
| 70 | |
| 71 #include "spandsp/private/logging.h" | |
| 72 #include "spandsp/private/t4_rx.h" | |
| 73 #include "spandsp/private/t4_tx.h" | |
| 74 #include "spandsp/private/t30.h" | |
| 75 | |
| 76 #include "t30_local.h" | |
| 77 | |
| 78 SPAN_DECLARE(int) t30_set_tx_ident(t30_state_t *s, const char *id) | |
| 79 { | |
| 80 if (id == NULL) | |
| 81 { | |
| 82 s->tx_info.ident[0] = '\0'; | |
| 83 return 0; | |
| 84 } | |
| 85 if (strlen(id) > T30_MAX_IDENT_LEN) | |
| 86 return -1; | |
| 87 strcpy(s->tx_info.ident, id); | |
| 88 t4_tx_set_local_ident(&s->t4, s->tx_info.ident); | |
| 89 return 0; | |
| 90 } | |
| 91 /*- End of function --------------------------------------------------------*/ | |
| 92 | |
| 93 SPAN_DECLARE(const char *) t30_get_tx_ident(t30_state_t *s) | |
| 94 { | |
| 95 if (s->tx_info.ident[0] == '\0') | |
| 96 return NULL; | |
| 97 return s->tx_info.ident; | |
| 98 } | |
| 99 /*- End of function --------------------------------------------------------*/ | |
| 100 | |
| 101 SPAN_DECLARE(const char *) t30_get_rx_ident(t30_state_t *s) | |
| 102 { | |
| 103 if (s->rx_info.ident[0] == '\0') | |
| 104 return NULL; | |
| 105 return s->rx_info.ident; | |
| 106 } | |
| 107 /*- End of function --------------------------------------------------------*/ | |
| 108 | |
| 109 SPAN_DECLARE(int) t30_set_tx_sub_address(t30_state_t *s, const char *sub_address) | |
| 110 { | |
| 111 if (sub_address == NULL) | |
| 112 { | |
| 113 s->tx_info.sub_address[0] = '\0'; | |
| 114 return 0; | |
| 115 } | |
| 116 if (strlen(sub_address) > T30_MAX_IDENT_LEN) | |
| 117 return -1; | |
| 118 strcpy(s->tx_info.sub_address, sub_address); | |
| 119 return 0; | |
| 120 } | |
| 121 /*- End of function --------------------------------------------------------*/ | |
| 122 | |
| 123 SPAN_DECLARE(const char *) t30_get_tx_sub_address(t30_state_t *s) | |
| 124 { | |
| 125 if (s->tx_info.sub_address[0] == '\0') | |
| 126 return NULL; | |
| 127 return s->tx_info.sub_address; | |
| 128 } | |
| 129 /*- End of function --------------------------------------------------------*/ | |
| 130 | |
| 131 SPAN_DECLARE(const char *) t30_get_rx_sub_address(t30_state_t *s) | |
| 132 { | |
| 133 if (s->rx_info.sub_address[0] == '\0') | |
| 134 return NULL; | |
| 135 return s->rx_info.sub_address; | |
| 136 } | |
| 137 /*- End of function --------------------------------------------------------*/ | |
| 138 | |
| 139 SPAN_DECLARE(int) t30_set_tx_selective_polling_address(t30_state_t *s, const char *selective_polling_address) | |
| 140 { | |
| 141 if (selective_polling_address == NULL) | |
| 142 { | |
| 143 s->tx_info.selective_polling_address[0] = '\0'; | |
| 144 return 0; | |
| 145 } | |
| 146 if (strlen(selective_polling_address) > T30_MAX_IDENT_LEN) | |
| 147 return -1; | |
| 148 strcpy(s->tx_info.selective_polling_address, selective_polling_address); | |
| 149 return 0; | |
| 150 } | |
| 151 /*- End of function --------------------------------------------------------*/ | |
| 152 | |
| 153 SPAN_DECLARE(const char *) t30_get_tx_selective_polling_address(t30_state_t *s) | |
| 154 { | |
| 155 if (s->tx_info.selective_polling_address[0] == '\0') | |
| 156 return NULL; | |
| 157 return s->tx_info.selective_polling_address; | |
| 158 } | |
| 159 /*- End of function --------------------------------------------------------*/ | |
| 160 | |
| 161 SPAN_DECLARE(const char *) t30_get_rx_selective_polling_address(t30_state_t *s) | |
| 162 { | |
| 163 if (s->rx_info.selective_polling_address[0] == '\0') | |
| 164 return NULL; | |
| 165 return s->rx_info.selective_polling_address; | |
| 166 } | |
| 167 /*- End of function --------------------------------------------------------*/ | |
| 168 | |
| 169 SPAN_DECLARE(int) t30_set_tx_polled_sub_address(t30_state_t *s, const char *polled_sub_address) | |
| 170 { | |
| 171 if (polled_sub_address == NULL) | |
| 172 { | |
| 173 s->tx_info.polled_sub_address[0] = '\0'; | |
| 174 return 0; | |
| 175 } | |
| 176 if (strlen(polled_sub_address) > T30_MAX_IDENT_LEN) | |
| 177 return -1; | |
| 178 strcpy(s->tx_info.polled_sub_address, polled_sub_address); | |
| 179 return 0; | |
| 180 } | |
| 181 /*- End of function --------------------------------------------------------*/ | |
| 182 | |
| 183 SPAN_DECLARE(const char *) t30_get_tx_polled_sub_address(t30_state_t *s) | |
| 184 { | |
| 185 if (s->tx_info.polled_sub_address[0] == '\0') | |
| 186 return NULL; | |
| 187 return s->tx_info.polled_sub_address; | |
| 188 } | |
| 189 /*- End of function --------------------------------------------------------*/ | |
| 190 | |
| 191 SPAN_DECLARE(const char *) t30_get_rx_polled_sub_address(t30_state_t *s) | |
| 192 { | |
| 193 if (s->rx_info.polled_sub_address[0] == '\0') | |
| 194 return NULL; | |
| 195 return s->rx_info.polled_sub_address; | |
| 196 } | |
| 197 /*- End of function --------------------------------------------------------*/ | |
| 198 | |
| 199 SPAN_DECLARE(int) t30_set_tx_sender_ident(t30_state_t *s, const char *sender_ident) | |
| 200 { | |
| 201 if (sender_ident == NULL) | |
| 202 { | |
| 203 s->tx_info.sender_ident[0] = '\0'; | |
| 204 return 0; | |
| 205 } | |
| 206 if (strlen(sender_ident) > T30_MAX_IDENT_LEN) | |
| 207 return -1; | |
| 208 strcpy(s->tx_info.sender_ident, sender_ident); | |
| 209 return 0; | |
| 210 } | |
| 211 /*- End of function --------------------------------------------------------*/ | |
| 212 | |
| 213 SPAN_DECLARE(const char *) t30_get_tx_sender_ident(t30_state_t *s) | |
| 214 { | |
| 215 if (s->tx_info.sender_ident[0] == '\0') | |
| 216 return NULL; | |
| 217 return s->tx_info.sender_ident; | |
| 218 } | |
| 219 /*- End of function --------------------------------------------------------*/ | |
| 220 | |
| 221 SPAN_DECLARE(const char *) t30_get_rx_sender_ident(t30_state_t *s) | |
| 222 { | |
| 223 if (s->rx_info.sender_ident[0] == '\0') | |
| 224 return NULL; | |
| 225 return s->rx_info.sender_ident; | |
| 226 } | |
| 227 /*- End of function --------------------------------------------------------*/ | |
| 228 | |
| 229 SPAN_DECLARE(int) t30_set_tx_password(t30_state_t *s, const char *password) | |
| 230 { | |
| 231 if (password == NULL) | |
| 232 { | |
| 233 s->tx_info.password[0] = '\0'; | |
| 234 return 0; | |
| 235 } | |
| 236 if (strlen(password) > T30_MAX_IDENT_LEN) | |
| 237 return -1; | |
| 238 strcpy(s->tx_info.password, password); | |
| 239 return 0; | |
| 240 } | |
| 241 /*- End of function --------------------------------------------------------*/ | |
| 242 | |
| 243 SPAN_DECLARE(const char *) t30_get_tx_password(t30_state_t *s) | |
| 244 { | |
| 245 if (s->tx_info.password[0] == '\0') | |
| 246 return NULL; | |
| 247 return s->tx_info.password; | |
| 248 } | |
| 249 /*- End of function --------------------------------------------------------*/ | |
| 250 | |
| 251 SPAN_DECLARE(const char *) t30_get_rx_password(t30_state_t *s) | |
| 252 { | |
| 253 if (s->rx_info.password[0] == '\0') | |
| 254 return NULL; | |
| 255 return s->rx_info.password; | |
| 256 } | |
| 257 /*- End of function --------------------------------------------------------*/ | |
| 258 | |
| 259 SPAN_DECLARE(int) t30_set_tx_nsf(t30_state_t *s, const uint8_t *nsf, int len) | |
| 260 { | |
| 261 if (s->tx_info.nsf) | |
| 262 free(s->tx_info.nsf); | |
| 263 if (nsf && len > 0 && (s->tx_info.nsf = malloc(len + 3))) | |
| 264 { | |
| 265 memcpy(s->tx_info.nsf + 3, nsf, len); | |
| 266 s->tx_info.nsf_len = len; | |
| 267 } | |
| 268 else | |
| 269 { | |
| 270 s->tx_info.nsf = NULL; | |
| 271 s->tx_info.nsf_len = 0; | |
| 272 } | |
| 273 return 0; | |
| 274 } | |
| 275 /*- End of function --------------------------------------------------------*/ | |
| 276 | |
| 277 SPAN_DECLARE(size_t) t30_get_tx_nsf(t30_state_t *s, const uint8_t *nsf[]) | |
| 278 { | |
| 279 if (nsf) | |
| 280 *nsf = s->tx_info.nsf; | |
| 281 return s->tx_info.nsf_len; | |
| 282 } | |
| 283 /*- End of function --------------------------------------------------------*/ | |
| 284 | |
| 285 SPAN_DECLARE(size_t) t30_get_rx_nsf(t30_state_t *s, const uint8_t *nsf[]) | |
| 286 { | |
| 287 if (nsf) | |
| 288 *nsf = s->rx_info.nsf; | |
| 289 return s->rx_info.nsf_len; | |
| 290 } | |
| 291 /*- End of function --------------------------------------------------------*/ | |
| 292 | |
| 293 SPAN_DECLARE(int) t30_set_tx_nsc(t30_state_t *s, const uint8_t *nsc, int len) | |
| 294 { | |
| 295 if (s->tx_info.nsc) | |
| 296 free(s->tx_info.nsc); | |
| 297 if (nsc && len > 0 && (s->tx_info.nsc = malloc(len + 3))) | |
| 298 { | |
| 299 memcpy(s->tx_info.nsc + 3, nsc, len); | |
| 300 s->tx_info.nsc_len = len; | |
| 301 } | |
| 302 else | |
| 303 { | |
| 304 s->tx_info.nsc = NULL; | |
| 305 s->tx_info.nsc_len = 0; | |
| 306 } | |
| 307 return 0; | |
| 308 } | |
| 309 /*- End of function --------------------------------------------------------*/ | |
| 310 | |
| 311 SPAN_DECLARE(size_t) t30_get_tx_nsc(t30_state_t *s, const uint8_t *nsc[]) | |
| 312 { | |
| 313 if (nsc) | |
| 314 *nsc = s->tx_info.nsc; | |
| 315 return s->tx_info.nsc_len; | |
| 316 } | |
| 317 /*- End of function --------------------------------------------------------*/ | |
| 318 | |
| 319 SPAN_DECLARE(size_t) t30_get_rx_nsc(t30_state_t *s, const uint8_t *nsc[]) | |
| 320 { | |
| 321 if (nsc) | |
| 322 *nsc = s->rx_info.nsc; | |
| 323 return s->rx_info.nsc_len; | |
| 324 } | |
| 325 /*- End of function --------------------------------------------------------*/ | |
| 326 | |
| 327 SPAN_DECLARE(int) t30_set_tx_nss(t30_state_t *s, const uint8_t *nss, int len) | |
| 328 { | |
| 329 if (s->tx_info.nss) | |
| 330 free(s->tx_info.nss); | |
| 331 if (nss && len > 0 && (s->tx_info.nss = malloc(len + 3))) | |
| 332 { | |
| 333 memcpy(s->tx_info.nss + 3, nss, len); | |
| 334 s->tx_info.nss_len = len; | |
| 335 } | |
| 336 else | |
| 337 { | |
| 338 s->tx_info.nss = NULL; | |
| 339 s->tx_info.nss_len = 0; | |
| 340 } | |
| 341 return 0; | |
| 342 } | |
| 343 /*- End of function --------------------------------------------------------*/ | |
| 344 | |
| 345 SPAN_DECLARE(size_t) t30_get_tx_nss(t30_state_t *s, const uint8_t *nss[]) | |
| 346 { | |
| 347 if (nss) | |
| 348 *nss = s->tx_info.nss; | |
| 349 return s->tx_info.nss_len; | |
| 350 } | |
| 351 /*- End of function --------------------------------------------------------*/ | |
| 352 | |
| 353 SPAN_DECLARE(size_t) t30_get_rx_nss(t30_state_t *s, const uint8_t *nss[]) | |
| 354 { | |
| 355 if (nss) | |
| 356 *nss = s->rx_info.nss; | |
| 357 return s->rx_info.nss_len; | |
| 358 } | |
| 359 /*- End of function --------------------------------------------------------*/ | |
| 360 | |
| 361 SPAN_DECLARE(int) t30_set_tx_tsa(t30_state_t *s, int type, const char *address, int len) | |
| 362 { | |
| 363 if (s->tx_info.tsa) | |
| 364 free(s->tx_info.tsa); | |
| 365 if (address == NULL || len == 0) | |
| 366 { | |
| 367 s->tx_info.tsa = NULL; | |
| 368 s->tx_info.tsa_len = 0; | |
| 369 return 0; | |
| 370 } | |
| 371 s->tx_info.tsa_type = type; | |
| 372 if (len < 0) | |
| 373 len = strlen(address); | |
| 374 if ((s->tx_info.tsa = malloc(len))) | |
| 375 { | |
| 376 memcpy(s->tx_info.tsa, address, len); | |
| 377 s->tx_info.tsa_len = len; | |
| 378 } | |
| 379 return 0; | |
| 380 } | |
| 381 /*- End of function --------------------------------------------------------*/ | |
| 382 | |
| 383 SPAN_DECLARE(size_t) t30_get_tx_tsa(t30_state_t *s, int *type, const char *address[]) | |
| 384 { | |
| 385 if (type) | |
| 386 *type = s->tx_info.tsa_type; | |
| 387 if (address) | |
| 388 *address = s->tx_info.tsa; | |
| 389 return s->tx_info.tsa_len; | |
| 390 } | |
| 391 /*- End of function --------------------------------------------------------*/ | |
| 392 | |
| 393 SPAN_DECLARE(size_t) t30_get_rx_tsa(t30_state_t *s, int *type, const char *address[]) | |
| 394 { | |
| 395 if (type) | |
| 396 *type = s->rx_info.tsa_type; | |
| 397 if (address) | |
| 398 *address = s->rx_info.tsa; | |
| 399 return s->rx_info.tsa_len; | |
| 400 } | |
| 401 /*- End of function --------------------------------------------------------*/ | |
| 402 | |
| 403 SPAN_DECLARE(int) t30_set_tx_ira(t30_state_t *s, int type, const char *address, int len) | |
| 404 { | |
| 405 if (s->tx_info.ira) | |
| 406 free(s->tx_info.ira); | |
| 407 if (address == NULL) | |
| 408 { | |
| 409 s->tx_info.ira = NULL; | |
| 410 return 0; | |
| 411 } | |
| 412 s->tx_info.ira = strdup(address); | |
| 413 return 0; | |
| 414 } | |
| 415 /*- End of function --------------------------------------------------------*/ | |
| 416 | |
| 417 SPAN_DECLARE(size_t) t30_get_tx_ira(t30_state_t *s, int *type, const char *address[]) | |
| 418 { | |
| 419 if (type) | |
| 420 *type = s->tx_info.ira_type; | |
| 421 if (address) | |
| 422 *address = s->tx_info.ira; | |
| 423 return s->tx_info.ira_len; | |
| 424 } | |
| 425 /*- End of function --------------------------------------------------------*/ | |
| 426 | |
| 427 SPAN_DECLARE(size_t) t30_get_rx_ira(t30_state_t *s, int *type, const char *address[]) | |
| 428 { | |
| 429 if (type) | |
| 430 *type = s->rx_info.ira_type; | |
| 431 if (address) | |
| 432 *address = s->rx_info.ira; | |
| 433 return s->rx_info.ira_len; | |
| 434 } | |
| 435 /*- End of function --------------------------------------------------------*/ | |
| 436 | |
| 437 SPAN_DECLARE(int) t30_set_tx_cia(t30_state_t *s, int type, const char *address, int len) | |
| 438 { | |
| 439 if (s->tx_info.cia) | |
| 440 free(s->tx_info.cia); | |
| 441 if (address == NULL) | |
| 442 { | |
| 443 s->tx_info.cia = NULL; | |
| 444 return 0; | |
| 445 } | |
| 446 s->tx_info.cia = strdup(address); | |
| 447 return 0; | |
| 448 } | |
| 449 /*- End of function --------------------------------------------------------*/ | |
| 450 | |
| 451 SPAN_DECLARE(size_t) t30_get_tx_cia(t30_state_t *s, int *type, const char *address[]) | |
| 452 { | |
| 453 if (type) | |
| 454 *type = s->tx_info.cia_type; | |
| 455 if (address) | |
| 456 *address = s->tx_info.cia; | |
| 457 return s->tx_info.cia_len; | |
| 458 } | |
| 459 /*- End of function --------------------------------------------------------*/ | |
| 460 | |
| 461 SPAN_DECLARE(size_t) t30_get_rx_cia(t30_state_t *s, int *type, const char *address[]) | |
| 462 { | |
| 463 if (type) | |
| 464 *type = s->rx_info.cia_type; | |
| 465 if (address) | |
| 466 *address = s->rx_info.cia; | |
| 467 return s->rx_info.cia_len; | |
| 468 } | |
| 469 /*- End of function --------------------------------------------------------*/ | |
| 470 | |
| 471 SPAN_DECLARE(int) t30_set_tx_isp(t30_state_t *s, int type, const char *address, int len) | |
| 472 { | |
| 473 if (s->tx_info.isp) | |
| 474 free(s->tx_info.isp); | |
| 475 if (address == NULL) | |
| 476 { | |
| 477 s->tx_info.isp = NULL; | |
| 478 return 0; | |
| 479 } | |
| 480 s->tx_info.isp = strdup(address); | |
| 481 return 0; | |
| 482 } | |
| 483 /*- End of function --------------------------------------------------------*/ | |
| 484 | |
| 485 SPAN_DECLARE(size_t) t30_get_tx_isp(t30_state_t *s, int *type, const char *address[]) | |
| 486 { | |
| 487 if (type) | |
| 488 *type = s->tx_info.isp_type; | |
| 489 if (address) | |
| 490 *address = s->tx_info.isp; | |
| 491 return s->tx_info.isp_len; | |
| 492 } | |
| 493 /*- End of function --------------------------------------------------------*/ | |
| 494 | |
| 495 SPAN_DECLARE(size_t) t30_get_rx_isp(t30_state_t *s, int *type, const char *address[]) | |
| 496 { | |
| 497 if (type) | |
| 498 *type = s->rx_info.isp_type; | |
| 499 if (address) | |
| 500 *address = s->rx_info.isp; | |
| 501 return s->rx_info.isp_len; | |
| 502 } | |
| 503 /*- End of function --------------------------------------------------------*/ | |
| 504 | |
| 505 SPAN_DECLARE(int) t30_set_tx_csa(t30_state_t *s, int type, const char *address, int len) | |
| 506 { | |
| 507 if (s->tx_info.csa) | |
| 508 free(s->tx_info.csa); | |
| 509 if (address == NULL) | |
| 510 { | |
| 511 s->tx_info.csa = NULL; | |
| 512 return 0; | |
| 513 } | |
| 514 s->tx_info.csa = strdup(address); | |
| 515 return 0; | |
| 516 } | |
| 517 /*- End of function --------------------------------------------------------*/ | |
| 518 | |
| 519 SPAN_DECLARE(size_t) t30_get_tx_csa(t30_state_t *s, int *type, const char *address[]) | |
| 520 { | |
| 521 if (type) | |
| 522 *type = s->tx_info.csa_type; | |
| 523 if (address) | |
| 524 *address = s->tx_info.csa; | |
| 525 return s->tx_info.csa_len; | |
| 526 } | |
| 527 /*- End of function --------------------------------------------------------*/ | |
| 528 | |
| 529 SPAN_DECLARE(size_t) t30_get_rx_csa(t30_state_t *s, int *type, const char *address[]) | |
| 530 { | |
| 531 if (type) | |
| 532 *type = s->rx_info.csa_type; | |
| 533 if (address) | |
| 534 *address = s->rx_info.csa; | |
| 535 return s->rx_info.csa_len; | |
| 536 } | |
| 537 /*- End of function --------------------------------------------------------*/ | |
| 538 | |
| 539 SPAN_DECLARE(int) t30_set_tx_page_header_info(t30_state_t *s, const char *info) | |
| 540 { | |
| 541 if (info == NULL) | |
| 542 { | |
| 543 s->header_info[0] = '\0'; | |
| 544 return 0; | |
| 545 } | |
| 546 if (strlen(info) > T30_MAX_PAGE_HEADER_INFO) | |
| 547 return -1; | |
| 548 strcpy(s->header_info, info); | |
| 549 t4_tx_set_header_info(&s->t4, s->header_info); | |
| 550 return 0; | |
| 551 } | |
| 552 /*- End of function --------------------------------------------------------*/ | |
| 553 | |
| 554 SPAN_DECLARE(size_t) t30_get_tx_page_header_info(t30_state_t *s, char *info) | |
| 555 { | |
| 556 if (info) | |
| 557 strcpy(info, s->header_info); | |
| 558 return strlen(s->header_info); | |
| 559 } | |
| 560 /*- End of function --------------------------------------------------------*/ | |
| 561 | |
| 562 SPAN_DECLARE(const char *) t30_get_rx_country(t30_state_t *s) | |
| 563 { | |
| 564 return s->country; | |
| 565 } | |
| 566 /*- End of function --------------------------------------------------------*/ | |
| 567 | |
| 568 SPAN_DECLARE(const char *) t30_get_rx_vendor(t30_state_t *s) | |
| 569 { | |
| 570 return s->vendor; | |
| 571 } | |
| 572 /*- End of function --------------------------------------------------------*/ | |
| 573 | |
| 574 SPAN_DECLARE(const char *) t30_get_rx_model(t30_state_t *s) | |
| 575 { | |
| 576 return s->model; | |
| 577 } | |
| 578 /*- End of function --------------------------------------------------------*/ | |
| 579 | |
| 580 SPAN_DECLARE(void) t30_set_rx_file(t30_state_t *s, const char *file, int stop_page) | |
| 581 { | |
| 582 strncpy(s->rx_file, file, sizeof(s->rx_file)); | |
| 583 s->rx_file[sizeof(s->rx_file) - 1] = '\0'; | |
| 584 s->rx_stop_page = stop_page; | |
| 585 } | |
| 586 /*- End of function --------------------------------------------------------*/ | |
| 587 | |
| 588 SPAN_DECLARE(void) t30_set_tx_file(t30_state_t *s, const char *file, int start_page, int stop_page) | |
| 589 { | |
| 590 strncpy(s->tx_file, file, sizeof(s->tx_file)); | |
| 591 s->tx_file[sizeof(s->tx_file) - 1] = '\0'; | |
| 592 s->tx_start_page = start_page; | |
| 593 s->tx_stop_page = stop_page; | |
| 594 } | |
| 595 /*- End of function --------------------------------------------------------*/ | |
| 596 | |
| 597 SPAN_DECLARE(void) t30_set_iaf_mode(t30_state_t *s, int iaf) | |
| 598 { | |
| 599 s->iaf = iaf; | |
| 600 } | |
| 601 /*- End of function --------------------------------------------------------*/ | |
| 602 | |
| 603 SPAN_DECLARE(int) t30_set_ecm_capability(t30_state_t *s, int enabled) | |
| 604 { | |
| 605 s->ecm_allowed = enabled; | |
| 606 t30_build_dis_or_dtc(s); | |
| 607 return 0; | |
| 608 } | |
| 609 /*- End of function --------------------------------------------------------*/ | |
| 610 | |
| 611 SPAN_DECLARE(int) t30_set_rx_encoding(t30_state_t *s, int encoding) | |
| 612 { | |
| 613 switch (encoding) | |
| 614 { | |
| 615 case T4_COMPRESSION_ITU_T4_1D: | |
| 616 case T4_COMPRESSION_ITU_T4_2D: | |
| 617 case T4_COMPRESSION_ITU_T6: | |
| 618 s->output_encoding = encoding; | |
| 619 return 0; | |
| 620 } | |
| 621 return -1; | |
| 622 } | |
| 623 /*- End of function --------------------------------------------------------*/ | |
| 624 | |
| 625 SPAN_DECLARE(int) t30_set_minimum_scan_line_time(t30_state_t *s, int min_time) | |
| 626 { | |
| 627 /* There are only certain possible times supported, so we need to select | |
| 628 the code which best matches the request. */ | |
| 629 if (min_time == 0) | |
| 630 s->local_min_scan_time_code = 7; | |
| 631 else if (min_time <= 5) | |
| 632 s->local_min_scan_time_code = 1; | |
| 633 else if (min_time <= 10) | |
| 634 s->local_min_scan_time_code = 2; | |
| 635 else if (min_time <= 20) | |
| 636 s->local_min_scan_time_code = 0; | |
| 637 else if (min_time <= 40) | |
| 638 s->local_min_scan_time_code = 4; | |
| 639 else | |
| 640 return -1; | |
| 641 t30_build_dis_or_dtc(s); | |
| 642 return 0; | |
| 643 } | |
| 644 /*- End of function --------------------------------------------------------*/ | |
| 645 | |
| 646 SPAN_DECLARE(int) t30_set_supported_modems(t30_state_t *s, int supported_modems) | |
| 647 { | |
| 648 s->supported_modems = supported_modems; | |
| 649 t30_build_dis_or_dtc(s); | |
| 650 return 0; | |
| 651 } | |
| 652 /*- End of function --------------------------------------------------------*/ | |
| 653 | |
| 654 SPAN_DECLARE(int) t30_set_supported_compressions(t30_state_t *s, int supported_compressions) | |
| 655 { | |
| 656 s->supported_compressions = supported_compressions; | |
| 657 t30_build_dis_or_dtc(s); | |
| 658 return 0; | |
| 659 } | |
| 660 /*- End of function --------------------------------------------------------*/ | |
| 661 | |
| 662 SPAN_DECLARE(int) t30_set_supported_resolutions(t30_state_t *s, int supported_resolutions) | |
| 663 { | |
| 664 s->supported_resolutions = supported_resolutions; | |
| 665 t30_build_dis_or_dtc(s); | |
| 666 return 0; | |
| 667 } | |
| 668 /*- End of function --------------------------------------------------------*/ | |
| 669 | |
| 670 SPAN_DECLARE(int) t30_set_supported_image_sizes(t30_state_t *s, int supported_image_sizes) | |
| 671 { | |
| 672 s->supported_image_sizes = supported_image_sizes; | |
| 673 t30_build_dis_or_dtc(s); | |
| 674 return 0; | |
| 675 } | |
| 676 /*- End of function --------------------------------------------------------*/ | |
| 677 | |
| 678 SPAN_DECLARE(int) t30_set_supported_t30_features(t30_state_t *s, int supported_t30_features) | |
| 679 { | |
| 680 s->supported_t30_features = supported_t30_features; | |
| 681 t30_build_dis_or_dtc(s); | |
| 682 return 0; | |
| 683 } | |
| 684 /*- End of function --------------------------------------------------------*/ | |
| 685 | |
| 686 SPAN_DECLARE(void) t30_set_status(t30_state_t *s, int status) | |
| 687 { | |
| 688 s->current_status = status; | |
| 689 } | |
| 690 /*- End of function --------------------------------------------------------*/ | |
| 691 | |
| 692 SPAN_DECLARE(int) t30_set_receiver_not_ready(t30_state_t *s, int count) | |
| 693 { | |
| 694 s->receiver_not_ready_count = count; | |
| 695 return 0; | |
| 696 } | |
| 697 /*- End of function --------------------------------------------------------*/ | |
| 698 | |
| 699 SPAN_DECLARE(void) t30_set_phase_b_handler(t30_state_t *s, t30_phase_b_handler_t *handler, void *user_data) | |
| 700 { | |
| 701 s->phase_b_handler = handler; | |
| 702 s->phase_b_user_data = user_data; | |
| 703 } | |
| 704 /*- End of function --------------------------------------------------------*/ | |
| 705 | |
| 706 SPAN_DECLARE(void) t30_set_phase_d_handler(t30_state_t *s, t30_phase_d_handler_t *handler, void *user_data) | |
| 707 { | |
| 708 s->phase_d_handler = handler; | |
| 709 s->phase_d_user_data = user_data; | |
| 710 } | |
| 711 /*- End of function --------------------------------------------------------*/ | |
| 712 | |
| 713 SPAN_DECLARE(void) t30_set_phase_e_handler(t30_state_t *s, t30_phase_e_handler_t *handler, void *user_data) | |
| 714 { | |
| 715 s->phase_e_handler = handler; | |
| 716 s->phase_e_user_data = user_data; | |
| 717 } | |
| 718 /*- End of function --------------------------------------------------------*/ | |
| 719 | |
| 720 SPAN_DECLARE(void) t30_set_document_handler(t30_state_t *s, t30_document_handler_t *handler, void *user_data) | |
| 721 { | |
| 722 s->document_handler = handler; | |
| 723 s->document_user_data = user_data; | |
| 724 } | |
| 725 /*- End of function --------------------------------------------------------*/ | |
| 726 | |
| 727 SPAN_DECLARE(void) t30_set_real_time_frame_handler(t30_state_t *s, t30_real_time_frame_handler_t *handler, void *user_data) | |
| 728 { | |
| 729 s->real_time_frame_handler = handler; | |
| 730 s->real_time_frame_user_data = user_data; | |
| 731 } | |
| 732 /*- End of function --------------------------------------------------------*/ | |
| 733 | |
| 734 SPAN_DECLARE(logging_state_t *) t30_get_logging_state(t30_state_t *s) | |
| 735 { | |
| 736 return &s->logging; | |
| 737 } | |
| 738 /*- End of function --------------------------------------------------------*/ | |
| 739 /*- End of file ------------------------------------------------------------*/ |
