[med-svn] [Git][med-team/edflib][master] 8 commits: New upstream version 1.16
Andreas Tille
gitlab at salsa.debian.org
Mon Sep 9 20:21:56 BST 2019
Andreas Tille pushed to branch master at Debian Med / edflib
Commits:
cc23e83b by Andreas Tille at 2019-09-09T19:20:08Z
New upstream version 1.16
- - - - -
d278b5d7 by Andreas Tille at 2019-09-09T19:20:08Z
New upstream version
- - - - -
54e05fd1 by Andreas Tille at 2019-09-09T19:20:08Z
Update upstream source from tag 'upstream/1.16'
Update to upstream version '1.16'
with Debian dir a5acbd1e4fd9e1ca723bccbb9a131a028388dceb
- - - - -
11832012 by Andreas Tille at 2019-09-09T19:20:08Z
debhelper-compat 12
- - - - -
179f4f00 by Andreas Tille at 2019-09-09T19:20:10Z
Standards-Version: 4.4.0
- - - - -
9b9ff260 by Andreas Tille at 2019-09-09T19:20:11Z
Use secure URI in Homepage field.
Fixes lintian: homepage-field-uses-insecure-uri
See https://lintian.debian.org/tags/homepage-field-uses-insecure-uri.html for more details.
- - - - -
1ebe779c by Andreas Tille at 2019-09-09T19:20:11Z
Rely on pre-initialized dpkg-architecture variables.
Fixes lintian: debian-rules-sets-dpkg-architecture-variable
See https://lintian.debian.org/tags/debian-rules-sets-dpkg-architecture-variable.html for more details.
- - - - -
7e72aad2 by Andreas Tille at 2019-09-09T19:20:42Z
Upload to unstable
- - - - -
11 changed files:
- README.md
- debian/changelog
- − debian/compat
- debian/control
- debian/rules
- edflib.c
- edflib.h
- sine_generator.c
- sweep_generator.c
- test_edflib.c
- test_generator.c
Changes:
=====================================
README.md
=====================================
@@ -83,26 +83,30 @@ The description/name of an EDF+ annotation on the other hand, is encoded in UTF-
## License
-Copyright (c) 2009, 2010, 2011, 2013, 2014, 2015, 2016, 2017, 2018 Teunis van Beelen
+Copyright (c) 2009 - 2019 Teunis van Beelen
All rights reserved.
-email: teuniz at gmail.com
-
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
-THIS SOFTWARE IS PROVIDED BY Teunis van Beelen ''AS IS'' AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL Teunis van Beelen BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+* Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=====================================
debian/changelog
=====================================
@@ -1,3 +1,13 @@
+edflib (1.16-1) unstable; urgency=medium
+
+ * New upstream version
+ * debhelper-compat 12
+ * Standards-Version: 4.4.0
+ * Use secure URI in Homepage field.
+ * Rely on pre-initialized dpkg-architecture variables.
+
+ -- Andreas Tille <tille at debian.org> Mon, 09 Sep 2019 21:20:11 +0200
+
edflib (1.15-1) unstable; urgency=medium
* New upstream version
=====================================
debian/compat deleted
=====================================
@@ -1 +0,0 @@
-11
=====================================
debian/control
=====================================
@@ -3,12 +3,12 @@ Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.
Uploaders: Andreas Tille <tille at debian.org>
Section: libs
Priority: optional
-Build-Depends: debhelper (>= 11~),
+Build-Depends: debhelper-compat (= 12),
cmake
-Standards-Version: 4.2.1
+Standards-Version: 4.4.0
Vcs-Browser: https://salsa.debian.org/med-team/edflib
Vcs-Git: https://salsa.debian.org/med-team/edflib.git
-Homepage: http://www.teuniz.net/edflib/
+Homepage: https://www.teuniz.net/edflib/
Package: libedf1
Architecture: any
=====================================
debian/rules
=====================================
@@ -1,6 +1,6 @@
#!/usr/bin/make -f
-DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
+include /usr/share/dpkg/architecture.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
=====================================
edflib.c
=====================================
@@ -1,10 +1,10 @@
/*
*****************************************************************************
*
-* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Teunis van Beelen
+* Copyright (c) 2009 - 2019 Teunis van Beelen
* All rights reserved.
*
-* email: teuniz at gmail.com
+* Email: teuniz at protonmail.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -13,11 +13,14 @@
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
+* * Neither the name of the copyright holder nor the names of its
+* contributors may be used to endorse or promote products derived from
+* this software without specific prior written permission.
*
-* THIS SOFTWARE IS PROVIDED BY Teunis van Beelen ''AS IS'' AND ANY
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL Teunis van Beelen BE LIABLE FOR ANY
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -39,7 +42,7 @@
#include "edflib.h"
-#define EDFLIB_VERSION 115
+#define EDFLIB_VERSION 116
#define EDFLIB_MAXFILES 64
@@ -188,14 +191,16 @@ static void edflib_latin12utf8(char *, int);
static void edflib_remove_padding_trailing_spaces(char *);
static int edflib_atoi_nonlocalized(const char *);
static double edflib_atof_nonlocalized(const char *);
-static int edflib_sprint_number_nonlocalized(char *, double);
+static int edflib_snprint_number_nonlocalized(char *, double, int);
/*
static int edflib_sprint_int_number_nonlocalized(char *, int, int, int);
*/
-static int edflib_sprint_ll_number_nonlocalized(char *, long long, int, int);
+static int edflib_snprint_ll_number_nonlocalized(char *, long long, int, int, int);
static int edflib_fprint_int_number_nonlocalized(FILE *, int, int, int);
static int edflib_fprint_ll_number_nonlocalized(FILE *, long long, int, int);
static int edflib_write_tal(struct edfhdrblock *, FILE *);
+static int edflib_strlcpy(char *, const char *, int);
+static int edflib_strlcat(char *, const char *, int);
@@ -377,8 +382,8 @@ int edfopen_file_readonly(const char *path, struct edf_hdr_struct *edfhdr, int r
if((!(hdr->edfplus))&&(!(hdr->bdfplus)))
{
- strcpy(edfhdr->patient, hdr->patient);
- strcpy(edfhdr->recording, hdr->recording);
+ edflib_strlcpy(edfhdr->patient, hdr->patient, 81);
+ edflib_strlcpy(edfhdr->recording, hdr->recording, 81);
edfhdr->patientcode[0] = 0;
edfhdr->gender[0] = 0;
edfhdr->birthdate[0] = 0;
@@ -393,15 +398,15 @@ int edfopen_file_readonly(const char *path, struct edf_hdr_struct *edfhdr, int r
{
edfhdr->patient[0] = 0;
edfhdr->recording[0] = 0;
- strcpy(edfhdr->patientcode, hdr->plus_patientcode);
- strcpy(edfhdr->gender, hdr->plus_gender);
- strcpy(edfhdr->birthdate, hdr->plus_birthdate);
- strcpy(edfhdr->patient_name, hdr->plus_patient_name);
- strcpy(edfhdr->patient_additional, hdr->plus_patient_additional);
- strcpy(edfhdr->admincode, hdr->plus_admincode);
- strcpy(edfhdr->technician, hdr->plus_technician);
- strcpy(edfhdr->equipment, hdr->plus_equipment);
- strcpy(edfhdr->recording_additional, hdr->plus_recording_additional);
+ edflib_strlcpy(edfhdr->patientcode, hdr->plus_patientcode, 81);
+ edflib_strlcpy(edfhdr->gender, hdr->plus_gender, 16);
+ edflib_strlcpy(edfhdr->birthdate, hdr->plus_birthdate, 16);
+ edflib_strlcpy(edfhdr->patient_name, hdr->plus_patient_name, 81);
+ edflib_strlcpy(edfhdr->patient_additional, hdr->plus_patient_additional, 81);
+ edflib_strlcpy(edfhdr->admincode, hdr->plus_admincode, 81);
+ edflib_strlcpy(edfhdr->technician, hdr->plus_technician, 81);
+ edflib_strlcpy(edfhdr->equipment, hdr->plus_equipment, 81);
+ edflib_strlcpy(edfhdr->recording_additional, hdr->plus_recording_additional, 81);
if((read_annotations==EDFLIB_READ_ANNOTATIONS)||(read_annotations==EDFLIB_READ_ALL_ANNOTATIONS))
{
@@ -426,7 +431,7 @@ int edfopen_file_readonly(const char *path, struct edf_hdr_struct *edfhdr, int r
edfhdr->annotations_in_file = hdr->annots_in_file;
}
- strcpy(hdr->path, path);
+ edflib_strlcpy(hdr->path, path, 1024);
edf_files_open++;
@@ -444,10 +449,10 @@ int edfopen_file_readonly(const char *path, struct edf_hdr_struct *edfhdr, int r
{
channel = hdr->mapped_signals[i];
- strcpy(edfhdr->signalparam[i].label, hdr->edfparam[channel].label);
- strcpy(edfhdr->signalparam[i].transducer, hdr->edfparam[channel].transducer);
- strcpy(edfhdr->signalparam[i].physdimension, hdr->edfparam[channel].physdimension);
- strcpy(edfhdr->signalparam[i].prefilter, hdr->edfparam[channel].prefilter);
+ edflib_strlcpy(edfhdr->signalparam[i].label, hdr->edfparam[channel].label, 17);
+ edflib_strlcpy(edfhdr->signalparam[i].transducer, hdr->edfparam[channel].transducer, 81);
+ edflib_strlcpy(edfhdr->signalparam[i].physdimension, hdr->edfparam[channel].physdimension, 9);
+ edflib_strlcpy(edfhdr->signalparam[i].prefilter, hdr->edfparam[channel].prefilter, 81);
edfhdr->signalparam[i].smp_in_file = hdr->edfparam[channel].smp_per_record * hdr->datarecords;
edfhdr->signalparam[i].phys_max = hdr->edfparam[channel].phys_max;
edfhdr->signalparam[i].phys_min = hdr->edfparam[channel].phys_min;
@@ -590,12 +595,12 @@ int edfclose_file(int handle)
break;
}
- p += edflib_sprint_ll_number_nonlocalized(str, (datarecords * hdr->long_data_record_duration) / EDFLIB_TIME_DIMENSION, 0, 1);
+ p += edflib_snprint_ll_number_nonlocalized(str, (datarecords * hdr->long_data_record_duration) / EDFLIB_TIME_DIMENSION, 0, 1, EDFLIB_ANNOTATION_BYTES * 2);
if(hdr->long_data_record_duration % EDFLIB_TIME_DIMENSION)
{
str[p++] = '.';
- n = edflib_sprint_ll_number_nonlocalized(str + p, (datarecords * hdr->long_data_record_duration) % EDFLIB_TIME_DIMENSION, 7, 0);
+ n = edflib_snprint_ll_number_nonlocalized(str + p, (datarecords * hdr->long_data_record_duration) % EDFLIB_TIME_DIMENSION, 7, 0, (EDFLIB_ANNOTATION_BYTES * 2) - p);
p += n;
}
str[p++] = 20;
@@ -603,23 +608,23 @@ int edfclose_file(int handle)
str[p++] = 0;
}
- n = edflib_sprint_ll_number_nonlocalized(str + p, annot2->onset / 10000LL, 0, 1);
+ n = edflib_snprint_ll_number_nonlocalized(str + p, annot2->onset / 10000LL, 0, 1, (EDFLIB_ANNOTATION_BYTES * 2) - p);
p += n;
if(annot2->onset % 10000LL)
{
str[p++] = '.';
- n = edflib_sprint_ll_number_nonlocalized(str + p, annot2->onset % 10000LL, 4, 0);
+ n = edflib_snprint_ll_number_nonlocalized(str + p, annot2->onset % 10000LL, 4, 0, (EDFLIB_ANNOTATION_BYTES * 2) - p);
p += n;
}
if(annot2->duration>=0LL)
{
str[p++] = 21;
- n = edflib_sprint_ll_number_nonlocalized(str + p, annot2->duration / 10000LL, 0, 0);
+ n = edflib_snprint_ll_number_nonlocalized(str + p, annot2->duration / 10000LL, 0, 0, (EDFLIB_ANNOTATION_BYTES * 2) - p);
p += n;
if(annot2->duration % 10000LL)
{
str[p++] = '.';
- n = edflib_sprint_ll_number_nonlocalized(str + p, annot2->duration % 10000LL, 4, 0);
+ n = edflib_snprint_ll_number_nonlocalized(str + p, annot2->duration % 10000LL, 4, 0, (EDFLIB_ANNOTATION_BYTES * 2) - p);
p += n;
}
}
@@ -1242,8 +1247,8 @@ int edf_get_annotation(int handle, int n, struct edf_annotation_struct *annot)
}
annot->onset = (annotationslist[handle] + n)->onset;
- strcpy(annot->duration, (annotationslist[handle] + n)->duration);
- strcpy(annot->annotation, (annotationslist[handle] + n)->annotation);
+ edflib_strlcpy(annot->duration, (annotationslist[handle] + n)->duration, 16);
+ edflib_strlcpy(annot->annotation, (annotationslist[handle] + n)->annotation, EDFLIB_MAX_ANNOTATION_LEN + 1);
return 0;
}
@@ -2338,11 +2343,11 @@ static struct edfhdrblock * edflib_check_edf_file(FILE *inputfile, int *edf_erro
if(edfhdr->patient[p]=='M')
{
- strcpy(edfhdr->plus_gender, "Male");
+ edflib_strlcpy(edfhdr->plus_gender, "Male", 16);
}
if(edfhdr->patient[p]=='F')
{
- strcpy(edfhdr->plus_gender, "Female");
+ edflib_strlcpy(edfhdr->plus_gender, "Female", 16);
}
if(edfhdr->patient[p]=='X')
{
@@ -3141,7 +3146,7 @@ static int edflib_get_annotations(struct edfhdrblock *edfhdr, int hdl, int read_
new_annotation->annotation[0] = 0;
- if(duration) strcpy(new_annotation->duration, duration_in_txt);
+ if(duration) edflib_strlcpy(new_annotation->duration, duration_in_txt, 16);
else new_annotation->duration[0] = 0;
for(j=0; j<n; j++)
@@ -3184,7 +3189,7 @@ static int edflib_get_annotations(struct edfhdrblock *edfhdr, int hdl, int read_
}
onset = 1;
n = 0;
- strcpy(time_in_txt, scratchpad);
+ edflib_strlcpy(time_in_txt, scratchpad, max_tal_ln + 3);
continue;
}
@@ -3727,7 +3732,7 @@ int edfopen_file_writeonly(const char *path, int filetype, int number_of_signals
hdr->file_hdl = file;
- strcpy(hdr->path, path);
+ edflib_strlcpy(hdr->path, path, 1024);
edf_files_open++;
@@ -3919,7 +3924,7 @@ int edf_set_micro_datarecord_duration(int handle, int duration)
return -1;
}
- if((duration < 1) || (duration > 99))
+ if((duration < 1) || (duration > 9999))
{
return -1;
}
@@ -5180,7 +5185,7 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
{
rest -= len;
}
- strcpy(str, hdr->plus_patientcode);
+ edflib_strlcpy(str, hdr->plus_patientcode, 128);
edflib_latin1_to_ascii(str, len);
str[len] = 0;
for(i=0; i<len; i++)
@@ -5265,7 +5270,7 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
{
rest -= len;
}
- strcpy(str, hdr->plus_patient_name);
+ edflib_strlcpy(str, hdr->plus_patient_name, 128);
edflib_latin1_to_ascii(str, len);
str[len] = 0;
for(i=0; i<len; i++)
@@ -5300,7 +5305,7 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
{
len = rest;
}
- strcpy(str, hdr->plus_patient_additional);
+ edflib_strlcpy(str, hdr->plus_patient_additional, 128);
edflib_latin1_to_ascii(str, len);
str[len] = 0;
p += fprintf(file, "%s", str);
@@ -5363,7 +5368,7 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
{
rest -= len;
}
- strcpy(str, hdr->plus_admincode);
+ edflib_strlcpy(str, hdr->plus_admincode, 128);
edflib_latin1_to_ascii(str, len);
str[len] = 0;
for(i=0; i<len; i++)
@@ -5401,7 +5406,7 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
{
rest -= len;
}
- strcpy(str, hdr->plus_technician);
+ edflib_strlcpy(str, hdr->plus_technician, 128);
edflib_latin1_to_ascii(str, len);
str[len] = 0;
for(i=0; i<len; i++)
@@ -5439,7 +5444,7 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
{
rest -= len;
}
- strcpy(str, hdr->plus_equipment);
+ edflib_strlcpy(str, hdr->plus_equipment, 128);
edflib_latin1_to_ascii(str, len);
str[len] = 0;
for(i=0; i<len; i++)
@@ -5472,7 +5477,7 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
{
len = rest;
}
- strcpy(str, hdr->plus_recording_additional);
+ edflib_strlcpy(str, hdr->plus_recording_additional, 128);
edflib_latin1_to_ascii(str, len);
str[len] = 0;
p += fprintf(file, "%s", str);
@@ -5509,8 +5514,8 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
}
else
{
- edflib_sprint_number_nonlocalized(str, hdr->data_record_duration);
- strcat(str, " ");
+ edflib_snprint_number_nonlocalized(str, hdr->data_record_duration, 128);
+ edflib_strlcat(str, " ", 128);
str[8] = 0;
fprintf(file, "%s", str);
}
@@ -5583,7 +5588,7 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
}
for(i=0; i<edfsignals; i++)
{
- p = edflib_sprint_number_nonlocalized(str, hdr->edfparam[i].phys_min);
+ p = edflib_snprint_number_nonlocalized(str, hdr->edfparam[i].phys_min, 128);
for(; p<8; p++)
{
str[p] = ' ';
@@ -5597,7 +5602,7 @@ static int edflib_write_edf_header(struct edfhdrblock *hdr)
}
for(i=0; i<edfsignals; i++)
{
- p = edflib_sprint_number_nonlocalized(str, hdr->edfparam[i].phys_max);
+ p = edflib_snprint_number_nonlocalized(str, hdr->edfparam[i].phys_max, 128);
for(; p<8; p++)
{
str[p] = ' ';
@@ -6870,12 +6875,17 @@ static int edflib_sprint_int_number_nonlocalized(char *str, int q, int minimum,
/* if sign is zero, only negative numbers will have the sign '-' character */
/* if sign is one, the sign '+' or '-' character will always be printed */
/* returns the amount of characters printed */
-static int edflib_sprint_ll_number_nonlocalized(char *str, long long q, int minimum, int sign)
+static int edflib_snprint_ll_number_nonlocalized(char *dest, long long q, int minimum, int sign, int sz)
{
int flag=0, z, i, j=0;
long long base = 1000000000000000000LL;
+ if(sz < 1)
+ {
+ return 0;
+ }
+
if(minimum < 0)
{
minimum = 0;
@@ -6888,7 +6898,7 @@ static int edflib_sprint_ll_number_nonlocalized(char *str, long long q, int mini
if(q < 0LL)
{
- str[j++] = '-';
+ dest[j++] = '-';
q = -q;
}
@@ -6896,10 +6906,17 @@ static int edflib_sprint_ll_number_nonlocalized(char *str, long long q, int mini
{
if(sign)
{
- str[j++] = '+';
+ dest[j++] = '+';
}
}
+ if(j == sz)
+ {
+ dest[--j] = 0;
+
+ return j;
+ }
+
for(i=19; i; i--)
{
if(minimum == i)
@@ -6913,7 +6930,14 @@ static int edflib_sprint_ll_number_nonlocalized(char *str, long long q, int mini
if(z || flag)
{
- str[j++] = '0' + z;
+ dest[j++] = '0' + z;
+
+ if(j == sz)
+ {
+ dest[--j] = 0;
+
+ return j;
+ }
flag = 1;
}
@@ -6923,28 +6947,37 @@ static int edflib_sprint_ll_number_nonlocalized(char *str, long long q, int mini
if(!flag)
{
- str[j++] = '0';
+ dest[j++] = '0';
}
- str[j] = 0;
+ if(j == sz)
+ {
+ dest[--j] = 0;
+
+ return j;
+ }
+
+ dest[j] = 0;
return j;
}
-static int edflib_sprint_number_nonlocalized(char *str, double nr)
+static int edflib_snprint_number_nonlocalized(char *dest, double val, int sz)
{
int flag=0, z, i, j=0, q, base = 1000000000;
double var;
- q = (int)nr;
+ if(sz < 1) return 0;
+
+ q = (int)val;
- var = nr - q;
+ var = val - q;
- if(nr < 0.0)
+ if(val < 0.0)
{
- str[j++] = '-';
+ dest[j++] = '-';
if(q < 0)
{
@@ -6952,6 +6985,13 @@ static int edflib_sprint_number_nonlocalized(char *str, double nr)
}
}
+ if(j == sz)
+ {
+ dest[--j] = 0;
+
+ return j;
+ }
+
for(i=10; i; i--)
{
z = q / base;
@@ -6960,7 +7000,14 @@ static int edflib_sprint_number_nonlocalized(char *str, double nr)
if(z || flag)
{
- str[j++] = '0' + z;
+ dest[j++] = '0' + z;
+
+ if(j == sz)
+ {
+ dest[--j] = 0;
+
+ return j;
+ }
flag = 1;
}
@@ -6970,7 +7017,14 @@ static int edflib_sprint_number_nonlocalized(char *str, double nr)
if(!flag)
{
- str[j++] = '0';
+ dest[j++] = '0';
+ }
+
+ if(j == sz)
+ {
+ dest[--j] = 0;
+
+ return j;
}
base = 100000000;
@@ -6986,12 +7040,19 @@ static int edflib_sprint_number_nonlocalized(char *str, double nr)
if(!q)
{
- str[j] = 0;
+ dest[j] = 0;
return j;
}
- str[j++] = '.';
+ dest[j++] = '.';
+
+ if(j == sz)
+ {
+ dest[--j] = 0;
+
+ return j;
+ }
for(i=9; i; i--)
{
@@ -6999,20 +7060,27 @@ static int edflib_sprint_number_nonlocalized(char *str, double nr)
q %= base;
- str[j++] = '0' + z;
+ dest[j++] = '0' + z;
+
+ if(j == sz)
+ {
+ dest[--j] = 0;
+
+ return j;
+ }
base /= 10;
}
- str[j] = 0;
+ dest[j] = 0;
j--;
for(; j>0; j--)
{
- if(str[j] == '0')
+ if(dest[j] == '0')
{
- str[j] = 0;
+ dest[j] = 0;
}
else
{
@@ -7195,11 +7263,11 @@ static int edflib_write_tal(struct edfhdrblock *hdr, FILE *file)
char str[EDFLIB_ANNOTATION_BYTES * (EDFLIB_MAX_ANNOTATION_CHANNELS + 1)];
- p = edflib_sprint_ll_number_nonlocalized(str, (hdr->datarecords * hdr->long_data_record_duration) / EDFLIB_TIME_DIMENSION, 0, 1);
+ p = edflib_snprint_ll_number_nonlocalized(str, (hdr->datarecords * hdr->long_data_record_duration) / EDFLIB_TIME_DIMENSION, 0, 1, EDFLIB_ANNOTATION_BYTES * (EDFLIB_MAX_ANNOTATION_CHANNELS + 1));
if(hdr->long_data_record_duration % EDFLIB_TIME_DIMENSION)
{
str[p++] = '.';
- p += edflib_sprint_ll_number_nonlocalized(str + p, (hdr->datarecords * hdr->long_data_record_duration) % EDFLIB_TIME_DIMENSION, 7, 0);
+ p += edflib_snprint_ll_number_nonlocalized(str + p, (hdr->datarecords * hdr->long_data_record_duration) % EDFLIB_TIME_DIMENSION, 7, 0, (EDFLIB_ANNOTATION_BYTES * (EDFLIB_MAX_ANNOTATION_CHANNELS + 1)) - p);
}
str[p++] = 20;
str[p++] = 20;
@@ -7217,6 +7285,45 @@ static int edflib_write_tal(struct edfhdrblock *hdr, FILE *file)
}
+static int edflib_strlcpy(char *dst, const char *src, int sz)
+{
+ int srclen;
+
+ sz--;
+
+ srclen = strlen(src);
+
+ if(srclen > sz) srclen = sz;
+
+ memcpy(dst, src, srclen);
+
+ dst[srclen] = 0;
+
+ return srclen;
+}
+
+
+static int edflib_strlcat(char *dst, const char *src, int sz)
+{
+ int srclen,
+ dstlen;
+
+ dstlen = strlen(dst);
+
+ sz -= dstlen + 1;
+
+ if(!sz) return dstlen;
+
+ srclen = strlen(src);
+
+ if(srclen > sz) srclen = sz;
+
+ memcpy(dst + dstlen, src, srclen);
+
+ dst[dstlen + srclen] = 0;
+
+ return (dstlen + srclen);
+}
=====================================
edflib.h
=====================================
@@ -1,10 +1,10 @@
/*
*****************************************************************************
*
-* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Teunis van Beelen
+* Copyright (c) 2009 - 2019 Teunis van Beelen
* All rights reserved.
*
-* email: teuniz at gmail.com
+* Email: teuniz at protonmail.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -13,11 +13,14 @@
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
+* * Neither the name of the copyright holder nor the names of its
+* contributors may be used to endorse or promote products derived from
+* this software without specific prior written permission.
*
-* THIS SOFTWARE IS PROVIDED BY Teunis van Beelen ''AS IS'' AND ANY
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL Teunis van Beelen BE LIABLE FOR ANY
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
@@ -650,7 +653,7 @@ int edf_set_micro_datarecord_duration(int handle, int duration);
/* Sets the datarecord duration to a very small value. */
/* ATTENTION: the argument "duration" is expressed in units of 1 microSecond! */
/* This function is optional, normally you don't need to change the default value. */
-/* The datarecord duration must be in the range 1 to 99 micro-seconds. */
+/* The datarecord duration must be in the range 1 to 9999 micro-seconds. */
/* Returns 0 on success, otherwise -1 */
/* This function is NOT REQUIRED but can be called after opening a */
/* file in writemode and before the first sample write action. */
=====================================
sine_generator.c
=====================================
@@ -1,10 +1,10 @@
/*
*****************************************************************************
*
-* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Teunis van Beelen
+* Copyright (c) 2009 - 2019 Teunis van Beelen
* All rights reserved.
*
-* email: teuniz at gmail.com
+* Email: teuniz at protonmail.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
=====================================
sweep_generator.c
=====================================
@@ -1,10 +1,10 @@
/*
*****************************************************************************
*
-* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Teunis van Beelen
+* Copyright (c) 2009 - 2019 Teunis van Beelen
* All rights reserved.
*
-* email: teuniz at gmail.com
+* Email: teuniz at protonmail.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
=====================================
test_edflib.c
=====================================
@@ -1,10 +1,10 @@
/*
*****************************************************************************
*
-* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Teunis van Beelen
+* Copyright (c) 2009 - 2019 Teunis van Beelen
* All rights reserved.
*
-* email: teuniz at gmail.com
+* Email: teuniz at protonmail.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
=====================================
test_generator.c
=====================================
@@ -1,10 +1,10 @@
/*
*****************************************************************************
*
-* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Teunis van Beelen
+* Copyright (c) 2009 - 2019 Teunis van Beelen
* All rights reserved.
*
-* email: teuniz at gmail.com
+* Email: teuniz at protonmail.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
View it on GitLab: https://salsa.debian.org/med-team/edflib/compare/44ce8e9377a757780010a936153cde5048a95776...7e72aad2f1df34d832a52241d8e412e939a84875
--
View it on GitLab: https://salsa.debian.org/med-team/edflib/compare/44ce8e9377a757780010a936153cde5048a95776...7e72aad2f1df34d832a52241d8e412e939a84875
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20190909/4a0e42b0/attachment-0001.html>
More information about the debian-med-commit
mailing list