Skip to content

Commit fc7ef2c

Browse files
Change sample type for text encoding to 't', value 'a' still supported
1 parent ca2f8c4 commit fc7ef2c

File tree

11 files changed

+33
-31
lines changed

11 files changed

+33
-31
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
2023.160:
22
- Add FAQ to documentation and update example code to match API changes.
3+
- Change sample type for text encoding to 't', value 'a' still supported.
34

45
2023.159:
56
WARNING: API change as follows:

example/lm_pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ main (int argc, char **argv)
191191
{
192192
msr->numsamples = strlen (textdata);
193193
msr->datasamples = textdata;
194-
msr->sampletype = 'a';
194+
msr->sampletype = 't';
195195
}
196196
else if (encoding == DE_FLOAT32)
197197
{

example/lm_parse.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,25 @@ main (int argc, char **argv)
109109
{
110110
ms_log (2, "Unrecognized sample type: '%c'\n", msr->sampletype);
111111
}
112-
if (msr->sampletype == 'a')
112+
if (msr->sampletype == 't')
113113
{
114-
char *ascii = (char *)msr->datasamples;
114+
char *text = (char *)msr->datasamples;
115115
int length = msr->numsamples;
116116

117-
ms_log (0, "ASCII Data:\n");
117+
ms_log (0, "Text data:\n");
118118

119119
/* Print maximum log message segments */
120120
while (length > (MAX_LOG_MSG_LENGTH - 1))
121121
{
122-
ms_log (0, "%.*s", (MAX_LOG_MSG_LENGTH - 1), ascii);
123-
ascii += MAX_LOG_MSG_LENGTH - 1;
122+
ms_log (0, "%.*s", (MAX_LOG_MSG_LENGTH - 1), text);
123+
text += MAX_LOG_MSG_LENGTH - 1;
124124
length -= MAX_LOG_MSG_LENGTH - 1;
125125
}
126126

127-
/* Print any remaining ASCII and add a newline */
127+
/* Print any remaining TEXT and add a newline */
128128
if (length > 0)
129129
{
130-
ms_log (0, "%.*s\n", length, ascii);
130+
ms_log (0, "%.*s\n", length, text);
131131
}
132132
else
133133
{

example/lm_read_recordlist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ main (int argc, char **argv)
154154
{
155155
ms_log (0, "DATA (%" PRId64 " samples) of type '%c':\n", seg->numsamples, seg->sampletype);
156156

157-
if (sampletype == 'a')
157+
if (sampletype == 't')
158158
{
159159
printf ("%*s",
160160
(seg->numsamples > INT_MAX) ? INT_MAX : (int)seg->numsamples,

libmseed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ extern int ms_md2doy (int year, int month, int mday, int *yday);
331331
@brief Data sample types used by the library.
332332
333333
Sample types are represented using a single character as follows:
334-
- \c 'a' - Text (ASCII) data samples
334+
- \c 't' - Text data samples
335335
- \c 'i' - 32-bit integer data samples
336336
- \c 'f' - 32-bit float (IEEE) data samples
337337
- \c 'd' - 64-bit float (IEEE) data samples

lookup.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
* @param[in] sampletype Library sample type code:
2929
* @parblock
30-
* - \c 'a' - Text/ASCII data type
30+
* - \c 't' - Text data type
3131
* - \c 'i' - 32-bit integer data type
3232
* - \c 'f' - 32-bit float data type
3333
* - \c 'd' - 64-bit float (double) data type
@@ -40,6 +40,7 @@ ms_samplesize (const char sampletype)
4040
{
4141
switch (sampletype)
4242
{
43+
case 't':
4344
case 'a':
4445
return 1;
4546
break;
@@ -78,7 +79,7 @@ ms_encoding_sizetype (const uint8_t encoding, uint8_t *samplesize, char *samplet
7879
if (samplesize)
7980
*samplesize = 1;
8081
if (sampletype)
81-
*sampletype = 'a';
82+
*sampletype = 't';
8283
break;
8384
case DE_INT16:
8485
case DE_INT32:

pack.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static uint32_t ms_timestr2btime (const char *timestr, uint8_t *btime, char *sid
7171
*
7272
* The following data encodings and expected @ref MS3Record.sampletype
7373
* are supported:
74-
* - ::DE_TEXT (0), Text, expects type \c 'a'
74+
* - ::DE_TEXT (0), Text, expects type \c 't'
7575
* - ::DE_INT16 (1), 16-bit integer, expects type \c 'i'
7676
* - ::DE_INT32 (3), 32-bit integer, expects type \c 'i'
7777
* - ::DE_FLOAT32 (4), 32-bit float (IEEE), expects type \c 'f'
@@ -229,7 +229,7 @@ msr3_pack_mseed3 (MS3Record *msr, void (*record_handler) (char *, int, void *),
229229
/* Short cut: if there are no samples, record packing is complete */
230230
if (msr->numsamples <= 0)
231231
{
232-
/* Set encoding to ASCII for consistency and to reduce expectations */
232+
/* Set encoding to text for consistency and to reduce expectations */
233233
*pMS3FSDH_ENCODING(rawrec) = DE_TEXT;
234234

235235
/* Calculate CRC (with CRC field set to 0) and set */
@@ -662,7 +662,7 @@ msr3_pack_mseed2 (MS3Record *msr, void (*record_handler) (char *, int, void *),
662662
/* Short cut: if there are no samples, record packing is complete */
663663
if (msr->numsamples <= 0)
664664
{
665-
/* Set encoding to ASCII for consistency and to reduce expectations */
665+
/* Set encoding to text for consistency and to reduce expectations */
666666
*pMS2B1000_ENCODING (rawrec + 48) = DE_TEXT;
667667

668668
/* Set empty part of record to zeros */
@@ -1580,15 +1580,15 @@ msr_pack_data (void *dest, void *src, int maxsamples, int maxdatabytes,
15801580
switch (encoding)
15811581
{
15821582
case DE_TEXT:
1583-
if (sampletype != 'a')
1583+
if (sampletype != 't' && sampletype != 'a')
15841584
{
1585-
ms_log (2, "%s: Sample type must be ascii (a) for ASCII text encoding not '%c'\n",
1585+
ms_log (2, "%s: Sample type must be text (t) for text encoding not '%c'\n",
15861586
sid, sampletype);
15871587
return -1;
15881588
}
15891589

15901590
if (verbose > 1)
1591-
ms_log (0, "%s: Packing ASCII data\n", sid);
1591+
ms_log (0, "%s: Packing text data\n", sid);
15921592

15931593
nsamples = msr_encode_text ((char *)src, maxsamples, (char *)dest, maxdatabytes);
15941594

packdata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***********************************************************************
2-
* Routines for packing text/ASCII, INT_16, INT_32, FLOAT_32, FLOAT_64,
2+
* Routines for packing Text, INT_16, INT_32, FLOAT_32, FLOAT_64,
33
* STEIM1 and STEIM2 data records.
44
*
55
* This file is part of the miniSEED Library.

test/test-write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ TEST (write, msr)
5252
msr->encoding = DE_TEXT;
5353
msr->numsamples = strlen (textdata);
5454
msr->datasamples = textdata;
55-
msr->sampletype = 'a';
55+
msr->sampletype = 't';
5656

5757
rv = msr3_writemseed (msr, TESTFILE_TEXT_V3, 1, flags, 0);
5858
REQUIRE (rv > 0, "msr3_writemseed() return unexpected value");
@@ -131,7 +131,7 @@ TEST (write, msr)
131131
msr->encoding = DE_TEXT;
132132
msr->numsamples = strlen (textdata);
133133
msr->datasamples = textdata;
134-
msr->sampletype = 'a';
134+
msr->sampletype = 't';
135135

136136
rv = msr3_writemseed (msr, TESTFILE_TEXT_V2, 1, flags, 0);
137137
REQUIRE (rv > 0, "msr3_writemseed() return unexpected value");

tracelist.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ mstl3_add_recordptr (MS3TraceSeg *seg, MS3Record *msr, nstime_t endtime, int8_t
13661366
* @brief Convert the data samples associated with an MS3TraceSeg to another
13671367
* data type
13681368
*
1369-
* ASCII data samples cannot be converted, if supplied or requested an
1369+
* Text data samples cannot be converted, if supplied or requested an
13701370
* error will be returned.
13711371
*
13721372
* When converting float & double sample types to integer type a
@@ -1413,9 +1413,9 @@ mstl3_convertsamples (MS3TraceSeg *seg, char type, int8_t truncate)
14131413
if (seg->sampletype == type)
14141414
return 0;
14151415

1416-
if (seg->sampletype == 'a' || type == 'a')
1416+
if (seg->sampletype == 't' || type == 't' || seg->sampletype == 'a' || type == 'a')
14171417
{
1418-
ms_log (2, "Cannot convert ASCII samples to/from numeric type\n");
1418+
ms_log (2, "Cannot convert text samples to/from numeric type\n");
14191419
return -1;
14201420
}
14211421

@@ -1929,7 +1929,7 @@ mstl3_unpack_recordlist (MS3TraceID *id, MS3TraceSeg *seg, void *output,
19291929
* record_handler() returns.
19301930
*
19311931
* The requested \a encoding value is currently only used for integer
1932-
* data samples. The encoding is set automatially for text (ASCII) and
1932+
* data samples. The encoding is set automatially for text and
19331933
* floating point data samples as there is only a single encoding for
19341934
* them. A value of \c -1 can be used to request the default.
19351935
*
@@ -2037,7 +2037,7 @@ mstl3_pack (MS3TraceList *mstl, void (*record_handler) (char *, int, void *),
20372037
/* Set encoding for data types with only one encoding, otherwise requested */
20382038
switch (seg->sampletype)
20392039
{
2040-
case 'a':
2040+
case 't':
20412041
msr->encoding = DE_TEXT;
20422042
break;
20432043
case 'f':

0 commit comments

Comments
 (0)