SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party) { if (s == NULL) { if ((s = (fax_state_t *) malloc(sizeof(*s))) == NULL) return NULL; } memset(s, 0, sizeof(*s)); span_log_init(&s->logging, SPAN_LOG_NONE, NULL); span_log_set_protocol(&s->logging, "FAX"); fax_modems_init(&s->modems, FALSE, t30_hdlc_accept, hdlc_underflow_handler, t30_non_ecm_put_bit, t30_non_ecm_get_bit, tone_detected, &s->t30); t30_init(&s->t30, calling_party, fax_set_rx_type, (void *) s, fax_set_tx_type, (void *) s, fax_send_hdlc, (void *) s); t30_set_supported_modems(&s->t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17); t30_restart(&s->t30); #if defined(LOG_FAX_AUDIO) { char buf[100 + 1]; struct tm *tm; time_t now; time(&now); tm = localtime(&now); sprintf(buf, "/tmp/fax-rx-audio-%p-%02d%02d%02d%02d%02d%02d", s, tm->tm_year%100, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); s->modems.audio_rx_log = open(buf, O_CREAT | O_TRUNC | O_WRONLY, 0666); sprintf(buf, "/tmp/fax-tx-audio-%p-%02d%02d%02d%02d%02d%02d", s, tm->tm_year%100, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); s->modems.audio_tx_log = open(buf, O_CREAT | O_TRUNC | O_WRONLY, 0666); } #endif return s; }
SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party) { #if 0 v8_parms_t v8_parms; #endif if (s == NULL) { if ((s = (fax_state_t *) span_alloc(sizeof(*s))) == NULL) return NULL; /*endif*/ } /*endif*/ memset(s, 0, sizeof(*s)); span_log_init(&s->logging, SPAN_LOG_NONE, NULL); span_log_set_protocol(&s->logging, "FAX"); fax_modems_init(&s->modems, false, t30_hdlc_accept, hdlc_underflow_handler, t30_non_ecm_put_bit, t30_non_ecm_get_bit, tone_detected, &s->t30); t30_init(&s->t30, calling_party, fax_set_rx_type, (void *) s, fax_set_tx_type, (void *) s, fax_send_hdlc, (void *) s); t30_set_supported_modems(&s->t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17); #if 0 v8_parms.modem_connect_tone = MODEM_CONNECT_TONES_ANSAM_PR; v8_parms.call_function = V8_CALL_T30_RX; v8_parms.modulations = V8_MOD_V21; if (s->t30.supported_modems & T30_SUPPORT_V27TER) v8_parms.modulations |= V8_MOD_V27TER; /*endif*/ if (s->t30.supported_modems & T30_SUPPORT_V29) v8_parms.modulations |= V8_MOD_V29; /*endif*/ if (s->t30.supported_modems & T30_SUPPORT_V17) v8_parms.modulations |= V8_MOD_V17; /*endif*/ if (s->t30.supported_modems & T30_SUPPORT_V34HDX) v8_parms.modulations |= V8_MOD_V34HDX; /*endif*/ v8_parms.protocol = V8_PROTOCOL_NONE; v8_parms.pcm_modem_availability = 0; v8_parms.pstn_access = 0; v8_parms.nsf = -1; v8_parms.t66 = -1; v8_init(&s->v8, calling_party, &v8_parms, v8_handler, s); #endif fax_restart(s, calling_party); return s; }