]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Spandsp tweaks
authorSteve Underwood <steveu@x100e.coppice.org>
Tue, 23 Jul 2013 12:44:46 +0000 (20:44 +0800)
committerSteve Underwood <steveu@x100e.coppice.org>
Tue, 23 Jul 2013 12:44:46 +0000 (20:44 +0800)
libs/spandsp/src/spandsp/t42.h
libs/spandsp/src/spandsp/v18.h
libs/spandsp/src/t4_tx.c
libs/spandsp/src/v18.c
libs/spandsp/tests/fax_tests.sh
libs/spandsp/tests/v18_tests.c
src/mod/applications/mod_spandsp/mod_spandsp_dsp.c

index 343780b9fe83138fe8b1f7c127268623dd97484e..17c4758a7fb0abdd1b5219121905f8631f19c9b0 100644 (file)
@@ -76,16 +76,6 @@ SPAN_DECLARE(void) set_lab_gamut2(lab_params_t *s, int L_P, int L_Q, int a_P, in
 
 SPAN_DECLARE(void) get_lab_gamut2(lab_params_t *s, int *L_P, int *L_Q, int *a_P, int *a_Q, int *b_P, int *b_Q);
 
-SPAN_DECLARE(int) t42_itulab_to_itulab(logging_state_t *logging, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t width, uint32_t height);
-
-SPAN_DECLARE(int) t42_itulab_to_jpeg(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen);
-
-SPAN_DECLARE(int) t42_jpeg_to_itulab(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen);
-
-SPAN_DECLARE(int) t42_srgb_to_itulab(logging_state_t *logging, lab_params_t *s, tdata_t *dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t width, uint32_t height);
-
-SPAN_DECLARE(int) t42_itulab_to_srgb(logging_state_t *logging, lab_params_t *s, tdata_t dst, tsize_t *dstlen, tdata_t src, tsize_t srclen, uint32_t *width, uint32_t *height);
-
 SPAN_DECLARE(void) t42_encode_set_options(t42_encode_state_t *s, uint32_t l0, int quality, int options);
 
 SPAN_DECLARE(int) t42_encode_set_image_width(t42_encode_state_t *s, uint32_t image_width);
index b1fd500f43cdf1b065d5088afdc4b0c373c51d72..970d2a3f22b46553780f89d9d056ea5ee8334e7f 100644 (file)
@@ -40,7 +40,7 @@ enum
 {
     V18_MODE_NONE = 0,
     /* V.18 Annex A - Weitbrecht TDD at 45.45bps (US TTY), half-duplex, 5 bit baudot (USA). */
-    V18_MODE_5BIT_45 = 1,
+    V18_MODE_5BIT_4545 = 1,
     /* V.18 Annex A - Weitbrecht TDD at 50bps (International TTY), half-duplex, 5 bit baudot (UK, Australia and others). */
     V18_MODE_5BIT_50 = 2,
     /* V.18 Annex B - DTMF encoding of ASCII (Denmark, Holland and others). */
@@ -55,6 +55,7 @@ enum
     V18_MODE_V21TEXTPHONE = 7,
     /* V.18 Annex G - V.18 text telephone mode. */
     V18_MODE_V18TEXTPHONE = 8,
+    V18_MODE_5BIT_476 = 9,
     /* Use repetitive shift characters where character set shifts are used */ 
     V18_MODE_REPETITIVE_SHIFTS_OPTION = 0x1000
 };
@@ -171,28 +172,6 @@ SPAN_DECLARE_NONSTD(int) v18_rx_fillin(v18_state_t *s, int len);
             invalid, this function will return -1. */
 SPAN_DECLARE(int) v18_put(v18_state_t *s, const char msg[], int len);
 
-/*! Convert a text string to a V.18 DTMF string.
-    \brief Convert a text string to a V.18 DTMF string.
-    \param s The V.18 context.
-    \param dtmf The resulting DTMF string.
-    \param msg The text string to be converted.
-    \return The length of the DTMF string.
-*/
-SPAN_DECLARE(int) v18_encode_dtmf(v18_state_t *s, char dtmf[], const char msg[]);
-
-/*! Convert a V.18 DTMF string to a text string.
-    \brief Convert a V.18 DTMF string to a text string.
-    \param s The V.18 context.
-    \param msg The resulting test string.
-    \param dtmf The DTMF string to be converted.
-    \return The length of the text string.
-*/
-SPAN_DECLARE(int) v18_decode_dtmf(v18_state_t *s, char msg[], const char dtmf[]);
-
-SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch);
-
-SPAN_DECLARE(uint8_t) v18_decode_baudot(v18_state_t *s, uint8_t ch);
-
 /*! \brief Return a short name for an V.18 mode
     \param mode The code for the V.18 mode.
     \return A pointer to the name.
index d281ff38f7d110f753ab5d32faf191cda0785706..ee0d6202d9fbcca834ca28f75d7caf65a7b21704 100644 (file)
@@ -132,18 +132,19 @@ static const res_table_t y_res_table[] =
     {             -1.00f, -1}
 };
 
-static const int resolution_map[10][10] =
+static const int resolution_map[10][9] =
 {
-    {                    0, 0,                     0,  T4_RESOLUTION_R8_STANDARD,                     0,                     0,                           0,                      0, 0,                       0},
-    {T4_RESOLUTION_100_100, 0, T4_RESOLUTION_200_100,                          0,                     0,                     0,                           0,                      0, 0,                       0},
-    {                    0, 0,                     0,      T4_RESOLUTION_R8_FINE,                     0,                     0,                           0,                      0, 0,                       0},
-    {                    0, 0, T4_RESOLUTION_200_200,                          0,                     0,                     0,                           0,                      0, 0,                       0},
-    {                    0, 0,                     0,                          0, T4_RESOLUTION_300_300,                     0,                           0,                      0, 0,                       0},
-    {                    0, 0,                     0, T4_RESOLUTION_R8_SUPERFINE,                     0,                     0, T4_RESOLUTION_R16_SUPERFINE,                      0, 0,                       0},
-    {                    0, 0, T4_RESOLUTION_200_400,                          0,                     0, T4_RESOLUTION_400_400,                           0,                      0, 0,                       0},
-    {                    0, 0,                     0,                          0, T4_RESOLUTION_300_600,                     0,                           0,  T4_RESOLUTION_600_600, 0,                       0},
-    {                    0, 0,                     0,                          0,                     0, T4_RESOLUTION_400_800,                           0,                      0, 0,                       0},
-    {                    0, 0,                     0,                          0,                     0,                     0,                           0, T4_RESOLUTION_600_1200, 0, T4_RESOLUTION_1200_1200},
+    /*  x =           100 102                    200                         204                    300                    400                          408                     600                     1200 */
+    {                    0, 0,                     0,  T4_RESOLUTION_R8_STANDARD,                     0,                     0,                           0,                      0,                       0}, /* y = 3.85/mm */
+    {T4_RESOLUTION_100_100, 0, T4_RESOLUTION_200_100,                          0,                     0,                     0,                           0,                      0,                       0}, /* y = 100 */
+    {                    0, 0,                     0,      T4_RESOLUTION_R8_FINE,                     0,                     0,                           0,                      0,                       0}, /* y = 7.7/mm */
+    {                    0, 0, T4_RESOLUTION_200_200,                          0,                     0,                     0,                           0,                      0,                       0}, /* y = 200 */
+    {                    0, 0,                     0,                          0, T4_RESOLUTION_300_300,                     0,                           0,                      0,                       0}, /* y = 300 */
+    {                    0, 0,                     0, T4_RESOLUTION_R8_SUPERFINE,                     0,                     0, T4_RESOLUTION_R16_SUPERFINE,                      0,                       0}, /* y = 154/mm */
+    {                    0, 0, T4_RESOLUTION_200_400,                          0,                     0, T4_RESOLUTION_400_400,                           0,                      0,                       0}, /* y = 400 */
+    {                    0, 0,                     0,                          0, T4_RESOLUTION_300_600,                     0,                           0,  T4_RESOLUTION_600_600,                       0}, /* y = 600 */
+    {                    0, 0,                     0,                          0,                     0, T4_RESOLUTION_400_800,                           0,                      0,                       0}, /* y = 800 */
+    {                    0, 0,                     0,                          0,                     0,                     0,                           0, T4_RESOLUTION_600_1200, T4_RESOLUTION_1200_1200}  /* y = 1200 */
 };
 
 #if defined(SPANDSP_SUPPORT_TIFF_FX)
@@ -1354,12 +1355,14 @@ SPAN_DECLARE(void) t4_tx_get_transfer_statistics(t4_tx_state_t *s, t4_stats_t *t
     t->image_type = s->tiff.image_type;
     t->image_width = s->tiff.image_width;
     t->image_length = s->tiff.image_length;
+
     t->image_x_resolution = s->tiff.x_resolution;
     t->image_y_resolution = s->tiff.y_resolution;
-
     t->x_resolution = s->metadata.x_resolution;
     t->y_resolution = s->metadata.y_resolution/s->row_squashing_ratio;
+
     t->compression = s->metadata.compression;
+
     switch (s->metadata.compression)
     {
     case T4_COMPRESSION_T4_1D:
@@ -1417,7 +1420,7 @@ SPAN_DECLARE(int) t4_tx_image_complete(t4_tx_state_t *s)
         return t85_encode_image_complete(&s->encoder.t85);
 #if defined(SPANDSP_SUPPORT_T88)
     case T4_COMPRESSION_T88:
-        break;
+        return t88_encode_image_complete(&s->encoder.t88);
 #endif
     case T4_COMPRESSION_T42_T81:
     case T4_COMPRESSION_SYCC_T81:
@@ -1428,7 +1431,7 @@ SPAN_DECLARE(int) t4_tx_image_complete(t4_tx_state_t *s)
 #endif
 #if defined(SPANDSP_SUPPORT_T45)
     case T4_COMPRESSION_T45:
-        break;
+        return t45_encode_image_complete(&s->encoder.t45);
 #endif
     }
     return SIG_STATUS_END_OF_DATA;
@@ -1444,6 +1447,19 @@ SPAN_DECLARE(int) t4_tx_get_bit(t4_tx_state_t *s)
 
 SPAN_DECLARE(int) t4_tx_get(t4_tx_state_t *s, uint8_t buf[], size_t max_len)
 {
+#if 0
+    if (s->pre_encoded_len > 0)
+    {
+        if (max_len > (s->pre_encoded_len - s->pre_encoded_ptr))
+            max_len = s->pre_encoded_len - s->pre_encoded_ptr;
+        memcpy(buf, &s->pre_encoded_buf[s->pre_encoded_ptr], max_len);
+        s->pre_encoded_ptr += max_len;
+        return max_len;
+    }
+
+    if (s->image_get_handler)
+        return s->image_get_handler((void *) &s->encoder, buf, max_len);
+#else
     switch (s->metadata.compression)
     {
     case T4_COMPRESSION_T4_1D:
@@ -1469,6 +1485,7 @@ SPAN_DECLARE(int) t4_tx_get(t4_tx_state_t *s, uint8_t buf[], size_t max_len)
         break;
 #endif
     }
+#endif
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
@@ -1497,31 +1514,44 @@ SPAN_DECLARE(int) t4_tx_start_page(t4_tx_state_t *s)
     case T4_COMPRESSION_T4_2D:
     case T4_COMPRESSION_T6:
         t4_t6_encode_restart(&s->encoder.t4_t6, s->metadata.image_width, s->metadata.image_length);
+        s->image_get_handler = (t4_image_get_handler_t) t4_t6_encode_get;
         break;
     case T4_COMPRESSION_T85:
     case T4_COMPRESSION_T85_L0:
         t85_encode_restart(&s->encoder.t85, s->metadata.image_width, s->metadata.image_length);
+        s->image_get_handler = (t4_image_get_handler_t) t85_encode_get;
         break;
 #if defined(SPANDSP_SUPPORT_T88)
     case T4_COMPRESSION_T88:
+        t88_encode_restart(&s->encoder.t88, s->metadata.image_width, s->metadata.image_length);
+        s->image_get_handler = (t4_image_get_handler_t) t88_encode_get;
         break;
 #endif
     case T4_COMPRESSION_T42_T81:
     case T4_COMPRESSION_SYCC_T81:
         t42_encode_restart(&s->encoder.t42, s->metadata.image_width, s->metadata.image_length);
+        s->image_get_handler = (t4_image_get_handler_t) t42_encode_get;
         break;
 #if defined(SPANDSP_SUPPORT_T43)
     case T4_COMPRESSION_T43:
         t43_encode_restart(&s->encoder.t43, s->metadata.image_width, s->metadata.image_length);
+        s->image_get_handler = (t4_image_get_handler_t) t43_encode_get;
         break;
 #endif
 #if defined(SPANDSP_SUPPORT_T45)
     case T4_COMPRESSION_T45:
+        t45_encode_restart(&s->encoder.t45, s->metadata.image_width, s->metadata.image_length);
+        s->image_get_handler = (t4_image_get_handler_t) t45_encode_get;
         break;
 #endif
+    default:
+        s->image_get_handler = NULL;
+        break;
     }
+
     /* If there is a page header, create that first */
-    if (s->tiff.image_type == T4_IMAGE_TYPE_BILEVEL  &&  s->header_info  &&  s->header_info[0]  &&  make_header(s) == 0)
+    if (s->metadata.image_type == T4_IMAGE_TYPE_BILEVEL  &&  s->header_info  &&  s->header_info[0]  &&  make_header(s) == 0)
+    //if (s->header_info  &&  s->header_info[0]  &&  make_header(s) == 0)
     {
         s->header_row = 0;
         set_row_read_handler(s, header_row_read_handler, (void *) s);
@@ -1634,7 +1664,7 @@ SPAN_DECLARE(int) t4_tx_release(t4_tx_state_t *s)
         return t85_encode_release(&s->encoder.t85);
 #if defined(SPANDSP_SUPPORT_T88)
     case T4_COMPRESSION_T88:
-        break;
+        return t88_encode_release(&s->encoder.t88);
 #endif
     case T4_COMPRESSION_T42_T81:
     case T4_COMPRESSION_SYCC_T81:
@@ -1645,7 +1675,7 @@ SPAN_DECLARE(int) t4_tx_release(t4_tx_state_t *s)
 #endif
 #if defined(SPANDSP_SUPPORT_T45)
     case T4_COMPRESSION_T45:
-        break;
+        return t45_encode_release(&s->encoder.t45);
 #endif
     }
     return -1;
index 70a9cacc9158b552368d09a44538d3de8b68a814..65783eb73b8f60e5a3cb8d90227df81fa148b9ad 100644 (file)
             Silence for 0.5s then send TXP
         DTMF
             Proceed as Annex B
-        1650Hz (V21 ch 2 low)
+        1650Hz (V21 ch 2 low) [1650Hz +-12Hz]
             Proceed as Annex F in call mode
-        1300Hz (Calling tone)
+        1300Hz (Calling tone) [1300Hz +-16Hz]
             Proceed as Annex E in call mode
-        1400Hz/1800Hz (Weitbrecht)
+        1400Hz/1800Hz (Weitbrecht) [1400Hz +-5% and 1800Hz +-5%]
             Detect rate and proceed as Annex A
-        980Hz/1180Hz (V21 ch 1)
+        980Hz/1180Hz (V21 ch 1) [980Hz +-12Hz, 1180Hz +-12Hz]
             Start timer Tr
         2225Hz (Bell ANS)
             Proceed as Annex D call mode
             Monitor as caller for 980Hz or 1300Hz
         CI/XCI
             Respond with ANSam
-        1300Hz
+        1300Hz [1300Hz +-16Hz]
             Probe
         Timer Ta (3s)
             Probe
-        1400Hz/1800Hz (Weitbrecht)
+        1400Hz/1800Hz (Weitbrecht) [1400Hz +-5% and 1800Hz +-5%]
             Detect rate and proceed as Annex A
         DTMF
             Proceed as Annex B
-        980Hz (V21 ch 1 low)
+        980Hz (V21 ch 1 low) [980Hz +-12Hz]
             Start timer Te
         1270Hz (Bell103 ch 2 high)
             Proceed as Annex D answer mode
         2225Hz (Bell ANS)
             Proceed as Annex D call mode
-        1650Hz (V21 ch 2 low)
+        1650Hz (V21 ch 2 low) [1650Hz +-12Hz]
             Proceed as Annex F answer mode
         ANSam
             Proceed as V.8 caller Annex G
@@ -131,6 +131,7 @@ struct dtmf_to_ascii_s
 
 static const struct dtmf_to_ascii_s dtmf_to_ascii[] =
 {
+    {"###0", '!'},
     {"###1", 'C'},
     {"###2", 'F'},
     {"###3", 'I'},
@@ -140,7 +141,6 @@ static const struct dtmf_to_ascii_s dtmf_to_ascii[] =
     {"###7", 'U'},
     {"###8", 'X'},
     {"###9", ';'},
-    {"###0", '!'},
     {"##*1", 'A'},
     {"##*2", 'D'},
     {"##*3", 'G'},
@@ -373,71 +373,174 @@ static const uint8_t txp[] = "1111111111000101011100001101110000010101";
     100 ms mark. */
 static const uint8_t xci[] = "01111111110111111111";
 
-static int cmp(const void *s, const void *t)
-{
-    const char *ss;
-    struct dtmf_to_ascii_s *tt;
-
-    ss = (const char *) s;
-    tt = (struct dtmf_to_ascii_s *) t;
-    return strncmp(ss, tt->dtmf, strlen(tt->dtmf));
-}
-/*- End of function --------------------------------------------------------*/
-
-SPAN_DECLARE(int) v18_encode_dtmf(v18_state_t *s, char dtmf[], const char msg[])
+/* The entries here must match the order in which the related names are defined in v18.h */
+static const int automoding_sequences[][6] =
 {
-    const char *t;
-    const char *v;
-    char *u;
-
-    t = msg;
-    u = dtmf;
-    while (*t)
     {
-        v = ascii_to_dtmf[*t & 0x7F];
-        while (*v)
-            *u++ = *v++;
-        t++;
-    }
-    *u = '\0';
-
-    return u - dtmf;
-}
-/*- End of function --------------------------------------------------------*/
-
-SPAN_DECLARE(int) v18_decode_dtmf(v18_state_t *s, char msg[], const char dtmf[])
-{
-    int entries;
-    const char *t;
-    char *u;
-    struct dtmf_to_ascii_s *ss;
-
-    entries = sizeof(dtmf_to_ascii)/sizeof(dtmf_to_ascii[0]) - 1;
-    t = dtmf;
-    u = msg;
-    while (*t)
+        /* Dummy entry 0 */
+        V18_MODE_5BIT_4545,
+        V18_MODE_BELL103,
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_EDT,
+        V18_MODE_DTMF
+    },
     {
-        ss = bsearch(t, dtmf_to_ascii, entries, sizeof(dtmf_to_ascii[0]), cmp);
-        if (ss)
-        {
-            t += strlen(ss->dtmf);
-            *u++ = ss->ascii;
-        }
-        else
-        {
-            /* Can't match the code. Let's assume this is a code we just don't know, and skip over it */
-            while (*t == '#'  ||  *t == '*')
-                t++;
-            if (*t)
-                t++;
-        }
+        /* Australia */
+        V18_MODE_5BIT_50,
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_EDT,
+        V18_MODE_DTMF,
+        V18_MODE_BELL103
+    },
+    {
+        /* Ireland */
+        V18_MODE_5BIT_50,
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_EDT,
+        V18_MODE_DTMF,
+        V18_MODE_BELL103
+    },
+    {
+        /* Germany */
+        V18_MODE_EDT,
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_5BIT_50,
+        V18_MODE_DTMF,
+        V18_MODE_BELL103
+    },
+    {
+        /* Switzerland */
+        V18_MODE_EDT,
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_5BIT_50,
+        V18_MODE_DTMF,
+        V18_MODE_BELL103
+    },
+    {
+        /* Italy */
+        V18_MODE_EDT,
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_5BIT_50,
+        V18_MODE_DTMF,
+        V18_MODE_BELL103
+    },
+    {
+        /* Spain */
+        V18_MODE_EDT,
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_5BIT_50,
+        V18_MODE_DTMF,
+        V18_MODE_BELL103
+    },
+    {
+        /* Austria */
+        V18_MODE_EDT,
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_5BIT_50,
+        V18_MODE_DTMF,
+        V18_MODE_BELL103
+    },
+    {
+        /* Netherlands */
+        V18_MODE_DTMF,
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_5BIT_50,
+        V18_MODE_EDT,
+        V18_MODE_BELL103
+    },
+    {
+        /* Iceland */
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_DTMF,
+        V18_MODE_5BIT_50,
+        V18_MODE_EDT,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_BELL103
+    },
+    {
+        /* Norway */
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_DTMF,
+        V18_MODE_5BIT_50,
+        V18_MODE_EDT,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_BELL103
+    },
+    {
+        /* Sweden */
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_DTMF,
+        V18_MODE_5BIT_50,
+        V18_MODE_EDT,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_BELL103
+    },
+    {
+        /* Finland */
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_DTMF,
+        V18_MODE_5BIT_50,
+        V18_MODE_EDT,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_BELL103
+    },
+    {
+        /* Denmark */
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_DTMF,
+        V18_MODE_5BIT_50,
+        V18_MODE_EDT,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_BELL103
+    },
+    {
+        /* UK */
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_5BIT_50,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_EDT,
+        V18_MODE_DTMF,
+        V18_MODE_BELL103
+    },
+    {
+        /* USA */
+        V18_MODE_5BIT_4545,
+        V18_MODE_BELL103,
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_EDT,
+        V18_MODE_DTMF
+    },
+    {
+        /* France */
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_EDT,
+        V18_MODE_DTMF,
+        V18_MODE_5BIT_50,
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_BELL103
+    },
+    {
+        /* Belgium */
+        V18_MODE_V23VIDEOTEX,
+        V18_MODE_EDT,
+        V18_MODE_DTMF,
+        V18_MODE_5BIT_50,
+        V18_MODE_V21TEXTPHONE,
+        V18_MODE_BELL103
     }
-    *u = '\0';
-    return u - msg;
-}
-/*- End of function --------------------------------------------------------*/
+};
 
-SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch)
+static uint16_t encode_baudot(v18_state_t *s, uint8_t ch)
 {
     static const uint8_t conv[128] =
     {
@@ -449,7 +552,7 @@ SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch)
         0xFF, /* ENQ */
         0xFF, /* ACK */
         0xFF, /* BEL */
-        0x00, /* BS */
+        0x40, /* BS */
         0x44, /* HT >> SPACE */
         0x42, /* LF */
         0x42, /* VT >> LF */
@@ -572,14 +675,7 @@ SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch)
     };
     uint16_t shift;
 
-    if (ch == 0x7F)
-    {
-        /* DLE is a special character meaning "force a
-           change to the letter character set */
-        shift = BAUDOT_LETTER_SHIFT;
-        return 0;
-    }
-    ch = conv[ch];
+    ch = conv[ch & 0x7F];
     /* Is it a non-existant code? */
     if (ch == 0xFF)
         return 0;
@@ -605,7 +701,7 @@ SPAN_DECLARE(uint16_t) v18_encode_baudot(v18_state_t *s, uint8_t ch)
 }
 /*- End of function --------------------------------------------------------*/
 
-SPAN_DECLARE(uint8_t) v18_decode_baudot(v18_state_t *s, uint8_t ch)
+static uint8_t decode_baudot(v18_state_t *s, uint8_t ch)
 {
     static const uint8_t conv[2][32] =
     {
@@ -624,8 +720,8 @@ SPAN_DECLARE(uint8_t) v18_decode_baudot(v18_state_t *s, uint8_t ch)
     default:
         return conv[s->baudot_rx_shift][ch];
     }
-    /* return 0 if we did not produce a character */
-    return 0;
+    /* Return 0xFF if we did not produce a character */
+    return 0xFF;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -649,7 +745,7 @@ static int v18_tdd_get_async_byte(void *user_data)
     if (s->tx_signal_on)
     {
         /* The FSK should now be switched off. */
-        s->tx_signal_on = FALSE;
+        s->tx_signal_on = 0;
     }
     return 0x1F;
 }
@@ -659,14 +755,16 @@ static void v18_dtmf_get(void *user_data)
 {
     v18_state_t *s;
     int ch;
-    const char *v;
+    int len;
+    const char *t;
 
     s = (v18_state_t *) user_data;
     if ((ch = queue_read_byte(&s->queue.queue)) >= 0)
     {
-        v = ascii_to_dtmf[ch & 0x7F];
-        dtmf_tx_put(&s->dtmf_tx, v, strlen(v));
-        s->rx_suppression = ((300 + 100*strlen(v))*SAMPLE_RATE)/1000;
+        t = ascii_to_dtmf[ch & 0x7F];
+        len = strlen(t);
+        dtmf_tx_put(&s->dtmf_tx, t, len);
+        s->rx_suppression = ((300 + 100*len)*SAMPLE_RATE)/1000;
     }
 }
 /*- End of function --------------------------------------------------------*/
@@ -685,7 +783,7 @@ static int v18_edt_get_async_byte(void *user_data)
     if (s->tx_signal_on)
     {
         /* The FSK should now be switched off. */
-        s->tx_signal_on = FALSE;
+        s->tx_signal_on = 0;
     }
     return 0;
 }
@@ -726,7 +824,7 @@ static void v18_tdd_put_async_byte(void *user_data, int byte)
         return;
     }
     span_log(&s->logging, SPAN_LOG_FLOW, "Rx byte %x\n", byte);
-    if ((octet = v18_decode_baudot(s, byte)))
+    if ((octet = decode_baudot(s, byte)) != 0xFF)
         s->rx_msg[s->rx_msg_len++] = octet;
     if (s->rx_msg_len >= 256)
     {
@@ -738,11 +836,55 @@ static void v18_tdd_put_async_byte(void *user_data, int byte)
 }
 /*- End of function --------------------------------------------------------*/
 
+static int decode_dtmf_cmp(const void *s, const void *t)
+{
+    const char *ss;
+    struct dtmf_to_ascii_s *tt;
+
+    ss = (const char *) s;
+    tt = (struct dtmf_to_ascii_s *) t;
+    return strncmp(ss, tt->dtmf, strlen(tt->dtmf));
+}
+/*- End of function --------------------------------------------------------*/
+
+static int decode_dtmf(v18_state_t *s, char msg[], const char dtmf[])
+{
+    int entries;
+    int len;
+    const char *t;
+    char *u;
+    struct dtmf_to_ascii_s *ss;
+
+    entries = sizeof(dtmf_to_ascii)/sizeof(dtmf_to_ascii[0]) - 1;
+    t = dtmf;
+    u = msg;
+    while (*t)
+    {
+        ss = bsearch(t, dtmf_to_ascii, entries, sizeof(dtmf_to_ascii[0]), decode_dtmf_cmp);
+        if (ss)
+        {
+            len = strlen(ss->dtmf);
+            t += len;
+            *u++ = ss->ascii;
+            return len;
+        }
+        /* Can't match the code. Let's assume this is a code we just don't know, and skip over it */
+        while (*t == '#'  ||  *t == '*')
+            t++;
+        if (*t)
+            t++;
+    }
+    *u = '\0';
+    return u - msg;
+}
+/*- End of function --------------------------------------------------------*/
+
 static void v18_dtmf_put(void *user_data, const char dtmf[], int len)
 {
     v18_state_t *s;
     char buf[128];
     int i;
+    int matched;
 
     s = (v18_state_t *) user_data;
     if (s->rx_suppression > 0)
@@ -753,11 +895,17 @@ static void v18_dtmf_put(void *user_data, const char dtmf[], int len)
         if (dtmf[i] >= '0'  &&  dtmf[i] <= '9')
         {
             s->rx_msg[s->rx_msg_len] = '\0';
-            if (v18_decode_dtmf(s, buf, (const char *) s->rx_msg) > 0)
+            if ((matched = decode_dtmf(s, buf, (const char *) s->rx_msg)) > 0)
+            {
+                buf[1] = '\0';
                 s->put_msg(s->user_data, (const uint8_t *) buf, 1);
-            s->rx_msg_len = 0;
+            }
+            if (s->rx_msg_len > matched)
+                memcpy(&s->rx_msg[0], &s->rx_msg[matched], s->rx_msg_len - matched);
+            s->rx_msg_len -= matched;
         }
     }
+    s->in_progress = 5*SAMPLE_RATE;
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -815,7 +963,7 @@ SPAN_DECLARE_NONSTD(int) v18_tx(v18_state_t *s, int16_t *amp, int max_len)
             if (len < max_len)
             {
                 if ((lenx = fsk_tx(&s->fsk_tx, amp + len, max_len - len)) <= 0)
-                    s->tx_signal_on = FALSE;
+                    s->tx_signal_on = 0;
                 len += lenx;
             }
             break;
@@ -894,12 +1042,12 @@ SPAN_DECLARE(int) v18_put(v18_state_t *s, const char msg[], int len)
     }
     switch (s->mode)
     {
-    case V18_MODE_5BIT_45:
+    case V18_MODE_5BIT_4545:
     case V18_MODE_5BIT_50:
         for (i = 0;  i < len;  i++)
         {
             n = 0;
-            if ((x = v18_encode_baudot(s, msg[i])))
+            if ((x = encode_baudot(s, msg[i])))
             {
                 if ((x & 0x3E0))
                     buf[n++] = (uint8_t) ((x >> 5) & 0x1F);
@@ -907,7 +1055,7 @@ SPAN_DECLARE(int) v18_put(v18_state_t *s, const char msg[], int len)
                 /* TODO: Deal with out of space condition */
                 if (queue_write(&s->queue.queue, (const uint8_t *) buf, n) < 0)
                     return i;
-                s->tx_signal_on = TRUE;
+                s->tx_signal_on = 1;
             }
         }
         return len;
@@ -920,12 +1068,14 @@ SPAN_DECLARE(int) v18_put(v18_state_t *s, const char msg[], int len)
 
 SPAN_DECLARE(const char *) v18_mode_to_str(int mode)
 {
-    switch ((mode & 0xFF))
+    switch ((mode & 0xFFF))
     {
     case V18_MODE_NONE:
         return "None";
-    case V18_MODE_5BIT_45:
+    case V18_MODE_5BIT_4545:
         return "Weitbrecht TDD (45.45bps)";
+    case V18_MODE_5BIT_476:
+        return "Weitbrecht TDD (47.6bps)";
     case V18_MODE_5BIT_50:
         return "Weitbrecht TDD (50bps)";
     case V18_MODE_DTMF:
@@ -958,6 +1108,9 @@ SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
                                      put_msg_func_t put_msg,
                                      void *user_data)
 {
+    if (nation < 0  ||  nation >= V18_AUTOMODING_END)
+        return NULL;
+
     if (s == NULL)
     {
         if ((s = (v18_state_t *) malloc(sizeof(*s))) == NULL)
@@ -965,14 +1118,14 @@ SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
     }
     memset(s, 0, sizeof(*s));
     s->calling_party = calling_party;
-    s->mode = mode & 0xFF;
+    s->mode = mode & ~V18_MODE_REPETITIVE_SHIFTS_OPTION;
     s->put_msg = put_msg;
     s->user_data = user_data;
 
     switch (s->mode)
     {
-    case V18_MODE_5BIT_45:
-        s->repeat_shifts = mode & 0x100;
+    case V18_MODE_5BIT_4545:
+        s->repeat_shifts = mode & V18_MODE_REPETITIVE_SHIFTS_OPTION;
         fsk_tx_init(&s->fsk_tx, &preset_fsk_specs[FSK_WEITBRECHT_4545], async_tx_get_bit, &s->async_tx);
         async_tx_init(&s->async_tx, 5, ASYNC_PARITY_NONE, 2, FALSE, v18_tdd_get_async_byte, s);
         /* Schedule an explicit shift at the start of baudot transmission */
@@ -983,8 +1136,20 @@ SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
         s->baudot_rx_shift = 0;
         s->next_byte = (uint8_t) 0xFF;
         break;
+    case V18_MODE_5BIT_476:
+        s->repeat_shifts = mode & V18_MODE_REPETITIVE_SHIFTS_OPTION;
+        fsk_tx_init(&s->fsk_tx, &preset_fsk_specs[FSK_WEITBRECHT_476], async_tx_get_bit, &s->async_tx);
+        async_tx_init(&s->async_tx, 5, ASYNC_PARITY_NONE, 2, FALSE, v18_tdd_get_async_byte, s);
+        /* Schedule an explicit shift at the start of baudot transmission */
+        s->baudot_tx_shift = 2;
+        /* TDD uses 5 bit data, no parity and 1.5 stop bits. We scan for the first stop bit, and
+           ride over the fraction. */
+        fsk_rx_init(&s->fsk_rx, &preset_fsk_specs[FSK_WEITBRECHT_476], FSK_FRAME_MODE_5N1_FRAMES, v18_tdd_put_async_byte, s);
+        s->baudot_rx_shift = 0;
+        s->next_byte = (uint8_t) 0xFF;
+        break;
     case V18_MODE_5BIT_50:
-        s->repeat_shifts = mode & 0x100;
+        s->repeat_shifts = mode & V18_MODE_REPETITIVE_SHIFTS_OPTION;
         fsk_tx_init(&s->fsk_tx, &preset_fsk_specs[FSK_WEITBRECHT_50], async_tx_get_bit, &s->async_tx);
         async_tx_init(&s->async_tx, 5, ASYNC_PARITY_NONE, 2, FALSE, v18_tdd_get_async_byte, s);
         /* Schedule an explicit shift at the start of baudot transmission */
index 4d4d1bc4e54f2eafebcd524342a33a840635decc..1fa6d4e19a75e3bc1305ef907f8c19ed80a0423d 100755 (executable)
@@ -70,49 +70,55 @@ LOCALTESTS_DIR=../test-data/local
 # Colour/gray -> bilevel by not allowing ECM
 for OPTS in "-p AA" "-p TT" "-p GG" "-p TG" "-p GT"
 do
-    IN_FILE="${LOCALTESTS_DIR}/lenna-colour.tif"
-    OUT_FILE="${LOCALTESTS_DIR}/lenna-colour-bilevel.tif"
-    run_colour_fax_test
-
-    IN_FILE="${LOCALTESTS_DIR}/lenna-bw.tif"
-    OUT_FILE="${LOCALTESTS_DIR}/lenna-bw-bilevel.tif"
-    run_colour_fax_test
-
-    IN_FILE="${TIFFFX_DIR}/c03x_02x.tif"
-    OUT_FILE="${TIFFFX_DIR}/c03x_02x.tif"
-    run_colour_fax_test
-
-    IN_FILE="${TIFFFX_DIR}/l02x_02x.tif"
-    OUT_FILE="${TIFFFX_DIR}/l02x_02x.tif"
-    run_colour_fax_test
-
-    IN_FILE="${TIFFFX_DIR}/l04x_02x.tif"
-    OUT_FILE="${TIFFFX_DIR}/l04x_02x.tif"
-    run_colour_fax_test
+    echo Colour to bi-level tests disabled
+#    IN_FILE="${LOCALTESTS_DIR}/lenna-colour.tif"
+#    OUT_FILE="${LOCALTESTS_DIR}/lenna-colour-bilevel.tif"
+#    run_colour_fax_test
+
+#    IN_FILE="${LOCALTESTS_DIR}/lenna-bw.tif"
+#    OUT_FILE="${LOCALTESTS_DIR}/lenna-bw-bilevel.tif"
+#    run_colour_fax_test
+
+#    IN_FILE="${LOCALTESTS_DIR}/lenna-colour.tif"
+#    OUT_FILE="${LOCALTESTS_DIR}/lenna-bw-bilevel.tif"
+#    run_colour_fax_test
+
+#    IN_FILE="${TIFFFX_DIR}/c03x_02x.tif"
+#    OUT_FILE="${TIFFFX_DIR}/c03x_02x.tif"
+#    run_colour_fax_test
+
+#    IN_FILE="${TIFFFX_DIR}/l02x_02x.tif"
+#    OUT_FILE="${TIFFFX_DIR}/l02x_02x.tif"
+#    run_colour_fax_test
+
+#    IN_FILE="${TIFFFX_DIR}/l04x_02x.tif"
+#    OUT_FILE="${TIFFFX_DIR}/l04x_02x.tif"
+#    run_colour_fax_test
 done
 
 # Colour/gray -> colour/gray by allowing ECM
 for OPTS in "-p AA -C -e" "-p TT -C -e" "-p GG -C -e" "-p TG -C -e" "-p GT -C -e"
 do
-    IN_FILE="${LOCALTESTS_DIR}/lenna-colour.tif"
-    OUT_FILE="${LOCALTESTS_DIR}/lenna-colour.tif"
-    run_colour_fax_test
-
-    IN_FILE="${LOCALTESTS_DIR}/lenna-bw.tif"
-    OUT_FILE="${LOCALTESTS_DIR}/lenna-bw.tif"
-    run_colour_fax_test
-
-    IN_FILE="${TIFFFX_DIR}/c03x_02x.tif"
-    OUT_FILE="${TIFFFX_DIR}/c03x_02x.tif"
-    run_colour_fax_test
-
-    IN_FILE="${TIFFFX_DIR}/l02x_02x.tif"
-    OUT_FILE="${TIFFFX_DIR}/l02x_02x.tif"
-    run_colour_fax_test
-
-    IN_FILE="${TIFFFX_DIR}/l04x_02x.tif"
-    OUT_FILE="${TIFFFX_DIR}/l04x_02x.tif"
-    run_colour_fax_test
+    echo Colour to colour tests disabled
+#    IN_FILE="${LOCALTESTS_DIR}/lenna-colour.tif"
+#    OUT_FILE="${LOCALTESTS_DIR}/lenna-colour.tif"
+#    run_colour_fax_test
+
+#    IN_FILE="${LOCALTESTS_DIR}/lenna-bw.tif"
+#    OUT_FILE="${LOCALTESTS_DIR}/lenna-bw.tif"
+#    run_colour_fax_test
+
+#    IN_FILE="${TIFFFX_DIR}/c03x_02x.tif"
+#    OUT_FILE="${TIFFFX_DIR}/c03x_02x.tif"
+#    run_colour_fax_test
+
+#    IN_FILE="${TIFFFX_DIR}/l02x_02x.tif"
+#    OUT_FILE="${TIFFFX_DIR}/l02x_02x.tif"
+#    run_colour_fax_test
+
+#    IN_FILE="${TIFFFX_DIR}/l04x_02x.tif"
+#    OUT_FILE="${TIFFFX_DIR}/l04x_02x.tif"
+#    run_colour_fax_test
 done
 
 # Bi-level tests
index 2293d39883236694873d19e9ed787219632cd09a..0cb6d93b8fa05d03b750ce5cf65a187156855fc2 100644 (file)
@@ -50,7 +50,7 @@
 
 int log_audio = FALSE;
 SNDFILE *outhandle = NULL;
-char result[1024];
+char result[2][1024];
 int unexpected_echo = FALSE;
 
 char *decode_test_file = NULL;
@@ -103,11 +103,11 @@ static void basic_tests(int mode)
     v18[0] = v18_init(NULL, TRUE, mode, V18_AUTOMODING_GLOBAL, put_text_msg, NULL);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
+    span_log_set_tag(logging, "Tester");
     v18[1] = v18_init(NULL, FALSE, mode, V18_AUTOMODING_GLOBAL, put_text_msg, NULL);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -227,14 +227,14 @@ static int test_misc_01(void)
                         TUT should continue to probe until the test is terminated.
         Comments:       This feature should also be verified by observation during the automoding tests.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -326,14 +326,14 @@ static int test_misc_02(void)
         Comments:       The TUT should indicate that carrier has been lost at some time after the 1650Hz
                         signal is lost.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -425,14 +425,14 @@ static int test_misc_03(void)
         Comments:       The TUT should indicate that carrier has been lost at some time after the carrier
                         signal is removed and not disconnect.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -523,14 +523,14 @@ static int test_misc_04(void)
                         automatically hang up when busy tone is detected. PABX busy tones may differ in
                         frequency and cadence from national parameters.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -618,14 +618,14 @@ static int test_misc_05(void)
         Pass criteria:  The RINGING condition should be visually indicated by the TUT.
         Comments:       This test should be repeated across a range of valid timings and ring voltages.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -716,14 +716,14 @@ static int test_misc_06(void)
                         mode. There may be other cases, e.g. where the V.18 DCE is used in a gateway,
                         when automatic disconnection is required.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -812,14 +812,14 @@ static int test_misc_07(void)
                         However, this may possibly not be indicated by the DTE.
         Comments:       The possible modes are: V.21, V.23, Baudot 45, Baudot 50, EDT, Bell 103, DTMF.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -909,14 +909,14 @@ static int test_misc_08(void)
         Comment:        The response times and signal level thresholds of Circuit 135 are not specified in
                         ITU-T V.18 or V.24 and therefore the pattern indicated may vary.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -1003,14 +1003,14 @@ static int test_misc_09(void)
         Pass criteria:  TBD
         Comment:        TBD
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -1106,14 +1106,14 @@ static int test_org_01(void)
                         8) The whole sequence should be repeated until the call is cleared.
                         9) When V.18 to V.18, the XCI must not force V.23 or Minitel mode.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -1204,14 +1204,14 @@ static int test_org_02(void)
                         2) The TUT should reply with transmission of TXP as defined in 5.1.2.
                         3) Verify that TXP sequence has correct bit pattern.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -1299,14 +1299,14 @@ static int test_org_03(void)
         Pass criteria:  The TUT should stop sending TXP at the end of the current sequence when ANS
                         tone ceases.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -1388,7 +1388,7 @@ static int test_org_04(void)
         III.5.4.2.4     ANS tone followed by TXP
         Purpose:        To check correct detection of V.18 modem.
         Preamble:       Tests ORG-02 and ORG-03 should be successfully completed prior to this test.
-        Method:         Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits
+        Method:         Tester transmits ANS for 2.5 seconds followed by 75ms of no tone then transmits
                         3 TXP sequences using V.21 (2) and starts a 1 s timer. It will then transmit 1650Hz
                         for 5 seconds.
         Pass criteria:  1) TUT should initially respond with TXP.
@@ -1398,14 +1398,14 @@ static int test_org_04(void)
                            with the V.18 operational requirements.
         Comments:       The TUT should indicate that V.18 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -1488,7 +1488,7 @@ static int test_org_05(void)
         Purpose:        To check correct detection of V.21 modem upper channel when preceded by answer
                         tone and to confirm discrimination between V.21 and V.18 modes.
         Preamble:       Tests ORG-02 and ORG-03 should be successfully completed prior to this test.
-        Method:         Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits
+        Method:         Tester transmits ANS for 2.5 seconds followed by 75ms of no tone then transmits
                         1650Hz and starts a 0.7 second timer.
         Pass criteria:  1) TUT should initially respond with TXP.
                         2) TUT should stop sending TXP within 0.2 seconds of end of ANS.
@@ -1498,14 +1498,14 @@ static int test_org_05(void)
                         examination of TUT. If there is no visual indication, verify by use of ITU-T T.50 for
                         ITU-T V.21 as opposed to UTF-8 coded ISO 10646 character set for ITU-T V.18.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -1588,7 +1588,7 @@ static int test_org_06(void)
         Purpose:        To check correct detection of V.23 modem upper channel when preceded by answer
                         tone.
         Preamble:       Tests ORG-02 and ORG-03 should be successfully completed prior to this test.
-        Method:         Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits
+        Method:         Tester transmits ANS for 2.5 seconds followed by 75ms of no tone then transmits
                         1300Hz and starts a 2.7 s timer.
         Pass criteria:  1) TUT should initially respond with TXP.
                         2) TUT should stop sending TXP within 0.2 seconds of end of ANS.
@@ -1597,14 +1597,14 @@ static int test_org_06(void)
                            by the TUT to comply with Annex E.
         Comments:       The TUT should indicate that V.23 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -1696,14 +1696,14 @@ static int test_org_07(void)
                         literally. It may however, occur when connected to certain Swedish textphones if the
                         handset is lifted just after the start of an automatically answered incoming call.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -1791,14 +1791,14 @@ static int test_org_08(void)
                         2) Data should be transmitted and received at 300 bit/s to comply with Annex D.
         Comments:       The TUT should indicate that Bell 103 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -1886,14 +1886,14 @@ static int test_org_09(void)
                         2) Data should be transmitted and received at 300 bit/s to comply with Annex F.
         Comments:       The TUT should indicate that V.21 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -1982,14 +1982,14 @@ static int test_org_10(void)
                            by the TUT to comply with Annex E.
         Comments:       The TUT should indicate that V.23 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -2081,14 +2081,14 @@ static int test_org_11(void)
         Comments:       The TUT should indicate that V.23 mode has been selected at least 3 seconds after
                         the start of the 390Hz tone.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -2185,14 +2185,14 @@ static int test_org_12(void)
                         automode answer state. The TUT may then select either 45.45 or 50 bit/s for the
                         transmission.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -2275,7 +2275,7 @@ static int test_org_13(void)
         Purpose:        To verify whether the TUT correctly recognizes DTMF signals during the 2-second
                         interval between transmission of CI.
         Preamble:       N/A
-        Method:         The tester will send a single DTMF tone of 40 ms duration to TUT. When TUT
+        Method:         The tester will send a single DTMF tone of 40ms duration to TUT. When TUT
                         indicates a connection, type at least 5 characters back to the tester so that correct
                         selection of mode can be confirmed.
         Pass criteria:  The tester will analyse the received characters to confirm DTMF mode selection.
@@ -2283,14 +2283,14 @@ static int test_org_13(void)
                         TUT should comply with ITU-T Q.24 for the Danish Administration while
                         receiving for best possible performance.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -2383,14 +2383,14 @@ static int test_org_14(void)
                         the number lost should be minimal. The data bits and parity are specified in
                         Annex C.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -2478,14 +2478,14 @@ static int test_org_15(void)
                         the CI signal.
         Comments:       Echoes of the CI sequences may be detected at 300 bit/s.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -2573,14 +2573,14 @@ static int test_org_16(void)
                         2) Data should be transmitted and received at 300 bit/s complying with Annex F.
         Comments:       The TUT should indicate that V.21 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -2666,14 +2666,14 @@ static int test_org_17(void)
         Pass criteria:  TUT should not respond to the 980Hz tone and resume sending CI signals after a
                         maximum of 2.4 seconds from the end of the 980Hz tone.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -2761,14 +2761,14 @@ static int test_org_18(void)
         Comments:       This implies timer Tr has expired 2 seconds after the start of the 980Hz tone and
                         then 1650Hz has been detected for 0.5 seconds.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -2855,14 +2855,14 @@ static int test_org_19(void)
                         2) Data should be transmitted and received at 300 bit/s complying with Annex D.
         Comments:       The TUT should indicate that Bell 103 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -2956,14 +2956,14 @@ static int test_org_20(void)
                         presence and cadence of the tones for instance by a flashing light. The TUT may
                         disconnect on reception of tones indicating a failed call attempt.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -3053,14 +3053,14 @@ static int test_org_21(void)
         Comments:       Some high speed modems may fall back to a compatibility mode, e.g. V.21 or V.23
                         that should be correctly detected by the TUT.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -3149,14 +3149,14 @@ static int test_org_22(void)
         Comments:       Ideally the TUT should detect the presence of a fax machine and report it back to
                         the user.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -3245,14 +3245,14 @@ static int test_org_23(void)
         Comments:       Ideally the TUT should report the presence of speech back to the user, e.g. via
                         circuit 135.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -3343,14 +3343,14 @@ static int test_org_24(void)
                         2) The TUT should reply with transmission of CM as defined in 5.2.13.
                         3) Verify that CM sequence has correct bit pattern.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -3436,14 +3436,14 @@ static int test_org_25(void)
         Method:         The Test System waits for the TUT to start transmitting V.21 carrier (1).
         Pass criteria:  The TUT should connect by sending V.21 carrier (1).
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -3530,14 +3530,14 @@ static int test_ans_01(void)
                         answers the call. It will then monitor for any signal.
         Pass criteria:  The TUT should start probing 3 seconds after answering the call.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -3626,14 +3626,14 @@ static int test_ans_02(void)
         Comments:       The ANSam tone is a modulated 2100Hz tone. It may have phase reversals. The
                         XCI signal is tested in a separate test.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -3719,21 +3719,21 @@ static int test_ans_03(void)
         Method:         The tester will transmit 2 sequences of 4 CI patterns separated by 2 seconds. On
                         reception of the ANSam tone the tester will wait 0.5 seconds and then begin
                         transmitting the TXP signal in V.21 (1) mode.
-        Pass criteria:  1) On reception of the TXP signal, the TUT should remain silent for 75+-5 ms.
+        Pass criteria:  1) On reception of the TXP signal, the TUT should remain silent for 75+-5ms.
                         2) The TUT should then transmit 3 TXP sequences in V.21(2) mode.
                         3) The 3 TXPs should be followed by continuous 1650Hz.
                         4) Correct transmission and reception of T.140 data should be verified after the
                            V.18 mode connection is completed.
         Comments:       The TUT should indicate V.18 mode.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -3820,14 +3820,14 @@ static int test_ans_04(void)
         Pass criteria:  The TUT should start probing 3 seconds after ANSam disappears.
         Comments:       It is assumed that timer Ta is restarted on return to Monitor A.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -3910,19 +3910,19 @@ static int test_ans_05(void)
         Purpose:        To check correct detection of V.21 modem lower channel when preceded by answer
                         tone.
         Preamble:       N/A
-        Method:         Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits
+        Method:         Tester transmits ANS for 2.5 seconds followed by 75ms of no tone then transmits
                         980Hz and starts a 1 s timer.
-        Pass criteria:  TUT should respond with 1650Hz within 400+-100 ms of start of 980Hz.
+        Pass criteria:  TUT should respond with 1650Hz within 400+-100ms of start of 980Hz.
         Comments:       The TUT should indicate that V.21 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -4005,19 +4005,19 @@ static int test_ans_06(void)
         Purpose:        To check correct detection of V.23 modem upper channel when preceded by answer
                         tone.
         Preamble:       N/A
-        Method:         Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits
+        Method:         Tester transmits ANS for 2.5 seconds followed by 75ms of no tone then transmits
                         1300Hz and starts a 2-s timer.
         Pass criteria:  TUT should respond with 390Hz after 1.7(+0.2-0.0) seconds of start of 1300Hz.
         Comments:       The TUT should indicate that V.23 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -4100,19 +4100,19 @@ static int test_ans_07(void)
         Purpose:        To check correct detection of V.21 modem upper channel when preceded by answer
                         tone and to confirm discrimination between V.21 and V.18 modes.
         Preamble:       N/A
-        Method:         Tester transmits ANS for 2.5 seconds followed by 75 ms of no tone then transmits
+        Method:         Tester transmits ANS for 2.5 seconds followed by 75ms of no tone then transmits
                         1650Hz and starts a 1-second timer.
-        Pass criteria:  TUT should respond with 980Hz within 400+-100 ms of start of 1650Hz.
+        Pass criteria:  TUT should respond with 980Hz within 400+-100ms of start of 1650Hz.
         Comments:       The TUT should indicate that V.21 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -4202,14 +4202,14 @@ static int test_ans_08(void)
         Comments:       The TUT should indicate a V.21 connection. The time for which each frequency is
                         transmitted is random and varies between 0.64 and 2.56 seconds.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -4291,21 +4291,21 @@ static int test_ans_09(void)
         III.5.4.3.9     980Hz calling tone detection
         Purpose:        To confirm correct detection of 980Hz calling tones as defined in V.25.
         Preamble:       N/A
-        Method:         The tester will send bursts of 980Hz signals (a) 400 ms, (b) 500 ms, (c) 700 ms and
-                        (d) 800 ms followed by 1 second of silence.
-        Pass criteria:  1) The TUT should not respond to bursts of 400 or 800 ms.
+        Method:         The tester will send bursts of 980Hz signals (a) 400ms, (b) 500ms, (c) 700ms and
+                        (d) 800ms followed by 1 second of silence.
+        Pass criteria:  1) The TUT should not respond to bursts of 400 or 800ms.
                         2) The TUT should immediately begin probing after a burst of 980Hz for 500 or
-                           700 ms followed by 1 second of silence.
+                           700ms followed by 1 second of silence.
         Comments:       The probe sent by the TUT will depend on the country setting.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -4392,14 +4392,14 @@ static int test_ans_10(void)
         Pass criteria:  The TUT should respond with a 1650Hz tone in 1.5+-0.1 seconds.
         Comments:       The TUT should indicate that V.21 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -4490,14 +4490,14 @@ static int test_ans_11(void)
                         be lost during the detection process. However, the number lost should be minimal.
                         The data bits and parity are specified in Annex C.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -4589,14 +4589,14 @@ static int test_ans_12(void)
                         (1650Hz) probe. However, it is catered for in V.18. It is more likely that this is
                         where CI or TXP characters would be detected (see test ANS-02).
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -4679,22 +4679,22 @@ static int test_ans_13(void)
         Purpose:        To ensure that the TUT returns to the Monitor A state on expiry of timer Tr
                         (2 seconds). Timer Tr is started when a modulated V.21 (1) signal is detected.
         Preamble:       N/A
-        Method:         The tester will transmit 980Hz for 200 ms followed by alternating 980Hz/1180Hz
-                        at 110 bit/s for 100 ms followed by 980Hz for 1 second.
+        Method:         The tester will transmit 980Hz for 200ms followed by alternating 980Hz/1180Hz
+                        at 110 bit/s for 100ms followed by 980Hz for 1 second.
         Pass criteria:  The TUT should begin probing 4+-0.5 seconds after the 980Hz signal is removed.
         Comments:       It is not possible to be precise on timings for this test since the definition of a
                         "modulated signal" as in 5.2.4.4 is not specified. Therefore it is not known exactly
                         when timer Tr will start. It is assumed that timer Ta is restarted on re-entering the
                         Monitor A state.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -4777,19 +4777,19 @@ static int test_ans_14(void)
         Purpose:        To ensure that the TUT returns to the Monitor A on expiry of timer Te
                         (2.7 seconds). Timer Te is started when a 980Hz signal is detected.
         Preamble:       N/A
-        Method:         The tester will transmit 980Hz for 200 ms followed silence for 7 s.
+        Method:         The tester will transmit 980Hz for 200ms followed silence for 7 s.
         Pass criteria:  The TUT should begin probing 5.5+-0.5 seconds after the 980Hz signal is removed.
         Comments:       It is assumed that timer Ta (3 seconds) is restarted on re-entering the Monitor A
                         state.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -4887,14 +4887,14 @@ static int test_ans_15(void)
                         automode answer state. The TUT may then select either 45.45 or 50 bit/s for the
                         transmission.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -4976,21 +4976,21 @@ static int test_ans_16(void)
         III.5.4.3.16    DTMF signal detection
         Purpose:        To verify whether the TUT correctly recognizes DTMF signals.
         Preamble:       N/A
-        Method:         The tester will send a single DTMF tone of 40 ms duration to TUT. When TUT
+        Method:         The tester will send a single DTMF tone of 40ms duration to TUT. When TUT
                         indicates a connection, type at least 5 characters back to the tester so that correct
                         selection of mode can be confirmed.
         Pass criteria:  Tester will analyse the received characters to confirm DTMF mode selection.
         Comments:       The TUT should indicate that it has selected DTMF mode. The DTMF capabilities
                         of the TUT should comply with ITU-T Q.24 for the Danish Administration.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -5076,14 +5076,14 @@ static int test_ans_17(void)
         Pass criteria:  TUT should respond with 2225Hz tone after 0.7+-0.1 s.
         Comments:       The TUT should indicate that Bell 103 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -5170,14 +5170,14 @@ static int test_ans_18(void)
         Comments:       The TUT should indicate that Bell 103 mode has been selected. Bell 103 modems
                         use 2225Hz as both answer tone and higher frequency of the upper channel.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -5263,14 +5263,14 @@ static int test_ans_19(void)
         Pass criteria:  The TUT should respond with 980Hz after 0.4+-0.2 seconds.
         Comments:       The TUT should indicate that V.21 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -5352,21 +5352,21 @@ static int test_ans_20(void)
         III.5.4.3.20    1300Hz calling tone discrimination
         Purpose:        To confirm correct detection of 1300Hz calling tones as defined in ITU-T V.25.
         Preamble:       N/A
-        Method:         The tester will send 1300Hz bursts of (a) 400 ms, (b) 500 ms, (c) 700 ms and
-                        (d) 800 ms followed by 1 second of silence.
-        Pass criteria:  1) The TUT should not respond to bursts of 400 or 800 ms.
+        Method:         The tester will send 1300Hz bursts of (a) 400ms, (b) 500ms, (c) 700ms and
+                        (d) 800ms followed by 1 second of silence.
+        Pass criteria:  1) The TUT should not respond to bursts of 400 or 800ms.
                         2) The TUT should immediately begin probing after a burst of 1300Hz for 500 or
-                           700 ms followed by 1 second of silence.
+                           700ms followed by 1 second of silence.
         Comments:       The probe sent by the TUT will depend on the country setting.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -5452,14 +5452,14 @@ static int test_ans_21(void)
                         Pass criteria: The TUT should respond with 390Hz after 1.7+-0.1 seconds.
         Comments:       The TUT should indicate that V.23 mode has been selected.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -5542,17 +5542,17 @@ static int test_ans_22(void)
         Purpose:        To ensure correct detection of the XCI signal and selection of V.18 mode.
         Preamble:       N/A
         Method:         The tester sends XCI signal as defined in 3.11. On reception of ANS it will become
-                        silent for 500 ms then transmit the TXP signal in V.21 (1) mode.
+                        silent for 500ms then transmit the TXP signal in V.21 (1) mode.
         Pass criteria:  The TUT should respond with TXP using V.21 (2) and select V.18 mode.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -5641,14 +5641,14 @@ static int test_ans_23(void)
         Pass criteria:  The TUT should use the orders described in Appendix I.
         Comments:       The order of the probes is not mandatory.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -5737,14 +5737,14 @@ static int test_ans_24(void)
                         modes followed by a pause of Tm (default 3) seconds.
         Comments:       The carrierless modes are those described in Annexes A, B and C.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -5828,19 +5828,19 @@ static int test_ans_25(void)
                         of 20 s after a failed connect attempt.
         Preamble:       The TUT should be configured for the UK country setting.
         Method:         The tester will call the TUT, wait for Ta to expire and then during the pause after
-                        the first Baudot probe it will send a 200 ms burst of 1270Hz followed by silence
+                        the first Baudot probe it will send a 200ms burst of 1270Hz followed by silence
                         for 30 s.
         Pass criteria:  The TUT should transmit silence on detecting the 1270Hz tone and then continue
                         probing starting with the V.23 probe 20 seconds after the end of the 1270Hz signal.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -5926,17 +5926,17 @@ static int test_ans_26(void)
         Method:         The tester will call the TUT, wait for Ta to expire and then monitor the probes sent
                         by the TUT.
         Pass criteria:  The TUT should send the ANS tone (2100Hz) for 1 second followed by silence for
-                        75+-5 ms and then the 1650Hz, 1300Hz and 2225Hz probes for time Tc.
+                        75+-5ms and then the 1650Hz, 1300Hz and 2225Hz probes for time Tc.
         Comments:       The carrier modes are those described in Annexes D, E, and F.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -6029,14 +6029,14 @@ static int test_ans_27(void)
                         390Hz. When the 1300Hz probe is not being transmitted, a 390Hz tone may be
                         interpreted as a 400Hz network tone.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -6120,21 +6120,21 @@ static int test_ans_28(void)
                         of 4 s after a failed connect attempt.
         Preamble:       The TUT should be configured for the UK country setting.
         Method:         The tester will call the TUT, wait for Ta to expire and then during the first V.21
-                        probe it will send a 200 ms burst of 1270Hz followed by silence for 30 s.
+                        probe it will send a 200ms burst of 1270Hz followed by silence for 30 s.
         Pass criteria:  The TUT should transmit silence on detecting the 1270Hz tone and then continue
                         probing with the Baudot stored message 4 seconds after the end of the 1270Hz
                         burst.
         Comments:       It is most likely that the TUT will return to probing time Ta (3 seconds) after the
                         1270Hz tone ceases. This condition needs further clarification.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -6224,14 +6224,14 @@ static int test_ans_29(void)
         Comments:       The TUT may not respond to any signals while a carrierless mode probe is being
                         sent since these modes are half duplex.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -6323,14 +6323,14 @@ static int test_ans_30(void)
                         tones may be ignored. Some devices may only provide a visual indication of the
                         presence and cadence of the tones for instance by a flashing light.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -6419,14 +6419,14 @@ static int test_ans_31(void)
         Comments:       This is an optional test as detection of the fax calling tone is not required by
                         ITU-T V.18.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -6515,14 +6515,14 @@ static int test_ans_32(void)
         Comments:       Ideally the TUT should report the presence of speech back to the user. This is an
                         optional test.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -6616,14 +6616,14 @@ static int test_ans_33(void)
                            V.18 mode connection is completed.
         Comments:       The TUT should indicate V.18 mode.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -6717,14 +6717,14 @@ static int test_mon_21(void)
                         for 1 minute.
         Pass criteria:  The TUT should not start probing.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -6807,22 +6807,22 @@ static int test_mon_22(void)
         Purpose:        To confirm correct detection and reporting of 1300Hz calling tones as defined in
                         ITU-T V.25.
         Preamble:       N/A
-        Method:         The tester will send 1300Hz bursts of (a) 400 ms, (b) 500 ms, (c) 700 ms and
-                        (d) 800 ms followed by 1 second of silence.
-        Pass criteria:  1) The TUT should not respond to bursts of 400 or 800 ms.
+        Method:         The tester will send 1300Hz bursts of (a) 400ms, (b) 500ms, (c) 700ms and
+                        (d) 800ms followed by 1 second of silence.
+        Pass criteria:  1) The TUT should not respond to bursts of 400 or 800ms.
                         2) The TUT should report detection of calling tones to the DTE after a burst of
-                           1300Hz for 500 or 700 ms followed by 1 second of silence.
+                           1300Hz for 500 or 700ms followed by 1 second of silence.
         Comments:       In automode answer, the 1300Hz calling causes the DCE to start probing. In
                         monitor mode it should only report detection to the DTE.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -6905,22 +6905,22 @@ static int test_mon_23(void)
         Purpose:        To confirm correct detection and reporting of 980Hz calling tones as defined in
                         ITU-T V.25.
         Preamble:       N/A
-        Method:         The tester will send 980Hz bursts of (a) 400 ms, (b) 500 ms, (c) 700 ms and
-                        (d) 800 ms followed by 1 second of silence.
-        Pass criteria:  1) The TUT should not respond to bursts of 400 or 800 ms.
+        Method:         The tester will send 980Hz bursts of (a) 400ms, (b) 500ms, (c) 700ms and
+                        (d) 800ms followed by 1 second of silence.
+        Pass criteria:  1) The TUT should not respond to bursts of 400 or 800ms.
                         2) The TUT should report detection of calling tones to the DTE after a burst of
-                           980Hz for 500 or 700 ms followed by 1 second of silence.
+                           980Hz for 500 or 700ms followed by 1 second of silence.
         Comments:       In automode answer, the 980Hz calling causes the DCE to start probing. In monitor
                         mode it should only report detection to the DTE.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -6989,9 +6989,9 @@ static void x_01_put_text_msg(void *user_data, const uint8_t *msg, int len)
 {
 printf("1-1 %d '%s'\n", len, msg);
     if (user_data == NULL)
-        strcat(result, (const char *) msg);
-    else
-        v18_put(v18[1], "abcdefghij", 10);
+        strcat(result[0], (const char *) msg);
+    //else
+    //    v18_put(v18[1], "abcdefghij", 10);
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -7010,26 +7010,26 @@ static int test_x_01(void)
 
     /*
         III.5.4.5.1     Baudot carrier timing and receiver disabling
-        Purpose:        To verify that the TUT sends unmodulated carrier for 150 ms before a new character
-                        and disables its receiver for 300 ms after a character is transmitted.
+        Purpose:        To verify that the TUT sends unmodulated carrier for 150ms before a new character
+                        and disables its receiver for 300ms after a character is transmitted.
         Preamble:       Establish a call between the tester and TUT in Baudot mode.
         Method:         The operator should send a single character from the TUT. The tester will
                         immediately start sending a unique character sequence. Examination of the TUT
                         display will show when its receiver is re-enabled.
-        Pass criteria:  1) The TUT should send unmodulated carrier for 150 ms before the beginning of
+        Pass criteria:  1) The TUT should send unmodulated carrier for 150ms before the beginning of
                            the start bit.
-                        2) The receiver should be re-enabled after 300 ms.
+                        2) The receiver should be re-enabled after 300ms.
                         3) The tester will confirm that 1 start bit and at least 1.5 stop bits are used.
-        Comments:       The carrier should be maintained during the 300 ms after a character.
+        Comments:       The carrier should be maintained during the 300ms after a character.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_45, V18_AUTOMODING_GLOBAL, x_01_put_text_msg, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, x_01_put_text_msg, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_45, V18_AUTOMODING_GLOBAL, x_01_put_text_msg, (void *) (intptr_t) 1);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, x_01_put_text_msg, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -7091,9 +7091,9 @@ static int test_x_01(void)
     v18_free(v18[0]);
     v18_free(v18[1]);
     ref = "cdefghij";
-    printf("Result:\n%s\n", result);
+    printf("Result:\n%s\n", result[0]);
     printf("Reference result:\n%s\n", ref);
-    if (unexpected_echo  ||  strcmp(result, ref) != 0)
+    if (unexpected_echo  ||  strcmp(result[0], ref) != 0)
         return -1;
     return 1;
 }
@@ -7121,14 +7121,14 @@ static int test_x_02(void)
                         transmit the string "abcdef" at each rate.
         Pass criteria:  The tester will measure the bit timings and confirm the rates.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_45, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_45, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -7218,14 +7218,14 @@ static int test_x_03(void)
         Comments:       The probe message must be long enough for the tester to establish the bit rate. "GA"
                         may not be sufficient.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_45, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_45, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, NULL, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -7300,7 +7300,7 @@ static void x_04_put_echo_text_msg(void *user_data, const uint8_t *msg, int len)
 static void x_04_put_text_msg(void *user_data, const uint8_t *msg, int len)
 {
 printf("1-1 %d '%s'\n", len, msg);
-    strcat(result, (const char *) msg);
+    strcat(result[0], (const char *) msg);
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -7336,14 +7336,14 @@ static int test_x_04(void)
                         assumed that the character conversion is the same for Baudot at 50 bit/s and any
                         other supported speed.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_45, V18_AUTOMODING_GLOBAL, x_04_put_echo_text_msg, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, x_04_put_echo_text_msg, NULL);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_45, V18_AUTOMODING_GLOBAL, x_04_put_text_msg, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_5BIT_4545, V18_AUTOMODING_GLOBAL, x_04_put_text_msg, NULL);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -7360,7 +7360,7 @@ static int test_x_04(void)
         exit(2);
     }
 
-    result[0] = '\0';
+    result[0][0] = '\0';
     unexpected_echo = FALSE;
     for (i = 0;  i < 127;  i++)
         msg[i] = i + 1;
@@ -7409,9 +7409,9 @@ static int test_x_04(void)
 
     v18_free(v18[0]);
     v18_free(v18[1]);
-    printf("Result:\n%s\n", result);
+    printf("Result:\n%s\n", result[0]);
     printf("Reference result:\n%s\n", full_baudot_rx);
-    if (unexpected_echo  ||  strcmp(result, full_baudot_rx) != 0)
+    if (unexpected_echo  ||  strcmp(result[0], full_baudot_rx) != 0)
         return -1;
     return 0;
 }
@@ -7420,7 +7420,7 @@ static int test_x_04(void)
 static void x_05_put_text_msg(void *user_data, const uint8_t *msg, int len)
 {
     if (user_data == NULL)
-        strcat(result, (const char *) msg);
+        strcat(result[0], (const char *) msg);
     else
         v18_put(v18[1], "behknqtwz", 9);
 }
@@ -7441,23 +7441,23 @@ static int test_x_05(void)
 
     /*
         III.5.4.5.5     DTMF receiver disabling
-        Purpose:        To verify that the TUT disables its DTMF receiver for 300 ms when a character is
+        Purpose:        To verify that the TUT disables its DTMF receiver for 300ms when a character is
                         transmitted.
         Preamble:       Establish a call between the tester and TUT in DTMF mode.
         Method:         The operator should send a single "e" character from the TUT which will result in
                         sending a single DTMF tone to the tester. The tester will immediately start sending a
                         unique character sequence using single DTMF tones. Examination of the TUT
                         display will show when its receiver is re-enabled.
-        Pass criteria:  The receiver should be re-enabled after 300 ms.
+        Pass criteria:  The receiver should be re-enabled after 300ms.
      */
     v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_05_put_text_msg, NULL);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
+    span_log_set_tag(logging, "Tester");
     v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_05_put_text_msg, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -7474,7 +7474,7 @@ static int test_x_05(void)
         exit(2);
     }
 
-    result[0] = '\0';
+    result[0][0] = '\0';
     v18_put(v18[0], "e", 1);
 
     for (i = 0;  i < 1000;  i++)
@@ -7521,9 +7521,9 @@ static int test_x_05(void)
     v18_free(v18[0]);
     v18_free(v18[1]);
     ref = "knqtwz";
-    printf("Result:\n%s\n", result);
+    printf("Result:\n%s\n", result[0]);
     printf("Reference result:\n%s\n", ref);
-    if (strcmp(result, ref) != 0)
+    if (strcmp(result[0], ref) != 0)
         return -1;
     return 0;
 }
@@ -7531,7 +7531,9 @@ static int test_x_05(void)
 
 static void x_06_put_text_msg(void *user_data, const uint8_t *msg, int len)
 {
-    strcat(result, (const char *) msg);
+    if (user_data == NULL)
+    else
+        strcat(result[1], (const char *) msg);
 }
 /*- End of function --------------------------------------------------------*/
 
@@ -7560,19 +7562,19 @@ static int test_x_06(void)
                         after each one. Each character should be responded to at the TUT by typing the
                         same character.
         Pass criteria:  The tester will verify that each character is correctly echoed back by the TUT.
-        Comments:       The conversion table is specified in Annex B. The receiver at the tester may be re-
-                        enabled 100 ms after transmission of each character to maximize likelihood of
+        Comments:       The conversion table is specified in Annex B. The receiver at the tester may be
+                        re-enabled 100ms after transmission of each character to maximize likelihood of
                         receiving character from the TUT. It is assumed that the echo delay in the test
                         system is negligible.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_06_put_text_msg, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_06_put_text_msg, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_06_put_text_msg, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -7589,16 +7591,12 @@ static int test_x_06(void)
         exit(2);
     }
 
-    result[0] = '\0';
     for (i = 0;  i < 127;  i++)
         msg[i] = i + 1;
     msg[127] = '\0';
     printf("Original:\n%s\n", msg);
 
-    v18_encode_dtmf(NULL, dtmf, msg);
-    printf("DTMF:\n%s\n", dtmf);
-    v18_decode_dtmf(NULL, result, dtmf);
-
+    result[0][0] = '\0';
     for (i = 0;  i < 10000;  i++)
     {
         for (j = 0;  j < 2;  j++)
@@ -7640,23 +7638,27 @@ static int test_x_06(void)
         v18_rx(v18[1], model_amp[0], samples);
     }
 
-    ref = "\b \n\n\n?\n\n\n  %+().+,-.0123456789:;(=)"
-          "?XABCDEFGHIJKLMNOPQRSTUVWXYZ\xC6\xD8\xC5"
+    ref = "\b \n\n\n?\n\n\n  !%+().+,-.0123456789:;(=)?"
+          "XABCDEFGHIJKLMNOPQRSTUVWXYZ\xC6\xD8\xC5"
           " abcdefghijklmnopqrstuvwxyz\xE6\xF8\xE5 \b";
 
-    printf("Result:\n%s\n", result);
+    printf("Result:\n%s\n", result[0]);
     printf("Reference result:\n%s\n", ref);
     v18_free(v18[0]);
     v18_free(v18[1]);
-    if (strcmp(result, ref) != 0)
+    if (strcmp(result[1], ref) != 0)
         return -1;
     return 0;
 }
 /*- End of function --------------------------------------------------------*/
 
+static void x_07_put_text_msg(void *user_data, const uint8_t *msg, int len)
+{
+}
+/*- End of function --------------------------------------------------------*/
+
 static int test_x_07(void)
 {
-    v18_state_t *v18[2];
     logging_state_t *logging;
     int16_t amp[2][SAMPLES_PER_CHUNK];
     int16_t model_amp[2][SAMPLES_PER_CHUNK];
@@ -7669,26 +7671,26 @@ static int test_x_07(void)
 
     /*
         III.5.4.5.7     EDT carrier timing and receiver disabling
-        Purpose:        To verify that the TUT sends unmodulated carrier for 300 ms before a character and
-                        disables its receiver for 300 ms after a character is transmitted.
+        Purpose:        To verify that the TUT sends unmodulated carrier for 300ms before a character and
+                        disables its receiver for 300ms after a character is transmitted.
         Preamble:       Establish a call between the tester and TUT in EDT mode.
         Method:         The operator should send a single character from the TUT. The tester will
                         immediately start sending a unique character sequence. Examination of the TUT
                         display will show when its receiver is re-enabled.
-        Pass criteria:  1) The TUT should send unmodulated carrier for 300 ms before the beginning of
+        Pass criteria:  1) The TUT should send unmodulated carrier for 300ms before the beginning of
                            the start bit.
-                        2) The receiver should be re-enabled after 300 ms.
+                        2) The receiver should be re-enabled after 300ms.
                         3) The tester will confirm that 1 start bit and at least 1.5 stop bits are used.
-        Comments:       The carrier should be maintained during the 300 ms after a character.
+        Comments:       The carrier should be maintained during the 300ms after a character.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_07_put_text_msg, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_07_put_text_msg, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -7753,9 +7755,13 @@ static int test_x_07(void)
 }
 /*- End of function --------------------------------------------------------*/
 
+static void x_08_put_text_msg(void *user_data, const uint8_t *msg, int len)
+{
+}
+/*- End of function --------------------------------------------------------*/
+
 static int test_x_08(void)
 {
-    v18_state_t *v18[2];
     logging_state_t *logging;
     int16_t amp[2][SAMPLES_PER_CHUNK];
     int16_t model_amp[2][SAMPLES_PER_CHUNK];
@@ -7776,14 +7782,14 @@ static int test_x_08(void)
                         2) The tester should confirm that 1 start bit, 7 data bits, 1 even parity bit and 2 stop
                            bits are used.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_08_put_text_msg, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_08_put_text_msg, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -7848,9 +7854,13 @@ static int test_x_08(void)
 }
 /*- End of function --------------------------------------------------------*/
 
+static void x_09_put_text_msg(void *user_data, const uint8_t *msg, int len)
+{
+}
+/*- End of function --------------------------------------------------------*/
+
 static int test_x_09(void)
 {
-    v18_state_t *v18[2];
     logging_state_t *logging;
     int16_t amp[2][SAMPLES_PER_CHUNK];
     int16_t model_amp[2][SAMPLES_PER_CHUNK];
@@ -7874,14 +7884,14 @@ static int test_x_09(void)
                            that there are no duplicate characters on the TUT display.
                         3) The received string should be correctly displayed despite the incorrect parity.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_09_put_text_msg, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_09_put_text_msg, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -7946,9 +7956,13 @@ static int test_x_09(void)
 }
 /*- End of function --------------------------------------------------------*/
 
+static void x_10_put_text_msg(void *user_data, const uint8_t *msg, int len)
+{
+}
+/*- End of function --------------------------------------------------------*/
+
 static int test_x_10(void)
 {
-    v18_state_t *v18[2];
     logging_state_t *logging;
     int16_t amp[2][SAMPLES_PER_CHUNK];
     int16_t model_amp[2][SAMPLES_PER_CHUNK];
@@ -7975,14 +7989,14 @@ static int test_x_10(void)
         Comments:       This test is only applicable to Minitel Dialogue terminals. Prestel and Minitel
                         Normal terminals cannot operate in this mode.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_10_put_text_msg, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_10_put_text_msg, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -8047,9 +8061,13 @@ static int test_x_10(void)
 }
 /*- End of function --------------------------------------------------------*/
 
+static void x_11_put_text_msg(void *user_data, const uint8_t *msg, int len)
+{
+}
+/*- End of function --------------------------------------------------------*/
+
 static int test_x_11(void)
 {
-    v18_state_t *v18[2];
     logging_state_t *logging;
     int16_t amp[2][SAMPLES_PER_CHUNK];
     int16_t model_amp[2][SAMPLES_PER_CHUNK];
@@ -8074,14 +8092,14 @@ static int test_x_11(void)
                         4) The last five characters on the TUT display should be "12345" (no "6")
                            correctly displayed despite the incorrect parity.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_11_put_text_msg, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_11_put_text_msg, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -8146,9 +8164,13 @@ static int test_x_11(void)
 }
 /*- End of function --------------------------------------------------------*/
 
+static void x_12_put_text_msg(void *user_data, const uint8_t *msg, int len)
+{
+}
+/*- End of function --------------------------------------------------------*/
+
 static int test_x_12(void)
 {
-    v18_state_t *v18[2];
     logging_state_t *logging;
     int16_t amp[2][SAMPLES_PER_CHUNK];
     int16_t model_amp[2][SAMPLES_PER_CHUNK];
@@ -8170,14 +8192,14 @@ static int test_x_12(void)
         Pass criteria:  The tester should confirm UTF8 encoded UNICODE characters are used with the
                         controls specified in ITU-T T.140.
      */
-    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    v18[0] = v18_init(NULL, TRUE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_12_put_text_msg, (void *) (intptr_t) 0);
     logging = v18_get_logging_state(v18[0]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "A");
-    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, NULL, NULL);
+    span_log_set_tag(logging, "Tester");
+    v18[1] = v18_init(NULL, FALSE, V18_MODE_DTMF, V18_AUTOMODING_GLOBAL, x_12_put_text_msg, (void *) (intptr_t) 1);
     logging = v18_get_logging_state(v18[1]);
     span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
-    span_log_set_tag(logging, "B");
+    span_log_set_tag(logging, "TUT");
 
     if ((model = both_ways_line_model_init(line_model_no,
                                            (float) noise_level,
@@ -8474,8 +8496,8 @@ int main(int argc, char *argv[])
         printf("Test not found\n");
         exit(2);
     }
-    basic_tests(V18_MODE_5BIT_45);
-    basic_tests(V18_MODE_5BIT_45 | 0x100);
+    basic_tests(V18_MODE_5BIT_4545);
+    basic_tests(V18_MODE_5BIT_4545 | V18_MODE_REPETITIVE_SHIFTS_OPTION);
     if (log_audio)
     {
         if (sf_close_telephony(outhandle))
index b46b9ee39646068a72007b8943770d3739aa6ce3..03d7297eddfecfa89f029630eb56497e76505b79 100644 (file)
@@ -150,11 +150,11 @@ static int get_v18_mode(switch_core_session_t *session)
 {
        switch_channel_t *channel = switch_core_session_get_channel(session);
        const char *var;
-       int r = V18_MODE_5BIT_45;
+       int r = V18_MODE_5BIT_4545;
 
        if ((var = switch_channel_get_variable(channel, "v18_mode"))) {
                if (!strcasecmp(var, "5BIT_45") || !strcasecmp(var, "baudot")) {
-                       r = V18_MODE_5BIT_45;
+                       r = V18_MODE_5BIT_4545;
                } else if (!strcasecmp(var, "5BIT_50")) {
                        r = V18_MODE_5BIT_50;
                } else if (!strcasecmp(var, "DTMF")) {